When exiting fullscreen, call a JS method immediately to implement the style changes for the presentation mode change right away
https://bugs.webkit.org/show_bug.cgi?id=157359
Reviewed by Eric Carlson.
No new tests as this is done to just mitigate a visual glitch.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::exitFullscreen):
(WebCore::HTMLMediaElement::updateMediaControlsAfterPresentationModeChange):
* html/HTMLMediaElement.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@200462 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 7661708..9f02ec2 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,17 @@
+2016-05-04 Ada Chan <adachan@apple.com>
+
+ When exiting fullscreen, call a JS method immediately to implement the style changes for the presentation mode change right away
+ https://bugs.webkit.org/show_bug.cgi?id=157359
+
+ Reviewed by Eric Carlson.
+
+ No new tests as this is done to just mitigate a visual glitch.
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::exitFullscreen):
+ (WebCore::HTMLMediaElement::updateMediaControlsAfterPresentationModeChange):
+ * html/HTMLMediaElement.h:
+
2016-05-04 Alex Christensen <achristensen@webkit.org>
Blocked redirected main resource requests need descriptive errors
diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp
index 90400d2..bb9197b 100644
--- a/Source/WebCore/html/HTMLMediaElement.cpp
+++ b/Source/WebCore/html/HTMLMediaElement.cpp
@@ -5395,6 +5395,9 @@
ASSERT(m_videoFullscreenMode != VideoFullscreenModeNone);
VideoFullscreenMode oldVideoFullscreenMode = m_videoFullscreenMode;
fullscreenModeChanged(VideoFullscreenModeNone);
+#if ENABLE(MEDIA_CONTROLS_SCRIPT)
+ updateMediaControlsAfterPresentationModeChange();
+#endif
if (hasMediaControls())
mediaControls()->exitedFullscreen();
if (document().page() && is<HTMLVideoElement>(*this)) {
@@ -6540,6 +6543,35 @@
document().unregisterForPageScaleFactorChangedCallbacks(this);
}
+void HTMLMediaElement::updateMediaControlsAfterPresentationModeChange()
+{
+ DOMWrapperWorld& world = ensureIsolatedWorld();
+ ScriptController& scriptController = document().frame()->script();
+ JSDOMGlobalObject* globalObject = JSC::jsCast<JSDOMGlobalObject*>(scriptController.globalObject(world));
+ JSC::ExecState* exec = globalObject->globalExec();
+ JSC::JSLockHolder lock(exec);
+
+ JSC::JSValue controllerValue = controllerJSValue(*exec, *globalObject, *this);
+ JSC::JSObject* controllerObject = controllerValue.toObject(exec);
+
+ if (exec->hadException())
+ return;
+
+ JSC::JSValue functionValue = controllerObject->get(exec, JSC::Identifier::fromString(exec, "handlePresentationModeChange"));
+ if (exec->hadException() || functionValue.isUndefinedOrNull())
+ return;
+
+ JSC::JSObject* function = functionValue.toObject(exec);
+ ASSERT(!exec->hadException());
+ JSC::CallData callData;
+ JSC::CallType callType = function->methodTable()->getCallData(function, callData);
+ if (callType == JSC::CallType::None)
+ return;
+
+ JSC::MarkedArgumentBuffer argList;
+ JSC::call(exec, function, callType, callData, controllerObject, argList);
+}
+
void HTMLMediaElement::pageScaleFactorChanged()
{
Page* page = document().page();
diff --git a/Source/WebCore/html/HTMLMediaElement.h b/Source/WebCore/html/HTMLMediaElement.h
index 142562c..8d09129 100644
--- a/Source/WebCore/html/HTMLMediaElement.h
+++ b/Source/WebCore/html/HTMLMediaElement.h
@@ -483,6 +483,7 @@
#if ENABLE(MEDIA_CONTROLS_SCRIPT)
bool mediaControlsDependOnPageScaleFactor() const { return m_mediaControlsDependOnPageScaleFactor; }
void setMediaControlsDependOnPageScaleFactor(bool);
+ void updateMediaControlsAfterPresentationModeChange();
#endif
void scheduleEvent(const AtomicString& eventName);