Bug 30034 - caretRangeFromPoint() returns wrong result for a zoomed and scrolled page
Summary: caretRangeFromPoint() returns wrong result for a zoomed and scrolled page
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-02 16:25 PDT by Xiaomei Ji
Modified: 2009-10-12 21:59 PDT (History)
7 users (show)

See Also:


Attachments
test case (1.38 KB, text/html)
2009-10-02 16:25 PDT, Xiaomei Ji
no flags Details
patch w/ layout test (9.29 KB, patch)
2009-10-07 10:08 PDT, Xiaomei Ji
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Xiaomei Ji 2009-10-02 16:25:37 PDT
Created attachment 40556 [details]
test case

Steps:
1. Open the attached HTML
2. click mouse somewhere to show the offset of mouse within the element
3. zoom the page *and* resize the window to make the page scroll
4. scroll the page horizontally and/or vertically, 
5. click mouse in the same place as step 2., observe the printed offset.

Results:
the printd offset is different when page is zoomed and scrolled.

Expected:
the printed offset should be the same.

Problem: in Document.caretRangeFromPoint()

    IntPoint point = roundedIntPoint(FloatPoint(x * zoomFactor, y * zoomFactor)) + view()->scrollOffset();

    should be:

    IntPoint point = roundedIntPoint(FloatPoint((x + view()->scrollX()) * zoomFactor, (y + view()->scrollY()) * zoomFactor));


Note:
Same bug applies to elementFromPoint() as well.
Comment 1 Xiaomei Ji 2009-10-07 10:08:20 PDT
Created attachment 40802 [details]
patch w/ layout test
Comment 2 Eric Seidel (no email) 2009-10-07 12:06:59 PDT
Sam's your best bet.  Why don't we have a zoomAndPanTransform() accessor on the document and just map points through that.  It seems using TransformationMatrix and IntPoint would make this code (which we have lots of) much less error prone.
Comment 3 WebKit Commit Bot 2009-10-12 19:06:31 PDT
Comment on attachment 40802 [details]
patch w/ layout test

Rejecting patch 40802 from commit-queue.

Failed to run "['WebKitTools/Scripts/run-webkit-tests', '--no-launch-safari', '--quiet', '--exit-after-n-failures=1']" exit_code: 1
Running build-dumprendertree
Running tests from /Users/eseidel/Projects/CommitQueue/LayoutTests
Testing 11423 test cases.
fast/dom/prototype-inheritance-2.html -> failed

Exiting early after 1 failures. 5497 tests run.
253.83s total testing time

5496 test cases (99%) succeeded
1 test case (<1%) had incorrect layout
1 test case (<1%) had stderr output
Comment 4 Eric Seidel (no email) 2009-10-12 19:11:58 PDT
Comment on attachment 40802 [details]
patch w/ layout test

Sorry.  The bots were behind.  bug 30098.  This is a false rejection.  Trying again.
Comment 5 WebKit Commit Bot 2009-10-12 21:59:44 PDT
Comment on attachment 40802 [details]
patch w/ layout test

Clearing flags on attachment: 40802

Committed r49490: <http://trac.webkit.org/changeset/49490>
Comment 6 WebKit Commit Bot 2009-10-12 21:59:48 PDT
All reviewed patches have been landed.  Closing bug.