Title: [121371] trunk
Revision
121371
Author
wjmacl...@chromium.org
Date
2012-06-27 14:24:54 -0700 (Wed, 27 Jun 2012)

Log Message

[chromium] ScrollbarLayerChromium should support painting forward-track and back-track in different styles.
https://bugs.webkit.org/show_bug.cgi?id=89908

Reviewed by Adrienne Walker.

Source/WebCore:

Test: platform/chromium/compositing/scrollbars/custom-composited-different-track-parts.html

Adds support for accelerated drawing (impl thread) of scrollbars with different styles for the
forward-track and back-track parts.

* platform/graphics/chromium/ScrollbarLayerChromium.cpp:
(WebCore::ScrollbarLayerChromium::pushPropertiesTo):
(WebCore::ScrollbarBackgroundPainter::create):
(WebCore::ScrollbarBackgroundPainter::ScrollbarBackgroundPainter):
(ScrollbarBackgroundPainter):
(WebCore::ScrollbarLayerChromium::setLayerTreeHost):
(WebCore::ScrollbarLayerChromium::createTextureUpdaterIfNeeded):
(WebCore::ScrollbarLayerChromium::update):
* platform/graphics/chromium/ScrollbarLayerChromium.h:
(ScrollbarLayerChromium):
* platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp:
(WebCore::CCScrollbarLayerImpl::CCScrollbarLayerImpl):
(WebCore):
(WebCore::CCScrollbarLayerImpl::appendQuads):
* platform/graphics/chromium/cc/CCScrollbarLayerImpl.h:
(WebCore::CCScrollbarLayerImpl::setBackTrackTextureId):
(WebCore::CCScrollbarLayerImpl::setForeTrackTextureId):
(CCScrollbarLayerImpl):

LayoutTests:

Adds support for accelerated drawing (impl thread) of scrollbars with different styles for the
forward-track and back-track parts.

* platform/chromium/compositing/scrollbars/custom-composited-different-track-parts-expected.png: Added.
* platform/chromium/compositing/scrollbars/custom-composited-different-track-parts-expected.txt: Added.
* platform/chromium/compositing/scrollbars/custom-composited-different-track-parts.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (121370 => 121371)


--- trunk/LayoutTests/ChangeLog	2012-06-27 21:18:53 UTC (rev 121370)
+++ trunk/LayoutTests/ChangeLog	2012-06-27 21:24:54 UTC (rev 121371)
@@ -1,3 +1,17 @@
+2012-06-27  W. James MacLean  <wjmacl...@chromium.org>
+
+        [chromium] ScrollbarLayerChromium should support painting forward-track and back-track in different styles.
+        https://bugs.webkit.org/show_bug.cgi?id=89908
+
+        Reviewed by Adrienne Walker.
+
+        Adds support for accelerated drawing (impl thread) of scrollbars with different styles for the
+        forward-track and back-track parts.
+
+        * platform/chromium/compositing/scrollbars/custom-composited-different-track-parts-expected.png: Added.
+        * platform/chromium/compositing/scrollbars/custom-composited-different-track-parts-expected.txt: Added.
+        * platform/chromium/compositing/scrollbars/custom-composited-different-track-parts.html: Added.
+
 2012-06-27  Zan Dobersek  <zandober...@gmail.com>
 
         Unreviewed GTK gardening, adding a new baseline that's required

Added: trunk/LayoutTests/platform/chromium/compositing/scrollbars/custom-composited-different-track-parts-expected.png (0 => 121371)


--- trunk/LayoutTests/platform/chromium/compositing/scrollbars/custom-composited-different-track-parts-expected.png	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/compositing/scrollbars/custom-composited-different-track-parts-expected.png	2012-06-27 21:24:54 UTC (rev 121371)
@@ -0,0 +1,5 @@
+\x89PNG
+
+
+IHDR X')tEXtchecksum510b4bd3b00e1396fd976e7c03f1cceb\xA4!\xF3IDATx\x9C\xED\xDDAR*I@Q\xCA`5_\xD7ӓ\xEF^l\xF6\xF2ݑ\xF6\xA4\x93=\xC0\xA8\x81(Wᜉ\x98Qbo\xBC\xAA\x84i\x8C\xB1\xE0\xA8iz{16o\xAF\xA6\xCD\xF8le\xFB\xAD[\xF8\xB1\xE6\x90\xFA\xF0\xD7yeڌ\xBB\xEF\xDB\xC0mX\xA7Ϋ\x8E\)\xB0b &\xB0N\x9BO.\xB9R`\xC4@L`\x9C\xE6!\xC0\x9A@L`\x9C\xE6!\xC0\x9A|\xD93\xC0"\xFB!\xD6\xFC\xB4\xFB<\xD3:\\x99\xC6X:\xEF\xB8Y\xBBi\xB7\xFCb\xB7b &\xB0b &\xB0b &\xB0b &\xB0b &\xB0b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\xEAȕ &\xB0b\xE0\xB4\xF9\x84\xE0\x92+@L`\xC4\xC0iN\xACI`\xC4\xC0iN\xACɗ=,\xB2b\xCDO\xBB\xCF3\xADV\x9E\xFDڿ\xFA\xFD\xFA\xBA\xF1|\xFF\xD9ʿ\xFF\xFC\xF5\xA5\xFB\xE6\xCA<\x8D\xBF\xD7\xDEpU\xA6\xDD\xDA;\xE0\xCA<\xBD\x85ё\xF8\x99W\x96\x9E!\xDCl6\xFB	\xD6\xFC\x97\xEF\xDE\xE8\xDD\xCA\xFC\x9F\xAEû\xBC9\xAC\x9D\xFD\xCAa\xE7,\x80\xD8\xDD\xF2";\xB7\xDD.\xD9\xF2\xBBs\xE7\xDE\xC73\xC1\x88	,\x80\xD8\xDD\xD7
+\xC7.\xD9\xEF\xD7\xD71-\xFA\xF8\xD0G\xB9\xACK`\x9C2\xCE\xFA,\xA7\x80[\xF5|?-+\xA7?g\xBD\xB3	p\xA3ΛJ\x9DC`Ĝ"n\xD4\xE3\xF2S\x84//g\xBD\xB3	p\xB3\xBE\xEA&\xE1vs\xF0-\x86G\xBEP\xE0\x9A\xECGS\xF6O\xBB?\xBE\xBC\xECgZ\x87+g\xF9\xCB\xF5\x9A;\x8F~\x8A\x91IEND\xAEB`\x82
\ No newline at end of file

Added: trunk/LayoutTests/platform/chromium/compositing/scrollbars/custom-composited-different-track-parts-expected.txt (0 => 121371)


--- trunk/LayoutTests/platform/chromium/compositing/scrollbars/custom-composited-different-track-parts-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/compositing/scrollbars/custom-composited-different-track-parts-expected.txt	2012-06-27 21:24:54 UTC (rev 121371)
@@ -0,0 +1 @@
+

Added: trunk/LayoutTests/platform/chromium/compositing/scrollbars/custom-composited-different-track-parts.html (0 => 121371)


--- trunk/LayoutTests/platform/chromium/compositing/scrollbars/custom-composited-different-track-parts.html	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/compositing/scrollbars/custom-composited-different-track-parts.html	2012-06-27 21:24:54 UTC (rev 121371)
@@ -0,0 +1,75 @@
+<html>
+<head>
+<title>Composited Scrollbars: different track part colours.</title>
+<style>
+::-webkit-scrollbar {
+    width: 15px;
+    height: 15px;
+}
+::-webkit-scrollbar-button:vertical:start {
+    background-color: red;
+    border: 1px dashed blue;
+}
+::-webkit-scrollbar-button:vertical:end {
+    background-color: blue;
+    border: 1px dashed red;
+}
+::-webkit-scrollbar-track-piece:start {
+    background-color: purple;
+}
+::-webkit-scrollbar-track-piece:end {
+    background-color: green;
+} 
+::-webkit-scrollbar-button:start:decrement,
+::-webkit-scrollbar-button:end:increment {
+    display: block;
+}
+::-webkit-scrollbar-thumb {
+    height: 20px;
+    background-color: yellow;
+}
+::-webkit-scrollbar-button:horizontal:start {
+    background-color: cyan;
+    border: 1px dashed brown;
+}
+::-webkit-scrollbar-button:horizontal:end {
+    background-color: brown;
+    border: 1px dashed cyan;
+}
+</style>
+<script>
+  if (window.internals) {
+    window.internals.settings.setMockScrollbarsEnabled(false);
+  }
+  if (window.testRunner) {
+    window.testRunner.waitUntilDone();
+    window.testRunner.dumpAsText(true); // This is only useful as a pixel test.
+  }
+
+  function doTest()
+  {
+    window.scrollTo(400,300);
+    window.setTimeout(function() {
+      if (window.testRunner) {
+        window.testRunner.notifyDone();
+      }
+    }, 0);
+  }
+
+  window.addEventListener("load", doTest, false);
+</script>
+</head>
+<body>
+<div style="width: 1600px; height: 1000px; -webkit-transform: translateZ(0);">
+</div>
+<div style="position : absolute; left : 450; top : 350; width : 200px; height : 100px; border-style : solid; border-color : green; border-width : 2px">
+<!---
+<h2>Composited Custom Scrollbars with Different Coloured Track Parts</h2>
+If this test succeeds, the track part before the thumb will be purple, and the track part after
+the thumb will be green. All four button rects will have different colours.
+
+The div border should be in the top-left area of the window.
+--->
+</div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (121370 => 121371)


--- trunk/Source/WebCore/ChangeLog	2012-06-27 21:18:53 UTC (rev 121370)
+++ trunk/Source/WebCore/ChangeLog	2012-06-27 21:24:54 UTC (rev 121371)
@@ -1,3 +1,34 @@
+2012-06-27  W. James MacLean  <wjmacl...@chromium.org>
+
+        [chromium] ScrollbarLayerChromium should support painting forward-track and back-track in different styles.
+        https://bugs.webkit.org/show_bug.cgi?id=89908
+
+        Reviewed by Adrienne Walker.
+
+        Test: platform/chromium/compositing/scrollbars/custom-composited-different-track-parts.html
+
+        Adds support for accelerated drawing (impl thread) of scrollbars with different styles for the
+        forward-track and back-track parts.
+
+        * platform/graphics/chromium/ScrollbarLayerChromium.cpp:
+        (WebCore::ScrollbarLayerChromium::pushPropertiesTo):
+        (WebCore::ScrollbarBackgroundPainter::create):
+        (WebCore::ScrollbarBackgroundPainter::ScrollbarBackgroundPainter):
+        (ScrollbarBackgroundPainter):
+        (WebCore::ScrollbarLayerChromium::setLayerTreeHost):
+        (WebCore::ScrollbarLayerChromium::createTextureUpdaterIfNeeded):
+        (WebCore::ScrollbarLayerChromium::update):
+        * platform/graphics/chromium/ScrollbarLayerChromium.h:
+        (ScrollbarLayerChromium):
+        * platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp:
+        (WebCore::CCScrollbarLayerImpl::CCScrollbarLayerImpl):
+        (WebCore):
+        (WebCore::CCScrollbarLayerImpl::appendQuads):
+        * platform/graphics/chromium/cc/CCScrollbarLayerImpl.h:
+        (WebCore::CCScrollbarLayerImpl::setBackTrackTextureId):
+        (WebCore::CCScrollbarLayerImpl::setForeTrackTextureId):
+        (CCScrollbarLayerImpl):
+
 2012-06-27  Ian Vollick  <voll...@chromium.org>
 
         [chromium] Allow screen space rects and occluding rects to be visualized for debugging.

Modified: trunk/Source/WebCore/platform/graphics/chromium/ScrollbarLayerChromium.cpp (121370 => 121371)


--- trunk/Source/WebCore/platform/graphics/chromium/ScrollbarLayerChromium.cpp	2012-06-27 21:18:53 UTC (rev 121370)
+++ trunk/Source/WebCore/platform/graphics/chromium/ScrollbarLayerChromium.cpp	2012-06-27 21:24:54 UTC (rev 121371)
@@ -76,11 +76,16 @@
 
     scrollbarLayer->setScrollbarOverlayStyle(m_scrollbarOverlayStyle);
 
-    if (m_background && m_background->texture()->isReserved())
-        scrollbarLayer->setBackgroundTextureId(m_background->texture()->textureId());
+    if (m_backTrack && m_backTrack->texture()->isReserved())
+        scrollbarLayer->setBackTrackTextureId(m_backTrack->texture()->textureId());
     else
-        scrollbarLayer->setBackgroundTextureId(0);
+        scrollbarLayer->setBackTrackTextureId(0);
 
+    if (m_foreTrack && m_foreTrack->texture()->isReserved())
+        scrollbarLayer->setForeTrackTextureId(m_foreTrack->texture()->textureId());
+    else
+        scrollbarLayer->setForeTrackTextureId(0);
+
     if (m_thumb && m_thumb->texture()->isReserved())
         scrollbarLayer->setThumbTextureId(m_thumb->texture()->textureId());
     else
@@ -106,9 +111,9 @@
 class ScrollbarBackgroundPainter : public LayerPainterChromium {
     WTF_MAKE_NONCOPYABLE(ScrollbarBackgroundPainter);
 public:
-    static PassOwnPtr<ScrollbarBackgroundPainter> create(ScrollbarThemeClient* scrollbar, ScrollbarThemeComposite* theme)
+    static PassOwnPtr<ScrollbarBackgroundPainter> create(ScrollbarThemeClient* scrollbar, ScrollbarThemeComposite* theme, ScrollbarPart trackPart)
     {
-        return adoptPtr(new ScrollbarBackgroundPainter(scrollbar, theme));
+        return adoptPtr(new ScrollbarBackgroundPainter(scrollbar, theme, trackPart));
     }
 
     virtual void paint(SkCanvas* canvas, const IntRect& contentRect, IntRect&) OVERRIDE
@@ -138,26 +143,22 @@
         m_theme->paintTrackBackground(&context, m_scrollbar, trackPaintRect);
 
         bool thumbPresent = m_theme->hasThumb(m_scrollbar);
-        if (thumbPresent) {
-            // FIXME: There's no "paint the whole track" part. Drawing both the
-            // BackTrackPart and the ForwardTrackPart in their splitTrack rects
-            // ends up leaving a distinctive line. Painting one part as the
-            // entire track appears to be identical to painting both and
-            // covering up the split between them with the thumb.
-            m_theme->paintTrackPiece(&context, m_scrollbar, trackPaintRect, BackTrackPart);
-        }
+        if (thumbPresent)
+            m_theme->paintTrackPiece(&context, m_scrollbar, trackPaintRect, m_trackPart);
 
         m_theme->paintTickmarks(&context, m_scrollbar, trackPaintRect);
     }
 private:
-    ScrollbarBackgroundPainter(ScrollbarThemeClient* scrollbar, ScrollbarThemeComposite* theme)
+    ScrollbarBackgroundPainter(ScrollbarThemeClient* scrollbar, ScrollbarThemeComposite* theme, ScrollbarPart trackPart)
         : m_scrollbar(scrollbar)
         , m_theme(theme)
+        , m_trackPart(trackPart)
     {
     }
 
     ScrollbarThemeClient* m_scrollbar;
     ScrollbarThemeComposite* m_theme;
+    ScrollbarPart m_trackPart;
 };
 
 class ScrollbarThumbPainter : public LayerPainterChromium {
@@ -193,8 +194,8 @@
 void ScrollbarLayerChromium::setLayerTreeHost(CCLayerTreeHost* host)
 {
     if (!host || host != layerTreeHost()) {
-        m_backgroundUpdater.clear();
-        m_background.clear();
+        m_backTrackUpdater.clear();
+        m_backTrack.clear();
         m_thumbUpdater.clear();
         m_thumb.clear();
     }
@@ -207,11 +208,20 @@
     bool useMapSubImage = layerTreeHost()->layerRendererCapabilities().usingMapSub;
     m_textureFormat = layerTreeHost()->layerRendererCapabilities().bestTextureFormat;
 
-    if (!m_backgroundUpdater)
-        m_backgroundUpdater = BitmapCanvasLayerTextureUpdater::create(ScrollbarBackgroundPainter::create(m_scrollbar.get(), theme()), useMapSubImage);
-    if (!m_background)
-        m_background = m_backgroundUpdater->createTexture(layerTreeHost()->contentsTextureManager());
+    if (!m_backTrackUpdater)
+        m_backTrackUpdater = BitmapCanvasLayerTextureUpdater::create(ScrollbarBackgroundPainter::create(m_scrollbar.get(), theme(), BackTrackPart), useMapSubImage);
+    if (!m_backTrack)
+        m_backTrack = m_backTrackUpdater->createTexture(layerTreeHost()->contentsTextureManager());
 
+    // Only create two-part track if we think the two parts could be different in appearance.
+    if (m_scrollbar->isCustomScrollbar()) {
+        if (!m_foreTrackUpdater)
+            m_foreTrackUpdater = BitmapCanvasLayerTextureUpdater::create(ScrollbarBackgroundPainter::create(m_scrollbar.get(), theme(), ForwardTrackPart), useMapSubImage);
+        if (!m_foreTrack)
+            m_foreTrack = m_foreTrackUpdater->createTexture(layerTreeHost()->contentsTextureManager());
+    }
+
+
     if (!m_thumbUpdater)
         m_thumbUpdater = BitmapCanvasLayerTextureUpdater::create(ScrollbarThumbPainter::create(m_scrollbar.get(), theme()), useMapSubImage);
     if (!m_thumb)
@@ -253,7 +263,9 @@
 
     IntPoint scrollbarOrigin(m_scrollbar->x(), m_scrollbar->y());
     IntRect contentRect(scrollbarOrigin, contentBounds());
-    updatePart(m_backgroundUpdater.get(), m_background.get(), contentRect, updater);
+    updatePart(m_backTrackUpdater.get(), m_backTrack.get(), contentRect, updater);
+    if (m_foreTrack && m_foreTrackUpdater)
+        updatePart(m_foreTrackUpdater.get(), m_foreTrack.get(), contentRect, updater);
 
     // Consider the thumb to be at the origin when painting.
     IntRect thumbRect = IntRect(IntPoint(), theme()->thumbRect(m_scrollbar.get()).size());

Modified: trunk/Source/WebCore/platform/graphics/chromium/ScrollbarLayerChromium.h (121370 => 121371)


--- trunk/Source/WebCore/platform/graphics/chromium/ScrollbarLayerChromium.h	2012-06-27 21:18:53 UTC (rev 121370)
+++ trunk/Source/WebCore/platform/graphics/chromium/ScrollbarLayerChromium.h	2012-06-27 21:24:54 UTC (rev 121371)
@@ -66,11 +66,13 @@
 
     GC3Denum m_textureFormat;
 
-    RefPtr<LayerTextureUpdater> m_backgroundUpdater;
+    RefPtr<LayerTextureUpdater> m_backTrackUpdater;
+    RefPtr<LayerTextureUpdater> m_foreTrackUpdater;
     RefPtr<LayerTextureUpdater> m_thumbUpdater;
 
     // All the parts of the scrollbar except the thumb
-    OwnPtr<LayerTextureUpdater::Texture> m_background;
+    OwnPtr<LayerTextureUpdater::Texture> m_backTrack;
+    OwnPtr<LayerTextureUpdater::Texture> m_foreTrack;
     OwnPtr<LayerTextureUpdater::Texture> m_thumb;
 
     ScrollbarOverlayStyle m_scrollbarOverlayStyle;

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp (121370 => 121371)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp	2012-06-27 21:18:53 UTC (rev 121370)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp	2012-06-27 21:24:54 UTC (rev 121371)
@@ -45,11 +45,23 @@
     : CCLayerImpl(id)
     , m_scrollLayer(0)
     , m_scrollbar(this)
-    , m_backgroundTextureId(0)
+    , m_backTrackTextureId(0)
+    , m_foreTrackTextureId(0)
     , m_thumbTextureId(0)
 {
 }
 
+namespace {
+
+FloatRect toUVRect(const IntRect& r, const IntRect& bounds)
+{
+    ASSERT(bounds.contains(r));
+    return FloatRect(static_cast<float>(r.x()) / bounds.width(), static_cast<float>(r.y()) / bounds.height(),
+                     static_cast<float>(r.width()) / bounds.width(), static_cast<float>(r.height()) / bounds.height());
+}
+
+}
+
 void CCScrollbarLayerImpl::appendQuads(CCQuadCuller& quadList, const CCSharedQuadState* sharedQuadState, bool&)
 {
     ScrollbarThemeComposite* theme = static_cast<ScrollbarThemeComposite*>(ScrollbarTheme::theme());
@@ -57,24 +69,33 @@
         return;
 
     bool premultipledAlpha = false;
+    bool flipped = false;
     FloatRect uvRect(0, 0, 1, 1);
-    bool flipped = false;
+    IntRect boundsRect(IntPoint(), contentBounds());
 
-    IntRect thumbRect = theme->thumbRect(&m_scrollbar);
-    thumbRect.move(-m_scrollbar.x(), -m_scrollbar.y());
+    IntRect thumbRect, backTrackRect, foreTrackRect;
+    theme->splitTrack(&m_scrollbar, theme->trackRect(&m_scrollbar), backTrackRect, thumbRect, foreTrackRect);
+
     if (m_thumbTextureId && theme->hasThumb(&m_scrollbar) && !thumbRect.isEmpty()) {
         OwnPtr<CCTextureDrawQuad> quad = CCTextureDrawQuad::create(sharedQuadState, thumbRect, m_thumbTextureId, premultipledAlpha, uvRect, flipped);
         quad->setNeedsBlending();
         quadList.append(quad.release());
     }
 
-    if (!m_backgroundTextureId)
+    if (!m_backTrackTextureId)
         return;
 
-    IntRect backgroundRect(IntPoint(), contentBounds());
-    quadList.append(CCTextureDrawQuad::create(sharedQuadState, backgroundRect, m_backgroundTextureId, premultipledAlpha, uvRect, flipped));
+    // We only paint the track in two parts if we were given a texture for the forward track part.
+    if (m_foreTrackTextureId && !foreTrackRect.isEmpty())
+        quadList.append(CCTextureDrawQuad::create(sharedQuadState, foreTrackRect, m_foreTrackTextureId, premultipledAlpha, toUVRect(foreTrackRect, boundsRect), flipped));
+
+    // Order matters here: since the back track texture is being drawn to the entire contents rect, we must append it after the thumb and
+    // fore track quads. The back track texture contains (and displays) the buttons.
+    if (!boundsRect.isEmpty())
+        quadList.append(CCTextureDrawQuad::create(sharedQuadState, boundsRect, m_backTrackTextureId, premultipledAlpha, uvRect, flipped));
 }
 
+
 int CCScrollbarLayerImpl::CCScrollbar::x() const
 {
     return frameRect().x();

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.h (121370 => 121371)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.h	2012-06-27 21:18:53 UTC (rev 121370)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.h	2012-06-27 21:24:54 UTC (rev 121371)
@@ -54,7 +54,8 @@
 
     void setEnabled(bool enabled) { m_enabled = enabled; }
 
-    void setBackgroundTextureId(unsigned id) { m_backgroundTextureId = id; }
+    void setBackTrackTextureId(unsigned id) { m_backTrackTextureId = id; }
+    void setForeTrackTextureId(unsigned id) { m_foreTrackTextureId = id; }
     void setThumbTextureId(unsigned id) { m_thumbTextureId = id; }
 
     CCLayerImpl* scrollLayer() const { return m_scrollLayer; }
@@ -124,7 +125,8 @@
     };
     CCScrollbar m_scrollbar;
 
-    unsigned m_backgroundTextureId;
+    unsigned m_backTrackTextureId;
+    unsigned m_foreTrackTextureId;
     unsigned m_thumbTextureId;
 
     ScrollbarOverlayStyle m_scrollbarOverlayStyle;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to