Fix dark theme issue in DOM inspector

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2196
This commit is contained in:
Raymond Hill 2022-08-04 10:52:09 -04:00
parent ac0cdf2d56
commit b01d57ab63
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 5 additions and 98 deletions

View File

@ -41,100 +41,6 @@ if ( document.querySelector('iframe.dom-inspector.' + sessionId) !== null ) {
/******************************************************************************/ /******************************************************************************/
/******************************************************************************/ /******************************************************************************/
// Modified to avoid installing as a global shim -- so the scriptlet can be
// flushed from memory once no longer in use.
// Added serializeAsString parameter.
/*! http://mths.be/cssescape v0.2.1 by @mathias | MIT license */
const cssEscape = (function(/*root*/) {
var InvalidCharacterError = function(message) {
this.message = message;
};
InvalidCharacterError.prototype = new Error();
InvalidCharacterError.prototype.name = 'InvalidCharacterError';
// http://dev.w3.org/csswg/cssom/#serialize-an-identifier
return function(value, serializeAsString) {
var string = String(value);
var length = string.length;
var index = -1;
var codeUnit;
var result = '';
var firstCodeUnit = string.charCodeAt(0);
while (++index < length) {
codeUnit = string.charCodeAt(index);
// Note: theres no need to special-case astral symbols, surrogate
// pairs, or lone surrogates.
// If the character is NULL (U+0000), then throw an
// `InvalidCharacterError` exception and terminate these steps.
if (codeUnit === 0x0000) {
throw new InvalidCharacterError(
'Invalid character: the input contains U+0000.'
);
}
if (
// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
// U+007F, […]
(codeUnit >= 0x0001 && codeUnit <= 0x001F) || codeUnit === 0x007F ||
// If the character is the first character and is in the range [0-9]
// (U+0030 to U+0039), […]
(index === 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039) ||
// If the character is the second character and is in the range [0-9]
// (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
(
index === 1 &&
codeUnit >= 0x0030 && codeUnit <= 0x0039 &&
firstCodeUnit === 0x002D
)
) {
// http://dev.w3.org/csswg/cssom/#escape-a-character-as-code-point
result += '\\' + codeUnit.toString(16) + ' ';
continue;
}
// If the character is not handled by one of the above rules and is
// greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
// is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
// U+005A), or [a-z] (U+0061 to U+007A), […]
if (
codeUnit >= 0x0080 ||
codeUnit === 0x002D ||
codeUnit === 0x005F ||
codeUnit >= 0x0030 && codeUnit <= 0x0039 ||
codeUnit >= 0x0041 && codeUnit <= 0x005A ||
codeUnit >= 0x0061 && codeUnit <= 0x007A
) {
// the character itself
result += string.charAt(index);
continue;
}
// If "serialize a string":
// If the character is '"' (U+0022) or "\" (U+005C), the escaped
// character. Otherwise, the character itself.
// http://dev.w3.org/csswg/cssom/#serialize-a-string
if ( serializeAsString && codeUnit !== 0x0022 && codeUnit !== 0x005C ) {
// the character itself
result += string.charAt(index);
continue;
}
// Otherwise, the escaped character.
// http://dev.w3.org/csswg/cssom/#escape-a-character
result += '\\' + string.charAt(index);
}
return result;
};
}(self));
/******************************************************************************/
/******************************************************************************/
let loggerConnectionId; let loggerConnectionId;
// Highlighter-related // Highlighter-related
@ -177,19 +83,19 @@ const domLayout = (function() {
const selectorFromNode = function(node) { const selectorFromNode = function(node) {
var str, attr, pos, sw, i; var str, attr, pos, sw, i;
var tag = node.localName; var tag = node.localName;
var selector = cssEscape(tag); var selector = CSS.escape(tag);
// Id // Id
if ( typeof node.id === 'string' ) { if ( typeof node.id === 'string' ) {
str = node.id.trim(); str = node.id.trim();
if ( str !== '' ) { if ( str !== '' ) {
selector += '#' + cssEscape(str); selector += '#' + CSS.escape(str);
} }
} }
// Class // Class
var cl = node.classList; var cl = node.classList;
if ( cl ) { if ( cl ) {
for ( i = 0; i < cl.length; i++ ) { for ( i = 0; i < cl.length; i++ ) {
selector += '.' + cssEscape(cl[i]); selector += '.' + CSS.escape(cl[i]);
} }
} }
// Tag-specific attributes // Tag-specific attributes
@ -209,7 +115,7 @@ const domLayout = (function() {
sw = ''; sw = '';
} }
if ( str !== '' ) { if ( str !== '' ) {
selector += '[' + attr + sw + '="' + cssEscape(str, true) + '"]'; selector += '[' + attr + sw + '="' + CSS.escape(str, true) + '"]';
} }
} }
return selector; return selector;
@ -949,6 +855,7 @@ pickerRoot.style.cssText = [
'border: 0', 'border: 0',
'border-radius: 0', 'border-radius: 0',
'box-shadow: none', 'box-shadow: none',
'color-scheme: light',
'display: block', 'display: block',
'height: 100%', 'height: 100%',
'left: 0', 'left: 0',