Changeset 74580 in webkit
- Timestamp:
- Dec 23, 2010 2:20:43 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r74579 r74580 1 2010-12-23 Darin Adler <darin@apple.com> 2 3 Reviewed by Sam Weinig. 4 5 WKView should not try to do asynchronous validation for selectors that are not editor commands 6 https://bugs.webkit.org/show_bug.cgi?id=51555 7 8 * WebCore.exp.in: Added commandIsSupportedFromMenuOrKeyBinding. 9 * editing/Editor.h: Reordered arguments in the Editor::Command constructor 10 and the data members too so the frame is last. Added 11 commandIsSupportedFromMenuOrKeyBinding. 12 13 * editing/EditorCommand.cpp: 14 (WebCore::supported): Removed the EditorCommandSource argument. These 15 functions are now only used when called from DOM. 16 (WebCore::supportedFromMenuOrKeyBinding): Ditto. 17 (WebCore::supportedCopyCut): Ditto. 18 (WebCore::supportedPaste): Ditto. 19 (WebCore::enabledDismissCorrectionPanel): Changed the supported function to 20 an enabled function. It was incorrect to say that this is "supported" only 21 when the correction panel is up. Correct to say that it is "enabled" only 22 then. And also probably OK to enable it even when the selection is not in 23 editable text, as long as the panel is up. 24 (WebCore::createCommandMap): Moved conditional commands out of the main 25 array into a separate section at the end. 26 (WebCore::internalCommand): Added. 27 (WebCore::Editor::command): Changed to use the new internalCommand function 28 and simplified by relying on the null check in the Command constructor. 29 (WebCore::Editor::commandIsSupportedFromMenuOrKeyBinding): Added. 30 (WebCore::Editor::Command::Command): Removed unneeded initialization of 31 m_source, which is never looked at if m_command is 0. Added feature of 32 passing a null command pointer to the non-default constructor. 33 (WebCore::Editor::Command::isSupported): Changed to only call the 34 per-command isSupported function when the command source is DOM. 35 Accordingly that function is now called isSupportedFromDOM. 36 1 37 2010-12-23 Matthew Delaney <mdelaney@apple.com> 2 38 -
trunk/WebCore/WebCore.exp.in
r74566 r74580 716 716 __ZN7WebCore6Editor35increaseSelectionListLevelUnorderedEv 717 717 __ZN7WebCore6Editor35setIgnoreCompositionSelectionChangeEb 718 __ZN7WebCore6Editor38commandIsSupportedFromMenuOrKeyBindingERKN3WTF6StringE 718 719 __ZN7WebCore6Editor3cutEv 719 720 __ZN7WebCore6Editor44confirmCompositionWithoutDisturbingSelectionEv -
trunk/WebCore/editing/Editor.h
r74566 r74580 176 176 public: 177 177 Command(); 178 Command( PassRefPtr<Frame>, const EditorInternalCommand*, EditorCommandSource);178 Command(const EditorInternalCommand*, EditorCommandSource, PassRefPtr<Frame>); 179 179 180 180 bool execute(const String& parameter = String(), Event* triggeringEvent = 0) const; … … 190 190 191 191 private: 192 RefPtr<Frame> m_frame;193 192 const EditorInternalCommand* m_command; 194 193 EditorCommandSource m_source; 194 RefPtr<Frame> m_frame; 195 195 }; 196 Command command(const String& commandName); // Defaultis CommandFromMenuOrKeyBinding.196 Command command(const String& commandName); // Command source is CommandFromMenuOrKeyBinding. 197 197 Command command(const String& commandName, EditorCommandSource); 198 static bool commandIsSupportedFromMenuOrKeyBinding(const String& commandName); // Works without a frame. 198 199 199 200 bool insertText(const String&, Event* triggeringEvent); -
trunk/WebCore/editing/EditorCommand.cpp
r74566 r74580 67 67 public: 68 68 bool (*execute)(Frame*, Event*, EditorCommandSource, const String&); 69 bool (*isSupported )(Frame*, EditorCommandSource);69 bool (*isSupportedFromDOM)(Frame*); 70 70 bool (*isEnabled)(Frame*, Event*, EditorCommandSource); 71 71 TriState (*state)(Frame*, Event*); … … 1089 1089 // Supported functions 1090 1090 1091 static bool supported(Frame*, EditorCommandSource) 1092 { 1093 return true; 1094 } 1095 1096 static bool supportedFromMenuOrKeyBinding(Frame*, EditorCommandSource source) 1097 { 1098 return source == CommandFromMenuOrKeyBinding; 1099 } 1100 1101 static bool supportedCopyCut(Frame* frame, EditorCommandSource source) 1102 { 1103 switch (source) { 1104 case CommandFromMenuOrKeyBinding: 1105 return true; 1106 case CommandFromDOM: 1107 case CommandFromDOMWithUserInterface: { 1108 Settings* settings = frame ? frame->settings() : 0; 1109 return settings && settings->javaScriptCanAccessClipboard(); 1110 } 1111 } 1112 ASSERT_NOT_REACHED(); 1091 static bool supported(Frame*) 1092 { 1093 return true; 1094 } 1095 1096 static bool supportedFromMenuOrKeyBinding(Frame*) 1097 { 1113 1098 return false; 1114 1099 } 1115 1100 1116 static bool supportedPaste(Frame* frame, EditorCommandSource source) 1117 { 1118 switch (source) { 1119 case CommandFromMenuOrKeyBinding: 1120 return true; 1121 case CommandFromDOM: 1122 case CommandFromDOMWithUserInterface: { 1123 Settings* settings = frame ? frame->settings() : 0; 1124 return settings && (settings->javaScriptCanAccessClipboard() ? settings->isDOMPasteAllowed() : 0); 1125 } 1126 } 1127 ASSERT_NOT_REACHED(); 1128 return false; 1129 } 1130 1131 #if SUPPORT_AUTOCORRECTION_PANEL 1132 static bool supportedDismissCorrectionPanel(Frame* frame, EditorCommandSource source) 1133 { 1134 return supportedFromMenuOrKeyBinding(frame, source) && frame->editor()->isShowingCorrectionPanel(); 1135 } 1136 #endif 1101 static bool supportedCopyCut(Frame* frame) 1102 { 1103 Settings* settings = frame ? frame->settings() : 0; 1104 return settings && settings->javaScriptCanAccessClipboard(); 1105 } 1106 1107 static bool supportedPaste(Frame* frame) 1108 { 1109 Settings* settings = frame ? frame->settings() : 0; 1110 return settings && (settings->javaScriptCanAccessClipboard() ? settings->isDOMPasteAllowed() : 0); 1111 } 1137 1112 1138 1113 // Enabled functions … … 1249 1224 return frame->editor()->canUndo(); 1250 1225 } 1226 1227 #if SUPPORT_AUTOCORRECTION_PANEL 1228 static bool enabledDismissCorrectionPanel(Frame* frame, EditorCommandSource source) 1229 { 1230 return frame->editor()->isShowingCorrectionPanel(); 1231 } 1232 #endif 1251 1233 1252 1234 // State functions … … 1507 1489 { "Superscript", { executeSuperscript, supported, enabledInRichlyEditableText, stateSuperscript, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } }, 1508 1490 { "SwapWithMark", { executeSwapWithMark, supportedFromMenuOrKeyBinding, enabledVisibleSelectionAndMark, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } }, 1509 #if PLATFORM(MAC)1510 { "TakeFindStringFromSelection", { executeTakeFindStringFromSelection, supportedFromMenuOrKeyBinding, enabledTakeFindStringFromSelection, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },1511 #endif1512 1491 { "ToggleBold", { executeToggleBold, supportedFromMenuOrKeyBinding, enabledInRichlyEditableText, stateBold, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } }, 1513 1492 { "ToggleItalic", { executeToggleItalic, supportedFromMenuOrKeyBinding, enabledInRichlyEditableText, stateItalic, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } }, … … 1521 1500 { "Yank", { executeYank, supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } }, 1522 1501 { "YankAndSelect", { executeYankAndSelect, supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } }, 1502 1503 #if PLATFORM(MAC) 1504 { "TakeFindStringFromSelection", { executeTakeFindStringFromSelection, supportedFromMenuOrKeyBinding, enabledTakeFindStringFromSelection, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } }, 1505 #endif 1506 1523 1507 #if SUPPORT_AUTOCORRECTION_PANEL 1524 { "CancelOperation", { executeCancelOperation, supported DismissCorrectionPanel, enabledInEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },1508 { "CancelOperation", { executeCancelOperation, supportedFromMenuOrKeyBinding, enabledDismissCorrectionPanel, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } }, 1525 1509 #endif 1526 1510 }; … … 1583 1567 } 1584 1568 1569 static const EditorInternalCommand* internalCommand(const String& commandName) 1570 { 1571 static const CommandMap& commandMap = createCommandMap(); 1572 return commandMap.get(commandName); 1573 } 1574 1585 1575 Editor::Command Editor::command(const String& commandName) 1586 1576 { 1587 return command(commandName, CommandFromMenuOrKeyBinding);1577 return Command(internalCommand(commandName), CommandFromMenuOrKeyBinding, m_frame); 1588 1578 } 1589 1579 1590 1580 Editor::Command Editor::command(const String& commandName, EditorCommandSource source) 1591 1581 { 1592 if (commandName.isEmpty())1593 return Command(); 1594 1595 static const CommandMap& commandMap = createCommandMap(); 1596 const EditorInternalCommand* internalCommand = commandMap.get(commandName); 1597 return internalCommand ? Command(m_frame, internalCommand, source) : Command();1582 return Command(internalCommand(commandName), source, m_frame); 1583 } 1584 1585 bool Editor::commandIsSupportedFromMenuOrKeyBinding(const String& commandName) 1586 { 1587 return internalCommand(commandName); 1598 1588 } 1599 1589 1600 1590 Editor::Command::Command() 1601 1591 : m_command(0) 1602 , m_source() 1603 { 1604 } 1605 1606 Editor::Command::Command(PassRefPtr<Frame> frame, const EditorInternalCommand* command, EditorCommandSource source) 1607 : m_frame(frame) 1608 , m_command(command) 1592 { 1593 } 1594 1595 Editor::Command::Command(const EditorInternalCommand* command, EditorCommandSource source, PassRefPtr<Frame> frame) 1596 : m_command(command) 1609 1597 , m_source(source) 1610 { 1611 ASSERT(m_frame); 1612 ASSERT(m_command); 1598 , m_frame(command ? frame : 0) 1599 { 1600 // Use separate assertions so we can tell which bad thing happened. 1601 if (!command) 1602 ASSERT(!m_frame); 1603 else 1604 ASSERT(m_frame); 1613 1605 } 1614 1606 … … 1631 1623 bool Editor::Command::isSupported() const 1632 1624 { 1633 return m_command && m_command->isSupported(m_frame.get(), m_source); 1625 if (!m_command) 1626 return false; 1627 switch (m_source) { 1628 case CommandFromMenuOrKeyBinding: 1629 return true; 1630 case CommandFromDOM: 1631 case CommandFromDOMWithUserInterface: 1632 return m_command->isSupportedFromDOM(m_frame.get()); 1633 } 1634 ASSERT_NOT_REACHED(); 1635 return false; 1634 1636 } 1635 1637 -
trunk/WebKit2/ChangeLog
r74575 r74580 1 2010-12-23 Darin Adler <darin@apple.com> 2 3 Reviewed by Sam Weinig. 4 5 WKView should not try to do asynchronous validation for selectors that are not editor commands 6 https://bugs.webkit.org/show_bug.cgi?id=51555 7 8 * UIProcess/API/mac/WKView.mm: 9 (-[WKView validateUserInterfaceItem:]): Removed the special case for startSpeaking. 10 Added call to commandIsSupportedFromMenuOrKeyBinding so we only try to do validation 11 for commands that are supported. Tweaked comments and added some bug numbers. 12 (-[WKView _setUserInterfaceItemState:enabled:state:]): Tweaked comment and added 13 bug number. 14 1 15 2010-12-23 Sam Weinig <sam@webkit.org> 2 16 -
trunk/WebKit2/UIProcess/API/mac/WKView.mm
r74521 r74580 336 336 SEL action = [item action]; 337 337 338 // FIXME: This is only needed to work around the fact that we don't return YES for339 // selectors that are not editing commands (see below). If that's fixed, this can be removed.340 if (action == @selector(startSpeaking:))341 return YES;342 343 338 if (action == @selector(stopSpeaking:)) 344 339 return [NSApp isSpeaking]; … … 357 352 } 358 353 359 // FIXME: We should return YES here for selectors that are not editing commands. 360 // But at the moment there is no way to find out if a selector is an editing command or not 361 // in the UI process. So for now we assume any selectors not handled above are editing commands. 362 354 // Next, handle editor commands. Start by returning YES for anything that is not an editor command. 355 // Returning YES is the default thing to do in an AppKit validate method for any selector that is not recognized. 363 356 String commandName = commandNameForSelector([item action]); 364 if ( commandName.isEmpty())357 if (!Editor::commandIsSupportedFromMenuOrKeyBinding(commandName)) 365 358 return YES; 366 359 367 // Add this menu item to the vector of items for a given command that are awaiting validation. 368 // If the item is the first to be added, then call validateMenuItem to start the asynchronous 369 // validation process. 360 // Add this item to the vector of items for a given command that are awaiting validation. 370 361 pair<ValidationMap::iterator, bool> addResult = _data->_validationMap.add(commandName, ValidationVector()); 371 362 addResult.first->second.append(item); 372 363 if (addResult.second) { 373 // FIXME: The function should be renamed validateCommand because it is not specific to menu items. 364 // If we are not already awaiting validation for this command, start the asynchronous validation process. 365 // FIXME: Theoretically, there is a race here; when we get the answer it might be old, from a previous time 366 // we asked for the same command; there is no guarantee the answer is still valid. 367 // FIXME: The function called here should be renamed validateCommand because it is not specific to menu items. 374 368 _data->_page->validateMenuItem(commandName); 375 369 } 376 370 377 371 // Treat as enabled until we get the result back from the web process and _setUserInterfaceItemState is called. 378 // FIXME : This means that items will flash enabled at first, and only then disable a moment later, which is unattractive.379 // But returning NO here is worse, because that makeskeyboard commands such as command-C fail.372 // FIXME <rdar://problem/8803459>: This means disabled items will flash enabled at first for a moment. 373 // But returning NO here would be worse; that would make keyboard commands such as command-C fail. 380 374 return YES; 381 375 } … … 989 983 [menuItem(item) setEnabled:isEnabled]; 990 984 [toolbarItem(item) setEnabled:isEnabled]; 991 // FIXME: If the user interface item is neither a menu item nor a toolbar, it will be left enabled. 992 // It's not obvious how to fix this. 985 // FIXME <rdar://problem/8803392>: If the item is neither a menu nor toolbar item, it will be left enabled. 993 986 } 994 987 }
Note: See TracChangeset
for help on using the changeset viewer.