diff options
9 files changed, 105 insertions, 12 deletions
diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp index d25bada..693f214 100644 --- a/Source/WebCore/html/HTMLMediaElement.cpp +++ b/Source/WebCore/html/HTMLMediaElement.cpp @@ -185,9 +185,9 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document* docum document->registerForDocumentActivationCallbacks(this); document->registerForMediaVolumeCallbacks(this); document->registerForPrivateBrowsingStateChangedCallbacks(this); -#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS) - m_restrictions |= RequireUserGestureForRateChangeRestriction; -#endif + + if (document->settings() && document->settings()->mediaPlaybackRequiresUserGesture()) + m_restrictions |= RequireUserGestureForRateChangeRestriction; } HTMLMediaElement::~HTMLMediaElement() diff --git a/Source/WebCore/page/Settings.cpp b/Source/WebCore/page/Settings.cpp index f668f3e..79e38d1 100644 --- a/Source/WebCore/page/Settings.cpp +++ b/Source/WebCore/page/Settings.cpp @@ -201,6 +201,8 @@ Settings::Settings(Page* page) #else , m_passwordEchoEnabled(false) #endif + , m_mediaPlaybackRequiresUserGesture(false) + , m_mediaPlaybackAllowsInline(true) { // A Frame may not have been created yet, so we initialize the AtomicString // hash before trying to use it. diff --git a/Source/WebCore/page/Settings.h b/Source/WebCore/page/Settings.h index 2cf7715..84828ab 100644 --- a/Source/WebCore/page/Settings.h +++ b/Source/WebCore/page/Settings.h @@ -479,6 +479,12 @@ namespace WebCore { bool blockNetworkImage() const { return m_blockNetworkImage; } #endif + void setMediaPlaybackRequiresUserGesture(bool flag) { m_mediaPlaybackRequiresUserGesture = flag; }; + bool mediaPlaybackRequiresUserGesture() const { return m_mediaPlaybackRequiresUserGesture; } + + void setMediaPlaybackAllowsInline(bool flag) { m_mediaPlaybackAllowsInline = flag; }; + bool mediaPlaybackAllowsInline() const { return m_mediaPlaybackAllowsInline; } + private: Page* m_page; @@ -633,6 +639,8 @@ namespace WebCore { #ifdef ANDROID_PLUGINS bool m_pluginsOnDemand : 1; #endif + bool m_mediaPlaybackRequiresUserGesture : 1; + bool m_mediaPlaybackAllowsInline : 1; bool m_passwordEchoEnabled : 1; #if USE(SAFARI_THEME) diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp index 2807163..25441f4 100644 --- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp @@ -852,8 +852,9 @@ bool GraphicsLayerAndroid::paintContext(LayerAndroid* layer, // TODO: add content checks (text, opacity, etc.) picture.updatePicturesIfNeeded(this); + // store the newly painted content in the layer if it's not empty PicturePileLayerContent* content = new PicturePileLayerContent(picture); - layer->setContent(content); + layer->setContent(content->isEmpty() ? 0 : content); SkSafeUnref(content); return true; diff --git a/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h b/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h index fc3b8bc..1cfb094 100644 --- a/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h +++ b/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h @@ -82,7 +82,9 @@ public: // Drawing , DrawBitmapPatternOperation , DrawBitmapRectOperation + , DrawConvexPolygonQuadOperation , DrawEllipseOperation + , DrawFocusRingOperation , DrawLineOperation , DrawLineForTextOperation , DrawLineForTextCheckingOperation @@ -153,7 +155,9 @@ public: // Drawing TYPE_CASE(DrawBitmapPatternOperation) TYPE_CASE(DrawBitmapRectOperation) + TYPE_CASE(DrawConvexPolygonQuadOperation) TYPE_CASE(DrawEllipseOperation) + TYPE_CASE(DrawFocusRingOperation) TYPE_CASE(DrawLineOperation) TYPE_CASE(DrawLineForTextOperation) TYPE_CASE(DrawLineForTextCheckingOperation) @@ -577,6 +581,23 @@ private: CompositeOperator m_operator; }; +class DrawConvexPolygonQuad : public Operation { +public: + DrawConvexPolygonQuad(const FloatPoint* points, bool shouldAntiAlias) + : m_shouldAntiAlias(shouldAntiAlias) + { + memcpy(m_points, points, 4 * sizeof(FloatPoint)); + } + virtual bool applyImpl(PlatformGraphicsContext* context) { + context->drawConvexPolygon(4, m_points, m_shouldAntiAlias); + return true; + } + virtual OperationType type() { return DrawConvexPolygonQuadOperation; } +private: + bool m_shouldAntiAlias; + FloatPoint m_points[4]; +}; + class DrawEllipse : public Operation { public: DrawEllipse(const IntRect& rect) : m_rect(rect) {} @@ -589,6 +610,26 @@ private: IntRect m_rect; }; +class DrawFocusRing : public Operation { +public: + DrawFocusRing(const Vector<IntRect>& rects, int width, int offset, const Color& color) + : m_rects(rects) + , m_width(width) + , m_offset(offset) + , m_color(color) + {} + virtual bool applyImpl(PlatformGraphicsContext* context) { + context->drawFocusRing(m_rects, m_width, m_offset, m_color); + return true; + } + virtual OperationType type() { return DrawFocusRingOperation; } +private: + Vector<IntRect> m_rects; + int m_width; + int m_offset; + Color m_color; +}; + class DrawLine : public Operation { public: DrawLine(const IntPoint& point1, const IntPoint& point2) diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp index f11154d..4a14513 100644 --- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp +++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp @@ -449,7 +449,15 @@ void PlatformGraphicsContextRecording::drawConvexPolygon(size_t numPoints, const FloatPoint* points, bool shouldAntialias) { - // TODO + if (numPoints < 1) return; + if (numPoints != 4) { + // TODO: Build a path and call draw on that (webkit currently never calls this) + ALOGW("drawConvexPolygon with numPoints != 4 is not supported!"); + return; + } + FloatRect bounds; + bounds.fitToPoints(points[0], points[1], points[2], points[3]); + appendDrawingOperation(new GraphicsOperation::DrawConvexPolygonQuad(points, shouldAntialias), bounds); } void PlatformGraphicsContextRecording::drawEllipse(const IntRect& rect) @@ -458,10 +466,15 @@ void PlatformGraphicsContextRecording::drawEllipse(const IntRect& rect) } void PlatformGraphicsContextRecording::drawFocusRing(const Vector<IntRect>& rects, - int /* width */, int /* offset */, + int width, int offset, const Color& color) { - // TODO + if (!rects.size()) + return; + IntRect bounds = rects[0]; + for (size_t i = 1; i < rects.size(); i++) + bounds.unite(rects[i]); + appendDrawingOperation(new GraphicsOperation::DrawFocusRing(rects, width, offset, color), bounds); } void PlatformGraphicsContextRecording::drawHighlightForText( @@ -596,6 +609,28 @@ void PlatformGraphicsContextRecording::popMatrix() mCurrentMatrix = &(mMatrixStack.last()); } +IntRect PlatformGraphicsContextRecording::calculateFinalBounds(FloatRect bounds) +{ + if (m_gc->hasShadow()) { + const ShadowRec& shadow = m_state->shadow; + if (shadow.blur > 0) + bounds.inflate(ceilf(shadow.blur)); + bounds.setWidth(bounds.width() + abs(shadow.dx)); + bounds.setHeight(bounds.height() + abs(shadow.dy)); + if (shadow.dx < 0) + bounds.move(shadow.dx, 0); + if (shadow.dy < 0) + bounds.move(0, shadow.dy); + // Add a bit extra to deal with rounding and blurring + bounds.inflate(4); + } + if (m_state->strokeStyle != NoStroke) + bounds.inflate(std::min(1.0f, m_state->strokeThickness)); + SkRect translated; + mCurrentMatrix->mapRect(&translated, bounds); + return enclosingIntRect(translated); +} + void PlatformGraphicsContextRecording::appendDrawingOperation( GraphicsOperation::Operation* operation, const FloatRect& untranslatedBounds) { @@ -604,12 +639,11 @@ void PlatformGraphicsContextRecording::appendDrawingOperation( return; } m_isEmpty = false; - SkRect bounds; - mCurrentMatrix->mapRect(&bounds, untranslatedBounds); if (mRecordingStateStack.size()) { RecordingState& state = mRecordingStateStack.last(); state.mHasDrawing = true; - state.addBounds(bounds); + if (!state.mHasClip) + state.addBounds(calculateFinalBounds(untranslatedBounds)); state.mSaveOperation->operations()->adoptAndAppend(operation); return; } @@ -621,7 +655,7 @@ void PlatformGraphicsContextRecording::appendDrawingOperation( operation->m_matrix = mOperationMatrix; RecordingData* data = new RecordingData(operation, mRecording->recording()->m_nodeCount++); - WebCore::IntRect ibounds = enclosingIntRect(bounds); + WebCore::IntRect ibounds = calculateFinalBounds(untranslatedBounds); mRecording->recording()->m_tree.insert(ibounds, data); } diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h index 89f9bbb..fd6fb5e 100644 --- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h +++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h @@ -152,6 +152,7 @@ private: void popSaveOperation(); void pushMatrix(); void popMatrix(); + IntRect calculateFinalBounds(FloatRect bounds); SkPicture* mPicture; SkMatrix* mCurrentMatrix; diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.h b/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.h index 06929e1..80c6545 100644 --- a/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.h +++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.h @@ -85,7 +85,7 @@ private: void swapTileGrids(); // Delay before we schedule a new tile at the new scale factor - static const double s_zoomUpdateDelay = 0.2; // 200 ms + static const double s_zoomUpdateDelay = 0.1; // 100 ms TileGrid* m_frontTileGrid; TileGrid* m_backTileGrid; diff --git a/Source/WebKit/android/jni/WebSettings.cpp b/Source/WebKit/android/jni/WebSettings.cpp index 467da3d..1bd3e36 100644 --- a/Source/WebKit/android/jni/WebSettings.cpp +++ b/Source/WebKit/android/jni/WebSettings.cpp @@ -151,6 +151,7 @@ struct FieldIds { #endif mOverrideCacheMode = env->GetFieldID(clazz, "mOverrideCacheMode", "I"); mPasswordEchoEnabled = env->GetFieldID(clazz, "mPasswordEchoEnabled", "Z"); + mMediaPlaybackRequiresUserGesture = env->GetFieldID(clazz, "mMediaPlaybackRequiresUserGesture", "Z"); ALOG_ASSERT(mLayoutAlgorithm, "Could not find field mLayoutAlgorithm"); ALOG_ASSERT(mTextSize, "Could not find field mTextSize"); @@ -195,6 +196,7 @@ struct FieldIds { ALOG_ASSERT(mUseDoubleTree, "Could not find field mUseDoubleTree"); ALOG_ASSERT(mPageCacheCapacity, "Could not find field mPageCacheCapacity"); ALOG_ASSERT(mPasswordEchoEnabled, "Could not find field mPasswordEchoEnabled"); + ALOG_ASSERT(mMediaPlaybackRequiresUserGesture, "Could not find field mMediaPlaybackRequiresUserGesture"); jclass enumClass = env->FindClass("java/lang/Enum"); ALOG_ASSERT(enumClass, "Could not find Enum class!"); @@ -281,6 +283,7 @@ struct FieldIds { #endif jfieldID mOverrideCacheMode; jfieldID mPasswordEchoEnabled; + jfieldID mMediaPlaybackRequiresUserGesture; }; static struct FieldIds* gFieldIds; @@ -616,6 +619,9 @@ public: bool echoPassword = env->GetBooleanField(obj, gFieldIds->mPasswordEchoEnabled); s->setPasswordEchoEnabled(echoPassword); + + flag = env->GetBooleanField(obj, gFieldIds->mMediaPlaybackRequiresUserGesture); + s->setMediaPlaybackRequiresUserGesture(flag); } }; |