[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
commit-queue at webkit.org
commit-queue at webkit.org
Wed Dec 22 14:30:37 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit a08de5954302f55b84c3f91ecb3fc011311557f5
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Oct 12 01:21:14 2010 +0000
2010-10-11 Jia Pu <jpu at apple.com>
Reviewed by Adele Peterson.
Should commit pending autocorrection before next round of text checking.
https://bugs.webkit.org/show_bug.cgi?id=46986
<rdar://problem/8424535>
1. Apply pending autocorrection before calling markAllMisspellingsAndBadGrammarInRanges().
2. Remove unneccessary calls to dismissCorrectionPanel(), since the panel is dismissed when
selection changes, which occurs after every typing command.
* editing/Editor.cpp:
(WebCore::Editor::markMisspellingsAfterTypingToPosition): Apply pending autocorrection.
(WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges): Store current correction replacement
in m_correctionReplacementString.
(WebCore::Editor::startCorrectionPanelTimer): Remove call to dismissCorrectionPanel().
* editing/Editor.h: Add m_correctionReplacementString to store proposed autocorrection string.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69548 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 91ca374..ed55e86 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,22 @@
+2010-10-11 Jia Pu <jpu at apple.com>
+
+ Reviewed by Adele Peterson.
+
+ Should commit pending autocorrection before next round of text checking.
+ https://bugs.webkit.org/show_bug.cgi?id=46986
+ <rdar://problem/8424535>
+
+ 1. Apply pending autocorrection before calling markAllMisspellingsAndBadGrammarInRanges().
+ 2. Remove unneccessary calls to dismissCorrectionPanel(), since the panel is dismissed when
+ selection changes, which occurs after every typing command.
+
+ * editing/Editor.cpp:
+ (WebCore::Editor::markMisspellingsAfterTypingToPosition): Apply pending autocorrection.
+ (WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges): Store current correction replacement
+ in m_correctionReplacementString.
+ (WebCore::Editor::startCorrectionPanelTimer): Remove call to dismissCorrectionPanel().
+ * editing/Editor.h: Add m_correctionReplacementString to store proposed autocorrection string.
+
2010-10-11 Oliver Hunt <oliver at apple.com>
Reviewed by Adam Barth.
diff --git a/WebCore/editing/Editor.cpp b/WebCore/editing/Editor.cpp
index ee15237..b41f8e8 100644
--- a/WebCore/editing/Editor.cpp
+++ b/WebCore/editing/Editor.cpp
@@ -2404,6 +2404,49 @@ void Editor::markMisspellingsAndBadGrammar(const VisibleSelection &movingSelecti
void Editor::markMisspellingsAfterTypingToPosition(const VisiblePosition &p)
{
#if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ // Apply pending autocorrection before next round of spell checking.
+ bool didApplyCorrection = false;
+ if (m_rangeToBeReplacedByCorrection) {
+ ExceptionCode ec = 0;
+ RefPtr<Range> paragraphRangeContainingCorrection = m_rangeToBeReplacedByCorrection->cloneRange(ec);
+ if (!ec) {
+ setStart(paragraphRangeContainingCorrection.get(), startOfParagraph(m_rangeToBeReplacedByCorrection->startPosition()));
+ setEnd(paragraphRangeContainingCorrection.get(), endOfParagraph(m_rangeToBeReplacedByCorrection->endPosition()));
+ // After we replace the word at range m_rangeToBeReplacedByCorrection, we need to add
+ // autocorrection underline at that range. However, once the replacement took place, the
+ // value of m_rangeToBeReplacedByCorrection is not valid anymore. So before we carry out
+ // the replacement, we need to store the start position of m_rangeToBeReplacedByCorrection
+ // 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_rangeToBeReplacedByCorrection.
+ RefPtr<Range> correctionStartOffsetInParagraphAsRange = Range::create(paragraphRangeContainingCorrection->startContainer(ec)->document(), paragraphRangeContainingCorrection->startPosition(), paragraphRangeContainingCorrection->startPosition());
+ if (!ec) {
+ Position startPositionOfRangeToBeReplaced = m_rangeToBeReplacedByCorrection->startPosition();
+ correctionStartOffsetInParagraphAsRange->setEnd(startPositionOfRangeToBeReplaced.containerNode(), startPositionOfRangeToBeReplaced.computeOffsetInContainerNode(), ec);
+ if (!ec) {
+ // Take note of the location of autocorrection so that we can add marker after the replacement took place.
+ int correctionStartOffsetInParagraph = TextIterator::rangeLength(correctionStartOffsetInParagraphAsRange.get());
+ Position caretPosition = m_frame->selection()->selection().end();
+ RefPtr<Range> rangeToBeReplaced = m_rangeToBeReplacedByCorrection->cloneRange(ec);
+ VisibleSelection selectionToReplace(rangeToBeReplaced.get(), DOWNSTREAM);
+ if (m_frame->selection()->shouldChangeSelection(selectionToReplace)) {
+ m_frame->selection()->setSelection(selectionToReplace);
+ replaceSelectionWithText(m_correctionReplacementString, false, false);
+ caretPosition.moveToOffset(caretPosition.offsetInContainerNode() + m_correctionReplacementString.length() - m_stringToBeReplacedByCorrection.length());
+ RefPtr<Range> replacementRange = TextIterator::subrange(paragraphRangeContainingCorrection.get(), correctionStartOffsetInParagraph, m_correctionReplacementString.length());
+ replacementRange->startContainer()->document()->markers()->addMarker(replacementRange.get(), DocumentMarker::Replacement, m_correctionReplacementString);
+ replacementRange->startContainer()->document()->markers()->addMarker(replacementRange.get(), DocumentMarker::CorrectionIndicator);
+ m_frame->selection()->moveTo(caretPosition, false);
+ didApplyCorrection = true;
+ }
+ }
+ }
+ }
+ m_rangeToBeReplacedByCorrection.release();
+ }
+#endif
+
TextCheckingOptions textCheckingOptions = 0;
if (isContinuousSpellCheckingEnabled())
textCheckingOptions |= MarkSpelling;
@@ -2754,6 +2797,7 @@ void Editor::markAllMisspellingsAndBadGrammarInRanges(TextCheckingOptions textCh
totalBoundingBox.unite(it->boundingBox());
m_rangeToBeReplacedByCorrection = rangeToReplace;
m_stringToBeReplacedByCorrection = replacedString;
+ m_correctionReplacementString = result->replacement;
client()->showCorrectionPanel(totalBoundingBox, m_stringToBeReplacedByCorrection, result->replacement, this);
doReplacement = false;
}
@@ -2765,10 +2809,6 @@ void Editor::markAllMisspellingsAndBadGrammarInRanges(TextCheckingOptions textCh
if (resultLocation < selectionOffset)
selectionOffset += replacementLength - resultLength;
if (result->type == TextCheckingTypeCorrection) {
-#if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
- if (client())
- client()->dismissCorrectionPanel(true);
-#endif
// Add a marker so that corrections can easily be undone and won't be re-corrected.
RefPtr<Range> replacedRange = TextIterator::subrange(paragraphRange.get(), resultLocation, replacementLength);
replacedRange->startContainer()->document()->markers()->addMarker(replacedRange.get(), DocumentMarker::Replacement, replacedString);
@@ -2857,8 +2897,6 @@ void Editor::startCorrectionPanelTimer()
{
#if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
static const double correctionPanelTimerInterval = 0.3;
- if (client())
- client()->dismissCorrectionPanel(true);
if (isAutomaticSpellingCorrectionEnabled())
m_correctionPanelTimer.startOneShot(correctionPanelTimerInterval);
#endif
diff --git a/WebCore/editing/Editor.h b/WebCore/editing/Editor.h
index 99d6fe6..928662c 100644
--- a/WebCore/editing/Editor.h
+++ b/WebCore/editing/Editor.h
@@ -379,6 +379,7 @@ private:
OwnPtr<KillRing> m_killRing;
RefPtr<Range> m_rangeToBeReplacedByCorrection;
String m_stringToBeReplacedByCorrection;
+ String m_correctionReplacementString;
Timer<Editor> m_correctionPanelTimer;
VisibleSelection m_mark;
bool m_areMarkedTextMatchesHighlighted;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list