Bug 1479234 - Factor out a function getting an OMTAValue from the compositor. r=boris
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Tue, 31 Jul 2018 08:13:04 +0900
changeset 429266 7356e631ab340da0b7f9090b1bc3374c903cc944
parent 429265 23119363c98a566674fb87148fa006c37536beea
child 429267 34b671e3dd5d29ee2c4429b816bbb37a8b764f63
push id34358
push usershindli@mozilla.com
push dateTue, 31 Jul 2018 09:52:17 +0000
treeherdermozilla-central@d423ef280609 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersboris
bugs1479234
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1479234 - Factor out a function getting an OMTAValue from the compositor. r=boris MozReview-Commit-ID: HciPnmLDiYd
dom/base/nsDOMWindowUtils.cpp
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -3650,16 +3650,44 @@ GetTargetFrame(const Element* aElement, 
       frame = nsLayoutUtils::GetAfterFrame(aElement);
     } else {
       return Err(NS_ERROR_INVALID_ARG);
     }
   }
   return frame;
 }
 
+static OMTAValue
+GetOMTAValue(nsIFrame* aFrame,
+             DisplayItemType aDisplayItemKey,
+             WebRenderBridgeChild* aWebRenderBridgeChild)
+{
+  OMTAValue value = mozilla::null_t();
+
+  Layer* layer =
+    FrameLayerBuilder::GetDedicatedLayer(aFrame, aDisplayItemKey);
+  if (layer) {
+    ShadowLayerForwarder* forwarder = layer->Manager()->AsShadowForwarder();
+    if (forwarder && forwarder->HasShadowManager()) {
+      forwarder->GetShadowManager()->
+        SendGetAnimationValue(layer->GetCompositorAnimationsId(), &value);
+    }
+  } else if (aWebRenderBridgeChild) {
+    RefPtr<WebRenderAnimationData> animationData =
+      GetWebRenderUserData<WebRenderAnimationData>(aFrame,
+                                                   (uint32_t)aDisplayItemKey);
+    if (animationData) {
+      aWebRenderBridgeChild->SendGetAnimationValue(
+        animationData->GetAnimationInfo().GetCompositorAnimationsId(),
+        &value);
+    }
+  }
+  return value;
+}
+
 NS_IMETHODIMP
 nsDOMWindowUtils::GetOMTAStyle(Element* aElement,
                                const nsAString& aProperty,
                                const nsAString& aPseudoElement,
                                nsAString& aResult)
 {
   if (!aElement) {
     return NS_ERROR_INVALID_ARG;
@@ -3674,59 +3702,27 @@ nsDOMWindowUtils::GetOMTAStyle(Element* 
   RefPtr<nsROCSSPrimitiveValue> cssValue = nullptr;
   if (frame && nsLayoutUtils::AreAsyncAnimationsEnabled()) {
     RefPtr<LayerManager> widgetLayerManager;
     if (nsIWidget* widget = GetWidget()) {
       widgetLayerManager = widget->GetLayerManager();
     }
 
     if (aProperty.EqualsLiteral("opacity")) {
-      OMTAValue value;
-
-      Layer* layer =
-        FrameLayerBuilder::GetDedicatedLayer(frame, DisplayItemType::TYPE_OPACITY);
-      if (layer) {
-        ShadowLayerForwarder* forwarder = layer->Manager()->AsShadowForwarder();
-        if (forwarder && forwarder->HasShadowManager()) {
-          forwarder->GetShadowManager()->
-            SendGetAnimationValue(layer->GetCompositorAnimationsId(), &value);
-        }
-      } else if (WebRenderBridgeChild* wrbc = GetWebRenderBridge()) {
-        RefPtr<WebRenderAnimationData> animationData =
-            GetWebRenderUserData<WebRenderAnimationData>(frame, (uint32_t)DisplayItemType::TYPE_OPACITY);
-        if (animationData) {
-          wrbc->SendGetAnimationValue(
-              animationData->GetAnimationInfo().GetCompositorAnimationsId(),
-              &value);
-        }
-      }
+      OMTAValue value = GetOMTAValue(frame,
+                                     DisplayItemType::TYPE_OPACITY,
+                                     GetWebRenderBridge());
       if (value.type() == OMTAValue::Tfloat) {
         cssValue = new nsROCSSPrimitiveValue;
         cssValue->SetNumber(value.get_float());
       }
     } else if (aProperty.EqualsLiteral("transform")) {
-      OMTAValue value;
-
-      Layer* layer =
-        FrameLayerBuilder::GetDedicatedLayer(frame, DisplayItemType::TYPE_TRANSFORM);
-      if (layer) {
-        ShadowLayerForwarder* forwarder = layer->Manager()->AsShadowForwarder();
-        if (forwarder && forwarder->HasShadowManager()) {
-          forwarder->GetShadowManager()->
-            SendGetAnimationValue(layer->GetCompositorAnimationsId(), &value);
-        }
-      } else if (WebRenderBridgeChild* wrbc = GetWebRenderBridge()) {
-        RefPtr<WebRenderAnimationData> animationData =
-            GetWebRenderUserData<WebRenderAnimationData>(frame, (uint32_t)DisplayItemType::TYPE_TRANSFORM);
-        if (animationData) {
-          wrbc->SendGetAnimationValue(
-              animationData->GetAnimationInfo().GetCompositorAnimationsId(),
-              &value);
-        }
-      }
+      OMTAValue value = GetOMTAValue(frame,
+                                     DisplayItemType::TYPE_TRANSFORM,
+                                     GetWebRenderBridge());
       if (value.type() == OMTAValue::TMatrix4x4) {
         cssValue = nsComputedDOMStyle::MatrixToCSSValue(value.get_Matrix4x4());
       }
     }
   }
 
   if (cssValue) {
     nsString text;