Commit 8588ee35 authored by Christian Biesinger's avatar Christian Biesinger Committed by Commit Bot

[layoutng] Fix TextPainterTest and PaintPropertyTreeBuilderTest

When enabling printing, we re-attach the layout objects, and so we
need to update the various layout object variables before accessing them.

R=ikilpatrick@chromium.org

Change-Id: I770621242d5c29762081a25b2699ffb46320597c
Reviewed-on: https://chromium-review.googlesource.com/c/1331607
Commit-Queue: Christian Biesinger <cbiesinger@chromium.org>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607321}
parent 5e499839
......@@ -937,6 +937,10 @@ TEST_P(PaintAndRasterInvalidationTest, UpdateVisualRectWhenPrinting) {
FloatSize page_size(400, 200);
GetFrame().StartPrinting(page_size, page_size, 1);
GetDocument().View()->UpdateLifecyclePhasesForPrinting();
// In LayoutNG these may be different layout objects, so get them again
a = GetDocument().getElementById("a")->GetLayoutObject();
b = GetDocument().getElementById("b")->GetLayoutObject();
c = GetDocument().getElementById("c")->GetLayoutObject();
EXPECT_EQ(LayoutRect(0, 0, 150, 20), a->FirstFragment().VisualRect());
EXPECT_EQ(LayoutRect(150, 0, 150, 20), b->FirstFragment().VisualRect());
......@@ -945,6 +949,9 @@ TEST_P(PaintAndRasterInvalidationTest, UpdateVisualRectWhenPrinting) {
GetFrame().EndPrinting();
GetDocument().View()->UpdateLifecyclePhasesForPrinting();
a = GetDocument().getElementById("a")->GetLayoutObject();
b = GetDocument().getElementById("b")->GetLayoutObject();
c = GetDocument().getElementById("c")->GetLayoutObject();
EXPECT_EQ(LayoutRect(0, 0, 150, 20), a->FirstFragment().VisualRect());
EXPECT_EQ(LayoutRect(150, 0, 150, 20), b->FirstFragment().VisualRect());
......
......@@ -5841,6 +5841,9 @@ TEST_P(PaintPropertyTreeBuilderTest, RepeatingFixedPositionInPagedMedia) {
FloatSize page_size(300, 400);
GetFrame().StartPrinting(page_size, page_size, 1);
GetDocument().View()->UpdateLifecyclePhasesForPrinting();
fixed = GetLayoutObjectByElementId("fixed");
fixed_child = GetLayoutObjectByElementId("fixed-child");
normal = GetLayoutObjectByElementId("normal");
// "fixed" should create fragments to repeat in each printed page.
EXPECT_TRUE(fixed->IsFixedPositionObjectInPagedMedia());
......@@ -5864,6 +5867,9 @@ TEST_P(PaintPropertyTreeBuilderTest, RepeatingFixedPositionInPagedMedia) {
GetFrame().EndPrinting();
UpdateAllLifecyclePhasesForTest();
fixed = GetLayoutObjectByElementId("fixed");
fixed_child = GetLayoutObjectByElementId("fixed-child");
normal = GetLayoutObjectByElementId("normal");
EXPECT_EQ(1u, NumFragments(fixed));
EXPECT_FALSE(fixed_child->IsFixedPositionObjectInPagedMedia());
EXPECT_EQ(1u, NumFragments(fixed_child));
......@@ -5894,6 +5900,8 @@ TEST_P(PaintPropertyTreeBuilderTest,
FloatSize page_size(300, 400);
GetFrame().StartPrinting(page_size, page_size, 1);
GetDocument().View()->UpdateLifecyclePhasesForPrinting();
fixed = GetLayoutObjectByElementId("fixed");
fixed_child = GetLayoutObjectByElementId("fixed-child");
// "fixed" should create fragments to repeat in each printed page.
EXPECT_TRUE(fixed->IsFixedPositionObjectInPagedMedia());
......@@ -5922,6 +5930,8 @@ TEST_P(PaintPropertyTreeBuilderTest,
GetFrame().EndPrinting();
UpdateAllLifecyclePhasesForTest();
fixed = GetLayoutObjectByElementId("fixed");
fixed_child = GetLayoutObjectByElementId("fixed-child");
EXPECT_EQ(1u, NumFragments(fixed));
EXPECT_FALSE(fixed_child->IsFixedPositionObjectInPagedMedia());
EXPECT_EQ(1u, NumFragments(fixed_child));
......@@ -5962,6 +5972,9 @@ TEST_P(PaintPropertyTreeBuilderTest, RepeatingTableSectionInPagedMedia) {
FloatSize page_size(300, 400);
GetFrame().StartPrinting(page_size, page_size, 1);
GetDocument().View()->UpdateLifecyclePhasesForPrinting();
// In LayoutNG, these may be different objects
head = ToLayoutTableSection(GetLayoutObjectByElementId("head"));
foot = ToLayoutTableSection(GetLayoutObjectByElementId("foot"));
// "fixed" should create fragments to repeat in each printed page.
EXPECT_TRUE(head->IsRepeatingHeaderGroup());
......@@ -5996,6 +6009,8 @@ TEST_P(PaintPropertyTreeBuilderTest, RepeatingTableSectionInPagedMedia) {
GetFrame().EndPrinting();
UpdateAllLifecyclePhasesForTest();
head = ToLayoutTableSection(GetLayoutObjectByElementId("head"));
foot = ToLayoutTableSection(GetLayoutObjectByElementId("foot"));
EXPECT_FALSE(head->IsRepeatingHeaderGroup());
EXPECT_EQ(1u, NumFragments(head));
EXPECT_EQ(1u, NumFragments(head->FirstRow()));
......
......@@ -38,10 +38,13 @@ class TextPainterTest : public RenderingTest {
is_printing ? kGlobalPaintPrinting : kGlobalPaintNormalPhase, 0);
}
private:
protected:
void SetUp() override {
RenderingTest::SetUp();
SetBodyInnerHTML("Hello world");
UpdateLayoutText();
}
void UpdateLayoutText() {
layout_text_ =
ToLayoutText(GetDocument().body()->firstChild()->GetLayoutObject());
ASSERT_TRUE(layout_text_);
......@@ -135,6 +138,9 @@ TEST_F(TextPainterTest,
FloatSize page_size(500, 800);
GetFrame().StartPrinting(page_size, page_size, 1);
UpdateAllLifecyclePhasesForTest();
// In LayoutNG, printing currently forces layout tree reattachment,
// so we need to re-get layout_text_.
UpdateLayoutText();
TextPaintStyle text_style = TextPainter::TextPaintingStyle(
GetLineLayoutText().GetDocument(), GetLineLayoutText().StyleRef(),
......@@ -157,6 +163,9 @@ TEST_F(TextPainterTest, TextPaintingStyle_ForceBackgroundToWhite_Darkened) {
FloatSize page_size(500, 800);
GetFrame().StartPrinting(page_size, page_size, 1);
GetDocument().View()->UpdateLifecyclePhasesForPrinting();
// In LayoutNG, printing currently forces layout tree reattachment,
// so we need to re-get layout_text_.
UpdateLayoutText();
TextPaintStyle text_style = TextPainter::TextPaintingStyle(
GetLineLayoutText().GetDocument(), GetLineLayoutText().StyleRef(),
......
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