Source/WebCore/ChangeLog

 12012-02-10 Patrick Gansterer <paroga@webkit.org>
 2
 3 Add WindowsExtras.h
 4 https://bugs.webkit.org/show_bug.cgi?id=78340
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Add a new file to share common code for Win32/WinCE differences.
 9
 10 * platform/win/PopupMenuWin.cpp:
 11 (WebCore::PopupMenuWin::PopupMenuWndProc):
 12 * platform/win/RunLoopWin.cpp:
 13 (WebCore::RunLoop::RunLoopWndProc):
 14 * platform/win/WindowsExtras.h: Added.
 15 (WebCore):
 16 (WebCore::getWindowPointer):
 17 (WebCore::setWindowPointer):
 18
1192012-02-06 Philippe Normand <pnormand@igalia.com>
220
321 Adding FFTFrameGStreamer.cpp that I forgot to commit

Source/WebCore/platform/win/PopupMenuWin.cpp

4343#include "SimpleFontData.h"
4444#include "TextRun.h"
4545#include "WebCoreInstanceHandle.h"
 46#include "WindowsExtras.h"
4647
4748#include <windows.h>
4849#include <windowsx.h>

@@void PopupMenuWin::registerClass()
763764
764765LRESULT CALLBACK PopupMenuWin::PopupMenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
765766{
766 #if OS(WINCE)
767  LONG longPtr = GetWindowLong(hWnd, 0);
768 #else
769  LONG_PTR longPtr = GetWindowLongPtr(hWnd, 0);
770 #endif
771 
772  if (PopupMenuWin* popup = reinterpret_cast<PopupMenuWin*>(longPtr))
 767 if (PopupMenuWin* popup = static_cast<PopupMenuWin*>(getWindowPointer(hWnd)))
773768 return popup->wndProc(hWnd, message, wParam, lParam);
774 
 769
775770 if (message == WM_CREATE) {
776771 LPCREATESTRUCT createStruct = reinterpret_cast<LPCREATESTRUCT>(lParam);
777772
778773 // Associate the PopupMenu with the window.
779 #if OS(WINCE)
780  ::SetWindowLong(hWnd, 0, (LONG)createStruct->lpCreateParams);
781 #else
782  ::SetWindowLongPtr(hWnd, 0, (LONG_PTR)createStruct->lpCreateParams);
783 #endif
 774 setWindowPointer(hWnd, createStruct->lpCreateParams);
784775 return 0;
785776 }
786777

Source/WebCore/platform/win/RunLoopWin.cpp

2626#include "config.h"
2727#include "RunLoop.h"
2828
 29#include "WindowsExtras.h"
2930#include <wtf/CurrentTime.h>
3031
3132using namespace std;

@@static const LPWSTR kRunLoopMessageWindowClassName = L"RunLoopMessageWindow";
3738
3839LRESULT CALLBACK RunLoop::RunLoopWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
3940{
40  LONG_PTR longPtr = ::GetWindowLongPtr(hWnd, 0);
41 
42  if (RunLoop* runLoop = reinterpret_cast<RunLoop*>(longPtr))
 41 if (RunLoop* runLoop = static_cast<RunLoop*>(getWindowPointer(hWnd))
4342 return runLoop->wndProc(hWnd, message, wParam, lParam);
4443
4544 if (message == WM_CREATE) {
4645 LPCREATESTRUCT createStruct = reinterpret_cast<LPCREATESTRUCT>(lParam);
4746
4847 // Associate the RunLoop with the window.
49  ::SetWindowLongPtr(hWnd, 0, (LONG_PTR)createStruct->lpCreateParams);
 48 setWindowsPointer(hWnd, createStruct->lpCreateParams);
5049 return 0;
5150 }
5251

Source/WebCore/platform/win/WindowsExtras.h

 1/*
 2 * Copyright (C) 2012 Patrick Gansterer <paroga@paroga.com>
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 16 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 20 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 23 */
 24
 25#ifndef WindowsExtras_h
 26#define WindowsExtras_h
 27
 28#include <windows.h>
 29
 30namespace WebCore {
 31
 32inline void* getWindowPointer(HWND hWnd, int index = 0)
 33{
 34#if OS(WINCE)
 35 return reinterpret_cast<void*>(::GetWindowLong(hWnd, index));
 36#else
 37 return reinterpret_cast<void*>(::GetWindowLongPtr(hWnd, index));
 38#endif
 39}
 40
 41inline void* setWindowPointer(HWND hWnd, void* value, int index = 0)
 42{
 43#if OS(WINCE)
 44 return reinterpret_cast<void*>(::SetWindowLong(hWnd, index, reinterpret_cast<LONG>(value)));
 45#else
 46 return reinterpret_cast<void*>(::SetWindowLongPtr(hWnd, index, reinterpret_cast<LONG_PTR>(value)));
 47#endif
 48}
 49
 50} // namespace WebCore
 51
 52#endif // WindowsExtras_h