[Blackberry] WebKit's fullscreen mode needs to notify page client.

https://bugs.webkit.org/show_bug.cgi?id=87337

Patch by Chris Guan <chris.guan@torchmobile.com.cn> on 2012-05-31
Reviewed by Antonio Gomes.

Move "fullScreenVideoCapable" into webpagePrivate to make code
clean for "fullScreenForElement/Node" of cromeClientBlackberry,
All Video checks and code path selections are in webpagePrivate now.
For some UX and secure reasons, we could not apply fullscreen capacity
for all elements, So we use client's fullscreenStart/Stop only for
those video elements and those elements containing video tags.

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::webContext):
(BlackBerry::WebKit::WebPage::notifyFullScreenVideoExited):
(WebKit):
(BlackBerry::WebKit::containsVideoTags):
(BlackBerry::WebKit::WebPagePrivate::enterFullScreenForElement):
(BlackBerry::WebKit::WebPagePrivate::exitFullScreenForElement):
* Api/WebPageClient.h:
* Api/WebPage_p.h:
(WebCore):
(WebPagePrivate):
* WebCoreSupport/ChromeClientBlackBerry.cpp:
(WebCore::ChromeClientBlackBerry::enterFullScreenForElement):
(WebCore::ChromeClientBlackBerry::exitFullScreenForElement):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@119119 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d218b346
......@@ -160,8 +160,8 @@
#endif
#if ENABLE(ACCELERATED_2D_CANVAS)
#include "SharedGraphicsContext3D.h"
#include "GrContext.h"
#include "SharedGraphicsContext3D.h"
#endif
#if ENABLE(REQUEST_ANIMATION_FRAME)
......@@ -2260,7 +2260,7 @@ Platform::WebContext WebPagePrivate::webContext(TargetDetectionStrategy strategy
}
if (node->isTextNode()) {
Text* curText = static_cast<Text*>(node.get());
Text* curText = toText(node.get());
if (!curText->wholeText().isEmpty())
context.setText(curText->wholeText().utf8().data());
}
......@@ -5482,8 +5482,15 @@ void WebPage::notifyFullScreenVideoExited(bool done)
{
UNUSED_PARAM(done);
#if ENABLE(VIDEO)
if (HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(d->m_fullscreenVideoNode.get()))
mediaElement->exitFullscreen();
if (d->m_webSettings->fullScreenVideoCapable()) {
if (HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(d->m_fullscreenVideoNode.get()))
mediaElement->exitFullscreen();
} else {
#if ENABLE(FULLSCREEN_API)
if (Element* element = static_cast<Element*>(d->m_fullscreenVideoNode.get()))
element->document()->webkitCancelFullScreen();
#endif
}
#endif
}
......@@ -6037,6 +6044,60 @@ void WebPagePrivate::exitFullscreenForNode(Node* node)
#endif
}
#if ENABLE(FULLSCREEN_API)
// TODO: We should remove this helper class when we decide to support all elements.
static bool containsVideoTags(Element* element)
{
for (Node* node = element->firstChild(); node; node = node->traverseNextNode(element)) {
if (node->hasTagName(HTMLNames::videoTag))
return true;
}
return false;
}
void WebPagePrivate::enterFullScreenForElement(Element* element)
{
#if ENABLE(VIDEO)
// TODO: We should not check video tag when we decide to support all elements.
if (!element || (!element->hasTagName(HTMLNames::videoTag) && !containsVideoTags(element)))
return;
if (m_webSettings->fullScreenVideoCapable()) {
// The Browser chrome has its own fullscreen video widget it wants to
// use, and this is a video element. The only reason that
// webkitWillEnterFullScreenForElement() and
// webkitDidEnterFullScreenForElement() are still called in this case
// is so that exitFullScreenForElement() gets called later.
enterFullscreenForNode(element);
} else {
// No fullscreen video widget has been made available by the Browser
// chrome, or this is not a video element. The webkitRequestFullScreen
// Javascript call is often made on a div element.
// This is where we would hide the browser's chrome if we wanted to.
client()->fullscreenStart();
m_fullscreenVideoNode = element;
}
#endif
}
void WebPagePrivate::exitFullScreenForElement(Element* element)
{
#if ENABLE(VIDEO)
// TODO: We should not check video tag when we decide to support all elements.
if (!element || !element->hasTagName(HTMLNames::videoTag))
return;
if (m_webSettings->fullScreenVideoCapable()) {
// The Browser chrome has its own fullscreen video widget.
exitFullscreenForNode(element);
} else {
// This is where we would restore the browser's chrome
// if hidden above.
client()->fullscreenStop();
m_fullscreenVideoNode = 0;
}
#endif
}
#endif
void WebPagePrivate::didChangeSettings(WebSettings* webSettings)
{
Settings* coreSettings = m_page->settings();
......
......@@ -231,6 +231,7 @@ public:
virtual bool downloadAllowed(const char* url) = 0;
virtual void downloadRequested(Platform::FilterStream*, const WebString& suggestedFilename) = 0;
virtual int fullscreenStart() = 0;
virtual int fullscreenStart(const char* contextName, Platform::Graphics::Window*, unsigned x, unsigned y, unsigned width, unsigned height) = 0;
virtual int fullscreenStop() = 0;
......
......@@ -41,6 +41,7 @@ namespace WebCore {
class AutofillManager;
class DOMWrapperWorld;
class Document;
class Element;
class Frame;
class GeolocationControllerClientBlackBerry;
class GraphicsLayerBlackBerry;
......@@ -191,6 +192,10 @@ public:
// Called from within WebKit via ChromeClientBlackBerry.
void enterFullscreenForNode(WebCore::Node*);
void exitFullscreenForNode(WebCore::Node*);
#if ENABLE(FULLSCREEN_API)
void enterFullScreenForElement(WebCore::Element*);
void exitFullScreenForElement(WebCore::Element*);
#endif
void contentsSizeChanged(const WebCore::IntSize&);
void overflowExceedsContentsSize() { m_overflowExceedsContentsSize = true; }
void layoutFinished();
......
2012-05-31 Chris Guan <chris.guan@torchmobile.com.cn>
[Blackberry] WebKit's fullscreen mode needs to notify page client.
https://bugs.webkit.org/show_bug.cgi?id=87337
Reviewed by Antonio Gomes.
Move "fullScreenVideoCapable" into webpagePrivate to make code
clean for "fullScreenForElement/Node" of cromeClientBlackberry,
All Video checks and code path selections are in webpagePrivate now.
For some UX and secure reasons, we could not apply fullscreen capacity
for all elements, So we use client's fullscreenStart/Stop only for
those video elements and those elements containing video tags.
* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::webContext):
(BlackBerry::WebKit::WebPage::notifyFullScreenVideoExited):
(WebKit):
(BlackBerry::WebKit::containsVideoTags):
(BlackBerry::WebKit::WebPagePrivate::enterFullScreenForElement):
(BlackBerry::WebKit::WebPagePrivate::exitFullScreenForElement):
* Api/WebPageClient.h:
* Api/WebPage_p.h:
(WebCore):
(WebPagePrivate):
* WebCoreSupport/ChromeClientBlackBerry.cpp:
(WebCore::ChromeClientBlackBerry::enterFullScreenForElement):
(WebCore::ChromeClientBlackBerry::exitFullScreenForElement):
2012-05-31 Arvid Nilsson <anilsson@rim.com>
[BlackBerry] Crash when closing web page if selection is active
......
......@@ -727,32 +727,14 @@ bool ChromeClientBlackBerry::supportsFullScreenForElement(const WebCore::Element
void ChromeClientBlackBerry::enterFullScreenForElement(WebCore::Element* element)
{
element->document()->webkitWillEnterFullScreenForElement(element);
if (supportsFullscreenForNode(element) && m_webPagePrivate->m_webSettings->fullScreenVideoCapable()) {
// The Browser chrome has its own fullscreen video widget it wants to
// use, and this is a video element. The only reason that
// webkitWillEnterFullScreenForElement() and
// webkitDidEnterFullScreenForElement() are still called in this case
// is so that exitFullScreenForElement() gets called later.
enterFullscreenForNode(element);
} else {
// No fullscreen video widget has been made available by the Browser
// chrome, or this is not a video element. The webkitRequestFullScreen
// Javascript call is often made on a div element.
// This is where we would hide the browser's chrome if we wanted to.
}
m_webPagePrivate->enterFullScreenForElement(element);
element->document()->webkitDidEnterFullScreenForElement(element);
}
void ChromeClientBlackBerry::exitFullScreenForElement(WebCore::Element* element)
{
element->document()->webkitWillExitFullScreenForElement(element);
if (supportsFullscreenForNode(element) && m_webPagePrivate->m_webSettings->fullScreenVideoCapable()) {
// The Browser chrome has its own fullscreen video widget.
exitFullscreenForNode(element);
} else {
// This is where we would restore the browser's chrome
// if hidden above.
}
m_webPagePrivate->exitFullScreenForElement(element);
element->document()->webkitDidExitFullScreenForElement(element);
}
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment