Changeset 220390 in webkit


Ignore:
Timestamp:
Aug 8, 2017 12:29:26 AM (7 years ago)
Author:
jmarcell@apple.com
Message:

Cherry-pick r220248. rdar://problem/33754458

Location:
branches/safari-604-branch/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-604-branch/Source/WebCore/ChangeLog

    r220389 r220390  
     12017-08-08  Jason Marcell  <jmarcell@apple.com>
     2
     3        Cherry-pick r220248. rdar://problem/33754458
     4
     5    2017-08-03  Jeremy Jones  <jeremyj@apple.com>
     6
     7            Improve WebKitLegacy video fullscreen animation begin and end rects.
     8            https://bugs.webkit.org/show_bug.cgi?id=175152
     9            rdar://problem/32840576
     10
     11            Reviewed by Eric Carlson.
     12
     13            No new tests, becuase this change has no effect on the DOM.
     14
     15            This change uses different rects for fullscreen animation to prevent the animation
     16            from failing, and to improve the aesthetics of the animation.
     17
     18            * platform/mac/WebVideoFullscreenController.mm:
     19            (frameExpandedToRatioOfFrame):
     20            (-[WebVideoFullscreenController enterFullscreen:]):
     21            (-[WebVideoFullscreenController exitFullscreen]):
     22            (-[WebVideoFullscreenWindow animateFromRect:toRect:withSubAnimation:controllerAction:]):
     23            (constrainFrameToRatioOfFrame): Deleted.
     24
    1252017-08-08  Jason Marcell  <jmarcell@apple.com>
    226
  • branches/safari-604-branch/Source/WebCore/platform/mac/WebVideoFullscreenController.mm

    r219191 r220390  
    234234// MARK: Exposed Interface
    235235
    236 static void constrainFrameToRatioOfFrame(NSRect *frameToConstrain, const NSRect *frame)
     236static NSRect frameExpandedToRatioOfFrame(NSRect frameToExpand, NSRect frame)
    237237{
    238238    // Keep a constrained aspect ratio for the destination window
    239     CGFloat originalRatio = frame->size.width / frame->size.height;
    240     CGFloat newRatio = frameToConstrain->size.width / frameToConstrain->size.height;
     239    NSRect result = frameToExpand;
     240    CGFloat newRatio = frame.size.width / frame.size.height;
     241    CGFloat originalRatio = frameToExpand.size.width / frameToExpand.size.height;
    241242    if (newRatio > originalRatio) {
    242         CGFloat newWidth = originalRatio * frameToConstrain->size.height;
    243         CGFloat diff = frameToConstrain->size.width - newWidth;
    244         frameToConstrain->size.width = newWidth;
    245         frameToConstrain->origin.x += diff / 2;
     243        CGFloat newWidth = newRatio * frameToExpand.size.height;
     244        CGFloat diff = newWidth - frameToExpand.size.width;
     245        result.size.width = newWidth;
     246        result.origin.x -= diff / 2;
    246247    } else {
    247         CGFloat newHeight = frameToConstrain->size.width / originalRatio;
    248         CGFloat diff = frameToConstrain->size.height - newHeight;
    249         frameToConstrain->size.height = newHeight;
    250         frameToConstrain->origin.y += diff / 2;
    251     }   
     248        CGFloat newHeight = frameToExpand.size.width / newRatio;
     249        CGFloat diff = newHeight - frameToExpand.size.height;
     250        result.size.height = newHeight;
     251        result.origin.y -= diff / 2;
     252    }
     253    return result;
    252254}
    253255
     
    278280        screen = [NSScreen mainScreen];
    279281
    280     NSRect frame = [self videoElementRect];
    281282    NSRect endFrame = [screen frame];
    282     constrainFrameToRatioOfFrame(&endFrame, &frame);
     283    NSRect frame = frameExpandedToRatioOfFrame([self videoElementRect], endFrame);
    283284
    284285    // Create a black window if needed
     
    317318    // Balanced in windowDidExitFullscreen
    318319    [self retain];   
    319    
    320     [[self fullscreenWindow] animateFromRect:[[self window] frame] toRect:endFrame withSubAnimation:_fadeAnimation controllerAction:@selector(windowDidExitFullscreen)];
     320
     321    NSRect startFrame = [[self window] frame];
     322    endFrame = frameExpandedToRatioOfFrame(endFrame, startFrame);
     323
     324    [[self fullscreenWindow] animateFromRect:startFrame toRect:endFrame withSubAnimation:_fadeAnimation controllerAction:@selector(windowDidExitFullscreen)];
    321325}
    322326
     
    505509        // We'll downscale the window during the animation based on the higher resolution rect
    506510        BOOL higherResolutionIsEndRect = startRect.size.width < endRect.size.width && startRect.size.height < endRect.size.height;
    507         [self setFrame:higherResolutionIsEndRect ? endRect : startRect display:NO];       
     511        [self setFrame:higherResolutionIsEndRect ? endRect : startRect display:NO];
    508512    }
    509513   
Note: See TracChangeset for help on using the changeset viewer.