Commit 17ef05cc authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

[PE] Make NeedsOverflowControlsClip() more accurate

Previously the function was a static function which didn't know the
current paint offset so was unable to calculate the accurate pixel
snapped border box rect, so used a conservative border box rect which
caused some unnecessary OverflowControlsClip() whose change of
existence was not updated.

Now make it a method of FragmentPaintPropertyTreeBuilder to return
the accurate needs, so the change of needs is covered by existing
SetNeedsPaintPropertyTreeUpdate conditions.

Bug: 823935
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I07578033d202af3c996004a88f25711eaac245a2
Reviewed-on: https://chromium-review.googlesource.com/974167Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544870}
parent 53f8bead
...@@ -339,6 +339,7 @@ class FragmentPaintPropertyTreeBuilder { ...@@ -339,6 +339,7 @@ class FragmentPaintPropertyTreeBuilder {
ALWAYS_INLINE void UpdateCssClip(); ALWAYS_INLINE void UpdateCssClip();
ALWAYS_INLINE void UpdateClipPathClip(bool spv1_compositing_specific_pass); ALWAYS_INLINE void UpdateClipPathClip(bool spv1_compositing_specific_pass);
ALWAYS_INLINE void UpdateLocalBorderBoxContext(); ALWAYS_INLINE void UpdateLocalBorderBoxContext();
ALWAYS_INLINE bool NeedsOverflowControlsClip() const;
ALWAYS_INLINE void UpdateOverflowControlsClip(); ALWAYS_INLINE void UpdateOverflowControlsClip();
ALWAYS_INLINE void UpdateInnerBorderRadiusClip(); ALWAYS_INLINE void UpdateInnerBorderRadiusClip();
ALWAYS_INLINE void UpdateOverflowClip(); ALWAYS_INLINE void UpdateOverflowClip();
...@@ -1047,11 +1048,11 @@ static bool NeedsOverflowClip(const LayoutObject& object) { ...@@ -1047,11 +1048,11 @@ static bool NeedsOverflowClip(const LayoutObject& object) {
!IsPrintingRootLayoutView(object); !IsPrintingRootLayoutView(object);
} }
static bool NeedsOverflowControlsClip(const LayoutObject& object) { bool FragmentPaintPropertyTreeBuilder::NeedsOverflowControlsClip() const {
if (!object.HasOverflowClip()) if (!object_.HasOverflowClip())
return false; return false;
const auto& box = ToLayoutBox(object); const auto& box = ToLayoutBox(object_);
const auto* scrollable_area = box.GetScrollableArea(); const auto* scrollable_area = box.GetScrollableArea();
IntRect scroll_controls_bounds = IntRect scroll_controls_bounds =
scrollable_area->ScrollCornerAndResizerRect(); scrollable_area->ScrollCornerAndResizerRect();
...@@ -1059,8 +1060,10 @@ static bool NeedsOverflowControlsClip(const LayoutObject& object) { ...@@ -1059,8 +1060,10 @@ static bool NeedsOverflowControlsClip(const LayoutObject& object) {
scroll_controls_bounds.Unite(scrollbar->FrameRect()); scroll_controls_bounds.Unite(scrollbar->FrameRect());
if (const auto* scrollbar = scrollable_area->VerticalScrollbar()) if (const auto* scrollbar = scrollable_area->VerticalScrollbar())
scroll_controls_bounds.Unite(scrollbar->FrameRect()); scroll_controls_bounds.Unite(scrollbar->FrameRect());
IntRect conservative_border_box_rect(IntPoint(), FlooredIntSize(box.Size())); auto pixel_snapped_border_box_rect = box.PixelSnappedBorderBoxRect(
return !conservative_border_box_rect.Contains(scroll_controls_bounds); ToLayoutSize(context_.current.paint_offset));
pixel_snapped_border_box_rect.SetLocation(IntPoint());
return !pixel_snapped_border_box_rect.Contains(scroll_controls_bounds);
} }
static bool NeedsInnerBorderRadiusClip(const LayoutObject& object) { static bool NeedsInnerBorderRadiusClip(const LayoutObject& object) {
...@@ -1101,7 +1104,7 @@ void FragmentPaintPropertyTreeBuilder::UpdateOverflowControlsClip() { ...@@ -1101,7 +1104,7 @@ void FragmentPaintPropertyTreeBuilder::UpdateOverflowControlsClip() {
if (!NeedsPaintPropertyUpdate()) if (!NeedsPaintPropertyUpdate())
return; return;
if (NeedsOverflowControlsClip(object_)) { if (NeedsOverflowControlsClip()) {
// Clip overflow controls to the border box rect. // Clip overflow controls to the border box rect.
properties_->UpdateOverflowControlsClip( properties_->UpdateOverflowControlsClip(
context_.current.clip, context_.current.transform, context_.current.clip, context_.current.transform,
...@@ -2296,8 +2299,7 @@ bool ObjectPaintPropertyTreeBuilder::UpdateFragments() { ...@@ -2296,8 +2299,7 @@ bool ObjectPaintPropertyTreeBuilder::UpdateFragments() {
NeedsFilter(object_) || NeedsCssClip(object_) || NeedsFilter(object_) || NeedsCssClip(object_) ||
NeedsInnerBorderRadiusClip(object_) || NeedsOverflowClip(object_) || NeedsInnerBorderRadiusClip(object_) || NeedsOverflowClip(object_) ||
NeedsPerspective(object_) || NeedsSVGLocalToBorderBoxTransform(object_) || NeedsPerspective(object_) || NeedsSVGLocalToBorderBoxTransform(object_) ||
NeedsScrollOrScrollTranslation(object_) || NeedsScrollOrScrollTranslation(object_);
NeedsOverflowControlsClip(object_);
// Need of fragmentation clip will be determined in CreateFragmentContexts(). // Need of fragmentation clip will be determined in CreateFragmentContexts().
if (!NeedsFragmentation()) { if (!NeedsFragmentation()) {
......
...@@ -5113,15 +5113,7 @@ TEST_P(PaintPropertyTreeBuilderTest, OverflowControlsClipSubpixel) { ...@@ -5113,15 +5113,7 @@ TEST_P(PaintPropertyTreeBuilderTest, OverflowControlsClipSubpixel) {
const auto* properties2 = PaintPropertiesForElement("div2"); const auto* properties2 = PaintPropertiesForElement("div2");
ASSERT_NE(nullptr, properties2); ASSERT_NE(nullptr, properties2);
EXPECT_NE(nullptr, properties2->OverflowControlsClip()); EXPECT_EQ(nullptr, properties2->OverflowControlsClip());
const auto* overflow_controls_clip2 = properties2->OverflowControlsClip();
if (RuntimeEnabledFeatures::SlimmingPaintV175Enabled()) {
EXPECT_EQ(FloatRect(0, 0, 51, 50),
overflow_controls_clip2->ClipRect().Rect());
} else {
EXPECT_EQ(FloatRect(0, 0, 50.5, 50),
overflow_controls_clip2->ClipRect().Rect());
}
} }
TEST_P(PaintPropertyTreeBuilderTest, FragmentPaintOffsetUnderOverflowScroll) { TEST_P(PaintPropertyTreeBuilderTest, FragmentPaintOffsetUnderOverflowScroll) {
......
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