<!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>[166017] 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/166017">166017</a></dd>
<dt>Author</dt> <dd>bdakin@apple.com</dd>
<dt>Date</dt> <dd>2014-03-20 16:19:04 -0700 (Thu, 20 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Implement contentInset for Mac WebKit2
https://bugs.webkit.org/show_bug.cgi?id=130273

Reviewed by Simon Fraser.

Source/WebCore: 

This patch adds support for topContentInset(). If a page has a topContentInset(), 
the root layer’s position is adjusted to account for the inset. It is assumed that 
the area accounted for by the inset is visible but obscured, so scrollbars need to 
be moved so that they only cover the non-obscured area, and most parts of WebCore 
that wonder about visibleContentSize only care about the unobscured area, so this 
patch makes that visibleContentRect return the unobscuredRect. Finally since this 
is achieved by moving a layer’s position, the topContentInset() also needs to be 
factored into various functions that are used to convert between coordinate 
spaces. 

Return Page::topContentInset() if this is the main frame.
* page/FrameView.cpp:
(WebCore::FrameView::topContentInset):
* page/FrameView.h:

Cache the inset on Page.
* page/Page.cpp:
(WebCore::Page::Page):
* page/Page.h:
(WebCore::Page::topContentInset):
(WebCore::Page::setTopContentInset):

unobscuredContentRect() used to unconditionally return visibleContentRect() on 
non-iOS platforms. Now that it is possible for some technically visible content to 
be obscured, this code needed to be re-worked a bit to make some more sense. 
visibleContentRect() now represents that visible content that is completely 
unobscured, so it should call into unobscuredContentRect() rather than the other 
way around.
* platform/ScrollView.cpp:
(WebCore::ScrollView::unobscuredContentRect):

unscaledTotalVisibleContentSize() includes the size of all content that might be 
visible. Some of this content might be obscured.
(WebCore::ScrollView::unscaledTotalVisibleContentSize):

Most of the time, we only care about the content that is FULLY visible. That is 
what you get from unscaledUnobscuredVisibleContentSize().
(WebCore::ScrollView::unscaledUnobscuredVisibleContentSize):

Use the unobscured size for these computations.
(WebCore::ScrollView::visibleContentRectInternal):
(WebCore::ScrollView::layoutSize):

Factor in the topContentInset().
(WebCore::ScrollView::scrollOffsetRelativeToDocument):
(WebCore::ScrollView::scrollPositionRelativeToDocument):

The scrollbars should be positioned to cover the non-obscured content only. 
(WebCore::ScrollView::updateScrollbars):

Again, factor the topContentInset() into these conversions since the root layer’s 
position has been adjusted to account for it.
(WebCore::ScrollView::contentsToRootView):
(WebCore::ScrollView::contentsToWindow):

 Just like the scrollbars, the scroll corner must be moved the account for the 
inset.
(WebCore::ScrollView::scrollCornerRect):
* platform/ScrollView.h:
(WebCore::ScrollView::topContentInset):

RenderLayerCompositor cares about unscaledTotalVisibleContentSize(). It does not 
care if some of that content is obscured.
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::frameViewDidChangeSize):

Move the root layer’s position based on the contentInset.
(WebCore::RenderLayerCompositor::updateRootLayerPosition):
(WebCore::RenderLayerCompositor::ensureRootLayer):

Allow setting contentInset via Internals for testing purposes.
* testing/Internals.cpp:
(WebCore::Internals::setTopContentInset):
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit2: 

This patch adds WKView API for setting a topContentInset(). All of this work gets 
that number plumbed down to WebCore.

* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode):
(WebKit::WebPageCreationParameters::decode):
* Shared/WebPageCreationParameters.h:
* UIProcess/API/Cocoa/WKViewPrivate.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _setTopContentInset:]):
(-[WKWebView _topContentInset]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/API/mac/WKView.mm:
(-[WKView _setTopContentInset:]):
(-[WKView _topContentInset]):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::setTopContentInset):
(WebKit::WebPageProxy::creationParameters):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::topContentInset):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
(WebKit::WebPage::setTopContentInset):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

LayoutTests: 

Add two tests for hit-testing with a topContentInset.

* platform/mac-wk2/tiled-drawing/content-inset-hit-testing-expected.txt: Added.
* platform/mac-wk2/tiled-drawing/content-inset-hit-testing-in-frame-expected.txt: Added.
* platform/mac-wk2/tiled-drawing/content-inset-hit-testing-in-frame.html: Added.
* platform/mac-wk2/tiled-drawing/content-inset-hit-testing.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="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCorepageFrameViewcpp">trunk/Source/WebCore/page/FrameView.cpp</a></li>
<li><a href="#trunkSourceWebCorepageFrameViewh">trunk/Source/WebCore/page/FrameView.h</a></li>
<li><a href="#trunkSourceWebCorepagePagecpp">trunk/Source/WebCore/page/Page.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePageh">trunk/Source/WebCore/page/Page.h</a></li>
<li><a href="#trunkSourceWebCoreplatformScrollViewcpp">trunk/Source/WebCore/platform/ScrollView.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformScrollViewh">trunk/Source/WebCore/platform/ScrollView.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerCompositorcpp">trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingInternalscpp">trunk/Source/WebCore/testing/Internals.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsh">trunk/Source/WebCore/testing/Internals.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsidl">trunk/Source/WebCore/testing/Internals.idl</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedWebPageCreationParameterscpp">trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedWebPageCreationParametersh">trunk/Source/WebKit2/Shared/WebPageCreationParameters.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKViewPrivateh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewPrivateh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPImacWKViewmm">trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxyh">trunk/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPageh">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagemessagesin">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsplatformmacwk2tileddrawingcontentinsethittestingexpectedtxt">trunk/LayoutTests/platform/mac-wk2/tiled-drawing/content-inset-hit-testing-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk2tileddrawingcontentinsethittestinginframeexpectedtxt">trunk/LayoutTests/platform/mac-wk2/tiled-drawing/content-inset-hit-testing-in-frame-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk2tileddrawingcontentinsethittestinginframehtml">trunk/LayoutTests/platform/mac-wk2/tiled-drawing/content-inset-hit-testing-in-frame.html</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk2tileddrawingcontentinsethittestinghtml">trunk/LayoutTests/platform/mac-wk2/tiled-drawing/content-inset-hit-testing.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (166016 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-03-20 23:16:28 UTC (rev 166016)
+++ trunk/LayoutTests/ChangeLog        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2014-03-20  Beth Dakin  &lt;bdakin@apple.com&gt;
+
+        Implement contentInset for Mac WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=130273
+
+        Reviewed by Simon Fraser.
+
+        Add two tests for hit-testing with a topContentInset.
+
+        * platform/mac-wk2/tiled-drawing/content-inset-hit-testing-expected.txt: Added.
+        * platform/mac-wk2/tiled-drawing/content-inset-hit-testing-in-frame-expected.txt: Added.
+        * platform/mac-wk2/tiled-drawing/content-inset-hit-testing-in-frame.html: Added.
+        * platform/mac-wk2/tiled-drawing/content-inset-hit-testing.html: Added.
+
</ins><span class="cx"> 2014-03-20  Brent Fulgham  &lt;bfulgham@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add a flushing mechanism for the WebVTTParser
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk2tileddrawingcontentinsethittestingexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac-wk2/tiled-drawing/content-inset-hit-testing-expected.txt (0 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk2/tiled-drawing/content-inset-hit-testing-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/tiled-drawing/content-inset-hit-testing-expected.txt        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+Pass!
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk2tileddrawingcontentinsethittestinginframeexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac-wk2/tiled-drawing/content-inset-hit-testing-in-frame-expected.txt (0 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk2/tiled-drawing/content-inset-hit-testing-in-frame-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/tiled-drawing/content-inset-hit-testing-in-frame-expected.txt        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -0,0 +1,2 @@
</span><ins>+
+Pass!
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk2tileddrawingcontentinsethittestinginframehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac-wk2/tiled-drawing/content-inset-hit-testing-in-frame.html (0 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk2/tiled-drawing/content-inset-hit-testing-in-frame.html                                (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/tiled-drawing/content-inset-hit-testing-in-frame.html        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+    function runTest() {
+        if (!window.eventSender)
+            return;
+        if (window.internals)
+            window.internals.setTopContentInset(100);
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        eventSender.mouseMoveTo(20, 120);
+        eventSender.mouseDown();
+        eventSender.mouseUp();
+    }
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body onload=&quot;runTest()&quot;&gt;
+    &lt;iframe src=&quot;resources/iframe-to-hit-test.html&quot; scrolling=&quot;no&quot; frameborder=&quot;no&quot; height=&quot;300&quot; width=&quot;600&quot;&gt;&lt;/iframe&gt;
+    &lt;div id=&quot;result&quot;&gt;This test needs to be run through WebKitTestRunner.&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk2tileddrawingcontentinsethittestinghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac-wk2/tiled-drawing/content-inset-hit-testing.html (0 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk2/tiled-drawing/content-inset-hit-testing.html                                (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/tiled-drawing/content-inset-hit-testing.html        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -0,0 +1,41 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;style&gt;
+    #target {
+        background-color:purple;
+        width:25px;
+        height:25px;
+    }
+&lt;/style&gt;
+&lt;script&gt;
+    var numberOfClicks = 0;
+
+    function runTest() {
+        if (!window.eventSender)
+            return;
+        if (window.internals)
+            window.internals.setTopContentInset(100);
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        eventSender.mouseMoveTo(15, 115);
+        eventSender.mouseDown();
+        eventSender.mouseUp();
+
+        var result = document.getElementById(&quot;result&quot;);
+        if (numberOfClicks &gt; 0)
+            result.innerHTML = &quot;Pass!&quot;;
+        else
+            result.innerHTML = &quot;Fail.&quot;;
+    }
+    
+    function clicked() {
+        numberOfClicks = 1;
+    }
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body onload=&quot;runTest()&quot;&gt;
+    &lt;div id=&quot;target&quot; onclick=&quot;clicked()&quot;&gt;&lt;/div&gt;
+    &lt;div id=&quot;result&quot;&gt;This test needs to be run through WebKitTestRunner.&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (166016 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-03-20 23:16:28 UTC (rev 166016)
+++ trunk/Source/WebCore/ChangeLog        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -1,3 +1,86 @@
</span><ins>+2014-03-20  Beth Dakin  &lt;bdakin@apple.com&gt;
+
+        Implement contentInset for Mac WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=130273
+
+        Reviewed by Simon Fraser.
+
+        This patch adds support for topContentInset(). If a page has a topContentInset(), 
+        the root layer’s position is adjusted to account for the inset. It is assumed that 
+        the area accounted for by the inset is visible but obscured, so scrollbars need to 
+        be moved so that they only cover the non-obscured area, and most parts of WebCore 
+        that wonder about visibleContentSize only care about the unobscured area, so this 
+        patch makes that visibleContentRect return the unobscuredRect. Finally since this 
+        is achieved by moving a layer’s position, the topContentInset() also needs to be 
+        factored into various functions that are used to convert between coordinate 
+        spaces. 
+
+        Return Page::topContentInset() if this is the main frame.
+        * page/FrameView.cpp:
+        (WebCore::FrameView::topContentInset):
+        * page/FrameView.h:
+
+        Cache the inset on Page.
+        * page/Page.cpp:
+        (WebCore::Page::Page):
+        * page/Page.h:
+        (WebCore::Page::topContentInset):
+        (WebCore::Page::setTopContentInset):
+
+        unobscuredContentRect() used to unconditionally return visibleContentRect() on 
+        non-iOS platforms. Now that it is possible for some technically visible content to 
+        be obscured, this code needed to be re-worked a bit to make some more sense. 
+        visibleContentRect() now represents that visible content that is completely 
+        unobscured, so it should call into unobscuredContentRect() rather than the other 
+        way around.
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::unobscuredContentRect):
+
+        unscaledTotalVisibleContentSize() includes the size of all content that might be 
+        visible. Some of this content might be obscured.
+        (WebCore::ScrollView::unscaledTotalVisibleContentSize):
+
+        Most of the time, we only care about the content that is FULLY visible. That is 
+        what you get from unscaledUnobscuredVisibleContentSize().
+        (WebCore::ScrollView::unscaledUnobscuredVisibleContentSize):
+
+        Use the unobscured size for these computations.
+        (WebCore::ScrollView::visibleContentRectInternal):
+        (WebCore::ScrollView::layoutSize):
+
+        Factor in the topContentInset().
+        (WebCore::ScrollView::scrollOffsetRelativeToDocument):
+        (WebCore::ScrollView::scrollPositionRelativeToDocument):
+
+        The scrollbars should be positioned to cover the non-obscured content only. 
+        (WebCore::ScrollView::updateScrollbars):
+
+        Again, factor the topContentInset() into these conversions since the root layer’s 
+        position has been adjusted to account for it.
+        (WebCore::ScrollView::contentsToRootView):
+        (WebCore::ScrollView::contentsToWindow):
+
+         Just like the scrollbars, the scroll corner must be moved the account for the 
+        inset.
+        (WebCore::ScrollView::scrollCornerRect):
+        * platform/ScrollView.h:
+        (WebCore::ScrollView::topContentInset):
+
+        RenderLayerCompositor cares about unscaledTotalVisibleContentSize(). It does not 
+        care if some of that content is obscured.
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::frameViewDidChangeSize):
+
+        Move the root layer’s position based on the contentInset.
+        (WebCore::RenderLayerCompositor::updateRootLayerPosition):
+        (WebCore::RenderLayerCompositor::ensureRootLayer):
+
+        Allow setting contentInset via Internals for testing purposes.
+        * testing/Internals.cpp:
+        (WebCore::Internals::setTopContentInset):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
</ins><span class="cx"> 2014-03-20  Laszlo Vidacs  &lt;lvidacs.u-szeged@partner.samsung.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Optimize RenderTable::colToEffCol() for tables without colspans
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (166016 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-03-20 23:16:28 UTC (rev 166016)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -1039,6 +1039,7 @@
</span><span class="cx"> __ZN7WebCore4Page16setDefersLoadingEb
</span><span class="cx"> __ZN7WebCore4Page18removeSchedulePairEN3WTF10PassRefPtrINS1_12SchedulePairEEE
</span><span class="cx"> __ZN7WebCore4Page18setPageScaleFactorEfRKNS_8IntPointE
</span><ins>+__ZN7WebCore4Page18setTopContentInsetEf
</ins><span class="cx"> __ZN7WebCore4Page19addLayoutMilestonesEj
</span><span class="cx"> __ZN7WebCore4Page20scrollingCoordinatorEv
</span><span class="cx"> __ZN7WebCore4Page20setDeviceScaleFactorEf
</span></span></pre></div>
<a id="trunkSourceWebCorepageFrameViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/FrameView.cpp (166016 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/FrameView.cpp        2014-03-20 23:16:28 UTC (rev 166016)
+++ trunk/Source/WebCore/page/FrameView.cpp        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -929,6 +929,15 @@
</span><span class="cx">         renderView-&gt;setNeedsLayout();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+float FrameView::topContentInset() const
+{
+    if (!frame().isMainFrame())
+        return 0;
+    
+    Page* page = frame().page();
+    return page ? page-&gt;topContentInset() : 0;
+}
+    
</ins><span class="cx"> bool FrameView::hasCompositedContent() const
</span><span class="cx"> {
</span><span class="cx">     if (RenderView* renderView = this-&gt;renderView())
</span></span></pre></div>
<a id="trunkSourceWebCorepageFrameViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/FrameView.h (166016 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/FrameView.h        2014-03-20 23:16:28 UTC (rev 166016)
+++ trunk/Source/WebCore/page/FrameView.h        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -449,6 +449,8 @@
</span><span class="cx">     virtual int footerHeight() const override { return m_footerHeight; }
</span><span class="cx">     void setFooterHeight(int);
</span><span class="cx"> 
</span><ins>+    virtual float topContentInset() const override;
+
</ins><span class="cx">     virtual void willStartLiveResize() override;
</span><span class="cx">     virtual void willEndLiveResize() override;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorepagePagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Page.cpp (166016 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Page.cpp        2014-03-20 23:16:28 UTC (rev 166016)
+++ trunk/Source/WebCore/page/Page.cpp        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -159,6 +159,7 @@
</span><span class="cx">     , m_mediaVolume(1)
</span><span class="cx">     , m_pageScaleFactor(1)
</span><span class="cx">     , m_deviceScaleFactor(1)
</span><ins>+    , m_topContentInset(0)
</ins><span class="cx">     , m_suppressScrollbarAnimations(false)
</span><span class="cx">     , m_didLoadUserStyleSheet(false)
</span><span class="cx">     , m_userStyleSheetModificationTime(0)
</span><span class="lines">@@ -748,7 +749,17 @@
</span><span class="cx">     pageCache()-&gt;markPagesForFullStyleRecalc(this);
</span><span class="cx">     GraphicsContext::updateDocumentMarkerResources();
</span><span class="cx"> }
</span><del>-
</del><ins>+    
+void Page::setTopContentInset(float contentInset)
+{
+    if (m_topContentInset == contentInset)
+        return;
+    
+    m_topContentInset = contentInset;
+    if (RenderView* renderView = mainFrame().contentRenderer())
+        renderView-&gt;setNeedsLayout();
+}
+    
</ins><span class="cx"> void Page::setShouldSuppressScrollbarAnimations(bool suppressAnimations)
</span><span class="cx"> {
</span><span class="cx">     if (suppressAnimations == m_suppressScrollbarAnimations)
</span></span></pre></div>
<a id="trunkSourceWebCorepagePageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Page.h (166016 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Page.h        2014-03-20 23:16:28 UTC (rev 166016)
+++ trunk/Source/WebCore/page/Page.h        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -278,6 +278,9 @@
</span><span class="cx">     float deviceScaleFactor() const { return m_deviceScaleFactor; }
</span><span class="cx">     void setDeviceScaleFactor(float);
</span><span class="cx"> 
</span><ins>+    float topContentInset() const { return m_topContentInset; }
+    void setTopContentInset(float);
+
</ins><span class="cx">     bool shouldSuppressScrollbarAnimations() const { return m_suppressScrollbarAnimations; }
</span><span class="cx">     void setShouldSuppressScrollbarAnimations(bool suppressAnimations);
</span><span class="cx">     void lockAllOverlayScrollbarsToHidden(bool lockOverlayScrollbars);
</span><span class="lines">@@ -489,6 +492,8 @@
</span><span class="cx">     float m_pageScaleFactor;
</span><span class="cx">     float m_deviceScaleFactor;
</span><span class="cx"> 
</span><ins>+    float m_topContentInset;
+
</ins><span class="cx">     bool m_suppressScrollbarAnimations;
</span><span class="cx"> 
</span><span class="cx">     Pagination m_pagination;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformScrollViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ScrollView.cpp (166016 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ScrollView.cpp        2014-03-20 23:16:28 UTC (rev 166016)
+++ trunk/Source/WebCore/platform/ScrollView.cpp        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -235,9 +235,18 @@
</span><span class="cx">     m_delegatesScrolling = delegatesScrolling;
</span><span class="cx">     delegatesScrollingDidChange();
</span><span class="cx"> }
</span><del>-
-IntSize ScrollView::unscaledVisibleContentSize(VisibleContentRectIncludesScrollbars scrollbarInclusion) const
</del><ins>+    
+#if !PLATFORM(IOS)
+IntRect ScrollView::unobscuredContentRect(VisibleContentRectIncludesScrollbars scrollbarInclusion) const
</ins><span class="cx"> {
</span><ins>+    FloatSize visibleContentSize = unscaledUnobscuredVisibleContentSize(scrollbarInclusion);
+    visibleContentSize.scale(1 / visibleContentScaleFactor());
+    return IntRect(IntPoint(m_scrollOffset), expandedIntSize(visibleContentSize));
+}
+#endif
+    
+IntSize ScrollView::unscaledTotalVisibleContentSize(VisibleContentRectIncludesScrollbars scrollbarInclusion) const
+{
</ins><span class="cx">     if (platformWidget())
</span><span class="cx">         return platformVisibleContentSize(scrollbarInclusion == IncludeScrollbars);
</span><span class="cx"> 
</span><span class="lines">@@ -258,9 +267,25 @@
</span><span class="cx"> 
</span><span class="cx">     return IntSize(width() - verticalScrollbarWidth, height() - horizontalScrollbarHeight).expandedTo(IntSize());
</span><span class="cx"> }
</span><ins>+    
+IntSize ScrollView::unscaledUnobscuredVisibleContentSize(VisibleContentRectIncludesScrollbars scrollbarInclusion) const
+{
+    IntSize visibleContentSize = unscaledTotalVisibleContentSize(scrollbarInclusion);
+    
+    if (platformWidget())
+        return visibleContentSize;
</ins><span class="cx"> 
</span><ins>+#if USE(TILED_BACKING_STORE)
+    if (!m_fixedVisibleContentRect.isEmpty())
+        return visibleContentSize;
+#endif
+
+    visibleContentSize.setHeight(visibleContentSize.height() - topContentInset());
+    return visibleContentSize;
+}
+
</ins><span class="cx"> #if !PLATFORM(GTK)
</span><del>-IntRect ScrollView::visibleContentRectInternal(VisibleContentRectIncludesScrollbars scollbarInclusion, VisibleContentRectBehavior visibleContentRectBehavior) const
</del><ins>+IntRect ScrollView::visibleContentRectInternal(VisibleContentRectIncludesScrollbars scrollbarInclusion, VisibleContentRectBehavior visibleContentRectBehavior) const
</ins><span class="cx"> {
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     if (visibleContentRectBehavior == LegacyIOSDocumentViewRect) {
</span><span class="lines">@@ -275,22 +300,20 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     if (platformWidget())
</span><del>-        return platformVisibleContentRect(scollbarInclusion == IncludeScrollbars);
</del><ins>+        return platformVisibleContentRect(scrollbarInclusion == IncludeScrollbars);
</ins><span class="cx"> 
</span><span class="cx"> #if USE(TILED_BACKING_STORE)
</span><span class="cx">     if (!m_fixedVisibleContentRect.isEmpty())
</span><span class="cx">         return m_fixedVisibleContentRect;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    FloatSize visibleContentSize = unscaledVisibleContentSize(scollbarInclusion);
-    visibleContentSize.scale(1 / visibleContentScaleFactor());
-    return IntRect(IntPoint(m_scrollOffset), expandedIntSize(visibleContentSize));
</del><ins>+    return unobscuredContentRect();
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> IntSize ScrollView::layoutSize() const
</span><span class="cx"> {
</span><del>-    return m_fixedLayoutSize.isEmpty() || !m_useFixedLayout ? unscaledVisibleContentSize(ExcludeScrollbars) : m_fixedLayoutSize;
</del><ins>+    return m_fixedLayoutSize.isEmpty() || !m_useFixedLayout ? unscaledUnobscuredVisibleContentSize(ExcludeScrollbars) : m_fixedLayoutSize;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> IntSize ScrollView::fixedLayoutSize() const
</span><span class="lines">@@ -369,13 +392,13 @@
</span><span class="cx"> IntSize ScrollView::scrollOffsetRelativeToDocument() const
</span><span class="cx"> {
</span><span class="cx">     IntSize scrollOffset = this-&gt;scrollOffset();
</span><del>-    return IntSize(scrollOffset.width(), scrollOffset.height() - headerHeight());
</del><ins>+    return IntSize(scrollOffset.width(), scrollOffset.height() - headerHeight() - topContentInset());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> IntPoint ScrollView::scrollPositionRelativeToDocument() const
</span><span class="cx"> {
</span><span class="cx">     IntPoint scrollPosition = this-&gt;scrollPosition();
</span><del>-    return IntPoint(scrollPosition.x(), scrollPosition.y() - headerHeight());
</del><ins>+    return IntPoint(scrollPosition.x(), scrollPosition.y() - headerHeight() - topContentInset());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int ScrollView::scrollSize(ScrollbarOrientation orientation) const
</span><span class="lines">@@ -642,9 +665,9 @@
</span><span class="cx">         int pageStep = std::max(std::max&lt;int&gt;(clientWidth * Scrollbar::minFractionToStepWhenPaging(), clientWidth - Scrollbar::maxOverlapBetweenPages()), 1);
</span><span class="cx">         IntRect oldRect(m_horizontalScrollbar-&gt;frameRect());
</span><span class="cx">         IntRect hBarRect(0,
</span><del>-                        height() - m_horizontalScrollbar-&gt;height(),
-                        width() - (m_verticalScrollbar ? m_verticalScrollbar-&gt;width() : 0),
-                        m_horizontalScrollbar-&gt;height());
</del><ins>+            height() - m_horizontalScrollbar-&gt;height(),
+            width() - (m_verticalScrollbar ? m_verticalScrollbar-&gt;width() : 0),
+            m_horizontalScrollbar-&gt;height());
</ins><span class="cx">         m_horizontalScrollbar-&gt;setFrameRect(hBarRect);
</span><span class="cx">         if (!m_scrollbarsSuppressed &amp;&amp; oldRect != m_horizontalScrollbar-&gt;frameRect())
</span><span class="cx">             m_horizontalScrollbar-&gt;invalidate();
</span><span class="lines">@@ -663,9 +686,9 @@
</span><span class="cx">         int pageStep = std::max(std::max&lt;int&gt;(clientHeight * Scrollbar::minFractionToStepWhenPaging(), clientHeight - Scrollbar::maxOverlapBetweenPages()), 1);
</span><span class="cx">         IntRect oldRect(m_verticalScrollbar-&gt;frameRect());
</span><span class="cx">         IntRect vBarRect(width() - m_verticalScrollbar-&gt;width(), 
</span><del>-                         0,
-                         m_verticalScrollbar-&gt;width(),
-                         height() - (m_horizontalScrollbar ? m_horizontalScrollbar-&gt;height() : 0));
</del><ins>+            topContentInset(),
+            m_verticalScrollbar-&gt;width(),
+            height() - topContentInset() - (m_horizontalScrollbar ? m_horizontalScrollbar-&gt;height() : 0));
</ins><span class="cx">         m_verticalScrollbar-&gt;setFrameRect(vBarRect);
</span><span class="cx">         if (!m_scrollbarsSuppressed &amp;&amp; oldRect != m_verticalScrollbar-&gt;frameRect())
</span><span class="cx">             m_verticalScrollbar-&gt;invalidate();
</span><span class="lines">@@ -792,7 +815,7 @@
</span><span class="cx">     if (delegatesScrolling())
</span><span class="cx">         return convertToRootView(contentsPoint);
</span><span class="cx"> 
</span><del>-    IntPoint viewPoint = contentsPoint + IntSize(0, headerHeight()) - scrollOffset();
</del><ins>+    IntPoint viewPoint = contentsPoint + IntSize(0, headerHeight() + topContentInset()) - scrollOffset();
</ins><span class="cx">     return convertToRootView(viewPoint);  
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -812,7 +835,7 @@
</span><span class="cx">         return convertToRootView(contentsRect);
</span><span class="cx"> 
</span><span class="cx">     IntRect viewRect = contentsRect;
</span><del>-    viewRect.move(-scrollOffset() + IntSize(0, headerHeight()));
</del><ins>+    viewRect.move(-scrollOffset() + IntSize(0, headerHeight() + topContentInset()));
</ins><span class="cx">     return convertToRootView(viewRect);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -839,7 +862,7 @@
</span><span class="cx">     if (delegatesScrolling())
</span><span class="cx">         return convertToContainingWindow(contentsPoint);
</span><span class="cx"> 
</span><del>-    IntPoint viewPoint = contentsPoint + IntSize(0, headerHeight()) - scrollOffset();
</del><ins>+    IntPoint viewPoint = contentsPoint + IntSize(0, headerHeight() + topContentInset()) - scrollOffset();
</ins><span class="cx">     return convertToContainingWindow(viewPoint);  
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -859,7 +882,7 @@
</span><span class="cx">         return convertToContainingWindow(contentsRect);
</span><span class="cx"> 
</span><span class="cx">     IntRect viewRect = contentsRect;
</span><del>-    viewRect.move(-scrollOffset() + IntSize(0, headerHeight()));
</del><ins>+    viewRect.move(-scrollOffset() + IntSize(0, headerHeight() + topContentInset()));
</ins><span class="cx">     return convertToContainingWindow(viewRect);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1056,20 +1079,22 @@
</span><span class="cx">     if (hasOverlayScrollbars())
</span><span class="cx">         return cornerRect;
</span><span class="cx"> 
</span><ins>+    int heightTrackedByScrollbar = height() - topContentInset();
+
</ins><span class="cx">     if (m_horizontalScrollbar &amp;&amp; width() - m_horizontalScrollbar-&gt;width() &gt; 0) {
</span><span class="cx">         cornerRect.unite(IntRect(m_horizontalScrollbar-&gt;width(),
</span><del>-                                 height() - m_horizontalScrollbar-&gt;height(),
-                                 width() - m_horizontalScrollbar-&gt;width(),
-                                 m_horizontalScrollbar-&gt;height()));
</del><ins>+            height() - m_horizontalScrollbar-&gt;height(),
+            width() - m_horizontalScrollbar-&gt;width(),
+            m_horizontalScrollbar-&gt;height()));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (m_verticalScrollbar &amp;&amp; height() - m_verticalScrollbar-&gt;height() &gt; 0) {
</del><ins>+    if (m_verticalScrollbar &amp;&amp; heightTrackedByScrollbar - m_verticalScrollbar-&gt;height() &gt; 0) {
</ins><span class="cx">         cornerRect.unite(IntRect(width() - m_verticalScrollbar-&gt;width(),
</span><del>-                                 m_verticalScrollbar-&gt;height(),
-                                 m_verticalScrollbar-&gt;width(),
-                                 height() - m_verticalScrollbar-&gt;height()));
</del><ins>+            m_verticalScrollbar-&gt;height() + topContentInset(),
+            m_verticalScrollbar-&gt;width(),
+            heightTrackedByScrollbar - m_verticalScrollbar-&gt;height()));
</ins><span class="cx">     }
</span><del>-    
</del><ins>+
</ins><span class="cx">     return cornerRect;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformScrollViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ScrollView.h (166016 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ScrollView.h        2014-03-20 23:16:28 UTC (rev 166016)
+++ trunk/Source/WebCore/platform/ScrollView.h        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -153,9 +153,11 @@
</span><span class="cx">     void setCanBlitOnScroll(bool);
</span><span class="cx">     bool canBlitOnScroll() const;
</span><span class="cx"> 
</span><del>-    // The visible content rect has a location that is the scrolled offset of the document. The width and height are the viewport width
-    // and height. By default the scrollbars themselves are excluded from this rectangle, but an optional boolean argument allows them to be
-    // included.
</del><ins>+    virtual float topContentInset() const { return 0; }
+
+    // The visible content rect has a location that is the scrolled offset of the document. The width and height are the unobscured viewport
+    // width and height. By default the scrollbars themselves are excluded from this rectangle, but an optional boolean argument allows them
+    // to be included.
</ins><span class="cx">     // In the situation the client is responsible for the scrolling (ie. with a tiled backing store) it is possible to use
</span><span class="cx">     // the setFixedVisibleContentRect instead for the mainframe, though this must be updated manually, e.g just before resuming the page
</span><span class="cx">     // which usually will happen when panning, pinching and rotation ends, or when scale or position are changed manually.
</span><span class="lines">@@ -173,7 +175,7 @@
</span><span class="cx">     IntRect unobscuredContentRect() const;
</span><span class="cx">     IntRect unobscuredContentRectIncludingScrollbars() const { return unobscuredContentRect(); }
</span><span class="cx"> #else
</span><del>-    IntRect unobscuredContentRect() const { return visibleContentRect(); }
</del><ins>+    IntRect unobscuredContentRect(VisibleContentRectIncludesScrollbars = ExcludeScrollbars) const;
</ins><span class="cx">     IntRect unobscuredContentRectIncludingScrollbars() const { return visibleContentRectIncludingScrollbars(); }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -189,11 +191,13 @@
</span><span class="cx">     TileCache* tileCache();
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    // visibleContentRect().size() is computed from unscaledVisibleContentSize() divided by the value of visibleContentScaleFactor.
</del><ins>+    // visibleContentRect().size() is computed from unscaledUnobscuredVisibleContentSize() divided by the value of visibleContentScaleFactor.
</ins><span class="cx">     // visibleContentScaleFactor is usually 1, except when the setting delegatesPageScaling is true and the
</span><span class="cx">     // ScrollView is the main frame; in that case, visibleContentScaleFactor is equal to the page's pageScaleFactor.
</span><del>-    // Ports that don't use pageScaleFactor can treat unscaledVisibleContentSize and visibleContentRect().size() as equivalent.
-    IntSize unscaledVisibleContentSize(VisibleContentRectIncludesScrollbars = ExcludeScrollbars) const;
</del><ins>+    // Ports that don't use pageScaleFactor can treat unscaledUnobscuredVisibleContentSize and visibleContentRect().size() as equivalent.
+    // unscaledTotalVisibleContentSize() includes areas in the content that might be obscured by UI elements.
+    IntSize unscaledUnobscuredVisibleContentSize(VisibleContentRectIncludesScrollbars = ExcludeScrollbars) const;
+    IntSize unscaledTotalVisibleContentSize(VisibleContentRectIncludesScrollbars = ExcludeScrollbars) const;
</ins><span class="cx">     virtual float visibleContentScaleFactor() const { return 1; }
</span><span class="cx"> 
</span><span class="cx">     // Functions for getting/setting the size webkit should use to layout the contents. By default this is the same as the visible
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerCompositorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (166016 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp        2014-03-20 23:16:28 UTC (rev 166016)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -1472,7 +1472,7 @@
</span><span class="cx"> {
</span><span class="cx">     if (m_clipLayer) {
</span><span class="cx">         const FrameView&amp; frameView = m_renderView.frameView();
</span><del>-        m_clipLayer-&gt;setSize(frameView.unscaledVisibleContentSize());
</del><ins>+        m_clipLayer-&gt;setSize(frameView.unscaledTotalVisibleContentSize());
</ins><span class="cx"> 
</span><span class="cx">         frameViewDidScroll();
</span><span class="cx">         updateOverflowControlsLayers();
</span><span class="lines">@@ -1875,11 +1875,12 @@
</span><span class="cx"> {
</span><span class="cx">     if (m_rootContentLayer) {
</span><span class="cx">         const IntRect&amp; documentRect = m_renderView.documentRect();
</span><del>-        m_rootContentLayer-&gt;setSize(documentRect.size());
-        m_rootContentLayer-&gt;setPosition(FloatPoint(documentRect.x(), documentRect.y() + m_renderView.frameView().headerHeight()));
</del><ins>+        m_rootContentLayer-&gt;setSize(documentRect.size());        
+        m_rootContentLayer-&gt;setPosition(FloatPoint(documentRect.x(), documentRect.y() + m_renderView.frameView().headerHeight()
+            + m_renderView.frameView().topContentInset()));
</ins><span class="cx">     }
</span><span class="cx">     if (m_clipLayer)
</span><del>-        m_clipLayer-&gt;setSize(m_renderView.frameView().unscaledVisibleContentSize());
</del><ins>+        m_clipLayer-&gt;setSize(m_renderView.frameView().unscaledTotalVisibleContentSize());
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(RUBBER_BANDING)
</span><span class="cx">     if (m_contentShadowLayer) {
</span><span class="lines">@@ -3123,7 +3124,7 @@
</span><span class="cx">             m_clipLayer-&gt;addChild(m_scrollLayer.get());
</span><span class="cx">             m_scrollLayer-&gt;addChild(m_rootContentLayer.get());
</span><span class="cx"> 
</span><del>-            m_clipLayer-&gt;setSize(m_renderView.frameView().unscaledVisibleContentSize());
</del><ins>+            m_clipLayer-&gt;setSize(m_renderView.frameView().unscaledTotalVisibleContentSize());
</ins><span class="cx"> 
</span><span class="cx">             updateOverflowControlsLayers();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.cpp (166016 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.cpp        2014-03-20 23:16:28 UTC (rev 166016)
+++ trunk/Source/WebCore/testing/Internals.cpp        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -1827,6 +1827,16 @@
</span><span class="cx">     FrameView* frameView = document-&gt;view();
</span><span class="cx">     frameView-&gt;setFooterHeight(height);
</span><span class="cx"> }
</span><ins>+    
+void Internals::setTopContentInset(float contentInset)
+{
+    Document* document = contextDocument();
+    if (!document)
+        return;
+    
+    Page* page = document-&gt;page();
+    page-&gt;setTopContentInset(contentInset);
+}
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(FULLSCREEN_API)
</span><span class="cx"> void Internals::webkitWillEnterFullScreenForElement(Element* element)
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.h (166016 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.h        2014-03-20 23:16:28 UTC (rev 166016)
+++ trunk/Source/WebCore/testing/Internals.h        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -255,6 +255,8 @@
</span><span class="cx">     void setHeaderHeight(float);
</span><span class="cx">     void setFooterHeight(float);
</span><span class="cx"> 
</span><ins>+    void setTopContentInset(float);
+
</ins><span class="cx"> #if ENABLE(FULLSCREEN_API)
</span><span class="cx">     void webkitWillEnterFullScreenForElement(Element*);
</span><span class="cx">     void webkitDidEnterFullScreenForElement(Element*);
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.idl (166016 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.idl        2014-03-20 23:16:28 UTC (rev 166016)
+++ trunk/Source/WebCore/testing/Internals.idl        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -214,6 +214,8 @@
</span><span class="cx">     void setHeaderHeight(float height);
</span><span class="cx">     void setFooterHeight(float height);
</span><span class="cx"> 
</span><ins>+    void setTopContentInset(float contentInset);
+
</ins><span class="cx"> #if defined(ENABLE_FULLSCREEN_API) &amp;&amp; ENABLE_FULLSCREEN_API
</span><span class="cx">     void webkitWillEnterFullScreenForElement(Element element);
</span><span class="cx">     void webkitDidEnterFullScreenForElement(Element element);
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (166016 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-03-20 23:16:28 UTC (rev 166016)
+++ trunk/Source/WebKit2/ChangeLog        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -1,3 +1,37 @@
</span><ins>+2014-03-20  Beth Dakin  &lt;bdakin@apple.com&gt;
+
+        Implement contentInset for Mac WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=130273
+
+        Reviewed by Simon Fraser.
+
+        This patch adds WKView API for setting a topContentInset(). All of this work gets 
+        that number plumbed down to WebCore.
+
+        * Shared/WebPageCreationParameters.cpp:
+        (WebKit::WebPageCreationParameters::encode):
+        (WebKit::WebPageCreationParameters::decode):
+        * Shared/WebPageCreationParameters.h:
+        * UIProcess/API/Cocoa/WKViewPrivate.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _setTopContentInset:]):
+        (-[WKWebView _topContentInset]):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView _setTopContentInset:]):
+        (-[WKView _topContentInset]):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::WebPageProxy):
+        (WebKit::WebPageProxy::setTopContentInset):
+        (WebKit::WebPageProxy::creationParameters):
+        * UIProcess/WebPageProxy.h:
+        (WebKit::WebPageProxy::topContentInset):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::WebPage):
+        (WebKit::WebPage::setTopContentInset):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+
</ins><span class="cx"> 2014-03-20  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix 32-bit build.
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebPageCreationParameterscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp (166016 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp        2014-03-20 23:16:28 UTC (rev 166016)
+++ trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -55,6 +55,7 @@
</span><span class="cx">     encoder &lt;&lt; canRunBeforeUnloadConfirmPanel;
</span><span class="cx">     encoder &lt;&lt; canRunModal;
</span><span class="cx">     encoder &lt;&lt; deviceScaleFactor;
</span><ins>+    encoder &lt;&lt; topContentInset;
</ins><span class="cx">     encoder &lt;&lt; mediaVolume;
</span><span class="cx">     encoder &lt;&lt; mayStartMediaWhenInWindow;
</span><span class="cx">     encoder &lt;&lt; minimumLayoutSize;
</span><span class="lines">@@ -120,6 +121,8 @@
</span><span class="cx">         return false;
</span><span class="cx">     if (!decoder.decode(parameters.deviceScaleFactor))
</span><span class="cx">         return false;
</span><ins>+    if (!decoder.decode(parameters.topContentInset))
+        return false;
</ins><span class="cx">     if (!decoder.decode(parameters.mediaVolume))
</span><span class="cx">         return false;
</span><span class="cx">     if (!decoder.decode(parameters.mayStartMediaWhenInWindow))
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebPageCreationParametersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebPageCreationParameters.h (166016 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebPageCreationParameters.h        2014-03-20 23:16:28 UTC (rev 166016)
+++ trunk/Source/WebKit2/Shared/WebPageCreationParameters.h        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -90,6 +90,8 @@
</span><span class="cx">     bool canRunModal;
</span><span class="cx"> 
</span><span class="cx">     float deviceScaleFactor;
</span><ins>+
+    float topContentInset;
</ins><span class="cx">     
</span><span class="cx">     float mediaVolume;
</span><span class="cx">     bool mayStartMediaWhenInWindow;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKViewPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h (166016 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h        2014-03-20 23:16:28 UTC (rev 166016)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -81,6 +81,7 @@
</span><span class="cx"> @property (readwrite) BOOL allowsMagnification;
</span><span class="cx"> @property (readwrite) double magnification;
</span><span class="cx"> @property (readwrite) BOOL allowsBackForwardNavigationGestures;
</span><ins>+@property (nonatomic, setter=_setTopContentInset:) CGFloat _topContentInset;
</ins><span class="cx"> 
</span><span class="cx"> @property (readonly) NSColor *_pageExtendedBackgroundColor;
</span><span class="cx"> @property(copy, nonatomic) NSColor *underlayColor;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (166016 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2014-03-20 23:16:28 UTC (rev 166016)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -1147,6 +1147,16 @@
</span><span class="cx">     _page-&gt;setDrawsTransparentBackground(drawsTransparentBackground);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)_setTopContentInset:(CGFloat)contentInset
+{
+    _page-&gt;setTopContentInset(contentInset);
+}
+
+- (CGFloat)_topContentInset
+{
+    return _page-&gt;topContentInset();
+}
+
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> @end
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (166016 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h        2014-03-20 23:16:28 UTC (rev 166016)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -94,6 +94,7 @@
</span><span class="cx"> #else
</span><span class="cx"> @property (readonly) NSColor *_pageExtendedBackgroundColor;
</span><span class="cx"> @property (nonatomic, setter=_setDrawsTransparentBackground:) BOOL _drawsTransparentBackground;
</span><ins>+@property (nonatomic, setter=_setTopContentInset:) CGFloat _topContentInset;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> - (void)_runJavaScriptInMainFrame:(NSString *)scriptString;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPImacWKViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (166016 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2014-03-20 23:16:28 UTC (rev 166016)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -3742,6 +3742,16 @@
</span><span class="cx">     return _data-&gt;_allowsBackForwardNavigationGestures;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)_setTopContentInset:(CGFloat)contentInset
+{
+    _data-&gt;_page-&gt;setTopContentInset(contentInset);
+}
+
+- (CGFloat)_topContentInset
+{
+    return _data-&gt;_page-&gt;topContentInset();
+}
+
</ins><span class="cx"> - (NSColor *)_pageExtendedBackgroundColor
</span><span class="cx"> {
</span><span class="cx">     WebCore::Color color = _data-&gt;_page-&gt;pageExtendedBackgroundColor();
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (166016 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2014-03-20 23:16:28 UTC (rev 166016)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -274,6 +274,7 @@
</span><span class="cx">     , m_pageScaleFactor(1)
</span><span class="cx">     , m_intrinsicDeviceScaleFactor(1)
</span><span class="cx">     , m_customDeviceScaleFactor(0)
</span><ins>+    , m_topContentInset(0)
</ins><span class="cx">     , m_layerHostingMode(LayerHostingMode::InProcess)
</span><span class="cx">     , m_drawsBackground(true)
</span><span class="cx">     , m_drawsTransparentBackground(false)
</span><span class="lines">@@ -925,6 +926,17 @@
</span><span class="cx">         m_process-&gt;send(Messages::WebPage::SetDrawsTransparentBackground(drawsTransparentBackground), m_pageID);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPageProxy::setTopContentInset(float contentInset)
+{
+    if (m_topContentInset == contentInset)
+        return;
+
+    m_topContentInset = contentInset;
+
+    if (isValid())
+        m_process-&gt;send(Messages::WebPage::SetTopContentInset(contentInset), m_pageID);
+}
+
</ins><span class="cx"> void WebPageProxy::setUnderlayColor(const Color&amp; color)
</span><span class="cx"> {
</span><span class="cx">     if (m_underlayColor == color)
</span><span class="lines">@@ -4078,6 +4090,7 @@
</span><span class="cx">     parameters.canRunBeforeUnloadConfirmPanel = m_uiClient-&gt;canRunBeforeUnloadConfirmPanel();
</span><span class="cx">     parameters.canRunModal = m_canRunModal;
</span><span class="cx">     parameters.deviceScaleFactor = deviceScaleFactor();
</span><ins>+    parameters.topContentInset = m_topContentInset;
</ins><span class="cx">     parameters.mediaVolume = m_mediaVolume;
</span><span class="cx">     parameters.mayStartMediaWhenInWindow = m_mayStartMediaWhenInWindow;
</span><span class="cx">     parameters.minimumLayoutSize = m_minimumLayoutSize;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (166016 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-03-20 23:16:28 UTC (rev 166016)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -523,6 +523,9 @@
</span><span class="cx">     bool drawsTransparentBackground() const { return m_drawsTransparentBackground; }
</span><span class="cx">     void setDrawsTransparentBackground(bool);
</span><span class="cx"> 
</span><ins>+    float topContentInset() const { return m_topContentInset; }
+    void setTopContentInset(float);
+
</ins><span class="cx">     WebCore::Color underlayColor() const { return m_underlayColor; }
</span><span class="cx">     void setUnderlayColor(const WebCore::Color&amp;);
</span><span class="cx"> 
</span><span class="lines">@@ -1461,6 +1464,7 @@
</span><span class="cx">     double m_pageScaleFactor;
</span><span class="cx">     float m_intrinsicDeviceScaleFactor;
</span><span class="cx">     float m_customDeviceScaleFactor;
</span><ins>+    float m_topContentInset;
</ins><span class="cx"> 
</span><span class="cx">     LayerHostingMode m_layerHostingMode;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (166016 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2014-03-20 23:16:28 UTC (rev 166016)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -404,6 +404,8 @@
</span><span class="cx">     setScrollPinningBehavior(parameters.scrollPinningBehavior);
</span><span class="cx">     setBackgroundExtendsBeyondPage(parameters.backgroundExtendsBeyondPage);
</span><span class="cx"> 
</span><ins>+    setTopContentInset(parameters.topContentInset);
+
</ins><span class="cx">     m_userAgent = parameters.userAgent;
</span><span class="cx"> 
</span><span class="cx">     WebBackForwardListProxy::setHighestItemIDFromUIProcess(parameters.highestUsedBackForwardItemID);
</span><span class="lines">@@ -2032,6 +2034,11 @@
</span><span class="cx">     m_drawingArea-&gt;setNeedsDisplay();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPage::setTopContentInset(float contentInset)
+{
+    m_page-&gt;setTopContentInset(contentInset);
+}
+
</ins><span class="cx"> void WebPage::viewWillStartLiveResize()
</span><span class="cx"> {
</span><span class="cx">     if (!m_page)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (166016 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2014-03-20 23:16:28 UTC (rev 166016)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -850,6 +850,8 @@
</span><span class="cx">     void setDrawsBackground(bool);
</span><span class="cx">     void setDrawsTransparentBackground(bool);
</span><span class="cx"> 
</span><ins>+    void setTopContentInset(float);
+
</ins><span class="cx">     void viewWillStartLiveResize();
</span><span class="cx">     void viewWillEndLiveResize();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagemessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (166016 => 166017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2014-03-20 23:16:28 UTC (rev 166016)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2014-03-20 23:19:04 UTC (rev 166017)
</span><span class="lines">@@ -30,6 +30,8 @@
</span><span class="cx">     SetDrawsBackground(bool drawsBackground)
</span><span class="cx">     SetDrawsTransparentBackground(bool drawsTransparentBackground)
</span><span class="cx"> 
</span><ins>+    SetTopContentInset(float contentInset)
+
</ins><span class="cx">     SetUnderlayColor(WebCore::Color color)
</span><span class="cx"> 
</span><span class="cx">     ViewWillStartLiveResize()
</span></span></pre>
</div>
</div>

</body>
</html>