<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[37486] trunk/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/37486">37486</a></dd>
<dt>Author</dt> <dd>hyatt@apple.com</dd>
<dt>Date</dt> <dd>2008-10-10 12:32:52 -0700 (Fri, 10 Oct 2008)</dd>
</dl>

<h3>Log Message</h3>
<pre>2008-10-10  David Hyatt  &lt;hyatt@apple.com&gt;

        https://bugs.webkit.org/show_bug.cgi?id=21527

        Make CSS scrollbars support :not, :hover and :active.

        Reviewed by Adam Roben

        Added WebCore/manual-tests/scrollbar-hover-active.html

        * css/CSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector):
        (WebCore::CSSStyleSelector::SelectorChecker::checkScrollbarPseudoClass):
        * platform/Scrollbar.cpp:
        (WebCore::Scrollbar::autoscrollPressedPart):
        (WebCore::Scrollbar::startTimerIfNeeded):
        (WebCore::Scrollbar::setHoveredPart):
        (WebCore::Scrollbar::setPressedPart):
        (WebCore::Scrollbar::mouseMoved):
        (WebCore::Scrollbar::mouseExited):
        (WebCore::Scrollbar::mouseUp):
        (WebCore::Scrollbar::mouseDown):
        * platform/Scrollbar.h:
        * rendering/RenderScrollbar.cpp:
        (WebCore::RenderScrollbar::setHoveredPart):
        (WebCore::RenderScrollbar::setPressedPart):
        (WebCore::RenderScrollbar::updateScrollbarParts):
        (WebCore::pseudoForScrollbarPart):
        (WebCore::RenderScrollbar::updateScrollbarPart):
        * rendering/RenderScrollbar.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCorecssCSSStyleSelectorcpp">trunk/WebCore/css/CSSStyleSelector.cpp</a></li>
<li><a href="#trunkWebCoreplatformScrollbarcpp">trunk/WebCore/platform/Scrollbar.cpp</a></li>
<li><a href="#trunkWebCoreplatformScrollbarh">trunk/WebCore/platform/Scrollbar.h</a></li>
<li><a href="#trunkWebCorerenderingRenderScrollbarcpp">trunk/WebCore/rendering/RenderScrollbar.cpp</a></li>
<li><a href="#trunkWebCorerenderingRenderScrollbarh">trunk/WebCore/rendering/RenderScrollbar.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkWebCoremanualtestsscrollbarhoveractivehtml">trunk/WebCore/manual-tests/scrollbar-hover-active.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (37485 => 37486)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2008-10-10 18:43:47 UTC (rev 37485)
+++ trunk/WebCore/ChangeLog        2008-10-10 19:32:52 UTC (rev 37486)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2008-10-10  David Hyatt  &lt;hyatt@apple.com&gt;
+
+        https://bugs.webkit.org/show_bug.cgi?id=21527
+
+        Make CSS scrollbars support :not, :hover and :active.
+
+        Reviewed by Adam Roben
+
+        Added WebCore/manual-tests/scrollbar-hover-active.html
+
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector):
+        (WebCore::CSSStyleSelector::SelectorChecker::checkScrollbarPseudoClass):
+        * platform/Scrollbar.cpp:
+        (WebCore::Scrollbar::autoscrollPressedPart):
+        (WebCore::Scrollbar::startTimerIfNeeded):
+        (WebCore::Scrollbar::setHoveredPart):
+        (WebCore::Scrollbar::setPressedPart):
+        (WebCore::Scrollbar::mouseMoved):
+        (WebCore::Scrollbar::mouseExited):
+        (WebCore::Scrollbar::mouseUp):
+        (WebCore::Scrollbar::mouseDown):
+        * platform/Scrollbar.h:
+        * rendering/RenderScrollbar.cpp:
+        (WebCore::RenderScrollbar::setHoveredPart):
+        (WebCore::RenderScrollbar::setPressedPart):
+        (WebCore::RenderScrollbar::updateScrollbarParts):
+        (WebCore::pseudoForScrollbarPart):
+        (WebCore::RenderScrollbar::updateScrollbarPart):
+        * rendering/RenderScrollbar.h:
+
</ins><span class="cx"> 2008-10-10  Chris Marrin  &lt;cmarrin@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Dan Bernstein.
</span></span></pre></div>
<a id="trunkWebCorecssCSSStyleSelectorcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/css/CSSStyleSelector.cpp (37485 => 37486)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/css/CSSStyleSelector.cpp        2008-10-10 18:43:47 UTC (rev 37485)
+++ trunk/WebCore/css/CSSStyleSelector.cpp        2008-10-10 19:32:52 UTC (rev 37486)
</span><span class="lines">@@ -1837,16 +1837,30 @@
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">     }
</span><ins>+    
</ins><span class="cx">     if (sel-&gt;m_match == CSSSelector::PseudoClass) {
</span><del>-        
-        // CSS scrollbars match a specific subset of pseudo classes, and they have specialized rules for each
-        // (since there are no elements involved).
-        if (RenderScrollbar::scrollbarForStyleResolve() &amp;&amp; dynamicPseudo != RenderStyle::NOPSEUDO)
</del><ins>+        // Handle :not up front.
+        if (sel-&gt;pseudoType() == CSSSelector::PseudoNot) {
+            // check the simple selector
+            for (CSSSelector* subSel = sel-&gt;m_simpleSelector; subSel; subSel = subSel-&gt;m_tagHistory) {
+                // :not cannot nest. I don't really know why this is a
+                // restriction in CSS3, but it is, so let's honor it.
+                if (subSel-&gt;m_simpleSelector)
+                    break;
+                if (!checkOneSelector(subSel, e, selectorAttrs, dynamicPseudo, isAncestor, true, elementStyle, elementParentStyle))
+                    return true;
+            }
+        } else if (RenderScrollbar::scrollbarForStyleResolve() &amp;&amp; dynamicPseudo != RenderStyle::NOPSEUDO) {
+            // CSS scrollbars match a specific subset of pseudo classes, and they have specialized rules for each
+            // (since there are no elements involved).
</ins><span class="cx">             return checkScrollbarPseudoClass(sel, dynamicPseudo);
</span><ins>+        }
</ins><span class="cx">         
</span><span class="cx">         // Normal element pseudo class checking.
</span><span class="cx">         switch (sel-&gt;pseudoType()) {
</span><span class="cx">             // Pseudo classes:
</span><ins>+            case CSSSelector::PseudoNot:
+                break; // Already handled up above.
</ins><span class="cx">             case CSSSelector::PseudoEmpty: {
</span><span class="cx">                 bool result = true;
</span><span class="cx">                 for (Node* n = e-&gt;firstChild(); n; n = n-&gt;nextSibling()) {
</span><span class="lines">@@ -2262,18 +2276,6 @@
</span><span class="cx">                     break;
</span><span class="cx">                 return true;
</span><span class="cx">             }
</span><del>-            case CSSSelector::PseudoNot: {
-                // check the simple selector
-                for (CSSSelector* subSel = sel-&gt;m_simpleSelector; subSel; subSel = subSel-&gt;m_tagHistory) {
-                    // :not cannot nest. I don't really know why this is a
-                    // restriction in CSS3, but it is, so let's honour it.
-                    if (subSel-&gt;m_simpleSelector)
-                        break;
-                    if (!checkOneSelector(subSel, e, selectorAttrs, dynamicPseudo, isAncestor, true, elementStyle, elementParentStyle))
-                        return true;
-                }
-                break;
-            }
</del><span class="cx">             case CSSSelector::PseudoUnknown:
</span><span class="cx">             case CSSSelector::PseudoNotParsed:
</span><span class="cx">             default:
</span><span class="lines">@@ -2391,6 +2393,22 @@
</span><span class="cx">             return scrollbar-&gt;enabled();
</span><span class="cx">         case CSSSelector::PseudoDisabled:
</span><span class="cx">             return !scrollbar-&gt;enabled();
</span><ins>+        case CSSSelector::PseudoHover: {
+            ScrollbarPart hoveredPart = scrollbar-&gt;hoveredPart();
+            if (part == ScrollbarBGPart)
+                return hoveredPart != NoPart;
+            if (part == TrackBGPart)
+                return hoveredPart == BackTrackPart || hoveredPart == ForwardTrackPart || hoveredPart == ThumbPart;
+            return part == hoveredPart;
+        }
+        case CSSSelector::PseudoActive: {
+            ScrollbarPart pressedPart = scrollbar-&gt;pressedPart();
+            if (part == ScrollbarBGPart)
+                return pressedPart != NoPart;
+            if (part == TrackBGPart)
+                return pressedPart == BackTrackPart || pressedPart == ForwardTrackPart || pressedPart == ThumbPart;
+            return part == pressedPart;
+        }
</ins><span class="cx">         case CSSSelector::PseudoHorizontal:
</span><span class="cx">             return scrollbar-&gt;orientation() == HorizontalScrollbar;
</span><span class="cx">         case CSSSelector::PseudoVertical:
</span></span></pre></div>
<a id="trunkWebCoremanualtestsscrollbarhoveractivehtml"></a>
<div class="addfile"><h4>Added: trunk/WebCore/manual-tests/scrollbar-hover-active.html (0 => 37486)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/manual-tests/scrollbar-hover-active.html                                (rev 0)
+++ trunk/WebCore/manual-tests/scrollbar-hover-active.html        2008-10-10 19:32:52 UTC (rev 37486)
</span><span class="lines">@@ -0,0 +1,76 @@
</span><ins>+&lt;head&gt;
+&lt;style&gt;
+div::-webkit-scrollbar {
+  width:17px;
+  height:17px;
+}
+
+div::-webkit-scrollbar-button {
+  display: block;
+  width: 17px;
+  height: 17px;
+}
+
+div::-webkit-scrollbar-button:-webkit-decrement:-webkit-start {
+  background-color:lightblue;
+  border:2px solid black;
+}
+
+div::-webkit-scrollbar-button:-webkit-increment:-webkit-start {
+  background-color:lightgreen;
+  border:2px solid black;
+}
+
+div::-webkit-scrollbar-button:-webkit-decrement:-webkit-end {
+  background-color:orange;
+  border:2px solid black;
+}
+
+div::-webkit-scrollbar-button:-webkit-increment:-webkit-end {
+  background-color:brown;
+  border:2px solid black;
+}
+
+div::-webkit-scrollbar-button:hover {
+  background-color:black !important;
+}
+
+div::-webkit-scrollbar-thumb {
+  min-width:20px;
+  min-height:20px;
+  background-color: navy;
+  border:2px solid #cccccc;
+}
+
+div::-webkit-scrollbar-track {
+  background-color: pink;
+}
+
+div::-webkit-scrollbar-thumb:hover {
+  background-color: green;
+}
+
+div::-webkit-scrollbar-thumb:active {
+  border:3px dotted white;
+}
+
+div::-webkit-scrollbar-track:hover {
+  background-color: maroon;
+}
+
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div style=&quot;width:200px; height:200px; overflow-y:scroll; overflow-x:hidden&quot;&gt;
+Hello&lt;br&gt;
+Hello&lt;br&gt;Hello&lt;br&gt;Hello&lt;br&gt;Hello&lt;br&gt;Hello&lt;br&gt;Hello&lt;br&gt;Hello&lt;br&gt;
+Hello&lt;br&gt;Hello&lt;br&gt;Hello&lt;br&gt;Hello&lt;br&gt;
+Hello&lt;br&gt;Hello&lt;br&gt;Hello&lt;br&gt;Hello&lt;br&gt;
+&lt;span style=&quot;white-space:nowrap&quot;&gt;Hello world this is a long string and will not wrap.&lt;/span&gt;
+Hello&lt;br&gt;Hello&lt;br&gt;Hello&lt;br&gt;Hello&lt;br&gt;
+Hello&lt;br&gt;Hello&lt;br&gt;Hello&lt;br&gt;Hello&lt;br&gt;Hello&lt;br&gt;Hello&lt;br&gt;
+Hello&lt;br&gt;Hello&lt;br&gt;Hello&lt;br&gt;Hello&lt;br&gt;
+Hello&lt;br&gt;Hello&lt;br&gt;Hello&lt;br&gt;Hello&lt;br&gt;Hello&lt;br&gt;Hello&lt;br&gt;
+Hello&lt;br&gt;Hello&lt;br&gt;Hello&lt;br&gt;Hello&lt;br&gt;
+Hello&lt;br&gt;Hello&lt;br&gt;Hello&lt;br&gt;
+&lt;/div&gt;
</ins></span></pre></div>
<a id="trunkWebCoreplatformScrollbarcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/Scrollbar.cpp (37485 => 37486)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/Scrollbar.cpp        2008-10-10 18:43:47 UTC (rev 37485)
+++ trunk/WebCore/platform/Scrollbar.cpp        2008-10-10 19:32:52 UTC (rev 37486)
</span><span class="lines">@@ -200,7 +200,7 @@
</span><span class="cx">     // Handle the track.
</span><span class="cx">     if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) &amp;&amp; thumbUnderMouse(this)) {
</span><span class="cx">         theme()-&gt;invalidatePart(this, m_pressedPart);
</span><del>-        m_hoveredPart = ThumbPart;
</del><ins>+        setHoveredPart(ThumbPart);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -219,7 +219,7 @@
</span><span class="cx">     // with us.
</span><span class="cx">     if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) &amp;&amp; thumbUnderMouse(this)) {
</span><span class="cx">         theme()-&gt;invalidatePart(this, m_pressedPart);
</span><del>-        m_hoveredPart = ThumbPart;
</del><ins>+        setHoveredPart(ThumbPart);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -280,6 +280,29 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Scrollbar::setHoveredPart(ScrollbarPart part)
+{
+    if (part == m_hoveredPart)
+        return;
+
+    if ((m_hoveredPart == NoPart || part == NoPart) &amp;&amp; theme()-&gt;invalidateOnMouseEnterExit())
+        invalidate();  // Just invalidate the whole scrollbar, since the buttons at either end change anyway.
+    else if (m_pressedPart == NoPart) {
+        theme()-&gt;invalidatePart(this, part);
+        theme()-&gt;invalidatePart(this, m_hoveredPart);
+    }
+    m_hoveredPart = part;
+}
+
+void Scrollbar::setPressedPart(ScrollbarPart part)
+{
+    if (m_pressedPart != NoPart)
+        theme()-&gt;invalidatePart(this, m_pressedPart);
+    m_pressedPart = part;
+    if (m_pressedPart != NoPart)
+        theme()-&gt;invalidatePart(this, m_pressedPart);
+}
+
</ins><span class="cx"> bool Scrollbar::mouseMoved(const PlatformMouseEvent&amp; evt)
</span><span class="cx"> {
</span><span class="cx">     if (m_pressedPart == ThumbPart) {
</span><span class="lines">@@ -294,9 +317,6 @@
</span><span class="cx"> 
</span><span class="cx">     ScrollbarPart part = theme()-&gt;hitTest(this, evt);    
</span><span class="cx">     if (part != m_hoveredPart) {
</span><del>-        if (m_hoveredPart == NoPart &amp;&amp; theme()-&gt;invalidateOnMouseEnterExit())
-            invalidate();  // Just invalidate the whole scrollbar, since the buttons at either end change anyway.
-
</del><span class="cx">         if (m_pressedPart != NoPart) {
</span><span class="cx">             if (part == m_pressedPart) {
</span><span class="cx">                 // The mouse is moving back over the pressed part.  We
</span><span class="lines">@@ -309,11 +329,9 @@
</span><span class="cx">                 stopTimerIfNeeded();
</span><span class="cx">                 theme()-&gt;invalidatePart(this, m_pressedPart);
</span><span class="cx">             }
</span><del>-        } else {
-            theme()-&gt;invalidatePart(this, part);
-            theme()-&gt;invalidatePart(this, m_hoveredPart);
-        }
-        m_hoveredPart = part;
</del><ins>+        } 
+        
+        setHoveredPart(part);
</ins><span class="cx">     } 
</span><span class="cx"> 
</span><span class="cx">     return true;
</span><span class="lines">@@ -321,18 +339,13 @@
</span><span class="cx"> 
</span><span class="cx"> bool Scrollbar::mouseExited()
</span><span class="cx"> {
</span><del>-    if (theme()-&gt;invalidateOnMouseEnterExit())
-        invalidate(); // Just invalidate the whole scrollbar, since the buttons at either end change anyway.
-    else
-        theme()-&gt;invalidatePart(this, m_hoveredPart);
-    m_hoveredPart = NoPart;
</del><ins>+    setHoveredPart(NoPart);
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool Scrollbar::mouseUp()
</span><span class="cx"> {
</span><del>-    theme()-&gt;invalidatePart(this, m_pressedPart);
-    m_pressedPart = NoPart;
</del><ins>+    setPressedPart(NoPart);
</ins><span class="cx">     m_pressedPos = 0;
</span><span class="cx">     stopTimerIfNeeded();
</span><span class="cx"> 
</span><span class="lines">@@ -348,11 +361,12 @@
</span><span class="cx">     if (evt.button() == RightButton)
</span><span class="cx">         return true; // FIXME: Handled as context menu by Qt right now.  Should just avoid even calling this method on a right click though.
</span><span class="cx"> 
</span><del>-    m_pressedPart = theme()-&gt;hitTest(this, evt);
</del><ins>+    setPressedPart(theme()-&gt;hitTest(this, evt));
</ins><span class="cx">     int pressedPos = (orientation() == HorizontalScrollbar ? convertFromContainingWindow(evt.pos()).x() : convertFromContainingWindow(evt.pos()).y());
</span><span class="cx">     
</span><span class="cx">     if (theme()-&gt;shouldCenterOnThumb(this, evt)) {
</span><del>-        m_hoveredPart = m_pressedPart = ThumbPart;
</del><ins>+        setHoveredPart(ThumbPart);
+        setPressedPart(ThumbPart);
</ins><span class="cx">         int thumbLen = theme()-&gt;thumbLength(this);
</span><span class="cx">         int desiredPos = pressedPos - thumbLen / 2;
</span><span class="cx">         // Set the pressed position to the top of the thumb so that when we do the move, the delta
</span><span class="lines">@@ -364,7 +378,6 @@
</span><span class="cx">     
</span><span class="cx">     m_pressedPos = pressedPos;
</span><span class="cx"> 
</span><del>-    theme()-&gt;invalidatePart(this, m_pressedPart);
</del><span class="cx">     autoscrollPressedPart(theme()-&gt;initialAutoscrollTimerDelay());
</span><span class="cx">     return true;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkWebCoreplatformScrollbarh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/Scrollbar.h (37485 => 37486)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/Scrollbar.h        2008-10-10 18:43:47 UTC (rev 37485)
+++ trunk/WebCore/platform/Scrollbar.h        2008-10-10 19:32:52 UTC (rev 37486)
</span><span class="lines">@@ -75,6 +75,8 @@
</span><span class="cx">     
</span><span class="cx">     ScrollbarPart pressedPart() const { return m_pressedPart; }
</span><span class="cx">     ScrollbarPart hoveredPart() const { return m_hoveredPart; }
</span><ins>+    virtual void setHoveredPart(ScrollbarPart);
+    virtual void setPressedPart(ScrollbarPart);
</ins><span class="cx"> 
</span><span class="cx">     void setSteps(int lineStep, int pageStep, int pixelsPerStep = 1);
</span><span class="cx">     bool setValue(int);
</span></span></pre></div>
<a id="trunkWebCorerenderingRenderScrollbarcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/rendering/RenderScrollbar.cpp (37485 => 37486)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/rendering/RenderScrollbar.cpp        2008-10-10 18:43:47 UTC (rev 37485)
+++ trunk/WebCore/rendering/RenderScrollbar.cpp        2008-10-10 19:32:52 UTC (rev 37486)
</span><span class="lines">@@ -71,6 +71,39 @@
</span><span class="cx">     Scrollbar::paint(context, damageRect);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void RenderScrollbar::setHoveredPart(ScrollbarPart part)
+{
+    if (part == m_hoveredPart)
+        return;
+
+    ScrollbarPart oldPart = m_hoveredPart;
+    Scrollbar::setHoveredPart(part);
+
+    updateScrollbarPart(oldPart);
+    updateScrollbarPart(m_hoveredPart);
+
+    // FIXME: Shouldn't always update the hover state of the scrollbar and track bg.
+    updateScrollbarPart(ScrollbarBGPart);
+    updateScrollbarPart(TrackBGPart);
+    invalidate();
+
+    m_hoveredPart = part;
+}
+
+void RenderScrollbar::setPressedPart(ScrollbarPart part)
+{
+    ScrollbarPart oldPart = m_pressedPart;
+    Scrollbar::setPressedPart(part);
+    
+    updateScrollbarPart(oldPart);
+    updateScrollbarPart(part);
+    
+    // FIXME: Shouldn't always update the active state of the scrollbar and track bg.
+    updateScrollbarPart(ScrollbarBGPart);
+    updateScrollbarPart(TrackBGPart);
+    invalidate();
+}
+
</ins><span class="cx"> static ScrollbarPart s_styleResolvePart;
</span><span class="cx"> static RenderScrollbar* s_styleResolveScrollbar;
</span><span class="cx"> 
</span><span class="lines">@@ -96,15 +129,15 @@
</span><span class="cx"> 
</span><span class="cx"> void RenderScrollbar::updateScrollbarParts(RenderStyle* scrollbarStyle, bool destroy)
</span><span class="cx"> {
</span><del>-    updateScrollbarPart(ScrollbarBGPart, RenderStyle::SCROLLBAR, scrollbarStyle, destroy);
-    updateScrollbarPart(BackButtonStartPart, RenderStyle::SCROLLBAR_BUTTON, 0, destroy);
-    updateScrollbarPart(ForwardButtonStartPart, RenderStyle::SCROLLBAR_BUTTON, 0, destroy);
-    updateScrollbarPart(BackTrackPart, RenderStyle::SCROLLBAR_TRACK_PIECE, 0, destroy);
-    updateScrollbarPart(ThumbPart, RenderStyle::SCROLLBAR_THUMB, 0, destroy);
-    updateScrollbarPart(ForwardTrackPart, RenderStyle::SCROLLBAR_TRACK_PIECE, 0, destroy);
-    updateScrollbarPart(BackButtonEndPart, RenderStyle::SCROLLBAR_BUTTON, 0, destroy);
-    updateScrollbarPart(ForwardButtonEndPart, RenderStyle::SCROLLBAR_BUTTON, 0, destroy);
-    updateScrollbarPart(TrackBGPart, RenderStyle::SCROLLBAR_TRACK, 0, destroy);
</del><ins>+    updateScrollbarPart(ScrollbarBGPart, scrollbarStyle, destroy);
+    updateScrollbarPart(BackButtonStartPart, 0, destroy);
+    updateScrollbarPart(ForwardButtonStartPart, 0, destroy);
+    updateScrollbarPart(BackTrackPart, 0, destroy);
+    updateScrollbarPart(ThumbPart, 0, destroy);
+    updateScrollbarPart(ForwardTrackPart, 0, destroy);
+    updateScrollbarPart(BackButtonEndPart, 0, destroy);
+    updateScrollbarPart(ForwardButtonEndPart, 0, destroy);
+    updateScrollbarPart(TrackBGPart, 0, destroy);
</ins><span class="cx">     
</span><span class="cx">     if (destroy)
</span><span class="cx">         return;
</span><span class="lines">@@ -125,10 +158,33 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RenderScrollbar::updateScrollbarPart(ScrollbarPart partType, RenderStyle::PseudoId pseudoId, RenderStyle* partStyle, bool destroy)
</del><ins>+static RenderStyle::PseudoId pseudoForScrollbarPart(ScrollbarPart part)
</ins><span class="cx"> {
</span><ins>+    switch (part) {
+        case BackButtonStartPart:
+        case ForwardButtonStartPart:
+        case BackButtonEndPart:
+        case ForwardButtonEndPart:
+            return RenderStyle::SCROLLBAR_BUTTON;
+        case BackTrackPart:
+        case ForwardTrackPart:
+            return RenderStyle::SCROLLBAR_TRACK_PIECE;
+        case ThumbPart:
+            return RenderStyle::SCROLLBAR_THUMB;
+        case TrackBGPart:
+            return RenderStyle::SCROLLBAR_TRACK;
+        default:
+            return RenderStyle::SCROLLBAR;
+    }
+}
+
+void RenderScrollbar::updateScrollbarPart(ScrollbarPart partType, RenderStyle* partStyle, bool destroy)
+{
+    if (partType == NoPart)
+        return;
+
</ins><span class="cx">     if (!partStyle &amp;&amp; !destroy)
</span><del>-        partStyle = getScrollbarPseudoStyle(partType, pseudoId);
</del><ins>+        partStyle = getScrollbarPseudoStyle(partType, pseudoForScrollbarPart(partType));
</ins><span class="cx">     
</span><span class="cx">     bool needRenderer = !destroy &amp;&amp; partStyle &amp;&amp; partStyle-&gt;display() != NONE &amp;&amp; partStyle-&gt;visibility() == VISIBLE;
</span><span class="cx">     
</span></span></pre></div>
<a id="trunkWebCorerenderingRenderScrollbarh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/rendering/RenderScrollbar.h (37485 => 37486)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/rendering/RenderScrollbar.h        2008-10-10 18:43:47 UTC (rev 37485)
+++ trunk/WebCore/rendering/RenderScrollbar.h        2008-10-10 19:32:52 UTC (rev 37486)
</span><span class="lines">@@ -50,6 +50,9 @@
</span><span class="cx"> 
</span><span class="cx">     virtual void paint(GraphicsContext*, const IntRect&amp; damageRect);
</span><span class="cx"> 
</span><ins>+    virtual void setHoveredPart(ScrollbarPart);
+    virtual void setPressedPart(ScrollbarPart);
+
</ins><span class="cx">     void updateScrollbarParts(RenderStyle* = 0, bool destroy = false);
</span><span class="cx"> 
</span><span class="cx">     static ScrollbarPart partForStyleResolve();
</span><span class="lines">@@ -67,7 +70,7 @@
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     RenderStyle* getScrollbarPseudoStyle(ScrollbarPart, RenderStyle::PseudoId);
</span><del>-    void updateScrollbarPart(ScrollbarPart, RenderStyle::PseudoId, RenderStyle*, bool destroy);
</del><ins>+    void updateScrollbarPart(ScrollbarPart, RenderStyle* = 0, bool destroy = false);
</ins><span class="cx"> 
</span><span class="cx">     RenderObject* m_owner;
</span><span class="cx">     HashMap&lt;unsigned, RenderScrollbarPart*&gt; m_parts;
</span></span></pre>
</div>
</div>

</body>
</html>