Reviewed by Adele Peterson.
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Apr 2011 22:53:49 +0000 (22:53 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Apr 2011 22:53:49 +0000 (22:53 +0000)
        WebKit2: Merge SelectionState and TextInputState
        https://bugs.webkit.org/show_bug.cgi?id=58919

        Combined TextInputState and EditorState in one structure, which is updated whenever we get
        a chance to. There is no sense to keep possibly stale SelectionState data when we have already
        requested the most recent data synchronously.

        This also simplifies the code, as we don't need to pass the state around in a separate variable.

        * GNUmakefile.am:
        * Scripts/webkit2/messages.py:
        * Shared/EditorState.h: Copied from Source/WebKit2/Shared/SelectionState.h.
        (WebKit::EditorState::EditorState):
        * Shared/SelectionState.h: Removed.
        * Shared/mac/TextInputState.h: Removed.
        * UIProcess/API/mac/PageClientImpl.h:
        * UIProcess/API/mac/PageClientImpl.mm:
        (WebKit::PageClientImpl::interpretKeyEvent):
        * UIProcess/API/mac/WKView.mm:
        (-[WKView validRequestorForSendType:returnType:]):
        (-[WKView validateUserInterfaceItem:]):
        (-[WKView shouldDelayWindowOrderingForEvent:]):
        (-[WKView doCommandBySelector:]):
        (-[WKView insertText:replacementRange:]):
        (-[WKView _handleStyleKeyEquivalent:]):
        (-[WKView _executeSavedKeypressCommands]):
        (-[WKView inputContext]):
        (-[WKView hasMarkedText]):
        (-[WKView unmarkText]):
        (-[WKView setMarkedText:selectedRange:replacementRange:]):
        (-[WKView attributedSubstringForProposedRange:actualRange:]):
        (-[WKView _interpretKeyEvent:savingCommandsTo:WebCore::]):
        (-[WKView _updateSecureInputState]):
        * UIProcess/API/mac/WKViewInternal.h:
        * UIProcess/PageClient.h:
        * UIProcess/WebPageProxy.cpp:
        (WebKit::WebPageProxy::editorStateChanged):
        * UIProcess/WebPageProxy.h:
        (WebKit::WebPageProxy::editorState):
        (WebKit::WebPageProxy::hasSelectedRange):
        (WebKit::WebPageProxy::isContentEditable):
        * UIProcess/WebPageProxy.messages.in:
        * UIProcess/mac/WebPageProxyMac.mm:
        (WebKit::WebPageProxy::setComposition):
        (WebKit::WebPageProxy::confirmComposition):
        (WebKit::WebPageProxy::insertText):
        (WebKit::WebPageProxy::executeKeypressCommands):
        (WebKit::WebPageProxy::writeSelectionToPasteboard):
        (WebKit::WebPageProxy::readSelectionFromPasteboard):
        (WebKit::WebPageProxy::interpretQueuedKeyEvent):
        * UIProcess/win/WebView.cpp:
        (WebKit::WebView::compositionSelectionChanged):
        (WebKit::WebView::onIMEComposition):
        (WebKit::WebView::onIMEEndComposition):
        (WebKit::WebView::onIMERequestCharPosition):
        (WebKit::WebView::onIMERequest):
        * WebKit2.xcodeproj/project.pbxproj:
        * WebProcess/WebCoreSupport/WebEditorClient.cpp:
        (WebKit::WebEditorClient::respondToChangedSelection):
        * WebProcess/WebPage/WebPage.cpp:
        (WebKit::WebPage::editorState):
        * WebProcess/WebPage/WebPage.h:
        * WebProcess/WebPage/WebPage.messages.in:
        * WebProcess/WebPage/mac/WebPageMac.mm:
        (WebKit::WebPage::handleEditingKeyboardEvent):
        (WebKit::WebPage::setComposition):
        (WebKit::WebPage::confirmComposition):
        (WebKit::WebPage::insertText):
        (WebKit::WebPage::executeKeypressCommands):
        * win/WebKit2.vcproj:

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

22 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/GNUmakefile.am
Source/WebKit2/Scripts/webkit2/messages.py
Source/WebKit2/Shared/EditorState.h [moved from Source/WebKit2/Shared/SelectionState.h with 65% similarity]
Source/WebKit2/Shared/mac/TextInputState.h [deleted file]
Source/WebKit2/UIProcess/API/mac/PageClientImpl.h
Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/API/mac/WKViewInternal.h
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm
Source/WebKit2/UIProcess/win/WebView.cpp
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm
Source/WebKit2/win/WebKit2.vcproj

index a5d647be574d1230e89a535f915391f9fbf64028..3453ab551925be857dae7b10cb9fa662f75775a5 100644 (file)
         (WebKit::PluginProcessConnection::syncMessageSendTimedOut):
         Send a message to the web process proxy.
 
+2011-04-19  Alexey Proskuryakov  <ap@apple.com>
+
+        Reviewed by Adele Peterson.
+
+        WebKit2: Merge SelectionState and TextInputState
+        https://bugs.webkit.org/show_bug.cgi?id=58919
+
+        Combined TextInputState and EditorState in one structure, which is updated whenever we get
+        a chance to. There is no sense to keep possibly stale SelectionState data when we have already
+        requested the most recent data synchronously.
+
+        This also simplifies the code, as we don't need to pass the state around in a separate variable.
+
+        * GNUmakefile.am:
+        * Scripts/webkit2/messages.py:
+        * Shared/EditorState.h: Copied from Source/WebKit2/Shared/SelectionState.h.
+        (WebKit::EditorState::EditorState):
+        * Shared/SelectionState.h: Removed.
+        * Shared/mac/TextInputState.h: Removed.
+        * UIProcess/API/mac/PageClientImpl.h:
+        * UIProcess/API/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::interpretKeyEvent):
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView validRequestorForSendType:returnType:]):
+        (-[WKView validateUserInterfaceItem:]):
+        (-[WKView shouldDelayWindowOrderingForEvent:]):
+        (-[WKView doCommandBySelector:]):
+        (-[WKView insertText:replacementRange:]):
+        (-[WKView _handleStyleKeyEquivalent:]):
+        (-[WKView _executeSavedKeypressCommands]):
+        (-[WKView inputContext]):
+        (-[WKView hasMarkedText]):
+        (-[WKView unmarkText]):
+        (-[WKView setMarkedText:selectedRange:replacementRange:]):
+        (-[WKView attributedSubstringForProposedRange:actualRange:]):
+        (-[WKView _interpretKeyEvent:savingCommandsTo:WebCore::]):
+        (-[WKView _updateSecureInputState]):
+        * UIProcess/API/mac/WKViewInternal.h:
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::editorStateChanged):
+        * UIProcess/WebPageProxy.h:
+        (WebKit::WebPageProxy::editorState):
+        (WebKit::WebPageProxy::hasSelectedRange):
+        (WebKit::WebPageProxy::isContentEditable):
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/mac/WebPageProxyMac.mm:
+        (WebKit::WebPageProxy::setComposition):
+        (WebKit::WebPageProxy::confirmComposition):
+        (WebKit::WebPageProxy::insertText):
+        (WebKit::WebPageProxy::executeKeypressCommands):
+        (WebKit::WebPageProxy::writeSelectionToPasteboard):
+        (WebKit::WebPageProxy::readSelectionFromPasteboard):
+        (WebKit::WebPageProxy::interpretQueuedKeyEvent):
+        * UIProcess/win/WebView.cpp:
+        (WebKit::WebView::compositionSelectionChanged):
+        (WebKit::WebView::onIMEComposition):
+        (WebKit::WebView::onIMEEndComposition):
+        (WebKit::WebView::onIMERequestCharPosition):
+        (WebKit::WebView::onIMERequest):
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/WebCoreSupport/WebEditorClient.cpp:
+        (WebKit::WebEditorClient::respondToChangedSelection):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::editorState):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::handleEditingKeyboardEvent):
+        (WebKit::WebPage::setComposition):
+        (WebKit::WebPage::confirmComposition):
+        (WebKit::WebPage::insertText):
+        (WebKit::WebPage::executeKeypressCommands):
+        * win/WebKit2.vcproj:
+
 2011-04-19  Alexey Proskuryakov  <ap@apple.com>
 
         Reviewed by Timothy Hatcher.
index c52a3fb2977b7069162e9adc68c6c8780b1595e0..2d6ad7e236aedef101beae0bb7a196b71997ef15 100644 (file)
@@ -184,6 +184,7 @@ libWebKit2_la_SOURCES = \
        Source/WebKit2/Shared/CoreIPCSupport/WebContextMessageKinds.h \
        Source/WebKit2/Shared/CoreIPCSupport/WebPageProxyMessageKinds.h \
        Source/WebKit2/Shared/DrawingAreaInfo.h \
+       Source/WebKit2/Shared/EditorState.h \
        Source/WebKit2/Shared/FontSmoothingLevel.h \
        Source/WebKit2/Shared/gtk/ShareableBitmapGtk.cpp \
        Source/WebKit2/Shared/gtk/NativeWebKeyboardEventGtk.cpp \
@@ -233,7 +234,6 @@ libWebKit2_la_SOURCES = \
        Source/WebKit2/Shared/SandboxExtension.h \
        Source/WebKit2/Shared/SecurityOriginData.h \
        Source/WebKit2/Shared/SecurityOriginData.cpp \
-       Source/WebKit2/Shared/SelectionState.h \
        Source/WebKit2/Shared/SessionState.cpp \
        Source/WebKit2/Shared/SessionState.h \
        Source/WebKit2/Shared/StringPairVector.h \
index 7169e0bc19d28aa8146999169a9154b837700186..433658de69e5da7dd583641670da28f3d0bc5a2f 100644 (file)
@@ -263,13 +263,12 @@ def struct_or_class(namespace, type):
         'WebKit::ContextMenuState',
         'WebKit::DictionaryPopupInfo',
         'WebKit::DrawingAreaInfo',
+        'WebKit::EditorState',
         'WebKit::PlatformPopupMenuData',
         'WebKit::PluginProcessCreationParameters',
         'WebKit::PrintInfo',
         'WebKit::SecurityOriginData',
-        'WebKit::SelectionState',
         'WebKit::TextCheckerState',
-        'WebKit::TextInputState',
         'WebKit::WebNavigationDataStore',
         'WebKit::WebOpenPanelParameters::Data',
         'WebKit::WebPageCreationParameters',
similarity index 65%
rename from Source/WebKit2/Shared/SelectionState.h
rename to Source/WebKit2/Shared/EditorState.h
index 9931a1000bcff05ec84f9a4ea98981dcbe1ccd40..1e8bcb82e7a5e21ad23890bbf4f82c9df665ba2f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef SelectionState_h
-#define SelectionState_h
+#ifndef EditorState_h
+#define EditorState_h
 
 #include "ArgumentCoders.h"
 #include <wtf/NotFound.h>
 
 namespace WebKit {
 
-struct SelectionState {
-    SelectionState()
-        : isNone(true)
+struct EditorState {
+    EditorState()
+        : selectionIsNone(true)
+        , selectionIsRange(false)
         , isContentEditable(false)
         , isContentRichlyEditable(false)
         , isInPasswordField(false)
         , hasComposition(false)
-        , selectedRangeStart(notFound)
-        , selectedRangeLength(0)
     {
     }
 
-    // Whether there is a selection at all. This will be false when there is a caret selection.
-    bool isNone;
-
-    // Whether the selection is in a content editable area.
+    bool selectionIsNone; // This will be false when there is a caret selection.
+    bool selectionIsRange;
     bool isContentEditable;
-    
-    // Whether the selection is in a rich content editable area.
     bool isContentRichlyEditable;
-
-    // Whether the selection is in a password field.
     bool isInPasswordField;
-
-    // Whether the selection has a composition.
     bool hasComposition;
-
-    // The start of the selected range.
-    uint64_t selectedRangeStart;
-    
-    // The length of the selected range.
-    uint64_t selectedRangeLength;
 };
 
-} // namespace WebKit
+}
 
 namespace CoreIPC {
-template<> struct ArgumentCoder<WebKit::SelectionState> : SimpleArgumentCoder<WebKit::SelectionState> { };
+template<> struct ArgumentCoder<WebKit::EditorState> : SimpleArgumentCoder<WebKit::EditorState> { };
 };
 
-#endif // SelectionState_h
+#endif // EditorState_h
diff --git a/Source/WebKit2/Shared/mac/TextInputState.h b/Source/WebKit2/Shared/mac/TextInputState.h
deleted file mode 100644 (file)
index 05ba912..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TextInputState_h
-#define TextInputState_h
-
-#include "ArgumentCoders.h"
-
-namespace WebKit {
-
-struct TextInputState {
-    bool hasMarkedText;
-    bool selectionIsEditable;
-};
-
-}
-
-namespace CoreIPC {
-template<> struct ArgumentCoder<WebKit::TextInputState> : SimpleArgumentCoder<WebKit::TextInputState> { };
-}
-
-#endif // TextInputState_h
index f4f19593a29f6a38a8f5f88ecde5e00b1606608d..9e08a28323253551e9f115ba743d37d28a4ddc23 100644 (file)
@@ -71,7 +71,7 @@ private:
     virtual void clearAllEditCommands();
     virtual bool canUndoRedo(WebPageProxy::UndoOrRedo);
     virtual void executeUndoRedo(WebPageProxy::UndoOrRedo);
-    virtual bool interpretKeyEvent(const NativeWebKeyboardEvent&, const TextInputState&, Vector<WebCore::KeypressCommand>&);
+    virtual bool interpretKeyEvent(const NativeWebKeyboardEvent&, Vector<WebCore::KeypressCommand>&);
     virtual bool executeSavedCommandBySelector(const String& selector);
     virtual void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag);
     virtual void updateSecureInputState();
index fba07383d8cb92fe4a63093f2cb2a0d0339a74a4..e1888de9a92fd759b899d684abbab53fc8cae256 100644 (file)
@@ -239,9 +239,9 @@ void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
     return (undoOrRedo == WebPageProxy::Undo) ? [[m_wkView undoManager] undo] : [[m_wkView undoManager] redo];
 }
 
-bool PageClientImpl::interpretKeyEvent(const NativeWebKeyboardEvent& event, const TextInputState& state, Vector<WebCore::KeypressCommand>& commands)
+bool PageClientImpl::interpretKeyEvent(const NativeWebKeyboardEvent& event, Vector<WebCore::KeypressCommand>& commands)
 {
-    return [m_wkView _interpretKeyEvent:event.nativeEvent() withCachedTextInputState:state savingCommandsTo:commands];
+    return [m_wkView _interpretKeyEvent:event.nativeEvent() savingCommandsTo:commands];
 }
 
 void PageClientImpl::setDragImage(const IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag)
index 6a1731481c42e7fa19b86cbad961a43030178111..80345f72cd9df6b6d3c58d59fa8f9228105b0f9e 100644 (file)
@@ -30,6 +30,7 @@
 #import "ChunkedUpdateDrawingAreaProxy.h"
 #import "DataReference.h"
 #import "DrawingAreaProxyImpl.h"
+#import "EditorState.h"
 #import "FindIndicator.h"
 #import "FindIndicatorWindow.h"
 #import "LayerTreeContext.h"
@@ -43,7 +44,6 @@
 #import "RunLoop.h"
 #import "TextChecker.h"
 #import "TextCheckerState.h"
-#import "TextInputState.h"
 #import "WKAPICast.h"
 #import "WKFullScreenWindowController.h"
 #import "WKPrintingView.h"
@@ -101,7 +101,6 @@ typedef HashMap<String, ValidationVector> ValidationMap;
 }
 
 struct WKViewInterpretKeyEventsParameters {
-    TextInputState cachedTextInputState;
     bool eventInterpretationHadSideEffects;
     bool consumedByIM;
     bool executingSavedKeypressCommands;
@@ -536,13 +535,13 @@ WEBCORE_COMMAND(yankAndSelect)
 
 - (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType
 {
-    BOOL isValidSendType = !sendType || ([PasteboardTypes::forSelection() containsObject:sendType] && !_data->_page->selectionState().isNone);
+    BOOL isValidSendType = !sendType || ([PasteboardTypes::forSelection() containsObject:sendType] && !_data->_page->editorState().selectionIsNone);
     BOOL isValidReturnType = NO;
     if (!returnType)
         isValidReturnType = YES;
-    else if ([PasteboardTypes::forEditing() containsObject:returnType] && _data->_page->selectionState().isContentEditable) {
+    else if ([PasteboardTypes::forEditing() containsObject:returnType] && _data->_page->editorState().isContentEditable) {
         // We can insert strings in any editable context.  We can insert other types, like images, only in rich edit contexts.
-        isValidReturnType = _data->_page->selectionState().isContentRichlyEditable || [returnType isEqualToString:NSStringPboardType];
+        isValidReturnType = _data->_page->editorState().isContentRichlyEditable || [returnType isEqualToString:NSStringPboardType];
     }
     if (isValidSendType && isValidReturnType)
         return self;
@@ -627,11 +626,11 @@ static void validateCommandCallback(WKStringRef commandName, bool isEnabled, int
     if (action == @selector(showGuessPanel:)) {
         if (NSMenuItem *menuItem = ::menuItem(item))
             [menuItem setTitle:contextMenuItemTagShowSpellingPanel(![[[NSSpellChecker sharedSpellChecker] spellingPanel] isVisible])];
-        return _data->_page->selectionState().isContentEditable;
+        return _data->_page->editorState().isContentEditable;
     }
 
     if (action == @selector(checkSpelling:) || action == @selector(changeSpelling:))
-        return _data->_page->selectionState().isContentEditable;
+        return _data->_page->editorState().isContentEditable;
 
     if (action == @selector(toggleContinuousSpellChecking:)) {
         bool enabled = TextChecker::isContinuousSpellCheckingAllowed();
@@ -649,47 +648,47 @@ static void validateCommandCallback(WKStringRef commandName, bool isEnabled, int
     if (action == @selector(toggleAutomaticSpellingCorrection:)) {
         bool checked = TextChecker::state().isAutomaticSpellingCorrectionEnabled;
         [menuItem(item) setState:checked ? NSOnState : NSOffState];
-        return _data->_page->selectionState().isContentEditable;
+        return _data->_page->editorState().isContentEditable;
     }
 
     if (action == @selector(orderFrontSubstitutionsPanel:)) {
         if (NSMenuItem *menuItem = ::menuItem(item))
             [menuItem setTitle:contextMenuItemTagShowSubstitutions(![[[NSSpellChecker sharedSpellChecker] substitutionsPanel] isVisible])];
-        return _data->_page->selectionState().isContentEditable;
+        return _data->_page->editorState().isContentEditable;
     }
 
     if (action == @selector(toggleSmartInsertDelete:)) {
         bool checked = _data->_page->isSmartInsertDeleteEnabled();
         [menuItem(item) setState:checked ? NSOnState : NSOffState];
-        return _data->_page->selectionState().isContentEditable;
+        return _data->_page->editorState().isContentEditable;
     }
 
     if (action == @selector(toggleAutomaticQuoteSubstitution:)) {
         bool checked = TextChecker::state().isAutomaticQuoteSubstitutionEnabled;
         [menuItem(item) setState:checked ? NSOnState : NSOffState];
-        return _data->_page->selectionState().isContentEditable;
+        return _data->_page->editorState().isContentEditable;
     }
 
     if (action == @selector(toggleAutomaticDashSubstitution:)) {
         bool checked = TextChecker::state().isAutomaticDashSubstitutionEnabled;
         [menuItem(item) setState:checked ? NSOnState : NSOffState];
-        return _data->_page->selectionState().isContentEditable;
+        return _data->_page->editorState().isContentEditable;
     }
 
     if (action == @selector(toggleAutomaticLinkDetection:)) {
         bool checked = TextChecker::state().isAutomaticLinkDetectionEnabled;
         [menuItem(item) setState:checked ? NSOnState : NSOffState];
-        return _data->_page->selectionState().isContentEditable;
+        return _data->_page->editorState().isContentEditable;
     }
 
     if (action == @selector(toggleAutomaticTextReplacement:)) {
         bool checked = TextChecker::state().isAutomaticTextReplacementEnabled;
         [menuItem(item) setState:checked ? NSOnState : NSOffState];
-        return _data->_page->selectionState().isContentEditable;
+        return _data->_page->editorState().isContentEditable;
     }
 
     if (action == @selector(uppercaseWord:) || action == @selector(lowercaseWord:) || action == @selector(capitalizeWord:))
-        return _data->_page->selectionState().selectedRangeLength && _data->_page->selectionState().isContentEditable;
+        return _data->_page->editorState().selectionIsRange && _data->_page->editorState().isContentEditable;
     
     if (action == @selector(stopSpeaking:))
         return [NSApp isSpeaking];
@@ -1028,7 +1027,7 @@ EVENT_HANDLER(scrollWheel, Wheel)
 {
     // If this is the active window or we don't have a range selection, there is no need to perform additional checks
     // and we can avoid making a synchronous call to the WebProcess.
-    if ([[self window] isKeyWindow] || _data->_page->selectionState().isNone || !_data->_page->selectionState().selectedRangeLength)
+    if ([[self window] isKeyWindow] || _data->_page->editorState().selectionIsNone || !_data->_page->editorState().selectionIsRange)
         return NO;
 
     // There's a chance that responding to this event will run a nested event loop, and
@@ -1089,7 +1088,7 @@ static const short kIOHIDEventTypeScroll = 6;
         parameters->consumedByIM = false;
 
     // As in insertText:replacementRange:, we assume that the call comes from an input method if there is marked text.
-    bool isFromInputMethod = parameters && parameters->cachedTextInputState.hasMarkedText;
+    bool isFromInputMethod = _data->_page->editorState().hasComposition;
 
     if (parameters && !isFromInputMethod)
         parameters->commands->append(KeypressCommand(NSStringFromSelector(selector)));
@@ -1122,7 +1121,7 @@ static const short kIOHIDEventTypeScroll = 6;
         parameters->consumedByIM = false;
 
     NSString *text;
-    bool isFromInputMethod = parameters && parameters->cachedTextInputState.hasMarkedText;
+    bool isFromInputMethod = _data->_page->editorState().hasComposition;
 
     if (isAttributedString) {
         // FIXME: We ignore most attributes from the string, so for example inserting from Character Palette loses font and glyph variation data.
@@ -1142,20 +1141,17 @@ static const short kIOHIDEventTypeScroll = 6;
         return;
     }
 
-    TextInputState newTextInputState;
     String eventText = text;
     eventText.replace(NSBackTabCharacter, NSTabCharacter); // same thing is done in KeyEventMac.mm in WebCore
-    bool eventHandled = _data->_page->insertText(eventText, replacementRange.location, NSMaxRange(replacementRange), newTextInputState);
+    bool eventHandled = _data->_page->insertText(eventText, replacementRange.location, NSMaxRange(replacementRange));
 
-    if (parameters) {
+    if (parameters)
         parameters->eventInterpretationHadSideEffects |= eventHandled;
-        parameters->cachedTextInputState = newTextInputState;
-    }
 }
 
 - (BOOL)_handleStyleKeyEquivalent:(NSEvent *)event
 {
-    if (!_data->_page->selectionState().isContentEditable)
+    if (!_data->_page->editorState().isContentEditable)
         return NO;
 
     if (([event modifierFlags] & NSDeviceIndependentModifierFlagsMask) != NSCommandKeyMask)
@@ -1261,9 +1257,7 @@ static const short kIOHIDEventTypeScroll = 6;
         return;
 
     parameters->executingSavedKeypressCommands = true;
-    TextInputState newTextInputState;
-    parameters->eventInterpretationHadSideEffects |= _data->_page->executeKeypressCommands(*parameters->commands, newTextInputState);
-    parameters->cachedTextInputState = newTextInputState;
+    parameters->eventInterpretationHadSideEffects |= _data->_page->executeKeypressCommands(*parameters->commands);
     parameters->commands->clear();
     parameters->executingSavedKeypressCommands = false;
 }
@@ -1276,9 +1270,7 @@ static const short kIOHIDEventTypeScroll = 6;
         return [[WKTextInputWindowController sharedTextInputWindowController] inputContext];
 
     // Disable text input machinery when in non-editable content. An invisible inline input area affects performance, and can prevent Expose from working.
-    if (parameters && !parameters->cachedTextInputState.selectionIsEditable)
-        return nil;
-    if (!_data->_page->selectionState().isContentEditable)
+    if (!_data->_page->editorState().isContentEditable)
         return nil;
 
     return [super inputContext];
@@ -1307,11 +1299,11 @@ static const short kIOHIDEventTypeScroll = 6;
 
     BOOL result;
     if (parameters) {
-        result = parameters->cachedTextInputState.hasMarkedText;
+        result = _data->_page->editorState().hasComposition;
         if (result) {
             // A saved command can confirm a composition, but it cannot start a new one.
             [self _executeSavedKeypressCommands];
-            result = parameters->cachedTextInputState.hasMarkedText;
+            result = _data->_page->editorState().hasComposition;
         }
     } else {
         uint64_t location;
@@ -1338,10 +1330,7 @@ static const short kIOHIDEventTypeScroll = 6;
         parameters->consumedByIM = false;
     }
 
-    TextInputState newTextInputState;
-    _data->_page->confirmComposition(newTextInputState);
-    if (parameters)
-        parameters->cachedTextInputState = newTextInputState;
+    _data->_page->confirmComposition();
 }
 
 - (NSArray *)validAttributesForMarkedText
@@ -1409,24 +1398,19 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
     } else
         text = string;
 
-    TextInputState newTextInputState;
-    if (_data->_page->selectionState().isInPasswordField) {
+    if (_data->_page->editorState().isInPasswordField) {
         // In password fields, we only allow ASCII dead keys, and don't allow inline input, matching NSSecureTextInputField.
         // Allowing ASCII dead keys is necessary to enable full Roman input when using a Vietnamese keyboard.
-        ASSERT(!_data->_page->selectionState().hasComposition);
+        ASSERT(!_data->_page->editorState().hasComposition);
         [[super inputContext] discardMarkedText]; // Inform the input method that we won't have an inline input area despite having been asked to.
         if ([text length] == 1 && [[text decomposedStringWithCanonicalMapping] characterAtIndex:0] < 0x80) {
-            _data->_page->insertText(text, replacementRange.location, NSMaxRange(replacementRange), newTextInputState);
-            if (parameters)
-                parameters->cachedTextInputState = newTextInputState;
+            _data->_page->insertText(text, replacementRange.location, NSMaxRange(replacementRange));
         } else
             NSBeep();
         return;
     }
 
-    _data->_page->setComposition(text, underlines, newSelRange.location, NSMaxRange(newSelRange), replacementRange.location, NSMaxRange(replacementRange), newTextInputState);
-    if (parameters)
-        parameters->cachedTextInputState = newTextInputState;
+    _data->_page->setComposition(text, underlines, newSelRange.location, NSMaxRange(newSelRange), replacementRange.location, NSMaxRange(replacementRange));
 }
 
 - (NSRange)markedRange
@@ -1445,13 +1429,12 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
 {
     [self _executeSavedKeypressCommands];
 
-    WKViewInterpretKeyEventsParameters* parameters = _data->_interpretKeyEventsParameters;
-    if (parameters && !parameters->cachedTextInputState.selectionIsEditable) {
+    if (!_data->_page->editorState().isContentEditable) {
         LOG(TextInput, "attributedSubstringFromRange:(%u, %u) -> nil", nsRange.location, nsRange.length);
         return nil;
     }
 
-    if (_data->_page->selectionState().isInPasswordField)
+    if (_data->_page->editorState().isInPasswordField)
         return nil;
 
     AttributedString result;
@@ -2012,7 +1995,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
     _data->_keyDownEventBeingResent = nullptr;
 }
 
-- (BOOL)_interpretKeyEvent:(NSEvent *)event withCachedTextInputState:(const TextInputState&)cachedTextInputState savingCommandsTo:(Vector<WebCore::KeypressCommand>&)commands
+- (BOOL)_interpretKeyEvent:(NSEvent *)event savingCommandsTo:(Vector<WebCore::KeypressCommand>&)commands
 {
     ASSERT(!_data->_interpretKeyEventsParameters);
     ASSERT(commands.isEmpty());
@@ -2021,7 +2004,6 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
         return NO;
 
     WKViewInterpretKeyEventsParameters parameters;
-    parameters.cachedTextInputState = cachedTextInputState;
     parameters.eventInterpretationHadSideEffects = false;
     parameters.executingSavedKeypressCommands = false;
     // We assume that an input method has consumed the event, and only change this assumption if one of the NSTextInput methods is called.
@@ -2331,7 +2313,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
     }
     // WKView has a single input context for all editable areas (except for plug-ins).
     NSTextInputContext *context = [super inputContext];
-    bool isInPasswordField = _data->_page->selectionState().isInPasswordField;
+    bool isInPasswordField = _data->_page->editorState().isInPasswordField;
 
     if (isInPasswordField) {
         if (!_data->_inSecureInputState)
index d129d5775d5ce54a8161e4ac77dd52f3ae62d3be..82acdcf7d44714b266e7b2573b3f9cdd9b2021ee 100644 (file)
@@ -40,7 +40,6 @@ namespace WebKit {
     class DrawingAreaProxy;
     class FindIndicator;
     class LayerTreeContext;
-    struct TextInputState;
 }
 
 @class WKFullScreenWindowController;
@@ -54,7 +53,7 @@ namespace WebKit {
 - (void)_toolTipChangedFrom:(NSString *)oldToolTip to:(NSString *)newToolTip;
 - (void)_setCursor:(NSCursor *)cursor;
 - (void)_setUserInterfaceItemState:(NSString *)commandName enabled:(BOOL)isEnabled state:(int)newState;
-- (BOOL)_interpretKeyEvent:(NSEvent *)theEvent withCachedTextInputState:(const WebKit::TextInputState&)cachedTextInputState savingCommandsTo:(Vector<WebCore::KeypressCommand>&)commands;
+- (BOOL)_interpretKeyEvent:(NSEvent *)theEvent savingCommandsTo:(Vector<WebCore::KeypressCommand>&)commands;
 - (void)_resendKeyDownEvent:(NSEvent *)event;
 - (bool)_executeSavedCommandBySelector:(SEL)selector;
 - (NSRect)_convertToDeviceSpace:(NSRect)rect;
index 088895b1966f3fb5c37d44d4f5e2a4135c2f8820..7582152f2feb8ebe49586b4834a199f8ac1ec427 100644 (file)
@@ -100,7 +100,7 @@ public:
     virtual void executeUndoRedo(WebPageProxy::UndoOrRedo) = 0;
 #if PLATFORM(MAC)
     virtual void accessibilityWebProcessTokenReceived(const CoreIPC::DataReference&) = 0;
-    virtual bool interpretKeyEvent(const NativeWebKeyboardEvent&, const TextInputState&, Vector<WebCore::KeypressCommand>&) = 0;
+    virtual bool interpretKeyEvent(const NativeWebKeyboardEvent&, Vector<WebCore::KeypressCommand>&) = 0;
     virtual bool executeSavedCommandBySelector(const String& selector) = 0;
     virtual void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag) = 0;
     virtual void updateSecureInputState() = 0;
index 491883e483eb0f3b5a7586df37f3bc194792ef83..aabb304ae56f4beab82f5468a760f256dd1438dc 100644 (file)
@@ -2142,17 +2142,17 @@ void WebPageProxy::backForwardForwardListCount(int32_t& count)
     count = m_backForwardList->forwardListCount();
 }
 
-void WebPageProxy::selectionStateChanged(const SelectionState& selectionState)
+void WebPageProxy::editorStateChanged(const EditorState& editorState)
 {
 #if PLATFORM(MAC)
-    bool couldChangeSecureInputState = m_selectionState.isInPasswordField != selectionState.isInPasswordField || m_selectionState.isNone;
+    bool couldChangeSecureInputState = m_editorState.isInPasswordField != editorState.isInPasswordField || m_editorState.selectionIsNone;
 #endif
 
-    m_selectionState = selectionState;
+    m_editorState = editorState;
 
 #if PLATFORM(MAC)
     // This is a temporary state. Flipping secure input state too quickly can expose race conditions.
-    if (selectionState.isNone)
+    if (editorState.selectionIsNone)
         return;
 
     if (couldChangeSecureInputState)
index fd28d5a96d952ff3aeae25076b1931a2de681ab1..bea43b5ee03b0dab58831d12504189c9c8914fa6 100644 (file)
@@ -31,9 +31,9 @@
 #include "ContextMenuState.h"
 #include "DragControllerAction.h"
 #include "DrawingAreaProxy.h"
+#include "EditorState.h"
 #include "GeolocationPermissionRequestManagerProxy.h"
 #include "SandboxExtension.h"
-#include "SelectionState.h"
 #include "SharedMemory.h"
 #include "WKBase.h"
 #include "WKPagePrivate.h"
@@ -97,9 +97,9 @@ class WebURLRequest;
 class WebWheelEvent;
 struct AttributedString;
 struct DictionaryPopupInfo;
+struct EditorState;
 struct PlatformPopupMenuData;
 struct PrintInfo;
-struct TextInputState;
 struct WebPageCreationParameters;
 struct WebPopupItem;
 
@@ -247,24 +247,24 @@ public:
     void executeEditCommand(const String& commandName);
     void validateCommand(const String& commandName, PassRefPtr<ValidateCommandCallback>);
 
-    const SelectionState& selectionState() const { return m_selectionState; }
+    const EditorState& editorState() const { return m_editorState; }
     bool canDelete() const { return hasSelectedRange() && isContentEditable(); }
-    bool hasSelectedRange() const { return m_selectionState.selectedRangeLength; }
-    bool isContentEditable() const { return m_selectionState.isContentEditable; }
+    bool hasSelectedRange() const { return m_editorState.selectionIsRange; }
+    bool isContentEditable() const { return m_editorState.isContentEditable; }
 
 #if PLATFORM(MAC)
     void updateWindowIsVisible(bool windowIsVisible);
     void windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates, const WebCore::IntPoint& accessibilityViewCoordinates);
 
-    void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, TextInputState& newState);
-    void confirmComposition(TextInputState& newState);
-    bool insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, TextInputState& newState);
+    void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd);
+    void confirmComposition();
+    bool insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd);
     void getMarkedRange(uint64_t& location, uint64_t& length);
     void getSelectedRange(uint64_t& location, uint64_t& length);
     void getAttributedSubstringFromRange(uint64_t location, uint64_t length, AttributedString&);
     uint64_t characterIndexForPoint(const WebCore::IntPoint);
     WebCore::IntRect firstRectForCharacterRange(uint64_t, uint64_t);
-    bool executeKeypressCommands(const Vector<WebCore::KeypressCommand>&, TextInputState& newState);
+    bool executeKeypressCommands(const Vector<WebCore::KeypressCommand>&);
 
     void sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String& textInput);
     CGContextRef containingWindowGraphicsContext();
@@ -589,8 +589,7 @@ private:
     void didFindZoomableArea(const WebCore::IntRect&);
 #endif
 
-    // Selection
-    void selectionStateChanged(const SelectionState&);
+    void editorStateChanged(const EditorState&);
 
     // Back/Forward list management
     void backForwardAddItem(uint64_t itemID);
@@ -608,7 +607,7 @@ private:
 
     // Keyboard handling
 #if PLATFORM(MAC)
-    void interpretQueuedKeyEvent(const TextInputState&, bool& handled, Vector<WebCore::KeypressCommand>&);
+    void interpretQueuedKeyEvent(const EditorState&, bool& handled, Vector<WebCore::KeypressCommand>&);
     void executeSavedCommandBySelector(const String& selector, bool& handled);
 #endif
 
@@ -764,7 +763,7 @@ private:
 
     String m_toolTip;
 
-    SelectionState m_selectionState;
+    EditorState m_editorState;
 
     double m_textZoomFactor;
     double m_pageZoomFactor;
index cfcb3098b78f4cd7ad945919a70f18064e359cc8..f5f4238e7d1a50aa55efe16463d8245436c1ca19 100644 (file)
@@ -145,9 +145,9 @@ messages -> WebPageProxy {
     ClearAllEditCommands()
     CanUndoRedo(uint32_t action) -> (bool result)
     ExecuteUndoRedo(uint32_t action) -> (bool result)
-    
-    # Selection messages
-    SelectionStateChanged(WebKit::SelectionState selectionState)
+
+    # Editor notifications
+    EditorStateChanged(WebKit::EditorState editorState)
 #if PLATFORM(WIN)
     DidChangeCompositionSelection(bool hasChanged)
 #endif
@@ -205,7 +205,7 @@ messages -> WebPageProxy {
     DidPerformDictionaryLookup(WTF::String text, WebKit::DictionaryPopupInfo dictionaryPopupInfo)
 
     # Keyboard input support messages
-    InterpretQueuedKeyEvent(WebKit::TextInputState state) -> (bool handled, Vector<WebCore::KeypressCommand> savedCommands)
+    InterpretQueuedKeyEvent(WebKit::EditorState state) -> (bool handled, Vector<WebCore::KeypressCommand> savedCommands)
     ExecuteSavedCommandBySelector(WTF::String selector) -> (bool handled)
 
     # Remote accessibility messages
index e377aaa575d73cbc6bd515c91e492dcfec2b8de1..9dacae5b290ef49b277eb2f04a0e989b559b5bfe 100644 (file)
 #import "AttributedString.h"
 #import "DataReference.h"
 #import "DictionaryPopupInfo.h"
+#import "EditorState.h"
 #import "NativeWebKeyboardEvent.h"
 #import "PageClient.h"
 #import "PageClientImpl.h"
 #import "TextChecker.h"
-#import "TextInputState.h"
 #import "WebPageMessages.h"
 #import "WebProcessProxy.h"
 #import <wtf/text/StringConcatenate.h>
@@ -141,20 +141,20 @@ void WebPageProxy::windowAndViewFramesChanged(const IntRect& windowFrameInScreen
     process()->send(Messages::WebPage::WindowAndViewFramesChanged(windowFrameInScreenCoordinates, viewFrameInWindowCoordinates, accessibilityViewCoordinates), m_pageID);
 }
 
-void WebPageProxy::setComposition(const String& text, Vector<CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, TextInputState& newState)
+void WebPageProxy::setComposition(const String& text, Vector<CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd)
 {
-    process()->sendSync(Messages::WebPage::SetComposition(text, underlines, selectionStart, selectionEnd, replacementRangeStart, replacementRangeEnd), Messages::WebPage::SetComposition::Reply(newState), m_pageID);
+    process()->sendSync(Messages::WebPage::SetComposition(text, underlines, selectionStart, selectionEnd, replacementRangeStart, replacementRangeEnd), Messages::WebPage::SetComposition::Reply(m_editorState), m_pageID);
 }
 
-void WebPageProxy::confirmComposition(TextInputState& newState)
+void WebPageProxy::confirmComposition()
 {
-    process()->sendSync(Messages::WebPage::ConfirmComposition(), Messages::WebPage::ConfirmComposition::Reply(newState), m_pageID);
+    process()->sendSync(Messages::WebPage::ConfirmComposition(), Messages::WebPage::ConfirmComposition::Reply(m_editorState), m_pageID);
 }
 
-bool WebPageProxy::insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, TextInputState& newState)
+bool WebPageProxy::insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd)
 {
     bool handled;
-    process()->sendSync(Messages::WebPage::InsertText(text, replacementRangeStart, replacementRangeEnd), Messages::WebPage::InsertText::Reply(handled, newState), m_pageID);
+    process()->sendSync(Messages::WebPage::InsertText(text, replacementRangeStart, replacementRangeEnd), Messages::WebPage::InsertText::Reply(handled, m_editorState), m_pageID);
     return handled;
 }
 
@@ -187,26 +187,26 @@ WebCore::IntRect WebPageProxy::firstRectForCharacterRange(uint64_t location, uin
     return resultRect;
 }
 
-bool WebPageProxy::executeKeypressCommands(const Vector<WebCore::KeypressCommand>& commands, TextInputState& newState)
+bool WebPageProxy::executeKeypressCommands(const Vector<WebCore::KeypressCommand>& commands)
 {
     bool result;
-    process()->sendSync(Messages::WebPage::ExecuteKeypressCommands(commands), Messages::WebPage::ExecuteKeypressCommands::Reply(result, newState), m_pageID);
+    process()->sendSync(Messages::WebPage::ExecuteKeypressCommands(commands), Messages::WebPage::ExecuteKeypressCommands::Reply(result, m_editorState), m_pageID);
     return result;
 }
 
 bool WebPageProxy::writeSelectionToPasteboard(const String& pasteboardName, const Vector<String>& pasteboardTypes)
 {
     bool result;
-    const double MessageTimeout = 20;
-    process()->sendSync(Messages::WebPage::WriteSelectionToPasteboard(pasteboardName, pasteboardTypes), Messages::WebPage::WriteSelectionToPasteboard::Reply(result), m_pageID, MessageTimeout);
+    const double messageTimeout = 20;
+    process()->sendSync(Messages::WebPage::WriteSelectionToPasteboard(pasteboardName, pasteboardTypes), Messages::WebPage::WriteSelectionToPasteboard::Reply(result), m_pageID, messageTimeout);
     return result;
 }
 
 bool WebPageProxy::readSelectionFromPasteboard(const String& pasteboardName)
 {
     bool result;
-    const double MessageTimeout = 20;
-    process()->sendSync(Messages::WebPage::ReadSelectionFromPasteboard(pasteboardName), Messages::WebPage::ReadSelectionFromPasteboard::Reply(result), m_pageID, MessageTimeout);
+    const double messageTimeout = 20;
+    process()->sendSync(Messages::WebPage::ReadSelectionFromPasteboard(pasteboardName), Messages::WebPage::ReadSelectionFromPasteboard::Reply(result), m_pageID, messageTimeout);
     return result;
 }
 
@@ -227,9 +227,10 @@ void WebPageProxy::performDictionaryLookupAtLocation(const WebCore::FloatPoint&
     process()->send(Messages::WebPage::PerformDictionaryLookupAtLocation(point), m_pageID); 
 }
 
-void WebPageProxy::interpretQueuedKeyEvent(const TextInputState& state, bool& handled, Vector<WebCore::KeypressCommand>& commands)
+void WebPageProxy::interpretQueuedKeyEvent(const EditorState& state, bool& handled, Vector<WebCore::KeypressCommand>& commands)
 {
-    handled = m_pageClient->interpretKeyEvent(m_keyEventQueue.first(), state, commands);
+    m_editorState = state;
+    handled = m_pageClient->interpretKeyEvent(m_keyEventQueue.first(), commands);
 }
 
 // Complex text input support for plug-ins.
index 38ae43ed998e5d8e4f94e94a7288c17a4ab9e826..8cecb02fb3c728f08f5c790a389d0794b76f6596 100644 (file)
@@ -1148,7 +1148,7 @@ void WebView::setInputMethodState(bool enabled)
 
 void WebView::compositionSelectionChanged(bool hasChanged)
 {
-    if (m_page->selectionState().hasComposition && !hasChanged)
+    if (m_page->editorState().hasComposition && !hasChanged)
         resetIME();
 }
 
@@ -1256,7 +1256,7 @@ bool WebView::onIMEComposition(LPARAM lparam)
     if (!hInputContext)
         return true;
 
-    if (!m_page->selectionState().isContentEditable)
+    if (!m_page->editorState().isContentEditable)
         return true;
 
     prepareCandidateWindow(hInputContext);
@@ -1299,7 +1299,7 @@ bool WebView::onIMEEndComposition()
     LOG(TextInput, "onIMEEndComposition");
     // If the composition hasn't been confirmed yet, it needs to be cancelled.
     // This happens after deleting the last character from inline input hole.
-    if (m_page->selectionState().hasComposition)
+    if (m_page->editorState().hasComposition)
         m_page->confirmComposition(String());
 
     if (m_inIMEComposition)
@@ -1310,7 +1310,7 @@ bool WebView::onIMEEndComposition()
 
 LRESULT WebView::onIMERequestCharPosition(IMECHARPOSITION* charPos)
 {
-    if (charPos->dwCharPos && !m_page->selectionState().hasComposition)
+    if (charPos->dwCharPos && !m_page->editorState().hasComposition)
         return 0;
     IntRect caret = m_page->firstRectForCharacterInSelectedRange(charPos->dwCharPos);
     charPos->pt.x = caret.x();
@@ -1342,7 +1342,7 @@ LRESULT WebView::onIMERequestReconvertString(RECONVERTSTRING* reconvertString)
 LRESULT WebView::onIMERequest(WPARAM request, LPARAM data)
 {
     LOG(TextInput, "onIMERequest %s", imeRequestName(request).latin1().data());
-    if (!m_page->selectionState().isContentEditable)
+    if (!m_page->editorState().isContentEditable)
         return 0;
 
     switch (request) {
index dcde91448de50fb2ef94f8cb69ff4a9a4fd34ad7..d899e1d29df18998e12f006c7423ee2b5ef86730 100644 (file)
                1AA2E51E12E4C05E00BC4966 /* CGUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AA2E51C12E4C05E00BC4966 /* CGUtilities.cpp */; };
                1AA417CB12C00CCA002BE67B /* TextChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA417C912C00CCA002BE67B /* TextChecker.h */; };
                1AA417EF12C00D87002BE67B /* TextCheckerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AA417ED12C00D87002BE67B /* TextCheckerMac.mm */; };
-               1AA41AB512C02EC4002BE67B /* SelectionState.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA41AB412C02EC4002BE67B /* SelectionState.h */; };
+               1AA41AB512C02EC4002BE67B /* EditorState.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA41AB412C02EC4002BE67B /* EditorState.h */; };
                1AA4792312A59FD9008236C3 /* PluginProcessMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AA4792212A59FD9008236C3 /* PluginProcessMac.mm */; };
                1AA479B012A5A436008236C3 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1CD06100FA1BA0078DEBC /* Carbon.framework */; };
                1AA56F2911E92BC80061B882 /* PluginController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA56F2811E92BC80061B882 /* PluginController.h */; };
                E134F01A12EA5D99004EC58D /* WKPrintingView.mm in Sources */ = {isa = PBXBuildFile; fileRef = E134F01912EA5D99004EC58D /* WKPrintingView.mm */; };
                E179FD9C134D38060015B883 /* ArgumentCodersMac.h in Headers */ = {isa = PBXBuildFile; fileRef = E179FD9B134D38060015B883 /* ArgumentCodersMac.h */; };
                E179FD9F134D38250015B883 /* ArgumentCodersMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = E179FD9E134D38250015B883 /* ArgumentCodersMac.mm */; };
-               E1839349134297A5001842EC /* TextInputState.h in Headers */ = {isa = PBXBuildFile; fileRef = E1839348134297A5001842EC /* TextInputState.h */; };
                E18C92F412DB9E7100CF2AEB /* PrintInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E18C92F312DB9E7100CF2AEB /* PrintInfo.cpp */; };
                E1A31732134CEA6C007C9A4F /* AttributedString.h in Headers */ = {isa = PBXBuildFile; fileRef = E1A31731134CEA6C007C9A4F /* AttributedString.h */; };
                E1A31735134CEA80007C9A4F /* AttributedString.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1A31734134CEA80007C9A4F /* AttributedString.mm */; };
                1AA2E51C12E4C05E00BC4966 /* CGUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CGUtilities.cpp; sourceTree = "<group>"; };
                1AA417C912C00CCA002BE67B /* TextChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextChecker.h; sourceTree = "<group>"; };
                1AA417ED12C00D87002BE67B /* TextCheckerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TextCheckerMac.mm; sourceTree = "<group>"; };
-               1AA41AB412C02EC4002BE67B /* SelectionState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectionState.h; sourceTree = "<group>"; };
+               1AA41AB412C02EC4002BE67B /* EditorState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditorState.h; sourceTree = "<group>"; };
                1AA4792212A59FD9008236C3 /* PluginProcessMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PluginProcessMac.mm; sourceTree = "<group>"; };
                1AA56F2811E92BC80061B882 /* PluginController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginController.h; sourceTree = "<group>"; };
                1AA5889011EE70400061B882 /* NetscapePluginStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetscapePluginStream.h; sourceTree = "<group>"; };
                E134F01912EA5D99004EC58D /* WKPrintingView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKPrintingView.mm; sourceTree = "<group>"; };
                E179FD9B134D38060015B883 /* ArgumentCodersMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArgumentCodersMac.h; sourceTree = "<group>"; };
                E179FD9E134D38250015B883 /* ArgumentCodersMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ArgumentCodersMac.mm; sourceTree = "<group>"; };
-               E1839348134297A5001842EC /* TextInputState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextInputState.h; sourceTree = "<group>"; };
                E18C92F312DB9E7100CF2AEB /* PrintInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrintInfo.cpp; sourceTree = "<group>"; };
                E1A31731134CEA6C007C9A4F /* AttributedString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AttributedString.h; sourceTree = "<group>"; };
                E1A31734134CEA80007C9A4F /* AttributedString.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AttributedString.mm; sourceTree = "<group>"; };
                                1AAB4A8C1296F0A20023952F /* SandboxExtension.h */,
                                33152973130D0CB200ED2483 /* SecurityOriginData.cpp */,
                                33152974130D0CB200ED2483 /* SecurityOriginData.h */,
-                               1AA41AB412C02EC4002BE67B /* SelectionState.h */,
+                               1AA41AB412C02EC4002BE67B /* EditorState.h */,
                                518D2CC812D51DFB003BB93B /* SessionState.cpp */,
                                518D2CC912D51DFB003BB93B /* SessionState.h */,
                                1A6420E212DCE2FF00CAAE2C /* ShareableBitmap.cpp */,
                                1AAB4AA91296F1540023952F /* SandboxExtensionMac.mm */,
                                1A9636BA12F348490078A062 /* ShareableSurface.cpp */,
                                1A9636BB12F348490078A062 /* ShareableSurface.h */,
-                               E1839348134297A5001842EC /* TextInputState.h */,
                                BC9E95D211449B0300870E71 /* UpdateChunk.cpp */,
                                BC9E95D111449B0300870E71 /* UpdateChunk.h */,
                                BCE23262122C6CF300D5C35A /* WebCoreArgumentCodersMac.mm */,
                                BC858A2012C0357B00EDEB2E /* WebResourceLoadClient.h in Headers */,
                                1AA417CB12C00CCA002BE67B /* TextChecker.h in Headers */,
                                909854ED12BC4E18000AD080 /* WebMemorySampler.h in Headers */,
-                               1AA41AB512C02EC4002BE67B /* SelectionState.h in Headers */,
+                               1AA41AB512C02EC4002BE67B /* EditorState.h in Headers */,
                                BCCF672D12C7EDF7008F9C35 /* OriginAndDatabases.h in Headers */,
                                BCCF6ABD12C91EF9008F9C35 /* WebImage.h in Headers */,
                                BCCF6AC312C91F34008F9C35 /* WKImage.h in Headers */,
                                5110AE0D133C16CB0072717A /* WKIconDatabase.h in Headers */,
                                5123CF1C133D260A0056F800 /* WKIconDatabaseCG.h in Headers */,
                                51834593134532E90092B696 /* WebIconDatabaseClient.h in Headers */,
-                               E1839349134297A5001842EC /* TextInputState.h in Headers */,
                                C0FA52431345694A0028E8C2 /* LayerTreeHostCAMac.h in Headers */,
                                E1A31732134CEA6C007C9A4F /* AttributedString.h in Headers */,
                                E179FD9C134D38060015B883 /* ArgumentCodersMac.h in Headers */,
index 58839622df2860bafb64f4c6fbe5e0e208a4afd8..197a0ab378c3bd2bccddab241397abf504f495c5 100644 (file)
@@ -26,7 +26,7 @@
 #include "config.h"
 #include "WebEditorClient.h"
 
-#include "SelectionState.h"
+#include "EditorState.h"
 #include "WebCoreArgumentCoders.h"
 #include "WebFrameLoaderClient.h"
 #include "WebPage.h"
@@ -44,7 +44,6 @@
 #include <WebCore/KeyboardEvent.h>
 #include <WebCore/NotImplemented.h>
 #include <WebCore/Page.h>
-#include <WebCore/TextIterator.h>
 #include <WebCore/UserTypingGestureIndicator.h>
 
 using namespace WebCore;
@@ -191,24 +190,7 @@ void WebEditorClient::respondToChangedSelection()
     if (!frame)
         return;
 
-    SelectionState selectionState;
-    selectionState.isNone = frame->selection()->isNone();
-    selectionState.isContentEditable = frame->selection()->isContentEditable();
-    selectionState.isContentRichlyEditable = frame->selection()->isContentRichlyEditable();
-    selectionState.isInPasswordField = frame->selection()->isInPasswordField();
-    selectionState.hasComposition = frame->editor()->hasComposition();
-
-    RefPtr<Range> range = frame->selection()->toNormalizedRange();
-    if (range) {
-        size_t location;
-        size_t length;
-        if (!TextIterator::locationAndLengthFromRange(range.get(), location, length))
-            return;
-        selectionState.selectedRangeStart = static_cast<uint64_t>(location);
-        selectionState.selectedRangeLength = static_cast<uint64_t>(length);
-    }
-
-    m_page->send(Messages::WebPageProxy::SelectionStateChanged(selectionState));
+    m_page->send(Messages::WebPageProxy::EditorStateChanged(m_page->editorState()));
 
 #if PLATFORM(WIN)
     // FIXME: This should also go into the selection state.
index b0eea78e83bf7fd8e949bc2a9afc96a79280acae..7707965929e958d24ac02922d111cc2ed15a7544 100644 (file)
@@ -321,6 +321,22 @@ PassRefPtr<Plugin> WebPage::createPlugin(const Plugin::Parameters& parameters)
 #endif
 }
 
+EditorState WebPage::editorState() const
+{
+    Frame* frame = m_page->focusController()->focusedOrMainFrame();
+    ASSERT(frame);
+
+    EditorState result;
+    result.selectionIsNone = frame->selection()->isNone();
+    result.selectionIsRange = frame->selection()->isRange();
+    result.isContentEditable = frame->selection()->isContentEditable();
+    result.isContentRichlyEditable = frame->selection()->isContentRichlyEditable();
+    result.isInPasswordField = frame->selection()->isInPasswordField();
+    result.hasComposition = frame->editor()->hasComposition();
+    
+    return result;
+}
+
 String WebPage::renderTreeExternalRepresentation() const
 {
     return externalRepresentation(m_mainFrame->coreFrame(), RenderAsTextBehaviorNormal);
index cd09857e58069983b094caf3f0dcffc39bd29d14..7828b45f79db9c2fceb4dba2dfdc48d40a855777 100644 (file)
@@ -106,8 +106,8 @@ class WebPageGroupProxy;
 class WebPopupMenu;
 class WebWheelEvent;
 struct AttributedString;
+struct EditorState;
 struct PrintInfo;
-struct TextInputState;
 struct WebPageCreationParameters;
 struct WebPreferencesStore;
 
@@ -216,6 +216,8 @@ public:
     WebFrame* mainFrame() const { return m_mainFrame.get(); }
     PassRefPtr<Plugin> createPlugin(const Plugin::Parameters&);
 
+    EditorState editorState() const;
+
     String renderTreeExternalRepresentation() const;
     void executeEditingCommand(const String& commandName, const String& argument);
     bool isEditingCommandEnabled(const String& commandName);
@@ -319,15 +321,15 @@ public:
     
     void sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String& textInput);
 
-    void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, TextInputState& newState);
-    void confirmComposition(TextInputState& newState);
-    void insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, bool& handled, TextInputState& newState);
+    void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, EditorState& newState);
+    void confirmComposition(EditorState& newState);
+    void insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, bool& handled, EditorState& newState);
     void getMarkedRange(uint64_t& location, uint64_t& length);
     void getSelectedRange(uint64_t& location, uint64_t& length);
     void getAttributedSubstringFromRange(uint64_t location, uint64_t length, AttributedString&);
     void characterIndexForPoint(const WebCore::IntPoint point, uint64_t& result);
     void firstRectForCharacterRange(uint64_t location, uint64_t length, WebCore::IntRect& resultRect);
-    void executeKeypressCommands(const Vector<WebCore::KeypressCommand>&, bool& handled, TextInputState& newState);
+    void executeKeypressCommands(const Vector<WebCore::KeypressCommand>&, bool& handled, EditorState& newState);
     void writeSelectionToPasteboard(const WTF::String& pasteboardName, const WTF::Vector<WTF::String>& pasteboardTypes, bool& result);
     void readSelectionFromPasteboard(const WTF::String& pasteboardName, bool& result);
     void shouldDelayWindowOrderingEvent(const WebKit::WebMouseEvent&, bool& result);
index 7112956019f634091cf2d357e7b91cc17bddadb4..673e8d6f791a275c783a001109258e6baec28b0c 100644 (file)
@@ -185,15 +185,15 @@ messages -> WebPage {
     ReadSelectionFromPasteboard(WTF::String pasteboardName) -> (bool result)
 
     # Text input.
-    SetComposition(WTF::String text, WTF::Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd) -> (WebKit::TextInputState newState)
-    ConfirmComposition() -> (WebKit::TextInputState newState)
-    InsertText(WTF::String text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd) -> (bool handled, WebKit::TextInputState newState)
+    SetComposition(WTF::String text, WTF::Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd) -> (WebKit::EditorState newState)
+    ConfirmComposition() -> (WebKit::EditorState newState)
+    InsertText(WTF::String text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd) -> (bool handled, WebKit::EditorState newState)
     GetMarkedRange() -> (uint64_t location, uint64_t length)
     GetSelectedRange() -> (uint64_t location, uint64_t length)
     GetAttributedSubstringFromRange(uint64_t location, uint64_t length) -> (WebKit::AttributedString result)
     CharacterIndexForPoint(WebCore::IntPoint point) -> (uint64_t result)
     FirstRectForCharacterRange(uint64_t location, uint64_t length) -> (WebCore::IntRect resultRect)
-    ExecuteKeypressCommands(Vector<WebCore::KeypressCommand> savedCommands) -> (bool handled, WebKit::TextInputState newState)
+    ExecuteKeypressCommands(Vector<WebCore::KeypressCommand> savedCommands) -> (bool handled, WebKit::EditorState newState)
     ShouldDelayWindowOrderingEvent(WebKit::WebMouseEvent event) -> (bool result)
     AcceptsFirstMouse(int eventNumber, WebKit::WebMouseEvent event) -> (bool result)
 #endif
index 7ed187cb59a97c357ff422d53144c4f7a45caae2..d7b352cd5afba43dee397bb4a784cdcc8df16182 100644 (file)
@@ -29,8 +29,8 @@
 #import "AccessibilityWebPageObject.h"
 #import "AttributedString.h"
 #import "DataReference.h"
+#import "EditorState.h"
 #import "PluginView.h"
-#import "TextInputState.h"
 #import "WebCoreArgumentCoders.h"
 #import "WebEvent.h"
 #import "WebEventConversion.h"
@@ -118,14 +118,6 @@ static String commandNameForSelectorName(const String& selectorName)
     return selectorName.left(selectorNameLength - 1);
 }
 
-static TextInputState currentTextInputState(Frame* frame)
-{
-    TextInputState state;
-    state.hasMarkedText = frame->editor()->hasComposition();
-    state.selectionIsEditable = !frame->selection()->isNone() && frame->selection()->isContentEditable();
-    return state;
-}
-
 static Frame* frameForEvent(KeyboardEvent* event)
 {
     Node* node = event->target()->toNode();
@@ -190,7 +182,7 @@ bool WebPage::handleEditingKeyboardEvent(KeyboardEvent* event, bool saveCommands
     if (saveCommands) {
         KeyboardEvent* oldEvent = m_keyboardEventBeingInterpreted;
         m_keyboardEventBeingInterpreted = event;
-        bool sendResult = WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::InterpretQueuedKeyEvent(currentTextInputState(frame)), 
+        bool sendResult = WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::InterpretQueuedKeyEvent(editorState()), 
             Messages::WebPageProxy::InterpretQueuedKeyEvent::Reply(eventWasHandled, commands), m_pageID);
         m_keyboardEventBeingInterpreted = oldEvent;
         if (!sendResult)
@@ -229,7 +221,7 @@ void WebPage::sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdenti
     }
 }
 
-void WebPage::setComposition(const String& text, Vector<CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, TextInputState& newState)
+void WebPage::setComposition(const String& text, Vector<CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, EditorState& newState)
 {
     Frame* frame = m_page->focusController()->focusedOrMainFrame();
 
@@ -243,19 +235,19 @@ void WebPage::setComposition(const String& text, Vector<CompositionUnderline> un
         frame->editor()->setComposition(text, underlines, selectionStart, selectionEnd);
     }
 
-    newState = currentTextInputState(frame);
+    newState = editorState();
 }
 
-void WebPage::confirmComposition(TextInputState& newState)
+void WebPage::confirmComposition(EditorState& newState)
 {
     Frame* frame = m_page->focusController()->focusedOrMainFrame();
 
     frame->editor()->confirmComposition();
 
-    newState = currentTextInputState(frame);
+    newState = editorState();
 }
 
-void WebPage::insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, bool& handled, TextInputState& newState)
+void WebPage::insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, bool& handled, EditorState& newState)
 {
     Frame* frame = m_page->focusController()->focusedOrMainFrame();
 
@@ -274,7 +266,7 @@ void WebPage::insertText(const String& text, uint64_t replacementRangeStart, uin
         frame->editor()->confirmComposition(text);
     }
 
-    newState = currentTextInputState(frame);
+    newState = editorState();
 }
 
 void WebPage::getMarkedRange(uint64_t& location, uint64_t& length)
@@ -394,13 +386,10 @@ void WebPage::firstRectForCharacterRange(uint64_t location, uint64_t length, Web
     resultRect = frame->view()->contentsToWindow(rect);
 }
 
-void WebPage::executeKeypressCommands(const Vector<WebCore::KeypressCommand>& commands, bool& handled, TextInputState& newState)
+void WebPage::executeKeypressCommands(const Vector<WebCore::KeypressCommand>& commands, bool& handled, EditorState& newState)
 {
-    Frame* frame = m_page->focusController()->focusedOrMainFrame();
-
     handled = executeKeypressCommandsInternal(commands, m_keyboardEventBeingInterpreted);
-
-    newState = currentTextInputState(frame);
+    newState = editorState();
 }
 
 static bool isPositionInRange(const VisiblePosition& position, Range* range)
index fb3708dd468fbca4d16e1c52178db28893bb22f4..cf8ee608af43aab21dc98eaf727842fcdf9c3667 100755 (executable)
                                RelativePath="..\Shared\DrawingAreaInfo.h"
                                >
                        </File>
+                       <File
+                               RelativePath="..\Shared\EditorState.h"
+                               >
+                       </File>
                        <File
                                RelativePath="..\Shared\FontInfo.cpp"
                                >
                                RelativePath="..\Shared\SecurityOriginData.h"
                                >
                        </File>
-                       <File
-                               RelativePath="..\Shared\SelectionState.h"
-                               >
-                       </File>
                        <File
                                RelativePath="..\Shared\SessionState.cpp"
                                >