Modified: trunk/Tools/WinLauncher/WinLauncher.cpp (154069 => 154070)
--- trunk/Tools/WinLauncher/WinLauncher.cpp 2013-08-14 20:30:14 UTC (rev 154069)
+++ trunk/Tools/WinLauncher/WinLauncher.cpp 2013-08-14 20:43:16 UTC (rev 154070)
@@ -31,6 +31,7 @@
#include "AccessibilityDelegate.h"
#include "DOMDefaultImpl.h"
#include "PrintWebUIDelegate.h"
+#include "WinLauncherLibResource.h"
#include <WebKit/WebKitCOMAPI.h>
#include <wtf/Platform.h>
@@ -56,8 +57,11 @@
HWND hURLBarWnd;
WNDPROC DefEditProc = 0;
WNDPROC DefWebKitProc = 0;
+IWebInspector* gInspector = 0;
IWebView* gWebView = 0;
IWebViewPrivate* gWebViewPrivate = 0;
+IWebPreferences* gStandardPreferences = 0;
+IWebPreferencesPrivate* gPrefsPrivate = 0;
HWND gViewWindow = 0;
WinLauncherWebHost* gWebHost = 0;
PrintWebUIDelegate* gPrintDelegate = 0;
@@ -265,6 +269,31 @@
return TRUE;
}
+static bool setToDefaultPreferences()
+{
+ HRESULT hr = gStandardPreferences->QueryInterface(IID_IWebPreferencesPrivate, reinterpret_cast<void**>(&gPrefsPrivate));
+ if (!SUCCEEDED(hr))
+ return false;
+
+#if USE(CG)
+ gStandardPreferences->setAVFoundationEnabled(TRUE);
+ gPrefsPrivate->setAcceleratedCompositingEnabled(TRUE);
+#endif
+
+ gPrefsPrivate->setFullScreenEnabled(TRUE);
+ gPrefsPrivate->setShowDebugBorders(FALSE);
+ gPrefsPrivate->setShowRepaintCounter(FALSE);
+
+ gStandardPreferences->setLoadsImagesAutomatically(TRUE);
+ gPrefsPrivate->setAuthorAndUserStylesEnabled(TRUE);
+ gStandardPreferences->setJavaScriptEnabled(TRUE);
+ gPrefsPrivate->setAllowUniversalAccessFromFileURLs(FALSE);
+ gPrefsPrivate->setAllowFileAccessFromFileURLs(TRUE);
+
+ return true;
+}
+
+
#if USE(CF)
extern "C" void _CFRunLoopSetWindowsMessageQueueMask(CFRunLoopRef, uint32_t, CFStringRef);
#endif
@@ -347,22 +376,16 @@
RECT clientRect = { s_windowPosition.x, s_windowPosition.y, s_windowPosition.x + s_windowSize.cx, s_windowPosition.y + s_windowSize.cy };
IWebPreferences* tmpPreferences = 0;
- IWebPreferences* standardPreferences = 0;
if (FAILED(WebKitCreateInstance(CLSID_WebPreferences, 0, IID_IWebPreferences, reinterpret_cast<void**>(&tmpPreferences))))
goto exit;
- if (FAILED(tmpPreferences->standardPreferences(&standardPreferences)))
+ if (FAILED(tmpPreferences->standardPreferences(&gStandardPreferences)))
goto exit;
- standardPreferences->setAcceleratedCompositingEnabled(TRUE);
- standardPreferences->setAVFoundationEnabled(TRUE);
+ if (!setToDefaultPreferences())
+ goto exit;
- IWebPreferencesPrivate* prefsPrivate = 0;
- HRESULT hr = standardPreferences->QueryInterface(IID_IWebPreferencesPrivate, reinterpret_cast<void**>(&prefsPrivate));
- if (SUCCEEDED(hr))
- prefsPrivate->setFullScreenEnabled(TRUE);
-
- hr = WebKitCreateInstance(CLSID_WebView, 0, IID_IWebView, reinterpret_cast<void**>(&gWebView));
+ HRESULT hr = WebKitCreateInstance(CLSID_WebView, 0, IID_IWebView, reinterpret_cast<void**>(&gWebView));
if (FAILED(hr))
goto exit;
@@ -452,9 +475,19 @@
gPrintDelegate->Release();
if (gWebViewPrivate)
gWebViewPrivate->Release();
+ if (gInspector) {
+ gInspector->Release();
+ gInspector = 0;
+ }
gWebView->Release();
- if (standardPreferences)
- standardPreferences->Release();
+ if (gPrefsPrivate) {
+ gPrefsPrivate->Release();
+ gPrefsPrivate = 0;
+ }
+ if (gStandardPreferences) {
+ gStandardPreferences->Release();
+ gStandardPreferences = 0;
+ }
tmpPreferences->Release();
shutDownWebKit();
@@ -569,6 +602,85 @@
framePrivate->Release();
}
+static void ToggleMenuItem(HWND hWnd, UINT menuID)
+{
+ HMENU menu = ::GetMenu(hWnd);
+
+ MENUITEMINFO info;
+ ::memset(&info, 0x00, sizeof(info));
+ info.cbSize = sizeof(info);
+ info.fMask = MIIM_STATE;
+
+ if (!::GetMenuItemInfo(menu, menuID, FALSE, &info))
+ return;
+
+ BOOL newState = !(info.fState & MFS_CHECKED);
+
+ if (!gStandardPreferences || !gPrefsPrivate)
+ return;
+
+ switch (menuID) {
+ case IDM_AVFOUNDATION:
+ gStandardPreferences->setAVFoundationEnabled(newState);
+ break;
+ case IDM_ACC_COMPOSITING:
+ gPrefsPrivate->setAcceleratedCompositingEnabled(newState);
+ break;
+ case IDM_WK_FULLSCREEN:
+ gPrefsPrivate->setFullScreenEnabled(newState);
+ break;
+ case IDM_COMPOSITING_BORDERS:
+ gPrefsPrivate->setShowDebugBorders(newState);
+ gPrefsPrivate->setShowRepaintCounter(newState);
+ break;
+ case IDM_DISABLE_IMAGES:
+ gStandardPreferences->setLoadsImagesAutomatically(!newState);
+ break;
+ case IDM_DISABLE_STYLES:
+ gPrefsPrivate->setAuthorAndUserStylesEnabled(!newState);
+ break;
+ case IDM_DISABLE_JAVASCRIPT:
+ gStandardPreferences->setJavaScriptEnabled(!newState);
+ break;
+ case IDM_DISABLE_LOCAL_FILE_RESTRICTIONS:
+ gPrefsPrivate->setAllowUniversalAccessFromFileURLs(newState);
+ gPrefsPrivate->setAllowFileAccessFromFileURLs(newState);
+ break;
+ }
+
+ info.fState = (newState) ? MFS_CHECKED : MFS_UNCHECKED;
+
+ ::SetMenuItemInfo(menu, menuID, FALSE, &info);
+}
+
+static void LaunchInspector(HWND hwnd)
+{
+ if (!gWebViewPrivate)
+ return;
+
+ if (gInspector) {
+ gInspector->Release();
+ gInspector = 0;
+ }
+
+ if (!SUCCEEDED(gWebViewPrivate->inspector(&gInspector)))
+ return;
+
+ gInspector->show();
+}
+
+static void NavigateForwardOrBackward(HWND hWnd, UINT menuID)
+{
+ if (!gWebView)
+ return;
+
+ BOOL wentBackOrForward = FALSE;
+ if (IDM_HISTORY_FORWARD == menuID)
+ gWebView->goForward(&wentBackOrForward);
+ else
+ gWebView->goBack(&wentBackOrForward);
+}
+
static const int dragBarHeight = 30;
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
@@ -607,12 +719,32 @@
case IDM_PRINT:
PrintView(hWnd, message, wParam, lParam);
break;
+ case IDM_WEB_INSPECTOR:
+ LaunchInspector(hWnd);
+ break;
+ case IDM_HISTORY_BACKWARD:
+ case IDM_HISTORY_FORWARD:
+ NavigateForwardOrBackward(hWnd, wmId);
+ break;
+ case IDM_AVFOUNDATION:
+ case IDM_ACC_COMPOSITING:
+ case IDM_WK_FULLSCREEN:
+ case IDM_COMPOSITING_BORDERS:
+ case IDM_DISABLE_IMAGES:
+ case IDM_DISABLE_STYLES:
+ case IDM_DISABLE_JAVASCRIPT:
+ case IDM_DISABLE_LOCAL_FILE_RESTRICTIONS:
+ ToggleMenuItem(hWnd, wmId);
+ break;
default:
return CallWindowProc(parentProc, hWnd, message, wParam, lParam);
}
}
break;
case WM_DESTROY:
+#if USE(CF)
+ CFRunLoopStop(CFRunLoopGetMain());
+#endif
PostQuitMessage(0);
break;
case WM_SIZE:
Modified: trunk/Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLib.rc (154069 => 154070)
--- trunk/Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLib.rc 2013-08-14 20:30:14 UTC (rev 154069)
+++ trunk/Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLib.rc 2013-08-14 20:43:16 UTC (rev 154070)
@@ -45,10 +45,32 @@
MENUITEM "&Print\tCtrl-P", IDM_PRINT
MENUITEM "E&xit", IDM_EXIT
END
+ POPUP "&History"
+ BEGIN
+ MENUITEM "Back", IDM_HISTORY_BACKWARD
+ MENUITEM "Forward", IDM_HISTORY_FORWARD
+ END
+ POPUP "D&evelop"
+ BEGIN
+ MENUITEM "Show Web Inspector", IDM_WEB_INSPECTOR
+ MENUITEM SEPARATOR
+ MENUITEM "Disable Images", IDM_DISABLE_IMAGES
+ MENUITEM "Disable Styles", IDM_DISABLE_STYLES
+ MENUITEM "Disable _javascript_", IDM_DISABLE_JAVASCRIPT
+ MENUITEM "Disable Local File Restrictions", IDM_DISABLE_LOCAL_FILE_RESTRICTIONS
+ END
POPUP "&Help"
BEGIN
MENUITEM "&About ...", IDM_ABOUT
END
+ POPUP "&Debug"
+ BEGIN
+ MENUITEM "Use AVFoundation", IDM_AVFOUNDATION, CHECKED
+ MENUITEM "Use Accelerated Compositing", IDM_ACC_COMPOSITING, CHECKED
+ MENUITEM "Enable WebKit Full Screen", IDM_WK_FULLSCREEN, CHECKED
+ MENUITEM SEPARATOR
+ MENUITEM "Show Compositing Borders", IDM_COMPOSITING_BORDERS
+ END
END
Modified: trunk/Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLibCommon.props (154069 => 154070)
--- trunk/Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLibCommon.props 2013-08-14 20:30:14 UTC (rev 154069)
+++ trunk/Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLibCommon.props 2013-08-14 20:43:16 UTC (rev 154070)
@@ -5,7 +5,7 @@
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
- <AdditionalIncludeDirectories>$(ProjectDir)\..;$(ConfigurationBuildDir)\include\WebKit;$(ConfigurationBuildDir)\Include\private;$(ConfigurationBuildDir)\Include;$(ConfigurationBuildDir)\Include\WebCore;$(ConfigurationBuildDir)\Include\WebCore\ForwardingHeaders;$(ConfigurationBuildDir)\Include\_javascript_Core;$(ConfigurationBuildDir)\obj\WebKit\DerivedSources;$(WebKit_Libraries)\Include;$(WebKit_Libraries)\Include\private;$(WebKit_Libraries)\Include\WebCore;$(WebKit_Libraries)\Include\WebCore\ForwardingHeaders;$(WebKit_Libraries)\Include\_javascript_Core;$(IntDir)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)\..;$(ConfigurationBuildDir)\include\WebKit;$(ConfigurationBuildDir)\Include\private;$(ConfigurationBuildDir)\Include;$(ConfigurationBuildDir)\Include\WebCore;$(ConfigurationBuildDir)\Include\WebCore\ForwardingHeaders;$(ConfigurationBuildDir)\Include\_javascript_Core;$(ConfigurationBuildDir)\obj\WebKit\DerivedSources;$(WebKit_Libraries)\Include;$(WebKit_Libraries)\Include\private;$(WebKit_Libraries)\Include\WebCore;$(WebKit_Libraries)\Include\WebCore\ForwardingHeaders;$(WebKit_Libraries)\Include\_javascript_Core;$(IntDir)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>StdAfx.h</PrecompiledHeaderFile>
</ClCompile>
@@ -13,4 +13,4 @@
<AdditionalDependencies>comdlg32.lib;gdi32.lib;comctl32.lib;shlwapi.lib;user32.lib;ole32.lib;oleaut32.lib;WebKitGUID$(DebugSuffix).lib;WebKit$(DebugSuffix).lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
-</Project>
\ No newline at end of file
+</Project>