Changeset 249039 in webkit


Ignore:
Timestamp:
Aug 22, 2019, 6:59:22 PM (6 years ago)
Author:
Fujii Hironori
Message:

[Win][MiniBrowser] URL bar should be updated for in-page navigations
https://bugs.webkit.org/show_bug.cgi?id=201032

Reviewed by Darin Adler.

  • MiniBrowser/win/BrowserWindow.h: Added activeURLChanged to BrowserWindowClient interface.
  • MiniBrowser/win/MainWindow.cpp:

(MainWindow::init):
(MainWindow::activeURLChanged): Added.

  • MiniBrowser/win/MainWindow.h:
  • MiniBrowser/win/MiniBrowserWebHost.cpp:

(MiniBrowserWebHost::didCommitLoadForFrame):
(MiniBrowserWebHost::didChangeLocationWithinPageForFrame): Added.
(MiniBrowserWebHost::updateAddressBar): Deleted.
(MiniBrowserWebHost::loadURL): Deleted.

  • MiniBrowser/win/MiniBrowserWebHost.h:

(MiniBrowserWebHost::MiniBrowserWebHost):
(MiniBrowserWebHost::didCommitLoadForFrame): Deleted.
(MiniBrowserWebHost::didChangeLocationWithinPageForFrame): Deleted.

  • MiniBrowser/win/PrintWebUIDelegate.cpp:
  • MiniBrowser/win/WebKitBrowserWindow.cpp:

(WebKitBrowserWindow::create):
(WebKitBrowserWindow::WebKitBrowserWindow):
(WebKitBrowserWindow::didChangeIsLoading): Removed an unused variable.
(WebKitBrowserWindow::didChangeActiveURL): Added.
(WebKitBrowserWindow::createNewPage):
(WebKitBrowserWindow::didCommitNavigation): Deleted.

  • MiniBrowser/win/WebKitBrowserWindow.h: Removed m_urlBarWnd.
  • MiniBrowser/win/WebKitLegacyBrowserWindow.cpp:

(WebKitLegacyBrowserWindow::create):
(WebKitLegacyBrowserWindow::WebKitLegacyBrowserWindow):
(WebKitLegacyBrowserWindow::init):
(WebKitLegacyBrowserWindow::navigateToHistory):

  • MiniBrowser/win/WebKitLegacyBrowserWindow.h: Removed m_urlBarWnd.
Location:
trunk/Tools
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r249036 r249039  
     12019-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
    1382019-08-22  Andy Estes  <aestes@apple.com>
    239
  • trunk/Tools/MiniBrowser/win/BrowserWindow.h

    r248990 r249039  
    3333    virtual void progressChanged(double) = 0;
    3434    virtual void progressFinished() = 0;
     35    virtual void activeURLChanged(std::wstring) = 0;
    3536};
    3637
  • trunk/Tools/MiniBrowser/win/MainWindow.cpp

    r248990 r249039  
    126126    SetWindowLongPtr(m_hURLBarWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(EditProc));
    127127
    128     m_browserWindow = factory(*this, m_hMainWnd, m_hURLBarWnd, usesLayeredWebView);
     128    m_browserWindow = factory(*this, m_hMainWnd, usesLayeredWebView);
    129129    if (!m_browserWindow)
    130130        return false;
     
    488488    SetWindowText(m_hProgressIndicator, L"");
    489489}
     490
     491void MainWindow::activeURLChanged(std::wstring url)
     492{
     493    SetWindowText(m_hURLBarWnd, url.c_str());
     494}
  • trunk/Tools/MiniBrowser/win/MainWindow.h

    r248990 r249039  
    3434class MainWindow final : public RefCounted<MainWindow>, public BrowserWindowClient {
    3535public:
    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)>;
    3737
    3838    static Ref<MainWindow> create();
     
    6363    void progressChanged(double) final;
    6464    void progressFinished() final;
     65    void activeURLChanged(std::wstring) final;
    6566
    6667    HWND m_hMainWnd { nullptr };
  • trunk/Tools/MiniBrowser/win/MiniBrowserWebHost.cpp

    r248990 r249039  
    3434
    3535typedef _com_ptr_t<_com_IIID<IWebDataSource, &__uuidof(IWebDataSource)>> IWebDataSourcePtr;
    36 typedef _com_ptr_t<_com_IIID<IWebMutableURLRequest, &__uuidof(IWebMutableURLRequest)>> IWebMutableURLRequestPtr;
    3736
    38 HRESULT MiniBrowserWebHost::updateAddressBar(IWebView& webView)
     37HRESULT MiniBrowserWebHost::didCommitLoadForFrame(_In_opt_ IWebView* webView, _In_opt_ IWebFrame* frame)
    3938{
    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);
    7040}
    7141
     
    8252        ::MessageBoxW(0, static_cast<LPCWSTR>(errorDescription), L"Error", MB_APPLMODAL | MB_OK);
    8353
     54    return S_OK;
     55}
     56
     57HRESULT 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());
    8473    return S_OK;
    8574}
     
    11099    return m_client->Release();
    111100}
    112 
    113 typedef _com_ptr_t<_com_IIID<IWebFrame2, &__uuidof(IWebFrame2)>> IWebFrame2Ptr;
    114101
    115102HRESULT MiniBrowserWebHost::didFinishLoadForFrame(_In_opt_ IWebView* webView, _In_opt_ IWebFrame* frame)
  • trunk/Tools/MiniBrowser/win/MiniBrowserWebHost.h

    r248990 r249039  
    3434class MiniBrowserWebHost : public IWebFrameLoadDelegate, public IWebFrameLoadDelegatePrivate, public IWebNotificationObserver {
    3535public:
    36     MiniBrowserWebHost(WebKitLegacyBrowserWindow* client, HWND urlBar)
    37         : m_client(client), m_hURLBarWnd(urlBar) { }
     36    MiniBrowserWebHost(WebKitLegacyBrowserWindow* client)
     37        : m_client(client) { }
    3838
    3939    // IUnknown
     
    4646    virtual HRESULT STDMETHODCALLTYPE didReceiveServerRedirectForProvisionalLoadForFrame(_In_opt_ IWebView*, _In_opt_ IWebFrame*) { return S_OK; }
    4747    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*);
    5649    virtual HRESULT STDMETHODCALLTYPE didReceiveTitle(_In_opt_ IWebView*, _In_ BSTR title, _In_opt_ IWebFrame*) { return S_OK; }
    5750    virtual HRESULT STDMETHODCALLTYPE didChangeIcons(_In_opt_ IWebView*, _In_opt_ IWebFrame*) { return S_OK; }
     
    5952    virtual HRESULT STDMETHODCALLTYPE didFinishLoadForFrame(_In_opt_ IWebView*, _In_opt_ IWebFrame*);
    6053    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*);
    6255    virtual HRESULT STDMETHODCALLTYPE willPerformClientRedirectToURL(_In_opt_ IWebView*, _In_ BSTR url, double delaySeconds, DATE fireDate, _In_opt_ IWebFrame*) { return S_OK; }
    6356    virtual HRESULT STDMETHODCALLTYPE didCancelClientRedirectForFrame(_In_opt_ IWebView*, _In_opt_ IWebFrame*) { return S_OK; }
     
    7568    virtual HRESULT STDMETHODCALLTYPE onNotify(_In_opt_ IWebNotification*);
    7669
    77     void loadURL(_bstr_t&);
    78 
    79 protected:
    80     HRESULT updateAddressBar(IWebView&);
    81 
    8270private:
    8371    WebKitLegacyBrowserWindow* m_client { nullptr };
    84     HWND m_hURLBarWnd { 0 };
    8572};
  • trunk/Tools/MiniBrowser/win/PrintWebUIDelegate.cpp

    r242984 r249039  
    160160}
    161161
    162 typedef _com_ptr_t<_com_IIID<IWebFrame, &__uuidof(IWebFrame)>> IWebFramePtr;
    163 typedef _com_ptr_t<_com_IIID<IWebFramePrivate, &__uuidof(IWebFramePrivate)>> IWebFramePrivatePtr;
    164 
    165162HRESULT PrintWebUIDelegate::webViewPrintingMarginRect(_In_opt_ IWebView* view, _Out_ RECT* rect)
    166163{
  • trunk/Tools/MiniBrowser/win/WebKitBrowserWindow.cpp

    r248990 r249039  
    105105}
    106106
    107 Ref<BrowserWindow> WebKitBrowserWindow::create(BrowserWindowClient& client, HWND mainWnd, HWND urlBarWnd, bool)
     107Ref<BrowserWindow> WebKitBrowserWindow::create(BrowserWindowClient& client, HWND mainWnd, bool)
    108108{
    109109    auto conf = adoptWK(WKPageConfigurationCreate());
     
    122122    WKPageConfigurationSetContext(conf.get(), context.get());
    123123
    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
     127WebKitBrowserWindow::WebKitBrowserWindow(BrowserWindowClient& client, WKPageConfigurationRef conf, HWND mainWnd)
    128128    : m_client(client)
    129129    , m_hMainWnd(mainWnd)
    130     , m_urlBarWnd(urlBarWnd)
    131130{
    132131    RECT rect = { };
     
    139138    navigationClient.base.version = 0;
    140139    navigationClient.base.clientInfo = this;
    141     navigationClient.didCommitNavigation = didCommitNavigation;
    142140    navigationClient.didReceiveAuthenticationChallenge = didReceiveAuthenticationChallenge;
    143141    WKPageSetPageNavigationClient(page, &navigationClient.base);
     
    156154    stateClient.didChangeIsLoading = didChangeIsLoading;
    157155    stateClient.didChangeEstimatedProgress = didChangeEstimatedProgress;
     156    stateClient.didChangeActiveURL = didChangeActiveURL;
    158157    WKPageSetPageStateClient(page, &stateClient.base);
    159158
     
    315314{
    316315    auto& thisWindow = toWebKitBrowserWindow(clientInfo);
    317     auto page = WKViewGetPage(thisWindow.m_view.get());
    318316    thisWindow.m_client.progressFinished();
    319317}
     
    326324}
    327325
    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());
     326void 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()));
    335332}
    336333
     
    385382{
    386383    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));
    389386    };
    390387    bool ok = newWindow.init(factory, hInst);
  • trunk/Tools/MiniBrowser/win/WebKitBrowserWindow.h

    r248990 r249039  
    3434class WebKitBrowserWindow : public BrowserWindow {
    3535public:
    36     static Ref<BrowserWindow> create(BrowserWindowClient&, HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView = false);
     36    static Ref<BrowserWindow> create(BrowserWindowClient&, HWND mainWnd, bool useLayeredWebView = false);
    3737
    3838private:
    39     WebKitBrowserWindow(BrowserWindowClient&, WKPageConfigurationRef, HWND mainWnd, HWND urlBarWnd);
     39    WebKitBrowserWindow(BrowserWindowClient&, WKPageConfigurationRef, HWND mainWnd);
    4040
    4141    HRESULT init() override;
     
    6969    static void didChangeIsLoading(const void*);
    7070    static void didChangeEstimatedProgress(const void*);
    71     static void didCommitNavigation(WKPageRef, WKNavigationRef, WKTypeRef, const void*);
     71    static void didChangeActiveURL(const void*);
    7272    static void didReceiveAuthenticationChallenge(WKPageRef, WKAuthenticationChallengeRef, const void*);
    7373    static WKPageRef createNewPage(WKPageRef, WKPageConfigurationRef, WKNavigationActionRef, WKWindowFeaturesRef, const void *);
     
    7777    WKRetainPtr<WKViewRef> m_view;
    7878    HWND m_hMainWnd { nullptr };
    79     HWND m_urlBarWnd { nullptr };
    8079    ProxySettings m_proxy { };
    8180    std::unordered_map<std::wstring, std::wstring> m_acceptedServerTrustCerts;
  • trunk/Tools/MiniBrowser/win/WebKitLegacyBrowserWindow.cpp

    r248990 r249039  
    5858static const int maxHistorySize = 10;
    5959
    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)
     60Ref<BrowserWindow> WebKitLegacyBrowserWindow::create(BrowserWindowClient& client, HWND mainWnd, bool useLayeredWebView)
     61{
     62    return adoptRef(*new WebKitLegacyBrowserWindow(client, mainWnd, useLayeredWebView));
     63}
     64
     65WebKitLegacyBrowserWindow::WebKitLegacyBrowserWindow(BrowserWindowClient& client, HWND mainWnd, bool useLayeredWebView)
    7166    : m_client(client)
    7267    , m_hMainWnd(mainWnd)
    73     , m_hURLBarWnd(urlBarWnd)
    7468    , m_useLayeredWebView(useLayeredWebView)
    7569{
     
    130124        return E_FAIL;
    131125
    132     auto webHost = new MiniBrowserWebHost(this, m_hURLBarWnd);
     126    auto webHost = new MiniBrowserWebHost(this);
    133127
    134128    hr = setFrameLoadDelegate(webHost);
     
    475469    desiredHistoryItem->URLString(frameURL.GetAddress());
    476470
    477     ::SendMessage(m_hURLBarWnd, (UINT)WM_SETTEXT, 0, (LPARAM)frameURL.GetBSTR());
     471    m_client.activeURLChanged(frameURL.GetBSTR());
    478472}
    479473
  • trunk/Tools/MiniBrowser/win/WebKitLegacyBrowserWindow.h

    r248990 r249039  
    3434typedef _com_ptr_t<_com_IIID<IUnknown, &__uuidof(IUnknown)>> IUnknownPtr;
    3535typedef _com_ptr_t<_com_IIID<IWebFrame, &__uuidof(IWebFrame)>> IWebFramePtr;
     36typedef _com_ptr_t<_com_IIID<IWebFrame2, &__uuidof(IWebFrame2)>> IWebFrame2Ptr;
    3637typedef _com_ptr_t<_com_IIID<IWebView, &__uuidof(IWebView)>> IWebViewPtr;
    3738typedef _com_ptr_t<_com_IIID<IWebViewPrivate2, &__uuidof(IWebViewPrivate2)>> IWebViewPrivatePtr;
     
    4950typedef _com_ptr_t<_com_IIID<IWebDownloadDelegate, &__uuidof(IWebDownloadDelegate)>> IWebDownloadDelegatePtr;
    5051typedef _com_ptr_t<_com_IIID<IWebFramePrivate, &__uuidof(IWebFramePrivate)>> IWebFramePrivatePtr;
     52typedef _com_ptr_t<_com_IIID<IWebMutableURLRequest, &__uuidof(IWebMutableURLRequest)>> IWebMutableURLRequestPtr;
     53typedef _com_ptr_t<_com_IIID<IWebNotificationObserver, &__uuidof(IWebNotificationObserver)>> IWebNotificationObserverPtr;
     54typedef _com_ptr_t<_com_IIID<IWebNotificationCenter, &__uuidof(IWebNotificationCenter)>> IWebNotificationCenterPtr;
    5155
    5256class WebKitLegacyBrowserWindow : public BrowserWindow {
    5357public:
    54     static Ref<BrowserWindow> create(BrowserWindowClient&, HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView = false);
     58    static Ref<BrowserWindow> create(BrowserWindowClient&, HWND mainWnd, bool useLayeredWebView = false);
    5559
    5660private:
     
    112116    void setPreference(UINT menuID, bool enable);
    113117
    114     WebKitLegacyBrowserWindow(BrowserWindowClient&, HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView);
     118    WebKitLegacyBrowserWindow(BrowserWindowClient&, HWND mainWnd, bool useLayeredWebView);
    115119    void subclassForLayeredWindow();
    116120    bool setCacheFolder();
     
    137141
    138142    HWND m_hMainWnd { nullptr };
    139     HWND m_hURLBarWnd { nullptr };
    140143    HWND m_viewWnd { nullptr };
    141144
Note: See TracChangeset for help on using the changeset viewer.