Long spins under Frame::rangeForPoint when doing Lookup on feedly.com
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 25 Jan 2015 08:17:39 +0000 (08:17 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 25 Jan 2015 08:17:39 +0000 (08:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=140862
<rdar://problem/19566089>

Reviewed by Dan Bernstein.

* page/Frame.cpp:
(WebCore::Frame::rangeForPoint):
If there isn't a selectable text node at the given point, rangeForPoint
will eventually return null. However, we can make it fail much faster
by checking the initial position's text-ness and selectability.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179086 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/page/Frame.cpp

index 009b89e34738b59d4545deccda73568aa8013e86..d2b34da734fc0f6b25abba022d640a1fa029dc3e 100644 (file)
@@ -1,3 +1,17 @@
+2015-01-25  Timothy Horton  <timothy_horton@apple.com>
+
+        Long spins under Frame::rangeForPoint when doing Lookup on feedly.com
+        https://bugs.webkit.org/show_bug.cgi?id=140862
+        <rdar://problem/19566089>
+
+        Reviewed by Dan Bernstein.
+
+        * page/Frame.cpp:
+        (WebCore::Frame::rangeForPoint):
+        If there isn't a selectable text node at the given point, rangeForPoint
+        will eventually return null. However, we can make it fail much faster
+        by checking the initial position's text-ness and selectability.
+
 2015-01-24  Darin Adler  <darin@apple.com>
 
         Move height/width implementation for use element from RenderSVGViewportContainer to SVGUseElement
index cfe8be50fd46d2b106a2a63046611c72dd096c24..57d7ea56c51f11dc8e8cafa05db05008987138f2 100644 (file)
@@ -849,6 +849,11 @@ RefPtr<Range> Frame::rangeForPoint(const IntPoint& framePoint)
     if (position.isNull())
         return nullptr;
 
+    Position deepPosition = position.deepEquivalent();
+    Text* containerText = deepPosition.containerText();
+    if (!containerText || !containerText->renderer() || containerText->renderer()->style().userSelect() == SELECT_NONE)
+        return nullptr;
+
     VisiblePosition previous = position.previous();
     if (previous.isNotNull()) {
         RefPtr<Range> previousCharacterRange = makeRange(previous, position);