Title: [149626] trunk/Source/WebKit/blackberry
- Revision
- 149626
- Author
- commit-qu...@webkit.org
- Date
- 2013-05-06 12:31:37 -0700 (Mon, 06 May 2013)
Log Message
[BlackBerry] Reduce the spellcheck checking range
https://bugs.webkit.org/show_bug.cgi?id=115479
Patch by Nima Ghanavatian <nghanavat...@blackberry.com> on 2013-05-06
Reviewed by Rob Buis.
Internally reviewed by Mike Fenton.
PR332773
Previously we were spellchecking the entire field on focus. If relayouting
occurred we rechecked this region, which is very costly. Switch to check
only a small region around the caret in both cases, which should alleviate
much of the delays experienced in very large contenteditable fields. This
allows for faster key input response and less time processing these requests
on the WebKit thread.
* WebKitSupport/InputHandler.cpp:
(BlackBerry::WebKit::InputHandler::requestCheckingOfString):
(BlackBerry::WebKit::InputHandler::spellCheckTextBlock):
* WebKitSupport/SpellingHandler.cpp:
(WebKit):
(BlackBerry::WebKit::SpellingHandler::spellCheckTextBlock):
* WebKitSupport/SpellingHandler.h:
(SpellingHandler):
Modified Paths
Diff
Modified: trunk/Source/WebKit/blackberry/ChangeLog (149625 => 149626)
--- trunk/Source/WebKit/blackberry/ChangeLog 2013-05-06 19:29:52 UTC (rev 149625)
+++ trunk/Source/WebKit/blackberry/ChangeLog 2013-05-06 19:31:37 UTC (rev 149626)
@@ -1,5 +1,31 @@
2013-05-06 Nima Ghanavatian <nghanavat...@blackberry.com>
+ [BlackBerry] Reduce the spellcheck checking range
+ https://bugs.webkit.org/show_bug.cgi?id=115479
+
+ Reviewed by Rob Buis.
+
+ Internally reviewed by Mike Fenton.
+
+ PR332773
+ Previously we were spellchecking the entire field on focus. If relayouting
+ occurred we rechecked this region, which is very costly. Switch to check
+ only a small region around the caret in both cases, which should alleviate
+ much of the delays experienced in very large contenteditable fields. This
+ allows for faster key input response and less time processing these requests
+ on the WebKit thread.
+
+ * WebKitSupport/InputHandler.cpp:
+ (BlackBerry::WebKit::InputHandler::requestCheckingOfString):
+ (BlackBerry::WebKit::InputHandler::spellCheckTextBlock):
+ * WebKitSupport/SpellingHandler.cpp:
+ (WebKit):
+ (BlackBerry::WebKit::SpellingHandler::spellCheckTextBlock):
+ * WebKitSupport/SpellingHandler.h:
+ (SpellingHandler):
+
+2013-05-06 Nima Ghanavatian <nghanavat...@blackberry.com>
+
[BlackBerry] Use a more descriptive timer name
https://bugs.webkit.org/show_bug.cgi?id=115481
Modified: trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp (149625 => 149626)
--- trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp 2013-05-06 19:29:52 UTC (rev 149625)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp 2013-05-06 19:31:37 UTC (rev 149626)
@@ -630,16 +630,7 @@
if (requestLength >= MaxSpellCheckingStringLength) {
// Cancel this request and send it off in newly created chunks.
spellCheckRequest->didCancel();
- if (m_currentFocusElement->document() && m_currentFocusElement->document()->frame() && m_currentFocusElement->document()->frame()->selection()) {
- VisiblePosition caretPosition = m_currentFocusElement->document()->frame()->selection()->start();
- // Convert from position back to selection so we can expand the range to include the previous line. This should handle cases when the user hits
- // enter to finish composing a word and create a new line. Account for word wrapping by jumping to the start of the previous line, then moving
- // to the start of any word which might be there.
- VisibleSelection visibleSelection = VisibleSelection(
- startOfWord(startOfLine(previousLinePosition(caretPosition, caretPosition.lineDirectionPointForBlockDirectionNavigation()))),
- endOfWord(endOfLine(caretPosition)));
- m_spellingHandler->spellCheckTextBlock(visibleSelection, TextCheckingProcessIncremental);
- }
+ m_spellingHandler->spellCheckTextBlock(m_currentFocusElement.get(), TextCheckingProcessIncremental);
return;
}
@@ -1118,10 +1109,6 @@
SpellingLog(Platform::LogLevelInfo, "InputHandler::setElementFocused Focusing the field took %f seconds.", timer.elapsed());
#endif
- // Check if the field should be spellchecked.
- if (!shouldSpellCheckElement(element) || !isActiveTextEdit())
- return;
-
// Spellcheck the field in its entirety.
spellCheckTextBlock(element);
@@ -1139,8 +1126,12 @@
element = m_currentFocusElement.get();
}
- const VisibleSelection visibleSelection = DOMSupport::visibleSelectionForFocusedBlock(element);
- m_spellingHandler->spellCheckTextBlock(visibleSelection, TextCheckingProcessBatch);
+
+ // Check if the field should be spellchecked.
+ if (!shouldSpellCheckElement(element) || !isActiveTextEdit())
+ return;
+
+ m_spellingHandler->spellCheckTextBlock(element, TextCheckingProcessBatch);
}
bool InputHandler::shouldSpellCheckElement(const Element* element) const
Modified: trunk/Source/WebKit/blackberry/WebKitSupport/SpellingHandler.cpp (149625 => 149626)
--- trunk/Source/WebKit/blackberry/WebKitSupport/SpellingHandler.cpp 2013-05-06 19:29:52 UTC (rev 149625)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/SpellingHandler.cpp 2013-05-06 19:31:37 UTC (rev 149626)
@@ -6,6 +6,7 @@
#include "SpellingHandler.h"
#include "DOMSupport.h"
+#include "Frame.h"
#include "InputHandler.h"
#include "Range.h"
#include "SpellChecker.h"
@@ -41,11 +42,21 @@
{
}
-void SpellingHandler::spellCheckTextBlock(const WebCore::VisibleSelection& visibleSelection, WebCore::TextCheckingProcessType textCheckingProcessType)
+void SpellingHandler::spellCheckTextBlock(const WebCore::Element* element, WebCore::TextCheckingProcessType textCheckingProcessType)
{
SpellingLog(Platform::LogLevelInfo, "SpellingHandler::spellCheckTextBlock received request of type %s",
textCheckingProcessType == TextCheckingProcessBatch ? "Batch" : "Incremental");
+ if (!(element->document() && element->document()->frame() && element->document()->frame()->selection()))
+ return;
+
+ VisiblePosition caretPosition = element->document()->frame()->selection()->start();
+ // Expand the range to include the previous line. This should handle cases when the user hits enter to finish composing a word and create a new line.
+ // Account for word wrapping by jumping to the start of the previous line, then moving to the start of any word which might be there.
+ VisibleSelection visibleSelection = VisibleSelection(
+ startOfWord(startOfLine(previousLinePosition(caretPosition, caretPosition.lineDirectionPointForBlockDirectionNavigation()))),
+ endOfWord(endOfLine(caretPosition)));
+
// Check if this request can be sent off in one message, or if it needs to be broken down.
RefPtr<Range> rangeForSpellChecking = visibleSelection.toNormalizedRange();
if (!rangeForSpellChecking || !rangeForSpellChecking->text() || !rangeForSpellChecking->text().length())
Modified: trunk/Source/WebKit/blackberry/WebKitSupport/SpellingHandler.h (149625 => 149626)
--- trunk/Source/WebKit/blackberry/WebKitSupport/SpellingHandler.h 2013-05-06 19:29:52 UTC (rev 149625)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/SpellingHandler.h 2013-05-06 19:31:37 UTC (rev 149626)
@@ -30,7 +30,7 @@
SpellingHandler(InputHandler*);
~SpellingHandler();
- void spellCheckTextBlock(const WebCore::VisibleSelection&, const WebCore::TextCheckingProcessType);
+ void spellCheckTextBlock(const WebCore::Element*, const WebCore::TextCheckingProcessType);
bool isSpellCheckActive() { return m_isSpellCheckActive; }
void setSpellCheckActive(bool active) { m_isSpellCheckActive = active; }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes