WebKit Bugzilla
Attachment 342242 Details for
Bug 186427
: [Win][MiniBrowser] MiniBrowser class should be renamed to WebKitLegacyBrowserWindow
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch (WK1BrowserWindow)
bug-186427-20180608150346.patch (text/plain), 87.82 KB, created by
Fujii Hironori
on 2018-06-07 23:03:47 PDT
(
hide
)
Description:
Patch (WK1BrowserWindow)
Filename:
MIME Type:
Creator:
Fujii Hironori
Created:
2018-06-07 23:03:47 PDT
Size:
87.82 KB
patch
obsolete
>Subversion Revision: 232616 >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 185b40aa8933f3dc86323f4884a1fce93dc4cccd..4b1592c36e5ef5b1ac7ad6a6b89a6ca0b108088e 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,37 @@ >+2018-06-07 Fujii Hironori <Hironori.Fujii@sony.com> >+ >+ [Win][MiniBrowser] MiniBrowser class should be renamed to WK1BrowserWindow >+ https://bugs.webkit.org/show_bug.cgi?id=186427 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * MiniBrowser/win/AccessibilityDelegate.cpp: >+ * MiniBrowser/win/AccessibilityDelegate.h: >+ (AccessibilityDelegate::AccessibilityDelegate): >+ * MiniBrowser/win/CMakeLists.txt: Removed MiniBrowser.cpp. Added WK1BrowserWindow.cpp. >+ * MiniBrowser/win/Common.h: >+ * MiniBrowser/win/MainWindow.cpp: >+ (MainWindow::init): >+ * MiniBrowser/win/MainWindow.h: >+ * MiniBrowser/win/MiniBrowserWebHost.cpp: >+ * MiniBrowser/win/MiniBrowserWebHost.h: >+ (MiniBrowserWebHost::MiniBrowserWebHost): >+ * MiniBrowser/win/PageLoadTestClient.cpp: >+ (PageLoadTestClient::PageLoadTestClient): >+ * MiniBrowser/win/PageLoadTestClient.h: >+ * MiniBrowser/win/PrintWebUIDelegate.cpp: >+ (PrintWebUIDelegate::createWebViewWithRequest): >+ * MiniBrowser/win/PrintWebUIDelegate.h: >+ (PrintWebUIDelegate::PrintWebUIDelegate): >+ * MiniBrowser/win/ResourceLoadDelegate.cpp: >+ * MiniBrowser/win/ResourceLoadDelegate.h: >+ (ResourceLoadDelegate::ResourceLoadDelegate): >+ * MiniBrowser/win/WK1BrowserWindow.cpp: Renamed from Tools/MiniBrowser/win/MiniBrowser.cpp. >+ * MiniBrowser/win/WK1BrowserWindow.h: Renamed from Tools/MiniBrowser/win/MiniBrowser.h. >+ * MiniBrowser/win/WebDownloadDelegate.cpp: >+ (WebDownloadDelegate::WebDownloadDelegate): >+ * MiniBrowser/win/WebDownloadDelegate.h: >+ > 2018-06-07 Fujii Hironori <Hironori.Fujii@sony.com> > > [Win][MiniBrowser] Add a new BrowserWindow interface to abstract WK1 and WK2 BrowserWindow >diff --git a/Tools/MiniBrowser/win/AccessibilityDelegate.cpp b/Tools/MiniBrowser/win/AccessibilityDelegate.cpp >index ae68b4272cf89cc46ad64db7fe5fb4a7fe0f8273..427a7838b6d8e69286dbeaada476b023c0e9065f 100644 >--- a/Tools/MiniBrowser/win/AccessibilityDelegate.cpp >+++ b/Tools/MiniBrowser/win/AccessibilityDelegate.cpp >@@ -26,7 +26,7 @@ > #include "stdafx.h" > #include "AccessibilityDelegate.h" > >-#include "MiniBrowser.h" >+#include "WK1BrowserWindow.h" > #include <WebKitLegacy/WebKitCOMAPI.h> > #include <commctrl.h> > #include <commdlg.h> >diff --git a/Tools/MiniBrowser/win/AccessibilityDelegate.h b/Tools/MiniBrowser/win/AccessibilityDelegate.h >index 78db286dba3c588ceac3ec92a183e07bbf54ceb5..53da9d0742839fd8c3acec930afba20c53c52beb 100644 >--- a/Tools/MiniBrowser/win/AccessibilityDelegate.h >+++ b/Tools/MiniBrowser/win/AccessibilityDelegate.h >@@ -28,11 +28,11 @@ > > #include <WebKitLegacy/WebKit.h> > >-class MiniBrowser; >+class WK1BrowserWindow; > > class AccessibilityDelegate : public IAccessibilityDelegate { > public: >- AccessibilityDelegate(MiniBrowser& client) >+ AccessibilityDelegate(WK1BrowserWindow& client) > : m_client(client) { } > virtual HRESULT STDMETHODCALLTYPE QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** ppvObject); > virtual ULONG STDMETHODCALLTYPE AddRef(); >@@ -41,7 +41,7 @@ public: > virtual HRESULT STDMETHODCALLTYPE fireFrameLoadStartedEvents(); > virtual HRESULT STDMETHODCALLTYPE fireFrameLoadFinishedEvents(); > private: >- MiniBrowser& m_client; >+ WK1BrowserWindow& m_client; > }; > > #endif >diff --git a/Tools/MiniBrowser/win/CMakeLists.txt b/Tools/MiniBrowser/win/CMakeLists.txt >index 9a4784d1695c40df62c9b68ee8453e3ee176e682..ca371c742b9c4b6c579cee5920187e02f06edf04 100644 >--- a/Tools/MiniBrowser/win/CMakeLists.txt >+++ b/Tools/MiniBrowser/win/CMakeLists.txt >@@ -14,9 +14,9 @@ set(MiniBrowser_SOURCES > PrintWebUIDelegate.cpp > ResourceLoadDelegate.cpp > WebDownloadDelegate.cpp >- MiniBrowser.cpp > MiniBrowserLib.rc > MiniBrowserWebHost.cpp >+ WK1BrowserWindow.cpp > WinMain.cpp > stdafx.cpp > ) >diff --git a/Tools/MiniBrowser/win/Common.h b/Tools/MiniBrowser/win/Common.h >index 4ea12738cdc5d25a51cd43ba2421f8749dae951b..746d89e7c3b9e833f84123d55463d54db59b0f06 100644 >--- a/Tools/MiniBrowser/win/Common.h >+++ b/Tools/MiniBrowser/win/Common.h >@@ -27,7 +27,7 @@ > > #include "stdafx.h" > #include "MainWindow.h" >-#include "MiniBrowser.h" >+#include "WK1BrowserWindow.h" > > void computeFullDesktopFrame(); > bool getAppDataFolder(_bstr_t& directory); >diff --git a/Tools/MiniBrowser/win/MainWindow.cpp b/Tools/MiniBrowser/win/MainWindow.cpp >index 5ed23cf86df3698dad527bfec7f1af1fddc8d423..67c4e6fb172674aa65f32ebbf2f85572eaffdc11 100644 >--- a/Tools/MiniBrowser/win/MainWindow.cpp >+++ b/Tools/MiniBrowser/win/MainWindow.cpp >@@ -113,7 +113,7 @@ bool MainWindow::init(HINSTANCE hInstance, bool usesLayeredWebView, bool pageLoa > DefEditProc = reinterpret_cast<WNDPROC>(GetWindowLongPtr(m_hURLBarWnd, GWLP_WNDPROC)); > SetWindowLongPtr(m_hURLBarWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(EditProc)); > >- m_browserWindow = MiniBrowser::create(m_hMainWnd, m_hURLBarWnd, usesLayeredWebView, pageLoadTesting); >+ m_browserWindow = WK1BrowserWindow::create(m_hMainWnd, m_hURLBarWnd, usesLayeredWebView, pageLoadTesting); > if (!m_browserWindow) > return false; > HRESULT hr = m_browserWindow->init(); >diff --git a/Tools/MiniBrowser/win/MainWindow.h b/Tools/MiniBrowser/win/MainWindow.h >index 4404d1cddee753819ae913e17238caada9a6a903..df263da0847f39c9fb1b2d76af49ba832a2cf948 100644 >--- a/Tools/MiniBrowser/win/MainWindow.h >+++ b/Tools/MiniBrowser/win/MainWindow.h >@@ -25,7 +25,7 @@ > > #pragma once > >-#include "MiniBrowser.h" >+#include "WK1BrowserWindow.h" > #include <memory> > #include <string> > #include <wtf/RefPtr.h> >diff --git a/Tools/MiniBrowser/win/MiniBrowser.cpp b/Tools/MiniBrowser/win/MiniBrowser.cpp >deleted file mode 100644 >index e9672977e0a6b9574569e928d2c07186c6150127..0000000000000000000000000000000000000000 >--- a/Tools/MiniBrowser/win/MiniBrowser.cpp >+++ /dev/null >@@ -1,895 +0,0 @@ >-/* >- * Copyright (C) 2006, 2008, 2013-2015 Apple Inc. All rights reserved. >- * Copyright (C) 2009, 2011 Brent Fulgham. All rights reserved. >- * Copyright (C) 2009, 2010, 2011 Appcelerator, Inc. All rights reserved. >- * Copyright (C) 2013 Alex Christensen. 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. ``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 >- * 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 "stdafx.h" >-#include "MiniBrowser.h" >- >-#include "AccessibilityDelegate.h" >-#include "Common.h" >-#include "DOMDefaultImpl.h" >-#include "MiniBrowserLibResource.h" >-#include "MiniBrowserReplace.h" >-#include "MiniBrowserWebHost.h" >-#include "PrintWebUIDelegate.h" >-#include "ResourceLoadDelegate.h" >-#include "WebDownloadDelegate.h" >-#include <WebCore/COMPtr.h> >-#include <WebKitLegacy/WebKitCOMAPI.h> >-#include <algorithm> >-#include <cassert> >-#include <functional> >-#include <memory> >-#include <string> >-#include <vector> >-#include <wtf/text/WTFString.h> >- >-#if USE(CF) >-#include <WebKitLegacy/CFDictionaryPropertyBag.h> >-#endif >- >-namespace WebCore { >-float deviceScaleFactorForWindow(HWND); >-} >- >-static const int maxHistorySize = 10; >- >-typedef _com_ptr_t<_com_IIID<IWebMutableURLRequest, &__uuidof(IWebMutableURLRequest)>> IWebMutableURLRequestPtr; >- >-Ref<BrowserWindow> MiniBrowser::create(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView, bool pageLoadTesting) >-{ >- return adoptRef(*new MiniBrowser(mainWnd, urlBarWnd, useLayeredWebView, pageLoadTesting)); >-} >- >-MiniBrowser::MiniBrowser(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView, bool pageLoadTesting) >- : m_hMainWnd(mainWnd) >- , m_hURLBarWnd(urlBarWnd) >- , m_useLayeredWebView(useLayeredWebView) >- , m_pageLoadTestClient(std::make_unique<PageLoadTestClient>(this, pageLoadTesting)) >-{ >-} >- >-ULONG MiniBrowser::AddRef() >-{ >- ref(); >- return refCount(); >-} >- >-ULONG MiniBrowser::Release() >-{ >- auto count = refCount(); >- deref(); >- return --count; >-} >- >-HRESULT MiniBrowser::init() >-{ >- HRESULT hr = WebKitCreateInstance(CLSID_WebView, 0, IID_IWebView, reinterpret_cast<void**>(&m_webView.GetInterfacePtr())); >- if (FAILED(hr)) >- return hr; >- >- hr = m_webView->QueryInterface(IID_IWebViewPrivate2, reinterpret_cast<void**>(&m_webViewPrivate.GetInterfacePtr())); >- if (FAILED(hr)) >- return hr; >- >- hr = WebKitCreateInstance(CLSID_WebHistory, 0, __uuidof(m_webHistory), reinterpret_cast<void**>(&m_webHistory.GetInterfacePtr())); >- if (FAILED(hr)) >- return hr; >- >- hr = WebKitCreateInstance(CLSID_WebCoreStatistics, 0, __uuidof(m_statistics), reinterpret_cast<void**>(&m_statistics.GetInterfacePtr())); >- if (FAILED(hr)) >- return hr; >- >- hr = WebKitCreateInstance(CLSID_WebCache, 0, __uuidof(m_webCache), reinterpret_cast<void**>(&m_webCache.GetInterfacePtr())); >- if (FAILED(hr)) >- return hr; >- >- if (!seedInitialDefaultPreferences()) >- return E_FAIL; >- >- if (!setToDefaultPreferences()) >- return E_FAIL; >- >- if (!setCacheFolder()) >- return E_FAIL; >- >- auto webHost = new MiniBrowserWebHost(this, m_hURLBarWnd); >- >- hr = setFrameLoadDelegate(webHost); >- if (FAILED(hr)) >- return hr; >- >- hr = setFrameLoadDelegatePrivate(webHost); >- if (FAILED(hr)) >- return hr; >- >- hr = setUIDelegate(new PrintWebUIDelegate(*this)); >- if (FAILED (hr)) >- return hr; >- >- hr = setAccessibilityDelegate(new AccessibilityDelegate(*this)); >- if (FAILED (hr)) >- return hr; >- >- hr = setResourceLoadDelegate(new ResourceLoadDelegate(this)); >- if (FAILED(hr)) >- return hr; >- >- IWebDownloadDelegatePtr downloadDelegate; >- downloadDelegate.Attach(new WebDownloadDelegate(*this)); >- hr = setDownloadDelegate(downloadDelegate); >- if (FAILED(hr)) >- return hr; >- >- RECT clientRect; >- ::GetClientRect(m_hMainWnd, &clientRect); >- if (usesLayeredWebView()) >- clientRect = { s_windowPosition.x, s_windowPosition.y, s_windowPosition.x + s_windowSize.cx, s_windowPosition.y + s_windowSize.cy }; >- >- hr = prepareViews(m_hMainWnd, clientRect); >- if (FAILED(hr)) >- return hr; >- >- if (usesLayeredWebView()) >- subclassForLayeredWindow(); >- >- return hr; >-} >- >-bool MiniBrowser::setCacheFolder() >-{ >- _bstr_t appDataFolder; >- if (!getAppDataFolder(appDataFolder)) >- return false; >- >- appDataFolder += L"\\cache"; >- webCache()->setCacheFolder(appDataFolder); >- >- return true; >-} >- >-HRESULT MiniBrowser::prepareViews(HWND mainWnd, const RECT& clientRect) >-{ >- if (!m_webView) >- return E_FAIL; >- >- HRESULT hr = m_webView->setHostWindow(mainWnd); >- if (FAILED(hr)) >- return hr; >- >- hr = m_webView->initWithFrame(clientRect, 0, 0); >- if (FAILED(hr)) >- return hr; >- >- hr = m_webViewPrivate->setTransparent(m_useLayeredWebView); >- if (FAILED(hr)) >- return hr; >- >- hr = m_webViewPrivate->setUsesLayeredWindow(m_useLayeredWebView); >- if (FAILED(hr)) >- return hr; >- >- hr = m_webViewPrivate->viewWindow(&m_viewWnd); >- >- return hr; >-} >- >-HRESULT MiniBrowser::loadHTMLString(const BSTR& str) >-{ >- IWebFramePtr frame; >- HRESULT hr = m_webView->mainFrame(&frame.GetInterfacePtr()); >- if (FAILED(hr)) >- return hr; >- >- frame->loadHTMLString(str, 0); >- return hr; >-} >- >-static WNDPROC gDefWebKitProc; >- >-static LRESULT CALLBACK viewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) >-{ >- switch (message) { >- case WM_NCHITTEST: >- constexpr int dragBarHeight = 30; >- RECT window; >- ::GetWindowRect(hWnd, &window); >- // For testing our transparent window, we need a region to use as a handle for >- // dragging. The right way to do this would be to query the web view to see what's >- // under the mouse. However, for testing purposes we just use an arbitrary >- // 30 logical pixel band at the top of the view as an arbitrary gripping location. >- // >- // When we are within this bad, return HT_CAPTION to tell Windows we want to >- // treat this region as if it were the title bar on a normal window. >- int y = HIWORD(lParam); >- float scaledDragBarHeightFactor = dragBarHeight * WebCore::deviceScaleFactorForWindow(hWnd); >- if ((y > window.top) && (y < window.top + scaledDragBarHeightFactor)) >- return HTCAPTION; >- } >- return CallWindowProc(gDefWebKitProc, hWnd, message, wParam, lParam); >-} >- >-void MiniBrowser::subclassForLayeredWindow() >-{ >-#if defined _M_AMD64 || defined _WIN64 >- gDefWebKitProc = reinterpret_cast<WNDPROC>(::GetWindowLongPtr(m_viewWnd, GWLP_WNDPROC)); >- ::SetWindowLongPtr(m_viewWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(viewWndProc)); >-#else >- gDefWebKitProc = reinterpret_cast<WNDPROC>(::GetWindowLong(m_viewWnd, GWL_WNDPROC)); >- ::SetWindowLong(m_viewWnd, GWL_WNDPROC, reinterpret_cast<LONG_PTR>(viewWndProc)); >-#endif >-} >- >-HRESULT MiniBrowser::setFrameLoadDelegate(IWebFrameLoadDelegate* frameLoadDelegate) >-{ >- m_frameLoadDelegate = frameLoadDelegate; >- return m_webView->setFrameLoadDelegate(frameLoadDelegate); >-} >- >-HRESULT MiniBrowser::setFrameLoadDelegatePrivate(IWebFrameLoadDelegatePrivate* frameLoadDelegatePrivate) >-{ >- return m_webViewPrivate->setFrameLoadDelegatePrivate(frameLoadDelegatePrivate); >-} >- >-HRESULT MiniBrowser::setUIDelegate(IWebUIDelegate* uiDelegate) >-{ >- m_uiDelegate = uiDelegate; >- return m_webView->setUIDelegate(uiDelegate); >-} >- >-HRESULT MiniBrowser::setAccessibilityDelegate(IAccessibilityDelegate* accessibilityDelegate) >-{ >- m_accessibilityDelegate = accessibilityDelegate; >- return m_webView->setAccessibilityDelegate(accessibilityDelegate); >-} >- >-HRESULT MiniBrowser::setResourceLoadDelegate(IWebResourceLoadDelegate* resourceLoadDelegate) >-{ >- m_resourceLoadDelegate = resourceLoadDelegate; >- return m_webView->setResourceLoadDelegate(resourceLoadDelegate); >-} >- >-HRESULT MiniBrowser::setDownloadDelegate(IWebDownloadDelegatePtr downloadDelegate) >-{ >- m_downloadDelegate = downloadDelegate; >- return m_webView->setDownloadDelegate(downloadDelegate); >-} >- >-IWebFramePtr MiniBrowser::mainFrame() >-{ >- IWebFramePtr framePtr; >- m_webView->mainFrame(&framePtr.GetInterfacePtr()); >- return framePtr; >-} >- >-bool MiniBrowser::seedInitialDefaultPreferences() >-{ >- IWebPreferencesPtr tmpPreferences; >- if (FAILED(WebKitCreateInstance(CLSID_WebPreferences, 0, IID_IWebPreferences, reinterpret_cast<void**>(&tmpPreferences.GetInterfacePtr())))) >- return false; >- >- if (FAILED(tmpPreferences->standardPreferences(&m_standardPreferences.GetInterfacePtr()))) >- return false; >- >- return true; >-} >- >-bool MiniBrowser::setToDefaultPreferences() >-{ >- HRESULT hr = m_standardPreferences->QueryInterface(IID_IWebPreferencesPrivate, reinterpret_cast<void**>(&m_prefsPrivate.GetInterfacePtr())); >- if (!SUCCEEDED(hr)) >- return false; >- >-#if USE(CG) >- m_standardPreferences->setAVFoundationEnabled(TRUE); >- m_prefsPrivate->setAcceleratedCompositingEnabled(TRUE); >-#endif >- >- m_prefsPrivate->setFullScreenEnabled(TRUE); >- m_prefsPrivate->setShowDebugBorders(FALSE); >- m_prefsPrivate->setShowRepaintCounter(FALSE); >- m_prefsPrivate->setShouldInvertColors(FALSE); >- >- m_standardPreferences->setLoadsImagesAutomatically(TRUE); >- m_prefsPrivate->setAuthorAndUserStylesEnabled(TRUE); >- m_standardPreferences->setJavaScriptEnabled(TRUE); >- m_prefsPrivate->setAllowUniversalAccessFromFileURLs(FALSE); >- m_prefsPrivate->setAllowFileAccessFromFileURLs(TRUE); >- >- m_prefsPrivate->setDeveloperExtrasEnabled(TRUE); >- >- return true; >-} >- >-static void updateMenuItemForHistoryItem(HMENU menu, IWebHistoryItem& historyItem, int currentHistoryItem) >-{ >- UINT menuID = IDM_HISTORY_LINK0 + currentHistoryItem; >- >- MENUITEMINFO menuItemInfo = { 0 }; >- menuItemInfo.cbSize = sizeof(MENUITEMINFO); >- menuItemInfo.fMask = MIIM_TYPE; >- menuItemInfo.fType = MFT_STRING; >- >- _bstr_t title; >- historyItem.title(title.GetAddress()); >- menuItemInfo.dwTypeData = static_cast<LPWSTR>(title); >- >- ::SetMenuItemInfo(menu, menuID, FALSE, &menuItemInfo); >- ::EnableMenuItem(menu, menuID, MF_BYCOMMAND | MF_ENABLED); >-} >- >-void MiniBrowser::showLastVisitedSites(IWebView& webView) >-{ >- HMENU menu = ::GetMenu(m_hMainWnd); >- >- _com_ptr_t<_com_IIID<IWebBackForwardList, &__uuidof(IWebBackForwardList)>> backForwardList; >- HRESULT hr = webView.backForwardList(&backForwardList.GetInterfacePtr()); >- if (FAILED(hr)) >- return; >- >- int capacity = 0; >- hr = backForwardList->capacity(&capacity); >- if (FAILED(hr)) >- return; >- >- int backCount = 0; >- hr = backForwardList->backListCount(&backCount); >- if (FAILED(hr)) >- return; >- >- UINT backSetting = MF_BYCOMMAND | ((backCount) ? MF_ENABLED : MF_DISABLED); >- ::EnableMenuItem(menu, IDM_HISTORY_BACKWARD, backSetting); >- >- int forwardCount = 0; >- hr = backForwardList->forwardListCount(&forwardCount); >- if (FAILED(hr)) >- return; >- >- UINT forwardSetting = MF_BYCOMMAND | ((forwardCount) ? MF_ENABLED : MF_DISABLED); >- ::EnableMenuItem(menu, IDM_HISTORY_FORWARD, forwardSetting); >- >- IWebHistoryItemPtr currentItem; >- hr = backForwardList->currentItem(¤tItem.GetInterfacePtr()); >- if (FAILED(hr)) >- return; >- >- hr = m_webHistory->addItems(1, ¤tItem.GetInterfacePtr()); >- if (FAILED(hr)) >- return; >- >- _com_ptr_t<_com_IIID<IWebHistoryPrivate, &__uuidof(IWebHistoryPrivate)>> webHistory; >- hr = m_webHistory->QueryInterface(IID_IWebHistoryPrivate, reinterpret_cast<void**>(&webHistory.GetInterfacePtr())); >- if (FAILED(hr)) >- return; >- >- int totalListCount = 0; >- hr = webHistory->allItems(&totalListCount, 0); >- if (FAILED(hr)) >- return; >- >- m_historyItems.resize(totalListCount); >- >- std::vector<IWebHistoryItem*> historyToLoad(totalListCount); >- hr = webHistory->allItems(&totalListCount, historyToLoad.data()); >- if (FAILED(hr)) >- return; >- >- size_t i = 0; >- for (auto& cur : historyToLoad) { >- m_historyItems[i].Attach(cur); >- ++i; >- } >- >- int allItemsOffset = 0; >- if (totalListCount > maxHistorySize) >- allItemsOffset = totalListCount - maxHistorySize; >- >- int currentHistoryItem = 0; >- for (int i = 0; i < m_historyItems.size() && (allItemsOffset + currentHistoryItem) < m_historyItems.size(); ++i) { >- updateMenuItemForHistoryItem(menu, *(m_historyItems[allItemsOffset + currentHistoryItem]), currentHistoryItem); >- ++currentHistoryItem; >- } >- >- // Hide any history we aren't using yet. >- for (int i = currentHistoryItem; i < maxHistorySize; ++i) >- ::EnableMenuItem(menu, IDM_HISTORY_LINK0 + i, MF_BYCOMMAND | MF_DISABLED); >-} >- >-void MiniBrowser::launchInspector() >-{ >- if (!m_webViewPrivate) >- return; >- >- if (!SUCCEEDED(m_webViewPrivate->inspector(&m_inspector.GetInterfacePtr()))) >- return; >- >- m_inspector->show(); >-} >- >-void MiniBrowser::navigateForwardOrBackward(UINT menuID) >-{ >- if (!m_webView) >- return; >- >- BOOL wentBackOrForward = FALSE; >- if (IDM_HISTORY_FORWARD == menuID) >- m_webView->goForward(&wentBackOrForward); >- else >- m_webView->goBack(&wentBackOrForward); >-} >- >-void MiniBrowser::navigateToHistory(UINT menuID) >-{ >- if (!m_webView) >- return; >- >- int historyEntry = menuID - IDM_HISTORY_LINK0; >- if (historyEntry > m_historyItems.size()) >- return; >- >- IWebHistoryItemPtr desiredHistoryItem = m_historyItems[historyEntry]; >- if (!desiredHistoryItem) >- return; >- >- BOOL succeeded = FALSE; >- m_webView->goToBackForwardItem(desiredHistoryItem, &succeeded); >- >- _bstr_t frameURL; >- desiredHistoryItem->URLString(frameURL.GetAddress()); >- >- ::SendMessage(m_hURLBarWnd, (UINT)WM_SETTEXT, 0, (LPARAM)frameURL.GetBSTR()); >-} >- >-bool MiniBrowser::goBack() >-{ >- BOOL wentBack = FALSE; >- m_webView->goBack(&wentBack); >- return wentBack; >-} >- >-bool MiniBrowser::goForward() >-{ >- BOOL wentForward = FALSE; >- m_webView->goForward(&wentForward); >- return wentForward; >-} >- >-HRESULT MiniBrowser::loadURL(const BSTR& passedURL) >-{ >- if (!passedURL) >- return E_INVALIDARG; >- >- _bstr_t urlBStr(passedURL); >- if (!!urlBStr && (::PathFileExists(urlBStr) || ::PathIsUNC(urlBStr))) { >- TCHAR fileURL[INTERNET_MAX_URL_LENGTH]; >- DWORD fileURLLength = sizeof(fileURL) / sizeof(fileURL[0]); >- >- if (SUCCEEDED(::UrlCreateFromPath(urlBStr, fileURL, &fileURLLength, 0))) >- urlBStr = fileURL; >- } >- >- IWebFramePtr frame; >- HRESULT hr = m_webView->mainFrame(&frame.GetInterfacePtr()); >- if (FAILED(hr)) >- return hr; >- >- IWebMutableURLRequestPtr request; >- hr = WebKitCreateInstance(CLSID_WebMutableURLRequest, 0, IID_IWebMutableURLRequest, (void**)&request); >- if (FAILED(hr)) >- return hr; >- >- hr = request->initWithURL(wcsstr(static_cast<wchar_t*>(urlBStr), L"://") ? urlBStr : _bstr_t(L"http://") + urlBStr, WebURLRequestUseProtocolCachePolicy, 60); >- if (FAILED(hr)) >- return hr; >- >- _bstr_t methodBStr(L"GET"); >- hr = request->setHTTPMethod(methodBStr); >- if (FAILED(hr)) >- return hr; >- >- hr = frame->loadRequest(request); >- >- return hr; >-} >- >-void MiniBrowser::exitProgram() >-{ >- ::PostMessage(m_hMainWnd, static_cast<UINT>(WM_COMMAND), MAKELPARAM(IDM_EXIT, 0), 0); >-} >- >-void MiniBrowser::setUserAgent(UINT menuID) >-{ >- if (!webView()) >- return; >- >- _bstr_t customUserAgent; >- switch (menuID) { >- case IDM_UA_DEFAULT: >- // Set to null user agent >- break; >- case IDM_UA_SAFARI_8_0: >- customUserAgent = L"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10) AppleWebKit/600.1.25 (KHTML, like Gecko) Version/8.0 Safari/600.1.25"; >- break; >- case IDM_UA_SAFARI_IOS_8_IPHONE: >- customUserAgent = L"Mozilla/5.0 (iPhone; CPU OS 8_1 like Mac OS X) AppleWebKit/601.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B403 Safari/600.1.4"; >- break; >- case IDM_UA_SAFARI_IOS_8_IPAD: >- customUserAgent = L"Mozilla/5.0 (iPad; CPU OS 8_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B403 Safari/600.1.4"; >- break; >- case IDM_UA_IE_11: >- customUserAgent = L"Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko"; >- break; >- case IDM_UA_CHROME_MAC: >- customUserAgent = L"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31"; >- break; >- case IDM_UA_CHROME_WIN: >- customUserAgent = L"Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31"; >- break; >- case IDM_UA_FIREFOX_MAC: >- customUserAgent = L"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:20.0) Gecko/20100101 Firefox/20.0"; >- break; >- case IDM_UA_FIREFOX_WIN: >- customUserAgent = L"Mozilla/5.0 (Windows NT 6.2; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0"; >- break; >- case IDM_UA_OTHER: >- default: >- ASSERT(0); // We should never hit this case >- return; >- } >- >- setUserAgent(customUserAgent); >-} >- >-void MiniBrowser::setUserAgent(_bstr_t& customUserAgent) >-{ >- webView()->setCustomUserAgent(customUserAgent.GetBSTR()); >-} >- >-_bstr_t MiniBrowser::userAgent() >-{ >- _bstr_t userAgent; >- if (FAILED(webView()->customUserAgent(&userAgent.GetBSTR()))) >- return _bstr_t(L"- Unknown -: Call failed."); >- >- return userAgent; >-} >- >-typedef _com_ptr_t<_com_IIID<IWebIBActions, &__uuidof(IWebIBActions)>> IWebIBActionsPtr; >- >-void MiniBrowser::resetZoom() >-{ >- IWebIBActionsPtr webActions; >- if (FAILED(m_webView->QueryInterface(IID_IWebIBActions, reinterpret_cast<void**>(&webActions.GetInterfacePtr())))) >- return; >- >- webActions->resetPageZoom(nullptr); >-} >- >-void MiniBrowser::zoomIn() >-{ >- IWebIBActionsPtr webActions; >- if (FAILED(m_webView->QueryInterface(IID_IWebIBActions, reinterpret_cast<void**>(&webActions.GetInterfacePtr())))) >- return; >- >- webActions->zoomPageIn(nullptr); >-} >- >-void MiniBrowser::zoomOut() >-{ >- IWebIBActionsPtr webActions; >- if (FAILED(m_webView->QueryInterface(IID_IWebIBActions, reinterpret_cast<void**>(&webActions.GetInterfacePtr())))) >- return; >- >- webActions->zoomPageOut(nullptr); >-} >- >-typedef _com_ptr_t<_com_IIID<IWebViewPrivate3, &__uuidof(IWebViewPrivate3)>> IWebViewPrivate3Ptr; >- >-void MiniBrowser::showLayerTree() >-{ >- IWebViewPrivate3Ptr webViewPrivate; >- if (FAILED(m_webView->QueryInterface(IID_IWebViewPrivate3, reinterpret_cast<void**>(&webViewPrivate.GetInterfacePtr())))) >- return; >- >- OutputDebugString(L"CURRENT TREE:\n"); >- >- _bstr_t layerTreeBstr; >- if (FAILED(webViewPrivate->layerTreeAsString(layerTreeBstr.GetAddress()))) >- OutputDebugString(L" Failed to retrieve the layer tree.\n"); >- else >- OutputDebugString(layerTreeBstr); >- OutputDebugString(L"\n\n"); >-} >- >-static BOOL CALLBACK AbortProc(HDC hDC, int Error) >-{ >- MSG msg; >- while (::PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { >- ::TranslateMessage(&msg); >- ::DispatchMessage(&msg); >- } >- >- return TRUE; >-} >- >-static HDC getPrinterDC() >-{ >- PRINTDLG pdlg; >- memset(&pdlg, 0, sizeof(PRINTDLG)); >- pdlg.lStructSize = sizeof(PRINTDLG); >- pdlg.Flags = PD_PRINTSETUP | PD_RETURNDC; >- >- ::PrintDlg(&pdlg); >- >- return pdlg.hDC; >-} >- >-static void initDocStruct(DOCINFO* di, TCHAR* docname) >-{ >- memset(di, 0, sizeof(DOCINFO)); >- di->cbSize = sizeof(DOCINFO); >- di->lpszDocName = docname; >-} >- >-void MiniBrowser::print() >-{ >- HDC printDC = getPrinterDC(); >- if (!printDC) { >- ::MessageBox(0, L"Error creating printing DC", L"Error", MB_APPLMODAL | MB_OK); >- return; >- } >- >- if (::SetAbortProc(printDC, AbortProc) == SP_ERROR) { >- ::MessageBox(0, L"Error setting up AbortProc", L"Error", MB_APPLMODAL | MB_OK); >- return; >- } >- >- IWebFramePtr frame = mainFrame(); >- if (!frame) >- return; >- >- IWebFramePrivatePtr framePrivate; >- if (FAILED(frame->QueryInterface(&framePrivate.GetInterfacePtr()))) >- return; >- >- framePrivate->setInPrintingMode(TRUE, printDC); >- >- UINT pageCount = 0; >- framePrivate->getPrintedPageCount(printDC, &pageCount); >- >- DOCINFO di; >- initDocStruct(&di, L"WebKit Doc"); >- ::StartDoc(printDC, &di); >- >- // FIXME: Need CoreGraphics implementation >- void* graphicsContext = 0; >- for (size_t page = 1; page <= pageCount; ++page) { >- ::StartPage(printDC); >- framePrivate->spoolPages(printDC, page, page, graphicsContext); >- ::EndPage(printDC); >- } >- >- framePrivate->setInPrintingMode(FALSE, printDC); >- >- ::EndDoc(printDC); >- ::DeleteDC(printDC); >-} >- >-static void setWindowText(HWND dialog, UINT field, _bstr_t value) >-{ >- ::SetDlgItemText(dialog, field, value); >-} >- >-static void setWindowText(HWND dialog, UINT field, UINT value) >-{ >- String valueStr = WTF::String::number(value); >- >- setWindowText(dialog, field, _bstr_t(valueStr.utf8().data())); >-} >- >-typedef _com_ptr_t<_com_IIID<IPropertyBag, &__uuidof(IPropertyBag)>> IPropertyBagPtr; >- >-static void setWindowText(HWND dialog, UINT field, IPropertyBagPtr statistics, const _bstr_t& key) >-{ >- _variant_t var; >- V_VT(&var) = VT_UI8; >- if (FAILED(statistics->Read(key, &var.GetVARIANT(), nullptr))) >- return; >- >- unsigned long long value = V_UI8(&var); >- String valueStr = WTF::String::number(value); >- >- setWindowText(dialog, field, _bstr_t(valueStr.utf8().data())); >-} >- >-static void setWindowText(HWND dialog, UINT field, CFDictionaryRef dictionary, CFStringRef key, UINT& total) >-{ >- CFNumberRef countNum = static_cast<CFNumberRef>(CFDictionaryGetValue(dictionary, key)); >- if (!countNum) >- return; >- >- int count = 0; >- CFNumberGetValue(countNum, kCFNumberIntType, &count); >- >- setWindowText(dialog, field, static_cast<UINT>(count)); >- total += count; >-} >- >-void MiniBrowser::updateStatistics(HWND dialog) >-{ >- IWebCoreStatisticsPtr webCoreStatistics = statistics(); >- if (!webCoreStatistics) >- return; >- >- IPropertyBagPtr statistics; >- HRESULT hr = webCoreStatistics->memoryStatistics(&statistics.GetInterfacePtr()); >- if (FAILED(hr)) >- return; >- >- // FastMalloc. >- setWindowText(dialog, IDC_RESERVED_VM, statistics, "FastMallocReservedVMBytes"); >- setWindowText(dialog, IDC_COMMITTED_VM, statistics, "FastMallocCommittedVMBytes"); >- setWindowText(dialog, IDC_FREE_LIST_BYTES, statistics, "FastMallocFreeListBytes"); >- >- // WebCore Cache. >-#if USE(CF) >- IWebCachePtr webCache = this->webCache(); >- >- int dictCount = 6; >- IPropertyBag* cacheDict[6] = { 0 }; >- if (FAILED(webCache->statistics(&dictCount, cacheDict))) >- return; >- >- COMPtr<CFDictionaryPropertyBag> counts, sizes, liveSizes, decodedSizes, purgableSizes; >- counts.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[0])); >- sizes.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[1])); >- liveSizes.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[2])); >- decodedSizes.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[3])); >- purgableSizes.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[4])); >- >- static CFStringRef imagesKey = CFSTR("images"); >- static CFStringRef stylesheetsKey = CFSTR("style sheets"); >- static CFStringRef xslKey = CFSTR("xsl"); >- static CFStringRef scriptsKey = CFSTR("scripts"); >- >- if (counts) { >- UINT totalObjects = 0; >- setWindowText(dialog, IDC_IMAGES_OBJECT_COUNT, counts->dictionary(), imagesKey, totalObjects); >- setWindowText(dialog, IDC_CSS_OBJECT_COUNT, counts->dictionary(), stylesheetsKey, totalObjects); >- setWindowText(dialog, IDC_XSL_OBJECT_COUNT, counts->dictionary(), xslKey, totalObjects); >- setWindowText(dialog, IDC_JSC_OBJECT_COUNT, counts->dictionary(), scriptsKey, totalObjects); >- setWindowText(dialog, IDC_TOTAL_OBJECT_COUNT, totalObjects); >- } >- >- if (sizes) { >- UINT totalBytes = 0; >- setWindowText(dialog, IDC_IMAGES_BYTES, sizes->dictionary(), imagesKey, totalBytes); >- setWindowText(dialog, IDC_CSS_BYTES, sizes->dictionary(), stylesheetsKey, totalBytes); >- setWindowText(dialog, IDC_XSL_BYTES, sizes->dictionary(), xslKey, totalBytes); >- setWindowText(dialog, IDC_JSC_BYTES, sizes->dictionary(), scriptsKey, totalBytes); >- setWindowText(dialog, IDC_TOTAL_BYTES, totalBytes); >- } >- >- if (liveSizes) { >- UINT totalLiveBytes = 0; >- setWindowText(dialog, IDC_IMAGES_LIVE_COUNT, liveSizes->dictionary(), imagesKey, totalLiveBytes); >- setWindowText(dialog, IDC_CSS_LIVE_COUNT, liveSizes->dictionary(), stylesheetsKey, totalLiveBytes); >- setWindowText(dialog, IDC_XSL_LIVE_COUNT, liveSizes->dictionary(), xslKey, totalLiveBytes); >- setWindowText(dialog, IDC_JSC_LIVE_COUNT, liveSizes->dictionary(), scriptsKey, totalLiveBytes); >- setWindowText(dialog, IDC_TOTAL_LIVE_COUNT, totalLiveBytes); >- } >- >- if (decodedSizes) { >- UINT totalDecoded = 0; >- setWindowText(dialog, IDC_IMAGES_DECODED_COUNT, decodedSizes->dictionary(), imagesKey, totalDecoded); >- setWindowText(dialog, IDC_CSS_DECODED_COUNT, decodedSizes->dictionary(), stylesheetsKey, totalDecoded); >- setWindowText(dialog, IDC_XSL_DECODED_COUNT, decodedSizes->dictionary(), xslKey, totalDecoded); >- setWindowText(dialog, IDC_JSC_DECODED_COUNT, decodedSizes->dictionary(), scriptsKey, totalDecoded); >- setWindowText(dialog, IDC_TOTAL_DECODED, totalDecoded); >- } >- >- if (purgableSizes) { >- UINT totalPurgable = 0; >- setWindowText(dialog, IDC_IMAGES_PURGEABLE_COUNT, purgableSizes->dictionary(), imagesKey, totalPurgable); >- setWindowText(dialog, IDC_CSS_PURGEABLE_COUNT, purgableSizes->dictionary(), stylesheetsKey, totalPurgable); >- setWindowText(dialog, IDC_XSL_PURGEABLE_COUNT, purgableSizes->dictionary(), xslKey, totalPurgable); >- setWindowText(dialog, IDC_JSC_PURGEABLE_COUNT, purgableSizes->dictionary(), scriptsKey, totalPurgable); >- setWindowText(dialog, IDC_TOTAL_PURGEABLE, totalPurgable); >- } >-#endif >- >- // JavaScript Heap. >- setWindowText(dialog, IDC_JSC_HEAP_SIZE, statistics, "JavaScriptHeapSize"); >- setWindowText(dialog, IDC_JSC_HEAP_FREE, statistics, "JavaScriptFreeSize"); >- >- UINT count; >- if (SUCCEEDED(webCoreStatistics->javaScriptObjectsCount(&count))) >- setWindowText(dialog, IDC_TOTAL_JSC_HEAP_OBJECTS, count); >- if (SUCCEEDED(webCoreStatistics->javaScriptGlobalObjectsCount(&count))) >- setWindowText(dialog, IDC_GLOBAL_JSC_HEAP_OBJECTS, count); >- if (SUCCEEDED(webCoreStatistics->javaScriptProtectedObjectsCount(&count))) >- setWindowText(dialog, IDC_PROTECTED_JSC_HEAP_OBJECTS, count); >- >- // Font and Glyph Caches. >- if (SUCCEEDED(webCoreStatistics->cachedFontDataCount(&count))) >- setWindowText(dialog, IDC_TOTAL_FONT_OBJECTS, count); >- if (SUCCEEDED(webCoreStatistics->cachedFontDataInactiveCount(&count))) >- setWindowText(dialog, IDC_INACTIVE_FONT_OBJECTS, count); >- if (SUCCEEDED(webCoreStatistics->glyphPageCount(&count))) >- setWindowText(dialog, IDC_GLYPH_PAGES, count); >- >- // Site Icon Database. >- if (SUCCEEDED(webCoreStatistics->iconPageURLMappingCount(&count))) >- setWindowText(dialog, IDC_PAGE_URL_MAPPINGS, count); >- if (SUCCEEDED(webCoreStatistics->iconRetainedPageURLCount(&count))) >- setWindowText(dialog, IDC_RETAINED_PAGE_URLS, count); >- if (SUCCEEDED(webCoreStatistics->iconRecordCount(&count))) >- setWindowText(dialog, IDC_SITE_ICON_RECORDS, count); >- if (SUCCEEDED(webCoreStatistics->iconsWithDataCount(&count))) >- setWindowText(dialog, IDC_SITE_ICONS_WITH_DATA, count); >-} >- >-void MiniBrowser::setPreference(UINT menuID, bool enable) >-{ >- if (!standardPreferences() || !privatePreferences()) >- return; >- >- switch (menuID) { >- case IDM_AVFOUNDATION: >- standardPreferences()->setAVFoundationEnabled(enable); >- break; >- case IDM_ACC_COMPOSITING: >- privatePreferences()->setAcceleratedCompositingEnabled(enable); >- break; >- case IDM_WK_FULLSCREEN: >- privatePreferences()->setFullScreenEnabled(enable); >- break; >- case IDM_COMPOSITING_BORDERS: >- privatePreferences()->setShowDebugBorders(enable); >- privatePreferences()->setShowRepaintCounter(enable); >- break; >- case IDM_DEBUG_INFO_LAYER: >- privatePreferences()->setShowTiledScrollingIndicator(enable); >- break; >- case IDM_INVERT_COLORS: >- privatePreferences()->setShouldInvertColors(enable); >- break; >- case IDM_DISABLE_IMAGES: >- standardPreferences()->setLoadsImagesAutomatically(!enable); >- break; >- case IDM_DISABLE_STYLES: >- privatePreferences()->setAuthorAndUserStylesEnabled(!enable); >- break; >- case IDM_DISABLE_JAVASCRIPT: >- standardPreferences()->setJavaScriptEnabled(!enable); >- break; >- case IDM_DISABLE_LOCAL_FILE_RESTRICTIONS: >- privatePreferences()->setAllowUniversalAccessFromFileURLs(enable); >- privatePreferences()->setAllowFileAccessFromFileURLs(enable); >- break; >- } >-} >diff --git a/Tools/MiniBrowser/win/MiniBrowser.h b/Tools/MiniBrowser/win/MiniBrowser.h >deleted file mode 100644 >index 3633b28a2219989a1310c66bbb7d9ea7d2c20101..0000000000000000000000000000000000000000 >--- a/Tools/MiniBrowser/win/MiniBrowser.h >+++ /dev/null >@@ -1,147 +0,0 @@ >-/* >- * Copyright (C) 2014-2015 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. ``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 >- * 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. >- */ >- >-#pragma once >-#include "BrowserWindow.h" >-#include "PageLoadTestClient.h" >-#include <WebKitLegacy/WebKit.h> >-#include <comip.h> >-#include <memory> >-#include <vector> >- >-typedef _com_ptr_t<_com_IIID<IWebFrame, &__uuidof(IWebFrame)>> IWebFramePtr; >-typedef _com_ptr_t<_com_IIID<IWebView, &__uuidof(IWebView)>> IWebViewPtr; >-typedef _com_ptr_t<_com_IIID<IWebViewPrivate2, &__uuidof(IWebViewPrivate2)>> IWebViewPrivatePtr; >-typedef _com_ptr_t<_com_IIID<IWebFrameLoadDelegate, &__uuidof(IWebFrameLoadDelegate)>> IWebFrameLoadDelegatePtr; >-typedef _com_ptr_t<_com_IIID<IWebHistory, &__uuidof(IWebHistory)>> IWebHistoryPtr; >-typedef _com_ptr_t<_com_IIID<IWebHistoryItem, &__uuidof(IWebHistoryItem)>> IWebHistoryItemPtr; >-typedef _com_ptr_t<_com_IIID<IWebPreferences, &__uuidof(IWebPreferences)>> IWebPreferencesPtr; >-typedef _com_ptr_t<_com_IIID<IWebPreferencesPrivate3, &__uuidof(IWebPreferencesPrivate3)>> IWebPreferencesPrivatePtr; >-typedef _com_ptr_t<_com_IIID<IWebUIDelegate, &__uuidof(IWebUIDelegate)>> IWebUIDelegatePtr; >-typedef _com_ptr_t<_com_IIID<IAccessibilityDelegate, &__uuidof(IAccessibilityDelegate)>> IAccessibilityDelegatePtr; >-typedef _com_ptr_t<_com_IIID<IWebInspector, &__uuidof(IWebInspector)>> IWebInspectorPtr; >-typedef _com_ptr_t<_com_IIID<IWebCoreStatistics, &__uuidof(IWebCoreStatistics)>> IWebCoreStatisticsPtr; >-typedef _com_ptr_t<_com_IIID<IWebCache, &__uuidof(IWebCache)>> IWebCachePtr; >-typedef _com_ptr_t<_com_IIID<IWebResourceLoadDelegate, &__uuidof(IWebResourceLoadDelegate)>> IWebResourceLoadDelegatePtr; >-typedef _com_ptr_t<_com_IIID<IWebDownloadDelegate, &__uuidof(IWebDownloadDelegate)>> IWebDownloadDelegatePtr; >-typedef _com_ptr_t<_com_IIID<IWebFramePrivate, &__uuidof(IWebFramePrivate)>> IWebFramePrivatePtr; >- >-class MiniBrowser : public BrowserWindow { >-public: >- static Ref<BrowserWindow> create(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView = false, bool pageLoadTesting = false); >- >-private: >- friend class AccessibilityDelegate; >- friend class MiniBrowserWebHost; >- friend class PrintWebUIDelegate; >- friend class WebDownloadDelegate; >- friend class ResourceLoadDelegate; >- friend class PageLoadTestClient; >- >- ULONG AddRef(); >- ULONG Release(); >- >- HRESULT init(); >- HRESULT prepareViews(HWND mainWnd, const RECT& clientRect); >- >- HRESULT loadHTMLString(const BSTR&); >- HRESULT loadURL(const BSTR& passedURL); >- >- void showLastVisitedSites(IWebView&); >- void launchInspector(); >- void navigateForwardOrBackward(UINT menuID); >- void navigateToHistory(UINT menuID); >- void exitProgram(); >- bool seedInitialDefaultPreferences(); >- bool setToDefaultPreferences(); >- >- HRESULT setFrameLoadDelegate(IWebFrameLoadDelegate*); >- HRESULT setFrameLoadDelegatePrivate(IWebFrameLoadDelegatePrivate*); >- HRESULT setUIDelegate(IWebUIDelegate*); >- HRESULT setAccessibilityDelegate(IAccessibilityDelegate*); >- HRESULT setResourceLoadDelegate(IWebResourceLoadDelegate*); >- HRESULT setDownloadDelegate(IWebDownloadDelegatePtr); >- >- IWebPreferencesPtr standardPreferences() { return m_standardPreferences; } >- IWebPreferencesPrivatePtr privatePreferences() { return m_prefsPrivate; } >- IWebFramePtr mainFrame(); >- IWebCoreStatisticsPtr statistics() { return m_statistics; } >- IWebCachePtr webCache() { return m_webCache; } >- IWebViewPtr webView() { return m_webView; } >- >- bool hasWebView() const { return !!m_webView; } >- bool usesLayeredWebView() const { return m_useLayeredWebView; } >- bool goBack(); >- bool goForward(); >- >- void setUserAgent(UINT menuID); >- void setUserAgent(_bstr_t& customUAString); >- _bstr_t userAgent(); >- >- PageLoadTestClient& pageLoadTestClient() { return *m_pageLoadTestClient; } >- >- void resetZoom(); >- void zoomIn(); >- void zoomOut(); >- >- void showLayerTree(); >- >- HWND hwnd() { return m_viewWnd; } >- >- void print(); >- void updateStatistics(HWND dialog); >- void setPreference(UINT menuID, bool enable); >- >- MiniBrowser(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView, bool pageLoadTesting); >- void subclassForLayeredWindow(); >- bool setCacheFolder(); >- >- std::vector<IWebHistoryItemPtr> m_historyItems; >- >- std::unique_ptr<PageLoadTestClient> m_pageLoadTestClient; >- >- IWebViewPtr m_webView; >- IWebViewPrivatePtr m_webViewPrivate; >- >- IWebHistoryPtr m_webHistory; >- IWebInspectorPtr m_inspector; >- IWebPreferencesPtr m_standardPreferences; >- IWebPreferencesPrivatePtr m_prefsPrivate; >- >- IWebFrameLoadDelegatePtr m_frameLoadDelegate; >- IWebUIDelegatePtr m_uiDelegate; >- IAccessibilityDelegatePtr m_accessibilityDelegate; >- IWebResourceLoadDelegatePtr m_resourceLoadDelegate; >- IWebDownloadDelegatePtr m_downloadDelegate; >- >- IWebCoreStatisticsPtr m_statistics; >- IWebCachePtr m_webCache; >- >- HWND m_hMainWnd { nullptr }; >- HWND m_hURLBarWnd { nullptr }; >- HWND m_viewWnd { nullptr }; >- >- bool m_useLayeredWebView; >-}; >diff --git a/Tools/MiniBrowser/win/MiniBrowserWebHost.cpp b/Tools/MiniBrowser/win/MiniBrowserWebHost.cpp >index 2b79174400d995f23dfd4b410491909bb3c648bf..5d6eb7acf2a4e0163a67e84f2a7675c8f103bbeb 100644 >--- a/Tools/MiniBrowser/win/MiniBrowserWebHost.cpp >+++ b/Tools/MiniBrowser/win/MiniBrowserWebHost.cpp >@@ -31,7 +31,7 @@ > > #include "DOMDefaultImpl.h" > #include "PageLoadTestClient.h" >-#include "MiniBrowser.h" >+#include "WK1BrowserWindow.h" > #include <WebKitLegacy/WebKit.h> > > class SimpleEventListener : public DOMEventListener { >diff --git a/Tools/MiniBrowser/win/MiniBrowserWebHost.h b/Tools/MiniBrowser/win/MiniBrowserWebHost.h >index 3cfedbb45f1d0a98caea3741ecb45cc229b1c5f6..67f14a2534b2ebaa763bd10143be3c61d8a11c70 100644 >--- a/Tools/MiniBrowser/win/MiniBrowserWebHost.h >+++ b/Tools/MiniBrowser/win/MiniBrowserWebHost.h >@@ -29,11 +29,11 @@ > #include <WebKitLegacy/WebKit.h> > #include <comutil.h> > >-class MiniBrowser; >+class WK1BrowserWindow; > > class MiniBrowserWebHost : public IWebFrameLoadDelegate, public IWebFrameLoadDelegatePrivate { > public: >- MiniBrowserWebHost(MiniBrowser* client, HWND urlBar) >+ MiniBrowserWebHost(WK1BrowserWindow* client, HWND urlBar) > : m_client(client), m_hURLBarWnd(urlBar) { } > > // IUnknown >@@ -80,5 +80,5 @@ private: > HWND m_hURLBarWnd { 0 }; > HGDIOBJ m_URLBarFont { 0 }; > HGDIOBJ m_oldFont { 0 }; >- MiniBrowser* m_client { nullptr }; >+ WK1BrowserWindow* m_client { nullptr }; > }; >diff --git a/Tools/MiniBrowser/win/PageLoadTestClient.cpp b/Tools/MiniBrowser/win/PageLoadTestClient.cpp >index 958ba02bada561f190ffe33501a608f6944a79df..e12d0ae0253bbc734d4a6937f4834cc97ca54c4c 100644 >--- a/Tools/MiniBrowser/win/PageLoadTestClient.cpp >+++ b/Tools/MiniBrowser/win/PageLoadTestClient.cpp >@@ -26,7 +26,7 @@ > #include "stdafx.h" > #include "PageLoadTestClient.h" > >-#include "MiniBrowser.h" >+#include "WK1BrowserWindow.h" > #include <WebCore/PlatformExportMacros.h> > #include <cmath> > #include <wtf/Assertions.h> >@@ -35,7 +35,7 @@ > > static const CFTimeInterval waitForNewResourceLoadDuration = 0.1; > >-PageLoadTestClient::PageLoadTestClient(MiniBrowser* host, bool pageLoadTesting) >+PageLoadTestClient::PageLoadTestClient(WK1BrowserWindow* host, bool pageLoadTesting) > : m_host(host) > , m_repetitions(pageLoadTesting ? 20 : 1) > , m_waitForLoadToReallyEnd(this, &PageLoadTestClient::endPageLoad) >diff --git a/Tools/MiniBrowser/win/PageLoadTestClient.h b/Tools/MiniBrowser/win/PageLoadTestClient.h >index a044b2071658285c169a4470b3f7dbbafe3ced69..44a4a9ac7e4d6882e2d4eab595cfa58dc51d483a 100644 >--- a/Tools/MiniBrowser/win/PageLoadTestClient.h >+++ b/Tools/MiniBrowser/win/PageLoadTestClient.h >@@ -101,12 +101,12 @@ private: > RetainPtr<CFRunLoopTimerRef> m_timer; > }; > >-class MiniBrowser; >+class WK1BrowserWindow; > > class PageLoadTestClient { > WTF_MAKE_NONCOPYABLE(PageLoadTestClient); > public: >- PageLoadTestClient(MiniBrowser* host, bool pageLoadTesting = false); >+ PageLoadTestClient(WK1BrowserWindow* host, bool pageLoadTesting = false); > > #if OS(WINDOWS) > void setPageURL(const _bstr_t&); >@@ -131,7 +131,7 @@ private: > virtual void pageLoadEndedAtTime(CFAbsoluteTime); > void dumpRunStatistics(); > >- MiniBrowser* m_host; >+ WK1BrowserWindow* m_host; > CFAbsoluteTime m_pageLoadEndTime { 0 }; > CFTimeInterval m_totalTime { 0 }; > CFTimeInterval m_totalSquareRootsOfTime { 0 }; >diff --git a/Tools/MiniBrowser/win/PrintWebUIDelegate.cpp b/Tools/MiniBrowser/win/PrintWebUIDelegate.cpp >index f4db4d247a48dcecec6bc9da5d2bafacc90b4f6f..141d202eab81a9ca888301af7dcdc92feed45863 100644 >--- a/Tools/MiniBrowser/win/PrintWebUIDelegate.cpp >+++ b/Tools/MiniBrowser/win/PrintWebUIDelegate.cpp >@@ -29,7 +29,7 @@ > > #include "Common.h" > #include "MainWindow.h" >-#include "MiniBrowser.h" >+#include "WK1BrowserWindow.h" > #include <WebCore/COMPtr.h> > #include <WebKitLegacy/WebKitCOMAPI.h> > #include <comip.h> >@@ -71,7 +71,7 @@ HRESULT PrintWebUIDelegate::createWebViewWithRequest(_In_opt_ IWebView*, _In_opt > return E_FAIL; > ShowWindow(newWindow.hwnd(), SW_SHOW); > >- auto& newBrowserWindow = *static_cast<MiniBrowser*>(newWindow.browserWindow()); >+ auto& newBrowserWindow = *static_cast<WK1BrowserWindow*>(newWindow.browserWindow()); > *newWebView = newBrowserWindow.webView(); > IWebFramePtr frame; > HRESULT hr; >diff --git a/Tools/MiniBrowser/win/PrintWebUIDelegate.h b/Tools/MiniBrowser/win/PrintWebUIDelegate.h >index 097e139addd8f4ee5cd7c6bb34df14d781aa448b..afc07d76d0b29515d58fbaaa3a67d72d9292f9d8 100644 >--- a/Tools/MiniBrowser/win/PrintWebUIDelegate.h >+++ b/Tools/MiniBrowser/win/PrintWebUIDelegate.h >@@ -29,11 +29,11 @@ > > #include <WebKitLegacy/WebKit.h> > >-class MiniBrowser; >+class WK1BrowserWindow; > > class PrintWebUIDelegate : public IWebUIDelegate { > public: >- PrintWebUIDelegate(MiniBrowser& client) >+ PrintWebUIDelegate(WK1BrowserWindow& client) > : m_client(client) { } > > // IUnknown >@@ -106,7 +106,7 @@ public: > virtual HRESULT STDMETHODCALLTYPE paintCustomScrollCorner(_In_opt_ IWebView*, _In_ HDC, RECT) { return E_NOTIMPL; } > > private: >- MiniBrowser& m_client; >+ WK1BrowserWindow& m_client; > HWND m_modalDialogParent { nullptr }; > }; > >diff --git a/Tools/MiniBrowser/win/ResourceLoadDelegate.cpp b/Tools/MiniBrowser/win/ResourceLoadDelegate.cpp >index a1d13ce09e35358f6f4266caad43c9d09a92221e..ad85b51f64d3feba203f311cd3f407137308e93b 100644 >--- a/Tools/MiniBrowser/win/ResourceLoadDelegate.cpp >+++ b/Tools/MiniBrowser/win/ResourceLoadDelegate.cpp >@@ -26,8 +26,8 @@ > #include "ResourceLoadDelegate.h" > > #include "Common.h" >-#include "MiniBrowser.h" > #include "PageLoadTestClient.h" >+#include "WK1BrowserWindow.h" > #include <WebCore/COMPtr.h> > #include <WebKitLegacy/WebKitCOMAPI.h> > #include <comip.h> >diff --git a/Tools/MiniBrowser/win/ResourceLoadDelegate.h b/Tools/MiniBrowser/win/ResourceLoadDelegate.h >index 3f07f6a080a75a256020f40da4a256c1d37cd79e..6a363f6b6da19d7750e7e1293274133ee8064c82 100644 >--- a/Tools/MiniBrowser/win/ResourceLoadDelegate.h >+++ b/Tools/MiniBrowser/win/ResourceLoadDelegate.h >@@ -28,11 +28,11 @@ > > #include <WebKitLegacy/WebKit.h> > >-class MiniBrowser; >+class WK1BrowserWindow; > > class ResourceLoadDelegate : public IWebResourceLoadDelegate { > public: >- ResourceLoadDelegate(MiniBrowser* client) >+ ResourceLoadDelegate(WK1BrowserWindow* client) > : m_client(client) { } > > // IUnknown >@@ -52,7 +52,7 @@ public: > virtual HRESULT STDMETHODCALLTYPE plugInFailedWithError(_In_opt_ IWebView*, _In_opt_ IWebError*, _In_opt_ IWebDataSource*); > > private: >- MiniBrowser* m_client; >+ WK1BrowserWindow* m_client; > }; > > #endif // ResourceLoadDelegate >diff --git a/Tools/MiniBrowser/win/WK1BrowserWindow.cpp b/Tools/MiniBrowser/win/WK1BrowserWindow.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..5929ce916ea66c9efacbb9f453c1e23e4e5cb9d8 >--- /dev/null >+++ b/Tools/MiniBrowser/win/WK1BrowserWindow.cpp >@@ -0,0 +1,895 @@ >+/* >+ * Copyright (C) 2006, 2008, 2013-2015 Apple Inc. All rights reserved. >+ * Copyright (C) 2009, 2011 Brent Fulgham. All rights reserved. >+ * Copyright (C) 2009, 2010, 2011 Appcelerator, Inc. All rights reserved. >+ * Copyright (C) 2013 Alex Christensen. 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. ``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 >+ * 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 "stdafx.h" >+#include "WK1BrowserWindow.h" >+ >+#include "AccessibilityDelegate.h" >+#include "Common.h" >+#include "DOMDefaultImpl.h" >+#include "MiniBrowserLibResource.h" >+#include "MiniBrowserReplace.h" >+#include "MiniBrowserWebHost.h" >+#include "PrintWebUIDelegate.h" >+#include "ResourceLoadDelegate.h" >+#include "WebDownloadDelegate.h" >+#include <WebCore/COMPtr.h> >+#include <WebKitLegacy/WebKitCOMAPI.h> >+#include <algorithm> >+#include <cassert> >+#include <functional> >+#include <memory> >+#include <string> >+#include <vector> >+#include <wtf/text/WTFString.h> >+ >+#if USE(CF) >+#include <WebKitLegacy/CFDictionaryPropertyBag.h> >+#endif >+ >+namespace WebCore { >+float deviceScaleFactorForWindow(HWND); >+} >+ >+static const int maxHistorySize = 10; >+ >+typedef _com_ptr_t<_com_IIID<IWebMutableURLRequest, &__uuidof(IWebMutableURLRequest)>> IWebMutableURLRequestPtr; >+ >+Ref<BrowserWindow> WK1BrowserWindow::create(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView, bool pageLoadTesting) >+{ >+ return adoptRef(*new WK1BrowserWindow(mainWnd, urlBarWnd, useLayeredWebView, pageLoadTesting)); >+} >+ >+WK1BrowserWindow::WK1BrowserWindow(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView, bool pageLoadTesting) >+ : m_hMainWnd(mainWnd) >+ , m_hURLBarWnd(urlBarWnd) >+ , m_useLayeredWebView(useLayeredWebView) >+ , m_pageLoadTestClient(std::make_unique<PageLoadTestClient>(this, pageLoadTesting)) >+{ >+} >+ >+ULONG WK1BrowserWindow::AddRef() >+{ >+ ref(); >+ return refCount(); >+} >+ >+ULONG WK1BrowserWindow::Release() >+{ >+ auto count = refCount(); >+ deref(); >+ return --count; >+} >+ >+HRESULT WK1BrowserWindow::init() >+{ >+ HRESULT hr = WebKitCreateInstance(CLSID_WebView, 0, IID_IWebView, reinterpret_cast<void**>(&m_webView.GetInterfacePtr())); >+ if (FAILED(hr)) >+ return hr; >+ >+ hr = m_webView->QueryInterface(IID_IWebViewPrivate2, reinterpret_cast<void**>(&m_webViewPrivate.GetInterfacePtr())); >+ if (FAILED(hr)) >+ return hr; >+ >+ hr = WebKitCreateInstance(CLSID_WebHistory, 0, __uuidof(m_webHistory), reinterpret_cast<void**>(&m_webHistory.GetInterfacePtr())); >+ if (FAILED(hr)) >+ return hr; >+ >+ hr = WebKitCreateInstance(CLSID_WebCoreStatistics, 0, __uuidof(m_statistics), reinterpret_cast<void**>(&m_statistics.GetInterfacePtr())); >+ if (FAILED(hr)) >+ return hr; >+ >+ hr = WebKitCreateInstance(CLSID_WebCache, 0, __uuidof(m_webCache), reinterpret_cast<void**>(&m_webCache.GetInterfacePtr())); >+ if (FAILED(hr)) >+ return hr; >+ >+ if (!seedInitialDefaultPreferences()) >+ return E_FAIL; >+ >+ if (!setToDefaultPreferences()) >+ return E_FAIL; >+ >+ if (!setCacheFolder()) >+ return E_FAIL; >+ >+ auto webHost = new MiniBrowserWebHost(this, m_hURLBarWnd); >+ >+ hr = setFrameLoadDelegate(webHost); >+ if (FAILED(hr)) >+ return hr; >+ >+ hr = setFrameLoadDelegatePrivate(webHost); >+ if (FAILED(hr)) >+ return hr; >+ >+ hr = setUIDelegate(new PrintWebUIDelegate(*this)); >+ if (FAILED (hr)) >+ return hr; >+ >+ hr = setAccessibilityDelegate(new AccessibilityDelegate(*this)); >+ if (FAILED (hr)) >+ return hr; >+ >+ hr = setResourceLoadDelegate(new ResourceLoadDelegate(this)); >+ if (FAILED(hr)) >+ return hr; >+ >+ IWebDownloadDelegatePtr downloadDelegate; >+ downloadDelegate.Attach(new WebDownloadDelegate(*this)); >+ hr = setDownloadDelegate(downloadDelegate); >+ if (FAILED(hr)) >+ return hr; >+ >+ RECT clientRect; >+ ::GetClientRect(m_hMainWnd, &clientRect); >+ if (usesLayeredWebView()) >+ clientRect = { s_windowPosition.x, s_windowPosition.y, s_windowPosition.x + s_windowSize.cx, s_windowPosition.y + s_windowSize.cy }; >+ >+ hr = prepareViews(m_hMainWnd, clientRect); >+ if (FAILED(hr)) >+ return hr; >+ >+ if (usesLayeredWebView()) >+ subclassForLayeredWindow(); >+ >+ return hr; >+} >+ >+bool WK1BrowserWindow::setCacheFolder() >+{ >+ _bstr_t appDataFolder; >+ if (!getAppDataFolder(appDataFolder)) >+ return false; >+ >+ appDataFolder += L"\\cache"; >+ webCache()->setCacheFolder(appDataFolder); >+ >+ return true; >+} >+ >+HRESULT WK1BrowserWindow::prepareViews(HWND mainWnd, const RECT& clientRect) >+{ >+ if (!m_webView) >+ return E_FAIL; >+ >+ HRESULT hr = m_webView->setHostWindow(mainWnd); >+ if (FAILED(hr)) >+ return hr; >+ >+ hr = m_webView->initWithFrame(clientRect, 0, 0); >+ if (FAILED(hr)) >+ return hr; >+ >+ hr = m_webViewPrivate->setTransparent(m_useLayeredWebView); >+ if (FAILED(hr)) >+ return hr; >+ >+ hr = m_webViewPrivate->setUsesLayeredWindow(m_useLayeredWebView); >+ if (FAILED(hr)) >+ return hr; >+ >+ hr = m_webViewPrivate->viewWindow(&m_viewWnd); >+ >+ return hr; >+} >+ >+HRESULT WK1BrowserWindow::loadHTMLString(const BSTR& str) >+{ >+ IWebFramePtr frame; >+ HRESULT hr = m_webView->mainFrame(&frame.GetInterfacePtr()); >+ if (FAILED(hr)) >+ return hr; >+ >+ frame->loadHTMLString(str, 0); >+ return hr; >+} >+ >+static WNDPROC gDefWebKitProc; >+ >+static LRESULT CALLBACK viewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) >+{ >+ switch (message) { >+ case WM_NCHITTEST: >+ constexpr int dragBarHeight = 30; >+ RECT window; >+ ::GetWindowRect(hWnd, &window); >+ // For testing our transparent window, we need a region to use as a handle for >+ // dragging. The right way to do this would be to query the web view to see what's >+ // under the mouse. However, for testing purposes we just use an arbitrary >+ // 30 logical pixel band at the top of the view as an arbitrary gripping location. >+ // >+ // When we are within this bad, return HT_CAPTION to tell Windows we want to >+ // treat this region as if it were the title bar on a normal window. >+ int y = HIWORD(lParam); >+ float scaledDragBarHeightFactor = dragBarHeight * WebCore::deviceScaleFactorForWindow(hWnd); >+ if ((y > window.top) && (y < window.top + scaledDragBarHeightFactor)) >+ return HTCAPTION; >+ } >+ return CallWindowProc(gDefWebKitProc, hWnd, message, wParam, lParam); >+} >+ >+void WK1BrowserWindow::subclassForLayeredWindow() >+{ >+#if defined _M_AMD64 || defined _WIN64 >+ gDefWebKitProc = reinterpret_cast<WNDPROC>(::GetWindowLongPtr(m_viewWnd, GWLP_WNDPROC)); >+ ::SetWindowLongPtr(m_viewWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(viewWndProc)); >+#else >+ gDefWebKitProc = reinterpret_cast<WNDPROC>(::GetWindowLong(m_viewWnd, GWL_WNDPROC)); >+ ::SetWindowLong(m_viewWnd, GWL_WNDPROC, reinterpret_cast<LONG_PTR>(viewWndProc)); >+#endif >+} >+ >+HRESULT WK1BrowserWindow::setFrameLoadDelegate(IWebFrameLoadDelegate* frameLoadDelegate) >+{ >+ m_frameLoadDelegate = frameLoadDelegate; >+ return m_webView->setFrameLoadDelegate(frameLoadDelegate); >+} >+ >+HRESULT WK1BrowserWindow::setFrameLoadDelegatePrivate(IWebFrameLoadDelegatePrivate* frameLoadDelegatePrivate) >+{ >+ return m_webViewPrivate->setFrameLoadDelegatePrivate(frameLoadDelegatePrivate); >+} >+ >+HRESULT WK1BrowserWindow::setUIDelegate(IWebUIDelegate* uiDelegate) >+{ >+ m_uiDelegate = uiDelegate; >+ return m_webView->setUIDelegate(uiDelegate); >+} >+ >+HRESULT WK1BrowserWindow::setAccessibilityDelegate(IAccessibilityDelegate* accessibilityDelegate) >+{ >+ m_accessibilityDelegate = accessibilityDelegate; >+ return m_webView->setAccessibilityDelegate(accessibilityDelegate); >+} >+ >+HRESULT WK1BrowserWindow::setResourceLoadDelegate(IWebResourceLoadDelegate* resourceLoadDelegate) >+{ >+ m_resourceLoadDelegate = resourceLoadDelegate; >+ return m_webView->setResourceLoadDelegate(resourceLoadDelegate); >+} >+ >+HRESULT WK1BrowserWindow::setDownloadDelegate(IWebDownloadDelegatePtr downloadDelegate) >+{ >+ m_downloadDelegate = downloadDelegate; >+ return m_webView->setDownloadDelegate(downloadDelegate); >+} >+ >+IWebFramePtr WK1BrowserWindow::mainFrame() >+{ >+ IWebFramePtr framePtr; >+ m_webView->mainFrame(&framePtr.GetInterfacePtr()); >+ return framePtr; >+} >+ >+bool WK1BrowserWindow::seedInitialDefaultPreferences() >+{ >+ IWebPreferencesPtr tmpPreferences; >+ if (FAILED(WebKitCreateInstance(CLSID_WebPreferences, 0, IID_IWebPreferences, reinterpret_cast<void**>(&tmpPreferences.GetInterfacePtr())))) >+ return false; >+ >+ if (FAILED(tmpPreferences->standardPreferences(&m_standardPreferences.GetInterfacePtr()))) >+ return false; >+ >+ return true; >+} >+ >+bool WK1BrowserWindow::setToDefaultPreferences() >+{ >+ HRESULT hr = m_standardPreferences->QueryInterface(IID_IWebPreferencesPrivate, reinterpret_cast<void**>(&m_prefsPrivate.GetInterfacePtr())); >+ if (!SUCCEEDED(hr)) >+ return false; >+ >+#if USE(CG) >+ m_standardPreferences->setAVFoundationEnabled(TRUE); >+ m_prefsPrivate->setAcceleratedCompositingEnabled(TRUE); >+#endif >+ >+ m_prefsPrivate->setFullScreenEnabled(TRUE); >+ m_prefsPrivate->setShowDebugBorders(FALSE); >+ m_prefsPrivate->setShowRepaintCounter(FALSE); >+ m_prefsPrivate->setShouldInvertColors(FALSE); >+ >+ m_standardPreferences->setLoadsImagesAutomatically(TRUE); >+ m_prefsPrivate->setAuthorAndUserStylesEnabled(TRUE); >+ m_standardPreferences->setJavaScriptEnabled(TRUE); >+ m_prefsPrivate->setAllowUniversalAccessFromFileURLs(FALSE); >+ m_prefsPrivate->setAllowFileAccessFromFileURLs(TRUE); >+ >+ m_prefsPrivate->setDeveloperExtrasEnabled(TRUE); >+ >+ return true; >+} >+ >+static void updateMenuItemForHistoryItem(HMENU menu, IWebHistoryItem& historyItem, int currentHistoryItem) >+{ >+ UINT menuID = IDM_HISTORY_LINK0 + currentHistoryItem; >+ >+ MENUITEMINFO menuItemInfo = { 0 }; >+ menuItemInfo.cbSize = sizeof(MENUITEMINFO); >+ menuItemInfo.fMask = MIIM_TYPE; >+ menuItemInfo.fType = MFT_STRING; >+ >+ _bstr_t title; >+ historyItem.title(title.GetAddress()); >+ menuItemInfo.dwTypeData = static_cast<LPWSTR>(title); >+ >+ ::SetMenuItemInfo(menu, menuID, FALSE, &menuItemInfo); >+ ::EnableMenuItem(menu, menuID, MF_BYCOMMAND | MF_ENABLED); >+} >+ >+void WK1BrowserWindow::showLastVisitedSites(IWebView& webView) >+{ >+ HMENU menu = ::GetMenu(m_hMainWnd); >+ >+ _com_ptr_t<_com_IIID<IWebBackForwardList, &__uuidof(IWebBackForwardList)>> backForwardList; >+ HRESULT hr = webView.backForwardList(&backForwardList.GetInterfacePtr()); >+ if (FAILED(hr)) >+ return; >+ >+ int capacity = 0; >+ hr = backForwardList->capacity(&capacity); >+ if (FAILED(hr)) >+ return; >+ >+ int backCount = 0; >+ hr = backForwardList->backListCount(&backCount); >+ if (FAILED(hr)) >+ return; >+ >+ UINT backSetting = MF_BYCOMMAND | ((backCount) ? MF_ENABLED : MF_DISABLED); >+ ::EnableMenuItem(menu, IDM_HISTORY_BACKWARD, backSetting); >+ >+ int forwardCount = 0; >+ hr = backForwardList->forwardListCount(&forwardCount); >+ if (FAILED(hr)) >+ return; >+ >+ UINT forwardSetting = MF_BYCOMMAND | ((forwardCount) ? MF_ENABLED : MF_DISABLED); >+ ::EnableMenuItem(menu, IDM_HISTORY_FORWARD, forwardSetting); >+ >+ IWebHistoryItemPtr currentItem; >+ hr = backForwardList->currentItem(¤tItem.GetInterfacePtr()); >+ if (FAILED(hr)) >+ return; >+ >+ hr = m_webHistory->addItems(1, ¤tItem.GetInterfacePtr()); >+ if (FAILED(hr)) >+ return; >+ >+ _com_ptr_t<_com_IIID<IWebHistoryPrivate, &__uuidof(IWebHistoryPrivate)>> webHistory; >+ hr = m_webHistory->QueryInterface(IID_IWebHistoryPrivate, reinterpret_cast<void**>(&webHistory.GetInterfacePtr())); >+ if (FAILED(hr)) >+ return; >+ >+ int totalListCount = 0; >+ hr = webHistory->allItems(&totalListCount, 0); >+ if (FAILED(hr)) >+ return; >+ >+ m_historyItems.resize(totalListCount); >+ >+ std::vector<IWebHistoryItem*> historyToLoad(totalListCount); >+ hr = webHistory->allItems(&totalListCount, historyToLoad.data()); >+ if (FAILED(hr)) >+ return; >+ >+ size_t i = 0; >+ for (auto& cur : historyToLoad) { >+ m_historyItems[i].Attach(cur); >+ ++i; >+ } >+ >+ int allItemsOffset = 0; >+ if (totalListCount > maxHistorySize) >+ allItemsOffset = totalListCount - maxHistorySize; >+ >+ int currentHistoryItem = 0; >+ for (int i = 0; i < m_historyItems.size() && (allItemsOffset + currentHistoryItem) < m_historyItems.size(); ++i) { >+ updateMenuItemForHistoryItem(menu, *(m_historyItems[allItemsOffset + currentHistoryItem]), currentHistoryItem); >+ ++currentHistoryItem; >+ } >+ >+ // Hide any history we aren't using yet. >+ for (int i = currentHistoryItem; i < maxHistorySize; ++i) >+ ::EnableMenuItem(menu, IDM_HISTORY_LINK0 + i, MF_BYCOMMAND | MF_DISABLED); >+} >+ >+void WK1BrowserWindow::launchInspector() >+{ >+ if (!m_webViewPrivate) >+ return; >+ >+ if (!SUCCEEDED(m_webViewPrivate->inspector(&m_inspector.GetInterfacePtr()))) >+ return; >+ >+ m_inspector->show(); >+} >+ >+void WK1BrowserWindow::navigateForwardOrBackward(UINT menuID) >+{ >+ if (!m_webView) >+ return; >+ >+ BOOL wentBackOrForward = FALSE; >+ if (IDM_HISTORY_FORWARD == menuID) >+ m_webView->goForward(&wentBackOrForward); >+ else >+ m_webView->goBack(&wentBackOrForward); >+} >+ >+void WK1BrowserWindow::navigateToHistory(UINT menuID) >+{ >+ if (!m_webView) >+ return; >+ >+ int historyEntry = menuID - IDM_HISTORY_LINK0; >+ if (historyEntry > m_historyItems.size()) >+ return; >+ >+ IWebHistoryItemPtr desiredHistoryItem = m_historyItems[historyEntry]; >+ if (!desiredHistoryItem) >+ return; >+ >+ BOOL succeeded = FALSE; >+ m_webView->goToBackForwardItem(desiredHistoryItem, &succeeded); >+ >+ _bstr_t frameURL; >+ desiredHistoryItem->URLString(frameURL.GetAddress()); >+ >+ ::SendMessage(m_hURLBarWnd, (UINT)WM_SETTEXT, 0, (LPARAM)frameURL.GetBSTR()); >+} >+ >+bool WK1BrowserWindow::goBack() >+{ >+ BOOL wentBack = FALSE; >+ m_webView->goBack(&wentBack); >+ return wentBack; >+} >+ >+bool WK1BrowserWindow::goForward() >+{ >+ BOOL wentForward = FALSE; >+ m_webView->goForward(&wentForward); >+ return wentForward; >+} >+ >+HRESULT WK1BrowserWindow::loadURL(const BSTR& passedURL) >+{ >+ if (!passedURL) >+ return E_INVALIDARG; >+ >+ _bstr_t urlBStr(passedURL); >+ if (!!urlBStr && (::PathFileExists(urlBStr) || ::PathIsUNC(urlBStr))) { >+ TCHAR fileURL[INTERNET_MAX_URL_LENGTH]; >+ DWORD fileURLLength = sizeof(fileURL) / sizeof(fileURL[0]); >+ >+ if (SUCCEEDED(::UrlCreateFromPath(urlBStr, fileURL, &fileURLLength, 0))) >+ urlBStr = fileURL; >+ } >+ >+ IWebFramePtr frame; >+ HRESULT hr = m_webView->mainFrame(&frame.GetInterfacePtr()); >+ if (FAILED(hr)) >+ return hr; >+ >+ IWebMutableURLRequestPtr request; >+ hr = WebKitCreateInstance(CLSID_WebMutableURLRequest, 0, IID_IWebMutableURLRequest, (void**)&request); >+ if (FAILED(hr)) >+ return hr; >+ >+ hr = request->initWithURL(wcsstr(static_cast<wchar_t*>(urlBStr), L"://") ? urlBStr : _bstr_t(L"http://") + urlBStr, WebURLRequestUseProtocolCachePolicy, 60); >+ if (FAILED(hr)) >+ return hr; >+ >+ _bstr_t methodBStr(L"GET"); >+ hr = request->setHTTPMethod(methodBStr); >+ if (FAILED(hr)) >+ return hr; >+ >+ hr = frame->loadRequest(request); >+ >+ return hr; >+} >+ >+void WK1BrowserWindow::exitProgram() >+{ >+ ::PostMessage(m_hMainWnd, static_cast<UINT>(WM_COMMAND), MAKELPARAM(IDM_EXIT, 0), 0); >+} >+ >+void WK1BrowserWindow::setUserAgent(UINT menuID) >+{ >+ if (!webView()) >+ return; >+ >+ _bstr_t customUserAgent; >+ switch (menuID) { >+ case IDM_UA_DEFAULT: >+ // Set to null user agent >+ break; >+ case IDM_UA_SAFARI_8_0: >+ customUserAgent = L"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10) AppleWebKit/600.1.25 (KHTML, like Gecko) Version/8.0 Safari/600.1.25"; >+ break; >+ case IDM_UA_SAFARI_IOS_8_IPHONE: >+ customUserAgent = L"Mozilla/5.0 (iPhone; CPU OS 8_1 like Mac OS X) AppleWebKit/601.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B403 Safari/600.1.4"; >+ break; >+ case IDM_UA_SAFARI_IOS_8_IPAD: >+ customUserAgent = L"Mozilla/5.0 (iPad; CPU OS 8_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B403 Safari/600.1.4"; >+ break; >+ case IDM_UA_IE_11: >+ customUserAgent = L"Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko"; >+ break; >+ case IDM_UA_CHROME_MAC: >+ customUserAgent = L"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31"; >+ break; >+ case IDM_UA_CHROME_WIN: >+ customUserAgent = L"Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31"; >+ break; >+ case IDM_UA_FIREFOX_MAC: >+ customUserAgent = L"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:20.0) Gecko/20100101 Firefox/20.0"; >+ break; >+ case IDM_UA_FIREFOX_WIN: >+ customUserAgent = L"Mozilla/5.0 (Windows NT 6.2; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0"; >+ break; >+ case IDM_UA_OTHER: >+ default: >+ ASSERT(0); // We should never hit this case >+ return; >+ } >+ >+ setUserAgent(customUserAgent); >+} >+ >+void WK1BrowserWindow::setUserAgent(_bstr_t& customUserAgent) >+{ >+ webView()->setCustomUserAgent(customUserAgent.GetBSTR()); >+} >+ >+_bstr_t WK1BrowserWindow::userAgent() >+{ >+ _bstr_t userAgent; >+ if (FAILED(webView()->customUserAgent(&userAgent.GetBSTR()))) >+ return _bstr_t(L"- Unknown -: Call failed."); >+ >+ return userAgent; >+} >+ >+typedef _com_ptr_t<_com_IIID<IWebIBActions, &__uuidof(IWebIBActions)>> IWebIBActionsPtr; >+ >+void WK1BrowserWindow::resetZoom() >+{ >+ IWebIBActionsPtr webActions; >+ if (FAILED(m_webView->QueryInterface(IID_IWebIBActions, reinterpret_cast<void**>(&webActions.GetInterfacePtr())))) >+ return; >+ >+ webActions->resetPageZoom(nullptr); >+} >+ >+void WK1BrowserWindow::zoomIn() >+{ >+ IWebIBActionsPtr webActions; >+ if (FAILED(m_webView->QueryInterface(IID_IWebIBActions, reinterpret_cast<void**>(&webActions.GetInterfacePtr())))) >+ return; >+ >+ webActions->zoomPageIn(nullptr); >+} >+ >+void WK1BrowserWindow::zoomOut() >+{ >+ IWebIBActionsPtr webActions; >+ if (FAILED(m_webView->QueryInterface(IID_IWebIBActions, reinterpret_cast<void**>(&webActions.GetInterfacePtr())))) >+ return; >+ >+ webActions->zoomPageOut(nullptr); >+} >+ >+typedef _com_ptr_t<_com_IIID<IWebViewPrivate3, &__uuidof(IWebViewPrivate3)>> IWebViewPrivate3Ptr; >+ >+void WK1BrowserWindow::showLayerTree() >+{ >+ IWebViewPrivate3Ptr webViewPrivate; >+ if (FAILED(m_webView->QueryInterface(IID_IWebViewPrivate3, reinterpret_cast<void**>(&webViewPrivate.GetInterfacePtr())))) >+ return; >+ >+ OutputDebugString(L"CURRENT TREE:\n"); >+ >+ _bstr_t layerTreeBstr; >+ if (FAILED(webViewPrivate->layerTreeAsString(layerTreeBstr.GetAddress()))) >+ OutputDebugString(L" Failed to retrieve the layer tree.\n"); >+ else >+ OutputDebugString(layerTreeBstr); >+ OutputDebugString(L"\n\n"); >+} >+ >+static BOOL CALLBACK AbortProc(HDC hDC, int Error) >+{ >+ MSG msg; >+ while (::PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { >+ ::TranslateMessage(&msg); >+ ::DispatchMessage(&msg); >+ } >+ >+ return TRUE; >+} >+ >+static HDC getPrinterDC() >+{ >+ PRINTDLG pdlg; >+ memset(&pdlg, 0, sizeof(PRINTDLG)); >+ pdlg.lStructSize = sizeof(PRINTDLG); >+ pdlg.Flags = PD_PRINTSETUP | PD_RETURNDC; >+ >+ ::PrintDlg(&pdlg); >+ >+ return pdlg.hDC; >+} >+ >+static void initDocStruct(DOCINFO* di, TCHAR* docname) >+{ >+ memset(di, 0, sizeof(DOCINFO)); >+ di->cbSize = sizeof(DOCINFO); >+ di->lpszDocName = docname; >+} >+ >+void WK1BrowserWindow::print() >+{ >+ HDC printDC = getPrinterDC(); >+ if (!printDC) { >+ ::MessageBox(0, L"Error creating printing DC", L"Error", MB_APPLMODAL | MB_OK); >+ return; >+ } >+ >+ if (::SetAbortProc(printDC, AbortProc) == SP_ERROR) { >+ ::MessageBox(0, L"Error setting up AbortProc", L"Error", MB_APPLMODAL | MB_OK); >+ return; >+ } >+ >+ IWebFramePtr frame = mainFrame(); >+ if (!frame) >+ return; >+ >+ IWebFramePrivatePtr framePrivate; >+ if (FAILED(frame->QueryInterface(&framePrivate.GetInterfacePtr()))) >+ return; >+ >+ framePrivate->setInPrintingMode(TRUE, printDC); >+ >+ UINT pageCount = 0; >+ framePrivate->getPrintedPageCount(printDC, &pageCount); >+ >+ DOCINFO di; >+ initDocStruct(&di, L"WebKit Doc"); >+ ::StartDoc(printDC, &di); >+ >+ // FIXME: Need CoreGraphics implementation >+ void* graphicsContext = 0; >+ for (size_t page = 1; page <= pageCount; ++page) { >+ ::StartPage(printDC); >+ framePrivate->spoolPages(printDC, page, page, graphicsContext); >+ ::EndPage(printDC); >+ } >+ >+ framePrivate->setInPrintingMode(FALSE, printDC); >+ >+ ::EndDoc(printDC); >+ ::DeleteDC(printDC); >+} >+ >+static void setWindowText(HWND dialog, UINT field, _bstr_t value) >+{ >+ ::SetDlgItemText(dialog, field, value); >+} >+ >+static void setWindowText(HWND dialog, UINT field, UINT value) >+{ >+ String valueStr = WTF::String::number(value); >+ >+ setWindowText(dialog, field, _bstr_t(valueStr.utf8().data())); >+} >+ >+typedef _com_ptr_t<_com_IIID<IPropertyBag, &__uuidof(IPropertyBag)>> IPropertyBagPtr; >+ >+static void setWindowText(HWND dialog, UINT field, IPropertyBagPtr statistics, const _bstr_t& key) >+{ >+ _variant_t var; >+ V_VT(&var) = VT_UI8; >+ if (FAILED(statistics->Read(key, &var.GetVARIANT(), nullptr))) >+ return; >+ >+ unsigned long long value = V_UI8(&var); >+ String valueStr = WTF::String::number(value); >+ >+ setWindowText(dialog, field, _bstr_t(valueStr.utf8().data())); >+} >+ >+static void setWindowText(HWND dialog, UINT field, CFDictionaryRef dictionary, CFStringRef key, UINT& total) >+{ >+ CFNumberRef countNum = static_cast<CFNumberRef>(CFDictionaryGetValue(dictionary, key)); >+ if (!countNum) >+ return; >+ >+ int count = 0; >+ CFNumberGetValue(countNum, kCFNumberIntType, &count); >+ >+ setWindowText(dialog, field, static_cast<UINT>(count)); >+ total += count; >+} >+ >+void WK1BrowserWindow::updateStatistics(HWND dialog) >+{ >+ IWebCoreStatisticsPtr webCoreStatistics = statistics(); >+ if (!webCoreStatistics) >+ return; >+ >+ IPropertyBagPtr statistics; >+ HRESULT hr = webCoreStatistics->memoryStatistics(&statistics.GetInterfacePtr()); >+ if (FAILED(hr)) >+ return; >+ >+ // FastMalloc. >+ setWindowText(dialog, IDC_RESERVED_VM, statistics, "FastMallocReservedVMBytes"); >+ setWindowText(dialog, IDC_COMMITTED_VM, statistics, "FastMallocCommittedVMBytes"); >+ setWindowText(dialog, IDC_FREE_LIST_BYTES, statistics, "FastMallocFreeListBytes"); >+ >+ // WebCore Cache. >+#if USE(CF) >+ IWebCachePtr webCache = this->webCache(); >+ >+ int dictCount = 6; >+ IPropertyBag* cacheDict[6] = { 0 }; >+ if (FAILED(webCache->statistics(&dictCount, cacheDict))) >+ return; >+ >+ COMPtr<CFDictionaryPropertyBag> counts, sizes, liveSizes, decodedSizes, purgableSizes; >+ counts.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[0])); >+ sizes.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[1])); >+ liveSizes.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[2])); >+ decodedSizes.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[3])); >+ purgableSizes.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[4])); >+ >+ static CFStringRef imagesKey = CFSTR("images"); >+ static CFStringRef stylesheetsKey = CFSTR("style sheets"); >+ static CFStringRef xslKey = CFSTR("xsl"); >+ static CFStringRef scriptsKey = CFSTR("scripts"); >+ >+ if (counts) { >+ UINT totalObjects = 0; >+ setWindowText(dialog, IDC_IMAGES_OBJECT_COUNT, counts->dictionary(), imagesKey, totalObjects); >+ setWindowText(dialog, IDC_CSS_OBJECT_COUNT, counts->dictionary(), stylesheetsKey, totalObjects); >+ setWindowText(dialog, IDC_XSL_OBJECT_COUNT, counts->dictionary(), xslKey, totalObjects); >+ setWindowText(dialog, IDC_JSC_OBJECT_COUNT, counts->dictionary(), scriptsKey, totalObjects); >+ setWindowText(dialog, IDC_TOTAL_OBJECT_COUNT, totalObjects); >+ } >+ >+ if (sizes) { >+ UINT totalBytes = 0; >+ setWindowText(dialog, IDC_IMAGES_BYTES, sizes->dictionary(), imagesKey, totalBytes); >+ setWindowText(dialog, IDC_CSS_BYTES, sizes->dictionary(), stylesheetsKey, totalBytes); >+ setWindowText(dialog, IDC_XSL_BYTES, sizes->dictionary(), xslKey, totalBytes); >+ setWindowText(dialog, IDC_JSC_BYTES, sizes->dictionary(), scriptsKey, totalBytes); >+ setWindowText(dialog, IDC_TOTAL_BYTES, totalBytes); >+ } >+ >+ if (liveSizes) { >+ UINT totalLiveBytes = 0; >+ setWindowText(dialog, IDC_IMAGES_LIVE_COUNT, liveSizes->dictionary(), imagesKey, totalLiveBytes); >+ setWindowText(dialog, IDC_CSS_LIVE_COUNT, liveSizes->dictionary(), stylesheetsKey, totalLiveBytes); >+ setWindowText(dialog, IDC_XSL_LIVE_COUNT, liveSizes->dictionary(), xslKey, totalLiveBytes); >+ setWindowText(dialog, IDC_JSC_LIVE_COUNT, liveSizes->dictionary(), scriptsKey, totalLiveBytes); >+ setWindowText(dialog, IDC_TOTAL_LIVE_COUNT, totalLiveBytes); >+ } >+ >+ if (decodedSizes) { >+ UINT totalDecoded = 0; >+ setWindowText(dialog, IDC_IMAGES_DECODED_COUNT, decodedSizes->dictionary(), imagesKey, totalDecoded); >+ setWindowText(dialog, IDC_CSS_DECODED_COUNT, decodedSizes->dictionary(), stylesheetsKey, totalDecoded); >+ setWindowText(dialog, IDC_XSL_DECODED_COUNT, decodedSizes->dictionary(), xslKey, totalDecoded); >+ setWindowText(dialog, IDC_JSC_DECODED_COUNT, decodedSizes->dictionary(), scriptsKey, totalDecoded); >+ setWindowText(dialog, IDC_TOTAL_DECODED, totalDecoded); >+ } >+ >+ if (purgableSizes) { >+ UINT totalPurgable = 0; >+ setWindowText(dialog, IDC_IMAGES_PURGEABLE_COUNT, purgableSizes->dictionary(), imagesKey, totalPurgable); >+ setWindowText(dialog, IDC_CSS_PURGEABLE_COUNT, purgableSizes->dictionary(), stylesheetsKey, totalPurgable); >+ setWindowText(dialog, IDC_XSL_PURGEABLE_COUNT, purgableSizes->dictionary(), xslKey, totalPurgable); >+ setWindowText(dialog, IDC_JSC_PURGEABLE_COUNT, purgableSizes->dictionary(), scriptsKey, totalPurgable); >+ setWindowText(dialog, IDC_TOTAL_PURGEABLE, totalPurgable); >+ } >+#endif >+ >+ // JavaScript Heap. >+ setWindowText(dialog, IDC_JSC_HEAP_SIZE, statistics, "JavaScriptHeapSize"); >+ setWindowText(dialog, IDC_JSC_HEAP_FREE, statistics, "JavaScriptFreeSize"); >+ >+ UINT count; >+ if (SUCCEEDED(webCoreStatistics->javaScriptObjectsCount(&count))) >+ setWindowText(dialog, IDC_TOTAL_JSC_HEAP_OBJECTS, count); >+ if (SUCCEEDED(webCoreStatistics->javaScriptGlobalObjectsCount(&count))) >+ setWindowText(dialog, IDC_GLOBAL_JSC_HEAP_OBJECTS, count); >+ if (SUCCEEDED(webCoreStatistics->javaScriptProtectedObjectsCount(&count))) >+ setWindowText(dialog, IDC_PROTECTED_JSC_HEAP_OBJECTS, count); >+ >+ // Font and Glyph Caches. >+ if (SUCCEEDED(webCoreStatistics->cachedFontDataCount(&count))) >+ setWindowText(dialog, IDC_TOTAL_FONT_OBJECTS, count); >+ if (SUCCEEDED(webCoreStatistics->cachedFontDataInactiveCount(&count))) >+ setWindowText(dialog, IDC_INACTIVE_FONT_OBJECTS, count); >+ if (SUCCEEDED(webCoreStatistics->glyphPageCount(&count))) >+ setWindowText(dialog, IDC_GLYPH_PAGES, count); >+ >+ // Site Icon Database. >+ if (SUCCEEDED(webCoreStatistics->iconPageURLMappingCount(&count))) >+ setWindowText(dialog, IDC_PAGE_URL_MAPPINGS, count); >+ if (SUCCEEDED(webCoreStatistics->iconRetainedPageURLCount(&count))) >+ setWindowText(dialog, IDC_RETAINED_PAGE_URLS, count); >+ if (SUCCEEDED(webCoreStatistics->iconRecordCount(&count))) >+ setWindowText(dialog, IDC_SITE_ICON_RECORDS, count); >+ if (SUCCEEDED(webCoreStatistics->iconsWithDataCount(&count))) >+ setWindowText(dialog, IDC_SITE_ICONS_WITH_DATA, count); >+} >+ >+void WK1BrowserWindow::setPreference(UINT menuID, bool enable) >+{ >+ if (!standardPreferences() || !privatePreferences()) >+ return; >+ >+ switch (menuID) { >+ case IDM_AVFOUNDATION: >+ standardPreferences()->setAVFoundationEnabled(enable); >+ break; >+ case IDM_ACC_COMPOSITING: >+ privatePreferences()->setAcceleratedCompositingEnabled(enable); >+ break; >+ case IDM_WK_FULLSCREEN: >+ privatePreferences()->setFullScreenEnabled(enable); >+ break; >+ case IDM_COMPOSITING_BORDERS: >+ privatePreferences()->setShowDebugBorders(enable); >+ privatePreferences()->setShowRepaintCounter(enable); >+ break; >+ case IDM_DEBUG_INFO_LAYER: >+ privatePreferences()->setShowTiledScrollingIndicator(enable); >+ break; >+ case IDM_INVERT_COLORS: >+ privatePreferences()->setShouldInvertColors(enable); >+ break; >+ case IDM_DISABLE_IMAGES: >+ standardPreferences()->setLoadsImagesAutomatically(!enable); >+ break; >+ case IDM_DISABLE_STYLES: >+ privatePreferences()->setAuthorAndUserStylesEnabled(!enable); >+ break; >+ case IDM_DISABLE_JAVASCRIPT: >+ standardPreferences()->setJavaScriptEnabled(!enable); >+ break; >+ case IDM_DISABLE_LOCAL_FILE_RESTRICTIONS: >+ privatePreferences()->setAllowUniversalAccessFromFileURLs(enable); >+ privatePreferences()->setAllowFileAccessFromFileURLs(enable); >+ break; >+ } >+} >diff --git a/Tools/MiniBrowser/win/WK1BrowserWindow.h b/Tools/MiniBrowser/win/WK1BrowserWindow.h >new file mode 100644 >index 0000000000000000000000000000000000000000..9d74abf27ba450d7abf3e070471a68ba3d456f5a >--- /dev/null >+++ b/Tools/MiniBrowser/win/WK1BrowserWindow.h >@@ -0,0 +1,147 @@ >+/* >+ * Copyright (C) 2014-2015 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. ``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 >+ * 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. >+ */ >+ >+#pragma once >+#include "BrowserWindow.h" >+#include "PageLoadTestClient.h" >+#include <WebKitLegacy/WebKit.h> >+#include <comip.h> >+#include <memory> >+#include <vector> >+ >+typedef _com_ptr_t<_com_IIID<IWebFrame, &__uuidof(IWebFrame)>> IWebFramePtr; >+typedef _com_ptr_t<_com_IIID<IWebView, &__uuidof(IWebView)>> IWebViewPtr; >+typedef _com_ptr_t<_com_IIID<IWebViewPrivate2, &__uuidof(IWebViewPrivate2)>> IWebViewPrivatePtr; >+typedef _com_ptr_t<_com_IIID<IWebFrameLoadDelegate, &__uuidof(IWebFrameLoadDelegate)>> IWebFrameLoadDelegatePtr; >+typedef _com_ptr_t<_com_IIID<IWebHistory, &__uuidof(IWebHistory)>> IWebHistoryPtr; >+typedef _com_ptr_t<_com_IIID<IWebHistoryItem, &__uuidof(IWebHistoryItem)>> IWebHistoryItemPtr; >+typedef _com_ptr_t<_com_IIID<IWebPreferences, &__uuidof(IWebPreferences)>> IWebPreferencesPtr; >+typedef _com_ptr_t<_com_IIID<IWebPreferencesPrivate3, &__uuidof(IWebPreferencesPrivate3)>> IWebPreferencesPrivatePtr; >+typedef _com_ptr_t<_com_IIID<IWebUIDelegate, &__uuidof(IWebUIDelegate)>> IWebUIDelegatePtr; >+typedef _com_ptr_t<_com_IIID<IAccessibilityDelegate, &__uuidof(IAccessibilityDelegate)>> IAccessibilityDelegatePtr; >+typedef _com_ptr_t<_com_IIID<IWebInspector, &__uuidof(IWebInspector)>> IWebInspectorPtr; >+typedef _com_ptr_t<_com_IIID<IWebCoreStatistics, &__uuidof(IWebCoreStatistics)>> IWebCoreStatisticsPtr; >+typedef _com_ptr_t<_com_IIID<IWebCache, &__uuidof(IWebCache)>> IWebCachePtr; >+typedef _com_ptr_t<_com_IIID<IWebResourceLoadDelegate, &__uuidof(IWebResourceLoadDelegate)>> IWebResourceLoadDelegatePtr; >+typedef _com_ptr_t<_com_IIID<IWebDownloadDelegate, &__uuidof(IWebDownloadDelegate)>> IWebDownloadDelegatePtr; >+typedef _com_ptr_t<_com_IIID<IWebFramePrivate, &__uuidof(IWebFramePrivate)>> IWebFramePrivatePtr; >+ >+class WK1BrowserWindow : public BrowserWindow { >+public: >+ static Ref<BrowserWindow> create(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView = false, bool pageLoadTesting = false); >+ >+private: >+ friend class AccessibilityDelegate; >+ friend class MiniBrowserWebHost; >+ friend class PrintWebUIDelegate; >+ friend class WebDownloadDelegate; >+ friend class ResourceLoadDelegate; >+ friend class PageLoadTestClient; >+ >+ ULONG AddRef(); >+ ULONG Release(); >+ >+ HRESULT init(); >+ HRESULT prepareViews(HWND mainWnd, const RECT& clientRect); >+ >+ HRESULT loadHTMLString(const BSTR&); >+ HRESULT loadURL(const BSTR& passedURL); >+ >+ void showLastVisitedSites(IWebView&); >+ void launchInspector(); >+ void navigateForwardOrBackward(UINT menuID); >+ void navigateToHistory(UINT menuID); >+ void exitProgram(); >+ bool seedInitialDefaultPreferences(); >+ bool setToDefaultPreferences(); >+ >+ HRESULT setFrameLoadDelegate(IWebFrameLoadDelegate*); >+ HRESULT setFrameLoadDelegatePrivate(IWebFrameLoadDelegatePrivate*); >+ HRESULT setUIDelegate(IWebUIDelegate*); >+ HRESULT setAccessibilityDelegate(IAccessibilityDelegate*); >+ HRESULT setResourceLoadDelegate(IWebResourceLoadDelegate*); >+ HRESULT setDownloadDelegate(IWebDownloadDelegatePtr); >+ >+ IWebPreferencesPtr standardPreferences() { return m_standardPreferences; } >+ IWebPreferencesPrivatePtr privatePreferences() { return m_prefsPrivate; } >+ IWebFramePtr mainFrame(); >+ IWebCoreStatisticsPtr statistics() { return m_statistics; } >+ IWebCachePtr webCache() { return m_webCache; } >+ IWebViewPtr webView() { return m_webView; } >+ >+ bool hasWebView() const { return !!m_webView; } >+ bool usesLayeredWebView() const { return m_useLayeredWebView; } >+ bool goBack(); >+ bool goForward(); >+ >+ void setUserAgent(UINT menuID); >+ void setUserAgent(_bstr_t& customUAString); >+ _bstr_t userAgent(); >+ >+ PageLoadTestClient& pageLoadTestClient() { return *m_pageLoadTestClient; } >+ >+ void resetZoom(); >+ void zoomIn(); >+ void zoomOut(); >+ >+ void showLayerTree(); >+ >+ HWND hwnd() { return m_viewWnd; } >+ >+ void print(); >+ void updateStatistics(HWND dialog); >+ void setPreference(UINT menuID, bool enable); >+ >+ WK1BrowserWindow(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView, bool pageLoadTesting); >+ void subclassForLayeredWindow(); >+ bool setCacheFolder(); >+ >+ std::vector<IWebHistoryItemPtr> m_historyItems; >+ >+ std::unique_ptr<PageLoadTestClient> m_pageLoadTestClient; >+ >+ IWebViewPtr m_webView; >+ IWebViewPrivatePtr m_webViewPrivate; >+ >+ IWebHistoryPtr m_webHistory; >+ IWebInspectorPtr m_inspector; >+ IWebPreferencesPtr m_standardPreferences; >+ IWebPreferencesPrivatePtr m_prefsPrivate; >+ >+ IWebFrameLoadDelegatePtr m_frameLoadDelegate; >+ IWebUIDelegatePtr m_uiDelegate; >+ IAccessibilityDelegatePtr m_accessibilityDelegate; >+ IWebResourceLoadDelegatePtr m_resourceLoadDelegate; >+ IWebDownloadDelegatePtr m_downloadDelegate; >+ >+ IWebCoreStatisticsPtr m_statistics; >+ IWebCachePtr m_webCache; >+ >+ HWND m_hMainWnd { nullptr }; >+ HWND m_hURLBarWnd { nullptr }; >+ HWND m_viewWnd { nullptr }; >+ >+ bool m_useLayeredWebView; >+}; >diff --git a/Tools/MiniBrowser/win/WebDownloadDelegate.cpp b/Tools/MiniBrowser/win/WebDownloadDelegate.cpp >index d1a0dfacfeec9cca8cc278d90fc112705e299a0c..57a5336b1a27f0dca78fcabeeb4699460f62f822 100644 >--- a/Tools/MiniBrowser/win/WebDownloadDelegate.cpp >+++ b/Tools/MiniBrowser/win/WebDownloadDelegate.cpp >@@ -28,10 +28,10 @@ > #include "stdafx.h" > #include "WebDownloadDelegate.h" > >-#include "MiniBrowser.h" >+#include "WK1BrowserWindow.h" > #include <shlobj.h> > >-WebDownloadDelegate::WebDownloadDelegate(MiniBrowser& client) >+WebDownloadDelegate::WebDownloadDelegate(WK1BrowserWindow& client) > : m_client(client) > { > } >diff --git a/Tools/MiniBrowser/win/WebDownloadDelegate.h b/Tools/MiniBrowser/win/WebDownloadDelegate.h >index 787dd8a9ce8adee06abaf932b3954d65bd008ca7..b9ddb799ce9a7c10c1f6478170fe5d46b80c576a 100644 >--- a/Tools/MiniBrowser/win/WebDownloadDelegate.h >+++ b/Tools/MiniBrowser/win/WebDownloadDelegate.h >@@ -29,11 +29,11 @@ > #include <WebKitLegacy/WebKit.h> > #include <WebKitLegacy/WebKitCOMAPI.h> > >-class MiniBrowser; >+class WK1BrowserWindow; > > class WebDownloadDelegate : public IWebDownloadDelegate { > public: >- WebDownloadDelegate(MiniBrowser& client); >+ WebDownloadDelegate(WK1BrowserWindow& client); > virtual ~WebDownloadDelegate(); > > virtual HRESULT STDMETHODCALLTYPE QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** ppvObject); >@@ -54,7 +54,7 @@ public: > virtual HRESULT STDMETHODCALLTYPE didFinish(_In_opt_ IWebDownload*); > > private: >- MiniBrowser& m_client; >+ WK1BrowserWindow& m_client; > }; > > #endif
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 186427
:
342242
|
342248