2011-04-06 MORITA Hajime <morrita@google.com>
Reviewed by Darin Adler.
[Refactoring] Auto correction panel should be handled by its own class.
https://bugs.webkit.org/show_bug.cgi?id=55571
Extracted code inside SUPPORT_AUTOCORRECTION_PANEL into
SpellingCorrectionController class.
This change also remove some SUPPORT_AUTOCORRECTION_PANEL guard if
code paths inside the never reached without autocorrection support.
Removing guards reduces unintentional build breakage.
No new tests, no behavior chagne.
* CMakeLists.txt:
* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* editing/CorrectionPanelInfo.h: Removed.
* editing/EditingAllInOne.cpp:
* editing/Editor.cpp:
(WebCore::Editor::respondToChangedSelection):
(WebCore::Editor::respondToChangedContents):
(WebCore::Editor::appliedEditing):
(WebCore::Editor::Editor):
(WebCore::Editor::~Editor):
(WebCore::Editor::insertTextWithoutSendingTextEvent):
(WebCore::Editor::insertLineBreak):
(WebCore::Editor::insertParagraphSeparator):
(WebCore::Editor::cut):
(WebCore::Editor::paste):
(WebCore::Editor::pasteAsPlainText):
(WebCore::Editor::isAutomaticSpellingCorrectionEnabled):
(WebCore::Editor::markMisspellingsAfterTypingToWord):
(WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges):
(WebCore::Editor::changeBackToReplacedString):
(WebCore::Editor::unappliedSpellCorrection):
(WebCore::Editor::updateMarkersForWordsAffectedByEditing):
(WebCore::Editor::startCorrectionPanelTimer):
(WebCore::Editor::handleCorrectionPanelResult):
(WebCore::Editor::dismissCorrectionPanelAsIgnored):
* editing/Editor.h:
* editing/SpellingCorrectionCommand.cpp:
* editing/SpellingCorrectionController.cpp: Added.
(WebCore::markerTypesForAutocorrection):
(WebCore::markerTypesForReplacement):
(WebCore::markersHaveIdenticalDescription):
(WebCore::SpellingCorrectionController::SpellingCorrectionController):
(WebCore::SpellingCorrectionController::~SpellingCorrectionController):
(WebCore::SpellingCorrectionController::startCorrectionPanelTimer):
(WebCore::SpellingCorrectionController::stopCorrectionPanelTimer):
(WebCore::SpellingCorrectionController::stopPendingCorrection):
(WebCore::SpellingCorrectionController::applyPendingCorrection):
(WebCore::SpellingCorrectionController::hasPendingCorrection):
(WebCore::SpellingCorrectionController::isSpellingMarkerAllowed):
(WebCore::SpellingCorrectionController::show):
(WebCore::SpellingCorrectionController::handleCancelOperation):
(WebCore::SpellingCorrectionController::dismiss):
(WebCore::SpellingCorrectionController::dismissSoon):
(WebCore::SpellingCorrectionController::applyCorrectionPanelInfo):
(WebCore::SpellingCorrectionController::applyAutocorrectionBeforeTypingIfAppropriate):
(WebCore::SpellingCorrectionController::respondToUnappliedSpellCorrection):
(WebCore::SpellingCorrectionController::correctionPanelTimerFired):
(WebCore::SpellingCorrectionController::handleCorrectionPanelResult):
(WebCore::SpellingCorrectionController::isAutomaticSpellingCorrectionEnabled):
(WebCore::SpellingCorrectionController::windowRectForRange):
(WebCore::SpellingCorrectionController::respondToChangedSelection):
(WebCore::SpellingCorrectionController::respondToAppliedEditing):
(WebCore::SpellingCorrectionController::client):
(WebCore::SpellingCorrectionController::textChecker):
(WebCore::SpellingCorrectionController::recordAutocorrectionResponseReversed):
(WebCore::SpellingCorrectionController::markReversed):
(WebCore::SpellingCorrectionController::markCorrection):
(WebCore::SpellingCorrectionController::recordSpellcheckerResponseForModifiedCorrection):
* editing/SpellingCorrectionController.h: Added.
(WebCore::SpellingCorrectionController::UNLESS_ENABLED):
(WebCore::SpellingCorrectionController::shouldStartTimeFor):
(WebCore::SpellingCorrectionController::shouldRemoveMarkersUponEditing):
* editing/TypingCommand.cpp:
(WebCore::TypingCommand::insertText):
(WebCore::TypingCommand::markMisspellingsAfterTyping):
(WebCore::TypingCommand::deleteKeyPressed):
(WebCore::TypingCommand::forwardDeleteKeyPressed):
* editing/htmlediting.h:
(WebCore::isAmbiguousBoundaryCharacter):
* page/EditorClient.h:
* page/Frame.cpp:
(WebCore::Frame::setPageAndTextZoomFactors):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@83344 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/editing/TypingCommand.cpp b/Source/WebCore/editing/TypingCommand.cpp
index 1ff2524..3f95d0d 100644
--- a/Source/WebCore/editing/TypingCommand.cpp
+++ b/Source/WebCore/editing/TypingCommand.cpp
@@ -154,11 +154,9 @@
Frame* frame = document->frame();
ASSERT(frame);
-#if REMOVE_MARKERS_UPON_EDITING
if (!text.isEmpty())
- document->frame()->editor()->removeSpellAndCorrectionMarkersFromWordsToBeEdited(isSpaceOrNewline(text.characters()[0]));
-#endif
-
+ document->frame()->editor()->updateMarkersForWordsAffectedByEditing(isSpaceOrNewline(text.characters()[0]));
+
insertText(document, text, frame->selection()->selection(), options, composition);
}
@@ -344,12 +342,8 @@
VisiblePosition p2 = startOfWord(start, LeftWordIfOnBoundary);
if (p1 != p2)
document()->frame()->editor()->markMisspellingsAfterTypingToWord(p1, endingSelection());
-#if SUPPORT_AUTOCORRECTION_PANEL
else if (commandType == TypingCommand::InsertText)
- document()->frame()->editor()->startCorrectionPanelTimer(CorrectionPanelInfo::PanelTypeCorrection);
-#else
- UNUSED_PARAM(commandType);
-#endif
+ document()->frame()->editor()->startCorrectionPanelTimer();
}
}
@@ -468,9 +462,8 @@
void TypingCommand::deleteKeyPressed(TextGranularity granularity, bool killRing)
{
-#if REMOVE_MARKERS_UPON_EDITING
- document()->frame()->editor()->removeSpellAndCorrectionMarkersFromWordsToBeEdited(false);
-#endif
+ document()->frame()->editor()->updateMarkersForWordsAffectedByEditing(false);
+
VisibleSelection selectionToDelete;
VisibleSelection selectionAfterUndo;
@@ -567,9 +560,8 @@
void TypingCommand::forwardDeleteKeyPressed(TextGranularity granularity, bool killRing)
{
-#if REMOVE_MARKERS_UPON_EDITING
- document()->frame()->editor()->removeSpellAndCorrectionMarkersFromWordsToBeEdited(false);
-#endif
+ document()->frame()->editor()->updateMarkersForWordsAffectedByEditing(false);
+
VisibleSelection selectionToDelete;
VisibleSelection selectionAfterUndo;