Changeset 181173 in webkit
- Timestamp:
- Mar 6, 2015 11:28:26 AM (9 years ago)
- Location:
- trunk/Source
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r181172 r181173 1 2015-03-06 Jeremy Jones <jeremyj@apple.com> 2 3 Scroll to make the video element visible when exiting fullscreen. 4 https://bugs.webkit.org/show_bug.cgi?id=141439 5 6 Reviewed by Simon Fraser. 7 8 This patch will scroll the element so it is visible when exiting fullscreen, 9 but only if the element is completely scrolled off screen. 10 Also update the element screen rect so exit animation goes to the correct location. 11 12 * dom/Element.cpp: 13 (WebCore::Element::scrollIntoViewIfNotVisible): Added. 14 * dom/Element.h: Add declaration for scrollIntoViewIfNotVisible. 15 * platform/ios/WebVideoFullscreenControllerAVKit.mm: 16 (-[WebVideoFullscreenController fullscreenMayReturnToInline]): 17 * platform/ios/WebVideoFullscreenInterfaceAVKit.h: 18 * platform/ios/WebVideoFullscreenInterfaceAVKit.mm: 19 (-[WebAVPlayerController playerViewController:restoreUserInterfaceForOptimizedFullscreenStopWithCompletionHandler:]): 20 (-[WebAVPlayerController playerViewControllerWillCancelOptimizedFullscree:]): 21 (WebVideoFullscreenInterfaceAVKit::setupFullscreen): 22 (WebVideoFullscreenInterfaceAVKit::setupFullscreenInternal): 23 (WebVideoFullscreenInterfaceAVKit::exitFullscreen): 24 (WebVideoFullscreenInterfaceAVKit::exitFullscreenInternal): 25 (WebVideoFullscreenInterfaceAVKit::preparedToReturnToInline): 26 (WebVideoFullscreenInterfaceAVKit::fullscreenMayReturnToInline): 27 * rendering/ScrollBehavior.cpp: 28 * rendering/ScrollBehavior.h: 29 1 30 2015-03-06 Myles C. Maxfield <mmaxfield@apple.com> 2 31 -
trunk/Source/WebCore/dom/Element.cpp
r181169 r181173 612 612 } 613 613 614 void Element::scrollIntoViewIfNotVisible(bool centerIfNotVisible) 615 { 616 document().updateLayoutIgnorePendingStylesheets(); 617 618 if (!renderer()) 619 return; 620 621 LayoutRect bounds = renderer()->anchorRect(); 622 if (centerIfNotVisible) 623 renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignCenterIfNotVisible, ScrollAlignment::alignCenterIfNotVisible); 624 else 625 renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNotVisible, ScrollAlignment::alignToEdgeIfNotVisible); 626 } 627 614 628 void Element::scrollByUnits(int units, ScrollGranularity granularity) 615 629 { -
trunk/Source/WebCore/dom/Element.h
r181169 r181173 123 123 void scrollIntoView(bool alignToTop = true); 124 124 void scrollIntoViewIfNeeded(bool centerIfNeeded = true); 125 WEBCORE_EXPORT void scrollIntoViewIfNotVisible(bool centerIfNotVisible = true); 125 126 126 127 void scrollByLines(int lines); -
trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm
r177399 r181173 184 184 - (void)fullscreenMayReturnToInline 185 185 { 186 _interface->preparedToReturnToInline(true, _videoElement->clientRect()); 186 187 } 187 188 -
trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h
r179941 r181173 85 85 WEBCORE_EXPORT virtual void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, WTF::String localizedDeviceName) override; 86 86 87 WEBCORE_EXPORT virtual void setupFullscreen(PlatformLayer&, IntRectinitialRect, UIView *, HTMLMediaElement::VideoFullscreenMode, bool allowOptimizedFullscreen);87 WEBCORE_EXPORT virtual void setupFullscreen(PlatformLayer&, const IntRect& initialRect, UIView *, HTMLMediaElement::VideoFullscreenMode, bool allowOptimizedFullscreen); 88 88 WEBCORE_EXPORT virtual void enterFullscreen(); 89 WEBCORE_EXPORT virtual void exitFullscreen( IntRectfinalRect);89 WEBCORE_EXPORT virtual void exitFullscreen(const IntRect& finalRect); 90 90 WEBCORE_EXPORT virtual void cleanupFullscreen(); 91 91 WEBCORE_EXPORT virtual void invalidate(); 92 92 WEBCORE_EXPORT virtual void requestHideAndExitFullscreen(); 93 WEBCORE_EXPORT virtual void preparedToReturnToInline(bool visible, const IntRect& inlineRect); 93 94 94 95 HTMLMediaElement::VideoFullscreenMode mode() const { return m_mode; } 95 96 void setIsOptimized(bool); 96 97 WEBCORE_EXPORT bool mayAutomaticallyShowVideoOptimized(); 97 boolfullscreenMayReturnToInline();98 void fullscreenMayReturnToInline(); 98 99 99 100 protected: 100 101 void beginSession(); 101 void setupFullscreenInternal(PlatformLayer&, IntRectinitialRect, UIView *, HTMLMediaElement::VideoFullscreenMode, bool allowOptimizedFullscreen);102 void setupFullscreenInternal(PlatformLayer&, const IntRect& initialRect, UIView *, HTMLMediaElement::VideoFullscreenMode, bool allowOptimizedFullscreen); 102 103 void enterFullscreenOptimized(); 103 104 void enterFullscreenStandard(); 104 void exitFullscreenInternal( IntRectfinalRect);105 void exitFullscreenInternal(const IntRect& finalRect); 105 106 void cleanupFullscreenInternal(); 106 107 -
trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm
r181049 r181173 116 116 @property (retain) NSString *externalPlaybackAirPlayDeviceLocalizedName; 117 117 118 @property (copy) void (^exitOptimizedCallback)(BOOL restored); 119 118 120 - (BOOL)playerViewController:(AVPlayerViewController *)playerViewController shouldExitFullScreenWithReason:(AVPlayerViewControllerExitFullScreenReason)reason; 119 121 @end … … 202 204 { 203 205 UNUSED_PARAM(playerViewController); 204 completionHandler(self.fullscreenInterface->fullscreenMayReturnToInline()); 206 self.exitOptimizedCallback = completionHandler; 207 self.fullscreenInterface->fullscreenMayReturnToInline(); 205 208 } 206 209 … … 208 211 { 209 212 UNUSED_PARAM(playerViewController); 210 ASSERT(self.delegate); 213 if (!self.delegate) 214 return 211 215 self.delegate->requestExitFullscreen(); 212 216 } … … 845 849 } 846 850 847 void WebVideoFullscreenInterfaceAVKit::setupFullscreen(PlatformLayer& videoLayer, WebCore::IntRectinitialRect, UIView* parentView, HTMLMediaElement::VideoFullscreenMode mode, bool allowOptimizedFullscreen)851 void WebVideoFullscreenInterfaceAVKit::setupFullscreen(PlatformLayer& videoLayer, const WebCore::IntRect& initialRect, UIView* parentView, HTMLMediaElement::VideoFullscreenMode mode, bool allowOptimizedFullscreen) 848 852 { 849 853 RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this); … … 859 863 } 860 864 861 void WebVideoFullscreenInterfaceAVKit::setupFullscreenInternal(PlatformLayer& videoLayer, WebCore::IntRectinitialRect, UIView* parentView, HTMLMediaElement::VideoFullscreenMode mode, bool allowOptimizedFullscreen)865 void WebVideoFullscreenInterfaceAVKit::setupFullscreenInternal(PlatformLayer& videoLayer, const WebCore::IntRect& initialRect, UIView* parentView, HTMLMediaElement::VideoFullscreenMode mode, bool allowOptimizedFullscreen) 862 866 { 863 867 UNUSED_PARAM(videoLayer); … … 993 997 } 994 998 995 void WebVideoFullscreenInterfaceAVKit::exitFullscreen( WebCore::IntRectfinalRect)999 void WebVideoFullscreenInterfaceAVKit::exitFullscreen(const WebCore::IntRect& finalRect) 996 1000 { 997 1001 RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this); … … 1013 1017 } 1014 1018 1015 void WebVideoFullscreenInterfaceAVKit::exitFullscreenInternal( WebCore::IntRectfinalRect)1019 void WebVideoFullscreenInterfaceAVKit::exitFullscreenInternal(const WebCore::IntRect& finalRect) 1016 1020 { 1017 1021 [m_playerViewController setShowsPlaybackControls:NO]; … … 1144 1148 } 1145 1149 1150 void WebVideoFullscreenInterfaceAVKit::preparedToReturnToInline(bool visible, const IntRect& inlineRect) 1151 { 1152 RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this); 1153 dispatch_async(dispatch_get_main_queue(), [strongThis, visible, inlineRect] { 1154 if (strongThis->m_playerController.get().exitOptimizedCallback) { 1155 1156 if (strongThis->m_viewController) 1157 [strongThis->m_playerViewController view].frame = [strongThis->m_parentView convertRect:inlineRect toView:nil]; 1158 else 1159 [strongThis->m_playerViewController view].frame = inlineRect; 1160 1161 strongThis->m_playerController.get().exitOptimizedCallback(visible); 1162 } 1163 }); 1164 } 1165 1146 1166 void WebVideoFullscreenInterfaceAVKit::setIsOptimized(bool active) 1147 1167 { … … 1182 1202 } 1183 1203 1184 boolWebVideoFullscreenInterfaceAVKit::fullscreenMayReturnToInline()1185 { 1186 m_fullscreenChangeObserver->fullscreenMayReturnToInline();1187 return true;1204 void WebVideoFullscreenInterfaceAVKit::fullscreenMayReturnToInline() 1205 { 1206 if (m_fullscreenChangeObserver) 1207 m_fullscreenChangeObserver->fullscreenMayReturnToInline(); 1188 1208 } 1189 1209 -
trunk/Source/WebCore/rendering/ScrollBehavior.cpp
r177050 r181173 47 47 namespace WebCore { 48 48 49 const ScrollAlignment ScrollAlignment::alignCenterIfNotVisible = { noScroll, alignCenter, noScroll }; 50 const ScrollAlignment ScrollAlignment::alignToEdgeIfNotVisible = { noScroll, alignToClosestEdge, noScroll }; 49 51 const ScrollAlignment ScrollAlignment::alignCenterIfNeeded = { noScroll, alignCenter, alignToClosestEdge }; 50 52 WEBCORE_EXPORT const ScrollAlignment ScrollAlignment::alignToEdgeIfNeeded = { noScroll, alignToClosestEdge, alignToClosestEdge }; -
trunk/Source/WebCore/rendering/ScrollBehavior.h
r180301 r181173 62 62 static ScrollBehavior getHiddenBehavior(const ScrollAlignment& s) { return s.m_rectHidden; } 63 63 64 static const ScrollAlignment alignCenterIfNotVisible; 65 static const ScrollAlignment alignToEdgeIfNotVisible; 64 66 static const ScrollAlignment alignCenterIfNeeded; 65 67 WEBCORE_EXPORT static const ScrollAlignment alignToEdgeIfNeeded; -
trunk/Source/WebKit2/ChangeLog
r181162 r181173 1 2015-03-06 Jeremy Jones <jeremyj@apple.com> 2 3 Scroll to make the video element visible when exiting fullscreen. 4 https://bugs.webkit.org/show_bug.cgi?id=141439 5 6 Reviewed by Simon Fraser. 7 8 This patch will restore interface state when exiting fullscreen. 9 Adds preparedToReturnToInline to continue exiting once the interface is updated. 10 11 * UIProcess/ios/WebVideoFullscreenManagerProxy.h: 12 * UIProcess/ios/WebVideoFullscreenManagerProxy.messages.in: 13 * UIProcess/ios/WebVideoFullscreenManagerProxy.mm: 14 (WebKit::WebVideoFullscreenManagerProxy::setupFullscreenWithID): 15 (WebKit::WebVideoFullscreenManagerProxy::fullscreenMayReturnToInline): 16 (WebKit::WebVideoFullscreenManagerProxy::preparedToReturnToInline): added. 17 * WebProcess/ios/WebVideoFullscreenManager.h: 18 * WebProcess/ios/WebVideoFullscreenManager.messages.in: 19 * WebProcess/ios/WebVideoFullscreenManager.mm: 20 (WebKit::WebVideoFullscreenManager::fullscreenMayReturnToInline): 21 1 22 2015-03-06 Antti Koivisto <antti@apple.com> 2 23 -
trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.h
r178660 r181173 56 56 57 57 // Translate to FullscreenInterface 58 void setupFullscreenWithID(uint32_t, WebCore::IntRectinitialRect, float hostingDeviceScaleFactor, WebCore::HTMLMediaElement::VideoFullscreenMode, bool allowOptimizedFullscreen);58 void setupFullscreenWithID(uint32_t, const WebCore::IntRect& initialRect, float hostingDeviceScaleFactor, WebCore::HTMLMediaElement::VideoFullscreenMode, bool allowOptimizedFullscreen); 59 59 void setSeekableRangesVector(const Vector<std::pair<double, double>>&); 60 60 void setExternalPlaybackProperties(bool enabled, uint32_t targetType, String localizedDeviceName); 61 61 void fullscreenModeChanged(WebCore::HTMLMediaElement::VideoFullscreenMode) override; 62 62 void preparedToReturnToInline(bool visible, const WebCore::IntRect& inlineRect) override; 63 63 64 // Fullscreen Observer 64 65 virtual void didSetupFullscreen() override; -
trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.messages.in
r179480 r181173 37 37 ExitFullscreen(WebCore::IntRect finalRect) 38 38 CleanupFullscreen() 39 PreparedToReturnToInline(bool visible, WebCore::IntRect inlineRect) 39 40 } 40 41 #endif -
trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.mm
r179574 r181173 76 76 } 77 77 78 void WebVideoFullscreenManagerProxy::setupFullscreenWithID(uint32_t videoLayerID, WebCore::IntRectinitialRect, float hostingDeviceScaleFactor, HTMLMediaElement::VideoFullscreenMode videoFullscreenMode, bool allowOptimizedFullscreen)78 void WebVideoFullscreenManagerProxy::setupFullscreenWithID(uint32_t videoLayerID, const WebCore::IntRect& initialRect, float hostingDeviceScaleFactor, HTMLMediaElement::VideoFullscreenMode videoFullscreenMode, bool allowOptimizedFullscreen) 79 79 { 80 80 ASSERT(videoLayerID); … … 120 120 void WebVideoFullscreenManagerProxy::fullscreenMayReturnToInline() 121 121 { 122 bool isViewVisible = m_page->isViewVisible(); 123 m_page->send(Messages::WebVideoFullscreenManager::FullscreenMayReturnToInline(isViewVisible), m_page->pageID()); 124 } 125 126 void WebVideoFullscreenManagerProxy::preparedToReturnToInline(bool visible, const WebCore::IntRect& inlineRect) 127 { 122 128 m_page->fullscreenMayReturnToInline(); 129 WebVideoFullscreenInterfaceAVKit::preparedToReturnToInline(visible, inlineRect); 123 130 } 124 131 -
trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.h
r179480 r181173 87 87 virtual void didCleanupFullscreen(); 88 88 virtual void setVideoLayerGravityEnum(unsigned); 89 virtual void fullscreenMayReturnToInline(bool isPageVisible); 89 90 void setVideoLayerFrameFenced(WebCore::FloatRect bounds, IPC::Attachment fencePort); 90 91 -
trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.messages.in
r177012 r181173 43 43 SelectLegibleMediaOption(uint64_t index) 44 44 fullscreenModeChanged(WebCore::HTMLMediaElement::VideoFullscreenMode videoFullscreenMode) 45 FullscreenMayReturnToInline(bool isPageVisible) 45 46 } 46 47 #endif -
trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.mm
r179480 r181173 259 259 } 260 260 261 void WebVideoFullscreenManager::fullscreenMayReturnToInline(bool isPageVisible) 262 { 263 if (!isPageVisible) 264 m_videoElement->scrollIntoViewIfNotVisible(false); 265 m_page->send(Messages::WebVideoFullscreenManagerProxy::PreparedToReturnToInline(true, clientRectForElement(m_videoElement.get())), m_page->pageID()); 266 } 267 261 268 void WebVideoFullscreenManager::setVideoLayerFrameFenced(WebCore::FloatRect bounds, IPC::Attachment fencePort) 262 269 {
Note: See TracChangeset
for help on using the changeset viewer.