summaryrefslogtreecommitdiffstats
path: root/Source/WebKit/win/WebFrame.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit/win/WebFrame.cpp')
-rw-r--r--Source/WebKit/win/WebFrame.cpp79
1 files changed, 45 insertions, 34 deletions
diff --git a/Source/WebKit/win/WebFrame.cpp b/Source/WebKit/win/WebFrame.cpp
index 80b91cd..5a99b66 100644
--- a/Source/WebKit/win/WebFrame.cpp
+++ b/Source/WebKit/win/WebFrame.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2008, 2009, 2011 Apple Inc. All rights reserved.
* Copyright (C) Research In Motion Limited 2009. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,7 +30,6 @@
#include "CFDictionaryPropertyBag.h"
#include "COMPropertyBag.h"
-#include "COMPtr.h"
#include "DOMCoreClasses.h"
#include "DefaultPolicyDelegate.h"
#include "HTMLFrameOwnerElement.h"
@@ -53,8 +52,8 @@
#include "WebScriptWorld.h"
#include "WebURLResponse.h"
#include "WebView.h"
-#pragma warning( push, 0 )
#include <WebCore/BString.h>
+#include <WebCore/COMPtr.h>
#include <WebCore/MemoryCache.h>
#include <WebCore/Document.h>
#include <WebCore/DocumentLoader.h>
@@ -104,15 +103,15 @@
#include <JavaScriptCore/JSObject.h>
#include <JavaScriptCore/JSValue.h>
#include <wtf/MathExtras.h>
-#pragma warning(pop)
-#if PLATFORM(CG)
+#if USE(CG)
#include <CoreGraphics/CoreGraphics.h>
-#elif PLATFORM(CAIRO)
+#elif USE(CAIRO)
+#include "PlatformContextCairo.h"
#include <cairo-win32.h>
#endif
-#if PLATFORM(CG)
+#if USE(CG)
// CG SPI used for printing
extern "C" {
CGAffineTransform CGContextGetBaseCTM(CGContextRef c);
@@ -1029,10 +1028,19 @@ HRESULT STDMETHODCALLTYPE WebFrame::hasSpellingMarker(
Frame* coreFrame = core(this);
if (!coreFrame)
return E_FAIL;
- *result = coreFrame->editor()->selectionStartHasSpellingMarkerFor(from, length);
+ *result = coreFrame->editor()->selectionStartHasMarkerFor(DocumentMarker::Spelling, from, length);
return S_OK;
}
+HRESULT STDMETHODCALLTYPE WebFrame::clearOpener()
+{
+ HRESULT hr = S_OK;
+ if (Frame* coreFrame = core(this))
+ coreFrame->loader()->setOpener(0);
+
+ return hr;
+}
+
// IWebDocumentText -----------------------------------------------------------
HRESULT STDMETHODCALLTYPE WebFrame::supportsTextEncoding(
@@ -1755,7 +1763,7 @@ void WebFrame::receivedPolicyDecision(PolicyAction action)
(coreFrame->loader()->policyChecker()->*function)(action);
}
-void WebFrame::dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const String& mimeType, const ResourceRequest& request)
+void WebFrame::dispatchDecidePolicyForResponse(FramePolicyFunction function, const ResourceResponse& response, const ResourceRequest& request)
{
Frame* coreFrame = core(this);
ASSERT(coreFrame);
@@ -1766,7 +1774,7 @@ void WebFrame::dispatchDecidePolicyForMIMEType(FramePolicyFunction function, con
COMPtr<IWebURLRequest> urlRequest(AdoptCOM, WebMutableURLRequest::createInstance(request));
- if (SUCCEEDED(policyDelegate->decidePolicyForMIMEType(d->webView, BString(mimeType), urlRequest.get(), this, setUpPolicyListener(function).get())))
+ if (SUCCEEDED(policyDelegate->decidePolicyForMIMEType(d->webView, BString(response.mimeType()), urlRequest.get(), this, setUpPolicyListener(function).get())))
return;
(coreFrame->loader()->policyChecker()->*function)(PolicyUse);
@@ -1890,9 +1898,9 @@ PassRefPtr<Widget> WebFrame::createJavaAppletWidget(const IntSize& pluginSize, H
return pluginView;
}
-ObjectContentType WebFrame::objectContentType(const KURL& url, const String& mimeType)
+ObjectContentType WebFrame::objectContentType(const KURL& url, const String& mimeType, bool shouldPreferPlugInsForImages)
{
- return WebCore::FrameLoader::defaultObjectContentType(url, mimeType);
+ return WebCore::FrameLoader::defaultObjectContentType(url, mimeType, shouldPreferPlugInsForImages);
}
String WebFrame::overrideMediaType() const
@@ -2105,7 +2113,7 @@ HRESULT STDMETHODCALLTYPE WebFrame::getPrintedPageCount(
return S_OK;
}
-#if PLATFORM(CG)
+#if USE(CG)
void WebFrame::drawHeader(PlatformGraphicsContext* pctx, IWebUIDelegate* ui, const IntRect& pageRect, float headerHeight)
{
int x = pageRect.x();
@@ -2159,7 +2167,7 @@ void WebFrame::spoolPage(PlatformGraphicsContext* pctx, GraphicsContext* spoolCt
CGContextEndPage(pctx);
CGContextRestoreGState(pctx);
}
-#elif PLATFORM(CAIRO)
+#elif USE(CAIRO)
static float scaleFactor(HDC printDC, const IntRect& marginRect, const IntRect& pageRect)
{
const IntRect& printRect = printerRect(printDC);
@@ -2167,8 +2175,8 @@ static float scaleFactor(HDC printDC, const IntRect& marginRect, const IntRect&
IntRect adjustedRect = IntRect(
printRect.x() + marginRect.x(),
printRect.y() + marginRect.y(),
- printRect.width() - marginRect.x() - marginRect.right(),
- printRect.height() - marginRect.y() - marginRect.bottom());
+ printRect.width() - marginRect.x() - marginRect.maxX(),
+ printRect.height() - marginRect.y() - marginRect.maxY());
float scale = static_cast<float>(adjustedRect.width()) / static_cast<float>(pageRect.width());
if (!scale)
@@ -2179,8 +2187,7 @@ static float scaleFactor(HDC printDC, const IntRect& marginRect, const IntRect&
static HDC hdcFromContext(PlatformGraphicsContext* pctx)
{
- cairo_surface_t* surface = cairo_get_target(pctx);
- return cairo_win32_surface_get_dc(surface);
+ return cairo_win32_surface_get_dc(cairo_get_target(pctx->cr()));
}
void WebFrame::drawHeader(PlatformGraphicsContext* pctx, IWebUIDelegate* ui, const IntRect& pageRect, float headerHeight)
@@ -2235,13 +2242,14 @@ void WebFrame::spoolPage(PlatformGraphicsContext* pctx, GraphicsContext* spoolCt
XFORM original, scaled;
GetWorldTransform(hdc, &original);
+ cairo_t* cr = pctx->cr();
bool preview = (hdc != printDC);
if (preview) {
// If this is a preview, the Windows HDC was set to a non-scaled state so that Cairo will
// draw correctly. We need to retain the correct preview scale here for use when the Cairo
// drawing completes so that we can scale our GDI-based header/footer calls. This is a
// workaround for a bug in Cairo (see https://bugs.freedesktop.org/show_bug.cgi?id=28161)
- scaled = buildXFORMFromCairo(hdc, pctx);
+ scaled = buildXFORMFromCairo(hdc, cr);
}
float scale = scaleFactor(printDC, marginRect, pageRect);
@@ -2251,13 +2259,13 @@ void WebFrame::spoolPage(PlatformGraphicsContext* pctx, GraphicsContext* spoolCt
// We cannot scale the display HDC because the print surface also scales fonts,
// resulting in invalid printing (and print preview)
- cairo_scale(pctx, scale, scale);
- cairo_translate(pctx, cairoMarginRect.x(), cairoMarginRect.y() + headerHeight);
+ cairo_scale(cr, scale, scale);
+ cairo_translate(cr, cairoMarginRect.x(), cairoMarginRect.y() + headerHeight);
// Modify Cairo (only) to account for page position.
- cairo_translate(pctx, -pageRect.x(), -pageRect.y());
+ cairo_translate(cr, -pageRect.x(), -pageRect.y());
coreFrame->view()->paintContents(spoolCtx, pageRect);
- cairo_translate(pctx, pageRect.x(), pageRect.y());
+ cairo_translate(cr, pageRect.x(), pageRect.y());
if (preview) {
// If this is a preview, the Windows HDC was set to a non-scaled state so that Cairo would
@@ -2278,8 +2286,8 @@ void WebFrame::spoolPage(PlatformGraphicsContext* pctx, GraphicsContext* spoolCt
SetWorldTransform(hdc, &original);
- cairo_show_page(pctx);
- ASSERT(!cairo_status(pctx));
+ cairo_show_page(cr);
+ ASSERT(!cairo_status(cr));
spoolCtx->restore();
}
@@ -2312,12 +2320,12 @@ HRESULT STDMETHODCALLTYPE WebFrame::spoolPages(
/* [in] */ UINT endPage,
/* [retval][out] */ void* ctx)
{
-#if PLATFORM(CG)
+#if USE(CG)
if (!printDC || !ctx) {
ASSERT_NOT_REACHED();
return E_POINTER;
}
-#elif PLATFORM(CAIRO)
+#elif USE(CAIRO)
if (!printDC) {
ASSERT_NOT_REACHED();
return E_POINTER;
@@ -2331,17 +2339,21 @@ HRESULT STDMETHODCALLTYPE WebFrame::spoolPages(
else
printSurface = cairo_win32_printing_surface_create(targetDC); // metafile
- PlatformGraphicsContext* pctx = (PlatformGraphicsContext*)cairo_create(printSurface);
- if (!pctx) {
+ cairo_t* cr = cairo_create(printSurface);
+ if (!cr) {
cairo_surface_destroy(printSurface);
return E_FAIL;
}
-
+
+ PlatformContextCairo platformContext(cr);
+ PlatformGraphicsContext* pctx = &platformContext;
+ cairo_destroy(cr);
+
if (ctx) {
// If this is a preview, the Windows HDC was sent with scaling information.
// Retrieve it and reset it so that it draws properly. This is a workaround
// for a bug in Cairo (see https://bugs.freedesktop.org/show_bug.cgi?id=28161)
- setCairoTransformToPreviewHDC(pctx, targetDC);
+ setCairoTransformToPreviewHDC(cr, targetDC);
}
cairo_surface_set_fallback_resolution(printSurface, 72.0, 72.0);
@@ -2357,7 +2369,7 @@ HRESULT STDMETHODCALLTYPE WebFrame::spoolPages(
return E_FAIL;
UINT pageCount = (UINT) m_pageRects.size();
-#if PLATFORM(CG)
+#if USE(CG)
PlatformGraphicsContext* pctx = (PlatformGraphicsContext*)ctx;
#endif
@@ -2384,8 +2396,7 @@ HRESULT STDMETHODCALLTYPE WebFrame::spoolPages(
for (UINT ii = startPage; ii < endPage; ii++)
spoolPage(pctx, &spoolCtx, printDC, ui.get(), headerHeight, footerHeight, ii, pageCount);
-#if PLATFORM(CAIRO)
- cairo_destroy(pctx);
+#if USE(CAIRO)
cairo_surface_finish(printSurface);
ASSERT(!cairo_surface_status(printSurface));
cairo_surface_destroy(printSurface);