Changeset 24381 in webkit
- Timestamp:
- Jul 17, 2007 2:17:25 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r24380 r24381 1 2007-07-17 Adam Roben <aroben@apple.com> 2 3 Fix Bug 14324: Cannot remove/customize the "Inspect Element" contextual menu item 4 http://bugs.webkit.org/show_bug.cgi?id=14324 5 6 Reviewed by Tim. 7 8 No regression test possible. 9 10 * page/ContextMenuController.cpp: 11 (WebCore::ContextMenuController::handleContextMenuEvent): Add the 12 Inspect Element item to the menu before passing it to the 13 ContextMenuClient so that the UI delegate has a chance to 14 modify/remove the item. 15 1 16 2007-07-17 Adam Roben <aroben@apple.com> 2 17 -
trunk/WebCore/page/ContextMenuController.cpp
r24380 r24381 96 96 m_contextMenu.set(new ContextMenu(result)); 97 97 m_contextMenu->populate(); 98 if (m_page->settings()->developerExtrasEnabled()) 99 m_contextMenu->addInspectElementItem(); 100 98 101 PlatformMenuDescription customMenu = m_client->getCustomMenuFromDefaultItems(m_contextMenu.get()); 99 102 m_contextMenu->setPlatformDescription(customMenu); 100 103 101 if (m_page->settings()->developerExtrasEnabled())102 m_contextMenu->addInspectElementItem();103 104 event->setDefaultHandled(); 104 105 } -
trunk/WebKit/ChangeLog
r24380 r24381 1 2007-07-17 Adam Roben <aroben@apple.com> 2 3 Fix Bug 14324: Cannot remove/customize the "Inspect Element" contextual menu item 4 http://bugs.webkit.org/show_bug.cgi?id=14324 5 6 Only clients linking against new versions of WebKit will see the item. 7 I've maintained our behavior for old clients of not including the 8 Inspect Element item in the menu items passed to the UI delegate. 9 10 Reviewed by Tim. 11 12 * Misc/WebKitVersionChecks.h: Added a new constant. 13 * WebCoreSupport/WebContextMenuClient.mm: 14 (isPreInspectElementTagClient): Added. 15 (fixMenusToSendToOldClients): Return an array of items that should be 16 appended to the menu received from the delegate. 17 (fixMenusReceivedFromOldClients): Append the saved items to the array. 18 (WebContextMenuClient::getCustomMenuFromDefaultItems): Retain/release 19 the saved items. 20 1 21 2007-07-17 Adam Roben <aroben@apple.com> 2 22 -
trunk/WebKit/Misc/WebKitVersionChecks.h
r24183 r24381 39 39 #define WEBKIT_FIRST_VERSION_WITH_MAIN_THREAD_EXCEPTIONS 0x020A0000 // 522.0.0 40 40 #define WEBKIT_FIRST_VERSION_WITHOUT_ADOBE_INSTALLER_QUIRK 0x020A0000 // 522.0.0 41 #define WEBKIT_FIRST_VERSION_WITH_INSPECT_ELEMENT_MENU_TAG 0x020A0C00 // 522.12.0 41 42 42 43 #ifdef __cplusplus -
trunk/WebKit/WebCoreSupport/WebContextMenuClient.mm
r24380 r24381 72 72 } 73 73 74 static void fixMenusToSendToOldClients(NSMutableArray *defaultMenuItems) 75 { 74 static BOOL isPreInspectElementTagClient(void) 75 { 76 static BOOL preInspectElementTagClient = !WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_INSPECT_ELEMENT_MENU_TAG); 77 return preInspectElementTagClient; 78 } 79 80 static NSMutableArray *fixMenusToSendToOldClients(NSMutableArray *defaultMenuItems) 81 { 82 NSMutableArray *savedItems = nil; 83 84 unsigned defaultItemsCount = [defaultMenuItems count]; 85 86 if (isPreInspectElementTagClient()) { 87 NSMenuItem *secondToLastItem = [defaultMenuItems objectAtIndex:defaultItemsCount - 2]; 88 NSMenuItem *lastItem = [defaultMenuItems objectAtIndex:defaultItemsCount - 1]; 89 90 if ([secondToLastItem isSeparatorItem] && [lastItem tag] == WebMenuItemTagInspectElement) { 91 savedItems = [NSMutableArray arrayWithCapacity:2]; 92 [savedItems addObject:secondToLastItem]; 93 [savedItems addObject:lastItem]; 94 95 [defaultMenuItems removeObject:secondToLastItem]; 96 [defaultMenuItems removeObject:lastItem]; 97 } 98 } 99 76 100 BOOL preVersion3Client = isPreVersion3Client(); 77 101 if (!preVersion3Client) 78 return ;102 return savedItems; 79 103 80 104 BOOL isMail = isAppleMail(); 81 unsigned defaultItemsCount = [defaultMenuItems count];82 105 for (unsigned i = 0; i < defaultItemsCount; ++i) { 83 106 NSMenuItem *item = [defaultMenuItems objectAtIndex:i]; … … 124 147 [item setTag:oldStyleTag]; 125 148 } 126 } 127 128 static void fixMenusReceivedFromOldClients(NSMutableArray *newMenuItems) 149 150 return savedItems; 151 } 152 153 static void fixMenusReceivedFromOldClients(NSMutableArray *newMenuItems, NSMutableArray *savedItems) 129 154 { 155 if (savedItems) 156 [newMenuItems addObjectsFromArray:savedItems]; 157 130 158 BOOL preVersion3Client = isPreVersion3Client(); 131 159 if (!preVersion3Client) … … 241 269 [[defaultMenuItems objectAtIndex:i] setRepresentedObject:element]; 242 270 243 fixMenusToSendToOldClients(defaultMenuItems);271 NSMutableArray *savedItems = [fixMenusToSendToOldClients(defaultMenuItems) retain]; 244 272 NSMutableArray *newMenuItems = [[[delegate webView:m_webView contextMenuItemsForElement:element defaultMenuItems:defaultMenuItems] mutableCopy] autorelease]; 245 fixMenusReceivedFromOldClients(newMenuItems); 273 fixMenusReceivedFromOldClients(newMenuItems, savedItems); 274 [savedItems release]; 246 275 return newMenuItems; 247 276 } -
trunk/WebKit/win/ChangeLog
r24380 r24381 1 2007-07-17 Adam Roben <aroben@apple.com> 2 3 Fix Bug 14324: Cannot remove/customize the "Inspect Element" contextual menu item 4 http://bugs.webkit.org/show_bug.cgi?id=14324 5 6 If we detect that we're running against the Safari 3 Beta, we add back 7 the Inspect Element menu item after passing it off to the delegate 8 because Safari's UI delegate will remove it. 9 10 Reviewed by Tim. 11 12 * WebContextMenuClient.cpp: 13 (isPreInspectElementTagSafari): Added. 14 (fixMenuReceivedFromOldSafari): Added. 15 (WebContextMenuClient::getCustomMenuFromDefaultItems): Call 16 fixMenuReceivedFromOldSafari before returning the new menu. 17 1 18 2007-07-17 Adam Roben <aroben@apple.com> 2 19 -
trunk/WebKit/win/WebContextMenuClient.cpp
r24380 r24381 55 55 } 56 56 57 static bool isPreInspectElementTagSafari(IWebUIDelegate* uiDelegate) 58 { 59 if (!uiDelegate) 60 return false; 61 62 // We assume anyone who implements IWebUIDelegate2 also knows about the Inspect Element item. 63 COMPtr<IWebUIDelegate2> uiDelegate2; 64 if (SUCCEEDED(uiDelegate->QueryInterface(IID_IWebUIDelegate2, (void**)&uiDelegate2))) 65 return false; 66 67 TCHAR modulePath[MAX_PATH]; 68 DWORD length = ::GetModuleFileName(0, modulePath, _countof(modulePath)); 69 if (!length) 70 return false; 71 72 return String(modulePath, length).endsWith("Safari.exe", false); 73 } 74 75 static HMENU fixMenuReceivedFromOldSafari(IWebUIDelegate* uiDelegate, ContextMenu* originalMenu, HMENU menuFromClient) 76 { 77 ASSERT_ARG(menu, menu); 78 if (!isPreInspectElementTagSafari(uiDelegate)) 79 return menuFromClient; 80 81 int count = ::GetMenuItemCount(originalMenu->platformDescription()); 82 if (count < 1) 83 return menuFromClient; 84 85 if (::GetMenuItemID(originalMenu->platformDescription(), count - 1) != WebMenuItemTagInspectElement) 86 return menuFromClient; 87 88 count = ::GetMenuItemCount(menuFromClient); 89 if (count < 1) 90 return menuFromClient; 91 92 if (::GetMenuItemID(menuFromClient, count - 1) == WebMenuItemTagInspectElement) 93 return menuFromClient; 94 95 originalMenu->setPlatformDescription(menuFromClient); 96 originalMenu->addInspectElementItem(); 97 return originalMenu->platformDescription(); 98 } 99 57 100 HMENU WebContextMenuClient::getCustomMenuFromDefaultItems(ContextMenu* menu) 58 101 { … … 69 112 if (FAILED(uiDelegate->contextMenuItemsForElement(m_webView, propertyBag.get(), (OLE_HANDLE)(ULONG64)menu->platformDescription(), (OLE_HANDLE*)&newMenu))) 70 113 return menu->platformDescription(); 71 72 return newMenu; 114 return fixMenuReceivedFromOldSafari(uiDelegate.get(), menu, newMenu); 73 115 } 74 116
Note: See TracChangeset
for help on using the changeset viewer.