[Computed view] we see the template in the UI

RESOLVED DUPLICATE of bug 834187

Status

()

Firefox
Developer Tools: Inspector
P1
normal
RESOLVED DUPLICATE of bug 834187
5 years ago
4 years ago

People

(Reporter: paul, Assigned: miker)

Tracking

Trunk
x86
All
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [blocked])

Attachments

(1 attachment, 2 obsolete attachments)

(Reporter)

Description

5 years ago
Created attachment 704553 [details]
screenshot

Some errors in the console (there are hundreds):

Expected selector.openStyleEditor to resolve to a function, but got undefined (In: div#templateMatchedSelectors > table > loop > foreach > 6 > tr > td > a > onclick)

Expected selector.maybeOpenStyleEditor to resolve to a function, but got undefined (In: div#templateMatchedSelectors > table > loop > foreach > 6 > tr > td > a > onkeydown)

"selectorInfo" is undefined (In: div#templateMatchedSelectors > table > loop > foreach > 6 > tr > td > a > title > ${selector.selectorInfo.href})

Template error evaluating 'selector.humanReadableText(__element)' (In: div#templateMatchedSelectors > table > loop > foreach > 7 > tr > td > #text >  ${selector.humanReadableText(__element)} )

TypeError: selector.humanReadableText is not a function
(Reporter)

Comment 1

5 years ago
STR:

- go to paulrouget.com
- inspector the round top left image
- use the computed view
- uncheck Only User Styles
- unfold -moz-box-sizing

It doesn't happen all the time.
Assignee: nobody → mratcliffe
Status: NEW → ASSIGNED
(Reporter)

Updated

5 years ago
Blocks: 831711
That was a difficult one to hunt down:

http://mxr.mozilla.org/mozilla-central/source/layout/base/nsPresShell.cpp#1387 contains the following:
1387       InsertRuleInternal(NS_LITERAL_STRING("*|*:-moz-any-link:not(svg|a){text-decoration:underline}"),
1388                          sInsertPrefSheetRulesAt, &index);

As of http://dev.w3.org/csswg/selectors4/#typenmsp using type selectors in :not() is fine and this is supported by Fx as illustrated by the preceding code.

Unfortunately, the following works just fine:
document.body.mozMatchesSelector("*|*:-moz-any-link:not(a)") // Returns false

But as soon as we add the svg namespace it fails:
document.body.mozMatchesSelector("*|*:-moz-any-link:not(svg|a)") // Exception: An invalid or illegal string was specified

This exception then stops the template from processing.
Priority: -- → P1
(Reporter)

Comment 3

5 years ago
(In reply to Michael Ratcliffe [:miker] [:mratcliffe] from comment #2)
> But as soon as we add the svg namespace it fails:
> document.body.mozMatchesSelector("*|*:-moz-any-link:not(svg|a)") //
> Exception: An invalid or illegal string was specified
> 
> This exception then stops the template from processing.

It doesn't fail because of svg, it fails because it's an invalid selector.
:not(svg|a) doesn't mean anything.

:not(svg):not(a) is, I think, what you want.
(Reporter)

Comment 4

5 years ago
ignore my comment 3. I was mistaken.
Depends on: 833808
As a workaround, why not just wrap humanReadableText in a try catch, and return something better than an error message?
(Reporter)

Comment 6

5 years ago
 (In reply to Joe Walker [:jwalker] from comment #5)
> As a workaround, why not just wrap humanReadableText in a try catch, and
> return something better than an error message?

What if we just bail on exception for mozMatchSelector and just consider it doesn't match? It makes me sad, but I think it's the best we can do until we get a better CSS logic.
So to be clear, a simple workaround would be:

CssHtmlTree.jsm:1200

  /**
   * A localized Get localized human readable info
   */
  humanReadableText: function SelectorView_humanReadableText(aElement)
  {
    try {
      if (this.tree.getRTLAttr == "rtl") {
        return this.selectorInfo.value + " \u2190 " + this.text(aElement);
      } else {
        return this.text(aElement) + " \u2192 " + this.selectorInfo.value;
      }
    }
    catch (ex) {
      return "Unsupported selector";
    }
  },

We can probably do better than this, but you get the idea...
Blocks: 834187
No longer depends on: 833808
Created attachment 705823 [details] [diff] [review]
Patch

(In reply to Joe Walker [:jwalker] from comment #7)
> So to be clear, a simple workaround would be:
> 
> CssHtmlTree.jsm:1200
> 
>   /**
>    * A localized Get localized human readable info
>    */
>   humanReadableText: function SelectorView_humanReadableText(aElement)
>   {
>     try {
>       if (this.tree.getRTLAttr == "rtl") {
>         return this.selectorInfo.value + " \u2190 " + this.text(aElement);
>       } else {
>         return this.text(aElement) + " \u2192 " + this.selectorInfo.value;
>       }
>     }
>     catch (ex) {
>       return "Unsupported selector";
>     }
>   },
> 
> We can probably do better than this, but you get the idea...

That wouldn't quite work as this is not where we check whether the selector matches the node. This patch dumps a warning and should be fixed (Bug 834187) once Bug 833808 is implemented.
Attachment #705823 - Flags: review?(paul)
Created attachment 705825 [details] [diff] [review]
Patch v2

Removed crud
Attachment #705823 - Attachment is obsolete: true
Attachment #705823 - Flags: review?(paul)
Attachment #705825 - Flags: review?(paul)
Comment on attachment 705825 [details] [diff] [review]
Patch v2

Actually, the patch in bug 834187 fixes this.
Attachment #705825 - Attachment is obsolete: true
Attachment #705825 - Flags: review?(paul)
No longer blocks: 834187
Depends on: 834187
Whiteboard: [blocked]
Because this was fixed as part of bug 834187  I am resolving it as a duplicate.
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 834187
No longer blocks: 831711
You need to log in before you can comment on or make changes to this bug.