1 /*
2 * Copyright (c) 2002-2026 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 * https://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 org.htmlunit.javascript.host.html;
16
17 import org.htmlunit.html.HtmlHtml;
18 import org.htmlunit.javascript.JavaScriptEngine;
19 import org.htmlunit.javascript.configuration.JsxClass;
20 import org.htmlunit.javascript.configuration.JsxConstructor;
21 import org.htmlunit.javascript.configuration.JsxGetter;
22 import org.htmlunit.javascript.configuration.JsxSetter;
23
24 /**
25 * The JavaScript object {@code HTMLHtmlElement}.
26 *
27 * @author Ahmed Ashour
28 * @author Marc Guillemot
29 * @author Ronald Brill
30 *
31 * @see <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLHtmlElement">MDN Documentation</a>
32 */
33 @JsxClass(domClass = HtmlHtml.class)
34 public class HTMLHtmlElement extends HTMLElement {
35
36 /**
37 * JavaScript constructor.
38 */
39 @Override
40 @JsxConstructor
41 public void jsConstructor() {
42 super.jsConstructor();
43 }
44
45 /** {@inheritDoc} */
46 @Override
47 public Object getParentNode() {
48 return getWindow().getDocument_js();
49 }
50
51 /** {@inheritDoc} */
52 @Override
53 public int getClientWidth() {
54 return getWindow().getInnerWidth();
55 }
56
57 /** {@inheritDoc} */
58 @Override
59 public int getClientHeight() {
60 return getWindow().getInnerHeight();
61 }
62
63 /**
64 * Overwritten to throw an exception.
65 * @param value the new value for replacing this node
66 */
67 @Override
68 public void setOuterHTML(final Object value) {
69 throw JavaScriptEngine.reportRuntimeError("outerHTML is read-only for tag 'html'");
70 }
71
72 /**
73 * Returns the {@code version} property.
74 * @return the {@code version} property
75 */
76 @JsxGetter
77 public String getVersion() {
78 return getDomNodeOrDie().getAttributeDirect("version");
79 }
80
81 /**
82 * Sets the {@code version} property.
83 * @param version the {@code version} property value
84 */
85 @JsxSetter
86 public void setVersion(final String version) {
87 getDomNodeOrDie().setAttribute("version", version);
88 }
89
90 }