Skip to content

Commit

Permalink
Bug 1528883 - Rename CSSPseudoElement.parentElement to CSSPseudoEleme…
Browse files Browse the repository at this point in the history
…nt.element; r=bzbarsky

As per CSSWG resolution:

  w3c/csswg-drafts#2816 (comment)

And corresponding spec change:

  w3c/csswg-drafts@2dbf1e4

Differential Revision: https://phabricator.services.mozilla.com/D20427

UltraBlame original commit: f35e52301a453825fbe63b074b7702968786d8fe
  • Loading branch information
marco-c committed Oct 4, 2019
1 parent b5e3c7f commit 3d4a88b
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 39 deletions.
6 changes: 3 additions & 3 deletions devtools/server/actors/animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
}

const pseudo = this.player.effect.target;
const treeWalker = this.walker.getDocumentWalker(pseudo.parentElement);
const treeWalker = this.walker.getDocumentWalker(pseudo.element);
return pseudo.type === "::before" ? treeWalker.firstChild() : treeWalker.lastChild();
},

Expand Down Expand Up @@ -270,7 +270,7 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
if (target.type) {

pseudo = target.type;
target = target.parentElement;
target = target.element;
}
return this.window.getComputedStyle(target, pseudo).animationTimingFunction;
},
Expand Down Expand Up @@ -429,7 +429,7 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
if (target.type) {

pseudo = target.type;
target = target.parentElement;
target = target.element;
}
const value =
DOMWindowUtils.getUnanimatedComputedStyle(target,
Expand Down
19 changes: 10 additions & 9 deletions dom/animation/CSSPseudoElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
namespace mozilla {
namespace dom {

NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(CSSPseudoElement, mParentElement)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(CSSPseudoElement, mOriginatingElement)

NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(CSSPseudoElement, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(CSSPseudoElement, Release)

CSSPseudoElement::CSSPseudoElement(Element* aElement, PseudoStyleType aType)
: mParentElement(aElement), mPseudoType(aType) {
CSSPseudoElement::CSSPseudoElement(dom::Element* aElement,
PseudoStyleType aType)
: mOriginatingElement(aElement), mPseudoType(aType) {
MOZ_ASSERT(aElement);
MOZ_ASSERT(
aType == PseudoStyleType::after || aType == PseudoStyleType::before,
Expand All @@ -28,14 +29,14 @@ CSSPseudoElement::CSSPseudoElement(Element* aElement, PseudoStyleType aType)

CSSPseudoElement::~CSSPseudoElement() {

if (mParentElement) {
mParentElement->DeleteProperty(
if (mOriginatingElement) {
mOriginatingElement->DeleteProperty(
GetCSSPseudoElementPropertyAtom(mPseudoType));
}
}

ParentObject CSSPseudoElement::GetParentObject() const {
return mParentElement->GetParentObject();
return mOriginatingElement->GetParentObject();
}

JSObject* CSSPseudoElement::WrapObject(JSContext* aCx,
Expand All @@ -45,7 +46,7 @@ JSObject* CSSPseudoElement::WrapObject(JSContext* aCx,

void CSSPseudoElement::GetAnimations(const AnimationFilter& filter,
nsTArray<RefPtr<Animation>>& aRetVal) {
Document* doc = mParentElement->GetComposedDoc();
Document* doc = mOriginatingElement->GetComposedDoc();
if (doc) {


Expand All @@ -55,7 +56,7 @@ void CSSPseudoElement::GetAnimations(const AnimationFilter& filter,
ChangesToFlush(FlushType::Style, false ));
}

Element::GetAnimationsUnsorted(mParentElement, mPseudoType, aRetVal);
Element::GetAnimationsUnsorted(mOriginatingElement, mPseudoType, aRetVal);
aRetVal.Sort(AnimationPtrComparator<RefPtr<Animation>>());
}

Expand All @@ -69,7 +70,7 @@ already_AddRefed<Animation> CSSPseudoElement::Animate(
}

already_AddRefed<CSSPseudoElement>
CSSPseudoElement::GetCSSPseudoElement(Element* aElement,
CSSPseudoElement::GetCSSPseudoElement(dom::Element* aElement,
PseudoStyleType aType) {
if (!aElement) {
return nullptr;
Expand Down
10 changes: 5 additions & 5 deletions dom/animation/CSSPseudoElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class CSSPseudoElement final : public nsWrapperCache {
aRetVal.Append(
nsDependentAtomString(nsCSSPseudoElements::GetPseudoAtom(mPseudoType)));
}
already_AddRefed<Element> ParentElement() const {
RefPtr<Element> retVal(mParentElement);
already_AddRefed<dom::Element> Element() const {
RefPtr<dom::Element> retVal(mOriginatingElement);
return retVal.forget();
}

Expand All @@ -66,18 +66,18 @@ class CSSPseudoElement final : public nsWrapperCache {


static already_AddRefed<CSSPseudoElement> GetCSSPseudoElement(
Element* aElement, PseudoStyleType aType);
dom::Element* aElement, PseudoStyleType aType);

private:

CSSPseudoElement(Element* aElement, PseudoStyleType aType);
CSSPseudoElement(dom::Element* aElement, PseudoStyleType aType);

static nsAtom* GetCSSPseudoElementPropertyAtom(PseudoStyleType aType);




RefPtr<Element> mParentElement;
RefPtr<dom::Element> mOriginatingElement;
PseudoStyleType mPseudoType;
};

Expand Down
2 changes: 1 addition & 1 deletion dom/animation/KeyframeEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ static KeyframeEffectParams KeyframeEffectParamsFromUnion(
if (target.IsElement()) {
result.emplace(&target.GetAsElement());
} else {
RefPtr<Element> elem = target.GetAsCSSPseudoElement().ParentElement();
RefPtr<Element> elem = target.GetAsCSSPseudoElement().Element();
result.emplace(elem, target.GetAsCSSPseudoElement().GetType());
}
return result;
Expand Down
6 changes: 3 additions & 3 deletions dom/animation/test/chrome/test_animation_observers_async.html
Original file line number Diff line number Diff line change
Expand Up @@ -501,13 +501,13 @@
var childBAnimations = childB.getAnimations();

var divBeforeAnimations =
docAnims.filter(x => (x.effect.target.parentElement == div &&
docAnims.filter(x => (x.effect.target.element == div &&
x.effect.target.type == "::before"));
var divAfterAnimations =
docAnims.filter(x => (x.effect.target.parentElement == div &&
docAnims.filter(x => (x.effect.target.element == div &&
x.effect.target.type == "::after"));
var childBPseudoAnimations =
docAnims.filter(x => x.effect.target.parentElement == childB);
docAnims.filter(x => x.effect.target.element == childB);

var seekRecords;
// The order in which we get the corresponding records is currently
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
var anims = document.getAnimations();
assert_true(anims.length >= 1);
var anim = anims[anims.length - 1];
assert_equals(anim.effect.target.parentElement, element);
assert_equals(anim.effect.target.element, element);
assert_equals(anim.effect.target.type, '::' + type);
anim.cancel();
return anim.effect.target;
Expand Down
2 changes: 1 addition & 1 deletion dom/base/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3421,7 +3421,7 @@ already_AddRefed<Animation> Element::Animate(
if (aTarget.Value().IsElement()) {
referenceElement = &aTarget.Value().GetAsElement();
} else {
referenceElement = aTarget.Value().GetAsCSSPseudoElement().ParentElement();
referenceElement = aTarget.Value().GetAsCSSPseudoElement().Element();
}

nsCOMPtr<nsIGlobalObject> ownerGlobal = referenceElement->GetOwnerGlobal();
Expand Down
9 changes: 2 additions & 7 deletions dom/webidl/CSSPseudoElement.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,16 @@
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* https://drafts.csswg.org/css-pseudo/#CSSPseudoElement-interface
* https://drafts.csswg.org/cssom/#pseudoelement
* https://drafts.csswg.org/css-pseudo-4/#csspseudoelement
*
* Copyright © 2015 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/

// Both CSSOM and CSS Pseudo-Elements 4 provide contradictory definitions for
// this interface.
// What we implement here is a minimal subset of the two definitions which we
// ship behind a pref until the specification issues have been resolved.
[Func="Document::IsWebAnimationsGetAnimationsEnabled"]
interface CSSPseudoElement {
readonly attribute DOMString type;
readonly attribute Element parentElement;
readonly attribute Element element;
};

// https://drafts.csswg.org/web-animations/#extensions-to-the-pseudoelement-interface
Expand Down
3 changes: 0 additions & 3 deletions testing/web-platform/meta/css/css-pseudo/idlharness.html.ini
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ prefs: [dom.animations-api.getAnimations.enabled:true]
[CSSPseudoElementList interface: calling item(unsigned long) on beforeElements with too few arguments must throw TypeError]
expected: FAIL

[CSSPseudoElement interface: attribute element]
expected: FAIL

[CSSPseudoElement interface: beforeElements.item(0) must inherit property "element" with the proper type]
expected: FAIL

Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,12 @@
assert_equals(animations[1].effect.target.type, '::before',
'The animation targeting the ::before pseudo-element ' +
'should be returned second');
assert_equals(animations[1].effect.target.parentElement, parent,
assert_equals(animations[1].effect.target.element, parent,
'This ::before element should be child of parent element');
assert_equals(animations[2].effect.target.type, '::after',
'The animation targeting the ::after pesudo-element ' +
'should be returned third');
assert_equals(animations[2].effect.target.parentElement, parent,
assert_equals(animations[2].effect.target.element, parent,
'This ::after element should be child of parent element');

assert_equals(animations[3].effect.target, child,
Expand All @@ -388,12 +388,12 @@
assert_equals(animations[4].effect.target.type, '::before',
'The animation targeting the ::before pseudo-element ' +
'should be returned fifth');
assert_equals(animations[4].effect.target.parentElement, child,
assert_equals(animations[4].effect.target.element, child,
'This ::before element should be child of child element');
assert_equals(animations[5].effect.target.type, '::after',
'The animation targeting the ::after pesudo-element ' +
'should be returned last');
assert_equals(animations[5].effect.target.parentElement, child,
assert_equals(animations[5].effect.target.element, child,
'This ::after element should be child of child element');
}, '{ subtree: true } on an element with a child returns animations from the'
+ ' element, its pseudo-elements, its child and its child pseudo-elements');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,7 @@ const gCSSProperties = {
function testAnimationSamples(animation, idlName, testSamples) {
const type = animation.effect.target.type;
const target = animation.effect.target.constructor.name === 'CSSPseudoElement'
? animation.effect.target.parentElement
? animation.effect.target.element
: animation.effect.target;
for (const testSample of testSamples) {
animation.currentTime = testSample.time;
Expand All @@ -1466,7 +1466,7 @@ function toOrderedArray(string) {
function testAnimationSamplesWithAnyOrder(animation, idlName, testSamples) {
const type = animation.effect.target.type;
const target = animation.effect.target.constructor.name === 'CSSPseudoElement'
? animation.effect.target.parentElement
? animation.effect.target.element
: animation.effect.target;
for (const testSample of testSamples) {
animation.currentTime = testSample.time;
Expand Down

0 comments on commit 3d4a88b

Please sign in to comment.