gecko-dev/layout/style/SVGAttrAnimationRuleProcess...

123 строки
3.3 KiB
C++
Исходник Обычный вид История

Bug 1057231 patch 1 - Add a rule processor class for rules from SMIL Animation of SVG attributes. r=dholbert This patch series (to move SVG Animation rules to their own level of the cascade) is needed so that they can participate in the mechanism for updating only animation styles to the present time without touching any other styles. In theory, this should have been done as part of 996796 or even as part of prior work on off main thread animations, except that it doesn't seem possible to have SVG Animations and CSS Transitions interacting on the same element and have that element's style out of date, which means it wasn't necessary for the existing code to update only animation styles. However, bug 960465 will use this similar mechanism as the new mechanism for making sure transitions start in a reasonable way (replacing the mechanism of phases, going from style without animation to style with animation via nsPresContext::IsProcessingAnimationStyleChange). This will require that, for SVG Animations to continue interacting correctly with CSS Transitions, that they have their own cascade level so that they can participate in RestyleManager::UpdateOnlyAnimationStyles. Additionally, this is needed even sooner, for bug 977991, which needs (temporarily, until bug 960465 lands) a mechanism for updating the style attribute style *and* all animation-phase-dependent styles. Yes, it's a little bit annoying to have to have another class, and another object per-document for this, but that's currently what comes with being a level of the cascade. But it's one class and one object per document, and I believe there will be substantial benefits to having all rule processor levels be only-animation-related or not-animation-related (except for the style attribute level, which is simple enough that it isn't needed yet).
2014-09-13 17:17:34 +04:00
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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/.
*/
/*
* style rule processor for rules from SMIL Animation of SVG mapped
* attributes (attributes whose values are mapped into style)
*/
#include "SVGAttrAnimationRuleProcessor.h"
#include "nsRuleProcessorData.h"
#include "nsSVGElement.h"
Bug 1057231 patch 1 - Add a rule processor class for rules from SMIL Animation of SVG attributes. r=dholbert This patch series (to move SVG Animation rules to their own level of the cascade) is needed so that they can participate in the mechanism for updating only animation styles to the present time without touching any other styles. In theory, this should have been done as part of 996796 or even as part of prior work on off main thread animations, except that it doesn't seem possible to have SVG Animations and CSS Transitions interacting on the same element and have that element's style out of date, which means it wasn't necessary for the existing code to update only animation styles. However, bug 960465 will use this similar mechanism as the new mechanism for making sure transitions start in a reasonable way (replacing the mechanism of phases, going from style without animation to style with animation via nsPresContext::IsProcessingAnimationStyleChange). This will require that, for SVG Animations to continue interacting correctly with CSS Transitions, that they have their own cascade level so that they can participate in RestyleManager::UpdateOnlyAnimationStyles. Additionally, this is needed even sooner, for bug 977991, which needs (temporarily, until bug 960465 lands) a mechanism for updating the style attribute style *and* all animation-phase-dependent styles. Yes, it's a little bit annoying to have to have another class, and another object per-document for this, but that's currently what comes with being a level of the cascade. But it's one class and one object per document, and I believe there will be substantial benefits to having all rule processor levels be only-animation-related or not-animation-related (except for the style attribute level, which is simple enough that it isn't needed yet).
2014-09-13 17:17:34 +04:00
using namespace mozilla;
using namespace mozilla::dom;
Bug 1057231 patch 1 - Add a rule processor class for rules from SMIL Animation of SVG attributes. r=dholbert This patch series (to move SVG Animation rules to their own level of the cascade) is needed so that they can participate in the mechanism for updating only animation styles to the present time without touching any other styles. In theory, this should have been done as part of 996796 or even as part of prior work on off main thread animations, except that it doesn't seem possible to have SVG Animations and CSS Transitions interacting on the same element and have that element's style out of date, which means it wasn't necessary for the existing code to update only animation styles. However, bug 960465 will use this similar mechanism as the new mechanism for making sure transitions start in a reasonable way (replacing the mechanism of phases, going from style without animation to style with animation via nsPresContext::IsProcessingAnimationStyleChange). This will require that, for SVG Animations to continue interacting correctly with CSS Transitions, that they have their own cascade level so that they can participate in RestyleManager::UpdateOnlyAnimationStyles. Additionally, this is needed even sooner, for bug 977991, which needs (temporarily, until bug 960465 lands) a mechanism for updating the style attribute style *and* all animation-phase-dependent styles. Yes, it's a little bit annoying to have to have another class, and another object per-document for this, but that's currently what comes with being a level of the cascade. But it's one class and one object per document, and I believe there will be substantial benefits to having all rule processor levels be only-animation-related or not-animation-related (except for the style attribute level, which is simple enough that it isn't needed yet).
2014-09-13 17:17:34 +04:00
SVGAttrAnimationRuleProcessor::SVGAttrAnimationRuleProcessor()
{
}
SVGAttrAnimationRuleProcessor::~SVGAttrAnimationRuleProcessor()
{
}
NS_IMPL_ISUPPORTS(SVGAttrAnimationRuleProcessor, nsIStyleRuleProcessor)
/* virtual */ void
SVGAttrAnimationRuleProcessor::RulesMatching(ElementRuleProcessorData* aData)
{
ElementRulesMatching(aData->mElement, aData->mRuleWalker);
}
void
SVGAttrAnimationRuleProcessor::ElementRulesMatching(Element* aElement,
nsRuleWalker* aRuleWalker)
{
if (aElement->IsSVGElement()) {
static_cast<nsSVGElement*>(aElement)->
WalkAnimatedContentStyleRules(aRuleWalker);
}
Bug 1057231 patch 1 - Add a rule processor class for rules from SMIL Animation of SVG attributes. r=dholbert This patch series (to move SVG Animation rules to their own level of the cascade) is needed so that they can participate in the mechanism for updating only animation styles to the present time without touching any other styles. In theory, this should have been done as part of 996796 or even as part of prior work on off main thread animations, except that it doesn't seem possible to have SVG Animations and CSS Transitions interacting on the same element and have that element's style out of date, which means it wasn't necessary for the existing code to update only animation styles. However, bug 960465 will use this similar mechanism as the new mechanism for making sure transitions start in a reasonable way (replacing the mechanism of phases, going from style without animation to style with animation via nsPresContext::IsProcessingAnimationStyleChange). This will require that, for SVG Animations to continue interacting correctly with CSS Transitions, that they have their own cascade level so that they can participate in RestyleManager::UpdateOnlyAnimationStyles. Additionally, this is needed even sooner, for bug 977991, which needs (temporarily, until bug 960465 lands) a mechanism for updating the style attribute style *and* all animation-phase-dependent styles. Yes, it's a little bit annoying to have to have another class, and another object per-document for this, but that's currently what comes with being a level of the cascade. But it's one class and one object per document, and I believe there will be substantial benefits to having all rule processor levels be only-animation-related or not-animation-related (except for the style attribute level, which is simple enough that it isn't needed yet).
2014-09-13 17:17:34 +04:00
}
/* virtual */ nsRestyleHint
SVGAttrAnimationRuleProcessor::HasStateDependentStyle(StateRuleProcessorData* aData)
{
return nsRestyleHint(0);
}
/* virtual */ nsRestyleHint
SVGAttrAnimationRuleProcessor::HasStateDependentStyle(PseudoElementStateRuleProcessorData* aData)
{
return nsRestyleHint(0);
}
/* virtual */ bool
SVGAttrAnimationRuleProcessor::HasDocumentStateDependentStyle(StateRuleProcessorData* aData)
{
return false;
}
/* virtual */ nsRestyleHint
SVGAttrAnimationRuleProcessor::HasAttributeDependentStyle(
AttributeRuleProcessorData* aData,
RestyleHintData& aRestyleHintDataResult)
Bug 1057231 patch 1 - Add a rule processor class for rules from SMIL Animation of SVG attributes. r=dholbert This patch series (to move SVG Animation rules to their own level of the cascade) is needed so that they can participate in the mechanism for updating only animation styles to the present time without touching any other styles. In theory, this should have been done as part of 996796 or even as part of prior work on off main thread animations, except that it doesn't seem possible to have SVG Animations and CSS Transitions interacting on the same element and have that element's style out of date, which means it wasn't necessary for the existing code to update only animation styles. However, bug 960465 will use this similar mechanism as the new mechanism for making sure transitions start in a reasonable way (replacing the mechanism of phases, going from style without animation to style with animation via nsPresContext::IsProcessingAnimationStyleChange). This will require that, for SVG Animations to continue interacting correctly with CSS Transitions, that they have their own cascade level so that they can participate in RestyleManager::UpdateOnlyAnimationStyles. Additionally, this is needed even sooner, for bug 977991, which needs (temporarily, until bug 960465 lands) a mechanism for updating the style attribute style *and* all animation-phase-dependent styles. Yes, it's a little bit annoying to have to have another class, and another object per-document for this, but that's currently what comes with being a level of the cascade. But it's one class and one object per document, and I believe there will be substantial benefits to having all rule processor levels be only-animation-related or not-animation-related (except for the style attribute level, which is simple enough that it isn't needed yet).
2014-09-13 17:17:34 +04:00
{
return nsRestyleHint(0);
}
/* virtual */ bool
SVGAttrAnimationRuleProcessor::MediumFeaturesChanged(nsPresContext* aPresContext)
{
return false;
}
/* virtual */ void
SVGAttrAnimationRuleProcessor::RulesMatching(PseudoElementRuleProcessorData* aData)
{
// If SMIL Animation of SVG attributes can ever target
// pseudo-elements, we need to adjust either
// nsStyleSet::RuleNodeWithReplacement or the test in
// ElementRestyler::RestyleSelf (added in bug 977991 patch 4) to
// handle such styles.
Bug 1057231 patch 1 - Add a rule processor class for rules from SMIL Animation of SVG attributes. r=dholbert This patch series (to move SVG Animation rules to their own level of the cascade) is needed so that they can participate in the mechanism for updating only animation styles to the present time without touching any other styles. In theory, this should have been done as part of 996796 or even as part of prior work on off main thread animations, except that it doesn't seem possible to have SVG Animations and CSS Transitions interacting on the same element and have that element's style out of date, which means it wasn't necessary for the existing code to update only animation styles. However, bug 960465 will use this similar mechanism as the new mechanism for making sure transitions start in a reasonable way (replacing the mechanism of phases, going from style without animation to style with animation via nsPresContext::IsProcessingAnimationStyleChange). This will require that, for SVG Animations to continue interacting correctly with CSS Transitions, that they have their own cascade level so that they can participate in RestyleManager::UpdateOnlyAnimationStyles. Additionally, this is needed even sooner, for bug 977991, which needs (temporarily, until bug 960465 lands) a mechanism for updating the style attribute style *and* all animation-phase-dependent styles. Yes, it's a little bit annoying to have to have another class, and another object per-document for this, but that's currently what comes with being a level of the cascade. But it's one class and one object per document, and I believe there will be substantial benefits to having all rule processor levels be only-animation-related or not-animation-related (except for the style attribute level, which is simple enough that it isn't needed yet).
2014-09-13 17:17:34 +04:00
}
/* virtual */ void
SVGAttrAnimationRuleProcessor::RulesMatching(AnonBoxRuleProcessorData* aData)
{
// If SMIL Animation of SVG attributes can ever target anonymous boxes,
// see comment in RulesMatching(PseudoElementRuleProcessorData*).
Bug 1057231 patch 1 - Add a rule processor class for rules from SMIL Animation of SVG attributes. r=dholbert This patch series (to move SVG Animation rules to their own level of the cascade) is needed so that they can participate in the mechanism for updating only animation styles to the present time without touching any other styles. In theory, this should have been done as part of 996796 or even as part of prior work on off main thread animations, except that it doesn't seem possible to have SVG Animations and CSS Transitions interacting on the same element and have that element's style out of date, which means it wasn't necessary for the existing code to update only animation styles. However, bug 960465 will use this similar mechanism as the new mechanism for making sure transitions start in a reasonable way (replacing the mechanism of phases, going from style without animation to style with animation via nsPresContext::IsProcessingAnimationStyleChange). This will require that, for SVG Animations to continue interacting correctly with CSS Transitions, that they have their own cascade level so that they can participate in RestyleManager::UpdateOnlyAnimationStyles. Additionally, this is needed even sooner, for bug 977991, which needs (temporarily, until bug 960465 lands) a mechanism for updating the style attribute style *and* all animation-phase-dependent styles. Yes, it's a little bit annoying to have to have another class, and another object per-document for this, but that's currently what comes with being a level of the cascade. But it's one class and one object per document, and I believe there will be substantial benefits to having all rule processor levels be only-animation-related or not-animation-related (except for the style attribute level, which is simple enough that it isn't needed yet).
2014-09-13 17:17:34 +04:00
}
#ifdef MOZ_XUL
/* virtual */ void
SVGAttrAnimationRuleProcessor::RulesMatching(XULTreeRuleProcessorData* aData)
{
// If SMIL Animation of SVG attributes can ever target XUL tree pseudos,
// see comment in RulesMatching(PseudoElementRuleProcessorData*).
Bug 1057231 patch 1 - Add a rule processor class for rules from SMIL Animation of SVG attributes. r=dholbert This patch series (to move SVG Animation rules to their own level of the cascade) is needed so that they can participate in the mechanism for updating only animation styles to the present time without touching any other styles. In theory, this should have been done as part of 996796 or even as part of prior work on off main thread animations, except that it doesn't seem possible to have SVG Animations and CSS Transitions interacting on the same element and have that element's style out of date, which means it wasn't necessary for the existing code to update only animation styles. However, bug 960465 will use this similar mechanism as the new mechanism for making sure transitions start in a reasonable way (replacing the mechanism of phases, going from style without animation to style with animation via nsPresContext::IsProcessingAnimationStyleChange). This will require that, for SVG Animations to continue interacting correctly with CSS Transitions, that they have their own cascade level so that they can participate in RestyleManager::UpdateOnlyAnimationStyles. Additionally, this is needed even sooner, for bug 977991, which needs (temporarily, until bug 960465 lands) a mechanism for updating the style attribute style *and* all animation-phase-dependent styles. Yes, it's a little bit annoying to have to have another class, and another object per-document for this, but that's currently what comes with being a level of the cascade. But it's one class and one object per document, and I believe there will be substantial benefits to having all rule processor levels be only-animation-related or not-animation-related (except for the style attribute level, which is simple enough that it isn't needed yet).
2014-09-13 17:17:34 +04:00
}
#endif
/* virtual */ size_t
SVGAttrAnimationRuleProcessor::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
{
return 0; // SVGAttrAnimationRuleProcessors are charged to the DOM, not layout
}
/* virtual */ size_t
SVGAttrAnimationRuleProcessor::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
{
return 0; // SVGAttrAnimationRuleProcessors are charged to the DOM, not layout
}
size_t
SVGAttrAnimationRuleProcessor::DOMSizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
{
size_t n = aMallocSizeOf(this);
return n;
}