summaryrefslogtreecommitdiff
path: root/Source/WebCore/css/CSSRule.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/css/CSSRule.cpp')
-rw-r--r--Source/WebCore/css/CSSRule.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/Source/WebCore/css/CSSRule.cpp b/Source/WebCore/css/CSSRule.cpp
index 13ad50ad3..09643ea9e 100644
--- a/Source/WebCore/css/CSSRule.cpp
+++ b/Source/WebCore/css/CSSRule.cpp
@@ -28,11 +28,13 @@
#include "CSSMediaRule.h"
#include "CSSPageRule.h"
#include "CSSStyleRule.h"
+#include "CSSStyleSheet.h"
#include "CSSUnknownRule.h"
#include "WebKitCSSKeyframeRule.h"
#include "WebKitCSSKeyframesRule.h"
#include "WebKitCSSRegionRule.h"
#include "NotImplemented.h"
+#include "StyleRule.h"
namespace WebCore {
@@ -113,4 +115,48 @@ void CSSRule::destroy()
ASSERT_NOT_REACHED();
}
+void CSSRule::reattach(StyleRuleBase* rule)
+{
+ switch (type()) {
+ case UNKNOWN_RULE:
+ return;
+ case STYLE_RULE:
+ static_cast<CSSStyleRule*>(this)->reattach(static_cast<StyleRule*>(rule));
+ return;
+ case PAGE_RULE:
+ static_cast<CSSPageRule*>(this)->reattach(static_cast<StyleRulePage*>(rule));
+ return;
+ case CHARSET_RULE:
+ ASSERT(!rule);
+ return;
+ case IMPORT_RULE:
+ // FIXME: Implement when enabling caching for stylesheets with import rules.
+ ASSERT_NOT_REACHED();
+ return;
+ case MEDIA_RULE:
+ static_cast<CSSMediaRule*>(this)->reattach(static_cast<StyleRuleMedia*>(rule));
+ return;
+ case FONT_FACE_RULE:
+ static_cast<CSSFontFaceRule*>(this)->reattach(static_cast<StyleRuleFontFace*>(rule));
+ return;
+ case WEBKIT_KEYFRAMES_RULE:
+ static_cast<WebKitCSSKeyframesRule*>(this)->reattach(static_cast<StyleRuleKeyframes*>(rule));
+ return;
+ case WEBKIT_KEYFRAME_RULE:
+ // No need to reattach, the underlying data is shareable on mutation.
+ ASSERT_NOT_REACHED();
+ return;
+ case WEBKIT_REGION_RULE:
+ static_cast<WebKitCSSRegionRule*>(this)->reattach(static_cast<StyleRuleRegion*>(rule));
+ return;
+ }
+ ASSERT_NOT_REACHED();
+}
+
+const CSSParserContext& CSSRule::parserContext() const
+{
+ CSSStyleSheet* styleSheet = parentStyleSheet();
+ return styleSheet ? styleSheet->internal()->parserContext() : strictCSSParserContext();
+}
+
} // namespace WebCore