| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2010 Igalia S.L | 3 * Copyright (C) 2010 Igalia S.L |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 155 |
| 156 m_hitTestResult = result; | 156 m_hitTestResult = result; |
| 157 | 157 |
| 158 return adoptPtr(new ContextMenu); | 158 return adoptPtr(new ContextMenu); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void ContextMenuController::showContextMenu(Event* event) | 161 void ContextMenuController::showContextMenu(Event* event) |
| 162 { | 162 { |
| 163 addInspectElementItem(); | 163 addInspectElementItem(); |
| 164 | 164 |
| 165 #if USE(CROSS_PLATFORM_CONTEXT_MENUS) | |
| 166 m_contextMenu = m_client->customizeMenu(m_contextMenu.release()); | 165 m_contextMenu = m_client->customizeMenu(m_contextMenu.release()); |
| 167 #else | |
| 168 PlatformMenuDescription customMenu = m_client->getCustomMenuFromDefaultItems
(m_contextMenu.get()); | |
| 169 m_contextMenu->setPlatformDescription(customMenu); | |
| 170 #endif | |
| 171 event->setDefaultHandled(); | 166 event->setDefaultHandled(); |
| 172 } | 167 } |
| 173 | 168 |
| 174 static void openNewWindow(const KURL& urlToLoad, Frame* frame) | 169 static void openNewWindow(const KURL& urlToLoad, Frame* frame) |
| 175 { | 170 { |
| 176 if (Page* oldPage = frame->page()) { | 171 if (Page* oldPage = frame->page()) { |
| 177 FrameLoadRequest request(frame->document()->securityOrigin(), ResourceRe
quest(urlToLoad, frame->loader()->outgoingReferrer())); | 172 FrameLoadRequest request(frame->document()->securityOrigin(), ResourceRe
quest(urlToLoad, frame->loader()->outgoingReferrer())); |
| 178 Page* newPage = oldPage; | 173 Page* newPage = oldPage; |
| 179 if (!frame->settings() || frame->settings()->supportsMultipleWindows())
{ | 174 if (!frame->settings() || frame->settings()->supportsMultipleWindows())
{ |
| 180 newPage = oldPage->chrome()->createWindow(frame, request, WindowFeat
ures(), NavigationAction(request.resourceRequest())); | 175 newPage = oldPage->chrome()->createWindow(frame, request, WindowFeat
ures(), NavigationAction(request.resourceRequest())); |
| 181 if (!newPage) | 176 if (!newPage) |
| 182 return; | 177 return; |
| 183 newPage->chrome()->show(); | 178 newPage->chrome()->show(); |
| 184 } | 179 } |
| 185 newPage->mainFrame()->loader()->loadFrameRequest(request, false, false,
0, 0, MaybeSendReferrer); | 180 newPage->mainFrame()->loader()->loadFrameRequest(request, false, false,
0, 0, MaybeSendReferrer); |
| 186 } | 181 } |
| 187 } | 182 } |
| 188 | 183 |
| 189 void ContextMenuController::contextMenuItemSelected(ContextMenuItem* item) | 184 void ContextMenuController::contextMenuItemSelected(const ContextMenuItem* item) |
| 190 { | 185 { |
| 191 ASSERT(item->type() == ActionType || item->type() == CheckableActionType); | 186 ASSERT(item->type() == ActionType || item->type() == CheckableActionType); |
| 192 | 187 |
| 193 if (item->action() >= ContextMenuItemBaseApplicationTag) { | 188 if (item->action() >= ContextMenuItemBaseApplicationTag) { |
| 194 m_client->contextMenuItemSelected(item, m_contextMenu.get()); | 189 m_client->contextMenuItemSelected(item, m_contextMenu.get()); |
| 195 return; | 190 return; |
| 196 } | 191 } |
| 197 | 192 |
| 198 if (item->action() >= ContextMenuItemBaseCustomTag) { | 193 if (item->action() >= ContextMenuItemBaseCustomTag) { |
| 199 ASSERT(m_menuProvider); | 194 ASSERT(m_menuProvider); |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 return; | 728 return; |
| 734 | 729 |
| 735 Page* page = frame->page(); | 730 Page* page = frame->page(); |
| 736 if (!page) | 731 if (!page) |
| 737 return; | 732 return; |
| 738 | 733 |
| 739 if (!page->inspectorController()) | 734 if (!page->inspectorController()) |
| 740 return; | 735 return; |
| 741 | 736 |
| 742 ContextMenuItem InspectElementItem(ActionType, ContextMenuItemTagInspectElem
ent, contextMenuItemTagInspectElement()); | 737 ContextMenuItem InspectElementItem(ActionType, ContextMenuItemTagInspectElem
ent, contextMenuItemTagInspectElement()); |
| 743 #if USE(CROSS_PLATFORM_CONTEXT_MENUS) | |
| 744 if (m_contextMenu && !m_contextMenu->items().isEmpty()) | 738 if (m_contextMenu && !m_contextMenu->items().isEmpty()) |
| 745 #else | |
| 746 if (m_contextMenu && m_contextMenu->itemCount()) | |
| 747 #endif | |
| 748 appendItem(*separatorItem(), m_contextMenu.get()); | 739 appendItem(*separatorItem(), m_contextMenu.get()); |
| 749 appendItem(InspectElementItem, m_contextMenu.get()); | 740 appendItem(InspectElementItem, m_contextMenu.get()); |
| 750 } | 741 } |
| 751 | 742 |
| 752 void ContextMenuController::checkOrEnableIfNeeded(ContextMenuItem& item) const | 743 void ContextMenuController::checkOrEnableIfNeeded(ContextMenuItem& item) const |
| 753 { | 744 { |
| 754 if (item.type() == SeparatorType) | 745 if (item.type() == SeparatorType) |
| 755 return; | 746 return; |
| 756 | 747 |
| 757 Frame* frame = m_hitTestResult.innerNonSharedNode()->document()->frame(); | 748 Frame* frame = m_hitTestResult.innerNonSharedNode()->document()->frame(); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 PlatformMouseEvent mouseEvent(clickPoint, clickPoint, RightButton, PlatformE
vent::MousePressed, 1, false, false, false, false, currentTime()); | 935 PlatformMouseEvent mouseEvent(clickPoint, clickPoint, RightButton, PlatformE
vent::MousePressed, 1, false, false, false, false, currentTime()); |
| 945 bool handled = frame->eventHandler()->sendContextMenuEvent(mouseEvent); | 936 bool handled = frame->eventHandler()->sendContextMenuEvent(mouseEvent); |
| 946 if (handled && client()) | 937 if (handled && client()) |
| 947 client()->showContextMenu(); | 938 client()->showContextMenu(); |
| 948 } | 939 } |
| 949 #endif | 940 #endif |
| 950 | 941 |
| 951 } // namespace WebCore | 942 } // namespace WebCore |
| 952 | 943 |
| 953 #endif // ENABLE(CONTEXT_MENUS) | 944 #endif // ENABLE(CONTEXT_MENUS) |
| OLD | NEW |