Changeset 249039 in webkit
- Timestamp:
- Aug 22, 2019, 6:59:22 PM (6 years ago)
- Location:
- trunk/Tools
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r249036 r249039 1 2019-08-22 Fujii Hironori <Hironori.Fujii@sony.com> 2 3 [Win][MiniBrowser] URL bar should be updated for in-page navigations 4 https://bugs.webkit.org/show_bug.cgi?id=201032 5 6 Reviewed by Darin Adler. 7 8 * MiniBrowser/win/BrowserWindow.h: Added activeURLChanged to BrowserWindowClient interface. 9 * MiniBrowser/win/MainWindow.cpp: 10 (MainWindow::init): 11 (MainWindow::activeURLChanged): Added. 12 * MiniBrowser/win/MainWindow.h: 13 * MiniBrowser/win/MiniBrowserWebHost.cpp: 14 (MiniBrowserWebHost::didCommitLoadForFrame): 15 (MiniBrowserWebHost::didChangeLocationWithinPageForFrame): Added. 16 (MiniBrowserWebHost::updateAddressBar): Deleted. 17 (MiniBrowserWebHost::loadURL): Deleted. 18 * MiniBrowser/win/MiniBrowserWebHost.h: 19 (MiniBrowserWebHost::MiniBrowserWebHost): 20 (MiniBrowserWebHost::didCommitLoadForFrame): Deleted. 21 (MiniBrowserWebHost::didChangeLocationWithinPageForFrame): Deleted. 22 * MiniBrowser/win/PrintWebUIDelegate.cpp: 23 * MiniBrowser/win/WebKitBrowserWindow.cpp: 24 (WebKitBrowserWindow::create): 25 (WebKitBrowserWindow::WebKitBrowserWindow): 26 (WebKitBrowserWindow::didChangeIsLoading): Removed an unused variable. 27 (WebKitBrowserWindow::didChangeActiveURL): Added. 28 (WebKitBrowserWindow::createNewPage): 29 (WebKitBrowserWindow::didCommitNavigation): Deleted. 30 * MiniBrowser/win/WebKitBrowserWindow.h: Removed m_urlBarWnd. 31 * MiniBrowser/win/WebKitLegacyBrowserWindow.cpp: 32 (WebKitLegacyBrowserWindow::create): 33 (WebKitLegacyBrowserWindow::WebKitLegacyBrowserWindow): 34 (WebKitLegacyBrowserWindow::init): 35 (WebKitLegacyBrowserWindow::navigateToHistory): 36 * MiniBrowser/win/WebKitLegacyBrowserWindow.h: Removed m_urlBarWnd. 37 1 38 2019-08-22 Andy Estes <aestes@apple.com> 2 39 -
trunk/Tools/MiniBrowser/win/BrowserWindow.h
r248990 r249039 33 33 virtual void progressChanged(double) = 0; 34 34 virtual void progressFinished() = 0; 35 virtual void activeURLChanged(std::wstring) = 0; 35 36 }; 36 37 -
trunk/Tools/MiniBrowser/win/MainWindow.cpp
r248990 r249039 126 126 SetWindowLongPtr(m_hURLBarWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(EditProc)); 127 127 128 m_browserWindow = factory(*this, m_hMainWnd, m_hURLBarWnd,usesLayeredWebView);128 m_browserWindow = factory(*this, m_hMainWnd, usesLayeredWebView); 129 129 if (!m_browserWindow) 130 130 return false; … … 488 488 SetWindowText(m_hProgressIndicator, L""); 489 489 } 490 491 void MainWindow::activeURLChanged(std::wstring url) 492 { 493 SetWindowText(m_hURLBarWnd, url.c_str()); 494 } -
trunk/Tools/MiniBrowser/win/MainWindow.h
r248990 r249039 34 34 class MainWindow final : public RefCounted<MainWindow>, public BrowserWindowClient { 35 35 public: 36 using BrowserWindowFactory = std::function<Ref<BrowserWindow>(BrowserWindowClient&, HWND mainWnd, HWND urlBarWnd,bool usesLayeredWebView)>;36 using BrowserWindowFactory = std::function<Ref<BrowserWindow>(BrowserWindowClient&, HWND mainWnd, bool usesLayeredWebView)>; 37 37 38 38 static Ref<MainWindow> create(); … … 63 63 void progressChanged(double) final; 64 64 void progressFinished() final; 65 void activeURLChanged(std::wstring) final; 65 66 66 67 HWND m_hMainWnd { nullptr }; -
trunk/Tools/MiniBrowser/win/MiniBrowserWebHost.cpp
r248990 r249039 34 34 35 35 typedef _com_ptr_t<_com_IIID<IWebDataSource, &__uuidof(IWebDataSource)>> IWebDataSourcePtr; 36 typedef _com_ptr_t<_com_IIID<IWebMutableURLRequest, &__uuidof(IWebMutableURLRequest)>> IWebMutableURLRequestPtr;37 36 38 HRESULT MiniBrowserWebHost:: updateAddressBar(IWebView& webView)37 HRESULT MiniBrowserWebHost::didCommitLoadForFrame(_In_opt_ IWebView* webView, _In_opt_ IWebFrame* frame) 39 38 { 40 IWebFramePtr mainFrame; 41 HRESULT hr = webView.mainFrame(&mainFrame.GetInterfacePtr()); 42 if (FAILED(hr)) 43 return hr; 44 45 IWebDataSourcePtr dataSource; 46 hr = mainFrame->dataSource(&dataSource.GetInterfacePtr()); 47 if (FAILED(hr) || !dataSource) 48 hr = mainFrame->provisionalDataSource(&dataSource.GetInterfacePtr()); 49 if (FAILED(hr) || !dataSource) 50 return hr; 51 52 IWebMutableURLRequestPtr request; 53 hr = dataSource->request(&request.GetInterfacePtr()); 54 if (FAILED(hr) || !request) 55 return hr; 56 57 _bstr_t frameURL; 58 hr = request->mainDocumentURL(frameURL.GetAddress()); 59 if (FAILED(hr)) 60 return hr; 61 62 loadURL(frameURL); 63 64 return S_OK; 65 } 66 67 void MiniBrowserWebHost::loadURL(_bstr_t& url) 68 { 69 ::SendMessage(m_hURLBarWnd, static_cast<UINT>(WM_SETTEXT), 0, reinterpret_cast<LPARAM>(url.GetBSTR())); 39 return didChangeLocationWithinPageForFrame(webView, frame); 70 40 } 71 41 … … 82 52 ::MessageBoxW(0, static_cast<LPCWSTR>(errorDescription), L"Error", MB_APPLMODAL | MB_OK); 83 53 54 return S_OK; 55 } 56 57 HRESULT MiniBrowserWebHost::didChangeLocationWithinPageForFrame(_In_opt_ IWebView* webView, _In_opt_ IWebFrame* frame) 58 { 59 IWebFrame2Ptr frame2(frame); 60 if (!frame2) 61 return E_NOINTERFACE; 62 BOOL isMainFrame; 63 HRESULT hr = frame2->isMainFrame(&isMainFrame); 64 if (FAILED(hr)) 65 return hr; 66 if (!isMainFrame) 67 return S_OK; 68 _bstr_t url; 69 hr = webView->mainFrameURL(url.GetAddress()); 70 if (FAILED(hr)) 71 return hr; 72 m_client->m_client.activeURLChanged(url.GetBSTR()); 84 73 return S_OK; 85 74 } … … 110 99 return m_client->Release(); 111 100 } 112 113 typedef _com_ptr_t<_com_IIID<IWebFrame2, &__uuidof(IWebFrame2)>> IWebFrame2Ptr;114 101 115 102 HRESULT MiniBrowserWebHost::didFinishLoadForFrame(_In_opt_ IWebView* webView, _In_opt_ IWebFrame* frame) -
trunk/Tools/MiniBrowser/win/MiniBrowserWebHost.h
r248990 r249039 34 34 class MiniBrowserWebHost : public IWebFrameLoadDelegate, public IWebFrameLoadDelegatePrivate, public IWebNotificationObserver { 35 35 public: 36 MiniBrowserWebHost(WebKitLegacyBrowserWindow* client , HWND urlBar)37 : m_client(client) , m_hURLBarWnd(urlBar){ }36 MiniBrowserWebHost(WebKitLegacyBrowserWindow* client) 37 : m_client(client) { } 38 38 39 39 // IUnknown … … 46 46 virtual HRESULT STDMETHODCALLTYPE didReceiveServerRedirectForProvisionalLoadForFrame(_In_opt_ IWebView*, _In_opt_ IWebFrame*) { return S_OK; } 47 47 virtual HRESULT STDMETHODCALLTYPE didFailProvisionalLoadWithError(_In_opt_ IWebView*, _In_opt_ IWebError*, _In_opt_ IWebFrame*); 48 virtual HRESULT STDMETHODCALLTYPE didCommitLoadForFrame(_In_opt_ IWebView* webView, _In_opt_ IWebFrame*) 49 { 50 if (!webView) 51 return E_POINTER; 52 53 return updateAddressBar(*webView); 54 } 55 48 virtual HRESULT STDMETHODCALLTYPE didCommitLoadForFrame(_In_opt_ IWebView*, _In_opt_ IWebFrame*); 56 49 virtual HRESULT STDMETHODCALLTYPE didReceiveTitle(_In_opt_ IWebView*, _In_ BSTR title, _In_opt_ IWebFrame*) { return S_OK; } 57 50 virtual HRESULT STDMETHODCALLTYPE didChangeIcons(_In_opt_ IWebView*, _In_opt_ IWebFrame*) { return S_OK; } … … 59 52 virtual HRESULT STDMETHODCALLTYPE didFinishLoadForFrame(_In_opt_ IWebView*, _In_opt_ IWebFrame*); 60 53 virtual HRESULT STDMETHODCALLTYPE didFailLoadWithError(_In_opt_ IWebView*, _In_opt_ IWebError*, _In_opt_ IWebFrame*); 61 virtual HRESULT STDMETHODCALLTYPE didChangeLocationWithinPageForFrame(_In_opt_ IWebView*, _In_opt_ IWebFrame*) { return S_OK; }54 virtual HRESULT STDMETHODCALLTYPE didChangeLocationWithinPageForFrame(_In_opt_ IWebView*, _In_opt_ IWebFrame*); 62 55 virtual HRESULT STDMETHODCALLTYPE willPerformClientRedirectToURL(_In_opt_ IWebView*, _In_ BSTR url, double delaySeconds, DATE fireDate, _In_opt_ IWebFrame*) { return S_OK; } 63 56 virtual HRESULT STDMETHODCALLTYPE didCancelClientRedirectForFrame(_In_opt_ IWebView*, _In_opt_ IWebFrame*) { return S_OK; } … … 75 68 virtual HRESULT STDMETHODCALLTYPE onNotify(_In_opt_ IWebNotification*); 76 69 77 void loadURL(_bstr_t&);78 79 protected:80 HRESULT updateAddressBar(IWebView&);81 82 70 private: 83 71 WebKitLegacyBrowserWindow* m_client { nullptr }; 84 HWND m_hURLBarWnd { 0 };85 72 }; -
trunk/Tools/MiniBrowser/win/PrintWebUIDelegate.cpp
r242984 r249039 160 160 } 161 161 162 typedef _com_ptr_t<_com_IIID<IWebFrame, &__uuidof(IWebFrame)>> IWebFramePtr;163 typedef _com_ptr_t<_com_IIID<IWebFramePrivate, &__uuidof(IWebFramePrivate)>> IWebFramePrivatePtr;164 165 162 HRESULT PrintWebUIDelegate::webViewPrintingMarginRect(_In_opt_ IWebView* view, _Out_ RECT* rect) 166 163 { -
trunk/Tools/MiniBrowser/win/WebKitBrowserWindow.cpp
r248990 r249039 105 105 } 106 106 107 Ref<BrowserWindow> WebKitBrowserWindow::create(BrowserWindowClient& client, HWND mainWnd, HWND urlBarWnd,bool)107 Ref<BrowserWindow> WebKitBrowserWindow::create(BrowserWindowClient& client, HWND mainWnd, bool) 108 108 { 109 109 auto conf = adoptWK(WKPageConfigurationCreate()); … … 122 122 WKPageConfigurationSetContext(conf.get(), context.get()); 123 123 124 return adoptRef(*new WebKitBrowserWindow(client, conf.get(), mainWnd , urlBarWnd));125 } 126 127 WebKitBrowserWindow::WebKitBrowserWindow(BrowserWindowClient& client, WKPageConfigurationRef conf, HWND mainWnd , HWND urlBarWnd)124 return adoptRef(*new WebKitBrowserWindow(client, conf.get(), mainWnd)); 125 } 126 127 WebKitBrowserWindow::WebKitBrowserWindow(BrowserWindowClient& client, WKPageConfigurationRef conf, HWND mainWnd) 128 128 : m_client(client) 129 129 , m_hMainWnd(mainWnd) 130 , m_urlBarWnd(urlBarWnd)131 130 { 132 131 RECT rect = { }; … … 139 138 navigationClient.base.version = 0; 140 139 navigationClient.base.clientInfo = this; 141 navigationClient.didCommitNavigation = didCommitNavigation;142 140 navigationClient.didReceiveAuthenticationChallenge = didReceiveAuthenticationChallenge; 143 141 WKPageSetPageNavigationClient(page, &navigationClient.base); … … 156 154 stateClient.didChangeIsLoading = didChangeIsLoading; 157 155 stateClient.didChangeEstimatedProgress = didChangeEstimatedProgress; 156 stateClient.didChangeActiveURL = didChangeActiveURL; 158 157 WKPageSetPageStateClient(page, &stateClient.base); 159 158 … … 315 314 { 316 315 auto& thisWindow = toWebKitBrowserWindow(clientInfo); 317 auto page = WKViewGetPage(thisWindow.m_view.get());318 316 thisWindow.m_client.progressFinished(); 319 317 } … … 326 324 } 327 325 328 void WebKitBrowserWindow::didCommitNavigation(WKPageRef page, WKNavigationRef navigation, WKTypeRef userData, const void* clientInfo) 329 { 330 auto& thisWindow = toWebKitBrowserWindow(clientInfo); 331 332 WKRetainPtr<WKURLRef> wkurl = adoptWK(WKPageCopyCommittedURL(page)); 333 std::wstring urlString = createString(wkurl.get()); 334 SetWindowText(thisWindow.m_urlBarWnd, urlString.c_str()); 326 void WebKitBrowserWindow::didChangeActiveURL(const void* clientInfo) 327 { 328 auto& thisWindow = toWebKitBrowserWindow(clientInfo); 329 auto page = WKViewGetPage(thisWindow.m_view.get()); 330 WKRetainPtr<WKURLRef> url = adoptWK(WKPageCopyActiveURL(page)); 331 thisWindow.m_client.activeURLChanged(createString(url.get())); 335 332 } 336 333 … … 385 382 { 386 383 auto& newWindow = MainWindow::create().leakRef(); 387 auto factory = [configuration](BrowserWindowClient& client, HWND mainWnd, HWND urlBarWnd,bool) -> auto {388 return adoptRef(*new WebKitBrowserWindow(client, configuration, mainWnd , urlBarWnd));384 auto factory = [configuration](BrowserWindowClient& client, HWND mainWnd, bool) -> auto { 385 return adoptRef(*new WebKitBrowserWindow(client, configuration, mainWnd)); 389 386 }; 390 387 bool ok = newWindow.init(factory, hInst); -
trunk/Tools/MiniBrowser/win/WebKitBrowserWindow.h
r248990 r249039 34 34 class WebKitBrowserWindow : public BrowserWindow { 35 35 public: 36 static Ref<BrowserWindow> create(BrowserWindowClient&, HWND mainWnd, HWND urlBarWnd,bool useLayeredWebView = false);36 static Ref<BrowserWindow> create(BrowserWindowClient&, HWND mainWnd, bool useLayeredWebView = false); 37 37 38 38 private: 39 WebKitBrowserWindow(BrowserWindowClient&, WKPageConfigurationRef, HWND mainWnd , HWND urlBarWnd);39 WebKitBrowserWindow(BrowserWindowClient&, WKPageConfigurationRef, HWND mainWnd); 40 40 41 41 HRESULT init() override; … … 69 69 static void didChangeIsLoading(const void*); 70 70 static void didChangeEstimatedProgress(const void*); 71 static void didC ommitNavigation(WKPageRef, WKNavigationRef, WKTypeRef,const void*);71 static void didChangeActiveURL(const void*); 72 72 static void didReceiveAuthenticationChallenge(WKPageRef, WKAuthenticationChallengeRef, const void*); 73 73 static WKPageRef createNewPage(WKPageRef, WKPageConfigurationRef, WKNavigationActionRef, WKWindowFeaturesRef, const void *); … … 77 77 WKRetainPtr<WKViewRef> m_view; 78 78 HWND m_hMainWnd { nullptr }; 79 HWND m_urlBarWnd { nullptr };80 79 ProxySettings m_proxy { }; 81 80 std::unordered_map<std::wstring, std::wstring> m_acceptedServerTrustCerts; -
trunk/Tools/MiniBrowser/win/WebKitLegacyBrowserWindow.cpp
r248990 r249039 58 58 static const int maxHistorySize = 10; 59 59 60 typedef _com_ptr_t<_com_IIID<IWebMutableURLRequest, &__uuidof(IWebMutableURLRequest)>> IWebMutableURLRequestPtr; 61 typedef _com_ptr_t<_com_IIID<IWebNotificationObserver, &__uuidof(IWebNotificationObserver)>> IWebNotificationObserverPtr; 62 typedef _com_ptr_t<_com_IIID<IWebNotificationCenter, &__uuidof(IWebNotificationCenter)>> IWebNotificationCenterPtr; 63 64 65 Ref<BrowserWindow> WebKitLegacyBrowserWindow::create(BrowserWindowClient& client, HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView) 66 { 67 return adoptRef(*new WebKitLegacyBrowserWindow(client, mainWnd, urlBarWnd, useLayeredWebView)); 68 } 69 70 WebKitLegacyBrowserWindow::WebKitLegacyBrowserWindow(BrowserWindowClient& client, HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView) 60 Ref<BrowserWindow> WebKitLegacyBrowserWindow::create(BrowserWindowClient& client, HWND mainWnd, bool useLayeredWebView) 61 { 62 return adoptRef(*new WebKitLegacyBrowserWindow(client, mainWnd, useLayeredWebView)); 63 } 64 65 WebKitLegacyBrowserWindow::WebKitLegacyBrowserWindow(BrowserWindowClient& client, HWND mainWnd, bool useLayeredWebView) 71 66 : m_client(client) 72 67 , m_hMainWnd(mainWnd) 73 , m_hURLBarWnd(urlBarWnd)74 68 , m_useLayeredWebView(useLayeredWebView) 75 69 { … … 130 124 return E_FAIL; 131 125 132 auto webHost = new MiniBrowserWebHost(this , m_hURLBarWnd);126 auto webHost = new MiniBrowserWebHost(this); 133 127 134 128 hr = setFrameLoadDelegate(webHost); … … 475 469 desiredHistoryItem->URLString(frameURL.GetAddress()); 476 470 477 ::SendMessage(m_hURLBarWnd, (UINT)WM_SETTEXT, 0, (LPARAM)frameURL.GetBSTR());471 m_client.activeURLChanged(frameURL.GetBSTR()); 478 472 } 479 473 -
trunk/Tools/MiniBrowser/win/WebKitLegacyBrowserWindow.h
r248990 r249039 34 34 typedef _com_ptr_t<_com_IIID<IUnknown, &__uuidof(IUnknown)>> IUnknownPtr; 35 35 typedef _com_ptr_t<_com_IIID<IWebFrame, &__uuidof(IWebFrame)>> IWebFramePtr; 36 typedef _com_ptr_t<_com_IIID<IWebFrame2, &__uuidof(IWebFrame2)>> IWebFrame2Ptr; 36 37 typedef _com_ptr_t<_com_IIID<IWebView, &__uuidof(IWebView)>> IWebViewPtr; 37 38 typedef _com_ptr_t<_com_IIID<IWebViewPrivate2, &__uuidof(IWebViewPrivate2)>> IWebViewPrivatePtr; … … 49 50 typedef _com_ptr_t<_com_IIID<IWebDownloadDelegate, &__uuidof(IWebDownloadDelegate)>> IWebDownloadDelegatePtr; 50 51 typedef _com_ptr_t<_com_IIID<IWebFramePrivate, &__uuidof(IWebFramePrivate)>> IWebFramePrivatePtr; 52 typedef _com_ptr_t<_com_IIID<IWebMutableURLRequest, &__uuidof(IWebMutableURLRequest)>> IWebMutableURLRequestPtr; 53 typedef _com_ptr_t<_com_IIID<IWebNotificationObserver, &__uuidof(IWebNotificationObserver)>> IWebNotificationObserverPtr; 54 typedef _com_ptr_t<_com_IIID<IWebNotificationCenter, &__uuidof(IWebNotificationCenter)>> IWebNotificationCenterPtr; 51 55 52 56 class WebKitLegacyBrowserWindow : public BrowserWindow { 53 57 public: 54 static Ref<BrowserWindow> create(BrowserWindowClient&, HWND mainWnd, HWND urlBarWnd,bool useLayeredWebView = false);58 static Ref<BrowserWindow> create(BrowserWindowClient&, HWND mainWnd, bool useLayeredWebView = false); 55 59 56 60 private: … … 112 116 void setPreference(UINT menuID, bool enable); 113 117 114 WebKitLegacyBrowserWindow(BrowserWindowClient&, HWND mainWnd, HWND urlBarWnd,bool useLayeredWebView);118 WebKitLegacyBrowserWindow(BrowserWindowClient&, HWND mainWnd, bool useLayeredWebView); 115 119 void subclassForLayeredWindow(); 116 120 bool setCacheFolder(); … … 137 141 138 142 HWND m_hMainWnd { nullptr }; 139 HWND m_hURLBarWnd { nullptr };140 143 HWND m_viewWnd { nullptr }; 141 144
Note:
See TracChangeset
for help on using the changeset viewer.