summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/html
diff options
context:
space:
mode:
authorTeng-Hui Zhu <ztenghui@google.com>2011-08-18 17:03:04 -0700
committerTeng-Hui Zhu <ztenghui@google.com>2011-08-19 09:23:38 -0700
commit0676d61efc26679f7a1ba9e9a72daf8e802d978c (patch)
treebcde38bed2b0dbcc0a6cf1219284b580df0c8479 /Source/WebCore/html
parentbd7e9ea6769039d66b97b4286e096416b53bdc4a (diff)
downloadexternal_webkit-0676d61efc26679f7a1ba9e9a72daf8e802d978c.zip
external_webkit-0676d61efc26679f7a1ba9e9a72daf8e802d978c.tar.gz
external_webkit-0676d61efc26679f7a1ba9e9a72daf8e802d978c.tar.bz2
Show/hide HTML5 video control properly according to the touch event
Due to the webkit merge, some code of handling touch and control is gone. Now basically add this functionality back. Refer to the original CL : c/101875 bug:5137664 Change-Id: I951c88cf8fa86061a13465f966fb291706104d8f
Diffstat (limited to 'Source/WebCore/html')
-rw-r--r--Source/WebCore/html/HTMLMediaElement.cpp22
-rw-r--r--Source/WebCore/html/HTMLMediaElement.h4
2 files changed, 24 insertions, 2 deletions
diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp
index a9f025f..93bd09e 100644
--- a/Source/WebCore/html/HTMLMediaElement.cpp
+++ b/Source/WebCore/html/HTMLMediaElement.cpp
@@ -79,6 +79,11 @@
#include "Widget.h"
#endif
+#if PLATFORM(ANDROID)
+// For every touch, show the media control for 4 seconds.
+#define TOUCH_DELAY 4
+#endif
+
using namespace std;
namespace WebCore {
@@ -171,6 +176,9 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document* docum
, m_dispatchingCanPlayEvent(false)
, m_loadInitiatedByUserGesture(false)
, m_completelyLoaded(false)
+#if PLATFORM(ANDROID)
+ , m_lastTouch(0)
+#endif
{
LOG(Media, "HTMLMediaElement::HTMLMediaElement");
document->registerForDocumentActivationCallbacks(this);
@@ -1626,8 +1634,13 @@ void HTMLMediaElement::playbackProgressTimerFired(Timer<HTMLMediaElement>*)
scheduleTimeupdateEvent(true);
if (hasMediaControls()) {
- if (!m_mouseOver && controls() && hasVideo())
+
+ if (!m_mouseOver && controls() && hasVideo()) {
+#if PLATFORM(ANDROID)
+ if (WTF::currentTime() - m_lastTouch > TOUCH_DELAY)
+#endif
mediaControls()->makeTransparent();
+ }
mediaControls()->playbackProgressed();
}
// FIXME: deal with cue ranges here
@@ -2373,8 +2386,13 @@ void HTMLMediaElement::defaultEventHandler(Event* event)
}
#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
- if (event->isTouchEvent())
+ if (event->isTouchEvent()) {
m_mouseOver = !(event->type() == eventNames().touchendEvent || event->type() == eventNames().touchcancelEvent);
+ if (m_mouseOver && hasMediaControls() && controls() && !canPlay()) {
+ m_lastTouch = WTF::currentTime();
+ mediaControls()->makeOpaque();
+ }
+ }
#endif
HTMLElement::defaultEventHandler(event);
diff --git a/Source/WebCore/html/HTMLMediaElement.h b/Source/WebCore/html/HTMLMediaElement.h
index 604cdf8..987cf87 100644
--- a/Source/WebCore/html/HTMLMediaElement.h
+++ b/Source/WebCore/html/HTMLMediaElement.h
@@ -417,6 +417,10 @@ private:
bool m_dispatchingCanPlayEvent : 1;
bool m_loadInitiatedByUserGesture : 1;
bool m_completelyLoaded : 1;
+
+#if PLATFORM(ANDROID)
+ double m_lastTouch;
+#endif
};
} //namespace