Modified: trunk/Source/WebKit/blackberry/ChangeLog (126882 => 126883)
--- trunk/Source/WebKit/blackberry/ChangeLog 2012-08-28 15:44:40 UTC (rev 126882)
+++ trunk/Source/WebKit/blackberry/ChangeLog 2012-08-28 15:46:22 UTC (rev 126883)
@@ -1,3 +1,25 @@
+2012-08-28 Nima Ghanavatian <[email protected]>
+
+ [BlackBerry] Range boundaries should use endOfBlock instead of endOfLine.
+ https://bugs.webkit.org/show_bug.cgi?id=95135
+
+ The original implementation used nextLinePosition to iterate
+ through the field from the start of each line, and was bounded in
+ comparison to the endOfLine. This works fine as long as there aren't any
+ empty lines between paragraphs of text, since these will have
+ startOfLine == endOfLine and break out.
+
+ Also, protect map access with a mutex in case we get a response
+ before updating the map. Further, we should check the Range pointer
+ before using it, since its not guaranteed to be valid.
+
+ Internally reviewed by Mike Fenton.
+
+ Reviewed by Antonio Gomes.
+
+ * WebKitSupport/InputHandler.cpp:
+ (BlackBerry::WebKit::InputHandler::spellCheckBlock):
+
2012-08-28 Andrew Lo <[email protected]>
[BlackBerry] One shot drawing synchronization broken
Modified: trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp (126882 => 126883)
--- trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp 2012-08-28 15:44:40 UTC (rev 126882)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp 2012-08-28 15:46:22 UTC (rev 126883)
@@ -135,6 +135,7 @@
, m_pendingKeyboardVisibilityChange(NoChange)
, m_delayKeyboardVisibilityChange(false)
{
+ pthread_mutex_init(&m_sequenceMapMutex, 0);
}
InputHandler::~InputHandler()
@@ -581,6 +582,7 @@
return;
}
+ BlackBerry::Platform::MutexLocker lock(&m_sequenceMapMutex);
int32_t transactionId = m_webPage->m_client->checkSpellingOfStringAsync(checkingString, paragraphLength);
free(checkingString);
@@ -598,6 +600,7 @@
int32_t InputHandler::convertTransactionIdToSequenceId(int32_t transactionId)
{
+ BlackBerry::Platform::MutexLocker lock(&m_sequenceMapMutex);
std::map<int32_t, int32_t>::iterator it = m_sequenceMap.find(transactionId);
if (it == m_sequenceMap.end())
@@ -660,6 +663,7 @@
void InputHandler::cancelAllSpellCheckingRequests()
{
+ BlackBerry::Platform::MutexLocker lock(&m_sequenceMapMutex);
for (std::map<int32_t, int32_t>::iterator it = m_sequenceMap.begin(); it != m_sequenceMap.end(); ++it)
spellCheckingRequestCancelled(it->second, true /* isSequenceId */);
m_sequenceMap.clear();
@@ -672,7 +676,7 @@
int32_t sequenceId = isSequenceId ? id : convertTransactionIdToSequenceId(id);
SpellChecker* spellChecker = getSpellChecker();
- if (!spellChecker) {
+ if (!spellChecker || !sequenceId) {
SpellingLog(LogLevelWarn, "InputHandler::spellCheckingRequestCancelled failed to cancel the request with sequenceId %d", sequenceId);
return;
}
@@ -856,14 +860,16 @@
if (!isActiveTextEdit())
return;
+ RefPtr<Range> rangeForSpellChecking = visibleSelection.toNormalizedRange();
+ if (!rangeForSpellChecking || !rangeForSpellChecking->text() || !rangeForSpellChecking->text().length())
+ return;
+
SpellChecker* spellChecker = getSpellChecker();
if (!spellChecker) {
SpellingLog(LogLevelInfo, "InputHandler::spellCheckBlock Failed to spellcheck the current focused element.");
return;
}
- RefPtr<Range> rangeForSpellChecking = visibleSelection.toNormalizedRange();
-
// If we have a batch request, try to send off the entire block.
if (textCheckingProcessType == TextCheckingProcessBatch) {
// If total block text is under the limited amount, send the entire chunk.
@@ -876,13 +882,16 @@
// Since we couldn't check the entire block at once, set up starting and ending markers to fire incrementally.
VisiblePosition startPos = visibleSelection.visibleStart();
VisiblePosition startOfCurrentLine = startOfLine(startPos);
- VisiblePosition endOfCurrentLine = endOfLine(startPos);
+ VisiblePosition endOfCurrentLine = endOfLine(startOfCurrentLine);
- while (startOfCurrentLine != endOfCurrentLine) {
+ while (!isEndOfBlock(startOfCurrentLine)) {
// Create a selection with the start and end points of the line, and convert to Range to create a SpellCheckRequest.
rangeForSpellChecking = VisibleSelection(startOfCurrentLine, endOfCurrentLine).toNormalizedRange();
- if (rangeForSpellChecking->text().length() >= MaxSpellCheckingStringLength) {
+ if (rangeForSpellChecking->text().length() < MaxSpellCheckingStringLength) {
+ startOfCurrentLine = nextLinePosition(startOfCurrentLine, startOfCurrentLine.lineDirectionPointForBlockDirectionNavigation());
+ endOfCurrentLine = endOfLine(startOfCurrentLine);
+ } else {
// Iterate through words from the start of the line to the end.
rangeForSpellChecking = getRangeForSpellCheckWithFineGranularity(startOfCurrentLine, endOfCurrentLine);
if (!rangeForSpellChecking) {
@@ -890,12 +899,6 @@
return;
}
startOfCurrentLine = VisiblePosition(rangeForSpellChecking->endPosition());
- } else {
- startOfCurrentLine = nextLinePosition(startOfCurrentLine, startOfCurrentLine.lineDirectionPointForBlockDirectionNavigation());
- endOfCurrentLine = endOfLine(startOfCurrentLine);
- // 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.
- if (startOfCurrentLine != endOfCurrentLine)
- startOfCurrentLine = startOfLine(startOfCurrentLine);
}
SpellingLog(LogLevelInfo, "InputHandler::spellCheckBlock Substring text is '%s', of size %d", rangeForSpellChecking->text().latin1().data(), rangeForSpellChecking->text().length());
Modified: trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.h (126882 => 126883)
--- trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.h 2012-08-28 15:44:40 UTC (rev 126882)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.h 2012-08-28 15:46:22 UTC (rev 126883)
@@ -26,6 +26,7 @@
#include <imf/events.h>
#include <imf/input_data.h>
#include <map>
+#include <pthread.h>
#include <wtf/RefPtr.h>
namespace WTF {
@@ -217,6 +218,7 @@
bool m_delayKeyboardVisibilityChange;
std::map<int32_t, int32_t> m_sequenceMap;
+ pthread_mutex_t m_sequenceMapMutex;
};
}