diff options
author | Steve Block <steveblock@google.com> | 2011-05-18 13:36:51 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2011-05-24 15:38:28 +0100 |
commit | 2fc2651226baac27029e38c9d6ef883fa32084db (patch) | |
tree | e396d4bf89dcce6ed02071be66212495b1df1dec /Source/WebKit2/UIProcess/win | |
parent | b3725cedeb43722b3b175aaeff70552e562d2c94 (diff) | |
download | external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.zip external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.tar.gz external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.tar.bz2 |
Merge WebKit at r78450: Initial merge by git.
Change-Id: I6d3e5f1f868ec266a0aafdef66182ddc3f265dc1
Diffstat (limited to 'Source/WebKit2/UIProcess/win')
12 files changed, 613 insertions, 189 deletions
diff --git a/Source/WebKit2/UIProcess/win/BackingStoreWin.cpp b/Source/WebKit2/UIProcess/win/BackingStoreWin.cpp new file mode 100644 index 0000000..801376f --- /dev/null +++ b/Source/WebKit2/UIProcess/win/BackingStoreWin.cpp @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "BackingStore.h" + +#include "ShareableBitmap.h" +#include "UpdateInfo.h" +#include <WebCore/BitmapInfo.h> +#include <WebCore/GraphicsContext.h> +#include <WebCore/IntRect.h> + +using namespace WebCore; + +namespace WebKit { + +class BitmapDC { + WTF_MAKE_NONCOPYABLE(BitmapDC); + +public: + BitmapDC(HBITMAP, HDC destinationDC); + ~BitmapDC(); + + operator HDC() const { return m_dc.get(); } + +private: + OwnPtr<HDC> m_dc; + HBITMAP m_originalBitmap; +}; + +BitmapDC::BitmapDC(HBITMAP bitmap, HDC destinationDC) + : m_dc(adoptPtr(::CreateCompatibleDC(destinationDC))) + , m_originalBitmap(static_cast<HBITMAP>(::SelectObject(m_dc.get(), bitmap))) +{ +} + +BitmapDC::~BitmapDC() +{ + ::SelectObject(m_dc.get(), m_originalBitmap); +} + +void BackingStore::paint(HDC dc, const IntRect& rect) +{ + ASSERT(m_bitmap); + ::BitBlt(dc, rect.x(), rect.y(), rect.width(), rect.height(), BitmapDC(m_bitmap.get(), dc), rect.x(), rect.y(), SRCCOPY); +} + +static PassOwnPtr<HBITMAP> createBitmap(const IntSize& size) +{ + // FIXME: Maybe it would be better for performance to create a device-dependent bitmap here? + BitmapInfo info = BitmapInfo::createBottomUp(size); + void* bits; + return adoptPtr(::CreateDIBSection(0, &info, DIB_RGB_COLORS, &bits, 0, 0)); +} + +void BackingStore::incorporateUpdate(ShareableBitmap* bitmap, const UpdateInfo& updateInfo) +{ + if (!m_bitmap) + m_bitmap = createBitmap(m_size); + + scroll(updateInfo.scrollRect, updateInfo.scrollOffset); + + IntPoint updateRectLocation = updateInfo.updateRectBounds.location(); + + BitmapDC dc(m_bitmap.get(), 0); + GraphicsContext graphicsContext(dc); + + // Paint all update rects. + for (size_t i = 0; i < updateInfo.updateRects.size(); ++i) { + IntRect updateRect = updateInfo.updateRects[i]; + IntRect srcRect = updateRect; + srcRect.move(-updateRectLocation.x(), -updateRectLocation.y()); + + bitmap->paint(graphicsContext, updateRect.location(), srcRect); + } +} + +void BackingStore::scroll(const IntRect& scrollRect, const IntSize& scrollOffset) +{ + if (scrollOffset.isZero()) + return; + + RECT winScrollRect = scrollRect; + ::ScrollDC(BitmapDC(m_bitmap.get(), 0), scrollOffset.width(), scrollOffset.height(), &winScrollRect, &winScrollRect, 0, 0); +} + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/win/ChunkedUpdateDrawingAreaProxyWin.cpp b/Source/WebKit2/UIProcess/win/ChunkedUpdateDrawingAreaProxyWin.cpp index 6a1ee36..e7ce37a 100644 --- a/Source/WebKit2/UIProcess/win/ChunkedUpdateDrawingAreaProxyWin.cpp +++ b/Source/WebKit2/UIProcess/win/ChunkedUpdateDrawingAreaProxyWin.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "ChunkedUpdateDrawingAreaProxy.h" #include "UpdateChunk.h" diff --git a/Source/WebKit2/UIProcess/win/LayerBackedDrawingAreaProxyWin.cpp b/Source/WebKit2/UIProcess/win/LayerBackedDrawingAreaProxyWin.cpp index 8259272..58dc3b0 100644 --- a/Source/WebKit2/UIProcess/win/LayerBackedDrawingAreaProxyWin.cpp +++ b/Source/WebKit2/UIProcess/win/LayerBackedDrawingAreaProxyWin.cpp @@ -23,10 +23,11 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#if USE(ACCELERATED_COMPOSITING) - +#include "config.h" #include "LayerBackedDrawingAreaProxy.h" +#if USE(ACCELERATED_COMPOSITING) + #include "DrawingAreaMessageKinds.h" #include "DrawingAreaProxyMessageKinds.h" #include "WebView.h" diff --git a/Source/WebKit2/UIProcess/win/TextCheckerWin.cpp b/Source/WebKit2/UIProcess/win/TextCheckerWin.cpp index 3c4b1eb..a16f169 100644 --- a/Source/WebKit2/UIProcess/win/TextCheckerWin.cpp +++ b/Source/WebKit2/UIProcess/win/TextCheckerWin.cpp @@ -23,8 +23,10 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "TextChecker.h" +#define DISABLE_NOT_IMPLEMENTED_WARNINGS 1 #include "NotImplemented.h" #include "TextCheckerState.h" diff --git a/Source/WebKit2/UIProcess/win/WebContextMenuProxyWin.cpp b/Source/WebKit2/UIProcess/win/WebContextMenuProxyWin.cpp index 090598f..f8f3a24 100644 --- a/Source/WebKit2/UIProcess/win/WebContextMenuProxyWin.cpp +++ b/Source/WebKit2/UIProcess/win/WebContextMenuProxyWin.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "WebContextMenuProxyWin.h" #include "NotImplemented.h" diff --git a/Source/WebKit2/UIProcess/win/WebContextWin.cpp b/Source/WebKit2/UIProcess/win/WebContextWin.cpp index 83b586d..210d6cc 100644 --- a/Source/WebKit2/UIProcess/win/WebContextWin.cpp +++ b/Source/WebKit2/UIProcess/win/WebContextWin.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "WebContext.h" #include "WebProcessCreationParameters.h" @@ -52,5 +53,10 @@ void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& para parameters.shouldPaintNativeControls = m_shouldPaintNativeControls; } +String WebContext::platformDefaultDatabaseDirectory() const +{ + return WebCore::pathByAppendingComponent(WebCore::localUserSpecificStorageDirectory(), "Databases"); +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/win/WebInspectorProxyWin.cpp b/Source/WebKit2/UIProcess/win/WebInspectorProxyWin.cpp index 7637429..35d73ac 100644 --- a/Source/WebKit2/UIProcess/win/WebInspectorProxyWin.cpp +++ b/Source/WebKit2/UIProcess/win/WebInspectorProxyWin.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "WebInspectorProxy.h" #if ENABLE(INSPECTOR) @@ -171,10 +172,13 @@ void WebInspectorProxy::platformOpen() void WebInspectorProxy::platformClose() { - ASSERT(m_inspectorWindow); - ASSERT(m_inspectorView); + ASSERT(!m_isVisible || m_inspectorWindow); + ASSERT(!m_isVisible || m_inspectorView); - ::DestroyWindow(m_inspectorWindow); + if (m_inspectorWindow) { + ASSERT(::IsWindow(m_inspectorWindow)); + ::DestroyWindow(m_inspectorWindow); + } m_inspectorWindow = 0; m_inspectorView = 0; diff --git a/Source/WebKit2/UIProcess/win/WebPageProxyWin.cpp b/Source/WebKit2/UIProcess/win/WebPageProxyWin.cpp index 6b0efd1..f70363c 100644 --- a/Source/WebKit2/UIProcess/win/WebPageProxyWin.cpp +++ b/Source/WebKit2/UIProcess/win/WebPageProxyWin.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "WebPageProxy.h" #include <tchar.h> diff --git a/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp index 40e3556..4039c49 100644 --- a/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp +++ b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp @@ -26,6 +26,7 @@ // NOTE: This implementation is very similar to the implementation of popups in WebCore::PopupMenuWin. // We should try and factor out the common bits and share them. +#include "config.h" #include "WebPopupMenuProxyWin.h" #include "WebView.h" @@ -187,7 +188,7 @@ WebPopupMenuProxyWin::~WebPopupMenuProxyWin() m_scrollbar->setParent(0); } -void WebPopupMenuProxyWin::showPopupMenu(const IntRect& rect, const Vector<WebPopupItem>& items, const PlatformPopupMenuData& data, int32_t selectedIndex) +void WebPopupMenuProxyWin::showPopupMenu(const IntRect& rect, TextDirection, const Vector<WebPopupItem>& items, const PlatformPopupMenuData& data, int32_t selectedIndex) { m_items = items; m_data = data; @@ -323,7 +324,8 @@ void WebPopupMenuProxyWin::showPopupMenu(const IntRect& rect, const Vector<WebPo m_showPopup = false; ::ShowWindow(m_popup, SW_HIDE); - m_client->valueChangedForPopupMenu(this, m_newSelectedIndex); + if (m_client) + m_client->valueChangedForPopupMenu(this, m_newSelectedIndex); } void WebPopupMenuProxyWin::hidePopupMenu() @@ -372,7 +374,7 @@ void WebPopupMenuProxyWin::calculatePositionAndSize(const IntRect& rect) // Always left-align items in the popup. This matches popup menus on the mac. int popupX = rectInScreenCoords.x() + m_data.m_clientInsetLeft; - IntRect popupRect(popupX, rectInScreenCoords.bottom(), popupWidth, popupHeight); + IntRect popupRect(popupX, rectInScreenCoords.maxY(), popupWidth, popupHeight); // The popup needs to stay within the bounds of the screen and not overlap any toolbars HMONITOR monitor = ::MonitorFromWindow(m_webView->window(), MONITOR_DEFAULTTOPRIMARY); @@ -382,7 +384,7 @@ void WebPopupMenuProxyWin::calculatePositionAndSize(const IntRect& rect) FloatRect screen = monitorInfo.rcWork; // Check that we don't go off the screen vertically - if (popupRect.bottom() > screen.height()) { + if (popupRect.maxY() > screen.height()) { // The popup will go off the screen, so try placing it above the client if (rectInScreenCoords.y() - popupRect.height() < 0) { // The popup won't fit above, either, so place it whereever's bigger and resize it to fit @@ -848,8 +850,10 @@ bool WebPopupMenuProxyWin::setFocusedIndex(int i, bool hotTracking) m_focusedIndex = i; - if (!hotTracking) - m_client->setTextFromItemForPopupMenu(this, i); + if (!hotTracking) { + if (m_client) + m_client->setTextFromItemForPopupMenu(this, i); + } if (!scrollToRevealSelection()) ::UpdateWindow(m_popup); diff --git a/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h index d1dc466..2d09bb9 100644 --- a/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h +++ b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h @@ -48,7 +48,7 @@ public: } ~WebPopupMenuProxyWin(); - virtual void showPopupMenu(const WebCore::IntRect&, const Vector<WebPopupItem>&, const PlatformPopupMenuData&, int32_t selectedIndex); + virtual void showPopupMenu(const WebCore::IntRect&, WebCore::TextDirection, const Vector<WebPopupItem>&, const PlatformPopupMenuData&, int32_t selectedIndex); virtual void hidePopupMenu(); void hide() { hidePopupMenu(); } diff --git a/Source/WebKit2/UIProcess/win/WebView.cpp b/Source/WebKit2/UIProcess/win/WebView.cpp index 4516f54..eea43c5 100644 --- a/Source/WebKit2/UIProcess/win/WebView.cpp +++ b/Source/WebKit2/UIProcess/win/WebView.cpp @@ -23,14 +23,18 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "WebView.h" #include "ChunkedUpdateDrawingAreaProxy.h" +#include "DrawingAreaProxyImpl.h" #include "FindIndicator.h" #include "LayerBackedDrawingAreaProxy.h" #include "Logging.h" -#include "RunLoop.h" #include "NativeWebKeyboardEvent.h" +#include "Region.h" +#include "RunLoop.h" +#include "WKAPICast.h" #include "WebContext.h" #include "WebContextMenuProxyWin.h" #include "WebEditCommandProxy.h" @@ -38,8 +42,10 @@ #include "WebPageProxy.h" #include "WebPopupMenuProxyWin.h" #include <Commctrl.h> +#include <WebCore/BitmapInfo.h> #include <WebCore/Cursor.h> #include <WebCore/FloatRect.h> +#include <WebCore/GraphicsContextCG.h> #include <WebCore/IntRect.h> #include <WebCore/SoftLinking.h> #include <WebCore/WebCoreInstanceHandle.h> @@ -47,17 +53,17 @@ #include <wtf/text/WTFString.h> namespace Ime { - // We need these functions in a separate namespace, because in the global namespace they conflict - // with the definitions in imm.h only by the type modifier (the macro defines them as static) and - // imm.h is included by windows.h - SOFT_LINK_LIBRARY(IMM32) - SOFT_LINK(IMM32, ImmGetContext, HIMC, WINAPI, (HWND hwnd), (hwnd)) - SOFT_LINK(IMM32, ImmReleaseContext, BOOL, WINAPI, (HWND hWnd, HIMC hIMC), (hWnd, hIMC)) - SOFT_LINK(IMM32, ImmGetCompositionStringW, LONG, WINAPI, (HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen), (hIMC, dwIndex, lpBuf, dwBufLen)) - SOFT_LINK(IMM32, ImmSetCandidateWindow, BOOL, WINAPI, (HIMC hIMC, LPCANDIDATEFORM lpCandidate), (hIMC, lpCandidate)) - SOFT_LINK(IMM32, ImmSetOpenStatus, BOOL, WINAPI, (HIMC hIMC, BOOL fOpen), (hIMC, fOpen)) - SOFT_LINK(IMM32, ImmNotifyIME, BOOL, WINAPI, (HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue), (hIMC, dwAction, dwIndex, dwValue)) - SOFT_LINK(IMM32, ImmAssociateContextEx, BOOL, WINAPI, (HWND hWnd, HIMC hIMC, DWORD dwFlags), (hWnd, hIMC, dwFlags)) +// We need these functions in a separate namespace, because in the global namespace they conflict +// with the definitions in imm.h only by the type modifier (the macro defines them as static) and +// imm.h is included by windows.h +SOFT_LINK_LIBRARY(IMM32) +SOFT_LINK(IMM32, ImmGetContext, HIMC, WINAPI, (HWND hwnd), (hwnd)) +SOFT_LINK(IMM32, ImmReleaseContext, BOOL, WINAPI, (HWND hWnd, HIMC hIMC), (hWnd, hIMC)) +SOFT_LINK(IMM32, ImmGetCompositionStringW, LONG, WINAPI, (HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen), (hIMC, dwIndex, lpBuf, dwBufLen)) +SOFT_LINK(IMM32, ImmSetCandidateWindow, BOOL, WINAPI, (HIMC hIMC, LPCANDIDATEFORM lpCandidate), (hIMC, lpCandidate)) +SOFT_LINK(IMM32, ImmSetOpenStatus, BOOL, WINAPI, (HIMC hIMC, BOOL fOpen), (hIMC, fOpen)) +SOFT_LINK(IMM32, ImmNotifyIME, BOOL, WINAPI, (HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue), (hIMC, dwAction, dwIndex, dwValue)) +SOFT_LINK(IMM32, ImmAssociateContextEx, BOOL, WINAPI, (HWND hWnd, HIMC hIMC, DWORD dwFlags), (hWnd, hIMC, dwFlags)) }; using namespace WebCore; @@ -76,6 +82,13 @@ enum { UpdateActiveStateTimer = 1, }; +static bool useNewDrawingArea() +{ + // FIXME: Remove this function and the old drawing area code once we aren't interested in + // testing the old drawing area anymore. + return true; +} + LRESULT CALLBACK WebView::WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { LONG_PTR longPtr = ::GetWindowLongPtr(hWnd, 0); @@ -100,93 +113,93 @@ LRESULT WebView::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) bool handled = true; switch (message) { - case WM_CLOSE: - m_page->tryClose(); - break; - case WM_DESTROY: - m_isBeingDestroyed = true; - close(); - break; - case WM_ERASEBKGND: - lResult = 1; - break; - case WM_PAINT: - lResult = onPaintEvent(hWnd, message, wParam, lParam, handled); - break; - case WM_PRINTCLIENT: - lResult = onPrintClientEvent(hWnd, message, wParam, lParam, handled); - break; - case WM_MOUSEACTIVATE: - setWasActivatedByMouseEvent(true); - handled = false; - break; - case WM_MOUSEMOVE: - case WM_LBUTTONDOWN: - case WM_MBUTTONDOWN: - case WM_RBUTTONDOWN: - case WM_LBUTTONDBLCLK: - case WM_MBUTTONDBLCLK: - case WM_RBUTTONDBLCLK: - case WM_LBUTTONUP: - case WM_MBUTTONUP: - case WM_RBUTTONUP: - case WM_MOUSELEAVE: - lResult = onMouseEvent(hWnd, message, wParam, lParam, handled); - break; - case WM_MOUSEWHEEL: - case WM_VISTA_MOUSEHWHEEL: - lResult = onWheelEvent(hWnd, message, wParam, lParam, handled); - break; - case WM_SYSKEYDOWN: - case WM_KEYDOWN: - case WM_SYSCHAR: - case WM_CHAR: - case WM_SYSKEYUP: - case WM_KEYUP: - lResult = onKeyEvent(hWnd, message, wParam, lParam, handled); - break; - case WM_SIZE: - lResult = onSizeEvent(hWnd, message, wParam, lParam, handled); - break; - case WM_WINDOWPOSCHANGED: - lResult = onWindowPositionChangedEvent(hWnd, message, wParam, lParam, handled); - break; - case WM_SETFOCUS: - lResult = onSetFocusEvent(hWnd, message, wParam, lParam, handled); - break; - case WM_KILLFOCUS: - lResult = onKillFocusEvent(hWnd, message, wParam, lParam, handled); - break; - case WM_TIMER: - lResult = onTimerEvent(hWnd, message, wParam, lParam, handled); - break; - case WM_SHOWWINDOW: - lResult = onShowWindowEvent(hWnd, message, wParam, lParam, handled); - break; - case WM_SETCURSOR: - lResult = onSetCursor(hWnd, message, wParam, lParam, handled); - break; - case WM_IME_STARTCOMPOSITION: - handled = onIMEStartComposition(); - break; - case WM_IME_REQUEST: - lResult = onIMERequest(wParam, lParam); - break; - case WM_IME_COMPOSITION: - handled = onIMEComposition(lParam); - break; - case WM_IME_ENDCOMPOSITION: - handled = onIMEEndComposition(); - break; - case WM_IME_SELECT: - handled = onIMESelect(wParam, lParam); - break; - case WM_IME_SETCONTEXT: - handled = onIMESetContext(wParam, lParam); - break; - default: - handled = false; - break; + case WM_CLOSE: + m_page->tryClose(); + break; + case WM_DESTROY: + m_isBeingDestroyed = true; + close(); + break; + case WM_ERASEBKGND: + lResult = 1; + break; + case WM_PAINT: + lResult = onPaintEvent(hWnd, message, wParam, lParam, handled); + break; + case WM_PRINTCLIENT: + lResult = onPrintClientEvent(hWnd, message, wParam, lParam, handled); + break; + case WM_MOUSEACTIVATE: + setWasActivatedByMouseEvent(true); + handled = false; + break; + case WM_MOUSEMOVE: + case WM_LBUTTONDOWN: + case WM_MBUTTONDOWN: + case WM_RBUTTONDOWN: + case WM_LBUTTONDBLCLK: + case WM_MBUTTONDBLCLK: + case WM_RBUTTONDBLCLK: + case WM_LBUTTONUP: + case WM_MBUTTONUP: + case WM_RBUTTONUP: + case WM_MOUSELEAVE: + lResult = onMouseEvent(hWnd, message, wParam, lParam, handled); + break; + case WM_MOUSEWHEEL: + case WM_VISTA_MOUSEHWHEEL: + lResult = onWheelEvent(hWnd, message, wParam, lParam, handled); + break; + case WM_SYSKEYDOWN: + case WM_KEYDOWN: + case WM_SYSCHAR: + case WM_CHAR: + case WM_SYSKEYUP: + case WM_KEYUP: + lResult = onKeyEvent(hWnd, message, wParam, lParam, handled); + break; + case WM_SIZE: + lResult = onSizeEvent(hWnd, message, wParam, lParam, handled); + break; + case WM_WINDOWPOSCHANGED: + lResult = onWindowPositionChangedEvent(hWnd, message, wParam, lParam, handled); + break; + case WM_SETFOCUS: + lResult = onSetFocusEvent(hWnd, message, wParam, lParam, handled); + break; + case WM_KILLFOCUS: + lResult = onKillFocusEvent(hWnd, message, wParam, lParam, handled); + break; + case WM_TIMER: + lResult = onTimerEvent(hWnd, message, wParam, lParam, handled); + break; + case WM_SHOWWINDOW: + lResult = onShowWindowEvent(hWnd, message, wParam, lParam, handled); + break; + case WM_SETCURSOR: + lResult = onSetCursor(hWnd, message, wParam, lParam, handled); + break; + case WM_IME_STARTCOMPOSITION: + handled = onIMEStartComposition(); + break; + case WM_IME_REQUEST: + lResult = onIMERequest(wParam, lParam); + break; + case WM_IME_COMPOSITION: + handled = onIMEComposition(lParam); + break; + case WM_IME_ENDCOMPOSITION: + handled = onIMEEndComposition(); + break; + case WM_IME_SELECT: + handled = onIMESelect(wParam, lParam); + break; + case WM_IME_SETCONTEXT: + handled = onIMESetContext(wParam, lParam); + break; + default: + handled = false; + break; } if (!handled) @@ -232,18 +245,23 @@ WebView::WebView(RECT rect, WebContext* context, WebPageGroup* pageGroup, HWND p , m_wasActivatedByMouseEvent(false) , m_isBeingDestroyed(false) , m_inIMEComposition(0) + , m_findIndicatorCallback(0) + , m_findIndicatorCallbackContext(0) { registerWebViewWindowClass(); - m_page = context->createWebPage(this, pageGroup); - - m_window = ::CreateWindowEx(0, kWebKit2WebViewWindowClassName, 0, WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, + m_window = ::CreateWindowExW(0, kWebKit2WebViewWindowClassName, 0, WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE, rect.top, rect.left, rect.right - rect.left, rect.bottom - rect.top, parentWindow ? parentWindow : HWND_MESSAGE, 0, instanceHandle(), this); ASSERT(::IsWindow(m_window)); + // We only check our window style, and not ::IsWindowVisible, because m_isVisible only tracks + // this window's visibility status, while ::IsWindowVisible takes our ancestors' visibility + // status into account. <http://webkit.org/b/54104> + ASSERT(m_isVisible == static_cast<bool>(::GetWindowLong(m_window, GWL_STYLE) & WS_VISIBLE)); + m_page = context->createWebPage(this, pageGroup); m_page->initializeWebPage(); - ::ShowWindow(m_window, SW_SHOW); + CoCreateInstance(CLSID_DragDropHelper, 0, CLSCTX_INPROC_SERVER, IID_IDropTargetHelper, (void**)&m_dropTargetHelper); // FIXME: Initializing the tooltip window here matches WebKit win, but seems like something // we could do on demand to save resources. @@ -260,6 +278,11 @@ WebView::~WebView() ::DestroyWindow(m_toolTipWindow); } +void WebView::initialize() +{ + ::RegisterDragDrop(m_window, this); +} + void WebView::setParentWindow(HWND parentWindow) { if (m_window) { @@ -325,29 +348,29 @@ LRESULT WebView::onMouseEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa setWasActivatedByMouseEvent(false); switch (message) { - case WM_LBUTTONDOWN: - case WM_MBUTTONDOWN: - case WM_RBUTTONDOWN: - ::SetFocus(m_window); - ::SetCapture(m_window); - break; - case WM_LBUTTONUP: - case WM_MBUTTONUP: - case WM_RBUTTONUP: - ::ReleaseCapture(); - break; - case WM_MOUSEMOVE: - startTrackingMouseLeave(); - break; - case WM_MOUSELEAVE: - stopTrackingMouseLeave(); - break; - case WM_LBUTTONDBLCLK: - case WM_MBUTTONDBLCLK: - case WM_RBUTTONDBLCLK: - break; - default: - ASSERT_NOT_REACHED(); + case WM_LBUTTONDOWN: + case WM_MBUTTONDOWN: + case WM_RBUTTONDOWN: + ::SetFocus(m_window); + ::SetCapture(m_window); + break; + case WM_LBUTTONUP: + case WM_MBUTTONUP: + case WM_RBUTTONUP: + ::ReleaseCapture(); + break; + case WM_MOUSEMOVE: + startTrackingMouseLeave(); + break; + case WM_MOUSELEAVE: + stopTrackingMouseLeave(); + break; + case WM_LBUTTONDBLCLK: + case WM_MBUTTONDBLCLK: + case WM_RBUTTONDBLCLK: + break; + default: + ASSERT_NOT_REACHED(); } m_page->handleMouseEvent(mouseEvent); @@ -382,19 +405,45 @@ LRESULT WebView::onKeyEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPara return 0; } +static void drawPageBackground(HDC dc, const RECT& rect) +{ + // Mac checks WebPageProxy::drawsBackground and + // WebPageProxy::drawsTransparentBackground here, but those are always false on + // Windows currently (see <http://webkit.org/b/52009>). + ::FillRect(dc, &rect, reinterpret_cast<HBRUSH>(COLOR_WINDOW + 1)); +} + +void WebView::paint(HDC hdc, const IntRect& dirtyRect) +{ + if (useNewDrawingArea()) { + if (DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(m_page->drawingArea())) { + // FIXME: We should port WebKit1's rect coalescing logic here. + Region unpaintedRegion; + drawingArea->paint(hdc, dirtyRect, unpaintedRegion); + + Vector<IntRect> unpaintedRects = unpaintedRegion.rects(); + for (size_t i = 0; i < unpaintedRects.size(); ++i) { + RECT winRect = unpaintedRects[i]; + drawPageBackground(hdc, unpaintedRects[i]); + } + } else + drawPageBackground(hdc, dirtyRect); + + m_page->didDraw(); + } else { + if (m_page->isValid() && m_page->drawingArea() && m_page->drawingArea()->paint(dirtyRect, hdc)) + m_page->didDraw(); + else + drawPageBackground(hdc, dirtyRect); + } +} + LRESULT WebView::onPaintEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled) { PAINTSTRUCT paintStruct; HDC hdc = ::BeginPaint(m_window, &paintStruct); - if (m_page->isValid() && m_page->drawingArea() && m_page->drawingArea()->paint(IntRect(paintStruct.rcPaint), hdc)) - m_page->didDraw(); - else { - // Mac checks WebPageProxy::drawsBackground and - // WebPageProxy::drawsTransparentBackground here, but those are always false on Windows - // currently (see <http://webkit.org/b/52009>). - ::FillRect(hdc, &paintStruct.rcPaint, reinterpret_cast<HBRUSH>(COLOR_WINDOW + 1)); - } + paint(hdc, paintStruct.rcPaint); ::EndPaint(m_window, &paintStruct); @@ -407,9 +456,8 @@ LRESULT WebView::onPrintClientEvent(HWND hWnd, UINT, WPARAM wParam, LPARAM, bool HDC hdc = reinterpret_cast<HDC>(wParam); RECT winRect; ::GetClientRect(hWnd, &winRect); - IntRect rect = winRect; - m_page->drawingArea()->paint(rect, hdc); + paint(hdc, winRect); handled = true; return 0; @@ -420,8 +468,8 @@ LRESULT WebView::onSizeEvent(HWND, UINT, WPARAM, LPARAM lParam, bool& handled) int width = LOWORD(lParam); int height = HIWORD(lParam); - if (m_page->drawingArea()) - m_page->drawingArea()->setSize(IntSize(width, height)); + if (m_page && m_page->drawingArea()) + m_page->drawingArea()->setSize(IntSize(width, height), IntSize()); handled = true; return 0; @@ -453,10 +501,10 @@ LRESULT WebView::onKillFocusEvent(HWND, UINT, WPARAM, LPARAM lParam, bool& handl LRESULT WebView::onTimerEvent(HWND hWnd, UINT, WPARAM wParam, LPARAM, bool& handled) { switch (wParam) { - case UpdateActiveStateTimer: - ::KillTimer(hWnd, UpdateActiveStateTimer); - updateActiveState(); - break; + case UpdateActiveStateTimer: + ::KillTimer(hWnd, UpdateActiveStateTimer); + updateActiveState(); + break; } handled = true; @@ -466,14 +514,15 @@ LRESULT WebView::onTimerEvent(HWND hWnd, UINT, WPARAM wParam, LPARAM, bool& hand LRESULT WebView::onShowWindowEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool& handled) { // lParam is 0 when the message is sent because of a ShowWindow call. - // FIXME: Is WM_SHOWWINDOW sent when ShowWindow is called on an ancestor of our window? + // FIXME: Since we don't get notified when an ancestor window is hidden or shown, we will keep + // painting even when we have a hidden ancestor. <http://webkit.org/b/54104> if (!lParam) { m_isVisible = wParam; - m_page->viewStateDidChange(WebPageProxy::ViewIsVisible); - - handled = true; + if (m_page) + m_page->viewStateDidChange(WebPageProxy::ViewIsVisible); } + handled = false; return 0; } @@ -569,6 +618,7 @@ void WebView::stopTrackingMouseLeave() void WebView::close() { + ::RevokeDragDrop(m_window); setParentWindow(0); m_page->close(); } @@ -577,6 +627,9 @@ void WebView::close() PassOwnPtr<DrawingAreaProxy> WebView::createDrawingAreaProxy() { + if (useNewDrawingArea()) + return DrawingAreaProxyImpl::create(m_page.get()); + return ChunkedUpdateDrawingAreaProxy::create(this, m_page.get()); } @@ -626,6 +679,10 @@ bool WebView::isViewInWindow() return m_isInWindow; } +void WebView::pageClosed() +{ +} + void WebView::processDidCrash() { updateNativeCursor(); @@ -740,11 +797,11 @@ void WebView::prepareCandidateWindow(HIMC hInputContext) form.dwIndex = 0; form.dwStyle = CFS_EXCLUDE; form.ptCurrentPos.x = caret.x(); - form.ptCurrentPos.y = caret.bottom(); + form.ptCurrentPos.y = caret.maxY(); form.rcArea.top = caret.y(); - form.rcArea.bottom = caret.bottom(); + form.rcArea.bottom = caret.maxY(); form.rcArea.left = caret.x(); - form.rcArea.right = caret.right(); + form.rcArea.right = caret.maxX(); Ime::ImmSetCandidateWindow(hInputContext, &form); } @@ -962,11 +1019,11 @@ LRESULT WebView::onIMERequest(WPARAM request, LPARAM data) return 0; switch (request) { - case IMR_RECONVERTSTRING: - return onIMERequestReconvertString(reinterpret_cast<RECONVERTSTRING*>(data)); + case IMR_RECONVERTSTRING: + return onIMERequestReconvertString(reinterpret_cast<RECONVERTSTRING*>(data)); - case IMR_QUERYCHARPOSITION: - return onIMERequestCharPosition(reinterpret_cast<IMECHARPOSITION*>(data)); + case IMR_QUERYCHARPOSITION: + return onIMERequestCharPosition(reinterpret_cast<IMECHARPOSITION*>(data)); } return 0; } @@ -985,11 +1042,12 @@ bool WebView::onIMESetContext(WPARAM wparam, LPARAM) return false; } -void WebView::didNotHandleKeyEvent(const NativeWebKeyboardEvent& event) +void WebView::doneWithKeyEvent(const NativeWebKeyboardEvent& event, bool wasEventHandled) { // Calling ::DefWindowProcW will ensure that pressing the Alt key will generate a WM_SYSCOMMAND // event, e.g. See <http://webkit.org/b/47671>. - ::DefWindowProcW(event.nativeEvent()->hwnd, event.nativeEvent()->message, event.nativeEvent()->wParam, event.nativeEvent()->lParam); + if (!wasEventHandled) + ::DefWindowProcW(event.nativeEvent()->hwnd, event.nativeEvent()->message, event.nativeEvent()->wParam, event.nativeEvent()->lParam); } PassRefPtr<WebPopupMenuProxy> WebView::createPopupMenuProxy(WebPageProxy* page) @@ -1002,9 +1060,54 @@ PassRefPtr<WebContextMenuProxy> WebView::createContextMenuProxy(WebPageProxy* pa return WebContextMenuProxyWin::create(m_window, page); } -void WebView::setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut) +void WebView::setFindIndicator(PassRefPtr<FindIndicator> prpFindIndicator, bool fadeOut) { - // FIXME: Implement. + if (!m_findIndicatorCallback) + return; + + HBITMAP hbmp = 0; + IntRect selectionRect; + + if (RefPtr<FindIndicator> findIndicator = prpFindIndicator) { + if (ShareableBitmap* contentImage = findIndicator->contentImage()) { + // Render the contentImage to an HBITMAP. + void* bits; + HDC hdc = ::CreateCompatibleDC(0); + int width = contentImage->bounds().width(); + int height = contentImage->bounds().height(); + BitmapInfo bitmapInfo = BitmapInfo::create(contentImage->size()); + + hbmp = CreateDIBSection(0, &bitmapInfo, DIB_RGB_COLORS, static_cast<void**>(&bits), 0, 0); + HBITMAP hbmpOld = static_cast<HBITMAP>(SelectObject(hdc, hbmp)); + RetainPtr<CGContextRef> context(AdoptCF, CGBitmapContextCreate(bits, width, height, + 8, width * sizeof(RGBQUAD), deviceRGBColorSpaceRef(), kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst)); + + GraphicsContext graphicsContext(context.get()); + contentImage->paint(graphicsContext, IntPoint(), contentImage->bounds()); + + ::SelectObject(hdc, hbmpOld); + ::DeleteDC(hdc); + } + + selectionRect = IntRect(findIndicator->selectionRectInWindowCoordinates()); + } + + // The callback is responsible for calling ::DeleteObject(hbmp). + (*m_findIndicatorCallback)(toAPI(this), hbmp, selectionRect, fadeOut, m_findIndicatorCallbackContext); +} + +void WebView::setFindIndicatorCallback(WKViewFindIndicatorCallback callback, void* context) +{ + m_findIndicatorCallback = callback; + m_findIndicatorCallbackContext = context; +} + +WKViewFindIndicatorCallback WebView::getFindIndicatorCallback(void** context) +{ + if (context) + *context = m_findIndicatorCallbackContext; + + return m_findIndicatorCallback; } void WebView::didCommitLoadForMainFrame(bool useCustomRepresentation) @@ -1024,6 +1127,10 @@ void WebView::setCustomRepresentationZoomFactor(double) { } +void WebView::didChangeScrollbarsForMainFrame() const +{ +} + void WebView::setIsInWindow(bool isInWindow) { m_isInWindow = isInWindow; @@ -1032,36 +1139,55 @@ void WebView::setIsInWindow(bool isInWindow) #if USE(ACCELERATED_COMPOSITING) +void WebView::enterAcceleratedCompositingMode(const LayerTreeContext&) +{ + ASSERT(useNewDrawingArea()); + // FIXME: Implement. + ASSERT_NOT_REACHED(); +} + +void WebView::exitAcceleratedCompositingMode() +{ + ASSERT(useNewDrawingArea()); + // FIXME: Implement. + ASSERT_NOT_REACHED(); +} + void WebView::pageDidEnterAcceleratedCompositing() { + ASSERT(!useNewDrawingArea()); switchToDrawingAreaTypeIfNecessary(DrawingAreaInfo::LayerBacked); } void WebView::pageDidLeaveAcceleratedCompositing() { + ASSERT(!useNewDrawingArea()); switchToDrawingAreaTypeIfNecessary(DrawingAreaInfo::ChunkedUpdate); } void WebView::switchToDrawingAreaTypeIfNecessary(DrawingAreaInfo::Type type) { + ASSERT(!useNewDrawingArea()); + DrawingAreaInfo::Type existingDrawingAreaType = m_page->drawingArea() ? m_page->drawingArea()->info().type : DrawingAreaInfo::None; if (existingDrawingAreaType == type) return; OwnPtr<DrawingAreaProxy> newDrawingArea; switch (type) { - case DrawingAreaInfo::None: - break; - case DrawingAreaInfo::ChunkedUpdate: - newDrawingArea = ChunkedUpdateDrawingAreaProxy::create(this, m_page.get()); - break; - case DrawingAreaInfo::LayerBacked: - newDrawingArea = LayerBackedDrawingAreaProxy::create(this, m_page.get()); - break; + case DrawingAreaInfo::Impl: + case DrawingAreaInfo::None: + break; + case DrawingAreaInfo::ChunkedUpdate: + newDrawingArea = ChunkedUpdateDrawingAreaProxy::create(this, m_page.get()); + break; + case DrawingAreaInfo::LayerBacked: + newDrawingArea = LayerBackedDrawingAreaProxy::create(this, m_page.get()); + break; } if (m_page->drawingArea()) - newDrawingArea->setSize(m_page->drawingArea()->size()); + newDrawingArea->setSize(m_page->drawingArea()->size(), IntSize()); m_page->drawingArea()->detachCompositingContext(); m_page->setDrawingArea(newDrawingArea.release()); @@ -1079,13 +1205,140 @@ HWND WebView::nativeWindow() void WebView::windowReceivedMessage(HWND, UINT message, WPARAM wParam, LPARAM) { switch (message) { - case WM_NCACTIVATE: - updateActiveStateSoon(); - break; - case WM_SETTINGCHANGE: - // systemParameterChanged(wParam); - break; + case WM_NCACTIVATE: + updateActiveStateSoon(); + break; + case WM_SETTINGCHANGE: + // systemParameterChanged(wParam); + break; } } +HRESULT STDMETHODCALLTYPE WebView::QueryInterface(REFIID riid, void** ppvObject) +{ + *ppvObject = 0; + if (IsEqualGUID(riid, IID_IUnknown)) + *ppvObject = static_cast<IUnknown*>(this); + else if (IsEqualGUID(riid, IID_IDropTarget)) + *ppvObject = static_cast<IDropTarget*>(this); + else + return E_NOINTERFACE; + + AddRef(); + return S_OK; +} + +ULONG STDMETHODCALLTYPE WebView::AddRef(void) +{ + ref(); + return refCount(); +} + +ULONG STDMETHODCALLTYPE WebView::Release(void) +{ + deref(); + return refCount(); +} + +static DWORD dragOperationToDragCursor(DragOperation op) +{ + DWORD res = DROPEFFECT_NONE; + if (op & DragOperationCopy) + res = DROPEFFECT_COPY; + else if (op & DragOperationLink) + res = DROPEFFECT_LINK; + else if (op & DragOperationMove) + res = DROPEFFECT_MOVE; + else if (op & DragOperationGeneric) + res = DROPEFFECT_MOVE; // This appears to be the Firefox behaviour + return res; +} + +WebCore::DragOperation WebView::keyStateToDragOperation(DWORD grfKeyState) const +{ + if (!m_page) + return DragOperationNone; + + // Conforms to Microsoft's key combinations as documented for + // IDropTarget::DragOver. Note, grfKeyState is the current + // state of the keyboard modifier keys on the keyboard. See: + // <http://msdn.microsoft.com/en-us/library/ms680129(VS.85).aspx>. + DragOperation operation = m_page->dragOperation(); + + if ((grfKeyState & (MK_CONTROL | MK_SHIFT)) == (MK_CONTROL | MK_SHIFT)) + operation = DragOperationLink; + else if ((grfKeyState & MK_CONTROL) == MK_CONTROL) + operation = DragOperationCopy; + else if ((grfKeyState & MK_SHIFT) == MK_SHIFT) + operation = DragOperationGeneric; + + return operation; +} + +HRESULT STDMETHODCALLTYPE WebView::DragEnter(IDataObject* pDataObject, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect) +{ + m_dragData = 0; + m_page->resetDragOperation(); + + if (m_dropTargetHelper) + m_dropTargetHelper->DragEnter(m_window, pDataObject, (POINT*)&pt, *pdwEffect); + + POINTL localpt = pt; + ::ScreenToClient(m_window, (LPPOINT)&localpt); + DragData data(pDataObject, IntPoint(localpt.x, localpt.y), IntPoint(pt.x, pt.y), keyStateToDragOperation(grfKeyState)); + m_page->performDragControllerAction(DragControllerActionEntered, &data); + *pdwEffect = dragOperationToDragCursor(m_page->dragOperation()); + + m_lastDropEffect = *pdwEffect; + m_dragData = pDataObject; + + return S_OK; +} + +HRESULT STDMETHODCALLTYPE WebView::DragOver(DWORD grfKeyState, POINTL pt, DWORD* pdwEffect) +{ + if (m_dropTargetHelper) + m_dropTargetHelper->DragOver((POINT*)&pt, *pdwEffect); + + if (m_dragData) { + POINTL localpt = pt; + ::ScreenToClient(m_window, (LPPOINT)&localpt); + DragData data(m_dragData.get(), IntPoint(localpt.x, localpt.y), IntPoint(pt.x, pt.y), keyStateToDragOperation(grfKeyState)); + m_page->performDragControllerAction(DragControllerActionUpdated, &data); + *pdwEffect = dragOperationToDragCursor(m_page->dragOperation()); + } else + *pdwEffect = DROPEFFECT_NONE; + + m_lastDropEffect = *pdwEffect; + return S_OK; +} + +HRESULT STDMETHODCALLTYPE WebView::DragLeave() +{ + if (m_dropTargetHelper) + m_dropTargetHelper->DragLeave(); + + if (m_dragData) { + DragData data(m_dragData.get(), IntPoint(), IntPoint(), DragOperationNone); + m_page->performDragControllerAction(DragControllerActionExited, &data); + m_dragData = 0; + m_page->resetDragOperation(); + } + return S_OK; +} + +HRESULT STDMETHODCALLTYPE WebView::Drop(IDataObject* pDataObject, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect) +{ + if (m_dropTargetHelper) + m_dropTargetHelper->Drop(pDataObject, (POINT*)&pt, *pdwEffect); + + m_dragData = 0; + *pdwEffect = m_lastDropEffect; + POINTL localpt = pt; + ::ScreenToClient(m_window, (LPPOINT)&localpt); + DragData data(pDataObject, IntPoint(localpt.x, localpt.y), IntPoint(pt.x, pt.y), keyStateToDragOperation(grfKeyState)); + m_page->performDragControllerAction(DragControllerActionPerformDrag, &data); + return S_OK; +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/win/WebView.h b/Source/WebKit2/UIProcess/win/WebView.h index dfb5ed1..297b6ad 100644 --- a/Source/WebKit2/UIProcess/win/WebView.h +++ b/Source/WebKit2/UIProcess/win/WebView.h @@ -28,21 +28,30 @@ #include "APIObject.h" #include "PageClient.h" +#include "WKView.h" #include "WebPageProxy.h" +#include <ShlObj.h> +#include <WebCore/COMPtr.h> +#include <WebCore/DragActions.h> +#include <WebCore/DragData.h> #include <WebCore/WindowMessageListener.h> #include <wtf/Forward.h> #include <wtf/PassRefPtr.h> #include <wtf/RefPtr.h> +interface IDropTargetHelper; + namespace WebKit { class DrawingAreaProxy; -class WebView : public APIObject, public PageClient, WebCore::WindowMessageListener { +class WebView : public APIObject, public PageClient, WebCore::WindowMessageListener, public IDropTarget { public: static PassRefPtr<WebView> create(RECT rect, WebContext* context, WebPageGroup* pageGroup, HWND parentWindow) { - return adoptRef(new WebView(rect, context, pageGroup, parentWindow)); + RefPtr<WebView> webView = adoptRef(new WebView(rect, context, pageGroup, parentWindow)); + webView->initialize(); + return webView; } ~WebView(); @@ -50,8 +59,22 @@ public: void setParentWindow(HWND); void windowAncestryDidChange(); void setIsInWindow(bool); - void setOverrideCursor(HCURSOR overrideCursor); + void setOverrideCursor(HCURSOR); void setInitialFocus(bool forward); + void setFindIndicatorCallback(WKViewFindIndicatorCallback, void*); + WKViewFindIndicatorCallback getFindIndicatorCallback(void**); + void initialize(); + + // IUnknown + virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject); + virtual ULONG STDMETHODCALLTYPE AddRef(void); + virtual ULONG STDMETHODCALLTYPE Release(void); + + // IDropTarget + virtual HRESULT STDMETHODCALLTYPE DragEnter(IDataObject* pDataObject, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect); + virtual HRESULT STDMETHODCALLTYPE DragOver(DWORD grfKeyState, POINTL pt, DWORD* pdwEffect); + virtual HRESULT STDMETHODCALLTYPE DragLeave(); + virtual HRESULT STDMETHODCALLTYPE Drop(IDataObject* pDataObject, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect); WebPageProxy* page() const { return m_page.get(); } @@ -64,7 +87,6 @@ private: static LRESULT CALLBACK WebViewWndProc(HWND, UINT, WPARAM, LPARAM); LRESULT wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); - void setWasActivatedByMouseEvent(bool flag) { m_wasActivatedByMouseEvent = flag; } LRESULT onMouseEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); LRESULT onWheelEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); LRESULT onKeyEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); @@ -77,6 +99,9 @@ private: LRESULT onTimerEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); LRESULT onShowWindowEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); LRESULT onSetCursor(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); + + void paint(HDC, const WebCore::IntRect& dirtyRect); + void setWasActivatedByMouseEvent(bool flag) { m_wasActivatedByMouseEvent = flag; } bool onIMEStartComposition(); bool onIMEComposition(LPARAM); bool onIMEEndComposition(); @@ -116,6 +141,7 @@ private: virtual bool isViewInWindow(); virtual void processDidCrash(); virtual void didRelaunchProcess(); + virtual void pageClosed(); virtual void takeFocus(bool direction); virtual void toolTipChanged(const WTF::String&, const WTF::String&); virtual void setCursor(const WebCore::Cursor&); @@ -125,13 +151,16 @@ private: virtual void setEditCommandState(const WTF::String&, bool, int); virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&); virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&); - virtual void didNotHandleKeyEvent(const NativeWebKeyboardEvent&); + virtual void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool wasEventHandled); virtual void compositionSelectionChanged(bool); virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*); virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*); virtual void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut); #if USE(ACCELERATED_COMPOSITING) + virtual void enterAcceleratedCompositingMode(const LayerTreeContext&); + virtual void exitAcceleratedCompositingMode(); + virtual void pageDidEnterAcceleratedCompositing(); virtual void pageDidLeaveAcceleratedCompositing(); void switchToDrawingAreaTypeIfNecessary(DrawingAreaInfo::Type); @@ -141,6 +170,8 @@ private: void didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference&); virtual double customRepresentationZoomFactor(); virtual void setCustomRepresentationZoomFactor(double); + WebCore::DragOperation keyStateToDragOperation(DWORD grfKeyState) const; + virtual void didChangeScrollbarsForMainFrame() const; virtual HWND nativeWindow(); @@ -164,6 +195,17 @@ private: RefPtr<WebPageProxy> m_page; unsigned m_inIMEComposition; + + WKViewFindIndicatorCallback m_findIndicatorCallback; + void* m_findIndicatorCallbackContext; + + COMPtr<IDataObject> m_dragData; + COMPtr<IDropTargetHelper> m_dropTargetHelper; + // FIXME: This variable is part of a workaround. The drop effect (pdwEffect) passed to Drop is incorrect. + // We set this variable in DragEnter and DragOver so that it can be used in Drop to set the correct drop effect. + // Thus, on return from DoDragDrop we have the correct pdwEffect for the drag-and-drop operation. + // (see https://bugs.webkit.org/show_bug.cgi?id=29264) + DWORD m_lastDropEffect; }; } // namespace WebKit |