Diff
Modified: trunk/Source/WebCore/ChangeLog (107573 => 107574)
--- trunk/Source/WebCore/ChangeLog 2012-02-13 15:54:24 UTC (rev 107573)
+++ trunk/Source/WebCore/ChangeLog 2012-02-13 16:29:46 UTC (rev 107574)
@@ -1,3 +1,21 @@
+2012-02-13 Patrick Gansterer <[email protected]>
+
+ Add WindowsExtras.h
+ https://bugs.webkit.org/show_bug.cgi?id=78340
+
+ Reviewed by Adam Roben.
+
+ Add a new file to share common code for Win32/WinCE differences.
+
+ * platform/win/PopupMenuWin.cpp:
+ (WebCore::PopupMenuWin::PopupMenuWndProc):
+ * platform/win/RunLoopWin.cpp:
+ (WebCore::RunLoop::RunLoopWndProc):
+ * platform/win/WindowsExtras.h: Added.
+ (WebCore):
+ (WebCore::getWindowPointer):
+ (WebCore::setWindowPointer):
+
2012-02-13 Andreas Kling <[email protected]>
Don't mark element for style recalc when modifying its attribute style.
Modified: trunk/Source/WebCore/platform/win/PopupMenuWin.cpp (107573 => 107574)
--- trunk/Source/WebCore/platform/win/PopupMenuWin.cpp 2012-02-13 15:54:24 UTC (rev 107573)
+++ trunk/Source/WebCore/platform/win/PopupMenuWin.cpp 2012-02-13 16:29:46 UTC (rev 107574)
@@ -43,6 +43,7 @@
#include "SimpleFontData.h"
#include "TextRun.h"
#include "WebCoreInstanceHandle.h"
+#include "WindowsExtras.h"
#include <windows.h>
#include <windowsx.h>
@@ -763,24 +764,14 @@
LRESULT CALLBACK PopupMenuWin::PopupMenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
-#if OS(WINCE)
- LONG longPtr = GetWindowLong(hWnd, 0);
-#else
- LONG_PTR longPtr = GetWindowLongPtr(hWnd, 0);
-#endif
-
- if (PopupMenuWin* popup = reinterpret_cast<PopupMenuWin*>(longPtr))
+ if (PopupMenuWin* popup = static_cast<PopupMenuWin*>(getWindowPointer(hWnd, 0)))
return popup->wndProc(hWnd, message, wParam, lParam);
-
+
if (message == WM_CREATE) {
LPCREATESTRUCT createStruct = reinterpret_cast<LPCREATESTRUCT>(lParam);
// Associate the PopupMenu with the window.
-#if OS(WINCE)
- ::SetWindowLong(hWnd, 0, (LONG)createStruct->lpCreateParams);
-#else
- ::SetWindowLongPtr(hWnd, 0, (LONG_PTR)createStruct->lpCreateParams);
-#endif
+ setWindowPointer(hWnd, 0, createStruct->lpCreateParams);
return 0;
}
Modified: trunk/Source/WebCore/platform/win/RunLoopWin.cpp (107573 => 107574)
--- trunk/Source/WebCore/platform/win/RunLoopWin.cpp 2012-02-13 15:54:24 UTC (rev 107573)
+++ trunk/Source/WebCore/platform/win/RunLoopWin.cpp 2012-02-13 16:29:46 UTC (rev 107574)
@@ -26,6 +26,7 @@
#include "config.h"
#include "RunLoop.h"
+#include "WindowsExtras.h"
#include <wtf/CurrentTime.h>
using namespace std;
@@ -37,16 +38,14 @@
LRESULT CALLBACK RunLoop::RunLoopWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- LONG_PTR longPtr = ::GetWindowLongPtr(hWnd, 0);
-
- if (RunLoop* runLoop = reinterpret_cast<RunLoop*>(longPtr))
+ if (RunLoop* runLoop = static_cast<RunLoop*>(getWindowPointer(hWnd, 0)))
return runLoop->wndProc(hWnd, message, wParam, lParam);
if (message == WM_CREATE) {
LPCREATESTRUCT createStruct = reinterpret_cast<LPCREATESTRUCT>(lParam);
// Associate the RunLoop with the window.
- ::SetWindowLongPtr(hWnd, 0, (LONG_PTR)createStruct->lpCreateParams);
+ setWindowPointer(hWnd, 0, createStruct->lpCreateParams);
return 0;
}
Added: trunk/Source/WebCore/platform/win/WindowsExtras.h (0 => 107574)
--- trunk/Source/WebCore/platform/win/WindowsExtras.h (rev 0)
+++ trunk/Source/WebCore/platform/win/WindowsExtras.h 2012-02-13 16:29:46 UTC (rev 107574)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2012 Patrick Gansterer <[email protected]>
+ *
+ * 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 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 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.
+ */
+
+#ifndef WindowsExtras_h
+#define WindowsExtras_h
+
+#include <windows.h>
+
+namespace WebCore {
+
+inline void* getWindowPointer(HWND hWnd, int index)
+{
+#if OS(WINCE)
+ return reinterpret_cast<void*>(::GetWindowLong(hWnd, index));
+#else
+ return reinterpret_cast<void*>(::GetWindowLongPtr(hWnd, index));
+#endif
+}
+
+inline void* setWindowPointer(HWND hWnd, int index, void* value)
+{
+#if OS(WINCE)
+ return reinterpret_cast<void*>(::SetWindowLong(hWnd, index, reinterpret_cast<LONG>(value)));
+#else
+ return reinterpret_cast<void*>(::SetWindowLongPtr(hWnd, index, reinterpret_cast<LONG_PTR>(value)));
+#endif
+}
+
+} // namespace WebCore
+
+#endif // WindowsExtras_h