diff options
Diffstat (limited to 'WebKit/win')
-rw-r--r-- | WebKit/win/ChangeLog | 136 | ||||
-rw-r--r-- | WebKit/win/Interfaces/IWebPreferences.idl | 9 | ||||
-rw-r--r-- | WebKit/win/WebCoreSupport/WebContextMenuClient.cpp | 3 | ||||
-rw-r--r-- | WebKit/win/WebFrame.cpp | 135 | ||||
-rw-r--r-- | WebKit/win/WebPreferenceKeysPrivate.h | 1 | ||||
-rw-r--r-- | WebKit/win/WebPreferences.cpp | 15 | ||||
-rw-r--r-- | WebKit/win/WebPreferences.h | 6 | ||||
-rw-r--r-- | WebKit/win/WebView.cpp | 25 | ||||
-rw-r--r-- | WebKit/win/WebView.h | 8 |
9 files changed, 298 insertions, 40 deletions
diff --git a/WebKit/win/ChangeLog b/WebKit/win/ChangeLog index a67e10f..69d7ea9 100644 --- a/WebKit/win/ChangeLog +++ b/WebKit/win/ChangeLog @@ -1,3 +1,139 @@ +2010-05-21 Steve Block <steveblock@google.com> + + Reviewed by Jeremy Orlow. + + Add DeviceOrientation and DeviceOrientationClient + https://bugs.webkit.org/show_bug.cgi?id=39479 + + * WebView.cpp: + (WebView::initWithFrame): + +2010-05-20 Simon Fraser <simon.fraser@apple.com> + + Build fix, no review. + + Fix the non-accelerated-compositing Windows build with some + #if USE(ACCELERATED_COMPOSITING) loving. + + * WebView.cpp: + * WebView.h: + +2010-05-20 Simon Fraser <simon.fraser@apple.com> + + Reviewed by Adam Roben. + + Avoid flushing CA layers when a layout is pending + https://bugs.webkit.org/show_bug.cgi?id=39463 + + <rdar://problem/7999463> + + Avoid rendering the compositing layers to the screen if there's a layout pending, + since the layer tree not in a state that should be presented to the user. + + This fixes flashes in some types of content that dynamically add and remove layers. + + Have the WebView implement WKCACFLayerRendererClient so that the + WKCACFLayerRenderer can ask whether it's a good time to render. If the FrameView + has a layout pending, say no. + + * WebView.h: + * WebView.cpp: + (WebView::setAcceleratedCompositing): + (WebView::shouldRender): + +2010-05-18 Brent Fulgham <bfulgham@webkit.org> + + Reviewed by Adam Roben. + + [WinCairo] Correct scaling for print preview + https://bugs.webkit.org/show_bug.cgi?id=39329 + + Cairo does not properly deal with Windows HDCs that have been + scaled using MM_ANISOTROPIC mapping mode, and a WindowExt and + ViewportExt setting. + (see http://bugs.freedesktop.org/show_bug.cgi?id=28161) + + Instead, reset the HDC's WorldTransform to be unscaled, then + scale the cairo context to the desired scaling, and perform + the drawing operation. + + * WebFrame.cpp: + (WebFrame::drawHeader): Use pre-positioned context to simplify + this method. + (WebFrame::drawFooter): Use pre-positioned context to simplify + this method. + (WebFrame::spoolPage): Revise scaling logic to turn off HDC + scaling, and scale using only Cairo. Revert scaling at end + so that user-defined GDI-based routines (e.g., header/footer) + will draw in the right position. + (WebFrame::spoolPages): Identify print preview case, and + retrieve scaling factors from preview context. Set the + Cairo context to use these factors during the spoolPage + operation. + +2010-05-20 Martin Robinson <mrobinson@igalia.com> + + Unreviewed. + + Touch WebKit.idl to ensure that interfaces rebuild. + + * Interfaces/WebKit.idl: Touched. + +2010-05-20 Martin Robinson <mrobinson@igalia.com> + + Reviewed by Adam Roben. + + Fix the Windows build and move new IDL declarations to the bottom of the file. + + * Interfaces/IWebPreferences.idl: Move new API to the bottom of the IDL file to prevent vtable mismatch. + * WebPreferences.cpp: + (WebPreferences::setEditingBehavior): Change the type of the parameter to setEditingBehavior to the proper type. + +2010-05-20 Martin Robinson <mrobinson@igalia.com> + + Unreviewed. + + Fix the Windows build. + + * WebView.cpp: + (WebView::notifyPreferencesChanged): Change behavior to 'editingBehavior'. + +2010-05-20 Martin Robinson <mrobinson@webkit.org> + + Reviewed by Ojan Vafai. + + Expose the editing behavior setting in DRT to test all editing code paths + https://bugs.webkit.org/show_bug.cgi?id=38603 + + Expose the EditingBehavior setting in the Windows API. + + * Interfaces/IWebPreferences.idl: Add the API point for setting the editing behavior. + * WebPreferenceKeysPrivate.h: Add a key for the editing behavior setting. + * WebPreferences.cpp: + (WebPreferences::editingBehavior): Added. + (WebPreferences::setEditingBehavior): Added. + * WebPreferences.h: Add method declarations. + * WebView.cpp: + (WebView::notifyPreferencesChanged): Update the WebCore setting based on the WebPreferences setting. + +2010-05-20 Chris Jerdonek <cjerdonek@webkit.org> + + Reviewed by Eric Seidel. + + Modified FrameLoader::urlSelected() to accept a KURL instead of a + ResourceRequest. + + https://bugs.webkit.org/show_bug.cgi?id=39320 + + Since ResourceRequest has non-explicit single-parameter constructors for + String and KURL, urlSelected() previously accepted any of String, KURL, + and ResourceRequest. This revision changes urlSelected() to accept only + a KURL to make the API tighter and easier to refactor. + + * WebCoreSupport/WebContextMenuClient.cpp: + (WebContextMenuClient::searchWithGoogle): + - Updated the call to urlSelected(). + 2010-05-13 Brian Weinstein <bweinstein@apple.com> Reviewed by Tim Hatcher. diff --git a/WebKit/win/Interfaces/IWebPreferences.idl b/WebKit/win/Interfaces/IWebPreferences.idl index 1c43135..4fb3de8 100644 --- a/WebKit/win/Interfaces/IWebPreferences.idl +++ b/WebKit/win/Interfaces/IWebPreferences.idl @@ -47,6 +47,12 @@ typedef enum WebKitEditableLinkBehavior { WebKitEditableLinkNeverLive } WebKitEditableLinkBehavior; +typedef enum WebKitEditingBehavior { + WebKitEditingMacBehavior = 0, + WebKitEditingWinBehavior +} WebKitEditingBehavior; + + typedef enum WebKitCookieStorageAcceptPolicy { WebKitCookieStorageAcceptPolicyAlways = 0, WebKitCookieStorageAcceptPolicyNever, @@ -189,4 +195,7 @@ interface IWebPreferences : IUnknown HRESULT setAcceleratedCompositingEnabled(BOOL acceleratedCompositingEnabled); HRESULT acceleratedCompositingEnabled(BOOL *acceleratedCompositingEnabled); + + HRESULT editingBehavior([out, retval] WebKitEditingBehavior* editingBehavior); + HRESULT setEditingBehavior([in] WebKitEditingBehavior behavior); } diff --git a/WebKit/win/WebCoreSupport/WebContextMenuClient.cpp b/WebKit/win/WebCoreSupport/WebContextMenuClient.cpp index 241c35d..078b725 100644 --- a/WebKit/win/WebCoreSupport/WebContextMenuClient.cpp +++ b/WebKit/win/WebCoreSupport/WebContextMenuClient.cpp @@ -140,9 +140,8 @@ void WebContextMenuClient::searchWithGoogle(const Frame* frame) url.append(encoded); url.append("&ie=UTF-8&oe=UTF-8"); - ResourceRequest request = ResourceRequest(url); if (Page* page = frame->page()) - page->mainFrame()->loader()->urlSelected(request, String(), 0, false, false, true, SendReferrer); + page->mainFrame()->loader()->urlSelected(KURL(ParsedURLString, url), String(), 0, false, false, true, SendReferrer); } void WebContextMenuClient::lookUpInDictionary(Frame*) diff --git a/WebKit/win/WebFrame.cpp b/WebKit/win/WebFrame.cpp index 0e8ee80..319fbbc 100644 --- a/WebKit/win/WebFrame.cpp +++ b/WebKit/win/WebFrame.cpp @@ -2150,12 +2150,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))); } @@ -2163,16 +2161,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); @@ -2180,48 +2191,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( @@ -2240,13 +2286,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 @@ -2260,7 +2321,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(); diff --git a/WebKit/win/WebPreferenceKeysPrivate.h b/WebKit/win/WebPreferenceKeysPrivate.h index c49a96d..da63754 100644 --- a/WebKit/win/WebPreferenceKeysPrivate.h +++ b/WebKit/win/WebPreferenceKeysPrivate.h @@ -74,6 +74,7 @@ #define WebKitPDFDisplayModePreferenceKey "WebKitPDFDisplayMode" #define WebKitPDFScaleFactorPreferenceKey "WebKitPDFScaleFactor" #define WebKitEditableLinkBehaviorPreferenceKey "WebKitEditableLinkBehavior" +#define WebKitEditingBehaviorPreferenceKey "WebKitEditingBehavior" // Window display is throttled to 60 frames per second if WebKitThrottleWindowDisplayPreferenceKey // is set to YES. The window display throttle is OFF by default for compatibility with Mac OS X diff --git a/WebKit/win/WebPreferences.cpp b/WebKit/win/WebPreferences.cpp index 33e904d..e49bd20 100644 --- a/WebKit/win/WebPreferences.cpp +++ b/WebKit/win/WebPreferences.cpp @@ -1130,6 +1130,21 @@ HRESULT STDMETHODCALLTYPE WebPreferences::setEditableLinkBehavior( return S_OK; } +HRESULT STDMETHODCALLTYPE WebPreferences::editingBehavior( + /* [out, retval] */ WebKitEditingBehavior* editingBehavior) +{ + *editingBehavior = (WebKitEditingBehavior) integerValueForKey(CFSTR(WebKitEditingBehaviorPreferenceKey)); + return S_OK; +} + +HRESULT STDMETHODCALLTYPE WebPreferences::setEditingBehavior( + /* [in] */ WebKitEditingBehavior behavior) +{ + setIntegerValue(CFSTR(WebKitEditingBehaviorPreferenceKey), behavior); + return S_OK; +} + + HRESULT STDMETHODCALLTYPE WebPreferences::cookieStorageAcceptPolicy( /* [retval][out] */ WebKitCookieStorageAcceptPolicy *acceptPolicy ) { diff --git a/WebKit/win/WebPreferences.h b/WebKit/win/WebPreferences.h index cfdefa8..1ea69c7 100644 --- a/WebKit/win/WebPreferences.h +++ b/WebKit/win/WebPreferences.h @@ -238,6 +238,12 @@ public: virtual HRESULT STDMETHODCALLTYPE setEditableLinkBehavior( /* [in] */ WebKitEditableLinkBehavior behavior); + virtual HRESULT STDMETHODCALLTYPE editingBehavior( + /* [retval][out] */ WebKitEditingBehavior* behavior); + + virtual HRESULT STDMETHODCALLTYPE setEditingBehavior( + /* [in] */ WebKitEditingBehavior behavior); + virtual HRESULT STDMETHODCALLTYPE cookieStorageAcceptPolicy( /* [retval][out] */ WebKitCookieStorageAcceptPolicy *acceptPolicy); diff --git a/WebKit/win/WebView.cpp b/WebKit/win/WebView.cpp index 1fbd8d3..20f0f06 100644 --- a/WebKit/win/WebView.cpp +++ b/WebKit/win/WebView.cpp @@ -2561,12 +2561,13 @@ HRESULT STDMETHODCALLTYPE WebView::initWithFrame( #else WebGeolocationControllerClient* geolocationControllerClient = 0; #endif + DeviceOrientationClient* deviceOrientationClient = 0; BOOL useHighResolutionTimer; if (SUCCEEDED(m_preferences->shouldUseHighResolutionTimers(&useHighResolutionTimer))) Settings::setShouldUseHighResolutionTimers(useHighResolutionTimer); - m_page = new Page(new WebChromeClient(this), new WebContextMenuClient(this), new WebEditorClient(this), new WebDragClient(this), new WebInspectorClient(this), new WebPluginHalterClient(this), geolocationControllerClient); + m_page = new Page(new WebChromeClient(this), new WebContextMenuClient(this), new WebEditorClient(this), new WebDragClient(this), new WebInspectorClient(this), new WebPluginHalterClient(this), geolocationControllerClient, deviceOrientationClient); BSTR localStoragePath; if (SUCCEEDED(m_preferences->localStorageDatabasePath(&localStoragePath))) { @@ -4593,6 +4594,12 @@ HRESULT WebView::notifyPreferencesChanged(IWebNotification* notification) return hr; settings->setEditableLinkBehavior((EditableLinkBehavior)behavior); + WebKitEditingBehavior editingBehavior; + hr = preferences->editingBehavior(&editingBehavior); + if (FAILED(hr)) + return hr; + settings->setEditingBehavior((EditingBehavior)editingBehavior); + hr = preferences->usesPageCache(&enabled); if (FAILED(hr)) return hr; @@ -6155,7 +6162,7 @@ void WebView::setAcceleratedCompositing(bool accelerated) return; if (accelerated) { - m_layerRenderer = WKCACFLayerRenderer::create(); + m_layerRenderer = WKCACFLayerRenderer::create(this); if (m_layerRenderer) { m_isAcceleratedCompositing = true; @@ -6371,6 +6378,20 @@ HRESULT WebView::nextDisplayIsSynchronous() return S_OK; } +#if USE(ACCELERATED_COMPOSITING) +bool WebView::shouldRender() const +{ + Frame* coreFrame = core(m_mainFrame); + if (!coreFrame) + return true; + FrameView* frameView = coreFrame->view(); + if (!frameView) + return true; + + return !frameView->layoutPending(); +} +#endif + class EnumTextMatches : public IEnumTextMatches { long m_ref; diff --git a/WebKit/win/WebView.h b/WebKit/win/WebView.h index 29f8705..752c16d 100644 --- a/WebKit/win/WebView.h +++ b/WebKit/win/WebView.h @@ -66,6 +66,9 @@ class WebView , public IWebNotificationObserver , public IDropTarget , WebCore::WindowMessageListener +#if USE(ACCELERATED_COMPOSITING) + , WebCore::WKCACFLayerRendererClient +#endif { public: static WebView* createInstance(); @@ -921,6 +924,11 @@ private: // (see https://bugs.webkit.org/show_bug.cgi?id=29264) DWORD m_lastDropEffect; +#if USE(ACCELERATED_COMPOSITING) + // WKCACFLayerRendererClient + virtual bool shouldRender() const; +#endif + protected: static bool registerWebViewWindowClass(); static LRESULT CALLBACK WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); |