summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--V8Binding/jni/jni_runtime.cpp15
-rw-r--r--V8Binding/jni/jni_runtime.h28
-rw-r--r--WebCore/Android.v8bindings.mk2
-rw-r--r--WebCore/bridge/Bridge.h1
-rw-r--r--WebCore/bridge/jni/v8/JNIBridgeV8.cpp44
-rw-r--r--WebCore/bridge/jni/v8/JNIBridgeV8.h60
-rw-r--r--WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp1
-rw-r--r--WebCore/bridge/jni/v8/JavaClassV8.h2
-rw-r--r--WebCore/dom/Document.cpp11
-rw-r--r--WebCore/dom/Node.cpp12
-rw-r--r--WebCore/dom/Touch.cpp17
-rw-r--r--WebCore/dom/Touch.h4
-rw-r--r--WebCore/history/CachedFrame.cpp14
-rw-r--r--WebCore/loader/EmptyClients.h4
-rw-r--r--WebCore/page/ChromeClient.h2
-rw-r--r--WebCore/page/EventHandler.cpp8
-rw-r--r--WebCore/platform/graphics/android/AndroidAnimation.cpp83
-rw-r--r--WebCore/platform/graphics/android/AndroidAnimation.h66
-rw-r--r--WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp34
-rw-r--r--WebCore/platform/graphics/android/GraphicsLayerAndroid.h3
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.cpp26
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.h2
-rw-r--r--WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp8
-rw-r--r--WebKit/android/WebCoreSupport/ChromeClientAndroid.h2
-rw-r--r--WebKit/android/jni/WebViewCore.cpp30
-rw-r--r--WebKit/android/jni/WebViewCore.h4
-rw-r--r--WebKit/android/nav/WebView.cpp7
-rw-r--r--WebKit/android/plugins/PluginWidgetAndroid.cpp10
28 files changed, 272 insertions, 228 deletions
diff --git a/V8Binding/jni/jni_runtime.cpp b/V8Binding/jni/jni_runtime.cpp
index 2b9c1cc..3b183bc 100644
--- a/V8Binding/jni/jni_runtime.cpp
+++ b/V8Binding/jni/jni_runtime.cpp
@@ -38,21 +38,6 @@ JavaParameter::JavaParameter(JNIEnv* env, jstring type)
m_JNIType = JNITypeFromClassName(m_type.UTF8String());
}
-JavaField::JavaField(JNIEnv* env, jobject aField)
-{
- // Get field type
- jobject fieldType = callJNIMethod<jobject>(aField, "getType", "()Ljava/lang/Class;");
- jstring fieldTypeName = static_cast<jstring>(callJNIMethod<jobject>(fieldType, "getName", "()Ljava/lang/String;"));
- m_type = JavaString(env, fieldTypeName);
- m_JNIType = JNITypeFromClassName(m_type.UTF8String());
-
- // Get field name
- jstring fieldName = static_cast<jstring>(callJNIMethod<jobject>(aField, "getName", "()Ljava/lang/String;"));
- m_name = JavaString(env, fieldName);
-
- m_field = new JObjectWrapper(aField);
-}
-
JavaMethod::JavaMethod(JNIEnv* env, jobject aMethod)
{
// Get return type
diff --git a/V8Binding/jni/jni_runtime.h b/V8Binding/jni/jni_runtime.h
index 735e2c2..c6565d0 100644
--- a/V8Binding/jni/jni_runtime.h
+++ b/V8Binding/jni/jni_runtime.h
@@ -26,8 +26,8 @@
#ifndef jni_runtime_h
#define jni_runtime_h
+#include "Bridge.h"
#include "JNIUtility.h"
-#include "JavaInstanceV8.h"
#if USE(V8)
#include "JavaStringV8.h"
@@ -37,6 +37,8 @@ namespace JSC {
namespace Bindings {
+typedef const char* RuntimeType;
+
class JavaString {
public:
JavaString()
@@ -68,7 +70,7 @@ public:
JavaParameter(JNIEnv*, jstring type);
virtual ~JavaParameter() { }
- const char* type() const { return m_type.UTF8String(); }
+ RuntimeType type() const { return m_type.UTF8String(); }
JNIType getJNIType() const { return m_JNIType; }
private:
@@ -76,31 +78,13 @@ private:
JNIType m_JNIType;
};
-
-class JavaField {
-public:
- JavaField(JNIEnv*, jobject aField);
-
- const JavaString& name() const { return m_name; }
- const char* type() const { return m_type.UTF8String(); }
-
- JNIType getJNIType() const { return m_JNIType; }
-
-private:
- JavaString m_name;
- JavaString m_type;
- JNIType m_JNIType;
- RefPtr<JObjectWrapper> m_field;
-};
-
-
-class JavaMethod {
+class JavaMethod : public Method {
public:
JavaMethod(JNIEnv*, jobject aMethod);
~JavaMethod();
const JavaString& name() const { return m_name; }
- const char* returnType() const { return m_returnType.UTF8String(); }
+ RuntimeType returnType() const { return m_returnType.UTF8String(); }
JavaParameter* parameterAt(int i) const { return &m_parameters[i]; }
int numParameters() const { return m_numParameters; }
diff --git a/WebCore/Android.v8bindings.mk b/WebCore/Android.v8bindings.mk
index 683de78..ce6c42d 100644
--- a/WebCore/Android.v8bindings.mk
+++ b/WebCore/Android.v8bindings.mk
@@ -31,6 +31,7 @@ BINDING_C_INCLUDES := \
$(LOCAL_PATH)/bindings/v8 \
$(LOCAL_PATH)/bindings/v8/custom \
$(LOCAL_PATH)/bridge \
+ $(LOCAL_PATH)/bridge/jsc \
\
$(base_intermediates)/WebCore/bindings \
$(base_intermediates)/WebCore/svg \
@@ -173,6 +174,7 @@ LOCAL_SRC_FILES += \
LOCAL_SRC_FILES += \
bridge/jni/JNIUtility.cpp \
+ bridge/jni/v8/JNIBridgeV8.cpp \
bridge/jni/v8/JNIUtilityPrivate.cpp \
bridge/jni/v8/JavaNPObjectV8.cpp \
bridge/jni/v8/JavaClassV8.cpp \
diff --git a/WebCore/bridge/Bridge.h b/WebCore/bridge/Bridge.h
index d92cd15..50efc64 100644
--- a/WebCore/bridge/Bridge.h
+++ b/WebCore/bridge/Bridge.h
@@ -28,6 +28,7 @@
#define Bridge_h
#include "BridgeJSC.h"
+#include <wtf/Noncopyable.h>
namespace JSC {
diff --git a/WebCore/bridge/jni/v8/JNIBridgeV8.cpp b/WebCore/bridge/jni/v8/JNIBridgeV8.cpp
new file mode 100644
index 0000000..9fb1bf3
--- /dev/null
+++ b/WebCore/bridge/jni/v8/JNIBridgeV8.cpp
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2010, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JNIBridgeV8.h"
+
+using namespace JSC::Bindings;
+
+JavaField::JavaField(JNIEnv* env, jobject aField)
+{
+ // Get field type
+ jobject fieldType = callJNIMethod<jobject>(aField, "getType", "()Ljava/lang/Class;");
+ jstring fieldTypeName = static_cast<jstring>(callJNIMethod<jobject>(fieldType, "getName", "()Ljava/lang/String;"));
+ m_type = JavaString(env, fieldTypeName);
+ m_JNIType = JNITypeFromClassName(m_type.UTF8String());
+
+ // Get field name
+ jstring fieldName = static_cast<jstring>(callJNIMethod<jobject>(aField, "getName", "()Ljava/lang/String;"));
+ m_name = JavaString(env, fieldName);
+
+ m_field = new JObjectWrapper(aField);
+}
diff --git a/WebCore/bridge/jni/v8/JNIBridgeV8.h b/WebCore/bridge/jni/v8/JNIBridgeV8.h
new file mode 100644
index 0000000..3922d62
--- /dev/null
+++ b/WebCore/bridge/jni/v8/JNIBridgeV8.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2010, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef JNIBridgeV8_h
+#define JNIBridgeV8_h
+
+#include "JNIUtility.h"
+#include "JavaInstanceV8.h"
+#include "JavaStringV8.h"
+#include "jni_runtime.h"
+
+
+namespace JSC {
+
+namespace Bindings {
+
+class JavaField
+{
+public:
+ JavaField(JNIEnv*, jobject aField);
+
+ const JavaString& name() const { return m_name; }
+ const char* type() const { return m_type.UTF8String(); }
+
+ JNIType getJNIType() const { return m_JNIType; }
+
+private:
+ JavaString m_name;
+ JavaString m_type;
+ JNIType m_JNIType;
+ RefPtr<JObjectWrapper> m_field;
+};
+
+} // namespace Bindings
+
+} // namespace JSC
+
+#endif // JNIBridgeV8_h
diff --git a/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp b/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp
index a817bc0..a71814c 100644
--- a/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp
+++ b/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp
@@ -26,6 +26,7 @@
#include "config.h"
#include "JNIUtilityPrivate.h"
+#include "JavaInstanceV8.h"
#include "JavaNPObjectV8.h"
#include "jni_runtime.h"
diff --git a/WebCore/bridge/jni/v8/JavaClassV8.h b/WebCore/bridge/jni/v8/JavaClassV8.h
index 12cdf93..2533d0e 100644
--- a/WebCore/bridge/jni/v8/JavaClassV8.h
+++ b/WebCore/bridge/jni/v8/JavaClassV8.h
@@ -27,9 +27,9 @@
#ifndef JavaClassV8_h
#define JavaClassV8_h
+#include "JNIBridgeV8.h"
#include "PlatformString.h"
#include "StringHash.h"
-#include "jni_runtime.h"
#include <wtf/HashMap.h>
#include <wtf/Vector.h>
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index d031853..5bae60e 100644
--- a/WebCore/dom/Document.cpp
+++ b/WebCore/dom/Document.cpp
@@ -1487,6 +1487,17 @@ void Document::detach()
FrameView* view = m_frame->view();
if (view)
view->detachCustomScrollbars();
+
+#if ENABLE(TOUCH_EVENTS)
+ Page* ownerPage = page();
+ if (ownerPage && (m_frame == ownerPage->mainFrame())) {
+ // Inform the Chrome Client that it no longer needs to
+ // foward touch events to WebCore as the document is being
+ // destroyed. It may start again if a subsequent page
+ // registers a touch event listener.
+ ownerPage->chrome()->client()->needTouchEvents(false);
+ }
+#endif
}
// indicate destruction mode, i.e. attached() but renderer == 0
diff --git a/WebCore/dom/Node.cpp b/WebCore/dom/Node.cpp
index c2d5281..b48819a 100644
--- a/WebCore/dom/Node.cpp
+++ b/WebCore/dom/Node.cpp
@@ -2438,18 +2438,6 @@ bool Node::removeEventListener(const AtomicString& eventType, EventListener* lis
updateSVGElementInstancesAfterEventListenerChange(this);
-#if ENABLE(TOUCH_EVENTS)
- if (Document* document = this->document()) {
- if (document->page()
- && (eventType == eventNames().touchstartEvent
- || eventType == eventNames().touchmoveEvent
- || eventType == eventNames().touchendEvent
- || eventType == eventNames().touchcancelEvent))
- // Note the corresponding needTouchEvents(true) is called in Document::addListenerTypeIfNeeded().
- document->page()->chrome()->client()->needTouchEvents(false);
-
- }
-#endif
return true;
}
diff --git a/WebCore/dom/Touch.cpp b/WebCore/dom/Touch.cpp
index 41d5c19..4ea83da 100644
--- a/WebCore/dom/Touch.cpp
+++ b/WebCore/dom/Touch.cpp
@@ -55,11 +55,10 @@ static int contentsY(Frame* frame)
Touch::Touch(Frame* frame, EventTarget* target, unsigned identifier,
int screenX, int screenY, int pageX, int pageY)
- : m_frame(frame)
- , m_target(target)
+ : m_target(target)
, m_identifier(identifier)
- , m_clientX(pageX - contentsX(m_frame.get()))
- , m_clientY(pageY - contentsY(m_frame.get()))
+ , m_clientX(pageX - contentsX(frame))
+ , m_clientY(pageY - contentsY(frame))
, m_screenX(screenX)
, m_screenY(screenY)
, m_pageX(pageX)
@@ -67,16 +66,6 @@ Touch::Touch(Frame* frame, EventTarget* target, unsigned identifier,
{
}
-void Touch::updateLocation(int screenX, int screenY, int pageX, int pageY)
-{
- m_clientX = pageX - contentsX(m_frame.get());
- m_clientY = pageY - contentsY(m_frame.get());
- m_screenX = screenX;
- m_screenY = screenY;
- m_pageX = pageX;
- m_pageY = pageY;
-}
-
} // namespace WebCore
#endif
diff --git a/WebCore/dom/Touch.h b/WebCore/dom/Touch.h
index cf39faf..ceb8ae7 100644
--- a/WebCore/dom/Touch.h
+++ b/WebCore/dom/Touch.h
@@ -45,9 +45,6 @@ public:
screenY, pageX, pageY));
}
- void updateLocation(int screenX, int screenY, int pageX, int pageY);
-
- Frame* frame() const { return m_frame.get(); }
EventTarget* target() const { return m_target.get(); }
unsigned identifier() const { return m_identifier; }
int clientX() const { return m_clientX; }
@@ -61,7 +58,6 @@ private:
Touch(Frame* frame, EventTarget* target, unsigned identifier,
int screenX, int screenY, int pageX, int pageY);
- RefPtr<Frame> m_frame;
RefPtr<EventTarget> m_target;
unsigned m_identifier;
int m_clientX;
diff --git a/WebCore/history/CachedFrame.cpp b/WebCore/history/CachedFrame.cpp
index a868134..7d69195 100644
--- a/WebCore/history/CachedFrame.cpp
+++ b/WebCore/history/CachedFrame.cpp
@@ -42,6 +42,11 @@
#include "SVGDocumentExtensions.h"
#endif
+#if ENABLE(TOUCH_EVENTS)
+#include "ChromeClient.h"
+#include "Page.h"
+#endif
+
namespace WebCore {
#ifndef NDEBUG
@@ -104,6 +109,10 @@ void CachedFrameBase::restore()
m_document->dispatchWindowLoadEvent();
#endif
m_document->dispatchWindowEvent(PageTransitionEvent::create(eventNames().pageshowEvent, true), m_document);
+#if ENABLE(TOUCH_EVENTS)
+ if (m_document->hasListenerType(Document::TOUCH_LISTENER))
+ m_document->page()->chrome()->client()->needTouchEvents(true);
+#endif
}
CachedFrame::CachedFrame(Frame* frame)
@@ -146,6 +155,11 @@ CachedFrame::CachedFrame(Frame* frame)
else
LOG(PageCache, "Finished creating CachedFrame for child frame with url '%s' and DocumentLoader %p\n", m_url.string().utf8().data(), m_documentLoader.get());
#endif
+
+#if ENABLE(TOUCH_EVENTS)
+ if (m_document->hasListenerType(Document::TOUCH_LISTENER))
+ m_document->page()->chrome()->client()->needTouchEvents(false);
+#endif
}
void CachedFrame::open()
diff --git a/WebCore/loader/EmptyClients.h b/WebCore/loader/EmptyClients.h
index e4b9af5..e5385c5 100644
--- a/WebCore/loader/EmptyClients.h
+++ b/WebCore/loader/EmptyClients.h
@@ -169,6 +169,10 @@ public:
virtual void setNeedsOneShotDrawingSynchronization() {};
virtual void scheduleCompositingLayerSync() {};
#endif
+
+#if ENABLE(TOUCH_EVENTS)
+ virtual void needTouchEvents(bool) { }
+#endif
};
class EmptyFrameLoaderClient : public FrameLoaderClient {
diff --git a/WebCore/page/ChromeClient.h b/WebCore/page/ChromeClient.h
index b28473b..d4af73b 100644
--- a/WebCore/page/ChromeClient.h
+++ b/WebCore/page/ChromeClient.h
@@ -226,7 +226,7 @@ namespace WebCore {
#endif
#if ENABLE(TOUCH_EVENTS)
- virtual void needTouchEvents(bool, bool force = false) = 0;
+ virtual void needTouchEvents(bool) = 0;
#endif
protected:
diff --git a/WebCore/page/EventHandler.cpp b/WebCore/page/EventHandler.cpp
index 1d5941b..e4274c2 100644
--- a/WebCore/page/EventHandler.cpp
+++ b/WebCore/page/EventHandler.cpp
@@ -210,14 +210,6 @@ void EventHandler::clear()
m_clickNode = 0;
#if ENABLE(TOUCH_EVENTS)
m_touchEventTarget = 0;
- if (Document* doc = m_frame->document()) {
- if (Page* page = doc->page()) {
- // We are clearing event handlers, which includes any touch
- // event handlers so force webkit to tell the chrome client to
- // stop forwarding the events.
- page->chrome()->client()->needTouchEvents(false, true);
- }
- }
#endif
m_frameSetBeingResized = 0;
#if ENABLE(DRAG_SUPPORT)
diff --git a/WebCore/platform/graphics/android/AndroidAnimation.cpp b/WebCore/platform/graphics/android/AndroidAnimation.cpp
index 9cdb0c7..5ea8d2a 100644
--- a/WebCore/platform/graphics/android/AndroidAnimation.cpp
+++ b/WebCore/platform/graphics/android/AndroidAnimation.cpp
@@ -42,15 +42,6 @@ void AndroidTransformAnimationValue::apply()
m_layer->setRotation(m_rotation);
}
-void AndroidAnimationTimer::fired()
-{
- if (!m_notificationSent) {
- m_notificationSent = true;
- if (m_layer && m_layer->client())
- m_layer->client()->notifyAnimationStarted(m_layer, WTF::currentTime());
- }
-}
-
static long gDebugAndroidAnimationInstances;
long AndroidAnimation::instancesCount()
@@ -58,10 +49,8 @@ long AndroidAnimation::instancesCount()
return gDebugAndroidAnimationInstances;
}
-AndroidAnimation::AndroidAnimation(LayerAndroid* contentLayer,
- const Animation* animation,
- double beginTime) :
- m_contentLayer(contentLayer),
+AndroidAnimation::AndroidAnimation(const Animation* animation,
+ double beginTime) :
m_beginTime(beginTime),
m_duration(animation->duration()),
m_iterationCount(animation->iterationCount()),
@@ -76,7 +65,6 @@ AndroidAnimation::AndroidAnimation(LayerAndroid* contentLayer,
}
AndroidAnimation::AndroidAnimation(AndroidAnimation* anim) :
- m_contentLayer(anim->m_contentLayer),
m_beginTime(anim->m_beginTime),
m_duration(anim->m_duration),
m_iterationCount(anim->m_iterationCount),
@@ -137,19 +125,27 @@ bool AndroidAnimation::checkIterationsAndProgress(double time, float* finalProgr
return true;
}
-PassRefPtr<AndroidOpacityAnimation> AndroidOpacityAnimation::create(LayerAndroid* contentLayer,
- float fromValue, float toValue,
- const Animation* animation, double beginTime)
+PassRefPtr<AndroidAnimationValue> AndroidAnimation::result()
+{
+ if (!m_result)
+ return 0;
+ return m_result.release();
+}
+
+PassRefPtr<AndroidOpacityAnimation> AndroidOpacityAnimation::create(
+ float fromValue,
+ float toValue,
+ const Animation* animation,
+ double beginTime)
{
- return adoptRef(new AndroidOpacityAnimation(contentLayer,
- fromValue, toValue, animation, beginTime));
+ return adoptRef(new AndroidOpacityAnimation(fromValue, toValue,
+ animation, beginTime));
}
-AndroidOpacityAnimation::AndroidOpacityAnimation(LayerAndroid* contentLayer,
- float fromValue, float toValue,
- const Animation* animation,
- double beginTime)
- : AndroidAnimation(contentLayer, animation, beginTime),
+AndroidOpacityAnimation::AndroidOpacityAnimation(float fromValue, float toValue,
+ const Animation* animation,
+ double beginTime)
+ : AndroidAnimation(animation, beginTime),
m_fromValue(fromValue), m_toValue(toValue)
{
}
@@ -161,9 +157,9 @@ AndroidOpacityAnimation::AndroidOpacityAnimation(AndroidOpacityAnimation* anim)
{
}
-AndroidAnimation* AndroidOpacityAnimation::copy()
+PassRefPtr<AndroidAnimation> AndroidOpacityAnimation::copy()
{
- return new AndroidOpacityAnimation(this);
+ return adoptRef(new AndroidOpacityAnimation(this));
}
void AndroidOpacityAnimation::swapDirection()
@@ -173,7 +169,7 @@ void AndroidOpacityAnimation::swapDirection()
m_fromValue = m_toValue;
}
-bool AndroidOpacityAnimation::evaluate(double time)
+bool AndroidOpacityAnimation::evaluate(LayerAndroid* layer, double time)
{
float progress;
if (!checkIterationsAndProgress(time, &progress))
@@ -183,20 +179,20 @@ bool AndroidOpacityAnimation::evaluate(double time)
return true;
float value = m_fromValue + ((m_toValue - m_fromValue) * progress);
- m_result = AndroidOpacityAnimationValue::create(m_contentLayer.get(), value);
+ m_result = AndroidOpacityAnimationValue::create(layer, value);
return true;
}
-PassRefPtr<AndroidTransformAnimation> AndroidTransformAnimation::create(LayerAndroid* contentLayer,
- const Animation* animation, double beginTime)
+PassRefPtr<AndroidTransformAnimation> AndroidTransformAnimation::create(
+ const Animation* animation,
+ double beginTime)
{
- return adoptRef(new AndroidTransformAnimation(contentLayer, animation, beginTime));
+ return adoptRef(new AndroidTransformAnimation(animation, beginTime));
}
-AndroidTransformAnimation::AndroidTransformAnimation(LayerAndroid* contentLayer,
- const Animation* animation,
- double beginTime)
- : AndroidAnimation(contentLayer, animation, beginTime),
+AndroidTransformAnimation::AndroidTransformAnimation(const Animation* animation,
+ double beginTime)
+ : AndroidAnimation(animation, beginTime),
m_doTranslation(false),
m_doScaling(false),
m_doRotation(false)
@@ -217,9 +213,9 @@ AndroidTransformAnimation::AndroidTransformAnimation(AndroidTransformAnimation*
{
}
-AndroidAnimation* AndroidTransformAnimation::copy()
+PassRefPtr<AndroidAnimation> AndroidTransformAnimation::copy()
{
- return new AndroidTransformAnimation(this);
+ return adoptRef(new AndroidTransformAnimation(this));
}
void AndroidTransformAnimation::setRotation(float fA, float tA)
@@ -281,7 +277,7 @@ void AndroidTransformAnimation::swapDirection()
}
}
-bool AndroidTransformAnimation::evaluate(double time)
+bool AndroidTransformAnimation::evaluate(LayerAndroid* layer, double time)
{
float progress;
if (!checkIterationsAndProgress(time, &progress))
@@ -300,11 +296,12 @@ bool AndroidTransformAnimation::evaluate(double time)
FloatPoint translation(x, y);
FloatPoint3D scale(sx, sy, sz);
- m_result = AndroidTransformAnimationValue::create(m_contentLayer.get(),
- translation, scale, a);
- m_result->setDoTranslation(m_doTranslation);
- m_result->setDoScaling(m_doScaling);
- m_result->setDoRotation(m_doRotation);
+ RefPtr<AndroidTransformAnimationValue> result =
+ AndroidTransformAnimationValue::create(layer, translation, scale, a);
+ result->setDoTranslation(m_doTranslation);
+ result->setDoScaling(m_doScaling);
+ result->setDoRotation(m_doRotation);
+ m_result = result.release();
return true;
}
diff --git a/WebCore/platform/graphics/android/AndroidAnimation.h b/WebCore/platform/graphics/android/AndroidAnimation.h
index 05d6a76..c4be10b 100644
--- a/WebCore/platform/graphics/android/AndroidAnimation.h
+++ b/WebCore/platform/graphics/android/AndroidAnimation.h
@@ -33,9 +33,6 @@ class AndroidAnimation;
class GraphicsLayerAndroid;
class TimingFunction;
-typedef Vector<RefPtr<AndroidAnimation> > AnimsVector;
-typedef HashMap<RefPtr<LayerAndroid>, AnimsVector* > LayersAnimsMap;
-
class AndroidAnimationValue : public RefCounted<AndroidAnimationValue> {
public:
AndroidAnimationValue(LayerAndroid* layer) : m_layer(layer) { }
@@ -92,26 +89,23 @@ class AndroidTransformAnimationValue : public AndroidAnimationValue {
class AndroidAnimation : public RefCounted<AndroidAnimation> {
public:
- AndroidAnimation(LayerAndroid* contentLayer,
- const Animation* animation,
+ AndroidAnimation(const Animation* animation,
double beginTime);
AndroidAnimation(AndroidAnimation* anim);
virtual ~AndroidAnimation();
- virtual AndroidAnimation* copy() = 0;
+ virtual PassRefPtr<AndroidAnimation> copy() = 0;
float currentProgress(double time);
bool checkIterationsAndProgress(double time, float* finalProgress);
virtual void swapDirection() = 0;
- virtual bool evaluate(double time) = 0;
- LayerAndroid* contentLayer() { return m_contentLayer.get(); }
+ virtual bool evaluate(LayerAndroid* layer, double time) = 0;
static long instancesCount();
- void setLayer(LayerAndroid* layer) { m_contentLayer = layer; }
void setName(const String& name) { m_name = name; }
String name() { return m_name; }
- virtual PassRefPtr<AndroidAnimationValue> result() = 0;
+ virtual PassRefPtr<AndroidAnimationValue> result();
protected:
- RefPtr<LayerAndroid> m_contentLayer;
+ RefPtr<AndroidAnimationValue> m_result;
double m_beginTime;
double m_elapsedTime;
double m_duration;
@@ -124,38 +118,33 @@ class AndroidAnimation : public RefCounted<AndroidAnimation> {
class AndroidOpacityAnimation : public AndroidAnimation {
public:
- static PassRefPtr<AndroidOpacityAnimation> create(LayerAndroid* contentLayer,
- float fromValue, float toValue,
- const Animation* animation,
- double beginTime);
- AndroidOpacityAnimation(LayerAndroid* contentLayer,
- float fromValue, float toValue,
+ static PassRefPtr<AndroidOpacityAnimation> create(float fromValue,
+ float toValue,
+ const Animation* animation,
+ double beginTime);
+ AndroidOpacityAnimation(float fromValue, float toValue,
const Animation* animation,
double beginTime);
AndroidOpacityAnimation(AndroidOpacityAnimation* anim);
- virtual AndroidAnimation* copy();
- virtual PassRefPtr<AndroidAnimationValue> result() { return m_result.release(); }
+ virtual PassRefPtr<AndroidAnimation> copy();
virtual void swapDirection();
- virtual bool evaluate(double time);
+ virtual bool evaluate(LayerAndroid* layer, double time);
private:
- RefPtr<AndroidOpacityAnimationValue> m_result;
float m_fromValue;
float m_toValue;
};
class AndroidTransformAnimation : public AndroidAnimation {
public:
- static PassRefPtr<AndroidTransformAnimation> create(LayerAndroid* contentLayer,
- const Animation* animation,
- double beginTime);
- AndroidTransformAnimation(LayerAndroid* contentLayer,
- const Animation* animation,
- double beginTime);
+ static PassRefPtr<AndroidTransformAnimation> create(
+ const Animation* animation,
+ double beginTime);
+ AndroidTransformAnimation(const Animation* animation, double beginTime);
AndroidTransformAnimation(AndroidTransformAnimation* anim);
- virtual AndroidAnimation* copy();
+ virtual PassRefPtr<AndroidAnimation> copy();
void setOriginalPosition(FloatPoint position) { m_position = position; }
void setRotation(float fA, float tA);
@@ -164,11 +153,9 @@ class AndroidTransformAnimation : public AndroidAnimation {
void setScale(float fX, float fY, float fZ,
float tX, float tY, float tZ);
virtual void swapDirection();
- virtual bool evaluate(double time);
- virtual PassRefPtr<AndroidAnimationValue> result() { return m_result.release(); }
+ virtual bool evaluate(LayerAndroid* layer, double time);
private:
- RefPtr<AndroidTransformAnimationValue> m_result;
bool m_doTranslation;
bool m_doScaling;
bool m_doRotation;
@@ -180,23 +167,6 @@ class AndroidTransformAnimation : public AndroidAnimation {
float m_toScaleX, m_toScaleY, m_toScaleZ;
};
-class AndroidAnimationTimer : public TimerBase {
- public:
-
- AndroidAnimationTimer(GraphicsLayerAndroid* layer, double beginTime)
- {
- m_layer = layer;
- m_notificationSent = false;
- m_beginTime = beginTime;
- }
-
- private:
- void fired();
- GraphicsLayerAndroid* m_layer;
- double m_beginTime;
- bool m_notificationSent;
-};
-
} // namespace WebCore
diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
index 9d9d067..bcfe13d 100644
--- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
@@ -96,6 +96,7 @@ GraphicsLayerAndroid::GraphicsLayerAndroid(GraphicsLayerClient* client) :
m_needsSyncMask(false),
m_needsRepaint(false),
m_needsDisplay(false),
+ m_needsNotifyClient(false),
m_haveContents(false),
m_haveImage(false),
m_translateX(0),
@@ -104,7 +105,7 @@ GraphicsLayerAndroid::GraphicsLayerAndroid(GraphicsLayerClient* client) :
m_currentTranslateY(0),
m_currentPosition(0, 0)
{
- m_contentLayer = new LayerAndroid(true);
+ m_contentLayer = adoptRef(new LayerAndroid(true));
if (client) {
RenderLayerBacking* backing = static_cast<RenderLayerBacking*>(client);
RenderLayer* renderLayer = backing->owningLayer();
@@ -525,8 +526,7 @@ bool GraphicsLayerAndroid::createAnimationFromKeyframes(const KeyframeValueList&
static_cast<const FloatAnimationValue*>(valueList.at(0));
const FloatAnimationValue* endVal =
static_cast<const FloatAnimationValue*>(valueList.at(1));
- RefPtr<AndroidOpacityAnimation> anim = AndroidOpacityAnimation::create(m_contentLayer.get(),
- startVal->value(),
+ RefPtr<AndroidOpacityAnimation> anim = AndroidOpacityAnimation::create(startVal->value(),
endVal->value(),
animation,
beginTime);
@@ -536,14 +536,19 @@ bool GraphicsLayerAndroid::createAnimationFromKeyframes(const KeyframeValueList&
anim->setName(keyframesName);
m_contentLayer->addAnimation(anim.release());
- AndroidAnimationTimer* timer = new AndroidAnimationTimer(this, WTF::currentTime());
- timer->startOneShot(0);
+ needsNotifyClient();
return true;
} break;
}
return false;
}
+void GraphicsLayerAndroid::needsNotifyClient()
+{
+ m_needsNotifyClient = true;
+ askForSync();
+}
+
bool GraphicsLayerAndroid::createTransformAnimationsFromKeyframes(const KeyframeValueList& valueList,
const Animation* animation,
const String& keyframesName,
@@ -705,8 +710,7 @@ bool GraphicsLayerAndroid::createTransformAnimationsFromKeyframes(const Keyframe
}
}
- RefPtr<AndroidTransformAnimation> anim = AndroidTransformAnimation::create(m_contentLayer.get(),
- animation, beginTime);
+ RefPtr<AndroidTransformAnimation> anim = AndroidTransformAnimation::create(animation, beginTime);
if (keyframesName.isEmpty())
anim->setName(propertyIdToString(valueList.property()));
@@ -725,8 +729,7 @@ bool GraphicsLayerAndroid::createTransformAnimationsFromKeyframes(const Keyframe
toScaleX, toScaleY, toScaleZ);
m_contentLayer->addAnimation(anim.release());
- AndroidAnimationTimer* timer = new AndroidAnimationTimer(this, WTF::currentTime());
- timer->startOneShot(0);
+ needsNotifyClient();
return true;
}
@@ -860,6 +863,19 @@ void GraphicsLayerAndroid::syncCompositingState()
repaintAll();
}
+void GraphicsLayerAndroid::notifyClientAnimationStarted()
+{
+ for (unsigned int i = 0; i < m_children.size(); i++) {
+ GraphicsLayerAndroid* layer = static_cast<GraphicsLayerAndroid*>(m_children[i]);
+ layer->notifyClientAnimationStarted();
+ }
+
+ if (m_needsNotifyClient) {
+ if (client())
+ client()->notifyAnimationStarted(this, WTF::currentTime());
+ m_needsNotifyClient = false;
+ }
+}
} // namespace WebCore
diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.h b/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
index fc88fbf..591a261 100644
--- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
+++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
@@ -116,6 +116,7 @@ public:
void syncMask();
virtual void syncCompositingState();
void setFrame(Frame*);
+ void notifyClientAnimationStarted();
void sendImmediateRepaint();
LayerAndroid* contentLayer() { return m_contentLayer.get(); }
@@ -125,11 +126,13 @@ public:
private:
bool repaint(const FloatRect& rect);
+ void needsNotifyClient();
bool m_needsSyncChildren;
bool m_needsSyncMask;
bool m_needsRepaint;
bool m_needsDisplay;
+ bool m_needsNotifyClient;
bool m_haveContents;
bool m_haveImage;
diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp
index 3b5d5b5..1788f2d 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/LayerAndroid.cpp
@@ -105,11 +105,7 @@ LayerAndroid::LayerAndroid(LayerAndroid* layer) :
KeyframesMap::const_iterator end = layer->m_animations.end();
for (KeyframesMap::const_iterator it = layer->m_animations.begin(); it != end; ++it)
- m_animations.add((it->second)->name(), adoptRef((it->second)->copy()));
-
- end = m_animations.end();
- for (KeyframesMap::const_iterator it = m_animations.begin(); it != end; ++it)
- (it->second)->setLayer(this);
+ m_animations.add((it->second)->name(), (it->second)->copy());
gDebugLayerAndroidInstances++;
}
@@ -127,10 +123,11 @@ static int gDebugNbAnims = 0;
Vector<RefPtr<AndroidAnimationValue> >* LayerAndroid::evaluateAnimations() const
{
double time = WTF::currentTime();
- Vector<RefPtr<AndroidAnimationValue> >* result = new Vector<RefPtr<AndroidAnimationValue> >();
+ Vector<RefPtr<AndroidAnimationValue> >* results = new Vector<RefPtr<AndroidAnimationValue> >();
gDebugNbAnims = 0;
- if (evaluateAnimations(time, result))
- return result;
+ if (evaluateAnimations(time, results))
+ return results;
+ delete results;
return 0;
}
@@ -144,22 +141,25 @@ bool LayerAndroid::hasAnimations() const
}
bool LayerAndroid::evaluateAnimations(double time,
- Vector<RefPtr<AndroidAnimationValue> >* result) const
+ Vector<RefPtr<AndroidAnimationValue> >* results) const
{
bool hasRunningAnimations = false;
for (unsigned int i = 0; i < m_children.size(); i++) {
- if (m_children[i]->evaluateAnimations(time, result))
+ if (m_children[i]->evaluateAnimations(time, results))
hasRunningAnimations = true;
}
KeyframesMap::const_iterator end = m_animations.end();
for (KeyframesMap::const_iterator it = m_animations.begin(); it != end; ++it) {
gDebugNbAnims++;
- if ((it->second)->evaluate(time)) {
- result->append((it->second)->result());
+ LayerAndroid* currentLayer = const_cast<LayerAndroid*>(this);
+ if ((it->second)->evaluate(currentLayer, time)) {
+ RefPtr<AndroidAnimationValue> result = (it->second)->result();
+ if (result)
+ results->append(result);
hasRunningAnimations = true;
}
}
-
+
return hasRunningAnimations;
}
diff --git a/WebCore/platform/graphics/android/LayerAndroid.h b/WebCore/platform/graphics/android/LayerAndroid.h
index 467c7dd..8436921 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.h
+++ b/WebCore/platform/graphics/android/LayerAndroid.h
@@ -83,7 +83,7 @@ public:
void removeAnimation(const String& name);
Vector<RefPtr<AndroidAnimationValue> >* evaluateAnimations() const;
bool evaluateAnimations(double time,
- Vector<RefPtr<AndroidAnimationValue> >* result) const;
+ Vector<RefPtr<AndroidAnimationValue> >* results) const;
bool hasAnimations() const;
private:
diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
index ffa96f8..17dc0d0 100644
--- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
+++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
@@ -71,8 +71,10 @@ void ChromeClientAndroid::compositingLayerSync()
frameView->syncCompositingStateRecursive();
GraphicsLayerAndroid* androidGraphicsLayer =
static_cast<GraphicsLayerAndroid*>(m_rootGraphicsLayer);
- if (androidGraphicsLayer)
+ if (androidGraphicsLayer) {
androidGraphicsLayer->sendImmediateRepaint();
+ androidGraphicsLayer->notifyClientAnimationStarted();
+ }
return;
}
}
@@ -466,12 +468,12 @@ void ChromeClientAndroid::wakeUpMainThreadWithNewQuota(long newQuota) {
}
#if ENABLE(TOUCH_EVENTS)
-void ChromeClientAndroid::needTouchEvents(bool needTouchEvents, bool force)
+void ChromeClientAndroid::needTouchEvents(bool needTouchEvents)
{
FrameView* frameView = m_webFrame->page()->mainFrame()->view();
android::WebViewCore* core = android::WebViewCore::getWebViewCore(frameView);
if (core)
- core->needTouchEvents(needTouchEvents, force);
+ core->needTouchEvents(needTouchEvents);
}
#endif
diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.h b/WebKit/android/WebCoreSupport/ChromeClientAndroid.h
index b61f9fd..15bf52a 100644
--- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.h
+++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.h
@@ -137,7 +137,7 @@ namespace android {
virtual void populateVisitedLinks();
#if ENABLE(TOUCH_EVENTS)
- virtual void needTouchEvents(bool, bool);
+ virtual void needTouchEvents(bool);
#endif
// Methods used to request and provide Geolocation permissions.
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index 9778ea0..ae3e47c 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -268,7 +268,9 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m
m_screenWidth = 320;
m_scale = 1;
m_screenWidthScale = 1;
- m_touchEventListenerCount = 0;
+#if ENABLE(TOUCH_EVENTS)
+ m_forwardingTouchEvents = false;
+#endif
LOG_ASSERT(m_mainFrame, "Uh oh, somehow a frameview was made without an initial frame!");
@@ -998,28 +1000,20 @@ void WebViewCore::restoreScreenWidthScale(int scale)
checkException(env);
}
-void WebViewCore::needTouchEvents(bool need, bool force)
+void WebViewCore::needTouchEvents(bool need)
{
DEBUG_NAV_UI_LOGD("%s", __FUNCTION__);
LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!");
-#if ENABLE(TOUCH_EVENTS) // Android
- bool needToUpdateJava = false;
- if (need) {
- if (++m_touchEventListenerCount == 1)
- needToUpdateJava = true;
- } else {
- if (force)
- m_touchEventListenerCount = 0;
- else if (--m_touchEventListenerCount == 0)
- needToUpdateJava = true;
- }
+#if ENABLE(TOUCH_EVENTS)
+ if (m_forwardingTouchEvents == need)
+ return;
- if (needToUpdateJava || force) {
- JNIEnv* env = JSC::Bindings::getJNIEnv();
- env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_needTouchEvents, need);
- checkException(env);
- }
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_needTouchEvents, need);
+ checkException(env);
+
+ m_forwardingTouchEvents = need;
#endif
}
diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h
index f528c73..2252878 100644
--- a/WebKit/android/jni/WebViewCore.h
+++ b/WebKit/android/jni/WebViewCore.h
@@ -375,7 +375,7 @@ namespace android {
Node* cursorNodeIsPlugin();
// Notify the Java side whether it needs to pass down the touch events
- void needTouchEvents(bool, bool);
+ void needTouchEvents(bool);
// Notify the Java side that webkit is requesting a keyboard
void requestKeyboard(bool showKeyboard, bool isTextView);
@@ -536,7 +536,7 @@ namespace android {
WebCore::HTMLAnchorElement* retrieveAnchorElement(WebCore::Frame* frame, WebCore::Node* node);
#if ENABLE(TOUCH_EVENTS)
- int m_touchEventListenerCount;
+ bool m_forwardingTouchEvents;
IntPoint m_lastTouchPoint;
#endif
diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp
index dae93fc..e2a7708 100644
--- a/WebKit/android/nav/WebView.cpp
+++ b/WebKit/android/nav/WebView.cpp
@@ -1533,13 +1533,10 @@ static void nativeDrawLayers(JNIEnv *env, jobject obj,
#endif
}
-static void nativeUpdateLayers(JNIEnv *env, jobject obj,
- jint layer, jint updates)
+static void nativeUpdateLayers(JNIEnv *env, jobject obj, jint updates)
{
if (!env)
return;
- if (!layer)
- return;
if (!updates)
return;
@@ -2138,7 +2135,7 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeEvaluateLayersAnimations },
{ "nativeDrawLayers", "(IIIIIFLandroid/graphics/Canvas;)V",
(void*) nativeDrawLayers },
- { "nativeUpdateLayers", "(II)V",
+ { "nativeUpdateLayers", "(I)V",
(void*) nativeUpdateLayers },
{ "nativeDrawMatches", "(Landroid/graphics/Canvas;)V",
(void*) nativeDrawMatches },
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp
index 2ea3191..7109ab4 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.cpp
+++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp
@@ -271,14 +271,8 @@ void PluginWidgetAndroid::updateEventFlags(ANPEventFlags flags) {
Document* doc = m_pluginView->getParentFrame()->document();
#if ENABLE(TOUCH_EVENTS)
if((m_eventFlags ^ flags) & kTouch_ANPEventFlag) {
- if (flags & kTouch_ANPEventFlag) {
- if (Page* page = doc->page())
- page->chrome()->client()->needTouchEvents(true, false);
- doc->addListenerTypeIfNeeded(eventNames().touchstartEvent);
- } else {
- if (Page* page = doc->page())
- page->chrome()->client()->needTouchEvents(false, false);
- }
+ if (flags & kTouch_ANPEventFlag)
+ doc->addListenerTypeIfNeeded(eventNames().touchstartEvent);
}
#endif