@@ -139,18 +139,20 @@ RuleEditor.prototype = {
139
139
// span to be placed absolutely against.
140
140
this . element . style . position = "relative" ;
141
141
142
- // Add the source link for supported rules. inline style and pres hints are not visible
143
- // in the StyleEditor, so don't show anything for such rule.
144
- if ( this . rule . domRule . type !== ELEMENT_STYLE ) {
145
- this . source = createChild ( this . element , "div" , {
146
- class : "ruleview-rule-source theme-link" ,
147
- } ) ;
148
- this . source . addEventListener ( "click" , this . _onSourceClick ) ;
142
+ // Add the source link.
143
+ this . source = createChild ( this . element , "div" , {
144
+ class : "ruleview-rule-source theme-link" ,
145
+ } ) ;
146
+ this . source . addEventListener ( "click" , this . _onSourceClick ) ;
147
+
148
+ // inline style are not visible in the StyleEditor, so don't create an actual link
149
+ // element for their location.
150
+ const sourceLabel = this . doc . createElement (
151
+ this . rule . domRule . type === ELEMENT_STYLE ? "span" : "a"
152
+ ) ;
153
+ sourceLabel . classList . add ( "ruleview-rule-source-label" ) ;
154
+ this . source . appendChild ( sourceLabel ) ;
149
155
150
- const sourceLabel = this . doc . createElement ( "a" ) ;
151
- sourceLabel . classList . add ( "ruleview-rule-source-label" ) ;
152
- this . source . appendChild ( sourceLabel ) ;
153
- }
154
156
this . updateSourceLink ( ) ;
155
157
156
158
if ( this . rule . domRule . ancestorData . length ) {
@@ -494,14 +496,13 @@ RuleEditor.prototype = {
494
496
* Called when a tool is registered or unregistered.
495
497
*/
496
498
_onToolChanged ( ) {
497
- if ( ! this . source ) {
498
- return ;
499
- }
500
-
501
499
// When the source editor is registered, update the source links
502
500
// to be clickable; and if it is unregistered, update the links to
503
- // be unclickable.
504
- if ( this . toolbox . isToolRegistered ( "styleeditor" ) ) {
501
+ // be unclickable. However, some links are never clickable, so
502
+ // filter those out first.
503
+ if ( this . source . getAttribute ( "unselectable" ) === "permanent" ) {
504
+ // Nothing.
505
+ } else if ( this . toolbox . isToolRegistered ( "styleeditor" ) ) {
505
506
this . source . removeAttribute ( "unselectable" ) ;
506
507
} else {
507
508
this . source . setAttribute ( "unselectable" , "true" ) ;
@@ -573,31 +574,38 @@ RuleEditor.prototype = {
573
574
} ,
574
575
575
576
updateSourceLink ( ) {
576
- if ( this . source ) {
577
- if ( this . rule . isSystem ) {
578
- const sourceLabel = this . element . querySelector (
579
- ".ruleview-rule-source-label"
580
- ) ;
581
- const uaLabel = STYLE_INSPECTOR_L10N . getStr ( "rule.userAgentStyles" ) ;
582
- sourceLabel . textContent = uaLabel + " " + this . rule . title ;
583
- sourceLabel . setAttribute ( "href" , this . rule . sheet ?. href ) ;
584
- } else {
585
- this . _updateLocation ( null ) ;
586
- }
577
+ if ( this . rule . isSystem ) {
578
+ const sourceLabel = this . element . querySelector (
579
+ ".ruleview-rule-source-label"
580
+ ) ;
581
+ const uaLabel = STYLE_INSPECTOR_L10N . getStr ( "rule.userAgentStyles" ) ;
582
+ sourceLabel . textContent = uaLabel + " " + this . rule . title ;
583
+ sourceLabel . setAttribute ( "href" , this . rule . sheet ?. href ) ;
584
+ } else {
585
+ this . _updateLocation ( null ) ;
586
+ }
587
587
588
- if ( this . rule . sheet && ! this . rule . isSystem ) {
589
- // Only get the original source link if the rule isn't a system
590
- // rule and if it isn't an inline rule.
591
- if ( this . _unsubscribeSourceMap ) {
592
- this . _unsubscribeSourceMap ( ) ;
593
- }
594
- this . _unsubscribeSourceMap = this . sourceMapURLService . subscribeByID (
595
- this . rule . sheet . resourceId ,
596
- this . rule . ruleLine ,
597
- this . rule . ruleColumn ,
598
- this . _updateLocation
599
- ) ;
588
+ if (
589
+ this . rule . sheet &&
590
+ ! this . rule . isSystem &&
591
+ this . rule . domRule . type !== ELEMENT_STYLE
592
+ ) {
593
+ // Only get the original source link if the rule isn't a system
594
+ // rule and if it isn't an inline rule.
595
+ if ( this . _unsubscribeSourceMap ) {
596
+ this . _unsubscribeSourceMap ( ) ;
600
597
}
598
+ this . _unsubscribeSourceMap = this . sourceMapURLService . subscribeByID (
599
+ this . rule . sheet . resourceId ,
600
+ this . rule . ruleLine ,
601
+ this . rule . ruleColumn ,
602
+ this . _updateLocation
603
+ ) ;
604
+ // Set "unselectable" appropriately.
605
+ this . _onToolChanged ( ) ;
606
+ } else if ( this . rule . domRule . type === ELEMENT_STYLE ) {
607
+ this . source . setAttribute ( "unselectable" , "permanent" ) ;
608
+ } else {
601
609
// Set "unselectable" appropriately.
602
610
this . _onToolChanged ( ) ;
603
611
}
0 commit comments