diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-02-13 16:23:34 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-02-14 10:37:21 +0000 |
commit | 38a9a29f4f9436cace7f0e7abf9c586057df8a4e (patch) | |
tree | c4e8c458dc595bc0ddb435708fa2229edfd00bd4 /chromium/third_party/blink/renderer/core/layout/svg | |
parent | e684a3455bcc29a6e3e66a004e352dea4e1141e7 (diff) | |
download | qtwebengine-chromium-38a9a29f4f9436cace7f0e7abf9c586057df8a4e.tar.gz |
BASELINE: Update Chromium to 73.0.3683.37
Change-Id: I08c9af2948b645f671e5d933aca1f7a90ea372f2
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/third_party/blink/renderer/core/layout/svg')
7 files changed, 39 insertions, 92 deletions
diff --git a/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_image.cc b/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_image.cc index 8494c388ccb..b05921f101e 100644 --- a/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_image.cc +++ b/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_image.cc @@ -157,8 +157,8 @@ void LayoutSVGImage::UpdateLayout() { DCHECK(!needs_transform_update_); if (auto* svg_image_element = ToSVGImageElementOrNull(GetElement())) { - if (svg_image_element->IsDefaultIntrinsicSize()) - media_element_parser_helpers::ReportUnsizedMediaViolation(this); + media_element_parser_helpers::ReportUnsizedMediaViolation( + this, svg_image_element->IsDefaultIntrinsicSize()); } ClearNeedsLayout(); } diff --git a/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_root.cc b/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_root.cc index 62a15b2e2a0..7e4d148ae32 100644 --- a/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_root.cc +++ b/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_root.cc @@ -95,6 +95,7 @@ void LayoutSVGRoot::UnscaledIntrinsicSizingInfo( void LayoutSVGRoot::ComputeIntrinsicSizingInfo( IntrinsicSizingInfo& intrinsic_sizing_info) const { + DCHECK(!ShouldApplySizeContainment()); UnscaledIntrinsicSizingInfo(intrinsic_sizing_info); intrinsic_sizing_info.size.Scale(StyleRef().EffectiveZoom()); @@ -209,15 +210,8 @@ void LayoutSVGRoot::UpdateLayout() { } const auto& old_overflow_rect = VisualOverflowRect(); - overflow_.reset(); - AddVisualEffectOverflow(); - - if (!ShouldApplyViewportClip()) { - FloatRect content_visual_rect = VisualRectInLocalSVGCoordinates(); - content_visual_rect = - local_to_border_box_transform_.MapRect(content_visual_rect); - AddContentsVisualOverflow(EnclosingLayoutRect(content_visual_rect)); - } + ClearSelfNeedsLayoutOverflowRecalc(); + ClearLayoutOverflow(); // The scale of one or more of the SVG elements may have changed, content // (the entire SVG) could have moved or new content may have been exposed, so @@ -248,11 +242,24 @@ bool LayoutSVGRoot::ShouldApplyViewportClip() const { StyleRef().OverflowX() == EOverflow::kScroll || IsDocumentElement(); } -LayoutRect LayoutSVGRoot::VisualOverflowRect() const { - LayoutRect rect = LayoutReplaced::SelfVisualOverflowRect(); +void LayoutSVGRoot::RecalcVisualOverflow() { + LayoutReplaced::RecalcVisualOverflow(); + UpdateCachedBoundaries(); if (!ShouldApplyViewportClip()) - rect.Unite(ContentsVisualOverflowRect()); - return rect; + AddContentsVisualOverflow(ComputeContentsVisualOverflow()); +} + +LayoutRect LayoutSVGRoot::ComputeContentsVisualOverflow() const { + FloatRect content_visual_rect = VisualRectInLocalSVGCoordinates(); + content_visual_rect = + local_to_border_box_transform_.MapRect(content_visual_rect); + // Condition the visual overflow rect to avoid being clipped/culled + // out if it is huge. This may sacrifice overflow, but usually only + // overflow that would never be seen anyway. + // To condition, we intersect with something that we oftentimes + // consider to be "infinity". + return Intersection(EnclosingLayoutRect(content_visual_rect), + LayoutRect(LayoutRect::InfiniteIntRect())); } void LayoutSVGRoot::PaintReplaced(const PaintInfo& paint_info, @@ -433,42 +440,6 @@ AffineTransform LayoutSVGRoot::LocalToSVGParentTransform() const { local_to_border_box_transform_; } -LayoutRect LayoutSVGRoot::LocalVisualRectIgnoringVisibility() const { - // This is an open-coded aggregate of SVGLayoutSupport::localVisualRect - // and LayoutReplaced::localVisualRect. The reason for this is to optimize/ - // minimize the visual rect when the box is not "decorated" (does not have - // background/border/etc., see - // LayoutSVGRootTest.VisualRectMappingWithViewportClipWithoutBorder). - - // Return early for any cases where we don't actually paint. - if (!EnclosingLayer()->HasVisibleContent()) - return LayoutRect(); - - // Compute the visual rect of the content of the SVG in the border-box - // coordinate space. - FloatRect content_visual_rect = VisualRectInLocalSVGCoordinates(); - content_visual_rect = - local_to_border_box_transform_.MapRect(content_visual_rect); - - // Apply initial viewport clip, overflow:visible content is added to - // visualOverflow but the most common case is that overflow is hidden, so - // always intersect. - content_visual_rect.Intersect(PixelSnappedBorderBoxRect()); - - LayoutRect visual_rect = EnclosingLayoutRect(content_visual_rect); - // If the box is decorated or is overflowing, extend it to include the - // border-box and overflow. - if (has_box_decoration_background_ || HasOverflowModel()) { - // The selectionRect can project outside of the overflowRect, so take their - // union for paint invalidation to avoid selection painting glitches. - LayoutRect decorated_visual_rect = - UnionRect(LocalSelectionRect(), VisualOverflowRect()); - visual_rect.Unite(decorated_visual_rect); - } - - return LayoutRect(EnclosingIntRect(visual_rect)); -} - // This method expects local CSS box coordinates. // Callers with local SVG viewport coordinates should first apply the // localToBorderBoxTransform to convert from SVG viewport coordinates to local diff --git a/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_root.h b/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_root.h index 91c97212585..8c057a10471 100644 --- a/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_root.h +++ b/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_root.h @@ -85,7 +85,7 @@ class CORE_EXPORT LayoutSVGRoot final : public LayoutReplaced { bool ShouldApplyViewportClip() const; - LayoutRect VisualOverflowRect() const override; + void RecalcVisualOverflow() override; bool HasNonIsolatedBlendingDescendants() const final; @@ -95,6 +95,7 @@ class CORE_EXPORT LayoutSVGRoot final : public LayoutReplaced { bool ComputeShouldClipOverflow() const override { return LayoutBox::ComputeShouldClipOverflow() || ShouldApplyViewportClip(); } + LayoutRect ComputeContentsVisualOverflow() const; const LayoutObjectChildList* Children() const { return &children_; } LayoutObjectChildList* Children() { return &children_; } @@ -141,8 +142,6 @@ class CORE_EXPORT LayoutSVGRoot final : public LayoutReplaced { const LayoutPoint& accumulated_offset, HitTestAction) override; - LayoutRect LocalVisualRectIgnoringVisibility() const override; - void MapLocalToAncestor( const LayoutBoxModelObject* ancestor, TransformState&, diff --git a/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_root_test.cc b/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_root_test.cc index 1558bb16ad4..0640e4aa5ec 100644 --- a/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_root_test.cc +++ b/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_root_test.cc @@ -35,12 +35,12 @@ TEST_F(LayoutSVGRootTest, VisualRectMappingWithoutViewportClipWithBorder) { LayoutRect root_visual_rect = static_cast<const LayoutObject&>(root).LocalVisualRect(); - // SVG root's overflow includes overflow from descendants. - EXPECT_EQ(LayoutRect(0, 0, 220, 190), root_visual_rect); + // SVG root's local overflow does not include overflow from descendants. + EXPECT_EQ(LayoutRect(0, 0, 220, 120), root_visual_rect); rect = root_visual_rect; EXPECT_TRUE(root.MapToVisualRectInAncestorSpace(&root, rect)); - EXPECT_EQ(LayoutRect(0, 0, 220, 190), rect); + EXPECT_EQ(LayoutRect(0, 0, 220, 120), rect); } TEST_F(LayoutSVGRootTest, VisualOverflowExpandsLayer) { @@ -80,8 +80,6 @@ TEST_F(LayoutSVGRootTest, VisualRectMappingWithViewportClipAndBorder) { *ToLayoutSVGShape(GetLayoutObjectByElementId("rect")); LayoutRect rect = SVGLayoutSupport::VisualRectInAncestorSpace(svg_rect, root); - // (80, 80, 100, 100) added by root's content rect offset from border rect, - // clipped by (10, 10, 200, 100). EXPECT_EQ(LayoutRect(90, 90, 100, 20), rect); LayoutRect root_visual_rect = @@ -96,34 +94,6 @@ TEST_F(LayoutSVGRootTest, VisualRectMappingWithViewportClipAndBorder) { EXPECT_EQ(LayoutRect(0, 0, 220, 120), rect); } -TEST_F(LayoutSVGRootTest, VisualRectMappingWithViewportClipWithoutBorder) { - SetBodyInnerHTML(R"HTML( - <svg id='root' style='width: 200px; height: 100px; overflow: hidden' - viewBox='0 0 200 100'> - <rect id='rect' x='80' y='80' width='100' height='100'/> - </svg> - )HTML"); - - const LayoutSVGRoot& root = - *ToLayoutSVGRoot(GetLayoutObjectByElementId("root")); - const LayoutSVGShape& svg_rect = - *ToLayoutSVGShape(GetLayoutObjectByElementId("rect")); - - LayoutRect rect = SVGLayoutSupport::VisualRectInAncestorSpace(svg_rect, root); - // (80, 80, 100, 100) clipped by (0, 0, 200, 100). - EXPECT_EQ(LayoutRect(80, 80, 100, 20), rect); - - LayoutRect root_visual_rect = - static_cast<const LayoutObject&>(root).LocalVisualRect(); - // SVG root doesn't have box decoration background, so just use clipped - // overflow of children. - EXPECT_EQ(LayoutRect(80, 80, 100, 20), root_visual_rect); - - rect = root_visual_rect; - EXPECT_TRUE(root.MapToVisualRectInAncestorSpace(&root, rect)); - EXPECT_EQ(LayoutRect(80, 80, 100, 20), rect); -} - TEST_F(LayoutSVGRootTest, PaintedOutputOfObjectHasNoEffectRegardlessOfSizeEmpty) { SetBodyInnerHTML(R"HTML( diff --git a/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_text.cc b/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_text.cc index 79297b4fae9..42eb744405c 100644 --- a/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_text.cc +++ b/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_text.cc @@ -283,9 +283,7 @@ void LayoutSVGText::UpdateLayout() { update_parent_boundaries = true; } - overflow_.reset(); - AddSelfVisualOverflow(LayoutRect(new_boundaries)); - AddVisualEffectOverflow(); + ClearLayoutOverflow(); // Invalidate all resources of this client if our layout changed. if (EverHadLayout() && SelfNeedsLayout()) @@ -299,9 +297,16 @@ void LayoutSVGText::UpdateLayout() { DCHECK(!needs_transform_update_); DCHECK(!needs_text_metrics_update_); DCHECK(!needs_positioning_values_update_); + ClearSelfNeedsLayoutOverflowRecalc(); ClearNeedsLayout(); } +void LayoutSVGText::RecalcVisualOverflow() { + LayoutObject::RecalcVisualOverflow(); + AddSelfVisualOverflow(LayoutRect(ObjectBoundingBox())); + AddVisualEffectOverflow(); +} + RootInlineBox* LayoutSVGText::CreateRootInlineBox() { RootInlineBox* box = new SVGRootInlineBox(LineLayoutItem(this)); box->SetHasVirtualLogicalHeight(); diff --git a/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_text.h b/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_text.h index ce40fa69fe9..bf9845cc258 100644 --- a/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_text.h +++ b/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_text.h @@ -62,6 +62,8 @@ class LayoutSVGText final : public LayoutSVGBlock { void SubtreeChildWillBeRemoved(); void SubtreeTextDidChange(); + void RecalcVisualOverflow() override; + const char* GetName() const override { return "LayoutSVGText"; } private: diff --git a/chromium/third_party/blink/renderer/core/layout/svg/svg_layout_tree_as_text.cc b/chromium/third_party/blink/renderer/core/layout/svg/svg_layout_tree_as_text.cc index 9ad37d5e881..f99236e3335 100644 --- a/chromium/third_party/blink/renderer/core/layout/svg/svg_layout_tree_as_text.cc +++ b/chromium/third_party/blink/renderer/core/layout/svg/svg_layout_tree_as_text.cc @@ -418,7 +418,7 @@ static void WriteLayoutSVGTextBox(WTF::TextStream& ts, return; // FIXME: Remove this hack, once the new text layout engine is completly - // landed. We want to preserve the old layout test results for now. + // landed. We want to preserve the old web test results for now. ts << " contains 1 chunk(s)"; if (text.Parent() && (text.Parent()->ResolveColor(GetCSSPropertyColor()) != @@ -451,7 +451,7 @@ static inline void WriteSVGInlineTextBox(WTF::TextStream& ts, unsigned end_offset = fragment.character_offset + fragment.length; // FIXME: Remove this hack, once the new text layout engine is completly - // landed. We want to preserve the old layout test results for now. + // landed. We want to preserve the old web test results for now. ts << "chunk 1 "; ETextAnchor anchor = svg_style.TextAnchor(); bool is_vertical_text = |