Changeset 126883 in webkit
- Timestamp:
- Aug 28, 2012, 8:46:22 AM (14 years ago)
- Location:
- trunk/Source/WebKit/blackberry
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
WebKitSupport/InputHandler.cpp (modified) (9 diffs)
-
WebKitSupport/InputHandler.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/blackberry/ChangeLog
r126878 r126883 1 2012-08-28 Nima Ghanavatian <nghanavatian@rim.com> 2 3 [BlackBerry] Range boundaries should use endOfBlock instead of endOfLine. 4 https://bugs.webkit.org/show_bug.cgi?id=95135 5 6 The original implementation used nextLinePosition to iterate 7 through the field from the start of each line, and was bounded in 8 comparison to the endOfLine. This works fine as long as there aren't any 9 empty lines between paragraphs of text, since these will have 10 startOfLine == endOfLine and break out. 11 12 Also, protect map access with a mutex in case we get a response 13 before updating the map. Further, we should check the Range pointer 14 before using it, since its not guaranteed to be valid. 15 16 Internally reviewed by Mike Fenton. 17 18 Reviewed by Antonio Gomes. 19 20 * WebKitSupport/InputHandler.cpp: 21 (BlackBerry::WebKit::InputHandler::spellCheckBlock): 22 1 23 2012-08-28 Andrew Lo <anlo@rim.com> 2 24 -
trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp
r125808 r126883 136 136 , m_delayKeyboardVisibilityChange(false) 137 137 { 138 pthread_mutex_init(&m_sequenceMapMutex, 0); 138 139 } 139 140 … … 582 583 } 583 584 585 BlackBerry::Platform::MutexLocker lock(&m_sequenceMapMutex); 584 586 int32_t transactionId = m_webPage->m_client->checkSpellingOfStringAsync(checkingString, paragraphLength); 585 587 free(checkingString); … … 599 601 int32_t InputHandler::convertTransactionIdToSequenceId(int32_t transactionId) 600 602 { 603 BlackBerry::Platform::MutexLocker lock(&m_sequenceMapMutex); 601 604 std::map<int32_t, int32_t>::iterator it = m_sequenceMap.find(transactionId); 602 605 … … 661 664 void InputHandler::cancelAllSpellCheckingRequests() 662 665 { 666 BlackBerry::Platform::MutexLocker lock(&m_sequenceMapMutex); 663 667 for (std::map<int32_t, int32_t>::iterator it = m_sequenceMap.begin(); it != m_sequenceMap.end(); ++it) 664 668 spellCheckingRequestCancelled(it->second, true /* isSequenceId */); … … 673 677 int32_t sequenceId = isSequenceId ? id : convertTransactionIdToSequenceId(id); 674 678 SpellChecker* spellChecker = getSpellChecker(); 675 if (!spellChecker ) {679 if (!spellChecker || !sequenceId) { 676 680 SpellingLog(LogLevelWarn, "InputHandler::spellCheckingRequestCancelled failed to cancel the request with sequenceId %d", sequenceId); 677 681 return; … … 857 861 return; 858 862 863 RefPtr<Range> rangeForSpellChecking = visibleSelection.toNormalizedRange(); 864 if (!rangeForSpellChecking || !rangeForSpellChecking->text() || !rangeForSpellChecking->text().length()) 865 return; 866 859 867 SpellChecker* spellChecker = getSpellChecker(); 860 868 if (!spellChecker) { … … 862 870 return; 863 871 } 864 865 RefPtr<Range> rangeForSpellChecking = visibleSelection.toNormalizedRange();866 872 867 873 // If we have a batch request, try to send off the entire block. … … 877 883 VisiblePosition startPos = visibleSelection.visibleStart(); 878 884 VisiblePosition startOfCurrentLine = startOfLine(startPos); 879 VisiblePosition endOfCurrentLine = endOfLine(start Pos);880 881 while ( startOfCurrentLine != endOfCurrentLine) {885 VisiblePosition endOfCurrentLine = endOfLine(startOfCurrentLine); 886 887 while (!isEndOfBlock(startOfCurrentLine)) { 882 888 // Create a selection with the start and end points of the line, and convert to Range to create a SpellCheckRequest. 883 889 rangeForSpellChecking = VisibleSelection(startOfCurrentLine, endOfCurrentLine).toNormalizedRange(); 884 890 885 if (rangeForSpellChecking->text().length() >= MaxSpellCheckingStringLength) { 891 if (rangeForSpellChecking->text().length() < MaxSpellCheckingStringLength) { 892 startOfCurrentLine = nextLinePosition(startOfCurrentLine, startOfCurrentLine.lineDirectionPointForBlockDirectionNavigation()); 893 endOfCurrentLine = endOfLine(startOfCurrentLine); 894 } else { 886 895 // Iterate through words from the start of the line to the end. 887 896 rangeForSpellChecking = getRangeForSpellCheckWithFineGranularity(startOfCurrentLine, endOfCurrentLine); … … 891 900 } 892 901 startOfCurrentLine = VisiblePosition(rangeForSpellChecking->endPosition()); 893 } else {894 startOfCurrentLine = nextLinePosition(startOfCurrentLine, startOfCurrentLine.lineDirectionPointForBlockDirectionNavigation());895 endOfCurrentLine = endOfLine(startOfCurrentLine);896 // If we are at the last line, nextLinePosition will return the position at the end of the line. If we're not at the end, wrap with a call to startOfLine to be safe.897 if (startOfCurrentLine != endOfCurrentLine)898 startOfCurrentLine = startOfLine(startOfCurrentLine);899 902 } 900 903 -
trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.h
r125598 r126883 27 27 #include <imf/input_data.h> 28 28 #include <map> 29 #include <pthread.h> 29 30 #include <wtf/RefPtr.h> 30 31 … … 218 219 219 220 std::map<int32_t, int32_t> m_sequenceMap; 221 pthread_mutex_t m_sequenceMapMutex; 220 222 }; 221 223
Note:
See TracChangeset
for help on using the changeset viewer.