Bug 68198

Summary: Refactor WebViewImpl::scrollFocusedNodeIntoRect to a better place
Product: WebKit Reporter: Varun Jain <varunjain>
Component: DOMAssignee: Varun Jain <varunjain>
Status: RESOLVED FIXED    
Severity: Normal CC: dglazkov, fishd, fsamuel, gustavo, rniwa, webkit.review.bot, xan.lopez
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Description Varun Jain 2011-09-15 16:27:15 PDT
On possible way is to move the logic to frameView and test using window.internals
Comment 1 Varun Jain 2011-09-21 13:21:14 PDT
Created attachment 108219 [details]
Patch
Comment 2 Varun Jain 2011-09-21 13:25:02 PDT
Hi Darin, Dimitri
refactored code according to discussion with Dimitri. PTAL.

@Darin: regarding your last comment on my earlier CL. This method is only invoked on elements that are currently in view. Hence it is enough to simply scroll the main frame. We need not care about the case where the element is in a subframe.
Comment 3 Fady Samuel 2011-09-21 13:26:19 PDT
(In reply to comment #1)
> Created an attachment (id=108219) [details]
> Patch

It would be great to have a layout test where there's sufficient size to center the input box in the rect so we know for a fact centering is working as expected.
Comment 4 Varun Jain 2011-09-21 13:47:57 PDT
Created attachment 108227 [details]
Patch
Comment 5 Varun Jain 2011-09-21 13:48:26 PDT
(In reply to comment #3)
> (In reply to comment #1)
> > Created an attachment (id=108219) [details] [details]
> > Patch
> 
> It would be great to have a layout test where there's sufficient size to center the input box in the rect so we know for a fact centering is working as expected.

Done.
Comment 6 Gustavo Noronha (kov) 2011-09-21 16:13:35 PDT
Comment on attachment 108227 [details]
Patch

Attachment 108227 [details] did not pass gtk-ews (gtk):
Output: http://queues.webkit.org/results/9773901
Comment 7 Varun Jain 2011-09-22 07:37:26 PDT
Created attachment 108330 [details]
Patch
Comment 8 Gustavo Noronha (kov) 2011-09-22 07:50:40 PDT
Comment on attachment 108330 [details]
Patch

Attachment 108330 [details] did not pass gtk-ews (gtk):
Output: http://queues.webkit.org/results/9792319
Comment 9 Varun Jain 2011-09-22 12:08:47 PDT
Created attachment 108378 [details]
Patch
Comment 10 Gustavo Noronha (kov) 2011-09-22 13:36:43 PDT
Comment on attachment 108378 [details]
Patch

Attachment 108378 [details] did not pass gtk-ews (gtk):
Output: http://queues.webkit.org/results/9796377
Comment 11 Varun Jain 2011-09-23 08:54:23 PDT
ping?
Comment 12 Varun Jain 2011-09-23 10:09:06 PDT
Created attachment 108486 [details]
Patch
Comment 13 Gustavo Noronha (kov) 2011-09-23 10:31:08 PDT
Comment on attachment 108486 [details]
Patch

Attachment 108486 [details] did not pass gtk-ews (gtk):
Output: http://queues.webkit.org/results/9822109
Comment 14 Varun Jain 2011-09-23 10:36:33 PDT
Created attachment 108489 [details]
Patch
Comment 15 Dimitri Glazkov (Google) 2011-09-23 11:28:44 PDT
Comment on attachment 108489 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=108489&action=review

Looks good, except for the test.

> LayoutTests/fast/dom/scroll-element-to-rect-centered.html:17
> +        if (window.internals) {
> +          var box = document.getElementById('textbox');
> +          window.internals.scrollElementToRect(box, 50, 30, 200, 250);
> +        }
> +      }
> +      window.addEventListener("load", doTest);
> +    </script>
> +  </head>
> +  <body>
> +    This is test<br>
> +    <div style="position: relative; width: 2400px; height: 2400px; background-color: white;">
> +      <div style="position:fixed; left: 50px; top: 30px; width: 200px; height: 250px; background-color: green;"></div>
> +      <div style="position:absolute; left: 600px; top: 800px;"> <input id="textbox" type="text"></div>

I am pretty sure we can make this test dumpAsText(), to avoid pixel baselines. Can we?

> Source/WebKit/chromium/src/WebViewImpl.cpp:1824
> +    if (focusedNode && focusedNode->isElementNode()) {

early return?
Comment 16 Fady Samuel 2011-09-23 12:59:10 PDT
(In reply to comment #15)
> (From update of attachment 108489 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=108489&action=review
> 
> Looks good, except for the test.
> 
> > LayoutTests/fast/dom/scroll-element-to-rect-centered.html:17
> > +        if (window.internals) {
> > +          var box = document.getElementById('textbox');
> > +          window.internals.scrollElementToRect(box, 50, 30, 200, 250);
> > +        }
> > +      }
> > +      window.addEventListener("load", doTest);
> > +    </script>
> > +  </head>
> > +  <body>
> > +    This is test<br>
> > +    <div style="position: relative; width: 2400px; height: 2400px; background-color: white;">
> > +      <div style="position:fixed; left: 50px; top: 30px; width: 200px; height: 250px; background-color: green;"></div>
> > +      <div style="position:absolute; left: 600px; top: 800px;"> <input id="textbox" type="text"></div>
> 
> I am pretty sure we can make this test dumpAsText(), to avoid pixel baselines. Can we?

Agreed, we should be able to output the final scroll position as text.
Comment 17 Varun Jain 2011-09-23 15:24:47 PDT
Created attachment 108545 [details]
Patch
Comment 18 Varun Jain 2011-09-23 15:25:17 PDT
(In reply to comment #15)
> (From update of attachment 108489 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=108489&action=review
> 
> Looks good, except for the test.
> 
> > LayoutTests/fast/dom/scroll-element-to-rect-centered.html:17
> > +        if (window.internals) {
> > +          var box = document.getElementById('textbox');
> > +          window.internals.scrollElementToRect(box, 50, 30, 200, 250);
> > +        }
> > +      }
> > +      window.addEventListener("load", doTest);
> > +    </script>
> > +  </head>
> > +  <body>
> > +    This is test<br>
> > +    <div style="position: relative; width: 2400px; height: 2400px; background-color: white;">
> > +      <div style="position:fixed; left: 50px; top: 30px; width: 200px; height: 250px; background-color: green;"></div>
> > +      <div style="position:absolute; left: 600px; top: 800px;"> <input id="textbox" type="text"></div>
> 
> I am pretty sure we can make this test dumpAsText(), to avoid pixel baselines. Can we?

Done.

> 
> > Source/WebKit/chromium/src/WebViewImpl.cpp:1824
> > +    if (focusedNode && focusedNode->isElementNode()) {
> 
> early return?

Done.
Comment 19 Dimitri Glazkov (Google) 2011-09-23 15:30:25 PDT
Comment on attachment 108545 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=108545&action=review

> LayoutTests/platform/chromium-linux/fast/dom/scroll-element-to-rect-centered-expected.txt:6
> +PASS rect.left is 72
> +PASS rect.top is 144
> +PASS computedLeft is 72
> +PASS computedTop is 144
> +PASS successfullyParsed is true

Thanks for converting the test! Are these numbers going to be different from platform to platform? If not, why are the expectations in platform-linux? If yes -- can we do better? Can the test be more of a PASS/FAIL report, with the assessment of the exact coordinates being platform-independent?
Comment 20 Varun Jain 2011-09-23 16:36:51 PDT
Created attachment 108557 [details]
Patch
Comment 21 Varun Jain 2011-09-23 16:37:21 PDT
(In reply to comment #19)
> (From update of attachment 108545 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=108545&action=review
> 
> > LayoutTests/platform/chromium-linux/fast/dom/scroll-element-to-rect-centered-expected.txt:6
> > +PASS rect.left is 72
> > +PASS rect.top is 144
> > +PASS computedLeft is 72
> > +PASS computedTop is 144
> > +PASS successfullyParsed is true
> 
> Thanks for converting the test! Are these numbers going to be different from platform to platform? If not, why are the expectations in platform-linux? If yes -- can we do better? Can the test be more of a PASS/FAIL report, with the assessment of the exact coordinates being platform-independent?

Added to all platforms. I think it should pass all tests.
Comment 22 Dimitri Glazkov (Google) 2011-09-23 16:42:41 PDT
Comment on attachment 108557 [details]
Patch

Let's give it a whirl.
Comment 23 WebKit Review Bot 2011-09-23 17:23:01 PDT
Comment on attachment 108557 [details]
Patch

Clearing flags on attachment: 108557

Committed r95890: <http://trac.webkit.org/changeset/95890>
Comment 24 WebKit Review Bot 2011-09-23 17:23:07 PDT
All reviewed patches have been landed.  Closing bug.
Comment 25 Ryosuke Niwa 2011-09-26 10:42:18 PDT
The test added by this patch is failing on Snow Leopard:
http://build.webkit.org/results/SnowLeopard%20Intel%20Release%20(Tests)/r95957%20(33384)/results.html
Comment 26 Varun Jain 2011-09-26 11:03:40 PDT
(In reply to comment #25)
> The test added by this patch is failing on Snow Leopard:
> http://build.webkit.org/results/SnowLeopard%20Intel%20Release%20(Tests)/r95957%20(33384)/results.html

hi.. thanks for bringing this to my attention.
I think the test is failing because the frame doesnot have enough room to scroll and hence cannot position the element correctly. This should be easily fixable by increasing the size of the div in the test. I'll try to get hold of a machine to try this fix on