#include "GraphicsContext.h"
#include "Image.h"
#include "Length.h"
+#include "MediaLayer.h"
#include "PlatformBridge.h"
#include "PlatformGraphicsContext.h"
#include "RenderLayerBacking.h"
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();
}
m_currentTextureInfo = 0;
m_isContentInverted = false;
+ m_outlineSize = 0;
XLOG("Creating Media Layer %p", this);
}
m_currentTextureInfo = 0;
m_isContentInverted = layer.m_isContentInverted;
+ m_outlineSize = layer.m_outlineSize;
XLOG("Creating Media Layer Copy %p -> %p", &layer, this);
}
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();
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();
TextureInfo* m_currentTextureInfo;
bool m_isContentInverted;
+ int m_outlineSize;
// Video texture variables
VideoTexture* m_videoTexture;