You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@corinthia.apache.org by ja...@apache.org on 2015/02/23 12:39:28 UTC

[25/31] incubator-corinthia git commit: Enable hit testing fixes for above/below body rect

Enable hit testing fixes for above/below body rect

At the start of Position_atPoint, we check if the position is above or
below the body rect, and if so, change the y value so it's on the first
or last line. Previously, we would then just go ahead and return the
result of document.caretRangeFromPoint, but this would skip the other
checks later in the function for things like images and empty footnotes
and endnotes. Now we just adjust the y position, and then continue on
with these checks.


Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/9262c467
Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/9262c467
Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/9262c467

Branch: refs/heads/experimentzip
Commit: 9262c4676dd7e7e77daf70c1f6794e4bd9d5ce97
Parents: b88d11e
Author: Peter Kelly <pe...@uxproductivity.com>
Authored: Wed Feb 18 17:39:29 2015 +0700
Committer: Peter Kelly <pe...@uxproductivity.com>
Committed: Wed Feb 18 16:46:54 2015 +0700

----------------------------------------------------------------------
 Editor/src/Position.js | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/9262c467/Editor/src/Position.js
----------------------------------------------------------------------
diff --git a/Editor/src/Position.js b/Editor/src/Position.js
index 4098e49..9eb03f3 100644
--- a/Editor/src/Position.js
+++ b/Editor/src/Position.js
@@ -941,10 +941,9 @@ var Position_atPoint;
         // cursor based on screen coordinates. However, this doesn't work if the screen coordinates
         // are outside the bounding box of the document's body. So when this is true, we find either
         // the first or last non-whitespace text node, calculate a y value that is half-way between
-        // the top and bottom of its first or last rect (respectively), and then make a call to
-        // caretRangeFromPoint with the same x value but this new y value. This results in the
-        // cursor being placed on the first or last line when the user taps outside the document
-        // bounds.
+        // the top and bottom of its first or last rect (respectively), and use that instead. This
+        // results in the cursor being placed on the first or last line when the user taps outside
+        // the document bounds.
 
         var bodyRect = document.body.getBoundingClientRect();
         var boundaryRect = null;
@@ -953,12 +952,8 @@ var Position_atPoint;
         else if (y >= bodyRect.bottom)
             boundaryRect = findLastTextRect();
 
-        if (boundaryRect != null) {
-            var boundaryY = boundaryRect.top + boundaryRect.height/2;
-            var range = document.caretRangeFromPoint(x,boundaryY);
-            if (range != null)
-                return new Position(range.startContainer,range.startOffset);
-        }
+        if (boundaryRect != null)
+            y = boundaryRect.top + boundaryRect.height/2;
 
         // We get here if the coordinates are inside the document's bounding rect, or if getting the
         // position from the first or last rect failed for some reason.