Bug 1062106 part 3 - Remove SMIL MappedAttribute mechanism. r=birtles
☠☠ backed out by 63cbef012e2a ☠ ☠
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Tue, 21 Mar 2017 15:45:58 +0900
changeset 348592 7682b2da0437cafe57b2358adf7400ce2d4b9ee7
parent 348591 e77bfa57be613acfa77da4c3d28ac61c9ef83ba6
child 348593 7ac1fffb6a876253d580abddfd62411673b93f3b
push id31532
push userkwierso@gmail.com
push dateTue, 21 Mar 2017 22:32:51 +0000
treeherdermozilla-central@18bb0299dd9b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
bugs1062106
milestone55.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 1062106 part 3 - Remove SMIL MappedAttribute mechanism. r=birtles We can remove unnecesasary SMILMappedAttribute and SMILAttrAnimationRuleProcessor since earlier patches in this serieas mean this code is no longer used. MozReview-Commit-ID: 5Rl5WFW5zZ1
dom/base/nsINode.h
dom/smil/moz.build
dom/smil/nsSMILMappedAttribute.cpp
dom/smil/nsSMILMappedAttribute.h
dom/smil/nsSMILTimeContainer.cpp
dom/svg/nsSVGElement.cpp
dom/svg/nsSVGElement.h
--- a/dom/base/nsINode.h
+++ b/dom/base/nsINode.h
@@ -277,17 +277,16 @@ private:
 // defined, it is inherited from nsINode.
 // This macro isn't actually specific to nodes, and bug 956400 will move it into MFBT.
 #define NS_DECL_SIZEOF_EXCLUDING_THIS \
   virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override;
 
 // Categories of node properties
 // 0 is global.
 #define DOM_USER_DATA         1
-#define SMIL_MAPPED_ATTR_ANIMVAL 2
 
 // IID for the nsINode interface
 #define NS_INODE_IID \
 { 0x70ba4547, 0x7699, 0x44fc, \
   { 0xb3, 0x20, 0x52, 0xdb, 0xe3, 0xd1, 0xf9, 0x0a } }
 
 /**
  * An internal interface that abstracts some DOMNode-related parts that both
--- a/dom/smil/moz.build
+++ b/dom/smil/moz.build
@@ -14,17 +14,16 @@ EXPORTS += [
     'nsISMILType.h',
     'nsSMILAnimationController.h',
     'nsSMILAnimationFunction.h',
     'nsSMILCompositorTable.h',
     'nsSMILCSSProperty.h',
     'nsSMILInstanceTime.h',
     'nsSMILInterval.h',
     'nsSMILKeySpline.h',
-    'nsSMILMappedAttribute.h',
     'nsSMILMilestone.h',
     'nsSMILNullType.h',
     'nsSMILRepeatCount.h',
     'nsSMILSetAnimationFunction.h',
     'nsSMILTargetIdentifier.h',
     'nsSMILTimeContainer.h',
     'nsSMILTimedElement.h',
     'nsSMILTimeValue.h',
@@ -43,17 +42,16 @@ UNIFIED_SOURCES += [
     'nsSMILAnimationFunction.cpp',
     'nsSMILCompositor.cpp',
     'nsSMILCSSProperty.cpp',
     'nsSMILCSSValueType.cpp',
     'nsSMILFloatType.cpp',
     'nsSMILInstanceTime.cpp',
     'nsSMILInterval.cpp',
     'nsSMILKeySpline.cpp',
-    'nsSMILMappedAttribute.cpp',
     'nsSMILNullType.cpp',
     'nsSMILParserUtils.cpp',
     'nsSMILRepeatCount.cpp',
     'nsSMILSetAnimationFunction.cpp',
     'nsSMILTimeContainer.cpp',
     'nsSMILTimedElement.cpp',
     'nsSMILTimeValue.cpp',
     'nsSMILTimeValueSpec.cpp',
deleted file mode 100644
--- a/dom/smil/nsSMILMappedAttribute.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/* representation of a SMIL-animatable mapped attribute on an element */
-#include "nsSMILMappedAttribute.h"
-#include "nsContentUtils.h"
-#include "nsError.h" // For NS_PROPTABLE_PROP_OVERWRITTEN
-#include "nsSMILValue.h"
-#include "nsSMILCSSValueType.h"
-#include "nsIDocument.h"
-#include "nsIPresShell.h"
-#include "nsCSSProps.h"
-#include "mozilla/dom/Element.h"
-
-// Callback function, for freeing string buffers stored in property table
-static void
-ReleaseStringBufferPropertyValue(void*    aObject,       /* unused */
-                                 nsIAtom* aPropertyName, /* unused */
-                                 void*    aPropertyValue,
-                                 void*    aData          /* unused */)
-{
-  nsStringBuffer* buf = static_cast<nsStringBuffer*>(aPropertyValue);
-  buf->Release();
-}
-
-
-nsresult
-nsSMILMappedAttribute::ValueFromString(const nsAString& aStr,
-                                       const mozilla::dom::SVGAnimationElement* aSrcElement,
-                                       nsSMILValue& aValue,
-                                       bool& aPreventCachingOfSandwich) const
-{
-  NS_ENSURE_TRUE(IsPropertyAnimatable(mPropID), NS_ERROR_FAILURE);
-
-  nsSMILCSSValueType::ValueFromString(mPropID, mElement, aStr, aValue,
-                                      &aPreventCachingOfSandwich);
-  return aValue.IsNull() ? NS_ERROR_FAILURE : NS_OK;
-}
-
-nsSMILValue
-nsSMILMappedAttribute::GetBaseValue() const
-{
-  nsAutoString baseStringValue;
-  RefPtr<nsIAtom> attrName = GetAttrNameAtom();
-  bool success = mElement->GetAttr(kNameSpaceID_None, attrName,
-                                     baseStringValue);
-  nsSMILValue baseValue;
-  if (success) {
-    // For base values, we don't need to worry whether the value returned is
-    // context-sensitive or not since the compositor will take care of comparing
-    // the returned (computed) base value and its cached value and determining
-    // if an update is required or not.
-    nsSMILCSSValueType::ValueFromString(mPropID, mElement,
-                                        baseStringValue, baseValue, nullptr);
-  } else {
-    // Attribute is unset -- use computed value.
-    // FIRST: Temporarily clear animated value, to make sure it doesn't pollute
-    // the computed value. (We want base value, _without_ animations applied.)
-    void* buf = mElement->UnsetProperty(SMIL_MAPPED_ATTR_ANIMVAL,
-                                        attrName, nullptr);
-    FlushChangesToTargetAttr();
-
-    // SECOND: we use nsSMILCSSProperty::GetBaseValue to look up the property's
-    // computed value.  NOTE: This call will temporarily clear the SMIL
-    // override-style for the corresponding CSS property on our target element.
-    // This prevents any animations that target the CSS property from affecting
-    // animations that target the mapped attribute.
-    baseValue = nsSMILCSSProperty::GetBaseValue();
-
-    // FINALLY: If we originally had an animated value set, then set it again.
-    if (buf) {
-      mElement->SetProperty(SMIL_MAPPED_ATTR_ANIMVAL, attrName, buf,
-                            ReleaseStringBufferPropertyValue);
-      FlushChangesToTargetAttr();
-    }
-  }
-  return baseValue;
-}
-
-nsresult
-nsSMILMappedAttribute::SetAnimValue(const nsSMILValue& aValue)
-{
-  NS_ENSURE_TRUE(IsPropertyAnimatable(mPropID), NS_ERROR_FAILURE);
-
-  // Convert nsSMILValue to string
-  nsAutoString valStr;
-  if (!nsSMILCSSValueType::ValueToString(aValue, valStr)) {
-    NS_WARNING("Failed to convert nsSMILValue for mapped attr into a string");
-    return NS_ERROR_FAILURE;
-  }
-
-  RefPtr<nsIAtom> attrName = GetAttrNameAtom();
-  nsStringBuffer* oldValStrBuf = static_cast<nsStringBuffer*>
-    (mElement->GetProperty(SMIL_MAPPED_ATTR_ANIMVAL, attrName));
-  if (oldValStrBuf) {
-    nsString oldValStr;
-    nsContentUtils::PopulateStringFromStringBuffer(oldValStrBuf, oldValStr);
-    if (valStr.Equals(oldValStr)) {
-      // New animated value is the same as the old; nothing to do.
-      return NS_OK;
-    }
-  }
-
-  // Set the string as this mapped attribute's animated value.
-  nsStringBuffer* valStrBuf =
-    nsCSSValue::BufferFromString(nsString(valStr)).take();
-  nsresult rv = mElement->SetProperty(SMIL_MAPPED_ATTR_ANIMVAL,
-                                      attrName, valStrBuf,
-                                      ReleaseStringBufferPropertyValue);
-  if (rv == NS_PROPTABLE_PROP_OVERWRITTEN) {
-    rv = NS_OK;
-  }
-  FlushChangesToTargetAttr();
-
-  return rv;
-}
-
-void
-nsSMILMappedAttribute::ClearAnimValue()
-{
-  RefPtr<nsIAtom> attrName = GetAttrNameAtom();
-  mElement->DeleteProperty(SMIL_MAPPED_ATTR_ANIMVAL, attrName);
-  FlushChangesToTargetAttr();
-}
-
-void
-nsSMILMappedAttribute::FlushChangesToTargetAttr() const
-{
-  // Clear animated content-style-rule
-  mElement->DeleteProperty(SMIL_MAPPED_ATTR_ANIMVAL,
-                           SMIL_MAPPED_ATTR_STYLEDECL_ATOM);
-  nsIDocument* doc = mElement->GetUncomposedDoc();
-
-  // Request animation restyle
-  if (doc) {
-    nsIPresShell* shell = doc->GetShell();
-    if (shell) {
-      shell->RestyleForAnimation(mElement, eRestyle_Self);
-    }
-  }
-}
-
-already_AddRefed<nsIAtom>
-nsSMILMappedAttribute::GetAttrNameAtom() const
-{
-  return NS_Atomize(nsCSSProps::GetStringValue(mPropID));
-}
deleted file mode 100644
--- a/dom/smil/nsSMILMappedAttribute.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/* representation of a SMIL-animatable mapped attribute on an element */
-
-#ifndef NS_SMILMAPPEDATTRIBUTE_H_
-#define NS_SMILMAPPEDATTRIBUTE_H_
-
-#include "mozilla/Attributes.h"
-#include "nsSMILCSSProperty.h"
-
-/* We'll use the empty-string atom |nsGkAtoms::_empty| as the key for storing an
- * element's animated content style declaration in its Property Table, under the
- * property-category SMIL_MAPPED_ATTR_ANIMVAL.  Everything else stored in that
- * category is keyed off of the XML attribute name, so the empty string is a
- * good "reserved" key to use for storing the style rule (since XML attributes
- * all have nonempty names).
- */
-#define SMIL_MAPPED_ATTR_STYLEDECL_ATOM nsGkAtoms::_empty
-
-/**
- * nsSMILMappedAttribute: Implements the nsISMILAttr interface for SMIL
- * animations whose targets are attributes that map to CSS properties.  An
- * instance of this class represents a particular animation-targeted mapped
- * attribute on a particular element.
- */
-class nsSMILMappedAttribute : public nsSMILCSSProperty {
-public:
-  /**
-   * Constructs a new nsSMILMappedAttribute.
-   *
-   * @param  aPropID   The CSS property for the mapped attribute we're
-   *                   interested in animating.
-   * @param  aElement  The element whose attribute is being animated.
-   */
-  nsSMILMappedAttribute(nsCSSPropertyID aPropID, mozilla::dom::Element* aElement) :
-    nsSMILCSSProperty(aPropID, aElement) {}
-
-  // nsISMILAttr methods
-  virtual nsresult ValueFromString(const nsAString& aStr,
-                                   const mozilla::dom::SVGAnimationElement* aSrcElement,
-                                   nsSMILValue& aValue,
-                                   bool& aPreventCachingOfSandwich) const override;
-  virtual nsSMILValue GetBaseValue() const override;
-  virtual nsresult    SetAnimValue(const nsSMILValue& aValue) override;
-  virtual void        ClearAnimValue() override;
-
-protected:
-  // Helper Methods
-  void FlushChangesToTargetAttr() const;
-  already_AddRefed<nsIAtom> GetAttrNameAtom() const;
-};
-#endif // NS_SMILMAPPEDATTRIBUTE_H_
--- a/dom/smil/nsSMILTimeContainer.cpp
+++ b/dom/smil/nsSMILTimeContainer.cpp
@@ -6,16 +6,18 @@
 
 #include "nsSMILTimeContainer.h"
 #include "nsSMILTimeValue.h"
 #include "nsSMILTimedElement.h"
 #include <algorithm>
 
 #include "mozilla/AutoRestore.h"
 
+using namespace mozilla;
+
 nsSMILTimeContainer::nsSMILTimeContainer()
 :
   mParent(nullptr),
   mCurrentTime(0L),
   mParentOffset(0L),
   mPauseStart(0L),
   mNeedsPauseSample(false),
   mNeedsRewind(false),
--- a/dom/svg/nsSVGElement.cpp
+++ b/dom/svg/nsSVGElement.cpp
@@ -42,17 +42,16 @@
 #include "SVGAnimatedLengthList.h"
 #include "SVGAnimatedPointList.h"
 #include "SVGAnimatedPathSegList.h"
 #include "SVGContentUtils.h"
 #include "SVGGeometryElement.h"
 #include "nsIFrame.h"
 #include "nsQueryObject.h"
 #include <stdarg.h>
-#include "nsSMILMappedAttribute.h"
 #include "SVGMotionSMILAttr.h"
 #include "nsAttrValueOrString.h"
 #include "nsSMILAnimationController.h"
 #include "mozilla/dom/SVGElementBinding.h"
 #include "mozilla/DeclarationBlock.h"
 #include "mozilla/DeclarationBlockInlines.h"
 #include "mozilla/Unused.h"
 #include "mozilla/RestyleManager.h"
@@ -929,44 +928,16 @@ nsSVGElement::WalkContentStyleRules(nsRu
     css::Declaration* declaration = mContentDeclarationBlock->AsGecko();
     declaration->SetImmutable();
     aRuleWalker->Forward(declaration);
   }
 
   return NS_OK;
 }
 
-void
-nsSVGElement::WalkAnimatedContentStyleRules(nsRuleWalker* aRuleWalker)
-{
-  // Update & walk the animated content style rule, to include style from
-  // animated mapped attributes.  But first, get nsPresContext to check
-  // whether this is a "no-animation restyle". (This should match the check
-  // in nsHTMLCSSStyleSheet::RulesMatching(), where we determine whether to
-  // apply the SMILOverrideStyle.)
-  RestyleManager* restyleManager =
-    aRuleWalker->PresContext()->RestyleManager();
-  MOZ_ASSERT(restyleManager->IsGecko(),
-             "stylo: Servo-backed style system should not be calling "
-             "WalkAnimatedContentStyleRules");
-  if (!restyleManager->AsGecko()->SkipAnimationRules()) {
-    // update/walk the animated content style rule.
-    DeclarationBlock* animContentDeclBlock = GetAnimatedContentDeclarationBlock();
-    if (!animContentDeclBlock) {
-      UpdateAnimatedContentDeclarationBlock();
-      animContentDeclBlock = GetAnimatedContentDeclarationBlock();
-    }
-    if (animContentDeclBlock) {
-      css::Declaration* declaration = animContentDeclBlock->AsGecko();
-      declaration->SetImmutable();
-      aRuleWalker->Forward(declaration);
-    }
-  }
-}
-
 NS_IMETHODIMP_(bool)
 nsSVGElement::IsAttributeMapped(const nsIAtom* name) const
 {
   if (name == nsGkAtoms::lang) {
     return true;
   }
   return nsSVGElementBase::IsAttributeMapped(name);
 }
@@ -1376,95 +1347,16 @@ nsSVGElement::UpdateContentDeclarationBl
 }
 
 const DeclarationBlock*
 nsSVGElement::GetContentDeclarationBlock() const
 {
   return mContentDeclarationBlock;
 }
 
-static void
-ParseMappedAttrAnimValueCallback(void*    aObject,
-                                 nsIAtom* aPropertyName,
-                                 void*    aPropertyValue,
-                                 void*    aData)
-{
-  MOZ_ASSERT(aPropertyName != SMIL_MAPPED_ATTR_STYLEDECL_ATOM,
-             "animated content style rule should have been removed "
-             "from properties table already (we're rebuilding it now)");
-
-  MappedAttrParser* mappedAttrParser = static_cast<MappedAttrParser*>(aData);
-  MOZ_ASSERT(mappedAttrParser, "parser should be non-null");
-
-  nsStringBuffer* animValBuf = static_cast<nsStringBuffer*>(aPropertyValue);
-  MOZ_ASSERT(animValBuf, "animated value should be non-null");
-
-  nsString animValStr;
-  nsContentUtils::PopulateStringFromStringBuffer(animValBuf, animValStr);
-
-  mappedAttrParser->ParseMappedAttrValue(aPropertyName, animValStr);
-}
-
-// Callback for freeing animated content decl block, in property table.
-static void
-ReleaseDeclBlock(void*    aObject,       /* unused */
-                 nsIAtom* aPropertyName,
-                 void*    aPropertyValue,
-                 void*    aData          /* unused */)
-{
-  MOZ_ASSERT(aPropertyName == SMIL_MAPPED_ATTR_STYLEDECL_ATOM,
-             "unexpected property name, for animated content style rule");
-  auto decl = static_cast<DeclarationBlock*>(aPropertyValue);
-  MOZ_ASSERT(decl, "unexpected null decl");
-  decl->Release();
-}
-
-void
-nsSVGElement::UpdateAnimatedContentDeclarationBlock()
-{
-  MOZ_ASSERT(!GetAnimatedContentDeclarationBlock(),
-             "Animated content declaration block already set");
-
-  nsIDocument* doc = OwnerDoc();
-  if (!doc) {
-    NS_ERROR("SVG element without owner document");
-    return;
-  }
-
-  // FIXME (bug 1342557): Support SMIL in Servo
-  MappedAttrParser mappedAttrParser(doc->CSSLoader(), doc->GetDocumentURI(),
-                                    GetBaseURI(), this, StyleBackendType::Gecko);
-  doc->PropertyTable(SMIL_MAPPED_ATTR_ANIMVAL)->
-    Enumerate(this, ParseMappedAttrAnimValueCallback, &mappedAttrParser);
- 
-  RefPtr<DeclarationBlock> animContentDeclBlock =
-    mappedAttrParser.GetDeclarationBlock();
-
-  if (animContentDeclBlock) {
-#ifdef DEBUG
-    nsresult rv =
-#endif
-      SetProperty(SMIL_MAPPED_ATTR_ANIMVAL,
-                  SMIL_MAPPED_ATTR_STYLEDECL_ATOM,
-                  animContentDeclBlock.forget().take(),
-                  ReleaseDeclBlock);
-    MOZ_ASSERT(rv == NS_OK,
-               "SetProperty failed (or overwrote something)");
-  }
-}
-
-DeclarationBlock*
-nsSVGElement::GetAnimatedContentDeclarationBlock()
-{
-  return
-    static_cast<DeclarationBlock*>(GetProperty(SMIL_MAPPED_ATTR_ANIMVAL,
-                                               SMIL_MAPPED_ATTR_STYLEDECL_ATOM,
-                                               nullptr));
-}
-
 /**
  * Helper methods for the type-specific WillChangeXXX methods.
  *
  * This method sends out appropriate pre-change notifications so that selector
  * restyles (e.g. due to changes that cause |elem[attr="val"]| to start/stop
  * matching) work, and it returns an nsAttrValue that _may_ contain the
  * attribute's pre-change value.
  *
--- a/dom/svg/nsSVGElement.h
+++ b/dom/svg/nsSVGElement.h
@@ -352,19 +352,16 @@ protected:
   virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
                                 const nsAttrValue* aValue, bool aNotify) override;
   virtual bool ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute,
                                 const nsAString& aValue, nsAttrValue& aResult) override;
   static nsresult ReportAttributeParseFailure(nsIDocument* aDocument,
                                               nsIAtom* aAttribute,
                                               const nsAString& aValue);
 
-  void UpdateAnimatedContentDeclarationBlock();
-  mozilla::DeclarationBlock* GetAnimatedContentDeclarationBlock();
-
   nsAttrValue WillChangeValue(nsIAtom* aName);
   // aNewValue is set to the old value. This value may be invalid if
   // !StoresOwnData.
   void DidChangeValue(nsIAtom* aName, const nsAttrValue& aEmptyOrOldValue,
                       nsAttrValue& aNewValue);
   void MaybeSerializeAttrBeforeRemoval(nsIAtom* aName, bool aNotify);
 
   static nsIAtom* GetEventNameForAttr(nsIAtom* aAttr);