+2016-06-20 Andreas Kling <akling@apple.com>
+
+ When navigating, discard decoded image data that is only live due to page cache.
+ <https://webkit.org/b/158941>
+
+ Reviewed by Antti Koivisto.
+
+ A resource is "live" if it's currently in use by a web page, and "dead" if it's
+ only kept alive by the memory cache.
+
+ This patch adds a mechanism that looks at CachedImage resources to see if all the
+ clients that make them appear "live" are actually pages in the page cache.
+
+ If so, we let the "jettison expensive objects on top-level navigation" mechanism
+ discard the decoded data for such half-live images. This can reduce the peak
+ memory usage during navigations quite a bit.
+
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::commitProvisionalLoad): Move the call to MemoryPressureHandler
+ before we add the outgoing page to the page cache. This allows the jettisoning code
+ to make decisions based on which pages were cached *before* the navigation.
+
+ * loader/cache/CachedImageClient.h:
+ (WebCore::CachedImageClient::inPageCache):
+ * loader/ImageLoader.h:
+ * loader/ImageLoader.cpp:
+ (WebCore::ImageLoader::inPageCache):
+ * rendering/RenderObject.h:
+ (WebCore::RenderObject::inPageCache): Added a CachedImageClient::inPageCache() virtual
+ to determine which clients are currently in page cache (answered by their Document.)
+
+ * loader/cache/CachedImage.h:
+ * loader/cache/CachedImage.cpp:
+ (WebCore::CachedImage::areAllClientsInPageCache): Walks all CachedImageClient clients
+ and returns true if all of them are inPageCache().
+
+ * platform/MemoryPressureHandler.cpp:
+ (WebCore::MemoryPressureHandler::jettisonExpensiveObjectsOnTopLevelNavigation):
+ Walk all the known CachedImages and nuke decoded data for those that have some but
+ are only considered live due to clients in the page cache.
+
2016-06-20 Chris Dumez <cdumez@apple.com>
Unreviewed, fix post-landing review comment from Darin on r202188.