Closed Bug 832980 Opened 11 years ago Closed 11 years ago

[Computed view] we see the template in the UI

Categories

(DevTools :: Inspector, defect, P1)

x86
All
defect

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 834187

People

(Reporter: paul, Assigned: miker)

References

Details

(Whiteboard: [blocked])

Attachments

(1 file, 2 obsolete files)

Attached image 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
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
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
(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.
ignore my comment 3. I was mistaken.
As a workaround, why not just wrap humanReadableText in a try catch, and return something better than an error message?
 (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...
No longer depends on: 833808
Attached patch Patch (obsolete) — Splinter Review
(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)
Attached patch Patch v2 (obsolete) — Splinter Review
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
Closed: 11 years ago
Resolution: --- → DUPLICATE
No longer blocks: DevToolsPaperCuts
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: