⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 249240 in webkit


Ignore:
Timestamp:
Aug 28, 2019, 10:57:14 PM (7 years ago)
Author:
Kocsen Chung
Message:

Cherry-pick r249224. rdar://problem/54819205

Null check webFrame when creating a print preview to prevent a crash.
https://bugs.webkit.org/show_bug.cgi?id=201237
<rdar://problem/51618863>

Reviewed by Tim Horton.

Source/WebKit:

Move and expend a null check to keep from crashing when making a print preview.

  • UIProcess/mac/WKPrintingView.mm: (-[WKPrintingView _drawPreview:]): (-[WKPrintingView drawRect:]):

Tools:

Test to verify that if we don't have the WebPageProxy, we will not crash when making a print preview.

  • TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm: (TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249224 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-608-branch
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-608-branch/Source/WebKit/ChangeLog

    r249167 r249240  
     12019-08-28  Kocsen Chung  <kocsen_chung@apple.com>
     2
     3        Cherry-pick r249224. rdar://problem/54819205
     4
     5    Null check webFrame when creating a print preview to prevent a crash.
     6    https://bugs.webkit.org/show_bug.cgi?id=201237
     7    <rdar://problem/51618863>
     8   
     9    Reviewed by Tim Horton.
     10   
     11    Source/WebKit:
     12   
     13    Move and expend a null check to keep from crashing when making a print preview.
     14   
     15    * UIProcess/mac/WKPrintingView.mm:
     16    (-[WKPrintingView _drawPreview:]):
     17    (-[WKPrintingView drawRect:]):
     18   
     19    Tools:
     20   
     21    Test to verify that if we don't have the WebPageProxy, we will not crash when making a print preview.
     22   
     23    * TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:
     24    (TEST):
     25   
     26   
     27    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249224 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     28
     29    2019-08-28  Megan Gardner  <megan_gardner@apple.com>
     30
     31            Null check webFrame when creating a print preview to prevent a crash.
     32            https://bugs.webkit.org/show_bug.cgi?id=201237
     33            <rdar://problem/51618863>
     34
     35            Reviewed by Tim Horton.
     36
     37            Move and expend a null check to keep from crashing when making a print preview.
     38
     39            * UIProcess/mac/WKPrintingView.mm:
     40            (-[WKPrintingView _drawPreview:]):
     41            (-[WKPrintingView drawRect:]):
     42
    1432019-08-27  Alan Coon  <alancoon@apple.com>
    244
  • branches/safari-608-branch/Source/WebKit/UIProcess/mac/WKPrintingView.mm

    r244202 r249240  
    505505{
    506506    ASSERT(RunLoop::isMain());
     507   
     508    if (!_webFrame || !_webFrame->page())
     509        return;
    507510
    508511    WebCore::IntRect scaledPrintingRect(nsRect);
     
    520523            } else {
    521524                // Preview isn't available yet, request it asynchronously.
    522                 if (!_webFrame->page())
    523                     return;
    524 
    525525                // Return to printing mode if we're already back to screen (e.g. due to window resizing).
    526526                _webFrame->page()->beginPrinting(_webFrame.get(), WebKit::PrintInfo([_printOperation printInfo]));
  • branches/safari-608-branch/Tools/ChangeLog

    r248844 r249240  
     12019-08-28  Kocsen Chung  <kocsen_chung@apple.com>
     2
     3        Cherry-pick r249224. rdar://problem/54819205
     4
     5    Null check webFrame when creating a print preview to prevent a crash.
     6    https://bugs.webkit.org/show_bug.cgi?id=201237
     7    <rdar://problem/51618863>
     8   
     9    Reviewed by Tim Horton.
     10   
     11    Source/WebKit:
     12   
     13    Move and expend a null check to keep from crashing when making a print preview.
     14   
     15    * UIProcess/mac/WKPrintingView.mm:
     16    (-[WKPrintingView _drawPreview:]):
     17    (-[WKPrintingView drawRect:]):
     18   
     19    Tools:
     20   
     21    Test to verify that if we don't have the WebPageProxy, we will not crash when making a print preview.
     22   
     23    * TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:
     24    (TEST):
     25   
     26   
     27    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249224 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     28
     29    2019-08-28  Megan Gardner  <megan_gardner@apple.com>
     30
     31            Null check webFrame when creating a print preview to prevent a crash.
     32            https://bugs.webkit.org/show_bug.cgi?id=201237
     33            <rdar://problem/51618863>
     34
     35            Reviewed by Tim Horton.
     36
     37            Test to verify that if we don't have the WebPageProxy, we will not crash when making a print preview.
     38
     39            * TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:
     40            (TEST):
     41
    1422019-08-18  Babak Shafiei  <bshafiei@apple.com>
    243
  • branches/safari-608-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm

    r243094 r249240  
    428428}
    429429
     430TEST(WebKit, PrintPreview)
     431{
     432    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
     433    auto delegate = adoptNS([[PrintDelegate alloc] init]);
     434    [webView setUIDelegate:delegate.get()];
     435    [webView loadHTMLString:@"<head><title>test_title</title></head><body onload='print()'>hello world!</body>" baseURL:[NSURL URLWithString:@"http://example.com/"]];
     436    TestWebKitAPI::Util::run(&done);
     437
     438    NSPrintOperation *operation = [webView _printOperationWithPrintInfo:[NSPrintInfo sharedPrintInfo]];
     439    NSPrintOperation.currentOperation = operation;
     440    auto previewView = [operation view];
     441    [webView _close];
     442    [previewView drawRect:CGRectMake(0, 0, 10, 10)];
     443}
     444
    430445@interface NotificationDelegate : NSObject <WKUIDelegatePrivate> {
    431446    bool _allowNotifications;
Note: See TracChangeset for help on using the changeset viewer.