Changeset 248990 in webkit
- Timestamp:
- Aug 21, 2019, 6:49:48 PM (7 years ago)
- Location:
- trunk/Tools
- Files:
-
- 10 edited
-
ChangeLog (modified) (1 diff)
-
MiniBrowser/win/BrowserWindow.h (modified) (1 diff)
-
MiniBrowser/win/MainWindow.cpp (modified) (4 diffs)
-
MiniBrowser/win/MainWindow.h (modified) (3 diffs)
-
MiniBrowser/win/MiniBrowserWebHost.cpp (modified) (1 diff)
-
MiniBrowser/win/MiniBrowserWebHost.h (modified) (2 diffs)
-
MiniBrowser/win/WebKitBrowserWindow.cpp (modified) (5 diffs)
-
MiniBrowser/win/WebKitBrowserWindow.h (modified) (3 diffs)
-
MiniBrowser/win/WebKitLegacyBrowserWindow.cpp (modified) (3 diffs)
-
MiniBrowser/win/WebKitLegacyBrowserWindow.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r248980 r248990 1 2019-08-21 Fujii Hironori <Hironori.Fujii@sony.com> 2 3 [Win][MiniBrowser] Add a progress indicator to the main window 4 https://bugs.webkit.org/show_bug.cgi?id=200970 5 6 Reviewed by Alex Christensen. 7 8 * MiniBrowser/win/BrowserWindow.h: Added BrowserWindowClient class. 9 * MiniBrowser/win/MainWindow.cpp: 10 (MainWindow::init): 11 (MainWindow::resizeSubViews): 12 (MainWindow::progressChanged): 13 (MainWindow::progressFinished): 14 * MiniBrowser/win/MainWindow.h: Inherited BrowserWindowClient. 15 Added m_hProgressIndicator. 16 (MainWindow::hwnd const): Deleted. 17 (MainWindow::browserWindow const): Deleted. 18 (): Deleted. 19 * MiniBrowser/win/MiniBrowserWebHost.cpp: 20 (MiniBrowserWebHost::onNotify): 21 * MiniBrowser/win/MiniBrowserWebHost.h: 22 * MiniBrowser/win/WebKitBrowserWindow.cpp: 23 (WebKitBrowserWindow::create): 24 (WebKitBrowserWindow::WebKitBrowserWindow): 25 (WebKitBrowserWindow::didChangeIsLoading): 26 (WebKitBrowserWindow::didChangeEstimatedProgress): 27 (WebKitBrowserWindow::createNewPage): 28 * MiniBrowser/win/WebKitBrowserWindow.h: 29 * MiniBrowser/win/WebKitLegacyBrowserWindow.cpp: 30 (WebKitLegacyBrowserWindow::create): 31 (WebKitLegacyBrowserWindow::WebKitLegacyBrowserWindow): 32 (WebKitLegacyBrowserWindow::init): 33 * MiniBrowser/win/WebKitLegacyBrowserWindow.h: 34 1 35 2019-08-21 Ryan Haddad <ryanhaddad@apple.com> 2 36 -
trunk/Tools/MiniBrowser/win/BrowserWindow.h
r247938 r248990 29 29 #include <wtf/RefCounted.h> 30 30 31 class BrowserWindowClient { 32 public: 33 virtual void progressChanged(double) = 0; 34 virtual void progressFinished() = 0; 35 }; 36 31 37 class BrowserWindow : public RefCounted<BrowserWindow> { 32 38 public: -
trunk/Tools/MiniBrowser/win/MainWindow.cpp
r248399 r248990 31 31 #include "WebKitLegacyBrowserWindow.h" 32 32 #include <CoreFoundation/CoreFoundation.h> 33 #include <sstream> 33 34 34 35 #if ENABLE(WEBKIT) … … 116 117 #endif 117 118 118 float scaleFactor = WebCore::deviceScaleFactorForWindow(nullptr);119 119 m_hBackButtonWnd = CreateWindow(L"BUTTON", L"<", WS_CHILD | WS_VISIBLE | BS_TEXT, 0, 0, 0, 0, m_hMainWnd, reinterpret_cast<HMENU>(IDM_HISTORY_BACKWARD), hInstance, 0); 120 120 m_hForwardButtonWnd = CreateWindow(L"BUTTON", L">", WS_CHILD | WS_VISIBLE | BS_TEXT, 0, 0, 0, 0, m_hMainWnd, reinterpret_cast<HMENU>(IDM_HISTORY_FORWARD), hInstance, 0); 121 121 m_hReloadButtonWnd = CreateWindow(L"BUTTON", L"↺", WS_CHILD | WS_VISIBLE | BS_TEXT, 0, 0, 0, 0, m_hMainWnd, reinterpret_cast<HMENU>(IDM_RELOAD), hInstance, 0); 122 122 m_hURLBarWnd = CreateWindow(L"EDIT", 0, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_AUTOVSCROLL, 0, 0, 0, 0, m_hMainWnd, 0, hInstance, 0); 123 m_hProgressIndicator = CreateWindow(L"STATIC", 0, WS_CHILD | WS_VISIBLE | WS_BORDER | SS_CENTER | SS_CENTERIMAGE, 0, 0, 0, 0, m_hMainWnd, 0, hInstance, 0); 123 124 124 125 DefEditProc = reinterpret_cast<WNDPROC>(GetWindowLongPtr(m_hURLBarWnd, GWLP_WNDPROC)); 125 126 SetWindowLongPtr(m_hURLBarWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(EditProc)); 126 127 127 m_browserWindow = factory( m_hMainWnd, m_hURLBarWnd, usesLayeredWebView);128 m_browserWindow = factory(*this, m_hMainWnd, m_hURLBarWnd, usesLayeredWebView); 128 129 if (!m_browserWindow) 129 130 return false; … … 151 152 MoveWindow(m_hForwardButtonWnd, width, 0, width, height, TRUE); 152 153 MoveWindow(m_hReloadButtonWnd, width * 2, 0, width, height, TRUE); 153 MoveWindow(m_hURLBarWnd, width * 3, 0, rcClient.right - width * 3, height, TRUE); 154 MoveWindow(m_hURLBarWnd, width * 3, 0, rcClient.right - width * 5, height, TRUE); 155 MoveWindow(m_hProgressIndicator, rcClient.right - width * 2, 0, width * 2, height, TRUE); 154 156 155 157 if (m_browserWindow->usesLayeredWebView() || !m_browserWindow->hwnd()) … … 474 476 ::SendMessage(m_hURLBarWnd, static_cast<UINT>(WM_SETFONT), reinterpret_cast<WPARAM>(m_hURLBarFont), TRUE); 475 477 } 478 479 void MainWindow::progressChanged(double progress) 480 { 481 std::wostringstream text; 482 text << static_cast<int>(progress * 100) << L'%'; 483 SetWindowText(m_hProgressIndicator, text.str().c_str()); 484 } 485 486 void MainWindow::progressFinished() 487 { 488 SetWindowText(m_hProgressIndicator, L""); 489 } -
trunk/Tools/MiniBrowser/win/MainWindow.h
r247938 r248990 32 32 #include <wtf/RefPtr.h> 33 33 34 class MainWindow : public RefCounted<MainWindow>{34 class MainWindow final : public RefCounted<MainWindow>, public BrowserWindowClient { 35 35 public: 36 using BrowserWindowFactory = std::function<Ref<BrowserWindow>( HWND mainWnd, HWND urlBarWnd, bool usesLayeredWebView)>;36 using BrowserWindowFactory = std::function<Ref<BrowserWindow>(BrowserWindowClient&, HWND mainWnd, HWND urlBarWnd, bool usesLayeredWebView)>; 37 37 38 38 static Ref<MainWindow> create(); … … 60 60 void updateDeviceScaleFactor(); 61 61 62 // BrowserWindowClient 63 void progressChanged(double) final; 64 void progressFinished() final; 65 62 66 HWND m_hMainWnd { nullptr }; 63 67 HWND m_hURLBarWnd { nullptr }; … … 65 69 HWND m_hForwardButtonWnd { nullptr }; 66 70 HWND m_hReloadButtonWnd { nullptr }; 71 HWND m_hProgressIndicator { nullptr }; 67 72 HWND m_hCacheWnd { nullptr }; 68 73 HGDIOBJ m_hURLBarFont { nullptr }; -
trunk/Tools/MiniBrowser/win/MiniBrowserWebHost.cpp
r247896 r248990 167 167 return S_OK; 168 168 } 169 170 HRESULT MiniBrowserWebHost::onNotify(_In_opt_ IWebNotification* notification) 171 { 172 _bstr_t name; 173 HRESULT hr = notification->name(name.GetAddress()); 174 if (FAILED(hr)) 175 return hr; 176 if (name == _bstr_t(WebViewProgressEstimateChangedNotification)) { 177 IUnknownPtr object; 178 hr = notification->getObject(&object.GetInterfacePtr()); 179 if (FAILED(hr)) 180 return hr; 181 IWebViewPtr webView(object); 182 if (!webView) 183 return E_NOINTERFACE; 184 double progress; 185 hr = webView->estimatedProgress(&progress); 186 if (FAILED(hr)) 187 return hr; 188 m_client->m_client.progressChanged(progress); 189 } else if (name == _bstr_t(WebViewProgressFinishedNotification)) 190 m_client->m_client.progressFinished(); 191 192 return S_OK; 193 } -
trunk/Tools/MiniBrowser/win/MiniBrowserWebHost.h
r239666 r248990 32 32 class WebKitLegacyBrowserWindow; 33 33 34 class MiniBrowserWebHost : public IWebFrameLoadDelegate, public IWebFrameLoadDelegatePrivate {34 class MiniBrowserWebHost : public IWebFrameLoadDelegate, public IWebFrameLoadDelegatePrivate, public IWebNotificationObserver { 35 35 public: 36 36 MiniBrowserWebHost(WebKitLegacyBrowserWindow* client, HWND urlBar) … … 72 72 virtual HRESULT STDMETHODCALLTYPE didFirstVisuallyNonEmptyLayoutInFrame(_In_opt_ IWebView* sender, _In_opt_ IWebFrame*) { return S_OK; } 73 73 74 // IWebNotificationObserver 75 virtual HRESULT STDMETHODCALLTYPE onNotify(_In_opt_ IWebNotification*); 76 74 77 void loadURL(_bstr_t&); 75 78 -
trunk/Tools/MiniBrowser/win/WebKitBrowserWindow.cpp
r248291 r248990 105 105 } 106 106 107 Ref<BrowserWindow> WebKitBrowserWindow::create( HWND mainWnd, HWND urlBarWnd, bool)107 Ref<BrowserWindow> WebKitBrowserWindow::create(BrowserWindowClient& client, HWND mainWnd, HWND urlBarWnd, bool) 108 108 { 109 109 auto conf = adoptWK(WKPageConfigurationCreate()); … … 122 122 WKPageConfigurationSetContext(conf.get(), context.get()); 123 123 124 return adoptRef(*new WebKitBrowserWindow(conf.get(), mainWnd, urlBarWnd)); 125 } 126 127 WebKitBrowserWindow::WebKitBrowserWindow(WKPageConfigurationRef conf, HWND mainWnd, HWND urlBarWnd) 128 : m_hMainWnd(mainWnd) 124 return adoptRef(*new WebKitBrowserWindow(client, conf.get(), mainWnd, urlBarWnd)); 125 } 126 127 WebKitBrowserWindow::WebKitBrowserWindow(BrowserWindowClient& client, WKPageConfigurationRef conf, HWND mainWnd, HWND urlBarWnd) 128 : m_client(client) 129 , m_hMainWnd(mainWnd) 129 130 , m_urlBarWnd(urlBarWnd) 130 131 { … … 153 154 stateClient.base.clientInfo = this; 154 155 stateClient.didChangeTitle = didChangeTitle; 156 stateClient.didChangeIsLoading = didChangeIsLoading; 157 stateClient.didChangeEstimatedProgress = didChangeEstimatedProgress; 155 158 WKPageSetPageStateClient(page, &stateClient.base); 156 159 … … 307 310 std::wstring titleString = createString(title.get()) + L" [WebKit]"; 308 311 SetWindowText(thisWindow.m_hMainWnd, titleString.c_str()); 312 } 313 314 void WebKitBrowserWindow::didChangeIsLoading(const void* clientInfo) 315 { 316 auto& thisWindow = toWebKitBrowserWindow(clientInfo); 317 auto page = WKViewGetPage(thisWindow.m_view.get()); 318 thisWindow.m_client.progressFinished(); 319 } 320 321 void WebKitBrowserWindow::didChangeEstimatedProgress(const void* clientInfo) 322 { 323 auto& thisWindow = toWebKitBrowserWindow(clientInfo); 324 auto page = WKViewGetPage(thisWindow.m_view.get()); 325 thisWindow.m_client.progressChanged(WKPageGetEstimatedProgress(page)); 309 326 } 310 327 … … 368 385 { 369 386 auto& newWindow = MainWindow::create().leakRef(); 370 auto factory = [configuration]( HWND mainWnd, HWND urlBarWnd, bool) -> auto {371 return adoptRef(*new WebKitBrowserWindow(c onfiguration, mainWnd, urlBarWnd));387 auto factory = [configuration](BrowserWindowClient& client, HWND mainWnd, HWND urlBarWnd, bool) -> auto { 388 return adoptRef(*new WebKitBrowserWindow(client, configuration, mainWnd, urlBarWnd)); 372 389 }; 373 390 bool ok = newWindow.init(factory, hInst); -
trunk/Tools/MiniBrowser/win/WebKitBrowserWindow.h
r248291 r248990 34 34 class WebKitBrowserWindow : public BrowserWindow { 35 35 public: 36 static Ref<BrowserWindow> create( HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView = false);36 static Ref<BrowserWindow> create(BrowserWindowClient&, HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView = false); 37 37 38 38 private: 39 WebKitBrowserWindow( WKPageConfigurationRef, HWND mainWnd, HWND urlBarWnd);39 WebKitBrowserWindow(BrowserWindowClient&, WKPageConfigurationRef, HWND mainWnd, HWND urlBarWnd); 40 40 41 41 HRESULT init() override; … … 67 67 68 68 static void didChangeTitle(const void*); 69 static void didChangeIsLoading(const void*); 70 static void didChangeEstimatedProgress(const void*); 69 71 static void didCommitNavigation(WKPageRef, WKNavigationRef, WKTypeRef, const void*); 70 72 static void didReceiveAuthenticationChallenge(WKPageRef, WKAuthenticationChallengeRef, const void*); … … 72 74 static void didNotHandleKeyEvent(WKPageRef, WKNativeEventPtr, const void*); 73 75 76 BrowserWindowClient& m_client; 74 77 WKRetainPtr<WKViewRef> m_view; 75 78 HWND m_hMainWnd { nullptr }; -
trunk/Tools/MiniBrowser/win/WebKitLegacyBrowserWindow.cpp
r248444 r248990 59 59 60 60 typedef _com_ptr_t<_com_IIID<IWebMutableURLRequest, &__uuidof(IWebMutableURLRequest)>> IWebMutableURLRequestPtr; 61 62 Ref<BrowserWindow> WebKitLegacyBrowserWindow::create(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView) 63 { 64 return adoptRef(*new WebKitLegacyBrowserWindow(mainWnd, urlBarWnd, useLayeredWebView)); 65 } 66 67 WebKitLegacyBrowserWindow::WebKitLegacyBrowserWindow(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView) 68 : m_hMainWnd(mainWnd) 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) 71 : m_client(client) 72 , m_hMainWnd(mainWnd) 69 73 , m_hURLBarWnd(urlBarWnd) 70 74 , m_useLayeredWebView(useLayeredWebView) … … 107 111 return hr; 108 112 113 IWebNotificationCenterPtr notificationCenter; 114 hr = WebKitCreateInstance(CLSID_WebNotificationCenter, 0, __uuidof(notificationCenter), reinterpret_cast<void**>(¬ificationCenter.GetInterfacePtr())); 115 if (FAILED(hr)) 116 return hr; 117 118 IWebNotificationCenterPtr defaultNotificationCenter; 119 hr = notificationCenter->defaultCenter(&defaultNotificationCenter.GetInterfacePtr()); 120 if (FAILED(hr)) 121 return hr; 122 109 123 if (!seedInitialDefaultPreferences()) 110 124 return E_FAIL; … … 123 137 124 138 hr = setFrameLoadDelegatePrivate(webHost); 139 if (FAILED(hr)) 140 return hr; 141 142 hr = defaultNotificationCenter->addObserver(webHost, _bstr_t(WebViewProgressEstimateChangedNotification), nullptr); 143 if (FAILED(hr)) 144 return hr; 145 146 hr = defaultNotificationCenter->addObserver(webHost, _bstr_t(WebViewProgressFinishedNotification), nullptr); 125 147 if (FAILED(hr)) 126 148 return hr; -
trunk/Tools/MiniBrowser/win/WebKitLegacyBrowserWindow.h
r247938 r248990 32 32 #include <wtf/Ref.h> 33 33 34 typedef _com_ptr_t<_com_IIID<IUnknown, &__uuidof(IUnknown)>> IUnknownPtr; 34 35 typedef _com_ptr_t<_com_IIID<IWebFrame, &__uuidof(IWebFrame)>> IWebFramePtr; 35 36 typedef _com_ptr_t<_com_IIID<IWebView, &__uuidof(IWebView)>> IWebViewPtr; … … 51 52 class WebKitLegacyBrowserWindow : public BrowserWindow { 52 53 public: 53 static Ref<BrowserWindow> create( HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView = false);54 static Ref<BrowserWindow> create(BrowserWindowClient&, HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView = false); 54 55 55 56 private: … … 111 112 void setPreference(UINT menuID, bool enable); 112 113 113 WebKitLegacyBrowserWindow( HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView);114 WebKitLegacyBrowserWindow(BrowserWindowClient&, HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView); 114 115 void subclassForLayeredWindow(); 115 116 bool setCacheFolder(); 116 117 118 BrowserWindowClient& m_client; 117 119 std::vector<IWebHistoryItemPtr> m_historyItems; 118 120
Note:
See TracChangeset
for help on using the changeset viewer.