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 { ...@@ -35,6 +35,10 @@ namespace blink {
LayoutSVGBlock::LayoutSVGBlock(SVGElement* element) LayoutSVGBlock::LayoutSVGBlock(SVGElement* element)
: LayoutBlockFlow(element) {} : LayoutBlockFlow(element) {}
SVGElement* LayoutSVGBlock::GetElement() const {
return ToSVGElement(LayoutObject::GetNode());
}
void LayoutSVGBlock::AbsoluteRects(Vector<IntRect>&, const LayoutPoint&) const { void LayoutSVGBlock::AbsoluteRects(Vector<IntRect>&, const LayoutPoint&) const {
// This code path should never be taken for SVG, as we're assuming // This code path should never be taken for SVG, as we're assuming
// useTransforms=true everywhere, absoluteQuads should be used. // useTransforms=true everywhere, absoluteQuads should be used.
......
...@@ -55,6 +55,8 @@ class LayoutSVGBlock : public LayoutBlockFlow { ...@@ -55,6 +55,8 @@ class LayoutSVGBlock : public LayoutBlockFlow {
PaintLayerType LayerTypeRequired() const override { return kNoPaintLayer; } PaintLayerType LayerTypeRequired() const override { return kNoPaintLayer; }
SVGElement* GetElement() const;
protected: protected:
void WillBeDestroyed() override; void WillBeDestroyed() override;
bool MapToVisualRectInAncestorSpaceInternal( bool MapToVisualRectInAncestorSpaceInternal(
...@@ -71,6 +73,9 @@ class LayoutSVGBlock : public LayoutBlockFlow { ...@@ -71,6 +73,9 @@ class LayoutSVGBlock : public LayoutBlockFlow {
void StyleDidChange(StyleDifference, const ComputedStyle* old_style) override; void StyleDidChange(StyleDifference, const ComputedStyle* old_style) override;
private: private:
// LayoutSVGBlock subclasses should use GetElement() instead.
void GetNode() const = delete;
LayoutRect AbsoluteVisualRect() const final; LayoutRect AbsoluteVisualRect() const final;
void AbsoluteRects(Vector<IntRect>&, void AbsoluteRects(Vector<IntRect>&,
......
...@@ -48,26 +48,26 @@ void LayoutSVGForeignObject::Paint(const PaintInfo& paint_info, ...@@ -48,26 +48,26 @@ void LayoutSVGForeignObject::Paint(const PaintInfo& paint_info,
LayoutUnit LayoutSVGForeignObject::ElementX() const { LayoutUnit LayoutSVGForeignObject::ElementX() const {
return LayoutUnit( return LayoutUnit(
roundf(SVGLengthContext(ToSVGElement(GetNode())) roundf(SVGLengthContext(GetElement())
.ValueForLength(StyleRef().SvgStyle().X(), StyleRef(), .ValueForLength(StyleRef().SvgStyle().X(), StyleRef(),
SVGLengthMode::kWidth))); SVGLengthMode::kWidth)));
} }
LayoutUnit LayoutSVGForeignObject::ElementY() const { LayoutUnit LayoutSVGForeignObject::ElementY() const {
return LayoutUnit( return LayoutUnit(
roundf(SVGLengthContext(ToSVGElement(GetNode())) roundf(SVGLengthContext(GetElement())
.ValueForLength(StyleRef().SvgStyle().Y(), StyleRef(), .ValueForLength(StyleRef().SvgStyle().Y(), StyleRef(),
SVGLengthMode::kHeight))); SVGLengthMode::kHeight)));
} }
LayoutUnit LayoutSVGForeignObject::ElementWidth() const { LayoutUnit LayoutSVGForeignObject::ElementWidth() const {
return LayoutUnit(SVGLengthContext(ToSVGElement(GetNode())) return LayoutUnit(SVGLengthContext(GetElement())
.ValueForLength(StyleRef().Width(), StyleRef(), .ValueForLength(StyleRef().Width(), StyleRef(),
SVGLengthMode::kWidth)); SVGLengthMode::kWidth));
} }
LayoutUnit LayoutSVGForeignObject::ElementHeight() const { LayoutUnit LayoutSVGForeignObject::ElementHeight() const {
return LayoutUnit(SVGLengthContext(ToSVGElement(GetNode())) return LayoutUnit(SVGLengthContext(GetElement())
.ValueForLength(StyleRef().Height(), StyleRef(), .ValueForLength(StyleRef().Height(), StyleRef(),
SVGLengthMode::kHeight)); SVGLengthMode::kHeight));
} }
...@@ -89,7 +89,7 @@ void LayoutSVGForeignObject::ComputeLogicalHeight( ...@@ -89,7 +89,7 @@ void LayoutSVGForeignObject::ComputeLogicalHeight(
void LayoutSVGForeignObject::UpdateLayout() { void LayoutSVGForeignObject::UpdateLayout() {
DCHECK(NeedsLayout()); DCHECK(NeedsLayout());
SVGForeignObjectElement* foreign = ToSVGForeignObjectElement(GetNode()); SVGForeignObjectElement* foreign = ToSVGForeignObjectElement(GetElement());
bool update_cached_boundaries_in_parents = false; bool update_cached_boundaries_in_parents = false;
if (needs_transform_update_) { if (needs_transform_update_) {
......
...@@ -92,7 +92,7 @@ class LayoutSVGModelObject : public LayoutObject { ...@@ -92,7 +92,7 @@ class LayoutSVGModelObject : public LayoutObject {
void WillBeDestroyed() override; void WillBeDestroyed() override;
private: private:
// LayoutSVGModelObject subclasses should use element() instead. // LayoutSVGModelObject subclasses should use GetElement() instead.
void GetNode() const = delete; void GetNode() const = delete;
// This method should never be called, SVG uses a different nodeAtPoint method // This method should never be called, SVG uses a different nodeAtPoint method
......
...@@ -202,8 +202,8 @@ void LayoutSVGText::UpdateLayout() { ...@@ -202,8 +202,8 @@ void LayoutSVGText::UpdateLayout() {
// the bounding box below, and after that we clear the // the bounding box below, and after that we clear the
// |needs_transform_update_| flag. // |needs_transform_update_| flag.
if (needs_transform_update_) { if (needs_transform_update_) {
local_transform_ = ToSVGTextElement(GetNode())->CalculateTransform( local_transform_ =
SVGElement::kIncludeMotionTransform); GetElement()->CalculateTransform(SVGElement::kIncludeMotionTransform);
} }
UpdateFontAndMetrics(*this); UpdateFontAndMetrics(*this);
...@@ -267,8 +267,8 @@ void LayoutSVGText::UpdateLayout() { ...@@ -267,8 +267,8 @@ void LayoutSVGText::UpdateLayout() {
// changed too, since the transform could depend on the bounding // changed too, since the transform could depend on the bounding
// box. // box.
if (bounds_changed || needs_transform_update_) { if (bounds_changed || needs_transform_update_) {
local_transform_ = ToSVGTextElement(GetNode())->CalculateTransform( local_transform_ =
SVGElement::kIncludeMotionTransform); GetElement()->CalculateTransform(SVGElement::kIncludeMotionTransform);
needs_transform_update_ = false; needs_transform_update_ = false;
update_parent_boundaries = true; update_parent_boundaries = true;
} }
...@@ -331,7 +331,7 @@ bool LayoutSVGText::NodeAtFloatPoint(HitTestResult& result, ...@@ -331,7 +331,7 @@ bool LayoutSVGText::NodeAtFloatPoint(HitTestResult& result,
const LayoutPoint& local_layout_point = LayoutPoint(local_point); const LayoutPoint& local_layout_point = LayoutPoint(local_point);
UpdateHitTestResult(result, local_layout_point); UpdateHitTestResult(result, local_layout_point);
if (result.AddNodeToListBasedTestResult( if (result.AddNodeToListBasedTestResult(
GetNode(), local_layout_point) == kStopHitTesting) GetElement(), local_layout_point) == kStopHitTesting)
return true; return true;
} }
} }
...@@ -386,9 +386,8 @@ FloatRect LayoutSVGText::StrokeBoundingBox() const { ...@@ -386,9 +386,8 @@ FloatRect LayoutSVGText::StrokeBoundingBox() const {
if (!svg_style.HasStroke()) if (!svg_style.HasStroke())
return stroke_boundaries; return stroke_boundaries;
DCHECK(GetNode()); DCHECK(GetElement());
DCHECK(GetNode()->IsSVGElement()); SVGLengthContext length_context(GetElement());
SVGLengthContext length_context(ToSVGElement(GetNode()));
stroke_boundaries.Inflate( stroke_boundaries.Inflate(
length_context.ValueForLength(svg_style.StrokeWidth())); length_context.ValueForLength(svg_style.StrokeWidth()));
return stroke_boundaries; 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