Closed Bug 1216234 Opened 10 years ago Closed 10 years ago

add new DOMUtils method to list pseudo-elements

Categories

(DevTools :: Inspector, defect)

defect
Not set
normal

Tracking

(firefox45 fixed)

RESOLVED FIXED
Firefox 45
Tracking Status
firefox45 --- fixed

People

(Reporter: tromey, Assigned: tromey)

References

Details

(Whiteboard: [devtools-platform])

Attachments

(1 file, 5 obsolete files)

Bug 1215373 points out a list of pseudo elements in css-logic.js: https://dxr.mozilla.org/mozilla-central/source/devtools/shared/styleinspector/css-logic.js#46 It seems that it would be more future-proof to have a new DOMUtils method to compute this list. Maybe this would have to be a method on some actor, to correctly support cross-debugging.
See Also: → 1215373
Whiteboard: [devtools-platform]
Assignee: nobody → ttromey
Status: NEW → ASSIGNED
Preliminary patch. The old list included ::selection, which isn't actually accepted by firefox (only the prefixed ::moz-selection is). I wasn't sure if this was a leftover from some earlier platform change or whether it is included in devtools for valence. The old list also included some UA-only pseudo-elements; this patch drops them. It also drops some css-logic code that was apparently unused.
Comment on attachment 8682003 [details] [diff] [review] add inIDOMUtils.getCSSPseudoElementNames This replaces a hand-maintained list of pseudo element names with a new platform call to get the same list that is used internally. UA-only pseudo-elements are not listed, since AFAIK we don't deal with those in devtools. (Patrick, is that accurate?) It updates the devtools to use this new API everywhere. It deletes some apparently unused code in css-logic.js. The new test is basic: it compares the result against a hard-coded list. I wasn't sure what else would make sense.
Attachment #8682003 - Flags: review?(pbrosset)
Attachment #8682003 - Flags: review?(cam)
Comment on attachment 8682003 [details] [diff] [review] add inIDOMUtils.getCSSPseudoElementNames Review of attachment 8682003 [details] [diff] [review]: ----------------------------------------------------------------- r=me on the non-JS files with the below addressed. ::: layout/inspector/inDOMUtils.cpp @@ +1186,5 @@ > // NotPseudoClass is ok. > return sPseudoClassStates[nsCSSPseudoClasses::GetPseudoType(atom)]; > } > > +NS_METHOD This should be NS_IMETHODIMP. @@ +1195,5 @@ > + for (int i = 0; i < nsCSSPseudoElements::ePseudo_PseudoElementCount; ++i) { > + nsCSSPseudoElements::Type type = static_cast<nsCSSPseudoElements::Type>(i); > + if (!nsCSSPseudoElements::PseudoElementIsUASheetOnly(type)) { > + nsIAtom* atom = nsCSSPseudoElements::GetPseudoAtom(type); > + array.AppendElement(nsAtomString(atom)); I think this will make a copy of the atom's string. We could avoid that by building up an array of nsIAtom*s instead of nsStrings, and then passing nsDependentAtomString(array[i]) to ToNewUnicode.
Attachment #8682003 - Flags: review?(cam) → review+
Comment on attachment 8682003 [details] [diff] [review] add inIDOMUtils.getCSSPseudoElementNames Review of attachment 8682003 [details] [diff] [review]: ----------------------------------------------------------------- What are UA-only pseudo-elements? Are they the list of pseudos we used to remove in styles.js: :-moz-meter-bar, :-moz-list-bullet, :-moz-list-number, :-moz-focus-inner, :-moz-focus-outer, :-moz-math-anonymous, :-moz-math-stretchy ? I'm not too sure about what we can or can't edit from devtools. Apart from this, the code changes look good to me. I just made a comment about some code that I think should be removed, and about the test. Please let me know what you think and I can quickly R+ this. ::: devtools/server/actors/styles.js @@ +37,4 @@ > > +loader.lazyGetter(this, "PSEUDO_ELEMENTS", () => { > + return ; > +}); This block should be removed, right? ::: layout/inspector/tests/test_getCSSPseudoElementNames.html @@ +38,5 @@ > + for (let extra of expected) { > + info("extra element: " + extra); > + } > + > + is(expected.size, 0, "no extra names are included"); This means the test will fail every time a new pseudo is added to the platform. I don't think this is what we want. It would be a good way to make sure this test is up to date, for sure. But is it a role of a devtools test to fail when this happens? Do we have UI in devtools that needs changing and/or checking when a new pseudo is added? If yes, then maybe we should keep this assertion, with a comment that says something like "please talk to devtools, adding a new pseudo has impact on devtools code, etc.". If no, then I think the assertion needs to be removed, or replaced by a todo() https://developer.mozilla.org/en/docs/Mochitest#Test_functions
Attachment #8682003 - Flags: review?(pbrosset)
(In reply to Patrick Brosset [:pbrosset] [:pbro] from comment #4) > Comment on attachment 8682003 [details] [diff] [review] > add inIDOMUtils.getCSSPseudoElementNames > > What are UA-only pseudo-elements? Are they the list of pseudos we used to > remove in styles.js: > :-moz-meter-bar, :-moz-list-bullet, :-moz-list-number, :-moz-focus-inner, > :-moz-focus-outer, :-moz-math-anonymous, :-moz-math-stretchy ? > I'm not too sure about what we can or can't edit from devtools. Yes, those are UA-only (except :-moz-math-stretchy, which no longer exists -- one of the ways that the devtools were out of sync with platform). A UA-only pseudo element is one that isn't available to content. See https://dxr.mozilla.org/mozilla-central/source/layout/style/nsCSSPseudoElements.h#36 I think those are the ones that were previously dropped in styles.js. It wasn't clear to me if we want to support those when browser styles are enabled? > > +loader.lazyGetter(this, "PSEUDO_ELEMENTS", () => { > > + return ; > > +}); > > This block should be removed, right? Yes, oops. > ::: layout/inspector/tests/test_getCSSPseudoElementNames.html > @@ +38,5 @@ > > + for (let extra of expected) { > > + info("extra element: " + extra); > > + } > > + > > + is(expected.size, 0, "no extra names are included"); > > This means the test will fail every time a new pseudo is added to the > platform. I don't think this is what we want. > It would be a good way to make sure this test is up to date, for sure. > But is it a role of a devtools test to fail when this happens? Do we have UI > in devtools that needs changing and/or checking when a new pseudo is added? > If yes, then maybe we should keep this assertion, with a comment that says > something like "please talk to devtools, adding a new pseudo has impact on > devtools code, etc.". If no, then I think the assertion needs to be removed, > or replaced by a todo() > https://developer.mozilla.org/en/docs/Mochitest#Test_functions I think there's nothing in particular to do, so I will do the todo thing.
Attachment #8682003 - Attachment is obsolete: true
Comment on attachment 8683351 [details] [diff] [review] add inIDOMUtils.getCSSPseudoElementNames Updated per review; see comments in bug for responses to your questions.
Attachment #8683351 - Flags: review?(pbrosset)
Attachment #8683351 - Flags: review?(pbrosset) → review+
(In reply to Tom Tromey :tromey from comment #5) > It wasn't clear to me if we want to support those when browser styles are > enabled? Possibly, but maybe in another bug.
Update to fix try issues.
Attachment #8683351 - Attachment is obsolete: true
Comment on attachment 8684439 [details] [diff] [review] add inIDOMUtils.getCSSPseudoElementNames Patrick, I thought perhaps you should review the test changes I made. In particular, in browser_ruleview_user-agent-styles.js, I think what is going on is that we see multiple rule entries from getApplied. However, a couple of these have different pseudo-elements but the same underlying rule -- and in the UI this is shown just once, throwing off the count in this test. So, this arranges to de-duplicate the list in the test.
Attachment #8684439 - Flags: review?(pbrosset)
Comment on attachment 8684439 [details] [diff] [review] add inIDOMUtils.getCSSPseudoElementNames Review of attachment 8684439 [details] [diff] [review]: ----------------------------------------------------------------- The test changes look good to me. ::: devtools/client/styleinspector/test/browser_ruleview_user-agent-styles.js @@ +169,5 @@ > + entrySet.add(entry.rule); > + newEntries.push(entry); > + } > + } > + entries = newEntries; nit: You can do the same thing without having to create 2 data structures: let entryMap = new Map(); for (let entry of entries) { entryMap.set(entry.rule, entry); } entries = [...entryMap.entries()];
Attachment #8684439 - Flags: review?(pbrosset) → review+
Simplify test case per review.
Attachment #8684439 - Attachment is obsolete: true
Attachment #8684910 - Flags: review+
You may be concerned by the dt6 failures in that try run. However, locally I see these same failures without this patch.
Keywords: checkin-needed
sorry had to back this out again for dt6 failures like https://treeherder.mozilla.org/logviewer.html#?job_id=5652372&repo=fx-team
Flags: needinfo?(ttromey)
TIL that the tests in question will time out on Xvfb or Xnest, but not if I run them against the real X server. This is why I thought they were already failing locally :-( I've reproduced the problem here, for real this time, and I'm working on it.
Flags: needinfo?(ttromey)
Depends on: 1223452
Rebased on the patch for bug 1223452. The change is trivial, just a bit of differing context.
Attachment #8684910 - Attachment is obsolete: true
Attachment #8685558 - Flags: review+
Keywords: checkin-needed
Blocks: 1225192
Hi Tim, this seems to have problems again, see patching file devtools/client/styleinspector/rule-view.js Hunk #1 FAILED at 7 1 out of 2 hunks FAILED -- saving rejects to file devtools/client/styleinspector/rule-view.js.rej patch failed, unable to continue (try -v) patch failed, rejects left in working directory errors during apply, please fix and qrefresh Bug-1216234---add-inIDOMUtilsgetCSSPseudoElementNa.patch Tomcats-MacBook-Pro-2:fx-team Tomcat$
Flags: needinfo?(ttromey)
Rebased.
Attachment #8685558 - Attachment is obsolete: true
Comment on attachment 8694211 [details] [diff] [review] add inIDOMUtils.getCSSPseudoElementNames I rebased the patch, which should help.
Flags: needinfo?(ttromey)
Attachment #8694211 - Flags: review+
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 45
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: