[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da
commit-queue at webkit.org
commit-queue at webkit.org
Wed Dec 22 17:58:35 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 7ae7c0a1c3abe4ba67eb73c35cdb7ed77a3785b5
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Dec 3 20:45:34 2010 +0000
2010-12-03 Jia Pu <jpu at apple.com>
Reviewed by Darin Adler.
Need to move all code that applies correction into correction panel callback.
https://bugs.webkit.org/show_bug.cgi?id=50426
<rdar://problem/8720832>
Added expected png file.
* platform/mac/editing/spelling/delete-autocorrected-word-1-expected.checksum: Added.
* platform/mac/editing/spelling/delete-autocorrected-word-1-expected.png: Added.
2010-12-03 Jia Pu <jpu at apple.com>
Reviewed by Darin Adler.
Need to move all code that applies correction into correction panel callback.
https://bugs.webkit.org/show_bug.cgi?id=50426
<rdar://problem/8720832>
No new test, since there's no behavioral change.
This patch is to prepare WebKit to work with upcoming AppKit changes. The main changes are:
1. Moved all calls to applyCorrectionPanelInfo() into handleCorrectionPanelResult().
2. Added more user dictionary learning code.
3. Removed m_ prefix in all member variables of CorrectionPanelInfo.
* editing/CorrectionPanelInfo.h: Remove m_ prefix on member variables. Added ReasonForDismissingCorrectionPanel enum type.
* editing/Editor.cpp: Moved all calls to applyCorrectionPanelInfo() into handleCorrectionPanelResult().
Adopted new member variable naming in class CorrectionPanelInfo.
(WebCore::Editor::respondToChangedSelection):
(WebCore::Editor::~Editor):
(WebCore::Editor::markMisspellingsAfterTypingToWord):
(WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges):
(WebCore::Editor::correctionPanelTimerFired):
(WebCore::Editor::handleCorrectionPanelResult):
(WebCore::Editor::startCorrectionPanelTimer):
(WebCore::Editor::stopCorrectionPanelTimer):
(WebCore::Editor::handleCancelOperation):
(WebCore::Editor::dismissCorrectionPanel):
(WebCore::Editor::applyCorrectionPanelInfo):
* editing/Editor.h: Changed signature of dismissCorrectionPanel to use ReasonForDismissingCorrectionPanel.
* loader/EmptyClients.h: Ditto.
(WebCore::EmptyEditorClient::dismissCorrectionPanel):
* page/EditorClient.h: Ditto.
2010-12-03 Jia Pu <jpu at apple.com>
Reviewed by Darin Adler.
Need to move all code that applies correction into correction panel callback.
https://bugs.webkit.org/show_bug.cgi?id=50426
<rdar://problem/8720832>
* WebCoreSupport/WebEditorClient.h: Adopted new signature of dismissCorrectionPanel.
* WebCoreSupport/WebEditorClient.mm:
(WebEditorClient::~WebEditorClient): Adopted new signature of dismissCorrectionPanel.
(WebEditorClient::showCorrectionPanel): Added more user dictionary learning code.
(WebEditorClient::dismissCorrectionPanel): Adopted new signature of dismissCorrectionPanel.
2010-12-03 Jia Pu <jpu at apple.com>
Reviewed by Darin Adler.
Need to move all code that applies correction into correction panel callback.
https://bugs.webkit.org/show_bug.cgi?id=50426
<rdar://problem/8720832>
Adopted new signature of dismissCorrectionPanel.
* WebProcess/WebCoreSupport/WebEditorClient.h:
* WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:
(WebKit::WebEditorClient::dismissCorrectionPanel):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73287 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index f586b23..a5d7e2e 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,16 @@
+2010-12-03 Jia Pu <jpu at apple.com>
+
+ Reviewed by Darin Adler.
+
+ Need to move all code that applies correction into correction panel callback.
+ https://bugs.webkit.org/show_bug.cgi?id=50426
+ <rdar://problem/8720832>
+
+ Added expected png file.
+
+ * platform/mac/editing/spelling/delete-autocorrected-word-1-expected.checksum: Added.
+ * platform/mac/editing/spelling/delete-autocorrected-word-1-expected.png: Added.
+
2010-12-03 Sam Weinig <sam at webkit.org>
Reviewed by Gavin Barraclough.
diff --git a/LayoutTests/platform/mac/editing/spelling/delete-autocorrected-word-1-expected.checksum b/LayoutTests/platform/mac/editing/spelling/delete-autocorrected-word-1-expected.checksum
new file mode 100644
index 0000000..0c077c4
--- /dev/null
+++ b/LayoutTests/platform/mac/editing/spelling/delete-autocorrected-word-1-expected.checksum
@@ -0,0 +1 @@
+0ee986a646ea5ac08399ac3f19985e34
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/editing/spelling/delete-autocorrected-word-1-expected.png b/LayoutTests/platform/mac/editing/spelling/delete-autocorrected-word-1-expected.png
new file mode 100644
index 0000000..6c482a2
Binary files /dev/null and b/LayoutTests/platform/mac/editing/spelling/delete-autocorrected-word-1-expected.png differ
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index c838e54..9689fda 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,41 @@
+2010-12-03 Jia Pu <jpu at apple.com>
+
+ Reviewed by Darin Adler.
+
+ Need to move all code that applies correction into correction panel callback.
+ https://bugs.webkit.org/show_bug.cgi?id=50426
+ <rdar://problem/8720832>
+
+ No new test, since there's no behavioral change.
+
+ This patch is to prepare WebKit to work with upcoming AppKit changes. The main changes are:
+ 1. Moved all calls to applyCorrectionPanelInfo() into handleCorrectionPanelResult().
+ 2. Added more user dictionary learning code.
+ 3. Removed m_ prefix in all member variables of CorrectionPanelInfo.
+
+ * editing/CorrectionPanelInfo.h: Remove m_ prefix on member variables. Added ReasonForDismissingCorrectionPanel enum type.
+
+ * editing/Editor.cpp: Moved all calls to applyCorrectionPanelInfo() into handleCorrectionPanelResult().
+ Adopted new member variable naming in class CorrectionPanelInfo.
+ (WebCore::Editor::respondToChangedSelection):
+ (WebCore::Editor::~Editor):
+ (WebCore::Editor::markMisspellingsAfterTypingToWord):
+ (WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges):
+ (WebCore::Editor::correctionPanelTimerFired):
+ (WebCore::Editor::handleCorrectionPanelResult):
+ (WebCore::Editor::startCorrectionPanelTimer):
+ (WebCore::Editor::stopCorrectionPanelTimer):
+ (WebCore::Editor::handleCancelOperation):
+ (WebCore::Editor::dismissCorrectionPanel):
+ (WebCore::Editor::applyCorrectionPanelInfo):
+
+ * editing/Editor.h: Changed signature of dismissCorrectionPanel to use ReasonForDismissingCorrectionPanel.
+
+ * loader/EmptyClients.h: Ditto.
+ (WebCore::EmptyEditorClient::dismissCorrectionPanel):
+
+ * page/EditorClient.h: Ditto.
+
2010-12-03 Pavel Feldman <pfeldman at chromium.org>
Reviewed by Yury Semikhatsky.
diff --git a/WebCore/editing/CorrectionPanelInfo.h b/WebCore/editing/CorrectionPanelInfo.h
index edc2bf7..76099e1 100644
--- a/WebCore/editing/CorrectionPanelInfo.h
+++ b/WebCore/editing/CorrectionPanelInfo.h
@@ -48,15 +48,18 @@ struct CorrectionPanelInfo {
PanelTypeSpellingSuggestions
};
- RefPtr<Range> m_rangeToBeReplaced;
- String m_replacedString;
- String m_replacementString;
- PanelType m_panelType;
- bool m_isActive;
+ RefPtr<Range> rangeToBeReplaced;
+ String replacedString;
+ String replacementString;
+ PanelType panelType;
+ bool isActive;
};
-enum CorrectionWasRejectedOrNot { CorrectionWasNotRejected, CorrectionWasRejected };
-
+enum ReasonForDismissingCorrectionPanel {
+ ReasonForDismissingCorrectionPanelCancelled = 0,
+ ReasonForDismissingCorrectionPanelIgnored,
+ ReasonForDismissingCorrectionPanelAccepted
+};
} // namespace WebCore
#endif // CorrectionPanelInfo_h
diff --git a/WebCore/editing/Editor.cpp b/WebCore/editing/Editor.cpp
index 8c85363..6aa7b20 100644
--- a/WebCore/editing/Editor.cpp
+++ b/WebCore/editing/Editor.cpp
@@ -93,16 +93,6 @@ static inline bool isAmbiguousBoundaryCharacter(UChar character)
}
#if SUPPORT_AUTOCORRECTION_PANEL
-static const Vector<DocumentMarker::MarkerType>& markerTypesForAutocorrection()
-{
- DEFINE_STATIC_LOCAL(Vector<DocumentMarker::MarkerType>, markerTypesForAutoCorrection, ());
- if (markerTypesForAutoCorrection.isEmpty()) {
- markerTypesForAutoCorrection.append(DocumentMarker::Replacement);
- markerTypesForAutoCorrection.append(DocumentMarker::CorrectionIndicator);
- }
- return markerTypesForAutoCorrection;
-}
-
static FloatRect boundingBoxForRange(Range* range)
{
Vector<FloatQuad> textQuads;
@@ -115,6 +105,16 @@ static FloatRect boundingBoxForRange(Range* range)
}
#endif // SUPPORT_AUTOCORRECTION_PANEL
+static const Vector<DocumentMarker::MarkerType>& markerTypesForAutocorrection()
+{
+ DEFINE_STATIC_LOCAL(Vector<DocumentMarker::MarkerType>, markerTypesForAutoCorrection, ());
+ if (markerTypesForAutoCorrection.isEmpty()) {
+ markerTypesForAutoCorrection.append(DocumentMarker::Replacement);
+ markerTypesForAutoCorrection.append(DocumentMarker::CorrectionIndicator);
+ }
+ return markerTypesForAutoCorrection;
+}
+
static const Vector<DocumentMarker::MarkerType>& markerTypesForReplacement()
{
DEFINE_STATIC_LOCAL(Vector<DocumentMarker::MarkerType>, markerTypesForReplacement, ());
@@ -500,7 +500,7 @@ void Editor::respondToChangedSelection(const VisibleSelection& oldSelection)
VisibleSelection currentSelection(frame()->selection()->selection());
if (currentSelection != oldSelection) {
stopCorrectionPanelTimer();
- dismissCorrectionPanel(CorrectionWasNotRejected);
+ dismissCorrectionPanel(ReasonForDismissingCorrectionPanelIgnored);
}
#endif // SUPPORT_AUTOCORRECTION_PANEL
@@ -535,12 +535,12 @@ void Editor::respondToChangedSelection(const VisibleSelection& oldSelection)
RefPtr<Range> wordRange = Range::create(frame()->document(), node, marker.startOffset, node, marker.endOffset);
String currentWord = plainText(wordRange.get());
if (currentWord.length()) {
- m_correctionPanelInfo.m_rangeToBeReplaced = wordRange;
- m_correctionPanelInfo.m_replacedString = currentWord;
+ m_correctionPanelInfo.rangeToBeReplaced = wordRange;
+ m_correctionPanelInfo.replacedString = currentWord;
if (marker.type == DocumentMarker::Spelling)
startCorrectionPanelTimer(CorrectionPanelInfo::PanelTypeSpellingSuggestions);
else {
- m_correctionPanelInfo.m_replacementString = marker.description;
+ m_correctionPanelInfo.replacementString = marker.description;
startCorrectionPanelTimer(CorrectionPanelInfo::PanelTypeReversion);
}
}
@@ -1147,7 +1147,7 @@ Editor::Editor(Frame* frame)
Editor::~Editor()
{
#if SUPPORT_AUTOCORRECTION_PANEL
- dismissCorrectionPanel(CorrectionWasNotRejected);
+ dismissCorrectionPanel(ReasonForDismissingCorrectionPanelIgnored);
#endif
}
@@ -2055,8 +2055,9 @@ void Editor::markMisspellingsAfterTypingToWord(const VisiblePosition &wordStart,
doApplyCorrection = false;
}
if (doApplyCorrection)
- applyCorrectionPanelInfo(markerTypesForAutocorrection());
- m_correctionPanelInfo.m_rangeToBeReplaced.clear();
+ dismissCorrectionPanel(ReasonForDismissingCorrectionPanelAccepted);
+ else
+ m_correctionPanelInfo.rangeToBeReplaced.clear();
#else
UNUSED_PARAM(selectionAfterTyping);
#endif
@@ -2373,11 +2374,11 @@ void Editor::markAllMisspellingsAndBadGrammarInRanges(TextCheckingOptions textCh
FloatRect totalBoundingBox;
for (Vector<FloatQuad>::const_iterator it = textQuads.begin(); it < end; ++it)
totalBoundingBox.unite(it->boundingBox());
- m_correctionPanelInfo.m_rangeToBeReplaced = rangeToReplace;
- m_correctionPanelInfo.m_replacedString = replacedString;
- m_correctionPanelInfo.m_replacementString = result->replacement;
- m_correctionPanelInfo.m_isActive = true;
- client()->showCorrectionPanel(m_correctionPanelInfo.m_panelType, totalBoundingBox, m_correctionPanelInfo.m_replacedString, result->replacement, Vector<String>(), this);
+ m_correctionPanelInfo.rangeToBeReplaced = rangeToReplace;
+ m_correctionPanelInfo.replacedString = replacedString;
+ m_correctionPanelInfo.replacementString = result->replacement;
+ m_correctionPanelInfo.isActive = true;
+ client()->showCorrectionPanel(m_correctionPanelInfo.panelType, totalBoundingBox, m_correctionPanelInfo.replacedString, result->replacement, Vector<String>(), this);
doReplacement = false;
}
#endif
@@ -2455,7 +2456,8 @@ void Editor::markMisspellingsAndBadGrammar(const VisibleSelection& spellingSelec
void Editor::correctionPanelTimerFired(Timer<Editor>*)
{
#if SUPPORT_AUTOCORRECTION_PANEL
- switch (m_correctionPanelInfo.m_panelType) {
+ m_correctionPanelIsDismissedByEditor = false;
+ switch (m_correctionPanelInfo.panelType) {
case CorrectionPanelInfo::PanelTypeCorrection: {
VisibleSelection selection(frame()->selection()->selection());
VisiblePosition start(selection.start(), selection.affinity());
@@ -2465,23 +2467,23 @@ void Editor::correctionPanelTimerFired(Timer<Editor>*)
}
break;
case CorrectionPanelInfo::PanelTypeReversion: {
- m_correctionPanelInfo.m_isActive = true;
- m_correctionPanelInfo.m_replacedString = plainText(m_correctionPanelInfo.m_rangeToBeReplaced.get());
- client()->showCorrectionPanel(m_correctionPanelInfo.m_panelType, boundingBoxForRange(m_correctionPanelInfo.m_rangeToBeReplaced.get()), m_correctionPanelInfo.m_replacedString, m_correctionPanelInfo.m_replacementString, Vector<String>(), this);
+ m_correctionPanelInfo.isActive = true;
+ m_correctionPanelInfo.replacedString = plainText(m_correctionPanelInfo.rangeToBeReplaced.get());
+ client()->showCorrectionPanel(m_correctionPanelInfo.panelType, boundingBoxForRange(m_correctionPanelInfo.rangeToBeReplaced.get()), m_correctionPanelInfo.replacedString, m_correctionPanelInfo.replacementString, Vector<String>(), this);
}
break;
case CorrectionPanelInfo::PanelTypeSpellingSuggestions: {
- if (plainText(m_correctionPanelInfo.m_rangeToBeReplaced.get()) != m_correctionPanelInfo.m_replacedString)
+ if (plainText(m_correctionPanelInfo.rangeToBeReplaced.get()) != m_correctionPanelInfo.replacedString)
break;
- String paragraphText = plainText(TextCheckingParagraph(m_correctionPanelInfo.m_rangeToBeReplaced).paragraphRange().get());
+ String paragraphText = plainText(TextCheckingParagraph(m_correctionPanelInfo.rangeToBeReplaced).paragraphRange().get());
Vector<String> suggestions;
- client()->getGuessesForWord(m_correctionPanelInfo.m_replacedString, paragraphText, suggestions);
+ client()->getGuessesForWord(m_correctionPanelInfo.replacedString, paragraphText, suggestions);
if (suggestions.isEmpty())
break;
String topSuggestion = suggestions.first();
suggestions.remove(0);
- m_correctionPanelInfo.m_isActive = true;
- client()->showCorrectionPanel(m_correctionPanelInfo.m_panelType, boundingBoxForRange(m_correctionPanelInfo.m_rangeToBeReplaced.get()), m_correctionPanelInfo.m_replacedString, topSuggestion, suggestions, this);
+ m_correctionPanelInfo.isActive = true;
+ client()->showCorrectionPanel(m_correctionPanelInfo.panelType, boundingBoxForRange(m_correctionPanelInfo.rangeToBeReplaced.get()), m_correctionPanelInfo.replacedString, topSuggestion, suggestions, this);
}
break;
}
@@ -2490,32 +2492,37 @@ void Editor::correctionPanelTimerFired(Timer<Editor>*)
void Editor::handleCorrectionPanelResult(const String& correction)
{
- Range* replacedRange = m_correctionPanelInfo.m_rangeToBeReplaced.get();
+ Range* replacedRange = m_correctionPanelInfo.rangeToBeReplaced.get();
if (!replacedRange || m_frame->document() != replacedRange->ownerDocument())
return;
- String currentWord = plainText(m_correctionPanelInfo.m_rangeToBeReplaced.get());
+ String currentWord = plainText(m_correctionPanelInfo.rangeToBeReplaced.get());
// Check to see if the word we are about to correct has been changed between timer firing and callback being triggered.
- if (currentWord != m_correctionPanelInfo.m_replacedString)
+ if (currentWord != m_correctionPanelInfo.replacedString)
return;
- m_correctionPanelInfo.m_isActive = false;
+ m_correctionPanelInfo.isActive = false;
- switch (m_correctionPanelInfo.m_panelType) {
+ switch (m_correctionPanelInfo.panelType) {
case CorrectionPanelInfo::PanelTypeCorrection:
- replacedRange->startContainer()->document()->markers()->addMarker(replacedRange, DocumentMarker::RejectedCorrection, m_correctionPanelInfo.m_replacedString);
+ if (correction.length()) {
+ m_correctionPanelInfo.replacementString = correction;
+ applyCorrectionPanelInfo(markerTypesForAutocorrection());
+ } else {
+ if (!m_correctionPanelIsDismissedByEditor)
+ replacedRange->startContainer()->document()->markers()->addMarker(replacedRange, DocumentMarker::RejectedCorrection, m_correctionPanelInfo.replacedString);
+ }
break;
case CorrectionPanelInfo::PanelTypeReversion:
- applyCorrectionPanelInfo(markerTypesForReplacement());
case CorrectionPanelInfo::PanelTypeSpellingSuggestions:
if (correction.length()) {
- m_correctionPanelInfo.m_replacementString = correction;
+ m_correctionPanelInfo.replacementString = correction;
applyCorrectionPanelInfo(markerTypesForReplacement());
}
break;
}
- m_correctionPanelInfo.m_rangeToBeReplaced.clear();
+ m_correctionPanelInfo.rangeToBeReplaced.clear();
}
void Editor::startCorrectionPanelTimer(CorrectionPanelInfo::PanelType type)
@@ -2525,8 +2532,8 @@ void Editor::startCorrectionPanelTimer(CorrectionPanelInfo::PanelType type)
if (isAutomaticSpellingCorrectionEnabled()) {
if (type == CorrectionPanelInfo::PanelTypeCorrection)
// If type is PanelTypeReversion, then the new range has been set. So we shouldn't clear it.
- m_correctionPanelInfo.m_rangeToBeReplaced.clear();
- m_correctionPanelInfo.m_panelType = type;
+ m_correctionPanelInfo.rangeToBeReplaced.clear();
+ m_correctionPanelInfo.panelType = type;
m_correctionPanelTimer.startOneShot(correctionPanelTimerInterval);
}
#else
@@ -2538,18 +2545,18 @@ void Editor::stopCorrectionPanelTimer()
{
#if SUPPORT_AUTOCORRECTION_PANEL
m_correctionPanelTimer.stop();
- m_correctionPanelInfo.m_rangeToBeReplaced.clear();
+ m_correctionPanelInfo.rangeToBeReplaced.clear();
#endif
}
void Editor::handleCancelOperation()
{
#if SUPPORT_AUTOCORRECTION_PANEL
- if (!m_correctionPanelInfo.m_isActive)
+ if (!m_correctionPanelInfo.isActive)
return;
- m_correctionPanelInfo.m_isActive = false;
+ m_correctionPanelInfo.isActive = false;
if (client())
- client()->dismissCorrectionPanel(CorrectionWasRejected);
+ client()->dismissCorrectionPanel(ReasonForDismissingCorrectionPanelCancelled);
#endif
}
@@ -2562,16 +2569,17 @@ bool Editor::isShowingCorrectionPanel()
return false;
}
-void Editor::dismissCorrectionPanel(CorrectionWasRejectedOrNot correctionWasRejectedOrNot)
+void Editor::dismissCorrectionPanel(ReasonForDismissingCorrectionPanel reasonForDismissing)
{
#if SUPPORT_AUTOCORRECTION_PANEL
- if (!m_correctionPanelInfo.m_isActive)
+ if (!m_correctionPanelInfo.isActive)
return;
- m_correctionPanelInfo.m_isActive = false;
+ m_correctionPanelInfo.isActive = false;
+ m_correctionPanelIsDismissedByEditor = true;
if (client())
- client()->dismissCorrectionPanel(correctionWasRejectedOrNot);
+ client()->dismissCorrectionPanel(reasonForDismissing);
#else
- UNUSED_PARAM(correctionWasRejectedOrNot);
+ UNUSED_PARAM(reasonForDismissing);
#endif
}
void Editor::removeSpellAndCorrectionMarkersFromWordsToBeEdited(bool doNotRemoveIfSelectionAtWordBoundary)
@@ -2673,28 +2681,28 @@ void Editor::removeSpellAndCorrectionMarkersFromWordsToBeEdited(bool doNotRemove
void Editor::applyCorrectionPanelInfo(const Vector<DocumentMarker::MarkerType>& markerTypesToAdd)
{
- if (!m_correctionPanelInfo.m_rangeToBeReplaced)
+ if (!m_correctionPanelInfo.rangeToBeReplaced)
return;
ExceptionCode ec = 0;
- RefPtr<Range> paragraphRangeContainingCorrection = m_correctionPanelInfo.m_rangeToBeReplaced->cloneRange(ec);
+ RefPtr<Range> paragraphRangeContainingCorrection = m_correctionPanelInfo.rangeToBeReplaced->cloneRange(ec);
if (ec)
return;
- setStart(paragraphRangeContainingCorrection.get(), startOfParagraph(m_correctionPanelInfo.m_rangeToBeReplaced->startPosition()));
- setEnd(paragraphRangeContainingCorrection.get(), endOfParagraph(m_correctionPanelInfo.m_rangeToBeReplaced->endPosition()));
+ setStart(paragraphRangeContainingCorrection.get(), startOfParagraph(m_correctionPanelInfo.rangeToBeReplaced->startPosition()));
+ setEnd(paragraphRangeContainingCorrection.get(), endOfParagraph(m_correctionPanelInfo.rangeToBeReplaced->endPosition()));
- // After we replace the word at range m_rangeToBeReplaced, we need to add markers to that range.
- // However, once the replacement took place, the value of m_rangeToBeReplaced is not valid anymore.
- // So before we carry out the replacement, we need to store the start position of m_rangeToBeReplaced
+ // After we replace the word at range rangeToBeReplaced, we need to add markers to that range.
+ // However, once the replacement took place, the value of rangeToBeReplaced is not valid anymore.
+ // So before we carry out the replacement, we need to store the start position of rangeToBeReplaced
// relative to the start position of the containing paragraph. We use correctionStartOffsetInParagraph
// to store this value. In order to obtain this offset, we need to first create a range
- // which spans from the start of paragraph to the start position of m_rangeToBeReplaced.
+ // which spans from the start of paragraph to the start position of rangeToBeReplaced.
RefPtr<Range> correctionStartOffsetInParagraphAsRange = Range::create(paragraphRangeContainingCorrection->startContainer(ec)->document(), paragraphRangeContainingCorrection->startPosition(), paragraphRangeContainingCorrection->startPosition());
if (ec)
return;
- Position startPositionOfRangeToBeReplaced = m_correctionPanelInfo.m_rangeToBeReplaced->startPosition();
+ Position startPositionOfRangeToBeReplaced = m_correctionPanelInfo.rangeToBeReplaced->startPosition();
correctionStartOffsetInParagraphAsRange->setEnd(startPositionOfRangeToBeReplaced.containerNode(), startPositionOfRangeToBeReplaced.computeOffsetInContainerNode(), ec);
if (ec)
return;
@@ -2704,18 +2712,18 @@ void Editor::applyCorrectionPanelInfo(const Vector<DocumentMarker::MarkerType>&
Position caretPosition = m_frame->selection()->selection().end();
// Clone the range, since the caller of this method may want to keep the original range around.
- RefPtr<Range> rangeToBeReplaced = m_correctionPanelInfo.m_rangeToBeReplaced->cloneRange(ec);
+ RefPtr<Range> rangeToBeReplaced = m_correctionPanelInfo.rangeToBeReplaced->cloneRange(ec);
VisibleSelection selectionToReplace(rangeToBeReplaced.get(), DOWNSTREAM);
if (m_frame->selection()->shouldChangeSelection(selectionToReplace)) {
m_frame->selection()->setSelection(selectionToReplace);
- replaceSelectionWithText(m_correctionPanelInfo.m_replacementString, false, false);
- caretPosition.moveToOffset(caretPosition.offsetInContainerNode() + m_correctionPanelInfo.m_replacementString.length() - m_correctionPanelInfo.m_replacedString.length());
+ replaceSelectionWithText(m_correctionPanelInfo.replacementString, false, false);
+ caretPosition.moveToOffset(caretPosition.offsetInContainerNode() + m_correctionPanelInfo.replacementString.length() - m_correctionPanelInfo.replacedString.length());
setEnd(paragraphRangeContainingCorrection.get(), endOfParagraph(caretPosition));
- RefPtr<Range> replacementRange = TextIterator::subrange(paragraphRangeContainingCorrection.get(), correctionStartOffsetInParagraph, m_correctionPanelInfo.m_replacementString.length());
+ RefPtr<Range> replacementRange = TextIterator::subrange(paragraphRangeContainingCorrection.get(), correctionStartOffsetInParagraph, m_correctionPanelInfo.replacementString.length());
DocumentMarkerController* markers = replacementRange->startContainer()->document()->markers();
size_t size = markerTypesToAdd.size();
for (size_t i = 0; i < size; ++i)
- markers->addMarker(replacementRange.get(), markerTypesToAdd[i], m_correctionPanelInfo.m_replacementString);
+ markers->addMarker(replacementRange.get(), markerTypesToAdd[i], m_correctionPanelInfo.replacementString);
m_frame->selection()->moveTo(caretPosition, false);
}
}
diff --git a/WebCore/editing/Editor.h b/WebCore/editing/Editor.h
index abba4f4..068760b 100644
--- a/WebCore/editing/Editor.h
+++ b/WebCore/editing/Editor.h
@@ -383,6 +383,7 @@ private:
OwnPtr<KillRing> m_killRing;
CorrectionPanelInfo m_correctionPanelInfo;
Timer<Editor> m_correctionPanelTimer;
+ bool m_correctionPanelIsDismissedByEditor;
VisibleSelection m_mark;
bool m_areMarkedTextMatchesHighlighted;
@@ -409,7 +410,7 @@ private:
void correctionPanelTimerFired(Timer<Editor>*);
Node* findEventTargetFromSelection() const;
void stopCorrectionPanelTimer();
- void dismissCorrectionPanel(CorrectionWasRejectedOrNot);
+ void dismissCorrectionPanel(ReasonForDismissingCorrectionPanel);
void applyCorrectionPanelInfo(const Vector<DocumentMarker::MarkerType>& markerTypesToAdd);
};
diff --git a/WebCore/loader/EmptyClients.h b/WebCore/loader/EmptyClients.h
index a29379d..2ac8dd0 100644
--- a/WebCore/loader/EmptyClients.h
+++ b/WebCore/loader/EmptyClients.h
@@ -481,7 +481,7 @@ public:
#endif
#if SUPPORT_AUTOCORRECTION_PANEL
virtual void showCorrectionPanel(CorrectionPanelInfo::PanelType, const FloatRect&, const String&, const String&, const Vector<String>&, Editor*) { }
- virtual void dismissCorrectionPanel(CorrectionWasRejectedOrNot) { }
+ virtual void dismissCorrectionPanel(ReasonForDismissingCorrectionPanel) { }
virtual bool isShowingCorrectionPanel() { return false; }
#endif
virtual void updateSpellingUIWithGrammarString(const String&, const GrammarDetail&) { }
diff --git a/WebCore/page/EditorClient.h b/WebCore/page/EditorClient.h
index ba9ceee..64d19a4 100644
--- a/WebCore/page/EditorClient.h
+++ b/WebCore/page/EditorClient.h
@@ -191,7 +191,7 @@ public:
#if SUPPORT_AUTOCORRECTION_PANEL
virtual void showCorrectionPanel(CorrectionPanelInfo::PanelType, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacmentString, const Vector<String>& alternativeReplacementStrings, Editor*) = 0;
- virtual void dismissCorrectionPanel(CorrectionWasRejectedOrNot) = 0;
+ virtual void dismissCorrectionPanel(ReasonForDismissingCorrectionPanel) = 0;
virtual bool isShowingCorrectionPanel() = 0;
#endif
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index 9b44736..e2c11e5 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,18 @@
+2010-12-03 Jia Pu <jpu at apple.com>
+
+ Reviewed by Darin Adler.
+
+ Need to move all code that applies correction into correction panel callback.
+ https://bugs.webkit.org/show_bug.cgi?id=50426
+ <rdar://problem/8720832>
+
+ * WebCoreSupport/WebEditorClient.h: Adopted new signature of dismissCorrectionPanel.
+
+ * WebCoreSupport/WebEditorClient.mm:
+ (WebEditorClient::~WebEditorClient): Adopted new signature of dismissCorrectionPanel.
+ (WebEditorClient::showCorrectionPanel): Added more user dictionary learning code.
+ (WebEditorClient::dismissCorrectionPanel): Adopted new signature of dismissCorrectionPanel.
+
2010-12-02 Simon Fraser <simon.fraser at apple.com>
Revert r73217 and r73227 because of continued bustage.
diff --git a/WebKit/mac/WebCoreSupport/WebEditorClient.h b/WebKit/mac/WebCoreSupport/WebEditorClient.h
index a7ffe3a..8b6e3f9 100644
--- a/WebKit/mac/WebCoreSupport/WebEditorClient.h
+++ b/WebKit/mac/WebCoreSupport/WebEditorClient.h
@@ -134,7 +134,7 @@ public:
virtual void setInputMethodState(bool enabled);
#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
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*);
- virtual void dismissCorrectionPanel(WebCore::CorrectionWasRejectedOrNot);
+ virtual void dismissCorrectionPanel(WebCore::ReasonForDismissingCorrectionPanel);
virtual bool isShowingCorrectionPanel();
#endif
private:
@@ -147,5 +147,7 @@ private:
#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
BOOL m_correctionPanelIsShown;
+ BOOL m_correctionPanelIsDismissedExternally;
+ WebCore::ReasonForDismissingCorrectionPanel m_reasonForDismissingCorrectionPanel;
#endif
};
diff --git a/WebKit/mac/WebCoreSupport/WebEditorClient.mm b/WebKit/mac/WebCoreSupport/WebEditorClient.mm
index 0376122..455aa9a 100644
--- a/WebKit/mac/WebCoreSupport/WebEditorClient.mm
+++ b/WebKit/mac/WebCoreSupport/WebEditorClient.mm
@@ -210,7 +210,7 @@ WebEditorClient::WebEditorClient(WebView *webView)
WebEditorClient::~WebEditorClient()
{
#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
- dismissCorrectionPanel(WebCore::CorrectionWasNotRejected);
+ dismissCorrectionPanel(ReasonForDismissingCorrectionPanelIgnored);
#endif
}
@@ -873,7 +873,7 @@ void WebEditorClient::updateSpellingUIWithGrammarString(const String& badGrammar
#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
void WebEditorClient::showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType panelType, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings, Editor* editor) {
- dismissCorrectionPanel(WebCore::CorrectionWasNotRejected);
+ dismissCorrectionPanel(ReasonForDismissingCorrectionPanelIgnored);
NSRect boundingBoxAsNSRect = boundingBoxOfReplacedString;
NSRect webViewFrame = m_webView.frame;
@@ -884,6 +884,9 @@ void WebEditorClient::showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelTyp
NSString *replacementStringAsNSString = replacementString;
m_correctionPanelIsShown = YES;
+ m_correctionPanelIsDismissedExternally = NO;
+ m_reasonForDismissingCorrectionPanel = ReasonForDismissingCorrectionPanelIgnored;
+
NSCorrectionBubbleType bubbleType = correctionBubbleType(panelType);
NSMutableArray *alternativeStrings = nil;
if (!alternativeReplacementStrings.isEmpty()) {
@@ -892,37 +895,41 @@ void WebEditorClient::showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelTyp
for (size_t i = 0; i < size; ++i)
[alternativeStrings addObject:(NSString*)alternativeReplacementStrings[i]];
}
-
+ NSSpellChecker *spellChecker = [NSSpellChecker sharedSpellChecker];
[[NSSpellChecker sharedSpellChecker] showCorrectionBubbleOfType:bubbleType primaryString:replacementStringAsNSString alternativeStrings:alternativeStrings forStringInRect:boundingBoxAsNSRect view:m_webView completionHandler:^(NSString *acceptedString) {
switch (bubbleType) {
case NSCorrectionBubbleTypeCorrection:
- if (!acceptedString) {
- [[NSSpellChecker sharedSpellChecker] recordResponse:NSCorrectionResponseRejected toCorrection:replacementStringAsNSString forWord:replacedStringAsNSString language:nil inSpellDocumentWithTag:[m_webView spellCheckerDocumentTag]];
- editor->handleCorrectionPanelResult(String());
+ if (acceptedString)
+ [spellChecker recordResponse:NSCorrectionResponseAccepted toCorrection:acceptedString forWord:replacedStringAsNSString language:nil inSpellDocumentWithTag:spellCheckerDocumentTag()];
+ else {
+ if (!m_correctionPanelIsDismissedExternally || m_reasonForDismissingCorrectionPanel == ReasonForDismissingCorrectionPanelCancelled)
+ [spellChecker recordResponse:NSCorrectionResponseRejected toCorrection:replacementStringAsNSString forWord:replacedStringAsNSString language:nil inSpellDocumentWithTag:spellCheckerDocumentTag()];
+ else
+ [spellChecker recordResponse:NSCorrectionResponseIgnored toCorrection:replacementStringAsNSString forWord:replacedStringAsNSString language:nil inSpellDocumentWithTag:spellCheckerDocumentTag()];
}
break;
case NSCorrectionBubbleTypeReversion:
- if (acceptedString) {
- [[NSSpellChecker sharedSpellChecker] recordResponse:NSCorrectionResponseReverted toCorrection:replacedStringAsNSString forWord:replacementStringAsNSString language:nil inSpellDocumentWithTag:[m_webView spellCheckerDocumentTag]];
- editor->handleCorrectionPanelResult(String());
- }
+ if (acceptedString)
+ [spellChecker recordResponse:NSCorrectionResponseReverted toCorrection:replacedStringAsNSString forWord:acceptedString language:nil inSpellDocumentWithTag:spellCheckerDocumentTag()];
break;
case NSCorrectionBubbleTypeGuesses:
if (acceptedString)
[[NSSpellChecker sharedSpellChecker] recordResponse:NSCorrectionResponseAccepted toCorrection:acceptedString forWord:replacedStringAsNSString language:nil inSpellDocumentWithTag:[m_webView spellCheckerDocumentTag]];
- editor->handleCorrectionPanelResult(String(acceptedString));
break;
}
+ editor->handleCorrectionPanelResult(String(acceptedString));
}];
}
-void WebEditorClient::dismissCorrectionPanel(WebCore::CorrectionWasRejectedOrNot correctionWasRejectedOrNot)
+void WebEditorClient::dismissCorrectionPanel(ReasonForDismissingCorrectionPanel reasonForDismissing)
{
if (isShowingCorrectionPanel()) {
- if (correctionWasRejectedOrNot == CorrectionWasRejected)
- [[NSSpellChecker sharedSpellChecker] cancelCorrectionBubbleForView:m_webView];
- else
+ m_correctionPanelIsDismissedExternally = YES;
+ m_reasonForDismissingCorrectionPanel = reasonForDismissing;
+ if (reasonForDismissing == ReasonForDismissingCorrectionPanelAccepted)
[[NSSpellChecker sharedSpellChecker] dismissCorrectionBubbleForView:m_webView];
+ else
+ [[NSSpellChecker sharedSpellChecker] cancelCorrectionBubbleForView:m_webView];
m_correctionPanelIsShown = NO;
}
}
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 6e6167c..4df071c 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,17 @@
+2010-12-03 Jia Pu <jpu at apple.com>
+
+ Reviewed by Darin Adler.
+
+ Need to move all code that applies correction into correction panel callback.
+ https://bugs.webkit.org/show_bug.cgi?id=50426
+ <rdar://problem/8720832>
+
+ Adopted new signature of dismissCorrectionPanel.
+
+ * WebProcess/WebCoreSupport/WebEditorClient.h:
+ * WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:
+ (WebKit::WebEditorClient::dismissCorrectionPanel):
+
2010-12-03 Jessie Berlin <jberlin at apple.com>
Windows build fix. Unreviewed.
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h b/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h
index 9ff2a62..ccdaf43 100644
--- a/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h
+++ b/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h
@@ -135,7 +135,7 @@ private:
virtual void setInputMethodState(bool enabled);
#if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
virtual void showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings, WebCore::Editor*);
- virtual void dismissCorrectionPanel(WebCore::CorrectionWasRejectedOrNot);
+ virtual void dismissCorrectionPanel(WebCore::ReasonForDismissingCorrectionPanel);
virtual bool isShowingCorrectionPanel();
#endif
WebPage* m_page;
diff --git a/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm b/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm
index c94f4d7..63d1617 100644
--- a/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm
+++ b/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm
@@ -228,7 +228,7 @@ void WebEditorClient::showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelTyp
notImplemented();
}
-void WebEditorClient::dismissCorrectionPanel(WebCore::CorrectionWasRejectedOrNot)
+void WebEditorClient::dismissCorrectionPanel(WebCore::ReasonForDismissingCorrectionPanel)
{
notImplemented();
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list