diff options
Diffstat (limited to 'chromium/third_party/WebKit/Source/core')
13 files changed, 99 insertions, 162 deletions
diff --git a/chromium/third_party/WebKit/Source/core/dom/Document.cpp b/chromium/third_party/WebKit/Source/core/dom/Document.cpp index 5f6f0c9aa6f..f76aea75a88 100644 --- a/chromium/third_party/WebKit/Source/core/dom/Document.cpp +++ b/chromium/third_party/WebKit/Source/core/dom/Document.cpp @@ -1922,7 +1922,7 @@ void Document::SetupFontBuilder(ComputedStyle& document_style) { font_builder.CreateFontForDocument(selector, document_style); } -void Document::PropagateStyleToViewport(StyleRecalcChange change) { +void Document::PropagateStyleToViewport() { DCHECK(InStyleRecalc()); DCHECK(documentElement()); @@ -2034,48 +2034,42 @@ void Document::PropagateStyleToViewport(StyleRecalcChange change) { scroll_boundary_behavior_y))); } - RefPtr<ComputedStyle> viewport_style; - if (change == kForce || !GetLayoutViewItem().Style()) { - viewport_style = StyleResolver::StyleForViewport(*this); - } else { - const ComputedStyle& old_style = GetLayoutViewItem().StyleRef(); - if (old_style.GetWritingMode() == root_writing_mode && - old_style.Direction() == root_direction && - old_style.VisitedDependentColor(CSSPropertyBackgroundColor) == - background_color && - old_style.BackgroundLayers() == background_layers && - old_style.ImageRendering() == image_rendering && - old_style.OverflowAnchor() == overflow_anchor && - old_style.OverflowX() == overflow_x && - old_style.OverflowY() == overflow_y && - old_style.HasNormalColumnGap() == column_gap_normal && - old_style.ColumnGap() == column_gap && - old_style.GetScrollSnapType() == snap_type && - old_style.GetScrollBehavior() == scroll_behavior && - old_style.OverscrollBehaviorX() == scroll_boundary_behavior_x && - old_style.OverscrollBehaviorY() == scroll_boundary_behavior_y) { - return; - } - viewport_style = ComputedStyle::Clone(old_style); - } - viewport_style->SetWritingMode(root_writing_mode); - viewport_style->SetDirection(root_direction); - viewport_style->SetBackgroundColor(background_color); - viewport_style->AccessBackgroundLayers() = background_layers; - viewport_style->SetImageRendering(image_rendering); - viewport_style->SetOverflowAnchor(overflow_anchor); - viewport_style->SetOverflowX(overflow_x); - viewport_style->SetOverflowY(overflow_y); - if (column_gap_normal) - viewport_style->SetHasNormalColumnGap(); - else - viewport_style->SetColumnGap(column_gap); - viewport_style->SetScrollSnapType(snap_type); - viewport_style->SetScrollBehavior(scroll_behavior); - viewport_style->SetOverscrollBehaviorX(scroll_boundary_behavior_x); - viewport_style->SetOverscrollBehaviorY(scroll_boundary_behavior_y); - GetLayoutViewItem().SetStyle(viewport_style); - SetupFontBuilder(*viewport_style); + RefPtr<ComputedStyle> viewport_style = GetLayoutViewItem().MutableStyle(); + if (viewport_style->GetWritingMode() != root_writing_mode || + viewport_style->Direction() != root_direction || + viewport_style->VisitedDependentColor(CSSPropertyBackgroundColor) != + background_color || + viewport_style->BackgroundLayers() != background_layers || + viewport_style->ImageRendering() != image_rendering || + viewport_style->OverflowAnchor() != overflow_anchor || + viewport_style->OverflowX() != overflow_x || + viewport_style->OverflowY() != overflow_y || + viewport_style->HasNormalColumnGap() != column_gap_normal || + viewport_style->ColumnGap() != column_gap || + viewport_style->GetScrollSnapType() != snap_type || + viewport_style->GetScrollBehavior() != scroll_behavior || + viewport_style->OverscrollBehaviorX() != scroll_boundary_behavior_x || + viewport_style->OverscrollBehaviorY() != scroll_boundary_behavior_y) { + RefPtr<ComputedStyle> new_style = ComputedStyle::Clone(*viewport_style); + new_style->SetWritingMode(root_writing_mode); + new_style->SetDirection(root_direction); + new_style->SetBackgroundColor(background_color); + new_style->AccessBackgroundLayers() = background_layers; + new_style->SetImageRendering(image_rendering); + new_style->SetOverflowAnchor(overflow_anchor); + new_style->SetOverflowX(overflow_x); + new_style->SetOverflowY(overflow_y); + if (column_gap_normal) + new_style->SetHasNormalColumnGap(); + else + new_style->SetColumnGap(column_gap); + new_style->SetScrollSnapType(snap_type); + new_style->SetScrollBehavior(scroll_behavior); + new_style->SetOverscrollBehaviorX(scroll_boundary_behavior_x); + new_style->SetOverscrollBehaviorY(scroll_boundary_behavior_y); + GetLayoutViewItem().SetStyle(new_style); + SetupFontBuilder(*new_style); + } } #if DCHECK_IS_ON() @@ -2213,13 +2207,28 @@ void Document::UpdateStyle() { lifecycle_.AdvanceTo(DocumentLifecycle::kInStyleRecalc); StyleRecalcChange change = kNoChange; - if (GetStyleChangeType() >= kSubtreeStyleChange) { + if (GetStyleChangeType() >= kSubtreeStyleChange) change = kForce; - has_nodes_with_placeholder_style_ = false; - } NthIndexCache nth_index_cache(*this); + // TODO(rune@opera.com): Cannot access the EnsureStyleResolver() before + // calling StyleForViewport() below because apparently the StyleResolver's + // constructor has side effects. We should fix it. See + // printing/setPrinting.html, printing/width-overflow.html though they only + // fail on mac when accessing the resolver by what appears to be a viewport + // size difference. + + if (change == kForce) { + has_nodes_with_placeholder_style_ = false; + RefPtr<ComputedStyle> viewport_style = + StyleResolver::StyleForViewport(*this); + StyleRecalcChange local_change = ComputedStyle::StylePropagationDiff( + viewport_style.get(), GetLayoutViewItem().Style()); + if (local_change != kNoChange) + GetLayoutViewItem().SetStyle(std::move(viewport_style)); + } + ClearNeedsStyleRecalc(); ClearNeedsReattachLayoutTree(); @@ -2238,15 +2247,13 @@ void Document::UpdateStyle() { ViewportDefiningElementDidChange(); } GetStyleEngine().MarkForWhitespaceReattachment(); - PropagateStyleToViewport(change); + PropagateStyleToViewport(); if (document_element->NeedsReattachLayoutTree() || document_element->ChildNeedsReattachLayoutTree()) { TRACE_EVENT0("blink,blink_style", "Document::rebuildLayoutTree"); WhitespaceAttacher whitespace_attacher; document_element->RebuildLayoutTree(whitespace_attacher); } - } else if (change == kForce) { - GetLayoutViewItem().SetStyle(StyleResolver::StyleForViewport(*this)); } GetStyleEngine().ClearWhitespaceReattachSet(); diff --git a/chromium/third_party/WebKit/Source/core/dom/Document.h b/chromium/third_party/WebKit/Source/core/dom/Document.h index 18d9321d2fd..72b66e4f296 100644 --- a/chromium/third_party/WebKit/Source/core/dom/Document.h +++ b/chromium/third_party/WebKit/Source/core/dom/Document.h @@ -1414,7 +1414,7 @@ class CORE_EXPORT Document : public ContainerNode, bool NeedsFullLayoutTreeUpdate() const; - void PropagateStyleToViewport(StyleRecalcChange); + void PropagateStyleToViewport(); void UpdateUseShadowTreesIfNeeded(); void EvaluateMediaQueryListIfNeeded(); diff --git a/chromium/third_party/WebKit/Source/core/editing/EditingUtilities.cpp b/chromium/third_party/WebKit/Source/core/editing/EditingUtilities.cpp index 9aa3d47f94b..7cc474be49e 100644 --- a/chromium/third_party/WebKit/Source/core/editing/EditingUtilities.cpp +++ b/chromium/third_party/WebKit/Source/core/editing/EditingUtilities.cpp @@ -1566,6 +1566,9 @@ bool IsTabHTMLSpanElement(const Node* node) { return false; if (!ToText(first_child)->data().Contains('\t')) return false; + // TODO(editing-dev): Hoist the call of UpdateStyleAndLayoutTree to callers. + // See crbug.com/590369 for details. + node->GetDocument().UpdateStyleAndLayoutTree(); return node->GetComputedStyle()->WhiteSpace() == EWhiteSpace::kPre; } diff --git a/chromium/third_party/WebKit/Source/core/editing/SelectionController.cpp b/chromium/third_party/WebKit/Source/core/editing/SelectionController.cpp index d57fcba1d6d..3032a4f60e0 100644 --- a/chromium/third_party/WebKit/Source/core/editing/SelectionController.cpp +++ b/chromium/third_party/WebKit/Source/core/editing/SelectionController.cpp @@ -848,6 +848,9 @@ void SelectionController::SetNonDirectionalSelectionIfNeeded( original_base_in_flat_tree_ = PositionInFlatTreeWithAffinity(); } + builder.SetIsDirectional( + frame_->GetEditor().Behavior().ShouldConsiderSelectionAsDirectional() || + new_selection.IsDirectional()); const SelectionInFlatTree& selection_in_flat_tree = builder.Build(); const bool should_show_handle = handle_visibility == HandleVisibility::kVisible; diff --git a/chromium/third_party/WebKit/Source/core/intersection_observer/IntersectionObserver.cpp b/chromium/third_party/WebKit/Source/core/intersection_observer/IntersectionObserver.cpp index f6a932411a1..2af3d3e83c2 100644 --- a/chromium/third_party/WebKit/Source/core/intersection_observer/IntersectionObserver.cpp +++ b/chromium/third_party/WebKit/Source/core/intersection_observer/IntersectionObserver.cpp @@ -329,7 +329,6 @@ String IntersectionObserver::rootMargin() const { void IntersectionObserver::EnqueueIntersectionObserverEntry( IntersectionObserverEntry& entry) { - DCHECK(delegate_->GetExecutionContext()); entries_.push_back(&entry); ToDocument(delegate_->GetExecutionContext()) ->EnsureIntersectionObserverController() diff --git a/chromium/third_party/WebKit/Source/core/layout/LayoutBlock.cpp b/chromium/third_party/WebKit/Source/core/layout/LayoutBlock.cpp index f73d3fd4f28..b998d060102 100644 --- a/chromium/third_party/WebKit/Source/core/layout/LayoutBlock.cpp +++ b/chromium/third_party/WebKit/Source/core/layout/LayoutBlock.cpp @@ -586,8 +586,7 @@ void LayoutBlock::UpdateBlockChildDirtyBitsBeforeLayout(bool relayout_children, if (relayout_children || (has_relative_logical_height && !IsLayoutView()) || (height_available_to_children_changed_ && ChangeInAvailableLogicalHeightAffectsChild(this, child)) || - (child.IsListMarker() && IsListItem() && - ToLayoutBlockFlow(this)->ContainsFloats())) { + (child.IsListMarker() && IsListItem())) { child.SetChildNeedsLayout(kMarkOnlyThis); } } diff --git a/chromium/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/chromium/third_party/WebKit/Source/core/layout/LayoutBox.cpp index d192c995ed4..8bde145857e 100644 --- a/chromium/third_party/WebKit/Source/core/layout/LayoutBox.cpp +++ b/chromium/third_party/WebKit/Source/core/layout/LayoutBox.cpp @@ -187,6 +187,18 @@ void LayoutBox::StyleWillChange(StyleDifference diff, if (flow_thread && flow_thread != this) flow_thread->FlowThreadDescendantStyleWillChange(this, diff, new_style); + // The background of the root element or the body element could propagate up + // to the canvas. Just dirty the entire canvas when our style changes + // substantially. + if ((diff.NeedsFullPaintInvalidation() || diff.NeedsLayout()) && + GetNode() && (IsDocumentElement() || IsHTMLBodyElement(*GetNode()))) { + View()->SetShouldDoFullPaintInvalidation(); + + if (old_style->HasEntirelyFixedBackground() != + new_style.HasEntirelyFixedBackground()) + View()->Compositor()->SetNeedsUpdateFixedBackground(); + } + // When a layout hint happens and an object's position style changes, we // have to do a layout to dirty the layout tree using the old position // value now. diff --git a/chromium/third_party/WebKit/Source/core/layout/LayoutView.cpp b/chromium/third_party/WebKit/Source/core/layout/LayoutView.cpp index f6c7f5d5e9a..acaa480ebe7 100644 --- a/chromium/third_party/WebKit/Source/core/layout/LayoutView.cpp +++ b/chromium/third_party/WebKit/Source/core/layout/LayoutView.cpp @@ -928,33 +928,6 @@ bool LayoutView::PaintedOutputOfObjectHasNoEffectRegardlessOfSize() const { return LayoutBlockFlow::PaintedOutputOfObjectHasNoEffectRegardlessOfSize(); } -void LayoutView::StyleWillChange(StyleDifference diff, - const ComputedStyle& new_style) { - LayoutBlockFlow::StyleWillChange(diff, new_style); - - // TODO(rune@opera.com): Ideally, StyleWillChange for LayoutBlockFlow should - // have been able to do the invalidation, but there is an early return in - // LayoutObject::StyleDidChange which returns if parent_ is nullptr. - - if (const ComputedStyle* old_style = Style()) { - // TODO(rune@opera.com): Consider checking diff.NeedsFullPaintInvalidation() - // instead. That will currently lead to more invalidation rectangles. For - // instance for computed overflow changes that would otherwise be - // invalidated by root and body changes. Also zoom related changes will - // cause extra invalidation rectangles to be recorded in paint/invalidation - // layout tests. - if (!old_style->BackgroundVisuallyEqual(new_style)) { - // Paint invalidation of background propagated from root or body elements - // to viewport. - SetShouldDoFullPaintInvalidation(); - if (old_style->HasEntirelyFixedBackground() != - new_style.HasEntirelyFixedBackground()) { - Compositor()->SetNeedsUpdateFixedBackground(); - } - } - } -} - void LayoutView::UpdateCounters() { if (!needs_counter_update_) return; diff --git a/chromium/third_party/WebKit/Source/core/layout/LayoutView.h b/chromium/third_party/WebKit/Source/core/layout/LayoutView.h index e793757869d..523a36f98cc 100644 --- a/chromium/third_party/WebKit/Source/core/layout/LayoutView.h +++ b/chromium/third_party/WebKit/Source/core/layout/LayoutView.h @@ -248,9 +248,6 @@ class CORE_EXPORT LayoutView final : public LayoutBlockFlow { // LocalFrameView or PaintLayerScrollableArea handle the scroll. ScrollResult Scroll(ScrollGranularity, const FloatSize&) override; - void StyleWillChange(StyleDifference, - const ComputedStyle& new_style) override; - LayoutRect DebugRect() const override; private: diff --git a/chromium/third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp b/chromium/third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp index 4bb9696ef87..8ef8813de2e 100644 --- a/chromium/third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp +++ b/chromium/third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp @@ -170,18 +170,8 @@ bool PrePaintTreeWalk::NeedsTreeBuilderContextUpdate( object); } -void PrePaintTreeWalk::Walk(const LayoutObject& object, - const PrePaintTreeWalkContext& parent_context) { - // Early out from the tree walk if possible. - bool needs_tree_builder_context_update = - this->NeedsTreeBuilderContextUpdate(object, parent_context); - if (!needs_tree_builder_context_update && - !object.ShouldCheckForPaintInvalidation()) - return; - - PrePaintTreeWalkContext context(parent_context, - needs_tree_builder_context_update); - +void PrePaintTreeWalk::WalkInternal(const LayoutObject& object, + PrePaintTreeWalkContext& context) { // This must happen before updatePropertiesForSelf, because the latter reads // some of the state computed here. UpdateAuxiliaryObjectProperties(object, context); @@ -205,6 +195,20 @@ void PrePaintTreeWalk::Walk(const LayoutObject& object, InvalidatePaintLayerOptimizationsIfNeeded(object, context); } +} + +void PrePaintTreeWalk::Walk(const LayoutObject& object, + const PrePaintTreeWalkContext& parent_context) { + // Early out from the tree walk if possible. + bool needs_tree_builder_context_update = + this->NeedsTreeBuilderContextUpdate(object, parent_context); + if (!needs_tree_builder_context_update && + !object.ShouldCheckForPaintInvalidation()) + return; + + PrePaintTreeWalkContext context(parent_context, + needs_tree_builder_context_update); + WalkInternal(object, context); for (const LayoutObject* child = object.SlowFirstChild(); child; child = child->NextSibling()) { diff --git a/chromium/third_party/WebKit/Source/core/paint/PrePaintTreeWalk.h b/chromium/third_party/WebKit/Source/core/paint/PrePaintTreeWalk.h index 389bc763382..cd70c521d23 100644 --- a/chromium/third_party/WebKit/Source/core/paint/PrePaintTreeWalk.h +++ b/chromium/third_party/WebKit/Source/core/paint/PrePaintTreeWalk.h @@ -26,6 +26,13 @@ class CORE_EXPORT PrePaintTreeWalk { private: void Walk(LocalFrameView&, const PrePaintTreeWalkContext&); + + // This is to minimize stack frame usage during recursion. Modern compilers + // (MSVC in particular) can inline across compilation units, resulting in + // very big stack frames. Splitting the heavy lifting to a separate function + // makes sure the stack frame is freed prior to making a recursive call. + // See https://crbug.com/781301 . + NOINLINE void WalkInternal(const LayoutObject&, PrePaintTreeWalkContext&); void Walk(const LayoutObject&, const PrePaintTreeWalkContext&); // Invalidates paint-layer painting optimizations, such as subsequence caching diff --git a/chromium/third_party/WebKit/Source/core/paint/compositing/CompositedLayerMappingTest.cpp b/chromium/third_party/WebKit/Source/core/paint/compositing/CompositedLayerMappingTest.cpp index c2e2cf1c4b6..d76e814a94c 100644 --- a/chromium/third_party/WebKit/Source/core/paint/compositing/CompositedLayerMappingTest.cpp +++ b/chromium/third_party/WebKit/Source/core/paint/compositing/CompositedLayerMappingTest.cpp @@ -2034,70 +2034,6 @@ TEST_P(CompositedLayerMappingTest, ASSERT_TRUE(child_mapping->AncestorClippingMaskLayer()); } -TEST_P(CompositedLayerMappingTest, - BorderRadiusPreventsSquashingWithInlineTransform) { - // When a node with inline transform has siblings with border radius and - // composited children, those siblings must not be squashed because it - // prevents application of a border radius clip mask. - SetBodyInnerHTML( - "<style>" - " .precursor {" - " width: 100px;" - " height: 40px;" - " }" - " .container {" - " position: relative;" - " top: 20px;" - " width: 100px;" - " height: 40px;" - " border: 1px solid black;" - " border-radius: 10px;" - " overflow: hidden;" - " }" - " .contents {" - " height: 200px;" - " width: 200px;" - " position: relative;" - " top: -10px;" - " left: -10px;" - " }" - "</style>" - "<div id='precursor' class='precursor'" - " style='transform: translateZ(0);'>" - "</div>" - "<div id='container1' class='container'>" - " <div id='contents1' class='contents'></div>" - "</div>" - "<div id='container2' class='container'>" - " <div id='contents2' class='contents'></div>" - "</div>"); - GetDocument().View()->UpdateAllLifecyclePhases(); - - Element* first_child = GetDocument().getElementById("contents1"); - ASSERT_TRUE(first_child); - PaintLayer* first_child_paint_layer = - ToLayoutBoxModelObject(first_child->GetLayoutObject())->Layer(); - ASSERT_TRUE(first_child_paint_layer); - CompositedLayerMapping* first_child_mapping = - first_child_paint_layer->GetCompositedLayerMapping(); - ASSERT_TRUE(first_child_mapping); - ASSERT_TRUE(first_child_mapping->AncestorClippingLayer()); - EXPECT_TRUE(first_child_mapping->AncestorClippingLayer()->MaskLayer()); - ASSERT_TRUE(first_child_mapping->AncestorClippingMaskLayer()); - - Element* second_child = GetDocument().getElementById("contents2"); - ASSERT_TRUE(second_child); - PaintLayer* second_child_paint_layer = - ToLayoutBoxModelObject(second_child->GetLayoutObject())->Layer(); - ASSERT_TRUE(second_child_paint_layer); - CompositedLayerMapping* second_child_mapping = - second_child_paint_layer->GetCompositedLayerMapping(); - ASSERT_TRUE(second_child_mapping); - ASSERT_TRUE(second_child_mapping->AncestorClippingLayer()); - EXPECT_TRUE(second_child_mapping->AncestorClippingLayer()->MaskLayer()); - ASSERT_TRUE(second_child_mapping->AncestorClippingMaskLayer()); -} - TEST_P(CompositedLayerMappingTest, StickyPositionMainThreadOffset) { SetBodyInnerHTML( "<style>.composited { backface-visibility: hidden; }" diff --git a/chromium/third_party/WebKit/Source/core/paint/compositing/CompositingLayerAssigner.cpp b/chromium/third_party/WebKit/Source/core/paint/compositing/CompositingLayerAssigner.cpp index 1969fe2c12c..6ba15f2b014 100644 --- a/chromium/third_party/WebKit/Source/core/paint/compositing/CompositingLayerAssigner.cpp +++ b/chromium/third_party/WebKit/Source/core/paint/compositing/CompositingLayerAssigner.cpp @@ -208,9 +208,6 @@ CompositingLayerAssigner::GetReasonsPreventingSquashing( if (layer->EnclosingPaginationLayer()) return kSquashingDisallowedReasonFragmentedContent; - if (layer->GetLayoutObject().Style()->HasBorderRadius()) - return kSquashingDisallowedReasonBorderRadiusClipsDescendants; - return kSquashingDisallowedReasonsNone; } |