[HtmlUnit] SVN: [14369] trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/ javascript/host

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[HtmlUnit] SVN: [14369] trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/ javascript/host

asashour-2
Revision: 14369
          http://sourceforge.net/p/htmlunit/code/14369
Author:   asashour
Date:     2017-05-05 08:26:21 +0000 (Fri, 05 May 2017)
Log Message:
-----------
move to Document

Modified Paths:
--------------
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Element.java
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Document.java
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Node.java
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement.java

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Element.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Element.java 2017-05-05 07:25:37 UTC (rev 14368)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Element.java 2017-05-05 08:26:21 UTC (rev 14369)
@@ -1113,9 +1113,9 @@
     }
 
     /**
-     * {@inheritDoc}
+     * Returns the element ID.
+     * @return the ID of this element
      */
-    @Override
     @JsxGetter({CHROME, FF})
     public String getId() {
         return getDomNodeOrDie().getId();

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Document.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Document.java 2017-05-05 07:25:37 UTC (rev 14368)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Document.java 2017-05-05 08:26:21 UTC (rev 14369)
@@ -1733,4 +1733,91 @@
         return false;
     }
 
+    /**
+     * Returns the current number of child elements.
+     * @return the child element count
+     */
+    @JsxGetter({CHROME, FF})
+    public int getChildElementCount() {
+        int counter = 0;
+        if (getPage().getDocumentElement() != null) {
+            counter++;
+        }
+        return counter;
+    }
+
+    /**
+     * Returns the element for the specified x coordinate and the specified y coordinate.
+     * The current implementation always returns the <body> element.
+     *
+     * @param x the x offset, in pixels
+     * @param y the y offset, in pixels
+     * @return the element for the specified x coordinate and the specified y coordinate
+     */
+    @JsxFunction
+    public Object elementFromPoint(final int x, final int y) {
+        return null;
+    }
+
+    /**
+     * Returns the value of the JavaScript property {@code forms}.
+     * @return the value of the JavaScript property {@code forms}
+     */
+    @JsxGetter({CHROME, IE})
+    public Object getForms() {
+        return null;
+    }
+
+    /**
+     * Returns all the descendant elements with the specified class name.
+     * @param className the name to search for
+     * @return all the descendant elements with the specified class name
+     * @see <a href="https://developer.mozilla.org/en/DOM/document.getElementsByClassName">Mozilla doc</a>
+     */
+    @JsxFunction
+    public HTMLCollection getElementsByClassName(final String className) {
+        return null;
+    }
+
+    /**
+     * Returns all HTML elements that have a {@code name} attribute with the specified value.
+     *
+     * Refer to <a href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-71555259">
+     * The DOM spec</a> for details.
+     *
+     * @param elementName - value of the {@code name} attribute to look for
+     * @return all HTML elements that have a {@code name} attribute with the specified value
+     */
+    @JsxFunction({CHROME, IE})
+    public HTMLCollection getElementsByName(final String elementName) {
+        return null;
+    }
+
+    /**
+     * Returns {@code false} if the active element in the document has no focus;
+     * {@code true} if the active element in the document has focus.
+     * @return whether the active element in the document has focus or not
+     */
+    @JsxFunction
+    public boolean hasFocus() {
+        return false;
+    }
+
+    /**
+     * Returns this document's title.
+     * @return this document's title
+     */
+    @JsxGetter
+    public String getTitle() {
+        return "";
+    }
+
+    /**
+     * Sets this document's title.
+     * @param title the new title
+     */
+    @JsxSetter
+    public void setTitle(final String title) {
+    }
+
 }

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Node.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Node.java 2017-05-05 07:25:37 UTC (rev 14368)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Node.java 2017-05-05 08:26:21 UTC (rev 14369)
@@ -714,15 +714,6 @@
     }
 
     /**
-     * Returns the element ID.
-     * @return the ID of this element
-     */
-    @JsxGetter(IE)
-    public Object getId() {
-        return Undefined.instance;
-    }
-
-    /**
      * Sets the identifier this element.
      * @param newId the new identifier of this element
      */

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java 2017-05-05 07:25:37 UTC (rev 14368)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java 2017-05-05 08:26:21 UTC (rev 14369)
@@ -157,10 +157,10 @@
     }
 
     /**
-     * Returns the value of the JavaScript property {@code forms}.
-     * @return the value of the JavaScript property {@code forms}
+     * {@inheritDoc}
      */
-    @JsxGetter
+    @Override
+    @JsxGetter(FF)
     public Object getForms() {
         return new HTMLCollection(getDomNodeOrDie(), false) {
             @Override
@@ -767,26 +767,18 @@
     }
 
     /**
-     * Returns all the descendant elements with the specified class name.
-     * @param className the name to search for
-     * @return all the descendant elements with the specified class name
-     * @see <a href="https://developer.mozilla.org/en/DOM/document.getElementsByClassName">Mozilla doc</a>
+     * {@inheritDoc}
      */
-    @JsxFunction
+    @Override
     public HTMLCollection getElementsByClassName(final String className) {
         return ((HTMLElement) getDocumentElement()).getElementsByClassName(className);
     }
 
     /**
-     * Returns all HTML elements that have a {@code name} attribute with the specified value.
-     *
-     * Refer to <a href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-71555259">
-     * The DOM spec</a> for details.
-     *
-     * @param elementName - value of the {@code name} attribute to look for
-     * @return all HTML elements that have a {@code name} attribute with the specified value
+     * {@inheritDoc}
      */
-    @JsxFunction
+    @Override
+    @JsxFunction(FF)
     public HTMLCollection getElementsByName(final String elementName) {
         implicitCloseIfNecessary();
         if ("null".equals(elementName)) {
@@ -914,19 +906,17 @@
     }
 
     /**
-     * Returns this document's title.
-     * @return this document's title
+     * {@inheritDoc}
      */
-    @JsxGetter
+    @Override
     public String getTitle() {
         return getPage().getTitleText();
     }
 
     /**
-     * Sets this document's title.
-     * @param title the new title
+     * {@inheritDoc}
      */
-    @JsxSetter
+    @Override
     public void setTitle(final String title) {
         getPage().setTitleText(title);
     }
@@ -1133,20 +1123,6 @@
     }
 
     /**
-     * Returns the element for the specified x coordinate and the specified y coordinate.
-     * The current implementation always returns the &lt;body&gt; element.
-     *
-     * @param x the x offset, in pixels
-     * @param y the y offset, in pixels
-     * @return the element for the specified x coordinate and the specified y coordinate
-     */
-    @JsxFunction
-    public Object elementFromPoint(final int x, final int y) {
-        final HtmlElement element = getPage().getElementFromPoint(x, y);
-        return element == null ? null : element.getScriptableObject();
-    }
-
-    /**
      * {@inheritDoc}
      */
     @Override
@@ -1162,11 +1138,9 @@
     }
 
     /**
-     * Returns {@code false} if the active element in the document has no focus;
-     * {@code true} if the active element in the document has focus.
-     * @return whether the active element in the document has focus or not
+     * {@inheritDoc}
      */
-    @JsxFunction
+    @Override
     public boolean hasFocus() {
         return activeElement_ != null && getPage().getFocusedElement() == activeElement_.getDomNodeOrDie();
     }
@@ -1315,16 +1289,11 @@
     }
 
     /**
-     * Returns the current number of child elements.
-     * @return the child element count
+     * {@inheritDoc}
      */
-    @JsxGetter
-    public int getChildElementCount() {
-        int counter = 0;
-        if (getPage().getDocumentElement() != null) {
-            counter++;
-        }
-        return counter;
-    }
-
+    @Override
+    public Object elementFromPoint(final int x, final int y) {
+        final HtmlElement element = getPage().getElementFromPoint(x, y);
+        return element == null ? null : element.getScriptableObject();
+    };
 }

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement.java 2017-05-05 07:25:37 UTC (rev 14368)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement.java 2017-05-05 08:26:21 UTC (rev 14369)
@@ -2540,4 +2540,13 @@
             getDomNodeOrDie().removeAttribute("hidden");
         }
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    @JsxGetter(IE)
+    public String getId() {
+        return super.getId();
+    }
 }


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
HtmlUnit-develop mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop