diff options
Diffstat (limited to 'third_party/WebKit/WebKit2/WebProcess')
5 files changed, 65 insertions, 4 deletions
diff --git a/third_party/WebKit/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp b/third_party/WebKit/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp index 6a70b33..79b6ad3 100644 --- a/third_party/WebKit/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp +++ b/third_party/WebKit/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp @@ -27,11 +27,12 @@ #include "WKBundlePagePrivate.h" #include "InjectedBundleBackForwardList.h" +#include "WKAPICast.h" +#include "WKBundleAPICast.h" +#include "WebImage.h" #include "WebPage.h" #include "WebURL.h" #include "WebURLRequest.h" -#include "WKAPICast.h" -#include "WKBundleAPICast.h" #include <WebCore/KURL.h> @@ -166,3 +167,15 @@ bool WKBundlePageFindString(WKBundlePageRef pageRef, WKStringRef target, WKFindO { return toImpl(pageRef)->findStringFromInjectedBundle(toImpl(target)->string(), toFindOptions(findOptions)); } + +WKImageRef WKBundlePageCreateSnapshotInViewCoordinates(WKBundlePageRef pageRef, WKRect rect, WKImageOptions options) +{ + RefPtr<WebImage> webImage = toImpl(pageRef)->snapshotInViewCoordinates(toIntRect(rect), toImageOptions(options)); + return toAPI(webImage.release().leakRef()); +} + +WKImageRef WKBundlePageCreateSnapshotInDocumentCoordinates(WKBundlePageRef pageRef, WKRect rect, WKImageOptions options) +{ + RefPtr<WebImage> webImage = toImpl(pageRef)->snapshotInDocumentCoordinates(toIntRect(rect), toImageOptions(options)); + return toAPI(webImage.release().leakRef()); +} diff --git a/third_party/WebKit/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h b/third_party/WebKit/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h index b4a028f..6c700993 100644 --- a/third_party/WebKit/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h +++ b/third_party/WebKit/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h @@ -29,6 +29,7 @@ #include <WebKit2/WKBase.h> #include <WebKit2/WKEvent.h> #include <WebKit2/WKFindOptions.h> +#include <WebKit2/WKImage.h> #include <WebKit2/WKPageLoadTypes.h> #ifndef __cplusplus @@ -214,6 +215,9 @@ WK_EXPORT bool WKBundlePageCanHandleRequest(WKURLRequestRef request); WK_EXPORT bool WKBundlePageFindString(WKBundlePageRef page, WKStringRef target, WKFindOptions findOptions); +WK_EXPORT WKImageRef WKBundlePageCreateSnapshotInViewCoordinates(WKBundlePageRef page, WKRect rect, WKImageOptions options); +WK_EXPORT WKImageRef WKBundlePageCreateSnapshotInDocumentCoordinates(WKBundlePageRef page, WKRect rect, WKImageOptions options); + #ifdef __cplusplus } #endif diff --git a/third_party/WebKit/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp b/third_party/WebKit/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp index 7e9211e..48fcab4 100644 --- a/third_party/WebKit/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp +++ b/third_party/WebKit/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp @@ -134,5 +134,5 @@ WKBundlePageOverlayRef WKBundlePageOverlayCreate(WKBundlePageOverlayClient* wkCl void WKBundlePageOverlaySetNeedsDisplay(WKBundlePageOverlayRef bundlePageOverlayRef, WKRect rect) { - toImpl(bundlePageOverlayRef)->setNeedsDisplay(enclosingIntRect(toImpl(rect))); + toImpl(bundlePageOverlayRef)->setNeedsDisplay(enclosingIntRect(toFloatRect(rect))); } diff --git a/third_party/WebKit/WebKit2/WebProcess/WebPage/WebPage.cpp b/third_party/WebKit/WebKit2/WebProcess/WebPage/WebPage.cpp index 4df97f1..571321c 100644 --- a/third_party/WebKit/WebKit2/WebProcess/WebPage/WebPage.cpp +++ b/third_party/WebKit/WebKit2/WebProcess/WebPage/WebPage.cpp @@ -41,14 +41,15 @@ #include "WebContextMenuClient.h" #include "WebContextMessages.h" #include "WebCoreArgumentCoders.h" -#include "WebOpenPanelResultListener.h" #include "WebDragClient.h" #include "WebEditorClient.h" #include "WebEvent.h" #include "WebEventConversion.h" #include "WebFrame.h" +#include "WebImage.h" #include "WebInspector.h" #include "WebInspectorClient.h" +#include "WebOpenPanelResultListener.h" #include "WebPageCreationParameters.h" #include "WebPageGroupProxy.h" #include "WebPageProxyMessages.h" @@ -587,6 +588,44 @@ void WebPage::uninstallPageOverlay(PageOverlay* pageOverlay) m_drawingArea->setNeedsDisplay(IntRect(IntPoint(0, 0), m_viewSize)); } +PassRefPtr<WebImage> WebPage::snapshotInViewCoordinates(const IntRect& rect, ImageOptions options) +{ + FrameView* frameView = m_mainFrame->coreFrame()->view(); + if (!frameView) + return 0; + + frameView->updateLayoutAndStyleIfNeededRecursive(); + + RefPtr<WebImage> snapshot = WebImage::create(rect.size(), options); + OwnPtr<WebCore::GraphicsContext> graphicsContext = snapshot->backingStore()->createGraphicsContext(); + + graphicsContext->save(); + graphicsContext->translate(-rect.x(), -rect.y()); + frameView->paint(graphicsContext.get(), rect); + graphicsContext->restore(); + + return snapshot.release(); +} + +PassRefPtr<WebImage> WebPage::snapshotInDocumentCoordinates(const IntRect& rect, ImageOptions options) +{ + FrameView* frameView = m_mainFrame->coreFrame()->view(); + if (!frameView) + return 0; + + frameView->updateLayoutAndStyleIfNeededRecursive(); + + RefPtr<WebImage> snapshot = WebImage::create(rect.size(), options); + OwnPtr<WebCore::GraphicsContext> graphicsContext = snapshot->backingStore()->createGraphicsContext(); + + graphicsContext->save(); + graphicsContext->translate(-rect.x(), -rect.y()); + frameView->paintContents(graphicsContext.get(), rect); + graphicsContext->restore(); + + return snapshot.release(); +} + void WebPage::pageDidScroll() { // Hide the find indicator. diff --git a/third_party/WebKit/WebKit2/WebProcess/WebPage/WebPage.h b/third_party/WebKit/WebKit2/WebProcess/WebPage/WebPage.h index 1cf257c..797478e 100644 --- a/third_party/WebKit/WebKit2/WebProcess/WebPage/WebPage.h +++ b/third_party/WebKit/WebKit2/WebProcess/WebPage/WebPage.h @@ -29,6 +29,7 @@ #include "APIObject.h" #include "DrawingArea.h" #include "FindController.h" +#include "ImageOptions.h" #include "InjectedBundlePageContextMenuClient.h" #include "InjectedBundlePageEditorClient.h" #include "InjectedBundlePageFormClient.h" @@ -75,6 +76,7 @@ class WebContextMenu; class WebContextMenuItemData; class WebEvent; class WebFrame; +class WebImage; class WebInspector; class WebKeyboardEvent; class WebMouseEvent; @@ -206,6 +208,9 @@ public: void installPageOverlay(PassRefPtr<PageOverlay>); void uninstallPageOverlay(PageOverlay*); + PassRefPtr<WebImage> snapshotInViewCoordinates(const WebCore::IntRect&, ImageOptions); + PassRefPtr<WebImage> snapshotInDocumentCoordinates(const WebCore::IntRect&, ImageOptions); + static const WebEvent* currentEvent(); FindController& findController() { return m_findController; } |