Diff
Modified: trunk/LayoutTests/ChangeLog (211909 => 211910)
--- trunk/LayoutTests/ChangeLog 2017-02-09 00:26:25 UTC (rev 211909)
+++ trunk/LayoutTests/ChangeLog 2017-02-09 00:56:42 UTC (rev 211910)
@@ -1,5 +1,20 @@
2017-02-08 Chris Dumez <cdu...@apple.com>
+ Use smaller tiles in windows that are not active to facilitate App Napping
+ https://bugs.webkit.org/show_bug.cgi?id=167997
+ <rdar://problem/30358835>
+
+ Reviewed by Simon Fraser.
+
+ Add layout test coverage.
+
+ * compositing/tiling/non-active-window-tiles-size-expected.txt: Added.
+ * compositing/tiling/non-active-window-tiles-size.html: Added.
+ * platform/ios-simulator-wk2/compositing/tiling/non-active-window-tiles-size-expected.txt: Added.
+ * platform/mac-wk1/compositing/tiling/non-active-window-tiles-size-expected.txt: Added.
+
+2017-02-08 Chris Dumez <cdu...@apple.com>
+
Unreviewed, rolling out r211907.
Broke the build
Added: trunk/LayoutTests/compositing/tiling/non-active-window-tiles-size-expected.txt (0 => 211910)
--- trunk/LayoutTests/compositing/tiling/non-active-window-tiles-size-expected.txt (rev 0)
+++ trunk/LayoutTests/compositing/tiling/non-active-window-tiles-size-expected.txt 2017-02-09 00:56:42 UTC (rev 211910)
@@ -0,0 +1,49 @@
+Tiles when window is active:
+
+(GraphicsLayer
+ (anchor 0.00 0.00)
+ (bounds 800.00 600.00)
+ (visible rect 0.00, 0.00 800.00 x 600.00)
+ (coverage rect 0.00, 0.00 800.00 x 600.00)
+ (intersects coverage rect 1)
+ (contentsScale 1.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 800.00 600.00)
+ (contentsOpaque 1)
+ (visible rect 0.00, 0.00 800.00 x 600.00)
+ (coverage rect 0.00, 0.00 800.00 x 600.00)
+ (intersects coverage rect 1)
+ (contentsScale 1.00)
+ (tile cache coverage 0, 0 800 x 600)
+ (tile size 800 x 600)
+ (top left tile 0, 0 tiles grid 1 x 1)
+ (in window 1)
+ )
+ )
+)
+Tiles when window is not active:
+
+(GraphicsLayer
+ (anchor 0.00 0.00)
+ (bounds 800.00 600.00)
+ (visible rect 0.00, 0.00 800.00 x 600.00)
+ (coverage rect 0.00, 0.00 800.00 x 600.00)
+ (intersects coverage rect 1)
+ (contentsScale 1.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 800.00 600.00)
+ (contentsOpaque 1)
+ (visible rect 0.00, 0.00 800.00 x 600.00)
+ (coverage rect 0.00, 0.00 800.00 x 600.00)
+ (intersects coverage rect 1)
+ (contentsScale 1.00)
+ (tile cache coverage 0, 0 800 x 600)
+ (tile size 512 x 512)
+ (top left tile 0, 0 tiles grid 2 x 2)
+ (in window 1)
+ )
+ )
+)
+
Added: trunk/LayoutTests/compositing/tiling/non-active-window-tiles-size.html (0 => 211910)
--- trunk/LayoutTests/compositing/tiling/non-active-window-tiles-size.html (rev 0)
+++ trunk/LayoutTests/compositing/tiling/non-active-window-tiles-size.html 2017-02-09 00:56:42 UTC (rev 211910)
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>Tiles when window is active:</p>
+<pre id="activeResult"></pre>
+<p>Tiles when window is not active:</p>
+<pre id="nonActiveResult"></pre>
+<script>
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+}
+
+if (window.internals)
+ internals.disableTileSizeUpdateDelay();
+
+_onload_ = function() {
+ document.getElementById("activeResult").innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS | internals.LAYER_TREE_INCLUDES_TILE_CACHES);
+ if (window.testRunner)
+ testRunner.setWindowIsKey(false);
+
+ setTimeout(function() {
+ document.getElementById("nonActiveResult").innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS | internals.LAYER_TREE_INCLUDES_TILE_CACHES);
+
+ if (window.testRunner)
+ testRunner.notifyDone();
+ }, 0);
+}
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/non-active-window-tiles-size-expected.txt (0 => 211910)
--- trunk/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/non-active-window-tiles-size-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/non-active-window-tiles-size-expected.txt 2017-02-09 00:56:42 UTC (rev 211910)
@@ -0,0 +1,49 @@
+Tiles when window is active:
+
+(GraphicsLayer
+ (anchor 0.00 0.00)
+ (bounds 800.00 600.00)
+ (visible rect 0.00, 0.00 800.00 x 600.00)
+ (coverage rect 0.00, 0.00 800.00 x 600.00)
+ (intersects coverage rect 1)
+ (contentsScale 2.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 800.00 600.00)
+ (contentsOpaque 1)
+ (visible rect 0.00, 0.00 800.00 x 600.00)
+ (coverage rect 0.00, 0.00 800.00 x 600.00)
+ (intersects coverage rect 1)
+ (contentsScale 2.00)
+ (tile cache coverage 0, 0 800 x 600)
+ (tile size 800 x 600)
+ (top left tile 0, 0 tiles grid 1 x 1)
+ (in window 1)
+ )
+ )
+)
+Tiles when window is not active:
+
+(GraphicsLayer
+ (anchor 0.00 0.00)
+ (bounds 800.00 600.00)
+ (visible rect 0.00, 0.00 800.00 x 600.00)
+ (coverage rect 0.00, 0.00 800.00 x 600.00)
+ (intersects coverage rect 1)
+ (contentsScale 2.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 800.00 600.00)
+ (contentsOpaque 1)
+ (visible rect 0.00, 0.00 800.00 x 600.00)
+ (coverage rect 0.00, 0.00 800.00 x 600.00)
+ (intersects coverage rect 1)
+ (contentsScale 2.00)
+ (tile cache coverage 0, 0 800 x 600)
+ (tile size 800 x 600)
+ (top left tile 0, 0 tiles grid 1 x 1)
+ (in window 1)
+ )
+ )
+)
+
Added: trunk/LayoutTests/platform/mac-wk1/compositing/tiling/non-active-window-tiles-size-expected.txt (0 => 211910)
--- trunk/LayoutTests/platform/mac-wk1/compositing/tiling/non-active-window-tiles-size-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/mac-wk1/compositing/tiling/non-active-window-tiles-size-expected.txt 2017-02-09 00:56:42 UTC (rev 211910)
@@ -0,0 +1,5 @@
+Tiles when window is active:
+
+Tiles when window is not active:
+
+
Modified: trunk/Source/WebCore/ChangeLog (211909 => 211910)
--- trunk/Source/WebCore/ChangeLog 2017-02-09 00:26:25 UTC (rev 211909)
+++ trunk/Source/WebCore/ChangeLog 2017-02-09 00:56:42 UTC (rev 211910)
@@ -1,5 +1,41 @@
2017-02-08 Chris Dumez <cdu...@apple.com>
+ Use smaller tiles in windows that are not active to facilitate App Napping
+ https://bugs.webkit.org/show_bug.cgi?id=167997
+ <rdar://problem/30358835>
+
+ Reviewed by Simon Fraser.
+
+ Use smaller / non-adaptative tiles in windows that are not active to facilitate
+ App Napping after <https://trac.webkit.org/r197594>.
+
+ Test: compositing/tiling/non-active-window-tiles-size.html
+
+ * page/FrameView.cpp:
+ (WebCore::FrameView::contentsResized):
+ (WebCore::FrameView::addedOrRemovedScrollbar):
+ (WebCore::FrameView::computeScrollability):
+ (WebCore::FrameView::updateTiledBackingAdaptiveSizing):
+ (WebCore::FrameView::unobscuredContentSizeChanged):
+ (WebCore::FrameView::setViewExposedRect):
+ * page/FrameView.h:
+ * page/Page.cpp:
+ (WebCore::Page::setActivityState):
+ (WebCore::Page::isWindowActive):
+ * page/Page.h:
+ * platform/graphics/TiledBacking.h:
+ * platform/graphics/ca/TileController.cpp:
+ (WebCore::TileController::setTileSizeUpdateDelayDisabledForTesting):
+ (WebCore::TileController::notePendingTileSizeChange):
+ * platform/graphics/ca/TileController.h:
+ * testing/Internals.cpp:
+ (WebCore::Internals::resetToConsistentState):
+ (WebCore::Internals::disableTileSizeUpdateDelay):
+ * testing/Internals.h:
+ * testing/Internals.idl:
+
+2017-02-08 Chris Dumez <cdu...@apple.com>
+
Unreviewed, rolling out r211907.
Broke the build
Modified: trunk/Source/WebCore/page/FrameView.cpp (211909 => 211910)
--- trunk/Source/WebCore/page/FrameView.cpp 2017-02-09 00:26:25 UTC (rev 211909)
+++ trunk/Source/WebCore/page/FrameView.cpp 2017-02-09 00:56:42 UTC (rev 211910)
@@ -2437,9 +2437,9 @@
void FrameView::contentsResized()
{
- // For non-delegated scrolling, adjustTiledBackingScrollability() is called via addedOrRemovedScrollbar() which occurs less often.
+ // For non-delegated scrolling, updateTiledBackingAdaptiveSizing() is called via addedOrRemovedScrollbar() which occurs less often.
if (delegatesScrolling())
- adjustTiledBackingScrollability();
+ updateTiledBackingAdaptiveSizing();
}
void FrameView::delegatesScrollingDidChange()
@@ -2780,21 +2780,23 @@
renderView->compositor().frameViewDidAddOrRemoveScrollbars();
}
- adjustTiledBackingScrollability();
+ updateTiledBackingAdaptiveSizing();
}
-void FrameView::adjustTiledBackingScrollability()
+TiledBacking::Scrollability FrameView::computeScrollability() const
{
- auto* tiledBacking = this->tiledBacking();
- if (!tiledBacking)
- return;
-
+ auto* page = frame().page();
+
+ // Use smaller square tiles if the Window is not active to facilitate app napping.
+ if (!page || !page->isWindowActive())
+ return TiledBacking::HorizontallyScrollable | TiledBacking::VerticallyScrollable;
+
bool horizontallyScrollable;
bool verticallyScrollable;
bool clippedByAncestorView = static_cast<bool>(m_viewExposedRect);
#if PLATFORM(IOS)
- if (Page* page = frame().page())
+ if (page)
clippedByAncestorView |= page->enclosedInScrollableAncestorView();
#endif
@@ -2801,7 +2803,7 @@
if (delegatesScrolling()) {
IntSize documentSize = contentsSize();
IntSize visibleSize = this->visibleSize();
-
+
horizontallyScrollable = clippedByAncestorView || documentSize.width() > visibleSize.width();
verticallyScrollable = clippedByAncestorView || documentSize.height() > visibleSize.height();
} else {
@@ -2816,14 +2818,23 @@
if (verticallyScrollable)
scrollability |= TiledBacking::VerticallyScrollable;
- tiledBacking->setScrollability(scrollability);
+ return scrollability;
}
+void FrameView::updateTiledBackingAdaptiveSizing()
+{
+ auto* tiledBacking = this->tiledBacking();
+ if (!tiledBacking)
+ return;
+
+ tiledBacking->setScrollability(computeScrollability());
+}
+
#if PLATFORM(IOS)
void FrameView::unobscuredContentSizeChanged()
{
- adjustTiledBackingScrollability();
+ updateTiledBackingAdaptiveSizing();
}
#endif
@@ -5244,7 +5255,7 @@
if (TiledBacking* tiledBacking = this->tiledBacking()) {
if (hasRectChanged)
- adjustTiledBackingScrollability();
+ updateTiledBackingAdaptiveSizing();
adjustTiledBackingCoverage();
tiledBacking->setTiledScrollingIndicatorPosition(m_viewExposedRect ? m_viewExposedRect.value().location() : FloatPoint());
}
Modified: trunk/Source/WebCore/page/FrameView.h (211909 => 211910)
--- trunk/Source/WebCore/page/FrameView.h 2017-02-09 00:26:25 UTC (rev 211909)
+++ trunk/Source/WebCore/page/FrameView.h 2017-02-09 00:56:42 UTC (rev 211910)
@@ -33,6 +33,7 @@
#include "PaintPhase.h"
#include "RenderPtr.h"
#include "ScrollView.h"
+#include "TiledBacking.h"
#include <memory>
#include <wtf/Forward.h>
#include <wtf/Function.h>
@@ -534,7 +535,8 @@
WEBCORE_EXPORT void availableContentSizeChanged(AvailableSizeChangeReason) final;
- void adjustTiledBackingScrollability();
+ void updateTiledBackingAdaptiveSizing();
+ TiledBacking::Scrollability computeScrollability() const;
void addPaintPendingMilestones(LayoutMilestones);
void firePaintRelatedMilestonesIfNeeded();
Modified: trunk/Source/WebCore/page/Page.cpp (211909 => 211910)
--- trunk/Source/WebCore/page/Page.cpp 2017-02-09 00:26:25 UTC (rev 211909)
+++ trunk/Source/WebCore/page/Page.cpp 2017-02-09 00:56:42 UTC (rev 211910)
@@ -1505,6 +1505,10 @@
setIsInWindowInternal(activityState & ActivityState::IsInWindow);
if (changed & ActivityState::IsVisuallyIdle)
setIsVisuallyIdleInternal(activityState & ActivityState::IsVisuallyIdle);
+ if (changed & ActivityState::WindowIsActive) {
+ if (auto* view = m_mainFrame->view())
+ view->updateTiledBackingAdaptiveSizing();
+ }
if (changed & (ActivityState::IsVisible | ActivityState::IsVisuallyIdle | ActivityState::IsAudible | ActivityState::IsLoading))
updateTimerThrottlingState();
@@ -1524,6 +1528,11 @@
return (m_activityState & ActivityState::IsVisible) && (m_activityState & ActivityState::WindowIsActive);
}
+bool Page::isWindowActive() const
+{
+ return m_activityState & ActivityState::WindowIsActive;
+}
+
void Page::setIsVisible(bool isVisible)
{
if (isVisible)
Modified: trunk/Source/WebCore/page/Page.h (211909 => 211910)
--- trunk/Source/WebCore/page/Page.h 2017-02-09 00:26:25 UTC (rev 211909)
+++ trunk/Source/WebCore/page/Page.h 2017-02-09 00:56:42 UTC (rev 211910)
@@ -362,6 +362,7 @@
WEBCORE_EXPORT void setActivityState(ActivityState::Flags);
ActivityState::Flags activityState() const { return m_activityState; }
+ bool isWindowActive() const;
bool isVisibleAndActive() const;
WEBCORE_EXPORT void setIsVisible(bool);
WEBCORE_EXPORT void setIsPrerender();
Modified: trunk/Source/WebCore/platform/graphics/TiledBacking.h (211909 => 211910)
--- trunk/Source/WebCore/platform/graphics/TiledBacking.h 2017-02-09 00:26:25 UTC (rev 211909)
+++ trunk/Source/WebCore/platform/graphics/TiledBacking.h 2017-02-09 00:56:42 UTC (rev 211910)
@@ -85,6 +85,8 @@
virtual void setTopContentInset(float) = 0;
virtual void setVelocity(const VelocityData&) = 0;
+
+ virtual void setTileSizeUpdateDelayDisabledForTesting(bool) = 0;
enum {
NotScrollable = 0,
Modified: trunk/Source/WebCore/platform/graphics/ca/TileController.cpp (211909 => 211910)
--- trunk/Source/WebCore/platform/graphics/ca/TileController.cpp 2017-02-09 00:26:25 UTC (rev 211909)
+++ trunk/Source/WebCore/platform/graphics/ca/TileController.cpp 2017-02-09 00:56:42 UTC (rev 211910)
@@ -309,6 +309,11 @@
tileGrid().updateTileLayerProperties();
}
+void TileController::setTileSizeUpdateDelayDisabledForTesting(bool value)
+{
+ m_isTileSizeUpdateDelayDisabledForTesting = value;
+}
+
IntRect TileController::boundsForSize(const FloatSize& size) const
{
IntPoint boundsOriginIncludingMargin(-leftMarginWidth(), -topMarginHeight());
@@ -487,7 +492,10 @@
void TileController::notePendingTileSizeChange()
{
- m_tileSizeChangeTimer.restart();
+ if (m_isTileSizeUpdateDelayDisabledForTesting)
+ tileSizeChangeTimerFired();
+ else
+ m_tileSizeChangeTimer.restart();
}
void TileController::tileSizeChangeTimerFired()
Modified: trunk/Source/WebCore/platform/graphics/ca/TileController.h (211909 => 211910)
--- trunk/Source/WebCore/platform/graphics/ca/TileController.h 2017-02-09 00:26:25 UTC (rev 211909)
+++ trunk/Source/WebCore/platform/graphics/ca/TileController.h 2017-02-09 00:56:42 UTC (rev 211910)
@@ -84,6 +84,8 @@
FloatRect coverageRect() const override { return m_coverageRect; }
std::optional<FloatRect> layoutViewportRect() const { return m_layoutViewportRect; }
+ void setTileSizeUpdateDelayDisabledForTesting(bool) final;
+
unsigned blankPixelCount() const;
static unsigned blankPixelCountForTiles(const PlatformLayerList&, const FloatRect&, const IntPoint&);
@@ -219,6 +221,7 @@
bool m_hasTilesWithTemporaryScaleFactor { false }; // Used to make low-res tiles when zooming.
bool m_inLiveResize { false };
mutable bool m_tileSizeLocked { false };
+ bool m_isTileSizeUpdateDelayDisabledForTesting { false };
Color m_tileDebugBorderColor;
float m_tileDebugBorderWidth { 0 };
Modified: trunk/Source/WebCore/testing/Internals.cpp (211909 => 211910)
--- trunk/Source/WebCore/testing/Internals.cpp 2017-02-09 00:26:25 UTC (rev 211909)
+++ trunk/Source/WebCore/testing/Internals.cpp 2017-02-09 00:56:42 UTC (rev 211910)
@@ -394,6 +394,8 @@
#if USE(COORDINATED_GRAPHICS)
mainFrameView->setFixedVisibleContentRect(IntRect());
#endif
+ if (auto* backing = mainFrameView->tiledBacking())
+ backing->setTileSizeUpdateDelayDisabledForTesting(false);
}
WebCore::clearDefaultPortForProtocolMapForTesting();
@@ -722,6 +724,20 @@
return PageCache::singleton().pageCount();
}
+void Internals::disableTileSizeUpdateDelay()
+{
+ Document* document = contextDocument();
+ if (!document || !document->frame())
+ return;
+
+ auto* view = document->frame()->view();
+ if (!view)
+ return;
+
+ if (auto* backing = view->tiledBacking())
+ backing->setTileSizeUpdateDelayDisabledForTesting(true);
+}
+
Node* Internals::treeScopeRootNode(Node& node)
{
return &node.treeScope().rootNode();
Modified: trunk/Source/WebCore/testing/Internals.h (211909 => 211910)
--- trunk/Source/WebCore/testing/Internals.h 2017-02-09 00:26:25 UTC (rev 211909)
+++ trunk/Source/WebCore/testing/Internals.h 2017-02-09 00:56:42 UTC (rev 211910)
@@ -111,6 +111,8 @@
void clearPageCache();
unsigned pageCacheSize() const;
+ void disableTileSizeUpdateDelay();
+
Ref<CSSComputedStyleDeclaration> computedStyleIncludingVisitedInfo(Element&) const;
Node* ensureUserAgentShadowRoot(Element& host);
Modified: trunk/Source/WebCore/testing/Internals.idl (211909 => 211910)
--- trunk/Source/WebCore/testing/Internals.idl 2017-02-09 00:26:25 UTC (rev 211909)
+++ trunk/Source/WebCore/testing/Internals.idl 2017-02-09 00:56:42 UTC (rev 211910)
@@ -501,4 +501,6 @@
#endif
[CallWith=Document] void setAsRunningUserScripts();
+
+ void disableTileSizeUpdateDelay();
};
Modified: trunk/Tools/ChangeLog (211909 => 211910)
--- trunk/Tools/ChangeLog 2017-02-09 00:26:25 UTC (rev 211909)
+++ trunk/Tools/ChangeLog 2017-02-09 00:56:42 UTC (rev 211910)
@@ -1,3 +1,16 @@
+2017-02-08 Chris Dumez <cdu...@apple.com>
+
+ Use smaller tiles in windows that are not active to facilitate App Napping
+ https://bugs.webkit.org/show_bug.cgi?id=167997
+ <rdar://problem/30358835>
+
+ Reviewed by Simon Fraser.
+
+ * WebKitTestRunner/mac/PlatformWebViewMac.mm:
+ (WTR::PlatformWebView::setWindowIsKey):
+ Actually update windowIsKey state of NSWindow so the WebView
+ properly updates its activity state.
+
2017-02-08 Wenson Hsieh <wenson_hs...@apple.com>
Add kUTTypeUTF8PlainText and kUTTypeJPEG to the list of compatible content types in DragData
Modified: trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm (211909 => 211910)
--- trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm 2017-02-09 00:26:25 UTC (rev 211909)
+++ trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm 2017-02-09 00:56:42 UTC (rev 211910)
@@ -162,6 +162,10 @@
void PlatformWebView::setWindowIsKey(bool isKey)
{
m_windowIsKey = isKey;
+ if (m_windowIsKey)
+ [m_window makeKeyWindow];
+ else
+ [m_window resignKeyWindow];
}
void PlatformWebView::resizeTo(unsigned width, unsigned height, WebViewSizingMode sizingMode)