Index: Source/core/inspector/InspectorStyleSheet.cpp |
diff --git a/Source/core/inspector/InspectorStyleSheet.cpp b/Source/core/inspector/InspectorStyleSheet.cpp |
index d03a828e158d1b137a078635ecc7ca552b14debf..7023b118e6580c335606eb6ec843364cc06fed04 100644 |
--- a/Source/core/inspector/InspectorStyleSheet.cpp |
+++ b/Source/core/inspector/InspectorStyleSheet.cpp |
@@ -453,36 +453,6 @@ static PassRefPtr<TypeBuilder::CSS::SourceRange> buildSourceRangeObject(const So |
return result.release(); |
} |
-static PassRefPtr<TypeBuilder::CSS::CSSMedia> buildMediaObject(const MediaList* media, MediaListSource mediaListSource, const String& sourceURL) |
-{ |
- // Make certain compilers happy by initializing |source| up-front. |
- TypeBuilder::CSS::CSSMedia::Source::Enum source = TypeBuilder::CSS::CSSMedia::Source::InlineSheet; |
- switch (mediaListSource) { |
- case MediaListSourceMediaRule: |
- source = TypeBuilder::CSS::CSSMedia::Source::MediaRule; |
- break; |
- case MediaListSourceImportRule: |
- source = TypeBuilder::CSS::CSSMedia::Source::ImportRule; |
- break; |
- case MediaListSourceLinkedSheet: |
- source = TypeBuilder::CSS::CSSMedia::Source::LinkedSheet; |
- break; |
- case MediaListSourceInlineSheet: |
- source = TypeBuilder::CSS::CSSMedia::Source::InlineSheet; |
- break; |
- } |
- |
- RefPtr<TypeBuilder::CSS::CSSMedia> mediaObject = TypeBuilder::CSS::CSSMedia::create() |
- .setText(media->mediaText()) |
- .setSource(source); |
- |
- if (!sourceURL.isEmpty()) { |
- mediaObject->setSourceURL(sourceURL); |
- mediaObject->setSourceLine(media->queries()->lastLine()); |
- } |
- return mediaObject.release(); |
-} |
- |
static PassRefPtr<CSSRuleList> asCSSRuleList(CSSStyleSheet* styleSheet) |
{ |
if (!styleSheet) |
@@ -519,61 +489,6 @@ static PassRefPtr<CSSRuleList> asCSSRuleList(CSSRule* rule) |
return 0; |
} |
-static void fillMediaListChain(CSSRule* rule, Array<TypeBuilder::CSS::CSSMedia>* mediaArray) |
-{ |
- MediaList* mediaList; |
- CSSRule* parentRule = rule; |
- String sourceURL; |
- while (parentRule) { |
- CSSStyleSheet* parentStyleSheet = 0; |
- bool isMediaRule = true; |
- if (parentRule->type() == CSSRule::MEDIA_RULE) { |
- CSSMediaRule* mediaRule = static_cast<CSSMediaRule*>(parentRule); |
- mediaList = mediaRule->media(); |
- parentStyleSheet = mediaRule->parentStyleSheet(); |
- } else if (parentRule->type() == CSSRule::IMPORT_RULE) { |
- CSSImportRule* importRule = static_cast<CSSImportRule*>(parentRule); |
- mediaList = importRule->media(); |
- parentStyleSheet = importRule->parentStyleSheet(); |
- isMediaRule = false; |
- } else |
- mediaList = 0; |
- |
- if (parentStyleSheet) { |
- sourceURL = parentStyleSheet->contents()->baseURL(); |
- if (sourceURL.isEmpty()) |
- sourceURL = InspectorDOMAgent::documentURLString(parentStyleSheet->ownerDocument()); |
- } else |
- sourceURL = ""; |
- |
- if (mediaList && mediaList->length()) |
- mediaArray->addItem(buildMediaObject(mediaList, isMediaRule ? MediaListSourceMediaRule : MediaListSourceImportRule, sourceURL)); |
- |
- if (parentRule->parentRule()) |
- parentRule = parentRule->parentRule(); |
- else { |
- CSSStyleSheet* styleSheet = parentRule->parentStyleSheet(); |
- while (styleSheet) { |
- mediaList = styleSheet->media(); |
- if (mediaList && mediaList->length()) { |
- Document* doc = styleSheet->ownerDocument(); |
- if (doc) |
- sourceURL = doc->url(); |
- else if (!styleSheet->contents()->baseURL().isEmpty()) |
- sourceURL = styleSheet->contents()->baseURL(); |
- else |
- sourceURL = ""; |
- mediaArray->addItem(buildMediaObject(mediaList, styleSheet->ownerNode() ? MediaListSourceLinkedSheet : MediaListSourceInlineSheet, sourceURL)); |
- } |
- parentRule = styleSheet->ownerRule(); |
- if (parentRule) |
- break; |
- styleSheet = styleSheet->parentStyleSheet(); |
- } |
- } |
- } |
-} |
- |
PassRefPtr<InspectorStyle> InspectorStyle::create(const InspectorCSSId& styleId, PassRefPtr<CSSStyleDeclaration> style, InspectorStyleSheet* parentStyleSheet) |
{ |
return adoptRef(new InspectorStyle(styleId, style, parentStyleSheet)); |
@@ -1025,9 +940,9 @@ Document* InspectorStyle::ownerDocument() const |
return m_parentStyleSheet->pageStyleSheet() ? m_parentStyleSheet->pageStyleSheet()->ownerDocument() : 0; |
} |
-PassRefPtr<InspectorStyleSheet> InspectorStyleSheet::create(InspectorPageAgent* pageAgent, const String& id, PassRefPtr<CSSStyleSheet> pageStyleSheet, TypeBuilder::CSS::StyleSheetOrigin::Enum origin, const String& documentURL, Listener* listener) |
+PassRefPtr<InspectorStyleSheet> InspectorStyleSheet::create(InspectorCSSAgent* cssAgent, const String& id, PassRefPtr<CSSStyleSheet> pageStyleSheet, TypeBuilder::CSS::StyleSheetOrigin::Enum origin, const String& documentURL, Listener* listener) |
{ |
- return adoptRef(new InspectorStyleSheet(pageAgent, id, pageStyleSheet, origin, documentURL, listener)); |
+ return adoptRef(new InspectorStyleSheet(cssAgent, id, pageStyleSheet, origin, documentURL, listener)); |
} |
// static |
@@ -1038,8 +953,8 @@ String InspectorStyleSheet::styleSheetURL(CSSStyleSheet* pageStyleSheet) |
return emptyString(); |
} |
-InspectorStyleSheet::InspectorStyleSheet(InspectorPageAgent* pageAgent, const String& id, PassRefPtr<CSSStyleSheet> pageStyleSheet, TypeBuilder::CSS::StyleSheetOrigin::Enum origin, const String& documentURL, Listener* listener) |
- : m_pageAgent(pageAgent) |
+InspectorStyleSheet::InspectorStyleSheet(InspectorCSSAgent* cssAgent, const String& id, PassRefPtr<CSSStyleSheet> pageStyleSheet, TypeBuilder::CSS::StyleSheetOrigin::Enum origin, const String& documentURL, Listener* listener) |
+ : m_cssAgent(cssAgent) |
, m_id(id) |
, m_pageStyleSheet(pageStyleSheet) |
, m_origin(origin) |
@@ -1266,7 +1181,7 @@ PassRefPtr<TypeBuilder::CSS::CSSStyleSheetHeader> InspectorStyleSheet::buildObje |
.setDisabled(styleSheet->disabled()) |
.setSourceURL(url()) |
.setTitle(styleSheet->title()) |
- .setFrameId(m_pageAgent->frameId(frame)) |
+ .setFrameId(m_cssAgent->pageAgent()->frameId(frame)) |
.setIsInline(styleSheet->isInline() && !startsAtZero()) |
.setStartLine(styleSheet->startPositionInSource().m_line.zeroBasedInt()) |
.setStartColumn(styleSheet->startPositionInSource().m_column.zeroBasedInt()); |
@@ -1350,7 +1265,7 @@ PassRefPtr<TypeBuilder::CSS::CSSRule> InspectorStyleSheet::buildObjectForRule(CS |
RefPtr<Array<TypeBuilder::CSS::CSSMedia> > mediaArray = Array<TypeBuilder::CSS::CSSMedia>::create(); |
- fillMediaListChain(rule, mediaArray.get()); |
+ m_cssAgent->fillMediaListChain(rule, mediaArray.get()); |
if (mediaArray->length()) |
result->setMedia(mediaArray.release()); |
@@ -1484,7 +1399,7 @@ String InspectorStyleSheet::sourceURL() const |
String commentValue = ContentSearchUtils::findSourceURL(styleSheetText, ContentSearchUtils::CSSMagicComment, &deprecated); |
if (!commentValue.isEmpty()) { |
if (deprecated) |
- m_pageAgent->page()->console()->addMessage(NetworkMessageSource, WarningMessageLevel, "\"/*@ sourceURL=\" source URL declaration is deprecated, \"/*# sourceURL=\" declaration should be used instead.", finalURL(), 0); |
+ m_cssAgent->pageAgent()->page()->console()->addMessage(NetworkMessageSource, WarningMessageLevel, "\"/*@ sourceURL=\" source URL declaration is deprecated, \"/*# sourceURL=\" declaration should be used instead.", finalURL(), 0); |
m_sourceURL = commentValue; |
return commentValue; |
} |
@@ -1538,11 +1453,11 @@ String InspectorStyleSheet::sourceMapURL() const |
String commentValue = ContentSearchUtils::findSourceMapURL(styleSheetText, ContentSearchUtils::CSSMagicComment, &deprecated); |
if (!commentValue.isEmpty()) { |
if (deprecated) |
- m_pageAgent->page()->console()->addMessage(NetworkMessageSource, WarningMessageLevel, "\"/*@ sourceMappingURL=\" source mapping URL declaration is deprecated, \"/*# sourceMappingURL=\" declaration should be used instead.", finalURL(), 0); |
+ m_cssAgent->pageAgent()->page()->console()->addMessage(NetworkMessageSource, WarningMessageLevel, "\"/*@ sourceMappingURL=\" source mapping URL declaration is deprecated, \"/*# sourceMappingURL=\" declaration should be used instead.", finalURL(), 0); |
return commentValue; |
} |
} |
- return m_pageAgent->resourceSourceMapURL(finalURL()); |
+ return m_cssAgent->pageAgent()->resourceSourceMapURL(finalURL()); |
} |
InspectorCSSId InspectorStyleSheet::ruleOrStyleId(CSSStyleDeclaration* style) const |
@@ -1776,13 +1691,13 @@ void InspectorStyleSheet::collectFlatRules(PassRefPtr<CSSRuleList> ruleList, CSS |
} |
} |
-PassRefPtr<InspectorStyleSheetForInlineStyle> InspectorStyleSheetForInlineStyle::create(InspectorPageAgent* pageAgent, const String& id, PassRefPtr<Element> element, TypeBuilder::CSS::StyleSheetOrigin::Enum origin, Listener* listener) |
+PassRefPtr<InspectorStyleSheetForInlineStyle> InspectorStyleSheetForInlineStyle::create(InspectorCSSAgent* cssAgent, const String& id, PassRefPtr<Element> element, TypeBuilder::CSS::StyleSheetOrigin::Enum origin, Listener* listener) |
{ |
- return adoptRef(new InspectorStyleSheetForInlineStyle(pageAgent, id, element, origin, listener)); |
+ return adoptRef(new InspectorStyleSheetForInlineStyle(cssAgent, id, element, origin, listener)); |
} |
-InspectorStyleSheetForInlineStyle::InspectorStyleSheetForInlineStyle(InspectorPageAgent* pageAgent, const String& id, PassRefPtr<Element> element, TypeBuilder::CSS::StyleSheetOrigin::Enum origin, Listener* listener) |
- : InspectorStyleSheet(pageAgent, id, 0, origin, "", listener) |
+InspectorStyleSheetForInlineStyle::InspectorStyleSheetForInlineStyle(InspectorCSSAgent* cssAgent, const String& id, PassRefPtr<Element> element, TypeBuilder::CSS::StyleSheetOrigin::Enum origin, Listener* listener) |
+ : InspectorStyleSheet(cssAgent, id, 0, origin, "", listener) |
, m_element(element) |
, m_ruleSourceData(0) |
, m_isStyleTextValid(false) |