1/*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include "config.h"
27#include "JSCSSRule.h"
28
29#include "CSSFontFaceRule.h"
30#include "CSSImportRule.h"
31#include "CSSKeyframeRule.h"
32#include "CSSKeyframesRule.h"
33#include "CSSMediaRule.h"
34#include "CSSNamespaceRule.h"
35#include "CSSPageRule.h"
36#include "CSSStyleRule.h"
37#include "CSSSupportsRule.h"
38#include "JSCSSFontFaceRule.h"
39#include "JSCSSImportRule.h"
40#include "JSCSSKeyframeRule.h"
41#include "JSCSSKeyframesRule.h"
42#include "JSCSSMediaRule.h"
43#include "JSCSSNamespaceRule.h"
44#include "JSCSSPageRule.h"
45#include "JSCSSStyleRule.h"
46#include "JSCSSSupportsRule.h"
47#include "JSNode.h"
48#include "JSStyleSheetCustom.h"
49#include "JSWebKitCSSViewportRule.h"
50#include "WebKitCSSViewportRule.h"
51
52
53namespace WebCore {
54using namespace JSC;
55
56void JSCSSRule::visitAdditionalChildren(SlotVisitor& visitor)
57{
58 visitor.addOpaqueRoot(root(&wrapped()));
59}
60
61JSValue toJSNewlyCreated(ExecState*, JSDOMGlobalObject* globalObject, Ref<CSSRule>&& rule)
62{
63 switch (rule->type()) {
64 case CSSRule::STYLE_RULE:
65 return createWrapper<CSSStyleRule>(globalObject, WTFMove(rule));
66 case CSSRule::MEDIA_RULE:
67 return createWrapper<CSSMediaRule>(globalObject, WTFMove(rule));
68 case CSSRule::FONT_FACE_RULE:
69 return createWrapper<CSSFontFaceRule>(globalObject, WTFMove(rule));
70 case CSSRule::PAGE_RULE:
71 return createWrapper<CSSPageRule>(globalObject, WTFMove(rule));
72 case CSSRule::IMPORT_RULE:
73 return createWrapper<CSSImportRule>(globalObject, WTFMove(rule));
74 case CSSRule::NAMESPACE_RULE:
75 return createWrapper<CSSNamespaceRule>(globalObject, WTFMove(rule));
76 case CSSRule::KEYFRAME_RULE:
77 return createWrapper<CSSKeyframeRule>(globalObject, WTFMove(rule));
78 case CSSRule::KEYFRAMES_RULE:
79 return createWrapper<CSSKeyframesRule>(globalObject, WTFMove(rule));
80 case CSSRule::SUPPORTS_RULE:
81 return createWrapper<CSSSupportsRule>(globalObject, WTFMove(rule));
82#if ENABLE(CSS_DEVICE_ADAPTATION)
83 case CSSRule::WEBKIT_VIEWPORT_RULE:
84 return createWrapper<WebKitCSSViewportRule>(globalObject, WTFMove(rule));
85#endif
86 default:
87 return createWrapper<CSSRule>(globalObject, WTFMove(rule));
88 }
89}
90
91JSValue toJS(ExecState* state, JSDOMGlobalObject* globalObject, CSSRule& object)
92{
93 return wrap(state, globalObject, object);
94}
95
96} // namespace WebCore
97