Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: Source/WebCore/page/ContextMenuController.cpp

Issue 13646003: DevTools: Remove ENABLE(INSPECTOR) and ENABLE(JAVASCRIPT_DEBUGGER) from the code. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 if (!result.innerNonSharedNode()) 157 if (!result.innerNonSharedNode())
158 return nullptr; 158 return nullptr;
159 159
160 m_hitTestResult = result; 160 m_hitTestResult = result;
161 161
162 return adoptPtr(new ContextMenu); 162 return adoptPtr(new ContextMenu);
163 } 163 }
164 164
165 void ContextMenuController::showContextMenu(Event* event) 165 void ContextMenuController::showContextMenu(Event* event)
166 { 166 {
167 #if ENABLE(INSPECTOR)
168 if (m_page->inspectorController()->enabled()) 167 if (m_page->inspectorController()->enabled())
169 addInspectElementItem(); 168 addInspectElementItem();
170 #endif
171 169
172 #if USE(CROSS_PLATFORM_CONTEXT_MENUS) 170 #if USE(CROSS_PLATFORM_CONTEXT_MENUS)
173 m_contextMenu = m_client->customizeMenu(m_contextMenu.release()); 171 m_contextMenu = m_client->customizeMenu(m_contextMenu.release());
174 #else 172 #else
175 PlatformMenuDescription customMenu = m_client->getCustomMenuFromDefaultItems (m_contextMenu.get()); 173 PlatformMenuDescription customMenu = m_client->getCustomMenuFromDefaultItems (m_contextMenu.get());
176 m_contextMenu->setPlatformDescription(customMenu); 174 m_contextMenu->setPlatformDescription(customMenu);
177 #endif 175 #endif
178 event->setDefaultHandled(); 176 event->setDefaultHandled();
179 } 177 }
180 178
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 case ContextMenuItemTagSmartLinks: 489 case ContextMenuItemTagSmartLinks:
492 frame->editor()->toggleAutomaticLinkDetection(); 490 frame->editor()->toggleAutomaticLinkDetection();
493 break; 491 break;
494 case ContextMenuItemTagTextReplacement: 492 case ContextMenuItemTagTextReplacement:
495 frame->editor()->toggleAutomaticTextReplacement(); 493 frame->editor()->toggleAutomaticTextReplacement();
496 break; 494 break;
497 case ContextMenuItemTagCorrectSpellingAutomatically: 495 case ContextMenuItemTagCorrectSpellingAutomatically:
498 frame->editor()->toggleAutomaticSpellingCorrection(); 496 frame->editor()->toggleAutomaticSpellingCorrection();
499 break; 497 break;
500 #endif 498 #endif
501 #if ENABLE(INSPECTOR)
502 case ContextMenuItemTagInspectElement: 499 case ContextMenuItemTagInspectElement:
503 if (Page* page = frame->page()) 500 if (Page* page = frame->page())
504 page->inspectorController()->inspect(m_hitTestResult.innerNonSharedN ode()); 501 page->inspectorController()->inspect(m_hitTestResult.innerNonSharedN ode());
505 break; 502 break;
506 #endif
507 case ContextMenuItemTagDictationAlternative: 503 case ContextMenuItemTagDictationAlternative:
508 frame->editor()->applyDictationAlternativelternative(item->title()); 504 frame->editor()->applyDictationAlternativelternative(item->title());
509 break; 505 break;
510 default: 506 default:
511 break; 507 break;
512 } 508 }
513 } 509 }
514 510
515 void ContextMenuController::appendItem(ContextMenuItem& menuItem, ContextMenu* p arentMenu) 511 void ContextMenuController::appendItem(ContextMenuItem& menuItem, ContextMenu* p arentMenu)
516 { 512 {
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 875
880 appendItem(CopyItem, m_contextMenu.get()); 876 appendItem(CopyItem, m_contextMenu.get());
881 #if PLATFORM(MAC) 877 #if PLATFORM(MAC)
882 appendItem(*separatorItem(), m_contextMenu.get()); 878 appendItem(*separatorItem(), m_contextMenu.get());
883 879
884 ContextMenuItem SpeechMenuItem(SubmenuType, ContextMenuItemTagSp eechMenu, contextMenuItemTagSpeechMenu()); 880 ContextMenuItem SpeechMenuItem(SubmenuType, ContextMenuItemTagSp eechMenu, contextMenuItemTagSpeechMenu());
885 createAndAppendSpeechSubMenu(SpeechMenuItem); 881 createAndAppendSpeechSubMenu(SpeechMenuItem);
886 appendItem(SpeechMenuItem, m_contextMenu.get()); 882 appendItem(SpeechMenuItem, m_contextMenu.get());
887 #endif 883 #endif
888 } else { 884 } else {
889 #if ENABLE(INSPECTOR)
890 if (!(frame->page() && frame->page()->inspectorController()->has InspectorFrontendClient())) { 885 if (!(frame->page() && frame->page()->inspectorController()->has InspectorFrontendClient())) {
891 #endif
892 886
893 // In GTK+ and EFL, unavailable items are not hidden but insensi tive. 887 // In GTK+ and EFL, unavailable items are not hidden but insensi tive.
894 #if PLATFORM(GTK) || PLATFORM(EFL) 888 #if PLATFORM(GTK) || PLATFORM(EFL)
895 appendItem(BackItem, m_contextMenu.get()); 889 appendItem(BackItem, m_contextMenu.get());
896 appendItem(ForwardItem, m_contextMenu.get()); 890 appendItem(ForwardItem, m_contextMenu.get());
897 appendItem(StopItem, m_contextMenu.get()); 891 appendItem(StopItem, m_contextMenu.get());
898 appendItem(ReloadItem, m_contextMenu.get()); 892 appendItem(ReloadItem, m_contextMenu.get());
899 #else 893 #else
900 if (frame->page() && frame->page()->backForward()->canGoBackOrFo rward(-1)) 894 if (frame->page() && frame->page()->backForward()->canGoBackOrFo rward(-1))
901 appendItem(BackItem, m_contextMenu.get()); 895 appendItem(BackItem, m_contextMenu.get());
902 896
903 if (frame->page() && frame->page()->backForward()->canGoBackOrFo rward(1)) 897 if (frame->page() && frame->page()->backForward()->canGoBackOrFo rward(1))
904 appendItem(ForwardItem, m_contextMenu.get()); 898 appendItem(ForwardItem, m_contextMenu.get());
905 899
906 // use isLoadingInAPISense rather than isLoading because Stop/Re load are 900 // use isLoadingInAPISense rather than isLoading because Stop/Re load are
907 // intended to match WebKit's API, not WebCore's internal notion of loading status 901 // intended to match WebKit's API, not WebCore's internal notion of loading status
908 if (loader->documentLoader()->isLoadingInAPISense()) 902 if (loader->documentLoader()->isLoadingInAPISense())
909 appendItem(StopItem, m_contextMenu.get()); 903 appendItem(StopItem, m_contextMenu.get());
910 else 904 else
911 appendItem(ReloadItem, m_contextMenu.get()); 905 appendItem(ReloadItem, m_contextMenu.get());
912 #endif 906 #endif
913 #if ENABLE(INSPECTOR)
914 } 907 }
915 #endif
916 908
917 if (frame->page() && frame != frame->page()->mainFrame()) 909 if (frame->page() && frame != frame->page()->mainFrame())
918 appendItem(OpenFrameItem, m_contextMenu.get()); 910 appendItem(OpenFrameItem, m_contextMenu.get());
919 } 911 }
920 } 912 }
921 } else { // Make an editing context menu 913 } else { // Make an editing context menu
922 FrameSelection* selection = frame->selection(); 914 FrameSelection* selection = frame->selection();
923 bool inPasswordField = selection->isInPasswordField(); 915 bool inPasswordField = selection->isInPasswordField();
924 if (!inPasswordField) { 916 if (!inPasswordField) {
925 bool haveContextMenuItemsForMisspellingOrGrammer = false; 917 bool haveContextMenuItemsForMisspellingOrGrammer = false;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 createAndAppendTextDirectionSubMenu(TextDirectionMenuIte m); 1078 createAndAppendTextDirectionSubMenu(TextDirectionMenuIte m);
1087 appendItem(TextDirectionMenuItem, m_contextMenu.get()); 1079 appendItem(TextDirectionMenuItem, m_contextMenu.get());
1088 } 1080 }
1089 } 1081 }
1090 } 1082 }
1091 #endif 1083 #endif
1092 } 1084 }
1093 } 1085 }
1094 } 1086 }
1095 1087
1096 #if ENABLE(INSPECTOR)
1097 void ContextMenuController::addInspectElementItem() 1088 void ContextMenuController::addInspectElementItem()
1098 { 1089 {
1099 Node* node = m_hitTestResult.innerNonSharedNode(); 1090 Node* node = m_hitTestResult.innerNonSharedNode();
1100 if (!node) 1091 if (!node)
1101 return; 1092 return;
1102 1093
1103 Frame* frame = node->document()->frame(); 1094 Frame* frame = node->document()->frame();
1104 if (!frame) 1095 if (!frame)
1105 return; 1096 return;
1106 1097
1107 Page* page = frame->page(); 1098 Page* page = frame->page();
1108 if (!page) 1099 if (!page)
1109 return; 1100 return;
1110 1101
1111 if (!page->inspectorController()) 1102 if (!page->inspectorController())
1112 return; 1103 return;
1113 1104
1114 ContextMenuItem InspectElementItem(ActionType, ContextMenuItemTagInspectElem ent, contextMenuItemTagInspectElement()); 1105 ContextMenuItem InspectElementItem(ActionType, ContextMenuItemTagInspectElem ent, contextMenuItemTagInspectElement());
1115 #if USE(CROSS_PLATFORM_CONTEXT_MENUS) 1106 #if USE(CROSS_PLATFORM_CONTEXT_MENUS)
1116 if (m_contextMenu && !m_contextMenu->items().isEmpty()) 1107 if (m_contextMenu && !m_contextMenu->items().isEmpty())
1117 #else 1108 #else
1118 if (m_contextMenu && m_contextMenu->itemCount()) 1109 if (m_contextMenu && m_contextMenu->itemCount())
1119 #endif 1110 #endif
1120 appendItem(*separatorItem(), m_contextMenu.get()); 1111 appendItem(*separatorItem(), m_contextMenu.get());
1121 appendItem(InspectElementItem, m_contextMenu.get()); 1112 appendItem(InspectElementItem, m_contextMenu.get());
1122 } 1113 }
1123 #endif // ENABLE(INSPECTOR)
1124 1114
1125 void ContextMenuController::checkOrEnableIfNeeded(ContextMenuItem& item) const 1115 void ContextMenuController::checkOrEnableIfNeeded(ContextMenuItem& item) const
1126 { 1116 {
1127 if (item.type() == SeparatorType) 1117 if (item.type() == SeparatorType)
1128 return; 1118 return;
1129 1119
1130 Frame* frame = m_hitTestResult.innerNonSharedNode()->document()->frame(); 1120 Frame* frame = m_hitTestResult.innerNonSharedNode()->document()->frame();
1131 if (!frame) 1121 if (!frame)
1132 return; 1122 return;
1133 1123
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 case ContextMenuItemTagSpellingMenu: 1355 case ContextMenuItemTagSpellingMenu:
1366 case ContextMenuItemTagShowFonts: 1356 case ContextMenuItemTagShowFonts:
1367 case ContextMenuItemTagStyles: 1357 case ContextMenuItemTagStyles:
1368 case ContextMenuItemTagShowColors: 1358 case ContextMenuItemTagShowColors:
1369 case ContextMenuItemTagSpeechMenu: 1359 case ContextMenuItemTagSpeechMenu:
1370 case ContextMenuItemTagStartSpeaking: 1360 case ContextMenuItemTagStartSpeaking:
1371 case ContextMenuItemTagWritingDirectionMenu: 1361 case ContextMenuItemTagWritingDirectionMenu:
1372 case ContextMenuItemTagTextDirectionMenu: 1362 case ContextMenuItemTagTextDirectionMenu:
1373 case ContextMenuItemTagPDFSinglePageScrolling: 1363 case ContextMenuItemTagPDFSinglePageScrolling:
1374 case ContextMenuItemTagPDFFacingPagesScrolling: 1364 case ContextMenuItemTagPDFFacingPagesScrolling:
1375 #if ENABLE(INSPECTOR)
1376 case ContextMenuItemTagInspectElement: 1365 case ContextMenuItemTagInspectElement:
1377 #endif
1378 case ContextMenuItemBaseCustomTag: 1366 case ContextMenuItemBaseCustomTag:
1379 case ContextMenuItemCustomTagNoAction: 1367 case ContextMenuItemCustomTagNoAction:
1380 case ContextMenuItemLastCustomTag: 1368 case ContextMenuItemLastCustomTag:
1381 case ContextMenuItemBaseApplicationTag: 1369 case ContextMenuItemBaseApplicationTag:
1382 case ContextMenuItemTagDictationAlternative: 1370 case ContextMenuItemTagDictationAlternative:
1383 break; 1371 break;
1384 case ContextMenuItemTagMediaPlayPause: 1372 case ContextMenuItemTagMediaPlayPause:
1385 if (m_hitTestResult.mediaPlaying()) 1373 if (m_hitTestResult.mediaPlaying())
1386 item.setTitle(contextMenuItemTagMediaPause()); 1374 item.setTitle(contextMenuItemTagMediaPause());
1387 else 1375 else
(...skipping 16 matching lines...) Expand all
1404 PlatformMouseEvent mouseEvent(clickPoint, clickPoint, RightButton, PlatformE vent::MousePressed, 1, false, false, false, false, currentTime()); 1392 PlatformMouseEvent mouseEvent(clickPoint, clickPoint, RightButton, PlatformE vent::MousePressed, 1, false, false, false, false, currentTime());
1405 bool handled = frame->eventHandler()->sendContextMenuEvent(mouseEvent); 1393 bool handled = frame->eventHandler()->sendContextMenuEvent(mouseEvent);
1406 if (handled && client()) 1394 if (handled && client())
1407 client()->showContextMenu(); 1395 client()->showContextMenu();
1408 } 1396 }
1409 #endif 1397 #endif
1410 1398
1411 } // namespace WebCore 1399 } // namespace WebCore
1412 1400
1413 #endif // ENABLE(CONTEXT_MENUS) 1401 #endif // ENABLE(CONTEXT_MENUS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698