OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/paint/PaintLayerScrollableArea.h" | 5 #include "core/paint/PaintLayerScrollableArea.h" |
6 | 6 |
7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
8 #include "core/layout/LayoutBoxModelObject.h" | 8 #include "core/layout/LayoutBoxModelObject.h" |
9 #include "core/layout/LayoutTestHelper.h" | 9 #include "core/layout/LayoutTestHelper.h" |
10 #include "core/paint/PaintLayer.h" | 10 #include "core/paint/PaintLayer.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 class MockChromeClient : public EmptyChromeClient { | 21 class MockChromeClient : public EmptyChromeClient { |
22 public: | 22 public: |
23 MOCK_METHOD3(mockSetToolTip, void(LocalFrame*, const String&, TextDirection)); | 23 MOCK_METHOD3(mockSetToolTip, void(LocalFrame*, const String&, TextDirection)); |
24 void setToolTip(LocalFrame& frame, | 24 void setToolTip(LocalFrame& frame, |
25 const String& tooltipText, | 25 const String& tooltipText, |
26 TextDirection dir) override { | 26 TextDirection dir) override { |
27 mockSetToolTip(&frame, tooltipText, dir); | 27 mockSetToolTip(&frame, tooltipText, dir); |
28 } | 28 } |
29 }; | 29 }; |
30 | 30 |
31 } // namespace { | 31 } // namespace |
32 | 32 |
33 class PaintLayerScrollableAreaTest : public RenderingTest { | 33 class PaintLayerScrollableAreaTest : public RenderingTest { |
34 public: | 34 public: |
35 PaintLayerScrollableAreaTest() | 35 PaintLayerScrollableAreaTest() |
36 : RenderingTest(EmptyFrameLoaderClient::create()), | 36 : RenderingTest(EmptyFrameLoaderClient::create()), |
37 m_chromeClient(new MockChromeClient) {} | 37 m_chromeClient(new MockChromeClient) {} |
38 | 38 |
39 ~PaintLayerScrollableAreaTest() { | 39 ~PaintLayerScrollableAreaTest() { |
40 testing::Mock::VerifyAndClearExpectations(&chromeClient()); | 40 testing::Mock::VerifyAndClearExpectations(&chromeClient()); |
41 } | 41 } |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 EXPECT_CALL(chromeClient(), mockSetToolTip(document().frame(), String(), _)) | 541 EXPECT_CALL(chromeClient(), mockSetToolTip(document().frame(), String(), _)) |
542 .Times(1); | 542 .Times(1); |
543 scrollableArea->setScrollOffset(ScrollOffset(1, 1), UserScroll); | 543 scrollableArea->setScrollOffset(ScrollOffset(1, 1), UserScroll); |
544 | 544 |
545 // Programmatic scrolling should not dismiss the tooltip, so setToolTip | 545 // Programmatic scrolling should not dismiss the tooltip, so setToolTip |
546 // should not be called for this invocation. | 546 // should not be called for this invocation. |
547 EXPECT_CALL(chromeClient(), mockSetToolTip(document().frame(), String(), _)) | 547 EXPECT_CALL(chromeClient(), mockSetToolTip(document().frame(), String(), _)) |
548 .Times(0); | 548 .Times(0); |
549 scrollableArea->setScrollOffset(ScrollOffset(2, 2), ProgrammaticScroll); | 549 scrollableArea->setScrollOffset(ScrollOffset(2, 2), ProgrammaticScroll); |
550 } | 550 } |
| 551 |
| 552 TEST_F(PaintLayerScrollableAreaTest, |
| 553 StickyPositionConstraintsInvalidatedByLayout) { |
| 554 setBodyInnerHTML( |
| 555 "<style>#scroller { overflow-y: scroll; height: 100px; }" |
| 556 "#sticky { height: 25px; position: sticky; top: 0; }" |
| 557 "#padding { height: 500px; }</style>" |
| 558 "<div id='scroller'><div id='sticky'></div><div id='padding'></div>" |
| 559 "</div>"); |
| 560 |
| 561 LayoutBoxModelObject* scroller = |
| 562 toLayoutBoxModelObject(getLayoutObjectByElementId("scroller")); |
| 563 LayoutBoxModelObject* sticky = |
| 564 toLayoutBoxModelObject(getLayoutObjectByElementId("sticky")); |
| 565 |
| 566 EXPECT_FALSE(sticky->layer()->needsCompositingInputsUpdate()); |
| 567 |
| 568 PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea(); |
| 569 ASSERT_TRUE(scrollableArea); |
| 570 |
| 571 // Fake layout. |
| 572 scrollableArea->updateAfterLayout(); |
| 573 |
| 574 EXPECT_TRUE(sticky->layer()->needsCompositingInputsUpdate()); |
| 575 EXPECT_EQ(0u, scrollableArea->stickyConstraintsMap().size()); |
551 } | 576 } |
| 577 |
| 578 } // namespace blink |
OLD | NEW |