Changeset 180885 in webkit


Ignore:
Timestamp:
Mar 2, 2015 9:37:14 AM (9 years ago)
Author:
jer.noble@apple.com
Message:

[WK1][WK2][Mac] Fullscreen animation is incorrect when page is scaled.
https://bugs.webkit.org/show_bug.cgi?id=142121

Reviewed by Simon Fraser.

Source/WebKit/mac:

Fullscreening a page with a non-1 scale would result in that scale being applied to the
fullscreen content, breaking fullscreen mode. Set the page scale to 1 when entering
fullscreen and reset it to the original value when exiting fullscreen.

  • WebView/WebFullScreenController.h:
  • WebView/WebFullScreenController.mm:

(-[WebFullScreenController enterFullScreen:]): Set the page scale to 1.
(-[WebFullScreenController finishedExitFullScreenAnimation:]): Reset the page

scale to the original value.

  • WebView/WebView.mm:

(-[WebView _supportsFullScreenForElement:withKeyboard:]): Drive-by fix. Check the

WebView's own preferences to see if fullscreen mode is enabled, rather than
the global object's.

Source/WebKit2:

Change the order of operations when entering or exiting fullscreen. Change the page scale to
1 before entering, so the final screen rect takes that scale into account, and vice-versa on
exiting.

  • UIProcess/mac/WKFullScreenWindowController.mm:

(-[WKFullScreenWindowController enterFullScreen:]):
(-[WKFullScreenWindowController exitFullScreen]):

Tools:

Add a test which changes the WebView's page scale, then enters fullscreen mode, and verifies
that the initial and final screen rects for the web content are as expected.

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/mac/FullscreenZoomInitialFrame.html: Added.
  • TestWebKitAPI/Tests/mac/FullscreenZoomInitialFrame.mm: Added.

(-[FullscreenStateDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:]):
(runJavaScriptAlert):
(TestWebKitAPI::FullscreenZoomInitialFrame::initializeView):
(TestWebKitAPI::FullscreenZoomInitialFrame::teardownView):
(TestWebKitAPI::FullscreenZoomInitialFrame::setPageScale):
(TestWebKitAPI::FullscreenZoomInitialFrame::sendMouseDownEvent):
(TestWebKitAPI::FullscreenZoomInitialFrame::runTest):
(TestWebKitAPI::TEST_F):

Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/mac/ChangeLog

    r180871 r180885  
     12015-03-02  Jer Noble  <jer.noble@apple.com>
     2
     3        [WK1][WK2][Mac] Fullscreen animation is incorrect when page is scaled.
     4        https://bugs.webkit.org/show_bug.cgi?id=142121
     5
     6        Reviewed by Simon Fraser.
     7
     8        Fullscreening a page with a non-1 scale would result in that scale being applied to the
     9        fullscreen content, breaking fullscreen mode. Set the page scale to 1 when entering
     10        fullscreen and reset it to the original value when exiting fullscreen.
     11
     12        * WebView/WebFullScreenController.h:
     13        * WebView/WebFullScreenController.mm:
     14        (-[WebFullScreenController enterFullScreen:]): Set the page scale to 1.
     15        (-[WebFullScreenController finishedExitFullScreenAnimation:]): Reset the page
     16                scale to the original value.
     17        * WebView/WebView.mm:
     18        (-[WebView _supportsFullScreenForElement:withKeyboard:]): Drive-by fix. Check the
     19                WebView's own preferences to see if fullscreen mode is enabled, rather than
     20                the global object's.
     21
    1222015-03-01  Chris Dumez  <cdumez@apple.com>
    223
  • trunk/Source/WebKit/mac/WebView/WebFullScreenController.h

    r161185 r180885  
    5252    NSRect _finalFrame;
    5353    WebCore::IntPoint _scrollPosition;
     54    float _savedScale;
    5455
    5556    BOOL _isEnteringFullScreen;
     
    5859    BOOL _isPlaying;
    5960}
     61
     62@property (readonly) NSRect initialFrame;
     63@property (readonly) NSRect finalFrame;
    6064
    6165- (WebView*)webView;
  • trunk/Source/WebKit/mac/WebView/WebFullScreenController.mm

    r171120 r180885  
    108108}
    109109
     110@synthesize initialFrame=_initialFrame;
     111@synthesize finalFrame=_finalFrame;
     112
    110113- (void)windowDidLoad
    111114{
     
    239242   
    240243    [[self window] makeResponder:webWindowFirstResponder firstResponderIfDescendantOfView:_webView];
    241    
     244
     245    _savedScale = [_webView _viewScaleFactor];
     246    [_webView _scaleWebView:1 atOrigin:NSMakePoint(0, 0)];
    242247    [self _document]->webkitWillEnterFullScreenForElement(_element.get());
    243248    [self _document]->setAnimatingFullScreen(true);
     
    345350    // Screen updates to be re-enabled at the end of this function
    346351    NSDisableScreenUpdates();
    347    
     352
    348353    [self _document]->setAnimatingFullScreen(false);
    349354    [self _document]->webkitDidExitFullScreenForElement(_element.get());
    350    
     355    [_webView _scaleWebView:_savedScale atOrigin:NSMakePoint(0, 0)];
     356
    351357    NSResponder *firstResponder = [[self window] firstResponder];
    352358    [self _swapView:_webViewPlaceholder.get() with:_webView];
  • trunk/Source/WebKit/mac/WebView/WebView.mm

    r180704 r180885  
    84358435- (BOOL)_supportsFullScreenForElement:(const WebCore::Element*)element withKeyboard:(BOOL)withKeyboard
    84368436{
    8437     if (![[WebPreferences standardPreferences] fullScreenEnabled])
     8437    if (![[self preferences] fullScreenEnabled])
    84388438        return NO;
    84398439
  • trunk/Source/WebKit2/ChangeLog

    r180882 r180885  
     12015-03-02  Jer Noble  <jer.noble@apple.com>
     2
     3        [WK1][WK2][Mac] Fullscreen animation is incorrect when page is scaled.
     4        https://bugs.webkit.org/show_bug.cgi?id=142121
     5
     6        Reviewed by Simon Fraser.
     7
     8        Change the order of operations when entering or exiting fullscreen. Change the page scale to
     9        1 before entering, so the final screen rect takes that scale into account, and vice-versa on
     10        exiting.
     11
     12        * UIProcess/mac/WKFullScreenWindowController.mm:
     13        (-[WKFullScreenWindowController enterFullScreen:]):
     14        (-[WKFullScreenWindowController exitFullScreen]):
     15
    1162015-03-01  Simon Fraser  <simon.fraser@apple.com>
    217
  • trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.h

    r177835 r180885  
    6262}
    6363
     64@property (readonly) NSRect initialFrame;
     65@property (readonly) NSRect finalFrame;
     66
    6467- (id)initWithWindow:(NSWindow *)window webView:(WKView *)webView;
    6568
  • trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm

    r173888 r180885  
    131131#pragma mark Accessors
    132132
     133@synthesize initialFrame=_initialFrame;
     134@synthesize finalFrame=_finalFrame;
     135
    133136- (BOOL)isFullScreen
    134137{
     
    250253    makeResponderFirstResponderIfDescendantOfView(self.window, webWindowFirstResponder, _webView);
    251254
     255    _savedScale = [self _page]->pageScaleFactor();
     256    [self _page]->scalePage(1, IntPoint());
    252257    [self _manager]->setAnimatingFullScreen(true);
    253258    [self _manager]->willEnterFullScreen();
    254     _savedScale = [self _page]->pageScaleFactor();
    255     [self _page]->scalePage(1, IntPoint());
    256259}
    257260
     
    321324        [[_webView window] makeKeyAndOrderFront:self];
    322325
     326        [self _page]->scalePage(_savedScale, IntPoint());
     327        [self _manager]->restoreScrollPosition();
    323328        [self _manager]->didExitFullScreen();
    324329        [self _manager]->setAnimatingFullScreen(false);
    325         [self _page]->scalePage(_savedScale, IntPoint());
    326         [self _manager]->restoreScrollPosition();
    327330    }
    328331
  • trunk/Tools/ChangeLog

    r180866 r180885  
     12015-03-02  Jer Noble  <jer.noble@apple.com>
     2
     3        [WK1][WK2][Mac] Fullscreen animation is incorrect when page is scaled.
     4        https://bugs.webkit.org/show_bug.cgi?id=142121
     5
     6        Reviewed by Simon Fraser.
     7
     8        Add a test which changes the WebView's page scale, then enters fullscreen mode, and verifies
     9        that the initial and final screen rects for the web content are as expected.
     10
     11        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     12        * TestWebKitAPI/Tests/mac/FullscreenZoomInitialFrame.html: Added.
     13        * TestWebKitAPI/Tests/mac/FullscreenZoomInitialFrame.mm: Added.
     14        (-[FullscreenStateDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:]):
     15        (runJavaScriptAlert):
     16        (TestWebKitAPI::FullscreenZoomInitialFrame::initializeView):
     17        (TestWebKitAPI::FullscreenZoomInitialFrame::teardownView):
     18        (TestWebKitAPI::FullscreenZoomInitialFrame::setPageScale):
     19        (TestWebKitAPI::FullscreenZoomInitialFrame::sendMouseDownEvent):
     20        (TestWebKitAPI::FullscreenZoomInitialFrame::runTest):
     21        (TestWebKitAPI::TEST_F):
     22
    1232015-03-01  David Kilzer  <ddkilzer@apple.com>
    224
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r180798 r180885  
    273273                CD59F53419E9110D00CF1835 /* file-with-mse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD59F53219E910AA00CF1835 /* file-with-mse.html */; };
    274274                CD59F53519E9110D00CF1835 /* test-mse.mp4 in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD59F53319E910BC00CF1835 /* test-mse.mp4 */; };
     275                CDBFCC451A9FF45300A7B691 /* FullscreenZoomInitialFrame.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDBFCC431A9FF44800A7B691 /* FullscreenZoomInitialFrame.mm */; };
     276                CDBFCC461A9FF49E00A7B691 /* FullscreenZoomInitialFrame.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CDBFCC421A9FF44800A7B691 /* FullscreenZoomInitialFrame.html */; };
    275277                CE14F1A4181873B0001C2705 /* WillPerformClientRedirectToURLCrash.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CE14F1A2181873B0001C2705 /* WillPerformClientRedirectToURLCrash.html */; };
    276278                CEA6CF2819CCF69D0064F5A7 /* open-and-close-window.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CEA6CF2719CCF69D0064F5A7 /* open-and-close-window.html */; };
     
    342344                                C5101C4F176B8D9200EE9B15 /* findRanges.html in Copy Resources */,
    343345                                1A7E8B3618120B2F00AEB74A /* FragmentNavigation.html in Copy Resources */,
     346                                CDBFCC461A9FF49E00A7B691 /* FullscreenZoomInitialFrame.html in Copy Resources */,
    344347                                26F52EAD1828827B0023D412 /* geolocationGetCurrentPosition.html in Copy Resources */,
    345348                                26F52EAF18288C230023D412 /* geolocationGetCurrentPositionWithHighAccuracy.html in Copy Resources */,
     
    666669                CD59F53219E910AA00CF1835 /* file-with-mse.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "file-with-mse.html"; sourceTree = "<group>"; };
    667670                CD59F53319E910BC00CF1835 /* test-mse.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = "test-mse.mp4"; sourceTree = "<group>"; };
     671                CDBFCC421A9FF44800A7B691 /* FullscreenZoomInitialFrame.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = FullscreenZoomInitialFrame.html; sourceTree = "<group>"; };
     672                CDBFCC431A9FF44800A7B691 /* FullscreenZoomInitialFrame.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FullscreenZoomInitialFrame.mm; sourceTree = "<group>"; };
    668673                CDC2C7141797089D00E627FB /* TimeRanges.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TimeRanges.cpp; sourceTree = "<group>"; };
    669674                CE14F1A2181873B0001C2705 /* WillPerformClientRedirectToURLCrash.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = WillPerformClientRedirectToURLCrash.html; sourceTree = "<group>"; };
     
    11451150                                4BB4160316815F9100824238 /* ElementAtPointInWebFrame.mm */,
    11461151                                1A7E8B33181208DE00AEB74A /* FragmentNavigation.mm */,
     1152                                CDBFCC431A9FF44800A7B691 /* FullscreenZoomInitialFrame.mm */,
    11471153                                9B4F8FA3159D52B1002D9F94 /* HTMLCollectionNamedItem.mm */,
    11481154                                9B26FC6B159D061000CC3765 /* HTMLFormCollectionNamedItem.mm */,
     
    11871193                                37DC678F140D7D3A00ABCCDB /* DOMRangeOfString.html */,
    11881194                                1A7E8B351812093600AEB74A /* FragmentNavigation.html */,
     1195                                CDBFCC421A9FF44800A7B691 /* FullscreenZoomInitialFrame.html */,
    11891196                                9B4F8FA6159D52CA002D9F94 /* HTMLCollectionNamedItem.html */,
    11901197                                9B26FCB4159D15E700CC3765 /* HTMLFormCollectionNamedItem.html */,
     
    14031410                                7CCE7EF81A411AE600447C4C /* Geolocation.cpp in Sources */,
    14041411                                7CCE7EE11A411A9A00447C4C /* GetBackingScaleFactor.mm in Sources */,
     1412                                CDBFCC451A9FF45300A7B691 /* FullscreenZoomInitialFrame.mm in Sources */,
    14051413                                7CCE7EF91A411AE600447C4C /* GetInjectedBundleInitializationUserDataCallback.cpp in Sources */,
    14061414                                7CCE7EE21A411A9A00447C4C /* GetPIDAfterAbortedProcessLaunch.cpp in Sources */,
Note: See TracChangeset for help on using the changeset viewer.