2011-04-29 Jon Lee <jonlee@apple.com>
authorjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Apr 2011 20:42:11 +0000 (20:42 +0000)
committerjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Apr 2011 20:42:11 +0000 (20:42 +0000)
        Reviewed by mitzpettel.

        REGRESSION (WebKit2): (Mac) Selection is gone after switching tabs (59721)
        <rdar://problem/9327332>
        https://bugs.webkit.org/show_bug.cgi?id=59721

        Removing shouldClearSelectionWhenLosingWebPageFocus().  Reverting changelist 83814.

        * WebCore.exp.in:
        * editing/EditingBehavior.h:
2011-04-29  Jon Lee  <jonlee@apple.com>

        Reviewed by mitzpettel.

        REGRESSION (WebKit2): (Mac) Selection is gone after switching tabs (59721)
        <rdar://problem/9327332>
        https://bugs.webkit.org/show_bug.cgi?id=59721

        When resigning first responder status, check to see if we need to maintain an inactive
        selection in the web view. If we don't, we clear the selection.

        This also reverts the change made in 83814, since that was a different attempt to solve this same issue.

        * UIProcess/API/C/WKPage.cpp:
        (WKPageSetMaintainsInactiveSelection): Export setMaintainsInactiveSelection()
        * UIProcess/API/C/WKPage.h:
        * UIProcess/API/mac/WKView.mm:
        (-[WKView resignFirstResponder]): Check and see if we need to maintain the selection in the view prior to resigning.
        If not, we clear the selection
        * UIProcess/WebPageProxy.cpp:
        (WebKit::WebPageProxy::clearSelection): Send message across process boundary
        (WebKit::WebPageProxy::setMaintainsInactiveSelection): Sets variable
        * UIProcess/WebPageProxy.h: New member variable to keep track of whether we need to maintain the current selection
        (WebKit::WebPageProxy::maintainsInactiveSelection): Returns variable
        * WebProcess/WebPage/WebPage.cpp:
        (WebKit::WebPage::setFocused): Reverting code to just set the focused bit instead of also clearing the selection
        (WebKit::WebPage::clearSelection):
        * WebProcess/WebPage/WebPage.h:
        * WebProcess/WebPage/WebPage.messages.in: add new ClearSelection() message

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

12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/editing/EditingBehavior.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/C/WKPage.cpp
Source/WebKit2/UIProcess/API/C/WKPage.h
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in

index 275faa7..9301e1b 100644 (file)
@@ -1,3 +1,16 @@
+2011-04-29  Jon Lee  <jonlee@apple.com>
+
+        Reviewed by mitzpettel.
+
+        REGRESSION (WebKit2): (Mac) Selection is gone after switching tabs (59721)
+        <rdar://problem/9327332>
+        https://bugs.webkit.org/show_bug.cgi?id=59721
+
+        Removing shouldClearSelectionWhenLosingWebPageFocus().  Reverting changelist 83814.
+
+        * WebCore.exp.in:
+        * editing/EditingBehavior.h:
+
 2011-04-29  Abhishek Arya  <inferno@chromium.org>
 
         Reviewed by Dave Hyatt.
index da6431d..4d7f058 100644 (file)
@@ -1248,7 +1248,6 @@ __ZNK7WebCore6Editor7Command7executeERKN3WTF6StringEPNS_5EventE
 __ZNK7WebCore6Editor7Command9isEnabledEPNS_5EventE
 __ZNK7WebCore6Editor7canCopyEv
 __ZNK7WebCore6Editor7canEditEv
-__ZNK7WebCore6Editor8behaviorEv
 __ZNK7WebCore6Editor8canPasteEv
 __ZNK7WebCore6Editor9canDeleteEv
 __ZNK7WebCore6Widget14platformWidgetEv
index 4ee85f3..a367c52 100644 (file)
@@ -59,10 +59,6 @@ public:
 
     // On Mac, when processing a contextual click, the object being clicked upon should be selected.
     bool shouldSelectOnContextualMenuClick() const { return m_type == EditingMacBehavior; }
-    
-    // On Mac, when the web view loses focus, any active selection clears. On Windows, the selection
-    // should remain highlighted, just in an inactive state.
-    bool shouldClearSelectionWhenLosingWebPageFocus() const { return m_type == EditingMacBehavior; }
 
 private:
     EditingBehaviorType m_type;
index 132674a..7fee9bf 100644 (file)
@@ -1,3 +1,33 @@
+2011-04-29  Jon Lee  <jonlee@apple.com>
+
+        Reviewed by mitzpettel.
+
+        REGRESSION (WebKit2): (Mac) Selection is gone after switching tabs (59721)
+        <rdar://problem/9327332>
+        https://bugs.webkit.org/show_bug.cgi?id=59721
+
+        When resigning first responder status, check to see if we need to maintain an inactive
+        selection in the web view. If we don't, we clear the selection.
+
+        This also reverts the change made in 83814, since that was a different attempt to solve this same issue.
+
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageSetMaintainsInactiveSelection): Export setMaintainsInactiveSelection()
+        * UIProcess/API/C/WKPage.h:
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView resignFirstResponder]): Check and see if we need to maintain the selection in the view prior to resigning.
+        If not, we clear the selection
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::clearSelection): Send message across process boundary
+        (WebKit::WebPageProxy::setMaintainsInactiveSelection): Sets variable
+        * UIProcess/WebPageProxy.h: New member variable to keep track of whether we need to maintain the current selection
+        (WebKit::WebPageProxy::maintainsInactiveSelection): Returns variable
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::setFocused): Reverting code to just set the focused bit instead of also clearing the selection
+        (WebKit::WebPage::clearSelection):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in: add new ClearSelection() message
+
 2011-04-29  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Darin Adler.
index 140182f..1ab4b8f 100644 (file)
@@ -334,6 +334,11 @@ bool WKPageIsContentEditable(WKPageRef pageRef)
     return toImpl(pageRef)->isContentEditable();
 }
 
+void WKPageSetMaintainsInactiveSelection(WKPageRef pageRef, bool newValue)
+{
+    return toImpl(pageRef)->setMaintainsInactiveSelection(newValue);
+}
+
 void WKPageFindString(WKPageRef pageRef, WKStringRef string, WKFindOptions options, unsigned maxMatchCount)
 {
     toImpl(pageRef)->findString(toImpl(string)->string(), toFindOptions(options), maxMatchCount);
index a3e2b5e..e1b82e2 100644 (file)
@@ -346,6 +346,8 @@ WK_EXPORT bool WKPageCanDelete(WKPageRef page);
 WK_EXPORT bool WKPageHasSelectedRange(WKPageRef page);
 WK_EXPORT bool WKPageIsContentEditable(WKPageRef page);
 
+WK_EXPORT void WKPageSetMaintainsInactiveSelection(WKPageRef page, bool maintainsInactiveSelection);
+    
 WK_EXPORT void WKPageFindString(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount);
 WK_EXPORT void WKPageHideFindUI(WKPageRef page);
 WK_EXPORT void WKPageCountStringMatches(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount);
index 9643ccd..7f7a987 100644 (file)
@@ -314,6 +314,9 @@ struct WKViewInterpretKeyEventsParameters {
         _data->_page->confirmCompositionWithoutDisturbingSelection();
     [self _resetTextInputState];
     
+    if (!_data->_page->maintainsInactiveSelection())
+        _data->_page->clearSelection();
+    
     _data->_page->viewStateDidChange(WebPageProxy::ViewIsFocused);
 
     _data->_inResignFirstResponder = false;
index 22a1ccb..5c51150 100644 (file)
@@ -642,6 +642,13 @@ void WebPageProxy::setWindowResizerSize(const IntSize& windowResizerSize)
         return;
     process()->send(Messages::WebPage::SetWindowResizerSize(windowResizerSize), m_pageID);
 }
+    
+void WebPageProxy::clearSelection()
+{
+    if (!isValid())
+        return;
+    process()->send(Messages::WebPage::ClearSelection(), m_pageID);
+}
 
 void WebPageProxy::validateCommand(const String& commandName, PassRefPtr<ValidateCommandCallback> callback)
 {
@@ -654,6 +661,11 @@ void WebPageProxy::validateCommand(const String& commandName, PassRefPtr<Validat
     m_validateCommandCallbacks.set(callbackID, callback.get());
     process()->send(Messages::WebPage::ValidateCommand(commandName, callbackID), m_pageID);
 }
+
+void WebPageProxy::setMaintainsInactiveSelection(bool newValue)
+{
+    m_maintainsInactiveSelection = newValue;
+}
     
 void WebPageProxy::executeEditCommand(const String& commandName)
 {
index 8630781..0e6846b 100644 (file)
@@ -234,6 +234,8 @@ public:
 
     void setInitialFocus(bool);
     void setWindowResizerSize(const WebCore::IntSize&);
+    
+    void clearSelection();
 
     void setViewNeedsDisplay(const WebCore::IntRect&);
     void displayView();
@@ -259,6 +261,9 @@ public:
     bool canDelete() const { return hasSelectedRange() && isContentEditable(); }
     bool hasSelectedRange() const { return m_editorState.selectionIsRange; }
     bool isContentEditable() const { return m_editorState.isContentEditable; }
+    
+    bool maintainsInactiveSelection() const { return m_maintainsInactiveSelection; }
+    void setMaintainsInactiveSelection(bool);
 
 #if PLATFORM(MAC)
     void updateWindowIsVisible(bool windowIsVisible);
@@ -784,6 +789,8 @@ private:
     bool m_canGoBack;
     bool m_canGoForward;
     RefPtr<WebBackForwardList> m_backForwardList;
+    
+    bool m_maintainsInactiveSelection;
 
     String m_toolTip;
 
index b68d1ba..76e690e 100644 (file)
@@ -78,7 +78,6 @@
 #include <WebCore/DocumentMarkerController.h>
 #include <WebCore/DragController.h>
 #include <WebCore/DragData.h>
-#include <WebCore/EditingBehavior.h>
 #include <WebCore/EventHandler.h>
 #include <WebCore/FocusController.h>
 #include <WebCore/FormState.h>
@@ -1206,9 +1205,6 @@ void WebPage::viewWillEndLiveResize()
 
 void WebPage::setFocused(bool isFocused)
 {
-    if (!isFocused && m_page->focusController()->focusedOrMainFrame()->editor()->behavior().shouldClearSelectionWhenLosingWebPageFocus())
-        m_page->focusController()->focusedOrMainFrame()->selection()->clear();
-
     m_page->focusController()->setFocused(isFocused);
 }
 
@@ -1807,6 +1803,11 @@ void WebPage::replaceSelectionWithText(Frame* frame, const String& text)
     frame->selection()->revealSelection(ScrollAlignment::alignToEdgeIfNeeded);
 }
 
+void WebPage::clearSelection()
+{
+    m_page->focusController()->focusedOrMainFrame()->selection()->clear();
+}
+
 bool WebPage::mainFrameHasCustomRepresentation() const
 {
     return static_cast<WebFrameLoaderClient*>(mainFrame()->coreFrame()->loader()->client())->frameHasCustomRepresentation();
index 7b8585b..1c48057 100644 (file)
@@ -364,6 +364,7 @@ public:
 #endif
 
     void replaceSelectionWithText(WebCore::Frame*, const String&);
+    void clearSelection();
 #if PLATFORM(WIN)
     void performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const WebCore::DragDataMap&, uint32_t flags);
 #else
index 57f83e6..a53db79 100644 (file)
@@ -67,6 +67,8 @@ messages -> WebPage {
 
     DidReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, uint32_t policyAction, uint64_t downloadID)
 
+    ClearSelection()
+
     # Callbacks.
     GetContentsAsString(uint64_t callbackID)
     GetMainResourceDataOfFrame(uint64_t frameID, uint64_t callbackID)