Changeset 140562 in webkit
- Timestamp:
- Jan 23, 2013 11:48:17 AM (11 years ago)
- Location:
- trunk/Source/WebKit/blackberry
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/blackberry/ChangeLog
r140541 r140562 1 2013-01-23 Nima Ghanavatian <nghanavatian@rim.com> 2 3 [BlackBerry] Optimize spellchecking by coalescing messages 4 https://bugs.webkit.org/show_bug.cgi?id=107707 5 6 Reviewed by Rob Buis. 7 8 PR233604 9 Instead of taking chunks one line at a time, coalesce them together 10 to fire off messages as close to our character limit as possible. 11 This should dramatically reduce the total number of messages in email 12 giving us a little performance bump. 13 14 Internally reviewed by Mike Fenton and Gen Mak. 15 16 * WebKitSupport/DOMSupport.cpp: 17 (BlackBerry::WebKit::DOMSupport::trimWhitespaceFromRange): 18 (DOMSupport): 19 * WebKitSupport/DOMSupport.h: 20 * WebKitSupport/InputHandler.cpp: 21 * WebKitSupport/InputHandler.h: 22 (InputHandler): 23 * WebKitSupport/SpellingHandler.cpp: 24 (BlackBerry::WebKit::SpellingHandler::spellCheckTextBlock): 25 (BlackBerry::WebKit::SpellingHandler::createSpellCheckRequest): 26 (BlackBerry::WebKit::SpellingHandler::parseBlockForSpellChecking): 27 (BlackBerry::WebKit::SpellingHandler::getRangeForSpellCheckWithFineGranularity): 28 * WebKitSupport/SpellingHandler.h: 29 1 30 2013-01-23 Shinya Kawanaka <shinyak@chromium.org> 2 31 -
trunk/Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp
r140161 r140562 517 517 } 518 518 519 PassRefPtr<Range> trimWhitespaceFromRange(PassRefPtr<Range> range) 520 { 521 return trimWhitespaceFromRange(VisiblePosition(range->startPosition()), VisiblePosition(range->endPosition())); 522 } 523 519 524 PassRefPtr<Range> trimWhitespaceFromRange(VisiblePosition startPosition, VisiblePosition endPosition) 520 525 { -
trunk/Source/WebKit/blackberry/WebKitSupport/DOMSupport.h
r140161 r140562 94 94 WebCore::Frame* incrementFrame(WebCore::Frame* curr, bool forward, bool wrapFlag); 95 95 96 PassRefPtr<WebCore::Range> trimWhitespaceFromRange(PassRefPtr<WebCore::Range>); 96 97 PassRefPtr<WebCore::Range> trimWhitespaceFromRange(WebCore::VisiblePosition startPosition, WebCore::VisiblePosition endPosition); 97 98 bool isEmptyRangeOrAllSpaces(WebCore::VisiblePosition, WebCore::VisiblePosition); -
trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp
r140170 r140562 71 71 #include <BlackBerryPlatformKeyboardEvent.h> 72 72 #include <BlackBerryPlatformLog.h> 73 #include <BlackBerryPlatformMisc.h>74 73 #include <BlackBerryPlatformScreen.h> 75 74 #include <BlackBerryPlatformSettings.h> -
trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.h
r140170 r140562 24 24 25 25 #include <BlackBerryPlatformInputEvents.h> 26 #include <BlackBerryPlatformMisc.h> 26 27 #include <BlackBerryPlatformSettings.h> 27 28 … … 241 242 SpellingHandler* m_spellingHandler; 242 243 244 DISABLE_COPY(InputHandler); 243 245 }; 244 246 -
trunk/Source/WebKit/blackberry/WebKitSupport/SpellingHandler.cpp
r140349 r140562 10 10 #include "Range.h" 11 11 #include "SpellChecker.h" 12 #include "TextIterator.h"13 12 #include "visible_units.h" 14 13 … … 45 44 void SpellingHandler::spellCheckTextBlock(WebCore::VisibleSelection& visibleSelection, WebCore::TextCheckingProcessType textCheckingProcessType) 46 45 { 46 SpellingLog(Platform::LogLevelInfo, "SpellingHandler::spellCheckTextBlock"); 47 47 48 // Check if this request can be sent off in one message, or if it needs to be broken down. 48 49 RefPtr<Range> rangeForSpellChecking = visibleSelection.toNormalizedRange(); … … 80 81 { 81 82 RefPtr<WebCore::Range> rangeForSpellChecking = rangeForSpellCheckingPtr; 82 if (isSpellCheckActive() && rangeForSpellChecking->text().length() >= MinSpellCheckingStringLength) 83 rangeForSpellChecking = DOMSupport::trimWhitespaceFromRange(rangeForSpellChecking); 84 85 SpellingLog(Platform::LogLevelInfo, "SpellingHandler::createSpellCheckRequest Substring text is '%s', of size %d" 86 , rangeForSpellChecking->text().latin1().data() 87 , rangeForSpellChecking->text().length()); 88 89 if (rangeForSpellChecking->text().length() >= MinSpellCheckingStringLength) 83 90 m_inputHandler->callRequestCheckingFor(SpellCheckRequest::create(TextCheckingTypeSpelling, textCheckingProcessType, rangeForSpellChecking, rangeForSpellChecking)); 84 91 } … … 86 93 void SpellingHandler::parseBlockForSpellChecking(WebCore::Timer<SpellingHandler>*) 87 94 { 88 if (isEndOfDocument(m_startOfCurrentLine)) {89 m_isSpellCheckActive = false;90 return;91 }92 93 95 // Create a selection with the start and end points of the line, and convert to Range to create a SpellCheckRequest. 94 RefPtr<Range> rangeForSpellChecking = VisibleSelection(m_startOfCurrentLine, m_endOfCurrentLine).toNormalizedRange();96 RefPtr<Range> rangeForSpellChecking = makeRange(m_startOfCurrentLine, m_endOfCurrentLine); 95 97 if (!rangeForSpellChecking) { 96 SpellingLog(Platform::LogLevelInfo, "SpellingHandler:: spellCheckBlockFailed to set text range for spellchecking.");98 SpellingLog(Platform::LogLevelInfo, "SpellingHandler::parseBlockForSpellChecking Failed to set text range for spellchecking."); 97 99 return; 98 100 } 99 101 100 102 if (rangeForSpellChecking->text().length() < MaxSpellCheckingStringLength) { 101 m_startOfCurrentLine = nextLinePosition(m_startOfCurrentLine, m_startOfCurrentLine.lineDirectionPointForBlockDirectionNavigation()); 102 m_endOfCurrentLine = endOfLine(m_startOfCurrentLine); 103 } else { 104 // Iterate through words from the start of the line to the end. 105 rangeForSpellChecking = getRangeForSpellCheckWithFineGranularity(m_startOfCurrentLine, m_endOfCurrentLine); 106 if (!rangeForSpellChecking) { 107 SpellingLog(Platform::LogLevelWarn, "SpellingHandler::spellCheckBlock Failed to set text range with fine granularity."); 103 if (isEndOfDocument(m_endOfCurrentLine)) { 104 createSpellCheckRequest(rangeForSpellChecking, m_textCheckingProcessType); 105 m_isSpellCheckActive = false; 108 106 return; 109 107 } 110 m_ startOfCurrentLine = VisiblePosition(rangeForSpellChecking->endPosition());111 m_ endOfCurrentLine = endOfLine(m_startOfCurrentLine);112 r angeForSpellChecking = DOMSupport::trimWhitespaceFromRange(VisiblePosition(rangeForSpellChecking->startPosition()), VisiblePosition(rangeForSpellChecking->endPosition()));108 m_endOfCurrentLine = endOfLine(nextLinePosition(m_endOfCurrentLine, m_endOfCurrentLine.lineDirectionPointForBlockDirectionNavigation())); 109 m_timer.startOneShot(s_timeout); 110 return; 113 111 } 114 112 115 SpellingLog(Platform::LogLevelInfo, 116 "SpellingHandler::spellCheckBlock Substring text is '%s', of size %d", 117 rangeForSpellChecking->text().latin1().data(), 118 rangeForSpellChecking->text().length()); 113 // Iterate through words from the start of the line to the end. 114 rangeForSpellChecking = getRangeForSpellCheckWithFineGranularity(m_startOfCurrentLine, m_endOfCurrentLine); 115 116 m_startOfCurrentLine = VisiblePosition(rangeForSpellChecking->endPosition()); 117 m_endOfCurrentLine = endOfLine(m_startOfCurrentLine); 119 118 120 119 // Call spellcheck with substring. … … 126 125 PassRefPtr<Range> SpellingHandler::getRangeForSpellCheckWithFineGranularity(WebCore::VisiblePosition startPosition, WebCore::VisiblePosition endPosition) 127 126 { 127 SpellingLog(Platform::LogLevelWarn, "SpellingHandler::getRangeForSpellCheckWithFineGranularity"); 128 ASSERT(makeRange(startPosition, endOfCurrentWord)); 128 129 VisiblePosition endOfCurrentWord = endOfWord(startPosition); 129 130 … … 131 132 while (startPosition != endPosition) { 132 133 // Check the text length within this range. 133 if ( VisibleSelection(startPosition, endOfCurrentWord).toNormalizedRange()->text().length() >= MaxSpellCheckingStringLength) {134 if (makeRange(startPosition, endOfCurrentWord)->text().length() >= MaxSpellCheckingStringLength) { 134 135 // If this is not the first word, return a Range with end boundary set to the previous word. 135 if (startOfWord(endOfCurrentWord, LeftWordIfOnBoundary) != startPosition && !DOMSupport::isEmptyRangeOrAllSpaces(startPosition, endOfCurrentWord)) 136 return VisibleSelection(startPosition, endOfWord(previousWordPosition(endOfCurrentWord), LeftWordIfOnBoundary)).toNormalizedRange(); 137 136 if (startOfWord(endOfCurrentWord, LeftWordIfOnBoundary) != startPosition && !DOMSupport::isEmptyRangeOrAllSpaces(startPosition, endOfCurrentWord)) { 137 // When a series of whitespace follows a word, previousWordPosition will jump passed all of them, and using LeftWordIfOnBoundary brings us to 138 // our starting position. Check for this case and use RightWordIfOnBoundary to jump back over the word. 139 VisiblePosition endOfPreviousWord = endOfWord(previousWordPosition(endOfCurrentWord), LeftWordIfOnBoundary); 140 if (startPosition == endOfPreviousWord) 141 return makeRange(startPosition, endOfWord(previousWordPosition(endOfCurrentWord), RightWordIfOnBoundary)); 142 return makeRange(startPosition, endOfPreviousWord); 143 } 138 144 // Our first word has gone over the character limit. Increment the starting position past an uncheckable word. 139 145 startPosition = endOfCurrentWord; 140 146 endOfCurrentWord = endOfWord(nextWordPosition(endOfCurrentWord)); 141 147 } else if (endOfCurrentWord == endPosition) 142 return VisibleSelection(startPosition, endPosition).toNormalizedRange(); // Return the last segment if the end of our word lies at the end of the range.148 return makeRange(startPosition, endPosition); // Return the last segment if the end of our word lies at the end of the range. 143 149 else 144 150 endOfCurrentWord = endOfWord(nextWordPosition(endOfCurrentWord)); // Increment the current word. 145 151 } 146 return 0; 152 // This will return an range with no string, but allows processing to continue 153 return makeRange(startPosition, endPosition); 147 154 } 148 155 -
trunk/Source/WebKit/blackberry/WebKitSupport/SpellingHandler.h
r140170 r140562 19 19 namespace WebCore { 20 20 class Range; 21 class SpellChecker;22 class VisibleSelection;23 class VisiblePosition;24 21 } 25 22
Note: See TracChangeset
for help on using the changeset viewer.