Bug 1307357 part 7 - Implement ServoStyleRule::List. r?heycam
MozReview-Commit-ID: 1XRoc43RJKP
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -54,16 +54,18 @@ SERVO_BINDING_FUNC(Servo_StyleSet_Insert
// CSSRuleList
SERVO_BINDING_FUNC(Servo_CssRules_ListTypes, void,
ServoCssRulesBorrowed rules,
nsTArrayBorrowed_uintptr_t result)
SERVO_BINDING_FUNC(Servo_CssRules_GetStyleRuleAt, RawServoStyleRuleStrong,
ServoCssRulesBorrowed rules, uint32_t index)
// CSS Rules
+SERVO_BINDING_FUNC(Servo_StyleRule_Debug, void,
+ RawServoStyleRuleBorrowed rule, nsACString* result)
SERVO_BINDING_FUNC(Servo_StyleRule_GetStyle, RawServoDeclarationBlockStrong,
RawServoStyleRuleBorrowed rule)
SERVO_BINDING_FUNC(Servo_StyleRule_SetStyle, void,
RawServoStyleRuleBorrowed rule,
RawServoDeclarationBlockBorrowed declarations)
SERVO_BINDING_FUNC(Servo_StyleRule_GetCssText, void,
RawServoStyleRuleBorrowed rule, nsAString* result)
SERVO_BINDING_FUNC(Servo_StyleRule_GetSelectorText, void,
--- a/layout/style/ServoStyleRule.cpp
+++ b/layout/style/ServoStyleRule.cpp
@@ -155,17 +155,22 @@ ServoStyleRule::SizeOfIncludingThis(Mall
// TODO Implement this!
return aMallocSizeOf(this);
}
#ifdef DEBUG
void
ServoStyleRule::List(FILE* out, int32_t aIndent) const
{
- // TODO Implement this!
+ nsAutoCString str;
+ for (int32_t i = 0; i < aIndent; i++) {
+ str.AppendLiteral(" ");
+ }
+ Servo_StyleRule_Debug(mRawRule, &str);
+ fprintf_stderr(out, "%s\n", str.get());
}
#endif
/* CSSRule implementation */
NS_IMETHODIMP
ServoStyleRule::GetType(uint16_t* aType)
{
--- a/servo/components/style/gecko_bindings/bindings.rs
+++ b/servo/components/style/gecko_bindings/bindings.rs
@@ -990,16 +990,20 @@ extern "C" {
reference:
RawServoStyleSheetBorrowed);
}
extern "C" {
pub fn Servo_CssRules_ListRuleTypes(rules: ServoCssRulesBorrowed,
result: nsTArrayBorrowed_uintptr_t);
}
extern "C" {
+ pub fn Servo_StyleRule_Debug(rule: RawServoStyleRuleBorrowed,
+ result: *mut nsACString_internal);
+}
+extern "C" {
pub fn Servo_StyleRule_GetStyle(rule: RawServoStyleRuleBorrowed)
-> RawServoDeclarationBlockStrong;
}
extern "C" {
pub fn Servo_StyleRule_SetStyle(rule: RawServoStyleRuleBorrowed,
declarations:
RawServoDeclarationBlockBorrowed);
}
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -315,16 +315,23 @@ pub extern "C" fn Servo_StyleRule_AddRef
}
#[no_mangle]
pub extern "C" fn Servo_StyleRule_Release(rule: RawServoStyleRuleBorrowed) -> () {
unsafe { RwLock::<StyleRule>::release(rule) };
}
#[no_mangle]
+pub extern "C" fn Servo_StyleRule_Debug(rule: RawServoStyleRuleBorrowed, result: *mut nsACString) -> () {
+ let rule = RwLock::<StyleRule>::as_arc(&rule);
+ let result = unsafe { result.as_mut().unwrap() };
+ write!(result, "{:?}", *rule.read()).unwrap();
+}
+
+#[no_mangle]
pub extern "C" fn Servo_StyleRule_GetStyle(rule: RawServoStyleRuleBorrowed) -> RawServoDeclarationBlockStrong {
let rule = RwLock::<StyleRule>::as_arc(&rule);
rule.read().block.clone().into_strong()
}
#[no_mangle]
pub extern "C" fn Servo_StyleRule_SetStyle(rule: RawServoStyleRuleBorrowed,
declarations: RawServoDeclarationBlockBorrowed) -> () {