summaryrefslogtreecommitdiff
path: root/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-08-12 09:27:39 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-08-12 09:27:39 +0200
commit3749d61e1f7a59f5ec5067e560af1eb610c82015 (patch)
tree73dc228333948738bbe02976cacca8cd382bc978 /Source/WebKit2/WebProcess/WebPage/WebPage.cpp
parentb32b4dcd9a51ab8de6afc53d9e17f8707e1f7a5e (diff)
downloadqtwebkit-3749d61e1f7a59f5ec5067e560af1eb610c82015.tar.gz
Imported WebKit commit a77350243e054f3460d1137301d8b3faee3d2052 (http://svn.webkit.org/repository/webkit/trunk@125365)
New snapshot with build fixes for latest API changes in Qt and all WK1 Win MSVC fixes upstream
Diffstat (limited to 'Source/WebKit2/WebProcess/WebPage/WebPage.cpp')
-rw-r--r--Source/WebKit2/WebProcess/WebPage/WebPage.cpp99
1 files changed, 57 insertions, 42 deletions
diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
index 59d3bc5cb..59617dfd3 100644
--- a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
+++ b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
@@ -120,6 +120,10 @@
#include <WebCore/Range.h>
#include <WebCore/VisiblePosition.h>
+#if ENABLE(MHTML)
+#include <WebCore/MHTMLArchive.h>
+#endif
+
#if ENABLE(PLUGIN_PROCESS)
#if PLATFORM(MAC)
#include "MachPort.h"
@@ -207,6 +211,10 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
, m_isInRedo(false)
, m_isClosed(false)
, m_tabToLinks(false)
+ , m_asynchronousPluginInitializationEnabled(false)
+ , m_asynchronousPluginInitializationEnabledForAllPlugins(false)
+ , m_artificialPluginInitializationDelayEnabled(false)
+ , m_scrollingPerformanceLoggingEnabled(false)
#if PLATFORM(MAC)
, m_windowIsVisible(false)
, m_isSmartInsertDeleteEnabled(parameters.isSmartInsertDeleteEnabled)
@@ -296,13 +304,7 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
WebCore::provideVibrationTo(m_page.get(), new WebVibrationClient(this));
#endif
- // Qt does not yet call setIsInWindow. Until it does, just leave
- // this line out so plug-ins and video will work. Eventually all platforms
- // should call setIsInWindow and this comment and #if should be removed,
- // leaving behind the setCanStartMedia call.
-#if !PLATFORM(QT)
m_page->setCanStartMedia(false);
-#endif
updatePreferences(parameters.store);
@@ -1190,43 +1192,27 @@ void WebPage::uninstallPageOverlay(PageOverlay* pageOverlay, bool fadeOut)
#endif
}
-PassRefPtr<WebImage> WebPage::snapshotInViewCoordinates(const IntRect& rect, ImageOptions options)
+static ImageOptions snapshotOptionsToImageOptions(SnapshotOptions snapshotOptions)
{
- FrameView* frameView = m_mainFrame->coreFrame()->view();
- if (!frameView)
- return 0;
-
- IntSize bitmapSize = rect.size();
- float deviceScaleFactor = corePage()->deviceScaleFactor();
- bitmapSize.scale(deviceScaleFactor);
-
- RefPtr<WebImage> snapshot = WebImage::create(bitmapSize, options);
- if (!snapshot->bitmap())
- return 0;
-
- OwnPtr<WebCore::GraphicsContext> graphicsContext = snapshot->bitmap()->createGraphicsContext();
- graphicsContext->applyDeviceScaleFactor(deviceScaleFactor);
- graphicsContext->translate(-rect.x(), -rect.y());
-
- frameView->updateLayoutAndStyleIfNeededRecursive();
+ unsigned imageOptions = 0;
- PaintBehavior oldBehavior = frameView->paintBehavior();
- frameView->setPaintBehavior(oldBehavior | PaintBehaviorFlattenCompositingLayers);
- frameView->paint(graphicsContext.get(), rect);
- frameView->setPaintBehavior(oldBehavior);
+ if (snapshotOptions & SnapshotOptionsShareable)
+ imageOptions |= ImageOptionsShareable;
- return snapshot.release();
+ return static_cast<ImageOptions>(imageOptions);
}
-PassRefPtr<WebImage> WebPage::scaledSnapshotInDocumentCoordinates(const IntRect& rect, double scaleFactor, ImageOptions options)
+PassRefPtr<WebImage> WebPage::scaledSnapshotWithOptions(const IntRect& rect, double scaleFactor, SnapshotOptions options)
{
FrameView* frameView = m_mainFrame->coreFrame()->view();
if (!frameView)
return 0;
+ IntSize bitmapSize = rect.size();
float combinedScaleFactor = scaleFactor * corePage()->deviceScaleFactor();
- IntSize size(ceil(rect.width() * combinedScaleFactor), ceil(rect.height() * combinedScaleFactor));
- RefPtr<WebImage> snapshot = WebImage::create(size, options);
+ bitmapSize.scale(combinedScaleFactor);
+
+ RefPtr<WebImage> snapshot = WebImage::create(bitmapSize, snapshotOptionsToImageOptions(options));
if (!snapshot->bitmap())
return 0;
@@ -1234,21 +1220,15 @@ PassRefPtr<WebImage> WebPage::scaledSnapshotInDocumentCoordinates(const IntRect&
graphicsContext->applyDeviceScaleFactor(combinedScaleFactor);
graphicsContext->translate(-rect.x(), -rect.y());
- frameView->updateLayoutAndStyleIfNeededRecursive();
+ FrameView::SelectionInSnaphot shouldPaintSelection = FrameView::IncludeSelection;
+ if (options & SnapshotOptionsExcludeSelectionHighlighting)
+ shouldPaintSelection = FrameView::ExcludeSelection;
- PaintBehavior oldBehavior = frameView->paintBehavior();
- frameView->setPaintBehavior(oldBehavior | PaintBehaviorFlattenCompositingLayers);
- frameView->paintContents(graphicsContext.get(), rect);
- frameView->setPaintBehavior(oldBehavior);
+ frameView->paintContentsForSnapshot(graphicsContext.get(), rect, shouldPaintSelection);
return snapshot.release();
}
-PassRefPtr<WebImage> WebPage::snapshotInDocumentCoordinates(const IntRect& rect, ImageOptions options)
-{
- return scaledSnapshotInDocumentCoordinates(rect, 1, options);
-}
-
void WebPage::pageDidScroll()
{
m_uiClient.pageDidScroll(this);
@@ -1854,6 +1834,22 @@ void WebPage::getContentsAsString(uint64_t callbackID)
send(Messages::WebPageProxy::StringCallback(resultString, callbackID));
}
+#if ENABLE(MHTML)
+void WebPage::getContentsAsMHTMLData(uint64_t callbackID, bool useBinaryEncoding)
+{
+ CoreIPC::DataReference dataReference;
+
+ RefPtr<SharedBuffer> buffer = useBinaryEncoding
+ ? MHTMLArchive::generateMHTMLDataUsingBinaryEncoding(m_page.get())
+ : MHTMLArchive::generateMHTMLData(m_page.get());
+
+ if (buffer)
+ dataReference = CoreIPC::DataReference(reinterpret_cast<const uint8_t*>(buffer->data()), buffer->size());
+
+ send(Messages::WebPageProxy::DataCallback(dataReference, callbackID));
+}
+#endif
+
void WebPage::getRenderTreeExternalRepresentation(uint64_t callbackID)
{
String resultString = renderTreeExternalRepresentation();
@@ -1976,6 +1972,11 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
Settings* settings = m_page->settings();
m_tabToLinks = store.getBoolValueForKey(WebPreferencesKey::tabsToLinksKey());
+ m_asynchronousPluginInitializationEnabled = store.getBoolValueForKey(WebPreferencesKey::asynchronousPluginInitializationEnabledKey());
+ m_asynchronousPluginInitializationEnabledForAllPlugins = store.getBoolValueForKey(WebPreferencesKey::asynchronousPluginInitializationEnabledForAllPluginsKey());
+ m_artificialPluginInitializationDelayEnabled = store.getBoolValueForKey(WebPreferencesKey::artificialPluginInitializationDelayEnabledKey());
+
+ m_scrollingPerformanceLoggingEnabled = store.getBoolValueForKey(WebPreferencesKey::scrollingPerformanceLoggingEnabledKey());
// FIXME: This should be generated from macro expansion for all preferences,
// but we currently don't match the naming of WebCore exactly so we are
@@ -2090,9 +2091,12 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
#endif
settings->setShouldRespectImageOrientation(store.getBoolValueForKey(WebPreferencesKey::shouldRespectImageOrientationKey()));
+ settings->setThirdPartyStorageBlockingEnabled(store.getBoolValueForKey(WebPreferencesKey::thirdPartyStorageBlockingEnabledKey()));
settings->setDiagnosticLoggingEnabled(store.getBoolValueForKey(WebPreferencesKey::diagnosticLoggingEnabledKey()));
+ settings->setScrollingPerformanceLoggingEnabled(m_scrollingPerformanceLoggingEnabled);
+
platformPreferencesDidChange(store);
if (m_drawingArea)
@@ -3286,4 +3290,15 @@ void WebPage::setVisibilityState(int visibilityState, bool isInitialState)
}
#endif
+void WebPage::setScrollingPerformanceLoggingEnabled(bool enabled)
+{
+ m_scrollingPerformanceLoggingEnabled = enabled;
+
+ FrameView* frameView = m_mainFrame->coreFrame()->view();
+ if (!frameView)
+ return;
+
+ frameView->setScrollingPerformanceLoggingEnabled(enabled);
+}
+
} // namespace WebKit