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 {
return frame_->GetDocument()->Lifecycle();
}
LayoutReplaced* LocalFrameView::EmbeddedReplacedContent() const {
LayoutSVGRoot* LocalFrameView::EmbeddedReplacedContent() const {
auto* layout_view = this->GetLayoutView();
if (!layout_view)
return nullptr;
......@@ -1441,16 +1441,13 @@ LayoutReplaced* LocalFrameView::EmbeddedReplacedContent() const {
// Currently only embedded SVG documents participate in the size-negotiation
// logic.
if (first_child->IsSVGRoot())
return ToLayoutSVGRoot(first_child);
return nullptr;
return ToLayoutSVGRootOrNull(first_child);
}
bool LocalFrameView::GetIntrinsicSizingInfo(
IntrinsicSizingInfo& intrinsic_sizing_info) const {
if (LayoutReplaced* content_layout_object = EmbeddedReplacedContent()) {
content_layout_object->ComputeIntrinsicSizingInfo(intrinsic_sizing_info);
if (LayoutSVGRoot* content_layout_object = EmbeddedReplacedContent()) {
content_layout_object->UnscaledIntrinsicSizingInfo(intrinsic_sizing_info);
return true;
}
return false;
......
......@@ -85,7 +85,7 @@ class LayoutAnalyzer;
class LayoutBox;
class LayoutEmbeddedObject;
class LayoutObject;
class LayoutReplaced;
class LayoutSVGRoot;
class LayoutScrollbarPart;
class LayoutView;
class PaintArtifactCompositor;
......@@ -984,7 +984,7 @@ class CORE_EXPORT LocalFrameView final
const CullRect&) const;
LocalFrameView* ParentFrameView() const;
LayoutReplaced* EmbeddedReplacedContent() const;
LayoutSVGRoot* EmbeddedReplacedContent() const;
void UpdateScrollOffset(const ScrollOffset&, ScrollType) override;
......
......@@ -65,7 +65,7 @@ LayoutSVGRoot::LayoutSVGRoot(SVGElement* node)
LayoutSVGRoot::~LayoutSVGRoot() = default;
void LayoutSVGRoot::ComputeIntrinsicSizingInfo(
void LayoutSVGRoot::UnscaledIntrinsicSizingInfo(
IntrinsicSizingInfo& intrinsic_sizing_info) const {
// https://www.w3.org/TR/SVG/coords.html#IntrinsicSizing
......@@ -91,6 +91,13 @@ void LayoutSVGRoot::ComputeIntrinsicSizingInfo(
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 {
return SVGImage::IsInSVGImage(ToSVGSVGElement(GetNode()));
}
......
......@@ -39,7 +39,7 @@ class CORE_EXPORT LayoutSVGRoot final : public LayoutReplaced {
bool IsEmbeddedThroughFrameContainingSVGDocument() const;
void IntrinsicSizingInfoChanged() const;
void ComputeIntrinsicSizingInfo(IntrinsicSizingInfo&) const override;
void UnscaledIntrinsicSizingInfo(IntrinsicSizingInfo&) const;
// If you have a LayoutSVGRoot, use firstChild or lastChild instead.
void SlowFirstChild() const = delete;
......@@ -110,6 +110,7 @@ class CORE_EXPORT LayoutSVGRoot final : public LayoutReplaced {
LayoutReplaced::IsOfType(type);
}
void ComputeIntrinsicSizingInfo(IntrinsicSizingInfo&) const override;
LayoutUnit ComputeReplacedLogicalWidth(
ShouldComputePreferred = kComputeActual) const override;
LayoutUnit ComputeReplacedLogicalHeight(
......
......@@ -222,7 +222,7 @@ bool SVGImage::GetIntrinsicSizingInfo(
if (!layout_object)
return false;
layout_object->ComputeIntrinsicSizingInfo(intrinsic_sizing_info);
layout_object->UnscaledIntrinsicSizingInfo(intrinsic_sizing_info);
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