Bug 1479234 - Factor out a function getting an OMTAValue from the compositor. r=boris
☠☠ backed out by 775c7c08f6fd ☠ ☠
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Tue, 31 Jul 2018 06:13:15 +0900
changeset 429236 6ecc1666f571b6c97b7c30e2795a91334d09d65f
parent 429235 c3bab1bc97cf21e73699a2b9d2ac114522d19391
child 429237 775c7c08f6fd3cb3e9d53a889f7860654cf60c9a
push id67091
push userhikezoe@mozilla.com
push dateMon, 30 Jul 2018 21:15:55 +0000
treeherderautoland@6ecc1666f571 [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
dom/base/nsDOMWindowUtils.h
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -3650,16 +3650,43 @@ GetTargetFrame(const Element* aElement, 
       frame = nsLayoutUtils::GetAfterFrame(aElement);
     } else {
       return Err(NS_ERROR_INVALID_ARG);
     }
   }
   return frame;
 }
 
+OMTAValue
+nsDOMWindowUtils::GetOMTAValue(nsIFrame* aFrame,
+                               DisplayItemType aDisplayItemKey)
+{
+  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 (WebRenderBridgeChild* wrbc = GetWebRenderBridge()) {
+    RefPtr<WebRenderAnimationData> animationData =
+      GetWebRenderUserData<WebRenderAnimationData>(aFrame,
+                                                   (uint32_t)aDisplayItemKey);
+    if (animationData) {
+      wrbc->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 +3701,23 @@ 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);
       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);
       if (value.type() == OMTAValue::TMatrix4x4) {
         cssValue = nsComputedDOMStyle::MatrixToCSSValue(value.get_Matrix4x4());
       }
     }
   }
 
   if (cssValue) {
     nsString text;
--- a/dom/base/nsDOMWindowUtils.h
+++ b/dom/base/nsDOMWindowUtils.h
@@ -5,20 +5,23 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsDOMWindowUtils_h_
 #define nsDOMWindowUtils_h_
 
 #include "nsWeakReference.h"
 
 #include "nsIDOMWindowUtils.h"
+#include "nsDisplayItemTypes.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/BasicEvents.h"
+#include "mozilla/layers/LayersMessages.h" // For OMTAValue
 
 class nsGlobalWindowOuter;
+class nsIFrame;
 class nsIPresShell;
 class nsIWidget;
 class nsPresContext;
 class nsIDocument;
 class nsView;
 struct nsPoint;
 
 namespace mozilla {
@@ -113,11 +116,14 @@ protected:
                                   uint32_t* aRys,
                                   float* aRotationAngles,
                                   float* aForces,
                                   uint32_t aCount,
                                   int32_t aModifiers,
                                   bool aIgnoreRootScrollFrame,
                                   bool aToWindow,
                                   bool* aPreventDefault);
+
+  mozilla::layers::OMTAValue GetOMTAValue(nsIFrame* aFrame,
+                                          DisplayItemType aDisplayItemKey);
 };
 
 #endif