Return-Path: X-Original-To: apmail-corinthia-commits-archive@minotaur.apache.org Delivered-To: apmail-corinthia-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C06FB1738F for ; Wed, 18 Feb 2015 12:27:20 +0000 (UTC) Received: (qmail 87361 invoked by uid 500); 18 Feb 2015 12:27:20 -0000 Delivered-To: apmail-corinthia-commits-archive@corinthia.apache.org Received: (qmail 87318 invoked by uid 500); 18 Feb 2015 12:27:20 -0000 Mailing-List: contact commits-help@corinthia.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@corinthia.incubator.apache.org Delivered-To: mailing list commits@corinthia.incubator.apache.org Received: (qmail 87302 invoked by uid 99); 18 Feb 2015 12:27:20 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Feb 2015 12:27:20 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 18 Feb 2015 12:26:58 +0000 Received: (qmail 84150 invoked by uid 99); 18 Feb 2015 12:26:56 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Feb 2015 12:26:56 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D4DA3E07A7; Wed, 18 Feb 2015 12:26:55 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: pmkelly@apache.org To: commits@corinthia.incubator.apache.org Date: Wed, 18 Feb 2015 12:26:57 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [3/4] incubator-corinthia git commit: Enable hit testing fixes for above/below body rect X-Virus-Checked: Checked by ClamAV on apache.org 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/master Commit: 9262c4676dd7e7e77daf70c1f6794e4bd9d5ce97 Parents: b88d11e Author: Peter Kelly Authored: Wed Feb 18 17:39:29 2015 +0700 Committer: Peter Kelly 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.