Commit 97a7bfac authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

[CompositeAfterPaint] Composited scrolling of view based on html/body's hint

CSS scrolling properties on html/body apply to the view. For example,
overflow:hidden on html or body actually means the view is not
scrollable. Based on this, using compositing hint on html/body for the
view composited scrolling is reasonable. This seems a better way to hint
composited scrolling of an iframe's content than hinting on the iframe
because this can be controlled by the content document.

Change-Id: I78c3683d1c6f3b610161f5ebfb5cd7d2f6129b11
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2125907Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#754565}
parent 0c2093e5
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "third_party/blink/renderer/core/frame/local_frame_view.h" #include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/settings.h" #include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/fullscreen/fullscreen.h" #include "third_party/blink/renderer/core/fullscreen/fullscreen.h"
#include "third_party/blink/renderer/core/html/html_body_element.h"
#include "third_party/blink/renderer/core/layout/layout_embedded_content.h" #include "third_party/blink/renderer/core/layout/layout_embedded_content.h"
#include "third_party/blink/renderer/core/layout/layout_video.h" #include "third_party/blink/renderer/core/layout/layout_video.h"
#include "third_party/blink/renderer/core/layout/layout_view.h" #include "third_party/blink/renderer/core/layout/layout_view.h"
...@@ -103,6 +104,26 @@ CompositingReasonFinder::PotentialCompositingReasonsFromStyle( ...@@ -103,6 +104,26 @@ CompositingReasonFinder::PotentialCompositingReasonsFromStyle(
return reasons; return reasons;
} }
static bool ShouldPreferCompositingForLayoutView(
const LayoutView& layout_view) {
auto has_direct_compositing_reasons = [](const LayoutObject* object) -> bool {
return object && CompositingReasonFinder::DirectReasonsForPaintProperties(
*object) != CompositingReason::kNone;
};
if (has_direct_compositing_reasons(
layout_view.GetFrame()->OwnerLayoutObject()))
return true;
if (auto* document_element = layout_view.GetDocument().documentElement()) {
if (has_direct_compositing_reasons(document_element->GetLayoutObject()))
return true;
}
if (auto* body = layout_view.GetDocument().FirstBodyElement()) {
if (has_direct_compositing_reasons(body->GetLayoutObject()))
return true;
}
return false;
}
CompositingReasons CompositingReasonFinder::DirectReasonsForPaintProperties( CompositingReasons CompositingReasonFinder::DirectReasonsForPaintProperties(
const LayoutObject& object) { const LayoutObject& object) {
// TODO(wangxianzhu): Don't depend on PaintLayer for CompositeAfterPaint. // TODO(wangxianzhu): Don't depend on PaintLayer for CompositeAfterPaint.
...@@ -143,15 +164,9 @@ CompositingReasons CompositingReasonFinder::DirectReasonsForPaintProperties( ...@@ -143,15 +164,9 @@ CompositingReasons CompositingReasonFinder::DirectReasonsForPaintProperties(
// a direct compositing reason, it's very likely that the object will // a direct compositing reason, it's very likely that the object will
// be composited, and it also indicates preference of compositing, // be composited, and it also indicates preference of compositing,
// so we prefer composited scrolling here. // so we prefer composited scrolling here.
style.BackfaceVisibility() == EBackfaceVisibility::kHidden; style.BackfaceVisibility() == EBackfaceVisibility::kHidden ||
(object.IsLayoutView() &&
if (!force_prefer_compositing_to_lcd_text && object.IsLayoutView()) { ShouldPreferCompositingForLayoutView(To<LayoutView>(object)));
if (auto* owner_object = object.GetFrame()->OwnerLayoutObject()) {
force_prefer_compositing_to_lcd_text =
DirectReasonsForPaintProperties(*owner_object) !=
CompositingReason::kNone;
}
}
if (scrollable_area->ComputeNeedsCompositedScrolling( if (scrollable_area->ComputeNeedsCompositedScrolling(
force_prefer_compositing_to_lcd_text)) { force_prefer_compositing_to_lcd_text)) {
......
...@@ -80,8 +80,6 @@ compositing/overflow/do-not-repaint-if-scrolling-composited-layers.html [ Failur ...@@ -80,8 +80,6 @@ compositing/overflow/do-not-repaint-if-scrolling-composited-layers.html [ Failur
# We paint the iframe's content background in the scrolling layer, causing invalidation on scroll. # We paint the iframe's content background in the scrolling layer, causing invalidation on scroll.
paint/invalidation/scroll/iframe-scroll-repaint.html [ Failure ] paint/invalidation/scroll/iframe-scroll-repaint.html [ Failure ]
# will-transform on descendant doesn't trigger compositing of iframe.
paint/invalidation/scroll/composited-iframe-scroll-repaint.html [ Failure ]
# Extra layers for non-fast scrolling areas. # Extra layers for non-fast scrolling areas.
compositing/overflow/textarea-scroll-touch.html [ Failure ] compositing/overflow/textarea-scroll-touch.html [ Failure ]
......
{
"layers": [
{
"name": "Scrolling background of LayoutView #document",
"bounds": [800, 600],
"contentsOpaque": true,
"backgroundColor": "#FFFFFF"
},
{
"name": "Scrolling background of LayoutView #document",
"bounds": [300, 516],
"contentsOpaque": true,
"backgroundColor": "#EEEEEE",
"transform": 2
},
{
"name": "LayoutNGBlockFlow BODY",
"bounds": [284, 500],
"drawsContent": false,
"transform": 3
}
],
"transforms": [
{
"id": 1,
"transform": [
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[10, 10, 0, 1]
]
},
{
"id": 2,
"parent": 1,
"transform": [
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[0, -20, 0, 1]
]
},
{
"id": 3,
"parent": 2,
"transform": [
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[8, 8, 0, 1]
]
}
]
}
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