Commit 8b74e031 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Don't report first contentful paint when painting opacity:0

Move IgnorePaintTimingScope from paint_timing_detector.h into dedicated
.h and .cc files under renderer/platform, so that PaintController can
check it before recording first paint status.

This fixes several wpt tests for FCP about opacity in
CompositeAfterPaint which always paint opacity:0 contents. This doesn't
fix (and probably we'll never fix) missing FCP when opacity:0 becomes
non-zero, because we don't repaint.

Change-Id: If1b393f5c1440fada11806a7ac071b5700843ac5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2145134
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758350}
parent 315758f9
...@@ -63,8 +63,6 @@ bool IsBackgroundImageContentful(const LayoutObject& object, ...@@ -63,8 +63,6 @@ bool IsBackgroundImageContentful(const LayoutObject& object,
} // namespace } // namespace
bool IgnorePaintTimingScope::should_ignore_ = false;
PaintTimingDetector::PaintTimingDetector(LocalFrameView* frame_view) PaintTimingDetector::PaintTimingDetector(LocalFrameView* frame_view)
: frame_view_(frame_view), : frame_view_(frame_view),
text_paint_timing_detector_( text_paint_timing_detector_(
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "third_party/blink/renderer/core/layout/layout_box_model_object.h" #include "third_party/blink/renderer/core/layout/layout_box_model_object.h"
#include "third_party/blink/renderer/core/paint/paint_timing_visualizer.h" #include "third_party/blink/renderer/core/paint/paint_timing_visualizer.h"
#include "third_party/blink/renderer/core/scroll/scroll_types.h" #include "third_party/blink/renderer/core/scroll/scroll_types.h"
#include "third_party/blink/renderer/platform/graphics/paint/ignore_paint_timing_scope.h"
#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/heap/member.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h" #include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
...@@ -273,22 +274,6 @@ class ScopedPaintTimingDetectorBlockPaintHook { ...@@ -273,22 +274,6 @@ class ScopedPaintTimingDetectorBlockPaintHook {
DISALLOW_COPY_AND_ASSIGN(ScopedPaintTimingDetectorBlockPaintHook); DISALLOW_COPY_AND_ASSIGN(ScopedPaintTimingDetectorBlockPaintHook);
}; };
// Creates a scope to ignore paint timing, e.g. when we are painting contents
// under opacity:0.
class IgnorePaintTimingScope {
STACK_ALLOCATED();
public:
IgnorePaintTimingScope() : auto_reset_(&should_ignore_, true) {}
~IgnorePaintTimingScope() = default;
static bool ShouldIgnore() { return should_ignore_; }
private:
base::AutoReset<bool> auto_reset_;
static bool should_ignore_;
};
// static // static
inline void PaintTimingDetector::NotifyTextPaint( inline void PaintTimingDetector::NotifyTextPaint(
const IntRect& text_visual_rect) { const IntRect& text_visual_rect) {
......
...@@ -1041,6 +1041,8 @@ jumbo_component("platform") { ...@@ -1041,6 +1041,8 @@ jumbo_component("platform") {
"graphics/paint/graphics_layer_display_item.h", "graphics/paint/graphics_layer_display_item.h",
"graphics/paint/hit_test_data.cc", "graphics/paint/hit_test_data.cc",
"graphics/paint/hit_test_data.h", "graphics/paint/hit_test_data.h",
"graphics/paint/ignore_paint_timing_scope.cc",
"graphics/paint/ignore_paint_timing_scope.h",
"graphics/paint/paint_artifact.cc", "graphics/paint/paint_artifact.cc",
"graphics/paint/paint_artifact.h", "graphics/paint/paint_artifact.h",
"graphics/paint/paint_canvas.h", "graphics/paint/paint_canvas.h",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/platform/graphics/paint/ignore_paint_timing_scope.h"
namespace blink {
bool IgnorePaintTimingScope::should_ignore_ = false;
} // namespace blink
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_PAINT_IGNORE_PAINT_TIMING_SCOPE_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_PAINT_IGNORE_PAINT_TIMING_SCOPE_H_
#include "base/auto_reset.h"
#include "third_party/blink/renderer/platform/platform_export.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
namespace blink {
// Creates a scope to ignore paint timing, e.g. when we are painting contents
// under opacity:0.
class PLATFORM_EXPORT IgnorePaintTimingScope {
STACK_ALLOCATED();
public:
IgnorePaintTimingScope() : auto_reset_(&should_ignore_, true) {}
~IgnorePaintTimingScope() = default;
static bool ShouldIgnore() { return should_ignore_; }
private:
base::AutoReset<bool> auto_reset_;
static bool should_ignore_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_PAINT_IGNORE_PAINT_TIMING_SCOPE_H_
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "third_party/blink/renderer/platform/graphics/logging_canvas.h" #include "third_party/blink/renderer/platform/graphics/logging_canvas.h"
#include "third_party/blink/renderer/platform/graphics/paint/drawing_display_item.h" #include "third_party/blink/renderer/platform/graphics/paint/drawing_display_item.h"
#include "third_party/blink/renderer/platform/graphics/paint/ignore_paint_timing_scope.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h" #include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
namespace blink { namespace blink {
...@@ -794,14 +795,17 @@ void PaintController::CheckUnderInvalidation() { ...@@ -794,14 +795,17 @@ void PaintController::CheckUnderInvalidation() {
} }
void PaintController::SetFirstPainted() { void PaintController::SetFirstPainted() {
if (!IgnorePaintTimingScope::ShouldIgnore())
frame_first_paints_.back().first_painted = true; frame_first_paints_.back().first_painted = true;
} }
void PaintController::SetTextPainted() { void PaintController::SetTextPainted() {
if (!IgnorePaintTimingScope::ShouldIgnore())
frame_first_paints_.back().text_painted = true; frame_first_paints_.back().text_painted = true;
} }
void PaintController::SetImagePainted() { void PaintController::SetImagePainted() {
if (!IgnorePaintTimingScope::ShouldIgnore())
frame_first_paints_.back().image_painted = true; frame_first_paints_.back().image_painted = true;
} }
......
...@@ -30,6 +30,11 @@ compositing/overflow/scrolls-with-respect-to-nested.html [ Skip ] ...@@ -30,6 +30,11 @@ compositing/overflow/scrolls-with-respect-to-nested.html [ Skip ]
compositing/overflow/scrolls-with-respect-to-transform.html [ Skip ] compositing/overflow/scrolls-with-respect-to-transform.html [ Skip ]
compositing/overflow/scrolls-with-respect-to.html [ Skip ] compositing/overflow/scrolls-with-respect-to.html [ Skip ]
# We don't repaint when opacity changes from zero to non-zero, so it's not feasible
# to detect that as a first paint. Won't fix.
external/wpt/paint-timing/fcp-only/fcp-opacity.html [ Skip ]
external/wpt/paint-timing/fcp-only/fcp-pseudo-element-opacity.html [ Skip ]
# Can't rebaseline because the file path is too long. # Can't rebaseline because the file path is too long.
virtual/compositor_threaded_scrollbar_scrolling/paint/invalidation/scroll/sticky/invalidate-after-composited-scroll-with-sticky.html [ Skip ] virtual/compositor_threaded_scrollbar_scrolling/paint/invalidation/scroll/sticky/invalidate-after-composited-scroll-with-sticky.html [ Skip ]
...@@ -109,8 +114,3 @@ crbug.com/1041322 virtual/threaded/synthetic_gestures/synthetic-pinch-zoom-gestu ...@@ -109,8 +114,3 @@ crbug.com/1041322 virtual/threaded/synthetic_gestures/synthetic-pinch-zoom-gestu
compositing/gestures/gesture-tapHighlight-composited-img.html [ Pass Failure ] compositing/gestures/gesture-tapHighlight-composited-img.html [ Pass Failure ]
http/tests/images/image-decode-in-frame.html [ Pass Failure ] http/tests/images/image-decode-in-frame.html [ Pass Failure ]
crbug.com/1062984 external/wpt/paint-timing/fcp-only/fcp-opacity-descendant.html [ Failure ]
crbug.com/1062984 external/wpt/paint-timing/fcp-only/fcp-opacity.html [ Failure ]
crbug.com/1062984 external/wpt/paint-timing/fcp-only/fcp-pseudo-element-opacity.html [ Failure ]
crbug.com/1062984 external/wpt/paint-timing/fcp-only/fcp-typographic-pseudo.html [ Failure ]
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