Esempio n. 1
0
TEST_F(VisualRectMappingTest, LayoutText) {
  setBodyInnerHTML(
      "<style>body { margin: 0; }</style>"
      "<div id='container' style='overflow: scroll; width: 50px; height: 50px'>"
      "  <span><img style='width: 20px; height: 100px'></span>"
      "  text text text text text text text"
      "</div>");

  LayoutBlock* container =
      toLayoutBlock(getLayoutObjectByElementId("container"));
  LayoutText* text = toLayoutText(container->lastChild());

  container->setScrollTop(LayoutUnit(50));
  LayoutRect originalRect(0, 60, 20, 80);
  LayoutRect rect = originalRect;
  EXPECT_TRUE(text->mapToVisualRectInAncestorSpace(container, rect));
  rect.move(-container->scrolledContentOffset());
  EXPECT_EQ(rect, LayoutRect(0, 10, 20, 80));

  rect = originalRect;
  EXPECT_TRUE(text->mapToVisualRectInAncestorSpace(&layoutView(), rect));
  EXPECT_EQ(rect, LayoutRect(0, 10, 20, 40));
  checkPaintInvalidationStateRectMapping(rect, originalRect, *text,
                                         layoutView(), layoutView());

  rect = LayoutRect(0, 60, 80, 0);
  EXPECT_TRUE(
      text->mapToVisualRectInAncestorSpace(container, rect, EdgeInclusive));
  rect.move(-container->scrolledContentOffset());
  EXPECT_EQ(rect, LayoutRect(0, 10, 80, 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)));
}
Esempio n. 3
0
TEST_F(VisualRectMappingTest, LayoutInline) {
  document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com"));
  setBodyInnerHTML(
      "<style>body { margin: 0; }</style>"
      "<div id='container' style='overflow: scroll; width: 50px; height: 50px'>"
      "  <span><img style='width: 20px; height: 100px'></span>"
      "  <span id=leaf></span></div>");

  LayoutBlock* container =
      toLayoutBlock(getLayoutObjectByElementId("container"));
  LayoutObject* leaf = container->lastChild();

  container->setScrollTop(LayoutUnit(50));
  LayoutRect originalRect(0, 60, 20, 80);
  LayoutRect rect = originalRect;
  EXPECT_TRUE(leaf->mapToVisualRectInAncestorSpace(container, rect));
  rect.move(-container->scrolledContentOffset());
  EXPECT_EQ(rect, LayoutRect(0, 10, 20, 80));

  rect = originalRect;
  EXPECT_TRUE(leaf->mapToVisualRectInAncestorSpace(&layoutView(), rect));
  EXPECT_EQ(rect, LayoutRect(0, 10, 20, 40));
  checkPaintInvalidationStateRectMapping(rect, originalRect, *leaf,
                                         layoutView(), layoutView());

  rect = LayoutRect(0, 60, 80, 0);
  EXPECT_TRUE(
      leaf->mapToVisualRectInAncestorSpace(container, rect, EdgeInclusive));
  rect.move(-container->scrolledContentOffset());
  EXPECT_EQ(rect, LayoutRect(0, 10, 80, 0));
}
Esempio n. 4
0
TEST_F(VisualRectMappingTest, SelfFlippedWritingMode) {
  setBodyInnerHTML(
      "<div id='target' style='writing-mode: vertical-rl; box-shadow: 40px "
      "20px black;"
      "    width: 100px; height: 50px; position: absolute; top: 111px; left: "
      "222px'>"
      "</div>");

  LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target"));
  LayoutRect visualRect = target->localVisualRect();
  // -40 = -box_shadow_offset_x(40) (with target's top-right corner as the
  // origin)
  // 140 = width(100) + box_shadow_offset_x(40)
  // 70 = height(50) + box_shadow_offset_y(20)
  EXPECT_EQ(LayoutRect(-40, 0, 140, 70), visualRect);

  LayoutRect rect = visualRect;
  // TODO(wkorman): The calls to flipForWritingMode() here and in other test
  // cases below are necessary because mapToVisualRectInAncestorSpace()
  // currently expects the input rect to be in "physical coordinates" (*not*
  // "physical coordinates with flipped block-flow direction"), see
  // LayoutBoxModelObject.h.
  target->flipForWritingMode(rect);
  EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect));
  // This rect is in physical coordinates of target.
  EXPECT_EQ(LayoutRect(0, 0, 140, 70), rect);

  rect = visualRect;
  target->flipForWritingMode(rect);
  EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect));
  EXPECT_EQ(LayoutRect(222, 111, 140, 70), rect);
  checkPaintInvalidationStateRectMapping(rect, visualRect, *target,
                                         layoutView(), layoutView());
}
TEST_F(LayoutObjectDrawingRecorderTest, Rect)
{
    GraphicsContext context(&rootDisplayItemList());
    FloatRect bound = layoutView().viewRect();
    drawRect(context, layoutView(), PaintPhaseForeground, bound);
    rootDisplayItemList().commitNewDisplayItems();
    EXPECT_EQ((size_t)1, rootDisplayItemList().displayItems().size());
    EXPECT_TRUE(rootDisplayItemList().displayItems()[0]->isDrawing());
}
TEST_F(LayoutObjectDrawingRecorderTest, Nothing)
{
    GraphicsContext context(&rootDisplayItemList());
    FloatRect bound = layoutView().viewRect();
    EXPECT_EQ((size_t)0, rootDisplayItemList().displayItems().size());

    drawNothing(context, layoutView(), PaintPhaseForeground, bound);
    rootDisplayItemList().commitNewDisplayItems();
    EXPECT_EQ((size_t)1, rootDisplayItemList().displayItems().size());
    ASSERT_TRUE(rootDisplayItemList().displayItems()[0]->isDrawing());
    EXPECT_FALSE(static_cast<DrawingDisplayItem*>(rootDisplayItemList().displayItems()[0].get())->picture());
}
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!
    }
}
Esempio n. 9
0
TEST_F(VisualRectMappingTest,
       DifferentPaintInvalidaitionContainerForAbsolutePosition) {
  enableCompositing();
  document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true);

  setBodyInnerHTML(
      "<div id='stacking-context' style='opacity: 0.9; background: blue; "
      "will-change: transform'>"
      "    <div id='scroller' style='overflow: scroll; width: 80px; height: "
      "80px'>"
      "        <div id='absolute' style='position: absolute; top: 111px; left: "
      "222px; width: 50px; height: 50px; background: green'></div>"
      "        <div id='normal-flow' style='width: 2000px; height: 2000px; "
      "background: yellow'></div>"
      "    </div>"
      "</div>");

  LayoutBlock* scroller = toLayoutBlock(getLayoutObjectByElementId("scroller"));
  scroller->setScrollTop(LayoutUnit(77));
  scroller->setScrollLeft(LayoutUnit(88));
  document().view()->updateAllLifecyclePhases();

  LayoutBlock* normalFlow =
      toLayoutBlock(getLayoutObjectByElementId("normal-flow"));
  EXPECT_EQ(scroller, &normalFlow->containerForPaintInvalidation());

  LayoutRect normalFlowVisualRect = normalFlow->localVisualRect();
  EXPECT_EQ(LayoutRect(0, 0, 2000, 2000), normalFlowVisualRect);
  LayoutRect rect = normalFlowVisualRect;
  EXPECT_TRUE(normalFlow->mapToVisualRectInAncestorSpace(scroller, rect));
  EXPECT_EQ(LayoutRect(0, 0, 2000, 2000), rect);
  checkPaintInvalidationStateRectMapping(rect, normalFlowVisualRect,
                                         *normalFlow, layoutView(), *scroller);

  LayoutBlock* stackingContext =
      toLayoutBlock(getLayoutObjectByElementId("stacking-context"));
  LayoutBlock* absolute = toLayoutBlock(getLayoutObjectByElementId("absolute"));
  EXPECT_EQ(stackingContext, &absolute->containerForPaintInvalidation());
  EXPECT_EQ(stackingContext, absolute->container());

  LayoutRect absoluteVisualRect = absolute->localVisualRect();
  EXPECT_EQ(LayoutRect(0, 0, 50, 50), absoluteVisualRect);
  rect = absoluteVisualRect;
  EXPECT_TRUE(absolute->mapToVisualRectInAncestorSpace(stackingContext, rect));
  EXPECT_EQ(LayoutRect(222, 111, 50, 50), rect);
  checkPaintInvalidationStateRectMapping(rect, absoluteVisualRect, *absolute,
                                         layoutView(), *stackingContext);
}
Esempio n. 10
0
TEST_P(BoxPaintInvalidatorTest, NonCompositedBackgroundAttachmentLocalResize) {
  Element* target = document().getElementById("target");
  target->setAttribute(HTMLNames::classAttr, "border local-background");
  target->setInnerHTML(
      "<div id=child style='width: 500px; height: 500px'></div>",
      ASSERT_NO_EXCEPTION);
  Element* child = document().getElementById("child");
  document().view()->updateAllLifecyclePhases();
  EXPECT_EQ(&layoutView(),
            &target->layoutObject()->containerForPaintInvalidation());

  // Resize the content.
  document().view()->setTracksPaintInvalidations(true);
  child->setAttribute(HTMLNames::styleAttr, "width: 500px; height: 1000px");
  document().view()->updateAllLifecyclePhases();
  // No invalidation because the changed part is invisible.
  EXPECT_FALSE(getRasterInvalidationTracking());

  // Resize the container.
  document().view()->setTracksPaintInvalidations(true);
  target->setAttribute(HTMLNames::styleAttr, "height: 200px");
  document().view()->updateAllLifecyclePhases();
  const auto& rasterInvalidations =
      getRasterInvalidationTracking()->trackedRasterInvalidations;
  ASSERT_EQ(1u, rasterInvalidations.size());
  EXPECT_EQ(IntRect(0, 120, 70, 120), rasterInvalidations[0].rect);
  EXPECT_EQ(static_cast<const DisplayItemClient*>(target->layoutObject()),
            rasterInvalidations[0].client);
  EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason);
  document().view()->setTracksPaintInvalidations(false);
}
Esempio n. 11
0
 const RasterInvalidationTracking* getRasterInvalidationTracking() const {
   // TODO(wangxianzhu): Test SPv2.
   return layoutView()
       .layer()
       ->graphicsLayerBackingForScrolling()
       ->getRasterInvalidationTracking();
 }
Esempio n. 12
0
TEST_F(LayoutObjectTest,
       ContainingBlockAbsoluteLayoutObjectShouldBeLayoutView) {
  setBodyInnerHTML("<foo style='position:absolute'></foo>");
  LayoutObject* layoutObject =
      document().body()->layoutObject()->slowFirstChild();
  EXPECT_EQ(layoutObject->containingBlock(), layoutView());
}
Esempio n. 13
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));
}
Esempio n. 14
0
TEST_P(BoxPaintInvalidatorTest, CompositedLayoutViewGradientResize) {
  enableCompositing();
  document().body()->setAttribute(HTMLNames::classAttr, "gradient");
  Element* target = document().getElementById("target");
  target->setAttribute(HTMLNames::classAttr, "");
  target->setAttribute(HTMLNames::styleAttr, "height: 2000px");
  document().view()->updateAllLifecyclePhases();

  // Resize the content.
  document().view()->setTracksPaintInvalidations(true);
  target->setAttribute(HTMLNames::styleAttr, "height: 3000px");
  document().view()->updateAllLifecyclePhases();
  if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
    // For now in RootLayerScrolling mode root background is invalidated and
    // painted on the container layer.
    // TODO(skobes): Treat LayoutView in the same way as normal objects having
    // background-attachment: local. crbug.com/568847.
    const auto& rasterInvalidations = layoutView()
                                          .layer()
                                          ->graphicsLayerBacking()
                                          ->getRasterInvalidationTracking()
                                          ->trackedRasterInvalidations;
    ASSERT_EQ(1u, rasterInvalidations.size());
    EXPECT_EQ(IntRect(0, 0, 800, 600), rasterInvalidations[0].rect);
    EXPECT_EQ(static_cast<const DisplayItemClient*>(&layoutView()),
              rasterInvalidations[0].client);
    EXPECT_EQ(PaintInvalidationLayoutOverflowBoxChange,
              rasterInvalidations[0].reason);
  } else {
    const auto& rasterInvalidations =
        getRasterInvalidationTracking()->trackedRasterInvalidations;
    ASSERT_EQ(1u, rasterInvalidations.size());
    EXPECT_EQ(IntRect(0, 0, 800, 3000), rasterInvalidations[0].rect);
    EXPECT_EQ(static_cast<const DisplayItemClient*>(&layoutView()),
              rasterInvalidations[0].client);
    EXPECT_EQ(PaintInvalidationLayoutOverflowBoxChange,
              rasterInvalidations[0].reason);
  }
  document().view()->setTracksPaintInvalidations(false);

  // Resize the viewport. No paint invalidation.
  document().view()->setTracksPaintInvalidations(true);
  document().view()->resize(800, 1000);
  document().view()->updateAllLifecyclePhases();
  EXPECT_FALSE(getRasterInvalidationTracking());
  document().view()->setTracksPaintInvalidations(false);
}
Esempio n. 15
0
TEST_F(VisualRectMappingTest, ContainPaint) {
  setBodyInnerHTML(
      "<div id='container' style='position: absolute; top: 0px; left: 0px; "
      "width: 200px; height: 200px; contain: paint'>"
      "    <div id='target' style='width: 400px; height: 400px'></div>"
      "    </div>"
      "</div>");

  LayoutBox* target = toLayoutBox(getLayoutObjectByElementId("target"));

  LayoutRect targetVisualRect = target->localVisualRect();
  EXPECT_EQ(LayoutRect(0, 0, 400, 400), targetVisualRect);
  LayoutRect rect = targetVisualRect;
  EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect));
  EXPECT_EQ(LayoutRect(0, 0, 200, 200), rect);
  checkPaintInvalidationStateRectMapping(rect, targetVisualRect, *target,
                                         layoutView(), layoutView());
}
TEST_F(LayoutObjectDrawingRecorderTest, Cached)
{
    GraphicsContext context(&rootDisplayItemList());
    FloatRect bound = layoutView().viewRect();
    drawNothing(context, layoutView(), PaintPhaseBlockBackground, bound);
    drawRect(context, layoutView(), PaintPhaseForeground, bound);
    rootDisplayItemList().commitNewDisplayItems();
    EXPECT_EQ((size_t)2, rootDisplayItemList().displayItems().size());
    EXPECT_TRUE(rootDisplayItemList().displayItems()[0]->isDrawing());
    EXPECT_TRUE(rootDisplayItemList().displayItems()[1]->isDrawing());

    drawNothing(context, layoutView(), PaintPhaseBlockBackground, bound);
    drawRect(context, layoutView(), PaintPhaseForeground, bound);
    EXPECT_EQ((size_t)2, newdisplayItemsBeforeUpdate().size());
    EXPECT_TRUE(newdisplayItemsBeforeUpdate()[0]->isCached());
    EXPECT_TRUE(newdisplayItemsBeforeUpdate()[1]->isCached());
    rootDisplayItemList().commitNewDisplayItems();
    EXPECT_EQ((size_t)2, rootDisplayItemList().displayItems().size());
    EXPECT_TRUE(rootDisplayItemList().displayItems()[0]->isDrawing());
    EXPECT_TRUE(rootDisplayItemList().displayItems()[1]->isDrawing());
}
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!
}
Esempio n. 18
0
TEST_F(VisualRectMappingTest, LayoutView) {
  document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com"));
  setBodyInnerHTML(
      "<style>body { margin: 0; }</style>"
      "<div id=frameContainer>"
      "  <iframe src='http://test.com' width='50' height='50' "
      "frameBorder='0'></iframe>"
      "</div>");
  setChildFrameHTML(
      "<style>body { margin: 0; }</style><span><img style='width: 20px; "
      "height: 100px'></span>text text text");

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

  LayoutBlock* frameContainer =
      toLayoutBlock(getLayoutObjectByElementId("frameContainer"));
  LayoutBlock* frameBody =
      toLayoutBlock(childDocument().body()->layoutObject());
  LayoutText* frameText = toLayoutText(frameBody->lastChild());

  // This case involves clipping: frame height is 50, y-coordinate of result
  // rect is 13, so height should be clipped to (50 - 13) == 37.
  childDocument().view()->setScrollOffset(ScrollOffset(0, 47),
                                          ProgrammaticScroll);
  LayoutRect originalRect(4, 60, 20, 80);
  LayoutRect rect = originalRect;
  EXPECT_TRUE(frameText->mapToVisualRectInAncestorSpace(frameContainer, rect));
  EXPECT_EQ(rect, LayoutRect(4, 13, 20, 37));

  rect = originalRect;
  EXPECT_TRUE(frameText->mapToVisualRectInAncestorSpace(&layoutView(), rect));
  EXPECT_EQ(rect, LayoutRect(4, 13, 20, 37));
  checkPaintInvalidationStateRectMapping(rect, originalRect, *frameText,
                                         layoutView(), layoutView());

  rect = LayoutRect(4, 60, 0, 80);
  EXPECT_TRUE(frameText->mapToVisualRectInAncestorSpace(frameContainer, rect,
                                                        EdgeInclusive));
  EXPECT_EQ(rect, LayoutRect(4, 13, 0, 37));
}
Esempio n. 19
0
TEST_P(BoxPaintInvalidatorTest, NonCompositedLayoutViewResize) {
  setBodyInnerHTML(
      "<style>"
      "  body { margin: 0 }"
      "  iframe { display: block; width: 100px; height: 100px; border: none; }"
      "</style>"
      "<iframe id='iframe'></iframe>");
  setChildFrameHTML(
      "<style>"
      "  ::-webkit-scrollbar { display: none }"
      "  body { margin: 0; background: green; height: 0 }"
      "</style>"
      "<div id='content' style='width: 200px; height: 200px'></div>");
  document().view()->updateAllLifecyclePhases();
  Element* iframe = document().getElementById("iframe");
  Element* content = childDocument().getElementById("content");
  EXPECT_EQ(layoutView(),
            content->layoutObject()->containerForPaintInvalidation());

  // Resize the content.
  document().view()->setTracksPaintInvalidations(true);
  content->setAttribute(HTMLNames::styleAttr, "height: 500px");
  document().view()->updateAllLifecyclePhases();
  // No invalidation because the changed part of layout overflow is clipped.
  EXPECT_FALSE(getRasterInvalidationTracking());
  document().view()->setTracksPaintInvalidations(false);

  // Resize the iframe.
  document().view()->setTracksPaintInvalidations(true);
  iframe->setAttribute(HTMLNames::styleAttr, "height: 200px");
  document().view()->updateAllLifecyclePhases();
  const auto& rasterInvalidations =
      getRasterInvalidationTracking()->trackedRasterInvalidations;
  ASSERT_EQ(2u, rasterInvalidations.size());
  EXPECT_EQ(IntRect(0, 100, 100, 100), rasterInvalidations[0].rect);
  EXPECT_EQ(static_cast<const DisplayItemClient*>(iframe->layoutObject()),
            rasterInvalidations[0].client);
  EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason);
  EXPECT_EQ(
      static_cast<const DisplayItemClient*>(content->layoutObject()->view()),
      rasterInvalidations[1].client);
  if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
    // TODO(skobes): Treat LayoutView in the same way as normal objects having
    // background-attachment: local. crbug.com/568847.
    EXPECT_EQ(IntRect(0, 0, 100, 200), rasterInvalidations[1].rect);
    EXPECT_EQ(PaintInvalidationFull, rasterInvalidations[1].reason);
  } else {
    EXPECT_EQ(IntRect(0, 100, 100, 100), rasterInvalidations[1].rect);
    EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[1].reason);
  }
  document().view()->setTracksPaintInvalidations(false);
}
Esempio n. 20
0
void ImageCollection::setState(State state)
{
    if(_state == state && state != Hidden)
        return;

    if(state == Hidden) {
        listItem()->visible().setValue(0.);
        iconItem()->visible().setValue(0.);
        viewingItem()->visible().setValue(0.);
        timeItem()->visible().setValue(0.);
    } else if(state == Time) {
        timeItem()->visible().setValue(1.);
        if(_state == Expanded) {
            layoutTime();
        } else {
            layoutImmTime();
        }
    } else if(_state == Hidden) {
        Q_ASSERT(state == Collapsed || state == Expanded);
        if(state == Expanded) {
            listItem()->setActive(true);
            listItem()->visible().setValue(1.);
            layoutImmExpanded();
        } else if(state == Collapsed) {
            iconItem()->visible().setValue(1.);
            layoutImmCollapsed();
            listItem()->setActive(false);
        } 
    } else if(state == Expanded) {
        Q_ASSERT(_state == Collapsed || _state == View || _state == Time);
        listItem()->setActive(true);
        listItem()->setFocused(true);
        listItem()->visible().setValue(1.);
        if(_state == Time) {
            layoutExpandedFromTime();
        } else if(_state == View) {
            layoutExpandedFromView();
        } else {
            layoutExpanded();
        }
    } else if(state == Collapsed) {
        Q_ASSERT(_state == Expanded);
        layoutCollapsed();
        listItem()->setActive(false);
    } else if(state == View) {
        Q_ASSERT(_state == Expanded);
        layoutView();
    }

    _state = state;
}
Esempio n. 21
0
void LoopChooserView::layoutModelObject(boost::optional<model::ModelObject> & modelObject)
{
  m_component = boost::none;

  if( modelObject )
  {
    if( boost::optional<model::HVACComponent> comp = modelObject->optionalCast<model::HVACComponent>() )
    {
      m_component = comp;
    }
  }

  layoutView();
}
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));
}
Esempio n. 23
0
void ZoneChooserView::layoutModelObject(openstudio::model::ModelObject & modelObject)
{
    if( model::OptionalAirLoopHVACZoneSplitter splitter = modelObject.optionalCast<model::AirLoopHVACZoneSplitter>() )
    {
        m_splitter = splitter;
    }
    else if( model::OptionalAirLoopHVACZoneMixer mixer = modelObject.optionalCast<model::AirLoopHVACZoneMixer>() )
    {
        m_mixer = mixer;
    }
    else
    {
        m_splitter = model::OptionalAirLoopHVACZoneSplitter();
        m_mixer = model::OptionalAirLoopHVACZoneMixer();
    }

    layoutView();
}
Esempio n. 24
0
TEST_F(VisualRectMappingTest, ContainerFlippedWritingMode) {
  setBodyInnerHTML(
      "<div id='container' style='writing-mode: vertical-rl; position: "
      "absolute; top: 111px; left: 222px'>"
      "    <div id='target' style='box-shadow: 40px 20px black; width: 100px; "
      "height: 90px'></div>"
      "    <div style='width: 100px; height: 100px'></div>"
      "</div>");

  LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target"));
  LayoutRect targetVisualRect = target->localVisualRect();
  // -40 = -box_shadow_offset_x(40) (with target's top-right corner as the
  // origin)
  // 140 = width(100) + box_shadow_offset_x(40)
  // 110 = height(90) + box_shadow_offset_y(20)
  EXPECT_EQ(LayoutRect(-40, 0, 140, 110), targetVisualRect);

  LayoutRect rect = targetVisualRect;
  target->flipForWritingMode(rect);
  EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect));
  // This rect is in physical coordinates of target.
  EXPECT_EQ(LayoutRect(0, 0, 140, 110), rect);

  LayoutBlock* container =
      toLayoutBlock(getLayoutObjectByElementId("container"));
  rect = targetVisualRect;
  target->flipForWritingMode(rect);
  EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect));
  // 100 is the physical x location of target in container.
  EXPECT_EQ(LayoutRect(100, 0, 140, 110), rect);
  rect = targetVisualRect;
  target->flipForWritingMode(rect);
  EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect));
  EXPECT_EQ(LayoutRect(322, 111, 140, 110), rect);
  checkPaintInvalidationStateRectMapping(rect, targetVisualRect, *target,
                                         layoutView(), layoutView());

  LayoutRect containerVisualRect = container->localVisualRect();
  EXPECT_EQ(LayoutRect(0, 0, 200, 100), containerVisualRect);
  rect = containerVisualRect;
  container->flipForWritingMode(rect);
  EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(container, rect));
  EXPECT_EQ(LayoutRect(0, 0, 200, 100), rect);
  rect = containerVisualRect;
  container->flipForWritingMode(rect);
  EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(&layoutView(), rect));
  EXPECT_EQ(LayoutRect(222, 111, 200, 100), rect);
  checkPaintInvalidationStateRectMapping(rect, containerVisualRect, *container,
                                         layoutView(), layoutView());
}
Esempio n. 25
0
TEST_F(VisualRectMappingTest, LayoutViewDisplayNone) {
  document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com"));
  setBodyInnerHTML(
      "<style>body { margin: 0; }</style>"
      "<div id=frameContainer>"
      "  <iframe id='frame' src='http://test.com' width='50' height='50' "
      "frameBorder='0'></iframe>"
      "</div>");
  setChildFrameHTML(
      "<style>body { margin: 0; }</style><div "
      "style='width:100px;height:100px;'></div>");

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

  LayoutBlock* frameContainer =
      toLayoutBlock(getLayoutObjectByElementId("frameContainer"));
  LayoutBlock* frameBody =
      toLayoutBlock(childDocument().body()->layoutObject());
  LayoutBlock* frameDiv = toLayoutBlock(frameBody->lastChild());

  // This part is copied from the LayoutView test, just to ensure that the
  // mapped rect is valid before display:none is set on the iframe.
  childDocument().view()->setScrollOffset(ScrollOffset(0, 47),
                                          ProgrammaticScroll);
  LayoutRect originalRect(4, 60, 20, 80);
  LayoutRect rect = originalRect;
  EXPECT_TRUE(frameDiv->mapToVisualRectInAncestorSpace(frameContainer, rect));
  EXPECT_EQ(rect, LayoutRect(4, 13, 20, 37));

  Element* frameElement = document().getElementById("frame");
  frameElement->setInlineStyleProperty(CSSPropertyDisplay, "none");
  document().view()->updateAllLifecyclePhases();

  rect = originalRect;
  EXPECT_FALSE(frameDiv->mapToVisualRectInAncestorSpace(&layoutView(), rect));
  EXPECT_EQ(rect, LayoutRect());
}
Esempio n. 26
0
TEST_F(VisualRectMappingTest,
       ContainerOfAbsoluteAbovePaintInvalidationContainer) {
  enableCompositing();
  document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true);

  setBodyInnerHTML(
      "<div id='container' style='position: absolute; top: 88px; left: 99px'>"
      "    <div style='height: 222px'></div>"
      // This div makes stacking-context composited.
      "    <div style='position: absolute; width: 1px; height: 1px; "
      "background:yellow; will-change: transform'></div>"
      // This stacking context is paintInvalidationContainer of the absolute
      // child, but not a container of it.
      "    <div id='stacking-context' style='opacity: 0.9'>"
      "        <div id='absolute' style='position: absolute; top: 50px; left: "
      "50px; width: 50px; height: 50px; background: green'></div>"
      "    </div>"
      "</div>");

  LayoutBlock* stackingContext =
      toLayoutBlock(getLayoutObjectByElementId("stacking-context"));
  LayoutBlock* absolute = toLayoutBlock(getLayoutObjectByElementId("absolute"));
  LayoutBlock* container =
      toLayoutBlock(getLayoutObjectByElementId("container"));
  EXPECT_EQ(stackingContext, &absolute->containerForPaintInvalidation());
  EXPECT_EQ(container, absolute->container());

  LayoutRect absoluteVisualRect = absolute->localVisualRect();
  EXPECT_EQ(LayoutRect(0, 0, 50, 50), absoluteVisualRect);
  LayoutRect rect = absoluteVisualRect;
  EXPECT_TRUE(absolute->mapToVisualRectInAncestorSpace(stackingContext, rect));
  // -172 = top(50) - y_offset_of_stacking_context(222)
  EXPECT_EQ(LayoutRect(50, -172, 50, 50), rect);
  checkPaintInvalidationStateRectMapping(rect, absoluteVisualRect, *absolute,
                                         layoutView(), *stackingContext);
}
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));
    }
}
Esempio n. 29
0
TEST_F(LayoutObjectTest, ContainingBlockDocumentElementShouldBeLayoutView)
{
    EXPECT_EQ(document().documentElement()->layoutObject()->containingBlock(), layoutView());
}
Esempio n. 30
0
// Containing block test.
TEST_F(LayoutObjectTest, ContainingBlockLayoutViewShouldBeNull)
{
    EXPECT_EQ(nullptr, layoutView().containingBlock());
}