Changeset 222059 in webkit


Ignore:
Timestamp:
Sep 14, 2017 4:37:32 PM (7 years ago)
Author:
achristensen@apple.com
Message:

Add WKUIDelegatePrivate equivalent of WKPageUIClient's drawHeader, drawFooter, headerHeight, and footerHeight
https://bugs.webkit.org/show_bug.cgi?id=176889
<rdar://problem/29270035>

Reviewed by Andy Estes.

Source/WebKit:

  • UIProcess/API/C/WKPage.cpp:

(WKPageLoadAlternateHTMLString):
(WKPageLoadAlternateHTMLStringWithUserData):

  • UIProcess/API/Cocoa/WKBrowsingContextController.mm:

(-[WKBrowsingContextController loadAlternateHTMLString:baseURL:forUnreachableURL:]):

  • UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView _loadAlternateHTMLString:baseURL:forUnreachableURL:]):

  • UIProcess/Cocoa/UIDelegate.h:
  • UIProcess/Cocoa/UIDelegate.mm:

(WebKit::UIDelegate::setDelegate):
(WebKit::UIDelegate::UIClient::headerHeight):
(WebKit::UIDelegate::UIClient::footerHeight):
(WebKit::UIDelegate::UIClient::drawHeader):
(WebKit::UIDelegate::UIClient::drawFooter):

  • UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.mm:

(-[WKReloadFrameErrorRecoveryAttempter attemptRecovery]):

  • UIProcess/Cocoa/WebViewImpl.mm:

(WebKit::WebViewImpl::printOperationWithPrintInfo):

  • UIProcess/FrameLoadState.cpp:

(WebKit::FrameLoadState::didStartProvisionalLoad):
(WebKit::FrameLoadState::didReceiveServerRedirectForProvisionalLoad):
(WebKit::FrameLoadState::didFailProvisionalLoad):
(WebKit::FrameLoadState::didCommitLoad):
(WebKit::FrameLoadState::didSameDocumentNotification):
(WebKit::FrameLoadState::setUnreachableURL):
(WebKit::FrameLoadState::FrameLoadState): Deleted.

  • UIProcess/FrameLoadState.h:

(WebKit::FrameLoadState::url const):
(WebKit::FrameLoadState::provisionalURL const):
(WebKit::FrameLoadState::unreachableURL const):

  • UIProcess/WebFrameProxy.cpp:

(WebKit::WebFrameProxy::loadURL):
(WebKit::WebFrameProxy::didStartProvisionalLoad):
(WebKit::WebFrameProxy::didReceiveServerRedirectForProvisionalLoad):
(WebKit::WebFrameProxy::didSameDocumentNavigation):
(WebKit::WebFrameProxy::setUnreachableURL):

  • UIProcess/WebFrameProxy.h:

(WebKit::WebFrameProxy::url const):
(WebKit::WebFrameProxy::provisionalURL const):
(WebKit::WebFrameProxy::unreachableURL const):

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::loadAlternateHTMLString):
(WebKit::WebPageProxy::didStartProvisionalLoadForFrame):
(WebKit::WebPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame):
(WebKit::WebPageProxy::didChangeProvisionalURLForFrame):
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame):

  • UIProcess/WebPageProxy.h:
  • UIProcess/WebPageProxy.messages.in:
  • WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:

(WebKit::WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad):
(WebKit::WebFrameLoaderClient::dispatchDidChangeProvisionalURL):
(WebKit::WebFrameLoaderClient::dispatchDidChangeLocationWithinPage):
(WebKit::WebFrameLoaderClient::dispatchDidPushStateWithinPage):
(WebKit::WebFrameLoaderClient::dispatchDidReplaceStateWithinPage):
(WebKit::WebFrameLoaderClient::dispatchDidPopStateWithinPage):
(WebKit::WebFrameLoaderClient::dispatchDidStartProvisionalLoad):

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::loadURLInFrame):

  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/WebPage.messages.in:

Tools:

  • TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:

(-[PrintDelegate _webView:printFrame:]):
(-[PrintDelegate _webViewHeaderHeight:]):
(-[PrintDelegate _webViewFooterHeight:]):
(-[PrintDelegate _webView:drawHeaderInRect:forPageWithTitle:URL:]):
(-[PrintDelegate _webView:drawFooterInRect:forPageWithTitle:URL:]):
(callbacksEqual):
(TEST):

  • TestWebKitAPI/cocoa/TestWKWebView.h:
  • TestWebKitAPI/cocoa/TestWKWebView.mm:

(-[TestWKWebView hostWindow]):

Location:
trunk
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r222053 r222059  
     12017-09-14  Alex Christensen  <achristensen@webkit.org>
     2
     3        Add WKUIDelegatePrivate equivalent of WKPageUIClient's drawHeader, drawFooter, headerHeight, and footerHeight
     4        https://bugs.webkit.org/show_bug.cgi?id=176889
     5        <rdar://problem/29270035>
     6
     7        Reviewed by Andy Estes.
     8
     9        * UIProcess/API/C/WKPage.cpp:
     10        (WKPageLoadAlternateHTMLString):
     11        (WKPageLoadAlternateHTMLStringWithUserData):
     12        * UIProcess/API/Cocoa/WKBrowsingContextController.mm:
     13        (-[WKBrowsingContextController loadAlternateHTMLString:baseURL:forUnreachableURL:]):
     14        * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
     15        * UIProcess/API/Cocoa/WKWebView.mm:
     16        (-[WKWebView _loadAlternateHTMLString:baseURL:forUnreachableURL:]):
     17        * UIProcess/Cocoa/UIDelegate.h:
     18        * UIProcess/Cocoa/UIDelegate.mm:
     19        (WebKit::UIDelegate::setDelegate):
     20        (WebKit::UIDelegate::UIClient::headerHeight):
     21        (WebKit::UIDelegate::UIClient::footerHeight):
     22        (WebKit::UIDelegate::UIClient::drawHeader):
     23        (WebKit::UIDelegate::UIClient::drawFooter):
     24        * UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.mm:
     25        (-[WKReloadFrameErrorRecoveryAttempter attemptRecovery]):
     26        * UIProcess/Cocoa/WebViewImpl.mm:
     27        (WebKit::WebViewImpl::printOperationWithPrintInfo):
     28        * UIProcess/FrameLoadState.cpp:
     29        (WebKit::FrameLoadState::didStartProvisionalLoad):
     30        (WebKit::FrameLoadState::didReceiveServerRedirectForProvisionalLoad):
     31        (WebKit::FrameLoadState::didFailProvisionalLoad):
     32        (WebKit::FrameLoadState::didCommitLoad):
     33        (WebKit::FrameLoadState::didSameDocumentNotification):
     34        (WebKit::FrameLoadState::setUnreachableURL):
     35        (WebKit::FrameLoadState::FrameLoadState): Deleted.
     36        * UIProcess/FrameLoadState.h:
     37        (WebKit::FrameLoadState::url const):
     38        (WebKit::FrameLoadState::provisionalURL const):
     39        (WebKit::FrameLoadState::unreachableURL const):
     40        * UIProcess/WebFrameProxy.cpp:
     41        (WebKit::WebFrameProxy::loadURL):
     42        (WebKit::WebFrameProxy::didStartProvisionalLoad):
     43        (WebKit::WebFrameProxy::didReceiveServerRedirectForProvisionalLoad):
     44        (WebKit::WebFrameProxy::didSameDocumentNavigation):
     45        (WebKit::WebFrameProxy::setUnreachableURL):
     46        * UIProcess/WebFrameProxy.h:
     47        (WebKit::WebFrameProxy::url const):
     48        (WebKit::WebFrameProxy::provisionalURL const):
     49        (WebKit::WebFrameProxy::unreachableURL const):
     50        * UIProcess/WebPageProxy.cpp:
     51        (WebKit::WebPageProxy::loadAlternateHTMLString):
     52        (WebKit::WebPageProxy::didStartProvisionalLoadForFrame):
     53        (WebKit::WebPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame):
     54        (WebKit::WebPageProxy::didChangeProvisionalURLForFrame):
     55        (WebKit::WebPageProxy::didSameDocumentNavigationForFrame):
     56        * UIProcess/WebPageProxy.h:
     57        * UIProcess/WebPageProxy.messages.in:
     58        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
     59        (WebKit::WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad):
     60        (WebKit::WebFrameLoaderClient::dispatchDidChangeProvisionalURL):
     61        (WebKit::WebFrameLoaderClient::dispatchDidChangeLocationWithinPage):
     62        (WebKit::WebFrameLoaderClient::dispatchDidPushStateWithinPage):
     63        (WebKit::WebFrameLoaderClient::dispatchDidReplaceStateWithinPage):
     64        (WebKit::WebFrameLoaderClient::dispatchDidPopStateWithinPage):
     65        (WebKit::WebFrameLoaderClient::dispatchDidStartProvisionalLoad):
     66        * WebProcess/WebPage/WebPage.cpp:
     67        (WebKit::WebPage::loadURLInFrame):
     68        * WebProcess/WebPage/WebPage.h:
     69        * WebProcess/WebPage/WebPage.messages.in:
     70
    1712017-09-14  Andy Estes  <aestes@apple.com>
    272
  • trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp

    r222047 r222059  
    210210void WKPageLoadAlternateHTMLString(WKPageRef pageRef, WKStringRef htmlStringRef, WKURLRef baseURLRef, WKURLRef unreachableURLRef)
    211211{
    212     toImpl(pageRef)->loadAlternateHTMLString(toWTFString(htmlStringRef), toWTFString(baseURLRef), toWTFString(unreachableURLRef));
     212    toImpl(pageRef)->loadAlternateHTMLString(toWTFString(htmlStringRef), URL(URL(), toWTFString(baseURLRef)), URL(URL(), toWTFString(unreachableURLRef)));
    213213}
    214214
    215215void WKPageLoadAlternateHTMLStringWithUserData(WKPageRef pageRef, WKStringRef htmlStringRef, WKURLRef baseURLRef, WKURLRef unreachableURLRef, WKTypeRef userDataRef)
    216216{
    217     toImpl(pageRef)->loadAlternateHTMLString(toWTFString(htmlStringRef), toWTFString(baseURLRef), toWTFString(unreachableURLRef), toImpl(userDataRef));
     217    toImpl(pageRef)->loadAlternateHTMLString(toWTFString(htmlStringRef), URL(URL(), toWTFString(baseURLRef)), URL(URL(), toWTFString(unreachableURLRef)), toImpl(userDataRef));
    218218}
    219219
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKBrowsingContextController.mm

    r222047 r222059  
    158158- (void)loadAlternateHTMLString:(NSString *)string baseURL:(NSURL *)baseURL forUnreachableURL:(NSURL *)unreachableURL
    159159{
    160     _page->loadAlternateHTMLString(string, [baseURL _web_originalDataAsWTFString], [unreachableURL _web_originalDataAsWTFString]);
     160    _page->loadAlternateHTMLString(string, baseURL, unreachableURL);
    161161}
    162162
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h

    r222047 r222059  
    162162- (void)_webView:(WKWebView *)webView getToolbarsAreVisibleWithCompletionHandler:(void(^)(BOOL))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA));
    163163- (void)_webView:(WKWebView *)webView saveDataToFile:(NSData *)data suggestedFilename:(NSString *)suggestedFilename mimeType:(NSString *)mimeType originatingURL:(NSURL *)url WK_API_AVAILABLE(macosx(WK_MAC_TBA));
     164- (CGFloat)_webViewHeaderHeight:(WKWebView *)webView WK_API_AVAILABLE(macosx(WK_MAC_TBA));
     165- (CGFloat)_webViewFooterHeight:(WKWebView *)webView WK_API_AVAILABLE(macosx(WK_MAC_TBA));
     166- (void)_webView:(WKWebView *)webView drawHeaderInRect:(CGRect)rect forPageWithTitle:(NSString *)title URL:(NSURL *)url WK_API_AVAILABLE(macosx(WK_MAC_TBA));
     167- (void)_webView:(WKWebView *)webView drawFooterInRect:(CGRect)rect forPageWithTitle:(NSString *)title URL:(NSURL *)url WK_API_AVAILABLE(macosx(WK_MAC_TBA));
    164168- (void)_webView:(WKWebView *)webView requestNotificationPermissionForSecurityOrigin:(WKSecurityOrigin *)securityOrigin decisionHandler:(void (^)(BOOL))decisionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA));
    165169- (void)_webView:(WKWebView *)webview mouseDidMoveOverElement:(_WKHitTestResult *)hitTestResult withFlags:(NSEventModifierFlags)flags userInfo:(id <NSSecureCoding>)userInfo;
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

    r222047 r222059  
    38403840- (void)_loadAlternateHTMLString:(NSString *)string baseURL:(NSURL *)baseURL forUnreachableURL:(NSURL *)unreachableURL
    38413841{
    3842     _page->loadAlternateHTMLString(string, [baseURL _web_originalDataAsWTFString], [unreachableURL _web_originalDataAsWTFString]);
     3842    _page->loadAlternateHTMLString(string, baseURL, unreachableURL);
    38433843}
    38443844
  • trunk/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp

    r222047 r222059  
    6666#include <WebCore/JSDOMExceptionHandling.h>
    6767#include <WebCore/RefPtrCairo.h>
     68#include <WebCore/URL.h>
    6869#include <glib/gi18n-lib.h>
    6970#include <wtf/SetForScope.h>
     
    24922493    g_return_if_fail(contentURI);
    24932494
    2494     getPage(webView).loadAlternateHTMLString(String::fromUTF8(content), String::fromUTF8(baseURI), String::fromUTF8(contentURI));
     2495    getPage(webView).loadAlternateHTMLString(String::fromUTF8(content), URL(URL(), String::fromUTF8(baseURI)), URL(URL(), String::fromUTF8(contentURI)));
    24952496}
    24962497
     
    26282629    g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
    26292630
    2630     getPage(webView).reload(WebCore::ReloadOption::FromOrigin);
     2631    getPage(webView).reload(ReloadOption::FromOrigin);
    26312632}
    26322633
     
    31563157}
    31573158
    3158 static void webkitWebViewRunJavaScriptCallback(API::SerializedScriptValue* wkSerializedScriptValue, const WebCore::ExceptionDetails& exceptionDetails, GTask* task)
     3159static void webkitWebViewRunJavaScriptCallback(API::SerializedScriptValue* wkSerializedScriptValue, const ExceptionDetails& exceptionDetails, GTask* task)
    31593160{
    31603161    if (g_task_return_error_if_cancelled(task))
     
    32073208
    32083209    GTask* task = g_task_new(webView, cancellable, callback, userData);
    3209     getPage(webView).runJavaScriptInMainFrame(String::fromUTF8(script), true, [task](API::SerializedScriptValue* serializedScriptValue, bool, const WebCore::ExceptionDetails& exceptionDetails, WebKit::CallbackBase::Error) {
     3210    getPage(webView).runJavaScriptInMainFrame(String::fromUTF8(script), true, [task](API::SerializedScriptValue* serializedScriptValue, bool, const ExceptionDetails& exceptionDetails, WebKit::CallbackBase::Error) {
    32103211        webkitWebViewRunJavaScriptCallback(serializedScriptValue, exceptionDetails, adoptGRef(task).get());
    32113212    });
     
    32983299    gpointer outputStreamData = g_memory_output_stream_get_data(G_MEMORY_OUTPUT_STREAM(object));
    32993300    getPage(webView).runJavaScriptInMainFrame(String::fromUTF8(reinterpret_cast<const gchar*>(outputStreamData)), true,
    3300         [task](API::SerializedScriptValue* serializedScriptValue, bool, const WebCore::ExceptionDetails& exceptionDetails, WebKit::CallbackBase::Error) {
     3301        [task](API::SerializedScriptValue* serializedScriptValue, bool, const ExceptionDetails& exceptionDetails, WebKit::CallbackBase::Error) {
    33013302            webkitWebViewRunJavaScriptCallback(serializedScriptValue, exceptionDetails, task.get());
    33023303        });
  • trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h

    r222047 r222059  
    106106        void windowFrame(WebPageProxy&, Function<void(WebCore::FloatRect)>&&) final;
    107107        void didNotHandleWheelEvent(WebPageProxy*, const NativeWebWheelEvent&) final;
     108        float headerHeight(WebPageProxy&, WebFrameProxy&) final;
     109        float footerHeight(WebPageProxy&, WebFrameProxy&) final;
     110        void drawHeader(WebPageProxy&, WebFrameProxy&, WebCore::FloatRect&&) final;
     111        void drawFooter(WebPageProxy&, WebFrameProxy&, WebCore::FloatRect&&) final;
    108112        void decidePolicyForNotificationPermissionRequest(WebPageProxy&, API::SecurityOrigin&, Function<void(bool)>&&) final;
    109113        void handleAutoplayEvent(WebPageProxy&, WebCore::AutoplayEvent, OptionSet<WebCore::AutoplayEventFlags>) final;
     
    161165        bool webViewTakeFocus : 1;
    162166        bool webViewDidScroll : 1;
     167        bool webViewHeaderHeight : 1;
     168        bool webViewFooterHeight : 1;
    163169        bool webViewSetResizable : 1;
    164170        bool webViewSetWindowFrame : 1;
     
    167173        bool webViewUnavailablePlugInButtonClicked : 1;
    168174        bool webViewDidClickAutoFillButtonWithUserInfo : 1;
     175        bool webViewDrawHeaderInRectForPageWithTitleURL : 1;
     176        bool webViewDrawFooterInRectForPageWithTitleURL : 1;
    169177        bool webViewGetWindowFrameWithCompletionHandler : 1;
    170178        bool webViewMouseDidMoveOverElementWithFlagsUserInfo : 1;
  • trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm

    r222047 r222059  
    121121    m_delegateMethods.webViewHandleAutoplayEventWithFlags = [delegate respondsToSelector:@selector(_webView:handleAutoplayEvent:withFlags:)];
    122122    m_delegateMethods.webViewDidClickAutoFillButtonWithUserInfo = [delegate respondsToSelector:@selector(_webView:didClickAutoFillButtonWithUserInfo:)];
     123    m_delegateMethods.webViewDrawHeaderInRectForPageWithTitleURL = [delegate respondsToSelector:@selector(_webView:drawHeaderInRect:forPageWithTitle:URL:)];
     124    m_delegateMethods.webViewDrawFooterInRectForPageWithTitleURL = [delegate respondsToSelector:@selector(_webView:drawFooterInRect:forPageWithTitle:URL:)];
     125    m_delegateMethods.webViewHeaderHeight = [delegate respondsToSelector:@selector(_webViewHeaderHeight:)];
     126    m_delegateMethods.webViewFooterHeight = [delegate respondsToSelector:@selector(_webViewFooterHeight:)];
    123127    m_delegateMethods.webViewMouseDidMoveOverElementWithFlagsUserInfo = [delegate respondsToSelector:@selector(_webView:mouseDidMoveOverElement:withFlags:userInfo:)];
    124128    m_delegateMethods.webViewDidExceedBackgroundResourceLimitWhileInForeground = [delegate respondsToSelector:@selector(_webView:didExceedBackgroundResourceLimitWhileInForeground:)];
     
    422426
    423427    [(id <WKUIDelegatePrivate>)delegate _webViewRunModal:m_uiDelegate.m_webView];
     428}
     429
     430float UIDelegate::UIClient::headerHeight(WebPageProxy&, WebFrameProxy& webFrameProxy)
     431{
     432    if (!m_uiDelegate.m_delegateMethods.webViewHeaderHeight)
     433        return 0;
     434   
     435    auto delegate = m_uiDelegate.m_delegate.get();
     436    if (!delegate)
     437        return 0;
     438   
     439    return [(id <WKUIDelegatePrivate>)delegate _webViewHeaderHeight:m_uiDelegate.m_webView];
     440}
     441
     442float UIDelegate::UIClient::footerHeight(WebPageProxy&, WebFrameProxy&)
     443{
     444    if (!m_uiDelegate.m_delegateMethods.webViewFooterHeight)
     445        return 0;
     446   
     447    auto delegate = m_uiDelegate.m_delegate.get();
     448    if (!delegate)
     449        return 0;
     450   
     451    return [(id <WKUIDelegatePrivate>)delegate _webViewFooterHeight:m_uiDelegate.m_webView];
     452}
     453
     454void UIDelegate::UIClient::drawHeader(WebPageProxy&, WebFrameProxy& frame, WebCore::FloatRect&& rect)
     455{
     456    if (!m_uiDelegate.m_delegateMethods.webViewDrawHeaderInRectForPageWithTitleURL)
     457        return;
     458   
     459    auto delegate = m_uiDelegate.m_delegate.get();
     460    if (!delegate)
     461        return;
     462   
     463    [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView drawHeaderInRect:rect forPageWithTitle:frame.title() URL:frame.url()];
     464}
     465
     466void UIDelegate::UIClient::drawFooter(WebPageProxy&, WebFrameProxy& frame, WebCore::FloatRect&& rect)
     467{
     468    if (!m_uiDelegate.m_delegateMethods.webViewDrawFooterInRectForPageWithTitleURL)
     469        return;
     470   
     471    auto delegate = m_uiDelegate.m_delegate.get();
     472    if (!delegate)
     473        return;
     474   
     475    [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView drawFooterInRect:rect forPageWithTitle:frame.title() URL:frame.url()];
    424476}
    425477
  • trunk/Source/WebKit/UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.mm

    r222047 r222059  
    7070        return NO;
    7171
    72     webFrameProxy->loadURL(_urlString);
     72    webFrameProxy->loadURL(WebCore::URL(WebCore::URL(), _urlString));
    7373    return YES;
    7474}
  • trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm

    r222047 r222059  
    16251625NSPrintOperation *WebViewImpl::printOperationWithPrintInfo(NSPrintInfo *printInfo, WebFrameProxy& frame)
    16261626{
    1627     LOG(Printing, "Creating an NSPrintOperation for frame '%s'", frame.url().utf8().data());
     1627    LOG(Printing, "Creating an NSPrintOperation for frame '%s'", frame.url().string().utf8().data());
    16281628
    16291629    // FIXME: If the frame cannot be printed (e.g. if it contains an encrypted PDF that disallows
  • trunk/Source/WebKit/UIProcess/FrameLoadState.cpp

    r222047 r222059  
    2929namespace WebKit {
    3030
    31 FrameLoadState::FrameLoadState()
    32     : m_state(State::Finished)
    33 {
    34 }
    35 
    3631FrameLoadState::~FrameLoadState()
    3732{
    3833}
    3934
    40 void FrameLoadState::didStartProvisionalLoad(const String& url)
     35void FrameLoadState::didStartProvisionalLoad(const WebCore::URL& url)
    4136{
    4237    ASSERT(m_provisionalURL.isEmpty());
     
    4641}
    4742
    48 void FrameLoadState::didReceiveServerRedirectForProvisionalLoad(const String& url)
     43void FrameLoadState::didReceiveServerRedirectForProvisionalLoad(const WebCore::URL& url)
    4944{
    5045    ASSERT(m_state == State::Provisional);
     
    5853
    5954    m_state = State::Finished;
    60     m_provisionalURL = String();
     55    m_provisionalURL = { };
    6156    m_unreachableURL = m_lastUnreachableURL;
    6257}
     
    6863    m_state = State::Committed;
    6964    m_url = m_provisionalURL;
    70     m_provisionalURL = String();
     65    m_provisionalURL = { };
    7166}
    7267
     
    8782}
    8883
    89 void FrameLoadState::didSameDocumentNotification(const String& url)
     84void FrameLoadState::didSameDocumentNotification(const WebCore::URL& url)
    9085{
    9186    m_url = url;
    9287}
    9388
    94 void FrameLoadState::setUnreachableURL(const String& unreachableURL)
     89void FrameLoadState::setUnreachableURL(const WebCore::URL& unreachableURL)
    9590{
    9691    m_lastUnreachableURL = m_unreachableURL;
  • trunk/Source/WebKit/UIProcess/FrameLoadState.h

    r222047 r222059  
    2424 */
    2525
    26 #ifndef FrameLoadState_h
    27 #define FrameLoadState_h
     26#pragma once
    2827
    29 #include <wtf/text/WTFString.h>
     28#include <WebCore/URL.h>
    3029
    3130namespace WebKit {
     
    3332class FrameLoadState {
    3433public:
    35     FrameLoadState();
    3634    ~FrameLoadState();
    3735
     
    4240    };
    4341
    44     void didStartProvisionalLoad(const String& url);
    45     void didReceiveServerRedirectForProvisionalLoad(const String& url);
     42    void didStartProvisionalLoad(const WebCore::URL&);
     43    void didReceiveServerRedirectForProvisionalLoad(const WebCore::URL&);
    4644    void didFailProvisionalLoad();
    4745
     
    5048    void didFailLoad();
    5149
    52     void didSameDocumentNotification(const String&);
     50    void didSameDocumentNotification(const WebCore::URL&);
    5351
    5452    State state() const { return m_state; }
    55     const String& url() const { return m_url; }
    56     const String& provisionalURL() const { return m_provisionalURL; }
     53    const WebCore::URL& url() const { return m_url; }
     54    const WebCore::URL& provisionalURL() const { return m_provisionalURL; }
    5755
    58     void setUnreachableURL(const String&);
    59     const String& unreachableURL() const { return m_unreachableURL; }
     56    void setUnreachableURL(const WebCore::URL&);
     57    const WebCore::URL& unreachableURL() const { return m_unreachableURL; }
    6058
    6159private:
    62     State m_state;
    63     String m_url;
    64     String m_provisionalURL;
    65     String m_unreachableURL;
    66     String m_lastUnreachableURL;
     60    State m_state { State::Finished };
     61    WebCore::URL m_url;
     62    WebCore::URL m_provisionalURL;
     63    WebCore::URL m_unreachableURL;
     64    WebCore::URL m_lastUnreachableURL;
    6765};
    6866
    6967} // namespace WebKit
    70 
    71 #endif // FrameLoadState_h
  • trunk/Source/WebKit/UIProcess/WebFrameProxy.cpp

    r222047 r222059  
    7777}
    7878
    79 void WebFrameProxy::loadURL(const String& url)
     79void WebFrameProxy::loadURL(const URL& url)
    8080{
    8181    if (!m_page)
     
    131131}
    132132
    133 void WebFrameProxy::didStartProvisionalLoad(const String& url)
     133void WebFrameProxy::didStartProvisionalLoad(const URL& url)
    134134{
    135135    m_frameLoadState.didStartProvisionalLoad(url);
    136136}
    137137
    138 void WebFrameProxy::didReceiveServerRedirectForProvisionalLoad(const String& url)
     138void WebFrameProxy::didReceiveServerRedirectForProvisionalLoad(const URL& url)
    139139{
    140140    m_frameLoadState.didReceiveServerRedirectForProvisionalLoad(url);
     
    167167}
    168168
    169 void WebFrameProxy::didSameDocumentNavigation(const String& url)
     169void WebFrameProxy::didSameDocumentNavigation(const URL& url)
    170170{
    171171    m_frameLoadState.didSameDocumentNotification(url);
     
    177177}
    178178
    179 void WebFrameProxy::receivedPolicyDecision(WebCore::PolicyAction action, uint64_t listenerID, API::Navigation* navigation, const WebsitePolicies& websitePolicies)
     179void WebFrameProxy::receivedPolicyDecision(PolicyAction action, uint64_t listenerID, API::Navigation* navigation, const WebsitePolicies& websitePolicies)
    180180{
    181181    if (!m_page)
     
    233233}
    234234
    235 void WebFrameProxy::setUnreachableURL(const String& unreachableURL)
     235void WebFrameProxy::setUnreachableURL(const URL& unreachableURL)
    236236{
    237237    m_frameLoadState.setUnreachableURL(unreachableURL);
     
    239239
    240240#if ENABLE(CONTENT_FILTERING)
    241 bool WebFrameProxy::didHandleContentFilterUnblockNavigation(const WebCore::ResourceRequest& request)
     241bool WebFrameProxy::didHandleContentFilterUnblockNavigation(const ResourceRequest& request)
    242242{
    243243    if (!m_contentFilterUnblockHandler.canHandleRequest(request)) {
  • trunk/Source/WebKit/UIProcess/WebFrameProxy.h

    r222047 r222059  
    7878    FrameLoadState& frameLoadState() { return m_frameLoadState; }
    7979
    80     void loadURL(const String&);
     80    void loadURL(const WebCore::URL&);
    8181    void stopLoading() const;
    8282
    83     const String& url() const { return m_frameLoadState.url(); }
    84     const String& provisionalURL() const { return m_frameLoadState.provisionalURL(); }
     83    const WebCore::URL& url() const { return m_frameLoadState.url(); }
     84    const WebCore::URL& provisionalURL() const { return m_frameLoadState.provisionalURL(); }
    8585
    86     void setUnreachableURL(const String&);
    87     const String& unreachableURL() const { return m_frameLoadState.unreachableURL(); }
     86    void setUnreachableURL(const WebCore::URL&);
     87    const WebCore::URL& unreachableURL() const { return m_frameLoadState.unreachableURL(); }
    8888
    8989    const String& mimeType() const { return m_MIMEType; }
     
    106106    void getResourceData(API::URL*, Function<void (API::Data*, CallbackBase::Error)>&&);
    107107
    108     void didStartProvisionalLoad(const String& url);
    109     void didReceiveServerRedirectForProvisionalLoad(const String& url);
     108    void didStartProvisionalLoad(const WebCore::URL&);
     109    void didReceiveServerRedirectForProvisionalLoad(const WebCore::URL&);
    110110    void didFailProvisionalLoad();
    111111    void didCommitLoad(const String& contentType, WebCertificateInfo&, bool containsPluginDocument);
    112112    void didFinishLoad();
    113113    void didFailLoad();
    114     void didSameDocumentNavigation(const String&); // eg. anchor navigation, session state change.
     114    void didSameDocumentNavigation(const WebCore::URL&); // eg. anchor navigation, session state change.
    115115    void didChangeTitle(const String&);
    116116
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r222047 r222059  
    962962}
    963963
    964 void WebPageProxy::loadAlternateHTMLString(const String& htmlString, const String& baseURL, const String& unreachableURL, API::Object* userData)
     964void WebPageProxy::loadAlternateHTMLString(const String& htmlString, const WebCore::URL& baseURL, const WebCore::URL& unreachableURL, API::Object* userData)
    965965{
    966966    // When the UIProcess is in the process of handling a failing provisional load, do not attempt to
     
    31473147}
    31483148
    3149 void WebPageProxy::didStartProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, const String& url, const String& unreachableURL, const UserData& userData)
     3149void WebPageProxy::didStartProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, WebCore::URL&& url, WebCore::URL&& unreachableURL, const UserData& userData)
    31503150{
    31513151    PageClientProtector protector(m_pageClient);
     
    31813181}
    31823182
    3183 void WebPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, const String& url, const UserData& userData)
     3183void WebPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, WebCore::URL&& url, const UserData& userData)
    31843184{
    31853185    PageClientProtector protector(m_pageClient);
     
    32353235}
    32363236
    3237 void WebPageProxy::didChangeProvisionalURLForFrame(uint64_t frameID, uint64_t, const String& url)
     3237void WebPageProxy::didChangeProvisionalURLForFrame(uint64_t frameID, uint64_t, WebCore::URL&& url)
    32383238{
    32393239    PageClientProtector protector(m_pageClient);
     
    34833483}
    34843484
    3485 void WebPageProxy::didSameDocumentNavigationForFrame(uint64_t frameID, uint64_t navigationID, uint32_t opaqueSameDocumentNavigationType, const String& url, const UserData& userData)
     3485void WebPageProxy::didSameDocumentNavigationForFrame(uint64_t frameID, uint64_t navigationID, uint32_t opaqueSameDocumentNavigationType, WebCore::URL&& url, const UserData& userData)
    34863486{
    34873487    PageClientProtector protector(m_pageClient);
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r222047 r222059  
    396396    RefPtr<API::Navigation> loadData(API::Data*, const String& MIMEType, const String& encoding, const String& baseURL, API::Object* userData = nullptr);
    397397    RefPtr<API::Navigation> loadHTMLString(const String& htmlString, const String& baseURL, API::Object* userData = nullptr);
    398     void loadAlternateHTMLString(const String& htmlString, const String& baseURL, const String& unreachableURL, API::Object* userData = nullptr);
     398    void loadAlternateHTMLString(const String& htmlString, const WebCore::URL& baseURL, const WebCore::URL& unreachableURL, API::Object* userData = nullptr);
    399399    void loadPlainTextString(const String&, API::Object* userData = nullptr);
    400400    void loadWebArchiveData(API::Data*, API::Object* userData = nullptr);
     
    12491249    void didCreateSubframe(uint64_t frameID);
    12501250
    1251     void didStartProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, const String& url, const String& unreachableURL, const UserData&);
    1252     void didReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, const String&, const UserData&);
     1251    void didStartProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, WebCore::URL&&, WebCore::URL&& unreachableURL, const UserData&);
     1252    void didReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, WebCore::URL&&, const UserData&);
    12531253    void willPerformClientRedirectForFrame(uint64_t frameID, const String& url, double delay);
    12541254    void didCancelClientRedirectForFrame(uint64_t frameID);
    1255     void didChangeProvisionalURLForFrame(uint64_t frameID, uint64_t navigationID, const String& url);
     1255    void didChangeProvisionalURLForFrame(uint64_t frameID, uint64_t navigationID, WebCore::URL&&);
    12561256    void didFailProvisionalLoadForFrame(uint64_t frameID, const WebCore::SecurityOriginData& frameSecurityOrigin, uint64_t navigationID, const String& provisionalURL, const WebCore::ResourceError&, const UserData&);
    12571257    void didCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, const String& mimeType, bool frameHasCustomContentProvider, uint32_t frameLoadType, const WebCore::CertificateInfo&, bool containsPluginDocument, std::optional<WebCore::HasInsecureContent> forcedHasInsecureContent, const UserData&);
     
    12591259    void didFinishLoadForFrame(uint64_t frameID, uint64_t navigationID, const UserData&);
    12601260    void didFailLoadForFrame(uint64_t frameID, uint64_t navigationID, const WebCore::ResourceError&, const UserData&);
    1261     void didSameDocumentNavigationForFrame(uint64_t frameID, uint64_t navigationID, uint32_t sameDocumentNavigationType, const String&, const UserData&);
     1261    void didSameDocumentNavigationForFrame(uint64_t frameID, uint64_t navigationID, uint32_t sameDocumentNavigationType, WebCore::URL&&, const UserData&);
    12621262    void didChangeMainDocument(uint64_t frameID);
    12631263
  • trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in

    r222047 r222059  
    116116
    117117    # Frame load messages
    118     DidStartProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, String url, String unreachableURL, WebKit::UserData userData)
    119     DidReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, String url, WebKit::UserData userData)
     118    DidStartProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, WebCore::URL url, WebCore::URL unreachableURL, WebKit::UserData userData)
     119    DidReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, WebCore::URL url, WebKit::UserData userData)
    120120    WillPerformClientRedirectForFrame(uint64_t frameID, String url, double delay)
    121121    DidCancelClientRedirectForFrame(uint64_t frameID)
    122     DidChangeProvisionalURLForFrame(uint64_t frameID, uint64_t navigationID, String url)
     122    DidChangeProvisionalURLForFrame(uint64_t frameID, uint64_t navigationID, WebCore::URL url)
    123123    DidFailProvisionalLoadForFrame(uint64_t frameID, struct WebCore::SecurityOriginData frameSecurityOrigin, uint64_t navigationID, String provisionalURL, WebCore::ResourceError error, WebKit::UserData userData)
    124124    DidCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, String mimeType, bool hasCustomContentProvider, uint32_t loadType, WebCore::CertificateInfo certificateInfo, bool containsPluginDocument, std::optional<WebCore::HasInsecureContent> forcedHasInsecureContent, WebKit::UserData userData)
     
    133133    DidRunInsecureContentForFrame(uint64_t frameID, WebKit::UserData userData)
    134134    DidDetectXSSForFrame(uint64_t frameID, WebKit::UserData userData)
    135     DidSameDocumentNavigationForFrame(uint64_t frameID, uint64_t navigationID, uint32_t type, String url, WebKit::UserData userData)
     135    DidSameDocumentNavigationForFrame(uint64_t frameID, uint64_t navigationID, uint32_t type, WebCore::URL url, WebKit::UserData userData)
    136136    DidChangeMainDocument(uint64_t frameID);
    137137    DidDestroyNavigation(uint64_t navigationID)
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

    r222047 r222059  
    280280
    281281    WebDocumentLoader& documentLoader = static_cast<WebDocumentLoader&>(*m_frame->coreFrame()->loader().provisionalDocumentLoader());
    282     const String& url = documentLoader.url().string();
    283282    RefPtr<API::Object> userData;
    284283
     
    287286
    288287    // Notify the UIProcess.
    289     webPage->send(Messages::WebPageProxy::DidReceiveServerRedirectForProvisionalLoadForFrame(m_frame->frameID(), documentLoader.navigationID(), url, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
     288    webPage->send(Messages::WebPageProxy::DidReceiveServerRedirectForProvisionalLoadForFrame(m_frame->frameID(), documentLoader.navigationID(), documentLoader.url(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
    290289}
    291290
     
    297296
    298297    WebDocumentLoader& documentLoader = static_cast<WebDocumentLoader&>(*m_frame->coreFrame()->loader().provisionalDocumentLoader());
    299     webPage->send(Messages::WebPageProxy::DidChangeProvisionalURLForFrame(m_frame->frameID(), documentLoader.navigationID(), documentLoader.url().string()));
     298    webPage->send(Messages::WebPageProxy::DidChangeProvisionalURLForFrame(m_frame->frameID(), documentLoader.navigationID(), documentLoader.url()));
    300299}
    301300
     
    340339
    341340    // Notify the UIProcess.
    342     webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), navigationID, SameDocumentNavigationAnchorNavigation, m_frame->coreFrame()->document()->url().string(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
     341    webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), navigationID, SameDocumentNavigationAnchorNavigation, m_frame->coreFrame()->document()->url(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
    343342}
    344343
     
    366365
    367366    // Notify the UIProcess.
    368     webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), navigationID, SameDocumentNavigationSessionStatePush, m_frame->coreFrame()->document()->url().string(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
     367    webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), navigationID, SameDocumentNavigationSessionStatePush, m_frame->coreFrame()->document()->url(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
    369368}
    370369
     
    383382
    384383    // Notify the UIProcess.
    385     webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), navigationID, SameDocumentNavigationSessionStateReplace, m_frame->coreFrame()->document()->url().string(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
     384    webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), navigationID, SameDocumentNavigationSessionStateReplace, m_frame->coreFrame()->document()->url(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
    386385}
    387386
     
    400399
    401400    // Notify the UIProcess.
    402     webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), navigationID, SameDocumentNavigationSessionStatePop, m_frame->coreFrame()->document()->url().string(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
     401    webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), navigationID, SameDocumentNavigationSessionStatePop, m_frame->coreFrame()->document()->url(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
    403402}
    404403
     
    424423
    425424    WebDocumentLoader& provisionalLoader = static_cast<WebDocumentLoader&>(*m_frame->coreFrame()->loader().provisionalDocumentLoader());
    426     const String& url = provisionalLoader.url().string();
     425    auto& url = provisionalLoader.url();
    427426    RefPtr<API::Object> userData;
    428427
     
    430429    webPage->injectedBundleLoaderClient().didStartProvisionalLoadForFrame(*webPage, *m_frame, userData);
    431430
    432     String unreachableURL = provisionalLoader.unreachableURL().string();
     431    auto& unreachableURL = provisionalLoader.unreachableURL();
    433432
    434433    // Notify the UIProcess.
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r222047 r222059  
    11771177}
    11781178
    1179 void WebPage::loadURLInFrame(const String& url, uint64_t frameID)
     1179void WebPage::loadURLInFrame(WebCore::URL&& url, uint64_t frameID)
    11801180{
    11811181    WebFrame* frame = WebProcess::singleton().webFrame(frameID);
     
    11831183        return;
    11841184
    1185     frame->coreFrame()->loader().load(FrameLoadRequest(*frame->coreFrame(), ResourceRequest(URL(URL(), url)), ShouldOpenExternalURLsPolicy::ShouldNotAllow));
     1185    frame->coreFrame()->loader().load(FrameLoadRequest(*frame->coreFrame(), ResourceRequest(url), ShouldOpenExternalURLsPolicy::ShouldNotAllow));
    11861186}
    11871187
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r222047 r222059  
    10961096    static bool logicalScroll(WebCore::Page*, WebCore::ScrollLogicalDirection, WebCore::ScrollGranularity);
    10971097
    1098     void loadURLInFrame(const String&, uint64_t frameID);
     1098    void loadURLInFrame(WebCore::URL&&, uint64_t frameID);
    10991099
    11001100    enum class WasRestoredByAPIRequest { No, Yes };
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in

    r222047 r222059  
    133133    TryRestoreScrollPosition()
    134134
    135     LoadURLInFrame(String url, uint64_t frameID)
     135    LoadURLInFrame(WebCore::URL url, uint64_t frameID)
    136136    LoadRequest(struct WebKit::LoadParameters loadParameters)
    137137    LoadData(struct WebKit::LoadParameters loadParameters)
  • trunk/Tools/ChangeLog

    r222047 r222059  
     12017-09-14  Alex Christensen  <achristensen@webkit.org>
     2
     3        Add WKUIDelegatePrivate equivalent of WKPageUIClient's drawHeader, drawFooter, headerHeight, and footerHeight
     4        https://bugs.webkit.org/show_bug.cgi?id=176889
     5        <rdar://problem/29270035>
     6
     7        Reviewed by Andy Estes.
     8
     9        * TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:
     10        (-[PrintDelegate _webView:printFrame:]):
     11        (-[PrintDelegate _webViewHeaderHeight:]):
     12        (-[PrintDelegate _webViewFooterHeight:]):
     13        (-[PrintDelegate _webView:drawHeaderInRect:forPageWithTitle:URL:]):
     14        (-[PrintDelegate _webView:drawFooterInRect:forPageWithTitle:URL:]):
     15        (callbacksEqual):
     16        (TEST):
     17        * TestWebKitAPI/cocoa/TestWKWebView.h:
     18        * TestWebKitAPI/cocoa/TestWKWebView.mm:
     19        (-[TestWKWebView hostWindow]):
     20
    1212017-09-14  Ryan Haddad  <ryanhaddad@apple.com>
    222
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm

    r222047 r222059  
    4242#import <WebKit/_WKHitTestResult.h>
    4343#import <wtf/RetainPtr.h>
     44#import <wtf/Vector.h>
    4445
    4546#if PLATFORM(MAC)
     
    283284}
    284285
     286static bool headerHeightCalled;
     287static bool footerHeightCalled;
     288static bool drawHeaderCalled;
     289static bool drawFooterCalled;
     290
     291@interface PrintDelegate : NSObject <WKUIDelegatePrivate>
     292@end
     293
     294@implementation PrintDelegate
     295
     296- (void)_webView:(WKWebView *)webView printFrame:(_WKFrameHandle *)frame
     297{
     298    done = true;
     299}
     300
     301- (CGFloat)_webViewHeaderHeight:(WKWebView *)webView
     302{
     303    headerHeightCalled = true;
     304    return 3.14159;
     305}
     306
     307- (CGFloat)_webViewFooterHeight:(WKWebView *)webView
     308{
     309    footerHeightCalled = true;
     310    return 2.71828;
     311}
     312
     313- (void)_webView:(WKWebView *)webView drawHeaderInRect:(CGRect)rect forPageWithTitle:(NSString *)title URL:(NSURL *)url
     314{
     315    EXPECT_EQ(rect.origin.x, 72);
     316    EXPECT_TRUE(fabs(rect.origin.y - 698.858398) < .00001);
     317    EXPECT_TRUE(fabs(rect.size.height - 3.141590) < .00001);
     318    EXPECT_EQ(rect.size.width, 468.000000);
     319    EXPECT_STREQ(title.UTF8String, "test_title");
     320    EXPECT_STREQ(url.absoluteString.UTF8String, "http://example.com/");
     321    drawHeaderCalled = true;
     322}
     323
     324- (void)_webView:(WKWebView *)webView drawFooterInRect:(CGRect)rect forPageWithTitle:(NSString *)title URL:(NSURL *)url
     325{
     326    EXPECT_EQ(rect.origin.x, 72);
     327    EXPECT_EQ(rect.origin.y, 90);
     328    EXPECT_TRUE(fabs(rect.size.height - 2.718280) < .00001);
     329    EXPECT_EQ(rect.size.width, 468.000000);
     330    EXPECT_STREQ(url.absoluteString.UTF8String, "http://example.com/");
     331    drawFooterCalled = true;
     332}
     333
     334@end
     335
     336TEST(WebKit, PrintFrame)
     337{
     338    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
     339    auto delegate = adoptNS([[PrintDelegate alloc] init]);
     340    [webView setUIDelegate:delegate.get()];
     341    [webView loadHTMLString:@"<head><title>test_title</title></head><body onload='print()'>hello world!</body>" baseURL:[NSURL URLWithString:@"http://example.com/"]];
     342    TestWebKitAPI::Util::run(&done);
     343
     344    NSPrintOperation *operation = [webView _printOperationWithPrintInfo:[NSPrintInfo sharedPrintInfo]];
     345    EXPECT_TRUE(operation.canSpawnSeparateThread);
     346    EXPECT_STREQ(operation.jobTitle.UTF8String, "test_title");
     347
     348    [operation runOperationModalForWindow:[webView hostWindow] delegate:nil didRunSelector:nil contextInfo:nil];
     349    TestWebKitAPI::Util::run(&headerHeightCalled);
     350    TestWebKitAPI::Util::run(&footerHeightCalled);
     351    TestWebKitAPI::Util::run(&drawHeaderCalled);
     352    TestWebKitAPI::Util::run(&drawFooterCalled);
     353}
     354
    285355@interface NotificationDelegate : NSObject <WKUIDelegatePrivate> {
    286356    bool _allowNotifications;
  • trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h

    r222047 r222059  
    6767- (void)sendClicksAtPoint:(NSPoint)point numberOfClicks:(NSUInteger)numberOfClicks;
    6868- (void)typeCharacter:(char)character;
     69- (NSWindow *)hostWindow;
    6970@end
    7071#endif
  • trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm

    r222047 r222059  
    350350}
    351351
     352- (NSWindow *)hostWindow
     353{
     354    return _hostWindow.get();
     355}
     356
    352357- (void)typeCharacter:(char)character {
    353358    NSString *characterAsString = [NSString stringWithFormat:@"%c" , character];
Note: See TracChangeset for help on using the changeset viewer.