View Javadoc
1   /*
2    * Copyright (c) 2002-2017 Gargoyle Software Inc.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software
10   * distributed under the License is distributed on an "AS IS" BASIS,
11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   * See the License for the specific language governing permissions and
13   * limitations under the License.
14   */
15  package com.gargoylesoftware.htmlunit.javascript.host.css;
16  
17  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_CSS_MOZ_CSS_KEYFRAMES_RULE;
18  import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.CHROME;
19  import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.EDGE;
20  import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF52;
21  import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.IE;
22  
23  import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass;
24  import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor;
25  import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter;
26  
27  /**
28   * A JavaScript object for {@code CSSKeyframesRule}.
29   *
30   * @author Ahmed Ashour
31   * @author Ronald Brill
32   */
33  @JsxClass({CHROME, FF52, IE, EDGE})
34  public class CSSKeyframesRule extends CSSRule {
35  
36      /**
37       * Default constructor.
38       */
39      @JsxConstructor({CHROME, EDGE})
40      public CSSKeyframesRule() {
41      }
42  
43      /**
44       * Creates a new instance.
45       * @param stylesheet the Stylesheet of this rule.
46       * @param rule the wrapped rule
47       */
48      protected CSSKeyframesRule(final CSSStyleSheet stylesheet, final org.w3c.dom.css.CSSUnknownRule rule) {
49          super(stylesheet, rule);
50      }
51  
52      /**
53       * Returns the type of the rule.
54       * @return the type of the rule.
55       */
56      @Override
57      @JsxGetter
58      public short getType() {
59          return KEYFRAMES_RULE;
60      }
61  
62      /**
63       * {@inheritDoc}
64       */
65      @Override
66      public Object getDefaultValue(final Class<?> hint) {
67          if ((String.class.equals(hint) || hint == null)
68                  && getBrowserVersion().hasFeature(JS_CSS_MOZ_CSS_KEYFRAMES_RULE)) {
69              return "[object MozCSSKeyframesRule]";
70          }
71          return super.getDefaultValue(hint);
72      }
73  }