Commit 2685a6b3 authored by Chris Harrelson's avatar Chris Harrelson Committed by Commit Bot

Add a bitfield in LayoutObject for whether it corresponds to an effective root scroller.

This saves almost 4% of hit test time on some examples, and improves performance of
occlusion hit testing for IOv2 accordingly.

Bug: 831762

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng;luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I045e0414c84208b60796fe44ea023ebbb3fbe40a
Reviewed-on: https://chromium-review.googlesource.com/1152296
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578704}
parent e508b79c
...@@ -63,7 +63,6 @@ ...@@ -63,7 +63,6 @@
#include "third_party/blink/renderer/core/layout/shapes/shape_outside_info.h" #include "third_party/blink/renderer/core/layout/shapes/shape_outside_info.h"
#include "third_party/blink/renderer/core/page/autoscroll_controller.h" #include "third_party/blink/renderer/core/page/autoscroll_controller.h"
#include "third_party/blink/renderer/core/page/page.h" #include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/page/scrolling/root_scroller_util.h"
#include "third_party/blink/renderer/core/page/scrolling/scrolling_coordinator.h" #include "third_party/blink/renderer/core/page/scrolling/scrolling_coordinator.h"
#include "third_party/blink/renderer/core/page/scrolling/snap_coordinator.h" #include "third_party/blink/renderer/core/page/scrolling/snap_coordinator.h"
#include "third_party/blink/renderer/core/paint/adjust_paint_offset_scope.h" #include "third_party/blink/renderer/core/paint/adjust_paint_offset_scope.h"
...@@ -120,7 +119,7 @@ PaintLayerType LayoutBox::LayerTypeRequired() const { ...@@ -120,7 +119,7 @@ PaintLayerType LayoutBox::LayerTypeRequired() const {
HasHiddenBackface() || HasReflection() || Style()->SpecifiesColumns() || HasHiddenBackface() || HasReflection() || Style()->SpecifiesColumns() ||
Style()->IsStackingContext() || Style()->IsStackingContext() ||
Style()->ShouldCompositeForCurrentAnimations() || Style()->ShouldCompositeForCurrentAnimations() ||
RootScrollerUtil::IsEffective(*this)) IsEffectiveRootScroller())
return kNormalPaintLayer; return kNormalPaintLayer;
if (HasOverflowClip()) if (HasOverflowClip())
...@@ -1512,7 +1511,7 @@ bool LayoutBox::HitTestAllPhases(HitTestResult& result, ...@@ -1512,7 +1511,7 @@ bool LayoutBox::HitTestAllPhases(HitTestResult& result,
// Check if we need to do anything at all. // Check if we need to do anything at all.
// If we have clipping, then we can't have any spillout. // If we have clipping, then we can't have any spillout.
// TODO(pdr): Why is this optimization not valid for the effective root? // TODO(pdr): Why is this optimization not valid for the effective root?
if (!RootScrollerUtil::IsEffective(*this)) { if (!IsEffectiveRootScroller()) {
LayoutRect overflow_box = LayoutRect overflow_box =
(HasOverflowClip() || ShouldApplyPaintContainment()) (HasOverflowClip() || ShouldApplyPaintContainment())
? BorderBoxRect() ? BorderBoxRect()
...@@ -1918,7 +1917,7 @@ LayoutRect LayoutBox::OverflowClipRect( ...@@ -1918,7 +1917,7 @@ LayoutRect LayoutBox::OverflowClipRect(
OverlayScrollbarClipBehavior overlay_scrollbar_clip_behavior) const { OverlayScrollbarClipBehavior overlay_scrollbar_clip_behavior) const {
LayoutRect clip_rect; LayoutRect clip_rect;
if (RootScrollerUtil::IsEffective(*this)) { if (IsEffectiveRootScroller()) {
// If this box is the effective root scroller, use the viewport clipping // If this box is the effective root scroller, use the viewport clipping
// rect since it will account for the URL bar correctly which the border // rect since it will account for the URL bar correctly which the border
// box does not. We can do this because the effective root scroller is // box does not. We can do this because the effective root scroller is
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include "third_party/blink/renderer/core/layout/hit_test_result.h" #include "third_party/blink/renderer/core/layout/hit_test_result.h"
#include "third_party/blink/renderer/core/layout/layout_analyzer.h" #include "third_party/blink/renderer/core/layout/layout_analyzer.h"
#include "third_party/blink/renderer/core/layout/layout_view.h" #include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/page/scrolling/root_scroller_util.h"
#include "third_party/blink/renderer/core/paint/embedded_content_painter.h" #include "third_party/blink/renderer/core/paint/embedded_content_painter.h"
namespace blink { namespace blink {
...@@ -290,7 +289,7 @@ CursorDirective LayoutEmbeddedContent::GetCursor(const LayoutPoint& point, ...@@ -290,7 +289,7 @@ CursorDirective LayoutEmbeddedContent::GetCursor(const LayoutPoint& point,
LayoutRect LayoutEmbeddedContent::ReplacedContentRect() const { LayoutRect LayoutEmbeddedContent::ReplacedContentRect() const {
LayoutRect content_rect = ContentBoxRect(); LayoutRect content_rect = ContentBoxRect();
// IFrames set as the root scroller should get their size from their parent. // IFrames set as the root scroller should get their size from their parent.
if (ChildFrameView() && View() && RootScrollerUtil::IsEffective(*this)) if (ChildFrameView() && View() && IsEffectiveRootScroller())
content_rect = LayoutRect(LayoutPoint(), View()->ViewRect().Size()); content_rect = LayoutRect(LayoutPoint(), View()->ViewRect().Size());
// We don't propagate sub-pixel into sub-frame layout, in other words, the // We don't propagate sub-pixel into sub-frame layout, in other words, the
......
...@@ -178,6 +178,7 @@ struct SameSizeAsLayoutObject : DisplayItemClient { ...@@ -178,6 +178,7 @@ struct SameSizeAsLayoutObject : DisplayItemClient {
#endif #endif
unsigned bitfields_; unsigned bitfields_;
unsigned bitfields2_; unsigned bitfields2_;
unsigned bitfields3_;
// The following fields are in FragmentData. // The following fields are in FragmentData.
LayoutRect visual_rect_; LayoutRect visual_rect_;
LayoutPoint paint_offset_; LayoutPoint paint_offset_;
......
...@@ -921,6 +921,16 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, ...@@ -921,6 +921,16 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver,
bool HasShapeOutside() const { return StyleRef().ShapeOutside(); } bool HasShapeOutside() const { return StyleRef().ShapeOutside(); }
// Return true if the given object is the effective root scroller in its
// Document. See |effective root scroller| in page/scrolling/README.md.
// Note: a root scroller always establishes a PaintLayer.
// This bit is updated in
// RootScrollerController::RecomputeEffectiveRootScroller in the LayoutClean
// document lifecycle phase.
bool IsEffectiveRootScroller() const {
return bitfields_.IsEffectiveRootScroller();
}
// The pseudo element style can be cached or uncached. Use the cached method // The pseudo element style can be cached or uncached. Use the cached method
// if the pseudo element doesn't respect any pseudo classes (and therefore // if the pseudo element doesn't respect any pseudo classes (and therefore
// has no concept of changing state). // has no concept of changing state).
...@@ -1139,6 +1149,9 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, ...@@ -1139,6 +1149,9 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver,
void SetCanContainFixedPositionObjects(bool can_contain_fixed_position) { void SetCanContainFixedPositionObjects(bool can_contain_fixed_position) {
bitfields_.SetCanContainFixedPositionObjects(can_contain_fixed_position); bitfields_.SetCanContainFixedPositionObjects(can_contain_fixed_position);
} }
void SetIsEffectiveRootScroller(bool is_effective_root_scroller) {
bitfields_.SetIsEffectiveRootScroller(is_effective_root_scroller);
}
virtual void Paint(const PaintInfo&) const; virtual void Paint(const PaintInfo&) const;
...@@ -2411,6 +2424,7 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, ...@@ -2411,6 +2424,7 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver,
inside_blocking_touch_event_handler_(false), inside_blocking_touch_event_handler_(false),
effective_whitelisted_touch_action_changed_(true), effective_whitelisted_touch_action_changed_(true),
descendant_effective_whitelisted_touch_action_changed_(false), descendant_effective_whitelisted_touch_action_changed_(false),
is_effective_root_scroller_(false),
positioned_state_(kIsStaticallyPositioned), positioned_state_(kIsStaticallyPositioned),
selection_state_(static_cast<unsigned>(SelectionState::kNone)), selection_state_(static_cast<unsigned>(SelectionState::kNone)),
background_obscuration_state_(kBackgroundObscurationStatusInvalid), background_obscuration_state_(kBackgroundObscurationStatusInvalid),
...@@ -2635,10 +2649,7 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, ...@@ -2635,10 +2649,7 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver,
ADD_BOOLEAN_BITFIELD(descendant_effective_whitelisted_touch_action_changed_, ADD_BOOLEAN_BITFIELD(descendant_effective_whitelisted_touch_action_changed_,
DescendantEffectiveWhitelistedTouchActionChanged); DescendantEffectiveWhitelistedTouchActionChanged);
protected: ADD_BOOLEAN_BITFIELD(is_effective_root_scroller_, IsEffectiveRootScroller);
// Use protected to avoid warning about unused variable.
// Increment this to 63 if a new bit is added.
// unsigned unused_bits_ : 0;
private: private:
// This is the cached 'position' value of this object // This is the cached 'position' value of this object
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "third_party/blink/renderer/core/layout/ng/ng_length_utils.h" #include "third_party/blink/renderer/core/layout/ng/ng_length_utils.h"
#include "third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.h" #include "third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.h"
#include "third_party/blink/renderer/core/layout/ng/ng_relative_utils.h" #include "third_party/blink/renderer/core/layout/ng/ng_relative_utils.h"
#include "third_party/blink/renderer/core/page/scrolling/root_scroller_util.h"
#include "third_party/blink/renderer/core/paint/adjust_paint_offset_scope.h" #include "third_party/blink/renderer/core/paint/adjust_paint_offset_scope.h"
#include "third_party/blink/renderer/core/paint/ng/ng_block_flow_painter.h" #include "third_party/blink/renderer/core/paint/ng/ng_block_flow_painter.h"
#include "third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h" #include "third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h"
...@@ -327,7 +326,7 @@ bool LayoutNGMixin<Base>::NodeAtPoint( ...@@ -327,7 +326,7 @@ bool LayoutNGMixin<Base>::NodeAtPoint(
// LayoutBox in the paint layer, regardless of writing mode or whether the box // LayoutBox in the paint layer, regardless of writing mode or whether the box
// was placed by NG or legacy. // was placed by NG or legacy.
const LayoutPoint physical_offset = accumulated_offset + Base::Location(); const LayoutPoint physical_offset = accumulated_offset + Base::Location();
if (!RootScrollerUtil::IsEffective(*this)) { if (!this->IsEffectiveRootScroller()) {
// Check if we need to do anything at all. // Check if we need to do anything at all.
// If we have clipping, then we can't have any spillout. // If we have clipping, then we can't have any spillout.
LayoutRect overflow_box = Base::HasOverflowClip() LayoutRect overflow_box = Base::HasOverflowClip()
......
...@@ -215,6 +215,11 @@ void RootScrollerController::RecomputeEffectiveRootScroller() { ...@@ -215,6 +215,11 @@ void RootScrollerController::RecomputeEffectiveRootScroller() {
} }
} }
} }
if (auto* object = old_effective_root_scroller->GetLayoutObject())
object->SetIsEffectiveRootScroller(false);
if (auto* object = new_effective_root_scroller->GetLayoutObject())
object->SetIsEffectiveRootScroller(true);
} }
ApplyRootScrollerProperties(*old_effective_root_scroller); ApplyRootScrollerProperties(*old_effective_root_scroller);
......
...@@ -66,14 +66,6 @@ PaintLayer* PaintLayerForRootScroller(const Node* node) { ...@@ -66,14 +66,6 @@ PaintLayer* PaintLayerForRootScroller(const Node* node) {
return box->Layer(); return box->Layer();
} }
bool IsEffective(const LayoutBox& box) {
if (!box.GetNode())
return false;
return box.GetNode() ==
&box.GetDocument().GetRootScrollerController().EffectiveRootScroller();
}
bool IsGlobal(const LayoutBox& box) { bool IsGlobal(const LayoutBox& box) {
if (!box.GetNode() || !box.GetNode()->GetDocument().GetPage()) if (!box.GetNode() || !box.GetNode()->GetDocument().GetPage())
return false; return false;
...@@ -84,13 +76,6 @@ bool IsGlobal(const LayoutBox& box) { ...@@ -84,13 +76,6 @@ bool IsGlobal(const LayoutBox& box) {
.GlobalRootScroller(); .GlobalRootScroller();
} }
bool IsEffective(const PaintLayer& layer) {
if (!layer.GetLayoutBox())
return false;
return IsEffective(*layer.GetLayoutBox());
}
bool IsGlobal(const PaintLayer& layer) { bool IsGlobal(const PaintLayer& layer) {
if (!layer.GetLayoutBox()) if (!layer.GetLayoutBox())
return false; return false;
......
...@@ -25,12 +25,6 @@ ScrollableArea* ScrollableAreaForRootScroller(const Node*); ...@@ -25,12 +25,6 @@ ScrollableArea* ScrollableAreaForRootScroller(const Node*);
// rather than <html>'s since scrolling is handled by LayoutView. // rather than <html>'s since scrolling is handled by LayoutView.
PaintLayer* PaintLayerForRootScroller(const Node*); PaintLayer* PaintLayerForRootScroller(const Node*);
// Return true if the given object is the effective root scroller in its
// Document. See |effective root scroller| in README.md. Note: a root scroller
// always establishes a PaintLayer.
bool IsEffective(const LayoutBox&);
bool IsEffective(const PaintLayer&);
bool IsGlobal(const LayoutBox&); bool IsGlobal(const LayoutBox&);
bool IsGlobal(const PaintLayer&); bool IsGlobal(const PaintLayer&);
bool IsGlobal(const Element*); bool IsGlobal(const Element*);
......
...@@ -68,7 +68,6 @@ ...@@ -68,7 +68,6 @@
#include "third_party/blink/renderer/core/layout/svg/layout_svg_resource_clipper.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_resource_clipper.h"
#include "third_party/blink/renderer/core/layout/svg/layout_svg_root.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_root.h"
#include "third_party/blink/renderer/core/page/page.h" #include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/page/scrolling/root_scroller_util.h"
#include "third_party/blink/renderer/core/page/scrolling/scrolling_coordinator.h" #include "third_party/blink/renderer/core/page/scrolling/scrolling_coordinator.h"
#include "third_party/blink/renderer/core/page/scrolling/sticky_position_scrolling_constraints.h" #include "third_party/blink/renderer/core/page/scrolling/sticky_position_scrolling_constraints.h"
#include "third_party/blink/renderer/core/paint/box_reflection_utils.h" #include "third_party/blink/renderer/core/paint/box_reflection_utils.h"
...@@ -2538,7 +2537,7 @@ bool PaintLayer::IntersectsDamageRect( ...@@ -2538,7 +2537,7 @@ bool PaintLayer::IntersectsDamageRect(
LayoutRect PaintLayer::LogicalBoundingBox() const { LayoutRect PaintLayer::LogicalBoundingBox() const {
LayoutRect rect = GetLayoutObject().VisualOverflowRect(); LayoutRect rect = GetLayoutObject().VisualOverflowRect();
if (RootScrollerUtil::IsEffective(*this) || IsRootLayer()) { if (GetLayoutObject().IsEffectiveRootScroller() || IsRootLayer()) {
rect.Unite(LayoutRect(rect.Location(), rect.Unite(LayoutRect(rect.Location(),
GetLayoutObject().View()->ViewRect().Size())); GetLayoutObject().View()->ViewRect().Size()));
} }
...@@ -2659,7 +2658,7 @@ LayoutRect PaintLayer::BoundingBoxForCompositingInternal( ...@@ -2659,7 +2658,7 @@ LayoutRect PaintLayer::BoundingBoxForCompositingInternal(
!HasVisibleDescendant()) !HasVisibleDescendant())
return LayoutRect(); return LayoutRect();
if (RootScrollerUtil::IsEffective(*this) || IsRootLayer()) { if (GetLayoutObject().IsEffectiveRootScroller() || IsRootLayer()) {
// In root layer scrolling mode, the main GraphicsLayer is the size of the // In root layer scrolling mode, the main GraphicsLayer is the size of the
// layout viewport. In non-RLS mode, it is the union of the layout viewport // layout viewport. In non-RLS mode, it is the union of the layout viewport
// and the document's layout overflow rect. // and the document's layout overflow rect.
......
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