Update scroll bars/form controls when FocusController::isActive changes
authoraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Jan 2008 17:45:31 +0000 (17:45 +0000)
committeraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Jan 2008 17:45:31 +0000 (17:45 +0000)
WebCore:

        Update scroll bars/form controls when FocusController::isActive changes

        Part of <rdar://5006915> Inactive look for Aqua controls

        Reviewed by Darin.

        All tests pass.

        * page/FocusController.cpp:
        (WebCore::FocusController::setActive): Update control tints when the
        active state changes.
        * page/FrameView.cpp:
        (WebCore::FrameView::updateControlTints): On Windows, we have to ask
        ScrollView to paint so that the outermost scroll bars will paint. On
        Mac, the outermost scroll bars are taken care of by NSScroller.
        * platform/PopupMenu.h: Updated for ScrollBarClient changes.
        * platform/ScrollBar.h: Added a new ScrollBarClient method.
        * platform/win/PlatformScrollBarSafari.cpp:
        (WebCore::PlatformScrollbar::paint): Invalidate when updating control
        tints so that we can paint with the new tint later.
        (WebCore::PlatformScrollbar::paintButton): Pass the active state down
        to SafariTheme.
        (WebCore::PlatformScrollbar::paintTrack): Ditto.
        (WebCore::PlatformScrollbar::paintThumb): Ditto.
        * platform/win/ScrollViewWin.cpp:
        (WebCore::ScrollView::ScrollViewPrivate::isActive): Added.
        (WebCore::ScrollView::paint): Pass paint calls on down if we're
        updating control tints so the scroll bars can invalidate.
        * rendering/RenderLayer.cpp:
        (WebCore::RenderLayer::isActive): Added.
        * rendering/RenderLayer.h:
        * rendering/RenderListBox.cpp:
        (WebCore::RenderListBox::isActive): Added.
        * rendering/RenderListBox.h:
        * rendering/RenderTheme.cpp:
        (WebCore::RenderTheme::isActive): Added.
        * rendering/RenderTheme.h:
        * rendering/RenderThemeSafari.cpp:
        (WebCore::RenderThemeSafari::determineState): Pass the active state
        down to SafariTheme.

WebKit/win:

        Updated for ScrollBarClient changes

        Reviewed by Darin.

        * WebScrollBar.h:
        (WebScrollBar::isActive): Added.

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

16 files changed:
WebCore/ChangeLog
WebCore/page/FocusController.cpp
WebCore/page/FrameView.cpp
WebCore/platform/PopupMenu.h
WebCore/platform/ScrollBar.h
WebCore/platform/win/PlatformScrollBarSafari.cpp
WebCore/platform/win/ScrollViewWin.cpp
WebCore/rendering/RenderLayer.cpp
WebCore/rendering/RenderLayer.h
WebCore/rendering/RenderListBox.cpp
WebCore/rendering/RenderListBox.h
WebCore/rendering/RenderTheme.cpp
WebCore/rendering/RenderTheme.h
WebCore/rendering/RenderThemeSafari.cpp
WebKit/win/ChangeLog
WebKit/win/WebScrollBar.h

index 6b5fd00..bfe2da4 100644 (file)
@@ -1,5 +1,48 @@
 2008-01-16  Adam Roben  <aroben@apple.com>
 
+        Update scroll bars/form controls when FocusController::isActive changes
+
+        Part of <rdar://5006915> Inactive look for Aqua controls
+
+        Reviewed by Darin.
+
+        All tests pass.
+
+        * page/FocusController.cpp:
+        (WebCore::FocusController::setActive): Update control tints when the
+        active state changes.
+        * page/FrameView.cpp:
+        (WebCore::FrameView::updateControlTints): On Windows, we have to ask
+        ScrollView to paint so that the outermost scroll bars will paint. On
+        Mac, the outermost scroll bars are taken care of by NSScroller.
+        * platform/PopupMenu.h: Updated for ScrollBarClient changes.
+        * platform/ScrollBar.h: Added a new ScrollBarClient method.
+        * platform/win/PlatformScrollBarSafari.cpp:
+        (WebCore::PlatformScrollbar::paint): Invalidate when updating control
+        tints so that we can paint with the new tint later.
+        (WebCore::PlatformScrollbar::paintButton): Pass the active state down
+        to SafariTheme.
+        (WebCore::PlatformScrollbar::paintTrack): Ditto.
+        (WebCore::PlatformScrollbar::paintThumb): Ditto.
+        * platform/win/ScrollViewWin.cpp:
+        (WebCore::ScrollView::ScrollViewPrivate::isActive): Added.
+        (WebCore::ScrollView::paint): Pass paint calls on down if we're
+        updating control tints so the scroll bars can invalidate.
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::isActive): Added.
+        * rendering/RenderLayer.h:
+        * rendering/RenderListBox.cpp:
+        (WebCore::RenderListBox::isActive): Added.
+        * rendering/RenderListBox.h:
+        * rendering/RenderTheme.cpp:
+        (WebCore::RenderTheme::isActive): Added.
+        * rendering/RenderTheme.h:
+        * rendering/RenderThemeSafari.cpp:
+        (WebCore::RenderThemeSafari::determineState): Pass the active state
+        down to SafariTheme.
+
+2008-01-16  Adam Roben  <aroben@apple.com>
+
         Move focused/active state from Frame to SelectionController/FocusController
 
         This is the first part of <rdar://5006915> Inactive look for Aqua
index a1ae4c2..cdc08b3 100644 (file)
@@ -296,6 +296,14 @@ void FocusController::setActive(bool active)
 
     m_isActive = active;
 
+    // FIXME: It would be nice to make Mac use this implementation someday.
+    // Right now Mac calls updateControlTints from within WebKit, and moving
+    // the call to here is not simple.
+#if !PLATFORM(MAC)
+    if (FrameView* view = m_page->mainFrame()->view())
+        view->updateControlTints();
+#endif
+
     if (Frame* frame = focusedFrame())
         frame->selectionController()->pageActivationChanged();
 }
index 8dea7f6..87644b3 100644 (file)
@@ -1029,13 +1029,17 @@ void FrameView::updateControlTints()
     if (!m_frame || m_frame->loader()->url().isEmpty()) 
         return;
     
-    Document* doc = m_frame->document();
-    if (doc && theme()->supportsControlTints() && m_frame->renderer()) {
-        doc->updateLayout(); // Ensure layout is up to date.
+    if (theme()->supportsControlTints() && m_frame->renderer()) {
+        if (needsLayout())
+            layout();
         PlatformGraphicsContext* const noContext = 0;
         GraphicsContext context(noContext);
         context.setUpdatingControlTints(true);
+#if !PLATFORM(MAC)
+        ScrollView::paint(&context, frameGeometry());
+#else
         m_frame->paint(&context, enclosingIntRect(visibleContentRect()));
+#endif
     }
 }
 
index 8b832e5..7348f9c 100644 (file)
@@ -123,6 +123,7 @@ protected:
     // ScrollBarClient
     virtual void valueChanged(Scrollbar*);
     virtual IntRect windowClipRect() const;
+    virtual bool isActive() const { return true; }
 #endif
     
 private:
index 5262632..3dcd3e3 100644 (file)
@@ -50,6 +50,10 @@ public:
 
     // Used to obtain a window clip rect.
     virtual IntRect windowClipRect() const = 0;
+
+    // FIXME: It would be nice to set this state on the scroll bar instead of
+    // having to ask for it from the client at paint time.
+    virtual bool isActive() const = 0;
 };
 
 class Scrollbar : public RefCounted<Scrollbar> {
index 6e72c0d..6485914 100644 (file)
@@ -228,6 +228,11 @@ void PlatformScrollbar::setEnabled(bool enabled)
 
 void PlatformScrollbar::paint(GraphicsContext* graphicsContext, const IntRect& damageRect)
 {
+    if (graphicsContext->updatingControlTints()) {
+        invalidate();
+        return;
+    }
+
     if (graphicsContext->paintingDisabled())
         return;
 
@@ -360,6 +365,8 @@ void PlatformScrollbar::paintButton(GraphicsContext* context, const IntRect& rec
 
     ThemePart part;
     ThemeControlState state = 0;
+    if (m_client->isActive())
+        state |= ActiveState;
     if (m_orientation == HorizontalScrollbar)
         part = start ? ScrollLeftArrowPart : ScrollRightArrowPart;
     else
@@ -386,6 +393,8 @@ void PlatformScrollbar::paintTrack(GraphicsContext* context, const IntRect& rect
 
     ThemePart part = m_orientation == HorizontalScrollbar ? HScrollTrackPart : VScrollTrackPart;
     ThemeControlState state = 0;
+    if (m_client->isActive())
+        state |= ActiveState;
     if (hasButtons())
         state |= EnabledState;
 
@@ -402,6 +411,8 @@ void PlatformScrollbar::paintThumb(GraphicsContext* context, const IntRect& rect
 
     ThemePart part = m_orientation == HorizontalScrollbar ? HScrollThumbPart : VScrollThumbPart;
     ThemeControlState state = 0;
+    if (m_client->isActive())
+        state |= ActiveState;
     if (isEnabled())
         state |= EnabledState;
 
index c7b191f..ead9425 100644 (file)
@@ -29,6 +29,7 @@
 #include "Chrome.h"
 #include "ChromeClient.h"
 #include "FloatRect.h"
+#include "FocusController.h"
 #include "Frame.h"
 #include "FrameView.h"
 #include "GraphicsContext.h"
@@ -76,6 +77,7 @@ public:
 
     virtual void valueChanged(Scrollbar*);
     virtual IntRect windowClipRect() const;
+    virtual bool isActive() const;
 
     void scrollBackingStore(const IntSize& scrollDelta);
 
@@ -203,6 +205,12 @@ IntRect ScrollView::ScrollViewPrivate::windowClipRect() const
     return static_cast<const FrameView*>(m_view)->windowClipRect(false);
 }
 
+bool ScrollView::ScrollViewPrivate::isActive() const
+{
+    Page* page = static_cast<const FrameView*>(m_view)->frame()->page();
+    return page && page->focusController()->isActive();
+}
+
 ScrollView::ScrollView()
     : m_data(new ScrollViewPrivate(this))
 {
@@ -598,7 +606,7 @@ void ScrollView::paint(GraphicsContext* context, const IntRect& rect)
     // In the end, FrameView should just merge with ScrollView.
     ASSERT(isFrameView());
 
-    if (context->paintingDisabled())
+    if (context->paintingDisabled() && !context->updatingControlTints())
         return;
 
     IntRect documentDirtyRect = rect;
index c486ba8..db18dae 100644 (file)
@@ -49,6 +49,7 @@
 #include "EventHandler.h"
 #include "EventNames.h"
 #include "FloatRect.h"
+#include "FocusController.h"
 #include "Frame.h"
 #include "FrameView.h"
 #include "FrameTree.h"
@@ -58,6 +59,7 @@
 #include "HitTestRequest.h"
 #include "HitTestResult.h"
 #include "OverflowEvent.h"
+#include "Page.h"
 #include "PlatformMouseEvent.h"
 #include "PlatformScrollBar.h" 
 #include "RenderArena.h"
@@ -1015,6 +1017,12 @@ IntRect RenderLayer::windowClipRect() const
     return frameView->windowClipRectForLayer(this, false);
 }
 
+bool RenderLayer::isActive() const
+{
+    Page* page = renderer()->document()->frame()->page();
+    return page && page->focusController()->isActive();
+}
+
 PassRefPtr<Scrollbar> RenderLayer::createScrollbar(ScrollbarOrientation orientation)
 {
     if (Scrollbar::hasPlatformScrollbars()) {
index 2cbb189..6738c47 100644 (file)
@@ -382,6 +382,7 @@ private:
 
     virtual void valueChanged(Scrollbar*);
     virtual IntRect windowClipRect() const;
+    virtual bool isActive() const;
 
     void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow);
 
index e342e72..252795c 100644 (file)
@@ -35,6 +35,7 @@
 #include "Document.h"
 #include "EventHandler.h"
 #include "EventNames.h"
+#include "FocusController.h"
 #include "Frame.h"
 #include "FrameView.h"
 #include "GraphicsContext.h"
@@ -43,6 +44,7 @@
 #include "HTMLOptionElement.h"
 #include "HTMLSelectElement.h"
 #include "HitTestResult.h"
+#include "Page.h"
 #include "PlatformScrollBar.h" 
 #include "RenderTheme.h"
 #include "RenderView.h"
@@ -546,6 +548,12 @@ IntRect RenderListBox::windowClipRect() const
     return frameView->windowClipRectForLayer(enclosingLayer(), true);
 }
 
+bool RenderListBox::isActive() const
+{
+    Page* page = document()->frame()->page();
+    return page && page->focusController()->isActive();
+}
+
 bool RenderListBox::isScrollable() const
 {
     if (numVisibleItems() < numItems())
index 89a62c4..c929ab3 100644 (file)
@@ -91,6 +91,7 @@ private:
     // ScrollbarClient interface.
     virtual void valueChanged(Scrollbar*);
     virtual IntRect windowClipRect() const;
+    virtual bool isActive() const;
 
     int itemHeight() const;
     void valueChanged(unsigned listIndex);
index fcafe91..41c19d8 100644 (file)
 
 #include "CSSValueKeywords.h"
 #include "Document.h"
+#include "FocusController.h"
 #include "Frame.h"
 #include "GraphicsContext.h"
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
+#include "Page.h"
 #include "RenderStyle.h"
 #include "SelectionController.h"
 
@@ -350,6 +352,25 @@ bool RenderTheme::stateChanged(RenderObject* o, ControlState state) const
     return true;
 }
 
+// FIXME: It would be nice to set this state on the RenderObjects instead of
+// having to dig up to the FocusController at paint time.
+bool RenderTheme::isActive(const RenderObject* o) const
+{
+    Node* node = o->element();
+    if (!node)
+        return false;
+
+    Frame* frame = node->document()->frame();
+    if (!frame)
+        return false;
+
+    Page* page = frame->page();
+    if (!page)
+        return false;
+
+    return page->focusController()->isActive();
+}
+
 bool RenderTheme::isChecked(const RenderObject* o) const
 {
     if (!o->element())
index 966c077..2fcf798 100644 (file)
@@ -130,6 +130,7 @@ public:
     virtual void adjustSliderThumbSize(RenderObject*) const;
 
     // Methods for state querying
+    bool isActive(const RenderObject*) const;
     bool isChecked(const RenderObject*) const;
     bool isIndeterminate(const RenderObject*) const;
     bool isEnabled(const RenderObject*) const;
index 75e50e4..ed82c54 100644 (file)
@@ -26,6 +26,7 @@
 #include "CSSValueKeywords.h"
 #include "Document.h"
 #include "Element.h"
+#include "Frame.h"
 #include "FrameView.h"
 #include "GraphicsContext.h"
 #include "HTMLInputElement.h"
@@ -81,6 +82,8 @@ SOFT_LINK(SafariTheme, STPaintProgressIndicator, void, APIENTRY, (ProgressIndica
 ThemeControlState RenderThemeSafari::determineState(RenderObject* o) const
 {
     ThemeControlState result = 0;
+    if (isActive(o))
+        result |= SafariTheme::ActiveState;
     if (isEnabled(o) && !isReadOnlyControl(o))
         result |= SafariTheme::EnabledState;
     if (isPressed(o))
index 54ed48c..5dc0fe0 100644 (file)
@@ -1,5 +1,14 @@
 2008-01-16  Adam Roben  <aroben@apple.com>
 
+        Updated for ScrollBarClient changes
+
+        Reviewed by Darin.
+
+        * WebScrollBar.h:
+        (WebScrollBar::isActive): Added.
+
+2008-01-16  Adam Roben  <aroben@apple.com>
+
         Updated for changes to WebCore methods
 
         Focus and active state are now handled (somewhat) separately. Future
index 74c842c..5007ebe 100644 (file)
@@ -117,10 +117,11 @@ public:
 protected:
     // ScrollbarClient
     virtual void valueChanged(Scrollbar*);
-
-    // Used to obtain a window clip rect.
     virtual IntRect windowClipRect() const;
 
+    // FIXME: We should provide a way to set this value.
+    virtual bool isActive() const { return true; }
+
     ULONG m_refCount;
     RefPtr<WebCore::PlatformScrollbar> m_scrollBar;
     COMPtr<IWebScrollBarDelegatePrivate> m_delegate;