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/frame/FrameView.h" | 5 #include "core/frame/FrameView.h" |
6 #include "core/layout/LayoutView.h" | 6 #include "core/layout/LayoutView.h" |
7 #include "core/paint/PaintLayerScrollableArea.h" | 7 #include "core/paint/PaintLayerScrollableArea.h" |
8 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | 8 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
9 #include "platform/testing/TestingPlatformSupport.h" | 9 #include "platform/testing/TestingPlatformSupport.h" |
10 #include "platform/testing/UnitTestHelpers.h" | 10 #include "platform/testing/UnitTestHelpers.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 // Forces recalc of LayoutView's computed style in Document::updateStyle, | 39 // Forces recalc of LayoutView's computed style in Document::updateStyle, |
40 // without invalidating layout. | 40 // without invalidating layout. |
41 mainFrame().executeScriptAndReturnValue(WebScriptSource( | 41 mainFrame().executeScriptAndReturnValue(WebScriptSource( |
42 "document.querySelector('style').sheet.insertRule('body {}', 1);")); | 42 "document.querySelector('style').sheet.insertRule('body {}', 1);")); |
43 | 43 |
44 compositor().beginFrame(); | 44 compositor().beginFrame(); |
45 ASSERT_TRUE(plsa->verticalScrollbar() && plsa->horizontalScrollbar()); | 45 ASSERT_TRUE(plsa->verticalScrollbar() && plsa->horizontalScrollbar()); |
46 } | 46 } |
47 | 47 |
| 48 // Ensure that causing a change in scrollbar existence causes a nested layout |
| 49 // to recalculate the existence of the opposite scrollbar. The bug here was |
| 50 // caused by trying to avoid the layout when overlays are enabled but not |
| 51 // checking whether the scrollbars should be custom - which do take up layout |
| 52 // space. https://crbug.com/668387. |
| 53 TEST_F(ScrollbarsTest, CustomScrollbarsCauseLayoutOnExistenceChange) { |
| 54 // The bug reproduces only with RLS off. When RLS ships we can keep the test |
| 55 // but remove this setting. |
| 56 ScopedRootLayerScrollingForTest turnOffRootLayerScrolling(false); |
| 57 |
| 58 // This test is specifically checking the behavior when overlay scrollbars |
| 59 // are enabled. |
| 60 DCHECK(ScrollbarTheme::theme().usesOverlayScrollbars()); |
| 61 |
| 62 webView().resize(WebSize(800, 600)); |
| 63 SimRequest request("https://example.com/test.html", "text/html"); |
| 64 loadURL("https://example.com/test.html"); |
| 65 request.complete( |
| 66 "<!DOCTYPE html>" |
| 67 "<style>" |
| 68 " ::-webkit-scrollbar {" |
| 69 " height: 16px;" |
| 70 " width: 16px" |
| 71 " }" |
| 72 " ::-webkit-scrollbar-thumb {" |
| 73 " background-color: rgba(0,0,0,.2);" |
| 74 " }" |
| 75 " html, body{" |
| 76 " margin: 0;" |
| 77 " height: 100%;" |
| 78 " }" |
| 79 " .box {" |
| 80 " width: 100%;" |
| 81 " height: 100%;" |
| 82 " }" |
| 83 " .transformed {" |
| 84 " transform: translateY(100px);" |
| 85 " }" |
| 86 "</style>" |
| 87 "<div id='box' class='box'></div>"); |
| 88 |
| 89 ScrollableArea* layoutViewport = |
| 90 document().view()->layoutViewportScrollableArea(); |
| 91 |
| 92 compositor().beginFrame(); |
| 93 ASSERT_FALSE(layoutViewport->verticalScrollbar()); |
| 94 ASSERT_FALSE(layoutViewport->horizontalScrollbar()); |
| 95 |
| 96 // Adding translation will cause a vertical scrollbar to appear but not dirty |
| 97 // layout otherwise. Ensure the change of scrollbar causes a layout to |
| 98 // recalculate the page width with the vertical scrollbar added. |
| 99 mainFrame().executeScript(WebScriptSource( |
| 100 "document.getElementById('box').className = 'box transformed';")); |
| 101 compositor().beginFrame(); |
| 102 |
| 103 ASSERT_TRUE(layoutViewport->verticalScrollbar()); |
| 104 ASSERT_FALSE(layoutViewport->horizontalScrollbar()); |
| 105 } |
| 106 |
48 typedef bool TestParamOverlayScrollbar; | 107 typedef bool TestParamOverlayScrollbar; |
49 class ScrollbarAppearanceTest | 108 class ScrollbarAppearanceTest |
50 : public SimTest, | 109 : public SimTest, |
51 public ::testing::WithParamInterface<TestParamOverlayScrollbar> { | 110 public ::testing::WithParamInterface<TestParamOverlayScrollbar> { |
52 public: | 111 public: |
53 // Use real scrollbars to ensure we're testing the real ScrollbarThemes. | 112 // Use real scrollbars to ensure we're testing the real ScrollbarThemes. |
54 ScrollbarAppearanceTest() : m_mockScrollbars(false, GetParam()) {} | 113 ScrollbarAppearanceTest() : m_mockScrollbars(false, GetParam()) {} |
55 | 114 |
56 private: | 115 private: |
57 FrameTestHelpers::UseMockScrollbarSettings m_mockScrollbars; | 116 FrameTestHelpers::UseMockScrollbarSettings m_mockScrollbars; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 EXPECT_EQ(StubWebThemeEngine::kMinimumHorizontalLength, | 170 EXPECT_EQ(StubWebThemeEngine::kMinimumHorizontalLength, |
112 theme.thumbLength(*scrollableArea->horizontalScrollbar())); | 171 theme.thumbLength(*scrollableArea->horizontalScrollbar())); |
113 EXPECT_EQ(StubWebThemeEngine::kMinimumVerticalLength, | 172 EXPECT_EQ(StubWebThemeEngine::kMinimumVerticalLength, |
114 theme.thumbLength(*scrollableArea->verticalScrollbar())); | 173 theme.thumbLength(*scrollableArea->verticalScrollbar())); |
115 } | 174 } |
116 #endif | 175 #endif |
117 | 176 |
118 } // namespace | 177 } // namespace |
119 | 178 |
120 } // namespace blink | 179 } // namespace blink |
OLD | NEW |