Commit a9180739 authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

[CI] Add LayoutSVGBlock::GetElement helper

Like the equivalent helper on LayoutSVGModelObject, this provides a more
specific type of Node (an SVGElement), since is guaranteed for
subclasses of LayoutSVGBlock.
Also update the documentation in LayoutSVGModelObject to reflect the
current name.

Bug: 769774
Change-Id: I720af53e5a24e960773059f7d2a113e74bd5bdc5
Reviewed-on: https://chromium-review.googlesource.com/973378
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545034}
parent 855330b0
......@@ -35,6 +35,10 @@ namespace blink {
LayoutSVGBlock::LayoutSVGBlock(SVGElement* element)
: LayoutBlockFlow(element) {}
SVGElement* LayoutSVGBlock::GetElement() const {
return ToSVGElement(LayoutObject::GetNode());
}
void LayoutSVGBlock::AbsoluteRects(Vector<IntRect>&, const LayoutPoint&) const {
// This code path should never be taken for SVG, as we're assuming
// useTransforms=true everywhere, absoluteQuads should be used.
......
......@@ -55,6 +55,8 @@ class LayoutSVGBlock : public LayoutBlockFlow {
PaintLayerType LayerTypeRequired() const override { return kNoPaintLayer; }
SVGElement* GetElement() const;
protected:
void WillBeDestroyed() override;
bool MapToVisualRectInAncestorSpaceInternal(
......@@ -71,6 +73,9 @@ class LayoutSVGBlock : public LayoutBlockFlow {
void StyleDidChange(StyleDifference, const ComputedStyle* old_style) override;
private:
// LayoutSVGBlock subclasses should use GetElement() instead.
void GetNode() const = delete;
LayoutRect AbsoluteVisualRect() const final;
void AbsoluteRects(Vector<IntRect>&,
......
......@@ -48,26 +48,26 @@ void LayoutSVGForeignObject::Paint(const PaintInfo& paint_info,
LayoutUnit LayoutSVGForeignObject::ElementX() const {
return LayoutUnit(
roundf(SVGLengthContext(ToSVGElement(GetNode()))
roundf(SVGLengthContext(GetElement())
.ValueForLength(StyleRef().SvgStyle().X(), StyleRef(),
SVGLengthMode::kWidth)));
}
LayoutUnit LayoutSVGForeignObject::ElementY() const {
return LayoutUnit(
roundf(SVGLengthContext(ToSVGElement(GetNode()))
roundf(SVGLengthContext(GetElement())
.ValueForLength(StyleRef().SvgStyle().Y(), StyleRef(),
SVGLengthMode::kHeight)));
}
LayoutUnit LayoutSVGForeignObject::ElementWidth() const {
return LayoutUnit(SVGLengthContext(ToSVGElement(GetNode()))
return LayoutUnit(SVGLengthContext(GetElement())
.ValueForLength(StyleRef().Width(), StyleRef(),
SVGLengthMode::kWidth));
}
LayoutUnit LayoutSVGForeignObject::ElementHeight() const {
return LayoutUnit(SVGLengthContext(ToSVGElement(GetNode()))
return LayoutUnit(SVGLengthContext(GetElement())
.ValueForLength(StyleRef().Height(), StyleRef(),
SVGLengthMode::kHeight));
}
......@@ -89,7 +89,7 @@ void LayoutSVGForeignObject::ComputeLogicalHeight(
void LayoutSVGForeignObject::UpdateLayout() {
DCHECK(NeedsLayout());
SVGForeignObjectElement* foreign = ToSVGForeignObjectElement(GetNode());
SVGForeignObjectElement* foreign = ToSVGForeignObjectElement(GetElement());
bool update_cached_boundaries_in_parents = false;
if (needs_transform_update_) {
......
......@@ -92,7 +92,7 @@ class LayoutSVGModelObject : public LayoutObject {
void WillBeDestroyed() override;
private:
// LayoutSVGModelObject subclasses should use element() instead.
// LayoutSVGModelObject subclasses should use GetElement() instead.
void GetNode() const = delete;
// This method should never be called, SVG uses a different nodeAtPoint method
......
......@@ -202,8 +202,8 @@ void LayoutSVGText::UpdateLayout() {
// the bounding box below, and after that we clear the
// |needs_transform_update_| flag.
if (needs_transform_update_) {
local_transform_ = ToSVGTextElement(GetNode())->CalculateTransform(
SVGElement::kIncludeMotionTransform);
local_transform_ =
GetElement()->CalculateTransform(SVGElement::kIncludeMotionTransform);
}
UpdateFontAndMetrics(*this);
......@@ -267,8 +267,8 @@ void LayoutSVGText::UpdateLayout() {
// changed too, since the transform could depend on the bounding
// box.
if (bounds_changed || needs_transform_update_) {
local_transform_ = ToSVGTextElement(GetNode())->CalculateTransform(
SVGElement::kIncludeMotionTransform);
local_transform_ =
GetElement()->CalculateTransform(SVGElement::kIncludeMotionTransform);
needs_transform_update_ = false;
update_parent_boundaries = true;
}
......@@ -331,7 +331,7 @@ bool LayoutSVGText::NodeAtFloatPoint(HitTestResult& result,
const LayoutPoint& local_layout_point = LayoutPoint(local_point);
UpdateHitTestResult(result, local_layout_point);
if (result.AddNodeToListBasedTestResult(
GetNode(), local_layout_point) == kStopHitTesting)
GetElement(), local_layout_point) == kStopHitTesting)
return true;
}
}
......@@ -386,9 +386,8 @@ FloatRect LayoutSVGText::StrokeBoundingBox() const {
if (!svg_style.HasStroke())
return stroke_boundaries;
DCHECK(GetNode());
DCHECK(GetNode()->IsSVGElement());
SVGLengthContext length_context(ToSVGElement(GetNode()));
DCHECK(GetElement());
SVGLengthContext length_context(GetElement());
stroke_boundaries.Inflate(
length_context.ValueForLength(svg_style.StrokeWidth()));
return stroke_boundaries;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment