[BlackBerry] Text selection - selection gets broken in test.com/individuals.htm
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Mar 2012 03:47:00 +0000 (03:47 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Mar 2012 03:47:00 +0000 (03:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=82292

Change to check and avoid text selection across frames.

Internal reviewed by Mike Fenton

Patch by Sean Wang <Xuewen.Wang@torchmobile.com.cn> on 2012-03-27
Reviewed by Rob Buis.

* WebKitSupport/SelectionHandler.cpp:
(BlackBerry::WebKit::visiblePositionForPointIgnoringClipping):
    support selection across frames, so check if the *framePoint* is in
    the *frame*.
(BlackBerry::WebKit::SelectionHandler::setSelection):
    function returns a null VisablePosition, it stands for a invalid position
    or a position in the different frames, therefor we don't execute setting
    handle's position.

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

Source/WebKit/blackberry/ChangeLog
Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp

index df521deaaa76c888d6345c82ed516cb6ebef8f1c..29963afe66709e98da17f3ac0fdb5dd5f31b4670 100644 (file)
@@ -1,3 +1,23 @@
+2012-03-27  Sean Wang  <Xuewen.Wang@torchmobile.com.cn>
+
+        [BlackBerry] Text selection - selection gets broken in test.com/individuals.htm
+        https://bugs.webkit.org/show_bug.cgi?id=82292
+
+        Change to check and avoid text selection across frames.
+
+        Internal reviewed by Mike Fenton
+
+        Reviewed by Rob Buis.
+
+        * WebKitSupport/SelectionHandler.cpp:
+        (BlackBerry::WebKit::visiblePositionForPointIgnoringClipping):
+            support selection across frames, so check if the *framePoint* is in
+            the *frame*.
+        (BlackBerry::WebKit::SelectionHandler::setSelection):
+            function returns a null VisablePosition, it stands for a invalid position
+            or a position in the different frames, therefor we don't execute setting
+            handle's position.
+
 2012-03-27  Andrew Lo  <anlo@rim.com>
 
         [BlackBerry] Switch WebPageCompositor to use AnimationFrameRateController instead of timer
 2012-03-27  Andrew Lo  <anlo@rim.com>
 
         [BlackBerry] Switch WebPageCompositor to use AnimationFrameRateController instead of timer
index 9a8f88e543958e5ad01fd4b15cbdb048b0d01b3f..631f66774b230c1a5a89d5f1641c0e6fd8923a9f 100644 (file)
@@ -138,7 +138,7 @@ static VisiblePosition visiblePositionForPointIgnoringClipping(const Frame& fram
     HitTestResult result = frame.eventHandler()->hitTestResultAtPoint(framePoint, true /* allowShadowContent */, true /* ignoreClipping */);
 
     Node* node = result.innerNode();
     HitTestResult result = frame.eventHandler()->hitTestResultAtPoint(framePoint, true /* allowShadowContent */, true /* ignoreClipping */);
 
     Node* node = result.innerNode();
-    if (!node)
+    if (!node || node->document() != frame.document())
         return VisiblePosition();
 
     RenderObject* renderer = node->renderer();
         return VisiblePosition();
 
     RenderObject* renderer = node->renderer();
@@ -450,24 +450,31 @@ void SelectionHandler::setSelection(const WebCore::IntPoint& start, const WebCor
     if (!controller->selection().isBaseFirst())
         controller->setSelection(VisibleSelection(controller->selection().start(), controller->selection().end(), true /* isDirectional */));
 
     if (!controller->selection().isBaseFirst())
         controller->setSelection(VisibleSelection(controller->selection().start(), controller->selection().end(), true /* isDirectional */));
 
+    // We don't return early in the following, so that we can do input field scrolling if the
+    // handle is outside the bounds of the field. This can be extended to handle sub-region
+    // scrolling as well
     if (startIsValid) {
         relativeStart = DOMSupport::convertPointToFrame(m_webPage->mainFrame(), focusedFrame, start);
 
     if (startIsValid) {
         relativeStart = DOMSupport::convertPointToFrame(m_webPage->mainFrame(), focusedFrame, start);
 
-        // Set the selection with validation.
-        newSelection.setBase(visiblePositionForPointIgnoringClipping(*focusedFrame, clipPointToVisibleContainer(start)));
-
-        // Reset the selection using the existing extent without validation.
-        newSelection.setWithoutValidation(newSelection.base(), controller->selection().end());
+        VisiblePosition base = visiblePositionForPointIgnoringClipping(*focusedFrame, clipPointToVisibleContainer(start));
+        if (base.isNotNull()) {
+            // The function setBase validates the "base"
+            newSelection.setBase(base);
+            newSelection.setWithoutValidation(newSelection.base(), controller->selection().end());
+            // Don't return early.
+        }
     }
 
     if (m_lastUpdatedEndPointIsValid) {
         relativeEnd = DOMSupport::convertPointToFrame(m_webPage->mainFrame(), focusedFrame, end);
 
     }
 
     if (m_lastUpdatedEndPointIsValid) {
         relativeEnd = DOMSupport::convertPointToFrame(m_webPage->mainFrame(), focusedFrame, end);
 
-        // Set the selection with validation.
-        newSelection.setExtent(visiblePositionForPointIgnoringClipping(*focusedFrame, clipPointToVisibleContainer(end)));
-
-        // Reset the selection using the existing base without validation.
-        newSelection.setWithoutValidation(controller->selection().start(), newSelection.extent());
+        VisiblePosition extent = visiblePositionForPointIgnoringClipping(*focusedFrame, clipPointToVisibleContainer(end));
+        if (extent.isNotNull()) {
+            // The function setExtent validates the "extent"
+            newSelection.setExtent(extent);
+            newSelection.setWithoutValidation(controller->selection().start(), newSelection.extent());
+            // Don't return early.
+        }
     }
 
     newSelection.setIsDirectional(true);
     }
 
     newSelection.setIsDirectional(true);