summaryrefslogtreecommitdiffstats
path: root/Source/WebKit2/UIProcess/win/WebView.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2011-05-25 19:08:45 +0100
committerSteve Block <steveblock@google.com>2011-06-08 13:51:31 +0100
commit2bde8e466a4451c7319e3a072d118917957d6554 (patch)
tree28f4a1b869a513e565c7760d0e6a06e7cf1fe95a /Source/WebKit2/UIProcess/win/WebView.cpp
parent6939c99b71d9372d14a0c74a772108052e8c48c8 (diff)
downloadexternal_webkit-2bde8e466a4451c7319e3a072d118917957d6554.zip
external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.gz
external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.bz2
Merge WebKit at r82507: Initial merge by git
Change-Id: I60ce9d780725b58b45e54165733a8ffee23b683e
Diffstat (limited to 'Source/WebKit2/UIProcess/win/WebView.cpp')
-rw-r--r--Source/WebKit2/UIProcess/win/WebView.cpp159
1 files changed, 156 insertions, 3 deletions
diff --git a/Source/WebKit2/UIProcess/win/WebView.cpp b/Source/WebKit2/UIProcess/win/WebView.cpp
index 62e0c42..1447864 100644
--- a/Source/WebKit2/UIProcess/win/WebView.cpp
+++ b/Source/WebKit2/UIProcess/win/WebView.cpp
@@ -44,7 +44,9 @@
#include <WebCore/BitmapInfo.h>
#include <WebCore/Cursor.h>
#include <WebCore/FloatRect.h>
+#if PLATFORM(CG)
#include <WebCore/GraphicsContextCG.h>
+#endif
#include <WebCore/IntRect.h>
#include <WebCore/SoftLinking.h>
#include <WebCore/WebCoreInstanceHandle.h>
@@ -149,6 +151,12 @@ LRESULT WebView::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_VISTA_MOUSEHWHEEL:
lResult = onWheelEvent(hWnd, message, wParam, lParam, handled);
break;
+ case WM_HSCROLL:
+ lResult = onHorizontalScroll(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_VSCROLL:
+ lResult = onVerticalScroll(hWnd, message, wParam, lParam, handled);
+ break;
case WM_SYSKEYDOWN:
case WM_KEYDOWN:
case WM_SYSCHAR:
@@ -280,6 +288,20 @@ WebView::~WebView()
void WebView::initialize()
{
::RegisterDragDrop(m_window, this);
+
+ if (shouldInitializeTrackPointHack()) {
+ // If we detected a registry key belonging to a TrackPoint driver, then create fake
+ // scrollbars, so the WebView will receive WM_VSCROLL and WM_HSCROLL messages.
+ // We create an invisible vertical scrollbar and an invisible horizontal scrollbar to allow
+ // for receiving both types of messages.
+ ::CreateWindow(TEXT("SCROLLBAR"), TEXT("FAKETRACKPOINTHSCROLLBAR"), WS_CHILD | WS_VISIBLE | SBS_HORZ, 0, 0, 0, 0, m_window, 0, instanceHandle(), 0);
+ ::CreateWindow(TEXT("SCROLLBAR"), TEXT("FAKETRACKPOINTVSCROLLBAR"), WS_CHILD | WS_VISIBLE | SBS_VERT, 0, 0, 0, 0, m_window, 0, instanceHandle(), 0);
+ }
+}
+
+void WebView::initializeUndoClient(const WKViewUndoClient* client)
+{
+ m_undoClient.initialize(client);
}
void WebView::setParentWindow(HWND parentWindow)
@@ -394,6 +416,70 @@ LRESULT WebView::onWheelEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
return 0;
}
+LRESULT WebView::onHorizontalScroll(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool& handled)
+{
+ ScrollDirection direction;
+ ScrollGranularity granularity;
+ switch (LOWORD(wParam)) {
+ case SB_LINELEFT:
+ granularity = ScrollByLine;
+ direction = ScrollLeft;
+ break;
+ case SB_LINERIGHT:
+ granularity = ScrollByLine;
+ direction = ScrollRight;
+ break;
+ case SB_PAGELEFT:
+ granularity = ScrollByDocument;
+ direction = ScrollLeft;
+ break;
+ case SB_PAGERIGHT:
+ granularity = ScrollByDocument;
+ direction = ScrollRight;
+ break;
+ default:
+ handled = false;
+ return 0;
+ }
+
+ m_page->scrollBy(direction, granularity);
+
+ handled = true;
+ return 0;
+}
+
+LRESULT WebView::onVerticalScroll(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool& handled)
+{
+ ScrollDirection direction;
+ ScrollGranularity granularity;
+ switch (LOWORD(wParam)) {
+ case SB_LINEDOWN:
+ granularity = ScrollByLine;
+ direction = ScrollDown;
+ break;
+ case SB_LINEUP:
+ granularity = ScrollByLine;
+ direction = ScrollUp;
+ break;
+ case SB_PAGEDOWN:
+ granularity = ScrollByDocument;
+ direction = ScrollDown;
+ break;
+ case SB_PAGEUP:
+ granularity = ScrollByDocument;
+ direction = ScrollUp;
+ break;
+ default:
+ handled = false;
+ return 0;
+ }
+
+ m_page->scrollBy(direction, granularity);
+
+ handled = true;
+ return 0;
+}
+
LRESULT WebView::onKeyEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool& handled)
{
m_page->handleKeyboardEvent(NativeWebKeyboardEvent(hWnd, message, wParam, lParam));
@@ -490,8 +576,10 @@ LRESULT WebView::onSizeEvent(HWND, UINT, WPARAM, LPARAM lParam, bool& handled)
int width = LOWORD(lParam);
int height = HIWORD(lParam);
- if (m_page && m_page->drawingArea())
- m_page->drawingArea()->setSize(IntSize(width, height), IntSize());
+ if (m_page && m_page->drawingArea()) {
+ m_page->drawingArea()->setSize(IntSize(width, height), m_nextResizeScrollOffset);
+ m_nextResizeScrollOffset = IntSize();
+ }
handled = true;
return 0;
@@ -638,8 +726,39 @@ void WebView::stopTrackingMouseLeave()
::TrackMouseEvent(&trackMouseEvent);
}
+bool WebView::shouldInitializeTrackPointHack()
+{
+ static bool shouldCreateScrollbars;
+ static bool hasRunTrackPointCheck;
+
+ if (hasRunTrackPointCheck)
+ return shouldCreateScrollbars;
+
+ hasRunTrackPointCheck = true;
+ const wchar_t* trackPointKeys[] = {
+ L"Software\\Lenovo\\TrackPoint",
+ L"Software\\Lenovo\\UltraNav",
+ L"Software\\Alps\\Apoint\\TrackPoint",
+ L"Software\\Synaptics\\SynTPEnh\\UltraNavUSB",
+ L"Software\\Synaptics\\SynTPEnh\\UltraNavPS2"
+ };
+
+ for (size_t i = 0; i < WTF_ARRAY_LENGTH(trackPointKeys); ++i) {
+ HKEY trackPointKey;
+ int readKeyResult = ::RegOpenKeyExW(HKEY_CURRENT_USER, trackPointKeys[i], 0, KEY_READ, &trackPointKey);
+ ::RegCloseKey(trackPointKey);
+ if (readKeyResult == ERROR_SUCCESS) {
+ shouldCreateScrollbars = true;
+ return shouldCreateScrollbars;
+ }
+ }
+
+ return shouldCreateScrollbars;
+}
+
void WebView::close()
{
+ m_undoClient.initialize(0);
::RevokeDragDrop(m_window);
setParentWindow(0);
m_page->close();
@@ -789,16 +908,41 @@ void WebView::setInitialFocus(bool forward)
m_page->setInitialFocus(forward);
}
+void WebView::setScrollOffsetOnNextResize(const IntSize& scrollOffset)
+{
+ // The next time we get a WM_SIZE message, scroll by the specified amount in onSizeEvent().
+ m_nextResizeScrollOffset = scrollOffset;
+}
+
void WebView::setViewportArguments(const WebCore::ViewportArguments&)
{
}
-void WebView::registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo)
+void WebView::registerEditCommand(PassRefPtr<WebEditCommandProxy> prpCommand, WebPageProxy::UndoOrRedo undoOrRedo)
{
+ RefPtr<WebEditCommandProxy> command = prpCommand;
+ m_undoClient.registerEditCommand(this, command, undoOrRedo);
}
void WebView::clearAllEditCommands()
{
+ m_undoClient.clearAllEditCommands(this);
+}
+
+void WebView::reapplyEditCommand(WebEditCommandProxy* command)
+{
+ if (!m_page->isValid() || !m_page->isValidEditCommand(command))
+ return;
+
+ command->reapply();
+}
+
+void WebView::unapplyEditCommand(WebEditCommandProxy* command)
+{
+ if (!m_page->isValid() || !m_page->isValidEditCommand(command))
+ return;
+
+ command->unapply();
}
FloatRect WebView::convertToDeviceSpace(const FloatRect& rect)
@@ -806,6 +950,11 @@ FloatRect WebView::convertToDeviceSpace(const FloatRect& rect)
return rect;
}
+IntRect WebView::windowToScreen(const IntRect& rect)
+{
+ return rect;
+}
+
FloatRect WebView::convertToUserSpace(const FloatRect& rect)
{
return rect;
@@ -1105,11 +1254,15 @@ void WebView::setFindIndicator(PassRefPtr<FindIndicator> prpFindIndicator, bool
hbmp = CreateDIBSection(0, &bitmapInfo, DIB_RGB_COLORS, static_cast<void**>(&bits), 0, 0);
HBITMAP hbmpOld = static_cast<HBITMAP>(SelectObject(hdc, hbmp));
+#if PLATFORM(CG)
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());
+#else
+ // FIXME: Implement!
+#endif
::SelectObject(hdc, hbmpOld);
::DeleteDC(hdc);