Commit 4f899bbe authored by Christian Biesinger's avatar Christian Biesinger Committed by Commit Bot

[layoutng] Get the DisplayItem id from the paint fragment

If there's a paint fragment, we're using it to paint, so we need
to get the ID from that, not from the LayoutObject.

Fixes 3 unit tests in paint_layer_painter_test.

R=chrishtr@chromium.org, kojii@chromium.org

Change-Id: Ieb3066e5a52c8b4ecdda20aa2226f5df6f32e7b4
Reviewed-on: https://chromium-review.googlesource.com/c/1338380
Commit-Queue: Christian Biesinger <cbiesinger@chromium.org>
Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608520}
parent 50ab16b8
...@@ -81,14 +81,21 @@ TEST_P(PaintLayerPainterTest, CachedSubsequence) { ...@@ -81,14 +81,21 @@ TEST_P(PaintLayerPainterTest, CachedSubsequence) {
auto& filler2 = *GetLayoutObjectByElementId("filler2"); auto& filler2 = *GetLayoutObjectByElementId("filler2");
const auto& view_client = ViewScrollingBackgroundClient(); const auto& view_client = ViewScrollingBackgroundClient();
EXPECT_THAT(RootPaintController().GetDisplayItemList(), EXPECT_THAT(
ElementsAre(IsSameId(&view_client, kDocumentBackgroundType), RootPaintController().GetDisplayItemList(),
IsSameId(&container1, kBackgroundType), ElementsAre(IsSameId(&view_client, kDocumentBackgroundType),
IsSameId(&content1, kBackgroundType), IsSameId(GetDisplayItemClientFromLayoutObject(&container1),
IsSameId(&filler1, kBackgroundType), kBackgroundType),
IsSameId(&container2, kBackgroundType), IsSameId(GetDisplayItemClientFromLayoutObject(&content1),
IsSameId(&content2, kBackgroundType), kBackgroundType),
IsSameId(&filler2, kBackgroundType))); IsSameId(GetDisplayItemClientFromLayoutObject(&filler1),
kBackgroundType),
IsSameId(GetDisplayItemClientFromLayoutObject(&container2),
kBackgroundType),
IsSameId(GetDisplayItemClientFromLayoutObject(&content2),
kBackgroundType),
IsSameId(GetDisplayItemClientFromLayoutObject(&filler2),
kBackgroundType)));
auto* container1_layer = ToLayoutBoxModelObject(container1).Layer(); auto* container1_layer = ToLayoutBoxModelObject(container1).Layer();
auto* filler1_layer = ToLayoutBoxModelObject(filler1).Layer(); auto* filler1_layer = ToLayoutBoxModelObject(filler1).Layer();
...@@ -143,14 +150,21 @@ TEST_P(PaintLayerPainterTest, CachedSubsequence) { ...@@ -143,14 +150,21 @@ TEST_P(PaintLayerPainterTest, CachedSubsequence) {
CommitAndFinishCycle(); CommitAndFinishCycle();
EXPECT_THAT(RootPaintController().GetDisplayItemList(), EXPECT_THAT(
ElementsAre(IsSameId(&view_client, kDocumentBackgroundType), RootPaintController().GetDisplayItemList(),
IsSameId(&container1, kBackgroundType), ElementsAre(IsSameId(&view_client, kDocumentBackgroundType),
IsSameId(&content1, kBackgroundType), IsSameId(GetDisplayItemClientFromLayoutObject(&container1),
IsSameId(&filler1, kBackgroundType), kBackgroundType),
IsSameId(&container2, kBackgroundType), IsSameId(GetDisplayItemClientFromLayoutObject(&content1),
IsSameId(&content2, kBackgroundType), kBackgroundType),
IsSameId(&filler2, kBackgroundType))); IsSameId(GetDisplayItemClientFromLayoutObject(&filler1),
kBackgroundType),
IsSameId(GetDisplayItemClientFromLayoutObject(&container2),
kBackgroundType),
IsSameId(GetDisplayItemClientFromLayoutObject(&content2),
kBackgroundType),
IsSameId(GetDisplayItemClientFromLayoutObject(&filler2),
kBackgroundType)));
// We should still have the paint chunks forced by the cached subsequences. // We should still have the paint chunks forced by the cached subsequences.
check_chunks(); check_chunks();
...@@ -184,20 +198,18 @@ TEST_P(PaintLayerPainterTest, CachedSubsequenceOnInterestRectChange) { ...@@ -184,20 +198,18 @@ TEST_P(PaintLayerPainterTest, CachedSubsequenceOnInterestRectChange) {
)HTML"); )HTML");
InvalidateAll(RootPaintController()); InvalidateAll(RootPaintController());
LayoutObject& container1 = DisplayItemClient& container1 =
*GetDocument().getElementById("container1")->GetLayoutObject(); *GetDisplayItemClientFromElementId("container1");
LayoutObject& content1 = DisplayItemClient& content1 = *GetDisplayItemClientFromElementId("content1");
*GetDocument().getElementById("content1")->GetLayoutObject(); DisplayItemClient& container2 =
LayoutObject& container2 = *GetDisplayItemClientFromElementId("container2");
*GetDocument().getElementById("container2")->GetLayoutObject(); DisplayItemClient& content2a =
LayoutObject& content2a = *GetDisplayItemClientFromElementId("content2a");
*GetDocument().getElementById("content2a")->GetLayoutObject(); DisplayItemClient& content2b =
LayoutObject& content2b = *GetDisplayItemClientFromElementId("content2b");
*GetDocument().getElementById("content2b")->GetLayoutObject(); DisplayItemClient& container3 =
LayoutObject& container3 = *GetDisplayItemClientFromElementId("container3");
*GetDocument().getElementById("container3")->GetLayoutObject(); DisplayItemClient& content3 = *GetDisplayItemClientFromElementId("content3");
LayoutObject& content3 =
*GetDocument().getElementById("content3")->GetLayoutObject();
GetDocument().View()->UpdateAllLifecyclePhasesExceptPaint(); GetDocument().View()->UpdateAllLifecyclePhasesExceptPaint();
IntRect interest_rect(0, 0, 400, 300); IntRect interest_rect(0, 0, 400, 300);
...@@ -286,14 +298,12 @@ TEST_P(PaintLayerPainterTest, ...@@ -286,14 +298,12 @@ TEST_P(PaintLayerPainterTest,
IntRect interest_rect(0, 0, 50, 300); IntRect interest_rect(0, 0, 50, 300);
Paint(&interest_rect); Paint(&interest_rect);
LayoutObject& container1 = DisplayItemClient& container1 =
*GetDocument().getElementById("container1")->GetLayoutObject(); *GetDisplayItemClientFromElementId("container1");
LayoutObject& content1 = DisplayItemClient& content1 = *GetDisplayItemClientFromElementId("content1");
*GetDocument().getElementById("content1")->GetLayoutObject(); DisplayItemClient& container2 =
LayoutObject& container2 = *GetDisplayItemClientFromElementId("container2");
*GetDocument().getElementById("container2")->GetLayoutObject(); DisplayItemClient& content2 = *GetDisplayItemClientFromElementId("content2");
LayoutObject& content2 =
*GetDocument().getElementById("content2")->GetLayoutObject();
const auto& background_display_item_client = ViewScrollingBackgroundClient(); const auto& background_display_item_client = ViewScrollingBackgroundClient();
EXPECT_THAT(RootPaintController().GetDisplayItemList(), EXPECT_THAT(RootPaintController().GetDisplayItemList(),
...@@ -304,7 +314,7 @@ TEST_P(PaintLayerPainterTest, ...@@ -304,7 +314,7 @@ TEST_P(PaintLayerPainterTest,
IsSameId(&container2, kBackgroundType), IsSameId(&container2, kBackgroundType),
IsSameId(&content2, kBackgroundType))); IsSameId(&content2, kBackgroundType)));
ToHTMLElement(content1.GetNode()) ToHTMLElement(GetElementById("content1"))
->setAttribute(html_names::kStyleAttr, ->setAttribute(html_names::kStyleAttr,
"position: absolute; width: 100px; height: 100px; " "position: absolute; width: 100px; height: 100px; "
"background-color: green"); "background-color: green");
......
...@@ -14,7 +14,9 @@ ...@@ -14,7 +14,9 @@
#include "third_party/blink/renderer/core/frame/settings.h" #include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/html/html_element.h" #include "third_party/blink/renderer/core/html/html_element.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/layout/ng/layout_ng_block_flow.h"
#include "third_party/blink/renderer/core/loader/empty_clients.h" #include "third_party/blink/renderer/core/loader/empty_clients.h"
#include "third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h" #include "third_party/blink/renderer/core/testing/page_test_base.h"
#include "third_party/blink/renderer/core/testing/use_mock_scrollbar_settings.h" #include "third_party/blink/renderer/core/testing/use_mock_scrollbar_settings.h"
#include "third_party/blink/renderer/platform/wtf/allocator.h" #include "third_party/blink/renderer/platform/wtf/allocator.h"
...@@ -117,6 +119,18 @@ class RenderingTest : public PageTestBase, public UseMockScrollbarSettings { ...@@ -117,6 +119,18 @@ class RenderingTest : public PageTestBase, public UseMockScrollbarSettings {
return ToLayoutBoxModelObject(GetLayoutObjectByElementId(id))->Layer(); return ToLayoutBoxModelObject(GetLayoutObjectByElementId(id))->Layer();
} }
DisplayItemClient* GetDisplayItemClientFromLayoutObject(
LayoutObject* obj) const {
LayoutNGBlockFlow* block_flow = ToLayoutNGBlockFlowOrNull(obj);
if (block_flow && block_flow->PaintFragment())
return block_flow->PaintFragment();
return obj;
}
DisplayItemClient* GetDisplayItemClientFromElementId(const char* id) const {
return GetDisplayItemClientFromLayoutObject(GetLayoutObjectByElementId(id));
}
private: private:
Persistent<LocalFrameClient> local_frame_client_; Persistent<LocalFrameClient> local_frame_client_;
}; };
......
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