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

enrica at apple.com enrica at apple.com
Wed Dec 22 18:43:59 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 6d1d09e2845f79f5f23218844766cd77697ea5ac
Author: enrica at apple.com <enrica at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Dec 16 20:18:42 2010 +0000

    WebKit2: Cannot copy two successive selections using cmd-c
    <rdar://problem/8680309>
    https://bugs.webkit.org/show_bug.cgi?id=51203
    
    Reviewed by Maciej Stachowiak.
    
    The previous implementation assumed a call sequence from AppKit that
    was not always happening.
    When the user clicks on the pulldown menu, AppKit sends validateUserInterfaceItem
    calls for each element that needs validation and we used to count the number of
    validation requests being sent to the web process.
    All these calls are made before we have the chance to get one reply from the WebProcess.
    We also delayed the menu update until we had received all the replies to the validation requests.
    At that point we called update on the menu to trigger the validation one more time with
    the data retrived from the WebProcess.
    When the user simply presses cmd-c, only one call to vaidateUserInterfaceItem is made
    and the menu update triggered the validation of all the menu entries causing the internal
    state to be out of sync.
    The new implementation is very simple: for each validation request from AppKit we send
    a request to the WebProcess and we cache a reference to the menu item being validated.
    When the WebProcess replies, we retrieve the menu item from our cache and update its state.
    
    * UIProcess/API/mac/WKView.mm:
    (-[WKView initWithFrame:contextRef:pageGroupRef:]): Removed initialization of deleted memebers.
    (-[WKView validateUserInterfaceItem:]): Request validation to the WebProcess and return YES to
    allow AppKit to do the keyBinding processing.
    (-[WKView _setUserInterfaceItemState:enabled:state:]): Called when the WebProcess replies to the
    validation request to check/uncheck and enable/disable the menu item.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74206 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index d7457d0..422a56b 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,34 @@
+2010-12-16  Enrica Casucci  <enrica at apple.com>
+
+        Reviewed by Maciej Stachowiak.
+
+        WebKit2: Cannot copy two successive selections using cmd-c
+        <rdar://problem/8680309> 
+        https://bugs.webkit.org/show_bug.cgi?id=51203
+        
+        The previous implementation assumed a call sequence from AppKit that
+        was not always happening.
+        When the user clicks on the pulldown menu, AppKit sends validateUserInterfaceItem
+        calls for each element that needs validation and we used to count the number of
+        validation requests being sent to the web process.
+        All these calls are made before we have the chance to get one reply from the WebProcess.
+        We also delayed the menu update until we had received all the replies to the validation requests.
+        At that point we called update on the menu to trigger the validation one more time with
+        the data retrived from the WebProcess.
+        When the user simply presses cmd-c, only one call to vaidateUserInterfaceItem is made
+        and the menu update triggered the validation of all the menu entries causing the internal
+        state to be out of sync.
+        The new implementation is very simple: for each validation request from AppKit we send
+        a request to the WebProcess and we cache a reference to the menu item being validated.
+        When the WebProcess replies, we retrieve the menu item from our cache and update its state.
+        
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView initWithFrame:contextRef:pageGroupRef:]): Removed initialization of deleted memebers.
+        (-[WKView validateUserInterfaceItem:]): Request validation to the WebProcess and return YES to 
+        allow AppKit to do the keyBinding processing.
+        (-[WKView _setUserInterfaceItemState:enabled:state:]): Called when the WebProcess replies to the
+        validation request to check/uncheck and enable/disable the menu item.
+
 2010-12-16  Anders Carlsson  <andersca at apple.com>
 
         Reviewed by Oliver Hunt.
diff --git a/WebKit2/UIProcess/API/mac/WKView.mm b/WebKit2/UIProcess/API/mac/WKView.mm
index 3618152..350b116 100644
--- a/WebKit2/UIProcess/API/mac/WKView.mm
+++ b/WebKit2/UIProcess/API/mac/WKView.mm
@@ -67,13 +67,6 @@ extern "C" {
 using namespace WebKit;
 using namespace WebCore;
 
-struct EditCommandState {
-    EditCommandState() : m_isEnabled(false), m_state(0) {};
-    EditCommandState(bool isEnabled, int state) : m_isEnabled(isEnabled), m_state(state) { }
-    bool m_isEnabled;
-    int m_state;
-};
-
 @interface NSWindow (Details)
 - (NSRect)_growBoxRect;
 - (BOOL)_updateGrowBoxForWindowFrameChange;
@@ -93,11 +86,7 @@ struct EditCommandState {
     NSView *_layerHostingView;
 #endif
     // For Menus.
-    int _menuEntriesCount;
-    Vector<RetainPtr<NSMenu> > _menuList;
-    bool _isPerformingUpdate;
-    
-    HashMap<String, EditCommandState> _menuMap;
+    HashMap<String, RetainPtr<NSMenuItem> > _menuItemsMap;
 
     OwnPtr<PDFViewController> _pdfViewController;
 
@@ -167,9 +156,6 @@ struct EditCommandState {
     _data->_page->initializeWebPage(IntSize(frame.size));
     _data->_page->setIsInWindow([self window]);
 
-    _data->_menuEntriesCount = 0;
-    _data->_isPerformingUpdate = false;
-
     _data->_isSelectionNone = YES;
     _data->_isSelectionEditable = NO;
     _data->_isSelectionInPasswordField = NO;
@@ -330,19 +316,9 @@ WEBCORE_COMMAND(takeFindStringFromSelection)
     if (![menuItem isKindOfClass:[NSMenuItem class]])
         return NO; // FIXME: We need to be able to handle other user interface elements.
     
-    RetainPtr<NSMenu> menu = [menuItem menu];
-    if (!_data->_isPerformingUpdate) {
-        if (_data->_menuList.find(menu) == notFound)
-            _data->_menuList.append(menu);
-        _data->_menuMap.add(commandName, EditCommandState(false, 0));
-        _data->_menuEntriesCount++;
+    if (_data->_menuItemsMap.find(commandName) == _data->_menuItemsMap.end()) {
+        _data->_menuItemsMap.add(commandName, menuItem);
         _data->_page->validateMenuItem(commandName);
-    } else {
-        EditCommandState info = _data->_menuMap.take(commandName);
-        [menuItem setState:info.m_state];
-        if (_data->_menuMap.isEmpty())
-            _data->_isPerformingUpdate = false;
-        return info.m_isEnabled;
     }
 
     return YES;
@@ -918,19 +894,9 @@ static bool isViewVisible(NSView *view)
 
 - (void)_setUserInterfaceItemState:(NSString *)commandName enabled:(BOOL)isEnabled state:(int)newState
 {
-    ASSERT(_data->_menuEntriesCount);
-    _data->_menuMap.set(commandName, EditCommandState(isEnabled, newState));
-    if (--_data->_menuEntriesCount)
-        return;
-    
-    // All the menu entries have been validated.
-    // Calling update will trigger the validation
-    // to be performed with the acquired data.
-    _data->_isPerformingUpdate = true;
-    for (size_t i = 0; i < _data->_menuList.size(); i++)
-        [_data->_menuList[i].get() update];
-    
-    _data->_menuList.clear();
+    NSMenuItem *menuItem = _data->_menuItemsMap.take(commandName).get();
+    [menuItem setState:newState];
+    [menuItem setEnabled:isEnabled];
 }
 
 - (NSRect)_convertToDeviceSpace:(NSRect)rect

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list