[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

enrica at apple.com enrica at apple.com
Wed Dec 22 15:29:05 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 7868c5d747c4cc6b9cf24c96651c8d008fa7c24e
Author: enrica at apple.com <enrica at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Nov 4 18:29:32 2010 +0000

    Need a way to test in WebKit2 whether a form field contains marked text
    <rdar://problem/8555293>
    https://bugs.webkit.org/show_bug.cgi?id=48969
    
    Reviewed by Alexey Proskuryakov.
    
    Added a selection changed notification from the Web process to the UI process.
    The message being sent contains information about the current selection.
    Event though for this specific bug the only information required is the marked text,
    I've added other selection information that will be needed to support IME.
    All the stubbed methods are required methods by the NSTextInput protocol.
    
    * UIProcess/API/mac/PageClientImpl.h:
    * UIProcess/API/mac/PageClientImpl.mm:
    (WebKit::PageClientImpl::selectionChanged): Added.
    * UIProcess/API/mac/WKView.h:
    * UIProcess/API/mac/WKView.mm:
    (-[WKView initWithFrame:pageNamespaceRef:]): Added initialization of new members.
    (-[WKView _selectionChanged:isEditable:isPassword:hasMarkedText:]): Stores the values from
    the selection changed message.
    (-[WKView selectedRange]): Added stub.
    (-[WKView hasMarkedText]): Implemented.
    (-[WKView unmarkText]): Added stub.
    (-[WKView validAttributesForMarkedText]): Added stub.
    (-[WKView setMarkedText:selectedRange:]): Added stub.
    (-[WKView markedRange]): Added stub.
    (-[WKView attributedSubstringFromRange:]): Added stub.
    (-[WKView conversationIdentifier]): Added stub.
    (-[WKView characterIndexForPoint:]): Added stub.
    (-[WKView firstRectForCharacterRange:]): Added stub.
    * UIProcess/API/mac/WKViewInternal.h:
    * UIProcess/API/qt/qwkpage.cpp:
    (QWKPagePrivate::selectionChanged): Added.
    * UIProcess/API/qt/qwkpage_p.h:
    * UIProcess/PageClient.h:
    * UIProcess/WebPageProxy.cpp:
    (WebKit::WebPageProxy::didSelectionChange): New message handler.
    * UIProcess/WebPageProxy.h:
    * UIProcess/WebPageProxy.messages.in:
    * UIProcess/win/WebView.cpp:
    (WebKit::WebView::selectionChanged): Added.
    * UIProcess/win/WebView.h:
    * WebProcess/WebCoreSupport/WebEditorClient.cpp:
    (WebKit::WebEditorClient::respondToChangedSelection): Added implementation.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71347 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 30a94d4..3db9b48 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,50 @@
+2010-11-03  Enrica Casucci  <enrica at apple.com>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Need a way to test in WebKit2 whether a form field contains marked text
+        <rdar://problem/8555293>
+        https://bugs.webkit.org/show_bug.cgi?id=48969
+        
+        Added a selection changed notification from the Web process to the UI process.
+        The message being sent contains information about the current selection.
+        Event though for this specific bug the only information required is the marked text,
+        I've added other selection information that will be needed to support IME.
+        All the stubbed methods are required methods by the NSTextInput protocol.
+        
+        * UIProcess/API/mac/PageClientImpl.h:
+        * UIProcess/API/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::selectionChanged): Added.
+        * UIProcess/API/mac/WKView.h:
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView initWithFrame:pageNamespaceRef:]): Added initialization of new members.
+        (-[WKView _selectionChanged:isEditable:isPassword:hasMarkedText:]): Stores the values from
+        the selection changed message.
+        (-[WKView selectedRange]): Added stub.
+        (-[WKView hasMarkedText]): Implemented.
+        (-[WKView unmarkText]): Added stub.
+        (-[WKView validAttributesForMarkedText]): Added stub.
+        (-[WKView setMarkedText:selectedRange:]): Added stub.
+        (-[WKView markedRange]): Added stub.
+        (-[WKView attributedSubstringFromRange:]): Added stub.
+        (-[WKView conversationIdentifier]): Added stub.
+        (-[WKView characterIndexForPoint:]): Added stub.
+        (-[WKView firstRectForCharacterRange:]): Added stub.
+        * UIProcess/API/mac/WKViewInternal.h:
+        * UIProcess/API/qt/qwkpage.cpp:
+        (QWKPagePrivate::selectionChanged): Added.
+        * UIProcess/API/qt/qwkpage_p.h:
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::didSelectionChange): New message handler.
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/win/WebView.cpp:
+        (WebKit::WebView::selectionChanged): Added.
+        * UIProcess/win/WebView.h:
+        * WebProcess/WebCoreSupport/WebEditorClient.cpp:
+        (WebKit::WebEditorClient::respondToChangedSelection): Added implementation.
+
 2010-11-04  Balazs Kelemen  <kbalazs at webkit.org>
 
         Reviewed by Andreas Kling.
diff --git a/WebKit2/UIProcess/API/mac/PageClientImpl.h b/WebKit2/UIProcess/API/mac/PageClientImpl.h
index 236a274..72ef0d1 100644
--- a/WebKit2/UIProcess/API/mac/PageClientImpl.h
+++ b/WebKit2/UIProcess/API/mac/PageClientImpl.h
@@ -64,6 +64,7 @@ private:
     virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&);
 
     virtual void didNotHandleKeyEvent(const NativeWebKeyboardEvent&);
+    virtual void selectionChanged(bool, bool, bool, bool);
 
     virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy();
     virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*);
diff --git a/WebKit2/UIProcess/API/mac/PageClientImpl.mm b/WebKit2/UIProcess/API/mac/PageClientImpl.mm
index 3532cd2..192defb 100644
--- a/WebKit2/UIProcess/API/mac/PageClientImpl.mm
+++ b/WebKit2/UIProcess/API/mac/PageClientImpl.mm
@@ -147,6 +147,11 @@ void PageClientImpl::setViewportArguments(const WebCore::ViewportArguments&)
 
 }
 
+void PageClientImpl::selectionChanged(bool isNone, bool isContentEditable, bool isPasswordField, bool hasComposition)
+{
+    [m_wkView _selectionChanged:isNone isEditable:isContentEditable isPassword:isPasswordField hasMarkedText:hasComposition];
+}
+
 static NSString* nameForEditAction(EditAction editAction)
 {
     // FIXME: Use localized strings.
diff --git a/WebKit2/UIProcess/API/mac/WKView.h b/WebKit2/UIProcess/API/mac/WKView.h
index 8ace4cd..0476fbd 100644
--- a/WebKit2/UIProcess/API/mac/WKView.h
+++ b/WebKit2/UIProcess/API/mac/WKView.h
@@ -29,7 +29,7 @@
 @class WKViewData;
 
 WK_EXPORT
- at interface WKView : NSView {
+ at interface WKView : NSView <NSTextInput> {
     WKViewData *_data;
 }
 
diff --git a/WebKit2/UIProcess/API/mac/WKView.mm b/WebKit2/UIProcess/API/mac/WKView.mm
index e558db5..59ad3e9 100644
--- a/WebKit2/UIProcess/API/mac/WKView.mm
+++ b/WebKit2/UIProcess/API/mac/WKView.mm
@@ -52,6 +52,15 @@
 #import <wtf/RefPtr.h>
 #import <wtf/RetainPtr.h>
 
+extern "C" {
+    
+    // Need to declare this attribute name because AppKit exports it but does not make it available in API or SPI headers.
+    // <rdar://problem/8631468> tracks the request to make it available. This code should be removed when the bug is closed.
+    
+    extern NSString *NSTextInputReplacementRangeAttributeName;
+    
+}
+
 using namespace WebKit;
 using namespace WebCore;
 
@@ -93,6 +102,10 @@ struct EditCommandState {
     // that has been already sent to WebCore.
     NSEvent *_keyDownEventBeingResent;
     Vector<KeypressCommand> _commandsList;
+    BOOL _isSelectionNone;
+    BOOL _isSelectionEditable;
+    BOOL _isSelectionInPasswordField;
+    BOOL _hasMarkedText;
 }
 @end
 
@@ -128,7 +141,11 @@ struct EditCommandState {
     
     _data->_menuEntriesCount = 0;
     _data->_isPerformingUpdate = false;
-
+    _data->_isSelectionNone = YES;
+    _data->_isSelectionEditable = NO;
+    _data->_isSelectionInPasswordField = NO;
+    _data->_hasMarkedText = NO;
+    
     return self;
 }
 
@@ -372,6 +389,14 @@ EVENT_HANDLER(scrollWheel, Wheel)
     _data->_keyDownEventBeingResent = [event retain];
 }
 
+- (void)_selectionChanged:(BOOL)isNone isEditable:(BOOL)isContentEditable isPassword:(BOOL)isPasswordField hasMarkedText:(BOOL)hasComposition
+{
+    _data->_isSelectionNone = isNone;
+    _data->_isSelectionEditable = isContentEditable;
+    _data->_isSelectionInPasswordField = isPasswordField;
+    _data->_hasMarkedText = hasComposition;
+}
+
 - (Vector<KeypressCommand>&)_interceptKeyEvent:(NSEvent *)theEvent
 {
     _data->_commandsList.clear();
@@ -402,6 +427,72 @@ EVENT_HANDLER(scrollWheel, Wheel)
     _data->_page->handleKeyboardEvent(NativeWebKeyboardEvent(theEvent, self));
 }
 
+- (NSRange)selectedRange
+{
+    return NSMakeRange(NSNotFound, 0);
+}
+
+- (BOOL)hasMarkedText
+{
+    return _data->_hasMarkedText;
+}
+
+- (void)unmarkText
+{
+    // Not implemented
+}
+
+- (NSArray *)validAttributesForMarkedText
+{
+    static NSArray *validAttributes;
+    if (!validAttributes) {
+        validAttributes = [[NSArray alloc] initWithObjects:
+                           NSUnderlineStyleAttributeName, NSUnderlineColorAttributeName,
+                           NSMarkedClauseSegmentAttributeName, NSTextInputReplacementRangeAttributeName, nil];
+        // NSText also supports the following attributes, but it's
+        // hard to tell which are really required for text input to
+        // work well; I have not seen any input method make use of them yet.
+        //     NSFontAttributeName, NSForegroundColorAttributeName,
+        //     NSBackgroundColorAttributeName, NSLanguageAttributeName.
+        CFRetain(validAttributes);
+    }
+    return validAttributes;
+}
+
+- (void)setMarkedText:(id)string selectedRange:(NSRange)newSelRange
+{
+    // Not implemented
+}
+
+- (NSRange)markedRange
+{
+    // Not implemented
+    return NSMakeRange(0, 0);
+}
+
+- (NSAttributedString *)attributedSubstringFromRange:(NSRange)nsRange
+{
+    // Not implemented
+    return nil;
+}
+
+- (NSInteger)conversationIdentifier
+{
+    return (NSInteger)self;
+}
+
+- (NSUInteger)characterIndexForPoint:(NSPoint)thePoint
+{
+    // Not implemented
+    return NSNotFound;
+}
+
+- (NSRect)firstRectForCharacterRange:(NSRange)theRange
+{ 
+    // Not implemented
+    return NSMakeRect(0, 0, 0, 0);
+}
+
 - (void)_updateActiveState
 {
     _data->_page->setActive([[self window] isKeyWindow]);
diff --git a/WebKit2/UIProcess/API/mac/WKViewInternal.h b/WebKit2/UIProcess/API/mac/WKViewInternal.h
index e13b069..ea70eb7 100644
--- a/WebKit2/UIProcess/API/mac/WKViewInternal.h
+++ b/WebKit2/UIProcess/API/mac/WKViewInternal.h
@@ -41,6 +41,7 @@ namespace WebKit {
 - (void)_setEventBeingResent:(NSEvent *)event;
 - (NSRect)_convertToDeviceSpace:(NSRect)rect;
 - (NSRect)_convertToUserSpace:(NSRect)rect;
+- (void)_selectionChanged:(BOOL)isNone isEditable:(BOOL)isContentEditable isPassword:(BOOL)isPasswordField hasMarkedText:(BOOL)hasComposition;
 
 - (void)_setFindIndicator:(PassRefPtr<WebKit::FindIndicator>)findIndicator fadeOut:(BOOL)fadeOut;
 
diff --git a/WebKit2/UIProcess/API/qt/qwkpage.cpp b/WebKit2/UIProcess/API/qt/qwkpage.cpp
index 6f5d9fb..8fb7df8 100644
--- a/WebKit2/UIProcess/API/qt/qwkpage.cpp
+++ b/WebKit2/UIProcess/API/qt/qwkpage.cpp
@@ -126,6 +126,10 @@ FloatRect QWKPagePrivate::convertToUserSpace(const FloatRect& rect)
     return rect;
 }
 
+void QWKPagePrivate::selectionChanged(bool, bool, bool, bool)
+{
+}
+
 void QWKPagePrivate::didNotHandleKeyEvent(const NativeWebKeyboardEvent&)
 {
 }
diff --git a/WebKit2/UIProcess/API/qt/qwkpage_p.h b/WebKit2/UIProcess/API/qt/qwkpage_p.h
index 531b085..744893d 100644
--- a/WebKit2/UIProcess/API/qt/qwkpage_p.h
+++ b/WebKit2/UIProcess/API/qt/qwkpage_p.h
@@ -60,6 +60,7 @@ public:
     virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&);
     virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&);
     virtual void didNotHandleKeyEvent(const WebKit::NativeWebKeyboardEvent&);
+    virtual void selectionChanged(bool, bool, bool, bool);
     virtual PassRefPtr<WebKit::WebPopupMenuProxy> createPopupMenuProxy();
     virtual PassRefPtr<WebKit::WebContextMenuProxy> createContextMenuProxy(WebKit::WebPageProxy*);
 
diff --git a/WebKit2/UIProcess/PageClient.h b/WebKit2/UIProcess/PageClient.h
index 0bee10c..db72a54 100644
--- a/WebKit2/UIProcess/PageClient.h
+++ b/WebKit2/UIProcess/PageClient.h
@@ -71,6 +71,7 @@ public:
     virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&) = 0;
 
     virtual void didNotHandleKeyEvent(const NativeWebKeyboardEvent&) = 0;
+    virtual void selectionChanged(bool, bool, bool, bool) = 0;
 
     virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy() = 0;
     virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*) = 0;
diff --git a/WebKit2/UIProcess/WebPageProxy.cpp b/WebKit2/UIProcess/WebPageProxy.cpp
index 4549803..8a33490 100644
--- a/WebKit2/UIProcess/WebPageProxy.cpp
+++ b/WebKit2/UIProcess/WebPageProxy.cpp
@@ -1073,6 +1073,12 @@ void WebPageProxy::backForwardForwardListCount(int32_t& count)
     count = m_backForwardList->forwardListCount();
 }
 
+// Selection change support
+void WebPageProxy::didSelectionChange(bool isNone, bool isContentEditable, bool isPasswordField, bool hasComposition)
+{
+    m_pageClient->selectionChanged(isNone, isContentEditable, isPasswordField, hasComposition);
+}
+    
 // Undo management
 
 void WebPageProxy::registerEditCommandForUndo(uint64_t commandID, uint32_t editAction)
diff --git a/WebKit2/UIProcess/WebPageProxy.h b/WebKit2/UIProcess/WebPageProxy.h
index 03a1bbb..3aa811d 100644
--- a/WebKit2/UIProcess/WebPageProxy.h
+++ b/WebKit2/UIProcess/WebPageProxy.h
@@ -220,6 +220,7 @@ public:
     void addEditCommand(WebEditCommandProxy*);
     void removeEditCommand(WebEditCommandProxy*);
     void registerEditCommand(PassRefPtr<WebEditCommandProxy>, UndoOrRedo);
+    void didSelectionChange(bool, bool, bool, bool);
 
     WebProcessProxy* process() const;
     WebPageNamespace* pageNamespace() const { return m_pageNamespace.get(); }
diff --git a/WebKit2/UIProcess/WebPageProxy.messages.in b/WebKit2/UIProcess/WebPageProxy.messages.in
index b484b96..7fc3363 100644
--- a/WebKit2/UIProcess/WebPageProxy.messages.in
+++ b/WebKit2/UIProcess/WebPageProxy.messages.in
@@ -108,6 +108,9 @@ messages -> WebPageProxy {
     # Undo/Redo messages.
     RegisterEditCommandForUndo(uint64_t commandID, uint32_t editAction)
     ClearAllEditCommands()
+    
+    # Selection messages.
+    DidSelectionChange(bool isNone, bool isContentEditable, bool isPasswordField, bool hasComposition)
 
     # Find.
     DidCountStringMatches(WTF::String string, uint32_t matchCount)
diff --git a/WebKit2/UIProcess/win/WebView.cpp b/WebKit2/UIProcess/win/WebView.cpp
index 18890ca..a926ebf 100644
--- a/WebKit2/UIProcess/win/WebView.cpp
+++ b/WebKit2/UIProcess/win/WebView.cpp
@@ -614,6 +614,11 @@ FloatRect WebView::convertToUserSpace(const FloatRect& rect)
     return rect;
 }
 
+void WebView::selectionChanged(bool, bool, bool, bool)
+{
+    // FIXME: Implement.
+}
+
 void WebView::didNotHandleKeyEvent(const NativeWebKeyboardEvent& event)
 {
     // Calling ::DefWindowProcW will ensure that pressing the Alt key will generate a WM_SYSCOMMAND
diff --git a/WebKit2/UIProcess/win/WebView.h b/WebKit2/UIProcess/win/WebView.h
index b0860df..7c5e128 100644
--- a/WebKit2/UIProcess/win/WebView.h
+++ b/WebKit2/UIProcess/win/WebView.h
@@ -104,6 +104,7 @@ private:
     virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&);
     virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&);
     virtual void didNotHandleKeyEvent(const NativeWebKeyboardEvent&);
+    virtual void selectionChanged(bool, bool, bool, bool);
     virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy();
     virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*);
     virtual void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut);
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp b/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp
index 10a2794..13595b0 100644
--- a/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp
+++ b/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp
@@ -35,11 +35,13 @@
 #include <WebCore/ArchiveResource.h>
 #include <WebCore/DocumentFragment.h>
 #include <WebCore/EditCommand.h>
+#include <WebCore/FocusController.h>
 #include <WebCore/Frame.h>
 #include <WebCore/HTMLInputElement.h>
 #include <WebCore/HTMLNames.h>
 #include <WebCore/HTMLTextAreaElement.h>
 #include <WebCore/KeyboardEvent.h>
+#include <WebCore/Page.h>
 #include <WebCore/UserTypingGestureIndicator.h>
 
 using namespace WebCore;
@@ -180,7 +182,10 @@ void WebEditorClient::respondToChangedSelection()
 {
     static const String WebViewDidChangeSelectionNotification = "WebViewDidChangeSelectionNotification";
     m_page->injectedBundleEditorClient().didChangeSelection(m_page, WebViewDidChangeSelectionNotification.impl());
-    notImplemented();
+    Frame* frame = m_page->corePage()->focusController()->focusedFrame();
+    if (!frame)
+        return;
+    m_page->send(Messages::WebPageProxy::DidSelectionChange(frame->selection()->isNone(), frame->selection()->isContentEditable(), frame->selection()->isInPasswordField(), frame->editor()->hasComposition()));
 }
 
 void WebEditorClient::didEndEditing()

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list