import changes from `dev' branch of rmottola/Arctic-Fox:

- Bug 1157400 - Port Chromium WinXP wifi scanner to gecko. r=mcmanus (9b635017e1)
- Bug 1244586 part 1 - Add KeyframeEffect constructor in dom/webidl/KeyframeEffect.webidl. r=smaug,birtles (1290148ebd)
- Bug 1226047 - Add AnimationEffectTiming interface in dom/webidl/AnimationEffectTiming.webidl. r=smaug,birtles (ba10fa4231)
- Bug 1244586 part 2 - Remove entry in testing/web-platform/meta/web-animations/animatable/animate.html.ini. r=birtles (fc517234a3)
- Bug 1244586 part 3 - Remove unnecessary spaces in dom/base/Element.cpp. r=smaug (206e3e39e9)
- Bug 1244328 - Merge the functionality of DOMSettableTokenList into DOMTokenList and make everything that used to refer to DOMSettableTokenList refer to DOMTokenList instead. r=bzbarsky (d9da9d650b)
- Bug 1249278 - Expose KeyframeEffect interface only if nsDocument::IsWebAnimationsEnabled is true. r=smaug (f2ebb43d75)
- Bug 1245075 patch 1 - Remove assertion, since it can fire during frame destruction. r=dholbert (cb2821f507)
- Bug 1237467 part 1 - No longer mark element as needing an animation restyle if we go to restyle it and it no longer has an effect set; r=heycam (dd0de52287)
- Bug 1237467 part 2 - Clear mProgressOnLastCompose when the effect is no longer relevant; r=heycam (d4249517e6)
- Bug 1237467 part 3 - Add debug methods to determine if an EffectSet is currently being enumerated; r=heycam (41b68593c0)
- Bug 1237467 part 4 - Delete the EffectSet when it becomes empty; r=heycam (8db9a40774)
- Bug 1226091 - Use MayHaveAnimations flag for animations on pseudo elements too; r=smaug (b60bbdd9d4)
- Bug 1245075 patch 2 - Fix EffectSet::GetEffectSet(nsIFrame*) and EffectCompositor::GetAnimationElementAndPseudoForFrame to only return effects when the frame is the style frame for its content. r=birtles (82fd23f632)
- Bug 1235112 - Move animation style rule processors to EffectCompositor; r=heycam (3b88ffab44)
- Bug 1247865 - Fix assertion to handle restyling of a table::after. r=birtles (62d4c12d58)
- Bug 1244049 - Part 1: Define scoped enum for CSSPseudoElement type. r=dbaron (b2232f2c37)
- Bug 1240479 - pass values for mReversePortion and mStartForReversingTestin through constructor. r=heycam (2b914ea48f)
- Bug 1244049 - Part 2: Replace nsCSSPseudoElements::Type with CSSPseudoElementType. r=dbaron (a7c2d48b62)
- Bug 1244250 - r=mats (c7b5cde4ba)
- Bug 1234095 - Rework sorting to handle to script-generated animations; r=heycam (44e9463b5a)
- Bug 888190. Implement case-insensitive attribute value selectors from Selectors 4. r=dbaron (43ede42ade)
- Bug 1240956 part 1 - [css-grid] Swap the order of column/row values for 'grid', 'grid-template' and 'grid-gap' properties. Block axis values now always comes first; inline axis values second. r=dholbert (73a78b5ee0)
- Bug 1240956 part 3 - [css-grid] Add a ParseGridTrackList convenience method. r=dholbert (8b62273ccc)
- Bug 1234409: Give percentage positions to the dummy transparent color-stops that we use to pad CSS -webkit-gradient() expressions. r=heycam (f9da14276b)
- Bug 1231485 part 1 - Fix text-emphasis shorthand with style part unspecified being computed incorrectly. r=dbaron (3a9ea936fa)
- Bug 1231485 part 2 - Add NeutralChange hint to nsStyleText::MaxDifference(). r=dbaron (db3adc0250)
- Bug 1231485 part 3 - Fix style tests for text-emphasis properties. r=dbaron (d17ec991fd)
- Bug 1231485 part 4 - Enable layout.css.text-emphasis.enabled pref. r=dbaron (9362cd4ef8)
- Bug 1157400 - Part1: port chromium XP wifi scanning code. r=mcmanus (bfe8b3f758)
- Bug 1240646 - Do not unthrottle animations if RestyleType::Throttled is specified. r=bbirtles (664255ff76)
- Bug 1240228 - Don't update an effect's timing when tweaking its animation's hold time; r=heycam (e1cb11e54c)
- Bug 1246046 part 1 - Get the animation rule in nsStyleSet::GetContext even if there are no CSS animations; r=heycam (4032b461cf)
- Bug 1246046 part 2 - Add reftest for style updating for script-generated animations; r=heycam (a134bc98b0)
- Bug 1241378 - Stop uselessly getting the style set from nsStyleSet::ResolveAnonymousBoxStyle. r=dholbert (4ad16c9a17)
- Bug 1230639 - Propagate the namespace ID to AttributeRuleProcessorData on attribute changes. r=dbaron (77a383158b)
This commit is contained in:
2023-11-17 13:51:57 +08:00
parent 6cfd64d931
commit ab81798c2c
136 changed files with 2357 additions and 3019 deletions
+53 -16
View File
@@ -11,11 +11,13 @@
#include "mozilla/AutoRestore.h"
#include "mozilla/AsyncEventDispatcher.h" // For AsyncEventDispatcher
#include "mozilla/Maybe.h" // For Maybe
#include "nsAnimationManager.h" // For CSSAnimation
#include "nsDOMMutationObserver.h" // For nsAutoAnimationMutationBatch
#include "nsIDocument.h" // For nsIDocument
#include "nsIPresShell.h" // For nsIPresShell
#include "nsLayoutUtils.h" // For PostRestyleEvent (remove after bug 1073336)
#include "nsThreadUtils.h" // For nsRunnableMethod and nsRevocableEventPtr
#include "nsTransitionManager.h" // For CSSTransition
#include "PendingAnimationTracker.h" // For PendingAnimationTracker
namespace mozilla {
@@ -693,14 +695,58 @@ Animation::UpdateRelevance()
bool
Animation::HasLowerCompositeOrderThan(const Animation& aOther) const
{
// Due to the way subclasses of this repurpose the mAnimationIndex to
// implement their own brand of composite ordering it is possible for
// two animations to have an identical mAnimationIndex member.
// However, these subclasses override this method so we shouldn't see
// identical animation indices here.
MOZ_ASSERT(mAnimationIndex != aOther.mAnimationIndex || &aOther == this,
// 0. Object-equality case
if (&aOther == this) {
return false;
}
// 1. CSS Transitions sort lowest
{
auto asCSSTransitionForSorting =
[] (const Animation& anim) -> const CSSTransition*
{
const CSSTransition* transition = anim.AsCSSTransition();
return transition && transition->IsTiedToMarkup() ?
transition :
nullptr;
};
auto thisTransition = asCSSTransitionForSorting(*this);
auto otherTransition = asCSSTransitionForSorting(aOther);
if (thisTransition && otherTransition) {
return thisTransition->HasLowerCompositeOrderThan(*otherTransition);
}
if (thisTransition || otherTransition) {
return thisTransition;
}
}
// 2. CSS Animations sort next
{
auto asCSSAnimationForSorting =
[] (const Animation& anim) -> const CSSAnimation*
{
const CSSAnimation* animation = anim.AsCSSAnimation();
return animation && animation->IsTiedToMarkup() ? animation : nullptr;
};
auto thisAnimation = asCSSAnimationForSorting(*this);
auto otherAnimation = asCSSAnimationForSorting(aOther);
if (thisAnimation && otherAnimation) {
return thisAnimation->HasLowerCompositeOrderThan(*otherAnimation);
}
if (thisAnimation || otherAnimation) {
return thisAnimation;
}
}
// Subclasses of Animation repurpose mAnimationIndex to implement their
// own brand of composite ordering. However, by this point we should have
// handled any such custom composite ordering so we should now have unique
// animation indices.
MOZ_ASSERT(mAnimationIndex != aOther.mAnimationIndex,
"Animation indices should be unique");
// 3. Finally, generic animations sort by their position in the global
// animation array.
return mAnimationIndex < aOther.mAnimationIndex;
}
@@ -750,7 +796,6 @@ Animation::ComposeStyle(RefPtr<AnimValuesStyleRule>& aStyleRule,
// immediately before updating the style rule and then restore it immediately
// afterwards. This is purely to prevent visual flicker. Other behavior
// such as dispatching events continues to rely on the regular timeline time.
bool updatedHoldTime = false;
AnimationPlayState playState = PlayState();
{
AutoRestore<Nullable<TimeDuration>> restoreHoldTime(mHoldTime);
@@ -767,20 +812,12 @@ Animation::ComposeStyle(RefPtr<AnimValuesStyleRule>& aStyleRule,
if (!timeToUse.IsNull()) {
mHoldTime.SetValue((timeToUse.Value() - mStartTime.Value())
.MultDouble(mPlaybackRate));
// Push the change down to the effect
UpdateEffect();
updatedHoldTime = true;
}
}
mEffect->ComposeStyle(aStyleRule, aSetProperties);
}
// Now that the hold time has been restored, update the effect
if (updatedHoldTime) {
UpdateEffect();
}
MOZ_ASSERT(playState == PlayState(),
"Play state should not change during the course of compositing");
mFinishedAtLastComposeStyle = (playState == AnimationPlayState::Finished);
@@ -1070,7 +1107,7 @@ Animation::PostUpdate()
}
Element* targetElement;
nsCSSPseudoElements::Type targetPseudoType;
CSSPseudoElementType targetPseudoType;
mEffect->GetTarget(targetElement, targetPseudoType);
if (!targetElement) {
return;
+1 -1
View File
@@ -288,7 +288,7 @@ public:
/**
* Returns true if this Animation has a lower composite order than aOther.
*/
virtual bool HasLowerCompositeOrderThan(const Animation& aOther) const;
bool HasLowerCompositeOrderThan(const Animation& aOther) const;
/**
* Returns the level at which the effect(s) associated with this Animation
+22
View File
@@ -0,0 +1,22 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* 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/. */
#include "mozilla/dom/AnimationEffectTiming.h"
#include "mozilla/dom/AnimatableBinding.h"
#include "mozilla/dom/AnimationEffectTimingBinding.h"
namespace mozilla {
namespace dom {
JSObject*
AnimationEffectTiming::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return AnimationEffectTimingBinding::Wrap(aCx, this, aGivenProto);
}
} // namespace dom
} // namespace mozilla
+27
View File
@@ -0,0 +1,27 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* 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/. */
#ifndef mozilla_dom_AnimationEffectTiming_h
#define mozilla_dom_AnimationEffectTiming_h
#include "mozilla/dom/AnimationEffectTimingReadOnly.h"
namespace mozilla {
namespace dom {
class AnimationEffectTiming : public AnimationEffectTimingReadOnly
{
public:
explicit AnimationEffectTiming(const TimingParams& aTiming)
: AnimationEffectTimingReadOnly(aTiming) { }
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_AnimationEffectTiming_h
+7 -8
View File
@@ -17,13 +17,13 @@ NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(CSSPseudoElement, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(CSSPseudoElement, Release)
CSSPseudoElement::CSSPseudoElement(Element* aElement,
nsCSSPseudoElements::Type aType)
CSSPseudoElementType aType)
: mParentElement(aElement)
, mPseudoType(aType)
{
MOZ_ASSERT(aElement);
MOZ_ASSERT(aType == nsCSSPseudoElements::ePseudo_after ||
aType == nsCSSPseudoElements::ePseudo_before,
MOZ_ASSERT(aType == CSSPseudoElementType::after ||
aType == CSSPseudoElementType::before,
"Unexpected Pseudo Type");
}
@@ -63,7 +63,7 @@ CSSPseudoElement::Animate(
/* static */ already_AddRefed<CSSPseudoElement>
CSSPseudoElement::GetCSSPseudoElement(Element* aElement,
nsCSSPseudoElements::Type aType)
CSSPseudoElementType aType)
{
if (!aElement) {
return nullptr;
@@ -90,14 +90,13 @@ CSSPseudoElement::GetCSSPseudoElement(Element* aElement,
}
/* static */ nsIAtom*
CSSPseudoElement::GetCSSPseudoElementPropertyAtom(
nsCSSPseudoElements::Type aType)
CSSPseudoElement::GetCSSPseudoElementPropertyAtom(CSSPseudoElementType aType)
{
switch (aType) {
case nsCSSPseudoElements::ePseudo_before:
case CSSPseudoElementType::before:
return nsGkAtoms::cssPseudoElementBeforeProperty;
case nsCSSPseudoElements::ePseudo_after:
case CSSPseudoElementType::after:
return nsGkAtoms::cssPseudoElementAfterProperty;
default:
+5 -6
View File
@@ -40,7 +40,7 @@ public:
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
nsCSSPseudoElements::Type GetType() const { return mPseudoType; }
CSSPseudoElementType GetType() const { return mPseudoType; }
void GetType(nsString& aRetVal) const
{
MOZ_ASSERT(nsCSSPseudoElements::GetPseudoAtom(mPseudoType),
@@ -66,20 +66,19 @@ public:
// pseudo-type on element, a new CSSPseudoElement will be created and stored
// on the element.
static already_AddRefed<CSSPseudoElement>
GetCSSPseudoElement(Element* aElement, nsCSSPseudoElements::Type aType);
GetCSSPseudoElement(Element* aElement, CSSPseudoElementType aType);
private:
// Only ::before and ::after are supported.
CSSPseudoElement(Element* aElement, nsCSSPseudoElements::Type aType);
CSSPseudoElement(Element* aElement, CSSPseudoElementType aType);
static nsIAtom*
GetCSSPseudoElementPropertyAtom(nsCSSPseudoElements::Type aType);
static nsIAtom* GetCSSPseudoElementPropertyAtom(CSSPseudoElementType aType);
// mParentElement needs to be an owning reference since if script is holding
// on to the pseudo-element, it needs to continue to be able to refer to
// the parent element.
RefPtr<Element> mParentElement;
nsCSSPseudoElements::Type mPseudoType;
CSSPseudoElementType mPseudoType;
};
} // namespace dom
+167 -32
View File
@@ -16,9 +16,11 @@
#include "nsComputedDOMStyle.h" // nsComputedDOMStyle::GetPresShellForContent
#include "nsCSSPropertySet.h"
#include "nsCSSProps.h"
#include "nsCSSPseudoElements.h"
#include "nsIPresShell.h"
#include "nsLayoutUtils.h"
#include "nsRuleNode.h" // For nsRuleNode::ComputePropertiesOverridingAnimation
#include "nsRuleProcessorData.h" // For ElementRuleProcessorData etc.
#include "nsTArray.h"
#include "RestyleManager.h"
@@ -79,7 +81,7 @@ FindAnimationsForCompositor(const nsIFrame* aFrame,
// Those cases are probably not important but just to be safe, let's make
// sure the cascade is up to date since if it *is* up to date, this is
// basically a no-op.
Maybe<Pair<dom::Element*, nsCSSPseudoElements::Type>> pseudoElement =
Maybe<Pair<dom::Element*, CSSPseudoElementType>> pseudoElement =
EffectCompositor::GetAnimationElementAndPseudoForFrame(aFrame);
if (pseudoElement) {
EffectCompositor::MaybeUpdateCascadeResults(pseudoElement->first(),
@@ -130,7 +132,7 @@ FindAnimationsForCompositor(const nsIFrame* aFrame,
void
EffectCompositor::RequestRestyle(dom::Element* aElement,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
RestyleType aRestyleType,
CascadeLevel aCascadeLevel)
{
@@ -142,9 +144,10 @@ EffectCompositor::RequestRestyle(dom::Element* aElement,
auto& elementsToRestyle = mElementsToRestyle[aCascadeLevel];
PseudoElementHashKey key = { aElement, aPseudoType };
if (aRestyleType == RestyleType::Throttled &&
!elementsToRestyle.Contains(key)) {
elementsToRestyle.Put(key, false);
if (aRestyleType == RestyleType::Throttled) {
if (!elementsToRestyle.Contains(key)) {
elementsToRestyle.Put(key, false);
}
mPresContext->Document()->SetNeedStyleFlush();
} else {
// Get() returns 0 if the element is not found. It will also return
@@ -169,7 +172,7 @@ EffectCompositor::RequestRestyle(dom::Element* aElement,
void
EffectCompositor::PostRestyleForAnimation(dom::Element* aElement,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
CascadeLevel aCascadeLevel)
{
if (!mPresContext) {
@@ -210,8 +213,7 @@ EffectCompositor::PostRestyleForThrottledAnimations()
void
EffectCompositor::MaybeUpdateAnimationRule(dom::Element* aElement,
nsCSSPseudoElements::Type
aPseudoType,
CSSPseudoElementType aPseudoType,
CascadeLevel aCascadeLevel)
{
// First update cascade results since that may cause some elements to
@@ -233,33 +235,55 @@ EffectCompositor::MaybeUpdateAnimationRule(dom::Element* aElement,
nsIStyleRule*
EffectCompositor::GetAnimationRule(dom::Element* aElement,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
CascadeLevel aCascadeLevel)
{
// NOTE: We need to be careful about early returns in this method where
// we *don't* update mElementsToRestyle. When we get a call to
// RequestRestyle that results in a call to PostRestyleForAnimation, we
// will set a bool flag in mElementsToRestyle indicating that we've
// called PostRestyleForAnimation so we don't need to call it again
// until that restyle happens. During that restyle, if we arrive here
// and *don't* update mElementsToRestyle we'll continue to skip calling
// PostRestyleForAnimation from RequestRestyle.
if (!mPresContext || !mPresContext->IsDynamic()) {
// For print or print preview, ignore animations.
return nullptr;
}
if (mPresContext->RestyleManager()->SkipAnimationRules()) {
// We don't need to worry about updating mElementsToRestyle in this case
// since this is not the animation restyle we requested when we called
// PostRestyleForAnimation (see comment at start of this method).
return nullptr;
}
MaybeUpdateAnimationRule(aElement, aPseudoType, aCascadeLevel);
#ifdef DEBUG
{
auto& elementsToRestyle = mElementsToRestyle[aCascadeLevel];
PseudoElementHashKey key = { aElement, aPseudoType };
MOZ_ASSERT(!elementsToRestyle.Contains(key),
"Element should no longer require a restyle after its "
"animation rule has been updated");
}
#endif
EffectSet* effectSet = EffectSet::GetEffectSet(aElement, aPseudoType);
if (!effectSet) {
return nullptr;
}
if (mPresContext->RestyleManager()->SkipAnimationRules()) {
return nullptr;
}
MaybeUpdateAnimationRule(aElement, aPseudoType, aCascadeLevel);
return effectSet->AnimationRule(aCascadeLevel);
}
/* static */ dom::Element*
EffectCompositor::GetElementToRestyle(dom::Element* aElement,
nsCSSPseudoElements::Type aPseudoType)
CSSPseudoElementType aPseudoType)
{
if (aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement) {
if (aPseudoType == CSSPseudoElementType::NotPseudo) {
return aElement;
}
@@ -268,9 +292,9 @@ EffectCompositor::GetElementToRestyle(dom::Element* aElement,
return nullptr;
}
nsIFrame* pseudoFrame;
if (aPseudoType == nsCSSPseudoElements::ePseudo_before) {
if (aPseudoType == CSSPseudoElementType::before) {
pseudoFrame = nsLayoutUtils::GetBeforeFrame(primaryFrame);
} else if (aPseudoType == nsCSSPseudoElements::ePseudo_after) {
} else if (aPseudoType == CSSPseudoElementType::after) {
pseudoFrame = nsLayoutUtils::GetAfterFrame(primaryFrame);
} else {
NS_NOTREACHED("Should not try to get the element to restyle for a pseudo "
@@ -393,8 +417,7 @@ EffectCompositor::ClearIsRunningOnCompositor(const nsIFrame *aFrame,
/* static */ void
EffectCompositor::MaybeUpdateCascadeResults(Element* aElement,
nsCSSPseudoElements::Type
aPseudoType,
CSSPseudoElementType aPseudoType,
nsStyleContext* aStyleContext)
{
EffectSet* effects = EffectSet::GetEffectSet(aElement, aPseudoType);
@@ -409,8 +432,7 @@ EffectCompositor::MaybeUpdateCascadeResults(Element* aElement,
/* static */ void
EffectCompositor::MaybeUpdateCascadeResults(Element* aElement,
nsCSSPseudoElements::Type
aPseudoType)
CSSPseudoElementType aPseudoType)
{
nsStyleContext* styleContext = nullptr;
{
@@ -450,7 +472,7 @@ namespace {
/* static */ void
EffectCompositor::UpdateCascadeResults(Element* aElement,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
nsStyleContext* aStyleContext)
{
EffectSet* effects = EffectSet::GetEffectSet(aElement, aPseudoType);
@@ -461,19 +483,18 @@ EffectCompositor::UpdateCascadeResults(Element* aElement,
UpdateCascadeResults(*effects, aElement, aPseudoType, aStyleContext);
}
/* static */ Maybe<Pair<Element*, nsCSSPseudoElements::Type>>
/* static */ Maybe<Pair<Element*, CSSPseudoElementType>>
EffectCompositor::GetAnimationElementAndPseudoForFrame(const nsIFrame* aFrame)
{
// Always return the same object to benefit from return-value optimization.
Maybe<Pair<Element*, nsCSSPseudoElements::Type>> result;
Maybe<Pair<Element*, CSSPseudoElementType>> result;
nsIContent* content = aFrame->GetContent();
if (!content) {
return result;
}
nsCSSPseudoElements::Type pseudoType =
nsCSSPseudoElements::ePseudo_NotPseudoElement;
CSSPseudoElementType pseudoType = CSSPseudoElementType::NotPseudo;
if (aFrame->IsGeneratedContentFrame()) {
nsIFrame* parent = aFrame->GetParent();
@@ -482,9 +503,9 @@ EffectCompositor::GetAnimationElementAndPseudoForFrame(const nsIFrame* aFrame)
}
nsIAtom* name = content->NodeInfo()->NameAtom();
if (name == nsGkAtoms::mozgeneratedcontentbefore) {
pseudoType = nsCSSPseudoElements::ePseudo_before;
pseudoType = CSSPseudoElementType::before;
} else if (name == nsGkAtoms::mozgeneratedcontentafter) {
pseudoType = nsCSSPseudoElements::ePseudo_after;
pseudoType = CSSPseudoElementType::after;
} else {
return result;
}
@@ -492,6 +513,11 @@ EffectCompositor::GetAnimationElementAndPseudoForFrame(const nsIFrame* aFrame)
if (!content) {
return result;
}
} else {
if (nsLayoutUtils::GetStyleFrame(content) != aFrame) {
// The effects associated with an element are for its primary frame.
return result;
}
}
if (!content->IsElement()) {
@@ -505,7 +531,7 @@ EffectCompositor::GetAnimationElementAndPseudoForFrame(const nsIFrame* aFrame)
/* static */ void
EffectCompositor::ComposeAnimationRule(dom::Element* aElement,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
CascadeLevel aCascadeLevel,
TimeStamp aRefreshTime)
{
@@ -542,6 +568,9 @@ EffectCompositor::ComposeAnimationRule(dom::Element* aElement,
effect->GetAnimation()->ComposeStyle(animationRule, properties);
}
MOZ_ASSERT(effects == EffectSet::GetEffectSet(aElement, aPseudoType),
"EffectSet should not change while composing style");
effects->UpdateAnimationRuleRefreshTime(aCascadeLevel, aRefreshTime);
}
@@ -583,7 +612,7 @@ EffectCompositor::GetOverriddenProperties(nsStyleContext* aStyleContext,
/* static */ void
EffectCompositor::UpdateCascadeResults(EffectSet& aEffectSet,
Element* aElement,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
nsStyleContext* aStyleContext)
{
MOZ_ASSERT(EffectSet::GetEffectSet(aElement, aPseudoType) == &aEffectSet,
@@ -680,4 +709,110 @@ EffectCompositor::GetPresContext(Element* aElement)
return shell->GetPresContext();
}
// ---------------------------------------------------------
//
// Nested class: AnimationStyleRuleProcessor
//
// ---------------------------------------------------------
NS_IMPL_ISUPPORTS(EffectCompositor::AnimationStyleRuleProcessor,
nsIStyleRuleProcessor)
nsRestyleHint
EffectCompositor::AnimationStyleRuleProcessor::HasStateDependentStyle(
StateRuleProcessorData* aData)
{
return nsRestyleHint(0);
}
nsRestyleHint
EffectCompositor::AnimationStyleRuleProcessor::HasStateDependentStyle(
PseudoElementStateRuleProcessorData* aData)
{
return nsRestyleHint(0);
}
bool
EffectCompositor::AnimationStyleRuleProcessor::HasDocumentStateDependentStyle(
StateRuleProcessorData* aData)
{
return false;
}
nsRestyleHint
EffectCompositor::AnimationStyleRuleProcessor::HasAttributeDependentStyle(
AttributeRuleProcessorData* aData,
RestyleHintData& aRestyleHintDataResult)
{
return nsRestyleHint(0);
}
bool
EffectCompositor::AnimationStyleRuleProcessor::MediumFeaturesChanged(
nsPresContext* aPresContext)
{
return false;
}
void
EffectCompositor::AnimationStyleRuleProcessor::RulesMatching(
ElementRuleProcessorData* aData)
{
nsIStyleRule *rule =
mCompositor->GetAnimationRule(aData->mElement,
CSSPseudoElementType::NotPseudo,
mCascadeLevel);
if (rule) {
aData->mRuleWalker->Forward(rule);
aData->mRuleWalker->CurrentNode()->SetIsAnimationRule();
}
}
void
EffectCompositor::AnimationStyleRuleProcessor::RulesMatching(
PseudoElementRuleProcessorData* aData)
{
if (aData->mPseudoType != CSSPseudoElementType::before &&
aData->mPseudoType != CSSPseudoElementType::after) {
return;
}
nsIStyleRule *rule =
mCompositor->GetAnimationRule(aData->mElement,
aData->mPseudoType,
mCascadeLevel);
if (rule) {
aData->mRuleWalker->Forward(rule);
aData->mRuleWalker->CurrentNode()->SetIsAnimationRule();
}
}
void
EffectCompositor::AnimationStyleRuleProcessor::RulesMatching(
AnonBoxRuleProcessorData* aData)
{
}
#ifdef MOZ_XUL
void
EffectCompositor::AnimationStyleRuleProcessor::RulesMatching(
XULTreeRuleProcessorData* aData)
{
}
#endif
size_t
EffectCompositor::AnimationStyleRuleProcessor::SizeOfExcludingThis(
MallocSizeOf aMallocSizeOf) const
{
return 0;
}
size_t
EffectCompositor::AnimationStyleRuleProcessor::SizeOfIncludingThis(
MallocSizeOf aMallocSizeOf) const
{
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}
} // namespace mozilla
+71 -13
View File
@@ -9,13 +9,14 @@
#include "mozilla/EnumeratedArray.h"
#include "mozilla/Maybe.h"
#include "mozilla/OwningNonNull.h"
#include "mozilla/Pair.h"
#include "mozilla/PseudoElementHashEntry.h"
#include "mozilla/RefPtr.h"
#include "nsCSSProperty.h"
#include "nsCSSPseudoElements.h"
#include "nsCycleCollectionParticipant.h"
#include "nsDataHashtable.h"
#include "nsIStyleRuleProcessor.h"
#include "nsTArray.h"
class nsCSSPropertySet;
@@ -28,6 +29,7 @@ namespace mozilla {
class EffectSet;
class RestyleTracker;
enum class CSSPseudoElementType : uint8_t;
namespace dom {
class Animation;
@@ -39,7 +41,13 @@ class EffectCompositor
public:
explicit EffectCompositor(nsPresContext* aPresContext)
: mPresContext(aPresContext)
{ }
{
for (size_t i = 0; i < kCascadeLevelCount; i++) {
CascadeLevel cascadeLevel = CascadeLevel(i);
mRuleProcessors[cascadeLevel] =
new AnimationStyleRuleProcessor(this, cascadeLevel);
}
}
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(EffectCompositor)
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(EffectCompositor)
@@ -86,7 +94,7 @@ public:
// The specified steps taken to update the animation rule depend on
// |aRestyleType| whose values are described above.
void RequestRestyle(dom::Element* aElement,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
RestyleType aRestyleType,
CascadeLevel aCascadeLevel);
@@ -95,7 +103,7 @@ public:
// need to perform this step when triggering transitions *without* also
// invalidating the animation style rule (which RequestRestyle would do).
void PostRestyleForAnimation(dom::Element* aElement,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
CascadeLevel aCascadeLevel);
// Posts an animation restyle for any elements whose animation style rule
@@ -108,11 +116,11 @@ public:
// If the animation rule is not marked as needing an update,
// no work is done.
void MaybeUpdateAnimationRule(dom::Element* aElement,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
CascadeLevel aCascadeLevel);
nsIStyleRule* GetAnimationRule(dom::Element* aElement,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
CascadeLevel aCascadeLevel);
bool HasPendingStyleUpdates() const;
@@ -123,6 +131,11 @@ public:
// elements.
void AddStyleUpdatesTo(RestyleTracker& aTracker);
nsIStyleRuleProcessor* RuleProcessor(CascadeLevel aCascadeLevel) const
{
return mRuleProcessors[aCascadeLevel];
}
static bool HasAnimationsForCompositor(const nsIFrame* aFrame,
nsCSSProperty aProperty);
@@ -142,14 +155,14 @@ public:
// animation level of the cascade have changed.
static void
MaybeUpdateCascadeResults(dom::Element* aElement,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
nsStyleContext* aStyleContext);
// An overload of MaybeUpdateCascadeResults that uses the style context
// of the primary frame of the specified (pseudo-)element, when available.
static void
MaybeUpdateCascadeResults(dom::Element* aElement,
nsCSSPseudoElements::Type aPseudoType);
CSSPseudoElementType aPseudoType);
// Update the mWinsInCascade member for each property in effects targetting
// the specified (pseudo-)element.
@@ -159,7 +172,7 @@ public:
// other cases we should call MaybeUpdateCascadeResults.
static void
UpdateCascadeResults(dom::Element* aElement,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
nsStyleContext* aStyleContext);
// Helper to fetch the corresponding element and pseudo-type from a frame.
@@ -171,7 +184,7 @@ public:
// Returns an empty result when a suitable element cannot be found including
// when the frame represents a pseudo-element on which we do not support
// animations.
static Maybe<Pair<dom::Element*, nsCSSPseudoElements::Type>>
static Maybe<Pair<dom::Element*, CSSPseudoElementType>>
GetAnimationElementAndPseudoForFrame(const nsIFrame* aFrame);
private:
@@ -180,12 +193,12 @@ private:
// Rebuilds the animation rule corresponding to |aCascadeLevel| on the
// EffectSet associated with the specified (pseudo-)element.
static void ComposeAnimationRule(dom::Element* aElement,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
CascadeLevel aCascadeLevel,
TimeStamp aRefreshTime);
static dom::Element* GetElementToRestyle(dom::Element* aElement,
nsCSSPseudoElements::Type
CSSPseudoElementType
aPseudoType);
// Get the properties in |aEffectSet| that we are able to animate on the
@@ -199,7 +212,7 @@ private:
static void
UpdateCascadeResults(EffectSet& aEffectSet,
dom::Element* aElement,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
nsStyleContext* aStyleContext);
static nsPresContext* GetPresContext(dom::Element* aElement);
@@ -214,6 +227,51 @@ private:
EnumeratedArray<CascadeLevel, CascadeLevel(kCascadeLevelCount),
nsDataHashtable<PseudoElementHashEntry, bool>>
mElementsToRestyle;
class AnimationStyleRuleProcessor final : public nsIStyleRuleProcessor
{
public:
AnimationStyleRuleProcessor(EffectCompositor* aCompositor,
CascadeLevel aCascadeLevel)
: mCompositor(aCompositor)
, mCascadeLevel(aCascadeLevel)
{
MOZ_ASSERT(aCompositor);
}
NS_DECL_ISUPPORTS
// nsIStyleRuleProcessor (parts)
nsRestyleHint HasStateDependentStyle(
StateRuleProcessorData* aData) override;
nsRestyleHint HasStateDependentStyle(
PseudoElementStateRuleProcessorData* aData) override;
bool HasDocumentStateDependentStyle(StateRuleProcessorData* aData) override;
nsRestyleHint HasAttributeDependentStyle(
AttributeRuleProcessorData* aData,
RestyleHintData& aRestyleHintDataResult) override;
bool MediumFeaturesChanged(nsPresContext* aPresContext) override;
void RulesMatching(ElementRuleProcessorData* aData) override;
void RulesMatching(PseudoElementRuleProcessorData* aData) override;
void RulesMatching(AnonBoxRuleProcessorData* aData) override;
#ifdef MOZ_XUL
void RulesMatching(XULTreeRuleProcessorData* aData) override;
#endif
size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf)
const MOZ_MUST_OVERRIDE override;
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf)
const MOZ_MUST_OVERRIDE override;
private:
~AnimationStyleRuleProcessor() = default;
EffectCompositor* mCompositor;
CascadeLevel mCascadeLevel;
};
EnumeratedArray<CascadeLevel, CascadeLevel(kCascadeLevelCount),
OwningNonNull<AnimationStyleRuleProcessor>>
mRuleProcessors;
};
} // namespace mozilla
+33 -10
View File
@@ -7,8 +7,10 @@
#include "EffectSet.h"
#include "mozilla/dom/Element.h" // For Element
#include "RestyleManager.h"
#include "nsCSSPseudoElements.h" // For CSSPseudoElementType
#include "nsCycleCollectionNoteChild.h" // For CycleCollectionNoteChild
#include "nsPresContext.h"
#include "nsLayoutUtils.h"
namespace mozilla {
@@ -37,7 +39,7 @@ EffectSet::Traverse(nsCycleCollectionTraversalCallback& aCallback)
/* static */ EffectSet*
EffectSet::GetEffectSet(dom::Element* aElement,
nsCSSPseudoElements::Type aPseudoType)
CSSPseudoElementType aPseudoType)
{
nsIAtom* propName = GetEffectSetPropertyAtom(aPseudoType);
return static_cast<EffectSet*>(aElement->GetProperty(propName));
@@ -70,18 +72,23 @@ EffectSet::GetEffectSet(const nsIFrame* aFrame)
return nullptr;
}
} else {
if (!content->MayHaveAnimations()) {
if (nsLayoutUtils::GetStyleFrame(content) != aFrame) {
// The effects associated with an element are for its primary frame.
return nullptr;
}
propName = nsGkAtoms::animationEffectsProperty;
}
if (!content->MayHaveAnimations()) {
return nullptr;
}
return static_cast<EffectSet*>(content->GetProperty(propName));
}
/* static */ EffectSet*
EffectSet::GetOrCreateEffectSet(dom::Element* aElement,
nsCSSPseudoElements::Type aPseudoType)
CSSPseudoElementType aPseudoType)
{
EffectSet* effectSet = GetEffectSet(aElement, aPseudoType);
if (effectSet) {
@@ -101,13 +108,29 @@ EffectSet::GetOrCreateEffectSet(dom::Element* aElement,
return nullptr;
}
if (aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement) {
aElement->SetMayHaveAnimations();
}
aElement->SetMayHaveAnimations();
return effectSet;
}
/* static */ void
EffectSet::DestroyEffectSet(dom::Element* aElement,
CSSPseudoElementType aPseudoType)
{
nsIAtom* propName = GetEffectSetPropertyAtom(aPseudoType);
EffectSet* effectSet =
static_cast<EffectSet*>(aElement->GetProperty(propName));
if (!effectSet) {
return;
}
MOZ_ASSERT(!effectSet->IsBeingEnumerated(),
"Should not destroy an effect set while it is being enumerated");
effectSet = nullptr;
aElement->DeleteProperty(propName);
}
void
EffectSet::UpdateAnimationGeneration(nsPresContext* aPresContext)
{
@@ -130,16 +153,16 @@ EffectSet::GetEffectSetPropertyAtoms()
}
/* static */ nsIAtom*
EffectSet::GetEffectSetPropertyAtom(nsCSSPseudoElements::Type aPseudoType)
EffectSet::GetEffectSetPropertyAtom(CSSPseudoElementType aPseudoType)
{
switch (aPseudoType) {
case nsCSSPseudoElements::ePseudo_NotPseudoElement:
case CSSPseudoElementType::NotPseudo:
return nsGkAtoms::animationEffectsProperty;
case nsCSSPseudoElements::ePseudo_before:
case CSSPseudoElementType::before:
return nsGkAtoms::animationEffectsForBeforeProperty;
case nsCSSPseudoElements::ePseudo_after:
case CSSPseudoElementType::after:
return nsGkAtoms::animationEffectsForAfterProperty;
default:
+49 -19
View File
@@ -8,10 +8,10 @@
#define mozilla_EffectSet_h
#include "mozilla/AnimValuesStyleRule.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/EffectCompositor.h"
#include "mozilla/EnumeratedArray.h"
#include "mozilla/TimeStamp.h"
#include "nsCSSPseudoElements.h" // For nsCSSPseudoElements::Type
#include "nsHashKeys.h" // For nsPtrHashKey
#include "nsTHashtable.h" // For nsTHashtable
@@ -24,6 +24,8 @@ class Element;
class KeyframeEffectReadOnly;
} // namespace dom
enum class CSSPseudoElementType : uint8_t;
// A wrapper around a hashset of AnimationEffect objects to handle
// storing the set as a property of an element.
class EffectSet
@@ -32,6 +34,7 @@ public:
EffectSet()
: mCascadeNeedsUpdate(false)
, mAnimationGeneration(0)
, mActiveIterators(0)
#ifdef DEBUG
, mCalledPropertyDtor(false)
#endif
@@ -43,6 +46,9 @@ public:
{
MOZ_ASSERT(mCalledPropertyDtor,
"must call destructor through element property dtor");
MOZ_ASSERT(mActiveIterators == 0,
"Effect set should not be destroyed while it is being "
"enumerated");
MOZ_COUNT_DTOR(EffectSet);
}
static void PropertyDtor(void* aObject, nsIAtom* aPropertyName,
@@ -52,10 +58,12 @@ public:
void Traverse(nsCycleCollectionTraversalCallback& aCallback);
static EffectSet* GetEffectSet(dom::Element* aElement,
nsCSSPseudoElements::Type aPseudoType);
CSSPseudoElementType aPseudoType);
static EffectSet* GetEffectSet(const nsIFrame* aFrame);
static EffectSet* GetOrCreateEffectSet(dom::Element* aElement,
nsCSSPseudoElements::Type aPseudoType);
CSSPseudoElementType aPseudoType);
static void DestroyEffectSet(dom::Element* aElement,
CSSPseudoElementType aPseudoType);
void AddEffect(dom::KeyframeEffectReadOnly& aEffect);
void RemoveEffect(dom::KeyframeEffectReadOnly& aEffect);
@@ -74,20 +82,35 @@ public:
class Iterator
{
public:
explicit Iterator(OwningEffectSet::Iterator&& aHashIterator)
: mHashIterator(mozilla::Move(aHashIterator))
, mIsEndIterator(false) { }
Iterator(Iterator&& aOther)
: mHashIterator(mozilla::Move(aOther.mHashIterator))
, mIsEndIterator(aOther.mIsEndIterator) { }
static Iterator EndIterator(OwningEffectSet::Iterator&& aHashIterator)
explicit Iterator(EffectSet& aEffectSet)
: mEffectSet(aEffectSet)
, mHashIterator(mozilla::Move(aEffectSet.mEffects.Iter()))
, mIsEndIterator(false)
{
Iterator result(mozilla::Move(aHashIterator));
mEffectSet.mActiveIterators++;
}
Iterator(Iterator&& aOther)
: mEffectSet(aOther.mEffectSet)
, mHashIterator(mozilla::Move(aOther.mHashIterator))
, mIsEndIterator(aOther.mIsEndIterator)
{
mEffectSet.mActiveIterators++;
}
static Iterator EndIterator(EffectSet& aEffectSet)
{
Iterator result(aEffectSet);
result.mIsEndIterator = true;
return result;
}
~Iterator()
{
MOZ_ASSERT(mEffectSet.mActiveIterators > 0);
mEffectSet.mActiveIterators--;
}
bool operator!=(const Iterator& aOther) const {
if (Done() || aOther.Done()) {
return Done() != aOther.Done();
@@ -117,15 +140,19 @@ public:
return mIsEndIterator || mHashIterator.Done();
}
EffectSet& mEffectSet;
OwningEffectSet::Iterator mHashIterator;
bool mIsEndIterator;
};
Iterator begin() { return Iterator(mEffects.Iter()); }
Iterator end()
{
return Iterator::EndIterator(mEffects.Iter());
}
friend class Iterator;
Iterator begin() { return Iterator(*this); }
Iterator end() { return Iterator::EndIterator(*this); }
#ifdef DEBUG
bool IsBeingEnumerated() const { return mActiveIterators != 0; }
#endif
bool IsEmpty() const { return mEffects.IsEmpty(); }
RefPtr<AnimValuesStyleRule>& AnimationRule(EffectCompositor::CascadeLevel
@@ -156,8 +183,7 @@ public:
static nsIAtom** GetEffectSetPropertyAtoms();
private:
static nsIAtom* GetEffectSetPropertyAtom(nsCSSPseudoElements::Type
aPseudoType);
static nsIAtom* GetEffectSetPropertyAtom(CSSPseudoElementType aPseudoType);
OwningEffectSet mEffects;
@@ -195,6 +221,10 @@ private:
// the animation manager.
uint64_t mAnimationGeneration;
// Track how many iterators are referencing this effect set when we are
// destroyed, we can assert that nothing is still pointing to us.
DebugOnly<uint64_t> mActiveIterators;
#ifdef DEBUG
bool mCalledPropertyDtor;
#endif
+115 -62
View File
@@ -17,6 +17,7 @@
#include "nsCSSParser.h"
#include "nsCSSPropertySet.h"
#include "nsCSSProps.h" // For nsCSSProps::PropHasFlags
#include "nsCSSPseudoElements.h"
#include "nsCSSValue.h"
#include "nsStyleUtil.h"
#include <algorithm> // For std::max
@@ -74,16 +75,26 @@ NS_IMPL_RELEASE_INHERITED(KeyframeEffectReadOnly, AnimationEffectReadOnly)
KeyframeEffectReadOnly::KeyframeEffectReadOnly(
nsIDocument* aDocument,
Element* aTarget,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
const TimingParams& aTiming)
: KeyframeEffectReadOnly(aDocument, aTarget, aPseudoType,
new AnimationEffectTimingReadOnly(aTiming))
{
}
KeyframeEffectReadOnly::KeyframeEffectReadOnly(
nsIDocument* aDocument,
Element* aTarget,
CSSPseudoElementType aPseudoType,
AnimationEffectTimingReadOnly* aTiming)
: AnimationEffectReadOnly(aDocument)
, mTarget(aTarget)
, mTiming(*aTiming)
, mPseudoType(aPseudoType)
, mInEffectOnLastAnimationTimingUpdate(false)
{
MOZ_ASSERT(aTiming);
MOZ_ASSERT(aTarget, "null animation target is not yet supported");
mTiming = new AnimationEffectTimingReadOnly(aTiming);
}
JSObject*
@@ -180,6 +191,14 @@ KeyframeEffectReadOnly::NotifyAnimationTimingUpdated()
RequestRestyle(mTarget, mPseudoType, restyleType,
mAnimation->CascadeLevel());
}
// If we're not relevant, we will have been removed from the EffectSet.
// As a result, when the restyle we requested above is fulfilled, our
// ComposeStyle will not get called and mProgressOnLastCompose will not
// be updated. Instead, we need to manually clear it.
if (!isRelevant) {
mProgressOnLastCompose.SetNull();
}
}
}
@@ -578,6 +597,71 @@ KeyframeEffectReadOnly::~KeyframeEffectReadOnly()
{
}
template <class KeyframeEffectType>
/* static */ already_AddRefed<KeyframeEffectType>
KeyframeEffectReadOnly::ConstructKeyframeEffect(const GlobalObject& aGlobal,
const Nullable<ElementOrCSSPseudoElement>& aTarget,
JS::Handle<JSObject*> aFrames,
const TimingParams& aTiming,
ErrorResult& aRv)
{
if (aTarget.IsNull()) {
// We don't support null targets yet.
aRv.Throw(NS_ERROR_DOM_ANIM_NO_TARGET_ERR);
return nullptr;
}
const ElementOrCSSPseudoElement& target = aTarget.Value();
MOZ_ASSERT(target.IsElement() || target.IsCSSPseudoElement(),
"Uninitialized target");
RefPtr<Element> targetElement;
CSSPseudoElementType pseudoType = CSSPseudoElementType::NotPseudo;
if (target.IsElement()) {
targetElement = &target.GetAsElement();
} else {
targetElement = target.GetAsCSSPseudoElement().ParentElement();
pseudoType = target.GetAsCSSPseudoElement().GetType();
}
if (!targetElement->GetComposedDoc()) {
aRv.Throw(NS_ERROR_DOM_ANIM_TARGET_NOT_IN_DOC_ERR);
return nullptr;
}
InfallibleTArray<AnimationProperty> animationProperties;
BuildAnimationPropertyList(aGlobal.Context(), targetElement, pseudoType,
aFrames, animationProperties, aRv);
if (aRv.Failed()) {
return nullptr;
}
RefPtr<KeyframeEffectType> effect =
new KeyframeEffectType(targetElement->OwnerDoc(), targetElement,
pseudoType, aTiming);
effect->mProperties = Move(animationProperties);
return effect.forget();
}
// Explicit instantiations to avoid linker errors.
template
already_AddRefed<KeyframeEffectReadOnly>
KeyframeEffectReadOnly::ConstructKeyframeEffect<>(const GlobalObject& aGlobal,
const Nullable<ElementOrCSSPseudoElement>& aTarget,
JS::Handle<JSObject*> aFrames,
const TimingParams& aTiming,
ErrorResult& aRv);
template
already_AddRefed<KeyframeEffect>
KeyframeEffectReadOnly::ConstructKeyframeEffect<>(const GlobalObject& aGlobal,
const Nullable<ElementOrCSSPseudoElement>& aTarget,
JS::Handle<JSObject*> aFrames,
const TimingParams& aTiming,
ErrorResult& aRv);
void
KeyframeEffectReadOnly::ResetIsRunningOnCompositor()
{
@@ -610,6 +694,9 @@ KeyframeEffectReadOnly::UpdateTargetRegistration()
EffectSet* effectSet = EffectSet::GetEffectSet(mTarget, mPseudoType);
if (effectSet) {
effectSet->RemoveEffect(*this);
if (effectSet->IsEmpty()) {
EffectSet::DestroyEffectSet(mTarget, mPseudoType);
}
}
}
}
@@ -1134,7 +1221,7 @@ ApplyDistributeSpacing(nsTArray<OffsetIndexedKeyframe>& aKeyframes)
*/
static void
GenerateValueEntries(Element* aTarget,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
nsTArray<OffsetIndexedKeyframe>& aKeyframes,
nsTArray<KeyframeValueEntry>& aResult,
ErrorResult& aRv)
@@ -1338,7 +1425,7 @@ static void
BuildAnimationPropertyListFromKeyframeSequence(
JSContext* aCx,
Element* aTarget,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
JS::ForOfIterator& aIterator,
nsTArray<AnimationProperty>& aResult,
ErrorResult& aRv)
@@ -1396,7 +1483,7 @@ static void
BuildAnimationPropertyListFromPropertyIndexedKeyframes(
JSContext* aCx,
Element* aTarget,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
JS::Handle<JS::Value> aValue,
InfallibleTArray<AnimationProperty>& aResult,
ErrorResult& aRv)
@@ -1571,7 +1658,7 @@ BuildAnimationPropertyListFromPropertyIndexedKeyframes(
KeyframeEffectReadOnly::BuildAnimationPropertyList(
JSContext* aCx,
Element* aTarget,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
JS::Handle<JSObject*> aFrames,
InfallibleTArray<AnimationProperty>& aResult,
ErrorResult& aRv)
@@ -1615,55 +1702,6 @@ KeyframeEffectReadOnly::BuildAnimationPropertyList(
}
}
/* static */ already_AddRefed<KeyframeEffectReadOnly>
KeyframeEffectReadOnly::Constructor(
const GlobalObject& aGlobal,
const Nullable<ElementOrCSSPseudoElement>& aTarget,
JS::Handle<JSObject*> aFrames,
const TimingParams& aTiming,
ErrorResult& aRv)
{
if (aTarget.IsNull()) {
// We don't support null targets yet.
aRv.Throw(NS_ERROR_DOM_ANIM_NO_TARGET_ERR);
return nullptr;
}
const ElementOrCSSPseudoElement& target = aTarget.Value();
MOZ_ASSERT(target.IsElement() || target.IsCSSPseudoElement(),
"Uninitialized target");
RefPtr<Element> targetElement;
nsCSSPseudoElements::Type pseudoType =
nsCSSPseudoElements::ePseudo_NotPseudoElement;
if (target.IsElement()) {
targetElement = &target.GetAsElement();
} else {
targetElement = target.GetAsCSSPseudoElement().ParentElement();
pseudoType = target.GetAsCSSPseudoElement().GetType();
}
if (!targetElement->GetCurrentDoc()) {
// Bug 1245748: We don't support targets that are not in a document yet.
aRv.Throw(NS_ERROR_DOM_ANIM_TARGET_NOT_IN_DOC_ERR);
return nullptr;
}
InfallibleTArray<AnimationProperty> animationProperties;
BuildAnimationPropertyList(aGlobal.Context(), targetElement, pseudoType,
aFrames, animationProperties, aRv);
if (aRv.Failed()) {
return nullptr;
}
RefPtr<KeyframeEffectReadOnly> effect =
new KeyframeEffectReadOnly(targetElement->OwnerDoc(), targetElement,
pseudoType, aTiming);
effect->mProperties = Move(animationProperties);
return effect.forget();
}
void
KeyframeEffectReadOnly::GetTarget(
Nullable<OwningElementOrCSSPseudoElement>& aRv) const
@@ -1674,13 +1712,13 @@ KeyframeEffectReadOnly::GetTarget(
}
switch (mPseudoType) {
case nsCSSPseudoElements::ePseudo_before:
case nsCSSPseudoElements::ePseudo_after:
case CSSPseudoElementType::before:
case CSSPseudoElementType::after:
aRv.SetValue().SetAsCSSPseudoElement() =
CSSPseudoElement::GetCSSPseudoElement(mTarget, mPseudoType);
break;
case nsCSSPseudoElements::ePseudo_NotPseudoElement:
case CSSPseudoElementType::NotPseudo:
aRv.SetValue().SetAsElement() = mTarget;
break;
@@ -1928,12 +1966,12 @@ KeyframeEffectReadOnly::GetAnimationFrame() const
return nullptr;
}
if (mPseudoType == nsCSSPseudoElements::ePseudo_before) {
if (mPseudoType == CSSPseudoElementType::before) {
frame = nsLayoutUtils::GetBeforeFrame(frame);
} else if (mPseudoType == nsCSSPseudoElements::ePseudo_after) {
} else if (mPseudoType == CSSPseudoElementType::after) {
frame = nsLayoutUtils::GetAfterFrame(frame);
} else {
MOZ_ASSERT(mPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement,
MOZ_ASSERT(mPseudoType == CSSPseudoElementType::NotPseudo,
"unknown mPseudoType");
}
if (!frame) {
@@ -2063,6 +2101,21 @@ KeyframeEffectReadOnly::ShouldBlockCompositorAnimations(const nsIFrame*
return false;
}
//---------------------------------------------------------------------
//
// KeyframeEffect
//
//---------------------------------------------------------------------
KeyframeEffect::KeyframeEffect(nsIDocument* aDocument,
Element* aTarget,
CSSPseudoElementType aPseudoType,
const TimingParams& aTiming)
: KeyframeEffectReadOnly(aDocument, aTarget, aPseudoType,
new AnimationEffectTiming(aTiming))
{
}
JSObject*
KeyframeEffect::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto)
+50 -20
View File
@@ -9,7 +9,6 @@
#include "nsAutoPtr.h"
#include "nsCycleCollectionParticipant.h"
#include "nsCSSPseudoElements.h"
#include "nsIDocument.h"
#include "nsWrapperCache.h"
#include "mozilla/Attributes.h"
@@ -20,6 +19,7 @@
#include "mozilla/StyleAnimationValue.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/dom/AnimationEffectReadOnly.h"
#include "mozilla/dom/AnimationEffectTiming.h"
#include "mozilla/dom/AnimationEffectTimingReadOnly.h" // TimingParams
#include "mozilla/dom/Element.h"
#include "mozilla/dom/KeyframeBinding.h"
@@ -37,6 +37,7 @@ namespace mozilla {
struct AnimationCollection;
class AnimValuesStyleRule;
enum class CSSPseudoElementType : uint8_t;
namespace dom {
class ElementOrCSSPseudoElement;
@@ -171,7 +172,7 @@ class KeyframeEffectReadOnly : public AnimationEffectReadOnly
public:
KeyframeEffectReadOnly(nsIDocument* aDocument,
Element* aTarget,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
const TimingParams& aTiming);
NS_DECL_ISUPPORTS_INHERITED
@@ -195,20 +196,11 @@ public:
const UnrestrictedDoubleOrKeyframeEffectOptions& aOptions,
ErrorResult& aRv)
{
return Constructor(aGlobal, aTarget, aFrames,
TimingParams::FromOptionsUnion(aOptions, aTarget),
aRv);
return ConstructKeyframeEffect<KeyframeEffectReadOnly>(
aGlobal, aTarget, aFrames,
TimingParams::FromOptionsUnion(aOptions, aTarget), aRv);
}
// More generalized version for Animatable.animate.
// Not exposed to content.
static already_AddRefed<KeyframeEffectReadOnly>
Constructor(const GlobalObject& aGlobal,
const Nullable<ElementOrCSSPseudoElement>& aTarget,
JS::Handle<JSObject*> aFrames,
const TimingParams& aTiming,
ErrorResult& aRv);
void GetTarget(Nullable<OwningElementOrCSSPseudoElement>& aRv) const;
void GetFrames(JSContext*& aCx,
nsTArray<JSObject*>& aResult,
@@ -217,7 +209,7 @@ public:
// Temporary workaround to return both the target element and pseudo-type
// until we implement PseudoElement (bug 1174575).
void GetTarget(Element*& aTarget,
nsCSSPseudoElements::Type& aPseudoType) const {
CSSPseudoElementType& aPseudoType) const {
aTarget = mTarget;
aPseudoType = mPseudoType;
}
@@ -328,7 +320,21 @@ public:
inline AnimationCollection* GetCollection() const;
protected:
KeyframeEffectReadOnly(nsIDocument* aDocument,
Element* aTarget,
CSSPseudoElementType aPseudoType,
AnimationEffectTimingReadOnly* aTiming);
virtual ~KeyframeEffectReadOnly();
template<typename KeyframeEffectType>
static already_AddRefed<KeyframeEffectType>
ConstructKeyframeEffect(const GlobalObject& aGlobal,
const Nullable<ElementOrCSSPseudoElement>& aTarget,
JS::Handle<JSObject*> aFrames,
const TimingParams& aTiming,
ErrorResult& aRv);
void ResetIsRunningOnCompositor();
// This effect is registered with its target element so long as:
@@ -345,7 +351,7 @@ protected:
static void BuildAnimationPropertyList(
JSContext* aCx,
Element* aTarget,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
JS::Handle<JSObject*> aFrames,
InfallibleTArray<AnimationProperty>& aResult,
ErrorResult& aRv);
@@ -354,7 +360,7 @@ protected:
RefPtr<Animation> mAnimation;
OwningNonNull<AnimationEffectTimingReadOnly> mTiming;
nsCSSPseudoElements::Type mPseudoType;
CSSPseudoElementType mPseudoType;
InfallibleTArray<AnimationProperty> mProperties;
@@ -389,12 +395,36 @@ class KeyframeEffect : public KeyframeEffectReadOnly
public:
KeyframeEffect(nsIDocument* aDocument,
Element* aTarget,
nsCSSPseudoElements::Type aPseudoType,
const TimingParams& aTiming)
: KeyframeEffectReadOnly(aDocument, aTarget, aPseudoType, aTiming) { }
CSSPseudoElementType aPseudoType,
const TimingParams& aTiming);
JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
static already_AddRefed<KeyframeEffect>
Constructor(const GlobalObject& aGlobal,
const Nullable<ElementOrCSSPseudoElement>& aTarget,
JS::Handle<JSObject*> aFrames,
const UnrestrictedDoubleOrKeyframeEffectOptions& aOptions,
ErrorResult& aRv)
{
return ConstructKeyframeEffect<KeyframeEffect>(
aGlobal, aTarget, aFrames,
TimingParams::FromOptionsUnion(aOptions, aTarget), aRv);
}
// More generalized version for Animatable.animate.
// Not exposed to content.
static already_AddRefed<KeyframeEffect>
inline Constructor(const GlobalObject& aGlobal,
const Nullable<ElementOrCSSPseudoElement>& aTarget,
JS::Handle<JSObject*> aFrames,
const TimingParams& aTiming,
ErrorResult& aRv)
{
return ConstructKeyframeEffect<KeyframeEffect>(aGlobal, aTarget, aFrames,
aTiming, aRv);
}
};
} // namespace dom
+8 -5
View File
@@ -9,18 +9,19 @@
#include "mozilla/dom/Element.h"
#include "mozilla/HashFunctions.h"
#include "nsCSSPseudoElements.h"
#include "PLDHashTable.h"
namespace mozilla {
enum class CSSPseudoElementType : uint8_t;
struct PseudoElementHashKey
{
dom::Element* mElement;
nsCSSPseudoElements::Type mPseudoType;
CSSPseudoElementType mPseudoType;
};
// A hash entry that uses a RefPtr<dom::Element>, nsCSSPseudoElements::Type pair
// A hash entry that uses a RefPtr<dom::Element>, CSSPseudoElementType pair
class PseudoElementHashEntry : public PLDHashEntryHdr
{
public:
@@ -47,12 +48,14 @@ public:
if (!aKey)
return 0;
return mozilla::HashGeneric(aKey->mElement, aKey->mPseudoType);
// Convert the scoped enum into an integer while adding it to hash.
return mozilla::HashGeneric(aKey->mElement,
static_cast<uint8_t>(aKey->mPseudoType));
}
enum { ALLOW_MEMMOVE = true };
RefPtr<dom::Element> mElement;
nsCSSPseudoElements::Type mPseudoType;
CSSPseudoElementType mPseudoType;
};
} // namespace mozilla
+2
View File
@@ -10,6 +10,7 @@ MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini']
EXPORTS.mozilla.dom += [
'Animation.h',
'AnimationEffectReadOnly.h',
'AnimationEffectTiming.h',
'AnimationEffectTimingReadOnly.h',
'AnimationTimeline.h',
'CSSPseudoElement.h',
@@ -31,6 +32,7 @@ EXPORTS.mozilla += [
UNIFIED_SOURCES += [
'Animation.cpp',
'AnimationEffectReadOnly.cpp',
'AnimationEffectTiming.cpp',
'AnimationEffectTimingReadOnly.cpp',
'AnimationTimeline.cpp',
'AnimationUtils.cpp',
+22 -24
View File
@@ -45,7 +45,6 @@
#include "nsNameSpaceManager.h"
#include "nsContentList.h"
#include "nsVariant.h"
#include "nsDOMSettableTokenList.h"
#include "nsDOMTokenList.h"
#include "nsXBLPrototypeBinding.h"
#include "nsError.h"
@@ -925,7 +924,7 @@ already_AddRefed<DOMRect>
Element::GetBoundingClientRect()
{
RefPtr<DOMRect> rect = new DOMRect(this);
nsIFrame* frame = GetPrimaryFrame(Flush_Layout);
if (!frame) {
// display:none, perhaps? Return the empty rect
@@ -1497,7 +1496,7 @@ Element::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
if (xulElem) {
xulElem->SetXULBindingParent(aBindingParent);
}
else
else
#endif
{
if (aBindingParent) {
@@ -1557,7 +1556,7 @@ Element::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
// XXXbz ordering issues here? Probably not, since ChangeDocumentFor is
// just pretty broken anyway.... Need to get it working.
// XXXbz XBL doesn't handle this (asserts), and we don't really want
// to be doing this during parsing anyway... sort this out.
// to be doing this during parsing anyway... sort this out.
// aDocument->BindingManager()->ChangeDocumentFor(this, nullptr,
// aDocument);
@@ -1882,7 +1881,7 @@ Element::UnbindFromTree(bool aDeep, bool aNullParent)
}
}
// This has to be here, rather than in nsGenericHTMLElement::UnbindFromTree,
// This has to be here, rather than in nsGenericHTMLElement::UnbindFromTree,
// because it has to happen after unsetting the parent pointer, but before
// recursively unbinding the kids.
if (IsHTMLElement()) {
@@ -2592,7 +2591,7 @@ Element::GetAttrInfo(int32_t aNamespaceID, nsIAtom* aName) const
return nsAttrInfo(nullptr, nullptr);
}
bool
Element::GetAttr(int32_t aNameSpaceID, nsIAtom* aName,
@@ -2613,7 +2612,7 @@ Element::FindAttrValueIn(int32_t aNameSpaceID,
NS_ASSERTION(aName, "Must have attr name");
NS_ASSERTION(aNameSpaceID != kNameSpaceID_Unknown, "Must have namespace");
NS_ASSERTION(aValues, "Null value array");
const nsAttrValue* val = mAttrsAndChildren.GetAttr(aName, aNameSpaceID);
if (val) {
for (int32_t i = 0; aValues[i]; ++i) {
@@ -2817,7 +2816,7 @@ Element::List(FILE* out, int32_t aIndent,
nsIContent* child = GetFirstChild();
if (child) {
fputs("\n", out);
for (; child; child = child->GetNextSibling()) {
child->List(out, aIndent + 1);
}
@@ -2826,7 +2825,7 @@ Element::List(FILE* out, int32_t aIndent,
}
fputs(">\n", out);
Element* nonConstThis = const_cast<Element*>(this);
// XXX sXBL/XBL2 issue! Owner or current document?
@@ -3119,11 +3118,11 @@ Element::GetLinkTarget(nsAString& aTarget)
}
static void
nsDOMSettableTokenListPropertyDestructor(void *aObject, nsIAtom *aProperty,
void *aPropertyValue, void *aData)
nsDOMTokenListPropertyDestructor(void *aObject, nsIAtom *aProperty,
void *aPropertyValue, void *aData)
{
nsDOMSettableTokenList* list =
static_cast<nsDOMSettableTokenList*>(aPropertyValue);
nsDOMTokenList* list =
static_cast<nsDOMTokenList*>(aPropertyValue);
NS_RELEASE(list);
}
@@ -3145,7 +3144,7 @@ Element::HTMLSVGPropertiesToTraverseAndUnlink()
return sPropertiesToTraverseAndUnlink;
}
nsDOMSettableTokenList*
nsDOMTokenList*
Element::GetTokenList(nsIAtom* aAtom)
{
#ifdef DEBUG
@@ -3161,14 +3160,14 @@ Element::GetTokenList(nsIAtom* aAtom)
MOZ_ASSERT(found, "Trying to use an unknown tokenlist!");
#endif
nsDOMSettableTokenList* list = nullptr;
nsDOMTokenList* list = nullptr;
if (HasProperties()) {
list = static_cast<nsDOMSettableTokenList*>(GetProperty(aAtom));
list = static_cast<nsDOMTokenList*>(GetProperty(aAtom));
}
if (!list) {
list = new nsDOMSettableTokenList(this, aAtom);
list = new nsDOMTokenList(this, aAtom);
NS_ADDREF(list);
SetProperty(aAtom, list, nsDOMSettableTokenListPropertyDestructor);
SetProperty(aAtom, list, nsDOMTokenListPropertyDestructor);
}
return list;
}
@@ -3185,7 +3184,7 @@ Element::GetTokenList(nsIAtom* aAtom, nsIVariant** aResult)
nsresult
Element::SetTokenList(nsIAtom* aAtom, nsIVariant* aValue)
{
nsDOMSettableTokenList* itemType = GetTokenList(aAtom);
nsDOMTokenList* itemType = GetTokenList(aAtom);
nsAutoString string;
aValue->GetAsAString(string);
ErrorResult rv;
@@ -3402,9 +3401,8 @@ Element::Animate(JSContext* aContext,
Nullable<ElementOrCSSPseudoElement> target;
target.SetValue().SetAsElement() = this;
// Bug 1211783: Use KeyframeEffect here (instead of KeyframeEffectReadOnly)
RefPtr<KeyframeEffectReadOnly> effect =
KeyframeEffectReadOnly::Constructor(global, target, frames,
RefPtr<KeyframeEffect> effect =
KeyframeEffect::Constructor(global, target, frames,
TimingParams::FromOptionsUnion(aOptions, target), aError);
if (aError.Failed()) {
return nullptr;
@@ -3444,7 +3442,7 @@ void
Element::GetAnimationsUnsorted(nsTArray<RefPtr<Animation>>& aAnimations)
{
EffectSet* effects = EffectSet::GetEffectSet(this,
nsCSSPseudoElements::ePseudo_NotPseudoElement);
CSSPseudoElementType::NotPseudo);
if (!effects) {
return;
}
@@ -3586,7 +3584,7 @@ Element::InsertAdjacentHTML(const nsAString& aPosition, const nsAString& aText,
// Needed when insertAdjacentHTML is used in combination with contenteditable
mozAutoDocUpdate updateBatch(doc, UPDATE_CONTENT_MODEL, true);
nsAutoScriptLoaderDisabler sld(doc);
// Batch possible DOMSubtreeModified events.
mozAutoSubtreeModified subtree(doc, nullptr);
+1 -2
View File
@@ -45,7 +45,6 @@ class nsIURI;
class nsIScrollableFrame;
class nsAttrValueOrString;
class nsContentList;
class nsDOMSettableTokenList;
class nsDOMTokenList;
struct nsRect;
class nsFocusManager;
@@ -1329,7 +1328,7 @@ protected:
*/
virtual void GetLinkTarget(nsAString& aTarget);
nsDOMSettableTokenList* GetTokenList(nsIAtom* aAtom);
nsDOMTokenList* GetTokenList(nsIAtom* aAtom);
void GetTokenList(nsIAtom* aAtom, nsIVariant** aResult);
nsresult SetTokenList(nsIAtom* aAtom, nsIVariant* aValue);
+21 -11
View File
@@ -1355,10 +1355,11 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(FragmentOrElement)
for (uint32_t i = 0; props[i]; ++i) {
tmp->DeleteProperty(*props[i]);
}
// Bug 1226091: Call MayHaveAnimations() first
nsIAtom** effectProps = EffectSet::GetEffectSetPropertyAtoms();
for (uint32_t i = 0; effectProps[i]; ++i) {
tmp->DeleteProperty(effectProps[i]);
if (tmp->MayHaveAnimations()) {
nsIAtom** effectProps = EffectSet::GetEffectSetPropertyAtoms();
for (uint32_t i = 0; effectProps[i]; ++i) {
tmp->DeleteProperty(effectProps[i]);
}
}
}
}
@@ -1900,6 +1901,14 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(FragmentOrElement)
tmp->OwnerDoc()->BindingManager()->Traverse(tmp, cb);
// Check that whenever we have effect properties, MayHaveAnimations is set.
#ifdef DEBUG
nsIAtom** effectProps = EffectSet::GetEffectSetPropertyAtoms();
for (uint32_t i = 0; effectProps[i]; ++i) {
MOZ_ASSERT_IF(tmp->GetProperty(effectProps[i]), tmp->MayHaveAnimations());
}
#endif
if (tmp->HasProperties()) {
if (tmp->IsHTMLElement() || tmp->IsSVGElement()) {
nsIAtom*** props = Element::HTMLSVGPropertiesToTraverseAndUnlink();
@@ -1908,13 +1917,14 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(FragmentOrElement)
static_cast<nsISupports*>(tmp->GetProperty(*props[i]));
cb.NoteXPCOMChild(property);
}
// Bug 1226091: Check MayHaveAnimations() first
nsIAtom** effectProps = EffectSet::GetEffectSetPropertyAtoms();
for (uint32_t i = 0; effectProps[i]; ++i) {
EffectSet* effectSet =
static_cast<EffectSet*>(tmp->GetProperty(effectProps[i]));
if (effectSet) {
effectSet->Traverse(cb);
if (tmp->MayHaveAnimations()) {
nsIAtom** effectProps = EffectSet::GetEffectSetPropertyAtoms();
for (uint32_t i = 0; effectProps[i]; ++i) {
EffectSet* effectSet =
static_cast<EffectSet*>(tmp->GetProperty(effectProps[i]));
if (effectSet) {
effectSet->Traverse(cb);
}
}
}
}
-1
View File
@@ -278,7 +278,6 @@ UNIFIED_SOURCES += [
'nsDOMNavigationTiming.cpp',
'nsDOMScriptObjectFactory.cpp',
'nsDOMSerializer.cpp',
'nsDOMSettableTokenList.cpp',
'nsDOMTokenList.cpp',
'nsDOMWindowList.cpp',
'nsFocusManager.cpp',
+1 -1
View File
@@ -389,7 +389,7 @@ nsAnimationReceiver::RecordAnimationMutation(Animation* aAnimation,
}
mozilla::dom::Element* animationTarget;
nsCSSPseudoElements::Type pseudoType;
CSSPseudoElementType pseudoType;
effect->GetTarget(animationTarget, pseudoType);
if (!animationTarget) {
return;
-29
View File
@@ -1,29 +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/. */
/*
* Implementation of DOMSettableTokenList specified by HTML5.
*/
#include "nsDOMSettableTokenList.h"
#include "mozilla/dom/DOMSettableTokenListBinding.h"
#include "mozilla/dom/Element.h"
void
nsDOMSettableTokenList::SetValue(const nsAString& aValue, mozilla::ErrorResult& rv)
{
if (!mElement) {
return;
}
rv = mElement->SetAttr(kNameSpaceID_None, mAttrAtom, aValue, true);
}
JSObject*
nsDOMSettableTokenList::WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto)
{
return mozilla::dom::DOMSettableTokenListBinding::Wrap(cx, this, aGivenProto);
}
-35
View File
@@ -1,35 +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/. */
/*
* Implementation of DOMSettableTokenList specified by HTML5.
*/
#ifndef nsDOMSettableTokenList_h___
#define nsDOMSettableTokenList_h___
#include "nsDOMTokenList.h"
class nsIAtom;
// nsISupports must be on the primary inheritance chain
// because nsDOMSettableTokenList is traversed by Element.
class nsDOMSettableTokenList final : public nsDOMTokenList
{
public:
nsDOMSettableTokenList(mozilla::dom::Element* aElement, nsIAtom* aAttrAtom)
: nsDOMTokenList(aElement, aAttrAtom) {}
virtual JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
// WebIDL
void GetValue(nsAString& aResult) { Stringify(aResult); }
void SetValue(const nsAString& aValue, mozilla::ErrorResult& rv);
};
#endif // nsDOMSettableTokenList_h___
+10 -1
View File
@@ -9,7 +9,6 @@
*/
#include "nsDOMTokenList.h"
#include "nsAttrValue.h"
#include "nsContentUtils.h"
#include "nsError.h"
@@ -74,6 +73,16 @@ nsDOMTokenList::IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aResult)
}
}
void
nsDOMTokenList::SetValue(const nsAString& aValue, mozilla::ErrorResult& rv)
{
if (!mElement) {
return;
}
rv = mElement->SetAttr(kNameSpaceID_None, mAttrAtom, aValue, true);
}
nsresult
nsDOMTokenList::CheckToken(const nsAString& aStr)
{
+4 -1
View File
@@ -26,7 +26,7 @@ class nsAttrValue;
class nsIAtom;
// nsISupports must be on the primary inheritance chain
// because nsDOMSettableTokenList is traversed by Element.
class nsDOMTokenList : public nsISupports,
public nsWrapperCache
{
@@ -66,6 +66,9 @@ public:
bool Toggle(const nsAString& aToken,
const mozilla::dom::Optional<bool>& force,
mozilla::ErrorResult& aError);
void GetValue(nsAString& aResult) { Stringify(aResult); }
void SetValue(const nsAString& aValue, mozilla::ErrorResult& rv);
void Stringify(nsAString& aResult);
protected:
+7 -7
View File
@@ -102,6 +102,7 @@
#include "nsIStyleSheet.h"
#include "nsIStyleSheetService.h"
#include "nsContentPermissionHelper.h"
#include "nsCSSPseudoElements.h" // for CSSPseudoElementType
#include "nsNetUtil.h"
#include "nsDocument.h"
#include "HTMLImageElement.h"
@@ -2380,13 +2381,12 @@ ComputeAnimationValue(nsCSSProperty aProperty,
StyleAnimationValue& aOutput)
{
if (!StyleAnimationValue::ComputeValue(
aProperty,
aElement,
nsCSSPseudoElements::ePseudo_NotPseudoElement,
aInput,
false,
aOutput)) {
if (!StyleAnimationValue::ComputeValue(aProperty,
aElement,
CSSPseudoElementType::NotPseudo,
aInput,
false,
aOutput)) {
return false;
}
+3 -2
View File
@@ -6,6 +6,7 @@
#include "nsNodeUtils.h"
#include "nsContentUtils.h"
#include "nsCSSPseudoElements.h"
#include "nsINode.h"
#include "nsIContent.h"
#include "mozilla/dom/Element.h"
@@ -235,13 +236,13 @@ nsNodeUtils::GetTargetForAnimation(const Animation* aAnimation)
}
Element* target;
nsCSSPseudoElements::Type pseudoType;
CSSPseudoElementType pseudoType;
effect->GetTarget(target, pseudoType);
// If the animation targets a pseudo-element, we don't dispatch
// notifications for it. (In the future we will have PseudoElement
// objects we can use as the target of the notifications.)
if (pseudoType != nsCSSPseudoElements::ePseudo_NotPseudoElement) {
if (pseudoType != CSSPseudoElementType::NotPseudo) {
return nullptr;
}
+1 -1
View File
@@ -22,7 +22,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=346485
/** Test for Bug 346485 **/
/**
* This test is testing DOMSettableTokenList used by the output element.
* This test is testing DOMTokenList used by the output element.
*/
function checkHtmlFor(htmlFor, list, msg) {
+7 -4
View File
@@ -98,15 +98,20 @@ function assignToClassListStrict(e) {
"use strict";
try {
e.classList = "foo";
ok(false, "assigning to classList didn't throw");
} catch (e) { }
ok(true, "assigning to classList didn't throw");
e.removeAttribute("class");
} catch (e) {
ok(false, "assigning to classList threw");
}
}
function assignToClassList(e) {
try {
var expect = e.classList;
e.classList = "foo";
ok(true, "assigning to classList didn't throw");
is(e.classList, expect, "classList should be unchanged after assignment");
e.removeAttribute("class");
} catch (e) {
ok(false, "assigning to classList threw");
}
@@ -160,8 +165,6 @@ function testClassList(e) {
ok(DOMTokenList.prototype.hasOwnProperty("toString"),
"Should have own toString on DOMTokenList")
ok(!DOMSettableTokenList.prototype.hasOwnProperty("toString"),
"Should not have own toString on DOMSettableTokenList")
e.removeAttribute("class");
is(e.classList.toString(), "", "wrong classList.toString() value");
-4
View File
@@ -437,10 +437,6 @@ DOMInterfaces = {
'implicitJSContext': [ 'then' ],
},
'DOMSettableTokenList': {
'nativeType': 'nsDOMSettableTokenList',
},
'DOMStringMap': {
'nativeType': 'nsDOMStringMap'
},
+2 -2
View File
@@ -10,7 +10,7 @@
#include "mozilla/Attributes.h"
#include "nsGenericHTMLFrameElement.h"
#include "nsIDOMHTMLIFrameElement.h"
#include "nsDOMSettableTokenList.h"
#include "nsDOMTokenList.h"
namespace mozilla {
namespace dom {
@@ -84,7 +84,7 @@ public:
{
SetHTMLAttr(nsGkAtoms::name, aName, aError);
}
nsDOMSettableTokenList* Sandbox()
nsDOMTokenList* Sandbox()
{
return GetTokenList(nsGkAtoms::sandbox);
}
+1 -1
View File
@@ -119,7 +119,7 @@ public:
{
SetHTMLAttr(nsGkAtoms::hreflang, aHreflang, aRv);
}
nsDOMSettableTokenList* Sizes()
nsDOMTokenList* Sizes()
{
return GetTokenList(nsGkAtoms::sizes);
}
+3 -3
View File
@@ -11,7 +11,7 @@
#include "mozilla/dom/HTMLFormElement.h"
#include "mozilla/dom/HTMLOutputElementBinding.h"
#include "nsContentUtils.h"
#include "nsDOMSettableTokenList.h"
#include "nsDOMTokenList.h"
#include "nsFormSubmission.h"
NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(Output)
@@ -166,11 +166,11 @@ HTMLOutputElement::SetDefaultValue(const nsAString& aDefaultValue, ErrorResult&
}
}
nsDOMSettableTokenList*
nsDOMTokenList*
HTMLOutputElement::HtmlFor()
{
if (!mTokenList) {
mTokenList = new nsDOMSettableTokenList(this, nsGkAtoms::_for);
mTokenList = new nsDOMTokenList(this, nsGkAtoms::_for);
}
return mTokenList;
}
+2 -2
View File
@@ -64,7 +64,7 @@ public:
virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
// WebIDL
nsDOMSettableTokenList* HtmlFor();
nsDOMTokenList* HtmlFor();
// nsGenericHTMLFormElement::GetForm is fine.
void GetName(nsAString& aName)
{
@@ -108,7 +108,7 @@ protected:
ValueModeFlag mValueModeFlag;
bool mIsDoneAddingChildren;
nsString mDefaultValue;
RefPtr<nsDOMSettableTokenList> mTokenList;
RefPtr<nsDOMTokenList> mTokenList;
};
} // namespace dom
+1 -1
View File
@@ -9,7 +9,7 @@
#include "nsContentUtils.h"
#include "nsGenericHTMLElement.h"
#include "nsVariant.h"
#include "nsDOMSettableTokenList.h"
#include "nsDOMTokenList.h"
#include "nsAttrValue.h"
#include "nsWrapperCacheInlines.h"
#include "mozilla/dom/HTMLPropertiesCollectionBinding.h"
+1 -1
View File
@@ -47,7 +47,7 @@ public:
{
SetHTMLIntAttr(nsGkAtoms::rowspan, aRowSpan, aError);
}
//already_AddRefed<nsDOMSettableTokenList> Headers() const;
//already_AddRefed<nsDOMTokenList> Headers() const;
void GetHeaders(DOMString& aHeaders)
{
GetHTMLAttr(nsGkAtoms::headers, aHeaders);
+1 -1
View File
@@ -96,7 +96,7 @@
#include "HTMLPropertiesCollection.h"
#include "nsVariant.h"
#include "nsDOMSettableTokenList.h"
#include "nsDOMTokenList.h"
#include "nsThreadUtils.h"
#include "nsTextFragment.h"
#include "mozilla/dom/BindingUtils.h"
+4 -4
View File
@@ -20,7 +20,7 @@
#include "mozilla/dom/ValidityState.h"
#include "mozilla/dom/ElementInlines.h"
class nsDOMSettableTokenList;
class nsDOMTokenList;
class nsIDOMHTMLMenuElement;
class nsIEditor;
class nsIFormControlFrame;
@@ -104,7 +104,7 @@ public:
{
SetHTMLBoolAttr(nsGkAtoms::itemscope, aItemScope, aError);
}
nsDOMSettableTokenList* ItemType()
nsDOMTokenList* ItemType()
{
return GetTokenList(nsGkAtoms::itemtype);
}
@@ -116,11 +116,11 @@ public:
{
SetHTMLAttr(nsGkAtoms::itemid, aItemID, aError);
}
nsDOMSettableTokenList* ItemRef()
nsDOMTokenList* ItemRef()
{
return GetTokenList(nsGkAtoms::itemref);
}
nsDOMSettableTokenList* ItemProp()
nsDOMTokenList* ItemProp()
{
return GetTokenList(nsGkAtoms::itemprop);
}
+1 -1
View File
@@ -109,7 +109,7 @@ function checkHtmlForIDLAttribute(element)
is(String(element.htmlFor), 'a b',
"htmlFor IDL attribute should reflect the for content attribute");
// DOMSettableTokenList is tested in another bug so we just test assignation
// DOMTokenList is tested in another bug so we just test assignation
element.htmlFor.value = 'a b c';
is(String(element.htmlFor), 'a b c', "htmlFor should have changed");
}
+2 -2
View File
@@ -26,8 +26,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=845057
return ((a+'').split(" ").sort()+'') == ((b+'').split(" ").sort()+'');
}
ok(attr instanceof DOMSettableTokenList,
"Iframe sandbox attribute is instace of DOMSettableTokenList");
ok(attr instanceof DOMTokenList,
"Iframe sandbox attribute is instace of DOMTokenList");
ok(eq(attr, "allow-scripts") &&
eq(iframe.getAttribute("sandbox"), "allow-scripts"),
"Stringyfied sandbox attribute is same as that of the DOM element");
@@ -33,8 +33,7 @@ var interfaces = [
"HTMLCollection",
"DOMStringList",
"DOMTokenList",
"DOMSettableTokenList"
];
];
test(function() {
for (var p in window) {
interfaces.forEach(function(i) {
+2 -4
View File
@@ -278,6 +278,7 @@ interface Element : Node {
attribute DOMString id;
attribute DOMString className;
[PutForwards=value]
readonly attribute DOMTokenList classList;
readonly attribute Attr[] attributes;
@@ -443,10 +444,7 @@ interface DOMTokenList {
void remove(DOMString... tokens);
boolean toggle(DOMString token, optional boolean force);
stringifier;
};
interface DOMSettableTokenList : DOMTokenList {
attribute DOMString value;
attribute DOMString value;
};
</script>
<script>
+1 -1
View File
@@ -32,7 +32,7 @@ interface nsIDOMHTMLElement : nsIDOMElement
attribute nsIVariant itemType;
attribute DOMString itemId;
readonly attribute nsISupports properties;
// The following attributes are really nsDOMSettableTokenList, which has
// The following attributes are really nsDOMTokenList, which has
// PutForwards, so we express them as nsIVariants to deal with this.
attribute nsIVariant itemValue;
attribute nsIVariant itemProp;
+7 -8
View File
@@ -360,14 +360,13 @@ ValueFromStringHelper(nsCSSProperty aPropID,
}
}
nsDependentSubstring subString(aString, subStringBegin);
if (!StyleAnimationValue::ComputeValue(
aPropID,
aTargetElement,
nsCSSPseudoElements::ePseudo_NotPseudoElement,
subString,
true,
aStyleAnimValue,
aIsContextSensitive)) {
if (!StyleAnimationValue::ComputeValue(aPropID,
aTargetElement,
CSSPseudoElementType::NotPseudo,
subString,
true,
aStyleAnimValue,
aIsContextSensitive)) {
return false;
}
if (isNegative) {
@@ -126,6 +126,8 @@ var interfaceNamesInGlobalScope =
{name: "Animation", release: false},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "AnimationEffectReadOnly", release: false},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "AnimationEffectTiming", release: false},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "AnimationEffectTimingReadOnly", release: false},
// IMPORTANT: Do not change this list without review from a DOM peer!
@@ -449,8 +451,6 @@ var interfaceNamesInGlobalScope =
"DOMRectReadOnly",
// IMPORTANT: Do not change this list without review from a DOM peer!
"DOMRequest",
// IMPORTANT: Do not change this list without review from a DOM peer!
"DOMSettableTokenList",
// IMPORTANT: Do not change this list without review from a DOM peer!
"DOMStringList",
// IMPORTANT: Do not change this list without review from a DOM peer!
+31
View File
@@ -0,0 +1,31 @@
/* -*- Mode: IDL; 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/.
*
* The origin of this IDL file is
* https://w3c.github.io/web-animations/#animationeffecttiming
*
* Copyright © 2015 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
[Func="nsDocument::IsWebAnimationsEnabled"]
interface AnimationEffectTiming : AnimationEffectTimingReadOnly {
//Bug 1244633 - implement AnimationEffectTiming delay
//inherit attribute double delay;
//Bug 1244635 - implement AnimationEffectTiming endDelay
//inherit attribute double endDelay;
//Bug 1244637 - implement AnimationEffectTiming fill
//inherit attribute FillMode fill;
//Bug 1244638 - implement AnimationEffectTiming iterationStart
//inherit attribute double iterationStart;
//Bug 1244640 - implement AnimationEffectTiming iterations
//inherit attribute unrestricted double iterations;
//Bug 1244641 - implement AnimationEffectTiming duration
//inherit attribute (unrestricted double or DOMString) duration;
//Bug 1244642 - implement AnimationEffectTiming direction
//inherit attribute PlaybackDirection direction;
//Bug 1244643 - implement AnimationEffectTiming easing
//inherit attribute DOMString easing;
};
-16
View File
@@ -1,16 +0,0 @@
/* -*- Mode: IDL; 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/.
*
* The origin of this IDL file is
* http://www.w3.org/TR/2012/WD-dom-20120105/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
interface DOMSettableTokenList : DOMTokenList {
[SetterThrows]
attribute DOMString value;
};
+2
View File
@@ -21,5 +21,7 @@ interface DOMTokenList {
void remove(DOMString... tokens);
[Throws]
boolean toggle(DOMString token, optional boolean force);
[SetterThrows]
attribute DOMString value;
stringifier DOMString ();
};
+1 -1
View File
@@ -30,7 +30,7 @@ interface Element : Node {
attribute DOMString id;
[Pure]
attribute DOMString className;
[Constant]
[Constant, PutForwards=value]
readonly attribute DOMTokenList classList;
[SameObject]
+1
View File
@@ -23,6 +23,7 @@ interface HTMLAnchorElement : HTMLElement {
attribute DOMString rel;
[SetterThrows, Pref="network.http.enablePerElementReferrer"]
attribute DOMString referrerPolicy;
[PutForwards=value]
readonly attribute DOMTokenList relList;
[SetterThrows]
attribute DOMString hreflang;
+1
View File
@@ -30,6 +30,7 @@ interface HTMLAreaElement : HTMLElement {
attribute DOMString rel;
[SetterThrows, Pref="network.http.enablePerElementReferrer"]
attribute DOMString referrerPolicy;
[PutForwards=value]
readonly attribute DOMTokenList relList;
};
+4 -4
View File
@@ -28,11 +28,11 @@ interface HTMLElement : Element {
// microdata
[SetterThrows, Pure]
attribute boolean itemScope;
[PutForwards=value,Constant] readonly attribute DOMSettableTokenList itemType;
[PutForwards=value,Constant] readonly attribute DOMTokenList itemType;
[SetterThrows, Pure]
attribute DOMString itemId;
[PutForwards=value,Constant] readonly attribute DOMSettableTokenList itemRef;
[PutForwards=value,Constant] readonly attribute DOMSettableTokenList itemProp;
[PutForwards=value,Constant] readonly attribute DOMTokenList itemRef;
[PutForwards=value,Constant] readonly attribute DOMTokenList itemProp;
[Constant]
readonly attribute HTMLPropertiesCollection properties;
[Throws]
@@ -54,7 +54,7 @@ interface HTMLElement : Element {
readonly attribute DOMString accessKeyLabel;
[SetterThrows, Pure]
attribute boolean draggable;
//[PutForwards=value] readonly attribute DOMSettableTokenList dropzone;
//[PutForwards=value] readonly attribute DOMTokenList dropzone;
[SetterThrows, Pure]
attribute DOMString contentEditable;
[Pure]
+1 -1
View File
@@ -18,7 +18,7 @@ interface HTMLIFrameElement : HTMLElement {
attribute DOMString srcdoc;
[SetterThrows, Pure]
attribute DOMString name;
[PutForwards=value] readonly attribute DOMSettableTokenList sandbox;
[PutForwards=value] readonly attribute DOMTokenList sandbox;
// attribute boolean seamless;
[SetterThrows, Pure]
attribute boolean allowFullscreen;
+2 -1
View File
@@ -21,6 +21,7 @@ interface HTMLLinkElement : HTMLElement {
attribute DOMString? crossOrigin;
[SetterThrows, Pure]
attribute DOMString rel;
[PutForwards=value]
readonly attribute DOMTokenList relList;
[SetterThrows, Pure]
attribute DOMString media;
@@ -28,7 +29,7 @@ interface HTMLLinkElement : HTMLElement {
attribute DOMString hreflang;
[SetterThrows, Pure]
attribute DOMString type;
[PutForwards=value] readonly attribute DOMSettableTokenList sizes;
[PutForwards=value] readonly attribute DOMTokenList sizes;
};
HTMLLinkElement implements LinkStyle;
+1 -1
View File
@@ -14,7 +14,7 @@
// http://www.whatwg.org/specs/web-apps/current-work/#the-output-element
interface HTMLOutputElement : HTMLElement {
[PutForwards=value, Constant]
readonly attribute DOMSettableTokenList htmlFor;
readonly attribute DOMTokenList htmlFor;
readonly attribute HTMLFormElement? form;
[SetterThrows, Pure]
attribute DOMString name;
+1 -1
View File
@@ -16,7 +16,7 @@ interface HTMLTableCellElement : HTMLElement {
attribute unsigned long colSpan;
[SetterThrows]
attribute unsigned long rowSpan;
//[PutForwards=value] readonly attribute DOMSettableTokenList headers;
//[PutForwards=value] readonly attribute DOMTokenList headers;
[SetterThrows]
attribute DOMString headers;
readonly attribute long cellIndex;
+4 -4
View File
@@ -46,10 +46,10 @@ interface KeyframeEffectReadOnly : AnimationEffectReadOnly {
};
// Bug 1211783 Implement KeyframeEffect constructor
// [Constructor (Animatable? target,
// object? frames,
// optional (unrestricted double or KeyframeEffectOptions) options)]
[Func="nsDocument::IsWebAnimationsEnabled",
Constructor ((Element or CSSPseudoElement)? target,
object? frames,
optional (unrestricted double or KeyframeEffectOptions) options)]
interface KeyframeEffect : KeyframeEffectReadOnly {
// Bug 1067769 - Allow setting KeyframeEffect.target
// inherit attribute Animatable? target;
+1 -1
View File
@@ -25,6 +25,7 @@ WEBIDL_FILES = [
'Animatable.webidl',
'Animation.webidl',
'AnimationEffectReadOnly.webidl',
'AnimationEffectTiming.webidl',
'AnimationEffectTimingReadOnly.webidl',
'AnimationEvent.webidl',
'AnimationTimeline.webidl',
@@ -135,7 +136,6 @@ WEBIDL_FILES = [
'DOMRect.webidl',
'DOMRectList.webidl',
'DOMRequest.webidl',
'DOMSettableTokenList.webidl',
'DOMStringList.webidl',
'DOMStringMap.webidl',
'DOMTokenList.webidl',
+43 -46
View File
@@ -21,6 +21,7 @@
#include "nsStyleUtil.h"
#include "nsCSSFrameConstructor.h"
#include "nsSVGEffects.h"
#include "nsCSSPseudoElements.h"
#include "nsCSSRendering.h"
#include "nsAnimationManager.h"
#include "nsTransitionManager.h"
@@ -1104,18 +1105,15 @@ RestyleManager::AnimationsWithDestroyedFrame::AnimationsWithDestroyedFrame(
void
RestyleManager::AnimationsWithDestroyedFrame::StopAnimationsForElementsWithoutFrames()
{
StopAnimationsWithoutFrame(mContents,
nsCSSPseudoElements::ePseudo_NotPseudoElement);
StopAnimationsWithoutFrame(mBeforeContents,
nsCSSPseudoElements::ePseudo_before);
StopAnimationsWithoutFrame(mAfterContents,
nsCSSPseudoElements::ePseudo_after);
StopAnimationsWithoutFrame(mContents, CSSPseudoElementType::NotPseudo);
StopAnimationsWithoutFrame(mBeforeContents, CSSPseudoElementType::before);
StopAnimationsWithoutFrame(mAfterContents, CSSPseudoElementType::after);
}
void
RestyleManager::AnimationsWithDestroyedFrame::StopAnimationsWithoutFrame(
nsTArray<RefPtr<nsIContent>>& aArray,
nsCSSPseudoElements::Type aPseudoType)
CSSPseudoElementType aPseudoType)
{
nsAnimationManager* animationManager =
mRestyleManager->PresContext()->AnimationManager();
@@ -1132,7 +1130,7 @@ RestyleManager::AnimationsWithDestroyedFrame::StopAnimationsWithoutFrame(
static inline dom::Element*
ElementForStyleContext(nsIContent* aParentContent,
nsIFrame* aFrame,
nsCSSPseudoElements::Type aPseudoType);
CSSPseudoElementType aPseudoType);
// Forwarded nsIDocumentObserver method, to handle restyling (and
// passing the notification to the frame).
@@ -1159,8 +1157,7 @@ RestyleManager::ContentStateChanged(nsIContent* aContent,
// need to force a reframe -- if it's needed, the HasStateDependentStyle
// call will handle things.
nsIFrame* primaryFrame = aElement->GetPrimaryFrame();
nsCSSPseudoElements::Type pseudoType =
nsCSSPseudoElements::ePseudo_NotPseudoElement;
CSSPseudoElementType pseudoType = CSSPseudoElementType::NotPseudo;
if (primaryFrame) {
// If it's generated content, ignore LOADING/etc state changes on it.
if (!primaryFrame->IsGeneratedContentFrame() &&
@@ -1192,7 +1189,7 @@ RestyleManager::ContentStateChanged(nsIContent* aContent,
nsRestyleHint rshint;
if (pseudoType >= nsCSSPseudoElements::ePseudo_PseudoElementCount) {
if (pseudoType >= CSSPseudoElementType::Count) {
rshint = styleSet->HasStateDependentStyle(aElement, aStateMask);
} else if (nsCSSPseudoElements::PseudoElementSupportsUserActionState(
pseudoType)) {
@@ -1232,6 +1229,7 @@ RestyleManager::AttributeWillChange(Element* aElement,
RestyleHintData rsdata;
nsRestyleHint rshint =
mPresContext->StyleSet()->HasAttributeDependentStyle(aElement,
aNameSpaceID,
aAttribute,
aModType,
false,
@@ -1323,6 +1321,7 @@ RestyleManager::AttributeChanged(Element* aElement,
RestyleHintData rsdata;
nsRestyleHint rshint =
mPresContext->StyleSet()->HasAttributeDependentStyle(aElement,
aNameSpaceID,
aAttribute,
aModType,
true,
@@ -2127,31 +2126,31 @@ RestyleManager::TryStartingTransition(nsPresContext* aPresContext,
static dom::Element*
ElementForStyleContext(nsIContent* aParentContent,
nsIFrame* aFrame,
nsCSSPseudoElements::Type aPseudoType)
CSSPseudoElementType aPseudoType)
{
// We don't expect XUL tree stuff here.
NS_PRECONDITION(aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement ||
aPseudoType == nsCSSPseudoElements::ePseudo_AnonBox ||
aPseudoType < nsCSSPseudoElements::ePseudo_PseudoElementCount,
NS_PRECONDITION(aPseudoType == CSSPseudoElementType::NotPseudo ||
aPseudoType == CSSPseudoElementType::AnonBox ||
aPseudoType < CSSPseudoElementType::Count,
"Unexpected pseudo");
// XXX see the comments about the various element confusion in
// ElementRestyler::Restyle.
if (aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement) {
if (aPseudoType == CSSPseudoElementType::NotPseudo) {
return aFrame->GetContent()->AsElement();
}
if (aPseudoType == nsCSSPseudoElements::ePseudo_AnonBox) {
if (aPseudoType == CSSPseudoElementType::AnonBox) {
return nullptr;
}
if (aPseudoType == nsCSSPseudoElements::ePseudo_firstLetter) {
if (aPseudoType == CSSPseudoElementType::firstLetter) {
NS_ASSERTION(aFrame->GetType() == nsGkAtoms::letterFrame,
"firstLetter pseudoTag without a nsFirstLetterFrame");
nsBlockFrame* block = nsBlockFrame::GetNearestAncestorBlock(aFrame);
return block->GetContent()->AsElement();
}
if (aPseudoType == nsCSSPseudoElements::ePseudo_mozColorSwatch) {
if (aPseudoType == CSSPseudoElementType::mozColorSwatch) {
MOZ_ASSERT(aFrame->GetParent() &&
aFrame->GetParent()->GetParent(),
"Color swatch frame should have a parent & grandparent");
@@ -2163,11 +2162,11 @@ ElementForStyleContext(nsIContent* aParentContent,
return grandparentFrame->GetContent()->AsElement();
}
if (aPseudoType == nsCSSPseudoElements::ePseudo_mozNumberText ||
aPseudoType == nsCSSPseudoElements::ePseudo_mozNumberWrapper ||
aPseudoType == nsCSSPseudoElements::ePseudo_mozNumberSpinBox ||
aPseudoType == nsCSSPseudoElements::ePseudo_mozNumberSpinUp ||
aPseudoType == nsCSSPseudoElements::ePseudo_mozNumberSpinDown) {
if (aPseudoType == CSSPseudoElementType::mozNumberText ||
aPseudoType == CSSPseudoElementType::mozNumberWrapper ||
aPseudoType == CSSPseudoElementType::mozNumberSpinBox ||
aPseudoType == CSSPseudoElementType::mozNumberSpinUp ||
aPseudoType == CSSPseudoElementType::mozNumberSpinDown) {
// Get content for nearest nsNumberControlFrame:
nsIFrame* f = aFrame->GetParent();
MOZ_ASSERT(f);
@@ -2199,9 +2198,9 @@ ElementForStyleContext(nsIContent* aParentContent,
*/
static dom::Element*
PseudoElementForStyleContext(nsIFrame* aFrame,
nsCSSPseudoElements::Type aPseudoType)
CSSPseudoElementType aPseudoType)
{
if (aPseudoType >= nsCSSPseudoElements::ePseudo_PseudoElementCount) {
if (aPseudoType >= CSSPseudoElementType::Count) {
return nullptr;
}
@@ -3845,7 +3844,7 @@ ElementRestyler::RestyleSelf(nsIFrame* aSelf,
#endif
nsIAtom* const pseudoTag = oldContext->GetPseudo();
const nsCSSPseudoElements::Type pseudoType = oldContext->GetPseudoType();
const CSSPseudoElementType pseudoType = oldContext->GetPseudoType();
// Get the frame providing the parent style context. If it is a
// child, then resolve the provider first.
@@ -3940,7 +3939,7 @@ ElementRestyler::RestyleSelf(nsIFrame* aSelf,
parentContext, oldContext,
rshint);
}
} else if (pseudoType == nsCSSPseudoElements::ePseudo_AnonBox) {
} else if (pseudoType == CSSPseudoElementType::AnonBox) {
newContext = styleSet->ResolveAnonymousBoxStyle(pseudoTag,
parentContext);
}
@@ -3974,8 +3973,7 @@ ElementRestyler::RestyleSelf(nsIFrame* aSelf,
} else {
// Don't expect XUL tree stuff here, since it needs a comparator and
// all.
NS_ASSERTION(pseudoType <
nsCSSPseudoElements::ePseudo_PseudoElementCount,
NS_ASSERTION(pseudoType < CSSPseudoElementType::Count,
"Unexpected pseudo type");
Element* pseudoElement =
PseudoElementForStyleContext(aSelf, pseudoType);
@@ -4256,12 +4254,12 @@ ElementRestyler::RestyleSelf(nsIFrame* aSelf,
LOG_RESTYLE_INDENT();
RefPtr<nsStyleContext> newExtraContext;
nsIAtom* const extraPseudoTag = oldExtraContext->GetPseudo();
const nsCSSPseudoElements::Type extraPseudoType =
const CSSPseudoElementType extraPseudoType =
oldExtraContext->GetPseudoType();
NS_ASSERTION(extraPseudoTag &&
extraPseudoTag != nsCSSAnonBoxes::mozNonElement,
"extra style context is not pseudo element");
Element* element = extraPseudoType != nsCSSPseudoElements::ePseudo_AnonBox
Element* element = extraPseudoType != CSSPseudoElementType::AnonBox
? mContent->AsElement() : nullptr;
if (!MustRestyleSelf(aRestyleHint, element)) {
if (CanReparentStyleContext(aRestyleHint)) {
@@ -4283,14 +4281,13 @@ ElementRestyler::RestyleSelf(nsIFrame* aSelf,
newContext, oldExtraContext,
nsRestyleHint(0));
}
} else if (extraPseudoType == nsCSSPseudoElements::ePseudo_AnonBox) {
} else if (extraPseudoType == CSSPseudoElementType::AnonBox) {
newExtraContext = styleSet->ResolveAnonymousBoxStyle(extraPseudoTag,
newContext);
} else {
// Don't expect XUL tree stuff here, since it needs a comparator and
// all.
NS_ASSERTION(extraPseudoType <
nsCSSPseudoElements::ePseudo_PseudoElementCount,
NS_ASSERTION(extraPseudoType < CSSPseudoElementType::Count,
"Unexpected type");
newExtraContext = styleSet->ResolvePseudoElementStyle(mContent->AsElement(),
extraPseudoType,
@@ -4399,11 +4396,11 @@ ElementRestyler::RestyleChildrenOfDisplayContentsElement(
const bool mightReframePseudos = aRestyleHint & eRestyle_Subtree;
DoRestyleUndisplayedDescendants(nsRestyleHint(0), mContent, aNewContext);
if (!(mHintsHandled & nsChangeHint_ReconstructFrame) && mightReframePseudos) {
MaybeReframeForPseudo(nsCSSPseudoElements::ePseudo_before,
MaybeReframeForPseudo(CSSPseudoElementType::before,
aParentFrame, nullptr, mContent, aNewContext);
}
if (!(mHintsHandled & nsChangeHint_ReconstructFrame) && mightReframePseudos) {
MaybeReframeForPseudo(nsCSSPseudoElements::ePseudo_after,
MaybeReframeForPseudo(CSSPseudoElementType::after,
aParentFrame, nullptr, mContent, aNewContext);
}
if (!(mHintsHandled & nsChangeHint_ReconstructFrame)) {
@@ -4644,7 +4641,7 @@ ElementRestyler::RestyleUndisplayedNodes(nsRestyleHint aChildRestyleHint,
void
ElementRestyler::MaybeReframeForBeforePseudo()
{
MaybeReframeForPseudo(nsCSSPseudoElements::ePseudo_before,
MaybeReframeForPseudo(CSSPseudoElementType::before,
mFrame, mFrame, mFrame->GetContent(),
mFrame->StyleContext());
}
@@ -4657,7 +4654,7 @@ void
ElementRestyler::MaybeReframeForAfterPseudo(nsIFrame* aFrame)
{
MOZ_ASSERT(aFrame);
MaybeReframeForPseudo(nsCSSPseudoElements::ePseudo_after,
MaybeReframeForPseudo(CSSPseudoElementType::after,
aFrame, aFrame, aFrame->GetContent(),
aFrame->StyleContext());
}
@@ -4666,7 +4663,7 @@ ElementRestyler::MaybeReframeForAfterPseudo(nsIFrame* aFrame)
bool
ElementRestyler::MustReframeForBeforePseudo()
{
return MustReframeForPseudo(nsCSSPseudoElements::ePseudo_before,
return MustReframeForPseudo(CSSPseudoElementType::before,
mFrame, mFrame, mFrame->GetContent(),
mFrame->StyleContext());
}
@@ -4675,14 +4672,14 @@ bool
ElementRestyler::MustReframeForAfterPseudo(nsIFrame* aFrame)
{
MOZ_ASSERT(aFrame);
return MustReframeForPseudo(nsCSSPseudoElements::ePseudo_after,
return MustReframeForPseudo(CSSPseudoElementType::after,
aFrame, aFrame, aFrame->GetContent(),
aFrame->StyleContext());
}
#endif
void
ElementRestyler::MaybeReframeForPseudo(nsCSSPseudoElements::Type aPseudoType,
ElementRestyler::MaybeReframeForPseudo(CSSPseudoElementType aPseudoType,
nsIFrame* aGenConParentFrame,
nsIFrame* aFrame,
nsIContent* aContent,
@@ -4699,14 +4696,14 @@ ElementRestyler::MaybeReframeForPseudo(nsCSSPseudoElements::Type aPseudoType,
}
bool
ElementRestyler::MustReframeForPseudo(nsCSSPseudoElements::Type aPseudoType,
ElementRestyler::MustReframeForPseudo(CSSPseudoElementType aPseudoType,
nsIFrame* aGenConParentFrame,
nsIFrame* aFrame,
nsIContent* aContent,
nsStyleContext* aStyleContext)
{
MOZ_ASSERT(aPseudoType == nsCSSPseudoElements::ePseudo_before ||
aPseudoType == nsCSSPseudoElements::ePseudo_after);
MOZ_ASSERT(aPseudoType == CSSPseudoElementType::before ||
aPseudoType == CSSPseudoElementType::after);
// Make sure not to do this for pseudo-frames...
if (aStyleContext->GetPseudo()) {
@@ -4722,7 +4719,7 @@ ElementRestyler::MustReframeForPseudo(nsCSSPseudoElements::Type aPseudoType,
}
}
if (aPseudoType == nsCSSPseudoElements::ePseudo_before) {
if (aPseudoType == CSSPseudoElementType::before) {
// Check for a ::before pseudo style and the absence of a ::before content,
// but only if aFrame is null or is the first continuation/ib-split.
if ((aFrame && !nsLayoutUtils::IsFirstContinuationOrIBSplitSibling(aFrame)) ||
+16 -16
View File
@@ -18,7 +18,6 @@
#include "nsPresContext.h"
#include "nsRefreshDriver.h"
#include "nsRefPtrHashtable.h"
#include "nsCSSPseudoElements.h"
#include "nsTransitionManager.h"
class nsIFrame;
@@ -26,6 +25,7 @@ class nsStyleChangeList;
struct TreeMatchContext;
namespace mozilla {
enum class CSSPseudoElementType : uint8_t;
class EventStates;
struct UndisplayedNode;
@@ -191,29 +191,29 @@ public:
void Put(nsIContent* aContent, nsStyleContext* aStyleContext) {
MOZ_ASSERT(aContent);
nsCSSPseudoElements::Type pseudoType = aStyleContext->GetPseudoType();
if (pseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement) {
CSSPseudoElementType pseudoType = aStyleContext->GetPseudoType();
if (pseudoType == CSSPseudoElementType::NotPseudo) {
mElementContexts.Put(aContent, aStyleContext);
} else if (pseudoType == nsCSSPseudoElements::ePseudo_before) {
} else if (pseudoType == CSSPseudoElementType::before) {
MOZ_ASSERT(aContent->NodeInfo()->NameAtom() == nsGkAtoms::mozgeneratedcontentbefore);
mBeforePseudoContexts.Put(aContent->GetParent(), aStyleContext);
} else if (pseudoType == nsCSSPseudoElements::ePseudo_after) {
} else if (pseudoType == CSSPseudoElementType::after) {
MOZ_ASSERT(aContent->NodeInfo()->NameAtom() == nsGkAtoms::mozgeneratedcontentafter);
mAfterPseudoContexts.Put(aContent->GetParent(), aStyleContext);
}
}
nsStyleContext* Get(nsIContent* aContent,
nsCSSPseudoElements::Type aPseudoType) {
CSSPseudoElementType aPseudoType) {
MOZ_ASSERT(aContent);
if (aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement) {
if (aPseudoType == CSSPseudoElementType::NotPseudo) {
return mElementContexts.GetWeak(aContent);
}
if (aPseudoType == nsCSSPseudoElements::ePseudo_before) {
if (aPseudoType == CSSPseudoElementType::before) {
MOZ_ASSERT(aContent->NodeInfo()->NameAtom() == nsGkAtoms::mozgeneratedcontentbefore);
return mBeforePseudoContexts.GetWeak(aContent->GetParent());
}
if (aPseudoType == nsCSSPseudoElements::ePseudo_after) {
if (aPseudoType == CSSPseudoElementType::after) {
MOZ_ASSERT(aContent->NodeInfo()->NameAtom() == nsGkAtoms::mozgeneratedcontentafter);
return mAfterPseudoContexts.GetWeak(aContent->GetParent());
}
@@ -269,13 +269,13 @@ public:
// the real element.
void Put(nsIContent* aContent, nsStyleContext* aStyleContext) {
MOZ_ASSERT(aContent);
nsCSSPseudoElements::Type pseudoType = aStyleContext->GetPseudoType();
if (pseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement) {
CSSPseudoElementType pseudoType = aStyleContext->GetPseudoType();
if (pseudoType == CSSPseudoElementType::NotPseudo) {
mContents.AppendElement(aContent);
} else if (pseudoType == nsCSSPseudoElements::ePseudo_before) {
} else if (pseudoType == CSSPseudoElementType::before) {
MOZ_ASSERT(aContent->NodeInfo()->NameAtom() == nsGkAtoms::mozgeneratedcontentbefore);
mBeforeContents.AppendElement(aContent->GetParent());
} else if (pseudoType == nsCSSPseudoElements::ePseudo_after) {
} else if (pseudoType == CSSPseudoElementType::after) {
MOZ_ASSERT(aContent->NodeInfo()->NameAtom() == nsGkAtoms::mozgeneratedcontentafter);
mAfterContents.AppendElement(aContent->GetParent());
}
@@ -285,7 +285,7 @@ public:
private:
void StopAnimationsWithoutFrame(nsTArray<RefPtr<nsIContent>>& aArray,
nsCSSPseudoElements::Type aPseudoType);
CSSPseudoElementType aPseudoType);
RestyleManager* mRestyleManager;
AutoRestore<AnimationsWithDestroyedFrame*> mRestorePointer;
@@ -792,7 +792,7 @@ private:
const uint8_t aDisplay);
void MaybeReframeForBeforePseudo();
void MaybeReframeForAfterPseudo(nsIFrame* aFrame);
void MaybeReframeForPseudo(nsCSSPseudoElements::Type aPseudoType,
void MaybeReframeForPseudo(CSSPseudoElementType aPseudoType,
nsIFrame* aGenConParentFrame,
nsIFrame* aFrame,
nsIContent* aContent,
@@ -801,7 +801,7 @@ private:
bool MustReframeForBeforePseudo();
bool MustReframeForAfterPseudo(nsIFrame* aFrame);
#endif
bool MustReframeForPseudo(nsCSSPseudoElements::Type aPseudoType,
bool MustReframeForPseudo(CSSPseudoElementType aPseudoType,
nsIFrame* aGenConParentFrame,
nsIFrame* aFrame,
nsIContent* aContent,
+19 -18
View File
@@ -20,6 +20,7 @@
#include "mozilla/Likely.h"
#include "mozilla/LinkedList.h"
#include "nsAbsoluteContainingBlock.h"
#include "nsCSSPseudoElements.h"
#include "nsIAtom.h"
#include "nsIFrameInlines.h"
#include "nsGkAtoms.h"
@@ -1757,11 +1758,11 @@ nsCSSFrameConstructor::CreateGeneratedContentItem(nsFrameConstructorState& aStat
nsContainerFrame* aParentFrame,
nsIContent* aParentContent,
nsStyleContext* aStyleContext,
nsCSSPseudoElements::Type aPseudoElement,
CSSPseudoElementType aPseudoElement,
FrameConstructionItemList& aItems)
{
MOZ_ASSERT(aPseudoElement == nsCSSPseudoElements::ePseudo_before ||
aPseudoElement == nsCSSPseudoElements::ePseudo_after,
MOZ_ASSERT(aPseudoElement == CSSPseudoElementType::before ||
aPseudoElement == CSSPseudoElementType::after,
"unexpected aPseudoElement");
// XXXbz is this ever true?
@@ -1782,7 +1783,7 @@ nsCSSFrameConstructor::CreateGeneratedContentItem(nsFrameConstructorState& aStat
if (!pseudoStyleContext)
return;
bool isBefore = aPseudoElement == nsCSSPseudoElements::ePseudo_before;
bool isBefore = aPseudoElement == CSSPseudoElementType::before;
// |ProbePseudoStyleFor| checked the 'display' property and the
// |ContentCount()| of the 'content' property for us.
@@ -2961,7 +2962,7 @@ nsCSSFrameConstructor::CreateBackdropFrameFor(nsIPresShell* aPresShell,
RefPtr<nsStyleContext> style = aPresShell->StyleSet()->
ResolvePseudoElementStyle(aContent->AsElement(),
nsCSSPseudoElements::ePseudo_backdrop,
CSSPseudoElementType::backdrop,
/* aParentStyleContext */ nullptr,
/* aPseudoElement */ nullptr);
nsBackdropFrame* backdropFrame = new (aPresShell) nsBackdropFrame(style);
@@ -4946,7 +4947,7 @@ nsCSSFrameConstructor::ResolveStyleContext(nsStyleContext* aParentStyleContext,
RestyleManager()->GetReframingStyleContexts();
if (rsc) {
nsStyleContext* oldStyleContext =
rsc->Get(aContent, nsCSSPseudoElements::ePseudo_NotPseudoElement);
rsc->Get(aContent, CSSPseudoElementType::NotPseudo);
nsPresContext* presContext = mPresShell->GetPresContext();
if (oldStyleContext) {
RestyleManager::TryStartingTransition(presContext, aContent,
@@ -4954,7 +4955,7 @@ nsCSSFrameConstructor::ResolveStyleContext(nsStyleContext* aParentStyleContext,
} else if (aContent->IsElement()) {
presContext->TransitionManager()->
PruneCompletedTransitions(aContent->AsElement(),
nsCSSPseudoElements::ePseudo_NotPseudoElement, result);
CSSPseudoElementType::NotPseudo, result);
}
}
@@ -5793,7 +5794,7 @@ nsCSSFrameConstructor::AddFrameConstructionItemsInternal(nsFrameConstructorState
aParentFrame->AddStateBits(NS_FRAME_MAY_HAVE_GENERATED_CONTENT);
}
CreateGeneratedContentItem(aState, aParentFrame, aContent, styleContext,
nsCSSPseudoElements::ePseudo_before, aItems);
CSSPseudoElementType::before, aItems);
FlattenedChildIterator iter(aContent);
for (nsIContent* child = iter.GetNextChild(); child; child = iter.GetNextChild()) {
@@ -5826,7 +5827,7 @@ nsCSSFrameConstructor::AddFrameConstructionItemsInternal(nsFrameConstructorState
aItems.SetParentHasNoXBLChildren(!iter.XBLInvolved());
CreateGeneratedContentItem(aState, aParentFrame, aContent, styleContext,
nsCSSPseudoElements::ePseudo_after, aItems);
CSSPseudoElementType::after, aItems);
if (canHavePageBreak && display->mBreakAfter) {
AddPageBreakItem(aContent, aStyleContext, aItems);
}
@@ -6213,7 +6214,7 @@ AdjustAppendParentForAfterContent(nsFrameManager* aFrameManager,
// document than aChild and return that in aAfterFrame.
if (aParentFrame->GetGenConPseudos() ||
nsLayoutUtils::HasPseudoStyle(aContainer, aParentFrame->StyleContext(),
nsCSSPseudoElements::ePseudo_after,
CSSPseudoElementType::after,
aParentFrame->PresContext()) ||
aFrameManager->GetDisplayContentsStyleFor(aContainer)) {
nsIFrame* afterFrame = nullptr;
@@ -9615,7 +9616,7 @@ nsCSSFrameConstructor::GetFirstLetterStyle(nsIContent* aContent,
if (aContent) {
return mPresShell->StyleSet()->
ResolvePseudoElementStyle(aContent->AsElement(),
nsCSSPseudoElements::ePseudo_firstLetter,
CSSPseudoElementType::firstLetter,
aStyleContext,
nullptr);
}
@@ -9629,7 +9630,7 @@ nsCSSFrameConstructor::GetFirstLineStyle(nsIContent* aContent,
if (aContent) {
return mPresShell->StyleSet()->
ResolvePseudoElementStyle(aContent->AsElement(),
nsCSSPseudoElements::ePseudo_firstLine,
CSSPseudoElementType::firstLine,
aStyleContext,
nullptr);
}
@@ -9643,7 +9644,7 @@ nsCSSFrameConstructor::ShouldHaveFirstLetterStyle(nsIContent* aContent,
nsStyleContext* aStyleContext)
{
return nsLayoutUtils::HasPseudoStyle(aContent, aStyleContext,
nsCSSPseudoElements::ePseudo_firstLetter,
CSSPseudoElementType::firstLetter,
mPresShell->GetPresContext());
}
@@ -9663,7 +9664,7 @@ nsCSSFrameConstructor::ShouldHaveFirstLineStyle(nsIContent* aContent,
{
bool hasFirstLine =
nsLayoutUtils::HasPseudoStyle(aContent, aStyleContext,
nsCSSPseudoElements::ePseudo_firstLine,
CSSPseudoElementType::firstLine,
mPresShell->GetPresContext());
if (hasFirstLine) {
// But disable for fieldsets
@@ -10591,7 +10592,7 @@ nsCSSFrameConstructor::ProcessChildren(nsFrameConstructorState& aState,
nsFrame::CorrectStyleParentFrame(aFrame, nullptr)->StyleContext();
// Probe for generated content before
CreateGeneratedContentItem(aState, aFrame, aContent, styleContext,
nsCSSPseudoElements::ePseudo_before,
CSSPseudoElementType::before,
itemsToConstruct);
}
@@ -10639,7 +10640,7 @@ nsCSSFrameConstructor::ProcessChildren(nsFrameConstructorState& aState,
if (aCanHaveGeneratedContent) {
// Probe for generated content after
CreateGeneratedContentItem(aState, aFrame, aContent, styleContext,
nsCSSPseudoElements::ePseudo_after,
CSSPseudoElementType::after,
itemsToConstruct);
}
} else {
@@ -11889,7 +11890,7 @@ nsCSSFrameConstructor::BuildInlineChildItems(nsFrameConstructorState& aState,
if (!aItemIsWithinSVGText) {
// Probe for generated content before
CreateGeneratedContentItem(aState, nullptr, parentContent, parentStyleContext,
nsCSSPseudoElements::ePseudo_before,
CSSPseudoElementType::before,
aParentItem.mChildItems);
}
@@ -11959,7 +11960,7 @@ nsCSSFrameConstructor::BuildInlineChildItems(nsFrameConstructorState& aState,
if (!aItemIsWithinSVGText) {
// Probe for generated content after
CreateGeneratedContentItem(aState, nullptr, parentContent, parentStyleContext,
nsCSSPseudoElements::ePseudo_after,
CSSPseudoElementType::after,
aParentItem.mChildItems);
}
+2 -2
View File
@@ -17,7 +17,6 @@
#include "nsILayoutHistoryState.h"
#include "nsQuoteList.h"
#include "nsCounterManager.h"
#include "nsCSSPseudoElements.h"
#include "nsIAnonymousContentCreator.h"
#include "nsFrameManager.h"
#include "nsIDocument.h"
@@ -51,6 +50,7 @@ class FlattenedChildIterator;
class nsCSSFrameConstructor : public nsFrameManager
{
public:
typedef mozilla::CSSPseudoElementType CSSPseudoElementType;
typedef mozilla::dom::Element Element;
friend class mozilla::RestyleManager;
@@ -452,7 +452,7 @@ private:
nsContainerFrame* aFrame,
nsIContent* aContent,
nsStyleContext* aStyleContext,
nsCSSPseudoElements::Type aPseudoElement,
CSSPseudoElementType aPseudoElement,
FrameConstructionItemList& aItems);
// This method can change aFrameList: it can chop off the beginning and put
+1 -1
View File
@@ -858,7 +858,7 @@ nsCSSRendering::PaintOutline(nsPresContext* aPresContext,
nsRect innerRect;
if (
#ifdef MOZ_XUL
aStyleContext->GetPseudoType() == nsCSSPseudoElements::ePseudo_XULTree
aStyleContext->GetPseudoType() == CSSPseudoElementType::XULTree
#else
false
#endif
+2 -2
View File
@@ -1424,7 +1424,7 @@ nsLayoutUtils::GetStyleFrame(nsIFrame* aFrame)
{
if (aFrame->GetType() == nsGkAtoms::tableOuterFrame) {
nsIFrame* inner = aFrame->PrincipalChildList().FirstChild();
NS_ASSERTION(inner, "Outer table must have an inner");
// inner may be null, if aFrame is mid-destruction
return inner;
}
@@ -1983,7 +1983,7 @@ nsLayoutUtils::GetScrolledRect(nsIFrame* aScrolledFrame,
bool
nsLayoutUtils::HasPseudoStyle(nsIContent* aContent,
nsStyleContext* aStyleContext,
nsCSSPseudoElements::Type aPseudoElement,
CSSPseudoElementType aPseudoElement,
nsPresContext* aPresContext)
{
NS_PRECONDITION(aPresContext, "Must have a prescontext");
+8 -3
View File
@@ -16,7 +16,6 @@
#include "mozilla/layout/FrameChildList.h"
#include "nsThreadUtils.h"
#include "nsIPrincipal.h"
#include "nsCSSPseudoElements.h"
#include "FrameMetrics.h"
#include "nsIWidget.h"
#include "nsCSSProperty.h"
@@ -62,6 +61,7 @@ struct nsStyleImageOrientation;
struct nsOverflowAreas;
namespace mozilla {
enum class CSSPseudoElementType : uint8_t;
class EventListenerManager;
class SVGImageContext;
struct IntrinsicSize;
@@ -325,6 +325,10 @@ public:
* return the frame that has the non-psuedoelement style context for
* the content.
* This is aPrimaryFrame itself except for tableOuter frames.
*
* Given a non-null input, this will return null if and only if its
* argument is a table outer frame that is mid-destruction (and its
* table frame has been destroyed).
*/
static nsIFrame* GetStyleFrame(nsIFrame* aPrimaryFrame);
@@ -651,7 +655,7 @@ public:
*/
static bool HasPseudoStyle(nsIContent* aContent,
nsStyleContext* aStyleContext,
nsCSSPseudoElements::Type aPseudoElement,
mozilla::CSSPseudoElementType aPseudoElement,
nsPresContext* aPresContext);
/**
@@ -2254,7 +2258,8 @@ public:
*/
static bool GetAnimationContent(const nsIFrame* aFrame,
nsIContent* &aContentResult,
nsCSSPseudoElements::Type &aPseudoTypeResult);
mozilla::CSSPseudoElementType
&aPseudoTypeResult);
/**
* Returns true if the frame has current (i.e. running or scheduled-to-run)
+2 -2
View File
@@ -465,13 +465,13 @@ nsButtonFrameRenderer::ReResolveStyles(nsPresContext* aPresContext)
// style for the inner such as a dotted line (Windows)
mInnerFocusStyle =
styleSet->ProbePseudoElementStyle(mFrame->GetContent()->AsElement(),
nsCSSPseudoElements::ePseudo_mozFocusInner,
CSSPseudoElementType::mozFocusInner,
context);
// style for outer focus like a ridged border (MAC).
mOuterFocusStyle =
styleSet->ProbePseudoElementStyle(mFrame->GetContent()->AsElement(),
nsCSSPseudoElements::ePseudo_mozFocusOuter,
CSSPseudoElementType::mozFocusOuter,
context);
#ifdef DEBUG
+4 -3
View File
@@ -8,6 +8,7 @@
#include "nsContentCreatorFunctions.h"
#include "nsContentList.h"
#include "nsContentUtils.h"
#include "nsCSSPseudoElements.h"
#include "nsFormControlFrame.h"
#include "nsGkAtoms.h"
#include "nsIDOMHTMLInputElement.h"
@@ -72,7 +73,7 @@ nsColorControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
nsresult rv = UpdateColor();
NS_ENSURE_SUCCESS(rv, rv);
nsCSSPseudoElements::Type pseudoType = nsCSSPseudoElements::ePseudo_mozColorSwatch;
CSSPseudoElementType pseudoType = CSSPseudoElementType::mozColorSwatch;
RefPtr<nsStyleContext> newStyleContext = PresContext()->StyleSet()->
ResolvePseudoElementStyle(mContent->AsElement(), pseudoType,
StyleContext(), mColorContent->AsElement());
@@ -135,9 +136,9 @@ nsColorControlFrame::GetContentInsertionFrame()
}
Element*
nsColorControlFrame::GetPseudoElement(nsCSSPseudoElements::Type aType)
nsColorControlFrame::GetPseudoElement(CSSPseudoElementType aType)
{
if (aType == nsCSSPseudoElements::ePseudo_mozColorSwatch) {
if (aType == CSSPseudoElementType::mozColorSwatch) {
return mColorContent;
}
+6 -1
View File
@@ -10,6 +10,10 @@
#include "nsHTMLButtonControlFrame.h"
#include "nsIAnonymousContentCreator.h"
namespace mozilla {
enum class CSSPseudoElementType : uint8_t;
} // namespace mozilla
typedef nsHTMLButtonControlFrame nsColorControlFrameSuper;
// Class which implements the input type=color
@@ -17,6 +21,7 @@ typedef nsHTMLButtonControlFrame nsColorControlFrameSuper;
class nsColorControlFrame final : public nsColorControlFrameSuper,
public nsIAnonymousContentCreator
{
typedef mozilla::CSSPseudoElementType CSSPseudoElementType;
typedef mozilla::dom::Element Element;
public:
@@ -47,7 +52,7 @@ public:
virtual bool IsLeaf() const override { return true; }
virtual nsContainerFrame* GetContentInsertionFrame() override;
virtual Element* GetPseudoElement(nsCSSPseudoElements::Type aType) override;
virtual Element* GetPseudoElement(CSSPseudoElementType aType) override;
// Refresh the color swatch, using associated input's value
nsresult UpdateColor();
+4 -3
View File
@@ -19,6 +19,7 @@
#include "mozilla/dom/Element.h"
#include "mozilla/dom/HTMLMeterElement.h"
#include "nsContentList.h"
#include "nsCSSPseudoElements.h"
#include "nsStyleSet.h"
#include "nsThemeConstants.h"
#include <algorithm>
@@ -72,7 +73,7 @@ nsMeterFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
mBarDiv = doc->CreateHTMLElement(nsGkAtoms::div);
// Associate ::-moz-meter-bar pseudo-element to the anonymous child.
nsCSSPseudoElements::Type pseudoType = nsCSSPseudoElements::ePseudo_mozMeterBar;
CSSPseudoElementType pseudoType = CSSPseudoElementType::mozMeterBar;
RefPtr<nsStyleContext> newStyleContext = PresContext()->StyleSet()->
ResolvePseudoElementStyle(mContent->AsElement(), pseudoType,
StyleContext(), mBarDiv->AsElement());
@@ -287,9 +288,9 @@ nsMeterFrame::ShouldUseNativeStyle() const
}
Element*
nsMeterFrame::GetPseudoElement(nsCSSPseudoElements::Type aType)
nsMeterFrame::GetPseudoElement(CSSPseudoElementType aType)
{
if (aType == nsCSSPseudoElements::ePseudo_mozMeterBar) {
if (aType == CSSPseudoElementType::mozMeterBar) {
return mBarDiv;
}
+1 -1
View File
@@ -75,7 +75,7 @@ public:
*/
bool ShouldUseNativeStyle() const;
virtual Element* GetPseudoElement(nsCSSPseudoElements::Type aType) override;
virtual Element* GetPseudoElement(CSSPseudoElementType aType) override;
protected:
// Helper function which reflow the anonymous div frame.
+16 -15
View File
@@ -20,6 +20,7 @@
#include "nsContentUtils.h"
#include "nsContentCreatorFunctions.h"
#include "nsContentList.h"
#include "nsCSSPseudoElements.h"
#include "nsStyleSet.h"
#include "nsIDOMMutationEvent.h"
#include "nsThreadUtils.h"
@@ -323,7 +324,7 @@ nsresult
nsNumberControlFrame::MakeAnonymousElement(Element** aResult,
nsTArray<ContentInfo>& aElements,
nsIAtom* aTagName,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
nsStyleContext* aParentContext)
{
// Get the NodeInfoManager and tag necessary to create the anonymous divs.
@@ -334,7 +335,7 @@ nsNumberControlFrame::MakeAnonymousElement(Element** aResult,
// non-pseudo-element anonymous children, then we'll need to add a branch
// that calls ResolveStyleFor((*aResult)->AsElement(), aParentContext)") to
// set newStyleContext.
NS_ASSERTION(aPseudoType != nsCSSPseudoElements::ePseudo_NotPseudoElement,
NS_ASSERTION(aPseudoType != CSSPseudoElementType::NotPseudo,
"Expecting anonymous children to all be pseudo-elements");
// Associate the pseudo-element with the anonymous child
RefPtr<nsStyleContext> newStyleContext =
@@ -347,8 +348,8 @@ nsNumberControlFrame::MakeAnonymousElement(Element** aResult,
return NS_ERROR_OUT_OF_MEMORY;
}
if (aPseudoType == nsCSSPseudoElements::ePseudo_mozNumberSpinDown ||
aPseudoType == nsCSSPseudoElements::ePseudo_mozNumberSpinUp) {
if (aPseudoType == CSSPseudoElementType::mozNumberSpinDown ||
aPseudoType == CSSPseudoElementType::mozNumberSpinUp) {
resultElement->SetAttr(kNameSpaceID_None, nsGkAtoms::role,
NS_LITERAL_STRING("button"), false);
}
@@ -380,7 +381,7 @@ nsNumberControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
rv = MakeAnonymousElement(getter_AddRefs(mOuterWrapper),
aElements,
nsGkAtoms::div,
nsCSSPseudoElements::ePseudo_mozNumberWrapper,
CSSPseudoElementType::mozNumberWrapper,
mStyleContext);
NS_ENSURE_SUCCESS(rv, rv);
@@ -390,7 +391,7 @@ nsNumberControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
rv = MakeAnonymousElement(getter_AddRefs(mTextField),
outerWrapperCI.mChildren,
nsGkAtoms::input,
nsCSSPseudoElements::ePseudo_mozNumberText,
CSSPseudoElementType::mozNumberText,
outerWrapperCI.mStyleContext);
NS_ENSURE_SUCCESS(rv, rv);
@@ -440,7 +441,7 @@ nsNumberControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
rv = MakeAnonymousElement(getter_AddRefs(mSpinBox),
outerWrapperCI.mChildren,
nsGkAtoms::div,
nsCSSPseudoElements::ePseudo_mozNumberSpinBox,
CSSPseudoElementType::mozNumberSpinBox,
outerWrapperCI.mStyleContext);
NS_ENSURE_SUCCESS(rv, rv);
@@ -450,7 +451,7 @@ nsNumberControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
rv = MakeAnonymousElement(getter_AddRefs(mSpinUp),
spinBoxCI.mChildren,
nsGkAtoms::div,
nsCSSPseudoElements::ePseudo_mozNumberSpinUp,
CSSPseudoElementType::mozNumberSpinUp,
spinBoxCI.mStyleContext);
NS_ENSURE_SUCCESS(rv, rv);
@@ -458,7 +459,7 @@ nsNumberControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
rv = MakeAnonymousElement(getter_AddRefs(mSpinDown),
spinBoxCI.mChildren,
nsGkAtoms::div,
nsCSSPseudoElements::ePseudo_mozNumberSpinDown,
CSSPseudoElementType::mozNumberSpinDown,
spinBoxCI.mStyleContext);
return rv;
@@ -826,27 +827,27 @@ nsNumberControlFrame::AnonTextControlIsEmpty()
}
Element*
nsNumberControlFrame::GetPseudoElement(nsCSSPseudoElements::Type aType)
nsNumberControlFrame::GetPseudoElement(CSSPseudoElementType aType)
{
if (aType == nsCSSPseudoElements::ePseudo_mozNumberWrapper) {
if (aType == CSSPseudoElementType::mozNumberWrapper) {
return mOuterWrapper;
}
if (aType == nsCSSPseudoElements::ePseudo_mozNumberText) {
if (aType == CSSPseudoElementType::mozNumberText) {
return mTextField;
}
if (aType == nsCSSPseudoElements::ePseudo_mozNumberSpinBox) {
if (aType == CSSPseudoElementType::mozNumberSpinBox) {
// Might be null.
return mSpinBox;
}
if (aType == nsCSSPseudoElements::ePseudo_mozNumberSpinUp) {
if (aType == CSSPseudoElementType::mozNumberSpinUp) {
// Might be null.
return mSpinUp;
}
if (aType == nsCSSPseudoElements::ePseudo_mozNumberSpinDown) {
if (aType == CSSPseudoElementType::mozNumberSpinDown) {
// Might be null.
return mSpinDown;
}
+4 -2
View File
@@ -16,6 +16,7 @@
class nsPresContext;
namespace mozilla {
enum class CSSPseudoElementType : uint8_t;
class WidgetEvent;
class WidgetGUIEvent;
namespace dom {
@@ -33,6 +34,7 @@ class nsNumberControlFrame final : public nsContainerFrame
friend nsIFrame*
NS_NewNumberControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
typedef mozilla::CSSPseudoElementType CSSPseudoElementType;
typedef mozilla::dom::Element Element;
typedef mozilla::dom::HTMLInputElement HTMLInputElement;
typedef mozilla::WidgetEvent WidgetEvent;
@@ -186,7 +188,7 @@ public:
*/
nsresult HandleSelectCall();
virtual Element* GetPseudoElement(nsCSSPseudoElements::Type aType) override;
virtual Element* GetPseudoElement(CSSPseudoElementType aType) override;
bool ShouldUseNativeStyleForSpinner() const;
@@ -196,7 +198,7 @@ private:
nsresult MakeAnonymousElement(Element** aResult,
nsTArray<ContentInfo>& aElements,
nsIAtom* aTagName,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
nsStyleContext* aParentContext);
class SyncDisabledStateEvent;
+4 -3
View File
@@ -19,6 +19,7 @@
#include "mozilla/dom/Element.h"
#include "mozilla/dom/HTMLProgressElement.h"
#include "nsContentList.h"
#include "nsCSSPseudoElements.h"
#include "nsStyleSet.h"
#include "nsThemeConstants.h"
#include <algorithm>
@@ -69,7 +70,7 @@ nsProgressFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
mBarDiv = doc->CreateHTMLElement(nsGkAtoms::div);
// Associate ::-moz-progress-bar pseudo-element to the anonymous child.
nsCSSPseudoElements::Type pseudoType = nsCSSPseudoElements::ePseudo_mozProgressBar;
CSSPseudoElementType pseudoType = CSSPseudoElementType::mozProgressBar;
RefPtr<nsStyleContext> newStyleContext = PresContext()->StyleSet()->
ResolvePseudoElementStyle(mContent->AsElement(), pseudoType,
StyleContext(), mBarDiv->AsElement());
@@ -293,9 +294,9 @@ nsProgressFrame::ShouldUseNativeStyle() const
}
Element*
nsProgressFrame::GetPseudoElement(nsCSSPseudoElements::Type aType)
nsProgressFrame::GetPseudoElement(CSSPseudoElementType aType)
{
if (aType == nsCSSPseudoElements::ePseudo_mozProgressBar) {
if (aType == CSSPseudoElementType::mozProgressBar) {
return mBarDiv;
}
+6 -1
View File
@@ -11,9 +11,14 @@
#include "nsIAnonymousContentCreator.h"
#include "nsCOMPtr.h"
namespace mozilla {
enum class CSSPseudoElementType : uint8_t;
} // namespace mozilla
class nsProgressFrame : public nsContainerFrame,
public nsIAnonymousContentCreator
{
typedef mozilla::CSSPseudoElementType CSSPseudoElementType;
typedef mozilla::dom::Element Element;
public:
@@ -78,7 +83,7 @@ public:
*/
bool ShouldUseNativeStyle() const;
virtual Element* GetPseudoElement(nsCSSPseudoElements::Type aType) override;
virtual Element* GetPseudoElement(CSSPseudoElementType aType) override;
protected:
// Helper function which reflow the anonymous div frame.
+10 -9
View File
@@ -11,6 +11,7 @@
#include "nsContentCreatorFunctions.h"
#include "nsContentList.h"
#include "nsContentUtils.h"
#include "nsCSSPseudoElements.h"
#include "nsCSSRendering.h"
#include "nsFormControlFrame.h"
#include "nsIContent.h"
@@ -86,7 +87,7 @@ nsRangeFrame::Init(nsIContent* aContent,
mOuterFocusStyle =
styleSet->ProbePseudoElementStyle(aContent->AsElement(),
nsCSSPseudoElements::ePseudo_mozFocusOuter,
CSSPseudoElementType::mozFocusOuter,
StyleContext());
return nsContainerFrame::Init(aContent, aParent, aPrevInFlow);
@@ -110,7 +111,7 @@ nsRangeFrame::DestroyFrom(nsIFrame* aDestructRoot)
nsresult
nsRangeFrame::MakeAnonymousDiv(Element** aResult,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
nsTArray<ContentInfo>& aElements)
{
nsCOMPtr<nsIDocument> doc = mContent->GetComposedDoc();
@@ -138,19 +139,19 @@ nsRangeFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
// Create the ::-moz-range-track pseuto-element (a div):
rv = MakeAnonymousDiv(getter_AddRefs(mTrackDiv),
nsCSSPseudoElements::ePseudo_mozRangeTrack,
CSSPseudoElementType::mozRangeTrack,
aElements);
NS_ENSURE_SUCCESS(rv, rv);
// Create the ::-moz-range-progress pseudo-element (a div):
rv = MakeAnonymousDiv(getter_AddRefs(mProgressDiv),
nsCSSPseudoElements::ePseudo_mozRangeProgress,
CSSPseudoElementType::mozRangeProgress,
aElements);
NS_ENSURE_SUCCESS(rv, rv);
// Create the ::-moz-range-thumb pseudo-element (a div):
rv = MakeAnonymousDiv(getter_AddRefs(mThumbDiv),
nsCSSPseudoElements::ePseudo_mozRangeThumb,
CSSPseudoElementType::mozRangeThumb,
aElements);
return rv;
}
@@ -894,17 +895,17 @@ nsRangeFrame::ShouldUseNativeStyle() const
}
Element*
nsRangeFrame::GetPseudoElement(nsCSSPseudoElements::Type aType)
nsRangeFrame::GetPseudoElement(CSSPseudoElementType aType)
{
if (aType == nsCSSPseudoElements::ePseudo_mozRangeTrack) {
if (aType == CSSPseudoElementType::mozRangeTrack) {
return mTrackDiv;
}
if (aType == nsCSSPseudoElements::ePseudo_mozRangeThumb) {
if (aType == CSSPseudoElementType::mozRangeThumb) {
return mThumbDiv;
}
if (aType == nsCSSPseudoElements::ePseudo_mozRangeProgress) {
if (aType == CSSPseudoElementType::mozRangeProgress) {
return mProgressDiv;
}
+3 -2
View File
@@ -27,6 +27,7 @@ class nsRangeFrame : public nsContainerFrame,
explicit nsRangeFrame(nsStyleContext* aContext);
virtual ~nsRangeFrame();
typedef mozilla::CSSPseudoElementType CSSPseudoElementType;
typedef mozilla::dom::Element Element;
public:
@@ -147,12 +148,12 @@ public:
*/
void UpdateForValueChange();
virtual Element* GetPseudoElement(nsCSSPseudoElements::Type aType) override;
virtual Element* GetPseudoElement(CSSPseudoElementType aType) override;
private:
nsresult MakeAnonymousDiv(Element** aResult,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
nsTArray<ContentInfo>& aElements);
// Helper function which reflows the anonymous div frames.
+4 -4
View File
@@ -10,6 +10,7 @@
#include "nsTextControlFrame.h"
#include "nsIPlaintextEditor.h"
#include "nsCaret.h"
#include "nsCSSPseudoElements.h"
#include "nsGenericHTMLElement.h"
#include "nsIEditor.h"
#include "nsIEditorIMESupport.h"
@@ -346,8 +347,7 @@ nsTextControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
NS_ENSURE_TRUE(placeholderNode, NS_ERROR_OUT_OF_MEMORY);
// Associate ::-moz-placeholder pseudo-element with the placeholder node.
nsCSSPseudoElements::Type pseudoType =
nsCSSPseudoElements::ePseudo_mozPlaceholder;
CSSPseudoElementType pseudoType = CSSPseudoElementType::mozPlaceholder;
RefPtr<nsStyleContext> placeholderStyleContext =
PresContext()->StyleSet()->ResolvePseudoElementStyle(
@@ -1444,9 +1444,9 @@ nsTextControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
}
mozilla::dom::Element*
nsTextControlFrame::GetPseudoElement(nsCSSPseudoElements::Type aType)
nsTextControlFrame::GetPseudoElement(CSSPseudoElementType aType)
{
if (aType == nsCSSPseudoElements::ePseudo_mozPlaceholder) {
if (aType == CSSPseudoElementType::mozPlaceholder) {
nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent());
return txtCtrl->GetPlaceholderNode();
}
+4 -2
View File
@@ -19,6 +19,7 @@ class EditorInitializerEntryTracker;
class nsTextEditorState;
class nsIEditor;
namespace mozilla {
enum class CSSPseudoElementType : uint8_t;
namespace dom {
class Element;
} // namespace dom
@@ -98,10 +99,11 @@ public:
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists) override;
virtual mozilla::dom::Element* GetPseudoElement(nsCSSPseudoElements::Type aType) override;
virtual mozilla::dom::Element*
GetPseudoElement(mozilla::CSSPseudoElementType aType) override;
//==== BEGIN NSIFORMCONTROLFRAME
virtual void SetFocus(bool aOn , bool aRepaint) override;
virtual void SetFocus(bool aOn , bool aRepaint) override;
virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue) override;
//==== END NSIFORMCONTROLFRAME
+3 -3
View File
@@ -6911,9 +6911,9 @@ nsBlockFrame::CreateBulletFrameForListItem(bool aCreateBulletList,
{
nsIPresShell* shell = PresContext()->PresShell();
nsCSSPseudoElements::Type pseudoType = aCreateBulletList ?
nsCSSPseudoElements::ePseudo_mozListBullet :
nsCSSPseudoElements::ePseudo_mozListNumber;
CSSPseudoElementType pseudoType = aCreateBulletList ?
CSSPseudoElementType::mozListBullet :
CSSPseudoElementType::mozListNumber;
nsStyleContext* parentStyle =
CorrectStyleParentFrame(this,
+1 -1
View File
@@ -366,7 +366,7 @@ protected:
{
return aPresContext->StyleSet()->
ProbePseudoElementStyle(mContent->AsElement(),
nsCSSPseudoElements::ePseudo_firstLetter,
mozilla::CSSPseudoElementType::firstLetter,
mStyleContext);
}
#endif
+5 -4
View File
@@ -25,6 +25,7 @@
#include "nsIContent.h"
#include "nsIContentInlines.h"
#include "nsContentUtils.h"
#include "nsCSSPseudoElements.h"
#include "nsIAtom.h"
#include "nsString.h"
#include "nsReadableUtils.h"
@@ -9096,13 +9097,13 @@ nsIFrame::IsPseudoStackingContextFromStyle() {
}
Element*
nsIFrame::GetPseudoElement(nsCSSPseudoElements::Type aType)
nsIFrame::GetPseudoElement(CSSPseudoElementType aType)
{
nsIFrame* frame = nullptr;
if (aType == nsCSSPseudoElements::ePseudo_before) {
if (aType == CSSPseudoElementType::before) {
frame = nsLayoutUtils::GetBeforeFrame(this);
} else if (aType == nsCSSPseudoElements::ePseudo_after) {
} else if (aType == CSSPseudoElementType::after) {
frame = nsLayoutUtils::GetAfterFrame(this);
}
@@ -9112,7 +9113,7 @@ nsIFrame::GetPseudoElement(nsCSSPseudoElements::Type aType)
return content->AsElement();
}
}
return nullptr;
}
+3 -1
View File
@@ -90,6 +90,7 @@ struct CharacterDataChangeInfo;
namespace mozilla {
enum class CSSPseudoElementType : uint8_t;
class EventStates;
namespace layers {
@@ -3098,7 +3099,8 @@ public:
* generated and which corresponds to the specified pseudo-element type,
* or nullptr if there is no such anonymous content.
*/
virtual mozilla::dom::Element* GetPseudoElement(nsCSSPseudoElements::Type aType);
virtual mozilla::dom::Element*
GetPseudoElement(mozilla::CSSPseudoElementType aType);
bool BackfaceIsHidden() {
return StyleDisplay()->BackfaceIsHidden();
+1 -1
View File
@@ -3809,7 +3809,7 @@ nsTextPaintStyle::InitSelectionColorsAndShadow()
RefPtr<nsStyleContext> sc = nullptr;
sc = mPresContext->StyleSet()->
ProbePseudoElementStyle(selectionElement,
nsCSSPseudoElements::ePseudo_mozSelection,
CSSPseudoElementType::mozSelection,
mFrame->StyleContext());
// Use -moz-selection pseudo class.
if (sc) {
+3 -2
View File
@@ -1194,8 +1194,9 @@ inDOMUtils::GetCSSPseudoElementNames(uint32_t* aLength, char16_t*** aNames)
{
nsTArray<nsIAtom*> array;
for (int i = 0; i < nsCSSPseudoElements::ePseudo_PseudoElementCount; ++i) {
nsCSSPseudoElements::Type type = static_cast<nsCSSPseudoElements::Type>(i);
const uint8_t pseudoCount = static_cast<uint8_t>(CSSPseudoElementType::Count);
for (uint8_t i = 0; i < pseudoCount; ++i) {
CSSPseudoElementType type = static_cast<CSSPseudoElementType>(i);
if (!nsCSSPseudoElements::PseudoElementIsUASheetOnly(type)) {
nsIAtom* atom = nsCSSPseudoElements::GetPseudoAtom(type);
array.AppendElement(atom);
+2 -2
View File
@@ -98,8 +98,8 @@ nsMathMLFrame::ResolveMathMLCharStyle(nsPresContext* aPresContext,
nsStyleContext* aParentStyleContext,
nsMathMLChar* aMathMLChar)
{
nsCSSPseudoElements::Type pseudoType =
nsCSSPseudoElements::ePseudo_mozMathAnonymous; // savings
CSSPseudoElementType pseudoType =
CSSPseudoElementType::mozMathAnonymous; // savings
RefPtr<nsStyleContext> newStyleContext;
newStyleContext = aPresContext->StyleSet()->
ResolvePseudoElementStyle(aContent->AsElement(), pseudoType,
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<title>Testcase for bug 1245075</title>
<style>
#test {
width: 100px; height: 100px;
background: rgb(102, 102, 255);
}
</style>
<div id="test"></div>
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<title>Testcase for bug 1245075</title>
<style>
@keyframes HoldOpacity {
from, to { opacity: 0.6 }
}
#test {
width: 100px; height: 100px;
background: blue;
display: table;
animation: HoldOpacity 100s linear infinite;
}
</style>
<div id="test"></div>
@@ -4,3 +4,4 @@ fails == print-no-animations.html print-no-animations-ref.html # reftest harness
fails != print-no-animations.html print-no-animations-notref.html # reftest harness doesn't actually make pres context non-dynamic for reftest-print tests
== animate-opacity.html animate-opacity-ref.html
== animate-preserves3d.html animate-preserves3d-ref.html
== animate-display-table-opacity.html animate-display-table-opacity-ref.html
+3
View File
@@ -355,6 +355,9 @@ include unicode/reftest.list
include view-source/reftest.list
# web-animations
include web-animations/reftest.list
# webcomponents/
include webcomponents/reftest.list
@@ -0,0 +1,25 @@
<!doctype html>
<html class="reftest-wait">
<head>
<meta charset=utf-8>
<title>Bug 1246046</title>
<style>
div {
width: 0px;
height: 100px;
background: green;
}
</style>
</head>
<body>
<div></div>
<script>
var target = document.querySelector("div");
var anim = target.animate(
[ { width: "0px" }, { width: "200px" } ], 2000);
anim.pause();
anim.currentTime = 1000;
document.documentElement.removeAttribute("class");
</script>
</body>
</html>
@@ -0,0 +1,17 @@
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<title>Reference green box</title>
<style>
div {
width: 100px;
height: 100px;
background: green;
}
</style>
</head>
<body>
<div></div>
</body>
</html>
@@ -0,0 +1 @@
== 1246046-1.html green-box.html
+12 -130
View File
@@ -68,7 +68,7 @@ CommonAnimationManager::RemoveAllElementCollections()
AnimationCollection*
CommonAnimationManager::GetAnimationCollection(dom::Element *aElement,
nsCSSPseudoElements::Type
CSSPseudoElementType
aPseudoType,
bool aCreateIfNeeded)
{
@@ -78,11 +78,11 @@ CommonAnimationManager::GetAnimationCollection(dom::Element *aElement,
}
nsIAtom *propName;
if (aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement) {
if (aPseudoType == CSSPseudoElementType::NotPseudo) {
propName = GetAnimationsAtom();
} else if (aPseudoType == nsCSSPseudoElements::ePseudo_before) {
} else if (aPseudoType == CSSPseudoElementType::before) {
propName = GetAnimationsBeforeAtom();
} else if (aPseudoType == nsCSSPseudoElements::ePseudo_after) {
} else if (aPseudoType == CSSPseudoElementType::after) {
propName = GetAnimationsAfterAtom();
} else {
NS_ASSERTION(!aCreateIfNeeded,
@@ -105,9 +105,8 @@ CommonAnimationManager::GetAnimationCollection(dom::Element *aElement,
AnimationCollection::PropertyDtor(aElement, propName, collection, nullptr);
return nullptr;
}
if (aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement) {
aElement->SetMayHaveAnimations();
}
aElement->SetMayHaveAnimations();
AddElementCollection(collection);
}
@@ -118,15 +117,13 @@ CommonAnimationManager::GetAnimationCollection(dom::Element *aElement,
AnimationCollection*
CommonAnimationManager::GetAnimationCollection(const nsIFrame* aFrame)
{
Maybe<Pair<dom::Element*, nsCSSPseudoElements::Type>> pseudoElement =
Maybe<Pair<dom::Element*, CSSPseudoElementType>> pseudoElement =
EffectCompositor::GetAnimationElementAndPseudoForFrame(aFrame);
if (!pseudoElement) {
return nullptr;
}
if (pseudoElement->second() ==
nsCSSPseudoElements::ePseudo_NotPseudoElement &&
!pseudoElement->first()->MayHaveAnimations()) {
if (!pseudoElement->first()->MayHaveAnimations()) {
return nullptr;
}
@@ -135,121 +132,6 @@ CommonAnimationManager::GetAnimationCollection(const nsIFrame* aFrame)
false /* aCreateIfNeeded */);
}
nsRestyleHint
CommonAnimationManager::HasStateDependentStyle(StateRuleProcessorData* aData)
{
return nsRestyleHint(0);
}
nsRestyleHint
CommonAnimationManager::HasStateDependentStyle(PseudoElementStateRuleProcessorData* aData)
{
return nsRestyleHint(0);
}
bool
CommonAnimationManager::HasDocumentStateDependentStyle(StateRuleProcessorData* aData)
{
return false;
}
nsRestyleHint
CommonAnimationManager::HasAttributeDependentStyle(
AttributeRuleProcessorData* aData,
RestyleHintData& aRestyleHintDataResult)
{
return nsRestyleHint(0);
}
/* virtual */ bool
CommonAnimationManager::MediumFeaturesChanged(nsPresContext* aPresContext)
{
return false;
}
/* virtual */ void
CommonAnimationManager::RulesMatching(ElementRuleProcessorData* aData)
{
MOZ_ASSERT(aData->mPresContext == mPresContext,
"pres context mismatch");
EffectCompositor::CascadeLevel cascadeLevel =
IsAnimationManager() ?
EffectCompositor::CascadeLevel::Animations :
EffectCompositor::CascadeLevel::Transitions;
nsCSSPseudoElements::Type pseudoType =
nsCSSPseudoElements::ePseudo_NotPseudoElement;
nsIStyleRule *rule =
mPresContext->EffectCompositor()->GetAnimationRule(aData->mElement,
pseudoType,
cascadeLevel);
if (rule) {
aData->mRuleWalker->Forward(rule);
aData->mRuleWalker->CurrentNode()->SetIsAnimationRule();
}
}
/* virtual */ void
CommonAnimationManager::RulesMatching(PseudoElementRuleProcessorData* aData)
{
MOZ_ASSERT(aData->mPresContext == mPresContext,
"pres context mismatch");
if (aData->mPseudoType != nsCSSPseudoElements::ePseudo_before &&
aData->mPseudoType != nsCSSPseudoElements::ePseudo_after) {
return;
}
// FIXME: Do we really want to be the only thing keeping a
// pseudo-element alive? I *think* the non-animation restyle should
// handle that, but should add a test.
EffectCompositor::CascadeLevel cascadeLevel =
IsAnimationManager() ?
EffectCompositor::CascadeLevel::Animations :
EffectCompositor::CascadeLevel::Transitions;
nsIStyleRule *rule =
mPresContext->EffectCompositor()->GetAnimationRule(aData->mElement,
aData->mPseudoType,
cascadeLevel);
if (rule) {
aData->mRuleWalker->Forward(rule);
aData->mRuleWalker->CurrentNode()->SetIsAnimationRule();
}
}
/* virtual */ void
CommonAnimationManager::RulesMatching(AnonBoxRuleProcessorData* aData)
{
}
#ifdef MOZ_XUL
/* virtual */ void
CommonAnimationManager::RulesMatching(XULTreeRuleProcessorData* aData)
{
}
#endif
/* virtual */ size_t
CommonAnimationManager::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
{
// Measurement of the following members may be added later if DMD finds it is
// worthwhile:
// - mElementCollections
//
// The following members are not measured
// - mPresContext, because it's non-owning
return 0;
}
/* virtual */ size_t
CommonAnimationManager::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
{
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}
/* static */ bool
CommonAnimationManager::ExtractComputedValueForTransition(
nsCSSProperty aProperty,
@@ -270,15 +152,15 @@ CommonAnimationManager::ExtractComputedValueForTransition(
}
/*static*/ nsString
AnimationCollection::PseudoTypeAsString(nsCSSPseudoElements::Type aPseudoType)
AnimationCollection::PseudoTypeAsString(CSSPseudoElementType aPseudoType)
{
switch (aPseudoType) {
case nsCSSPseudoElements::ePseudo_before:
case CSSPseudoElementType::before:
return NS_LITERAL_STRING("::before");
case nsCSSPseudoElements::ePseudo_after:
case CSSPseudoElementType::after:
return NS_LITERAL_STRING("::after");
default:
MOZ_ASSERT(aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement,
MOZ_ASSERT(aPseudoType == CSSPseudoElementType::NotPseudo,
"Unexpected pseudo type");
return EmptyString();
}
+14 -34
View File
@@ -7,7 +7,6 @@
#define mozilla_css_AnimationCommon_h
#include <algorithm> // For <std::stable_sort>
#include "nsIStyleRuleProcessor.h"
#include "nsChangeHint.h"
#include "nsCSSProperty.h"
#include "nsDisplayList.h" // For nsDisplayItem::Type
@@ -33,29 +32,10 @@ namespace mozilla {
struct AnimationCollection;
class CommonAnimationManager : public nsIStyleRuleProcessor {
class CommonAnimationManager {
public:
explicit CommonAnimationManager(nsPresContext *aPresContext);
// nsIStyleRuleProcessor (parts)
virtual nsRestyleHint HasStateDependentStyle(StateRuleProcessorData* aData) override;
virtual nsRestyleHint HasStateDependentStyle(PseudoElementStateRuleProcessorData* aData) override;
virtual bool HasDocumentStateDependentStyle(StateRuleProcessorData* aData) override;
virtual nsRestyleHint
HasAttributeDependentStyle(AttributeRuleProcessorData* aData,
RestyleHintData& aRestyleHintDataResult) override;
virtual bool MediumFeaturesChanged(nsPresContext* aPresContext) override;
virtual void RulesMatching(ElementRuleProcessorData* aData) override;
virtual void RulesMatching(PseudoElementRuleProcessorData* aData) override;
virtual void RulesMatching(AnonBoxRuleProcessorData* aData) override;
#ifdef MOZ_XUL
virtual void RulesMatching(XULTreeRuleProcessorData* aData) override;
#endif
virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf)
const MOZ_MUST_OVERRIDE override;
virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf)
const MOZ_MUST_OVERRIDE override;
// NOTE: This can return null after Disconnect().
nsPresContext* PresContext() const { return mPresContext; }
@@ -103,7 +83,7 @@ public:
// by this class for the given |aElement| and |aPseudoType|.
AnimationCollection*
GetAnimationCollection(dom::Element *aElement,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
bool aCreateIfNeeded);
// Given the frame |aFrame| with possibly animated content, finds its
@@ -194,20 +174,20 @@ public:
mElementProperty == nsGkAtoms::animationsOfAfterProperty;
}
nsCSSPseudoElements::Type PseudoElementType() const
CSSPseudoElementType PseudoElementType() const
{
if (IsForElement()) {
return nsCSSPseudoElements::ePseudo_NotPseudoElement;
return CSSPseudoElementType::NotPseudo;
}
if (IsForBeforePseudo()) {
return nsCSSPseudoElements::ePseudo_before;
return CSSPseudoElementType::before;
}
MOZ_ASSERT(IsForAfterPseudo(),
"::before & ::after should be the only pseudo-elements here");
return nsCSSPseudoElements::ePseudo_after;
return CSSPseudoElementType::after;
}
static nsString PseudoTypeAsString(nsCSSPseudoElements::Type aPseudoType);
static nsString PseudoTypeAsString(CSSPseudoElementType aPseudoType);
dom::Element* GetElementToRestyle() const;
@@ -255,11 +235,11 @@ class OwningElementRef final
public:
OwningElementRef()
: mElement(nullptr)
, mPseudoType(nsCSSPseudoElements::ePseudo_NotPseudoElement)
, mPseudoType(CSSPseudoElementType::NotPseudo)
{ }
OwningElementRef(dom::Element& aElement,
nsCSSPseudoElements::Type aPseudoType)
CSSPseudoElementType aPseudoType)
: mElement(&aElement)
, mPseudoType(aPseudoType)
{ }
@@ -279,15 +259,15 @@ public:
return nsContentUtils::PositionIsBefore(mElement, aOther.mElement);
}
return mPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement ||
(mPseudoType == nsCSSPseudoElements::ePseudo_before &&
aOther.mPseudoType == nsCSSPseudoElements::ePseudo_after);
return mPseudoType == CSSPseudoElementType::NotPseudo ||
(mPseudoType == CSSPseudoElementType::before &&
aOther.mPseudoType == CSSPseudoElementType::after);
}
bool IsSet() const { return !!mElement; }
void GetElement(dom::Element*& aElement,
nsCSSPseudoElements::Type& aPseudoType) const {
CSSPseudoElementType& aPseudoType) const {
aElement = mElement;
aPseudoType = mPseudoType;
}
@@ -296,7 +276,7 @@ public:
private:
dom::Element* MOZ_NON_OWNING_REF mElement;
nsCSSPseudoElements::Type mPseudoType;
CSSPseudoElementType mPseudoType;
};
template <class EventInfo>
+9 -9
View File
@@ -1123,10 +1123,10 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue,
AppendValueToString(eCSSProperty_grid_auto_flow,
aValue, aSerialization);
aValue.Append(char16_t(' '));
AppendValueToString(eCSSProperty_grid_auto_columns,
AppendValueToString(eCSSProperty_grid_auto_rows,
aValue, aSerialization);
aValue.AppendLiteral(" / ");
AppendValueToString(eCSSProperty_grid_auto_rows,
AppendValueToString(eCSSProperty_grid_auto_columns,
aValue, aSerialization);
break;
} else if (!(autoFlowValue.GetUnit() == eCSSUnit_Enumerated &&
@@ -1147,10 +1147,10 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue,
const nsCSSValue& rowsValue =
*data->ValueFor(eCSSProperty_grid_template_rows);
if (areasValue.GetUnit() == eCSSUnit_None) {
AppendValueToString(eCSSProperty_grid_template_columns,
AppendValueToString(eCSSProperty_grid_template_rows,
aValue, aSerialization);
aValue.AppendLiteral(" / ");
AppendValueToString(eCSSProperty_grid_template_rows,
AppendValueToString(eCSSProperty_grid_template_columns,
aValue, aSerialization);
break;
}
@@ -1188,11 +1188,6 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue,
// Not serializable, bail.
return;
}
if (columnsValue.GetUnit() != eCSSUnit_None) {
AppendValueToString(eCSSProperty_grid_template_columns,
aValue, aSerialization);
aValue.AppendLiteral(" / ");
}
rowsItem = rowsValue.GetListValue();
uint32_t row = 0;
for (;;) {
@@ -1234,6 +1229,11 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue,
aValue.Append(char16_t(' '));
}
}
if (columnsValue.GetUnit() != eCSSUnit_None) {
aValue.AppendLiteral(" / ");
AppendValueToString(eCSSProperty_grid_template_columns,
aValue, aSerialization);
}
break;
}
case eCSSProperty_grid_gap: {
+6 -5
View File
@@ -19,6 +19,7 @@
#include "nsStyleSet.h"
#include "nsComputedDOMStyle.h"
#include "nsCSSParser.h"
#include "nsCSSPseudoElements.h"
#include "mozilla/css/Declaration.h"
#include "mozilla/dom/Element.h"
#include "mozilla/FloatingPoint.h"
@@ -2526,7 +2527,7 @@ BuildStyleRule(nsCSSProperty aProperty,
inline
already_AddRefed<nsStyleContext>
LookupStyleContext(dom::Element* aElement,
nsCSSPseudoElements::Type aPseudoType)
CSSPseudoElementType aPseudoType)
{
nsIDocument* doc = aElement->GetCurrentDoc();
nsIPresShell* shell = doc->GetShell();
@@ -2535,7 +2536,7 @@ LookupStyleContext(dom::Element* aElement,
}
nsIAtom* pseudo =
aPseudoType < nsCSSPseudoElements::ePseudo_PseudoElementCount ?
aPseudoType < CSSPseudoElementType::Count ?
nsCSSPseudoElements::GetPseudoAtom(aPseudoType) : nullptr;
return nsComputedDOMStyle::GetStyleContextForElement(aElement, pseudo, shell);
}
@@ -2543,7 +2544,7 @@ LookupStyleContext(dom::Element* aElement,
/* static */ bool
StyleAnimationValue::ComputeValue(nsCSSProperty aProperty,
dom::Element* aTargetElement,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
const nsAString& aSpecifiedValue,
bool aUseSVGMode,
StyleAnimationValue& aComputedValue,
@@ -2595,7 +2596,7 @@ StyleAnimationValue::ComputeValue(nsCSSProperty aProperty,
StyleAnimationValue::ComputeValues(nsCSSProperty aProperty,
nsCSSProps::EnabledState aEnabledState,
dom::Element* aTargetElement,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
const nsAString& aSpecifiedValue,
bool aUseSVGMode,
nsTArray<PropertyStyleAnimationValuePair>& aResult)
@@ -2625,7 +2626,7 @@ StyleAnimationValue::ComputeValues(
nsCSSProperty aProperty,
nsCSSProps::EnabledState aEnabledState,
dom::Element* aTargetElement,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
css::StyleRule* aStyleRule,
nsTArray<PropertyStyleAnimationValuePair>& aValues,
bool* aIsContextSensitive)
+4 -4
View File
@@ -14,7 +14,6 @@
#include "nsCoord.h"
#include "nsColor.h"
#include "nsCSSProps.h"
#include "nsCSSPseudoElements.h"
#include "nsCSSValue.h"
class nsIFrame;
@@ -31,6 +30,7 @@ namespace dom {
class Element;
} // namespace dom
enum class CSSPseudoElementType : uint8_t;
struct PropertyStyleAnimationValuePair;
/**
@@ -156,7 +156,7 @@ public:
*/
static bool ComputeValue(nsCSSProperty aProperty,
mozilla::dom::Element* aTargetElement,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
const nsAString& aSpecifiedValue,
bool aUseSVGMode,
StyleAnimationValue& aComputedValue,
@@ -175,7 +175,7 @@ public:
static bool ComputeValues(nsCSSProperty aProperty,
nsCSSProps::EnabledState aEnabledState,
mozilla::dom::Element* aTargetElement,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
const nsAString& aSpecifiedValue,
bool aUseSVGMode,
nsTArray<PropertyStyleAnimationValuePair>& aResult);
@@ -403,7 +403,7 @@ private:
static bool ComputeValues(nsCSSProperty aProperty,
nsCSSProps::EnabledState aEnabledState,
mozilla::dom::Element* aTargetElement,
nsCSSPseudoElements::Type aPseudoType,
CSSPseudoElementType aPseudoType,
mozilla::css::StyleRule* aStyleRule,
nsTArray<PropertyStyleAnimationValuePair>& aValues,
bool* aIsContextSensitive);
+22 -14
View File
@@ -23,7 +23,6 @@
#include "nsDOMCSSDeclaration.h"
#include "nsNameSpaceManager.h"
#include "nsXMLNameSpaceMap.h"
#include "nsCSSPseudoElements.h"
#include "nsCSSPseudoClasses.h"
#include "nsCSSAnonBoxes.h"
#include "nsTArray.h"
@@ -222,7 +221,8 @@ nsAttrSelector::nsAttrSelector(int32_t aNameSpace, const nsString& aAttr)
mCasedAttr(nullptr),
mNameSpace(aNameSpace),
mFunction(NS_ATTR_FUNC_SET),
mCaseSensitive(1)
// mValueCaseSensitivity doesn't matter; we have no value.
mValueCaseSensitivity(ValueCaseSensitivity::CaseSensitive)
{
MOZ_COUNT_CTOR(nsAttrSelector);
@@ -234,14 +234,15 @@ nsAttrSelector::nsAttrSelector(int32_t aNameSpace, const nsString& aAttr)
}
nsAttrSelector::nsAttrSelector(int32_t aNameSpace, const nsString& aAttr, uint8_t aFunction,
const nsString& aValue, bool aCaseSensitive)
const nsString& aValue,
ValueCaseSensitivity aValueCaseSensitivity)
: mValue(aValue),
mNext(nullptr),
mLowercaseAttr(nullptr),
mCasedAttr(nullptr),
mNameSpace(aNameSpace),
mFunction(aFunction),
mCaseSensitive(aCaseSensitive)
mValueCaseSensitivity(aValueCaseSensitivity)
{
MOZ_COUNT_CTOR(nsAttrSelector);
@@ -254,14 +255,15 @@ nsAttrSelector::nsAttrSelector(int32_t aNameSpace, const nsString& aAttr, uint8_
nsAttrSelector::nsAttrSelector(int32_t aNameSpace, nsIAtom* aLowercaseAttr,
nsIAtom* aCasedAttr, uint8_t aFunction,
const nsString& aValue, bool aCaseSensitive)
const nsString& aValue,
ValueCaseSensitivity aValueCaseSensitivity)
: mValue(aValue),
mNext(nullptr),
mLowercaseAttr(aLowercaseAttr),
mCasedAttr(aCasedAttr),
mNameSpace(aNameSpace),
mFunction(aFunction),
mCaseSensitive(aCaseSensitive)
mValueCaseSensitivity(aValueCaseSensitivity)
{
MOZ_COUNT_CTOR(nsAttrSelector);
}
@@ -271,7 +273,7 @@ nsAttrSelector::Clone(bool aDeep) const
{
nsAttrSelector *result =
new nsAttrSelector(mNameSpace, mLowercaseAttr, mCasedAttr,
mFunction, mValue, mCaseSensitive);
mFunction, mValue, mValueCaseSensitivity);
if (aDeep)
NS_CSS_CLONE_LIST_MEMBER(nsAttrSelector, this, mNext, result, (false));
@@ -312,11 +314,11 @@ nsCSSSelector::nsCSSSelector(void)
mNext(nullptr),
mNameSpace(kNameSpaceID_Unknown),
mOperator(0),
mPseudoType(nsCSSPseudoElements::ePseudo_NotPseudoElement)
mPseudoType(static_cast<int16_t>(CSSPseudoElementType::NotPseudo))
{
MOZ_COUNT_CTOR(nsCSSSelector);
static_assert(nsCSSPseudoElements::ePseudo_MAX < INT16_MAX,
"nsCSSPseudoElements::Type values overflow mPseudoType");
static_assert(static_cast<int16_t>(CSSPseudoElementType::MAX) < INT16_MAX,
"CSSPseudoElementType values overflow mPseudoType");
}
nsCSSSelector*
@@ -466,14 +468,15 @@ void nsCSSSelector::AddAttribute(int32_t aNameSpace, const nsString& aAttr)
}
void nsCSSSelector::AddAttribute(int32_t aNameSpace, const nsString& aAttr, uint8_t aFunc,
const nsString& aValue, bool aCaseSensitive)
const nsString& aValue,
nsAttrSelector::ValueCaseSensitivity aCaseSensitivity)
{
if (!aAttr.IsEmpty()) {
nsAttrSelector** list = &mAttrList;
while (nullptr != *list) {
list = &((*list)->mNext);
}
*list = new nsAttrSelector(aNameSpace, aAttr, aFunc, aValue, aCaseSensitive);
*list = new nsAttrSelector(aNameSpace, aAttr, aFunc, aValue, aCaseSensitivity);
}
}
@@ -488,7 +491,7 @@ int32_t nsCSSSelector::CalcWeightWithoutNegations() const
#ifdef MOZ_XUL
MOZ_ASSERT(!(IsPseudoElement() &&
PseudoType() != nsCSSPseudoElements::ePseudo_XULTree &&
PseudoType() != CSSPseudoElementType::XULTree &&
mClassList),
"If non-XUL-tree pseudo-elements can have class selectors "
"after them, specificity calculation must be updated");
@@ -513,7 +516,7 @@ int32_t nsCSSSelector::CalcWeightWithoutNegations() const
#ifdef MOZ_XUL
// XUL tree pseudo-elements abuse mClassList to store some private
// data; ignore that.
if (PseudoType() == nsCSSPseudoElements::ePseudo_XULTree) {
if (PseudoType() == CSSPseudoElementType::XULTree) {
list = nullptr;
}
#endif
@@ -865,6 +868,11 @@ nsCSSSelector::AppendToStringWithoutCombinatorsOrNegations
// Append the value
nsStyleUtil::AppendEscapedCSSString(list->mValue, aString);
if (list->mValueCaseSensitivity ==
nsAttrSelector::ValueCaseSensitivity::CaseInsensitive) {
aString.Append(NS_LITERAL_STRING(" i"));
}
}
aString.Append(char16_t(']'));
+25 -13
View File
@@ -17,8 +17,8 @@
#include "nsString.h"
#include "nsCOMPtr.h"
#include "nsCSSPseudoElements.h"
#include "nsCSSPseudoClasses.h"
#include "nsCSSPseudoElements.h"
#include "nsIStyleRule.h"
class nsIAtom;
@@ -96,12 +96,20 @@ private:
struct nsAttrSelector {
public:
enum class ValueCaseSensitivity : uint8_t {
CaseSensitive,
CaseInsensitive,
CaseInsensitiveInHTML
};
nsAttrSelector(int32_t aNameSpace, const nsString& aAttr);
nsAttrSelector(int32_t aNameSpace, const nsString& aAttr, uint8_t aFunction,
const nsString& aValue, bool aCaseSensitive);
const nsString& aValue,
ValueCaseSensitivity aValueCaseSensitivity);
nsAttrSelector(int32_t aNameSpace, nsIAtom* aLowercaseAttr,
nsIAtom* aCasedAttr, uint8_t aFunction,
const nsString& aValue, bool aCaseSensitive);
const nsString& aValue,
ValueCaseSensitivity aValueCaseSensitivity);
~nsAttrSelector(void);
/** Do a deep clone. Should be used only on the first in the linked list. */
@@ -109,14 +117,20 @@ public:
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
bool IsValueCaseSensitive(bool aInHTML) const {
return mValueCaseSensitivity == ValueCaseSensitivity::CaseSensitive ||
(!aInHTML &&
mValueCaseSensitivity == ValueCaseSensitivity::CaseInsensitiveInHTML);
}
nsString mValue;
nsAttrSelector* mNext;
nsCOMPtr<nsIAtom> mLowercaseAttr;
nsCOMPtr<nsIAtom> mCasedAttr;
int32_t mNameSpace;
uint8_t mFunction;
bool mCaseSensitive; // If we are in an HTML document,
// is the value case sensitive?
ValueCaseSensitivity mValueCaseSensitivity;
private:
nsAttrSelector* Clone(bool aDeep) const;
@@ -145,7 +159,8 @@ public:
nsCSSSelectorList* aSelectorList);
void AddAttribute(int32_t aNameSpace, const nsString& aAttr);
void AddAttribute(int32_t aNameSpace, const nsString& aAttr, uint8_t aFunc,
const nsString& aValue, bool aCaseSensitive);
const nsString& aValue,
nsAttrSelector::ValueCaseSensitivity aValueCaseSensitivity);
void SetOperator(char16_t aOperator);
inline bool HasTagSelector() const {
@@ -163,7 +178,7 @@ public:
bool aAppend = false) const;
bool IsRestrictedSelector() const {
return PseudoType() == nsCSSPseudoElements::ePseudo_NotPseudoElement;
return PseudoType() == mozilla::CSSPseudoElementType::NotPseudo;
}
#ifdef DEBUG
@@ -193,13 +208,10 @@ private:
public:
// Get and set the selector's pseudo type
nsCSSPseudoElements::Type PseudoType() const {
return static_cast<nsCSSPseudoElements::Type>(mPseudoType);
mozilla::CSSPseudoElementType PseudoType() const {
return static_cast<mozilla::CSSPseudoElementType>(mPseudoType);
}
void SetPseudoType(nsCSSPseudoElements::Type aType) {
NS_ASSERTION(static_cast<int32_t>(aType) >= INT16_MIN &&
static_cast<int32_t>(aType) <= INT16_MAX,
"Out of bounds - this will overflow mPseudoType");
void SetPseudoType(mozilla::CSSPseudoElementType aType) {
mPseudoType = static_cast<int16_t>(aType);
}
+19
View File
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<style>
.nav { display: table }
.nav:after { content: " " }
</style>
</head>
<body>
<div style="font-size: 1rem"></div>
<div class="nav">
</div>
<script>
document.documentElement.style.fontSize = "10px";
document.documentElement.offsetHeight;
document.documentElement.style.fontSize = "15px";
</script>
</body>
</html>
+1
View File
@@ -132,6 +132,7 @@ load 1230408-1.html
load 1233135-1.html
load 1233135-2.html
load 1238660-1.html
load 1247865-1.html
load border-image-visited-link.html
load font-face-truncated-src.html
load large_border_image_width.html
+28 -75
View File
@@ -124,43 +124,24 @@ CSSAnimation::Tick()
}
bool
CSSAnimation::HasLowerCompositeOrderThan(const Animation& aOther) const
CSSAnimation::HasLowerCompositeOrderThan(const CSSAnimation& aOther) const
{
MOZ_ASSERT(IsTiedToMarkup() && aOther.IsTiedToMarkup(),
"Should only be called for CSS animations that are sorted "
"as CSS animations (i.e. tied to CSS markup)");
// 0. Object-equality case
if (&aOther == this) {
return false;
}
// 1. Transitions sort lower
//
// FIXME: We need to differentiate between transitions and generic Animations.
// Generic animations don't exist yet (that's bug 1096773) so for now we're
// ok.
const CSSAnimation* otherAnimation = aOther.AsCSSAnimation();
if (!otherAnimation) {
MOZ_ASSERT(aOther.AsCSSTransition(),
"Animation being compared is a CSS transition");
return false;
// 1. Sort by document order
if (!mOwningElement.Equals(aOther.mOwningElement)) {
return mOwningElement.LessThan(aOther.mOwningElement);
}
// 2. CSS animations that correspond to an animation-name property sort lower
// than other CSS animations (e.g. those created or kept-alive by script).
if (!IsTiedToMarkup()) {
return !otherAnimation->IsTiedToMarkup() ?
Animation::HasLowerCompositeOrderThan(aOther) :
false;
}
if (!otherAnimation->IsTiedToMarkup()) {
return true;
}
// 3. Sort by document order
if (!mOwningElement.Equals(otherAnimation->mOwningElement)) {
return mOwningElement.LessThan(otherAnimation->mOwningElement);
}
// 4. (Same element and pseudo): Sort by position in animation-name
return mAnimationIndex < otherAnimation->mAnimationIndex;
// 2. (Same element and pseudo): Sort by position in animation-name
return mAnimationIndex < aOther.mAnimationIndex;
}
void
@@ -187,7 +168,7 @@ CSSAnimation::QueueEvents()
}
dom::Element* owningElement;
nsCSSPseudoElements::Type owningPseudoType;
CSSPseudoElementType owningPseudoType;
mOwningElement.GetElement(owningElement, owningPseudoType);
MOZ_ASSERT(owningElement, "Owning element should be set");
@@ -317,39 +298,18 @@ CSSAnimation::ElapsedTimeToTimeStamp(const StickyTimeDuration&
NS_IMPL_CYCLE_COLLECTION(nsAnimationManager, mEventDispatcher)
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsAnimationManager)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsAnimationManager)
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(nsAnimationManager, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(nsAnimationManager, Release)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsAnimationManager)
NS_INTERFACE_MAP_ENTRY(nsIStyleRuleProcessor)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRuleProcessor)
NS_INTERFACE_MAP_END
/* virtual */ size_t
nsAnimationManager::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
void
nsAnimationManager::UpdateAnimations(nsStyleContext* aStyleContext,
mozilla::dom::Element* aElement)
{
return CommonAnimationManager::SizeOfExcludingThis(aMallocSizeOf);
// Measurement of the following members may be added later if DMD finds it is
// worthwhile:
// - mEventDispatcher
}
/* virtual */ size_t
nsAnimationManager::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
{
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}
nsIStyleRule*
nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
mozilla::dom::Element* aElement)
{
// Ignore animations for print or print preview, and for elements
// that are not attached to the document tree.
if (!mPresContext->IsDynamic() || !aElement->IsInComposedDoc()) {
return nullptr;
}
MOZ_ASSERT(mPresContext->IsDynamic(),
"Should not update animations for print or print preview");
MOZ_ASSERT(aElement->IsInComposedDoc(),
"Should not update animations that are not attached to the "
"document tree");
// Everything that causes our animation data to change triggers a
// style change, which in turn triggers a non-animation restyle.
@@ -364,7 +324,7 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
if (!collection &&
disp->mAnimationNameCount == 1 &&
disp->mAnimations[0].GetName().IsEmpty()) {
return nullptr;
return;
}
nsAutoAnimationMutationBatch mb(aElement->OwnerDoc());
@@ -380,7 +340,7 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
if (collection) {
collection->Destroy();
}
return nullptr;
return;
}
if (collection) {
@@ -511,12 +471,10 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
aStyleContext->GetPseudoType(),
aStyleContext);
EffectCompositor::CascadeLevel cascadeLevel =
EffectCompositor::CascadeLevel::Animations;
mPresContext->EffectCompositor()
->MaybeUpdateAnimationRule(aElement,
aStyleContext->GetPseudoType(),
cascadeLevel);
mPresContext->EffectCompositor()->
MaybeUpdateAnimationRule(aElement,
aStyleContext->GetPseudoType(),
EffectCompositor::CascadeLevel::Animations);
// We don't actually dispatch the pending events now. We'll either
// dispatch them the next time we get a refresh driver notification
@@ -525,17 +483,12 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
if (mEventDispatcher.HasQueuedEvents()) {
mPresContext->Document()->SetNeedStyleFlush();
}
return mPresContext->EffectCompositor()
->GetAnimationRule(aElement,
aStyleContext->GetPseudoType(),
cascadeLevel);
}
void
nsAnimationManager::StopAnimationsForElement(
mozilla::dom::Element* aElement,
nsCSSPseudoElements::Type aPseudoType)
mozilla::CSSPseudoElementType aPseudoType)
{
MOZ_ASSERT(aElement);
AnimationCollection* collection =

Some files were not shown because too many files have changed in this diff Show More