OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
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 28 matching lines...) Expand all Loading... |
39 #include "core/dom/AXObjectCache.h" | 39 #include "core/dom/AXObjectCache.h" |
40 #include "core/dom/DocumentFragment.h" | 40 #include "core/dom/DocumentFragment.h" |
41 #include "core/dom/ElementTraversal.h" | 41 #include "core/dom/ElementTraversal.h" |
42 #include "core/dom/NodeTraversal.h" | 42 #include "core/dom/NodeTraversal.h" |
43 #include "core/dom/ParserContentPolicy.h" | 43 #include "core/dom/ParserContentPolicy.h" |
44 #include "core/dom/Text.h" | 44 #include "core/dom/Text.h" |
45 #include "core/editing/EditingStyleUtilities.h" | 45 #include "core/editing/EditingStyleUtilities.h" |
46 #include "core/editing/EditingUtilities.h" | 46 #include "core/editing/EditingUtilities.h" |
47 #include "core/editing/InputMethodController.h" | 47 #include "core/editing/InputMethodController.h" |
48 #include "core/editing/RenderedPosition.h" | 48 #include "core/editing/RenderedPosition.h" |
| 49 #include "core/editing/TextSuggestionController.h" |
49 #include "core/editing/VisibleUnits.h" | 50 #include "core/editing/VisibleUnits.h" |
50 #include "core/editing/commands/ApplyStyleCommand.h" | 51 #include "core/editing/commands/ApplyStyleCommand.h" |
51 #include "core/editing/commands/DeleteSelectionCommand.h" | 52 #include "core/editing/commands/DeleteSelectionCommand.h" |
52 #include "core/editing/commands/IndentOutdentCommand.h" | 53 #include "core/editing/commands/IndentOutdentCommand.h" |
53 #include "core/editing/commands/InsertListCommand.h" | 54 #include "core/editing/commands/InsertListCommand.h" |
54 #include "core/editing/commands/RemoveFormatCommand.h" | 55 #include "core/editing/commands/RemoveFormatCommand.h" |
55 #include "core/editing/commands/ReplaceSelectionCommand.h" | 56 #include "core/editing/commands/ReplaceSelectionCommand.h" |
56 #include "core/editing/commands/SimplifyMarkupCommand.h" | 57 #include "core/editing/commands/SimplifyMarkupCommand.h" |
57 #include "core/editing/commands/TypingCommand.h" | 58 #include "core/editing/commands/TypingCommand.h" |
58 #include "core/editing/commands/UndoStack.h" | 59 #include "core/editing/commands/UndoStack.h" |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 return hasEditableStyle(*startContainer) && hasEditableStyle(*endContainer); | 757 return hasEditableStyle(*startContainer) && hasEditableStyle(*endContainer); |
757 } | 758 } |
758 | 759 |
759 void Editor::respondToChangedContents(const Position& position) { | 760 void Editor::respondToChangedContents(const Position& position) { |
760 if (frame().settings() && frame().settings()->getAccessibilityEnabled()) { | 761 if (frame().settings() && frame().settings()->getAccessibilityEnabled()) { |
761 Node* node = position.anchorNode(); | 762 Node* node = position.anchorNode(); |
762 if (AXObjectCache* cache = frame().document()->existingAXObjectCache()) | 763 if (AXObjectCache* cache = frame().document()->existingAXObjectCache()) |
763 cache->handleEditableTextContentChanged(node); | 764 cache->handleEditableTextContentChanged(node); |
764 } | 765 } |
765 | 766 |
766 spellChecker().respondToChangedContents(); | 767 spellChecker().updateMarkersForWordsAffectedByEditing(true); |
| 768 frame().textSuggestionController().removeSuggestionMarkersAffectedByEditing( |
| 769 true); |
767 client().respondToChangedContents(); | 770 client().respondToChangedContents(); |
768 } | 771 } |
769 | 772 |
770 void Editor::removeFormattingAndStyle() { | 773 void Editor::removeFormattingAndStyle() { |
771 DCHECK(frame().document()); | 774 DCHECK(frame().document()); |
772 RemoveFormatCommand::create(*frame().document())->apply(); | 775 RemoveFormatCommand::create(*frame().document())->apply(); |
773 } | 776 } |
774 | 777 |
775 void Editor::registerCommandGroup(CompositeEditCommand* commandGroupWrapper) { | 778 void Editor::registerCommandGroup(CompositeEditCommand* commandGroupWrapper) { |
776 DCHECK(commandGroupWrapper->isCommandGroupWrapper()); | 779 DCHECK(commandGroupWrapper->isCommandGroupWrapper()); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 bool selectInsertedText, | 1040 bool selectInsertedText, |
1038 TextEvent* triggeringEvent, | 1041 TextEvent* triggeringEvent, |
1039 InputEvent::InputType inputType) { | 1042 InputEvent::InputType inputType) { |
1040 if (text.isEmpty()) | 1043 if (text.isEmpty()) |
1041 return false; | 1044 return false; |
1042 | 1045 |
1043 const VisibleSelection& selection = selectionForCommand(triggeringEvent); | 1046 const VisibleSelection& selection = selectionForCommand(triggeringEvent); |
1044 if (!selection.isContentEditable()) | 1047 if (!selection.isContentEditable()) |
1045 return false; | 1048 return false; |
1046 | 1049 |
| 1050 bool firstCharIsSpaceOrNewline = isSpaceOrNewline(text[0]); |
1047 spellChecker().updateMarkersForWordsAffectedByEditing( | 1051 spellChecker().updateMarkersForWordsAffectedByEditing( |
1048 isSpaceOrNewline(text[0])); | 1052 firstCharIsSpaceOrNewline); |
| 1053 frame().textSuggestionController().removeSuggestionMarkersAffectedByEditing( |
| 1054 firstCharIsSpaceOrNewline); |
1049 | 1055 |
1050 // Insert the text | 1056 // Insert the text |
1051 TypingCommand::insertText( | 1057 TypingCommand::insertText( |
1052 *selection.start().document(), text, selection.asSelection(), | 1058 *selection.start().document(), text, selection.asSelection(), |
1053 selectInsertedText ? TypingCommand::SelectInsertedText : 0, | 1059 selectInsertedText ? TypingCommand::SelectInsertedText : 0, |
1054 triggeringEvent && triggeringEvent->isComposition() | 1060 triggeringEvent && triggeringEvent->isComposition() |
1055 ? TypingCommand::TextCompositionConfirm | 1061 ? TypingCommand::TextCompositionConfirm |
1056 : TypingCommand::TextCompositionNone, | 1062 : TypingCommand::TextCompositionNone, |
1057 false, inputType); | 1063 false, inputType); |
1058 | 1064 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 | 1125 |
1120 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | 1126 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
1121 // needs to be audited. See http://crbug.com/590369 for more details. | 1127 // needs to be audited. See http://crbug.com/590369 for more details. |
1122 // |tryDHTMLCut| dispatches cut event, which may make layout dirty, but we | 1128 // |tryDHTMLCut| dispatches cut event, which may make layout dirty, but we |
1123 // need clean layout to obtain the selected content. | 1129 // need clean layout to obtain the selected content. |
1124 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 1130 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
1125 | 1131 |
1126 // TODO(yosin) We should use early return style here. | 1132 // TODO(yosin) We should use early return style here. |
1127 if (canDeleteRange(selectedRange())) { | 1133 if (canDeleteRange(selectedRange())) { |
1128 spellChecker().updateMarkersForWordsAffectedByEditing(true); | 1134 spellChecker().updateMarkersForWordsAffectedByEditing(true); |
| 1135 frame().textSuggestionController().removeSuggestionMarkersAffectedByEditing( |
| 1136 true); |
1129 if (enclosingTextControl(frame() | 1137 if (enclosingTextControl(frame() |
1130 .selection() | 1138 .selection() |
1131 .computeVisibleSelectionInDOMTreeDeprecated() | 1139 .computeVisibleSelectionInDOMTreeDeprecated() |
1132 .start())) { | 1140 .start())) { |
1133 String plainText = frame().selectedTextForClipboard(); | 1141 String plainText = frame().selectedTextForClipboard(); |
1134 Pasteboard::generalPasteboard()->writePlainText( | 1142 Pasteboard::generalPasteboard()->writePlainText( |
1135 plainText, canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace | 1143 plainText, canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace |
1136 : Pasteboard::CannotSmartReplace); | 1144 : Pasteboard::CannotSmartReplace); |
1137 } else { | 1145 } else { |
1138 writeSelectionToPasteboard(); | 1146 writeSelectionToPasteboard(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 } | 1193 } |
1186 } | 1194 } |
1187 | 1195 |
1188 void Editor::paste(EditorCommandSource source) { | 1196 void Editor::paste(EditorCommandSource source) { |
1189 DCHECK(frame().document()); | 1197 DCHECK(frame().document()); |
1190 if (tryDHTMLPaste(AllMimeTypes)) | 1198 if (tryDHTMLPaste(AllMimeTypes)) |
1191 return; // DHTML did the whole operation | 1199 return; // DHTML did the whole operation |
1192 if (!canPaste()) | 1200 if (!canPaste()) |
1193 return; | 1201 return; |
1194 spellChecker().updateMarkersForWordsAffectedByEditing(false); | 1202 spellChecker().updateMarkersForWordsAffectedByEditing(false); |
| 1203 frame().textSuggestionController().removeSuggestionMarkersAffectedByEditing( |
| 1204 false); |
1195 ResourceFetcher* loader = frame().document()->fetcher(); | 1205 ResourceFetcher* loader = frame().document()->fetcher(); |
1196 ResourceCacheValidationSuppressor validationSuppressor(loader); | 1206 ResourceCacheValidationSuppressor validationSuppressor(loader); |
1197 | 1207 |
1198 PasteMode pasteMode = frame().selection() | 1208 PasteMode pasteMode = frame().selection() |
1199 .computeVisibleSelectionInDOMTreeDeprecated() | 1209 .computeVisibleSelectionInDOMTreeDeprecated() |
1200 .isContentRichlyEditable() | 1210 .isContentRichlyEditable() |
1201 ? AllMimeTypes | 1211 ? AllMimeTypes |
1202 : PlainTextOnly; | 1212 : PlainTextOnly; |
1203 | 1213 |
1204 if (source == CommandFromMenuOrKeyBinding) { | 1214 if (source == CommandFromMenuOrKeyBinding) { |
(...skipping 16 matching lines...) Expand all Loading... |
1221 else | 1231 else |
1222 pasteAsPlainTextWithPasteboard(Pasteboard::generalPasteboard()); | 1232 pasteAsPlainTextWithPasteboard(Pasteboard::generalPasteboard()); |
1223 } | 1233 } |
1224 | 1234 |
1225 void Editor::pasteAsPlainText(EditorCommandSource source) { | 1235 void Editor::pasteAsPlainText(EditorCommandSource source) { |
1226 if (tryDHTMLPaste(PlainTextOnly)) | 1236 if (tryDHTMLPaste(PlainTextOnly)) |
1227 return; | 1237 return; |
1228 if (!canPaste()) | 1238 if (!canPaste()) |
1229 return; | 1239 return; |
1230 spellChecker().updateMarkersForWordsAffectedByEditing(false); | 1240 spellChecker().updateMarkersForWordsAffectedByEditing(false); |
| 1241 frame().textSuggestionController().removeSuggestionMarkersAffectedByEditing( |
| 1242 false); |
1231 pasteAsPlainTextWithPasteboard(Pasteboard::generalPasteboard()); | 1243 pasteAsPlainTextWithPasteboard(Pasteboard::generalPasteboard()); |
1232 } | 1244 } |
1233 | 1245 |
1234 void Editor::performDelete() { | 1246 void Editor::performDelete() { |
1235 if (!canDelete()) | 1247 if (!canDelete()) |
1236 return; | 1248 return; |
1237 | 1249 |
1238 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | 1250 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
1239 // needs to be audited. See http://crbug.com/590369 for more details. | 1251 // needs to be audited. See http://crbug.com/590369 for more details. |
1240 // |selectedRange| requires clean layout for visible selection normalization. | 1252 // |selectedRange| requires clean layout for visible selection normalization. |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1795 | 1807 |
1796 DEFINE_TRACE(Editor) { | 1808 DEFINE_TRACE(Editor) { |
1797 visitor->trace(m_frame); | 1809 visitor->trace(m_frame); |
1798 visitor->trace(m_lastEditCommand); | 1810 visitor->trace(m_lastEditCommand); |
1799 visitor->trace(m_undoStack); | 1811 visitor->trace(m_undoStack); |
1800 visitor->trace(m_mark); | 1812 visitor->trace(m_mark); |
1801 visitor->trace(m_typingStyle); | 1813 visitor->trace(m_typingStyle); |
1802 } | 1814 } |
1803 | 1815 |
1804 } // namespace blink | 1816 } // namespace blink |
OLD | NEW |