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/LayoutBlock.h" | 8 #include "core/layout/LayoutBlock.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" |
11 #include "platform/graphics/GraphicsLayer.h" | 11 #include "platform/graphics/GraphicsLayer.h" |
| 12 #include "platform/scroll/ScrollTypes.h" |
12 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | 13 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
13 | 14 |
14 namespace blink { | 15 namespace blink { |
15 | 16 |
16 class PaintLayerScrollableAreaTest : public RenderingTest { | 17 class PaintLayerScrollableAreaTest : public RenderingTest { |
17 public: | 18 public: |
18 PaintLayerScrollableAreaTest() | 19 PaintLayerScrollableAreaTest() |
19 : RenderingTest(SingleChildFrameLoaderClient::create()) {} | 20 : RenderingTest(SingleChildFrameLoaderClient::create()) {} |
20 | 21 |
21 bool canPaintBackgroundOntoScrollingContentsLayer(const char* elementId) { | 22 bool canPaintBackgroundOntoScrollingContentsLayer(const char* elementId) { |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 EXPECT_TRUE(paintLayer->graphicsLayerBackingForScrolling()->contentsOpaque()); | 364 EXPECT_TRUE(paintLayer->graphicsLayerBackingForScrolling()->contentsOpaque()); |
364 | 365 |
365 // Make the scroller translucent. | 366 // Make the scroller translucent. |
366 scroller->setAttribute(HTMLNames::styleAttr, "opacity: 0.5"); | 367 scroller->setAttribute(HTMLNames::styleAttr, "opacity: 0.5"); |
367 document().view()->updateAllLifecyclePhases(); | 368 document().view()->updateAllLifecyclePhases(); |
368 paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer(); | 369 paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer(); |
369 ASSERT_TRUE(paintLayer); | 370 ASSERT_TRUE(paintLayer); |
370 EXPECT_FALSE(paintLayer->needsCompositedScrolling()); | 371 EXPECT_FALSE(paintLayer->needsCompositedScrolling()); |
371 EXPECT_FALSE(paintLayer->graphicsLayerBacking()); | 372 EXPECT_FALSE(paintLayer->graphicsLayerBacking()); |
372 } | 373 } |
| 374 |
| 375 // Ensure OverlayScrollbarColorTheme get updated when page load |
| 376 TEST_F(PaintLayerScrollableAreaTest, OverlayScrollbarColorThemeUpdated) { |
| 377 setBodyInnerHTML( |
| 378 "<style>" |
| 379 "div { overflow: scroll; }" |
| 380 "#white { background-color: white; }" |
| 381 "#black { background-color: black; }" |
| 382 "</style>" |
| 383 "<div id=\"none\">a</div>" |
| 384 "<div id=\"white\">b</div>" |
| 385 "<div id=\"black\">c</div>"); |
| 386 document().view()->updateAllLifecyclePhases(); |
| 387 |
| 388 Element* none = document().getElementById("none"); |
| 389 Element* white = document().getElementById("white"); |
| 390 Element* black = document().getElementById("black"); |
| 391 |
| 392 PaintLayer* noneLayer = toLayoutBoxModelObject(none->layoutObject())->layer(); |
| 393 PaintLayer* whiteLayer = |
| 394 toLayoutBoxModelObject(white->layoutObject())->layer(); |
| 395 PaintLayer* blackLayer = |
| 396 toLayoutBoxModelObject(black->layoutObject())->layer(); |
| 397 |
| 398 ASSERT_TRUE(noneLayer); |
| 399 ASSERT_TRUE(whiteLayer); |
| 400 ASSERT_TRUE(blackLayer); |
| 401 |
| 402 ASSERT_EQ(ScrollbarOverlayColorTheme::ScrollbarOverlayColorThemeDark, |
| 403 noneLayer->getScrollableArea()->getScrollbarOverlayColorTheme()); |
| 404 ASSERT_EQ(ScrollbarOverlayColorTheme::ScrollbarOverlayColorThemeDark, |
| 405 whiteLayer->getScrollableArea()->getScrollbarOverlayColorTheme()); |
| 406 ASSERT_EQ(ScrollbarOverlayColorTheme::ScrollbarOverlayColorThemeLight, |
| 407 blackLayer->getScrollableArea()->getScrollbarOverlayColorTheme()); |
373 } | 408 } |
| 409 } |
OLD | NEW |