Title: [102334] trunk/Source/WebKit2
Revision
102334
Author
kenn...@webkit.org
Date
2011-12-08 06:27:14 -0800 (Thu, 08 Dec 2011)

Log Message

Upsteam the Qt changes to the EditorState https://bugs.webkit.org/show_bug.cgi?id=74080

Reviewed by Simon Hausmann.

We are not doing the serialization manually due to it not being a POD
structure anymore in the case of Qt.

* GNUmakefile.am:
* Shared/EditorState.h:
(WebKit::EditorState::EditorState):
* Target.pri:
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::respondToChangedSelection):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::editorState):
* win/WebKit2.vcproj:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (102333 => 102334)


--- trunk/Source/WebKit2/ChangeLog	2011-12-08 14:23:10 UTC (rev 102333)
+++ trunk/Source/WebKit2/ChangeLog	2011-12-08 14:27:14 UTC (rev 102334)
@@ -1,3 +1,24 @@
+2011-12-08  Kenneth Rohde Christiansen  <kenn...@webkit.org>
+
+        Upsteam the Qt changes to the EditorState
+        https://bugs.webkit.org/show_bug.cgi?id=74080
+
+        Reviewed by Simon Hausmann.
+
+        We are not doing the serialization manually due to it not being a POD
+        structure anymore in the case of Qt.
+
+        * GNUmakefile.am:
+        * Shared/EditorState.h:
+        (WebKit::EditorState::EditorState):
+        * Target.pri:
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/WebCoreSupport/WebEditorClient.cpp:
+        (WebKit::WebEditorClient::respondToChangedSelection):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::editorState):
+        * win/WebKit2.vcproj:
+
 2011-12-08  Gopal Raghavan  <gopal.1.ragha...@nokia.com>
 
         [Qt] cleanup qmlplugin

Modified: trunk/Source/WebKit2/GNUmakefile.am (102333 => 102334)


--- trunk/Source/WebKit2/GNUmakefile.am	2011-12-08 14:23:10 UTC (rev 102333)
+++ trunk/Source/WebKit2/GNUmakefile.am	2011-12-08 14:27:14 UTC (rev 102334)
@@ -307,6 +307,7 @@
 	Source/WebKit2/Shared/CoreIPCSupport/WebContextMessageKinds.h \
 	Source/WebKit2/Shared/CoreIPCSupport/WebPageProxyMessageKinds.h \
 	Source/WebKit2/Shared/DrawingAreaInfo.h \
+	Source/WebKit2/Shared/EditorState.cpp \
 	Source/WebKit2/Shared/EditorState.h \
 	Source/WebKit2/Shared/FontSmoothingLevel.h \
 	Source/WebKit2/Shared/cairo/LayerTreeContextCairo.cpp \

Added: trunk/Source/WebKit2/Shared/EditorState.cpp (0 => 102334)


--- trunk/Source/WebKit2/Shared/EditorState.cpp	                        (rev 0)
+++ trunk/Source/WebKit2/Shared/EditorState.cpp	2011-12-08 14:27:14 UTC (rev 102334)
@@ -0,0 +1,108 @@
+/*
+ * 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
+ * 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.
+ */
+
+#include "config.h"
+#include "EditorState.h"
+
+#include "Arguments.h"
+#include "WebCoreArgumentCoders.h"
+
+namespace WebKit {
+
+void EditorState::encode(CoreIPC::ArgumentEncoder* encoder) const
+{
+    encoder->encode(shouldIgnoreCompositionSelectionChange);
+    encoder->encode(selectionIsNone);
+    encoder->encode(selectionIsRange);
+    encoder->encode(isContentEditable);
+    encoder->encode(isContentRichlyEditable);
+    encoder->encode(isInPasswordField);
+    encoder->encode(hasComposition);
+
+#if PLATFORM(QT)
+    encoder->encode(cursorPosition);
+    encoder->encode(anchorPosition);
+    encoder->encode(microFocus);
+    encoder->encode(compositionRect);
+    encoder->encode(compositionStart);
+    encoder->encode(compositionLength);
+    encoder->encode(selectedText);
+    encoder->encode(surroundingText);
+#endif
+}
+
+bool EditorState::decode(CoreIPC::ArgumentDecoder* decoder, EditorState& result)
+{
+    if (!decoder->decode(result.shouldIgnoreCompositionSelectionChange))
+        return false;
+
+    if (!decoder->decode(result.selectionIsNone))
+        return false;
+
+    if (!decoder->decode(result.selectionIsRange))
+        return false;
+
+    if (!decoder->decode(result.isContentEditable))
+        return false;
+
+    if (!decoder->decode(result.isContentRichlyEditable))
+        return false;
+
+    if (!decoder->decode(result.isInPasswordField))
+        return false;
+
+    if (!decoder->decode(result.hasComposition))
+        return false;
+
+#if PLATFORM(QT)
+    if (!decoder->decode(result.cursorPosition))
+        return false;
+
+    if (!decoder->decode(result.anchorPosition))
+        return false;
+
+    if (!decoder->decode(result.microFocus))
+        return false;
+
+    if (!decoder->decode(result.compositionRect))
+        return false;
+
+    if (!decoder->decode(result.compositionStart))
+        return false;
+
+    if (!decoder->decode(result.compositionLength))
+        return false;
+
+    if (!decoder->decode(result.selectedText))
+        return false;
+
+    if (!decoder->decode(result.surroundingText))
+        return false;
+#endif
+
+    return true;
+}
+
+}

Modified: trunk/Source/WebKit2/Shared/EditorState.h (102333 => 102334)


--- trunk/Source/WebKit2/Shared/EditorState.h	2011-12-08 14:23:10 UTC (rev 102333)
+++ trunk/Source/WebKit2/Shared/EditorState.h	2011-12-08 14:27:14 UTC (rev 102334)
@@ -27,35 +27,53 @@
 #define EditorState_h
 
 #include "ArgumentCoders.h"
+#include <WebCore/IntRect.h>
 #include <wtf/NotFound.h>
+#include <wtf/text/WTFString.h>
 
 namespace WebKit {
 
 struct EditorState {
     EditorState()
-        : selectionIsNone(true)
+        : shouldIgnoreCompositionSelectionChange(false)
+        , selectionIsNone(true)
         , selectionIsRange(false)
         , isContentEditable(false)
         , isContentRichlyEditable(false)
         , isInPasswordField(false)
         , hasComposition(false)
-        , shouldIgnoreCompositionSelectionChange(false)
+#if PLATFORM(QT)
+        , cursorPosition(0)
+        , anchorPosition(0)
+        , compositionStart(0)
+        , compositionLength(0)
+#endif
     {
     }
 
+    bool shouldIgnoreCompositionSelectionChange;
+
     bool selectionIsNone; // This will be false when there is a caret selection.
     bool selectionIsRange;
     bool isContentEditable;
     bool isContentRichlyEditable;
     bool isInPasswordField;
     bool hasComposition;
-    bool shouldIgnoreCompositionSelectionChange;
+#if PLATFORM(QT)
+    int cursorPosition;
+    int anchorPosition;
+    WebCore::IntRect microFocus;
+    WebCore::IntRect compositionRect;
+    int compositionStart;
+    int compositionLength;
+    WTF::String selectedText;
+    WTF::String surroundingText;
+#endif
+
+    void encode(CoreIPC::ArgumentEncoder*) const;
+    static bool decode(CoreIPC::ArgumentDecoder*, EditorState&);
 };
 
 }
 
-namespace CoreIPC {
-template<> struct ArgumentCoder<WebKit::EditorState> : SimpleArgumentCoder<WebKit::EditorState> { };
-};
-
 #endif // EditorState_h

Modified: trunk/Source/WebKit2/Target.pri (102333 => 102334)


--- trunk/Source/WebKit2/Target.pri	2011-12-08 14:23:10 UTC (rev 102333)
+++ trunk/Source/WebKit2/Target.pri	2011-12-08 14:27:14 UTC (rev 102334)
@@ -71,6 +71,7 @@
     Shared/CacheModel.h \
     Shared/ChildProcess.h \
     Shared/DictionaryPopupInfo.h \
+    Shared/EditorState.h \
     Shared/FontInfo.h \
     Shared/ImageOptions.h \
     Shared/ImmutableArray.h \
@@ -405,6 +406,7 @@
     Shared/Plugins/PluginProcessCreationParameters.cpp \
     Shared/ChildProcess.cpp \
     Shared/DictionaryPopupInfo.cpp \
+    Shared/EditorState.cpp \
     Shared/FontInfo.cpp \
     Shared/ImmutableArray.cpp \
     Shared/ImmutableDictionary.cpp \

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (102333 => 102334)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2011-12-08 14:23:10 UTC (rev 102333)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2011-12-08 14:27:14 UTC (rev 102334)
@@ -423,6 +423,7 @@
 		762B748D120BC75C00819339 /* WKPreferencesPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 762B7484120BBA2D00819339 /* WKPreferencesPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		7801C099142290C400FAF9AF /* WebHitTestResult.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7801C095142290C400FAF9AF /* WebHitTestResult.cpp */; };
 		7801C09A142290C400FAF9AF /* WebHitTestResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 7801C096142290C400FAF9AF /* WebHitTestResult.h */; };
+		8CFECE941490F140002AAA32 /* EditorState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8CFECE931490F140002AAA32 /* EditorState.cpp */; };
 		8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C1666FE841158C02AAC07 /* InfoPlist.strings */; };
 		8DC2EF570486A6940098B216 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */; };
 		909854EC12BC4E17000AD080 /* WebMemorySampler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 905620E812BC248B000799B6 /* WebMemorySampler.cpp */; };
@@ -1420,6 +1421,7 @@
 		762B7484120BBA2D00819339 /* WKPreferencesPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPreferencesPrivate.h; sourceTree = "<group>"; };
 		7801C095142290C400FAF9AF /* WebHitTestResult.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebHitTestResult.cpp; sourceTree = "<group>"; };
 		7801C096142290C400FAF9AF /* WebHitTestResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebHitTestResult.h; sourceTree = "<group>"; };
+		8CFECE931490F140002AAA32 /* EditorState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EditorState.cpp; sourceTree = "<group>"; };
 		8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
 		8DC2EF5B0486A6940098B216 /* WebKit2.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = WebKit2.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		905620E512BC2476000799B6 /* WebMemorySampler.mac.mm */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebMemorySampler.mac.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
@@ -2270,6 +2272,7 @@
 				BCE81D97131AE02100241910 /* DictionaryPopupInfo.h */,
 				C517388012DF8F4F00EE3F47 /* DragControllerAction.h */,
 				0FB659221208B4DB0044816C /* DrawingAreaInfo.h */,
+				8CFECE931490F140002AAA32 /* EditorState.cpp */,
 				762B7481120BBA0100819339 /* FontSmoothingLevel.h */,
 				F638954F133BEF38008941D5 /* HTTPCookieAcceptPolicy.h */,
 				BCCF6B2312C93E7A008F9C35 /* ImageOptions.h */,
@@ -4776,6 +4779,7 @@
 				31C11AB3148452E90049A4CC /* WebNotification.cpp in Sources */,
 				31BA924D148831260062EDB5 /* WebNotificationManagerMessageReceiver.cpp in Sources */,
 				BCD3675C148C26C000447E87 /* WebConnectionToUIProcess.cpp in Sources */,
+				8CFECE941490F140002AAA32 /* EditorState.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp (102333 => 102334)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp	2011-12-08 14:23:10 UTC (rev 102333)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp	2011-12-08 14:27:14 UTC (rev 102334)
@@ -183,28 +183,14 @@
     if (!frame)
         return;
 
-#if PLATFORM(QT)
-    bool selectionIsNone = frame->selection()->isNone();
-    Element* scope = frame->selection()->rootEditableElement();
+    EditorState state = m_page->editorState();
 
-    RefPtr<Range> range;
-    if (scope && !selectionIsNone && (range = frame->selection()->selection().firstRange())) {
-        size_t location = 0;
-        size_t length = 0;
-
-        TextIterator::getLocationAndLengthFromRange(scope, range.get(), location, length);
-
-        ExceptionCode ec = 0;
-        RefPtr<Range> tempRange = range->cloneRange(ec);
-        tempRange->setStart(tempRange->startContainer(ec), tempRange->startOffset(ec) + location, ec);
-        IntRect caretRect = frame->view()->contentsToWindow(frame->editor()->firstRectForRange(tempRange.get()));
-        IntRect nodeRect = frame->view()->contentsToWindow(scope->getRect());
-
-        m_page->send(Messages::WebPageProxy::FocusEditableArea(caretRect, nodeRect));
-    }
+#if PLATFORM(QT)
+    if (Element* scope = frame->selection()->rootEditableElement())
+        m_page->send(Messages::WebPageProxy::FocusEditableArea(state.microFocus, scope->getRect()));
 #endif
 
-    m_page->send(Messages::WebPageProxy::EditorStateChanged(m_page->editorState()));
+    m_page->send(Messages::WebPageProxy::EditorStateChanged(state));
 
 #if PLATFORM(WIN)
     // FIXME: This should also go into the selection state.

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (102333 => 102334)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2011-12-08 14:23:10 UTC (rev 102333)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2011-12-08 14:27:14 UTC (rev 102334)
@@ -380,8 +380,43 @@
     result.isContentRichlyEditable = frame->selection()->isContentRichlyEditable();
     result.isInPasswordField = frame->selection()->isInPasswordField();
     result.hasComposition = frame->editor()->hasComposition();
+
+#if PLATFORM(QT)
+    size_t location = 0;
+    size_t length = 0;
+    Element* scope = frame->selection()->rootEditableElement();
+
+    RefPtr<Range> range;
+    if (result.hasComposition && (range = frame->editor()->compositionRange())) {
+        TextIterator::getLocationAndLengthFromRange(scope, range.get(), location, length);
+        result.compositionStart = location;
+        result.compositionLength = length;
+        result.compositionRect = range->boundingBox();
+    }
+
+    if (!result.selectionIsNone && (range = frame->selection()->selection().firstRange())) {
+        TextIterator::getLocationAndLengthFromRange(scope, range.get(), location, length);
+
+        ExceptionCode ec = 0;
+        RefPtr<Range> tempRange = range->cloneRange(ec);
+        tempRange->setStart(tempRange->startContainer(ec), tempRange->startOffset(ec) + location, ec);
+        IntRect rect = frame->editor()->firstRectForRange(tempRange.get());
+        bool baseIsFirst = frame->selection()->selection().isBaseFirst();
+
+        result.cursorPosition = (baseIsFirst) ? location + length : location;
+        result.anchorPosition = (baseIsFirst) ? location : location + length;
+        result.microFocus = frame->view()->contentsToWindow(rect);
+        result.selectedText = range->text();
+    }
+
+    if (result.isContentEditable && !result.isInPasswordField) {
+        result.surroundingText = scope->innerText();
+        result.surroundingText.remove(result.compositionStart, result.compositionLength);
+    }
+#endif
+
     result.shouldIgnoreCompositionSelectionChange = frame->editor()->ignoreCompositionSelectionChange();
-    
+
     return result;
 }
 

Modified: trunk/Source/WebKit2/win/WebKit2.vcproj (102333 => 102334)


--- trunk/Source/WebKit2/win/WebKit2.vcproj	2011-12-08 14:23:10 UTC (rev 102333)
+++ trunk/Source/WebKit2/win/WebKit2.vcproj	2011-12-08 14:27:14 UTC (rev 102334)
@@ -439,6 +439,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\Shared\EditorState.cpp"
+				>
+			</File>
+			<File
 				RelativePath="..\Shared\EditorState.h"
 				>
 			</File>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to