summaryrefslogtreecommitdiffstats
path: root/WebKit/win/WebFrame.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/win/WebFrame.cpp')
-rw-r--r--WebKit/win/WebFrame.cpp376
1 files changed, 291 insertions, 85 deletions
diff --git a/WebKit/win/WebFrame.cpp b/WebKit/win/WebFrame.cpp
index b7ad014..60be4d5 100644
--- a/WebKit/win/WebFrame.cpp
+++ b/WebKit/win/WebFrame.cpp
@@ -42,10 +42,10 @@
#include "WebDownload.h"
#include "WebEditorClient.h"
#include "WebError.h"
+#include "WebFrameNetworkingContext.h"
#include "WebFramePolicyListener.h"
#include "WebHistory.h"
#include "WebHistoryItem.h"
-#include "WebIconFetcher.h"
#include "WebKit.h"
#include "WebKitStatisticsPrivate.h"
#include "WebMutableURLRequest.h"
@@ -55,7 +55,7 @@
#include "WebView.h"
#pragma warning( push, 0 )
#include <WebCore/BString.h>
-#include <WebCore/Cache.h>
+#include <WebCore/MemoryCache.h>
#include <WebCore/Document.h>
#include <WebCore/DocumentLoader.h>
#include <WebCore/DOMImplementation.h>
@@ -83,11 +83,11 @@
#include <WebCore/NotImplemented.h>
#include <WebCore/Page.h>
#include <WebCore/PlatformKeyboardEvent.h>
-#include <WebCore/PluginInfoStore.h>
+#include <WebCore/PluginData.h>
#include <WebCore/PluginDatabase.h>
#include <WebCore/PluginView.h>
+#include <WebCore/PrintContext.h>
#include <WebCore/ResourceHandle.h>
-#include <WebCore/ResourceHandleWin.h>
#include <WebCore/ResourceRequest.h>
#include <WebCore/RenderView.h>
#include <WebCore/RenderTreeAsText.h>
@@ -339,9 +339,9 @@ HRESULT STDMETHODCALLTYPE WebFrame::paintDocumentRectToContext(
return E_FAIL;
// We can't paint with a layout still pending.
- view->layoutIfNeededRecursive();
+ view->updateLayoutAndStyleIfNeededRecursive();
- HDC dc = (HDC)(ULONG64)deviceContext;
+ HDC dc = reinterpret_cast<HDC>(static_cast<ULONG64>(deviceContext));
GraphicsContext gc(dc);
gc.setShouldIncludeChildWindows(true);
gc.save();
@@ -358,6 +358,34 @@ HRESULT STDMETHODCALLTYPE WebFrame::paintDocumentRectToContext(
return S_OK;
}
+HRESULT STDMETHODCALLTYPE WebFrame::paintScrollViewRectToContextAtPoint(
+ /* [in] */ RECT rect,
+ /* [in] */ POINT pt,
+ /* [in] */ OLE_HANDLE deviceContext)
+{
+ Frame* coreFrame = core(this);
+ if (!coreFrame)
+ return E_FAIL;
+
+ FrameView* view = coreFrame->view();
+ if (!view)
+ return E_FAIL;
+
+ // We can't paint with a layout still pending.
+ view->updateLayoutAndStyleIfNeededRecursive();
+
+ HDC dc = reinterpret_cast<HDC>(static_cast<ULONG64>(deviceContext));
+ GraphicsContext gc(dc);
+ gc.setShouldIncludeChildWindows(true);
+ gc.save();
+ IntRect dirtyRect(rect);
+ dirtyRect.move(-pt.x, -pt.y);
+ view->paint(&gc, dirtyRect);
+ gc.restore();
+
+ return S_OK;
+}
+
// IUnknown -------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE WebFrame::QueryInterface(REFIID riid, void** ppvObject)
@@ -410,7 +438,7 @@ HRESULT STDMETHODCALLTYPE WebFrame::name(
if (!coreFrame)
return E_FAIL;
- *frameName = BString(coreFrame->tree()->name()).release();
+ *frameName = BString(coreFrame->tree()->uniqueName()).release();
return S_OK;
}
@@ -477,9 +505,10 @@ HRESULT STDMETHODCALLTYPE WebFrame::currentForm(
*currentForm = 0;
- if (Frame* coreFrame = core(this))
- if (HTMLFormElement* formElement = coreFrame->currentForm())
+ if (Frame* coreFrame = core(this)) {
+ if (HTMLFormElement* formElement = coreFrame->selection()->currentForm())
*currentForm = DOMElement::createInstance(formElement);
+ }
return *currentForm ? S_OK : E_FAIL;
}
@@ -571,6 +600,17 @@ HRESULT STDMETHODCALLTYPE WebFrame::loadData(
return S_OK;
}
+HRESULT WebFrame::loadPlainTextString(
+ /* [in] */ BSTR string,
+ /* [in] */ BSTR url)
+{
+ RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<char*>(string), sizeof(UChar) * SysStringLen(string));
+ BString plainTextMimeType(TEXT("text/plain"), 10);
+ BString utf16Encoding(TEXT("utf-16"), 6);
+ loadData(sharedBuffer.release(), plainTextMimeType, utf16Encoding, url, 0);
+ return S_OK;
+}
+
void WebFrame::loadHTMLString(BSTR string, BSTR baseURL, BSTR unreachableURL)
{
RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<char*>(string), sizeof(UChar) * SysStringLen(string));
@@ -816,8 +856,7 @@ HRESULT STDMETHODCALLTYPE WebFrame::childFrames(
// IWebFramePrivate ------------------------------------------------------
-HRESULT STDMETHODCALLTYPE WebFrame::renderTreeAsExternalRepresentation(
- /* [retval][out] */ BSTR *result)
+HRESULT WebFrame::renderTreeAsExternalRepresentation(BOOL forPrinting, BSTR *result)
{
if (!result)
return E_POINTER;
@@ -826,7 +865,7 @@ HRESULT STDMETHODCALLTYPE WebFrame::renderTreeAsExternalRepresentation(
if (!coreFrame)
return E_FAIL;
- *result = BString(externalRepresentation(coreFrame)).release();
+ *result = BString(externalRepresentation(coreFrame, forPrinting ? RenderAsTextPrintingMode : RenderAsTextBehaviorNormal)).release();
return S_OK;
}
@@ -849,6 +888,44 @@ HRESULT STDMETHODCALLTYPE WebFrame::counterValueForElementById(
return S_OK;
}
+HRESULT STDMETHODCALLTYPE WebFrame::pageNumberForElementById(
+ /* [in] */ BSTR id,
+ /* [in] */ float pageWidthInPixels,
+ /* [in] */ float pageHeightInPixels,
+ /* [retval][out] */ int* result)
+{
+ if (!result)
+ return E_POINTER;
+
+ Frame* coreFrame = core(this);
+ if (!coreFrame)
+ return E_FAIL;
+
+ String coreId = String(id, SysStringLen(id));
+
+ Element* element = coreFrame->document()->getElementById(coreId);
+ if (!element)
+ return E_FAIL;
+ *result = PrintContext::pageNumberForElement(element, FloatSize(pageWidthInPixels, pageHeightInPixels));
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE WebFrame::numberOfPages(
+ /* [in] */ float pageWidthInPixels,
+ /* [in] */ float pageHeightInPixels,
+ /* [retval][out] */ int* result)
+{
+ if (!result)
+ return E_POINTER;
+
+ Frame* coreFrame = core(this);
+ if (!coreFrame)
+ return E_FAIL;
+
+ *result = PrintContext::numberOfPages(coreFrame, FloatSize(pageWidthInPixels, pageHeightInPixels));
+ return S_OK;
+}
+
HRESULT STDMETHODCALLTYPE WebFrame::scrollOffset(
/* [retval][out] */ SIZE* offset)
{
@@ -897,7 +974,7 @@ HRESULT STDMETHODCALLTYPE WebFrame::firstLayoutDone(
if (!coreFrame)
return E_FAIL;
- *result = coreFrame->loader()->firstLayoutDone();
+ *result = coreFrame->loader()->stateMachine()->firstLayoutDone();
return S_OK;
}
@@ -937,26 +1014,20 @@ HRESULT STDMETHODCALLTYPE WebFrame::pendingFrameUnloadEventCount(
return S_OK;
}
-HRESULT STDMETHODCALLTYPE WebFrame::fetchApplicationIcon(
- /* [in] */ IWebIconFetcherDelegate *delegate,
- /* [retval][out] */ IWebIconFetcher **result)
+HRESULT STDMETHODCALLTYPE WebFrame::unused2()
{
- if (!result)
- return E_POINTER;
-
- *result = 0;
-
- if (!delegate)
- return E_FAIL;
+ return E_NOTIMPL;
+}
+HRESULT STDMETHODCALLTYPE WebFrame::hasSpellingMarker(
+ /* [in] */ UINT from,
+ /* [in] */ UINT length,
+ /* [retval][out] */ BOOL* result)
+{
Frame* coreFrame = core(this);
if (!coreFrame)
return E_FAIL;
-
- *result = WebIconFetcher::fetchApplicationIcon(coreFrame, delegate);
- if (!*result)
- return E_FAIL;
-
+ *result = coreFrame->editor()->selectionStartHasSpellingMarkerFor(from, length);
return S_OK;
}
@@ -978,7 +1049,7 @@ HRESULT STDMETHODCALLTYPE WebFrame::selectedString(
if (!coreFrame)
return E_FAIL;
- String text = coreFrame->displayStringModifiedByEncoding(coreFrame->selectedText());
+ String text = coreFrame->displayStringModifiedByEncoding(coreFrame->editor()->selectedText());
*result = BString(text).release();
return S_OK;
@@ -1031,13 +1102,6 @@ void WebFrame::invalidate()
document->recalcStyle(Node::Force);
}
-void WebFrame::setTextSizeMultiplier(float multiplier)
-{
- Frame* coreFrame = core(this);
- ASSERT(coreFrame);
- coreFrame->setZoomFactor(multiplier, true);
-}
-
HRESULT WebFrame::inViewSourceMode(BOOL* flag)
{
if (!flag) {
@@ -1072,7 +1136,7 @@ HRESULT WebFrame::elementWithName(BSTR name, IDOMElement* form, IDOMElement** el
HTMLFormElement *formElement = formElementFromDOMElement(form);
if (formElement) {
- Vector<HTMLFormControlElement*>& elements = formElement->formElements;
+ const Vector<HTMLFormControlElement*>& elements = formElement->associatedElements();
AtomicString targetName((UChar*)name, SysStringLen(name));
for (unsigned int i = 0; i < elements.size(); i++) {
HTMLFormControlElement *elt = elements[i];
@@ -1113,7 +1177,7 @@ HRESULT WebFrame::elementDoesAutoComplete(IDOMElement *element, BOOL *result)
if (!inputElement)
*result = false;
else
- *result = (inputElement->inputType() == HTMLInputElement::TEXT && inputElement->autoComplete());
+ *result = inputElement->isTextField() && !inputElement->isPasswordField() && inputElement->autoComplete();
return S_OK;
}
@@ -1192,6 +1256,24 @@ HRESULT WebFrame::pauseSVGAnimation(BSTR elementId, IDOMNode* node, double secon
return S_OK;
}
+HRESULT WebFrame::visibleContentRect(RECT* rect)
+{
+ if (!rect)
+ return E_POINTER;
+ SetRectEmpty(rect);
+
+ Frame* frame = core(this);
+ if (!frame)
+ return E_FAIL;
+
+ FrameView* view = frame->view();
+ if (!view)
+ return E_FAIL;
+
+ *rect = view->visibleContentRect(false);
+ return S_OK;
+}
+
HRESULT WebFrame::numberOfActiveAnimations(UINT* number)
{
if (!number)
@@ -1211,6 +1293,26 @@ HRESULT WebFrame::numberOfActiveAnimations(UINT* number)
return S_OK;
}
+HRESULT WebFrame::suspendAnimations()
+{
+ Frame* frame = core(this);
+ if (!frame)
+ return E_FAIL;
+
+ frame->animation()->suspendAnimations();
+ return S_OK;
+}
+
+HRESULT WebFrame::resumeAnimations()
+{
+ Frame* frame = core(this);
+ if (!frame)
+ return E_FAIL;
+
+ frame->animation()->resumeAnimations();
+ return S_OK;
+}
+
HRESULT WebFrame::isDisplayingStandaloneImage(BOOL* result)
{
if (!result)
@@ -1238,7 +1340,7 @@ HRESULT WebFrame::allowsFollowingLink(BSTR url, BOOL* result)
if (!frame)
return E_FAIL;
- *result = SecurityOrigin::canLoad(MarshallingHelpers::BSTRToKURL(url), String(), frame->document());
+ *result = frame->document()->securityOrigin()->canDisplay(MarshallingHelpers::BSTRToKURL(url));
return S_OK;
}
@@ -1252,7 +1354,7 @@ HRESULT WebFrame::controlsInForm(IDOMElement* form, IDOMElement** controls, int*
return E_FAIL;
int inCount = *cControls;
- int count = (int) formElement->formElements.size();
+ int count = (int) formElement->associatedElements().size();
*cControls = count;
if (!controls)
return S_OK;
@@ -1260,7 +1362,7 @@ HRESULT WebFrame::controlsInForm(IDOMElement* form, IDOMElement** controls, int*
return E_FAIL;
*cControls = 0;
- Vector<HTMLFormControlElement*>& elements = formElement->formElements;
+ const Vector<HTMLFormControlElement*>& elements = formElement->associatedElements();
for (int i = 0; i < count; i++) {
if (elements.at(i)->isEnumeratable()) { // Skip option elements, other duds
controls[*cControls] = DOMElement::createInstance(elements.at(i));
@@ -1272,9 +1374,8 @@ HRESULT WebFrame::controlsInForm(IDOMElement* form, IDOMElement** controls, int*
HRESULT WebFrame::elementIsPassword(IDOMElement *element, bool *result)
{
- HTMLInputElement *inputElement = inputElementFromDOMElement(element);
- *result = inputElement != 0
- && inputElement->inputType() == HTMLInputElement::PASSWORD;
+ HTMLInputElement* inputElement = inputElementFromDOMElement(element);
+ *result = inputElement && inputElement->isPasswordField();
return S_OK;
}
@@ -1378,6 +1479,21 @@ HRESULT WebFrame::canProvideDocumentSource(bool* result)
return hr;
}
+HRESULT STDMETHODCALLTYPE WebFrame::layerTreeAsText(BSTR* result)
+{
+ if (!result)
+ return E_POINTER;
+ *result = 0;
+
+ Frame* frame = core(this);
+ if (!frame)
+ return E_FAIL;
+
+ String text = frame->layerTreeAsText();
+ *result = BString(text).release();
+ return S_OK;
+}
+
void WebFrame::frameLoaderDestroyed()
{
// The FrameLoader going away is equivalent to the Frame going away,
@@ -1472,11 +1588,22 @@ void WebFrame::didChangeTitle(DocumentLoader*)
notImplemented();
}
+void WebFrame::didChangeIcons(DocumentLoader*)
+{
+ notImplemented();
+}
+
bool WebFrame::canHandleRequest(const ResourceRequest& request) const
{
return WebView::canHandleRequest(request);
}
+bool WebFrame::canShowMIMETypeAsHTML(const String& /*MIMEType*/) const
+{
+ notImplemented();
+ return true;
+}
+
bool WebFrame::canShowMIMEType(const String& /*MIMEType*/) const
{
notImplemented();
@@ -1583,7 +1710,13 @@ ResourceError WebFrame::pluginWillHandleLoadError(const ResourceResponse& respon
bool WebFrame::shouldFallBack(const ResourceError& error)
{
- return error.errorCode() != WebURLErrorCancelled;
+ if (error.errorCode() == WebURLErrorCancelled && error.domain() == String(WebURLErrorDomain))
+ return false;
+
+ if (error.errorCode() == WebKitErrorPlugInWillHandleLoad && error.domain() == String(WebKitErrorDomain))
+ return false;
+
+ return true;
}
COMPtr<WebFramePolicyListener> WebFrame::setUpPolicyListener(WebCore::FramePolicyFunction function)
@@ -1833,7 +1966,7 @@ void WebFrame::setPrinting(bool printing, float minPageWidth, float maxPageWidth
{
Frame* coreFrame = core(this);
ASSERT(coreFrame);
- coreFrame->setPrinting(printing, minPageWidth, maxPageWidth, adjustViewSize);
+ coreFrame->setPrinting(printing, FloatSize(minPageWidth, 0), maxPageWidth / minPageWidth, adjustViewSize ? Frame::AdjustViewSize : Frame::DoNotAdjustViewSize);
}
HRESULT STDMETHODCALLTYPE WebFrame::setInPrintingMode(
@@ -2044,12 +2177,10 @@ static HDC hdcFromContext(PlatformGraphicsContext* pctx)
void WebFrame::drawHeader(PlatformGraphicsContext* pctx, IWebUIDelegate* ui, const IntRect& pageRect, float headerHeight)
{
HDC hdc = hdcFromContext(pctx);
- const IntRect& marginRect = printerMarginRect(hdc);
- const float scale = scaleFactor(hdc, marginRect, pageRect);
- int x = static_cast<int>(scale * pageRect.x());
+ int x = pageRect.x();
int y = 0;
- RECT headerRect = {x, y, x + static_cast<int>(scale * pageRect.width()), y + static_cast<int>(scale * headerHeight)};
+ RECT headerRect = {x, y, x + pageRect.width(), y + static_cast<int>(headerHeight)};
ui->drawHeaderInRect(d->webView, &headerRect, static_cast<OLE_HANDLE>(reinterpret_cast<LONG64>(hdc)));
}
@@ -2057,16 +2188,29 @@ void WebFrame::drawHeader(PlatformGraphicsContext* pctx, IWebUIDelegate* ui, con
void WebFrame::drawFooter(PlatformGraphicsContext* pctx, IWebUIDelegate* ui, const IntRect& pageRect, UINT page, UINT pageCount, float headerHeight, float footerHeight)
{
HDC hdc = hdcFromContext(pctx);
- const IntRect& marginRect = printerMarginRect(hdc);
-
- const float scale = scaleFactor(hdc, marginRect, pageRect);
- int x = static_cast<int>(scale * pageRect.x());
- int y = static_cast<int>(scale * max(static_cast<int>(headerHeight) + pageRect.height(), m_pageHeight-static_cast<int>(footerHeight)));
- RECT footerRect = {x, y, x + static_cast<int>(scale * pageRect.width()), y + static_cast<int>(scale * footerHeight)};
+
+ int x = pageRect.x();
+ int y = max(static_cast<int>(headerHeight) + pageRect.height(), m_pageHeight -static_cast<int>(footerHeight));
+ RECT footerRect = {x, y, x + pageRect.width(), y + static_cast<int>(footerHeight)};
ui->drawFooterInRect(d->webView, &footerRect, static_cast<OLE_HANDLE>(reinterpret_cast<LONG64>(hdc)), page+1, pageCount);
}
+static XFORM buildXFORMFromCairo(HDC targetDC, cairo_t* previewContext)
+{
+ XFORM scaled;
+ GetWorldTransform(targetDC, &scaled);
+
+ cairo_matrix_t ctm;
+ cairo_get_matrix(previewContext, &ctm);
+
+ // Scale to the preview screen bounds
+ scaled.eM11 = ctm.xx;
+ scaled.eM22 = ctm.yy;
+
+ return scaled;
+}
+
void WebFrame::spoolPage(PlatformGraphicsContext* pctx, GraphicsContext* spoolCtx, HDC printDC, IWebUIDelegate* ui, float headerHeight, float footerHeight, UINT page, UINT pageCount)
{
Frame* coreFrame = core(this);
@@ -2074,48 +2218,83 @@ void WebFrame::spoolPage(PlatformGraphicsContext* pctx, GraphicsContext* spoolCt
const IntRect& pageRect = m_pageRects[page];
const IntRect& marginRect = printerMarginRect(printDC);
- cairo_save(pctx);
+ // In preview, the printDC is a placeholder, so just always use the HDC backing the graphics context.
+ HDC hdc = hdcFromContext(pctx);
+
spoolCtx->save();
- float scale = scaleFactor(printDC, marginRect, pageRect);
- cairo_scale(pctx, scale, scale);
+
+ XFORM original, scaled;
+ GetWorldTransform(hdc, &original);
+
+ 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);
+ }
- IntRect cairoMarginRect (marginRect);
- cairoMarginRect.scale (1 / scale);
+ float scale = scaleFactor(printDC, marginRect, pageRect);
+
+ IntRect cairoMarginRect(marginRect);
+ cairoMarginRect.scale(1 / scale);
- // Modify Cairo and GDI World Transform to account for margin in the
- // subsequent WebKit-controlled 'paintContents' drawing operations:
- spoolCtx->translate(cairoMarginRect.x(), cairoMarginRect.y() + headerHeight);
+ // 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);
// Modify Cairo (only) to account for page position.
cairo_translate(pctx, -pageRect.x(), -pageRect.y());
coreFrame->view()->paintContents(spoolCtx, pageRect);
-
cairo_translate(pctx, pageRect.x(), pageRect.y());
-
- XFORM originalWorld;
- ::GetWorldTransform(printDC, &originalWorld);
-
- // Position GDI world transform to account for margin in GDI-only
- // header/footer calls
- XFORM newWorld = originalWorld;
- newWorld.eDx = marginRect.x();
- newWorld.eDy = marginRect.y();
-
- ::SetWorldTransform(printDC, &newWorld);
-
+
+ if (preview) {
+ // If this is a preview, the Windows HDC was set to a non-scaled state so that Cairo would
+ // draw correctly. We need to rescale the HDC to the correct preview scale so our GDI-based
+ // header/footer calls will draw properly. This is a workaround for a bug in Cairo.
+ // (see https://bugs.freedesktop.org/show_bug.cgi?id=28161)
+ SetWorldTransform(hdc, &scaled);
+ }
+
+ XFORM xform = TransformationMatrix().translate(marginRect.x(), marginRect.y()).scale(scale);
+ ModifyWorldTransform(hdc, &xform, MWT_LEFTMULTIPLY);
+
if (headerHeight)
drawHeader(pctx, ui, pageRect, headerHeight);
if (footerHeight)
drawFooter(pctx, ui, pageRect, page, pageCount, headerHeight, footerHeight);
- ::SetWorldTransform(printDC, &originalWorld);
+ SetWorldTransform(hdc, &original);
cairo_show_page(pctx);
ASSERT(!cairo_status(pctx));
spoolCtx->restore();
- cairo_restore(pctx);
}
+
+static void setCairoTransformToPreviewHDC(cairo_t* previewCtx, HDC previewDC)
+{
+ XFORM passedCTM;
+ GetWorldTransform(previewDC, &passedCTM);
+
+ // Reset HDC WorldTransform to unscaled state. Scaling must be
+ // done in Cairo to avoid drawing errors.
+ XFORM unscaledCTM = passedCTM;
+ unscaledCTM.eM11 = 1.0;
+ unscaledCTM.eM22 = 1.0;
+
+ SetWorldTransform(previewDC, &unscaledCTM);
+
+ // Make the Cairo transform match the information passed to WebKit
+ // in the HDC's WorldTransform.
+ cairo_matrix_t ctm = { passedCTM.eM11, passedCTM.eM12, passedCTM.eM21,
+ passedCTM.eM22, passedCTM.eDx, passedCTM.eDy };
+
+ cairo_set_matrix(previewCtx, &ctm);
+}
+
#endif
HRESULT STDMETHODCALLTYPE WebFrame::spoolPages(
@@ -2134,13 +2313,28 @@ HRESULT STDMETHODCALLTYPE WebFrame::spoolPages(
ASSERT_NOT_REACHED();
return E_POINTER;
}
+
+ HDC targetDC = (ctx) ? (HDC)ctx : printDC;
- cairo_surface_t* printSurface = cairo_win32_printing_surface_create(printDC);
- ctx = cairo_create(printSurface);
- if (!ctx) {
+ cairo_surface_t* printSurface = 0;
+ if (ctx)
+ printSurface = cairo_win32_surface_create(targetDC); // in-memory
+ else
+ printSurface = cairo_win32_printing_surface_create(targetDC); // metafile
+
+ PlatformGraphicsContext* pctx = (PlatformGraphicsContext*)cairo_create(printSurface);
+ if (!pctx) {
cairo_surface_destroy(printSurface);
return E_FAIL;
}
+
+ 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);
+ }
+
cairo_surface_set_fallback_resolution(printSurface, 72.0, 72.0);
#endif
@@ -2154,7 +2348,9 @@ HRESULT STDMETHODCALLTYPE WebFrame::spoolPages(
return E_FAIL;
UINT pageCount = (UINT) m_pageRects.size();
+#if PLATFORM(CG)
PlatformGraphicsContext* pctx = (PlatformGraphicsContext*)ctx;
+#endif
if (!pageCount || startPage > pageCount) {
ASSERT_NOT_REACHED();
@@ -2353,7 +2549,7 @@ HRESULT WebFrame::stringByEvaluatingJavaScriptInScriptWorld(IWebScriptWorld* iWo
return S_OK;
JSLock lock(SilenceAssertionsOnly);
- String resultString = String(result.toString(anyWorldGlobalObject->globalExec()));
+ String resultString = ustringToString(result.toString(anyWorldGlobalObject->globalExec()));
*evaluationResult = BString(resultString).release();
return S_OK;
@@ -2367,7 +2563,7 @@ void WebFrame::unmarkAllMisspellings()
if (!doc)
return;
- doc->removeMarkers(DocumentMarker::Spelling);
+ doc->markers()->removeMarkers(DocumentMarker::Spelling);
}
}
@@ -2379,7 +2575,7 @@ void WebFrame::unmarkAllBadGrammar()
if (!doc)
return;
- doc->removeMarkers(DocumentMarker::Grammar);
+ doc->markers()->removeMarkers(DocumentMarker::Grammar);
}
}
@@ -2388,6 +2584,11 @@ WebView* WebFrame::webView() const
return d->webView;
}
+void WebFrame::setWebView(WebView* webView)
+{
+ d->webView = webView;
+}
+
COMPtr<IAccessible> WebFrame::accessible() const
{
Frame* coreFrame = core(this);
@@ -2416,3 +2617,8 @@ void WebFrame::updateBackground()
coreFrame->view()->updateBackgroundRecursively(backgroundColor, webView()->transparent());
}
+
+PassRefPtr<FrameNetworkingContext> WebFrame::createNetworkingContext()
+{
+ return WebFrameNetworkingContext::create(core(this), userAgent(url()));
+}