Invalidate scrollbars when custom scrollbar style changes dynamically.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 3 May 2014 22:16:53 +0000 (22:16 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 3 May 2014 22:16:53 +0000 (22:16 +0000)
<https://webkit.org/b/132529>

Source/WebCore:
Add a ScrollView::styleDidChange() and call that from RenderView::styleDidChange()
so that the scrollbars are sure to get repainted with potentially different style.

Reviewed by Antti Koivisto.

Test: fast/css/scrollbar-dynamic-style-change.html

* platform/ScrollView.cpp:
(WebCore::ScrollView::styleDidChange):
* platform/ScrollView.h:
* rendering/RenderView.cpp:
(WebCore::RenderView::styleDidChange):

LayoutTests:
Reviewed by Antti Koivisto.

* fast/css/scrollbar-dynamic-style-change-expected.html: Added.
* fast/css/scrollbar-dynamic-style-change.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@168230 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/css/scrollbar-dynamic-style-change-expected.html [new file with mode: 0644]
LayoutTests/fast/css/scrollbar-dynamic-style-change.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/ScrollView.cpp
Source/WebCore/platform/ScrollView.h
Source/WebCore/rendering/RenderView.cpp

index 9bf85b5..937086a 100644 (file)
@@ -1,3 +1,13 @@
+2014-05-03  Andreas Kling  <akling@apple.com>
+
+        Invalidate scrollbars when custom scrollbar style changes dynamically.
+        <https://webkit.org/b/132529>
+
+        Reviewed by Antti Koivisto.
+
+        * fast/css/scrollbar-dynamic-style-change-expected.html: Added.
+        * fast/css/scrollbar-dynamic-style-change.html: Added.
+
 2014-05-03  Simon Fraser  <simon.fraser@apple.com>
 
         [UI-side compositing] Assertion in PlatformCAFilters::setFiltersOnLayer with animated reference filter
diff --git a/LayoutTests/fast/css/scrollbar-dynamic-style-change-expected.html b/LayoutTests/fast/css/scrollbar-dynamic-style-change-expected.html
new file mode 100644 (file)
index 0000000..2509476
--- /dev/null
@@ -0,0 +1,15 @@
+<style>
+::-webkit-scrollbar {
+    background: green;
+}
+body {
+    overflow: scroll;
+}
+div {
+    overflow: scroll;
+    width: 200px;
+    height: 200px;
+}
+</style>
+<div></div>
+</script>
diff --git a/LayoutTests/fast/css/scrollbar-dynamic-style-change.html b/LayoutTests/fast/css/scrollbar-dynamic-style-change.html
new file mode 100644 (file)
index 0000000..cfef201
--- /dev/null
@@ -0,0 +1,20 @@
+<style>
+::-webkit-scrollbar {
+    background: red;
+}
+body {
+    overflow: scroll;
+}
+div {
+    overflow: scroll;
+    width: 200px;
+    height: 200px;
+}
+</style>
+<div></div>
+<script>
+window.onload = function() {
+    document.body.offsetWidth;
+    document.styleSheets[0].cssRules[0].style.backgroundColor = 'green';
+}
+</script>
index 04e9f3e..cbc5b9c 100644 (file)
@@ -1,3 +1,21 @@
+2014-05-03  Andreas Kling  <akling@apple.com>
+
+        Invalidate scrollbars when custom scrollbar style changes dynamically.
+        <https://webkit.org/b/132529>
+
+        Add a ScrollView::styleDidChange() and call that from RenderView::styleDidChange()
+        so that the scrollbars are sure to get repainted with potentially different style.
+
+        Reviewed by Antti Koivisto.
+
+        Test: fast/css/scrollbar-dynamic-style-change.html
+
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::styleDidChange):
+        * platform/ScrollView.h:
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::styleDidChange):
+
 2014-05-03  Simon Fraser  <simon.fraser@apple.com>
 
         Very fuzzy layers under non-decompasable matrices
index c022d12..a317039 100644 (file)
@@ -1459,6 +1459,15 @@ void ScrollView::setScrollOrigin(const IntPoint& origin, bool updatePositionAtAl
         updateScrollbars(scrollOffset());
 }
 
+void ScrollView::styleDidChange()
+{
+    if (m_horizontalScrollbar)
+        m_horizontalScrollbar->styleChanged();
+
+    if (m_verticalScrollbar)
+        m_verticalScrollbar->styleChanged();
+}
+
 #if !PLATFORM(COCOA)
 
 void ScrollView::platformAddChild(Widget*)
index 2d61b29..e9bbe4f 100644 (file)
@@ -144,6 +144,8 @@ public:
     // Overridden by FrameView to create custom CSS scrollbars if applicable.
     virtual PassRefPtr<Scrollbar> createScrollbar(ScrollbarOrientation);
 
+    void styleDidChange();
+
     // If the prohibits scrolling flag is set, then all scrolling in the view (even programmatic scrolling) is turned off.
     void setProhibitsScrolling(bool b) { m_prohibitsScrolling = b; }
     bool prohibitsScrolling() const { return m_prohibitsScrolling; }
index 0d24260..250b027 100644 (file)
@@ -1260,6 +1260,8 @@ void RenderView::styleDidChange(StyleDifference diff, const RenderStyle* oldStyl
     RenderBlockFlow::styleDidChange(diff, oldStyle);
     if (hasRenderNamedFlowThreads())
         flowThreadController().styleDidChange();
+
+    frameView().styleDidChange();
 }
 
 bool RenderView::hasRenderNamedFlowThreads() const