<!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>[173668] trunk/Source/WebCore</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/173668">173668</a></dd>
<dt>Author</dt> <dd>bdakin@apple.com</dd>
<dt>Date</dt> <dd>2014-09-16 13:32:29 -0700 (Tue, 16 Sep 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>overflow:scroll should not leave space for a scroll corner with overlay scrollbars
https://bugs.webkit.org/show_bug.cgi?id=136861

Reviewed by Sam Weinig.

overflow:scroll should behave like overflow:auto when the scrollbar will render as 
an overlay scrollbar.

Re-name hasAutoVerticalScrollbar()/Horizontal to 
hasVerticalScrollbarWithAutoBehavior()/Horizontal, and return true for 
overflow:scroll scrollbars that will render as overlay scrollbars.
* rendering/RenderBox.cpp:
(WebCore::RenderBox::hasVerticalScrollbarWithAutoBehavior):
(WebCore::RenderBox::hasHorizontalScrollbarWithAutoBehavior):
* rendering/RenderBox.h:
(WebCore::RenderBox::scrollsOverflowX):
(WebCore::RenderBox::scrollsOverflowY):
(WebCore::RenderBox::hasAutoVerticalScrollbar): Deleted.
(WebCore::RenderBox::hasAutoHorizontalScrollbar): Deleted.

Re-name overflowRequiresScrollbar() to styleRequiresScrollbar() and also re-name 
overflowDefinesAutomaticScrollbar() to styleDefinesAutomaticScrollbar(), and make         
these functions take into account the fact that overflow:scroll should act like 
overflow:auto when the scrollbar will render as an overlay scrollbar.
* rendering/RenderLayer.cpp:
(WebCore::styleRequiresScrollbar):
(WebCore::styleDefinesAutomaticScrollbar):
(WebCore::RenderLayer::updateScrollbarsAfterLayout):
(WebCore::RenderLayer::calculateClipRects):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBoxcpp">trunk/Source/WebCore/rendering/RenderBox.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBoxh">trunk/Source/WebCore/rendering/RenderBox.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayercpp">trunk/Source/WebCore/rendering/RenderLayer.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (173667 => 173668)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-09-16 19:54:12 UTC (rev 173667)
+++ trunk/Source/WebCore/ChangeLog        2014-09-16 20:32:29 UTC (rev 173668)
</span><span class="lines">@@ -1,3 +1,35 @@
</span><ins>+2014-09-16  Beth Dakin  &lt;bdakin@apple.com&gt;
+
+        overflow:scroll should not leave space for a scroll corner with overlay scrollbars
+        https://bugs.webkit.org/show_bug.cgi?id=136861
+
+        Reviewed by Sam Weinig.
+
+        overflow:scroll should behave like overflow:auto when the scrollbar will render as 
+        an overlay scrollbar.
+
+        Re-name hasAutoVerticalScrollbar()/Horizontal to 
+        hasVerticalScrollbarWithAutoBehavior()/Horizontal, and return true for 
+        overflow:scroll scrollbars that will render as overlay scrollbars.
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::hasVerticalScrollbarWithAutoBehavior):
+        (WebCore::RenderBox::hasHorizontalScrollbarWithAutoBehavior):
+        * rendering/RenderBox.h:
+        (WebCore::RenderBox::scrollsOverflowX):
+        (WebCore::RenderBox::scrollsOverflowY):
+        (WebCore::RenderBox::hasAutoVerticalScrollbar): Deleted.
+        (WebCore::RenderBox::hasAutoHorizontalScrollbar): Deleted.
+
+        Re-name overflowRequiresScrollbar() to styleRequiresScrollbar() and also re-name 
+        overflowDefinesAutomaticScrollbar() to styleDefinesAutomaticScrollbar(), and make         
+        these functions take into account the fact that overflow:scroll should act like 
+        overflow:auto when the scrollbar will render as an overlay scrollbar.
+        * rendering/RenderLayer.cpp:
+        (WebCore::styleRequiresScrollbar):
+        (WebCore::styleDefinesAutomaticScrollbar):
+        (WebCore::RenderLayer::updateScrollbarsAfterLayout):
+        (WebCore::RenderLayer::calculateClipRects):
+
</ins><span class="cx"> 2014-09-16  peavo@outlook.com  &lt;peavo@outlook.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Curl] Sometimes incomplete or empty content can be loaded from cache.
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBoxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (173667 => 173668)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBox.cpp        2014-09-16 19:54:12 UTC (rev 173667)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp        2014-09-16 20:32:29 UTC (rev 173668)
</span><span class="lines">@@ -55,6 +55,7 @@
</span><span class="cx"> #include &quot;RenderTableCell.h&quot;
</span><span class="cx"> #include &quot;RenderTheme.h&quot;
</span><span class="cx"> #include &quot;RenderView.h&quot;
</span><ins>+#include &quot;ScrollbarTheme.h&quot;
</ins><span class="cx"> #include &quot;TransformState.h&quot;
</span><span class="cx"> #include &quot;htmlediting.h&quot;
</span><span class="cx"> #include &lt;algorithm&gt;
</span><span class="lines">@@ -928,6 +929,18 @@
</span><span class="cx">         layer()-&gt;panScrollFromPoint(source);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool RenderBox::hasVerticalScrollbarWithAutoBehavior() const
+{
+    bool overflowScrollActsLikeAuto = style().overflowY() == OSCROLL &amp;&amp; !style().hasPseudoStyle(SCROLLBAR) &amp;&amp; ScrollbarTheme::theme()-&gt;usesOverlayScrollbars();
+    return hasOverflowClip() &amp;&amp; (style().overflowY() == OAUTO || style().overflowY() == OOVERLAY || overflowScrollActsLikeAuto);
+}
+
+bool RenderBox::hasHorizontalScrollbarWithAutoBehavior() const
+{
+    bool overflowScrollActsLikeAuto = style().overflowX() == OSCROLL &amp;&amp; !style().hasPseudoStyle(SCROLLBAR) &amp;&amp; ScrollbarTheme::theme()-&gt;usesOverlayScrollbars();
+    return hasOverflowClip() &amp;&amp; (style().overflowX() == OAUTO || style().overflowX() == OOVERLAY || overflowScrollActsLikeAuto);
+}
+
</ins><span class="cx"> bool RenderBox::needsPreferredWidthsRecalculation() const
</span><span class="cx"> {
</span><span class="cx">     return style().paddingStart().isPercent() || style().paddingEnd().isPercent();
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBoxh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBox.h (173667 => 173668)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBox.h        2014-09-16 19:54:12 UTC (rev 173667)
+++ trunk/Source/WebCore/rendering/RenderBox.h        2014-09-16 20:32:29 UTC (rev 173668)
</span><span class="lines">@@ -466,11 +466,11 @@
</span><span class="cx">     virtual void stopAutoscroll() { }
</span><span class="cx">     virtual void panScroll(const IntPoint&amp;);
</span><span class="cx"> 
</span><del>-    bool hasAutoVerticalScrollbar() const { return hasOverflowClip() &amp;&amp; (style().overflowY() == OAUTO || style().overflowY() == OOVERLAY); }
-    bool hasAutoHorizontalScrollbar() const { return hasOverflowClip() &amp;&amp; (style().overflowX() == OAUTO || style().overflowX() == OOVERLAY); }
</del><ins>+    bool hasVerticalScrollbarWithAutoBehavior() const;
+    bool hasHorizontalScrollbarWithAutoBehavior() const;
</ins><span class="cx">     bool scrollsOverflow() const { return scrollsOverflowX() || scrollsOverflowY(); }
</span><del>-    bool scrollsOverflowX() const { return hasOverflowClip() &amp;&amp; (style().overflowX() == OSCROLL || hasAutoHorizontalScrollbar()); }
-    bool scrollsOverflowY() const { return hasOverflowClip() &amp;&amp; (style().overflowY() == OSCROLL || hasAutoVerticalScrollbar()); }
</del><ins>+    bool scrollsOverflowX() const { return hasOverflowClip() &amp;&amp; (style().overflowX() == OSCROLL || hasHorizontalScrollbarWithAutoBehavior()); }
+    bool scrollsOverflowY() const { return hasOverflowClip() &amp;&amp; (style().overflowY() == OSCROLL || hasVerticalScrollbarWithAutoBehavior()); }
</ins><span class="cx">     bool hasScrollableOverflowX() const { return scrollsOverflowX() &amp;&amp; scrollWidth() != clientWidth(); }
</span><span class="cx">     bool hasScrollableOverflowY() const { return scrollsOverflowY() &amp;&amp; scrollHeight() != clientHeight(); }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (173667 => 173668)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayer.cpp        2014-09-16 19:54:12 UTC (rev 173667)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp        2014-09-16 20:32:29 UTC (rev 173668)
</span><span class="lines">@@ -3255,6 +3255,20 @@
</span><span class="cx">     return scrollHeight() &gt; renderBox()-&gt;pixelSnappedClientHeight();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static bool styleRequiresScrollbar(const RenderStyle&amp; style, ScrollbarOrientation axis)
+{
+    EOverflow overflow = axis == ScrollbarOrientation::HorizontalScrollbar ? style.overflowX() : style.overflowY();
+    bool overflowScrollActsLikeAuto = overflow == OSCROLL &amp;&amp; !style.hasPseudoStyle(SCROLLBAR) &amp;&amp; ScrollbarTheme::theme()-&gt;usesOverlayScrollbars();
+    return overflow == OSCROLL &amp;&amp; !overflowScrollActsLikeAuto;
+}
+
+static bool styleDefinesAutomaticScrollbar(const RenderStyle&amp; style, ScrollbarOrientation axis)
+{
+    EOverflow overflow = axis == ScrollbarOrientation::HorizontalScrollbar ? style.overflowX() : style.overflowY();
+    bool overflowScrollActsLikeAuto = overflow == OSCROLL &amp;&amp; !style.hasPseudoStyle(SCROLLBAR) &amp;&amp; ScrollbarTheme::theme()-&gt;usesOverlayScrollbars();
+    return overflow == OAUTO || overflow == OOVERLAY || overflowScrollActsLikeAuto;
+}
+
</ins><span class="cx"> void RenderLayer::updateScrollbarsAfterLayout()
</span><span class="cx"> {
</span><span class="cx">     RenderBox* box = renderBox();
</span><span class="lines">@@ -3267,20 +3281,20 @@
</span><span class="cx">     bool hasHorizontalOverflow = this-&gt;hasHorizontalOverflow();
</span><span class="cx">     bool hasVerticalOverflow = this-&gt;hasVerticalOverflow();
</span><span class="cx"> 
</span><del>-    // overflow:scroll should just enable/disable.
-    if (renderer().style().overflowX() == OSCROLL)
</del><ins>+    // If overflow requires a scrollbar, then we just need to enable or disable.
+    if (styleRequiresScrollbar(renderer().style(), HorizontalScrollbar))
</ins><span class="cx">         m_hBar-&gt;setEnabled(hasHorizontalOverflow);
</span><del>-    if (renderer().style().overflowY() == OSCROLL)
</del><ins>+    if (styleRequiresScrollbar(renderer().style(), VerticalScrollbar))
</ins><span class="cx">         m_vBar-&gt;setEnabled(hasVerticalOverflow);
</span><span class="cx"> 
</span><del>-    // overflow:auto may need to lay out again if scrollbars got added/removed.
-    bool autoHorizontalScrollBarChanged = box-&gt;hasAutoHorizontalScrollbar() &amp;&amp; (hasHorizontalScrollbar() != hasHorizontalOverflow);
-    bool autoVerticalScrollBarChanged = box-&gt;hasAutoVerticalScrollbar() &amp;&amp; (hasVerticalScrollbar() != hasVerticalOverflow);
</del><ins>+    // Scrollbars with auto behavior may need to lay out again if scrollbars got added or removed.
+    bool autoHorizontalScrollBarChanged = box-&gt;hasHorizontalScrollbarWithAutoBehavior() &amp;&amp; (hasHorizontalScrollbar() != hasHorizontalOverflow);
+    bool autoVerticalScrollBarChanged = box-&gt;hasVerticalScrollbarWithAutoBehavior() &amp;&amp; (hasVerticalScrollbar() != hasVerticalOverflow);
</ins><span class="cx"> 
</span><span class="cx">     if (autoHorizontalScrollBarChanged || autoVerticalScrollBarChanged) {
</span><del>-        if (box-&gt;hasAutoHorizontalScrollbar())
</del><ins>+        if (box-&gt;hasHorizontalScrollbarWithAutoBehavior())
</ins><span class="cx">             setHasHorizontalScrollbar(hasHorizontalOverflow);
</span><del>-        if (box-&gt;hasAutoVerticalScrollbar())
</del><ins>+        if (box-&gt;hasVerticalScrollbarWithAutoBehavior())
</ins><span class="cx">             setHasVerticalScrollbar(hasVerticalOverflow);
</span><span class="cx"> 
</span><span class="cx">         updateSelfPaintingLayer();
</span><span class="lines">@@ -6387,16 +6401,6 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static bool overflowRequiresScrollbar(EOverflow overflow)
-{
-    return overflow == OSCROLL;
-}
-
-static bool overflowDefinesAutomaticScrollbar(EOverflow overflow)
-{
-    return overflow == OAUTO || overflow == OOVERLAY;
-}
-
</del><span class="cx"> void RenderLayer::updateScrollbarsAfterStyleChange(const RenderStyle* oldStyle)
</span><span class="cx"> {
</span><span class="cx">     // Overflow are a box concept.
</span><span class="lines">@@ -6412,22 +6416,18 @@
</span><span class="cx">     EOverflow overflowY = box-&gt;style().overflowY();
</span><span class="cx"> 
</span><span class="cx">     // To avoid doing a relayout in updateScrollbarsAfterLayout, we try to keep any automatic scrollbar that was already present.
</span><del>-    bool needsHorizontalScrollbar = box-&gt;hasOverflowClip() &amp;&amp; ((hasHorizontalScrollbar() &amp;&amp; overflowDefinesAutomaticScrollbar(overflowX)) || overflowRequiresScrollbar(overflowX));
-    bool needsVerticalScrollbar = box-&gt;hasOverflowClip() &amp;&amp; ((hasVerticalScrollbar() &amp;&amp; overflowDefinesAutomaticScrollbar(overflowY)) || overflowRequiresScrollbar(overflowY));
</del><ins>+    bool needsHorizontalScrollbar = box-&gt;hasOverflowClip() &amp;&amp; ((hasHorizontalScrollbar() &amp;&amp; styleDefinesAutomaticScrollbar(box-&gt;style(), HorizontalScrollbar)) || styleRequiresScrollbar(box-&gt;style(), HorizontalScrollbar));
+    bool needsVerticalScrollbar = box-&gt;hasOverflowClip() &amp;&amp; ((hasVerticalScrollbar() &amp;&amp; styleDefinesAutomaticScrollbar(box-&gt;style(), VerticalScrollbar)) || styleRequiresScrollbar(box-&gt;style(), VerticalScrollbar));
</ins><span class="cx">     setHasHorizontalScrollbar(needsHorizontalScrollbar);
</span><span class="cx">     setHasVerticalScrollbar(needsVerticalScrollbar);
</span><span class="cx"> 
</span><del>-    // With overflow: scroll, scrollbars are always visible but may be disabled.
</del><ins>+    // With non-overlay overflow:scroll, scrollbars are always visible but may be disabled.
</ins><span class="cx">     // When switching to another value, we need to re-enable them (see bug 11985).
</span><del>-    if (needsHorizontalScrollbar &amp;&amp; oldStyle &amp;&amp; oldStyle-&gt;overflowX() == OSCROLL &amp;&amp; overflowX != OSCROLL) {
-        ASSERT(hasHorizontalScrollbar());
</del><ins>+    if (m_hBar &amp;&amp; needsHorizontalScrollbar &amp;&amp; oldStyle &amp;&amp; oldStyle-&gt;overflowX() == OSCROLL &amp;&amp; overflowX != OSCROLL)
</ins><span class="cx">         m_hBar-&gt;setEnabled(true);
</span><del>-    }
</del><span class="cx"> 
</span><del>-    if (needsVerticalScrollbar &amp;&amp; oldStyle &amp;&amp; oldStyle-&gt;overflowY() == OSCROLL &amp;&amp; overflowY != OSCROLL) {
-        ASSERT(hasVerticalScrollbar());
</del><ins>+    if (m_vBar &amp;&amp; needsVerticalScrollbar &amp;&amp; oldStyle &amp;&amp; oldStyle-&gt;overflowY() == OSCROLL &amp;&amp; overflowY != OSCROLL)
</ins><span class="cx">         m_vBar-&gt;setEnabled(true);
</span><del>-    }
</del><span class="cx"> 
</span><span class="cx">     if (!m_scrollDimensionsDirty)
</span><span class="cx">         updateScrollableAreaSet(hasScrollableHorizontalOverflow() || hasScrollableVerticalOverflow());
</span></span></pre>
</div>
</div>

</body>
</html>