From: <asa...@us...> - 2013-10-06 13:19:57
|
Revision: 8603 http://sourceforge.net/p/htmlunit/code/8603 Author: asashour Date: 2013-10-06 13:19:54 +0000 (Sun, 06 Oct 2013) Log Message: ----------- JavaScript: add SVGSVGElement.createSVGRect(). Issue 1538 Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGSVGElement.java Added Paths: ----------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGRect.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGSVGElementTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-10-06 12:21:52 UTC (rev 8602) +++ trunk/htmlunit/src/changes/changes.xml 2013-10-06 13:19:54 UTC (rev 8603) @@ -8,6 +8,9 @@ <body> <release version="2.13" date="???" description="Bugfixes"> + <action type="add" dev="asashour" issue="1538"> + JavaScript: add SVGSVGElement.createSVGRect(). + </action> <action type="fix" dev="asashour" issue="1548"> JavaScript: .innerHTML to correctly process nested SVG elements. </action> Added: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGRect.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGRect.java (rev 0) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGRect.java 2013-10-06 13:19:54 UTC (rev 8603) @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2002-2013 Gargoyle Software Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gargoylesoftware.htmlunit.javascript.host.svg; + +import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter; + +/** + * A JavaScript object for SVGRect. + * + * @version $Revision$ + * @author Ahmed Ashour + */ +@JsxClass +public class SVGRect extends SimpleScriptable { + + private double xValue_; + private double yValue_; + private double width_; + private double height_; + + /** + * Gets x. + * @return x + */ + @JsxGetter + public double getX() { + return xValue_; + } + + /** + * Sets x. + * @param x the x + */ + @JsxSetter + public void setX(final double x) { + this.xValue_ = x; + } + + /** + * Gets y. + * @return y + */ + @JsxGetter + public double getY() { + return yValue_; + } + + /** + * Sets y. + * @param y the y + */ + @JsxSetter + public void setY(final double y) { + this.yValue_ = y; + } + + /** + * Gets width. + * @return width + */ + @JsxGetter + public double getWidth() { + return width_; + } + + /** + * Sets width. + * @param width the width + */ + @JsxSetter + public void setWidth(final double width) { + this.width_ = width; + } + + /** + * Gets height. + * @return height + */ + @JsxGetter + public double getHeight() { + return height_; + } + + /** + * Sets height. + * @param height the height + */ + @JsxSetter + public void setHeigth(final double height) { + this.height_ = height; + } + +} Property changes on: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGRect.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Author Date Id Revision \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGSVGElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGSVGElement.java 2013-10-06 12:21:52 UTC (rev 8602) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGSVGElement.java 2013-10-06 13:19:54 UTC (rev 8603) @@ -57,4 +57,16 @@ public SVGMatrix getScreenCTM() { return new SVGMatrix(getWindow()); } + + /** + * Creates a new {@link SVGRect}. + * @return the new rect + */ + @JsxFunction + public SVGRect createSVGRect() { + final SVGRect rect = new SVGRect(); + rect.setPrototype(getPrototype(rect.getClass())); + rect.setParentScope(getParentScope()); + return rect; + } } Added: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGSVGElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGSVGElementTest.java (rev 0) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGSVGElementTest.java 2013-10-06 13:19:54 UTC (rev 8603) @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2002-2013 Gargoyle Software Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gargoylesoftware.htmlunit.javascript.host.svg; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.gargoylesoftware.htmlunit.BrowserRunner; +import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.WebDriverTestCase; +import com.gargoylesoftware.htmlunit.html.HtmlPageTest; + +/** + * Tests for {@link SVGSVGElement}. + * + * @version $Revision$ + * @author Ahmed Ashour + */ +@RunWith(BrowserRunner.class) +public class SVGSVGElementTest extends WebDriverTestCase { + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "[object SVGRect]", IE = "undefined") + public void createSVGRect() throws Exception { + final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html><head>\n" + + "<script>\n" + + " function test() {\n" + + " if (document.createElementNS) {\n" + + " alert(document.createElementNS('http://www.w3.org/2000/svg', 'svg').createSVGRect());\n" + + " } else {\n" + + " alert('undefined');\n" + + " }\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } +} Property changes on: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGSVGElementTest.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Author Date Id Revision \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property |