diff options
Diffstat (limited to 'WebCore')
-rw-r--r-- | WebCore/html/HTMLInputElement.cpp | 9 | ||||
-rw-r--r-- | WebCore/html/HTMLMediaElement.cpp | 4 | ||||
-rw-r--r-- | WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp | 7 | ||||
-rw-r--r-- | WebCore/platform/graphics/android/GraphicsLayerAndroid.h | 1 | ||||
-rw-r--r-- | WebCore/platform/graphics/android/LayerAndroid.cpp | 21 | ||||
-rw-r--r-- | WebCore/platform/graphics/android/LayerAndroid.h | 6 | ||||
-rw-r--r-- | WebCore/platform/graphics/android/ShaderProgram.cpp | 11 | ||||
-rw-r--r-- | WebCore/platform/graphics/android/ShaderProgram.h | 1 | ||||
-rw-r--r-- | WebCore/rendering/MediaControlElements.cpp | 6 | ||||
-rw-r--r-- | WebCore/rendering/RenderMedia.cpp | 13 | ||||
-rw-r--r-- | WebCore/rendering/RenderMedia.h | 3 | ||||
-rw-r--r-- | WebCore/rendering/RenderSlider.cpp | 41 |
12 files changed, 112 insertions, 11 deletions
diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp index 7449098..e4c253e 100644 --- a/WebCore/html/HTMLInputElement.cpp +++ b/WebCore/html/HTMLInputElement.cpp @@ -1554,7 +1554,14 @@ void HTMLInputElement::defaultEventHandler(Event* evt) if (isTextField() && renderer() && (evt->isMouseEvent() || evt->isDragEvent() || evt->isWheelEvent() || evt->type() == eventNames().blurEvent || evt->type() == eventNames().focusEvent)) toRenderTextControlSingleLine(renderer())->forwardEvent(evt); - if (deprecatedInputType() == RANGE && renderer() && (evt->isMouseEvent() || evt->isDragEvent() || evt->isWheelEvent())) + if (deprecatedInputType() == RANGE + && renderer() + && (evt->isMouseEvent() +#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS) + || evt->isTouchEvent() +#endif + || evt->isDragEvent() + || evt->isWheelEvent())) toRenderSlider(renderer())->forwardEvent(evt); if (!callBaseClassEarly && !evt->defaultHandled()) diff --git a/WebCore/html/HTMLMediaElement.cpp b/WebCore/html/HTMLMediaElement.cpp index 7c061d0..8af8927 100644 --- a/WebCore/html/HTMLMediaElement.cpp +++ b/WebCore/html/HTMLMediaElement.cpp @@ -170,6 +170,10 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document* docum LOG(Media, "HTMLMediaElement::HTMLMediaElement"); document->registerForDocumentActivationCallbacks(this); document->registerForMediaVolumeCallbacks(this); +#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS) + // Enable the Media Element to listen to all the touch events + document->addListenerTypeIfNeeded(eventNames().touchstartEvent); +#endif } HTMLMediaElement::~HTMLMediaElement() diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp index 59f8408..e8120f9 100644 --- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp +++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp @@ -337,6 +337,13 @@ void GraphicsLayerAndroid::setSize(const FloatSize& size) askForSync(); } +void GraphicsLayerAndroid::setBackfaceVisibility(bool b) +{ + GraphicsLayer::setBackfaceVisibility(b); + m_contentLayer->setBackfaceVisibility(b); + askForSync(); +} + void GraphicsLayerAndroid::setTransform(const TransformationMatrix& t) { if (t == m_transform) diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.h b/WebCore/platform/graphics/android/GraphicsLayerAndroid.h index 94b828b..10db5a1 100644 --- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.h +++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.h @@ -61,6 +61,7 @@ public: virtual void setAnchorPoint(const FloatPoint3D&); virtual void setSize(const FloatSize&); + virtual void setBackfaceVisibility(bool b); virtual void setTransform(const TransformationMatrix&); virtual void setChildrenTransform(const TransformationMatrix&); diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp index e616041..7bef420 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -58,6 +58,8 @@ LayerAndroid::LayerAndroid(RenderLayer* owner) : SkLayer(), m_haveClip(false), m_isFixed(false), m_isIframe(false), + m_backfaceVisibility(true), + m_visible(true), m_preserves3D(false), m_anchorPointZ(0), m_recordingPicture(0), @@ -97,6 +99,8 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer) : SkLayer(layer), copyBitmap(layer.m_contentsImage); m_renderLayerPos = layer.m_renderLayerPos; m_transform = layer.m_transform; + m_backfaceVisibility = layer.m_backfaceVisibility; + m_visible = layer.m_visible; m_backgroundColor = layer.m_backgroundColor; m_fixedLeft = layer.m_fixedLeft; @@ -604,6 +608,8 @@ void LayerAndroid::updateGLPositions(const TransformationMatrix& parentMatrix, -anchorPointZ()); setDrawTransform(localMatrix); + m_zValue = TilesManager::instance()->shader()->zValue(drawTransform(), getSize().width(), getSize().height()); + opacity *= getOpacity(); setDrawOpacity(opacity); @@ -617,6 +623,14 @@ void LayerAndroid::updateGLPositions(const TransformationMatrix& parentMatrix, setDrawClip(clipping); } + if (!m_backfaceVisibility + && drawTransform().inverse().m33() < 0) { + setVisible(false); + return; + } else { + setVisible(true); + } + int count = this->countChildren(); if (!count) return; @@ -925,15 +939,14 @@ bool LayerAndroid::needsScheduleRepaint(LayerTexture* texture) static inline bool compareLayerZ(const LayerAndroid* a, const LayerAndroid* b) { - const TransformationMatrix& transformA = a->drawTransform(); - const TransformationMatrix& transformB = b->drawTransform(); - - return transformA.m43() < transformB.m43(); + return a->zValue() > b->zValue(); } bool LayerAndroid::drawGL(GLWebViewState* glWebViewState, SkMatrix& matrix) { TilesManager::instance()->shader()->clip(m_clippingRect); + if (!m_visible) + return false; if (m_drawingTexture) { TextureInfo* textureInfo = m_drawingTexture->consumerLock(); diff --git a/WebCore/platform/graphics/android/LayerAndroid.h b/WebCore/platform/graphics/android/LayerAndroid.h index e01a9a7..d4510c5 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.h +++ b/WebCore/platform/graphics/android/LayerAndroid.h @@ -101,6 +101,7 @@ public: LayerTexture* texture() { return m_reservedTexture; } virtual TiledPage* page() { return 0; } + void setBackfaceVisibility(bool value) { m_backfaceVisibility = value; } void setTransform(const TransformationMatrix& matrix) { m_transform = matrix; } FloatPoint translation() const; SkRect bounds() const; @@ -134,6 +135,7 @@ public: void updateGLPositions(const TransformationMatrix& parentMatrix, const FloatRect& clip, float opacity); void setDrawOpacity(float opacity) { m_drawOpacity = opacity; } + void setVisible(bool value) { m_visible = value; } bool preserves3D() { return m_preserves3D; } void setPreserves3D(bool value) { m_preserves3D = value; } @@ -252,6 +254,7 @@ public: RenderLayer* owningLayer() const { return m_owningLayer; } void setIsIframe(bool isIframe) { m_isIframe = isIframe; } + float zValue() const { return m_zValue; } protected: virtual void onDraw(SkCanvas*, SkScalar opacity); @@ -287,6 +290,9 @@ private: IntPoint m_renderLayerPos; TransformationMatrix m_transform; + float m_zValue; + bool m_backfaceVisibility; + bool m_visible; SkColor m_backgroundColor; diff --git a/WebCore/platform/graphics/android/ShaderProgram.cpp b/WebCore/platform/graphics/android/ShaderProgram.cpp index 9e0a4ab..6933890 100644 --- a/WebCore/platform/graphics/android/ShaderProgram.cpp +++ b/WebCore/platform/graphics/android/ShaderProgram.cpp @@ -28,6 +28,7 @@ #if USE(ACCELERATED_COMPOSITING) +#include "FloatPoint3D.h" #include "GLUtils.h" #include <GLES2/gl2.h> @@ -372,6 +373,16 @@ IntRect ShaderProgram::clippedRectWithViewport(const IntRect& rect, int margin) return viewport; } +float ShaderProgram::zValue(const TransformationMatrix& drawMatrix, float w, float h) +{ + TransformationMatrix renderMatrix = drawMatrix; + renderMatrix.scale3d(w, h, 1); + renderMatrix.multiply(m_projectionMatrix); + FloatPoint3D point(0.5, 0.5, 0.0); + FloatPoint3D result = renderMatrix.mapPoint(point); + return result.z(); +} + void ShaderProgram::drawLayerQuad(const TransformationMatrix& drawMatrix, SkRect& geometry, int textureId, float opacity, bool forceBlending) diff --git a/WebCore/platform/graphics/android/ShaderProgram.h b/WebCore/platform/graphics/android/ShaderProgram.h index 256cc2b..55afe4f 100644 --- a/WebCore/platform/graphics/android/ShaderProgram.h +++ b/WebCore/platform/graphics/android/ShaderProgram.h @@ -39,6 +39,7 @@ class ShaderProgram { // Drawing void setViewport(SkRect& viewport); void drawQuad(SkRect& geometry, int textureId, float opacity); + float zValue(const TransformationMatrix& drawMatrix, float w, float h); void drawLayerQuad(const TransformationMatrix& drawMatrix, SkRect& geometry, int textureId, float opacity, bool forceBlending = false); diff --git a/WebCore/rendering/MediaControlElements.cpp b/WebCore/rendering/MediaControlElements.cpp index 1af1b80..25b5a12 100644 --- a/WebCore/rendering/MediaControlElements.cpp +++ b/WebCore/rendering/MediaControlElements.cpp @@ -719,8 +719,12 @@ void MediaControlTimelineElement::defaultEventHandler(Event* event) } RenderSlider* slider = toRenderSlider(renderer()); - if (slider && slider->inDragMode()) + if (slider && slider->inDragMode()) { toRenderMedia(mediaElement()->renderer())->updateTimeDisplay(); +#if PLATFORM(ANDROID) + toRenderMedia(mediaElement()->renderer())->updateLastTouch(); +#endif + } if (event->type() == eventNames().mouseupEvent) mediaElement()->endScrubbing(); diff --git a/WebCore/rendering/RenderMedia.cpp b/WebCore/rendering/RenderMedia.cpp index f19ca96..6fe0337 100644 --- a/WebCore/rendering/RenderMedia.cpp +++ b/WebCore/rendering/RenderMedia.cpp @@ -550,11 +550,22 @@ void RenderMedia::updateVolumeSliderContainer(bool visible) } } +#if PLATFORM(ANDROID) +void RenderMedia::updateLastTouch() +{ + m_lastTouch = WTF::currentTime(); +} +#endif + void RenderMedia::forwardEvent(Event* event) { #if PLATFORM(ANDROID) if (event->isMouseEvent()) - m_lastTouch = WTF::currentTime(); + updateLastTouch(); +#if ENABLE(TOUCH_EVENTS) + if (event->isTouchEvent()) + updateLastTouch(); +#endif #endif if (event->isMouseEvent() && m_controlsShadowRoot) { diff --git a/WebCore/rendering/RenderMedia.h b/WebCore/rendering/RenderMedia.h index 65fdc7d..a3b5c5c 100644 --- a/WebCore/rendering/RenderMedia.h +++ b/WebCore/rendering/RenderMedia.h @@ -71,6 +71,9 @@ public: void updateTimeDisplay(); void forwardEvent(Event*); +#if PLATFORM(ANDROID) + void updateLastTouch(); +#endif protected: virtual void layout(); diff --git a/WebCore/rendering/RenderSlider.cpp b/WebCore/rendering/RenderSlider.cpp index d680bc7..f00b586 100644 --- a/WebCore/rendering/RenderSlider.cpp +++ b/WebCore/rendering/RenderSlider.cpp @@ -43,6 +43,10 @@ #include "Settings.h" #endif +#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS) +#include "TouchEvent.h" +#endif + using std::min; namespace WebCore { @@ -85,7 +89,11 @@ inline PassRefPtr<SliderThumbElement> SliderThumbElement::create(HTMLElement* sh void SliderThumbElement::defaultEventHandler(Event* event) { - if (!event->isMouseEvent()) { + if (!event->isMouseEvent() +#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS) + && !event->isTouchEvent() +#endif + ) { ShadowBlockElement::defaultEventHandler(event); return; } @@ -94,7 +102,11 @@ void SliderThumbElement::defaultEventHandler(Event* event) bool isLeftButton = mouseEvent->button() == LeftButton; const AtomicString& eventType = event->type(); - if (eventType == eventNames().mousedownEvent && isLeftButton) { + if (eventType == eventNames().mousedownEvent && isLeftButton +#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS) + || eventType == eventNames().touchstartEvent +#endif + ) { if (document()->frame() && renderer()) { RenderSlider* slider = toRenderSlider(renderer()->parent()); if (slider) { @@ -115,7 +127,11 @@ void SliderThumbElement::defaultEventHandler(Event* event) return; } } - } else if (eventType == eventNames().mouseupEvent && isLeftButton) { + } else if (eventType == eventNames().mouseupEvent && isLeftButton +#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS) + || eventType == eventNames().touchendEvent +#endif + ) { if (m_inDragMode) { if (Frame* frame = document()->frame()) frame->eventHandler()->setCapturingMouseEventsNode(0); @@ -123,11 +139,28 @@ void SliderThumbElement::defaultEventHandler(Event* event) event->setDefaultHandled(); return; } - } else if (eventType == eventNames().mousemoveEvent) { + } else if (eventType == eventNames().mousemoveEvent +#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS) + || eventType == eventNames().touchmoveEvent +#endif + ) { if (m_inDragMode && renderer() && renderer()->parent()) { RenderSlider* slider = toRenderSlider(renderer()->parent()); if (slider) { FloatPoint curPoint = slider->absoluteToLocal(mouseEvent->absoluteLocation(), false, true); +#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS) + // Update the position when it is a touch event + if (event->isTouchEvent()) { + TouchEvent* touchEvent = static_cast<TouchEvent*>(event); + if (touchEvent && touchEvent->touches() && touchEvent->touches()->item(0)) { + curPoint.setX(touchEvent->touches()->item(0)->pageX()); + curPoint.setY(touchEvent->touches()->item(0)->pageY()); + curPoint = slider->absoluteToLocal(curPoint, false, true); + } + } + // Tell the webview that webkit will handle the following move events + event->setDefaultPrevented(true); +#endif IntPoint eventOffset(curPoint.x() + m_offsetToThumb.x(), curPoint.y() + m_offsetToThumb.y()); slider->setValueForPosition(slider->positionForOffset(eventOffset)); event->setDefaultHandled(); |