Пример #1
0
// TODO(wangxianzhu): Create a version for slimming paint v2 when it supports interest rect
TEST_F(TableCellPainterTest, TableCellBackgroundInterestRect)
{
    setBodyInnerHTML(
        "<style>"
        "  td { width: 200px; height: 200px; border: none; }"
        "  tr { background-color: blue; }"
        "  table { border: none; border-spacing: 0; border-collapse: collapse; }"
        "</style>"
        "<table>"
        "  <tr><td id='cell1'></td></tr>"
        "  <tr><td id='cell2'></td></tr>"
        "</table>");

    LayoutView& layoutView = *document().layoutView();
    PaintLayer& rootLayer = *layoutView.layer();
    LayoutObject& cell1 = *document().getElementById("cell1")->layoutObject();
    LayoutObject& cell2 = *document().getElementById("cell2")->layoutObject();

    GraphicsContext context(&rootDisplayItemList());
    PaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(0, 0, 200, 200), GlobalPaintNormalPhase, LayoutSize());
    PaintLayerPainter(rootLayer).paintLayerContents(&context, paintingInfo, PaintLayerPaintingCompositingAllPhases);
    rootDisplayItemList().commitNewDisplayItems();

    EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 2,
        TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground),
        TestDisplayItem(cell1, DisplayItem::TableCellBackgroundFromRow));

    PaintLayerPaintingInfo paintingInfo1(&rootLayer, LayoutRect(0, 300, 200, 200), GlobalPaintNormalPhase, LayoutSize());
    PaintLayerPainter(rootLayer).paintLayerContents(&context, paintingInfo1, PaintLayerPaintingCompositingAllPhases);
    rootDisplayItemList().commitNewDisplayItems();

    EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 2,
        TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground),
        TestDisplayItem(cell2, DisplayItem::TableCellBackgroundFromRow));
}
Пример #2
0
TEST_F(PaintControllerPaintTestForSlimmingPaintV2, CompositingFold) {
  setBodyInnerHTML(
      "<div id='div' style='width: 200px; height: 200px; opacity: 0.5'>"
      "  <div style='width: 100px; height: 100px; background-color: "
      "blue'></div>"
      "</div>");
  PaintLayer& htmlLayer =
      *toLayoutBoxModelObject(document().documentElement()->layoutObject())
           ->layer();
  LayoutBlock& div = *toLayoutBlock(getLayoutObjectByElementId("div"));
  LayoutObject& subDiv = *div.firstChild();

  EXPECT_DISPLAY_LIST(
      rootPaintController().getDisplayItemList(), 8,
      TestDisplayItem(layoutView(),
                      DisplayItem::kClipFrameToVisibleContentRect),
      TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence),
      TestDisplayItem(layoutView(), documentBackgroundType),
      TestDisplayItem(htmlLayer, DisplayItem::kSubsequence),
      // The begin and end compositing display items have been folded into this
      // one.
      TestDisplayItem(subDiv, backgroundType),
      TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence),
      TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence),
      TestDisplayItem(layoutView(),
                      DisplayItem::clipTypeToEndClipType(
                          DisplayItem::kClipFrameToVisibleContentRect)));
}
TEST_P(PaintControllerPaintTestForSlimmingPaintV1AndV2, FullDocumentPaintingWithCaret)
{
    setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'>XYZ</div>");
    document().page()->focusController().setActive(true);
    document().page()->focusController().setFocused(true);
    Element& div = *toElement(document().body()->firstChild());
    LayoutObject& divLayoutObject = *document().body()->firstChild()->layoutObject();
    InlineTextBox& textInlineBox = *toLayoutText(div.firstChild()->layoutObject())->firstTextBox();

    EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 2,
        TestDisplayItem(layoutView(), backgroundType),
        TestDisplayItem(textInlineBox, foregroundType));

    div.focus();
    document().view()->updateAllLifecyclePhases();

    EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 3,
        TestDisplayItem(layoutView(), backgroundType),
        TestDisplayItem(textInlineBox, foregroundType),
        TestDisplayItem(divLayoutObject, DisplayItem::Caret)); // New!
}
TEST_F(TableCellPainterTest, TableCellBackgroundInterestRect)
{
    RuntimeEnabledFeatures::setSlimmingPaintSynchronizedPaintingEnabled(true);

    setBodyInnerHTML(
        "<style>"
        "  td { width: 200px; height: 200px; border: none; }"
        "  tr { background-color: blue; }"
        "  table { border: none; border-spacing: 0; border-collapse: collapse; }"
        "</style>"
        "<table>"
        "  <tr><td id='cell1'></td></tr>"
        "  <tr><td id='cell2'></td></tr>"
        "</table>");

    LayoutView& layoutView = *document().layoutView();
    LayoutObject& cell1 = *document().getElementById("cell1")->layoutObject();
    LayoutObject& cell2 = *document().getElementById("cell2")->layoutObject();

    rootPaintController().invalidateAll();
    updateLifecyclePhasesBeforePaint();
    IntRect interestRect(0, 0, 200, 200);
    paint(&interestRect);

    EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 2,
        TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground),
        TestDisplayItem(cell1, DisplayItem::TableCellBackgroundFromRow));

    updateLifecyclePhasesBeforePaint();
    interestRect = IntRect(0, 300, 200, 1000);
    paint(&interestRect);

    EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 2,
        TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground),
        TestDisplayItem(cell2, DisplayItem::TableCellBackgroundFromRow));
}
TEST_P(PaintControllerPaintTestForSlimmingPaintV1AndV2, InlineRelayout)
{
    setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAAA BBBBBBBBBB</div>");
    Element& div = *toElement(document().body()->firstChild());
    LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layoutObject());
    LayoutText& text = *toLayoutText(divBlock.firstChild());
    InlineTextBox& firstTextBox = *text.firstTextBox();

    EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 2,
        TestDisplayItem(layoutView(), backgroundType),
        TestDisplayItem(firstTextBox, foregroundType));

    div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px");
    document().view()->updateAllLifecyclePhases();

    LayoutText& newText = *toLayoutText(divBlock.firstChild());
    InlineTextBox& newFirstTextBox = *newText.firstTextBox();
    InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox();

    EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 3,
        TestDisplayItem(layoutView(), backgroundType),
        TestDisplayItem(newFirstTextBox, foregroundType),
        TestDisplayItem(secondTextBox, foregroundType));
}
TEST_P(PaintLayerPainterTest, CachedSubsequence)
{
    RuntimeEnabledFeatures::setSlimmingPaintSynchronizedPaintingEnabled(true);

    setBodyInnerHTML(
        "<div id='container1' style='position: relative; z-index: 1; width: 200px; height: 200px; background-color: blue'>"
        "  <div id='content1' style='position: absolute; width: 100px; height: 100px; background-color: red'></div>"
        "</div>"
        "<div id='container2' style='position: relative; z-index: 1; width: 200px; height: 200px; background-color: blue'>"
        "  <div id='content2' style='position: absolute; width: 100px; height: 100px; background-color: green'></div>"
        "</div>");
    document().view()->updateAllLifecyclePhases();

    bool rootLayerScrolls = document().frame()->settings()->rootLayerScrolls();
    PaintLayer& rootLayer = *layoutView().layer();
    PaintLayer& htmlLayer = *toLayoutBoxModelObject(document().documentElement()->layoutObject())->layer();
    LayoutObject& container1 = *document().getElementById("container1")->layoutObject();
    PaintLayer& container1Layer = *toLayoutBoxModelObject(container1).layer();
    LayoutObject& content1 = *document().getElementById("content1")->layoutObject();
    LayoutObject& container2 = *document().getElementById("container2")->layoutObject();
    PaintLayer& container2Layer = *toLayoutBoxModelObject(container2).layer();
    LayoutObject& content2 = *document().getElementById("content2")->layoutObject();

    if (rootLayerScrolls) {
        EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 7,
            TestDisplayItem(rootLayer, DisplayItem::Subsequence),
            TestDisplayItem(layoutView(), backgroundType),
            TestDisplayItem(container1, backgroundType),
            TestDisplayItem(content1, backgroundType),
            TestDisplayItem(container2, backgroundType),
            TestDisplayItem(content2, backgroundType),
            TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
    } else {
        EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 13,
            TestDisplayItem(rootLayer, DisplayItem::Subsequence),
            TestDisplayItem(layoutView(), backgroundType),
            TestDisplayItem(htmlLayer, DisplayItem::Subsequence),
            TestDisplayItem(container1Layer, DisplayItem::Subsequence),
            TestDisplayItem(container1, backgroundType),
            TestDisplayItem(content1, backgroundType),
            TestDisplayItem(container1Layer, DisplayItem::EndSubsequence),
            TestDisplayItem(container2Layer, DisplayItem::Subsequence),
            TestDisplayItem(container2, backgroundType),
            TestDisplayItem(content2, backgroundType),
            TestDisplayItem(container2Layer, DisplayItem::EndSubsequence),
            TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence),
            TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
    }

    toHTMLElement(content1.node())->setAttribute(HTMLNames::styleAttr, "position: absolute; width: 100px; height: 100px; background-color: green");
    updateLifecyclePhasesBeforePaint();
    paint();

    if (rootLayerScrolls) {
        EXPECT_DISPLAY_LIST(rootPaintController().newDisplayItemList(), 7,
            TestDisplayItem(rootLayer, DisplayItem::Subsequence),
            TestDisplayItem(layoutView(), cachedBackgroundType),
            TestDisplayItem(container1, cachedBackgroundType),
            TestDisplayItem(content1, backgroundType),
            TestDisplayItem(container2, cachedBackgroundType),
            TestDisplayItem(content2, cachedBackgroundType),
            TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
    } else {
        EXPECT_DISPLAY_LIST(rootPaintController().newDisplayItemList(), 10,
            TestDisplayItem(rootLayer, DisplayItem::Subsequence),
            TestDisplayItem(layoutView(), cachedBackgroundType),
            TestDisplayItem(htmlLayer, DisplayItem::Subsequence),
            TestDisplayItem(container1Layer, DisplayItem::Subsequence),
            TestDisplayItem(container1, cachedBackgroundType),
            TestDisplayItem(content1, backgroundType),
            TestDisplayItem(container1Layer, DisplayItem::EndSubsequence),
            TestDisplayItem(container2Layer, DisplayItem::CachedSubsequence),
            TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence),
            TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
    }

    commit();

    if (rootLayerScrolls) {
        EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 7,
            TestDisplayItem(rootLayer, DisplayItem::Subsequence),
            TestDisplayItem(layoutView(), backgroundType),
            TestDisplayItem(container1, backgroundType),
            TestDisplayItem(content1, backgroundType),
            TestDisplayItem(container2, backgroundType),
            TestDisplayItem(content2, backgroundType),
            TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
    } else {
        EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 13,
            TestDisplayItem(rootLayer, DisplayItem::Subsequence),
            TestDisplayItem(layoutView(), backgroundType),
            TestDisplayItem(htmlLayer, DisplayItem::Subsequence),
            TestDisplayItem(container1Layer, DisplayItem::Subsequence),
            TestDisplayItem(container1, backgroundType),
            TestDisplayItem(content1, backgroundType),
            TestDisplayItem(container1Layer, DisplayItem::EndSubsequence),
            TestDisplayItem(container2Layer, DisplayItem::Subsequence),
            TestDisplayItem(container2, backgroundType),
            TestDisplayItem(content2, backgroundType),
            TestDisplayItem(container2Layer, DisplayItem::EndSubsequence),
            TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence),
            TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
    }
}
TEST_P(PaintLayerPainterTest, CachedSubsequenceOnInterestRectChange)
{
    RuntimeEnabledFeatures::setSlimmingPaintSynchronizedPaintingEnabled(true);

    setBodyInnerHTML(
        "<div id='container1' style='position: relative; z-index: 1; width: 200px; height: 200px; background-color: blue'>"
        "  <div id='content1' style='position: absolute; width: 100px; height: 100px; background-color: green'></div>"
        "</div>"
        "<div id='container2' style='position: relative; z-index: 1; width: 200px; height: 200px; background-color: blue'>"
        "  <div id='content2a' style='position: absolute; width: 100px; height: 100px; background-color: green'></div>"
        "  <div id='content2b' style='position: absolute; top: 200px; width: 100px; height: 100px; background-color: green'></div>"
        "</div>"
        "<div id='container3' style='position: absolute; z-index: 2; left: 300px; top: 0; width: 200px; height: 200px; background-color: blue'>"
        "  <div id='content3' style='position: absolute; width: 200px; height: 200px; background-color: green'></div>"
        "</div>");
    rootPaintController().invalidateAll();

    bool rootLayerScrolls = document().frame()->settings()->rootLayerScrolls();
    PaintLayer& rootLayer = *layoutView().layer();
    PaintLayer& htmlLayer = *toLayoutBoxModelObject(document().documentElement()->layoutObject())->layer();
    LayoutObject& container1 = *document().getElementById("container1")->layoutObject();
    PaintLayer& container1Layer = *toLayoutBoxModelObject(container1).layer();
    LayoutObject& content1 = *document().getElementById("content1")->layoutObject();
    LayoutObject& container2 = *document().getElementById("container2")->layoutObject();
    PaintLayer& container2Layer = *toLayoutBoxModelObject(container2).layer();
    LayoutObject& content2a = *document().getElementById("content2a")->layoutObject();
    LayoutObject& content2b = *document().getElementById("content2b")->layoutObject();
    LayoutObject& container3 = *document().getElementById("container3")->layoutObject();
    PaintLayer& container3Layer = *toLayoutBoxModelObject(container3).layer();
    LayoutObject& content3 = *document().getElementById("content3")->layoutObject();

    updateLifecyclePhasesBeforePaint();
    IntRect interestRect(0, 0, 400, 300);
    paint(&interestRect);
    commit();

    // Container1 is fully in the interest rect;
    // Container2 is partly (including its stacking chidren) in the interest rect;
    // Content2b is out of the interest rect and output nothing;
    // Container3 is partly in the interest rect.
    if (rootLayerScrolls) {
        EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 9,
            TestDisplayItem(rootLayer, DisplayItem::Subsequence),
            TestDisplayItem(layoutView(), backgroundType),
            TestDisplayItem(container1, backgroundType),
            TestDisplayItem(content1, backgroundType),
            TestDisplayItem(container2, backgroundType),
            TestDisplayItem(content2a, backgroundType),
            TestDisplayItem(container3, backgroundType),
            TestDisplayItem(content3, backgroundType),
            TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
    } else {
        EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 17,
            TestDisplayItem(rootLayer, DisplayItem::Subsequence),
            TestDisplayItem(layoutView(), backgroundType),
            TestDisplayItem(htmlLayer, DisplayItem::Subsequence),
            TestDisplayItem(container1Layer, DisplayItem::Subsequence),
            TestDisplayItem(container1, backgroundType),
            TestDisplayItem(content1, backgroundType),
            TestDisplayItem(container1Layer, DisplayItem::EndSubsequence),
            TestDisplayItem(container2Layer, DisplayItem::Subsequence),
            TestDisplayItem(container2, backgroundType),
            TestDisplayItem(content2a, backgroundType),
            TestDisplayItem(container2Layer, DisplayItem::EndSubsequence),
            TestDisplayItem(container3Layer, DisplayItem::Subsequence),
            TestDisplayItem(container3, backgroundType),
            TestDisplayItem(content3, backgroundType),
            TestDisplayItem(container3Layer, DisplayItem::EndSubsequence),
            TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence),
            TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
    }

    updateLifecyclePhasesBeforePaint();
    IntRect newInterestRect(0, 100, 300, 1000);
    paint(&newInterestRect);

    // Container1 becomes partly in the interest rect, but uses cached subsequence
    // because it was fully painted before;
    // Container2's intersection with the interest rect changes;
    // Content2b is out of the interest rect and outputs nothing;
    // Container3 becomes out of the interest rect and outputs nothing.

    if (rootLayerScrolls) {
        EXPECT_DISPLAY_LIST(rootPaintController().newDisplayItemList(), 8,
            TestDisplayItem(rootLayer, DisplayItem::Subsequence),
            TestDisplayItem(layoutView(), cachedBackgroundType),
            TestDisplayItem(container1, cachedBackgroundType),
            TestDisplayItem(content1, cachedBackgroundType),
            TestDisplayItem(container2, cachedBackgroundType),
            TestDisplayItem(content2a, cachedBackgroundType),
            TestDisplayItem(content2b, backgroundType),
            TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
    } else {
        EXPECT_DISPLAY_LIST(rootPaintController().newDisplayItemList(), 11,
            TestDisplayItem(rootLayer, DisplayItem::Subsequence),
            TestDisplayItem(layoutView(), cachedBackgroundType),
            TestDisplayItem(htmlLayer, DisplayItem::Subsequence),
            TestDisplayItem(container1Layer, DisplayItem::CachedSubsequence),
            TestDisplayItem(container2Layer, DisplayItem::Subsequence),
            TestDisplayItem(container2, cachedBackgroundType),
            TestDisplayItem(content2a, cachedBackgroundType),
            TestDisplayItem(content2b, backgroundType),
            TestDisplayItem(container2Layer, DisplayItem::EndSubsequence),
            TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence),
            TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
    }

    commit();

    if (rootLayerScrolls) {
        EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 8,
            TestDisplayItem(rootLayer, DisplayItem::Subsequence),
            TestDisplayItem(layoutView(), backgroundType),
            TestDisplayItem(container1, backgroundType),
            TestDisplayItem(content1, backgroundType),
            TestDisplayItem(container2, backgroundType),
            TestDisplayItem(content2a, backgroundType),
            TestDisplayItem(content2b, backgroundType),
            TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
    } else {
        EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 14,
            TestDisplayItem(rootLayer, DisplayItem::Subsequence),
            TestDisplayItem(layoutView(), backgroundType),
            TestDisplayItem(htmlLayer, DisplayItem::Subsequence),
            TestDisplayItem(container1Layer, DisplayItem::Subsequence),
            TestDisplayItem(container1, backgroundType),
            TestDisplayItem(content1, backgroundType),
            TestDisplayItem(container1Layer, DisplayItem::EndSubsequence),
            TestDisplayItem(container2Layer, DisplayItem::Subsequence),
            TestDisplayItem(container2, backgroundType),
            TestDisplayItem(content2a, backgroundType),
            TestDisplayItem(content2b, backgroundType),
            TestDisplayItem(container2Layer, DisplayItem::EndSubsequence),
            TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence),
            TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
    }
}
Пример #8
0
TEST_P(PaintControllerPaintTestForSlimmingPaintV1AndV2, InlineRelayout) {
  setBodyInnerHTML(
      "<div id='div' style='width:100px; height: 200px'>AAAAAAAAAA "
      "BBBBBBBBBB</div>");
  Element& div = *toElement(document().body()->firstChild());
  LayoutBlock& divBlock =
      *toLayoutBlock(document().body()->firstChild()->layoutObject());
  LayoutText& text = *toLayoutText(divBlock.firstChild());
  InlineTextBox& firstTextBox = *text.firstTextBox();

  if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
    EXPECT_DISPLAY_LIST(
        rootPaintController().getDisplayItemList(), 6,
        TestDisplayItem(layoutView(),
                        DisplayItem::kClipFrameToVisibleContentRect),
        TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence),
        TestDisplayItem(layoutView(), documentBackgroundType),
        TestDisplayItem(firstTextBox, foregroundType),
        TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence),
        TestDisplayItem(layoutView(),
                        DisplayItem::clipTypeToEndClipType(
                            DisplayItem::kClipFrameToVisibleContentRect)));
  } else {
    EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 2,
                        TestDisplayItem(layoutView(), documentBackgroundType),
                        TestDisplayItem(firstTextBox, foregroundType));
  }

  div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px");
  document().view()->updateAllLifecyclePhases();

  LayoutText& newText = *toLayoutText(divBlock.firstChild());
  InlineTextBox& newFirstTextBox = *newText.firstTextBox();
  InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox();

  if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
    EXPECT_DISPLAY_LIST(
        rootPaintController().getDisplayItemList(), 7,
        TestDisplayItem(layoutView(),
                        DisplayItem::kClipFrameToVisibleContentRect),
        TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence),
        TestDisplayItem(layoutView(), documentBackgroundType),
        TestDisplayItem(newFirstTextBox, foregroundType),
        TestDisplayItem(secondTextBox, foregroundType),
        TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence),
        TestDisplayItem(layoutView(),
                        DisplayItem::clipTypeToEndClipType(
                            DisplayItem::kClipFrameToVisibleContentRect)));
  } else {
    EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 3,
                        TestDisplayItem(layoutView(), documentBackgroundType),
                        TestDisplayItem(newFirstTextBox, foregroundType),
                        TestDisplayItem(secondTextBox, foregroundType));
  }
}
Пример #9
0
TEST_P(PaintControllerPaintTestForSlimmingPaintV1AndV2,
       FullDocumentPaintingWithCaret) {
  setBodyInnerHTML(
      "<div id='div' contentEditable='true' style='outline:none'>XYZ</div>");
  document().page()->focusController().setActive(true);
  document().page()->focusController().setFocused(true);
  Element& div = *toElement(document().body()->firstChild());
  InlineTextBox& textInlineBox =
      *toLayoutText(div.firstChild()->layoutObject())->firstTextBox();

  if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
    EXPECT_DISPLAY_LIST(
        rootPaintController().getDisplayItemList(), 6,
        TestDisplayItem(layoutView(),
                        DisplayItem::kClipFrameToVisibleContentRect),
        TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence),
        TestDisplayItem(layoutView(), documentBackgroundType),
        TestDisplayItem(textInlineBox, foregroundType),
        TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence),
        TestDisplayItem(layoutView(),
                        DisplayItem::clipTypeToEndClipType(
                            DisplayItem::kClipFrameToVisibleContentRect)));
  } else {
    EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 2,
                        TestDisplayItem(layoutView(), documentBackgroundType),
                        TestDisplayItem(textInlineBox, foregroundType));
  }

  div.focus();
  document().view()->updateAllLifecyclePhases();

  if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
    EXPECT_DISPLAY_LIST(
        rootPaintController().getDisplayItemList(), 7,
        TestDisplayItem(layoutView(),
                        DisplayItem::kClipFrameToVisibleContentRect),
        TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence),
        TestDisplayItem(layoutView(), documentBackgroundType),
        TestDisplayItem(textInlineBox, foregroundType),
        TestDisplayItem(*document().frame()->selection().m_frameCaret,
                        DisplayItem::kCaret),  // New!
        TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence),
        TestDisplayItem(layoutView(),
                        DisplayItem::clipTypeToEndClipType(
                            DisplayItem::kClipFrameToVisibleContentRect)));
  } else {
    EXPECT_DISPLAY_LIST(
        rootPaintController().getDisplayItemList(), 3,
        TestDisplayItem(layoutView(), documentBackgroundType),
        TestDisplayItem(textInlineBox, foregroundType),
        TestDisplayItem(*document().frame()->selection().m_frameCaret,
                        DisplayItem::kCaret));  // New!
  }
}
Пример #10
0
TEST_F(PaintControllerPaintTestForSlimmingPaintV2, ChunkIdClientCacheFlag) {
  setBodyInnerHTML(
      "<div id='div' style='width: 200px; height: 200px; opacity: 0.5'>"
      "  <div style='width: 100px; height: 100px; background-color: "
      "blue'></div>"
      "  <div style='width: 100px; height: 100px; background-color: "
      "blue'></div>"
      "</div>");
  PaintLayer& htmlLayer =
      *toLayoutBoxModelObject(document().documentElement()->layoutObject())
           ->layer();
  LayoutBlock& div = *toLayoutBlock(getLayoutObjectByElementId("div"));
  LayoutObject& subDiv = *div.firstChild();
  LayoutObject& subDiv2 = *subDiv.nextSibling();
  EXPECT_DISPLAY_LIST(
      rootPaintController().getDisplayItemList(), 11,
      TestDisplayItem(layoutView(),
                      DisplayItem::kClipFrameToVisibleContentRect),
      TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence),
      TestDisplayItem(layoutView(), documentBackgroundType),
      TestDisplayItem(htmlLayer, DisplayItem::kSubsequence),
      TestDisplayItem(div, DisplayItem::kBeginCompositing),
      TestDisplayItem(subDiv, backgroundType),
      TestDisplayItem(subDiv2, backgroundType),
      TestDisplayItem(div, DisplayItem::kEndCompositing),
      TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence),
      TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence),
      TestDisplayItem(layoutView(),
                      DisplayItem::clipTypeToEndClipType(
                          DisplayItem::kClipFrameToVisibleContentRect)));

  const PaintChunk& backgroundChunk = rootPaintController().paintChunks()[0];
  EXPECT_TRUE(backgroundChunk.properties.scroll->isRoot());

  const EffectPaintPropertyNode* effectNode = div.paintProperties()->effect();
  EXPECT_EQ(0.5f, effectNode->opacity());
  const PaintChunk& chunk = rootPaintController().paintChunks()[1];
  EXPECT_EQ(*div.layer(), chunk.id->client);
  EXPECT_EQ(effectNode, chunk.properties.effect.get());

  EXPECT_FALSE(div.layer()->isJustCreated());
  // Client used by only paint chunks and non-cachaeable display items but not
  // by any cacheable display items won't be marked as validly cached.
  EXPECT_FALSE(rootPaintController().clientCacheIsValid(*div.layer()));
  EXPECT_FALSE(rootPaintController().clientCacheIsValid(div));
  EXPECT_TRUE(rootPaintController().clientCacheIsValid(subDiv));
}
TEST_P(PaintControllerPaintTestForSlimmingPaintV1AndV2, InlineRelayout)
{
    setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAAA BBBBBBBBBB</div>");
    PaintLayer& rootLayer = *layoutView().layer();
    Element& div = *toElement(document().body()->firstChild());
    LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layoutObject());
    LayoutText& text = *toLayoutText(divBlock.firstChild());
    InlineTextBox& firstTextBox = *text.firstTextBox();

    if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) {
        EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 4,
            TestDisplayItem(rootLayer, DisplayItem::Subsequence),
            TestDisplayItem(layoutView(), backgroundType),
            TestDisplayItem(firstTextBox, foregroundType),
            TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
    } else {
        GraphicsContext context(rootPaintController());
        PaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(0, 0, 800, 600), GlobalPaintNormalPhase, LayoutSize());
        PaintLayerPainter(rootLayer).paintLayerContents(&context, paintingInfo, PaintLayerPaintingCompositingAllPhases);
        rootPaintController().commitNewDisplayItems();

        EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 2,
            TestDisplayItem(layoutView(), backgroundType),
            TestDisplayItem(firstTextBox, foregroundType));
    }

    div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px");
    document().view()->updateAllLifecyclePhases();

    LayoutText& newText = *toLayoutText(divBlock.firstChild());
    InlineTextBox& newFirstTextBox = *newText.firstTextBox();
    InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox();

    if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) {
        EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 5,
            TestDisplayItem(rootLayer, DisplayItem::Subsequence),
            TestDisplayItem(layoutView(), backgroundType),
            TestDisplayItem(newFirstTextBox, foregroundType),
            TestDisplayItem(secondTextBox, foregroundType),
            TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
    } else {
        GraphicsContext context(rootPaintController());
        PaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(0, 0, 800, 600), GlobalPaintNormalPhase, LayoutSize());
        PaintLayerPainter(rootLayer).paintLayerContents(&context, paintingInfo, PaintLayerPaintingCompositingAllPhases);
        rootPaintController().commitNewDisplayItems();

        EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 3,
            TestDisplayItem(layoutView(), backgroundType),
            TestDisplayItem(newFirstTextBox, foregroundType),
            TestDisplayItem(secondTextBox, foregroundType));
    }
}
TEST_P(PaintControllerPaintTestForSlimmingPaintV1AndV2, FullDocumentPaintingWithCaret)
{
    setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'>XYZ</div>");
    document().page()->focusController().setActive(true);
    document().page()->focusController().setFocused(true);
    PaintLayer& rootLayer = *layoutView().layer();
    Element& div = *toElement(document().body()->firstChild());
    LayoutObject& divLayoutObject = *document().body()->firstChild()->layoutObject();
    InlineTextBox& textInlineBox = *toLayoutText(div.firstChild()->layoutObject())->firstTextBox();

    if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) {
        EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 4,
            TestDisplayItem(rootLayer, DisplayItem::Subsequence),
            TestDisplayItem(layoutView(), backgroundType),
            TestDisplayItem(textInlineBox, foregroundType),
            TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
    } else {
        GraphicsContext context(rootPaintController());
        PaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(0, 0, 800, 600), GlobalPaintNormalPhase, LayoutSize());
        PaintLayerPainter(rootLayer).paintLayerContents(&context, paintingInfo, PaintLayerPaintingCompositingAllPhases);
        rootPaintController().commitNewDisplayItems();

        EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 2,
            TestDisplayItem(layoutView(), backgroundType),
            TestDisplayItem(textInlineBox, foregroundType));
    }

    div.focus();
    document().view()->updateAllLifecyclePhases();

    if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) {
        EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 5,
            TestDisplayItem(rootLayer, DisplayItem::Subsequence),
            TestDisplayItem(layoutView(), backgroundType),
            TestDisplayItem(textInlineBox, foregroundType),
            TestDisplayItem(divLayoutObject, DisplayItem::Caret), // New!
            TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
    } else {
        GraphicsContext context(rootPaintController());
        PaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(0, 0, 800, 600), GlobalPaintNormalPhase, LayoutSize());
        PaintLayerPainter(rootLayer).paintLayerContents(&context, paintingInfo, PaintLayerPaintingCompositingAllPhases);
        rootPaintController().commitNewDisplayItems();

        EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 3,
            TestDisplayItem(layoutView(), backgroundType),
            TestDisplayItem(textInlineBox, foregroundType),
            TestDisplayItem(divLayoutObject, DisplayItem::Caret)); // New!
    }
}