Diff
Modified: trunk/Tools/ChangeLog (250116 => 250117)
--- trunk/Tools/ChangeLog 2019-09-20 02:31:45 UTC (rev 250116)
+++ trunk/Tools/ChangeLog 2019-09-20 03:18:45 UTC (rev 250117)
@@ -1,3 +1,40 @@
+2019-09-19 Fujii Hironori <[email protected]>
+
+ [Win][MiniBrowser] Use _com_ptr_t methods instead of calling QueryInterface explictly
+ https://bugs.webkit.org/show_bug.cgi?id=201976
+
+ Reviewed by Don Olmstead.
+
+ This change consists of three refactorings:
+ 1. Replaced explicit QueryInterface with _com_ptr_t methods
+ 2. Replaced typedef with _COM_SMARTPTR_TYPEDEF macro
+ 3. Replaced WebCore's COMPtr with _com_ptr_t because it is not a public WebKit API
+
+ * MiniBrowser/win/MiniBrowserWebHost.cpp:
+ (MiniBrowserWebHost::didFirstLayoutInFrame): Deleted.
+ * MiniBrowser/win/MiniBrowserWebHost.h:
+ (MiniBrowserWebHost::didFirstLayoutInFrame):
+ * MiniBrowser/win/PrintWebUIDelegate.cpp:
+ (getHandleFromWebView):
+ (PrintWebUIDelegate::webViewPrintingMarginRect):
+ (PrintWebUIDelegate::runModal):
+ (PrintWebUIDelegate::createModalDialog):
+ * MiniBrowser/win/WebKitLegacyBrowserWindow.cpp:
+ (WebKitLegacyBrowserWindow::init):
+ (WebKitLegacyBrowserWindow::setToDefaultPreferences):
+ (WebKitLegacyBrowserWindow::showLastVisitedSites):
+ (WebKitLegacyBrowserWindow::reload):
+ (WebKitLegacyBrowserWindow::resetZoom):
+ (WebKitLegacyBrowserWindow::zoomIn):
+ (WebKitLegacyBrowserWindow::zoomOut):
+ (WebKitLegacyBrowserWindow::showLayerTree):
+ (WebKitLegacyBrowserWindow::print):
+ * MiniBrowser/win/WebKitLegacyBrowserWindow.h:
+ (WebKitLegacyBrowserWindow::privatePreferences):
+ * MiniBrowser/win/WinMain.cpp:
+ (wWinMain):
+ * MiniBrowser/win/stdafx.h:
+
2019-09-19 Joanmarie Diggs <[email protected]>
[GTK] Dependency hunspell-en-gb cannot be found on Fedora 30
Modified: trunk/Tools/MiniBrowser/win/MiniBrowserWebHost.cpp (250116 => 250117)
--- trunk/Tools/MiniBrowser/win/MiniBrowserWebHost.cpp 2019-09-20 02:31:45 UTC (rev 250116)
+++ trunk/Tools/MiniBrowser/win/MiniBrowserWebHost.cpp 2019-09-20 03:18:45 UTC (rev 250117)
@@ -32,8 +32,6 @@
#include "WebKitLegacyBrowserWindow.h"
#include <WebKitLegacy/WebKit.h>
-typedef _com_ptr_t<_com_IIID<IWebDataSource, &__uuidof(IWebDataSource)>> IWebDataSourcePtr;
-
HRESULT MiniBrowserWebHost::didCommitLoadForFrame(_In_opt_ IWebView* webView, _In_opt_ IWebFrame* frame)
{
return didChangeLocationWithinPageForFrame(webView, frame);
@@ -149,18 +147,6 @@
return S_OK;
}
-HRESULT MiniBrowserWebHost::didFirstLayoutInFrame(_In_opt_ IWebView*, _In_opt_ IWebFrame* frame)
-{
- if (!frame)
- return E_POINTER;
-
- IWebFrame2Ptr frame2;
- if (FAILED(frame->QueryInterface(&frame2.GetInterfacePtr())))
- return S_OK;
-
- return S_OK;
-}
-
HRESULT MiniBrowserWebHost::onNotify(_In_opt_ IWebNotification* notification)
{
_bstr_t name;
Modified: trunk/Tools/MiniBrowser/win/MiniBrowserWebHost.h (250116 => 250117)
--- trunk/Tools/MiniBrowser/win/MiniBrowserWebHost.h 2019-09-20 02:31:45 UTC (rev 250116)
+++ trunk/Tools/MiniBrowser/win/MiniBrowserWebHost.h 2019-09-20 03:18:45 UTC (rev 250117)
@@ -60,7 +60,7 @@
// IWebFrameLoadDelegatePrivate
virtual HRESULT STDMETHODCALLTYPE didFinishDocumentLoadForFrame(_In_opt_ IWebView* sender, _In_opt_ IWebFrame*) { return S_OK; }
- virtual HRESULT STDMETHODCALLTYPE didFirstLayoutInFrame(_In_opt_ IWebView* sender, _In_opt_ IWebFrame*);
+ virtual HRESULT STDMETHODCALLTYPE didFirstLayoutInFrame(_In_opt_ IWebView* sender, _In_opt_ IWebFrame*) { return S_OK; }
virtual HRESULT STDMETHODCALLTYPE didHandleOnloadEventsForFrame(_In_opt_ IWebView*, _In_opt_ IWebFrame*);
virtual HRESULT STDMETHODCALLTYPE didFirstVisuallyNonEmptyLayoutInFrame(_In_opt_ IWebView* sender, _In_opt_ IWebFrame*) { return S_OK; }
Modified: trunk/Tools/MiniBrowser/win/PrintWebUIDelegate.cpp (250116 => 250117)
--- trunk/Tools/MiniBrowser/win/PrintWebUIDelegate.cpp 2019-09-20 02:31:45 UTC (rev 250116)
+++ trunk/Tools/MiniBrowser/win/PrintWebUIDelegate.cpp 2019-09-20 03:18:45 UTC (rev 250117)
@@ -30,7 +30,6 @@
#include "Common.h"
#include "MainWindow.h"
#include "WebKitLegacyBrowserWindow.h"
-#include <WebCore/COMPtr.h>
#include <WebKitLegacy/WebKitCOMAPI.h>
#include <comip.h>
#include <commctrl.h>
@@ -87,13 +86,12 @@
static HWND getHandleFromWebView(IWebView* webView)
{
- COMPtr<IWebViewPrivate2> webViewPrivate;
- HRESULT hr = webView->QueryInterface(&webViewPrivate);
- if (FAILED(hr))
+ IWebViewPrivate2Ptr webViewPrivate(webView);
+ if (!webViewPrivate)
return nullptr;
HWND webViewWindow = nullptr;
- hr = webViewPrivate->viewWindow(&webViewWindow);
+ HRESULT hr = webViewPrivate->viewWindow(&webViewWindow);
if (FAILED(hr))
return nullptr;
@@ -171,8 +169,8 @@
if (FAILED(view->mainFrame(&mainFrame.GetInterfacePtr())))
return E_FAIL;
- IWebFramePrivatePtr privateFrame;
- if (FAILED(mainFrame->QueryInterface(&privateFrame.GetInterfacePtr())))
+ IWebFramePrivatePtr privateFrame(mainFrame);
+ if (!privateFrame)
return E_FAIL;
privateFrame->frameBounds(rect);
@@ -295,7 +293,7 @@
HRESULT PrintWebUIDelegate::runModal(_In_opt_ IWebView* webView)
{
- COMPtr<IWebView> protector(webView);
+ IWebViewPtr protector(webView);
auto modalDialogOwner = ::GetWindow(m_modalDialogParent, GW_OWNER);
auto topLevelParent = ::GetAncestor(modalDialogOwner, GA_ROOT);
@@ -324,7 +322,7 @@
if (!newWebView)
return E_POINTER;
- COMPtr<IWebView> webView;
+ IWebViewPtr webView;
HRESULT hr = WebKitCreateInstance(CLSID_WebView, 0, IID_IWebView, (void**)&webView);
if (FAILED(hr))
return hr;
@@ -340,14 +338,14 @@
if (FAILED(hr))
return hr;
- COMPtr<IWebUIDelegate> uiDelegate;
+ IWebUIDelegatePtr uiDelegate;
hr = sender->uiDelegate(&uiDelegate);
if (FAILED(hr))
return hr;
- webView->setUIDelegate(uiDelegate.get());
+ webView->setUIDelegate(uiDelegate);
- *newWebView = webView.leakRef();
+ *newWebView = webView.Detach();
return S_OK;
}
Modified: trunk/Tools/MiniBrowser/win/WebKitLegacyBrowserWindow.cpp (250116 => 250117)
--- trunk/Tools/MiniBrowser/win/WebKitLegacyBrowserWindow.cpp 2019-09-20 02:31:45 UTC (rev 250116)
+++ trunk/Tools/MiniBrowser/win/WebKitLegacyBrowserWindow.cpp 2019-09-20 03:18:45 UTC (rev 250117)
@@ -80,8 +80,8 @@
if (FAILED(hr))
return hr;
- hr = m_webView->QueryInterface(IID_IWebViewPrivate2, reinterpret_cast<void**>(&m_webViewPrivate.GetInterfacePtr()));
- if (FAILED(hr))
+ m_webViewPrivate = m_webView;
+ if (!m_webViewPrivate)
return hr;
hr = WebKitCreateInstance(CLSID_WebHistory, 0, __uuidof(m_webHistory), reinterpret_cast<void**>(&m_webHistory.GetInterfacePtr()));
@@ -278,8 +278,8 @@
bool WebKitLegacyBrowserWindow::setToDefaultPreferences()
{
- HRESULT hr = m_standardPreferences->QueryInterface(IID_IWebPreferencesPrivate, reinterpret_cast<void**>(&m_prefsPrivate.GetInterfacePtr()));
- if (!SUCCEEDED(hr))
+ m_prefsPrivate = m_standardPreferences;
+ if (!m_prefsPrivate)
return false;
#if USE(CG)
@@ -324,7 +324,7 @@
{
HMENU menu = ::GetMenu(m_hMainWnd);
- _com_ptr_t<_com_IIID<IWebBackForwardList, &__uuidof(IWebBackForwardList)>> backForwardList;
+ IWebBackForwardListPtr backForwardList;
HRESULT hr = webView.backForwardList(&backForwardList.GetInterfacePtr());
if (FAILED(hr))
return;
@@ -359,9 +359,8 @@
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))
+ IWebHistoryPrivatePtr webHistory(m_webHistory);
+ if (!webHistory)
return;
int totalListCount = 0;
@@ -506,12 +505,10 @@
return userAgent;
}
-typedef _com_ptr_t<_com_IIID<IWebIBActions, &__uuidof(IWebIBActions)>> IWebIBActionsPtr;
-
void WebKitLegacyBrowserWindow::reload()
{
- IWebIBActionsPtr webActions;
- if (FAILED(m_webView->QueryInterface(IID_IWebIBActions, reinterpret_cast<void**>(&webActions.GetInterfacePtr()))))
+ IWebIBActionsPtr webActions(m_webView);
+ if (!webActions)
return;
webActions->reload(nullptr);
@@ -519,8 +516,8 @@
void WebKitLegacyBrowserWindow::resetZoom()
{
- IWebIBActionsPtr webActions;
- if (FAILED(m_webView->QueryInterface(IID_IWebIBActions, reinterpret_cast<void**>(&webActions.GetInterfacePtr()))))
+ IWebIBActionsPtr webActions(m_webView);
+ if (!webActions)
return;
webActions->resetPageZoom(nullptr);
@@ -528,8 +525,8 @@
void WebKitLegacyBrowserWindow::zoomIn()
{
- IWebIBActionsPtr webActions;
- if (FAILED(m_webView->QueryInterface(IID_IWebIBActions, reinterpret_cast<void**>(&webActions.GetInterfacePtr()))))
+ IWebIBActionsPtr webActions(m_webView);
+ if (!webActions)
return;
webActions->zoomPageIn(nullptr);
@@ -537,19 +534,17 @@
void WebKitLegacyBrowserWindow::zoomOut()
{
- IWebIBActionsPtr webActions;
- if (FAILED(m_webView->QueryInterface(IID_IWebIBActions, reinterpret_cast<void**>(&webActions.GetInterfacePtr()))))
+ IWebIBActionsPtr webActions(m_webView);
+ if (!webActions)
return;
webActions->zoomPageOut(nullptr);
}
-typedef _com_ptr_t<_com_IIID<IWebViewPrivate3, &__uuidof(IWebViewPrivate3)>> IWebViewPrivate3Ptr;
-
void WebKitLegacyBrowserWindow::showLayerTree()
{
- IWebViewPrivate3Ptr webViewPrivate;
- if (FAILED(m_webView->QueryInterface(IID_IWebViewPrivate3, reinterpret_cast<void**>(&webViewPrivate.GetInterfacePtr()))))
+ IWebViewPrivate3Ptr webViewPrivate(m_webView);
+ if (!webViewPrivate)
return;
OutputDebugString(L"CURRENT TREE:\n");
@@ -609,8 +604,8 @@
if (!frame)
return;
- IWebFramePrivatePtr framePrivate;
- if (FAILED(frame->QueryInterface(&framePrivate.GetInterfacePtr())))
+ IWebFramePrivatePtr framePrivate(frame);
+ if (!framePrivate)
return;
framePrivate->setInPrintingMode(TRUE, printDC);
@@ -648,8 +643,6 @@
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;
Modified: trunk/Tools/MiniBrowser/win/WebKitLegacyBrowserWindow.h (250116 => 250117)
--- trunk/Tools/MiniBrowser/win/WebKitLegacyBrowserWindow.h 2019-09-20 02:31:45 UTC (rev 250116)
+++ trunk/Tools/MiniBrowser/win/WebKitLegacyBrowserWindow.h 2019-09-20 03:18:45 UTC (rev 250117)
@@ -31,27 +31,32 @@
#include <vector>
#include <wtf/Ref.h>
-typedef _com_ptr_t<_com_IIID<IUnknown, &__uuidof(IUnknown)>> IUnknownPtr;
-typedef _com_ptr_t<_com_IIID<IWebFrame, &__uuidof(IWebFrame)>> IWebFramePtr;
-typedef _com_ptr_t<_com_IIID<IWebFrame2, &__uuidof(IWebFrame2)>> IWebFrame2Ptr;
-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;
-typedef _com_ptr_t<_com_IIID<IWebMutableURLRequest, &__uuidof(IWebMutableURLRequest)>> IWebMutableURLRequestPtr;
-typedef _com_ptr_t<_com_IIID<IWebNotificationObserver, &__uuidof(IWebNotificationObserver)>> IWebNotificationObserverPtr;
-typedef _com_ptr_t<_com_IIID<IWebNotificationCenter, &__uuidof(IWebNotificationCenter)>> IWebNotificationCenterPtr;
+_COM_SMARTPTR_TYPEDEF(IAccessibilityDelegate, IID_IAccessibilityDelegate);
+_COM_SMARTPTR_TYPEDEF(IWebBackForwardList, IID_IWebBackForwardList);
+_COM_SMARTPTR_TYPEDEF(IWebCache, IID_IWebCache);
+_COM_SMARTPTR_TYPEDEF(IWebCoreStatistics, IID_IWebCoreStatistics);
+_COM_SMARTPTR_TYPEDEF(IWebDataSource, IID_IWebDataSource);
+_COM_SMARTPTR_TYPEDEF(IWebDownloadDelegate, IID_IWebDownloadDelegate);
+_COM_SMARTPTR_TYPEDEF(IWebFrame, IID_IWebFrame);
+_COM_SMARTPTR_TYPEDEF(IWebFrame2, IID_IWebFrame2);
+_COM_SMARTPTR_TYPEDEF(IWebFrameLoadDelegate, IID_IWebFrameLoadDelegate);
+_COM_SMARTPTR_TYPEDEF(IWebFramePrivate, IID_IWebFramePrivate);
+_COM_SMARTPTR_TYPEDEF(IWebHistory, IID_IWebHistory);
+_COM_SMARTPTR_TYPEDEF(IWebHistoryItem, IID_IWebHistoryItem);
+_COM_SMARTPTR_TYPEDEF(IWebHistoryPrivate, IID_IWebHistoryPrivate);
+_COM_SMARTPTR_TYPEDEF(IWebIBActions, IID_IWebIBActions);
+_COM_SMARTPTR_TYPEDEF(IWebInspector, IID_IWebInspector);
+_COM_SMARTPTR_TYPEDEF(IWebKitMessageLoop, IID_IWebKitMessageLoop);
+_COM_SMARTPTR_TYPEDEF(IWebMutableURLRequest, IID_IWebMutableURLRequest);
+_COM_SMARTPTR_TYPEDEF(IWebNotificationCenter, IID_IWebNotificationCenter);
+_COM_SMARTPTR_TYPEDEF(IWebNotificationObserver, IID_IWebNotificationObserver);
+_COM_SMARTPTR_TYPEDEF(IWebPreferences, IID_IWebPreferences);
+_COM_SMARTPTR_TYPEDEF(IWebPreferencesPrivate3, IID_IWebPreferencesPrivate3);
+_COM_SMARTPTR_TYPEDEF(IWebResourceLoadDelegate, IID_IWebResourceLoadDelegate);
+_COM_SMARTPTR_TYPEDEF(IWebUIDelegate, IID_IWebUIDelegate);
+_COM_SMARTPTR_TYPEDEF(IWebView, IID_IWebView);
+_COM_SMARTPTR_TYPEDEF(IWebViewPrivate2, IID_IWebViewPrivate2);
+_COM_SMARTPTR_TYPEDEF(IWebViewPrivate3, IID_IWebViewPrivate3);
class WebKitLegacyBrowserWindow : public BrowserWindow {
public:
@@ -84,7 +89,7 @@
HRESULT setDownloadDelegate(IWebDownloadDelegatePtr);
IWebPreferencesPtr standardPreferences() { return m_standardPreferences; }
- IWebPreferencesPrivatePtr privatePreferences() { return m_prefsPrivate; }
+ IWebPreferencesPrivate3Ptr privatePreferences() { return m_prefsPrivate; }
IWebFramePtr mainFrame();
IWebCoreStatisticsPtr statistics() { return m_statistics; }
IWebCachePtr webCache() { return m_webCache; }
@@ -119,12 +124,12 @@
std::vector<IWebHistoryItemPtr> m_historyItems;
IWebViewPtr m_webView;
- IWebViewPrivatePtr m_webViewPrivate;
+ IWebViewPrivate2Ptr m_webViewPrivate;
IWebHistoryPtr m_webHistory;
IWebInspectorPtr m_inspector;
IWebPreferencesPtr m_standardPreferences;
- IWebPreferencesPrivatePtr m_prefsPrivate;
+ IWebPreferencesPrivate3Ptr m_prefsPrivate;
IWebNotificationCenterPtr m_defaultNotificationCenter;
IWebNotificationObserverPtr m_notificationObserver;
Modified: trunk/Tools/MiniBrowser/win/WinMain.cpp (250116 => 250117)
--- trunk/Tools/MiniBrowser/win/WinMain.cpp 2019-09-20 02:31:45 UTC (rev 250116)
+++ trunk/Tools/MiniBrowser/win/WinMain.cpp 2019-09-20 03:18:45 UTC (rev 250117)
@@ -95,7 +95,7 @@
// Main message loop:
__try {
- _com_ptr_t<_com_IIID<IWebKitMessageLoop, &__uuidof(IWebKitMessageLoop)>> messageLoop;
+ IWebKitMessageLoopPtr messageLoop;
hr = WebKitCreateInstance(CLSID_WebKitMessageLoop, 0, IID_IWebKitMessageLoop, reinterpret_cast<void**>(&messageLoop.GetInterfacePtr()));
if (FAILED(hr))
Modified: trunk/Tools/MiniBrowser/win/stdafx.h (250116 => 250117)
--- trunk/Tools/MiniBrowser/win/stdafx.h 2019-09-20 02:31:45 UTC (rev 250116)
+++ trunk/Tools/MiniBrowser/win/stdafx.h 2019-09-20 03:18:45 UTC (rev 250117)
@@ -42,6 +42,7 @@
#endif
#include <assert.h>
+#include <comdef.h>
#include <comip.h>
#include <commctrl.h>
#include <commdlg.h>