Commit 5a2e6afd authored by Fredrik Söderqvist's avatar Fredrik Söderqvist Committed by Commit Bot

Move HasValidViewBox() and HasEmptyViewBox() to SVGSVGElement

These need to take any potential view spec into account, so it makes
more sense to let them live in SVGSVGElement. Other users are trivial
and can be open-coded.

Bug: 427650
Change-Id: Ib0c9d3378cb08613356207ac3f062d66747ee14e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2510129Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#822670}
parent eceb8ae1
......@@ -64,15 +64,6 @@ SVGFitToViewBox::SVGFitToViewBox(SVGElement* element)
element->AddToPropertyMap(preserve_aspect_ratio_);
}
bool SVGFitToViewBox::HasValidViewBox() const {
return view_box_->CurrentValue()->IsValid();
}
bool SVGFitToViewBox::HasEmptyViewBox() const {
return view_box_->CurrentValue()->IsValid() &&
view_box_->CurrentValue()->Value().IsEmpty();
}
void SVGFitToViewBox::Trace(Visitor* visitor) const {
visitor->Trace(view_box_);
visitor->Trace(preserve_aspect_ratio_);
......
......@@ -43,9 +43,6 @@ class SVGFitToViewBox : public GarbageCollectedMixin {
static bool IsKnownAttribute(const QualifiedName&);
bool HasValidViewBox() const;
bool HasEmptyViewBox() const;
// JS API
SVGAnimatedRect* viewBox() const { return view_box_.Get(); }
SVGAnimatedPreserveAspectRatio* preserveAspectRatio() const {
......
......@@ -232,7 +232,7 @@ static void SetPatternAttributes(const SVGPatternElement& element,
if (!attributes.HasHeight() && element.height()->IsSpecified())
attributes.SetHeight(element.height()->CurrentValue());
if (!attributes.HasViewBox() && element.HasValidViewBox())
if (!attributes.HasViewBox() && element.viewBox()->CurrentValue()->IsValid())
attributes.SetViewBox(element.viewBox()->CurrentValue()->Value());
if (!attributes.HasPreserveAspectRatio() &&
......
......@@ -576,6 +576,15 @@ bool SVGSVGElement::SelfHasRelativeLengths() const {
height_->CurrentValue()->IsRelative();
}
bool SVGSVGElement::HasValidViewBox() const {
return viewBox()->CurrentValue()->IsValid();
}
bool SVGSVGElement::HasEmptyViewBox() const {
const SVGRect* view_box = viewBox()->CurrentValue();
return view_box->IsValid() && view_box->Value().IsEmpty();
}
bool SVGSVGElement::ShouldSynthesizeViewBox() const {
return GetLayoutObject() && GetLayoutObject()->IsSVGRoot() &&
ToLayoutSVGRoot(GetLayoutObject())->IsEmbeddedThroughSVGImage();
......
......@@ -52,6 +52,7 @@ class SVGSVGElement final : public SVGGraphicsElement,
base::Optional<float> IntrinsicHeight() const;
FloatSize CurrentViewportSize() const;
FloatRect CurrentViewBoxRect() const;
bool HasEmptyViewBox() const;
const SVGPreserveAspectRatio* CurrentPreserveAspectRatio() const;
float currentScale() const;
......@@ -131,6 +132,7 @@ class SVGSVGElement final : public SVGGraphicsElement,
bool SelfHasRelativeLengths() const override;
bool HasValidViewBox() const;
bool ShouldSynthesizeViewBox() const;
void UpdateUserTransform();
......
......@@ -49,7 +49,7 @@ SVGViewSpec* SVGViewSpec::CreateFromFragment(const String& fragment) {
SVGViewSpec* SVGViewSpec::CreateForViewElement(const SVGViewElement& view) {
SVGViewSpec* view_spec = MakeGarbageCollected<SVGViewSpec>();
if (view.HasValidViewBox())
if (view.viewBox()->CurrentValue()->IsValid())
view_spec->view_box_ = view.viewBox()->CurrentValue()->Clone();
if (view.preserveAspectRatio()->IsSpecified()) {
view_spec->preserve_aspect_ratio_ =
......
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