Changeset 217461 in webkit


Ignore:
Timestamp:
May 25, 2017 5:42:58 PM (7 years ago)
Author:
mmaxfield@apple.com
Message:

[WK1] iframes in layer-backed NSViews are not cleared between successive draws
https://bugs.webkit.org/show_bug.cgi?id=172554
<rdar://problem/31247133>

Reviewed by Simon Fraser.

Source/WebKit/mac:

Update an overridden internal AppKit function to the new signature.

  • WebView/WebHTMLView.mm:

(-[WebHTMLView _recursive:displayRectIgnoringOpacity:inContext:shouldChangeFontReferenceColor:_recursive:displayRectIgnoringOpacity:inContext:topView:]):
(-[WebHTMLView _recursive:displayRectIgnoringOpacity:inGraphicsContext:CGContext:shouldChangeFontReferenceColor:_recursive:displayRectIgnoringOpacity:inGraphicsContext:CGContext:topView:shouldChangeFontReferenceColor:]):
(-[WebHTMLView _recursive:displayRectIgnoringOpacity:inContext:topView:]): Deleted.
(-[WebHTMLView _recursive:displayRectIgnoringOpacity:inGraphicsContext:CGContext:topView:shouldChangeFontReferenceColor:]): Deleted.

Tools:

Previously, there was no way to make DumpRenderTree's views layer-backed. Unfortunately,
simply setting [WebView setWantsLayer:] is insufficient; turning it on and then off again
leaves some state around inside the NSWindow which isn't easily cleaned up. Instead,
we should just tear down and rebuild the window whenever we need a layer-backed WebView.
We can also use the "webkit-test-runner" header comment to trigger this new layer-backed
codepath.

  • DumpRenderTree/TestOptions.h:
  • DumpRenderTree/TestOptions.mm:

(TestOptions::TestOptions):
(TestOptions::webViewIsCompatibleWithOptions):

  • DumpRenderTree/mac/DumpRenderTree.mm:

(shouldIgnoreWebCoreNodeLeaks):
(allowedFontFamilySet):
(-[DRTMockScroller rectForPart:]):
(-[DRTMockScroller drawKnob]):
(-[DRTMockScroller drawRect:]):
(createWebViewAndOffscreenWindow):
(initializeGlobalsFromCommandLineOptions):
(prepareConsistentTestingEnvironment):
(dumpRenderTree):
(dumpAudio):
(dumpHistoryItem):
(dumpBackForwardListForWebView):
(resetWebViewToConsistentStateBeforeTesting):
(WebThreadLockAfterDelegateCallbacksHaveCompleted):
(runTest):

LayoutTests:

Cause two successive paints, and compare it against 0 paints.

  • fast/frames/iframe-translucent-background-expected.html: Added.
  • fast/frames/iframe-translucent-background.html: Added.
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r217458 r217461  
     12017-05-25  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        [WK1] iframes in layer-backed NSViews are not cleared between successive draws
     4        https://bugs.webkit.org/show_bug.cgi?id=172554
     5        <rdar://problem/31247133>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Cause two successive paints, and compare it against 0 paints.
     10
     11        * fast/frames/iframe-translucent-background-expected.html: Added.
     12        * fast/frames/iframe-translucent-background.html: Added.
     13
    1142017-05-25  Keith Miller  <keith_miller@apple.com>
    215
  • trunk/Source/WebKit/mac/ChangeLog

    r217371 r217461  
     12017-05-25  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        [WK1] iframes in layer-backed NSViews are not cleared between successive draws
     4        https://bugs.webkit.org/show_bug.cgi?id=172554
     5        <rdar://problem/31247133>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Update an overridden internal AppKit function to the new signature.
     10
     11        * WebView/WebHTMLView.mm:
     12        (-[WebHTMLView _recursive:displayRectIgnoringOpacity:inContext:shouldChangeFontReferenceColor:_recursive:displayRectIgnoringOpacity:inContext:topView:]):
     13        (-[WebHTMLView _recursive:displayRectIgnoringOpacity:inGraphicsContext:CGContext:shouldChangeFontReferenceColor:_recursive:displayRectIgnoringOpacity:inGraphicsContext:CGContext:topView:shouldChangeFontReferenceColor:]):
     14        (-[WebHTMLView _recursive:displayRectIgnoringOpacity:inContext:topView:]): Deleted.
     15        (-[WebHTMLView _recursive:displayRectIgnoringOpacity:inGraphicsContext:CGContext:topView:shouldChangeFontReferenceColor:]): Deleted.
     16
    1172017-05-24  Jer Noble  <jer.noble@apple.com>
    218
  • trunk/Source/WebKit/mac/WebView/WebHTMLView.mm

    r217296 r217461  
    685685- (void)_recursiveDisplayRectIfNeededIgnoringOpacity:(NSRect)rect isVisibleRect:(BOOL)isVisibleRect rectIsVisibleRectForView:(NSView *)visibleView topView:(BOOL)topView;
    686686- (void)_recursiveDisplayAllDirtyWithLockFocus:(BOOL)needsLockFocus visRect:(NSRect)visRect;
    687 #if !PLATFORM(IOS)
     687#if PLATFORM(MAC)
     688#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
     689- (void)_recursive:(BOOL)recurse displayRectIgnoringOpacity:(NSRect)displayRect inContext:(NSGraphicsContext *)context shouldChangeFontReferenceColor:(BOOL)shouldChangeFontReferenceColor;
     690- (void)_recursive:(BOOL)recurseX displayRectIgnoringOpacity:(NSRect)displayRect inGraphicsContext:(NSGraphicsContext *)graphicsContext CGContext:(CGContextRef)ctx shouldChangeFontReferenceColor:(BOOL)shouldChangeFontReferenceColor;
     691#else
    688692- (void)_recursive:(BOOL)recurse displayRectIgnoringOpacity:(NSRect)displayRect inContext:(NSGraphicsContext *)context topView:(BOOL)topView;
    689693- (void)_recursive:(BOOL)recurseX displayRectIgnoringOpacity:(NSRect)displayRect inGraphicsContext:(NSGraphicsContext *)graphicsContext CGContext:(CGContextRef)ctx topView:(BOOL)isTopView shouldChangeFontReferenceColor:(BOOL)shouldChangeFontReferenceColor;
     694#endif
    690695#endif
    691696- (NSRect)_dirtyRect;
     
    18371842
    18381843// Don't let AppKit even draw subviews. We take care of that.
     1844#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
     1845- (void)_recursive:(BOOL)recurse displayRectIgnoringOpacity:(NSRect)displayRect inContext:(NSGraphicsContext *)context shouldChangeFontReferenceColor:(BOOL)shouldChangeFontReferenceColor
     1846#else
    18391847- (void)_recursive:(BOOL)recurse displayRectIgnoringOpacity:(NSRect)displayRect inContext:(NSGraphicsContext *)context topView:(BOOL)topView
     1848#endif
    18401849{
    18411850    [self _setAsideSubviews];
     1851#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
     1852    [super _recursive:recurse displayRectIgnoringOpacity:displayRect inContext:context shouldChangeFontReferenceColor:shouldChangeFontReferenceColor];
     1853#else
    18421854    [super _recursive:recurse displayRectIgnoringOpacity:displayRect inContext:context topView:topView];
     1855#endif
    18431856    [self _restoreSubviews];
    18441857}
    18451858
    18461859// Don't let AppKit even draw subviews. We take care of that.
     1860#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
     1861- (void)_recursive:(BOOL)recurseX displayRectIgnoringOpacity:(NSRect)displayRect inGraphicsContext:(NSGraphicsContext *)graphicsContext CGContext:(CGContextRef)ctx shouldChangeFontReferenceColor:(BOOL)shouldChangeFontReferenceColor
     1862#else
    18471863- (void)_recursive:(BOOL)recurseX displayRectIgnoringOpacity:(NSRect)displayRect inGraphicsContext:(NSGraphicsContext *)graphicsContext CGContext:(CGContextRef)ctx topView:(BOOL)isTopView shouldChangeFontReferenceColor:(BOOL)shouldChangeFontReferenceColor
     1864#endif
    18481865{
    18491866    BOOL didSetAsideSubviews = NO;
     
    18541871    }
    18551872   
     1873#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
     1874    [super _recursive:recurseX displayRectIgnoringOpacity:displayRect inGraphicsContext:graphicsContext CGContext:ctx shouldChangeFontReferenceColor:shouldChangeFontReferenceColor];
     1875#else
    18561876    [super _recursive:recurseX displayRectIgnoringOpacity:displayRect inGraphicsContext:graphicsContext CGContext:ctx topView:isTopView shouldChangeFontReferenceColor:shouldChangeFontReferenceColor];
     1877#endif
    18571878
    18581879    if (didSetAsideSubviews)
  • trunk/Tools/ChangeLog

    r217451 r217461  
     12017-05-25  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        [WK1] iframes in layer-backed NSViews are not cleared between successive draws
     4        https://bugs.webkit.org/show_bug.cgi?id=172554
     5        <rdar://problem/31247133>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Previously, there was no way to make DumpRenderTree's views layer-backed. Unfortunately,
     10        simply setting [WebView setWantsLayer:] is insufficient; turning it on and then off again
     11        leaves some state around inside the NSWindow which isn't easily cleaned up. Instead,
     12        we should just tear down and rebuild the window whenever we need a layer-backed WebView.
     13        We can also use the "webkit-test-runner" header comment to trigger this new layer-backed
     14        codepath.
     15
     16        * DumpRenderTree/TestOptions.h:
     17        * DumpRenderTree/TestOptions.mm:
     18        (TestOptions::TestOptions):
     19        (TestOptions::webViewIsCompatibleWithOptions):
     20        * DumpRenderTree/mac/DumpRenderTree.mm:
     21        (shouldIgnoreWebCoreNodeLeaks):
     22        (allowedFontFamilySet):
     23        (-[DRTMockScroller rectForPart:]):
     24        (-[DRTMockScroller drawKnob]):
     25        (-[DRTMockScroller drawRect:]):
     26        (createWebViewAndOffscreenWindow):
     27        (initializeGlobalsFromCommandLineOptions):
     28        (prepareConsistentTestingEnvironment):
     29        (dumpRenderTree):
     30        (dumpAudio):
     31        (dumpHistoryItem):
     32        (dumpBackForwardListForWebView):
     33        (resetWebViewToConsistentStateBeforeTesting):
     34        (WebThreadLockAfterDelegateCallbacksHaveCompleted):
     35        (runTest):
     36
    1372017-05-25  Sam Weinig  <sam@webkit.org>
    238
  • trunk/Tools/DumpRenderTree/TestOptions.h

    r215189 r217461  
    3535    bool enableCredentialManagement { false };
    3636    bool enableDragDestinationActionLoad { false };
     37    bool layerBackedWebView { false };
    3738
    3839    TestOptions(NSURL*, const TestCommand&);
     40    bool webViewIsCompatibleWithOptions(const TestOptions&) const;
    3941};
  • trunk/Tools/DumpRenderTree/TestOptions.mm

    r215189 r217461  
    9191        else if (key == "enableDragDestinationActionLoad")
    9292            this->enableDragDestinationActionLoad = parseBooleanTestHeaderValue(value);
     93        else if (key == "layerBackedWebView")
     94            this->layerBackedWebView = parseBooleanTestHeaderValue(value);
    9395        pairStart = pairEnd + 1;
    9496    }
    9597}
     98
     99bool TestOptions::webViewIsCompatibleWithOptions(const TestOptions& other) const
     100{
     101    return other.layerBackedWebView == layerBackedWebView;
     102}
  • trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm

    r217273 r217461  
    181181RefPtr<TestRunner> gTestRunner;
    182182
     183std::optional<TestOptions> mainFrameTestOptions;
    183184WebFrame *mainFrame = nil;
    184185// This is the topmost frame that is loading, during a given load, or nil when no load is
     
    291292    };
    292293    static const int ignoreSetCount = sizeof(ignoreSet) / sizeof(char*);
    293    
     294
    294295    for (int i = 0; i < ignoreSetCount; i++) {
    295296        // FIXME: ignore case
     
    426427        @"Zapfino",
    427428        nil] retain];
    428    
     429
    429430    return fontFamilySet;
    430431}
     
    648649    CGFloat knobLength = max(minKnobSize, static_cast<CGFloat>(round(trackLength * [self knobProportion])));
    649650    CGFloat knobPosition = static_cast<CGFloat>((round([self doubleValue] * (trackLength - knobLength))));
    650    
     651
    651652    if (isHorizontal)
    652653        return NSMakeRect(bounds.origin.x + knobPosition, bounds.origin.y, knobLength, bounds.size.height);
     
    661662
    662663    NSRect knobRect = [self rectForPart:NSScrollerKnob];
    663    
     664
    664665    static NSColor *knobColor = [[NSColor colorWithDeviceRed:0x80 / 255.0 green:0x80 / 255.0 blue:0x80 / 255.0 alpha:1] retain];
    665666    [knobColor set];
     
    679680
    680681    NSRectFill(dirtyRect);
    681    
     682
    682683    [self drawKnob];
    683684}
     
    715716    [WebView registerURLSchemeAsLocal:@"feeds"];
    716717    [WebView registerURLSchemeAsLocal:@"feedsearch"];
    717    
     718
    718719#if PLATFORM(MAC)
    719720    [WebView _setFontWhitelist:fontWhitelist()];
     
    732733    [webView setInteractiveFormValidationEnabled:YES];
    733734    [webView setValidationMessageTimerMagnification:-1];
    734    
     735
    735736    // To make things like certain NSViews, dragging, and plug-ins work, put the WebView a window, but put it off-screen so you don't see it.
    736737    // Put it at -10000, -10000 in "flipped coordinates", since WebCore and the DOM use flipped coordinates.
     
    777778    adjustWebDocumentForStandardViewport(webBrowserView, scrollView);
    778779#endif
    779    
     780
    780781#if !PLATFORM(IOS)
    781782    // For reasons that are not entirely clear, the following pair of calls makes WebView handle its
     
    11291130        {nullptr, 0, nullptr, 0}
    11301131    };
    1131    
     1132
    11321133    int option;
    11331134    while ((option = getopt_long(argc, (char * const *)argv, "", options, nullptr)) != -1) {
     
    12121213    activateFontsIOS();
    12131214#endif
    1214    
     1215
    12151216    allocateGlobalControllers();
    1216    
     1217
    12171218#if PLATFORM(MAC)
    12181219    NSActivityOptions options = (NSActivityUserInitiatedAllowingIdleSystemSleep | NSActivityLatencyCritical) & ~(NSActivitySuddenTerminationDisabled | NSActivityAutomaticTerminationDisabled);
     
    12571258    [NSSound _setAlertType:0];
    12581259#endif
    1259 
    1260     WebView *webView = createWebViewAndOffscreenWindow();
    1261     mainFrame = [webView mainFrame];
    12621260
    12631261    [[NSURLCache sharedURLCache] removeAllCachedResponses];
     
    12851283        stopJavaScriptThreads();
    12861284
    1287     destroyWebViewAndOffscreenWindow(webView);
    1288    
     1285    destroyWebViewAndOffscreenWindow([mainFrame webView]);
     1286
    12891287    releaseGlobalControllers();
    1290    
     1288
    12911289#if !PLATFORM(IOS)
    12921290    [DumpRenderTreePasteboard releaseLocalPasteboards];
     
    14071405{
    14081406    const vector<char>& dataVector = gTestRunner->audioResult();
    1409    
     1407
    14101408    NSData *data = [NSData dataWithBytes:dataVector.data() length:dataVector.size()];
    14111409    return data;
     
    14211419    for (int i = start; i < indent; i++)
    14221420        putchar(' ');
    1423    
     1421
    14241422    NSString *urlString = [item URLString];
    14251423    if ([[NSURL URLWithString:urlString] isFileURL]) {
     
    14271425        urlString = [@"(file test):" stringByAppendingString:[urlString substringFromIndex:(range.length + range.location)]];
    14281426    }
    1429    
     1427
    14301428    printf("%s", [urlString UTF8String]);
    14311429    NSString *target = [item target];
     
    15521550        [itemsToPrint addObject:item];
    15531551    }
    1554            
     1552
    15551553    assert([bfList currentItem] != prevTestBFItem);
    15561554    [itemsToPrint addObject:[bfList currentItem]];
     
    18111809
    18121810    [WebCache clearCachedCredentials];
    1813    
     1811
    18141812    resetWebPreferencesToConsistentValues();
    18151813    setWebPreferencesForTestOptions(options);
     1814#if PLATFORM(MAC)
     1815    [webView setWantsLayer:options.layerBackedWebView];
     1816#endif
    18161817
    18171818    TestRunner::setSerializeHTTPLoads(false);
     
    18461847    [[MockGeolocationProvider shared] stopTimer];
    18471848    [[MockWebNotificationProvider shared] reset];
    1848    
     1849
    18491850#if !PLATFORM(IOS)
    18501851    // Clear the contents of the general pasteboard
     
    18801881
    18811882    WebThreadLock();
    1882    
     1883
    18831884    dispatch_release(delegateSemaphore);
    18841885}
     
    19501951
    19511952    TestOptions options(url, command);
     1953    if (!mainFrameTestOptions || !options.webViewIsCompatibleWithOptions(mainFrameTestOptions.value())) {
     1954        if (mainFrame)
     1955            destroyWebViewAndOffscreenWindow([mainFrame webView]);
     1956        WebView *pristineWebView = createWebViewAndOffscreenWindow();
     1957        mainFrame = [pristineWebView mainFrame];
     1958    }
     1959    mainFrameTestOptions = options;
     1960
    19521961    resetWebViewToConsistentStateBeforeTesting(options);
    19531962
     
    20572066            if (window == [[mainFrame webView] window])
    20582067                continue;
    2059            
     2068
    20602069#if !PLATFORM(IOS)
    20612070            WebView *webView = [[[window contentView] subviews] objectAtIndex:0];
Note: See TracChangeset for help on using the changeset viewer.