Changeset 202292 in webkit


Ignore:
Timestamp:
Jun 21, 2016, 1:57:29 PM (9 years ago)
Author:
Simon Fraser
Message:

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 Tim Horton.
Source/WebCore:

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. Pass SelectionRevealMode through various callers,
and use RevealUpToMainFrame for iOS, allowing the UI process to do the zoomToRect: for the main frame.

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

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

  • dom/Document.h:
  • dom/Element.cpp:

(WebCore::Element::scrollIntoView):
(WebCore::Element::scrollIntoViewIfNeeded):
(WebCore::Element::scrollIntoViewIfNotVisible):
(WebCore::Element::focus):
(WebCore::Element::updateFocusAppearance):

  • dom/Element.h:
  • editing/Editor.cpp:

(WebCore::Editor::insertTextWithoutSendingTextEvent):
(WebCore::Editor::revealSelectionAfterEditingOperation):
(WebCore::Editor::findStringAndScrollToVisible):

  • editing/FrameSelection.cpp:

(WebCore::FrameSelection::updateAndRevealSelection):
(WebCore::FrameSelection::revealSelection):
(WebCore::FrameSelection::FrameSelection): Deleted.

  • editing/FrameSelection.h:
  • html/HTMLInputElement.cpp:

(WebCore::HTMLInputElement::updateFocusAppearance):

  • html/HTMLTextAreaElement.cpp:

(WebCore::HTMLTextAreaElement::updateFocusAppearance):

  • page/ContextMenuController.cpp:

(WebCore::ContextMenuController::contextMenuItemSelected):

  • page/FrameView.cpp:

(WebCore::FrameView::scrollToAnchor):

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::scrollRectToVisible):
(WebCore::RenderLayer::autoscroll):

  • rendering/RenderLayer.h:
  • rendering/RenderObject.cpp:

(WebCore::RenderObject::scrollRectToVisible):

  • rendering/RenderObject.h:

Source/WebKit/mac:

Pass SelectionRevealMode::Reveal in existing code.

  • WebView/WebFrame.mm:

(-[WebFrame _scrollDOMRangeToVisible:]):
(-[WebFrame _scrollDOMRangeToVisible:withInset:]):
(-[WebFrame revealSelectionAtExtent:]):

  • WebView/WebHTMLView.mm:

(-[WebHTMLView jumpToSelection:]):
(-[WebHTMLView centerSelectionInVisibleArea:]):

Source/WebKit2:

Pass SelectionRevealMode::Reveal in existing code.

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::centerSelectionInVisibleArea):

LayoutTests:

  • 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-expected.txt: Added.
  • fast/forms/ios/programmatic-focus-input-in-iframe.html: Added.
Location:
trunk
Files:
15 added
25 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r202290 r202292  
     12016-06-20  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 Tim Horton.
     8
     9        * fast/forms/ios/focus-input-in-iframe-expected.txt: Added.
     10        * fast/forms/ios/focus-input-in-iframe.html: Added.
     11        * fast/forms/ios/programmatic-focus-input-in-iframe-expected.txt: Added.
     12        * fast/forms/ios/programmatic-focus-input-in-iframe.html: Added.
     13
    1142016-06-21  Alexey Proskuryakov  <ap@apple.com>
    215
  • trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations

    r201724 r202292  
    861861fast/overflow/overflow-update-transform.html [ Failure ]
    862862fast/overflow/replaced-child-100percent-height-inside-fixed-container-with-overflow-auto.html [ Failure ]
    863 fast/overflow/scroll-vertical-not-horizontal.html [ Failure ]
     863# fast/overflow/scroll-vertical-not-horizontal.html [ Failure ]
    864864fast/regions/region-styling/region-style-block-background-color2.html [ ImageOnlyFailure ]
    865865fast/shapes/shape-outside-floats/shape-outside-floats-circle-000.html [ ImageOnlyFailure ]
  • trunk/LayoutTests/platform/ios-simulator-wk1/fast/overflow/scrollRevealButton-expected.txt

    r202291 r202292  
    1616            RenderBlock {HTML} at (0,0) size 300x316
    1717              RenderBody {BODY} at (8,8) size 284x300
    18           layer at (8,8) size 300x300 clip at (8,8) size 285x300 scrollY 545 scrollHeight 1270
     18          layer at (8,8) size 300x300 scrollY 545 scrollHeight 1270
    1919            RenderBlock {DIV} at (0,0) size 300x300
    20               RenderBlock (anonymous) at (0,0) size 285x20
     20              RenderBlock (anonymous) at (0,0) size 300x20
    2121                RenderText {#text} at (0,0) size 90x19
    2222                  text run at (0,0) width 90: "overflow:auto"
    23               RenderBlock {DIV} at (0,20) size 285x600
    24               RenderBlock {DIV} at (0,770) size 285x500
    25           layer at (8,83) size 150x150 clip at (8,83) size 135x150 scrollY 477 scrollHeight 864
     23              RenderBlock {DIV} at (0,20) size 300x600
     24              RenderBlock {DIV} at (0,770) size 300x500
     25          layer at (8,83) size 150x150 scrollY 477 scrollHeight 864
    2626            RenderBlock {DIV} at (0,620) size 150x150
    27               RenderBlock (anonymous) at (0,0) size 135x20
     27              RenderBlock (anonymous) at (0,0) size 150x20
    2828                RenderText {#text} at (0,0) size 90x19
    2929                  text run at (0,0) width 90: "overflow:auto"
    30               RenderBlock {DIV} at (0,20) size 135x500
    31               RenderBlock (anonymous) at (0,520) size 135x44
     30              RenderBlock {DIV} at (0,20) size 150x500
     31              RenderBlock (anonymous) at (0,520) size 150x44
    3232                RenderBR {BR} at (0,0) size 0x19
    3333                RenderButton {INPUT} at (2,22) size 56x20 [bgcolor=#FFFFFF02] [border: (1px solid #4C4C4C)]
     
    3636                      text run at (0,0) width 32: "Button"
    3737                RenderText {#text} at (0,0) size 0x0
    38               RenderBlock {DIV} at (0,564) size 135x300
     38              RenderBlock {DIV} at (0,564) size 150x300
    3939        RenderText {#text} at (0,0) size 0x0
    4040      RenderBlock {DIV} at (0,674) size 784x500
    41 scrolled to 0,388
     41frame 'fr' scrolled to 0,18
  • trunk/LayoutTests/platform/ios-simulator-wk2/fast/overflow/scrollRevealButton-expected.txt

    r177430 r202292  
    3939        RenderText {#text} at (0,0) size 0x0
    4040      RenderBlock {DIV} at (0,674) size 784x500
    41 scrolled to 0,388
  • trunk/LayoutTests/platform/ios-simulator/TestExpectations

    r202170 r202292  
    17601760fast/forms/option-mouseevents.html [ Failure ]
    17611761fast/forms/password-doubleclick-selection.html [ Failure ]
    1762 fast/forms/password-placeholder-text-security.html [ ImageOnlyFailure ]
     1762fast/forms/password-placeholder-text-security.html [ Pass ImageOnlyFailure ]
    17631763fast/forms/placeholder-position.html [ Failure ]
    1764 fast/forms/radio/indeterminate-radio.html [ Failure ]
     1764fast/forms/radio/indeterminate-radio.html [ Pass Failure ]
    17651765fast/forms/range/range-drag-when-toggled-disabled.html [ Failure ]
    17661766fast/forms/range/range-drag.html [ Failure ]
     
    29422942fast/inline/inline-with-outline-offset.html [ ImageOnlyFailure ]
    29432943fast/inline/outline-corners-with-offset.html [ ImageOnlyFailure ]
    2944 fast/overflow/overflow-hidden-scroll-into-view.html [ ImageOnlyFailure ]
     2944fast/overflow/overflow-hidden-scroll-into-view.html [ Pass ImageOnlyFailure ]
    29452945fast/regions/layers/region-removed-during-animation.html [ ImageOnlyFailure ]
    29462946fast/sub-pixel/table-with-subpixel-cell-size.html [ ImageOnlyFailure ]
  • trunk/Source/WebCore/ChangeLog

    r202284 r202292  
     12016-06-20  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 Tim Horton.
     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. Pass SelectionRevealMode through various callers,
     17        and use RevealUpToMainFrame for iOS, allowing the UI process to do the zoomToRect: for the main frame.
     18
     19        Tests: fast/forms/ios/focus-input-in-iframe.html
     20               fast/forms/ios/programmatic-focus-input-in-iframe.html
     21
     22        * dom/Document.h:
     23        * dom/Element.cpp:
     24        (WebCore::Element::scrollIntoView):
     25        (WebCore::Element::scrollIntoViewIfNeeded):
     26        (WebCore::Element::scrollIntoViewIfNotVisible):
     27        (WebCore::Element::focus):
     28        (WebCore::Element::updateFocusAppearance):
     29        * dom/Element.h:
     30        * editing/Editor.cpp:
     31        (WebCore::Editor::insertTextWithoutSendingTextEvent):
     32        (WebCore::Editor::revealSelectionAfterEditingOperation):
     33        (WebCore::Editor::findStringAndScrollToVisible):
     34        * editing/FrameSelection.cpp:
     35        (WebCore::FrameSelection::updateAndRevealSelection):
     36        (WebCore::FrameSelection::revealSelection):
     37        (WebCore::FrameSelection::FrameSelection): Deleted.
     38        * editing/FrameSelection.h:
     39        * html/HTMLInputElement.cpp:
     40        (WebCore::HTMLInputElement::updateFocusAppearance):
     41        * html/HTMLTextAreaElement.cpp:
     42        (WebCore::HTMLTextAreaElement::updateFocusAppearance):
     43        * page/ContextMenuController.cpp:
     44        (WebCore::ContextMenuController::contextMenuItemSelected):
     45        * page/FrameView.cpp:
     46        (WebCore::FrameView::scrollToAnchor):
     47        * rendering/RenderLayer.cpp:
     48        (WebCore::RenderLayer::scrollRectToVisible):
     49        (WebCore::RenderLayer::autoscroll):
     50        * rendering/RenderLayer.h:
     51        * rendering/RenderObject.cpp:
     52        (WebCore::RenderObject::scrollRectToVisible):
     53        * rendering/RenderObject.h:
     54
    1552016-06-21  Frederic Wang  <fwang@igalia.com>
    256
  • trunk/Source/WebCore/dom/Document.h

    r202263 r202292  
    283283};
    284284
    285 enum class SelectionRevealMode {
    286     Reveal,
    287     DoNotReveal
    288 };
    289 
    290285enum class HttpEquivPolicy {
    291286    Enabled,
  • trunk/Source/WebCore/dom/Element.cpp

    r202263 r202292  
    640640    // Align to the top / bottom and to the closest edge.
    641641    if (alignToTop)
    642         renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways);
     642        renderer()->scrollRectToVisible(SelectionRevealMode::Reveal, bounds, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways);
    643643    else
    644         renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignBottomAlways);
     644        renderer()->scrollRectToVisible(SelectionRevealMode::Reveal, bounds, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignBottomAlways);
    645645}
    646646
     
    654654    LayoutRect bounds = renderer()->anchorRect();
    655655    if (centerIfNeeded)
    656         renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded);
     656        renderer()->scrollRectToVisible(SelectionRevealMode::Reveal, bounds, ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded);
    657657    else
    658         renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
     658        renderer()->scrollRectToVisible(SelectionRevealMode::Reveal, bounds, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
    659659}
    660660
     
    668668    LayoutRect bounds = renderer()->anchorRect();
    669669    if (centerIfNotVisible)
    670         renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignCenterIfNotVisible, ScrollAlignment::alignCenterIfNotVisible);
     670        renderer()->scrollRectToVisible(SelectionRevealMode::Reveal, bounds, ScrollAlignment::alignCenterIfNotVisible, ScrollAlignment::alignCenterIfNotVisible);
    671671    else
    672         renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNotVisible, ScrollAlignment::alignToEdgeIfNotVisible);
     672        renderer()->scrollRectToVisible(SelectionRevealMode::Reveal, bounds, ScrollAlignment::alignToEdgeIfNotVisible, ScrollAlignment::alignToEdgeIfNotVisible);
    673673}
    674674   
     
    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.
    22502252    // Calling updateFocusAppearance() would generate an unnecessary call to ScrollView::setScrollPosition(),
    22512253    // which would jump us around during this animation. See <rdar://problem/6699741>.
    2252     FrameView* view = document().view();
    2253     bool isFormControl = view && is<HTMLFormControlElement>(*this);
     2254    bool isFormControl = is<HTMLFormControlElement>(*this);
    22542255    if (isFormControl)
    2255         view->setProhibitsScrolling(true);
     2256        revealMode = SelectionRevealMode::RevealUpToMainFrame;
    22562257#endif
    2257     updateFocusAppearance(restorePreviousSelection ? SelectionRestorationMode::Restore : SelectionRestorationMode::SetDefault);
    2258 #if PLATFORM(IOS)
    2259     if (isFormControl)
    2260         view->setProhibitsScrolling(false);
    2261 #endif
     2258
     2259    updateFocusAppearance(restorePreviousSelection ? SelectionRestorationMode::Restore : SelectionRestorationMode::SetDefault, revealMode);
    22622260}
    22632261
     
    22912289        if (frame->selection().shouldChangeSelection(newSelection)) {
    22922290            frame->selection().setSelection(newSelection, FrameSelection::defaultSetSelectionOptions(), Element::defaultFocusTextStateChangeIntent());
    2293             if (revealMode == SelectionRevealMode::Reveal)
    2294                 frame->selection().revealSelection();
     2291            frame->selection().revealSelection(revealMode);
    22952292        }
    2296     } else if (renderer() && !renderer()->isWidget() && revealMode == SelectionRevealMode::Reveal)
    2297         renderer()->scrollRectToVisible(renderer()->anchorRect());
     2293    } else if (renderer() && !renderer()->isWidget())
     2294        renderer()->scrollRectToVisible(revealMode, renderer()->anchorRect());
    22982295}
    22992296
  • trunk/Source/WebCore/dom/Element.h

    r202263 r202292  
    6161};
    6262
     63enum class SelectionRevealMode {
     64    Reveal,
     65    RevealUpToMainFrame, // Scroll overflow and iframes, but not the main frame.
     66    DoNotReveal
     67};
     68
    6369class Element : public ContainerNode {
    6470public:
  • trunk/Source/WebCore/editing/Editor.cpp

    r202263 r202292  
    12051205            if (Frame* editedFrame = document->frame())
    12061206                if (Page* page = editedFrame->page())
    1207                     page->focusController().focusedOrMainFrame().selection().revealSelection(ScrollAlignment::alignCenterIfNeeded);
     1207                    page->focusController().focusedOrMainFrame().selection().revealSelection(SelectionRevealMode::Reveal, ScrollAlignment::alignCenterIfNeeded);
    12081208        }
    12091209    }
     
    28002800        return;
    28012801
    2802     m_frame.selection().revealSelection(alignment, revealExtentOption);
     2802    m_frame.selection().revealSelection(SelectionRevealMode::Reveal, alignment, revealExtentOption);
    28032803}
    28042804
     
    31483148        return nullptr;
    31493149
    3150     nextMatch->firstNode()->renderer()->scrollRectToVisible(nextMatch->absoluteBoundingBox(),
     3150    nextMatch->firstNode()->renderer()->scrollRectToVisible(SelectionRevealMode::Reveal, nextMatch->absoluteBoundingBox(),
    31513151        ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded);
    31523152
  • trunk/Source/WebCore/editing/FrameSelection.cpp

    r202263 r202292  
    128128    , m_updateAppearanceEnabled(false)
    129129    , m_caretBlinks(true)
    130     , m_scrollingSuppressCount(0)
    131130#endif
    132131{
     
    389388            alignment = m_alwaysAlignCursorOnScrollWhenRevealingSelection ? ScrollAlignment::alignTopAlways : ScrollAlignment::alignToEdgeIfNeeded;
    390389
    391         revealSelection(alignment, RevealExtent);
     390        revealSelection(SelectionRevealMode::Reveal, alignment, RevealExtent);
    392391    }
    393392
     
    22912290}
    22922291
    2293 void FrameSelection::revealSelection(const ScrollAlignment& alignment, RevealExtentOption revealExtentOption)
    2294 {
     2292void FrameSelection::revealSelection(SelectionRevealMode revealMode, const ScrollAlignment& alignment, RevealExtentOption revealExtentOption)
     2293{
     2294    if (revealMode == SelectionRevealMode::DoNotReveal)
     2295        return;
     2296
    22952297    LayoutRect rect;
    22962298
     
    23132315            if (!m_scrollingSuppressCount) {
    23142316                layer->setAdjustForIOSCaretWhenScrolling(true);
    2315                 layer->scrollRectToVisible(rect, alignment, alignment);
     2317                layer->scrollRectToVisible(revealMode, rect, alignment, alignment);
    23162318                layer->setAdjustForIOSCaretWhenScrolling(false);
    23172319                updateAppearance();
     
    23242326        // the selection rect could intersect more than just that.
    23252327        // See <rdar://problem/4799899>.
    2326         if (start.deprecatedNode()->renderer()->scrollRectToVisible(rect, alignment, alignment))
     2328        if (start.deprecatedNode()->renderer()->scrollRectToVisible(revealMode, rect, alignment, alignment))
    23272329            updateAppearance();
    23282330#endif
  • trunk/Source/WebCore/editing/FrameSelection.h

    r202263 r202292  
    2929#include "AXTextStateChangeIntent.h"
    3030#include "EditingStyle.h"
     31#include "Element.h"
    3132#include "IntRect.h"
    3233#include "LayoutRect.h"
     
    267268    WEBCORE_EXPORT HTMLFormElement* currentForm() const;
    268269
    269     WEBCORE_EXPORT void revealSelection(const ScrollAlignment& = ScrollAlignment::alignCenterIfNeeded, RevealExtentOption = DoNotRevealExtent);
     270    WEBCORE_EXPORT void revealSelection(SelectionRevealMode = SelectionRevealMode::Reveal, const ScrollAlignment& = ScrollAlignment::alignCenterIfNeeded, RevealExtentOption = DoNotRevealExtent);
    270271    WEBCORE_EXPORT void setSelectionFromNone();
    271272
     
    351352    bool m_caretBlinks : 1;
    352353    Color m_caretColor;
    353     int m_scrollingSuppressCount;
     354    int m_scrollingSuppressCount { 0 };
    354355#endif
    355356};
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r202263 r202292  
    405405        else
    406406            restoreCachedSelection();
    407         if (document().frame() && revealMode == SelectionRevealMode::Reveal)
    408             document().frame()->selection().revealSelection();
     407        if (document().frame())
     408            document().frame()->selection().revealSelection(revealMode);
    409409    } else
    410410        HTMLTextFormControlElement::updateFocusAppearance(restorationMode, revealMode);
  • trunk/Source/WebCore/html/HTMLTextAreaElement.cpp

    r202263 r202292  
    261261        restoreCachedSelection(Element::defaultFocusTextStateChangeIntent());
    262262
    263     if (document().frame() && revealMode == SelectionRevealMode::Reveal)
    264         document().frame()->selection().revealSelection();
     263    if (document().frame())
     264        document().frame()->selection().revealSelection(revealMode);
    265265}
    266266
  • trunk/Source/WebCore/page/ContextMenuController.cpp

    r202263 r202292  
    373373            RefPtr<ReplaceSelectionCommand> command = ReplaceSelectionCommand::create(*document, createFragmentFromMarkup(*document, title, ""), replaceOptions);
    374374            applyCommand(command);
    375             frame->selection().revealSelection(ScrollAlignment::alignToEdgeIfNeeded);
     375            frame->selection().revealSelection(SelectionRevealMode::Reveal, ScrollAlignment::alignToEdgeIfNeeded);
    376376        }
    377377        break;
  • trunk/Source/WebCore/page/FrameView.cpp

    r202263 r202292  
    30513051    // Align to the top and to the closest side (this matches other browsers).
    30523052    if (anchorNode->renderer()->style().isHorizontalWritingMode())
    3053         anchorNode->renderer()->scrollRectToVisible(rect, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways);
     3053        anchorNode->renderer()->scrollRectToVisible(SelectionRevealMode::Reveal, rect, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways);
    30543054    else if (anchorNode->renderer()->style().isFlippedBlocksWritingMode())
    3055         anchorNode->renderer()->scrollRectToVisible(rect, ScrollAlignment::alignRightAlways, ScrollAlignment::alignToEdgeIfNeeded);
     3055        anchorNode->renderer()->scrollRectToVisible(SelectionRevealMode::Reveal, rect, ScrollAlignment::alignRightAlways, ScrollAlignment::alignToEdgeIfNeeded);
    30563056    else
    3057         anchorNode->renderer()->scrollRectToVisible(rect, ScrollAlignment::alignLeftAlways, ScrollAlignment::alignToEdgeIfNeeded);
     3057        anchorNode->renderer()->scrollRectToVisible(SelectionRevealMode::Reveal, rect, ScrollAlignment::alignLeftAlways, ScrollAlignment::alignToEdgeIfNeeded);
    30583058
    30593059    if (AXObjectCache* cache = frame().document()->existingAXObjectCache())
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r202263 r202292  
    8181#include "HitTestResult.h"
    8282#include "Logging.h"
     83#include "MainFrame.h"
    8384#include "NoEventDispatchAssertion.h"
    8485#include "OverflowEvent.h"
     
    24912492}
    24922493
    2493 void RenderLayer::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignment& alignX, const ScrollAlignment& alignY)
     2494void RenderLayer::scrollRectToVisible(SelectionRevealMode revealMode, const LayoutRect& rect, const ScrollAlignment& alignX, const ScrollAlignment& alignY)
    24942495{
    24952496    LOG_WITH_STREAM(Scrolling, stream << "Layer " << this << " scrollRectToVisible " << rect);
     
    25512552            }
    25522553        } else {
     2554            if (revealMode == SelectionRevealMode::RevealUpToMainFrame && frameView.frame().isMainFrame())
     2555                return;
     2556
    25532557#if !PLATFORM(IOS)
    25542558            LayoutRect viewRect = frameView.visibleContentRect();
     
    25752579   
    25762580    if (parentLayer)
    2577         parentLayer->scrollRectToVisible(newRect, alignX, alignY);
     2581        parentLayer->scrollRectToVisible(revealMode, newRect, alignX, alignY);
    25782582}
    25792583
     
    26682672{
    26692673    IntPoint currentDocumentPosition = renderer().view().frameView().windowToContents(position);
    2670     scrollRectToVisible(LayoutRect(currentDocumentPosition, LayoutSize(1, 1)), ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
     2674    scrollRectToVisible(SelectionRevealMode::Reveal, LayoutRect(currentDocumentPosition, LayoutSize(1, 1)), ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
    26712675}
    26722676
  • trunk/Source/WebCore/rendering/RenderLayer.h

    r202263 r202292  
    206206    void availableContentSizeChanged(AvailableSizeChangeReason) override;
    207207
    208     void scrollRectToVisible(const LayoutRect&, const ScrollAlignment& alignX, const ScrollAlignment& alignY);
     208    void scrollRectToVisible(SelectionRevealMode, const LayoutRect&, const ScrollAlignment& alignX, const ScrollAlignment& alignY);
    209209
    210210    LayoutRect getRectToExpose(const LayoutRect& visibleRect, const LayoutRect& visibleRectRelativeToDocument, const LayoutRect& exposeRect, const ScrollAlignment& alignX, const ScrollAlignment& alignY);
  • trunk/Source/WebCore/rendering/RenderObject.cpp

    r202263 r202292  
    359359}
    360360
    361 bool RenderObject::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignment& alignX, const ScrollAlignment& alignY)
    362 {
     361bool RenderObject::scrollRectToVisible(SelectionRevealMode revealMode, const LayoutRect& rect, const ScrollAlignment& alignX, const ScrollAlignment& alignY)
     362{
     363    if (revealMode == SelectionRevealMode::DoNotReveal)
     364        return false;
     365
    363366    RenderLayer* enclosingLayer = this->enclosingLayer();
    364367    if (!enclosingLayer)
    365368        return false;
    366369
    367     enclosingLayer->scrollRectToVisible(rect, alignX, alignY);
     370    enclosingLayer->scrollRectToVisible(revealMode, rect, alignX, alignY);
    368371    return true;
    369372}
  • trunk/Source/WebCore/rendering/RenderObject.h

    r202278 r202292  
    156156
    157157    // Scrolling is a RenderBox concept, however some code just cares about recursively scrolling our enclosing ScrollableArea(s).
    158     WEBCORE_EXPORT bool scrollRectToVisible(const LayoutRect&, const ScrollAlignment& alignX = ScrollAlignment::alignCenterIfNeeded, const ScrollAlignment& alignY = ScrollAlignment::alignCenterIfNeeded);
     158    WEBCORE_EXPORT bool scrollRectToVisible(SelectionRevealMode, const LayoutRect&, const ScrollAlignment& alignX = ScrollAlignment::alignCenterIfNeeded, const ScrollAlignment& alignY = ScrollAlignment::alignCenterIfNeeded);
    159159
    160160    // Convenience function for getting to the nearest enclosing box of a RenderObject.
  • trunk/Source/WebKit/mac/ChangeLog

    r202279 r202292  
     12016-06-20  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 Tim Horton.
     8       
     9        Pass SelectionRevealMode::Reveal in existing code.
     10
     11        * WebView/WebFrame.mm:
     12        (-[WebFrame _scrollDOMRangeToVisible:]):
     13        (-[WebFrame _scrollDOMRangeToVisible:withInset:]):
     14        (-[WebFrame revealSelectionAtExtent:]):
     15        * WebView/WebHTMLView.mm:
     16        (-[WebHTMLView jumpToSelection:]):
     17        (-[WebHTMLView centerSelectionInVisibleArea:]):
     18
    1192016-06-21  Amir Alavi  <aalavi@apple.com>
    220
  • trunk/Source/WebKit/mac/WebView/WebFrame.mm

    r202263 r202292  
    718718    if (startNode && startNode->renderer()) {
    719719#if !PLATFORM(IOS)
    720         startNode->renderer()->scrollRectToVisible(enclosingIntRect(rangeRect), ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
     720        startNode->renderer()->scrollRectToVisible(SelectionRevealMode::Reveal, enclosingIntRect(rangeRect), ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
    721721#else
    722722        RenderLayer* layer = startNode->renderer()->enclosingLayer();
    723723        if (layer) {
    724724            layer->setAdjustForIOSCaretWhenScrolling(true);
    725             startNode->renderer()->scrollRectToVisible(enclosingIntRect(rangeRect), ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
     725            startNode->renderer()->scrollRectToVisible(SelectionRevealMode::Reveal, enclosingIntRect(rangeRect), ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
    726726            layer->setAdjustForIOSCaretWhenScrolling(false);
    727727            _private->coreFrame->selection().setCaretRectNeedsUpdate();
     
    742742        if (layer) {
    743743            layer->setAdjustForIOSCaretWhenScrolling(true);
    744             startNode->renderer()->scrollRectToVisible(enclosingIntRect(rangeRect), ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
     744            startNode->renderer()->scrollRectToVisible(SelectionRevealMode::Reveal, enclosingIntRect(rangeRect), ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
    745745            layer->setAdjustForIOSCaretWhenScrolling(false);
    746746
     
    13761376    WebCore::Frame *frame = core(self);
    13771377    RevealExtentOption revealExtentOption = revealExtent ? RevealExtent : DoNotRevealExtent;
    1378     frame->selection().revealSelection(ScrollAlignment::alignToEdgeIfNeeded, revealExtentOption);
     1378    frame->selection().revealSelection(SelectionRevealMode::Reveal, ScrollAlignment::alignToEdgeIfNeeded, revealExtentOption);
    13791379}
    13801380
  • trunk/Source/WebKit/mac/WebView/WebHTMLView.mm

    r202263 r202292  
    31473147
    31483148    if (Frame* coreFrame = core([self _frame]))
    3149         coreFrame->selection().revealSelection(ScrollAlignment::alignCenterAlways);
     3149        coreFrame->selection().revealSelection(SelectionRevealMode::Reveal, ScrollAlignment::alignCenterAlways);
    31503150}
    31513151
     
    53465346
    53475347    if (Frame* coreFrame = core([self _frame]))
    5348         coreFrame->selection().revealSelection(ScrollAlignment::alignCenterAlways);
     5348        coreFrame->selection().revealSelection(SelectionRevealMode::Reveal, ScrollAlignment::alignCenterAlways);
    53495349}
    53505350
  • trunk/Source/WebKit/win/WebView.cpp

    r202163 r202292  
    39733973        return E_UNEXPECTED;
    39743974
    3975     coreFrame->selection().revealSelection(ScrollAlignment::alignCenterAlways);
     3975    coreFrame->selection().revealSelection(SelectionRevealMode::Reveal, ScrollAlignment::alignCenterAlways);
    39763976    return S_OK;
    39773977}
  • trunk/Source/WebKit2/ChangeLog

    r202291 r202292  
     12016-06-20  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 Tim Horton.
     8
     9        Pass SelectionRevealMode::Reveal in existing code.
     10
     11        * WebProcess/WebPage/WebPage.cpp:
     12        (WebKit::WebPage::centerSelectionInVisibleArea):
     13
    1142016-06-21  Said Abou-Hallawa  <sabouhallawa@apple,com>
    215
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r202263 r202292  
    23972397{
    23982398    Frame& frame = m_page->focusController().focusedOrMainFrame();
    2399     frame.selection().revealSelection(ScrollAlignment::alignCenterAlways);
     2399    frame.selection().revealSelection(SelectionRevealMode::Reveal, ScrollAlignment::alignCenterAlways);
    24002400    m_findController.showFindIndicatorInSelection();
    24012401}
Note: See TracChangeset for help on using the changeset viewer.