| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1044 command.replace(0, 1, command.substring(0, 1).upper()); | 1044 command.replace(0, 1, command.substring(0, 1).upper()); |
| 1045 | 1045 |
| 1046 // Remove the trailing ':' if existing. | 1046 // Remove the trailing ':' if existing. |
| 1047 if (command[command.length() - 1] == UChar(':')) | 1047 if (command[command.length() - 1] == UChar(':')) |
| 1048 command = command.substring(0, command.length() - 1); | 1048 command = command.substring(0, command.length() - 1); |
| 1049 | 1049 |
| 1050 WebPluginContainerImpl* pluginContainer = pluginContainerFromNode(frame(), n
ode); | 1050 WebPluginContainerImpl* pluginContainer = pluginContainerFromNode(frame(), n
ode); |
| 1051 if (pluginContainer && pluginContainer->executeEditCommand(name)) | 1051 if (pluginContainer && pluginContainer->executeEditCommand(name)) |
| 1052 return true; | 1052 return true; |
| 1053 | 1053 |
| 1054 bool result = true; | 1054 return frame()->editor().executeCommand(command); |
| 1055 | |
| 1056 // Specially handling commands that Editor::execCommand does not directly | |
| 1057 // support. | |
| 1058 if (command == "DeleteToEndOfParagraph") { | |
| 1059 if (!frame()->editor().deleteWithDirection(DirectionForward, ParagraphBo
undary, true, false)) | |
| 1060 frame()->editor().deleteWithDirection(DirectionForward, CharacterGra
nularity, true, false); | |
| 1061 } else if (command == "DeleteBackward") { | |
| 1062 result = frame()->editor().command(AtomicString("BackwardDelete")).execu
te(); | |
| 1063 } else if (command == "DeleteForward") { | |
| 1064 result = frame()->editor().command(AtomicString("ForwardDelete")).execut
e(); | |
| 1065 } else if (command == "AdvanceToNextMisspelling") { | |
| 1066 // Wee need to pass false here or else the currently selected word will
never be skipped. | |
| 1067 frame()->spellChecker().advanceToNextMisspelling(false); | |
| 1068 } else if (command == "ToggleSpellPanel") { | |
| 1069 frame()->spellChecker().showSpellingGuessPanel(); | |
| 1070 } else { | |
| 1071 result = frame()->editor().command(command).execute(); | |
| 1072 } | |
| 1073 return result; | |
| 1074 } | 1055 } |
| 1075 | 1056 |
| 1076 bool WebLocalFrameImpl::executeCommand(const WebString& name, const WebString& v
alue, const WebNode& node) | 1057 bool WebLocalFrameImpl::executeCommand(const WebString& name, const WebString& v
alue, const WebNode& node) |
| 1077 { | 1058 { |
| 1078 ASSERT(frame()); | 1059 ASSERT(frame()); |
| 1079 String webName = name; | |
| 1080 | 1060 |
| 1081 WebPluginContainerImpl* pluginContainer = pluginContainerFromNode(frame(), n
ode); | 1061 WebPluginContainerImpl* pluginContainer = pluginContainerFromNode(frame(), n
ode); |
| 1082 if (pluginContainer && pluginContainer->executeEditCommand(name, value)) | 1062 if (pluginContainer && pluginContainer->executeEditCommand(name, value)) |
| 1083 return true; | 1063 return true; |
| 1084 | 1064 |
| 1085 // moveToBeginningOfDocument and moveToEndfDocument are only handled by WebK
it for editable nodes. | 1065 return frame()->editor().executeCommand(name, value); |
| 1086 if (!frame()->editor().canEdit() && webName == "moveToBeginningOfDocument") | |
| 1087 return viewImpl()->bubblingScroll(ScrollUp, ScrollByDocument); | |
| 1088 | |
| 1089 if (!frame()->editor().canEdit() && webName == "moveToEndOfDocument") | |
| 1090 return viewImpl()->bubblingScroll(ScrollDown, ScrollByDocument); | |
| 1091 | |
| 1092 if (webName == "showGuessPanel") { | |
| 1093 frame()->spellChecker().showSpellingGuessPanel(); | |
| 1094 return true; | |
| 1095 } | |
| 1096 | |
| 1097 return frame()->editor().command(webName).execute(value); | |
| 1098 } | 1066 } |
| 1099 | 1067 |
| 1100 bool WebLocalFrameImpl::isCommandEnabled(const WebString& name) const | 1068 bool WebLocalFrameImpl::isCommandEnabled(const WebString& name) const |
| 1101 { | 1069 { |
| 1102 ASSERT(frame()); | 1070 ASSERT(frame()); |
| 1103 return frame()->editor().command(name).isEnabled(); | 1071 return frame()->editor().command(name).isEnabled(); |
| 1104 } | 1072 } |
| 1105 | 1073 |
| 1106 void WebLocalFrameImpl::enableContinuousSpellChecking(bool enable) | 1074 void WebLocalFrameImpl::enableContinuousSpellChecking(bool enable) |
| 1107 { | 1075 { |
| (...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1890 { | 1858 { |
| 1891 RefPtr<LocalFrame> frame = LocalFrame::create(&m_frameLoaderClientImpl, host
, owner); | 1859 RefPtr<LocalFrame> frame = LocalFrame::create(&m_frameLoaderClientImpl, host
, owner); |
| 1892 setWebCoreFrame(frame); | 1860 setWebCoreFrame(frame); |
| 1893 frame->tree().setName(name, fallbackName); | 1861 frame->tree().setName(name, fallbackName); |
| 1894 // May dispatch JS events; frame may be detached after this. | 1862 // May dispatch JS events; frame may be detached after this. |
| 1895 frame->init(); | 1863 frame->init(); |
| 1896 return frame; | 1864 return frame; |
| 1897 } | 1865 } |
| 1898 | 1866 |
| 1899 } // namespace blink | 1867 } // namespace blink |
| OLD | NEW |