Changeset 232616 in webkit


Ignore:
Timestamp:
Jun 7, 2018 10:14:03 PM (6 years ago)
Author:
Fujii Hironori
Message:

[Win][MiniBrowser] Add a new BrowserWindow interface to abstract WK1 and WK2 BrowserWindow
https://bugs.webkit.org/show_bug.cgi?id=186421

Reviewed by Ryosuke Niwa.

This is the core patch to make MiniBrowser to support WK1 and WK2
windows (Bug 184770).

I will rename MiniBrowser class to WK1BrowserWindow in a follow-up
patch (Bug 184770 Comment 12).

  • MiniBrowser/win/BrowserWindow.h: Added.
  • MiniBrowser/win/MainWindow.cpp:

(MainWindow::WndProc):

  • MiniBrowser/win/MainWindow.h:

(MainWindow::browserWindow const):

  • MiniBrowser/win/MiniBrowser.cpp:

(MiniBrowser::create):
(MiniBrowser::navigateForwardOrBackward): Removed the unsed first argument hWnd.
(MiniBrowser::navigateToHistory): Ditto.

  • MiniBrowser/win/MiniBrowser.h: Inherit BrowserWindow interface.

Make all other methods private and make delegates classes friends.

  • MiniBrowser/win/PrintWebUIDelegate.cpp:

(PrintWebUIDelegate::createWebViewWithRequest):

Location:
trunk/Tools
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r232609 r232616  
     12018-06-07  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        [Win][MiniBrowser] Add a new BrowserWindow interface to abstract WK1 and WK2 BrowserWindow
     4        https://bugs.webkit.org/show_bug.cgi?id=186421
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        This is the core patch to make MiniBrowser to support WK1 and WK2
     9        windows (Bug 184770).
     10
     11        I will rename MiniBrowser class to WK1BrowserWindow in a follow-up
     12        patch (Bug 184770 Comment 12).
     13
     14        * MiniBrowser/win/BrowserWindow.h: Added.
     15        * MiniBrowser/win/MainWindow.cpp:
     16        (MainWindow::WndProc):
     17        * MiniBrowser/win/MainWindow.h:
     18        (MainWindow::browserWindow const):
     19        * MiniBrowser/win/MiniBrowser.cpp:
     20        (MiniBrowser::create):
     21        (MiniBrowser::navigateForwardOrBackward): Removed the unsed first argument hWnd.
     22        (MiniBrowser::navigateToHistory): Ditto.
     23        * MiniBrowser/win/MiniBrowser.h: Inherit BrowserWindow interface.
     24        Make all other methods private and make delegates classes friends.
     25        * MiniBrowser/win/PrintWebUIDelegate.cpp:
     26        (PrintWebUIDelegate::createWebViewWithRequest):
     27
    1282018-06-07  Fujii Hironori  <Hironori.Fujii@sony.com>
    229
  • trunk/Tools/MiniBrowser/win/BrowserWindow.h

    r232615 r232616  
    2626#pragma once
    2727
    28 #include "MiniBrowser.h"
    29 #include <memory>
    30 #include <string>
    31 #include <wtf/RefPtr.h>
     28#include <windows.h>
     29#include <wtf/RefCounted.h>
    3230
    33 class MainWindow : public RefCounted<MainWindow> {
     31class BrowserWindow : public RefCounted<BrowserWindow> {
    3432public:
    35     static Ref<MainWindow> create();
     33    virtual ~BrowserWindow() { };
    3634
    37     ~MainWindow();
    38     bool init(HINSTANCE hInstance, bool usesLayeredWebView = false, bool pageLoadTesting = false);
     35    virtual HRESULT init() = 0;
     36    virtual HWND hwnd() = 0;
    3937
    40     void resizeSubViews();
    41     HWND hwnd() const { return m_hMainWnd; }
    42     MiniBrowser* browserWindow() const { return m_browserWindow.get(); }
     38    virtual HRESULT loadHTMLString(const BSTR&) = 0;
     39    virtual HRESULT loadURL(const BSTR& passedURL) = 0;
     40    virtual void navigateForwardOrBackward(UINT menuID) = 0;
     41    virtual void navigateToHistory(UINT menuID) = 0;
     42    virtual void setPreference(UINT menuID, bool enable) = 0;
     43    virtual bool usesLayeredWebView() const { return false; }
    4344
    44     void loadURL(BSTR url);
    45    
    46 private:
    47     static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
    48     static INT_PTR CALLBACK customUserAgentDialogProc(HWND, UINT, WPARAM, LPARAM);
    49     static INT_PTR CALLBACK cachesDialogProc(HWND, UINT, WPARAM, LPARAM);
    50     static void registerClass(HINSTANCE hInstance);
    51     static std::wstring s_windowClass;
    52     static size_t s_numInstances;
     45    virtual void print() = 0;
     46    virtual void launchInspector() = 0;
    5347
    54     MainWindow();
    55     bool toggleMenuItem(UINT menuID);
    56     void onURLBarEnter();
    57     void updateDeviceScaleFactor();
     48    virtual _bstr_t userAgent() = 0;
     49    virtual void setUserAgent(UINT menuID) = 0;
     50    virtual void setUserAgent(_bstr_t& customUAString) = 0;
    5851
    59     HWND m_hMainWnd { nullptr };
    60     HWND m_hURLBarWnd { nullptr };
    61     HWND m_hBackButtonWnd { nullptr };
    62     HWND m_hForwardButtonWnd { nullptr };
    63     HWND m_hCacheWnd { nullptr };
    64     HGDIOBJ m_hURLBarFont { nullptr };
    65     RefPtr<MiniBrowser> m_browserWindow;
     52    virtual void showLayerTree() = 0;
     53    virtual void updateStatistics(HWND dialog) = 0;
     54
     55    virtual void resetZoom() = 0;
     56    virtual void zoomIn() = 0;
     57    virtual void zoomOut() = 0;
    6658};
  • trunk/Tools/MiniBrowser/win/MainWindow.cpp

    r232609 r232616  
    164164        }
    165165        if (wmId >= IDM_HISTORY_LINK0 && wmId <= IDM_HISTORY_LINK9) {
    166             thisWindow->browserWindow()->navigateToHistory(hWnd, wmId);
     166            thisWindow->browserWindow()->navigateToHistory(wmId);
    167167            break;
    168168        }
     
    192192        case IDM_HISTORY_BACKWARD:
    193193        case IDM_HISTORY_FORWARD:
    194             thisWindow->browserWindow()->navigateForwardOrBackward(hWnd, wmId);
     194            thisWindow->browserWindow()->navigateForwardOrBackward(wmId);
    195195            break;
    196196        case IDM_UA_OTHER:
  • trunk/Tools/MiniBrowser/win/MainWindow.h

    r232609 r232616  
    4040    void resizeSubViews();
    4141    HWND hwnd() const { return m_hMainWnd; }
    42     MiniBrowser* browserWindow() const { return m_browserWindow.get(); }
     42    BrowserWindow* browserWindow() const { return m_browserWindow.get(); }
    4343
    4444    void loadURL(BSTR url);
     
    6363    HWND m_hCacheWnd { nullptr };
    6464    HGDIOBJ m_hURLBarFont { nullptr };
    65     RefPtr<MiniBrowser> m_browserWindow;
     65    RefPtr<BrowserWindow> m_browserWindow;
    6666};
  • trunk/Tools/MiniBrowser/win/MiniBrowser.cpp

    r232609 r232616  
    6161typedef _com_ptr_t<_com_IIID<IWebMutableURLRequest, &__uuidof(IWebMutableURLRequest)>> IWebMutableURLRequestPtr;
    6262
    63 Ref<MiniBrowser> MiniBrowser::create(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView, bool pageLoadTesting)
     63Ref<BrowserWindow> MiniBrowser::create(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView, bool pageLoadTesting)
    6464{
    6565    return adoptRef(*new MiniBrowser(mainWnd, urlBarWnd, useLayeredWebView, pageLoadTesting));
     
    431431}
    432432
    433 void MiniBrowser::navigateForwardOrBackward(HWND hWnd, UINT menuID)
     433void MiniBrowser::navigateForwardOrBackward(UINT menuID)
    434434{
    435435    if (!m_webView)
     
    443443}
    444444
    445 void MiniBrowser::navigateToHistory(HWND hWnd, UINT menuID)
     445void MiniBrowser::navigateToHistory(UINT menuID)
    446446{
    447447    if (!m_webView)
  • trunk/Tools/MiniBrowser/win/MiniBrowser.h

    r232609 r232616  
    2525
    2626#pragma once
     27#include "BrowserWindow.h"
    2728#include "PageLoadTestClient.h"
    2829#include <WebKitLegacy/WebKit.h>
     
    3031#include <memory>
    3132#include <vector>
    32 #include <wtf/RefCounted.h>
    3333
    3434typedef _com_ptr_t<_com_IIID<IWebFrame, &__uuidof(IWebFrame)>> IWebFramePtr;
     
    4949typedef _com_ptr_t<_com_IIID<IWebFramePrivate, &__uuidof(IWebFramePrivate)>> IWebFramePrivatePtr;
    5050
    51 class MiniBrowser : public RefCounted<MiniBrowser> {
     51class MiniBrowser : public BrowserWindow {
    5252public:
    53     static Ref<MiniBrowser> create(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView = false, bool pageLoadTesting = false);
     53    static Ref<BrowserWindow> create(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView = false, bool pageLoadTesting = false);
     54
     55private:
     56    friend class AccessibilityDelegate;
     57    friend class MiniBrowserWebHost;
     58    friend class PrintWebUIDelegate;
     59    friend class WebDownloadDelegate;
     60    friend class ResourceLoadDelegate;
     61    friend class PageLoadTestClient;
    5462
    5563    ULONG AddRef();
     
    6472    void showLastVisitedSites(IWebView&);
    6573    void launchInspector();
    66     void navigateForwardOrBackward(HWND hWnd, UINT menuID);
    67     void navigateToHistory(HWND hWnd, UINT menuID);
     74    void navigateForwardOrBackward(UINT menuID);
     75    void navigateToHistory(UINT menuID);
    6876    void exitProgram();
    6977    bool seedInitialDefaultPreferences();
     
    107115    void setPreference(UINT menuID, bool enable);
    108116
    109 private:
    110117    MiniBrowser(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView, bool pageLoadTesting);
    111118    void subclassForLayeredWindow();
  • trunk/Tools/MiniBrowser/win/PrintWebUIDelegate.cpp

    r232577 r232616  
    3030#include "Common.h"
    3131#include "MainWindow.h"
    32 #if USE(CF)
    33 #include <CoreFoundation/CoreFoundation.h>
    34 #endif
     32#include "MiniBrowser.h"
    3533#include <WebCore/COMPtr.h>
    3634#include <WebKitLegacy/WebKitCOMAPI.h>
     
    4240#include <wininet.h>
    4341
     42#if USE(CF)
     43#include <CoreFoundation/CoreFoundation.h>
     44#endif
     45
    4446static const int MARGIN = 20;
    4547
     
    7072    ShowWindow(newWindow.hwnd(), SW_SHOW);
    7173
    72     *newWebView = newWindow.browserWindow()->webView();
     74    auto& newBrowserWindow = *static_cast<MiniBrowser*>(newWindow.browserWindow());
     75    *newWebView = newBrowserWindow.webView();
    7376    IWebFramePtr frame;
    7477    HRESULT hr;
Note: See TracChangeset for help on using the changeset viewer.