[chromium] Implement cache eviction logic in ImageDecodingStore
https://bugs.webkit.org/show_bug.cgi?id=103480

Reviewed by James Robinson.

Source/WebCore:

This patch implements these features in the new image cache:
- Least-recently-used eviction logic
- Setting cache limit (default is 32MB)
- Remove cache entries when ImageFrameGenerator is removed

New tests in ImageDecodingTestTest. Also covered by platform/chromium/virtual/deferred.

* platform/graphics/chromium/ImageDecodingStore.cpp:
(WebCore::ImageDecodingStore::ImageDecodingStore):
(WebCore::ImageDecodingStore::~ImageDecodingStore):
Code to assert that everything is cleaned up.
(WebCore::ImageDecodingStore::lockCompleteCache):
(WebCore::ImageDecodingStore::unlockCache):
(WebCore::ImageDecodingStore::insertAndLockCache):
(WebCore::ImageDecodingStore::removeCacheIndexedByGenerator):
New method to remove all cache entries index by ImageFrameGenerator.
(WebCore):
(WebCore::ImageDecodingStore::setCacheLimitInBytes):
(WebCore::ImageDecodingStore::memoryUsageInBytes):
(WebCore::ImageDecodingStore::cacheEntries):
(WebCore::ImageDecodingStore::prune):
New code to implement LRU eviction logic.
(WebCore::ImageDecodingStore::insertCacheInternal):
New method to help new cache insertion. This is separately because it touches 3 containers.
(WebCore::ImageDecodingStore::removeFromCacheInternal):
New method to help remove a cache entry from containers.
(WebCore::ImageDecodingStore::removeFromCacheListInternal):
New helper method to help remove cache entry from doubly linked list.
* platform/graphics/chromium/ImageDecodingStore.h:
(ImageDecodingStore):
(CacheEntry):
(WebCore::ImageDecodingStore::CacheEntry::createAndUse):
(WebCore::ImageDecodingStore::CacheEntry::CacheEntry):
(WebCore::ImageDecodingStore::CacheEntry::~CacheEntry):
(WebCore::ImageDecodingStore::CacheEntry::cacheKey):
(WebCore::ImageDecodingStore::CacheEntry::cachedImage):
(WebCore::ImageDecodingStore::CacheEntry::useCount):
(WebCore::ImageDecodingStore::CacheEntry::incrementUseCount):
(WebCore::ImageDecodingStore::CacheEntry::decrementUseCount):
(WebCore::ImageDecodingStore::CacheEntry::memoryUsageInBytes):
(WebCore::ImageDecodingStore::incrementMemoryUsage):
(WebCore::ImageDecodingStore::decrementMemoryUsage):
New helper methods.
* platform/graphics/chromium/ImageFrameGenerator.cpp:
(WebCore::ImageFrameGenerator::~ImageFrameGenerator):

Source/WebKit/chromium:

Added ImageDecodingStoreTest for unit testing new image cache.

New tests:

ImageDecodingStoreTest.evictOneCache

Test eviction of one cache entry by setting a smaller cache limit.

ImageDecodingStoreTest.pruneOrderIsLeastRecentlyUsed

Test eviction order is least recently used.

ImageDecodingStoreTest.pruneCausedByInsertion

Test that eviction is triggered also by cache insertion.

ImageDecodingStoreTest.cacheInUseNotEvicted

Test that cache in use is not evicted.

ImageDecodingStoreTest.destroyImageFrameGenerator

Test that deleting a ImageFrameGenerator causes associated cache
entries to be removed.

* WebKit.gypi:
* tests/ImageDecodingStoreTest.cpp: Added.
(WebCore):
(ImageDecodingStoreTest):
(WebCore::ImageDecodingStoreTest::SetUp):
(WebCore::ImageDecodingStoreTest::TearDown):
(WebCore::ImageDecodingStoreTest::createCompleteImage):
(WebCore::ImageDecodingStoreTest::insertCache):
(WebCore::ImageDecodingStoreTest::lockCache):
(WebCore::ImageDecodingStoreTest::unlockCache):
(WebCore::ImageDecodingStoreTest::evictOneCache):
(WebCore::ImageDecodingStoreTest::isCacheAlive):
(WebCore::TEST_F):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136616 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Avoid repeated calls to decorationColor on RenderObject::getTextDecorationColors
https://bugs.webkit.org/show_bug.cgi?id=94131

Reviewed by Brent Fulgham.

Replaces repeated calls to decorationColor by adding a variable that reads the
return value from that function just once on each loop and gets used upon need.

This change won't affect text decoration behavior, so current tests suffice.

* rendering/RenderObject.cpp:
(WebCore::RenderObject::getTextDecorationColors):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136617 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed, WebKit gardening. A rebaseline.

* platform/chromium/media/track/opera/interfaces/TextTrack/addCue-expected.txt: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136618 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Crash in WebCore::ApplyStyleCommand::pushDownInlineStyleAroundNode
https://bugs.webkit.org/show_bug.cgi?id=103515

Reviewed by Ryosuke Niwa.

|current| is weak node pointer that iterates in the hierarchy chain
between |highestAncestor| and |targetNode|. Script executed as part
of iframe onload event can blow away the nodes and we no longer have
|targetNode| in our descendants chain. So, we RefPtr |current| and bail
out when |targetNode| stops being a part of descendant chain.

Test blocked on https://bugs.webkit.org/show_bug.cgi?id=104044.

* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::pushDownInlineStyleAroundNode):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136619 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Remove #ifs that are always true
https://bugs.webkit.org/show_bug.cgi?id=104080

Reviewed by Andreas Kling.

__MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 is always true, so remove all the #ifs.

* PluginProcess/mac/PluginProcessMac.mm:
(WebKit::initializeSandbox):
(WebKit::PluginProcess::platformInitialize):
* Shared/DictionaryPopupInfo.cpp:
(WebKit::DictionaryPopupInfo::encode):
(WebKit::DictionaryPopupInfo::decode):
* Shared/DictionaryPopupInfo.h:
* Shared/mac/WebEventFactory.mm:
(WebKit::phaseForEvent):
(WebKit::momentumPhaseForEvent):
* SharedWorkerProcess/mac/SharedWorkerProcessMac.mm:
(WebKit::initializeSandbox):
(WebKit::SharedWorkerProcess::platformInitialize):
* UIProcess/API/mac/PDFViewController.mm:
(WebKit::PDFViewScrollView_scrollWheel):
(WebKit::PDFViewController::pdfKitBundle):
* UIProcess/API/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::didPerformDictionaryLookup):
(WebKit::PageClientImpl::dismissDictionaryLookupPanel):
(WebKit::PageClientImpl::recordAutocorrectionResponse):
(WebKit::PageClientImpl::recommendedScrollbarStyleDidChange):
* UIProcess/API/mac/WKView.mm:
(-[WKView displayIfNeeded]):
(-[WKView draggingUpdated:]):
(-[WKView viewDidMoveToWindow]):
(-[WKView _intrinsicDeviceScaleFactor]):
(-[WKView _cacheWindowBottomCornerRect]):
(-[WKView initWithFrame:contextRef:pageGroupRef:relatedToPage:]):
(+[WKView hideWordDefinitionWindow]):
* UIProcess/Launcher/mac/EnvironmentVariables.cpp:
* UIProcess/Launcher/mac/EnvironmentVariables.h:
(EnvironmentVariables):
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::addDYLDEnvironmentAdditions):
(WebKit::createWebProcessServiceForWebKitDevelopment):
(WebKit):
(WebKit::tryPreexistingProcess):
(WebKit::createProcess):
(WebKit::ProcessLauncher::launchProcess):
* UIProcess/Plugins/mac/PluginInfoStoreMac.mm:
(WebKit::PluginInfoStore::shouldUsePlugin):
(WebKit::PluginInfoStore::reactivateInactivePlugin):
* UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
(WebKit::PluginProcessProxy::platformInitializePluginProcess):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didCommitLoadForFrame):
(WebKit::WebPageProxy::pageDidScroll):
(WebKit::WebPageProxy::processDidCrash):
(WebKit::WebPageProxy::recordAutocorrectionResponse):
(WebKit::WebPageProxy::handleAlternativeTextUIResult):
* UIProcess/WebPageProxy.h:
(WebPageProxy):
* UIProcess/WebPageProxy.messages.in:
* UIProcess/mac/TextCheckerMac.mm:
(WebKit::initializeState):
(WebKit::TextChecker::getGuessesForWord):
* UIProcess/mac/WKFullScreenWindowController.mm:
(convertRectToScreen):
* UIProcess/mac/WebContextMac.mm:
(WebKit::WebContext::platformInitializeWebProcess):
* WebKit2Prefix.h:
* WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
(WebKit::NPN_GetValue):
* WebProcess/Plugins/Netscape/mac/NetscapeSandboxFunctions.mm:
* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::shouldEraseMarkersAfterChangeSelection):
* WebProcess/WebCoreSupport/WebEditorClient.h:
* WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
(InitWebCoreSystemInterface):
* WebProcess/WebPage/WebPage.cpp:
(WebKit):
* WebProcess/WebPage/WebPage.h:
(WebPage):
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::performDictionaryLookupAtLocation):
(WebKit::WebPage::performDictionaryLookupForSelection):
(WebKit::WebPage::performDictionaryLookupForRange):
* WebProcess/mac/SecItemShimMethods.mm:
* WebProcess/mac/WebProcessMac.mm:
(WebKit::WebProcess::secItemResponse):
* WebProcess/mac/WebProcessMainMac.mm:
(WebKit::WebProcessMain):
* WebProcessService/WebProcessServiceMain.mm:
(main):
* WebProcessServiceForWebKitDevelopment/WebProcessServiceForWebKitDevelopmentMain.mm:
(WebProcessServiceForWebKitDevelopmentEventHandler):
(main):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136620 268f45cc-cd09-0410-ab3c-d52691b4dbfc