PassRefPtr<InspectorObject> InspectorStyleSheet::buildObjectForRule(CSSStyleRule* rule) { CSSStyleSheet* styleSheet = pageStyleSheet(); if (!styleSheet) return 0; RefPtr<InspectorObject> result = InspectorObject::create(); result->setString("selectorText", rule->selectorText()); result->setString("cssText", rule->cssText()); result->setNumber("sourceLine", rule->sourceLine()); result->setString("documentURL", m_documentURL); RefPtr<InspectorObject> parentStyleSheetValue = InspectorObject::create(); parentStyleSheetValue->setString("id", id()); parentStyleSheetValue->setString("href", styleSheet->href()); result->setObject("parentStyleSheet", parentStyleSheetValue.release()); result->setString("origin", m_origin); RefPtr<CSSRuleSourceData> sourceData; if (ensureParsedDataReady()) sourceData = ruleSourceDataFor(rule->style()); if (sourceData) { result->setNumber("selectorStartOffset", sourceData->selectorListRange.start); result->setNumber("selectorEndOffset", sourceData->selectorListRange.end); } result->setObject("style", buildObjectForStyle(rule->style())); if (canBind()) result->setString("id", fullRuleId(rule)); return result.release(); }
PassRefPtr<InspectorObject> InspectorStyleSheet::buildObjectForStyleSheet() { CSSStyleSheet* styleSheet = pageStyleSheet(); if (!styleSheet) return 0; RefPtr<InspectorObject> result = InspectorObject::create(); result->setString("id", id()); result->setBoolean("disabled", styleSheet->disabled()); result->setString("href", styleSheet->href()); result->setString("title", styleSheet->title()); RefPtr<CSSRuleList> cssRuleList = CSSRuleList::create(styleSheet, true); RefPtr<InspectorArray> cssRules = buildArrayForRuleList(cssRuleList.get()); result->setArray("cssRules", cssRules.release()); String styleSheetText; bool success = text(&styleSheetText); if (success) result->setString("text", styleSheetText); return result.release(); }