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

Apply zoom in LayoutSVGRoot::ComputeIntrinsicSizingInfo

Previously we didn't know in what context said method was called, so we
didn't know if zoom ought to be applied or not.
Add LayoutSVGRoot::UnscaledIntrinsicSizingInfo and change current
callers of ComputeIntrinsicSizingInfo to use it. Then make
ComputeIntrinsicSizingInfo scale the intrinsic size.

Bug: 722055
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: If668e85bcea1028e48a3bc98c74d07435d425338
Reviewed-on: https://chromium-review.googlesource.com/1067397
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560331}
parent 56982b16
<!DOCTYPE html>
<div style="width: 100px; height: 100px; background-color: green"></div>
<!DOCTYPE html>
<div style="zoom: 2; background-color: red; width: 50px">
<svg width="50" height="50" style="width: auto; height: auto; display: block">
<rect width="50" height="50" fill="green"/>
</svg>
</div>
...@@ -1430,7 +1430,7 @@ DocumentLifecycle& LocalFrameView::Lifecycle() const { ...@@ -1430,7 +1430,7 @@ DocumentLifecycle& LocalFrameView::Lifecycle() const {
return frame_->GetDocument()->Lifecycle(); return frame_->GetDocument()->Lifecycle();
} }
LayoutReplaced* LocalFrameView::EmbeddedReplacedContent() const { LayoutSVGRoot* LocalFrameView::EmbeddedReplacedContent() const {
auto* layout_view = this->GetLayoutView(); auto* layout_view = this->GetLayoutView();
if (!layout_view) if (!layout_view)
return nullptr; return nullptr;
...@@ -1441,16 +1441,13 @@ LayoutReplaced* LocalFrameView::EmbeddedReplacedContent() const { ...@@ -1441,16 +1441,13 @@ LayoutReplaced* LocalFrameView::EmbeddedReplacedContent() const {
// Currently only embedded SVG documents participate in the size-negotiation // Currently only embedded SVG documents participate in the size-negotiation
// logic. // logic.
if (first_child->IsSVGRoot()) return ToLayoutSVGRootOrNull(first_child);
return ToLayoutSVGRoot(first_child);
return nullptr;
} }
bool LocalFrameView::GetIntrinsicSizingInfo( bool LocalFrameView::GetIntrinsicSizingInfo(
IntrinsicSizingInfo& intrinsic_sizing_info) const { IntrinsicSizingInfo& intrinsic_sizing_info) const {
if (LayoutReplaced* content_layout_object = EmbeddedReplacedContent()) { if (LayoutSVGRoot* content_layout_object = EmbeddedReplacedContent()) {
content_layout_object->ComputeIntrinsicSizingInfo(intrinsic_sizing_info); content_layout_object->UnscaledIntrinsicSizingInfo(intrinsic_sizing_info);
return true; return true;
} }
return false; return false;
......
...@@ -85,7 +85,7 @@ class LayoutAnalyzer; ...@@ -85,7 +85,7 @@ class LayoutAnalyzer;
class LayoutBox; class LayoutBox;
class LayoutEmbeddedObject; class LayoutEmbeddedObject;
class LayoutObject; class LayoutObject;
class LayoutReplaced; class LayoutSVGRoot;
class LayoutScrollbarPart; class LayoutScrollbarPart;
class LayoutView; class LayoutView;
class PaintArtifactCompositor; class PaintArtifactCompositor;
...@@ -984,7 +984,7 @@ class CORE_EXPORT LocalFrameView final ...@@ -984,7 +984,7 @@ class CORE_EXPORT LocalFrameView final
const CullRect&) const; const CullRect&) const;
LocalFrameView* ParentFrameView() const; LocalFrameView* ParentFrameView() const;
LayoutReplaced* EmbeddedReplacedContent() const; LayoutSVGRoot* EmbeddedReplacedContent() const;
void UpdateScrollOffset(const ScrollOffset&, ScrollType) override; void UpdateScrollOffset(const ScrollOffset&, ScrollType) override;
......
...@@ -65,7 +65,7 @@ LayoutSVGRoot::LayoutSVGRoot(SVGElement* node) ...@@ -65,7 +65,7 @@ LayoutSVGRoot::LayoutSVGRoot(SVGElement* node)
LayoutSVGRoot::~LayoutSVGRoot() = default; LayoutSVGRoot::~LayoutSVGRoot() = default;
void LayoutSVGRoot::ComputeIntrinsicSizingInfo( void LayoutSVGRoot::UnscaledIntrinsicSizingInfo(
IntrinsicSizingInfo& intrinsic_sizing_info) const { IntrinsicSizingInfo& intrinsic_sizing_info) const {
// https://www.w3.org/TR/SVG/coords.html#IntrinsicSizing // https://www.w3.org/TR/SVG/coords.html#IntrinsicSizing
...@@ -91,6 +91,13 @@ void LayoutSVGRoot::ComputeIntrinsicSizingInfo( ...@@ -91,6 +91,13 @@ void LayoutSVGRoot::ComputeIntrinsicSizingInfo(
intrinsic_sizing_info.Transpose(); intrinsic_sizing_info.Transpose();
} }
void LayoutSVGRoot::ComputeIntrinsicSizingInfo(
IntrinsicSizingInfo& intrinsic_sizing_info) const {
UnscaledIntrinsicSizingInfo(intrinsic_sizing_info);
intrinsic_sizing_info.size.Scale(StyleRef().EffectiveZoom());
}
bool LayoutSVGRoot::IsEmbeddedThroughSVGImage() const { bool LayoutSVGRoot::IsEmbeddedThroughSVGImage() const {
return SVGImage::IsInSVGImage(ToSVGSVGElement(GetNode())); return SVGImage::IsInSVGImage(ToSVGSVGElement(GetNode()));
} }
......
...@@ -39,7 +39,7 @@ class CORE_EXPORT LayoutSVGRoot final : public LayoutReplaced { ...@@ -39,7 +39,7 @@ class CORE_EXPORT LayoutSVGRoot final : public LayoutReplaced {
bool IsEmbeddedThroughFrameContainingSVGDocument() const; bool IsEmbeddedThroughFrameContainingSVGDocument() const;
void IntrinsicSizingInfoChanged() const; void IntrinsicSizingInfoChanged() const;
void ComputeIntrinsicSizingInfo(IntrinsicSizingInfo&) const override; void UnscaledIntrinsicSizingInfo(IntrinsicSizingInfo&) const;
// If you have a LayoutSVGRoot, use firstChild or lastChild instead. // If you have a LayoutSVGRoot, use firstChild or lastChild instead.
void SlowFirstChild() const = delete; void SlowFirstChild() const = delete;
...@@ -110,6 +110,7 @@ class CORE_EXPORT LayoutSVGRoot final : public LayoutReplaced { ...@@ -110,6 +110,7 @@ class CORE_EXPORT LayoutSVGRoot final : public LayoutReplaced {
LayoutReplaced::IsOfType(type); LayoutReplaced::IsOfType(type);
} }
void ComputeIntrinsicSizingInfo(IntrinsicSizingInfo&) const override;
LayoutUnit ComputeReplacedLogicalWidth( LayoutUnit ComputeReplacedLogicalWidth(
ShouldComputePreferred = kComputeActual) const override; ShouldComputePreferred = kComputeActual) const override;
LayoutUnit ComputeReplacedLogicalHeight( LayoutUnit ComputeReplacedLogicalHeight(
......
...@@ -222,7 +222,7 @@ bool SVGImage::GetIntrinsicSizingInfo( ...@@ -222,7 +222,7 @@ bool SVGImage::GetIntrinsicSizingInfo(
if (!layout_object) if (!layout_object)
return false; return false;
layout_object->ComputeIntrinsicSizingInfo(intrinsic_sizing_info); layout_object->UnscaledIntrinsicSizingInfo(intrinsic_sizing_info);
return true; return true;
} }
......
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