Bug 1386865 part 2 - Collect style rule maps for XBL bindings. r?heycam
MozReview-Commit-ID: HPmZopu1L7Z
--- a/layout/inspector/inDOMUtils.cpp
+++ b/layout/inspector/inDOMUtils.cpp
@@ -269,23 +269,51 @@ inDOMUtils::GetCSSStyleRules(nsIDOMEleme
if (!shell) {
return NS_OK;
}
ServoStyleContext* servo = styleContext->AsServo();
nsTArray<const RawServoStyleRule*> rawRuleList;
Servo_ComputedValues_GetStyleRuleList(servo, &rawRuleList);
- ServoStyleSet* styleSet = shell->StyleSet()->AsServo();
- ServoStyleRuleMap* map = styleSet->StyleRuleMap();
- map->EnsureTable();
+ AutoTArray<ServoStyleRuleMap*, 1> maps;
+ {
+ ServoStyleSet* styleSet = shell->StyleSet()->AsServo();
+ ServoStyleRuleMap* map = styleSet->StyleRuleMap();
+ map->EnsureTable();
+ maps.AppendElement(map);
+ }
+
+ // Collect style rule maps for bindings.
+ for (nsIContent* bindingContent = element; bindingContent;
+ bindingContent = bindingContent->GetBindingParent()) {
+ if (nsXBLBinding* binding = bindingContent->GetXBLBinding()) {
+ if (ServoStyleSet* styleSet = binding->GetServoStyleSet()) {
+ ServoStyleRuleMap* map = styleSet->StyleRuleMap();
+ map->EnsureTable();
+ maps.AppendElement(map);
+ }
+ }
+ // Note that we intentionally don't cut off here, unlike when we
+ // do styling, because even if style rules from parent binding
+ // do not apply to the element directly in those cases, their
+ // rules may still show up in the list we get above due to the
+ // inheritance in cascading.
+ }
// Find matching rules in the table.
for (const RawServoStyleRule* rawRule : Reversed(rawRuleList)) {
- if (ServoStyleRule* rule = map->Lookup(rawRule)) {
+ ServoStyleRule* rule = nullptr;
+ for (ServoStyleRuleMap* map : maps) {
+ rule = map->Lookup(rawRule);
+ if (rule) {
+ break;
+ }
+ }
+ if (rule) {
rules->AppendElement(static_cast<css::Rule*>(rule), false);
} else {
MOZ_ASSERT_UNREACHABLE("We should be able to map a raw rule to a rule");
}
}
}
rules.forget(_retval);