Title: [151332] trunk/Source/WebKit2
Revision
151332
Author
[email protected]
Date
2013-06-07 13:16:41 -0700 (Fri, 07 Jun 2013)

Log Message

Reproducible crash with triple-finger-tap "define word" gesture on a Netflix video
https://bugs.webkit.org/show_bug.cgi?id=117020

Patch by Thomas Deniau <[email protected]> on 2013-06-07
Reviewed by Ryosuke Niwa.

* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::performDictionaryLookupAtLocation):
Don't invoke the Dictionary lookup when we failed to extract the range of the token
surrounding the tapped position.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (151331 => 151332)


--- trunk/Source/WebKit2/ChangeLog	2013-06-07 20:11:47 UTC (rev 151331)
+++ trunk/Source/WebKit2/ChangeLog	2013-06-07 20:16:41 UTC (rev 151332)
@@ -1,3 +1,15 @@
+2013-06-07  Thomas Deniau  <[email protected]>
+
+        Reproducible crash with triple-finger-tap "define word" gesture on a Netflix video
+        https://bugs.webkit.org/show_bug.cgi?id=117020
+
+        Reviewed by Ryosuke Niwa.
+
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::performDictionaryLookupAtLocation):
+        Don't invoke the Dictionary lookup when we failed to extract the range of the token
+        surrounding the tapped position.
+
 2013-06-07  Enrique Ocana Gonzalez  <[email protected]>
 
         [GTK] Weird behaviour and no clues to the user when the shared memory file can't be opened

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (151331 => 151332)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm	2013-06-07 20:11:47 UTC (rev 151331)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm	2013-06-07 20:16:41 UTC (rev 151332)
@@ -535,9 +535,15 @@
             break;
         contextEnd = n;
     }
-    contextStart = startOfLine(contextStart);
-    contextEnd = endOfLine(contextEnd);
-    
+
+    VisiblePosition lineStart = startOfLine(contextStart);
+    if (!lineStart.isNull())
+        contextStart = lineStart;
+
+    VisiblePosition lineEnd = endOfLine(contextEnd);
+    if (!lineEnd.isNull())
+        contextEnd = lineEnd;
+
     NSRange rangeToPass = NSMakeRange(TextIterator::rangeLength(makeRange(contextStart, position).get()), 0);
 
     RefPtr<Range> fullCharacterRange = makeRange(contextStart, contextEnd);
@@ -545,6 +551,10 @@
 
     NSRange extractedRange = WKExtractWordDefinitionTokenRangeFromContextualString(fullPlainTextString, rangeToPass, &options);
 
+    // This function sometimes returns {NSNotFound, 0} if it was unable to determine a good string.
+    if (extractedRange.location == NSNotFound)
+        return;
+
     RefPtr<Range> finalRange = TextIterator::subrange(fullCharacterRange.get(), extractedRange.location, extractedRange.length);
     if (!finalRange)
         return;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to