Commit 9b15a04b authored by fs's avatar fs Committed by Commit bot

Simplify the SVGGraphicsElement ...CTM methods

GetCTM() only has a single caller, so can be trivially folded. Similarly
GetScreenCTM which has one kAllowStyleUpdate and one
kDisallowStyleUpdate, so it can be folded while hoisting the call to
update style and layout.
This means that there are no longer a collision between internal methods
and the ones exposed in the DOM, so the "...FromJavascript" suffixes can
be dropped.

Review-Url: https://codereview.chromium.org/2858913002
Cr-Commit-Position: refs/heads/master@{#469055}
parent 763e9101
...@@ -228,8 +228,7 @@ Path* LayoutSVGShape::NonScalingStrokePath( ...@@ -228,8 +228,7 @@ Path* LayoutSVGShape::NonScalingStrokePath(
AffineTransform LayoutSVGShape::NonScalingStrokeTransform() const { AffineTransform LayoutSVGShape::NonScalingStrokeTransform() const {
AffineTransform t = AffineTransform t =
ToSVGGraphicsElement(GetElement()) ToSVGGraphicsElement(GetElement())->ComputeCTM(SVGElement::kScreenScope);
->GetScreenCTM(SVGGraphicsElement::kDisallowStyleUpdate);
// Width of non-scaling stroke is independent of translation, so zero it out // Width of non-scaling stroke is independent of translation, so zero it out
// here. // here.
t.SetE(0); t.SetE(0);
......
...@@ -57,11 +57,7 @@ static bool IsViewportElement(const Element& element) { ...@@ -57,11 +57,7 @@ static bool IsViewportElement(const Element& element) {
AffineTransform SVGGraphicsElement::ComputeCTM( AffineTransform SVGGraphicsElement::ComputeCTM(
SVGElement::CTMScope mode, SVGElement::CTMScope mode,
SVGGraphicsElement::StyleUpdateStrategy style_update_strategy,
const SVGGraphicsElement* ancestor) const { const SVGGraphicsElement* ancestor) const {
if (style_update_strategy == kAllowStyleUpdate)
GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets();
AffineTransform ctm; AffineTransform ctm;
bool done = false; bool done = false;
...@@ -88,26 +84,19 @@ AffineTransform SVGGraphicsElement::ComputeCTM( ...@@ -88,26 +84,19 @@ AffineTransform SVGGraphicsElement::ComputeCTM(
break; break;
} }
} }
return ctm; return ctm;
} }
AffineTransform SVGGraphicsElement::GetCTM( SVGMatrixTearOff* SVGGraphicsElement::getCTM() {
StyleUpdateStrategy style_update_strategy) { GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheetsForNode(this);
return ComputeCTM(kNearestViewportScope, style_update_strategy);
}
AffineTransform SVGGraphicsElement::GetScreenCTM( return SVGMatrixTearOff::Create(ComputeCTM(kNearestViewportScope));
StyleUpdateStrategy style_update_strategy) {
return ComputeCTM(kScreenScope, style_update_strategy);
} }
SVGMatrixTearOff* SVGGraphicsElement::getCTMFromJavascript() { SVGMatrixTearOff* SVGGraphicsElement::getScreenCTM() {
return SVGMatrixTearOff::Create(GetCTM()); GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheetsForNode(this);
}
SVGMatrixTearOff* SVGGraphicsElement::getScreenCTMFromJavascript() { return SVGMatrixTearOff::Create(ComputeCTM(kScreenScope));
return SVGMatrixTearOff::Create(GetScreenCTM());
} }
void SVGGraphicsElement::CollectStyleForPresentationAttribute( void SVGGraphicsElement::CollectStyleForPresentationAttribute(
......
...@@ -41,12 +41,8 @@ class CORE_EXPORT SVGGraphicsElement : public SVGElement, public SVGTests { ...@@ -41,12 +41,8 @@ class CORE_EXPORT SVGGraphicsElement : public SVGElement, public SVGTests {
public: public:
~SVGGraphicsElement() override; ~SVGGraphicsElement() override;
enum StyleUpdateStrategy { kAllowStyleUpdate, kDisallowStyleUpdate }; SVGMatrixTearOff* getCTM();
SVGMatrixTearOff* getScreenCTM();
AffineTransform GetCTM(StyleUpdateStrategy = kAllowStyleUpdate);
AffineTransform GetScreenCTM(StyleUpdateStrategy = kAllowStyleUpdate);
SVGMatrixTearOff* getCTMFromJavascript();
SVGMatrixTearOff* getScreenCTMFromJavascript();
SVGElement* nearestViewportElement() const; SVGElement* nearestViewportElement() const;
SVGElement* farthestViewportElement() const; SVGElement* farthestViewportElement() const;
...@@ -64,8 +60,7 @@ class CORE_EXPORT SVGGraphicsElement : public SVGElement, public SVGTests { ...@@ -64,8 +60,7 @@ class CORE_EXPORT SVGGraphicsElement : public SVGElement, public SVGTests {
SVGAnimatedTransformList* transform() { return transform_.Get(); } SVGAnimatedTransformList* transform() { return transform_.Get(); }
const SVGAnimatedTransformList* transform() const { return transform_.Get(); } const SVGAnimatedTransformList* transform() const { return transform_.Get(); }
AffineTransform ComputeCTM(SVGElement::CTMScope mode, AffineTransform ComputeCTM(CTMScope mode,
SVGGraphicsElement::StyleUpdateStrategy,
const SVGGraphicsElement* ancestor = 0) const; const SVGGraphicsElement* ancestor = 0) const;
DECLARE_VIRTUAL_TRACE(); DECLARE_VIRTUAL_TRACE();
......
...@@ -34,8 +34,8 @@ interface SVGGraphicsElement : SVGElement { ...@@ -34,8 +34,8 @@ interface SVGGraphicsElement : SVGElement {
[Measure] readonly attribute SVGAnimatedTransformList transform; [Measure] readonly attribute SVGAnimatedTransformList transform;
[ImplementedAs=getBBoxFromJavascript] SVGRect getBBox(); [ImplementedAs=getBBoxFromJavascript] SVGRect getBBox();
[ImplementedAs=getCTMFromJavascript] SVGMatrix getCTM(); SVGMatrix getCTM();
[ImplementedAs=getScreenCTMFromJavascript] SVGMatrix getScreenCTM(); SVGMatrix getScreenCTM();
// TODO(foolip): The following two properties existed on SVGLocatable in SVG // TODO(foolip): The following two properties existed on SVGLocatable in SVG
// 1.1, but were removed in SVG2. https://crbug.com/695981 // 1.1, but were removed in SVG2. https://crbug.com/695981
......
...@@ -332,8 +332,8 @@ bool SVGSVGElement::CheckIntersectionOrEnclosure( ...@@ -332,8 +332,8 @@ bool SVGSVGElement::CheckIntersectionOrEnclosure(
if (!IsIntersectionOrEnclosureTarget(layout_object)) if (!IsIntersectionOrEnclosureTarget(layout_object))
return false; return false;
AffineTransform ctm = ToSVGGraphicsElement(element).ComputeCTM( AffineTransform ctm =
kAncestorScope, kDisallowStyleUpdate, this); ToSVGGraphicsElement(element).ComputeCTM(kAncestorScope, this);
FloatRect mapped_repaint_rect = FloatRect mapped_repaint_rect =
ctm.MapRect(layout_object->VisualRectInLocalSVGCoordinates()); ctm.MapRect(layout_object->VisualRectInLocalSVGCoordinates());
......
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