Beispiel #1
0
 void SetUp() override {
   RenderingTest::SetUp();
   enableCompositing();
   setBodyInnerHTML(
       "<style>"
       "  body {"
       "    margin: 0;"
       "    height: 0;"
       "  }"
       "  ::-webkit-scrollbar { display: none }"
       "  #target {"
       "    width: 50px;"
       "    height: 100px;"
       "    transform-origin: 0 0;"
       "  }"
       "  .border {"
       "    border-width: 20px 10px;"
       "    border-style: solid;"
       "    border-color: red;"
       "  }"
       "  .local-background {"
       "    background-attachment: local;"
       "    overflow: scroll;"
       "  }"
       "  .gradient {"
       "    background-image: linear-gradient(blue, yellow)"
       "  }"
       "</style>"
       "<div id='target' class='border'></div>");
 }
    void SetUp() override
    {
        RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true);
        Settings::setMockScrollbarsEnabled(true);

        RenderingTest::SetUp();
        enableCompositing();
    }
Beispiel #3
0
TEST_P(BoxPaintInvalidatorTest,
       CompositedBackgroundAttachmentLocalGradientResize) {
  enableCompositing();

  Element* target = document().getElementById("target");
  target->setAttribute(HTMLNames::classAttr,
                       "border local-background gradient");
  target->setAttribute(HTMLNames::styleAttr, "will-change: transform");
  target->setInnerHTML(
      "<div id='child' style='width: 500px; height: 500px'></div>",
      ASSERT_NO_EXCEPTION);
  Element* child = document().getElementById("child");
  document().view()->updateAllLifecyclePhases();

  // Resize the content.
  document().view()->setTracksPaintInvalidations(true);
  child->setAttribute(HTMLNames::styleAttr, "width: 500px; height: 1000px");
  document().view()->updateAllLifecyclePhases();
  GraphicsLayer* containerLayer = toLayoutBoxModelObject(target->layoutObject())
                                      ->layer()
                                      ->graphicsLayerBacking();
  GraphicsLayer* contentsLayer = toLayoutBoxModelObject(target->layoutObject())
                                     ->layer()
                                     ->graphicsLayerBackingForScrolling();
  // No invalidation on the container layer.
  EXPECT_FALSE(containerLayer->getRasterInvalidationTracking());
  // Full invalidation of background on contents layer because the gradient
  // background is resized.
  const auto& contentsRasterInvalidations =
      contentsLayer->getRasterInvalidationTracking()
          ->trackedRasterInvalidations;
  ASSERT_EQ(1u, contentsRasterInvalidations.size());
  EXPECT_EQ(IntRect(0, 0, 500, 1000), contentsRasterInvalidations[0].rect);
  EXPECT_EQ(static_cast<const DisplayItemClient*>(target->layoutObject()),
            contentsRasterInvalidations[0].client);
  EXPECT_EQ(PaintInvalidationBackgroundOnScrollingContentsLayer,
            contentsRasterInvalidations[0].reason);
  document().view()->setTracksPaintInvalidations(false);

  // Resize the container.
  document().view()->setTracksPaintInvalidations(true);
  target->setAttribute(HTMLNames::styleAttr,
                       "will-change: transform; height: 200px");
  document().view()->updateAllLifecyclePhases();
  EXPECT_FALSE(contentsLayer->getRasterInvalidationTracking());
  // Full invalidation on the container layer.
  const auto& containerRasterInvalidations =
      containerLayer->getRasterInvalidationTracking()
          ->trackedRasterInvalidations;
  ASSERT_EQ(1u, containerRasterInvalidations.size());
  EXPECT_EQ(IntRect(0, 0, 70, 240), containerRasterInvalidations[0].rect);
  EXPECT_EQ(static_cast<const DisplayItemClient*>(target->layoutObject()),
            containerRasterInvalidations[0].client);
  EXPECT_EQ(PaintInvalidationBorderBoxChange,
            containerRasterInvalidations[0].reason);
  document().view()->setTracksPaintInvalidations(false);
}
    virtual void SetUp() override
    {
        RuntimeEnabledFeatures::setSlimmingPaintEnabled(true);

        RenderingTest::SetUp();
        enableCompositing();

        m_layoutView = document().view()->layoutView();
        ASSERT_TRUE(m_layoutView);
    }
Beispiel #5
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);
}
Beispiel #6
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);
}
Beispiel #7
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);
}
 void SetUp() override {
   RenderingTest::SetUp();
   enableCompositing();
 }
  void SetUp() override {
    Settings::setMockScrollbarsEnabled(true);

    RenderingTest::SetUp();
    enableCompositing();
  }