summaryrefslogtreecommitdiff
path: root/Source/WebCore/css/InspectorCSSOMWrappers.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/css/InspectorCSSOMWrappers.cpp')
-rw-r--r--Source/WebCore/css/InspectorCSSOMWrappers.cpp73
1 files changed, 40 insertions, 33 deletions
diff --git a/Source/WebCore/css/InspectorCSSOMWrappers.cpp b/Source/WebCore/css/InspectorCSSOMWrappers.cpp
index 042e44e2c..674c0ab6b 100644
--- a/Source/WebCore/css/InspectorCSSOMWrappers.cpp
+++ b/Source/WebCore/css/InspectorCSSOMWrappers.cpp
@@ -30,14 +30,15 @@
#include "InspectorCSSOMWrappers.h"
#include "CSSDefaultStyleSheets.h"
-#include "CSSHostRule.h"
#include "CSSImportRule.h"
#include "CSSMediaRule.h"
+#include "CSSNamespaceRule.h"
#include "CSSRule.h"
#include "CSSStyleRule.h"
#include "CSSStyleSheet.h"
#include "CSSSupportsRule.h"
-#include "DocumentStyleSheetCollection.h"
+#include "ExtensionStyleSheets.h"
+#include "StyleScope.h"
#include "StyleSheetContents.h"
#include "WebKitCSSRegionRule.h"
@@ -59,28 +60,21 @@ void InspectorCSSOMWrappers::collect(ListType* listType)
CSSRule* cssRule = listType->item(i);
switch (cssRule->type()) {
case CSSRule::IMPORT_RULE:
- collect(static_cast<CSSImportRule*>(cssRule)->styleSheet());
+ collect(downcast<CSSImportRule>(*cssRule).styleSheet());
break;
case CSSRule::MEDIA_RULE:
- collect(static_cast<CSSMediaRule*>(cssRule));
+ collect(downcast<CSSMediaRule>(cssRule));
break;
-#if ENABLE(CSS3_CONDITIONAL_RULES)
case CSSRule::SUPPORTS_RULE:
- collect(static_cast<CSSSupportsRule*>(cssRule));
+ collect(downcast<CSSSupportsRule>(cssRule));
break;
-#endif
#if ENABLE(CSS_REGIONS)
case CSSRule::WEBKIT_REGION_RULE:
- collect(static_cast<WebKitCSSRegionRule*>(cssRule));
- break;
-#endif
-#if ENABLE(SHADOW_DOM)
- case CSSRule::HOST_RULE:
- collect(static_cast<CSSHostRule*>(cssRule));
+ collect(downcast<WebKitCSSRegionRule>(cssRule));
break;
#endif
case CSSRule::STYLE_RULE:
- m_styleRuleToCSSOMWrapperMap.add(static_cast<CSSStyleRule*>(cssRule)->styleRule(), static_cast<CSSStyleRule*>(cssRule));
+ m_styleRuleToCSSOMWrapperMap.add(&downcast<CSSStyleRule>(*cssRule).styleRule(), downcast<CSSStyleRule>(cssRule));
break;
default:
break;
@@ -88,43 +82,56 @@ void InspectorCSSOMWrappers::collect(ListType* listType)
}
}
-void InspectorCSSOMWrappers::collectFromStyleSheetContents(HashSet<RefPtr<CSSStyleSheet>>& sheetWrapperSet, StyleSheetContents* styleSheet)
+void InspectorCSSOMWrappers::collectFromStyleSheetContents(StyleSheetContents* styleSheet)
{
if (!styleSheet)
return;
RefPtr<CSSStyleSheet> styleSheetWrapper = CSSStyleSheet::create(*styleSheet);
- sheetWrapperSet.add(styleSheetWrapper);
+ m_styleSheetCSSOMWrapperSet.add(styleSheetWrapper);
collect(styleSheetWrapper.get());
}
void InspectorCSSOMWrappers::collectFromStyleSheets(const Vector<RefPtr<CSSStyleSheet>>& sheets)
{
- for (unsigned i = 0; i < sheets.size(); ++i)
- collect(sheets[i].get());
+ for (auto& sheet : sheets)
+ collect(sheet.get());
}
-void InspectorCSSOMWrappers::collectFromDocumentStyleSheetCollection(DocumentStyleSheetCollection& styleSheetCollection)
+void InspectorCSSOMWrappers::maybeCollectFromStyleSheets(const Vector<RefPtr<CSSStyleSheet>>& sheets)
{
- collectFromStyleSheets(styleSheetCollection.activeAuthorStyleSheets());
- collect(styleSheetCollection.pageUserSheet());
- collectFromStyleSheets(styleSheetCollection.injectedUserStyleSheets());
- collectFromStyleSheets(styleSheetCollection.documentUserStyleSheets());
+ for (auto& sheet : sheets) {
+ if (!m_styleSheetCSSOMWrapperSet.contains(sheet.get())) {
+ m_styleSheetCSSOMWrapperSet.add(sheet);
+ collect(sheet.get());
+ }
+ }
}
-CSSStyleRule* InspectorCSSOMWrappers::getWrapperForRuleInSheets(StyleRule* rule, DocumentStyleSheetCollection& styleSheetCollection)
+void InspectorCSSOMWrappers::collectDocumentWrappers(ExtensionStyleSheets& extensionStyleSheets)
{
if (m_styleRuleToCSSOMWrapperMap.isEmpty()) {
- collectFromStyleSheetContents(m_styleSheetCSSOMWrapperSet, CSSDefaultStyleSheets::simpleDefaultStyleSheet);
- collectFromStyleSheetContents(m_styleSheetCSSOMWrapperSet, CSSDefaultStyleSheets::defaultStyleSheet);
- collectFromStyleSheetContents(m_styleSheetCSSOMWrapperSet, CSSDefaultStyleSheets::quirksStyleSheet);
- collectFromStyleSheetContents(m_styleSheetCSSOMWrapperSet, CSSDefaultStyleSheets::svgStyleSheet);
- collectFromStyleSheetContents(m_styleSheetCSSOMWrapperSet, CSSDefaultStyleSheets::mathMLStyleSheet);
- collectFromStyleSheetContents(m_styleSheetCSSOMWrapperSet, CSSDefaultStyleSheets::mediaControlsStyleSheet);
- collectFromStyleSheetContents(m_styleSheetCSSOMWrapperSet, CSSDefaultStyleSheets::fullscreenStyleSheet);
- collectFromStyleSheetContents(m_styleSheetCSSOMWrapperSet, CSSDefaultStyleSheets::plugInsStyleSheet);
+ collectFromStyleSheetContents(CSSDefaultStyleSheets::simpleDefaultStyleSheet);
+ collectFromStyleSheetContents(CSSDefaultStyleSheets::defaultStyleSheet);
+ collectFromStyleSheetContents(CSSDefaultStyleSheets::quirksStyleSheet);
+ collectFromStyleSheetContents(CSSDefaultStyleSheets::svgStyleSheet);
+ collectFromStyleSheetContents(CSSDefaultStyleSheets::mathMLStyleSheet);
+ collectFromStyleSheetContents(CSSDefaultStyleSheets::mediaControlsStyleSheet);
+ collectFromStyleSheetContents(CSSDefaultStyleSheets::fullscreenStyleSheet);
+ collectFromStyleSheetContents(CSSDefaultStyleSheets::plugInsStyleSheet);
- collectFromDocumentStyleSheetCollection(styleSheetCollection);
+ collect(extensionStyleSheets.pageUserSheet());
+ collectFromStyleSheets(extensionStyleSheets.injectedUserStyleSheets());
+ collectFromStyleSheets(extensionStyleSheets.documentUserStyleSheets());
}
+}
+
+void InspectorCSSOMWrappers::collectScopeWrappers(Style::Scope& styleScope)
+{
+ maybeCollectFromStyleSheets(styleScope.activeStyleSheets());
+}
+
+CSSStyleRule* InspectorCSSOMWrappers::getWrapperForRuleInSheets(StyleRule* rule)
+{
return m_styleRuleToCSSOMWrapperMap.get(rule);
}