DevTools: Improper function call in Styles pane

A bug in the Styles pane exists due to un-followed typing within
the _setActiveProperty function. The line previous to the expression
in question goes through treeElement.property, which is a
StylePropertyTreeElement. Its property `ownerStyle` returns an
SDK.CSSStyleDeclaration. We can see that SDK.CSSStyleDeclaration is
initialized with a property `parentRule` of type SDK.CSSRule, which
is the inferred type of `rule` in the outcome of the line in question.
However, SDK.CSSRule does not contain a member function called
`selectorText()`; only SDK.CSSStyleRule does.

Ostensibly it's possible that this is of type CSSKeyframesRule or
CSSKeyframeRule, and neither of these contains meaningful definitions
of something that matches a "selector," so it isn't really practically
possible to address via polymorphism.

This corrects the value-check and only calls the function if the
rule in question is of type SDK.CSSStyleRule.

Change-Id: I960e2b49ce9734134b55007149a39a97861739dd
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1872447
Reviewed-by: Lorne Mitchell <lomitch@microsoft.com>
Commit-Queue: Lorne Mitchell <lomitch@microsoft.com>
This commit is contained in:
Rob Paveza
2019-10-21 23:22:14 +00:00
committed by Commit Bot
parent 027399473a
commit acb77af66d
+1 -1
View File
@@ -432,7 +432,7 @@ Elements.StylesSidebarPane = class extends Elements.ElementsSidebarPane {
}
const rule = treeElement.property.ownerStyle.parentRule;
const selectorList = rule ? rule.selectorText() : undefined;
const selectorList = (rule instanceof SDK.CSSStyleRule) ? rule.selectorText() : undefined;
for (const mode of ['padding', 'border', 'margin']) {
if (!treeElement.name.startsWith(mode)) {
continue;