Commit da246e99 authored by Chris Harrelson's avatar Chris Harrelson Committed by Commit Bot

Add an assert to catch more cases where clip, transform or effect nodes are

incorrectly null.

Bug: 811269
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: Ia8f0a8d1ec9c95df5e540cfb66a4310f59e6d97c
Reviewed-on: https://chromium-review.googlesource.com/922391
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Reviewed-by: default avatarvmpstr <vmpstr@chromium.org>
Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537555}
parent 08f7783b
...@@ -26,12 +26,21 @@ ...@@ -26,12 +26,21 @@
#include "core/testing/DummyPageHolder.h" #include "core/testing/DummyPageHolder.h"
#include "platform/graphics/paint/DrawingRecorder.h" #include "platform/graphics/paint/DrawingRecorder.h"
#include "platform/graphics/paint/PaintController.h" #include "platform/graphics/paint/PaintController.h"
#include "platform/testing/FakeDisplayItemClient.h"
#include "platform/wtf/StdLibExtras.h" #include "platform/wtf/StdLibExtras.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace blink { namespace blink {
class FrameSelectionTest : public EditingTestBase { class FrameSelectionTest : public EditingTestBase {
public:
FrameSelectionTest()
: root_paint_property_client_("root"),
root_paint_chunk_id_(root_paint_property_client_,
DisplayItem::kUninitializedType) {}
FakeDisplayItemClient root_paint_property_client_;
PaintChunk::Id root_paint_chunk_id_;
protected: protected:
VisibleSelection VisibleSelectionInDOMTree() const { VisibleSelection VisibleSelectionInDOMTree() const {
return Selection().ComputeVisibleSelectionInDOMTree(); return Selection().ComputeVisibleSelectionInDOMTree();
...@@ -135,6 +144,15 @@ TEST_F(FrameSelectionTest, PaintCaretShouldNotLayout) { ...@@ -135,6 +144,15 @@ TEST_F(FrameSelectionTest, PaintCaretShouldNotLayout) {
std::unique_ptr<PaintController> paint_controller = PaintController::Create(); std::unique_ptr<PaintController> paint_controller = PaintController::Create();
{ {
GraphicsContext context(*paint_controller); GraphicsContext context(*paint_controller);
if (RuntimeEnabledFeatures::SlimmingPaintV175Enabled()) {
paint_controller->UpdateCurrentPaintChunkProperties(
root_paint_chunk_id_,
PaintChunkProperties(PropertyTreeState(
TransformPaintPropertyNode::Root(), ClipPaintPropertyNode::Root(),
EffectPaintPropertyNode::Root())));
}
Selection().PaintCaret(context, LayoutPoint()); Selection().PaintCaret(context, LayoutPoint());
} }
paint_controller->CommitNewDisplayItems(); paint_controller->CommitNewDisplayItems();
......
...@@ -20,6 +20,7 @@ const IntRect kBounds(1, 2, 3, 4); ...@@ -20,6 +20,7 @@ const IntRect kBounds(1, 2, 3, 4);
TEST_F(DrawingRecorderTest, Nothing) { TEST_F(DrawingRecorderTest, Nothing) {
FakeDisplayItemClient client; FakeDisplayItemClient client;
GraphicsContext context(GetPaintController()); GraphicsContext context(GetPaintController());
InitRootChunk();
DrawNothing(context, client, kForegroundType); DrawNothing(context, client, kForegroundType);
GetPaintController().CommitNewDisplayItems(); GetPaintController().CommitNewDisplayItems();
EXPECT_DISPLAY_LIST(GetPaintController().GetDisplayItemList(), 1, EXPECT_DISPLAY_LIST(GetPaintController().GetDisplayItemList(), 1,
...@@ -32,6 +33,7 @@ TEST_F(DrawingRecorderTest, Nothing) { ...@@ -32,6 +33,7 @@ TEST_F(DrawingRecorderTest, Nothing) {
TEST_F(DrawingRecorderTest, Rect) { TEST_F(DrawingRecorderTest, Rect) {
FakeDisplayItemClient client; FakeDisplayItemClient client;
GraphicsContext context(GetPaintController()); GraphicsContext context(GetPaintController());
InitRootChunk();
DrawRect(context, client, kForegroundType, kBounds); DrawRect(context, client, kForegroundType, kBounds);
GetPaintController().CommitNewDisplayItems(); GetPaintController().CommitNewDisplayItems();
EXPECT_DISPLAY_LIST(GetPaintController().GetDisplayItemList(), 1, EXPECT_DISPLAY_LIST(GetPaintController().GetDisplayItemList(), 1,
...@@ -41,6 +43,7 @@ TEST_F(DrawingRecorderTest, Rect) { ...@@ -41,6 +43,7 @@ TEST_F(DrawingRecorderTest, Rect) {
TEST_F(DrawingRecorderTest, Cached) { TEST_F(DrawingRecorderTest, Cached) {
FakeDisplayItemClient client; FakeDisplayItemClient client;
GraphicsContext context(GetPaintController()); GraphicsContext context(GetPaintController());
InitRootChunk();
DrawNothing(context, client, kBackgroundType); DrawNothing(context, client, kBackgroundType);
DrawRect(context, client, kForegroundType, kBounds); DrawRect(context, client, kForegroundType, kBounds);
GetPaintController().CommitNewDisplayItems(); GetPaintController().CommitNewDisplayItems();
...@@ -49,6 +52,7 @@ TEST_F(DrawingRecorderTest, Cached) { ...@@ -49,6 +52,7 @@ TEST_F(DrawingRecorderTest, Cached) {
TestDisplayItem(client, kBackgroundType), TestDisplayItem(client, kBackgroundType),
TestDisplayItem(client, kForegroundType)); TestDisplayItem(client, kForegroundType));
InitRootChunk();
DrawNothing(context, client, kBackgroundType); DrawNothing(context, client, kBackgroundType);
DrawRect(context, client, kForegroundType, kBounds); DrawRect(context, client, kForegroundType, kBounds);
......
...@@ -34,7 +34,7 @@ bool PaintChunker::IncrementDisplayItemIndex(const DisplayItem& item) { ...@@ -34,7 +34,7 @@ bool PaintChunker::IncrementDisplayItemIndex(const DisplayItem& item) {
// properties. See: ScopedPaintChunkProperties. // properties. See: ScopedPaintChunkProperties.
// TODO(trchen): Enable this check for SPv175 too. Some drawable layers // TODO(trchen): Enable this check for SPv175 too. Some drawable layers
// don't paint with property tree yet, e.g. scrollbar layers. // don't paint with property tree yet, e.g. scrollbar layers.
if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::SlimmingPaintV175Enabled()) {
DCHECK(current_properties_.property_tree_state.Transform()); DCHECK(current_properties_.property_tree_state.Transform());
DCHECK(current_properties_.property_tree_state.Clip()); DCHECK(current_properties_.property_tree_state.Clip());
DCHECK(current_properties_.property_tree_state.Effect()); DCHECK(current_properties_.property_tree_state.Effect());
......
...@@ -8,15 +8,23 @@ ...@@ -8,15 +8,23 @@
#include "platform/graphics/paint/ClipRecorder.h" #include "platform/graphics/paint/ClipRecorder.h"
#include "platform/graphics/paint/DrawingRecorder.h" #include "platform/graphics/paint/DrawingRecorder.h"
#include "platform/graphics/paint/PaintController.h" #include "platform/graphics/paint/PaintController.h"
#include "platform/testing/FakeDisplayItemClient.h"
#include "platform/testing/PaintPropertyTestHelpers.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace blink { namespace blink {
class GraphicsContext; class GraphicsContext;
using blink::testing::DefaultPaintChunkProperties;
class PaintControllerTestBase : public ::testing::Test { class PaintControllerTestBase : public ::testing::Test {
public: public:
PaintControllerTestBase() : paint_controller_(PaintController::Create()) {} PaintControllerTestBase()
: root_paint_property_client_("root"),
root_paint_chunk_id_(root_paint_property_client_,
DisplayItem::kUninitializedType),
paint_controller_(PaintController::Create()) {}
static void DrawNothing(GraphicsContext& context, static void DrawNothing(GraphicsContext& context,
const DisplayItemClient& client, const DisplayItemClient& client,
...@@ -37,6 +45,13 @@ class PaintControllerTestBase : public ::testing::Test { ...@@ -37,6 +45,13 @@ class PaintControllerTestBase : public ::testing::Test {
context.DrawRect(RoundedIntRect(FloatRect(bounds))); context.DrawRect(RoundedIntRect(FloatRect(bounds)));
} }
void InitRootChunk() {
if (RuntimeEnabledFeatures::SlimmingPaintV175Enabled()) {
GetPaintController().UpdateCurrentPaintChunkProperties(
root_paint_chunk_id_, DefaultPaintChunkProperties());
}
}
protected: protected:
PaintController& GetPaintController() { return *paint_controller_; } PaintController& GetPaintController() { return *paint_controller_; }
...@@ -62,6 +77,8 @@ class PaintControllerTestBase : public ::testing::Test { ...@@ -62,6 +77,8 @@ class PaintControllerTestBase : public ::testing::Test {
} }
private: private:
FakeDisplayItemClient root_paint_property_client_;
PaintChunk::Id root_paint_chunk_id_;
std::unique_ptr<PaintController> paint_controller_; std::unique_ptr<PaintController> paint_controller_;
}; };
......
...@@ -79,6 +79,7 @@ TEST_F(PaintRecordBuilderTest, LastingPaintController) { ...@@ -79,6 +79,7 @@ TEST_F(PaintRecordBuilderTest, LastingPaintController) {
TEST_F(PaintRecordBuilderTest, TransientAndAnotherPaintController) { TEST_F(PaintRecordBuilderTest, TransientAndAnotherPaintController) {
GraphicsContext context(GetPaintController()); GraphicsContext context(GetPaintController());
InitRootChunk();
FakeDisplayItemClient client("client", LayoutRect(10, 10, 20, 20)); FakeDisplayItemClient client("client", LayoutRect(10, 10, 20, 20));
DrawRect(context, client, kBackgroundType, FloatRect(10, 10, 20, 20)); DrawRect(context, client, kBackgroundType, FloatRect(10, 10, 20, 20));
DrawRect(context, client, kForegroundType, FloatRect(15, 15, 10, 10)); DrawRect(context, client, kForegroundType, FloatRect(15, 15, 10, 10));
......
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