- Revision
- 168726
- Author
- [email protected]
- Date
- 2014-05-13 12:32:37 -0700 (Tue, 13 May 2014)
Log Message
[iOS WK2] background-attachment:fixed behaves very poorly
https://bugs.webkit.org/show_bug.cgi?id=132881
<rdar://problem/16789526>
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:
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (168725 => 168726)
--- 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)
@@ -1,3 +1,16 @@
+2014-05-13 Simon Fraser <[email protected]>
+
+ [iOS WK2] background-attachment:fixed behaves very poorly
+ https://bugs.webkit.org/show_bug.cgi?id=132881
+ <rdar://problem/16789526>
+
+ Reviewed by Beth Dakin.
+
+ Remove ENABLE_FAST_MOBILE_SCROLLING. Ports can use the fixedBackgroundsPaintRelativeToDocument
+ setting now.
+
+ * wtf/FeatureDefines.h:
+
2014-05-08 Alexey Proskuryakov <[email protected]>
Automatically zip document bundles used via File API
Modified: trunk/Source/WTF/wtf/FeatureDefines.h (168725 => 168726)
--- 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)
@@ -452,10 +452,6 @@
#define ENABLE_ENCRYPTED_MEDIA_V2 0
#endif
-#if !defined(ENABLE_FAST_MOBILE_SCROLLING)
-#define ENABLE_FAST_MOBILE_SCROLLING 0
-#endif
-
#if !defined(ENABLE_FILTERS)
#define ENABLE_FILTERS 0
#endif
Modified: trunk/Source/WebCore/ChangeLog (168725 => 168726)
--- 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)
@@ -1,3 +1,28 @@
+2014-05-13 Simon Fraser <[email protected]>
+
+ [iOS WK2] background-attachment:fixed behaves very poorly
+ https://bugs.webkit.org/show_bug.cgi?id=132881
+ <rdar://problem/16789526>
+
+ 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):
+
2014-05-13 Zalan Bujtas <[email protected]>
REGRESSSION(r168528) Subpixel rendering: Selection rect is not positioned properly when SVG text is selected.
Modified: trunk/Source/WebCore/page/Settings.cpp (168725 => 168726)
--- 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)
@@ -122,12 +122,14 @@
#if PLATFORM(IOS)
static const bool defaultFixedPositionCreatesStackingContext = true;
+static const bool defaultFixedBackgroundsPaintRelativeToDocument = true;
static const bool defaultAcceleratedCompositingForFixedPositionEnabled = true;
static const bool defaultMediaPlaybackAllowsInline = false;
static const bool defaultMediaPlaybackRequiresUserGesture = true;
static const bool defaultShouldRespectImageOrientation = true;
#else
static const bool defaultFixedPositionCreatesStackingContext = false;
+static const bool defaultFixedBackgroundsPaintRelativeToDocument = false;
static const bool defaultAcceleratedCompositingForFixedPositionEnabled = false;
static const bool defaultMediaPlaybackAllowsInline = true;
static const bool defaultMediaPlaybackRequiresUserGesture = false;
Modified: trunk/Source/WebCore/page/Settings.in (168725 => 168726)
--- 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)
@@ -187,6 +187,7 @@
selectionIncludesAltImageText initial=true
useLegacyBackgroundSizeShorthandBehavior initial=false
+fixedBackgroundsPaintRelativeToDocument initial=defaultFixedBackgroundsPaintRelativeToDocument
minimumZoomFontSize type=float, initial=15, conditional=IOS_TEXT_AUTOSIZING
Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (168725 => 168726)
--- 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)
@@ -1082,17 +1082,6 @@
// destRect will be adjusted later if the background is non-repeating.
// FIXME: transforms spec says that fixed backgrounds behave like scroll inside transforms. https://bugs.webkit.org/show_bug.cgi?id=15679
bool fixedAttachment = fillLayer->attachment() == FixedBackgroundAttachment;
-
-#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 "background-attachment: fixed" 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
-
if (!fixedAttachment) {
geometry.setDestRect(paintRect);
@@ -1127,12 +1116,17 @@
} else {
geometry.setHasNonLocalGeometry();
- LayoutRect viewportRect = view().viewRect();
- if (fixedBackgroundPaintsInLocalCoordinates())
- viewportRect.setLocation(LayoutPoint());
- else
- viewportRect.setLocation(toLayoutPoint(view().frameView().scrollOffsetForFixedPosition()));
-
+ 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()));
+ }
+
if (paintContainer)
viewportRect.moveBy(LayoutPoint(-paintContainer->localToAbsolute(FloatPoint())));
Modified: trunk/Source/WebCore/rendering/RenderElement.cpp (168725 => 168726)
--- 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)
@@ -57,6 +57,7 @@
#include "RenderTheme.h"
#include "RenderView.h"
#include "SVGRenderSupport.h"
+#include "Settings.h"
#include "StyleResolver.h"
#include <wtf/MathExtras.h>
#include <wtf/StackStats.h>
@@ -793,19 +794,6 @@
}
}
-// 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 "background-attachment: fixed".
-static bool shouldRepaintFixedBackgroundsOnScroll()
-{
-#if ENABLE(FAST_MOBILE_SCROLLING)
- return false;
-#else
- return true;
-#endif
-}
-
static inline bool rendererHasBackground(const RenderElement* renderer)
{
return renderer && renderer->hasBackground();
@@ -879,27 +867,31 @@
s_noLongerAffectsParentBlock = false;
}
- bool repaintFixedBackgroundsOnScroll = shouldRepaintFixedBackgroundsOnScroll();
+ bool newStyleUsesFixedBackgrounds = newStyle.hasFixedBackgroundImage();
+ bool oldStyleUsesFixedBackgrounds = m_style->hasFixedBackgroundImage();
+ if (newStyleUsesFixedBackgrounds || oldStyleUsesFixedBackgrounds) {
+ bool repaintFixedBackgroundsOnScroll = !frame().settings().fixedBackgroundsPaintRelativeToDocument();
- bool newStyleSlowScroll = repaintFixedBackgroundsOnScroll && newStyle.hasFixedBackgroundImage();
- bool oldStyleSlowScroll = oldStyle && repaintFixedBackgroundsOnScroll && m_style->hasFixedBackgroundImage();
- bool drawsRootBackground = isRoot() || (isBody() && !rendererHasBackground(document().documentElement()->renderer()));
- if (drawsRootBackground && repaintFixedBackgroundsOnScroll) {
- if (view().compositor().supportsFixedRootBackgroundCompositing()) {
- if (newStyleSlowScroll && newStyle.hasEntirelyFixedBackground())
- newStyleSlowScroll = false;
+ bool newStyleSlowScroll = repaintFixedBackgroundsOnScroll && newStyleUsesFixedBackgrounds;
+ bool oldStyleSlowScroll = oldStyle && repaintFixedBackgroundsOnScroll && oldStyleUsesFixedBackgrounds;
+ bool drawsRootBackground = isRoot() || (isBody() && !rendererHasBackground(document().documentElement()->renderer()));
+ if (drawsRootBackground && repaintFixedBackgroundsOnScroll) {
+ if (view().compositor().supportsFixedRootBackgroundCompositing()) {
+ if (newStyleSlowScroll && newStyle.hasEntirelyFixedBackground())
+ newStyleSlowScroll = false;
- if (oldStyleSlowScroll && m_style->hasEntirelyFixedBackground())
- oldStyleSlowScroll = false;
+ if (oldStyleSlowScroll && m_style->hasEntirelyFixedBackground())
+ oldStyleSlowScroll = false;
+ }
}
- }
- if (oldStyleSlowScroll != newStyleSlowScroll) {
- if (oldStyleSlowScroll)
- view().frameView().removeSlowRepaintObject(this);
+ if (oldStyleSlowScroll != newStyleSlowScroll) {
+ if (oldStyleSlowScroll)
+ view().frameView().removeSlowRepaintObject(this);
- if (newStyleSlowScroll)
- view().frameView().addSlowRepaintObject(this);
+ if (newStyleSlowScroll)
+ view().frameView().addSlowRepaintObject(this);
+ }
}
if (isRoot() || isBody())
@@ -1002,8 +994,7 @@
removeLayers(layer);
}
- bool repaintFixedBackgroundsOnScroll = shouldRepaintFixedBackgroundsOnScroll();
- if (repaintFixedBackgroundsOnScroll && m_style->hasFixedBackgroundImage())
+ if (m_style->hasFixedBackgroundImage() && !frame().settings().fixedBackgroundsPaintRelativeToDocument())
view().frameView().removeSlowRepaintObject(this);
if (isOutOfFlowPositioned() && parent()->childrenInline())
Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (168725 => 168726)
--- 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)
@@ -2720,6 +2720,9 @@
if (&layer != m_renderView.layer())
return false;
+ if (m_renderView.frameView().frame().settings().fixedBackgroundsPaintRelativeToDocument())
+ return false;
+
return supportsFixedRootBackgroundCompositing() && m_renderView.rootBackgroundIsEntirelyFixed();
}