summaryrefslogtreecommitdiffstats
path: root/WebCore/platform
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2011-03-02 15:44:58 -0500
committerDerek Sollenberger <djsollen@google.com>2011-03-02 15:50:45 -0500
commit06a6a5b3278850bdae8370474da78c119801b4e2 (patch)
treea96b502f7c1109409ef80562b0a79ea391c59859 /WebCore/platform
parent46319ccd782989cc691ea412e44cb4283d183ccb (diff)
downloadexternal_webkit-06a6a5b3278850bdae8370474da78c119801b4e2.zip
external_webkit-06a6a5b3278850bdae8370474da78c119801b4e2.tar.gz
external_webkit-06a6a5b3278850bdae8370474da78c119801b4e2.tar.bz2
Ensure plugin content does not shift when gaining focus.
bug: 3477581 Change-Id: Ia7bbaaca405db33dbefaa8f6f00e9250580e5f7b
Diffstat (limited to 'WebCore/platform')
-rw-r--r--WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp14
-rw-r--r--WebCore/platform/graphics/android/MediaLayer.cpp10
-rw-r--r--WebCore/platform/graphics/android/MediaLayer.h2
3 files changed, 25 insertions, 1 deletions
diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
index 48badf8..7963ae0 100644
--- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
@@ -25,6 +25,7 @@
#include "GraphicsContext.h"
#include "Image.h"
#include "Length.h"
+#include "MediaLayer.h"
#include "PlatformBridge.h"
#include "PlatformGraphicsContext.h"
#include "RenderLayerBacking.h"
@@ -321,6 +322,19 @@ void GraphicsLayerAndroid::setSize(const FloatSize& size)
return;
MLOG("(%x) setSize (%.2f,%.2f)", this, size.width(), size.height());
GraphicsLayer::setSize(size);
+
+ // If it is a media layer the size may have changed as a result of the media
+ // element (e.g. plugin) gaining focus. Therefore, we must sync the size of
+ // the focus' outline so that our UI thread can draw accordingly.
+ if (m_contentLayer->isMedia() && m_client) {
+ RenderLayer* layer = renderLayerFromClient(m_client);
+ RenderBox* box = layer->renderBox();
+ int outline = box->view()->maximalOutlineSize();
+ static_cast<MediaLayer*>(m_contentLayer)->setOutlineSize(outline);
+ LOG("Media Outline: %d %p %p %p", outline, m_client, layer, box);
+ LOG("Media Size: %g,%g", size.width(), size.height());
+ }
+
m_contentLayer->setSize(size.width(), size.height());
askForSync();
}
diff --git a/WebCore/platform/graphics/android/MediaLayer.cpp b/WebCore/platform/graphics/android/MediaLayer.cpp
index 9bc2a3e..fbcd494 100644
--- a/WebCore/platform/graphics/android/MediaLayer.cpp
+++ b/WebCore/platform/graphics/android/MediaLayer.cpp
@@ -49,6 +49,7 @@ MediaLayer::MediaLayer(jobject weakWebViewRef) : LayerAndroid(false)
m_currentTextureInfo = 0;
m_isContentInverted = false;
+ m_outlineSize = 0;
XLOG("Creating Media Layer %p", this);
}
@@ -61,6 +62,7 @@ MediaLayer::MediaLayer(const MediaLayer& layer) : LayerAndroid(layer)
m_currentTextureInfo = 0;
m_isContentInverted = layer.m_isContentInverted;
+ m_outlineSize = layer.m_outlineSize;
XLOG("Creating Media Layer Copy %p -> %p", &layer, this);
}
@@ -73,7 +75,13 @@ MediaLayer::~MediaLayer()
bool MediaLayer::drawGL(SkMatrix& matrix)
{
- TilesManager::instance()->shader()->clip(drawClip());
+ // when the plugin gains focus webkit applies an outline to the widget,
+ // which causes the layer to expand to accommodate the outline. Therefore,
+ // we shrink the clip by the outline's dimensions to ensure the plugin does
+ // not draw outside of its bounds.
+ FloatRect clip = drawClip();
+ clip.inflate(-m_outlineSize);
+ TilesManager::instance()->shader()->clip(clip);
// check to see if we need to create a video texture
m_videoTexture->initNativeWindowIfNeeded();
diff --git a/WebCore/platform/graphics/android/MediaLayer.h b/WebCore/platform/graphics/android/MediaLayer.h
index 15bd6d8..203ef93 100644
--- a/WebCore/platform/graphics/android/MediaLayer.h
+++ b/WebCore/platform/graphics/android/MediaLayer.h
@@ -49,6 +49,7 @@ public:
TextureInfo* getCurrentTextureInfo() const { return m_currentTextureInfo; }
void invertContents(bool invertContent) { m_isContentInverted = invertContent; }
+ void setOutlineSize(int size) { m_outlineSize = size; }
// functions to manipulate secondary layers for video playback
ANativeWindow* acquireNativeWindowForVideo();
@@ -62,6 +63,7 @@ private:
TextureInfo* m_currentTextureInfo;
bool m_isContentInverted;
+ int m_outlineSize;
// Video texture variables
VideoTexture* m_videoTexture;