Changeset 146907 in webkit
- Timestamp:
- Mar 26, 2013 10:58:11 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r146905 r146907 1 2013-03-26 Sergio Villar Senin <svillar@igalia.com> 2 3 Implement overtype mode for editable content 4 https://bugs.webkit.org/show_bug.cgi?id=112126 5 6 Reviewed by Ryosuke Niwa. 7 8 Two new layout tests for the new overtype mode. We use 9 overtype-support.html to check that the Overwrite command is not 10 exported to JavaScript but accessible through Internals. The 11 overtype.html one is used to test the actual behaviour of the 12 command. 13 14 The new command was also added to enabling-and-selection-2.js to 15 check that it is only available for richly editable content. 16 17 * editing/execCommand/enabling-and-selection-2-expected.txt: 18 Updated expectations for OverWrite command. 19 * editing/execCommand/overtype-expected.txt: Added. 20 * editing/execCommand/overtype-support-expected.txt: Added. 21 * editing/execCommand/overtype-support.html: Added. 22 * editing/execCommand/overtype.html: Added. 23 * editing/execCommand/script-tests/enabling-and-selection-2.js: 24 Added a check for OverWrite command. 25 1 26 2013-03-26 Sheriff Bot <webkit.review.bot@gmail.com> 2 27 -
trunk/LayoutTests/editing/execCommand/enabling-and-selection-2-expected.txt
r39114 r146907 84 84 PASS whenEnabled('SelectWord') is 'visible' 85 85 PASS whenEnabled('SetMark') is 'visible' 86 PASS whenEnabled('OverWrite') is 'richly editable' 86 87 PASS successfullyParsed is true 87 88 -
trunk/LayoutTests/editing/execCommand/script-tests/enabling-and-selection-2.js
r120173 r146907 165 165 shouldBe("whenEnabled('SetMark')", "'visible'"); 166 166 167 shouldBe("whenEnabled('OverWrite')", "'richly editable'"); 168 167 169 document.body.removeChild(nonEditableParagraph); 168 170 document.body.removeChild(editableParagraph); -
trunk/Source/WebCore/ChangeLog
r146906 r146907 1 2013-03-26 Sergio Villar Senin <svillar@igalia.com> 2 3 Implement overtype mode for editable content 4 https://bugs.webkit.org/show_bug.cgi?id=112126 5 6 Reviewed by Ryosuke Niwa. 7 8 Tests: editing/execCommand/overtype-support.html 9 editing/execCommand/overtype.html 10 11 Add a new Overwrite command to the editor. This command will 12 perform overtype operations when enabled instead of "normal" text 13 insertions. As IE does, we maintain a single toggle state in the 14 editor (enabled/disabled) for all the editable content in the 15 page. 16 17 This new command will be only available for richly editable 18 content via keybindings or the context menu. For testing purposes 19 it is also accessible via internals. 20 21 * editing/CompositeEditCommand.cpp: 22 (WebCore::CompositeEditCommand::replaceTextInNode): Use RefPtr for 23 local variables. 24 * editing/Editor.cpp: 25 (WebCore::Editor::Editor): 26 * editing/Editor.h: 27 (WebCore::Editor::isOverwriteModeEnabled): 28 (WebCore::Editor::toggleOverwriteModeEnabled): 29 (Editor): Added two new functions and a new attribute. 30 * editing/EditorCommand.cpp: 31 (WebCore::executeToggleOverwrite): Enables/disables overwrite mode. 32 (WebCore): 33 (WebCore::createCommandMap): New OverWrite command. 34 * editing/InsertTextCommand.cpp: 35 (WebCore::InsertTextCommand::setEndingSelectionWithoutValidation): 36 Refactored from performTrivialReplace(), shared by 37 performOverwrite(). 38 (WebCore): 39 (WebCore::InsertTextCommand::performTrivialReplace): 40 (WebCore::InsertTextCommand::performOverwrite): 41 (WebCore::InsertTextCommand::doApply): Perform overwrite if enabled. 42 * editing/InsertTextCommand.h: 43 (InsertTextCommand): 44 * testing/Internals.cpp: 45 (WebCore::Internals::resetToConsistentState): Reset OverWrite mode 46 to false. 47 (WebCore::Internals::isOverwriteModeEnabled): 48 (WebCore): 49 (WebCore::Internals::toggleOverwriteModeEnabled): Provide access 50 to overwrite functionality in Editor for testing purposes. 51 * testing/Internals.h: 52 (Internals): 53 * testing/Internals.idl: 54 1 55 2013-03-26 Arvid Nilsson <anilsson@rim.com> 2 56 -
trunk/Source/WebCore/editing/CompositeEditCommand.cpp
r145754 r146907 501 501 } 502 502 503 void CompositeEditCommand::replaceTextInNode(PassRefPtr<Text> node, unsigned offset, unsigned count, const String& replacementText) 504 { 505 applyCommandToComposite(DeleteFromTextNodeCommand::create(node.get(), offset, count)); 503 void CompositeEditCommand::replaceTextInNode(PassRefPtr<Text> prpNode, unsigned offset, unsigned count, const String& replacementText) 504 { 505 RefPtr<Text> node(prpNode); 506 applyCommandToComposite(DeleteFromTextNodeCommand::create(node, offset, count)); 506 507 if (!replacementText.isEmpty()) 507 508 applyCommandToComposite(InsertIntoTextNodeCommand::create(node, offset, replacementText)); -
trunk/Source/WebCore/editing/Editor.cpp
r146835 r146907 906 906 , m_areMarkedTextMatchesHighlighted(false) 907 907 , m_defaultParagraphSeparator(EditorParagraphSeparatorIsDiv) 908 , m_overwriteModeEnabled(false) 908 909 { 909 910 #if ENABLE(DELETION_UI) -
trunk/Source/WebCore/editing/Editor.h
r146835 r146907 246 246 void markAndReplaceFor(PassRefPtr<SpellCheckRequest>, const Vector<TextCheckingResult>&); 247 247 248 bool isOverwriteModeEnabled() const { return m_overwriteModeEnabled; } 249 void toggleOverwriteModeEnabled() { m_overwriteModeEnabled = !m_overwriteModeEnabled; } 250 248 251 #if USE(APPKIT) 249 252 void uppercaseWord(); … … 434 437 bool m_areMarkedTextMatchesHighlighted; 435 438 EditorParagraphSeparator m_defaultParagraphSeparator; 439 bool m_overwriteModeEnabled; 436 440 437 441 bool canDeleteRange(Range*) const; -
trunk/Source/WebCore/editing/EditorCommand.cpp
r143398 r146907 900 900 { 901 901 applyCommand(IndentOutdentCommand::create(frame->document(), IndentOutdentCommand::Outdent)); 902 return true; 903 } 904 905 static bool executeToggleOverwrite(Frame* frame, Event*, EditorCommandSource, const String&) 906 { 907 frame->editor()->toggleOverwriteModeEnabled(); 902 908 return true; 903 909 } … … 1552 1558 { "MoveWordRightAndModifySelection", { executeMoveWordRightAndModifySelection, supportedFromMenuOrKeyBinding, enabledVisibleSelectionOrCaretBrowsing, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } }, 1553 1559 { "Outdent", { executeOutdent, supported, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } }, 1560 { "OverWrite", { executeToggleOverwrite, supportedFromMenuOrKeyBinding, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } }, 1554 1561 { "Paste", { executePaste, supportedPaste, enabledPaste, stateNone, valueNull, notTextInsertion, allowExecutionWhenDisabled } }, 1555 1562 { "PasteAndMatchStyle", { executePasteAndMatchStyle, supportedPaste, enabledPaste, stateNone, valueNull, notTextInsertion, allowExecutionWhenDisabled } }, … … 1630 1637 // MultipleSelection (not supported) 1631 1638 // Open (not supported) 1632 // Overwrite (not supported)1633 1639 // PlayImage (not supported) 1634 1640 // Refresh (not supported) -
trunk/Source/WebCore/editing/InsertTextCommand.cpp
r144911 r146907 76 76 } 77 77 78 // This avoids the expense of a full fledged delete operation, and avoids a layout that typically results 79 // from text removal. 80 bool InsertTextCommand::performTrivialReplace(const String& text, bool selectInsertedText) 81 { 82 if (!endingSelection().isRange()) 83 return false; 84 85 if (text.contains('\t') || text.contains(' ') || text.contains('\n')) 86 return false; 87 88 Position start = endingSelection().start(); 89 Position endPosition = replaceSelectedTextInNode(text); 90 if (endPosition.isNull()) 91 return false; 92 78 void InsertTextCommand::setEndingSelectionWithoutValidation(const Position& startPosition, const Position& endPosition, bool selectInsertedText) 79 { 93 80 // We could have inserted a part of composed character sequence, 94 81 // so we are basically treating ending selection as a range to avoid validation. 95 82 // <http://bugs.webkit.org/show_bug.cgi?id=15781> 96 83 VisibleSelection forcedEndingSelection; 97 forcedEndingSelection.setWithoutValidation(start , endPosition);84 forcedEndingSelection.setWithoutValidation(startPosition, endPosition); 98 85 forcedEndingSelection.setIsDirectional(endingSelection().isDirectional()); 99 86 setEndingSelection(forcedEndingSelection); … … 101 88 if (!selectInsertedText) 102 89 setEndingSelection(VisibleSelection(endingSelection().visibleEnd(), endingSelection().isDirectional())); 103 90 } 91 92 // This avoids the expense of a full fledged delete operation, and avoids a layout that typically results 93 // from text removal. 94 bool InsertTextCommand::performTrivialReplace(const String& text, bool selectInsertedText) 95 { 96 if (!endingSelection().isRange()) 97 return false; 98 99 if (text.contains('\t') || text.contains(' ') || text.contains('\n')) 100 return false; 101 102 Position start = endingSelection().start(); 103 Position endPosition = replaceSelectedTextInNode(text); 104 if (endPosition.isNull()) 105 return false; 106 107 setEndingSelectionWithoutValidation(start, endPosition, selectInsertedText); 108 109 return true; 110 } 111 112 bool InsertTextCommand::performOverwrite(const String& text, bool selectInsertedText) 113 { 114 Position start = endingSelection().start(); 115 RefPtr<Text> textNode = start.containerText(); 116 if (!textNode) 117 return false; 118 119 unsigned count = std::min(text.length(), textNode->length() - start.offsetInContainerNode()); 120 replaceTextInNode(textNode, start.offsetInContainerNode(), count, text); 121 122 Position endPosition = Position(textNode.release(), start.offsetInContainerNode() + text.length()); 123 setEndingSelectionWithoutValidation(start, endPosition, selectInsertedText); 124 104 125 return true; 105 126 } … … 122 143 // anything other than NoSelection. The rest of this function requires a real endingSelection, so bail out. 123 144 if (endingSelection().isNone()) 145 return; 146 } else if (document()->frame()->editor()->isOverwriteModeEnabled()) { 147 if (performOverwrite(m_text, m_selectInsertedText)) 124 148 return; 125 149 } -
trunk/Source/WebCore/editing/InsertTextCommand.h
r114220 r146907 73 73 74 74 bool performTrivialReplace(const String&, bool selectInsertedText); 75 bool performOverwrite(const String&, bool selectInsertedText); 76 void setEndingSelectionWithoutValidation(const Position& startPosition, const Position& endPosition, bool selectInsertedText); 75 77 76 78 friend class TypingCommand; -
trunk/Source/WebCore/testing/Internals.cpp
r146361 r146907 275 275 if (!page->mainFrame()->editor()->isContinuousSpellCheckingEnabled()) 276 276 page->mainFrame()->editor()->toggleContinuousSpellChecking(); 277 if (page->mainFrame()->editor()->isOverwriteModeEnabled()) 278 page->mainFrame()->editor()->toggleOverwriteModeEnabled(); 277 279 } 278 280 … … 1512 1514 if (enabled != contextDocument()->frame()->editor()->isContinuousSpellCheckingEnabled()) 1513 1515 contextDocument()->frame()->editor()->toggleContinuousSpellChecking(); 1516 } 1517 1518 bool Internals::isOverwriteModeEnabled(Document* document, ExceptionCode&) 1519 { 1520 if (!document || !document->frame()) 1521 return 0; 1522 1523 return document->frame()->editor()->isOverwriteModeEnabled(); 1524 } 1525 1526 void Internals::toggleOverwriteModeEnabled(Document* document, ExceptionCode&) 1527 { 1528 if (!document || !document->frame()) 1529 return; 1530 1531 document->frame()->editor()->toggleOverwriteModeEnabled(); 1514 1532 } 1515 1533 -
trunk/Source/WebCore/testing/Internals.h
r146361 r146907 203 203 void setContinuousSpellCheckingEnabled(bool enabled, ExceptionCode&); 204 204 205 bool isOverwriteModeEnabled(Document*, ExceptionCode&); 206 void toggleOverwriteModeEnabled(Document*, ExceptionCode&); 207 205 208 unsigned numberOfScrollableAreas(Document*, ExceptionCode&); 206 209 -
trunk/Source/WebCore/testing/Internals.idl
r146361 r146907 170 170 void setContinuousSpellCheckingEnabled(in boolean enabled) raises (DOMException); 171 171 172 boolean isOverwriteModeEnabled(in Document document) raises (DOMException); 173 void toggleOverwriteModeEnabled(in Document document) raises (DOMException); 174 172 175 unsigned long numberOfScrollableAreas(in Document document) raises (DOMException); 173 176 -
trunk/Source/WebKit/mac/ChangeLog
r146847 r146907 1 2013-03-26 Sergio Villar Senin <svillar@igalia.com> 2 3 Implement overtype mode for editable content 4 https://bugs.webkit.org/show_bug.cgi?id=112126 5 6 Reviewed by Ryosuke Niwa. 7 8 Added the OverWrite editing command to the WebCore editing 9 commands lists. 10 11 * WebView/WebHTMLView.mm: 12 * WebView/WebView.h: 13 * WebView/WebView.mm: 14 1 15 2013-03-25 Kent Tamura <tkent@chromium.org> 2 16 -
trunk/Source/WebKit/mac/WebView/WebHTMLView.mm
r143863 r146907 2503 2503 WEBCORE_COMMAND(moveWordRightAndModifySelection) 2504 2504 WEBCORE_COMMAND(outdent) 2505 WEBCORE_COMMAND(overWrite) 2505 2506 WEBCORE_COMMAND(pageDown) 2506 2507 WEBCORE_COMMAND(pageDownAndModifySelection) -
trunk/Source/WebKit/mac/WebView/WebView.h
r93258 r146907 756 756 - (void)moveToEndOfSentenceAndModifySelection:(id)sender; 757 757 - (void)selectSentence:(id)sender; 758 759 - (void)overWrite:(id)sender; 758 760 759 761 /* -
trunk/Source/WebKit/mac/WebView/WebView.mm
r146704 r146907 321 321 macro(moveWordRight) \ 322 322 macro(moveWordRightAndModifySelection) \ 323 macro(orderFrontSubstitutionsPanel) \ 323 324 macro(outdent) \ 324 macro(o rderFrontSubstitutionsPanel) \325 macro(overWrite) \ 325 326 macro(pageDown) \ 326 327 macro(pageDownAndModifySelection) \
Note: See TracChangeset
for help on using the changeset viewer.