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.html;
16  
17  import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.CHROME;
18  import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.EDGE;
19  import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF;
20  
21  import com.gargoylesoftware.htmlunit.html.HtmlVideo;
22  import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass;
23  import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor;
24  import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter;
25  import com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter;
26  
27  /**
28   * The JavaScript object {@code HTMLVideoElement}.
29   *
30   * @author Ahmed Ashour
31   * @author Ronald Brill
32   * @author Frank Danek
33   */
34  @JsxClass(domClass = HtmlVideo.class)
35  public class HTMLVideoElement extends HTMLMediaElement {
36  
37      /**
38       * Creates an instance.
39       */
40      @JsxConstructor({CHROME, FF, EDGE})
41      public HTMLVideoElement() {
42      }
43  
44      /**
45       * Returns the {@code width} property.
46       * @return the {@code width} property
47       */
48      @Override
49      @JsxGetter
50      public int getWidth() {
51          final String value = getDomNodeOrDie().getAttribute("width");
52          final Integer intValue = HTMLCanvasElement.getValue(value);
53          if (intValue != null) {
54              return intValue;
55          }
56          return 0;
57      }
58  
59      /**
60       * Sets the {@code width} property.
61       * @param width the {@code width} property
62       */
63      @JsxSetter
64      public void setWidth(final int width) {
65          getDomNodeOrDie().setAttribute("width", Integer.toString(width));
66      }
67  
68      /**
69       * Returns the {@code height} property.
70       * @return the {@code height} property
71       */
72      @Override
73      @JsxGetter
74      public int getHeight() {
75          final String value = getDomNodeOrDie().getAttribute("height");
76          final Integer intValue = HTMLCanvasElement.getValue(value);
77          if (intValue != null) {
78              return intValue;
79          }
80          return 0;
81      }
82  
83      /**
84       * Sets the {@code height} property.
85       * @param height the {@code height} property
86       */
87      @JsxSetter
88      public void setHeight(final int height) {
89          getDomNodeOrDie().setAttribute("height", Integer.toString(height));
90      }
91  
92  }