Changeset 202147 in webkit


Ignore:
Timestamp:
Jun 16, 2016, 4:34:17 PM (9 years ago)
Author:
Simon Fraser
Message:

Source/WebCore:
[iOS] Focus event dispatched in iframe causes parent document to scroll incorrectly
https://bugs.webkit.org/show_bug.cgi?id=158629
rdar://problem/26521616

Reviewed by Enrica Casucci.

When focussing elements in iframes, the page could scroll to an incorrect location.
This happened because code in Element::focus() tried to disable scrolling on focus,
but did so only for the current frame, so ancestor frames got programmatically scrolled.
On iOS we handle the scrolling in the UI process, so never want the web process to
do programmatic scrolling.

Fix by changing the focus and cache restore code to use SelectionRevealMode::DoNotReveal,
rather than manually prohibiting frame scrolling.

Tests: fast/forms/ios/focus-input-in-iframe.html

fast/forms/ios/programmatic-focus-input-in-iframe.html

  • dom/Element.cpp:

(WebCore::Element::focus):

  • history/CachedPage.cpp:

(WebCore::CachedPage::restore):

LayoutTests:
Focus event dispatched in iframe causes parent document to scroll incorrectly
https://bugs.webkit.org/show_bug.cgi?id=158629
rdar://problem/26521616

Reviewed by Enrica Casucci.

Tests for user-initiated and programmatic focus in frames.

  • fast/forms/ios/focus-input-in-iframe-expected.txt: Added.
  • fast/forms/ios/focus-input-in-iframe.html: Added.
  • fast/forms/ios/programmatic-focus-input-in-iframe.html: Added.
  • fast/forms/ios/programmatic-focus-input-in-iframe-expected.txt: Added.
Location:
trunk
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r202146 r202147  
     12016-06-16  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Focus event dispatched in iframe causes parent document to scroll incorrectly
     4        https://bugs.webkit.org/show_bug.cgi?id=158629
     5        rdar://problem/26521616
     6
     7        Reviewed by Enrica Casucci.
     8       
     9        Tests for user-initiated and programmatic focus in frames.
     10
     11        * fast/forms/ios/focus-input-in-iframe-expected.txt: Added.
     12        * fast/forms/ios/focus-input-in-iframe.html: Added.
     13        * fast/forms/ios/programmatic-focus-input-in-iframe.html: Added.
     14        * fast/forms/ios/programmatic-focus-input-in-iframe-expected.txt: Added.
     15
    1162016-06-16  Zalan Bujtas  <zalan@apple.com>
    217
  • trunk/Source/WebCore/ChangeLog

    r202146 r202147  
     12016-06-16  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [iOS] Focus event dispatched in iframe causes parent document to scroll incorrectly
     4        https://bugs.webkit.org/show_bug.cgi?id=158629
     5        rdar://problem/26521616
     6
     7        Reviewed by Enrica Casucci.
     8
     9        When focussing elements in iframes, the page could scroll to an incorrect location.
     10        This happened because code in Element::focus() tried to disable scrolling on focus,
     11        but did so only for the current frame, so ancestor frames got programmatically scrolled.
     12        On iOS we handle the scrolling in the UI process, so never want the web process to
     13        do programmatic scrolling.
     14
     15        Fix by changing the focus and cache restore code to use SelectionRevealMode::DoNotReveal,
     16        rather than manually prohibiting frame scrolling.
     17
     18        Tests: fast/forms/ios/focus-input-in-iframe.html
     19               fast/forms/ios/programmatic-focus-input-in-iframe.html
     20
     21        * dom/Element.cpp:
     22        (WebCore::Element::focus):
     23        * history/CachedPage.cpp:
     24        (WebCore::CachedPage::restore):
     25
    1262016-06-16  Zalan Bujtas  <zalan@apple.com>
    227
  • trunk/Source/WebCore/dom/Element.cpp

    r202105 r202147  
    22462246       
    22472247    cancelFocusAppearanceUpdate();
     2248
     2249    SelectionRevealMode revealMode = SelectionRevealMode::Reveal;
    22482250#if PLATFORM(IOS)
    22492251    // Focusing a form element triggers animation in UIKit to scroll to the right position.
     
    22532255    bool isFormControl = view && is<HTMLFormControlElement>(*this);
    22542256    if (isFormControl)
    2255         view->setProhibitsScrolling(true);
     2257        revealMode = SelectionRevealMode::DoNotReveal;
    22562258#endif
    2257     updateFocusAppearance(restorePreviousSelection ? SelectionRestorationMode::Restore : SelectionRestorationMode::SetDefault);
    2258 #if PLATFORM(IOS)
    2259     if (isFormControl)
    2260         view->setProhibitsScrolling(false);
    2261 #endif
     2259    updateFocusAppearance(restorePreviousSelection ? SelectionRestorationMode::Restore : SelectionRestorationMode::SetDefault, revealMode);
    22622260}
    22632261
  • trunk/Source/WebCore/history/CachedPage.cpp

    r201655 r202147  
    7878   
    7979    // Restore the focus appearance for the focused element.
    80     // FIXME: Right now we don't support pages w/ frames in the b/f cache. This may need to be tweaked when we add support for that.
     80    // FIXME: Right now we don't support pages with frames in the b/f cache. This may need to be tweaked when we add support for that.
    8181    Document* focusedDocument = page.focusController().focusedOrMainFrame().document();
    8282    if (Element* element = focusedDocument->focusedElement()) {
     83        SelectionRevealMode revealMode = SelectionRevealMode::Reveal;
    8384#if PLATFORM(IOS)
    8485        // We don't want focused nodes changing scroll position when restoring from the cache
    8586        // as it can cause ugly jumps before we manage to restore the cached position.
    8687        page.mainFrame().selection().suppressScrolling();
    87 
    88         bool hadProhibitsScrolling = false;
    89         FrameView* frameView = page.mainFrame().view();
    90         if (frameView) {
    91             hadProhibitsScrolling = frameView->prohibitsScrolling();
    92             frameView->setProhibitsScrolling(true);
    93         }
     88        revealMode = SelectionRevealMode::DoNotReveal;
    9489#endif
    95         element->updateFocusAppearance(SelectionRestorationMode::Restore);
     90        element->updateFocusAppearance(SelectionRestorationMode::Restore, revealMode);
    9691#if PLATFORM(IOS)
    97         if (frameView)
    98             frameView->setProhibitsScrolling(hadProhibitsScrolling);
    9992        page.mainFrame().selection().restoreScrolling();
    10093#endif
Note: See TracChangeset for help on using the changeset viewer.