Changeset 73287 in webkit
- Timestamp:
- Dec 3, 2010 12:45:34 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r73280 r73287 1 2010-12-03 Jia Pu <jpu@apple.com> 2 3 Reviewed by Darin Adler. 4 5 Need to move all code that applies correction into correction panel callback. 6 https://bugs.webkit.org/show_bug.cgi?id=50426 7 <rdar://problem/8720832> 8 9 Added expected png file. 10 11 * platform/mac/editing/spelling/delete-autocorrected-word-1-expected.checksum: Added. 12 * platform/mac/editing/spelling/delete-autocorrected-word-1-expected.png: Added. 13 1 14 2010-12-03 Sam Weinig <sam@webkit.org> 2 15 -
trunk/WebCore/ChangeLog
r73285 r73287 1 2010-12-03 Jia Pu <jpu@apple.com> 2 3 Reviewed by Darin Adler. 4 5 Need to move all code that applies correction into correction panel callback. 6 https://bugs.webkit.org/show_bug.cgi?id=50426 7 <rdar://problem/8720832> 8 9 No new test, since there's no behavioral change. 10 11 This patch is to prepare WebKit to work with upcoming AppKit changes. The main changes are: 12 1. Moved all calls to applyCorrectionPanelInfo() into handleCorrectionPanelResult(). 13 2. Added more user dictionary learning code. 14 3. Removed m_ prefix in all member variables of CorrectionPanelInfo. 15 16 * editing/CorrectionPanelInfo.h: Remove m_ prefix on member variables. Added ReasonForDismissingCorrectionPanel enum type. 17 18 * editing/Editor.cpp: Moved all calls to applyCorrectionPanelInfo() into handleCorrectionPanelResult(). 19 Adopted new member variable naming in class CorrectionPanelInfo. 20 (WebCore::Editor::respondToChangedSelection): 21 (WebCore::Editor::~Editor): 22 (WebCore::Editor::markMisspellingsAfterTypingToWord): 23 (WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges): 24 (WebCore::Editor::correctionPanelTimerFired): 25 (WebCore::Editor::handleCorrectionPanelResult): 26 (WebCore::Editor::startCorrectionPanelTimer): 27 (WebCore::Editor::stopCorrectionPanelTimer): 28 (WebCore::Editor::handleCancelOperation): 29 (WebCore::Editor::dismissCorrectionPanel): 30 (WebCore::Editor::applyCorrectionPanelInfo): 31 32 * editing/Editor.h: Changed signature of dismissCorrectionPanel to use ReasonForDismissingCorrectionPanel. 33 34 * loader/EmptyClients.h: Ditto. 35 (WebCore::EmptyEditorClient::dismissCorrectionPanel): 36 37 * page/EditorClient.h: Ditto. 38 1 39 2010-12-03 Pavel Feldman <pfeldman@chromium.org> 2 40 -
trunk/WebCore/editing/CorrectionPanelInfo.h
r73088 r73287 49 49 }; 50 50 51 RefPtr<Range> m_rangeToBeReplaced;52 String m_replacedString;53 String m_replacementString;54 PanelType m_panelType;55 bool m_isActive;51 RefPtr<Range> rangeToBeReplaced; 52 String replacedString; 53 String replacementString; 54 PanelType panelType; 55 bool isActive; 56 56 }; 57 57 58 enum CorrectionWasRejectedOrNot { CorrectionWasNotRejected, CorrectionWasRejected }; 59 58 enum ReasonForDismissingCorrectionPanel { 59 ReasonForDismissingCorrectionPanelCancelled = 0, 60 ReasonForDismissingCorrectionPanelIgnored, 61 ReasonForDismissingCorrectionPanelAccepted 62 }; 60 63 } // namespace WebCore 61 64 -
trunk/WebCore/editing/Editor.cpp
r73088 r73287 94 94 95 95 #if SUPPORT_AUTOCORRECTION_PANEL 96 static const Vector<DocumentMarker::MarkerType>& markerTypesForAutocorrection()97 {98 DEFINE_STATIC_LOCAL(Vector<DocumentMarker::MarkerType>, markerTypesForAutoCorrection, ());99 if (markerTypesForAutoCorrection.isEmpty()) {100 markerTypesForAutoCorrection.append(DocumentMarker::Replacement);101 markerTypesForAutoCorrection.append(DocumentMarker::CorrectionIndicator);102 }103 return markerTypesForAutoCorrection;104 }105 106 96 static FloatRect boundingBoxForRange(Range* range) 107 97 { … … 115 105 } 116 106 #endif // SUPPORT_AUTOCORRECTION_PANEL 107 108 static const Vector<DocumentMarker::MarkerType>& markerTypesForAutocorrection() 109 { 110 DEFINE_STATIC_LOCAL(Vector<DocumentMarker::MarkerType>, markerTypesForAutoCorrection, ()); 111 if (markerTypesForAutoCorrection.isEmpty()) { 112 markerTypesForAutoCorrection.append(DocumentMarker::Replacement); 113 markerTypesForAutoCorrection.append(DocumentMarker::CorrectionIndicator); 114 } 115 return markerTypesForAutoCorrection; 116 } 117 117 118 118 static const Vector<DocumentMarker::MarkerType>& markerTypesForReplacement() … … 501 501 if (currentSelection != oldSelection) { 502 502 stopCorrectionPanelTimer(); 503 dismissCorrectionPanel( CorrectionWasNotRejected);503 dismissCorrectionPanel(ReasonForDismissingCorrectionPanelIgnored); 504 504 } 505 505 #endif // SUPPORT_AUTOCORRECTION_PANEL … … 536 536 String currentWord = plainText(wordRange.get()); 537 537 if (currentWord.length()) { 538 m_correctionPanelInfo. m_rangeToBeReplaced = wordRange;539 m_correctionPanelInfo. m_replacedString = currentWord;538 m_correctionPanelInfo.rangeToBeReplaced = wordRange; 539 m_correctionPanelInfo.replacedString = currentWord; 540 540 if (marker.type == DocumentMarker::Spelling) 541 541 startCorrectionPanelTimer(CorrectionPanelInfo::PanelTypeSpellingSuggestions); 542 542 else { 543 m_correctionPanelInfo. m_replacementString = marker.description;543 m_correctionPanelInfo.replacementString = marker.description; 544 544 startCorrectionPanelTimer(CorrectionPanelInfo::PanelTypeReversion); 545 545 } … … 1148 1148 { 1149 1149 #if SUPPORT_AUTOCORRECTION_PANEL 1150 dismissCorrectionPanel( CorrectionWasNotRejected);1150 dismissCorrectionPanel(ReasonForDismissingCorrectionPanelIgnored); 1151 1151 #endif 1152 1152 } … … 2056 2056 } 2057 2057 if (doApplyCorrection) 2058 applyCorrectionPanelInfo(markerTypesForAutocorrection()); 2059 m_correctionPanelInfo.m_rangeToBeReplaced.clear(); 2058 dismissCorrectionPanel(ReasonForDismissingCorrectionPanelAccepted); 2059 else 2060 m_correctionPanelInfo.rangeToBeReplaced.clear(); 2060 2061 #else 2061 2062 UNUSED_PARAM(selectionAfterTyping); … … 2374 2375 for (Vector<FloatQuad>::const_iterator it = textQuads.begin(); it < end; ++it) 2375 2376 totalBoundingBox.unite(it->boundingBox()); 2376 m_correctionPanelInfo. m_rangeToBeReplaced = rangeToReplace;2377 m_correctionPanelInfo. m_replacedString = replacedString;2378 m_correctionPanelInfo. m_replacementString = result->replacement;2379 m_correctionPanelInfo. m_isActive = true;2380 client()->showCorrectionPanel(m_correctionPanelInfo. m_panelType, totalBoundingBox, m_correctionPanelInfo.m_replacedString, result->replacement, Vector<String>(), this);2377 m_correctionPanelInfo.rangeToBeReplaced = rangeToReplace; 2378 m_correctionPanelInfo.replacedString = replacedString; 2379 m_correctionPanelInfo.replacementString = result->replacement; 2380 m_correctionPanelInfo.isActive = true; 2381 client()->showCorrectionPanel(m_correctionPanelInfo.panelType, totalBoundingBox, m_correctionPanelInfo.replacedString, result->replacement, Vector<String>(), this); 2381 2382 doReplacement = false; 2382 2383 } … … 2456 2457 { 2457 2458 #if SUPPORT_AUTOCORRECTION_PANEL 2458 switch (m_correctionPanelInfo.m_panelType) { 2459 m_correctionPanelIsDismissedByEditor = false; 2460 switch (m_correctionPanelInfo.panelType) { 2459 2461 case CorrectionPanelInfo::PanelTypeCorrection: { 2460 2462 VisibleSelection selection(frame()->selection()->selection()); … … 2466 2468 break; 2467 2469 case CorrectionPanelInfo::PanelTypeReversion: { 2468 m_correctionPanelInfo. m_isActive = true;2469 m_correctionPanelInfo. m_replacedString = plainText(m_correctionPanelInfo.m_rangeToBeReplaced.get());2470 client()->showCorrectionPanel(m_correctionPanelInfo. m_panelType, boundingBoxForRange(m_correctionPanelInfo.m_rangeToBeReplaced.get()), m_correctionPanelInfo.m_replacedString, m_correctionPanelInfo.m_replacementString, Vector<String>(), this);2470 m_correctionPanelInfo.isActive = true; 2471 m_correctionPanelInfo.replacedString = plainText(m_correctionPanelInfo.rangeToBeReplaced.get()); 2472 client()->showCorrectionPanel(m_correctionPanelInfo.panelType, boundingBoxForRange(m_correctionPanelInfo.rangeToBeReplaced.get()), m_correctionPanelInfo.replacedString, m_correctionPanelInfo.replacementString, Vector<String>(), this); 2471 2473 } 2472 2474 break; 2473 2475 case CorrectionPanelInfo::PanelTypeSpellingSuggestions: { 2474 if (plainText(m_correctionPanelInfo. m_rangeToBeReplaced.get()) != m_correctionPanelInfo.m_replacedString)2476 if (plainText(m_correctionPanelInfo.rangeToBeReplaced.get()) != m_correctionPanelInfo.replacedString) 2475 2477 break; 2476 String paragraphText = plainText(TextCheckingParagraph(m_correctionPanelInfo. m_rangeToBeReplaced).paragraphRange().get());2478 String paragraphText = plainText(TextCheckingParagraph(m_correctionPanelInfo.rangeToBeReplaced).paragraphRange().get()); 2477 2479 Vector<String> suggestions; 2478 client()->getGuessesForWord(m_correctionPanelInfo. m_replacedString, paragraphText, suggestions);2480 client()->getGuessesForWord(m_correctionPanelInfo.replacedString, paragraphText, suggestions); 2479 2481 if (suggestions.isEmpty()) 2480 2482 break; 2481 2483 String topSuggestion = suggestions.first(); 2482 2484 suggestions.remove(0); 2483 m_correctionPanelInfo. m_isActive = true;2484 client()->showCorrectionPanel(m_correctionPanelInfo. m_panelType, boundingBoxForRange(m_correctionPanelInfo.m_rangeToBeReplaced.get()), m_correctionPanelInfo.m_replacedString, topSuggestion, suggestions, this);2485 m_correctionPanelInfo.isActive = true; 2486 client()->showCorrectionPanel(m_correctionPanelInfo.panelType, boundingBoxForRange(m_correctionPanelInfo.rangeToBeReplaced.get()), m_correctionPanelInfo.replacedString, topSuggestion, suggestions, this); 2485 2487 } 2486 2488 break; … … 2491 2493 void Editor::handleCorrectionPanelResult(const String& correction) 2492 2494 { 2493 Range* replacedRange = m_correctionPanelInfo. m_rangeToBeReplaced.get();2495 Range* replacedRange = m_correctionPanelInfo.rangeToBeReplaced.get(); 2494 2496 if (!replacedRange || m_frame->document() != replacedRange->ownerDocument()) 2495 2497 return; 2496 2498 2497 String currentWord = plainText(m_correctionPanelInfo. m_rangeToBeReplaced.get());2499 String currentWord = plainText(m_correctionPanelInfo.rangeToBeReplaced.get()); 2498 2500 // Check to see if the word we are about to correct has been changed between timer firing and callback being triggered. 2499 if (currentWord != m_correctionPanelInfo. m_replacedString)2500 return; 2501 2502 m_correctionPanelInfo. m_isActive = false;2503 2504 switch (m_correctionPanelInfo. m_panelType) {2501 if (currentWord != m_correctionPanelInfo.replacedString) 2502 return; 2503 2504 m_correctionPanelInfo.isActive = false; 2505 2506 switch (m_correctionPanelInfo.panelType) { 2505 2507 case CorrectionPanelInfo::PanelTypeCorrection: 2506 replacedRange->startContainer()->document()->markers()->addMarker(replacedRange, DocumentMarker::RejectedCorrection, m_correctionPanelInfo.m_replacedString); 2508 if (correction.length()) { 2509 m_correctionPanelInfo.replacementString = correction; 2510 applyCorrectionPanelInfo(markerTypesForAutocorrection()); 2511 } else { 2512 if (!m_correctionPanelIsDismissedByEditor) 2513 replacedRange->startContainer()->document()->markers()->addMarker(replacedRange, DocumentMarker::RejectedCorrection, m_correctionPanelInfo.replacedString); 2514 } 2507 2515 break; 2508 2516 case CorrectionPanelInfo::PanelTypeReversion: 2509 applyCorrectionPanelInfo(markerTypesForReplacement());2510 2517 case CorrectionPanelInfo::PanelTypeSpellingSuggestions: 2511 2518 if (correction.length()) { 2512 m_correctionPanelInfo. m_replacementString = correction;2519 m_correctionPanelInfo.replacementString = correction; 2513 2520 applyCorrectionPanelInfo(markerTypesForReplacement()); 2514 2521 } … … 2516 2523 } 2517 2524 2518 m_correctionPanelInfo. m_rangeToBeReplaced.clear();2525 m_correctionPanelInfo.rangeToBeReplaced.clear(); 2519 2526 } 2520 2527 … … 2526 2533 if (type == CorrectionPanelInfo::PanelTypeCorrection) 2527 2534 // If type is PanelTypeReversion, then the new range has been set. So we shouldn't clear it. 2528 m_correctionPanelInfo. m_rangeToBeReplaced.clear();2529 m_correctionPanelInfo. m_panelType = type;2535 m_correctionPanelInfo.rangeToBeReplaced.clear(); 2536 m_correctionPanelInfo.panelType = type; 2530 2537 m_correctionPanelTimer.startOneShot(correctionPanelTimerInterval); 2531 2538 } … … 2539 2546 #if SUPPORT_AUTOCORRECTION_PANEL 2540 2547 m_correctionPanelTimer.stop(); 2541 m_correctionPanelInfo. m_rangeToBeReplaced.clear();2548 m_correctionPanelInfo.rangeToBeReplaced.clear(); 2542 2549 #endif 2543 2550 } … … 2546 2553 { 2547 2554 #if SUPPORT_AUTOCORRECTION_PANEL 2548 if (!m_correctionPanelInfo. m_isActive)2549 return; 2550 m_correctionPanelInfo. m_isActive = false;2555 if (!m_correctionPanelInfo.isActive) 2556 return; 2557 m_correctionPanelInfo.isActive = false; 2551 2558 if (client()) 2552 client()->dismissCorrectionPanel( CorrectionWasRejected);2559 client()->dismissCorrectionPanel(ReasonForDismissingCorrectionPanelCancelled); 2553 2560 #endif 2554 2561 } … … 2563 2570 } 2564 2571 2565 void Editor::dismissCorrectionPanel( CorrectionWasRejectedOrNot correctionWasRejectedOrNot)2572 void Editor::dismissCorrectionPanel(ReasonForDismissingCorrectionPanel reasonForDismissing) 2566 2573 { 2567 2574 #if SUPPORT_AUTOCORRECTION_PANEL 2568 if (!m_correctionPanelInfo.m_isActive) 2569 return; 2570 m_correctionPanelInfo.m_isActive = false; 2575 if (!m_correctionPanelInfo.isActive) 2576 return; 2577 m_correctionPanelInfo.isActive = false; 2578 m_correctionPanelIsDismissedByEditor = true; 2571 2579 if (client()) 2572 client()->dismissCorrectionPanel( correctionWasRejectedOrNot);2580 client()->dismissCorrectionPanel(reasonForDismissing); 2573 2581 #else 2574 UNUSED_PARAM( correctionWasRejectedOrNot);2582 UNUSED_PARAM(reasonForDismissing); 2575 2583 #endif 2576 2584 } … … 2674 2682 void Editor::applyCorrectionPanelInfo(const Vector<DocumentMarker::MarkerType>& markerTypesToAdd) 2675 2683 { 2676 if (!m_correctionPanelInfo. m_rangeToBeReplaced)2684 if (!m_correctionPanelInfo.rangeToBeReplaced) 2677 2685 return; 2678 2686 2679 2687 ExceptionCode ec = 0; 2680 RefPtr<Range> paragraphRangeContainingCorrection = m_correctionPanelInfo. m_rangeToBeReplaced->cloneRange(ec);2688 RefPtr<Range> paragraphRangeContainingCorrection = m_correctionPanelInfo.rangeToBeReplaced->cloneRange(ec); 2681 2689 if (ec) 2682 2690 return; 2683 2691 2684 setStart(paragraphRangeContainingCorrection.get(), startOfParagraph(m_correctionPanelInfo. m_rangeToBeReplaced->startPosition()));2685 setEnd(paragraphRangeContainingCorrection.get(), endOfParagraph(m_correctionPanelInfo. m_rangeToBeReplaced->endPosition()));2686 2687 // After we replace the word at range m_rangeToBeReplaced, we need to add markers to that range.2688 // However, once the replacement took place, the value of m_rangeToBeReplaced is not valid anymore.2689 // So before we carry out the replacement, we need to store the start position of m_rangeToBeReplaced2692 setStart(paragraphRangeContainingCorrection.get(), startOfParagraph(m_correctionPanelInfo.rangeToBeReplaced->startPosition())); 2693 setEnd(paragraphRangeContainingCorrection.get(), endOfParagraph(m_correctionPanelInfo.rangeToBeReplaced->endPosition())); 2694 2695 // After we replace the word at range rangeToBeReplaced, we need to add markers to that range. 2696 // However, once the replacement took place, the value of rangeToBeReplaced is not valid anymore. 2697 // So before we carry out the replacement, we need to store the start position of rangeToBeReplaced 2690 2698 // relative to the start position of the containing paragraph. We use correctionStartOffsetInParagraph 2691 2699 // to store this value. In order to obtain this offset, we need to first create a range 2692 // which spans from the start of paragraph to the start position of m_rangeToBeReplaced.2700 // which spans from the start of paragraph to the start position of rangeToBeReplaced. 2693 2701 RefPtr<Range> correctionStartOffsetInParagraphAsRange = Range::create(paragraphRangeContainingCorrection->startContainer(ec)->document(), paragraphRangeContainingCorrection->startPosition(), paragraphRangeContainingCorrection->startPosition()); 2694 2702 if (ec) 2695 2703 return; 2696 2704 2697 Position startPositionOfRangeToBeReplaced = m_correctionPanelInfo. m_rangeToBeReplaced->startPosition();2705 Position startPositionOfRangeToBeReplaced = m_correctionPanelInfo.rangeToBeReplaced->startPosition(); 2698 2706 correctionStartOffsetInParagraphAsRange->setEnd(startPositionOfRangeToBeReplaced.containerNode(), startPositionOfRangeToBeReplaced.computeOffsetInContainerNode(), ec); 2699 2707 if (ec) … … 2705 2713 2706 2714 // Clone the range, since the caller of this method may want to keep the original range around. 2707 RefPtr<Range> rangeToBeReplaced = m_correctionPanelInfo. m_rangeToBeReplaced->cloneRange(ec);2715 RefPtr<Range> rangeToBeReplaced = m_correctionPanelInfo.rangeToBeReplaced->cloneRange(ec); 2708 2716 VisibleSelection selectionToReplace(rangeToBeReplaced.get(), DOWNSTREAM); 2709 2717 if (m_frame->selection()->shouldChangeSelection(selectionToReplace)) { 2710 2718 m_frame->selection()->setSelection(selectionToReplace); 2711 replaceSelectionWithText(m_correctionPanelInfo. m_replacementString, false, false);2712 caretPosition.moveToOffset(caretPosition.offsetInContainerNode() + m_correctionPanelInfo. m_replacementString.length() - m_correctionPanelInfo.m_replacedString.length());2719 replaceSelectionWithText(m_correctionPanelInfo.replacementString, false, false); 2720 caretPosition.moveToOffset(caretPosition.offsetInContainerNode() + m_correctionPanelInfo.replacementString.length() - m_correctionPanelInfo.replacedString.length()); 2713 2721 setEnd(paragraphRangeContainingCorrection.get(), endOfParagraph(caretPosition)); 2714 RefPtr<Range> replacementRange = TextIterator::subrange(paragraphRangeContainingCorrection.get(), correctionStartOffsetInParagraph, m_correctionPanelInfo. m_replacementString.length());2722 RefPtr<Range> replacementRange = TextIterator::subrange(paragraphRangeContainingCorrection.get(), correctionStartOffsetInParagraph, m_correctionPanelInfo.replacementString.length()); 2715 2723 DocumentMarkerController* markers = replacementRange->startContainer()->document()->markers(); 2716 2724 size_t size = markerTypesToAdd.size(); 2717 2725 for (size_t i = 0; i < size; ++i) 2718 markers->addMarker(replacementRange.get(), markerTypesToAdd[i], m_correctionPanelInfo. m_replacementString);2726 markers->addMarker(replacementRange.get(), markerTypesToAdd[i], m_correctionPanelInfo.replacementString); 2719 2727 m_frame->selection()->moveTo(caretPosition, false); 2720 2728 } -
trunk/WebCore/editing/Editor.h
r73088 r73287 384 384 CorrectionPanelInfo m_correctionPanelInfo; 385 385 Timer<Editor> m_correctionPanelTimer; 386 bool m_correctionPanelIsDismissedByEditor; 386 387 VisibleSelection m_mark; 387 388 bool m_areMarkedTextMatchesHighlighted; … … 410 411 Node* findEventTargetFromSelection() const; 411 412 void stopCorrectionPanelTimer(); 412 void dismissCorrectionPanel( CorrectionWasRejectedOrNot);413 void dismissCorrectionPanel(ReasonForDismissingCorrectionPanel); 413 414 void applyCorrectionPanelInfo(const Vector<DocumentMarker::MarkerType>& markerTypesToAdd); 414 415 }; -
trunk/WebCore/loader/EmptyClients.h
r73088 r73287 482 482 #if SUPPORT_AUTOCORRECTION_PANEL 483 483 virtual void showCorrectionPanel(CorrectionPanelInfo::PanelType, const FloatRect&, const String&, const String&, const Vector<String>&, Editor*) { } 484 virtual void dismissCorrectionPanel( CorrectionWasRejectedOrNot) { }484 virtual void dismissCorrectionPanel(ReasonForDismissingCorrectionPanel) { } 485 485 virtual bool isShowingCorrectionPanel() { return false; } 486 486 #endif -
trunk/WebCore/page/EditorClient.h
r73088 r73287 192 192 #if SUPPORT_AUTOCORRECTION_PANEL 193 193 virtual void showCorrectionPanel(CorrectionPanelInfo::PanelType, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacmentString, const Vector<String>& alternativeReplacementStrings, Editor*) = 0; 194 virtual void dismissCorrectionPanel( CorrectionWasRejectedOrNot) = 0;194 virtual void dismissCorrectionPanel(ReasonForDismissingCorrectionPanel) = 0; 195 195 virtual bool isShowingCorrectionPanel() = 0; 196 196 #endif -
trunk/WebKit/mac/ChangeLog
r73237 r73287 1 2010-12-03 Jia Pu <jpu@apple.com> 2 3 Reviewed by Darin Adler. 4 5 Need to move all code that applies correction into correction panel callback. 6 https://bugs.webkit.org/show_bug.cgi?id=50426 7 <rdar://problem/8720832> 8 9 * WebCoreSupport/WebEditorClient.h: Adopted new signature of dismissCorrectionPanel. 10 11 * WebCoreSupport/WebEditorClient.mm: 12 (WebEditorClient::~WebEditorClient): Adopted new signature of dismissCorrectionPanel. 13 (WebEditorClient::showCorrectionPanel): Added more user dictionary learning code. 14 (WebEditorClient::dismissCorrectionPanel): Adopted new signature of dismissCorrectionPanel. 15 1 16 2010-12-02 Simon Fraser <simon.fraser@apple.com> 2 17 -
trunk/WebKit/mac/WebCoreSupport/WebEditorClient.h
r73088 r73287 135 135 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) 136 136 virtual void showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const WTF::String& replacedString, const WTF::String& replacementString, const WTF::Vector<WTF::String>& alternativeReplacementStrings, WebCore::Editor*); 137 virtual void dismissCorrectionPanel(WebCore:: CorrectionWasRejectedOrNot);137 virtual void dismissCorrectionPanel(WebCore::ReasonForDismissingCorrectionPanel); 138 138 virtual bool isShowingCorrectionPanel(); 139 139 #endif … … 148 148 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) 149 149 BOOL m_correctionPanelIsShown; 150 BOOL m_correctionPanelIsDismissedExternally; 151 WebCore::ReasonForDismissingCorrectionPanel m_reasonForDismissingCorrectionPanel; 150 152 #endif 151 153 }; -
trunk/WebKit/mac/WebCoreSupport/WebEditorClient.mm
r73088 r73287 211 211 { 212 212 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) 213 dismissCorrectionPanel( WebCore::CorrectionWasNotRejected);213 dismissCorrectionPanel(ReasonForDismissingCorrectionPanelIgnored); 214 214 #endif 215 215 } … … 874 874 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) 875 875 void WebEditorClient::showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType panelType, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings, Editor* editor) { 876 dismissCorrectionPanel( WebCore::CorrectionWasNotRejected);876 dismissCorrectionPanel(ReasonForDismissingCorrectionPanelIgnored); 877 877 878 878 NSRect boundingBoxAsNSRect = boundingBoxOfReplacedString; … … 885 885 886 886 m_correctionPanelIsShown = YES; 887 m_correctionPanelIsDismissedExternally = NO; 888 m_reasonForDismissingCorrectionPanel = ReasonForDismissingCorrectionPanelIgnored; 889 887 890 NSCorrectionBubbleType bubbleType = correctionBubbleType(panelType); 888 891 NSMutableArray *alternativeStrings = nil; … … 893 896 [alternativeStrings addObject:(NSString*)alternativeReplacementStrings[i]]; 894 897 } 895 898 NSSpellChecker *spellChecker = [NSSpellChecker sharedSpellChecker]; 896 899 [[NSSpellChecker sharedSpellChecker] showCorrectionBubbleOfType:bubbleType primaryString:replacementStringAsNSString alternativeStrings:alternativeStrings forStringInRect:boundingBoxAsNSRect view:m_webView completionHandler:^(NSString *acceptedString) { 897 900 switch (bubbleType) { 898 901 case NSCorrectionBubbleTypeCorrection: 899 if (!acceptedString) { 900 [[NSSpellChecker sharedSpellChecker] recordResponse:NSCorrectionResponseRejected toCorrection:replacementStringAsNSString forWord:replacedStringAsNSString language:nil inSpellDocumentWithTag:[m_webView spellCheckerDocumentTag]]; 901 editor->handleCorrectionPanelResult(String()); 902 if (acceptedString) 903 [spellChecker recordResponse:NSCorrectionResponseAccepted toCorrection:acceptedString forWord:replacedStringAsNSString language:nil inSpellDocumentWithTag:spellCheckerDocumentTag()]; 904 else { 905 if (!m_correctionPanelIsDismissedExternally || m_reasonForDismissingCorrectionPanel == ReasonForDismissingCorrectionPanelCancelled) 906 [spellChecker recordResponse:NSCorrectionResponseRejected toCorrection:replacementStringAsNSString forWord:replacedStringAsNSString language:nil inSpellDocumentWithTag:spellCheckerDocumentTag()]; 907 else 908 [spellChecker recordResponse:NSCorrectionResponseIgnored toCorrection:replacementStringAsNSString forWord:replacedStringAsNSString language:nil inSpellDocumentWithTag:spellCheckerDocumentTag()]; 902 909 } 903 910 break; 904 911 case NSCorrectionBubbleTypeReversion: 905 if (acceptedString) { 906 [[NSSpellChecker sharedSpellChecker] recordResponse:NSCorrectionResponseReverted toCorrection:replacedStringAsNSString forWord:replacementStringAsNSString language:nil inSpellDocumentWithTag:[m_webView spellCheckerDocumentTag]]; 907 editor->handleCorrectionPanelResult(String()); 908 } 912 if (acceptedString) 913 [spellChecker recordResponse:NSCorrectionResponseReverted toCorrection:replacedStringAsNSString forWord:acceptedString language:nil inSpellDocumentWithTag:spellCheckerDocumentTag()]; 909 914 break; 910 915 case NSCorrectionBubbleTypeGuesses: 911 916 if (acceptedString) 912 917 [[NSSpellChecker sharedSpellChecker] recordResponse:NSCorrectionResponseAccepted toCorrection:acceptedString forWord:replacedStringAsNSString language:nil inSpellDocumentWithTag:[m_webView spellCheckerDocumentTag]]; 913 editor->handleCorrectionPanelResult(String(acceptedString));914 918 break; 915 919 } 920 editor->handleCorrectionPanelResult(String(acceptedString)); 916 921 }]; 917 922 } 918 923 919 void WebEditorClient::dismissCorrectionPanel( WebCore::CorrectionWasRejectedOrNot correctionWasRejectedOrNot)924 void WebEditorClient::dismissCorrectionPanel(ReasonForDismissingCorrectionPanel reasonForDismissing) 920 925 { 921 926 if (isShowingCorrectionPanel()) { 922 if (correctionWasRejectedOrNot == CorrectionWasRejected) 927 m_correctionPanelIsDismissedExternally = YES; 928 m_reasonForDismissingCorrectionPanel = reasonForDismissing; 929 if (reasonForDismissing == ReasonForDismissingCorrectionPanelAccepted) 930 [[NSSpellChecker sharedSpellChecker] dismissCorrectionBubbleForView:m_webView]; 931 else 923 932 [[NSSpellChecker sharedSpellChecker] cancelCorrectionBubbleForView:m_webView]; 924 else925 [[NSSpellChecker sharedSpellChecker] dismissCorrectionBubbleForView:m_webView];926 933 m_correctionPanelIsShown = NO; 927 934 } -
trunk/WebKit2/ChangeLog
r73286 r73287 1 2010-12-03 Jia Pu <jpu@apple.com> 2 3 Reviewed by Darin Adler. 4 5 Need to move all code that applies correction into correction panel callback. 6 https://bugs.webkit.org/show_bug.cgi?id=50426 7 <rdar://problem/8720832> 8 9 Adopted new signature of dismissCorrectionPanel. 10 11 * WebProcess/WebCoreSupport/WebEditorClient.h: 12 * WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm: 13 (WebKit::WebEditorClient::dismissCorrectionPanel): 14 1 15 2010-12-03 Jessie Berlin <jberlin@apple.com> 2 16 -
trunk/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h
r73088 r73287 136 136 #if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) 137 137 virtual void showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings, WebCore::Editor*); 138 virtual void dismissCorrectionPanel(WebCore:: CorrectionWasRejectedOrNot);138 virtual void dismissCorrectionPanel(WebCore::ReasonForDismissingCorrectionPanel); 139 139 virtual bool isShowingCorrectionPanel(); 140 140 #endif -
trunk/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm
r73088 r73287 229 229 } 230 230 231 void WebEditorClient::dismissCorrectionPanel(WebCore:: CorrectionWasRejectedOrNot)231 void WebEditorClient::dismissCorrectionPanel(WebCore::ReasonForDismissingCorrectionPanel) 232 232 { 233 233 notImplemented();
Note: See TracChangeset
for help on using the changeset viewer.