https://bugs.webkit.org/show_bug.cgi?id=147182
Reviewed by Simon Fraser.
Source/WebCore:
Notify the MediaDocument that it's underlying media element has changed its natural size, either when
the media engine notifies us that the size changed, or when the ready state progresses to HAVE_METADATA.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::setReadyState): Notify the media document.
(WebCore::HTMLMediaElement::mediaPlayerSizeChanged): Ditto.
* html/MediaDocument.cpp:
(WebCore::MediaDocument::mediaElementNaturalSizeChanged): Pass to the chrome client.
* html/MediaDocument.h:
* page/ChromeClient.h:
Source/WebKit2:
Pipe notifications of media document natural size changes up from the chrome client, through
to the UIProcess, through the page client, through the WKWebView, to the UIDelegate.
* UIProcess/API/APIUIClient.h:
(API::UIClient::mediaDocumentNaturalSizeChanged):
* UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _mediaDocumentNaturalSizeChanged:]):
* UIProcess/API/Cocoa/WKWebViewInternal.h:
* UIProcess/Cocoa/UIDelegate.h:
* UIProcess/Cocoa/UIDelegate.mm:
(WebKit::UIDelegate::setDelegate):
(WebKit::UIDelegate::UIClient::mediaDocumentNaturalSizeChanged):
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::mediaDocumentNaturalSizeChanged):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::mediaDocumentNaturalSizeChanged):
* UIProcess/mac/PageClientImpl.h:
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::mediaDocumentNaturalSizeChanged):
* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::mediaDocumentNaturalSizeChanged):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::mediaDocumentNaturalSizeChanged):
* WebProcess/WebPage/WebPage.h:
* UIProcess/API/gtk/PageClientImpl.h: Add default, empty implementation of new pure-virtual method.
* UIProcess/efl/WebViewEfl.h: Ditto.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@187272
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2015-07-21 Jer Noble <jer.noble@apple.com>
+
+ Notify the UI delegate when a MediaDocument's natural size changes
+ https://bugs.webkit.org/show_bug.cgi?id=147182
+
+ Reviewed by Simon Fraser.
+
+ Notify the MediaDocument that it's underlying media element has changed its natural size, either when
+ the media engine notifies us that the size changed, or when the ready state progresses to HAVE_METADATA.
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::setReadyState): Notify the media document.
+ (WebCore::HTMLMediaElement::mediaPlayerSizeChanged): Ditto.
+ * html/MediaDocument.cpp:
+ (WebCore::MediaDocument::mediaElementNaturalSizeChanged): Pass to the chrome client.
+ * html/MediaDocument.h:
+ * page/ChromeClient.h:
+
2015-07-22 Simon Fraser <simon.fraser@apple.com>
Layer z-ordering is incorrect when scrolling on page witih position:fixed
if (renderer())
renderer()->updateFromElement();
+ if (is<MediaDocument>(document()))
+ downcast<MediaDocument>(document()).mediaElementNaturalSizeChanged(expandedIntSize(m_player->naturalSize()));
+
logMediaLoadRequest(document().page(), m_player->engineDescription(), String(), true);
}
{
LOG(Media, "HTMLMediaElement::mediaPlayerSizeChanged(%p)", this);
+ if (is<MediaDocument>(document()) && m_player)
+ downcast<MediaDocument>(document()).mediaElementNaturalSizeChanged(expandedIntSize(m_player->naturalSize()));
+
beginProcessingMediaPlayerCallback();
if (renderer())
renderer()->updateFromElement();
#if ENABLE(VIDEO)
#include "MediaDocument.h"
+#include "Chrome.h"
+#include "ChromeClient.h"
#include "DocumentLoader.h"
#include "EventNames.h"
#include "ExceptionCodePlaceholder.h"
}
}
+void MediaDocument::mediaElementNaturalSizeChanged(const IntSize& newSize)
+{
+ if (ownerElement())
+ return;
+
+ if (newSize.isZero())
+ return;
+
+ if (page())
+ page()->chrome().client().mediaDocumentNaturalSizeChanged(newSize);
+}
+
}
#endif
virtual ~MediaDocument();
void mediaElementSawUnsupportedTracks();
+ void mediaElementNaturalSizeChanged(const IntSize&);
String outgoingReferrer() const { return m_outgoingReferrer; }
private:
virtual void playbackTargetPickerClientStateDidChange(uint64_t /*contextId*/, MediaProducer::MediaStateFlags) { }
#endif
+#if ENABLE(VIDEO)
+ virtual void mediaDocumentNaturalSizeChanged(const WebCore::IntSize&) { }
+#endif
+
protected:
virtual ~ChromeClient() { }
};
+2015-07-21 Jer Noble <jer.noble@apple.com>
+
+ Notify the UI delegate when a MediaDocument's natural size changes
+ https://bugs.webkit.org/show_bug.cgi?id=147182
+
+ Reviewed by Simon Fraser.
+
+ Pipe notifications of media document natural size changes up from the chrome client, through
+ to the UIProcess, through the page client, through the WKWebView, to the UIDelegate.
+
+ * UIProcess/API/APIUIClient.h:
+ (API::UIClient::mediaDocumentNaturalSizeChanged):
+ * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _mediaDocumentNaturalSizeChanged:]):
+ * UIProcess/API/Cocoa/WKWebViewInternal.h:
+ * UIProcess/Cocoa/UIDelegate.h:
+ * UIProcess/Cocoa/UIDelegate.mm:
+ (WebKit::UIDelegate::setDelegate):
+ (WebKit::UIDelegate::UIClient::mediaDocumentNaturalSizeChanged):
+ * UIProcess/PageClient.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::mediaDocumentNaturalSizeChanged):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPageProxy.messages.in:
+ * UIProcess/ios/PageClientImplIOS.h:
+ * UIProcess/ios/PageClientImplIOS.mm:
+ (WebKit::PageClientImpl::mediaDocumentNaturalSizeChanged):
+ * UIProcess/mac/PageClientImpl.h:
+ * UIProcess/mac/PageClientImpl.mm:
+ (WebKit::PageClientImpl::mediaDocumentNaturalSizeChanged):
+ * WebProcess/WebCoreSupport/WebChromeClient.h:
+ * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+ (WebKit::WebChromeClient::mediaDocumentNaturalSizeChanged):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::mediaDocumentNaturalSizeChanged):
+ * WebProcess/WebPage/WebPage.h:
+ * UIProcess/API/gtk/PageClientImpl.h: Add default, empty implementation of new pure-virtual method.
+ * UIProcess/efl/WebViewEfl.h: Ditto.
+
2015-07-23 Enrica Casucci <enrica@apple.com>
Removing one incorrect annotation from the previous change.
#endif
virtual void didClickAutoFillButton(WebKit::WebPageProxy&, API::Object*) { }
+
+#if ENABLE(VIDEO)
+ virtual void mediaDocumentNaturalSizeChanged(const WebCore::IntSize&) { }
+#endif
};
} // namespace API
- (void)_webViewFullscreenMayReturnToInline:(WKWebView *)webView;
- (void)_webViewDidEnterFullscreen:(WKWebView *)webView WK_AVAILABLE(WK_MAC_TBA, 8_3);
- (void)_webViewDidExitFullscreen:(WKWebView *)webView WK_AVAILABLE(WK_MAC_TBA, 8_3);
+- (void)_webView:(WKWebView *)webView mediaDocumentNaturalSizeChanged:(CGSize)size;
#if TARGET_OS_IPHONE
- (BOOL)_webView:(WKWebView *)webView shouldIncludeAppLinkActionsForElement:(_WKActivatedElementInfo *)element WK_AVAILABLE(NA, WK_IOS_TBA);
}
#endif // PLATFORM(MAC)
+#if ENABLE(VIDEO)
+- (void)_mediaDocumentNaturalSizeChanged:(NSSize)newSize
+{
+ id <WKUIDelegatePrivate> uiDelegate = static_cast<id <WKUIDelegatePrivate>>([self UIDelegate]);
+ if ([uiDelegate respondsToSelector:@selector(_webView:mediaDocumentNaturalSizeChanged:)])
+ [uiDelegate _webView:self mediaDocumentNaturalSizeChanged:newSize];
+}
+#endif
+
@end
@implementation WKWebView (WKPrivate)
- (WKPageRef)_pageForTesting;
+#if ENABLE(VIDEO)
+- (void)_mediaDocumentNaturalSizeChanged:(CGSize)newSize;
+#endif
+
@end
WKWebView* fromWebPageProxy(WebKit::WebPageProxy&);
virtual void didChangeBackgroundColor() override;
+#if ENABLE(VIDEO)
+ virtual void mediaDocumentNaturalSizeChanged(const WebCore::IntSize&) override { }
+#endif
+
virtual void refView() override;
virtual void derefView() override;
virtual RetainPtr<NSArray> actionsForElement(_WKActivatedElementInfo *, RetainPtr<NSArray> defaultActions) override;
virtual void didNotHandleTapAsClick(const WebCore::IntPoint&) override;
#endif
+#if ENABLE(VIDEO)
+ virtual void mediaDocumentNaturalSizeChanged(const WebCore::IntSize&) override;
+#endif
UIDelegate& m_uiDelegate;
};
bool webViewActionsForElementDefaultActions : 1;
bool webViewDidNotHandleTapAsClickAtPoint : 1;
#endif
+#if ENABLE(VIDEO)
+ bool webViewMediaDocumentNaturalSizeChanged : 1;
+#endif
} m_delegateMethods;
};
m_delegateMethods.webViewActionsForElementDefaultActions = [delegate respondsToSelector:@selector(_webView:actionsForElement:defaultActions:)];
m_delegateMethods.webViewDidNotHandleTapAsClickAtPoint = [delegate respondsToSelector:@selector(_webView:didNotHandleTapAsClickAtPoint:)];
#endif
+#if ENABLE(VIDEO)
+ m_delegateMethods.webViewMediaDocumentNaturalSizeChanged = [delegate respondsToSelector:@selector(_webView:mediaDocumentNaturalSizeChanged:)];
+#endif
}
UIDelegate::UIClient::UIClient(UIDelegate& uiDelegate)
}
#endif
+#if ENABLE(VIDEO)
+void UIDelegate::UIClient::mediaDocumentNaturalSizeChanged(const WebCore::IntSize& newSize)
+{
+ if (!m_uiDelegate.m_delegateMethods.webViewMediaDocumentNaturalSizeChanged)
+ return;
+
+ auto delegate = m_uiDelegate.m_delegate.get();
+ if (!delegate)
+ return;
+
+ [static_cast<id <WKUIDelegatePrivate>>(delegate) _webView:m_uiDelegate.m_webView mediaDocumentNaturalSizeChanged:newSize];
+}
+#endif
+
} // namespace WebKit
#endif // WK_API_ENABLED
virtual WebCore::WebMediaSessionManager& mediaSessionManager() = 0;
#endif
+#if ENABLE(VIDEO)
+ virtual void mediaDocumentNaturalSizeChanged(const WebCore::IntSize&) = 0;
+#endif
+
virtual void refView() = 0;
virtual void derefView() = 0;
};
}
#endif
+#if ENABLE(VIDEO)
+void WebPageProxy::mediaDocumentNaturalSizeChanged(const WebCore::IntSize& newSize)
+{
+ m_uiClient->mediaDocumentNaturalSizeChanged(newSize);
+}
+#endif
+
void WebPageProxy::setShouldDispatchFakeMouseMoveEvents(bool shouldDispatchFakeMouseMoveEvents)
{
m_process->send(Messages::WebPage::SetShouldDispatchFakeMouseMoveEvents(shouldDispatchFakeMouseMoveEvents), m_pageID);
void useFixedLayoutDidChange(bool useFixedLayout) { m_useFixedLayout = useFixedLayout; }
void fixedLayoutSizeDidChange(WebCore::IntSize fixedLayoutSize) { m_fixedLayoutSize = fixedLayoutSize; }
+#if ENABLE(VIDEO)
+ void mediaDocumentNaturalSizeChanged(const WebCore::IntSize&);
+#endif
+
void handleAutoFillButtonClick(const UserData&);
void handleMessage(IPC::Connection&, const String& messageName, const UserData& messageBody);
PlaybackTargetPickerClientStateDidChange(uint64_t contextId, unsigned mediaState)
#endif
+#if ENABLE(VIDEO)
+ MediaDocumentNaturalSizeChanged(WebCore::IntSize newSize)
+#endif
+
UseFixedLayoutDidChange(bool useFixedLayout)
FixedLayoutSizeDidChange(WebCore::IntSize fixedLayoutSize)
}
virtual void didFinishLoadForMainFrame() override final { }
virtual void didSameDocumentNavigationForMainFrame(SameDocumentNavigationType) override final { }
+#if ENABLE(VIDEO)
+ virtual void mediaDocumentNaturalSizeChanged(const WebCore::IntSize&) override final { }
+#endif
+
virtual void refView() override final { }
virtual void derefView() override final { }
virtual void didChangeBackgroundColor() override;
+#if ENABLE(VIDEO)
+ virtual void mediaDocumentNaturalSizeChanged(const WebCore::IntSize&) override;
+#endif
+
virtual void refView() override;
virtual void derefView() override;
[m_webView _updateScrollViewBackground];
}
+#if ENABLE(VIDEO)
+void PageClientImpl::mediaDocumentNaturalSizeChanged(const IntSize& newSize)
+{
+ [m_webView _mediaDocumentNaturalSizeChanged:newSize];
+}
+#endif
+
+
void PageClientImpl::refView()
{
[m_contentView retain];
virtual void didChangeBackgroundColor() override;
+#if ENABLE(VIDEO)
+ virtual void mediaDocumentNaturalSizeChanged(const WebCore::IntSize&) override;
+#endif
+
WKView *m_wkView;
WKWebView *m_webView;
RetainPtr<WKEditorUndoTargetObjC> m_undoTarget;
}
#endif
+#if ENABLE(VIDEO)
+void PageClientImpl::mediaDocumentNaturalSizeChanged(const IntSize& newSize)
+{
+ [m_webView _mediaDocumentNaturalSizeChanged:newSize];
+}
+#endif
+
void PageClientImpl::refView()
{
CFRetain(m_wkView);
}
#endif
+#if ENABLE(VIDEO)
+void WebChromeClient::mediaDocumentNaturalSizeChanged(const WebCore::IntSize& newSize)
+{
+ m_page->mediaDocumentNaturalSizeChanged(newSize);
+}
+#endif
} // namespace WebKit
virtual void playbackTargetPickerClientStateDidChange(uint64_t, WebCore::MediaProducer::MediaStateFlags) override;
#endif
+#if ENABLE(VIDEO)
+ virtual void mediaDocumentNaturalSizeChanged(const WebCore::IntSize&) override;
+#endif
+
String m_cachedToolTip;
mutable RefPtr<WebFrame> m_cachedFrameSetLargestFrame;
mutable bool m_cachedMainFrameHasHorizontalScrollbar;
m_page->setUserContentExtensionsEnabled(userContentExtensionsEnabled);
}
+#if ENABLE(VIDEO)
+void WebPage::mediaDocumentNaturalSizeChanged(const IntSize& newSize)
+{
+ send(Messages::WebPageProxy::MediaDocumentNaturalSizeChanged(newSize));
+}
+#endif
+
} // namespace WebKit
void setInputMethodState(bool);
#endif
+#if ENABLE(VIDEO)
+ void mediaDocumentNaturalSizeChanged(const WebCore::IntSize&);
+#endif
+
private:
WebPage(uint64_t pageID, const WebPageCreationParameters&);