<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[202243] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/202243">202243</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2016-06-20 14:22:54 -0700 (Mon, 20 Jun 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>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.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomDocumenth">trunk/Source/WebCore/dom/Document.h</a></li>
<li><a href="#trunkSourceWebCoredomElementcpp">trunk/Source/WebCore/dom/Element.cpp</a></li>
<li><a href="#trunkSourceWebCoredomElementh">trunk/Source/WebCore/dom/Element.h</a></li>
<li><a href="#trunkSourceWebCoreeditingEditorcpp">trunk/Source/WebCore/editing/Editor.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingFrameSelectioncpp">trunk/Source/WebCore/editing/FrameSelection.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingFrameSelectionh">trunk/Source/WebCore/editing/FrameSelection.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLInputElementcpp">trunk/Source/WebCore/html/HTMLInputElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLTextAreaElementcpp">trunk/Source/WebCore/html/HTMLTextAreaElement.cpp</a></li>
<li><a href="#trunkSourceWebCorepageContextMenuControllercpp">trunk/Source/WebCore/page/ContextMenuController.cpp</a></li>
<li><a href="#trunkSourceWebCorepageFrameViewcpp">trunk/Source/WebCore/page/FrameView.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayercpp">trunk/Source/WebCore/rendering/RenderLayer.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerh">trunk/Source/WebCore/rendering/RenderLayer.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderObjectcpp">trunk/Source/WebCore/rendering/RenderObject.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderObjecth">trunk/Source/WebCore/rendering/RenderObject.h</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebFramemm">trunk/Source/WebKit/mac/WebView/WebFrame.mm</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebHTMLViewmm">trunk/Source/WebKit/mac/WebView/WebHTMLView.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastformsiosfocusinputiniframeexpectedtxt">trunk/LayoutTests/fast/forms/ios/focus-input-in-iframe-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastformsiosfocusinputiniframehtml">trunk/LayoutTests/fast/forms/ios/focus-input-in-iframe.html</a></li>
<li><a href="#trunkLayoutTestsfastformsiosprogrammaticfocusinputiniframeexpectedtxt">trunk/LayoutTests/fast/forms/ios/programmatic-focus-input-in-iframe-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastformsiosprogrammaticfocusinputiniframehtml">trunk/LayoutTests/fast/forms/ios/programmatic-focus-input-in-iframe.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (202242 => 202243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-06-20 20:52:45 UTC (rev 202242)
+++ trunk/LayoutTests/ChangeLog        2016-06-20 21:22:54 UTC (rev 202243)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2016-06-20  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        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.
+
+        * 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.
+
</ins><span class="cx"> 2016-06-20  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r202179.
</span></span></pre></div>
<a id="trunkLayoutTestsfastformsiosfocusinputiniframeexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/ios/focus-input-in-iframe-expected.txt (0 => 202243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/ios/focus-input-in-iframe-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/focus-input-in-iframe-expected.txt        2016-06-20 21:22:54 UTC (rev 202243)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+Tests zooming into a text input on tap.
+
+Click to focus input
+
+tap location        { x: 20.000, y: 62.000 }
+scale        1.455
+visibleRect        { left: 0.000, top: 1201.976, width: 219.979, height: 329.968 }
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsiosfocusinputiniframehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/ios/focus-input-in-iframe.html (0 => 202243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/ios/focus-input-in-iframe.html                                (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/focus-input-in-iframe.html        2016-06-20 21:22:54 UTC (rev 202243)
</span><span class="lines">@@ -0,0 +1,48 @@
</span><ins>+&lt;!DOCTYPE html&gt; &lt;!-- webkit-test-runner [ useFlexibleViewport=true ] --&gt;
+
+&lt;html&gt;
+&lt;head&gt;
+    &lt;meta name=&quot;viewport&quot; content=&quot;initial-scale=0.5&quot;&gt;
+    &lt;style&gt;
+        button {
+            display: block;
+        }
+        iframe {
+            margin-top: 800px;
+        }
+    &lt;/style&gt;
+    
+    &lt;script src=&quot;resources/zooming-test-utils.js&quot;&gt;&lt;/script&gt;
+    &lt;script&gt;
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+    }
+
+    if (window.internals)
+        internals.settings.setFrameFlatteningEnabled(true);
+    
+    function buttonClicked()
+    {
+        document.getElementById('frame').contentDocument.getElementById('input').focus();
+    }
+
+    function doTest()
+    {
+        testZoomAfterTap(document.getElementById('target'), 10, 10);
+    }
+
+    window.addEventListener('load', doTest, false);
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+
+&lt;p&gt;Tests zooming into a text input on tap.&lt;/p&gt;
+&lt;button id=&quot;target&quot; onclick=&quot;buttonClicked()&quot;&gt;Click to focus input&lt;/button&gt;
+
+&lt;iframe id=&quot;frame&quot; srcdoc=&quot;&lt;style&gt;input { margin: 400px 20px; }&lt;/style&gt;
+&lt;input id='input' type='text'&gt;
+&quot;&gt;&lt;/iframe&gt;
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsiosprogrammaticfocusinputiniframeexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/ios/programmatic-focus-input-in-iframe-expected.txt (0 => 202243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/ios/programmatic-focus-input-in-iframe-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/programmatic-focus-input-in-iframe-expected.txt        2016-06-20 21:22:54 UTC (rev 202243)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+Tests that a programmatic focus should not scroll into view
+
+PASS: page did not scroll.
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsiosprogrammaticfocusinputiniframehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/ios/programmatic-focus-input-in-iframe.html (0 => 202243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/ios/programmatic-focus-input-in-iframe.html                                (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/programmatic-focus-input-in-iframe.html        2016-06-20 21:22:54 UTC (rev 202243)
</span><span class="lines">@@ -0,0 +1,57 @@
</span><ins>+&lt;!DOCTYPE html&gt; &lt;!-- webkit-test-runner [ useFlexibleViewport=true ] --&gt;
+
+&lt;html&gt;
+&lt;head&gt;
+    &lt;meta name=&quot;viewport&quot; content=&quot;initial-scale=0.5&quot;&gt;
+    &lt;style&gt;
+        button {
+            display: block;
+        }
+        iframe {
+            margin-top: 800px;
+        }
+    &lt;/style&gt;
+    
+    &lt;script&gt;
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+    }
+    
+    if (window.internals)
+        internals.settings.setFrameFlatteningEnabled(true);
+    
+    function pageDidScroll()
+    {
+        document.getElementById('result').textContent = 'FAIL: page scrolled to ' + document.scrollingElement.scrollTop;
+    }
+
+    function doTest()
+    {
+        window.setTimeout(function() {
+            document.getElementById('frame').contentDocument.getElementById('input').focus();
+        }, 0);
+
+        // Wait for any scroll to happen.
+        window.setTimeout(function() {
+            if (window.testRunner)
+                testRunner.notifyDone();
+        }, 100);
+    }
+
+    window.addEventListener('load', doTest, false);
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body onscroll=&quot;pageDidScroll()&quot;&gt;
+
+&lt;p&gt;Tests that a programmatic focus should not scroll into view&lt;/p&gt;
+&lt;div id=&quot;result&quot;&gt;
+    PASS: page did not scroll.
+&lt;/div&gt;
+
+&lt;iframe id=&quot;frame&quot; srcdoc=&quot;&lt;style&gt;input { margin: 400px 20px; }&lt;/style&gt;
+&lt;input id='input' type='text'&gt;
+&quot;&gt;&lt;/iframe&gt;
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (202242 => 202243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-06-20 20:52:45 UTC (rev 202242)
+++ trunk/Source/WebCore/ChangeLog        2016-06-20 21:22:54 UTC (rev 202243)
</span><span class="lines">@@ -1,3 +1,57 @@
</span><ins>+2016-06-20  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        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.
+
+        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:
+
</ins><span class="cx"> 2016-06-20  Keith Rollin  &lt;krollin@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove RefPtr::release() and change calls sites to use WTFMove()
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.h (202242 => 202243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.h        2016-06-20 20:52:45 UTC (rev 202242)
+++ trunk/Source/WebCore/dom/Document.h        2016-06-20 21:22:54 UTC (rev 202243)
</span><span class="lines">@@ -282,11 +282,6 @@
</span><span class="cx">     SetDefault,
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-enum class SelectionRevealMode {
-    Reveal,
-    DoNotReveal
-};
-
</del><span class="cx"> enum class HttpEquivPolicy {
</span><span class="cx">     Enabled,
</span><span class="cx">     DisabledBySettings,
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Element.cpp (202242 => 202243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Element.cpp        2016-06-20 20:52:45 UTC (rev 202242)
+++ trunk/Source/WebCore/dom/Element.cpp        2016-06-20 21:22:54 UTC (rev 202243)
</span><span class="lines">@@ -639,9 +639,9 @@
</span><span class="cx">     LayoutRect bounds = renderer()-&gt;anchorRect();
</span><span class="cx">     // Align to the top / bottom and to the closest edge.
</span><span class="cx">     if (alignToTop)
</span><del>-        renderer()-&gt;scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways);
</del><ins>+        renderer()-&gt;scrollRectToVisible(SelectionRevealMode::Reveal, bounds, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways);
</ins><span class="cx">     else
</span><del>-        renderer()-&gt;scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignBottomAlways);
</del><ins>+        renderer()-&gt;scrollRectToVisible(SelectionRevealMode::Reveal, bounds, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignBottomAlways);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Element::scrollIntoViewIfNeeded(bool centerIfNeeded)
</span><span class="lines">@@ -653,9 +653,9 @@
</span><span class="cx"> 
</span><span class="cx">     LayoutRect bounds = renderer()-&gt;anchorRect();
</span><span class="cx">     if (centerIfNeeded)
</span><del>-        renderer()-&gt;scrollRectToVisible(bounds, ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded);
</del><ins>+        renderer()-&gt;scrollRectToVisible(SelectionRevealMode::Reveal, bounds, ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded);
</ins><span class="cx">     else
</span><del>-        renderer()-&gt;scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
</del><ins>+        renderer()-&gt;scrollRectToVisible(SelectionRevealMode::Reveal, bounds, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Element::scrollIntoViewIfNotVisible(bool centerIfNotVisible)
</span><span class="lines">@@ -667,9 +667,9 @@
</span><span class="cx">     
</span><span class="cx">     LayoutRect bounds = renderer()-&gt;anchorRect();
</span><span class="cx">     if (centerIfNotVisible)
</span><del>-        renderer()-&gt;scrollRectToVisible(bounds, ScrollAlignment::alignCenterIfNotVisible, ScrollAlignment::alignCenterIfNotVisible);
</del><ins>+        renderer()-&gt;scrollRectToVisible(SelectionRevealMode::Reveal, bounds, ScrollAlignment::alignCenterIfNotVisible, ScrollAlignment::alignCenterIfNotVisible);
</ins><span class="cx">     else
</span><del>-        renderer()-&gt;scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNotVisible, ScrollAlignment::alignToEdgeIfNotVisible);
</del><ins>+        renderer()-&gt;scrollRectToVisible(SelectionRevealMode::Reveal, bounds, ScrollAlignment::alignToEdgeIfNotVisible, ScrollAlignment::alignToEdgeIfNotVisible);
</ins><span class="cx"> }
</span><span class="cx">     
</span><span class="cx"> void Element::scrollByUnits(int units, ScrollGranularity granularity)
</span><span class="lines">@@ -2245,20 +2245,18 @@
</span><span class="cx">     }
</span><span class="cx">         
</span><span class="cx">     cancelFocusAppearanceUpdate();
</span><ins>+
+    SelectionRevealMode revealMode = SelectionRevealMode::Reveal;
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     // Focusing a form element triggers animation in UIKit to scroll to the right position.
</span><span class="cx">     // Calling updateFocusAppearance() would generate an unnecessary call to ScrollView::setScrollPosition(),
</span><span class="cx">     // which would jump us around during this animation. See &lt;rdar://problem/6699741&gt;.
</span><del>-    FrameView* view = document().view();
-    bool isFormControl = view &amp;&amp; is&lt;HTMLFormControlElement&gt;(*this);
</del><ins>+    bool isFormControl = is&lt;HTMLFormControlElement&gt;(*this);
</ins><span class="cx">     if (isFormControl)
</span><del>-        view-&gt;setProhibitsScrolling(true);
</del><ins>+        revealMode = SelectionRevealMode::RevealUpToMainFrame;
</ins><span class="cx"> #endif
</span><del>-    updateFocusAppearance(restorePreviousSelection ? SelectionRestorationMode::Restore : SelectionRestorationMode::SetDefault);
-#if PLATFORM(IOS)
-    if (isFormControl)
-        view-&gt;setProhibitsScrolling(false);
-#endif
</del><ins>+
+    updateFocusAppearance(restorePreviousSelection ? SelectionRestorationMode::Restore : SelectionRestorationMode::SetDefault, revealMode);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Element::updateFocusAppearanceAfterAttachIfNeeded()
</span><span class="lines">@@ -2290,11 +2288,10 @@
</span><span class="cx">         
</span><span class="cx">         if (frame-&gt;selection().shouldChangeSelection(newSelection)) {
</span><span class="cx">             frame-&gt;selection().setSelection(newSelection, FrameSelection::defaultSetSelectionOptions(), Element::defaultFocusTextStateChangeIntent());
</span><del>-            if (revealMode == SelectionRevealMode::Reveal)
-                frame-&gt;selection().revealSelection();
</del><ins>+            frame-&gt;selection().revealSelection(revealMode);
</ins><span class="cx">         }
</span><del>-    } else if (renderer() &amp;&amp; !renderer()-&gt;isWidget() &amp;&amp; revealMode == SelectionRevealMode::Reveal)
-        renderer()-&gt;scrollRectToVisible(renderer()-&gt;anchorRect());
</del><ins>+    } else if (renderer() &amp;&amp; !renderer()-&gt;isWidget())
+        renderer()-&gt;scrollRectToVisible(revealMode, renderer()-&gt;anchorRect());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Element::blur()
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Element.h (202242 => 202243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Element.h        2016-06-20 20:52:45 UTC (rev 202242)
+++ trunk/Source/WebCore/dom/Element.h        2016-06-20 21:22:54 UTC (rev 202243)
</span><span class="lines">@@ -60,6 +60,12 @@
</span><span class="cx">     SpellcheckAttributeDefault
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+enum class SelectionRevealMode {
+    Reveal,
+    RevealUpToMainFrame, // Scroll overflow and iframes, but not the main frame.
+    DoNotReveal
+};
+
</ins><span class="cx"> class Element : public ContainerNode {
</span><span class="cx"> public:
</span><span class="cx">     static Ref&lt;Element&gt; create(const QualifiedName&amp;, Document&amp;);
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingEditorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/Editor.cpp (202242 => 202243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/Editor.cpp        2016-06-20 20:52:45 UTC (rev 202242)
+++ trunk/Source/WebCore/editing/Editor.cpp        2016-06-20 21:22:54 UTC (rev 202243)
</span><span class="lines">@@ -1204,7 +1204,7 @@
</span><span class="cx">             // Reveal the current selection
</span><span class="cx">             if (Frame* editedFrame = document-&gt;frame())
</span><span class="cx">                 if (Page* page = editedFrame-&gt;page())
</span><del>-                    page-&gt;focusController().focusedOrMainFrame().selection().revealSelection(ScrollAlignment::alignCenterIfNeeded);
</del><ins>+                    page-&gt;focusController().focusedOrMainFrame().selection().revealSelection(SelectionRevealMode::Reveal, ScrollAlignment::alignCenterIfNeeded);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -2799,7 +2799,7 @@
</span><span class="cx">     if (m_ignoreCompositionSelectionChange)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    m_frame.selection().revealSelection(alignment, revealExtentOption);
</del><ins>+    m_frame.selection().revealSelection(SelectionRevealMode::Reveal, alignment, revealExtentOption);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Editor::setIgnoreCompositionSelectionChange(bool ignore, RevealSelection shouldRevealExistingSelection)
</span><span class="lines">@@ -3147,7 +3147,7 @@
</span><span class="cx">     if (!nextMatch)
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    nextMatch-&gt;firstNode()-&gt;renderer()-&gt;scrollRectToVisible(nextMatch-&gt;absoluteBoundingBox(),
</del><ins>+    nextMatch-&gt;firstNode()-&gt;renderer()-&gt;scrollRectToVisible(SelectionRevealMode::Reveal, nextMatch-&gt;absoluteBoundingBox(),
</ins><span class="cx">         ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded);
</span><span class="cx"> 
</span><span class="cx">     return nextMatch;
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingFrameSelectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (202242 => 202243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/FrameSelection.cpp        2016-06-20 20:52:45 UTC (rev 202242)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp        2016-06-20 21:22:54 UTC (rev 202243)
</span><span class="lines">@@ -127,7 +127,6 @@
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     , m_updateAppearanceEnabled(false)
</span><span class="cx">     , m_caretBlinks(true)
</span><del>-    , m_scrollingSuppressCount(0)
</del><span class="cx"> #endif
</span><span class="cx"> {
</span><span class="cx">     if (shouldAlwaysUseDirectionalSelection(m_frame))
</span><span class="lines">@@ -388,7 +387,7 @@
</span><span class="cx">         else
</span><span class="cx">             alignment = m_alwaysAlignCursorOnScrollWhenRevealingSelection ? ScrollAlignment::alignTopAlways : ScrollAlignment::alignToEdgeIfNeeded;
</span><span class="cx"> 
</span><del>-        revealSelection(alignment, RevealExtent);
</del><ins>+        revealSelection(SelectionRevealMode::Reveal, alignment, RevealExtent);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     notifyAccessibilityForSelectionChange(intent);
</span><span class="lines">@@ -2290,8 +2289,11 @@
</span><span class="cx">     return scanForForm(start);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void FrameSelection::revealSelection(const ScrollAlignment&amp; alignment, RevealExtentOption revealExtentOption)
</del><ins>+void FrameSelection::revealSelection(SelectionRevealMode revealMode, const ScrollAlignment&amp; alignment, RevealExtentOption revealExtentOption)
</ins><span class="cx"> {
</span><ins>+    if (revealMode == SelectionRevealMode::DoNotReveal)
+        return;
+
</ins><span class="cx">     LayoutRect rect;
</span><span class="cx"> 
</span><span class="cx">     switch (m_selection.selectionType()) {
</span><span class="lines">@@ -2312,7 +2314,7 @@
</span><span class="cx">         if (RenderLayer* layer = start.deprecatedNode()-&gt;renderer()-&gt;enclosingLayer()) {
</span><span class="cx">             if (!m_scrollingSuppressCount) {
</span><span class="cx">                 layer-&gt;setAdjustForIOSCaretWhenScrolling(true);
</span><del>-                layer-&gt;scrollRectToVisible(rect, alignment, alignment);
</del><ins>+                layer-&gt;scrollRectToVisible(revealMode, rect, alignment, alignment);
</ins><span class="cx">                 layer-&gt;setAdjustForIOSCaretWhenScrolling(false);
</span><span class="cx">                 updateAppearance();
</span><span class="cx">                 if (m_frame-&gt;page())
</span><span class="lines">@@ -2323,7 +2325,7 @@
</span><span class="cx">         // FIXME: This code only handles scrolling the startContainer's layer, but
</span><span class="cx">         // the selection rect could intersect more than just that.
</span><span class="cx">         // See &lt;rdar://problem/4799899&gt;.
</span><del>-        if (start.deprecatedNode()-&gt;renderer()-&gt;scrollRectToVisible(rect, alignment, alignment))
</del><ins>+        if (start.deprecatedNode()-&gt;renderer()-&gt;scrollRectToVisible(revealMode, rect, alignment, alignment))
</ins><span class="cx">             updateAppearance();
</span><span class="cx"> #endif
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingFrameSelectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/FrameSelection.h (202242 => 202243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/FrameSelection.h        2016-06-20 20:52:45 UTC (rev 202242)
+++ trunk/Source/WebCore/editing/FrameSelection.h        2016-06-20 21:22:54 UTC (rev 202243)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;AXTextStateChangeIntent.h&quot;
</span><span class="cx"> #include &quot;EditingStyle.h&quot;
</span><ins>+#include &quot;Element.h&quot;
</ins><span class="cx"> #include &quot;IntRect.h&quot;
</span><span class="cx"> #include &quot;LayoutRect.h&quot;
</span><span class="cx"> #include &quot;Range.h&quot;
</span><span class="lines">@@ -266,7 +267,7 @@
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT HTMLFormElement* currentForm() const;
</span><span class="cx"> 
</span><del>-    WEBCORE_EXPORT void revealSelection(const ScrollAlignment&amp; = ScrollAlignment::alignCenterIfNeeded, RevealExtentOption = DoNotRevealExtent);
</del><ins>+    WEBCORE_EXPORT void revealSelection(SelectionRevealMode = SelectionRevealMode::Reveal, const ScrollAlignment&amp; = ScrollAlignment::alignCenterIfNeeded, RevealExtentOption = DoNotRevealExtent);
</ins><span class="cx">     WEBCORE_EXPORT void setSelectionFromNone();
</span><span class="cx"> 
</span><span class="cx">     bool shouldShowBlockCursor() const { return m_shouldShowBlockCursor; }
</span><span class="lines">@@ -350,7 +351,7 @@
</span><span class="cx">     bool m_updateAppearanceEnabled : 1;
</span><span class="cx">     bool m_caretBlinks : 1;
</span><span class="cx">     Color m_caretColor;
</span><del>-    int m_scrollingSuppressCount;
</del><ins>+    int m_scrollingSuppressCount { 0 };
</ins><span class="cx"> #endif
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLInputElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (202242 => 202243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLInputElement.cpp        2016-06-20 20:52:45 UTC (rev 202242)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp        2016-06-20 21:22:54 UTC (rev 202243)
</span><span class="lines">@@ -404,8 +404,8 @@
</span><span class="cx">             select(Element::defaultFocusTextStateChangeIntent());
</span><span class="cx">         else
</span><span class="cx">             restoreCachedSelection();
</span><del>-        if (document().frame() &amp;&amp; revealMode == SelectionRevealMode::Reveal)
-            document().frame()-&gt;selection().revealSelection();
</del><ins>+        if (document().frame())
+            document().frame()-&gt;selection().revealSelection(revealMode);
</ins><span class="cx">     } else
</span><span class="cx">         HTMLTextFormControlElement::updateFocusAppearance(restorationMode, revealMode);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLTextAreaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.cpp (202242 => 202243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLTextAreaElement.cpp        2016-06-20 20:52:45 UTC (rev 202242)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.cpp        2016-06-20 21:22:54 UTC (rev 202243)
</span><span class="lines">@@ -260,8 +260,8 @@
</span><span class="cx">     } else
</span><span class="cx">         restoreCachedSelection(Element::defaultFocusTextStateChangeIntent());
</span><span class="cx"> 
</span><del>-    if (document().frame() &amp;&amp; revealMode == SelectionRevealMode::Reveal)
-        document().frame()-&gt;selection().revealSelection();
</del><ins>+    if (document().frame())
+        document().frame()-&gt;selection().revealSelection(revealMode);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLTextAreaElement::defaultEventHandler(Event* event)
</span></span></pre></div>
<a id="trunkSourceWebCorepageContextMenuControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/ContextMenuController.cpp (202242 => 202243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ContextMenuController.cpp        2016-06-20 20:52:45 UTC (rev 202242)
+++ trunk/Source/WebCore/page/ContextMenuController.cpp        2016-06-20 21:22:54 UTC (rev 202243)
</span><span class="lines">@@ -372,7 +372,7 @@
</span><span class="cx">             ASSERT(document);
</span><span class="cx">             RefPtr&lt;ReplaceSelectionCommand&gt; command = ReplaceSelectionCommand::create(*document, createFragmentFromMarkup(*document, title, &quot;&quot;), replaceOptions);
</span><span class="cx">             applyCommand(command);
</span><del>-            frame-&gt;selection().revealSelection(ScrollAlignment::alignToEdgeIfNeeded);
</del><ins>+            frame-&gt;selection().revealSelection(SelectionRevealMode::Reveal, ScrollAlignment::alignToEdgeIfNeeded);
</ins><span class="cx">         }
</span><span class="cx">         break;
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCorepageFrameViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/FrameView.cpp (202242 => 202243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/FrameView.cpp        2016-06-20 20:52:45 UTC (rev 202242)
+++ trunk/Source/WebCore/page/FrameView.cpp        2016-06-20 21:22:54 UTC (rev 202243)
</span><span class="lines">@@ -3050,11 +3050,11 @@
</span><span class="cx">     // Scroll nested layers and frames to reveal the anchor.
</span><span class="cx">     // Align to the top and to the closest side (this matches other browsers).
</span><span class="cx">     if (anchorNode-&gt;renderer()-&gt;style().isHorizontalWritingMode())
</span><del>-        anchorNode-&gt;renderer()-&gt;scrollRectToVisible(rect, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways);
</del><ins>+        anchorNode-&gt;renderer()-&gt;scrollRectToVisible(SelectionRevealMode::Reveal, rect, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways);
</ins><span class="cx">     else if (anchorNode-&gt;renderer()-&gt;style().isFlippedBlocksWritingMode())
</span><del>-        anchorNode-&gt;renderer()-&gt;scrollRectToVisible(rect, ScrollAlignment::alignRightAlways, ScrollAlignment::alignToEdgeIfNeeded);
</del><ins>+        anchorNode-&gt;renderer()-&gt;scrollRectToVisible(SelectionRevealMode::Reveal, rect, ScrollAlignment::alignRightAlways, ScrollAlignment::alignToEdgeIfNeeded);
</ins><span class="cx">     else
</span><del>-        anchorNode-&gt;renderer()-&gt;scrollRectToVisible(rect, ScrollAlignment::alignLeftAlways, ScrollAlignment::alignToEdgeIfNeeded);
</del><ins>+        anchorNode-&gt;renderer()-&gt;scrollRectToVisible(SelectionRevealMode::Reveal, rect, ScrollAlignment::alignLeftAlways, ScrollAlignment::alignToEdgeIfNeeded);
</ins><span class="cx"> 
</span><span class="cx">     if (AXObjectCache* cache = frame().document()-&gt;existingAXObjectCache())
</span><span class="cx">         cache-&gt;handleScrolledToAnchor(anchorNode.get());
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (202242 => 202243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayer.cpp        2016-06-20 20:52:45 UTC (rev 202242)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp        2016-06-20 21:22:54 UTC (rev 202243)
</span><span class="lines">@@ -80,6 +80,7 @@
</span><span class="cx"> #include &quot;HitTestRequest.h&quot;
</span><span class="cx"> #include &quot;HitTestResult.h&quot;
</span><span class="cx"> #include &quot;Logging.h&quot;
</span><ins>+#include &quot;MainFrame.h&quot;
</ins><span class="cx"> #include &quot;NoEventDispatchAssertion.h&quot;
</span><span class="cx"> #include &quot;OverflowEvent.h&quot;
</span><span class="cx"> #include &quot;OverlapTestRequestClient.h&quot;
</span><span class="lines">@@ -2490,7 +2491,7 @@
</span><span class="cx">     return box-&gt;hasHorizontalOverflow() || box-&gt;hasVerticalOverflow();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RenderLayer::scrollRectToVisible(const LayoutRect&amp; rect, const ScrollAlignment&amp; alignX, const ScrollAlignment&amp; alignY)
</del><ins>+void RenderLayer::scrollRectToVisible(SelectionRevealMode revealMode, const LayoutRect&amp; rect, const ScrollAlignment&amp; alignX, const ScrollAlignment&amp; alignY)
</ins><span class="cx"> {
</span><span class="cx">     LOG_WITH_STREAM(Scrolling, stream &lt;&lt; &quot;Layer &quot; &lt;&lt; this &lt;&lt; &quot; scrollRectToVisible &quot; &lt;&lt; rect);
</span><span class="cx"> 
</span><span class="lines">@@ -2550,6 +2551,9 @@
</span><span class="cx">                     parentLayer = nullptr;
</span><span class="cx">             }
</span><span class="cx">         } else {
</span><ins>+            if (revealMode == SelectionRevealMode::RevealUpToMainFrame &amp;&amp; frameView.frame().isMainFrame())
+                return;
+
</ins><span class="cx"> #if !PLATFORM(IOS)
</span><span class="cx">             LayoutRect viewRect = frameView.visibleContentRect();
</span><span class="cx">             LayoutRect visibleRectRelativeToDocument = viewRect;
</span><span class="lines">@@ -2574,7 +2578,7 @@
</span><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     if (parentLayer)
</span><del>-        parentLayer-&gt;scrollRectToVisible(newRect, alignX, alignY);
</del><ins>+        parentLayer-&gt;scrollRectToVisible(revealMode, newRect, alignX, alignY);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RenderLayer::updateCompositingLayersAfterScroll()
</span><span class="lines">@@ -2667,7 +2671,7 @@
</span><span class="cx"> void RenderLayer::autoscroll(const IntPoint&amp; position)
</span><span class="cx"> {
</span><span class="cx">     IntPoint currentDocumentPosition = renderer().view().frameView().windowToContents(position);
</span><del>-    scrollRectToVisible(LayoutRect(currentDocumentPosition, LayoutSize(1, 1)), ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
</del><ins>+    scrollRectToVisible(SelectionRevealMode::Reveal, LayoutRect(currentDocumentPosition, LayoutSize(1, 1)), ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool RenderLayer::canResize() const
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayer.h (202242 => 202243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayer.h        2016-06-20 20:52:45 UTC (rev 202242)
+++ trunk/Source/WebCore/rendering/RenderLayer.h        2016-06-20 21:22:54 UTC (rev 202243)
</span><span class="lines">@@ -205,7 +205,7 @@
</span><span class="cx"> 
</span><span class="cx">     void availableContentSizeChanged(AvailableSizeChangeReason) override;
</span><span class="cx"> 
</span><del>-    void scrollRectToVisible(const LayoutRect&amp;, const ScrollAlignment&amp; alignX, const ScrollAlignment&amp; alignY);
</del><ins>+    void scrollRectToVisible(SelectionRevealMode, const LayoutRect&amp;, const ScrollAlignment&amp; alignX, const ScrollAlignment&amp; alignY);
</ins><span class="cx"> 
</span><span class="cx">     LayoutRect getRectToExpose(const LayoutRect&amp; visibleRect, const LayoutRect&amp; visibleRectRelativeToDocument, const LayoutRect&amp; exposeRect, const ScrollAlignment&amp; alignX, const ScrollAlignment&amp; alignY);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (202242 => 202243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderObject.cpp        2016-06-20 20:52:45 UTC (rev 202242)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp        2016-06-20 21:22:54 UTC (rev 202243)
</span><span class="lines">@@ -358,13 +358,16 @@
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool RenderObject::scrollRectToVisible(const LayoutRect&amp; rect, const ScrollAlignment&amp; alignX, const ScrollAlignment&amp; alignY)
</del><ins>+bool RenderObject::scrollRectToVisible(SelectionRevealMode revealMode, const LayoutRect&amp; rect, const ScrollAlignment&amp; alignX, const ScrollAlignment&amp; alignY)
</ins><span class="cx"> {
</span><ins>+    if (revealMode == SelectionRevealMode::DoNotReveal)
+        return false;
+
</ins><span class="cx">     RenderLayer* enclosingLayer = this-&gt;enclosingLayer();
</span><span class="cx">     if (!enclosingLayer)
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    enclosingLayer-&gt;scrollRectToVisible(rect, alignX, alignY);
</del><ins>+    enclosingLayer-&gt;scrollRectToVisible(revealMode, rect, alignX, alignY);
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderObject.h (202242 => 202243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderObject.h        2016-06-20 20:52:45 UTC (rev 202242)
+++ trunk/Source/WebCore/rendering/RenderObject.h        2016-06-20 21:22:54 UTC (rev 202243)
</span><span class="lines">@@ -155,7 +155,7 @@
</span><span class="cx">     WEBCORE_EXPORT RenderLayer* enclosingLayer() const;
</span><span class="cx"> 
</span><span class="cx">     // Scrolling is a RenderBox concept, however some code just cares about recursively scrolling our enclosing ScrollableArea(s).
</span><del>-    WEBCORE_EXPORT bool scrollRectToVisible(const LayoutRect&amp;, const ScrollAlignment&amp; alignX = ScrollAlignment::alignCenterIfNeeded, const ScrollAlignment&amp; alignY = ScrollAlignment::alignCenterIfNeeded);
</del><ins>+    WEBCORE_EXPORT bool scrollRectToVisible(SelectionRevealMode, const LayoutRect&amp;, const ScrollAlignment&amp; alignX = ScrollAlignment::alignCenterIfNeeded, const ScrollAlignment&amp; alignY = ScrollAlignment::alignCenterIfNeeded);
</ins><span class="cx"> 
</span><span class="cx">     // Convenience function for getting to the nearest enclosing box of a RenderObject.
</span><span class="cx">     RenderBox&amp; enclosingBox() const;
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (202242 => 202243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2016-06-20 20:52:45 UTC (rev 202242)
+++ trunk/Source/WebKit/mac/ChangeLog        2016-06-20 21:22:54 UTC (rev 202243)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2016-06-20  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        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.
+        
+        Pass SelectionRevealMode::Reveal in existing code.
+
+        * WebView/WebFrame.mm:
+        (-[WebFrame _scrollDOMRangeToVisible:]):
+        (-[WebFrame _scrollDOMRangeToVisible:withInset:]):
+        (-[WebFrame revealSelectionAtExtent:]):
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView jumpToSelection:]):
+        (-[WebHTMLView centerSelectionInVisibleArea:]):
+
</ins><span class="cx"> 2016-06-20  Keith Rollin  &lt;krollin@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove RefPtr::release() and change calls sites to use WTFMove()
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebFramemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebFrame.mm (202242 => 202243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebFrame.mm        2016-06-20 20:52:45 UTC (rev 202242)
+++ trunk/Source/WebKit/mac/WebView/WebFrame.mm        2016-06-20 21:22:54 UTC (rev 202243)
</span><span class="lines">@@ -717,12 +717,12 @@
</span><span class="cx">         
</span><span class="cx">     if (startNode &amp;&amp; startNode-&gt;renderer()) {
</span><span class="cx"> #if !PLATFORM(IOS)
</span><del>-        startNode-&gt;renderer()-&gt;scrollRectToVisible(enclosingIntRect(rangeRect), ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
</del><ins>+        startNode-&gt;renderer()-&gt;scrollRectToVisible(SelectionRevealMode::Reveal, enclosingIntRect(rangeRect), ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
</ins><span class="cx"> #else
</span><span class="cx">         RenderLayer* layer = startNode-&gt;renderer()-&gt;enclosingLayer();
</span><span class="cx">         if (layer) {
</span><span class="cx">             layer-&gt;setAdjustForIOSCaretWhenScrolling(true);
</span><del>-            startNode-&gt;renderer()-&gt;scrollRectToVisible(enclosingIntRect(rangeRect), ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
</del><ins>+            startNode-&gt;renderer()-&gt;scrollRectToVisible(SelectionRevealMode::Reveal, enclosingIntRect(rangeRect), ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
</ins><span class="cx">             layer-&gt;setAdjustForIOSCaretWhenScrolling(false);
</span><span class="cx">             _private-&gt;coreFrame-&gt;selection().setCaretRectNeedsUpdate();
</span><span class="cx">             _private-&gt;coreFrame-&gt;selection().updateAppearance();
</span><span class="lines">@@ -741,7 +741,7 @@
</span><span class="cx">         RenderLayer* layer = startNode-&gt;renderer()-&gt;enclosingLayer();
</span><span class="cx">         if (layer) {
</span><span class="cx">             layer-&gt;setAdjustForIOSCaretWhenScrolling(true);
</span><del>-            startNode-&gt;renderer()-&gt;scrollRectToVisible(enclosingIntRect(rangeRect), ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
</del><ins>+            startNode-&gt;renderer()-&gt;scrollRectToVisible(SelectionRevealMode::Reveal, enclosingIntRect(rangeRect), ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
</ins><span class="cx">             layer-&gt;setAdjustForIOSCaretWhenScrolling(false);
</span><span class="cx"> 
</span><span class="cx">             Frame *coreFrame = core(self);
</span><span class="lines">@@ -1375,7 +1375,7 @@
</span><span class="cx"> {
</span><span class="cx">     WebCore::Frame *frame = core(self);
</span><span class="cx">     RevealExtentOption revealExtentOption = revealExtent ? RevealExtent : DoNotRevealExtent;
</span><del>-    frame-&gt;selection().revealSelection(ScrollAlignment::alignToEdgeIfNeeded, revealExtentOption);
</del><ins>+    frame-&gt;selection().revealSelection(SelectionRevealMode::Reveal, ScrollAlignment::alignToEdgeIfNeeded, revealExtentOption);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)resetSelection
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebHTMLViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebHTMLView.mm (202242 => 202243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebHTMLView.mm        2016-06-20 20:52:45 UTC (rev 202242)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLView.mm        2016-06-20 21:22:54 UTC (rev 202243)
</span><span class="lines">@@ -3146,7 +3146,7 @@
</span><span class="cx">     COMMAND_PROLOGUE
</span><span class="cx"> 
</span><span class="cx">     if (Frame* coreFrame = core([self _frame]))
</span><del>-        coreFrame-&gt;selection().revealSelection(ScrollAlignment::alignCenterAlways);
</del><ins>+        coreFrame-&gt;selection().revealSelection(SelectionRevealMode::Reveal, ScrollAlignment::alignCenterAlways);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if !PLATFORM(IOS)
</span><span class="lines">@@ -5345,7 +5345,7 @@
</span><span class="cx">     COMMAND_PROLOGUE
</span><span class="cx"> 
</span><span class="cx">     if (Frame* coreFrame = core([self _frame]))
</span><del>-        coreFrame-&gt;selection().revealSelection(ScrollAlignment::alignCenterAlways);
</del><ins>+        coreFrame-&gt;selection().revealSelection(SelectionRevealMode::Reveal, ScrollAlignment::alignCenterAlways);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if !PLATFORM(IOS)
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (202242 => 202243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-06-20 20:52:45 UTC (rev 202242)
+++ trunk/Source/WebKit2/ChangeLog        2016-06-20 21:22:54 UTC (rev 202243)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2016-06-20  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        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.
+
+        Pass SelectionRevealMode::Reveal in existing code.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::centerSelectionInVisibleArea):
+
</ins><span class="cx"> 2016-06-20  Keith Rollin  &lt;krollin@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove RefPtr::release() and change calls sites to use WTFMove()
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (202242 => 202243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2016-06-20 20:52:45 UTC (rev 202242)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2016-06-20 21:22:54 UTC (rev 202243)
</span><span class="lines">@@ -2396,7 +2396,7 @@
</span><span class="cx"> void WebPage::centerSelectionInVisibleArea()
</span><span class="cx"> {
</span><span class="cx">     Frame&amp; frame = m_page-&gt;focusController().focusedOrMainFrame();
</span><del>-    frame.selection().revealSelection(ScrollAlignment::alignCenterAlways);
</del><ins>+    frame.selection().revealSelection(SelectionRevealMode::Reveal, ScrollAlignment::alignCenterAlways);
</ins><span class="cx">     m_findController.showFindIndicatorInSelection();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>