Move focused/active state from Frame to SelectionController/FocusController
authoraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Jan 2008 17:44:35 +0000 (17:44 +0000)
committeraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Jan 2008 17:44:35 +0000 (17:44 +0000)
WebCore:

        Move focused/active state from Frame to SelectionController/FocusController

        This is the first part of <rdar://5006915> Inactive look for Aqua
        controls.

        The following methods were moved/renamed:
            - Frame::setIsActive -> FocusController::setActive
            - Frame::isActive -> SelectionController::isActiveAndFocused
            - Frame::setWindowHasFocus -> SelectionController::setFocused

        Active state is now correctly a Page-level concept.

        The Mac parts of this patch were written by Darin.

        Reviewed by Darin.

        All tests pass.

        * WebCore.base.exp: Updated for method renames.
        * css/CSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::checkOneSelector): Ditto.
        * editing/SelectionController.cpp:
        (WebCore::SelectionController::SelectionController): Initialize new
        member.
        (WebCore::SelectionController::focusedOrActiveStateChanged): New
        private method. Most of this code came from Frame::setIsActive.
        (WebCore::SelectionController::pageActivationChanged): Added.
        (WebCore::SelectionController::setFocused): Added. Replaces
        Frame::setWindowHasFocus.
        (WebCore::SelectionController::isFocusedAndActive): Added. Replaces
        Frame::isActive.
        * editing/SelectionController.h:
        * page/FocusController.cpp:
        (WebCore::FocusController::FocusController): Initialize new member.
        (WebCore::FocusController::setFocusedFrame): Changed to just call
        SelectionController::setFocused, since active state has doesn't change
        when the focused frame changes.
        (WebCore::FocusController::setActive): Added. Replaces
        Frame::setIsActive.
        * page/FocusController.h:
        (WebCore::FocusController::isActive): Added.
        * page/Frame.cpp:
        (WebCore::Frame::setDocument): Updated for method renames.
        (WebCore::Frame::setFocusedNodeIfNeeded): Ditto.
        (WebCore::Frame::updateSecureKeyboardEntryIfActive): Ditto.
        (WebCore::FramePrivate::FramePrivate): Removed initialization of
        removed members.
        * page/Frame.h:
        * page/FramePrivate.h:
        * page/mac/WebCoreFrameBridge.h: Removed -selectionColor.
        * page/mac/WebCoreFrameBridge.mm: Ditto.
        * rendering/RenderListBox.cpp:
        (WebCore::RenderListBox::paintItemForeground): Updated for method
        renames.
        (WebCore::RenderListBox::paintItemBackground): Ditto.
        * rendering/RenderObject.cpp:
        (WebCore::RenderObject::selectionBackgroundColor): Ditto.
        (WebCore::RenderObject::selectionForegroundColor): Ditto.
        * rendering/RenderTextControl.cpp:
        (WebCore::RenderTextControl::capsLockStateMayHaveChanged): Ditto.
        * rendering/RenderTheme.cpp:
        (WebCore::RenderTheme::isFocused): Ditto.

WebKit/mac:

        Updated for renames/removal of WebCore methods.

        Reviewed by Darin.

        * Plugins/WebPluginController.mm:
        (-[WebPluginController webPlugInContainerSelectionColor]): Changed to
        ask isFocusedAndActive directly, instead of going through the frame
        bridge.
        * WebView/WebHTMLView.mm:
        (-[WebHTMLView _updateActiveState]): Updated for method renames.

WebKit/win:

        Updated for changes to WebCore methods

        Focus and active state are now handled (somewhat) separately. Future
        patches will further separate these concepts.

        Reviewed by Darin.

        * WebView.cpp:
        (WebViewWndProc): Updated for method renames.
        (WebView::updateActiveState): Only change the active state here. Focus
        is handled inside WM_SETFOCUS and WM_KILLFOCUS message handlers.

WebKit/wx:

        Updated for WebCore method renames.

        Reviewed by Darin.

        * WebView.cpp:
        (wxWebView::OnSetFocus):
        (wxWebView::OnKillFocus):
        (wxWebView::OnActivate):

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

23 files changed:
WebCore/ChangeLog
WebCore/WebCore.base.exp
WebCore/css/CSSStyleSelector.cpp
WebCore/editing/SelectionController.cpp
WebCore/editing/SelectionController.h
WebCore/page/FocusController.cpp
WebCore/page/FocusController.h
WebCore/page/Frame.cpp
WebCore/page/Frame.h
WebCore/page/FramePrivate.h
WebCore/page/mac/WebCoreFrameBridge.h
WebCore/page/mac/WebCoreFrameBridge.mm
WebCore/rendering/RenderListBox.cpp
WebCore/rendering/RenderObject.cpp
WebCore/rendering/RenderTextControl.cpp
WebCore/rendering/RenderTheme.cpp
WebKit/mac/ChangeLog
WebKit/mac/Plugins/WebPluginController.mm
WebKit/mac/WebView/WebHTMLView.mm
WebKit/win/ChangeLog
WebKit/win/WebView.cpp
WebKit/wx/ChangeLog
WebKit/wx/WebView.cpp

index 9448f6e..6b5fd00 100644 (file)
@@ -1,3 +1,68 @@
+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
+        controls.
+
+        The following methods were moved/renamed:
+            - Frame::setIsActive -> FocusController::setActive
+            - Frame::isActive -> SelectionController::isActiveAndFocused
+            - Frame::setWindowHasFocus -> SelectionController::setFocused
+
+        Active state is now correctly a Page-level concept.
+
+        The Mac parts of this patch were written by Darin.
+
+        Reviewed by Darin.
+
+        All tests pass.
+
+        * WebCore.base.exp: Updated for method renames.
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::checkOneSelector): Ditto.
+        * editing/SelectionController.cpp:
+        (WebCore::SelectionController::SelectionController): Initialize new
+        member.
+        (WebCore::SelectionController::focusedOrActiveStateChanged): New
+        private method. Most of this code came from Frame::setIsActive.
+        (WebCore::SelectionController::pageActivationChanged): Added.
+        (WebCore::SelectionController::setFocused): Added. Replaces
+        Frame::setWindowHasFocus.
+        (WebCore::SelectionController::isFocusedAndActive): Added. Replaces
+        Frame::isActive.
+        * editing/SelectionController.h:
+        * page/FocusController.cpp:
+        (WebCore::FocusController::FocusController): Initialize new member.
+        (WebCore::FocusController::setFocusedFrame): Changed to just call
+        SelectionController::setFocused, since active state has doesn't change
+        when the focused frame changes.
+        (WebCore::FocusController::setActive): Added. Replaces
+        Frame::setIsActive.
+        * page/FocusController.h:
+        (WebCore::FocusController::isActive): Added.
+        * page/Frame.cpp:
+        (WebCore::Frame::setDocument): Updated for method renames.
+        (WebCore::Frame::setFocusedNodeIfNeeded): Ditto.
+        (WebCore::Frame::updateSecureKeyboardEntryIfActive): Ditto.
+        (WebCore::FramePrivate::FramePrivate): Removed initialization of
+        removed members.
+        * page/Frame.h:
+        * page/FramePrivate.h:
+        * page/mac/WebCoreFrameBridge.h: Removed -selectionColor.
+        * page/mac/WebCoreFrameBridge.mm: Ditto.
+        * rendering/RenderListBox.cpp:
+        (WebCore::RenderListBox::paintItemForeground): Updated for method
+        renames.
+        (WebCore::RenderListBox::paintItemBackground): Ditto.
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::selectionBackgroundColor): Ditto.
+        (WebCore::RenderObject::selectionForegroundColor): Ditto.
+        * rendering/RenderTextControl.cpp:
+        (WebCore::RenderTextControl::capsLockStateMayHaveChanged): Ditto.
+        * rendering/RenderTheme.cpp:
+        (WebCore::RenderTheme::isFocused): Ditto.
+
 2008-01-17  Holger Hans Peter Freyther  <holger.freyther@trolltech.com>
 
         Reviewed by Simon.
index 38a2264..67b0e36 100644 (file)
@@ -308,6 +308,7 @@ __ZN7WebCore15DatabaseTracker9setClientEPNS_21DatabaseTrackerClientE
 __ZN7WebCore15FocusController15setFocusedFrameEN3WTF10PassRefPtrINS_5FrameEEE
 __ZN7WebCore15FocusController15setInitialFocusENS_14FocusDirectionEPNS_13KeyboardEventE
 __ZN7WebCore15FocusController18focusedOrMainFrameEv
+__ZN7WebCore15FocusController9setActiveEb
 __ZN7WebCore15StringTruncator13rightTruncateERKNS_6StringEfRKNS_4FontEb
 __ZN7WebCore15StringTruncator14centerTruncateERKNS_6StringEfRKNS_4FontEb
 __ZN7WebCore15StringTruncator5widthERKNS_6StringERKNS_4FontEb
@@ -341,6 +342,7 @@ __ZN7WebCore19InspectorController16setWindowVisibleEb
 __ZN7WebCore19InspectorController4showEv
 __ZN7WebCore19InspectorController5closeEv
 __ZN7WebCore19InspectorController7inspectEPNS_4NodeE
+__ZN7WebCore19SelectionController10setFocusedEb
 __ZN7WebCore19SelectionController16setSelectedRangeEPNS_5RangeENS_9EAffinityEb
 __ZN7WebCore19SelectionController5clearEv
 __ZN7WebCore19SelectionController9selectAllEv
@@ -388,10 +390,8 @@ __ZN7WebCore5Cache11setDisabledEb
 __ZN7WebCore5Cache13getStatisticsEv
 __ZN7WebCore5Cache13setCapacitiesEjjj
 __ZN7WebCore5Frame11scriptProxyEv
-__ZN7WebCore5Frame11setIsActiveEb
 __ZN7WebCore5Frame11shouldCloseEv
 __ZN7WebCore5Frame17bindingRootObjectEv
-__ZN7WebCore5Frame17setWindowHasFocusEb
 __ZN7WebCore5Frame18windowScriptObjectEv
 __ZN7WebCore5Frame20setSelectionFromNoneEv
 __ZN7WebCore5Frame20windowScriptNPObjectEv
@@ -623,6 +623,7 @@ __ZNK7WebCore16ResourceResponse13nsURLResponseEv
 __ZNK7WebCore19ResourceRequestBase3urlEv
 __ZNK7WebCore19ResourceRequestBase7isEmptyEv
 __ZNK7WebCore19SelectionController17isInPasswordFieldEv
+__ZNK7WebCore19SelectionController18isFocusedAndActiveEv
 __ZNK7WebCore20ResourceResponseBase14httpStatusCodeEv
 __ZNK7WebCore20ResourceResponseBase16httpHeaderFieldsEv
 __ZNK7WebCore20ResourceResponseBase16textEncodingNameEv
index 18b5ddb..5b7eef5 100644 (file)
@@ -59,6 +59,7 @@
 #include "Pair.h"
 #include "Rect.h"
 #include "RenderTheme.h"
+#include "SelectionController.h"
 #include "Settings.h"
 #include "ShadowValue.h"
 #include "StyleSheetList.h"
@@ -1638,7 +1639,7 @@ bool CSSStyleSelector::checkOneSelector(CSSSelector* sel, Element* e, bool isAnc
                 break;
             }
             case CSSSelector::PseudoFocus:
-                if (e && e->focused() && e->document()->frame()->isActive())
+                if (e && e->focused() && e->document()->frame()->selectionController()->isFocusedAndActive())
                     return true;
                 break;
             case CSSSelector::PseudoHover: {
index 5619f6f..4d68044 100644 (file)
@@ -30,6 +30,7 @@
 #include "Document.h"
 #include "Editor.h"
 #include "Element.h"
+#include "EventHandler.h"
 #include "EventNames.h"
 #include "ExceptionCode.h"
 #include "FocusController.h"
@@ -43,6 +44,7 @@
 #include "HitTestResult.h"
 #include "Page.h"
 #include "Range.h"
+#include "RenderTheme.h"
 #include "RenderView.h"
 #include "TextIterator.h"
 #include "TypingCommand.h"
@@ -65,6 +67,7 @@ SelectionController::SelectionController(Frame* frame, bool isDragCaretControlle
     , m_isDragCaretController(isDragCaretController)
     , m_isCaretBlinkingSuspended(false)
     , m_xPosForVerticalArrowNavigation(NoXPosForVerticalArrowNavigation)
+    , m_focused(false)
 {
 }
 
@@ -1019,6 +1022,61 @@ bool SelectionController::isInsideNode() const
         return false;
     return !isTableElement(startNode) && !editingIgnoresContent(startNode);
 }
+
+void SelectionController::focusedOrActiveStateChanged()
+{
+    bool activeAndFocused = isFocusedAndActive();
+
+    // Because RenderObject::selectionBackgroundColor() and
+    // RenderObject::selectionForegroundColor() check if the frame is active,
+    // we have to update places those colors were painted.
+    if (m_frame->view())
+        m_frame->view()->updateContents(enclosingIntRect(m_frame->selectionRect()));
+
+    // Caret appears in the active frame.
+    if (activeAndFocused)
+        m_frame->setSelectionFromNone();
+    m_frame->setCaretVisible(activeAndFocused);
+
+    // Update for caps lock state
+    m_frame->eventHandler()->capsLockStateMayHaveChanged();
+
+    // Because CSSStyleSelector::checkOneSelector() and
+    // RenderTheme::isFocused() check if the frame is active, we have to
+    // update style and theme state that depended on those.
+    if (Node* node = m_frame->document()->focusedNode()) {
+        node->setChanged();
+        if (RenderObject* renderer = node->renderer())
+            if (renderer && renderer->style()->hasAppearance())
+                theme()->stateChanged(renderer, FocusState);
+    }
+
+    // Secure keyboard entry is set by the active frame.
+    if (m_frame->document()->useSecureKeyboardEntryWhenActive())
+        m_frame->setUseSecureKeyboardEntry(activeAndFocused);
+}
+
+void SelectionController::pageActivationChanged()
+{
+    focusedOrActiveStateChanged();
+}
+
+void SelectionController::setFocused(bool flag)
+{
+    if (m_focused == flag)
+        return;
+    m_focused = flag;
+
+    focusedOrActiveStateChanged();
+
+    if (Document* doc = m_frame->document())
+        doc->dispatchWindowEvent(flag ? focusEvent : blurEvent, false, false);
+}
+
+bool SelectionController::isFocusedAndActive() const
+{
+    return m_focused && m_frame->page() && m_frame->page()->focusController()->isActive();
+}
   
 #ifndef NDEBUG
 
index 7c8c018..5e2f5ed 100644 (file)
@@ -111,6 +111,11 @@ public:
     void setCaretBlinkingSuspended(bool suspended) { m_isCaretBlinkingSuspended = suspended; }
     bool isCaretBlinkingSuspended() const { return m_isCaretBlinkingSuspended; }
 
+    // Focus
+    void setFocused(bool);
+    bool isFocusedAndActive() const;
+    void pageActivationChanged();
+
 #ifndef NDEBUG
     void formatForDebugger(char* buffer, unsigned length) const;
     void showTreeForThis() const;
@@ -135,6 +140,8 @@ private:
     void notifyAccessibilityForSelectionChange() {};
 #endif
 
+    void focusedOrActiveStateChanged();
+
     Selection m_sel;
 
     IntRect m_caretRect;            // caret coordinates, size, and position
@@ -152,6 +159,7 @@ private:
     bool m_isCaretBlinkingSuspended;
     
     int m_xPosForVerticalArrowNavigation;
+    bool m_focused;
 };
 
 inline bool operator==(const SelectionController& a, const SelectionController& b)
index b7589e4..a1ae4c2 100644 (file)
@@ -56,6 +56,7 @@ using namespace HTMLNames;
 
 FocusController::FocusController(Page* page)
     : m_page(page)
+    , m_isActive(false)
 {
 }
 
@@ -64,17 +65,13 @@ void FocusController::setFocusedFrame(PassRefPtr<Frame> frame)
     if (m_focusedFrame == frame)
         return;
 
-    if (m_focusedFrame) {
-        m_focusedFrame->setWindowHasFocus(false);
-        m_focusedFrame->setIsActive(false);
-    }
+    if (m_focusedFrame)
+        m_focusedFrame->selectionController()->setFocused(false);
 
     m_focusedFrame = frame;
 
-    if (m_focusedFrame) {
-        m_focusedFrame->setWindowHasFocus(true);
-        m_focusedFrame->setIsActive(true);
-    }
+    if (m_focusedFrame)
+        m_focusedFrame->selectionController()->setFocused(true);
 }
 
 Frame* FocusController::focusedOrMainFrame()
@@ -292,4 +289,15 @@ bool FocusController::setFocusedNode(Node* node, PassRefPtr<Frame> newFocusedFra
     return true;
 }
 
+void FocusController::setActive(bool active)
+{
+    if (m_isActive == active)
+        return;
+
+    m_isActive = active;
+
+    if (Frame* frame = focusedFrame())
+        frame->selectionController()->pageActivationChanged();
+}
+
 } // namespace WebCore
index 2f3a4b1..f4a6632 100644 (file)
@@ -50,9 +50,13 @@ namespace WebCore {
         
         bool setFocusedNode(Node*, PassRefPtr<Frame>);
 
+        void setActive(bool);
+        bool isActive() const { return m_isActive; }
+
     private:
         Page* m_page;
         RefPtr<Frame> m_focusedFrame;
+        bool m_isActive;
     };
 
 } // namespace WebCore
index 26c98a6..0684518 100644 (file)
@@ -275,7 +275,7 @@ void Frame::setDocument(PassRefPtr<Document> newDoc)
     }
 
     d->m_doc = newDoc;
-    if (d->m_doc && d->m_isActive)
+    if (d->m_doc && selectionController()->isFocusedAndActive())
         setUseSecureKeyboardEntry(d->m_doc->useSecureKeyboardEntryWhenActive());
         
     if (d->m_doc && !d->m_doc->attached())
@@ -585,7 +585,7 @@ static bool isFrameElement(const Node *n)
 
 void Frame::setFocusedNodeIfNeeded()
 {
-    if (!document() || selectionController()->isNone() || !d->m_isActive)
+    if (!document() || selectionController()->isNone() || !selectionController()->isFocusedAndActive())
         return;
 
     Node* target = selectionController()->rootEditableElement();
@@ -832,7 +832,7 @@ void Frame::setUseSecureKeyboardEntry(bool)
 
 void Frame::updateSecureKeyboardEntryIfActive()
 {
-    if (d->m_isActive)
+    if (selectionController()->isFocusedAndActive())
         setUseSecureKeyboardEntry(d->m_doc->useSecureKeyboardEntryWhenActive());
 }
 
@@ -1535,58 +1535,6 @@ void Frame::setSelectionFromNone()
         selectionController()->setSelection(Selection(Position(node, 0), DOWNSTREAM));
 }
 
-bool Frame::isActive() const
-{
-    return d->m_isActive;
-}
-
-void Frame::setIsActive(bool flag)
-{
-    if (d->m_isActive == flag)
-        return;
-    d->m_isActive = flag;
-
-    // Because RenderObject::selectionBackgroundColor() and
-    // RenderObject::selectionForegroundColor() check if the frame is active,
-    // we have to update places those colors were painted.
-    if (d->m_view)
-        d->m_view->updateContents(enclosingIntRect(selectionRect()));
-
-    // Caret appears in the active frame.
-    if (flag)
-        setSelectionFromNone();
-    setCaretVisible(flag);
-
-    // Update for caps lock state
-    eventHandler()->capsLockStateMayHaveChanged();
-
-    // Because CSSStyleSelector::checkOneSelector() and
-    // RenderTheme::isFocused() check if the frame is active, we have to
-    // update style and theme state that depended on those.
-    if (d->m_doc) {
-        if (Node* node = d->m_doc->focusedNode()) {
-            node->setChanged();
-            if (RenderObject* renderer = node->renderer())
-                if (renderer && renderer->style()->hasAppearance())
-                    theme()->stateChanged(renderer, FocusState);
-        }
-    }
-
-    // Secure keyboard entry is set by the active frame.
-    if (d->m_doc->useSecureKeyboardEntryWhenActive())
-        setUseSecureKeyboardEntry(flag);
-}
-
-void Frame::setWindowHasFocus(bool flag)
-{
-    if (d->m_windowHasFocus == flag)
-        return;
-    d->m_windowHasFocus = flag;
-    
-    if (Document *doc = document())
-        doc->dispatchWindowEvent(flag ? focusEvent : blurEvent, false, false);
-}
-
 bool Frame::inViewSourceMode() const
 {
     return d->m_inViewSourceMode;
@@ -1952,14 +1900,12 @@ FramePrivate::FramePrivate(Page* page, Frame* parent, Frame* thisFrame, HTMLFram
     , m_animationController(thisFrame)
     , m_caretVisible(false)
     , m_caretPaint(true)
-    , m_isActive(false)
     , m_isPainting(false)
     , m_lifeSupportTimer(thisFrame, &Frame::lifeSupportTimerFired)
     , m_loader(new FrameLoader(thisFrame, frameLoaderClient))
     , m_userStyleSheetLoader(0)
     , m_paintRestriction(PaintRestrictionNone)
     , m_highlightTextMatches(false)
-    , m_windowHasFocus(false)
     , m_inViewSourceMode(false)
     , frameCount(0)
     , m_prohibitsScrolling(false)
index 5697dd8..101ff3b 100644 (file)
@@ -189,9 +189,6 @@ public:
     void clearTimers();
     static void clearTimers(FrameView*);
 
-    bool isActive() const;
-    void setIsActive(bool flag);
-
     // Convenience, to avoid repeating the code to dig down to get this.
     UChar backslashAsCurrencySymbol() const;
 
@@ -225,8 +222,6 @@ public:
     void sendResizeEvent();
     void sendScrollEvent();
 
-    void setWindowHasFocus(bool flag);
-
 // === to be moved into FrameView
 
 public:
@@ -337,9 +332,10 @@ public:
     void revealCaret(const RenderLayer::ScrollAlignment& = RenderLayer::gAlignCenterIfNeeded) const;
     void setSelectionFromNone();
 
+    void setUseSecureKeyboardEntry(bool);
+
 private:
     void caretBlinkTimerFired(Timer<Frame>*);
-    void setUseSecureKeyboardEntry(bool);
 
 public:
     SelectionController* dragCaretController() const;
index 9967d47..6a720c7 100644 (file)
@@ -94,7 +94,6 @@ namespace WebCore {
 
         bool m_caretVisible : 1;
         bool m_caretPaint : 1;
-        bool m_isActive : 1;
         bool m_isPainting : 1;
 
         RefPtr<CSSMutableStyleDeclaration> m_typingStyle;
@@ -109,7 +108,6 @@ namespace WebCore {
         PaintRestriction m_paintRestriction;
         
         bool m_highlightTextMatches;
-        bool m_windowHasFocus;
         
         bool m_inViewSourceMode;
 
index 757c4e3..a81d5d9 100644 (file)
@@ -171,8 +171,6 @@ enum WebScrollGranularity {
 - (void)setBaseBackgroundColor:(NSColor *)backgroundColor;
 - (void)setDrawsBackground:(BOOL)drawsBackround;
 
-- (NSColor *)selectionColor;
-
 - (id)accessibilityTree;
 
 - (DOMRange *)rangeByAlteringCurrentSelection:(WebCore::SelectionController::EAlteration)alteration direction:(WebCore::SelectionController::EDirection)direction granularity:(WebCore::TextGranularity)granularity;
index 3a13a9e..c314096 100644 (file)
@@ -784,11 +784,6 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
     _shouldCreateRenderers = f;
 }
 
-- (NSColor *)selectionColor
-{
-    return m_frame->isActive() ? [NSColor selectedTextBackgroundColor] : [NSColor secondarySelectedControlColor];
-}
-
 - (id)accessibilityTree
 {
     AXObjectCache::enableAccessibility();
index fcc0d9a..e342e72 100644 (file)
@@ -46,6 +46,7 @@
 #include "PlatformScrollBar.h" 
 #include "RenderTheme.h"
 #include "RenderView.h"
+#include "SelectionController.h"
 #include <math.h>
 
 using namespace std;
@@ -316,7 +317,7 @@ void RenderListBox::paintItemForeground(PaintInfo& paintInfo, int tx, int ty, in
     
     Color textColor = element->renderStyle() ? element->renderStyle()->color() : style()->color();
     if (element->hasTagName(optionTag) && static_cast<HTMLOptionElement*>(element)->selected()) {
-        if (document()->frame()->isActive() && document()->focusedNode() == node())
+        if (document()->frame()->selectionController()->isFocusedAndActive() && document()->focusedNode() == node())
             textColor = theme()->activeListBoxSelectionForegroundColor();
         // Honor the foreground color for disabled items
         else if (!element->disabled())
@@ -351,7 +352,7 @@ void RenderListBox::paintItemBackground(PaintInfo& paintInfo, int tx, int ty, in
 
     Color backColor;
     if (element->hasTagName(optionTag) && static_cast<HTMLOptionElement*>(element)->selected()) {
-        if (document()->frame()->isActive() && document()->focusedNode() == node())
+        if (document()->frame()->selectionController()->isFocusedAndActive() && document()->focusedNode() == node())
             backColor = theme()->activeListBoxSelectionBackgroundColor();
         else
             backColor = theme()->inactiveListBoxSelectionBackgroundColor();
index 64d5a52..a2198bd 100644 (file)
@@ -59,6 +59,7 @@
 #include "RenderText.h"
 #include "RenderTheme.h"
 #include "RenderView.h"
+#include "SelectionController.h"
 #include "TextResourceDecoder.h"
 #include "TextStream.h"
 #include <algorithm>
@@ -2038,7 +2039,7 @@ Color RenderObject::selectionBackgroundColor() const
         if (pseudoStyle && pseudoStyle->backgroundColor().isValid())
             color = pseudoStyle->backgroundColor().blendWithWhite();
         else
-            color = document()->frame()->isActive() ?
+            color = document()->frame()->selectionController()->isFocusedAndActive() ?
                     theme()->activeSelectionBackgroundColor() :
                     theme()->inactiveSelectionBackgroundColor();
     }
@@ -2056,7 +2057,7 @@ Color RenderObject::selectionForegroundColor() const
             if (!color.isValid())
                 color = pseudoStyle->color();
         } else
-            color = document()->frame()->isActive() ?
+            color = document()->frame()->selectionController()->isFocusedAndActive() ?
                     theme()->platformActiveSelectionForegroundColor() :
                     theme()->platformInactiveSelectionForegroundColor();
     }
index 5835818..f33bef2 100644 (file)
@@ -1231,7 +1231,7 @@ void RenderTextControl::capsLockStateMayHaveChanged()
         if (Document* d = document())
             if (Frame* f = d->frame())
                 shouldDrawCapsLockIndicator = !m_multiLine && static_cast<HTMLInputElement*>(n)->inputType() == HTMLInputElement::PASSWORD && 
-                                               f->isActive() && d->focusedNode() == n && PlatformKeyboardEvent::currentCapsLockState();
+                                               f->selectionController()->isFocusedAndActive() && d->focusedNode() == n && PlatformKeyboardEvent::currentCapsLockState();
 
     if (shouldDrawCapsLockIndicator != m_shouldDrawCapsLockIndicator) {
         m_shouldDrawCapsLockIndicator = shouldDrawCapsLockIndicator;
index 8ebbb7e..fcafe91 100644 (file)
@@ -29,6 +29,7 @@
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "RenderStyle.h"
+#include "SelectionController.h"
 
 // The methods in this file are shared by all themes on every platform.
 
@@ -377,7 +378,7 @@ bool RenderTheme::isFocused(const RenderObject* o) const
         return false;
     Document* document = node->document();
     Frame* frame = document->frame();
-    return node == document->focusedNode() && frame && frame->isActive();
+    return node == document->focusedNode() && frame && frame->selectionController()->isFocusedAndActive();
 }
 
 bool RenderTheme::isPressed(const RenderObject* o) const
index 9ec8e8a..466a44d 100644 (file)
@@ -1,3 +1,16 @@
+2008-01-16  Adam Roben  <aroben@apple.com>
+
+        Updated for renames/removal of WebCore methods.
+
+        Reviewed by Darin.
+
+        * Plugins/WebPluginController.mm:
+        (-[WebPluginController webPlugInContainerSelectionColor]): Changed to
+        ask isFocusedAndActive directly, instead of going through the frame
+        bridge.
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView _updateActiveState]): Updated for method renames.
+
 2008-01-16  John Sullivan  <sullivan@apple.com>
 
         Reviewed by Adam and Dan
index 4c8b734..9e9ec19 100644 (file)
@@ -363,7 +363,10 @@ static void cancelOutstandingCheck(const void *item, void *context)
 
 - (NSColor *)webPlugInContainerSelectionColor
 {
-    return [[_dataSource _bridge] selectionColor];
+    bool primary = true;
+    if (Frame* frame = core([self webFrame]))
+        primary = frame->selectionController()->isFocusedAndActive();
+    return primary ? [NSColor selectedTextBackgroundColor] : [NSColor secondarySelectedControlColor];
 }
 
 // For compatibility only.
index 823a648..ec7d2a9 100644 (file)
@@ -1727,10 +1727,10 @@ static void _updateMouseoverTimerCallback(CFRunLoopTimerRef timer, void *info)
     BOOL windowOrSheetIsKey = windowIsKey || [[window attachedSheet] isKeyWindow];
 
     BOOL isActive = !_private->resigningFirstResponder && windowIsKey && [self _web_firstResponderCausesFocusDisplay];
-    frame->setIsActive(isActive);            
+    page->focusController()->setActive(isActive);
 
     Frame* focusedFrame = page->focusController()->focusedOrMainFrame();
-    frame->setWindowHasFocus(frame == focusedFrame && windowOrSheetIsKey);
+    frame->selectionController()->setFocused(frame == focusedFrame && windowOrSheetIsKey);
 }
 
 - (void)_writeSelectionToPasteboard:(NSPasteboard *)pasteboard
index a0cecfe..54ed48c 100644 (file)
@@ -1,3 +1,17 @@
+2008-01-16  Adam Roben  <aroben@apple.com>
+
+        Updated for changes to WebCore methods
+
+        Focus and active state are now handled (somewhat) separately. Future
+        patches will further separate these concepts.
+
+        Reviewed by Darin.
+
+        * WebView.cpp:
+        (WebViewWndProc): Updated for method renames.
+        (WebView::updateActiveState): Only change the active state here. Focus
+        is handled inside WM_SETFOCUS and WM_KILLFOCUS message handlers.
+
 2008-01-16  Steve Falkenburg  <sfalken@apple.com>
 
         <rdar://problem/5097419> Cursor flickers when over window resizer
index fa4d0aa..a2bc399 100644 (file)
@@ -1661,18 +1661,18 @@ static LRESULT CALLBACK WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam, L
                 uiDelegatePrivate->webViewReceivedFocus(webView);
             // FIXME: Merge this logic with updateActiveState, and switch this over to use updateActiveState
 
+            webView->page()->focusController()->setActive(true);
+
             // It's ok to just always do setWindowHasFocus, since we won't fire the focus event on the DOM
             // window unless the value changes.  It's also ok to do setIsActive inside focus,
             // because Windows has no concept of having to update control tints (e.g., graphite vs. aqua)
             // and therefore only needs to update the selection (which is limited to the focused frame).
             FocusController* focusController = webView->page()->focusController();
             if (Frame* frame = focusController->focusedFrame()) {
-                frame->setIsActive(true);
-
                 // If the previously focused window is a child of ours (for example a plugin), don't send any
                 // focus events.
                 if (!IsChild(hWnd, reinterpret_cast<HWND>(wParam)))
-                    frame->setWindowHasFocus(true);
+                    frame->selectionController()->setFocused(true);
             } else
                 focusController->setFocusedFrame(webView->page()->mainFrame());
             break;
@@ -1693,12 +1693,11 @@ static LRESULT CALLBACK WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam, L
             FocusController* focusController = webView->page()->focusController();
             webView->resetIME(focusController->focusedOrMainFrame());
             if (GetAncestor(hWnd, GA_ROOT) != newFocusWnd) {
+                webView->page()->focusController()->setActive(false);
                 if (Frame* frame = focusController->focusedOrMainFrame()) {
-                    frame->setIsActive(false);
-
                     // If we're losing focus to a child of ours, don't send blur events.
                     if (!IsChild(hWnd, newFocusWnd))
-                        frame->setWindowHasFocus(false);
+                        frame->selectionController()->setFocused(false);
                 }
             } else
                 focusController->setFocusedFrame(0);
@@ -2664,8 +2663,6 @@ HRESULT STDMETHODCALLTYPE WebView::searchFor(
 
 HRESULT STDMETHODCALLTYPE WebView::updateActiveState()
 {
-    Frame* frame = m_page->mainFrame();
-
     HWND window = ::GetAncestor(m_viewWindow, GA_ROOT);
     HWND activeWindow = ::GetActiveWindow();
     bool windowIsKey = window == activeWindow;
@@ -2673,10 +2670,7 @@ HRESULT STDMETHODCALLTYPE WebView::updateActiveState()
 
     bool windowOrSheetIsKey = windowIsKey || (window == activeWindow);
 
-    frame->setIsActive(windowIsKey);            
-
-    Frame* focusedFrame = m_page->focusController()->focusedOrMainFrame();
-    frame->setWindowHasFocus(frame == focusedFrame && windowOrSheetIsKey);
+    m_page->focusController()->setActive(windowOrSheetIsKey);
 
     return S_OK;
 }
index fa8468c..dd31d29 100644 (file)
@@ -1,3 +1,14 @@
+2008-01-16  Adam Roben  <aroben@apple.com>
+
+        Updated for WebCore method renames.
+
+        Reviewed by Darin.
+
+        * WebView.cpp:
+        (wxWebView::OnSetFocus):
+        (wxWebView::OnKillFocus):
+        (wxWebView::OnActivate):
+
 2008-01-12  Kevin Ollivier  <kevino@theolliviers.com>
 
         Reviewed by Darin Adler.
index 1d143f6..cc526d8 100644 (file)
@@ -29,6 +29,7 @@
 #include "Element.h"
 #include "Editor.h"
 #include "EventHandler.h"
+#include "FocusController.h"
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "FrameView.h"
@@ -43,6 +44,7 @@
 #include "PlatformWheelEvent.h"
 #include "RenderObject.h"
 #include "RenderTreeAsText.h"
+#include "SelectionController.h"
 #include "Settings.h"
 
 #include "ChromeClientWx.h"
@@ -556,7 +558,7 @@ void wxWebView::OnKeyEvents(wxKeyEvent& event)
 void wxWebView::OnSetFocus(wxFocusEvent& event)
 {
     if (m_impl->frame) {
-        m_impl->frame->setWindowHasFocus(true);
+        m_impl->frame->selectionController()->setFocused(true);
     }
     event.Skip();
 }
@@ -564,15 +566,15 @@ void wxWebView::OnSetFocus(wxFocusEvent& event)
 void wxWebView::OnKillFocus(wxFocusEvent& event)
 {
     if (m_impl->frame) {
-        m_impl->frame->setWindowHasFocus(false);
+        m_impl->frame->selectionController()->setFocused(false);
     }
     event.Skip();
 }
 
 void wxWebView::OnActivate(wxActivateEvent& event)
 {
-    if (m_impl->frame) {
-        m_impl->frame->setIsActive(event.GetActive());
+    if (m_impl->page) {
+        m_impl->page->focusController()->setActive(event.GetActive());
     }
     event.Skip();
 }