<!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>[168726] trunk/Source</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/168726">168726</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2014-05-13 12:32:37 -0700 (Tue, 13 May 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[iOS WK2] background-attachment:fixed behaves very poorly
https://bugs.webkit.org/show_bug.cgi?id=132881
&lt;rdar://problem/16789526&gt;

Reviewed by Beth Dakin.

Source/WebCore:

Remove the old ENABLE_FAST_MOBILE_SCROLLING code, and add a setting that
controls whether fixed backgrounds paint relative to the document, which
is enabled for iOS (WK1 and WK2). This setting is consulted when we repaint
fixed backgrounds on scrolling, when we paint them, and when we decide to make
a layer for fixed backgrounds.

* page/Settings.cpp:
* page/Settings.in:
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry):
* rendering/RenderElement.cpp:
(WebCore::RenderElement::styleWillChange):
(WebCore::RenderElement::willBeRemovedFromTree):
(WebCore::shouldRepaintFixedBackgroundsOnScroll): Deleted.
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::needsFixedRootBackgroundLayer):

Source/WTF:

Remove ENABLE_FAST_MOBILE_SCROLLING. Ports can use the fixedBackgroundsPaintRelativeToDocument
setting now.

* wtf/FeatureDefines.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfFeatureDefinesh">trunk/Source/WTF/wtf/FeatureDefines.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorepageSettingscpp">trunk/Source/WebCore/page/Settings.cpp</a></li>
<li><a href="#trunkSourceWebCorepageSettingsin">trunk/Source/WebCore/page/Settings.in</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBoxModelObjectcpp">trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderElementcpp">trunk/Source/WebCore/rendering/RenderElement.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerCompositorcpp">trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (168725 => 168726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2014-05-13 19:32:29 UTC (rev 168725)
+++ trunk/Source/WTF/ChangeLog        2014-05-13 19:32:37 UTC (rev 168726)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2014-05-13  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        [iOS WK2] background-attachment:fixed behaves very poorly
+        https://bugs.webkit.org/show_bug.cgi?id=132881
+        &lt;rdar://problem/16789526&gt;
+
+        Reviewed by Beth Dakin.
+        
+        Remove ENABLE_FAST_MOBILE_SCROLLING. Ports can use the fixedBackgroundsPaintRelativeToDocument
+        setting now.
+
+        * wtf/FeatureDefines.h:
+
</ins><span class="cx"> 2014-05-08  Alexey Proskuryakov  &lt;ap@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Automatically zip document bundles used via File API
</span></span></pre></div>
<a id="trunkSourceWTFwtfFeatureDefinesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/FeatureDefines.h (168725 => 168726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/FeatureDefines.h        2014-05-13 19:32:29 UTC (rev 168725)
+++ trunk/Source/WTF/wtf/FeatureDefines.h        2014-05-13 19:32:37 UTC (rev 168726)
</span><span class="lines">@@ -452,10 +452,6 @@
</span><span class="cx"> #define ENABLE_ENCRYPTED_MEDIA_V2 0
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if !defined(ENABLE_FAST_MOBILE_SCROLLING)
-#define ENABLE_FAST_MOBILE_SCROLLING 0
-#endif
-
</del><span class="cx"> #if !defined(ENABLE_FILTERS)
</span><span class="cx"> #define ENABLE_FILTERS 0
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (168725 => 168726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-05-13 19:32:29 UTC (rev 168725)
+++ trunk/Source/WebCore/ChangeLog        2014-05-13 19:32:37 UTC (rev 168726)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2014-05-13  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        [iOS WK2] background-attachment:fixed behaves very poorly
+        https://bugs.webkit.org/show_bug.cgi?id=132881
+        &lt;rdar://problem/16789526&gt;
+
+        Reviewed by Beth Dakin.
+
+        Remove the old ENABLE_FAST_MOBILE_SCROLLING code, and add a setting that
+        controls whether fixed backgrounds paint relative to the document, which
+        is enabled for iOS (WK1 and WK2). This setting is consulted when we repaint
+        fixed backgrounds on scrolling, when we paint them, and when we decide to make
+        a layer for fixed backgrounds.
+        
+        * page/Settings.cpp:
+        * page/Settings.in:
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry):
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::styleWillChange):
+        (WebCore::RenderElement::willBeRemovedFromTree):
+        (WebCore::shouldRepaintFixedBackgroundsOnScroll): Deleted.
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::needsFixedRootBackgroundLayer):
+
</ins><span class="cx"> 2014-05-13  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSSION(r168528) Subpixel rendering: Selection rect is not positioned properly when SVG text is selected.
</span></span></pre></div>
<a id="trunkSourceWebCorepageSettingscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Settings.cpp (168725 => 168726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Settings.cpp        2014-05-13 19:32:29 UTC (rev 168725)
+++ trunk/Source/WebCore/page/Settings.cpp        2014-05-13 19:32:37 UTC (rev 168726)
</span><span class="lines">@@ -122,12 +122,14 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> static const bool defaultFixedPositionCreatesStackingContext = true;
</span><ins>+static const bool defaultFixedBackgroundsPaintRelativeToDocument = true;
</ins><span class="cx"> static const bool defaultAcceleratedCompositingForFixedPositionEnabled = true;
</span><span class="cx"> static const bool defaultMediaPlaybackAllowsInline = false;
</span><span class="cx"> static const bool defaultMediaPlaybackRequiresUserGesture = true;
</span><span class="cx"> static const bool defaultShouldRespectImageOrientation = true;
</span><span class="cx"> #else
</span><span class="cx"> static const bool defaultFixedPositionCreatesStackingContext = false;
</span><ins>+static const bool defaultFixedBackgroundsPaintRelativeToDocument = false;
</ins><span class="cx"> static const bool defaultAcceleratedCompositingForFixedPositionEnabled = false;
</span><span class="cx"> static const bool defaultMediaPlaybackAllowsInline = true;
</span><span class="cx"> static const bool defaultMediaPlaybackRequiresUserGesture = false;
</span></span></pre></div>
<a id="trunkSourceWebCorepageSettingsin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Settings.in (168725 => 168726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Settings.in        2014-05-13 19:32:29 UTC (rev 168725)
+++ trunk/Source/WebCore/page/Settings.in        2014-05-13 19:32:37 UTC (rev 168726)
</span><span class="lines">@@ -187,6 +187,7 @@
</span><span class="cx"> 
</span><span class="cx"> selectionIncludesAltImageText initial=true
</span><span class="cx"> useLegacyBackgroundSizeShorthandBehavior initial=false
</span><ins>+fixedBackgroundsPaintRelativeToDocument initial=defaultFixedBackgroundsPaintRelativeToDocument
</ins><span class="cx"> 
</span><span class="cx"> minimumZoomFontSize type=float, initial=15, conditional=IOS_TEXT_AUTOSIZING
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBoxModelObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (168725 => 168726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2014-05-13 19:32:29 UTC (rev 168725)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2014-05-13 19:32:37 UTC (rev 168726)
</span><span class="lines">@@ -1082,17 +1082,6 @@
</span><span class="cx">     // destRect will be adjusted later if the background is non-repeating.
</span><span class="cx">     // FIXME: transforms spec says that fixed backgrounds behave like scroll inside transforms. https://bugs.webkit.org/show_bug.cgi?id=15679
</span><span class="cx">     bool fixedAttachment = fillLayer-&gt;attachment() == FixedBackgroundAttachment;
</span><del>-    
-#if ENABLE(FAST_MOBILE_SCROLLING)
-    if (view().frameView().canBlitOnScroll()) {
-        // As a side effect of an optimization to blit on scroll, we do not honor the CSS
-        // property &quot;background-attachment: fixed&quot; because it may result in rendering
-        // artifacts. Note, these artifacts only appear if we are blitting on scroll of
-        // a page that has fixed background images.
-        fixedAttachment = false;
-    }
-#endif
-
</del><span class="cx">     if (!fixedAttachment) {
</span><span class="cx">         geometry.setDestRect(paintRect);
</span><span class="cx"> 
</span><span class="lines">@@ -1127,12 +1116,17 @@
</span><span class="cx">     } else {
</span><span class="cx">         geometry.setHasNonLocalGeometry();
</span><span class="cx"> 
</span><del>-        LayoutRect viewportRect = view().viewRect();
-        if (fixedBackgroundPaintsInLocalCoordinates())
-            viewportRect.setLocation(LayoutPoint());
-        else
-            viewportRect.setLocation(toLayoutPoint(view().frameView().scrollOffsetForFixedPosition()));
-
</del><ins>+        LayoutRect viewportRect;
+        if (frame().settings().fixedBackgroundsPaintRelativeToDocument())
+            viewportRect = view().unscaledDocumentRect();
+        else {
+            viewportRect = view().viewRect();
+            if (fixedBackgroundPaintsInLocalCoordinates())
+                viewportRect.setLocation(LayoutPoint());
+            else
+                viewportRect.setLocation(toLayoutPoint(view().frameView().scrollOffsetForFixedPosition()));
+        }
+        
</ins><span class="cx">         if (paintContainer)
</span><span class="cx">             viewportRect.moveBy(LayoutPoint(-paintContainer-&gt;localToAbsolute(FloatPoint())));
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderElement.cpp (168725 => 168726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderElement.cpp        2014-05-13 19:32:29 UTC (rev 168725)
+++ trunk/Source/WebCore/rendering/RenderElement.cpp        2014-05-13 19:32:37 UTC (rev 168726)
</span><span class="lines">@@ -57,6 +57,7 @@
</span><span class="cx"> #include &quot;RenderTheme.h&quot;
</span><span class="cx"> #include &quot;RenderView.h&quot;
</span><span class="cx"> #include &quot;SVGRenderSupport.h&quot;
</span><ins>+#include &quot;Settings.h&quot;
</ins><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><span class="cx"> #include &lt;wtf/MathExtras.h&gt;
</span><span class="cx"> #include &lt;wtf/StackStats.h&gt;
</span><span class="lines">@@ -793,19 +794,6 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// On low-powered/mobile devices, preventing blitting on a scroll can cause noticeable delays
-// when scrolling a page with a fixed background image. As an optimization, assuming there are
-// no fixed positoned elements on the page, we can acclerate scrolling (via blitting) if we
-// ignore the CSS property &quot;background-attachment: fixed&quot;.
-static bool shouldRepaintFixedBackgroundsOnScroll()
-{
-#if ENABLE(FAST_MOBILE_SCROLLING)
-    return false;
-#else
-    return true;
-#endif
-}
-
</del><span class="cx"> static inline bool rendererHasBackground(const RenderElement* renderer)
</span><span class="cx"> {
</span><span class="cx">     return renderer &amp;&amp; renderer-&gt;hasBackground();
</span><span class="lines">@@ -879,27 +867,31 @@
</span><span class="cx">         s_noLongerAffectsParentBlock = false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    bool repaintFixedBackgroundsOnScroll = shouldRepaintFixedBackgroundsOnScroll();
</del><ins>+    bool newStyleUsesFixedBackgrounds = newStyle.hasFixedBackgroundImage();
+    bool oldStyleUsesFixedBackgrounds = m_style-&gt;hasFixedBackgroundImage();
+    if (newStyleUsesFixedBackgrounds || oldStyleUsesFixedBackgrounds) {
+        bool repaintFixedBackgroundsOnScroll = !frame().settings().fixedBackgroundsPaintRelativeToDocument();
</ins><span class="cx"> 
</span><del>-    bool newStyleSlowScroll = repaintFixedBackgroundsOnScroll &amp;&amp; newStyle.hasFixedBackgroundImage();
-    bool oldStyleSlowScroll = oldStyle &amp;&amp; repaintFixedBackgroundsOnScroll &amp;&amp; m_style-&gt;hasFixedBackgroundImage();
-    bool drawsRootBackground = isRoot() || (isBody() &amp;&amp; !rendererHasBackground(document().documentElement()-&gt;renderer()));
-    if (drawsRootBackground &amp;&amp; repaintFixedBackgroundsOnScroll) {
-        if (view().compositor().supportsFixedRootBackgroundCompositing()) {
-            if (newStyleSlowScroll &amp;&amp; newStyle.hasEntirelyFixedBackground())
-                newStyleSlowScroll = false;
</del><ins>+        bool newStyleSlowScroll = repaintFixedBackgroundsOnScroll &amp;&amp; newStyleUsesFixedBackgrounds;
+        bool oldStyleSlowScroll = oldStyle &amp;&amp; repaintFixedBackgroundsOnScroll &amp;&amp; oldStyleUsesFixedBackgrounds;
+        bool drawsRootBackground = isRoot() || (isBody() &amp;&amp; !rendererHasBackground(document().documentElement()-&gt;renderer()));
+        if (drawsRootBackground &amp;&amp; repaintFixedBackgroundsOnScroll) {
+            if (view().compositor().supportsFixedRootBackgroundCompositing()) {
+                if (newStyleSlowScroll &amp;&amp; newStyle.hasEntirelyFixedBackground())
+                    newStyleSlowScroll = false;
</ins><span class="cx"> 
</span><del>-            if (oldStyleSlowScroll &amp;&amp; m_style-&gt;hasEntirelyFixedBackground())
-                oldStyleSlowScroll = false;
</del><ins>+                if (oldStyleSlowScroll &amp;&amp; m_style-&gt;hasEntirelyFixedBackground())
+                    oldStyleSlowScroll = false;
+            }
</ins><span class="cx">         }
</span><del>-    }
</del><span class="cx"> 
</span><del>-    if (oldStyleSlowScroll != newStyleSlowScroll) {
-        if (oldStyleSlowScroll)
-            view().frameView().removeSlowRepaintObject(this);
</del><ins>+        if (oldStyleSlowScroll != newStyleSlowScroll) {
+            if (oldStyleSlowScroll)
+                view().frameView().removeSlowRepaintObject(this);
</ins><span class="cx"> 
</span><del>-        if (newStyleSlowScroll)
-            view().frameView().addSlowRepaintObject(this);
</del><ins>+            if (newStyleSlowScroll)
+                view().frameView().addSlowRepaintObject(this);
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (isRoot() || isBody())
</span><span class="lines">@@ -1002,8 +994,7 @@
</span><span class="cx">         removeLayers(layer);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    bool repaintFixedBackgroundsOnScroll = shouldRepaintFixedBackgroundsOnScroll();
-    if (repaintFixedBackgroundsOnScroll &amp;&amp; m_style-&gt;hasFixedBackgroundImage())
</del><ins>+    if (m_style-&gt;hasFixedBackgroundImage() &amp;&amp; !frame().settings().fixedBackgroundsPaintRelativeToDocument())
</ins><span class="cx">         view().frameView().removeSlowRepaintObject(this);
</span><span class="cx"> 
</span><span class="cx">     if (isOutOfFlowPositioned() &amp;&amp; parent()-&gt;childrenInline())
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerCompositorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (168725 => 168726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp        2014-05-13 19:32:29 UTC (rev 168725)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp        2014-05-13 19:32:37 UTC (rev 168726)
</span><span class="lines">@@ -2720,6 +2720,9 @@
</span><span class="cx">     if (&amp;layer != m_renderView.layer())
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><ins>+    if (m_renderView.frameView().frame().settings().fixedBackgroundsPaintRelativeToDocument())
+        return false;
+
</ins><span class="cx">     return supportsFixedRootBackgroundCompositing() &amp;&amp; m_renderView.rootBackgroundIsEntirelyFixed();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>