Changeset 78632 in webkit
- Timestamp:
- Feb 15, 2011 3:44:13 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 5 added
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r78630 r78632 1 2011-02-15 Jia Pu <jpu@apple.com> 2 3 Reviewed by Darin Adler. 4 5 Autocorrection should respect undo. 6 https://bugs.webkit.org/show_bug.cgi?id=52221 7 <rdar://problem/8663399> 8 9 Manual test: manual-tests/autocorrection/undo-autocorrection.html 10 11 When user undoes an autocorrection, we need to do four things: 12 1. Revert the change in text that has been made by correction. 13 2. Revert the selection to pre-correction state so that user can immediately continue typing. 14 3. Add appropriate markers to reverted text so that it won't be corrected again and/or shown 15 as misspelled. 16 4. If applicable, notify spell checking service to record this reversion. 17 18 To achieve these, this patch introduces following changes: 19 1. Created SpellingCorrectionCommand so that correction can be undone in similar way as any 20 other editing command. SpellingCorrectionCommand is a composition of SetSelectionCommand, 21 SpellingCorrectionRecordUndoCommand and ReplaceSelectionCommand. 22 2. Created SetSelectionCommand so that undo command can restore selection state. 23 3. Added member function recordAutocorrectionResponse() to editor client. 24 25 To improve readability, this patch also consolidates various boolean arguments in SelectionController::setSelection() 26 and ReplaceSelectionCommand::ReplaceSelectionCommand(). These boolean arguments have been 27 replaced by enum variable. 28 29 * WebCore.exp.in: Updated for changes in Editor and ReplaceSelectionCommand. 30 31 * WebCore.xcodeproj/project.pbxproj: Updated for new source files. 32 33 * editing/CompositeEditCommand.cpp: 34 (WebCore::CompositeEditCommand::moveParagraphs): Adopted new signature of ReplaceSelectionCommand::create(). 35 36 * editing/Editor.cpp: 37 (WebCore::Editor::replaceSelectionWithFragment): Ditto. 38 (WebCore::Editor::unappliedEditing): Cleaned up trailing whitespace. 39 (WebCore::Editor::reappliedEditing): Ditto. 40 (WebCore::Editor::selectComposition): Adopted new signature of SelectionController::setSelection(). 41 (WebCore::Editor::confirmComposition): Ditto. 42 (WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges): Rearranged code to reduce the 43 level of deeply nested if statement. Adopted SpellingCorrectionCommand. 44 (WebCore::Editor::applyCorrectionPanelInfo): Adopted SpellingCorrectionCommand. 45 (WebCore::Editor::unappliedSpellCorrection): Function for adding markers to reverted text and 46 for notifiying editor client about undone correction. 47 (WebCore::Editor::changeSelectionAfterCommand): Adopted new signature of SelectionController::setSelection(). 48 (WebCore::Editor::respondToChangedSelection): Use SelectionController::SetSelectionOptions 49 instead of boolean variables. 50 51 * editing/Editor.h: Added Editor::unappliedSpellCorrection(). 52 53 * editing/EditorCommand.cpp: 54 (WebCore::executeInsertFragment): Adopted new signature of ReplaceSelectionCommand::create(). 55 56 * editing/MoveSelectionCommand.cpp: 57 (WebCore::MoveSelectionCommand::doApply): Ditto. 58 59 * editing/ReplaceSelectionCommand.cpp: 60 (WebCore::ReplaceSelectionCommand::ReplaceSelectionCommand): Replaced all boolean arguments 61 with an enum value. 62 63 * editing/ReplaceSelectionCommand.h: 64 (WebCore::ReplaceSelectionCommand::create): Ditto. 65 66 * editing/SelectionController.cpp: Adopted new signature of SelectionController::setSelection(). 67 (WebCore::SelectionController::moveTo): 68 (WebCore::SelectionController::setSelection): 69 (WebCore::SelectionController::respondToNodeModification): 70 (WebCore::SelectionController::setBase): 71 (WebCore::SelectionController::setExtent): 72 (WebCore::SelectionController::setSelectedRange): 73 74 * editing/SelectionController.h: 75 (WebCore::SelectionController::setSelection): Replaced all boolean arguments with an enum value. 76 77 * editing/SetSelectionCommand.cpp: Added. 78 (WebCore::SetSelectionCommand::SetSelectionCommand): 79 (WebCore::SetSelectionCommand::doApply): 80 (WebCore::SetSelectionCommand::doUnapply): 81 82 * editing/SetSelectionCommand.h: Added. 83 (WebCore::SetSelectionCommand::create): 84 85 * editing/mac/SpellingCorrectionCommand.cpp: Added. 86 (WebCore::SpellingCorrectionRecordUndoCommand::create): 87 (WebCore::SpellingCorrectionRecordUndoCommand::SpellingCorrectionRecordUndoCommand): 88 (WebCore::SpellingCorrectionRecordUndoCommand::doApply): 89 (WebCore::SpellingCorrectionRecordUndoCommand::doUnapply): 90 (WebCore::SpellingCorrectionCommand::SpellingCorrectionCommand): 91 (WebCore::SpellingCorrectionCommand::doApply): 92 93 * editing/mac/SpellingCorrectionCommand.h: Added. 94 (WebCore::SpellingCorrectionCommand::create): 95 96 * loader/EmptyClients.h: Updated for the new function declared in EditorClient. 97 (WebCore::EmptyEditorClient::recordAutocorrectionResponse): 98 99 * manual-tests/autocorrection/undo-autocorrection.html: Added. 100 101 * page/ContextMenuController.cpp: 102 (WebCore::ContextMenuController::contextMenuItemSelected): Adopted new signature of ReplaceSelectionCommand::create(). 103 104 * page/DragController.cpp: 105 (WebCore::DragController::concludeEditDrag): Ditto. 106 107 * page/EditorClient.h: Added EditorClient::recordAutocorrectionResponse(). 108 1 109 2011-02-15 Beth Dakin <bdakin@apple.com> 2 110 -
trunk/Source/WebCore/WebCore.exp.in
r78626 r78632 490 490 __ZN7WebCore19ResourceRequestBase6setURLERKNS_4KURLE 491 491 __ZN7WebCore19SelectionController10setFocusedEb 492 __ZN7WebCore19SelectionController12setSelectionERKNS_16VisibleSelectionE bbbNS0_19CursorAlignOnScrollENS_15TextGranularityENS_20DirectionalityPolicyE492 __ZN7WebCore19SelectionController12setSelectionERKNS_16VisibleSelectionEjNS0_19CursorAlignOnScrollENS_15TextGranularityENS_20DirectionalityPolicyE 493 493 __ZN7WebCore19SelectionController15revealSelectionERKNS_15ScrollAlignmentEb 494 494 __ZN7WebCore19SelectionController16setSelectedRangeEPNS_5RangeENS_9EAffinityEb … … 536 536 __ZN7WebCore22externalRepresentationEPNS_5FrameEj 537 537 __ZN7WebCore23AuthenticationChallengeC1ERKNS_15ProtectionSpaceERKNS_10CredentialEjRKNS_16ResourceResponseERKNS_13ResourceErrorE 538 __ZN7WebCore23ReplaceSelectionCommandC1EPNS_8DocumentEN3WTF10PassRefPtrINS_16DocumentFragmentEEEbbbbbNS_10EditActionE539 538 __ZN7WebCore23createFragmentFromNodesEPNS_8DocumentERKN3WTF6VectorIPNS_4NodeELm0EEE 540 539 __ZN7WebCore23overrideDefaultLanguageERKN3WTF6StringE 540 __ZN7WebCore23ReplaceSelectionCommandC1EPNS_8DocumentEN3WTF10PassRefPtrINS_16DocumentFragmentEEEjNS_10EditActionE 541 541 __ZN7WebCore24BinaryPropertyListWriter17writePropertyListEv 542 542 __ZN7WebCore24DocumentMarkerController13removeMarkersEj -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r78617 r78632 4770 4770 B885E8D511E06DD2009FFBF4 /* InspectorApplicationCacheAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = B885E8D311E06DD2009FFBF4 /* InspectorApplicationCacheAgent.h */; settings = {ATTRIBUTES = (); }; }; 4771 4771 B8A6A6D5127B338D008673BA /* CorrectionPanelInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = B8A6A6D4127B338D008673BA /* CorrectionPanelInfo.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4772 B8DBDB4B130B0F8A00F5CDB1 /* SetSelectionCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B8DBDB47130B0F8A00F5CDB1 /* SetSelectionCommand.cpp */; }; 4773 B8DBDB4C130B0F8A00F5CDB1 /* SetSelectionCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = B8DBDB48130B0F8A00F5CDB1 /* SetSelectionCommand.h */; }; 4774 B8DBDB4D130B0F8A00F5CDB1 /* SpellingCorrectionCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B8DBDB49130B0F8A00F5CDB1 /* SpellingCorrectionCommand.cpp */; }; 4775 B8DBDB4E130B0F8A00F5CDB1 /* SpellingCorrectionCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = B8DBDB4A130B0F8A00F5CDB1 /* SpellingCorrectionCommand.h */; }; 4772 4776 BC00F0040E0A185500FD04E3 /* DOMFile.h in Headers */ = {isa = PBXBuildFile; fileRef = BC00EFFE0E0A185500FD04E3 /* DOMFile.h */; }; 4773 4777 BC00F0050E0A185500FD04E3 /* DOMFile.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC00EFFF0E0A185500FD04E3 /* DOMFile.mm */; }; … … 11062 11066 B885E8D311E06DD2009FFBF4 /* InspectorApplicationCacheAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorApplicationCacheAgent.h; sourceTree = "<group>"; }; 11063 11067 B8A6A6D4127B338D008673BA /* CorrectionPanelInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CorrectionPanelInfo.h; sourceTree = "<group>"; }; 11068 B8DBDB47130B0F8A00F5CDB1 /* SetSelectionCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SetSelectionCommand.cpp; sourceTree = "<group>"; }; 11069 B8DBDB48130B0F8A00F5CDB1 /* SetSelectionCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SetSelectionCommand.h; sourceTree = "<group>"; }; 11070 B8DBDB49130B0F8A00F5CDB1 /* SpellingCorrectionCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpellingCorrectionCommand.cpp; sourceTree = "<group>"; }; 11071 B8DBDB4A130B0F8A00F5CDB1 /* SpellingCorrectionCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpellingCorrectionCommand.h; sourceTree = "<group>"; }; 11064 11072 BC00EFFE0E0A185500FD04E3 /* DOMFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMFile.h; sourceTree = "<group>"; }; 11065 11073 BC00EFFF0E0A185500FD04E3 /* DOMFile.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMFile.mm; sourceTree = "<group>"; }; … … 15325 15333 93309DC0099E64910056E581 /* SetNodeAttributeCommand.cpp */, 15326 15334 93309DC1099E64910056E581 /* SetNodeAttributeCommand.h */, 15335 B8DBDB47130B0F8A00F5CDB1 /* SetSelectionCommand.cpp */, 15336 B8DBDB48130B0F8A00F5CDB1 /* SetSelectionCommand.h */, 15337 B8DBDB49130B0F8A00F5CDB1 /* SpellingCorrectionCommand.cpp */, 15338 B8DBDB4A130B0F8A00F5CDB1 /* SpellingCorrectionCommand.h */, 15327 15339 4B6FA6F30C39E48C00087011 /* SmartReplace.cpp */, 15328 15340 4B6FA6F20C39E48C00087011 /* SmartReplace.h */, … … 22421 22433 975CA2A21303679D00E99AD9 /* JSCrypto.h in Headers */, 22422 22434 26E98A10130A9FCA008EB7B2 /* TextCodecASCIIFastPath.h in Headers */, 22435 B8DBDB4C130B0F8A00F5CDB1 /* SetSelectionCommand.h in Headers */, 22436 B8DBDB4E130B0F8A00F5CDB1 /* SpellingCorrectionCommand.h in Headers */, 22423 22437 ); 22424 22438 runOnlyForDeploymentPostprocessing = 0; … … 25103 25117 A1E1154613015C4E0054AC8C /* PointLightSource.cpp in Sources */, 25104 25118 A1E1154813015C5D0054AC8C /* SpotLightSource.cpp in Sources */, 25119 B8DBDB4B130B0F8A00F5CDB1 /* SetSelectionCommand.cpp in Sources */, 25120 B8DBDB4D130B0F8A00F5CDB1 /* SpellingCorrectionCommand.cpp in Sources */, 25105 25121 ); 25106 25122 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/WebCore/editing/CompositeEditCommand.cpp
r77062 r78632 1007 1007 setEndingSelection(destination); 1008 1008 ASSERT(endingSelection().isCaretOrRange()); 1009 applyCommandToComposite(ReplaceSelectionCommand::create(document(), fragment, true, false, !preserveStyle, false, true)); 1009 ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::SelectReplacement | ReplaceSelectionCommand::MovingParagraph; 1010 if (!preserveStyle) 1011 options |= ReplaceSelectionCommand::MatchStyle; 1012 applyCommandToComposite(ReplaceSelectionCommand::create(document(), fragment, options)); 1010 1013 1011 1014 document()->frame()->editor()->markMisspellingsAndBadGrammar(endingSelection()); -
trunk/Source/WebCore/editing/Editor.cpp
r78533 r78632 75 75 #include "Sound.h" 76 76 #include "SpellChecker.h" 77 #include "SpellingCorrectionCommand.h" 77 78 #include "Text.h" 78 79 #include "TextEvent.h" … … 437 438 if (m_frame->selection()->isNone() || !fragment) 438 439 return; 439 440 applyCommand(ReplaceSelectionCommand::create(m_frame->document(), fragment, selectReplacement, smartReplace, matchStyle)); 440 441 ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::PreventNesting; 442 if (selectReplacement) 443 options |= ReplaceSelectionCommand::SelectReplacement; 444 if (smartReplace) 445 options |= ReplaceSelectionCommand::SmartReplace; 446 if (matchStyle) 447 options |= ReplaceSelectionCommand::MatchStyle; 448 applyCommand(ReplaceSelectionCommand::create(m_frame->document(), fragment, options, EditActionPaste)); 441 449 revealSelectionAfterEditingOperation(); 442 450 … … 1134 1142 if (client()) 1135 1143 client()->registerCommandForRedo(cmd); 1136 respondToChangedContents(newSelection); 1144 respondToChangedContents(newSelection); 1137 1145 } 1138 1146 … … 1149 1157 if (client()) 1150 1158 client()->registerCommandForUndo(cmd); 1151 respondToChangedContents(newSelection); 1159 respondToChangedContents(newSelection); 1152 1160 } 1153 1161 … … 1588 1596 VisibleSelection selection; 1589 1597 selection.setWithoutValidation(range->startPosition(), range->endPosition()); 1590 m_frame->selection()->setSelection(selection, false, false);1598 m_frame->selection()->setSelection(selection, 0); 1591 1599 } 1592 1600 … … 1646 1654 1647 1655 if (preserveSelection) { 1648 m_frame->selection()->setSelection(oldSelection, false, false);1656 m_frame->selection()->setSelection(oldSelection, 0); 1649 1657 // An open typing command that disagrees about current selection would cause issues with typing later on. 1650 1658 TypingCommand::closeTyping(m_lastEditCommand.get()); … … 2355 2363 ASSERT(resultLength > 0 && resultLocation >= 0); 2356 2364 2357 if (shouldShowCorrectionPanel && resultLocation + resultLength < spellingRangeEndOffset)2365 if (shouldShowCorrectionPanel && (resultLocation + resultLength < spellingRangeEndOffset || result->type != TextCheckingTypeCorrection)) 2358 2366 continue; 2359 2367 … … 2370 2378 // adding links should be done only immediately after they are typed 2371 2379 if (result->type == TextCheckingTypeLink && selectionOffset > resultLocation + resultLength + 1) 2372 doReplacement = false;2380 continue; 2373 2381 2374 2382 // Don't correct spelling in an already-corrected word. 2375 if ( doReplacement &&result->type == TextCheckingTypeCorrection) {2383 if (result->type == TextCheckingTypeCorrection) { 2376 2384 Node* node = rangeToReplace->startContainer(); 2377 2385 int startOffset = rangeToReplace->startOffset(); … … 2389 2397 } 2390 2398 } 2391 if (doReplacement && !shouldShowCorrectionPanel && selectionToReplace != m_frame->selection()->selection()) { 2392 if (m_frame->selection()->shouldChangeSelection(selectionToReplace)) { 2399 2400 if (!doReplacement) 2401 continue; 2402 2403 #if SUPPORT_AUTOCORRECTION_PANEL 2404 if (shouldShowCorrectionPanel) { 2405 if (resultLocation + resultLength == spellingRangeEndOffset) { 2406 // We only show the correction panel on the last word. 2407 Vector<FloatQuad> textQuads; 2408 rangeToReplace->getBorderAndTextQuads(textQuads); 2409 Vector<FloatQuad>::const_iterator end = textQuads.end(); 2410 FloatRect totalBoundingBox; 2411 for (Vector<FloatQuad>::const_iterator it = textQuads.begin(); it < end; ++it) 2412 totalBoundingBox.unite(it->boundingBox()); 2413 m_correctionPanelInfo.rangeToBeReplaced = rangeToReplace; 2414 m_correctionPanelInfo.replacedString = plainText(rangeToReplace.get()); 2415 m_correctionPanelInfo.replacementString = result->replacement; 2416 m_correctionPanelInfo.isActive = true; 2417 client()->showCorrectionPanel(m_correctionPanelInfo.panelType, totalBoundingBox, m_correctionPanelInfo.replacedString, result->replacement, Vector<String>(), this); 2418 break; 2419 } 2420 // If this function is called for showing correction panel, we ignore other correction or replacement. 2421 continue; 2422 } 2423 #endif 2424 2425 if (selectionToReplace != m_frame->selection()->selection()) { 2426 if (!m_frame->selection()->shouldChangeSelection(selectionToReplace)) 2427 continue; 2428 } 2429 2430 if (result->type == TextCheckingTypeLink) { 2431 m_frame->selection()->setSelection(selectionToReplace); 2432 selectionChanged = true; 2433 restoreSelectionAfterChange = false; 2434 if (canEditRichly()) 2435 applyCommand(CreateLinkCommand::create(m_frame->document(), result->replacement)); 2436 } else if (canEdit() && shouldInsertText(result->replacement, rangeToReplace.get(), EditorInsertActionTyped)) { 2437 String replacedString; 2438 if (result->type == TextCheckingTypeCorrection) 2439 replacedString = plainText(rangeToReplace.get()); 2440 2441 bool useSpellingCorrectionCommand = false; 2442 #if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) 2443 if (result->type == TextCheckingTypeCorrection) 2444 useSpellingCorrectionCommand = true; 2445 #endif 2446 if (useSpellingCorrectionCommand) 2447 applyCommand(SpellingCorrectionCommand::create(rangeToReplace, result->replacement)); 2448 else { 2393 2449 m_frame->selection()->setSelection(selectionToReplace); 2394 selectionChanged = true; 2395 } else { 2396 doReplacement = false; 2450 replaceSelectionWithText(result->replacement, false, false); 2397 2451 } 2398 } 2399 2400 String replacedString; 2401 if (doReplacement) { 2402 if (result->type == TextCheckingTypeLink) { 2403 restoreSelectionAfterChange = false; 2404 if (canEditRichly()) 2405 applyCommand(CreateLinkCommand::create(m_frame->document(), result->replacement)); 2406 } else if (canEdit() && shouldInsertText(result->replacement, rangeToReplace.get(), EditorInsertActionTyped)) { 2407 if (result->type == TextCheckingTypeCorrection) 2408 replacedString = plainText(rangeToReplace.get()); 2409 #if SUPPORT_AUTOCORRECTION_PANEL 2410 if (shouldShowCorrectionPanel && resultLocation + resultLength == spellingRangeEndOffset && result->type == TextCheckingTypeCorrection) { 2411 // We only show the correction panel on the last word. 2412 Vector<FloatQuad> textQuads; 2413 rangeToReplace->getBorderAndTextQuads(textQuads); 2414 Vector<FloatQuad>::const_iterator end = textQuads.end(); 2415 FloatRect totalBoundingBox; 2416 for (Vector<FloatQuad>::const_iterator it = textQuads.begin(); it < end; ++it) 2417 totalBoundingBox.unite(it->boundingBox()); 2418 m_correctionPanelInfo.rangeToBeReplaced = rangeToReplace; 2419 m_correctionPanelInfo.replacedString = replacedString; 2420 m_correctionPanelInfo.replacementString = result->replacement; 2421 m_correctionPanelInfo.isActive = true; 2422 client()->showCorrectionPanel(m_correctionPanelInfo.panelType, totalBoundingBox, m_correctionPanelInfo.replacedString, result->replacement, Vector<String>(), this); 2423 doReplacement = false; 2424 } 2425 #endif 2426 if (doReplacement) { 2427 replaceSelectionWithText(result->replacement, false, false); 2428 offsetDueToReplacement += replacementLength - resultLength; 2429 if (resultLocation < selectionOffset) { 2430 selectionOffset += replacementLength - resultLength; 2431 if (ambiguousBoundaryOffset >= 0) 2432 ambiguousBoundaryOffset = selectionOffset - 1; 2433 } 2434 2435 if (result->type == TextCheckingTypeCorrection) { 2436 // Add a marker so that corrections can easily be undone and won't be re-corrected. 2437 RefPtr<Range> replacedRange = paragraph.subrange(resultLocation, replacementLength); 2438 replacedRange->startContainer()->document()->markers()->addMarker(replacedRange.get(), DocumentMarker::Replacement, replacedString); 2439 replacedRange->startContainer()->document()->markers()->addMarker(replacedRange.get(), DocumentMarker::CorrectionIndicator, replacedString); 2440 replacedRange->startContainer()->document()->markers()->addMarker(replacedRange.get(), DocumentMarker::SpellCheckingExemption); 2441 } 2442 } 2452 2453 selectionChanged = true; 2454 offsetDueToReplacement += replacementLength - resultLength; 2455 if (resultLocation < selectionOffset) { 2456 selectionOffset += replacementLength - resultLength; 2457 if (ambiguousBoundaryOffset >= 0) 2458 ambiguousBoundaryOffset = selectionOffset - 1; 2459 } 2460 2461 if (result->type == TextCheckingTypeCorrection) { 2462 // Add a marker so that corrections can easily be undone and won't be re-corrected. 2463 RefPtr<Range> replacedRange = paragraph.subrange(resultLocation, replacementLength); 2464 replacedRange->startContainer()->document()->markers()->addMarker(replacedRange.get(), DocumentMarker::Replacement, replacedString); 2465 replacedRange->startContainer()->document()->markers()->addMarker(replacedRange.get(), DocumentMarker::CorrectionIndicator, replacedString); 2466 replacedRange->startContainer()->document()->markers()->addMarker(replacedRange.get(), DocumentMarker::SpellCheckingExemption); 2443 2467 } 2444 2468 } … … 2690 2714 void Editor::applyCorrectionPanelInfo(const Vector<DocumentMarker::MarkerType>& markerTypesToAdd) 2691 2715 { 2716 #if SUPPORT_AUTOCORRECTION_PANEL 2692 2717 if (!m_correctionPanelInfo.rangeToBeReplaced) 2693 2718 return; … … 2721 2746 // Clone the range, since the caller of this method may want to keep the original range around. 2722 2747 RefPtr<Range> rangeToBeReplaced = m_correctionPanelInfo.rangeToBeReplaced->cloneRange(ec); 2723 VisibleSelection selectionToReplace(rangeToBeReplaced.get(), DOWNSTREAM); 2724 if (m_frame->selection()->shouldChangeSelection(selectionToReplace)) { 2725 m_frame->selection()->setSelection(selectionToReplace); 2726 replaceSelectionWithText(m_correctionPanelInfo.replacementString, false, false); 2727 setEnd(paragraphRangeContainingCorrection.get(), m_frame->selection()->selection().start()); 2728 RefPtr<Range> replacementRange = TextIterator::subrange(paragraphRangeContainingCorrection.get(), correctionStartOffsetInParagraph, m_correctionPanelInfo.replacementString.length()); 2729 DocumentMarkerController* markers = replacementRange->startContainer()->document()->markers(); 2730 size_t size = markerTypesToAdd.size(); 2731 for (size_t i = 0; i < size; ++i) { 2732 if (m_correctionPanelInfo.panelType == CorrectionPanelInfo::PanelTypeReversion) 2733 markers->addMarker(replacementRange.get(), markerTypesToAdd[i]); 2734 else 2735 markers->addMarker(replacementRange.get(), markerTypesToAdd[i], m_correctionPanelInfo.replacedString); 2736 } 2737 } 2748 applyCommand(SpellingCorrectionCommand::create(rangeToBeReplaced, m_correctionPanelInfo.replacementString)); 2749 setEnd(paragraphRangeContainingCorrection.get(), m_frame->selection()->selection().start()); 2750 RefPtr<Range> replacementRange = TextIterator::subrange(paragraphRangeContainingCorrection.get(), correctionStartOffsetInParagraph, m_correctionPanelInfo.replacementString.length()); 2751 String newText = plainText(replacementRange.get()); 2752 2753 // Check to see if replacement succeeded. 2754 if (newText != m_correctionPanelInfo.replacementString) 2755 return; 2756 2757 DocumentMarkerController* markers = replacementRange->startContainer()->document()->markers(); 2758 size_t size = markerTypesToAdd.size(); 2759 for (size_t i = 0; i < size; ++i) { 2760 if (m_correctionPanelInfo.panelType == CorrectionPanelInfo::PanelTypeReversion) 2761 markers->addMarker(replacementRange.get(), markerTypesToAdd[i]); 2762 else 2763 markers->addMarker(replacementRange.get(), markerTypesToAdd[i], m_correctionPanelInfo.replacedString); 2764 } 2765 #else // SUPPORT_AUTOCORRECTION_PANEL 2766 UNUSED_PARAM(markerTypesToAdd); 2767 #endif // SUPPORT_AUTOCORRECTION_PANEL 2738 2768 } 2739 2769 … … 2751 2781 ASSERT(m_correctionPanelInfo.rangeToBeReplaced->endPosition() == caretPosition); 2752 2782 dismissCorrectionPanel(m_correctionPanelInfo.rangeToBeReplaced->endPosition() == caretPosition ? ReasonForDismissingCorrectionPanelAccepted : ReasonForDismissingCorrectionPanelIgnored); 2783 } 2784 2785 void Editor::unappliedSpellCorrection(const VisibleSelection& selectionOfCorrected, const String& corrected, const String& correction) 2786 { 2787 #if SUPPORT_AUTOCORRECTION_PANEL 2788 client()->recordAutocorrectionResponse(EditorClient::AutocorrectionReverted, corrected, correction); 2789 m_frame->document()->updateLayout(); 2790 m_frame->selection()->setSelection(selectionOfCorrected, SelectionController::CloseTyping | SelectionController::ClearTypingStyle | SelectionController::SpellCorrectionTriggered); 2791 RefPtr<Range> range = Range::create(m_frame->document(), m_frame->selection()->selection().start(), m_frame->selection()->selection().end()); 2792 2793 DocumentMarkerController* markers = m_frame->document()->markers(); 2794 markers->removeMarkers(range.get(), DocumentMarker::Spelling); 2795 markers->addMarker(range.get(), DocumentMarker::Replacement); 2796 markers->addMarker(range.get(), DocumentMarker::SpellCheckingExemption); 2797 #else // SUPPORT_AUTOCORRECTION_PANEL 2798 UNUSED_PARAM(selectionOfCorrected); 2799 UNUSED_PARAM(corrected); 2800 UNUSED_PARAM(correction); 2801 #endif // SUPPORT_AUTOCORRECTION_PANEL 2753 2802 } 2754 2803 … … 3024 3073 // See <rdar://problem/5729315> Some shouldChangeSelectedDOMRange contain Ranges for selections that are no longer valid 3025 3074 bool selectionDidNotChangeDOMPosition = newSelection == m_frame->selection()->selection(); 3026 if (selectionDidNotChangeDOMPosition || m_frame->selection()->shouldChangeSelection(newSelection)) 3027 m_frame->selection()->setSelection(newSelection, closeTyping, clearTypingStyle); 3075 if (selectionDidNotChangeDOMPosition || m_frame->selection()->shouldChangeSelection(newSelection)) { 3076 SelectionController::SetSelectionOptions options = 0; 3077 if (closeTyping) 3078 options |= SelectionController::CloseTyping; 3079 if (clearTypingStyle) 3080 options |= SelectionController::ClearTypingStyle; 3081 m_frame->selection()->setSelection(newSelection, options); 3082 } 3028 3083 3029 3084 // Some editing operations change the selection visually without affecting its position within the DOM. … … 3449 3504 } 3450 3505 3451 void Editor::respondToChangedSelection(const VisibleSelection& oldSelection, bool closeTyping)3506 void Editor::respondToChangedSelection(const VisibleSelection& oldSelection, SelectionController::SetSelectionOptions options) 3452 3507 { 3453 3508 #if SUPPORT_AUTOCORRECTION_PANEL … … 3460 3515 #endif // SUPPORT_AUTOCORRECTION_PANEL 3461 3516 3517 bool closeTyping = options & SelectionController::CloseTyping; 3462 3518 bool isContinuousSpellCheckingEnabled = this->isContinuousSpellCheckingEnabled(); 3463 3519 bool isContinuousGrammarCheckingEnabled = isContinuousSpellCheckingEnabled && isGrammarCheckingEnabled(); … … 3473 3529 } 3474 3530 3531 bool shouldCheckSpellingAndGrammar = true; 3532 #if SUPPORT_AUTOCORRECTION_PANEL 3533 // Don't check spelling and grammar if the change of selection is triggered by spelling correction itself. 3534 shouldCheckSpellingAndGrammar = !(options & SelectionController::SpellCorrectionTriggered); 3535 #endif 3536 3475 3537 // When typing we check spelling elsewhere, so don't redo it here. 3476 3538 // If this is a change in selection resulting from a delete operation, 3477 3539 // oldSelection may no longer be in the document. 3478 if ( closeTyping && oldSelection.isContentEditable() && oldSelection.start().node() && oldSelection.start().node()->inDocument()) {3540 if (shouldCheckSpellingAndGrammar && closeTyping && oldSelection.isContentEditable() && oldSelection.start().node() && oldSelection.start().node()->inDocument()) { 3479 3541 VisiblePosition oldStart(oldSelection.visibleStart()); 3480 3542 VisibleSelection oldAdjacentWords = VisibleSelection(startOfWord(oldStart, LeftWordIfOnBoundary), endOfWord(oldStart, RightWordIfOnBoundary)); -
trunk/Source/WebCore/editing/Editor.h
r78533 r78632 36 36 #include "EditorInsertAction.h" 37 37 #include "FindOptions.h" 38 #include "SelectionController.h" 38 39 #include "Timer.h" 39 40 #include "VisibleSelection.h" … … 168 169 void unappliedEditing(PassRefPtr<EditCommand>); 169 170 void reappliedEditing(PassRefPtr<EditCommand>); 170 171 void unappliedSpellCorrection(const VisibleSelection& selectionOfCorrected, const String& corrected, const String& correction); 172 171 173 bool selectionStartHasStyle(CSSStyleDeclaration*) const; 172 174 … … 354 356 IntRect firstRectForRange(Range*) const; 355 357 356 void respondToChangedSelection(const VisibleSelection& oldSelection, bool closeTyping);358 void respondToChangedSelection(const VisibleSelection& oldSelection, SelectionController::SetSelectionOptions); 357 359 bool shouldChangeSelection(const VisibleSelection& oldSelection, const VisibleSelection& newSelection, EAffinity, bool stillSelecting) const; 358 360 -
trunk/Source/WebCore/editing/EditorCommand.cpp
r78532 r78632 195 195 static bool executeInsertFragment(Frame* frame, PassRefPtr<DocumentFragment> fragment) 196 196 { 197 applyCommand(ReplaceSelectionCommand::create(frame->document(), fragment, 198 false, false, false, true, false, EditActionUnspecified)); 197 applyCommand(ReplaceSelectionCommand::create(frame->document(), fragment, ReplaceSelectionCommand::PreventNesting, EditActionUnspecified)); 199 198 return true; 200 199 } -
trunk/Source/WebCore/editing/MoveSelectionCommand.cpp
r76560 r78632 71 71 return; 72 72 } 73 applyCommandToComposite(ReplaceSelectionCommand::create(document(), m_fragment, true, m_smartInsert)); 73 ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::SelectReplacement | ReplaceSelectionCommand::PreventNesting; 74 if (m_smartInsert) 75 options |= ReplaceSelectionCommand::SmartReplace; 76 applyCommandToComposite(ReplaceSelectionCommand::create(document(), m_fragment, options)); 74 77 } 75 78 -
trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp
r78150 r78632 341 341 } 342 342 343 ReplaceSelectionCommand::ReplaceSelectionCommand(Document* document, PassRefPtr<DocumentFragment> fragment, 344 bool selectReplacement, bool smartReplace, bool matchStyle, bool preventNesting, bool movingParagraph, 345 EditAction editAction) 346 : CompositeEditCommand(document), 347 m_selectReplacement(selectReplacement), 348 m_smartReplace(smartReplace), 349 m_matchStyle(matchStyle), 350 m_documentFragment(fragment), 351 m_preventNesting(preventNesting), 352 m_movingParagraph(movingParagraph), 353 m_editAction(editAction), 354 m_shouldMergeEnd(false) 343 ReplaceSelectionCommand::ReplaceSelectionCommand(Document* document, PassRefPtr<DocumentFragment> fragment, CommandOptions options, EditAction editAction) 344 : CompositeEditCommand(document) 345 , m_selectReplacement(options & SelectReplacement) 346 , m_smartReplace(options & SmartReplace) 347 , m_matchStyle(options & MatchStyle) 348 , m_documentFragment(fragment) 349 , m_preventNesting(options & PreventNesting) 350 , m_movingParagraph(options & MovingParagraph) 351 , m_editAction(editAction) 352 , m_shouldMergeEnd(false) 355 353 { 356 354 } -
trunk/Source/WebCore/editing/ReplaceSelectionCommand.h
r71556 r78632 37 37 class ReplaceSelectionCommand : public CompositeEditCommand { 38 38 public: 39 static PassRefPtr<ReplaceSelectionCommand> create(Document* document, PassRefPtr<DocumentFragment> fragment, 40 bool selectReplacement = true, bool smartReplace = false, bool matchStyle = false, bool preventNesting = true, bool movingParagraph = false, 41 EditAction action = EditActionPaste) 39 enum CommandOption { 40 SelectReplacement = 1 << 0, 41 SmartReplace = 1 << 1, 42 MatchStyle = 1 << 2, 43 PreventNesting = 1 << 3, 44 MovingParagraph = 1 << 4 45 }; 46 47 typedef unsigned CommandOptions; 48 49 static PassRefPtr<ReplaceSelectionCommand> create(Document* document, PassRefPtr<DocumentFragment> fragment, CommandOptions options, EditAction action = EditActionPaste) 42 50 { 43 return adoptRef(new ReplaceSelectionCommand(document, fragment, selectReplacement, smartReplace, matchStyle, preventNesting, movingParagraph, action));51 return adoptRef(new ReplaceSelectionCommand(document, fragment, options, action)); 44 52 } 45 53 46 54 private: 47 ReplaceSelectionCommand(Document*, PassRefPtr<DocumentFragment>, 48 bool selectReplacement, bool smartReplace, bool matchStyle, bool preventNesting, bool movingParagraph, EditAction); 55 ReplaceSelectionCommand(Document*, PassRefPtr<DocumentFragment>, CommandOptions, EditAction); 49 56 50 57 virtual void doApply(); -
trunk/Source/WebCore/editing/SelectionController.cpp
r78150 r78632 89 89 void SelectionController::moveTo(const VisiblePosition &pos, bool userTriggered, CursorAlignOnScroll align) 90 90 { 91 setSelection(VisibleSelection(pos.deepEquivalent(), pos.deepEquivalent(), pos.affinity()), true, true, userTriggered, align); 91 SetSelectionOptions options = CloseTyping | ClearTypingStyle; 92 if (userTriggered) 93 options |= UserTriggered; 94 setSelection(VisibleSelection(pos.deepEquivalent(), pos.deepEquivalent(), pos.affinity()), options, align); 92 95 } 93 96 94 97 void SelectionController::moveTo(const VisiblePosition &base, const VisiblePosition &extent, bool userTriggered) 95 98 { 96 setSelection(VisibleSelection(base.deepEquivalent(), extent.deepEquivalent(), base.affinity()), true, true, userTriggered); 99 SetSelectionOptions options = CloseTyping | ClearTypingStyle; 100 if (userTriggered) 101 options |= UserTriggered; 102 setSelection(VisibleSelection(base.deepEquivalent(), extent.deepEquivalent(), base.affinity()), options); 97 103 } 98 104 99 105 void SelectionController::moveTo(const Position &pos, EAffinity affinity, bool userTriggered) 100 106 { 101 setSelection(VisibleSelection(pos, affinity), true, true, userTriggered); 107 SetSelectionOptions options = CloseTyping | ClearTypingStyle; 108 if (userTriggered) 109 options |= UserTriggered; 110 setSelection(VisibleSelection(pos, affinity), options); 102 111 } 103 112 104 113 void SelectionController::moveTo(const Range *r, EAffinity affinity, bool userTriggered) 105 114 { 115 SetSelectionOptions options = CloseTyping | ClearTypingStyle; 116 if (userTriggered) 117 options |= UserTriggered; 106 118 VisibleSelection selection = r ? VisibleSelection(r->startPosition(), r->endPosition(), affinity) : VisibleSelection(Position(), Position(), affinity); 107 setSelection(selection, true, true, userTriggered);119 setSelection(selection, options); 108 120 } 109 121 110 122 void SelectionController::moveTo(const Position &base, const Position &extent, EAffinity affinity, bool userTriggered) 111 123 { 112 setSelection(VisibleSelection(base, extent, affinity), true, true, userTriggered); 113 } 114 115 void SelectionController::setSelection(const VisibleSelection& s, bool closeTyping, bool shouldClearTypingStyle, bool userTriggered, CursorAlignOnScroll align, TextGranularity granularity, DirectionalityPolicy directionalityPolicy) 124 SetSelectionOptions options = CloseTyping | ClearTypingStyle; 125 if (userTriggered) 126 options |= UserTriggered; 127 setSelection(VisibleSelection(base, extent, affinity), options); 128 } 129 130 void SelectionController::setSelection(const VisibleSelection& s, SetSelectionOptions options, CursorAlignOnScroll align, TextGranularity granularity, DirectionalityPolicy directionalityPolicy) 116 131 { 117 132 m_granularity = granularity; 133 134 bool closeTyping = options & CloseTyping; 135 bool shouldClearTypingStyle = options & ClearTypingStyle; 136 bool userTriggered = options & UserTriggered; 118 137 119 138 setIsDirectional(directionalityPolicy == MakeDirectionalSelection); … … 140 159 // if document->frame() == m_frame we can get into an infinite loop 141 160 if (document && document->frame() && document->frame() != m_frame && document != m_frame->document()) { 142 document->frame()->selection()->setSelection(s, closeTyping, shouldClearTypingStyle, userTriggered);143 return; 144 } 145 161 document->frame()->selection()->setSelection(s, options); 162 return; 163 } 164 146 165 if (closeTyping) 147 166 TypingCommand::closeTyping(m_frame->editor()->lastEditCommand()); … … 169 188 selectFrameElementInParentIfFullySelected(); 170 189 notifyRendererOfSelectionChange(userTriggered); 171 m_frame->editor()->respondToChangedSelection(oldSelection, closeTyping);190 m_frame->editor()->respondToChangedSelection(oldSelection, options); 172 191 if (userTriggered) { 173 192 ScrollAlignment alignment; … … 251 270 252 271 if (clearDOMTreeSelection) 253 setSelection(VisibleSelection(), false, false);272 setSelection(VisibleSelection(), 0); 254 273 } 255 274 … … 943 962 void SelectionController::setBase(const VisiblePosition &pos, bool userTriggered) 944 963 { 945 setSelection(VisibleSelection(pos.deepEquivalent(), m_selection.extent(), pos.affinity()), true, true, userTriggered); 964 SetSelectionOptions options = CloseTyping | ClearTypingStyle; 965 if (userTriggered) 966 options |= UserTriggered; 967 setSelection(VisibleSelection(pos.deepEquivalent(), m_selection.extent(), pos.affinity()), options); 946 968 } 947 969 948 970 void SelectionController::setExtent(const VisiblePosition &pos, bool userTriggered) 949 971 { 950 setSelection(VisibleSelection(m_selection.base(), pos.deepEquivalent(), pos.affinity()), true, true, userTriggered); 972 SetSelectionOptions options = CloseTyping | ClearTypingStyle; 973 if (userTriggered) 974 options |= UserTriggered; 975 setSelection(VisibleSelection(m_selection.base(), pos.deepEquivalent(), pos.affinity()), options); 951 976 } 952 977 953 978 void SelectionController::setBase(const Position &pos, EAffinity affinity, bool userTriggered) 954 979 { 955 setSelection(VisibleSelection(pos, m_selection.extent(), affinity), true, true, userTriggered); 980 SetSelectionOptions options = CloseTyping | ClearTypingStyle; 981 if (userTriggered) 982 options |= UserTriggered; 983 setSelection(VisibleSelection(pos, m_selection.extent(), affinity), options); 956 984 } 957 985 958 986 void SelectionController::setExtent(const Position &pos, EAffinity affinity, bool userTriggered) 959 987 { 960 setSelection(VisibleSelection(m_selection.base(), pos, affinity), true, true, userTriggered); 988 SetSelectionOptions options = CloseTyping | ClearTypingStyle; 989 if (userTriggered) 990 options |= UserTriggered; 991 setSelection(VisibleSelection(m_selection.base(), pos, affinity), options); 961 992 } 962 993 … … 1390 1421 VisiblePosition visibleStart(startContainer, startOffset, collapsed ? affinity : DOWNSTREAM); 1391 1422 VisiblePosition visibleEnd(endContainer, endOffset, SEL_DEFAULT_AFFINITY); 1392 setSelection(VisibleSelection(visibleStart, visibleEnd), closeTyping); 1423 SetSelectionOptions options = ClearTypingStyle; 1424 if (closeTyping) 1425 options |= CloseTyping; 1426 setSelection(VisibleSelection(visibleStart, visibleEnd), options); 1393 1427 return true; 1394 1428 } -
trunk/Source/WebCore/editing/SelectionController.h
r76248 r78632 55 55 enum CursorAlignOnScroll { AlignCursorOnScrollIfNeeded, 56 56 AlignCursorOnScrollAlways }; 57 enum SetSelectionOption { 58 CloseTyping = 1 << 0, 59 ClearTypingStyle = 1 << 1, 60 UserTriggered = 1 << 2, 61 SpellCorrectionTriggered = 1 << 3, 62 }; 63 typedef unsigned SetSelectionOptions; 57 64 58 65 SelectionController(Frame* = 0, bool isDragCaretController = false); … … 70 77 71 78 const VisibleSelection& selection() const { return m_selection; } 72 void setSelection(const VisibleSelection&, bool closeTyping = true, bool clearTypingStyle = true, bool userTriggered = false, CursorAlignOnScroll = AlignCursorOnScrollIfNeeded, TextGranularity = CharacterGranularity, DirectionalityPolicy = MakeDirectionalSelection);73 void setSelection(const VisibleSelection& selection, TextGranularity granularity, DirectionalityPolicy directionality = MakeDirectionalSelection) { setSelection(selection, true, true, false, AlignCursorOnScrollIfNeeded, granularity, directionality); }79 void setSelection(const VisibleSelection&, SetSelectionOptions = CloseTyping | ClearTypingStyle, CursorAlignOnScroll = AlignCursorOnScrollIfNeeded, TextGranularity = CharacterGranularity, DirectionalityPolicy = MakeDirectionalSelection); 80 void setSelection(const VisibleSelection& selection, TextGranularity granularity, DirectionalityPolicy directionality = MakeDirectionalSelection) { setSelection(selection, CloseTyping | ClearTypingStyle, AlignCursorOnScrollIfNeeded, granularity, directionality); } 74 81 bool setSelectedRange(Range*, EAffinity, bool closeTyping); 75 82 void selectAll(); -
trunk/Source/WebCore/loader/EmptyClients.h
r78533 r78632 513 513 virtual void dismissCorrectionPanel(ReasonForDismissingCorrectionPanel) { } 514 514 virtual bool isShowingCorrectionPanel() { return false; } 515 virtual void recordAutocorrectionResponse(AutocorrectionResponseType, const String&, const String&) { } 515 516 #endif 516 517 virtual void updateSpellingUIWithGrammarString(const String&, const GrammarDetail&) { } -
trunk/Source/WebCore/page/ContextMenuController.cpp
r78480 r78632 279 279 if (frame->editor()->shouldInsertText(item->title(), frame->selection()->toNormalizedRange().get(), EditorInsertActionPasted)) { 280 280 Document* document = frame->document(); 281 RefPtr<ReplaceSelectionCommand> command = ReplaceSelectionCommand::create(document, createFragmentFromMarkup(document, item->title(), ""), true, false, true);281 RefPtr<ReplaceSelectionCommand> command = ReplaceSelectionCommand::create(document, createFragmentFromMarkup(document, item->title(), ""), ReplaceSelectionCommand::SelectReplacement | ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::PreventNesting); 282 282 applyCommand(command); 283 283 frame->selection()->revealSelection(ScrollAlignment::alignToEdgeIfNeeded); -
trunk/Source/WebCore/page/DragController.cpp
r78590 r78632 467 467 applyCommand(MoveSelectionCommand::create(fragment, dragCaret.base(), smartInsert, smartDelete)); 468 468 } else { 469 if (setSelectionToDragCaret(innerFrame, dragCaret, range, point)) 470 applyCommand(ReplaceSelectionCommand::create(m_documentUnderMouse.get(), fragment, true, dragData->canSmartReplace(), chosePlainText)); 469 if (setSelectionToDragCaret(innerFrame, dragCaret, range, point)) { 470 ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::SelectReplacement | ReplaceSelectionCommand::PreventNesting; 471 if (dragData->canSmartReplace()) 472 options |= ReplaceSelectionCommand::SmartReplace; 473 if (chosePlainText) 474 options |= ReplaceSelectionCommand::MatchStyle; 475 applyCommand(ReplaceSelectionCommand::create(m_documentUnderMouse.get(), fragment, options)); 476 } 471 477 } 472 478 } else { … … 479 485 m_client->willPerformDragDestinationAction(DragDestinationActionEdit, dragData); 480 486 if (setSelectionToDragCaret(innerFrame, dragCaret, range, point)) 481 applyCommand(ReplaceSelectionCommand::create(m_documentUnderMouse.get(), createFragmentFromText(range.get(), text), true, false, true));487 applyCommand(ReplaceSelectionCommand::create(m_documentUnderMouse.get(), createFragmentFromText(range.get(), text), ReplaceSelectionCommand::SelectReplacement | ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::PreventNesting)); 482 488 } 483 489 cachedResourceLoader->setAllowStaleResources(false); -
trunk/Source/WebCore/page/EditorClient.h
r78534 r78632 162 162 163 163 #if SUPPORT_AUTOCORRECTION_PANEL 164 enum AutocorrectionResponseType { 165 AutocorrectionEdited, 166 AutocorrectionReverted 167 }; 164 168 virtual void showCorrectionPanel(CorrectionPanelInfo::PanelType, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacmentString, const Vector<String>& alternativeReplacementStrings, Editor*) = 0; 165 169 virtual void dismissCorrectionPanel(ReasonForDismissingCorrectionPanel) = 0; 166 170 virtual bool isShowingCorrectionPanel() = 0; 171 virtual void recordAutocorrectionResponse(AutocorrectionResponseType, const String& replacedString, const String& replacementString) = 0; 167 172 #endif 168 173 -
trunk/Source/WebKit/chromium/ChangeLog
r78620 r78632 1 2011-02-15 Jia Pu <jpu@apple.com> 2 3 Reviewed by Darin Adler. 4 5 Autocorrection should respect undo. 6 https://bugs.webkit.org/show_bug.cgi?id=52221 7 <rdar://problem/8663399> 8 9 Please see WebCore/ChangeLog for detailed description. 10 11 * WebCoreSupport/WebEditorClient.cpp: 12 (WebFrameImpl::replaceSelection): Adopted new signature of ReplaceSelectionCommand::create(). 13 1 14 2011-02-15 Kenneth Russell <kbr@google.com> 2 15 -
trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp
r78342 r78632 1058 1058 frame()->selection()->toNormalizedRange().get(), text); 1059 1059 applyCommand(ReplaceSelectionCommand::create( 1060 frame()->document(), fragment.get(), false, true, true));1060 frame()->document(), fragment.get(), ReplaceSelectionCommand::SmartReplace | ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::PreventNesting)); 1061 1061 } 1062 1062 -
trunk/Source/WebKit/mac/ChangeLog
r78627 r78632 1 2011-02-15 Jia Pu <jpu@apple.com> 2 3 Reviewed by Darin Adler. 4 5 Autocorrection should respect undo. 6 https://bugs.webkit.org/show_bug.cgi?id=52221 7 <rdar://problem/8663399> 8 9 Please see WebCore/ChangeLog for detailed description. 10 11 * WebCoreSupport/WebEditorClient.h: Updated for the new function declared in EditorClient. 12 13 * WebCoreSupport/WebEditorClient.mm: 14 (WebEditorClient::recordAutocorrectionResponse): Ditto. 15 16 * WebView/WebFrame.mm: 17 (-[WebFrame _replaceSelectionWithFragment:selectReplacement:smartReplace:matchStyle:]): 18 Adopted new signature of ReplaceSelectionCommand::create(). 19 1 20 2011-02-15 David Kilzer <ddkilzer@apple.com> 2 21 … … 27 46 (-[WebView _setMinimumTimerInterval:]): 28 47 * WebView/WebViewPrivate.h: 29 30 2011-01-26 MORITA Hajime <morrita@google.com>31 32 Reviewed by Ryosuke Niwa.33 34 Refactoring: Extract TextCheckerClient from EditorClient35 https://bugs.webkit.org/show_bug.cgi?id=5321336 37 * WebCoreSupport/WebEditorClient.h:38 (WebEditorClient::textChecker):39 40 2011-02-07 Ryosuke Niwa <rniwa@webkit.org>41 42 Reviewed by Adam Barth.43 44 Add EditorClient callbacks to override isDOMPasteAllowed and javaScriptCanAccessClipboard45 https://bugs.webkit.org/show_bug.cgi?id=5241746 47 Added two callback functions, canCopyCut and canPaste to EditorClient. They are currently48 not implemented.49 50 * WebCoreSupport/WebEditorClient.h:51 * WebCoreSupport/WebEditorClient.mm:52 (WebEditorClient::canCopyCut): Added.53 (WebEditorClient::canPaste): Added.54 48 55 49 2011-02-11 Geoffrey Garen <ggaren@apple.com> -
trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h
r78533 r78632 145 145 virtual void dismissCorrectionPanel(WebCore::ReasonForDismissingCorrectionPanel); 146 146 virtual bool isShowingCorrectionPanel(); 147 virtual void recordAutocorrectionResponse(AutocorrectionResponseType, const WTF::String& replacedString, const WTF::String& replacementString); 147 148 #endif 148 149 private: -
trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm
r78532 r78632 963 963 return m_correctionPanelIsShown; 964 964 } 965 966 void WebEditorClient::recordAutocorrectionResponse(EditorClient::AutocorrectionResponseType responseType, const String& replacedString, const String& replacementString) 967 { 968 NSCorrectionResponse spellCheckerResponse = responseType == EditorClient::AutocorrectionReverted ? NSCorrectionResponseReverted : NSCorrectionResponseEdited; 969 [[NSSpellChecker sharedSpellChecker] recordResponse:spellCheckerResponse toCorrection:replacementString forWord:replacedString language:nil inSpellDocumentWithTag:[m_webView spellCheckerDocumentTag]]; 970 } 965 971 #endif 966 972 -
trunk/Source/WebKit/mac/WebView/WebFrame.mm
r78342 r78632 1137 1137 if (_private->coreFrame->selection()->isNone() || !fragment) 1138 1138 return; 1139 1140 applyCommand(ReplaceSelectionCommand::create(_private->coreFrame->document(), core(fragment), selectReplacement, smartReplace, matchStyle)); 1139 ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::PreventNesting; 1140 if (selectReplacement) 1141 options |= ReplaceSelectionCommand::SelectReplacement; 1142 if (smartReplace) 1143 options |= ReplaceSelectionCommand::SmartReplace; 1144 if (matchStyle) 1145 options |= ReplaceSelectionCommand::MatchStyle; 1146 applyCommand(ReplaceSelectionCommand::create(_private->coreFrame->document(), core(fragment), options)); 1141 1147 _private->coreFrame->selection()->revealSelection(ScrollAlignment::alignToEdgeIfNeeded); 1142 1148 } -
trunk/Source/WebKit2/ChangeLog
r78624 r78632 1 2011-02-15 Jia Pu <jpu@apple.com> 2 3 Reviewed by Darin Adler. 4 5 Autocorrection should respect undo. 6 https://bugs.webkit.org/show_bug.cgi?id=52221 7 <rdar://problem/8663399> 8 9 Please see WebCore/ChangeLog for detailed description. 10 11 * WebProcess/WebCoreSupport/WebEditorClient.h: Updated for the new function declared in EditorClient. 12 13 * WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm: 14 (WebKit::WebEditorClient::recordAutocorrectionResponse): Ditto. 15 16 * WebProcess/WebPage/WebPage.cpp: 17 (WebKit::WebPage::replaceSelectionWithText): Adopted new signature of ReplaceSelectionCommand::create(). 18 1 19 2011-02-15 Jessie Berlin <jberlin@apple.com> 2 20 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h
r78533 r78632 146 146 virtual void dismissCorrectionPanel(WebCore::ReasonForDismissingCorrectionPanel); 147 147 virtual bool isShowingCorrectionPanel(); 148 virtual void recordAutocorrectionResponse(AutocorrectionResponseType, const WTF::String& replacedString, const WTF::String& replacementString); 148 149 #endif 149 150 WebPage* m_page; -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm
r76991 r78632 265 265 return false; 266 266 } 267 268 void WebEditorClient::recordAutocorrectionResponse(EditorClient::AutocorrectionResponseType responseType, const String& replacedString, const String& replacementString) 269 { 270 notImplemented(); 271 } 267 272 #endif 268 273 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r78620 r78632 1665 1665 if (frame->selection()->isNone()) 1666 1666 return; 1667 1667 1668 1668 RefPtr<DocumentFragment> textFragment = createFragmentFromText(frame->selection()->toNormalizedRange().get(), text); 1669 applyCommand(ReplaceSelectionCommand::create(frame->document(), textFragment.release(), true, false, true));1669 applyCommand(ReplaceSelectionCommand::create(frame->document(), textFragment.release(), ReplaceSelectionCommand::SelectReplacement | ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::PreventNesting)); 1670 1670 frame->selection()->revealSelection(ScrollAlignment::alignToEdgeIfNeeded); 1671 1671 }
Note: See TracChangeset
for help on using the changeset viewer.