Bug 1411238 - Make OMTA queries work with layers-free webrender. r=mtseng

MozReview-Commit-ID: Jq57GtjNO3E

--HG--
extra : rebase_source : 15c2e3a4acbc61c60827bf1748ef691f2275fb66
This commit is contained in:
Kartikaya Gupta 2017-10-25 11:14:41 -04:00
parent 0a3125a592
commit 4c7c7873e4
2 changed files with 50 additions and 16 deletions

View File

@ -3931,48 +3931,62 @@ nsDOMWindowUtils::GetOMTAStyle(nsIDOMElement* aElement,
}
}
if (frame && nsLayoutUtils::AreAsyncAnimationsEnabled()) {
RefPtr<LayerManager> widgetLayerManager;
if (nsIWidget* widget = GetWidget()) {
widgetLayerManager = widget->GetLayerManager();
}
if (aProperty.EqualsLiteral("opacity")) {
float value = 0;
bool hadAnimatedOpacity = false;
Layer* layer =
FrameLayerBuilder::GetDedicatedLayer(frame, DisplayItemType::TYPE_OPACITY);
if (layer) {
float value = 0;
bool hadAnimatedOpacity = false;
ShadowLayerForwarder* forwarder = layer->Manager()->AsShadowForwarder();
if (forwarder && forwarder->HasShadowManager()) {
forwarder->GetShadowManager()->
SendGetAnimationOpacity(layer->GetCompositorAnimationsId(),
&value,
&hadAnimatedOpacity);
} else if (WebRenderLayerManager* wrlm = layer->Manager()->AsWebRenderLayerManager()) {
}
} else if (WebRenderLayerManager* wrlm = widgetLayerManager->AsWebRenderLayerManager()) {
RefPtr<WebRenderAnimationData> animationData = wrlm->CommandBuilder()
.GetWebRenderUserData<WebRenderAnimationData>(frame, (uint32_t)DisplayItemType::TYPE_OPACITY);
if (animationData) {
wrlm->WrBridge()->SendGetAnimationOpacity(
layer->GetCompositorAnimationsId(),
animationData->GetAnimationInfo().GetCompositorAnimationsId(),
&value,
&hadAnimatedOpacity);
}
if (hadAnimatedOpacity) {
cssValue = new nsROCSSPrimitiveValue;
cssValue->SetNumber(value);
}
}
if (hadAnimatedOpacity) {
cssValue = new nsROCSSPrimitiveValue;
cssValue->SetNumber(value);
}
} else if (aProperty.EqualsLiteral("transform")) {
MaybeTransform transform;
Layer* layer =
FrameLayerBuilder::GetDedicatedLayer(frame, DisplayItemType::TYPE_TRANSFORM);
if (layer) {
MaybeTransform transform;
ShadowLayerForwarder* forwarder = layer->Manager()->AsShadowForwarder();
if (forwarder && forwarder->HasShadowManager()) {
forwarder->GetShadowManager()->
SendGetAnimationTransform(layer->GetCompositorAnimationsId(), &transform);
} else if (WebRenderLayerManager* wrlm = layer->Manager()->AsWebRenderLayerManager()) {
}
} else if (WebRenderLayerManager* wrlm = widgetLayerManager->AsWebRenderLayerManager()) {
RefPtr<WebRenderAnimationData> animationData = wrlm->CommandBuilder()
.GetWebRenderUserData<WebRenderAnimationData>(frame, (uint32_t)DisplayItemType::TYPE_TRANSFORM);
if (animationData) {
wrlm->WrBridge()->SendGetAnimationTransform(
layer->GetCompositorAnimationsId(),
animationData->GetAnimationInfo().GetCompositorAnimationsId(),
&transform);
}
if (transform.type() == MaybeTransform::TMatrix4x4) {
Matrix4x4 matrix = transform.get_Matrix4x4();
cssValue = nsComputedDOMStyle::MatrixToCSSValue(matrix);
}
}
if (transform.type() == MaybeTransform::TMatrix4x4) {
Matrix4x4 matrix = transform.get_Matrix4x4();
cssValue = nsComputedDOMStyle::MatrixToCSSValue(matrix);
}
}
}

View File

@ -146,6 +146,26 @@ public:
return res.forget();
}
template<class T> already_AddRefed<T>
GetWebRenderUserData(nsIFrame* aFrame, uint32_t aPerFrameKey)
{
RefPtr<T> result;
MOZ_ASSERT(aFrame);
nsIFrame::WebRenderUserDataTable* userDataTable =
aFrame->GetProperty(nsIFrame::WebRenderUserDataProperty());
if (!userDataTable) {
return result.forget();
}
WebRenderUserData* data = nullptr;
if (userDataTable->Get(aPerFrameKey, &data)) {
if (data->GetType() == T::Type() && data->IsDataValid(mManager)) {
result = static_cast<T*>(data);
}
}
return result.forget();
}
private:
WebRenderLayerManager* mManager;
ScrollingLayersHelper mScrollingHelper;