Diff
Modified: trunk/Source/WebCore/ChangeLog (148033 => 148034)
--- trunk/Source/WebCore/ChangeLog 2013-04-09 18:53:19 UTC (rev 148033)
+++ trunk/Source/WebCore/ChangeLog 2013-04-09 19:04:33 UTC (rev 148034)
@@ -1,3 +1,36 @@
+2013-04-09 Tim Horton <[email protected]>
+
+ [wk2] IconDatabase images should be decoded in the WebProcess
+ https://bugs.webkit.org/show_bug.cgi?id=112524
+ <rdar://problem/10133914>
+
+ Reviewed by Oliver Hunt.
+
+ No testable behavior change.
+
+ * loader/icon/IconDatabase.cpp:
+ (WebCore::IconDatabase::updateIconRecord):
+ Added updateIconRecord, which factors most of setIconDataForIconURL out so it can
+ be shared with setIconBitmapForIconURL. This function will set either a bitmap or
+ raw image data for the given icon URL.
+
+ (WebCore::IconDatabase::setIconBitmapForIconURL):
+ Added; make a copy of the bitmap for thread-safety purposes, and call updateIconRecord.
+
+ (WebCore::IconDatabase::setIconDataForIconURL):
+ Factored out of what is now updateIconRecord.
+
+ * loader/icon/IconDatabase.h:
+ (IconDatabase): Add setIconBitmapForIconURL and updateIconRecord.
+
+ * loader/icon/IconDatabaseBase.h:
+ (WebCore::IconDatabaseBase::setIconBitmapForIconURL): Added.
+ * loader/icon/IconRecord.cpp:
+ (WebCore::IconRecord::setImage): Set the image for an icon record directly (as opposed
+ to setting the image data, which causes the image to be decoded in the WebProcess).
+ * loader/icon/IconRecord.h:
+ (IconRecord): Add setImage.
+
2013-04-09 Chris Fleizach <[email protected]>
AX: The bounding paths should be made available through accessibility
Modified: trunk/Source/WebCore/loader/icon/IconDatabase.cpp (148033 => 148034)
--- trunk/Source/WebCore/loader/icon/IconDatabase.cpp 2013-04-09 18:53:19 UTC (rev 148033)
+++ trunk/Source/WebCore/loader/icon/IconDatabase.cpp 2013-04-09 19:04:33 UTC (rev 148034)
@@ -29,11 +29,13 @@
#if ENABLE(ICONDATABASE)
+#include "BitmapImage.h"
#include "DocumentLoader.h"
#include "FileSystem.h"
#include "IconDatabaseClient.h"
#include "IconRecord.h"
#include "Image.h"
+#include "ImageBuffer.h"
#include "IntSize.h"
#include "Logging.h"
#include "SQLiteStatement.h"
@@ -533,24 +535,15 @@
delete pageRecord;
}
-void IconDatabase::setIconDataForIconURL(PassRefPtr<SharedBuffer> dataOriginal, const String& iconURLOriginal)
-{
- ASSERT_NOT_SYNC_THREAD();
-
- // Cannot do anything with dataOriginal or iconURLOriginal that would end up storing them without deep copying first
-
- if (!isOpen() || iconURLOriginal.isEmpty())
- return;
-
- RefPtr<SharedBuffer> data = "" ? dataOriginal->copy() : PassRefPtr<SharedBuffer>(0);
- if (data)
- data->setMutexForVerifier(m_urlAndIconLock);
- String iconURL = iconURLOriginal.isolatedCopy();
-
+void IconDatabase::updateIconRecord(PassRefPtr<SharedBuffer> iconData, PassRefPtr<Image> iconBitmap, const String& iconURL)
+{
+ // Only one of iconData or iconBitmap should be provided, never both.
+ ASSERT(!iconData != !iconBitmap);
+
Vector<String> pageURLs;
{
MutexLocker locker(m_urlAndIconLock);
-
+
// If this icon was pending a read, remove it from that set because this new data should override what is on disk
RefPtr<IconRecord> icon = m_iconURLToRecordMap.get(iconURL);
if (icon) {
@@ -558,14 +551,17 @@
m_iconsPendingReading.remove(icon.get());
} else
icon = getOrCreateIconRecord(iconURL);
-
- // Update the data and set the time stamp
- icon->setImageData(data.release());
+
+ // Update the image and set the time stamp
+ if (iconData)
+ icon->setImageData(iconData);
+ else if (iconBitmap)
+ icon->setImage(iconBitmap);
icon->setTimestamp((int)currentTime());
-
+
// Copy the current retaining pageURLs - if any - to notify them of the change
pageURLs.appendRange(icon->retainingPageURLs().begin(), icon->retainingPageURLs().end());
-
+
// Mark the IconRecord as requiring an update to the database only if private browsing is disabled
if (!m_privateBrowsingEnabled) {
MutexLocker locker(m_pendingSyncLock);
@@ -587,7 +583,7 @@
scheduleOrDeferSyncTimer();
// Informal testing shows that draining the autorelease pool every 25 iterations is about as low as we can go
- // before performance starts to drop off, but we don't want to increase this number because then accumulated memory usage will go up
+ // before performance starts to drop off, but we don't want to increase this number because then accumulated memory usage will go up
AutodrainedPool pool(25);
for (unsigned i = 0; i < pageURLs.size(); ++i) {
@@ -599,6 +595,51 @@
}
}
+void IconDatabase::setIconBitmapForIconURL(PassRefPtr<Image> imageOriginal, const String& iconURLOriginal)
+{
+ ASSERT_NOT_SYNC_THREAD();
+ ASSERT(imageOriginal->isBitmapImage());
+
+ // Cannot do anything with imageOriginal or iconURLOriginal that would end up storing them without deep copying first
+
+ if (!isOpen() || iconURLOriginal.isEmpty())
+ return;
+
+ RefPtr<Image> image;
+ if (imageOriginal) {
+ OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(imageOriginal->size());
+ GraphicsContext* context = imageBuffer->context();
+
+ context->drawImage(imageOriginal.get(), ColorSpaceDeviceRGB, IntPoint());
+ image = imageBuffer->copyImage();
+ }
+
+ if (image)
+ image->setMutexForVerifier(m_urlAndIconLock);
+
+ String iconURL = iconURLOriginal.isolatedCopy();
+
+ updateIconRecord(0, image.release(), iconURL);
+}
+
+void IconDatabase::setIconDataForIconURL(PassRefPtr<SharedBuffer> dataOriginal, const String& iconURLOriginal)
+{
+ ASSERT_NOT_SYNC_THREAD();
+
+ // Cannot do anything with dataOriginal or iconURLOriginal that would end up storing them without deep copying first
+
+ if (!isOpen() || iconURLOriginal.isEmpty())
+ return;
+
+ RefPtr<SharedBuffer> data = "" ? dataOriginal->copy() : PassRefPtr<SharedBuffer>(0);
+ if (data)
+ data->setMutexForVerifier(m_urlAndIconLock);
+
+ String iconURL = iconURLOriginal.isolatedCopy();
+
+ updateIconRecord(data.release(), 0, iconURL);
+}
+
void IconDatabase::setIconURLForPageURL(const String& iconURLOriginal, const String& pageURLOriginal)
{
ASSERT_NOT_SYNC_THREAD();
Modified: trunk/Source/WebCore/loader/icon/IconDatabase.h (148033 => 148034)
--- trunk/Source/WebCore/loader/icon/IconDatabase.h 2013-04-09 18:53:19 UTC (rev 148033)
+++ trunk/Source/WebCore/loader/icon/IconDatabase.h 2013-04-09 19:04:33 UTC (rev 148034)
@@ -93,7 +93,8 @@
virtual void retainIconForPageURL(const String&);
virtual void releaseIconForPageURL(const String&);
- virtual void setIconDataForIconURL(PassRefPtr<SharedBuffer> data, const String&);
+ virtual void setIconDataForIconURL(PassRefPtr<SharedBuffer> data, const String&) OVERRIDE;
+ virtual void setIconBitmapForIconURL(PassRefPtr<Image>, const String&) OVERRIDE;
virtual void setIconURLForPageURL(const String& iconURL, const String& pageURL);
virtual Image* synchronousIconForPageURL(const String&, const IntSize&);
@@ -128,6 +129,8 @@
void wakeSyncThread();
void scheduleOrDeferSyncTimer();
void syncTimerFired(Timer<IconDatabase>*);
+
+ void updateIconRecord(PassRefPtr<SharedBuffer>, PassRefPtr<Image>, const String&);
Timer<IconDatabase> m_syncTimer;
ThreadIdentifier m_syncThread;
Modified: trunk/Source/WebCore/loader/icon/IconDatabaseBase.h (148033 => 148034)
--- trunk/Source/WebCore/loader/icon/IconDatabaseBase.h 2013-04-09 18:53:19 UTC (rev 148033)
+++ trunk/Source/WebCore/loader/icon/IconDatabaseBase.h 2013-04-09 19:04:33 UTC (rev 148034)
@@ -26,6 +26,7 @@
#ifndef IconDatabaseBase_h
#define IconDatabaseBase_h
+#include "Image.h"
#include "ImageSource.h"
#include "SharedBuffer.h"
@@ -172,6 +173,7 @@
virtual void setIconURLForPageURL(const String&, const String&) { }
virtual void setIconDataForIconURL(PassRefPtr<SharedBuffer>, const String&) { }
+ virtual void setIconBitmapForIconURL(PassRefPtr<Image>, const String&) { }
// Synchronous calls used internally by WebCore.
// Usage should be replaced by asynchronous calls.
Modified: trunk/Source/WebCore/loader/icon/IconRecord.cpp (148033 => 148034)
--- trunk/Source/WebCore/loader/icon/IconRecord.cpp 2013-04-09 18:53:19 UTC (rev 148033)
+++ trunk/Source/WebCore/loader/icon/IconRecord.cpp 2013-04-09 19:04:33 UTC (rev 148034)
@@ -77,6 +77,12 @@
m_dataSet = true;
}
+void IconRecord::setImage(PassRefPtr<Image> image)
+{
+ m_image = image;
+ m_dataSet = true;
+}
+
void IconRecord::loadImageFromResource(const char* resource)
{
if (!resource)
Modified: trunk/Source/WebCore/loader/icon/IconRecord.h (148033 => 148034)
--- trunk/Source/WebCore/loader/icon/IconRecord.h 2013-04-09 18:53:19 UTC (rev 148033)
+++ trunk/Source/WebCore/loader/icon/IconRecord.h 2013-04-09 19:04:33 UTC (rev 148034)
@@ -85,6 +85,7 @@
void setTimestamp(time_t stamp) { m_stamp = stamp; }
void setImageData(PassRefPtr<SharedBuffer> data);
+ void setImage(PassRefPtr<Image> data);
Image* image(const IntSize&);
String iconURL() { return m_iconURL; }
Modified: trunk/Source/WebKit2/ChangeLog (148033 => 148034)
--- trunk/Source/WebKit2/ChangeLog 2013-04-09 18:53:19 UTC (rev 148033)
+++ trunk/Source/WebKit2/ChangeLog 2013-04-09 19:04:33 UTC (rev 148034)
@@ -1,3 +1,29 @@
+2013-04-09 Tim Horton <[email protected]>
+
+ [wk2] IconDatabase images should be decoded in the WebProcess
+ https://bugs.webkit.org/show_bug.cgi?id=112524
+ <rdar://problem/10133914>
+
+ Reviewed by Oliver Hunt.
+
+ In the interests of keeping decoding of data coming in from the greater Internet
+ in the WebProcess, move decoding of favicons from the UIProcess to the WebProcess.
+
+ * UIProcess/WebIconDatabase.cpp:
+ (WebKit::WebIconDatabase::setIconBitmapForIconURL):
+ Receive a ShareableBitmap handle from the WebProcess instead of a DataReference.
+ Use the new setIconBitmapForIconURL IconDatabase method.
+
+ * UIProcess/WebIconDatabase.h:
+ (WebIconDatabase):
+ Rename setIconDataForIconURL to setIconBitmapForIconURL.
+
+ * UIProcess/WebIconDatabase.messages.in: Ditto.
+
+ * WebProcess/IconDatabase/WebIconDatabaseProxy.cpp:
+ (WebKit::WebIconDatabaseProxy::setIconDataForIconURL):
+ In the WebProcess, decode the incoming icon and draw it into a ShareableBitmap.
+
2013-04-09 Raphael Kubo da Costa <[email protected]>
[EFL] Declare TEST_THEME_DIR in a single place.
Modified: trunk/Source/WebKit2/UIProcess/WebIconDatabase.cpp (148033 => 148034)
--- trunk/Source/WebKit2/UIProcess/WebIconDatabase.cpp 2013-04-09 18:53:19 UTC (rev 148033)
+++ trunk/Source/WebKit2/UIProcess/WebIconDatabase.cpp 2013-04-09 19:04:33 UTC (rev 148034)
@@ -121,14 +121,19 @@
m_iconDatabaseImpl->setIconURLForPageURL(iconURL, pageURL);
}
-void WebIconDatabase::setIconDataForIconURL(const CoreIPC::DataReference& iconData, const String& iconURL)
+void WebIconDatabase::setIconBitmapForIconURL(const ShareableBitmap::Handle& bitmapHandle, const String& iconURL)
{
- LOG(IconDatabase, "WK2 UIProcess setting icon data (%i bytes) for page URL %s", (int)iconData.size(), iconURL.ascii().data());
+ LOG(IconDatabase, "WK2 UIProcess setting icon bitmap for page URL %s", iconURL.ascii().data());
if (!m_iconDatabaseImpl)
return;
- RefPtr<SharedBuffer> buffer = SharedBuffer::create(iconData.data(), iconData.size());
- m_iconDatabaseImpl->setIconDataForIconURL(buffer.release(), iconURL);
+ if (bitmapHandle.isNull()) {
+ m_iconDatabaseImpl->setIconBitmapForIconURL(0, iconURL);
+ return;
+ }
+
+ RefPtr<ShareableBitmap> iconBitmap = ShareableBitmap::create(bitmapHandle, SharedMemory::ReadOnly);
+ m_iconDatabaseImpl->setIconBitmapForIconURL(iconBitmap->createImage(), iconURL);
}
void WebIconDatabase::synchronousIconDataForPageURL(const String&, CoreIPC::DataReference& iconData)
Modified: trunk/Source/WebKit2/UIProcess/WebIconDatabase.h (148033 => 148034)
--- trunk/Source/WebKit2/UIProcess/WebIconDatabase.h 2013-04-09 18:53:19 UTC (rev 148033)
+++ trunk/Source/WebKit2/UIProcess/WebIconDatabase.h 2013-04-09 19:04:33 UTC (rev 148034)
@@ -29,6 +29,7 @@
#include "APIObject.h"
#include "Connection.h"
+#include "ShareableBitmap.h"
#include "WebIconDatabaseClient.h"
#include <WebCore/IconDatabaseClient.h>
#include <WebCore/ImageSource.h>
@@ -66,7 +67,7 @@
void retainIconForPageURL(const String&);
void releaseIconForPageURL(const String&);
void setIconURLForPageURL(const String&, const String&);
- void setIconDataForIconURL(const CoreIPC::DataReference&, const String&);
+ void setIconBitmapForIconURL(const ShareableBitmap::Handle&, const String&);
void synchronousIconDataForPageURL(const String&, CoreIPC::DataReference&);
void synchronousIconURLForPageURL(const String&, String&);
Modified: trunk/Source/WebKit2/UIProcess/WebIconDatabase.messages.in (148033 => 148034)
--- trunk/Source/WebKit2/UIProcess/WebIconDatabase.messages.in 2013-04-09 18:53:19 UTC (rev 148033)
+++ trunk/Source/WebKit2/UIProcess/WebIconDatabase.messages.in 2013-04-09 19:04:33 UTC (rev 148034)
@@ -24,7 +24,7 @@
RetainIconForPageURL(WTF::String pageURL)
ReleaseIconForPageURL(WTF::String pageURL)
SetIconURLForPageURL(WTF::String iconURL, WTF::String pageURL)
- SetIconDataForIconURL(CoreIPC::DataReference iconData, WTF::String iconURL)
+ SetIconBitmapForIconURL(WebKit::ShareableBitmap::Handle bitmapHandle, WTF::String iconURL)
SynchronousIconDataForPageURL(WTF::String pageURL) -> (CoreIPC::DataReference iconData)
SynchronousIconURLForPageURL(WTF::String pageURL) -> (WTF::String iconURL)
Modified: trunk/Source/WebKit2/WebProcess/IconDatabase/WebIconDatabaseProxy.cpp (148033 => 148034)
--- trunk/Source/WebKit2/WebProcess/IconDatabase/WebIconDatabaseProxy.cpp 2013-04-09 18:53:19 UTC (rev 148033)
+++ trunk/Source/WebKit2/WebProcess/IconDatabase/WebIconDatabaseProxy.cpp 2013-04-09 19:04:33 UTC (rev 148034)
@@ -30,6 +30,9 @@
#include "WebIconDatabaseMessages.h"
#include "WebIconDatabaseProxyMessages.h"
#include "WebProcess.h"
+#include <WebCore/BitmapImage.h>
+#include <WebCore/GraphicsContext.h>
+#include <WebCore/IntPoint.h>
#include <WebCore/SharedBuffer.h>
#include <wtf/text/WTFString.h>
@@ -135,8 +138,18 @@
void WebIconDatabaseProxy::setIconDataForIconURL(PassRefPtr<SharedBuffer> iconData, const String& iconURL)
{
- CoreIPC::DataReference data(reinterpret_cast<const uint8_t*>(iconData ? iconData->data() : 0), iconData ? iconData->size() : 0);
- m_process->connection()->send(Messages::WebIconDatabase::SetIconDataForIconURL(data, iconURL), 0);
+ RefPtr<Image> image = BitmapImage::create();
+ ShareableBitmap::Handle handle;
+
+ if (image->setData(iconData, true) && !image->size().isEmpty()) {
+ RefPtr<ShareableBitmap> shareableBitmap = ShareableBitmap::createShareable(image->size(), ShareableBitmap::SupportsAlpha);
+ OwnPtr<GraphicsContext> bitmapContext = shareableBitmap->createGraphicsContext();
+ bitmapContext->drawImage(image.get(), ColorSpaceDeviceRGB, IntPoint());
+
+ shareableBitmap->createHandle(handle, SharedMemory::ReadOnly);
+ }
+
+ m_process->connection()->send(Messages::WebIconDatabase::SetIconBitmapForIconURL(handle, iconURL), 0);
}
void WebIconDatabaseProxy::urlImportFinished()
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm (148033 => 148034)
--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm 2013-04-09 18:53:19 UTC (rev 148033)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm 2013-04-09 19:04:33 UTC (rev 148034)
@@ -345,7 +345,7 @@
{
m_pdfLayerController.get().delegate = 0;
- if (webFrame()) {
+ if (webFrame() && webFrame()->coreFrame()) {
if (FrameView* frameView = webFrame()->coreFrame()->view())
frameView->removeScrollableArea(this);
}