From: <rb...@us...> - 2013-10-18 18:58:06
|
Revision: 8662 http://sourceforge.net/p/htmlunit/code/8662 Author: rbri Date: 2013-10-18 18:58:03 +0000 (Fri, 18 Oct 2013) Log Message: ----------- some more HTMLElementClasses added to come closer to the modern browsers Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DefaultElementFactory.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLPhraseElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HTMLElementsTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HTMLParser2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java Added Paths: ----------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlRp.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlRt.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlRuby.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-10-18 18:47:53 UTC (rev 8661) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-10-18 18:58:03 UTC (rev 8662) @@ -498,6 +498,10 @@ @BrowserFeature(@WebBrowser(IE)) HEADER_CONTENT_DISPOSITION_ABSOLUTE_PATH, + /** Indicates if HTML5 ruby tags ruby, tp and rt are recognized. */ + @BrowserFeature({ @WebBrowser(IE) }) + HTML5_RUBY_TAGS, + /** Indicates if HTML5 tags source, video and audio are recognized. */ @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME) }) HTML5_TAGS, Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DefaultElementFactory.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DefaultElementFactory.java 2013-10-18 18:47:53 UTC (rev 8661) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DefaultElementFactory.java 2013-10-18 18:58:03 UTC (rev 8662) @@ -16,6 +16,7 @@ import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.CANVAS; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTML5_TAGS; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTML5_RUBY_TAGS; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLBASEFONT_SUPPORTED; import java.util.Arrays; @@ -79,7 +80,9 @@ HtmlNoScript.TAG_NAME, HtmlObject.TAG_NAME, HtmlOrderedList.TAG_NAME, HtmlOptionGroup.TAG_NAME, HtmlOption.TAG_NAME, HtmlParagraph.TAG_NAME, HtmlParameter.TAG_NAME, HtmlPlainText.TAG_NAME, HtmlPreformattedText.TAG_NAME, - HtmlProgress.TAG_NAME, HtmlS.TAG_NAME, HtmlSample.TAG_NAME, + HtmlProgress.TAG_NAME, + HtmlRp.TAG_NAME, HtmlRt.TAG_NAME, HtmlRuby.TAG_NAME, + HtmlS.TAG_NAME, HtmlSample.TAG_NAME, HtmlScript.TAG_NAME, HtmlSelect.TAG_NAME, HtmlSmall.TAG_NAME, HtmlSource.TAG_NAME, HtmlSpacer.TAG_NAME, HtmlSpan.TAG_NAME, HtmlStrike.TAG_NAME, HtmlStrong.TAG_NAME, HtmlStyle.TAG_NAME, @@ -409,6 +412,30 @@ else if (tagName.equals(HtmlProgress.TAG_NAME)) { element = new HtmlProgress(namespaceURI, qualifiedName, page, attributeMap); } + else if (tagName.equals(HtmlRp.TAG_NAME)) { + if (page.getWebClient().getBrowserVersion().hasFeature(HTML5_RUBY_TAGS)) { + element = new HtmlRp(namespaceURI, qualifiedName, page, attributeMap); + } + else { + return UnknownElementFactory.instance.createElementNS(page, namespaceURI, qualifiedName, attributes); + } + } + else if (tagName.equals(HtmlRt.TAG_NAME)) { + if (page.getWebClient().getBrowserVersion().hasFeature(HTML5_RUBY_TAGS)) { + element = new HtmlRt(namespaceURI, qualifiedName, page, attributeMap); + } + else { + return UnknownElementFactory.instance.createElementNS(page, namespaceURI, qualifiedName, attributes); + } + } + else if (tagName.equals(HtmlRuby.TAG_NAME)) { + if (page.getWebClient().getBrowserVersion().hasFeature(HTML5_RUBY_TAGS)) { + element = new HtmlRuby(namespaceURI, qualifiedName, page, attributeMap); + } + else { + return UnknownElementFactory.instance.createElementNS(page, namespaceURI, qualifiedName, attributes); + } + } else if (tagName.equals(HtmlS.TAG_NAME)) { element = new HtmlS(namespaceURI, qualifiedName, page, attributeMap); } Added: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlRp.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlRp.java (rev 0) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlRp.java 2013-10-18 18:58:03 UTC (rev 8662) @@ -0,0 +1,44 @@ +/* + * 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.html; + +import java.util.Map; + +import com.gargoylesoftware.htmlunit.SgmlPage; + +/** + * Wrapper for the HTML element "rp". + * + * @version $Revision$ + * @author Ronald Brill + */ +public class HtmlRp extends HtmlElement { + + /** The HTML tag represented by this element. */ + public static final String TAG_NAME = "rp"; + + /** + * Creates a new instance. + * + * @param namespaceURI the URI that identifies an XML namespace + * @param qualifiedName the qualified name of the element type to instantiate + * @param page the page that contains this element + * @param attributes the initial attributes + */ + HtmlRp(final String namespaceURI, final String qualifiedName, final SgmlPage page, + final Map<String, DomAttr> attributes) { + super(namespaceURI, qualifiedName, page, attributes); + } +} Property changes on: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlRp.java ___________________________________________________________________ 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 Added: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlRt.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlRt.java (rev 0) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlRt.java 2013-10-18 18:58:03 UTC (rev 8662) @@ -0,0 +1,44 @@ +/* + * 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.html; + +import java.util.Map; + +import com.gargoylesoftware.htmlunit.SgmlPage; + +/** + * Wrapper for the HTML element "rt". + * + * @version $Revision$ + * @author Ronald Brill + */ +public class HtmlRt extends HtmlElement { + + /** The HTML tag represented by this element. */ + public static final String TAG_NAME = "rt"; + + /** + * Creates a new instance. + * + * @param namespaceURI the URI that identifies an XML namespace + * @param qualifiedName the qualified name of the element type to instantiate + * @param page the page that contains this element + * @param attributes the initial attributes + */ + HtmlRt(final String namespaceURI, final String qualifiedName, final SgmlPage page, + final Map<String, DomAttr> attributes) { + super(namespaceURI, qualifiedName, page, attributes); + } +} Property changes on: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlRt.java ___________________________________________________________________ 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 Added: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlRuby.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlRuby.java (rev 0) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlRuby.java 2013-10-18 18:58:03 UTC (rev 8662) @@ -0,0 +1,44 @@ +/* + * 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.html; + +import java.util.Map; + +import com.gargoylesoftware.htmlunit.SgmlPage; + +/** + * Wrapper for the HTML element "ruby". + * + * @version $Revision$ + * @author Ronald Brill + */ +public class HtmlRuby extends HtmlElement { + + /** The HTML tag represented by this element. */ + public static final String TAG_NAME = "ruby"; + + /** + * Creates a new instance. + * + * @param namespaceURI the URI that identifies an XML namespace + * @param qualifiedName the qualified name of the element type to instantiate + * @param page the page that contains this element + * @param attributes the initial attributes + */ + HtmlRuby(final String namespaceURI, final String qualifiedName, final SgmlPage page, + final Map<String, DomAttr> attributes) { + super(namespaceURI, qualifiedName, page, attributes); + } +} Property changes on: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlRuby.java ___________________________________________________________________ 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/html/HTMLPhraseElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLPhraseElement.java 2013-10-18 18:47:53 UTC (rev 8661) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLPhraseElement.java 2013-10-18 18:58:03 UTC (rev 8662) @@ -14,6 +14,7 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.html; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.CSS_DISPLAY_DEFAULT; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLABBREVIATED; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_PHRASE_COMMON_CLASS_NAME; @@ -31,6 +32,9 @@ import com.gargoylesoftware.htmlunit.html.HtmlItalic; import com.gargoylesoftware.htmlunit.html.HtmlKeyboard; import com.gargoylesoftware.htmlunit.html.HtmlNoBreak; +import com.gargoylesoftware.htmlunit.html.HtmlRp; +import com.gargoylesoftware.htmlunit.html.HtmlRt; +import com.gargoylesoftware.htmlunit.html.HtmlRuby; import com.gargoylesoftware.htmlunit.html.HtmlS; import com.gargoylesoftware.htmlunit.html.HtmlSample; import com.gargoylesoftware.htmlunit.html.HtmlSmall; @@ -62,6 +66,7 @@ HtmlItalic.class, HtmlKeyboard.class, HtmlNoBreak.class, + HtmlRt.class, HtmlRp.class, HtmlRuby.class, HtmlS.class, HtmlSample.class, HtmlSmall.class, HtmlStrike.class, HtmlSubscript.class, HtmlSuperscript.class, HtmlStrong.class, HtmlTeletype.class, @@ -158,6 +163,20 @@ */ @Override public String getDefaultStyleDisplay() { + final String tagName = getTagName(); + if ("RUBY".equals(tagName)) { + if (getBrowserVersion().hasFeature(CSS_DISPLAY_DEFAULT)) { + return "inline"; + } + return "ruby"; + } + if ("RT".equals(tagName)) { + if (getBrowserVersion().hasFeature(CSS_DISPLAY_DEFAULT)) { + return "inline"; + } + return "ruby-text"; + } + return "inline"; } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HTMLElementsTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HTMLElementsTest.java 2013-10-18 18:47:53 UTC (rev 8661) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HTMLElementsTest.java 2013-10-18 18:58:03 UTC (rev 8662) @@ -15,6 +15,7 @@ package com.gargoylesoftware.htmlunit.html; import static com.gargoylesoftware.htmlunit.BrowserRunner.Browser.FF; +import static com.gargoylesoftware.htmlunit.BrowserRunner.Browser.IE10; import static com.gargoylesoftware.htmlunit.BrowserRunner.Browser.IE8; import org.junit.Test; @@ -31,6 +32,7 @@ * @version $Revision$ * @author Ahmed Ashour * @author Frank Danek + * @author Ronald Brill */ @RunWith(BrowserRunner.class) public class HTMLElementsTest extends WebDriverTestCase { @@ -796,6 +798,39 @@ * @throws Exception if the test fails */ @Test + @Alerts(DEFAULT = "1", + IE8 = "0") + @NotYetImplemented({ FF, IE10 }) + public void elementClosesItself_ruby() throws Exception { + loadPageWithAlerts2(elementClosesItself("ruby")); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "1", + IE8 = "0") + @NotYetImplemented(IE8) + public void elementClosesItself_rp() throws Exception { + loadPageWithAlerts2(elementClosesItself("rp")); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "1", + IE8 = "0") + @NotYetImplemented(IE8) + public void elementClosesItself_rt() throws Exception { + loadPageWithAlerts2(elementClosesItself("rt")); + } + + /** + * @throws Exception if the test fails + */ + @Test @Alerts("1") public void elementClosesItself_s() throws Exception { loadPageWithAlerts2(elementClosesItself("s")); Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HTMLParser2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HTMLParser2Test.java 2013-10-18 18:47:53 UTC (rev 8661) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HTMLParser2Test.java 2013-10-18 18:58:03 UTC (rev 8662) @@ -804,6 +804,39 @@ * @throws Exception if the test fails */ @Test + @Alerts(DEFAULT = { "3", "2", "2", "3", "2", "2" }, + IE8 = { "1", "1", "1", "2", "2", "1" }) + @NotYetImplemented(IE8) + public void childNodes_ruby() throws Exception { + loadPageWithAlerts2(createHtmlForChildNodes("ruby")); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "3", "2", "2", "3", "2", "2" }, + IE8 = { "1", "1", "1", "2", "2", "1" }) + @NotYetImplemented() + public void childNodes_rt() throws Exception { + loadPageWithAlerts2(createHtmlForChildNodes("rt")); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "3", "2", "2", "3", "2", "2" }, + IE8 = { "1", "1", "1", "2", "2", "1" }) + @NotYetImplemented() + public void childNodes_rp() throws Exception { + loadPageWithAlerts2(createHtmlForChildNodes("rp")); + } + + /** + * @throws Exception if the test fails + */ + @Test @Alerts(DEFAULT = { "3", "2", "2", "3", "2", "3" }, IE8 = { "3", "3", "2", "4", "4", "3" }) @NotYetImplemented(IE8) Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java 2013-10-18 18:47:53 UTC (rev 8661) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java 2013-10-18 18:58:03 UTC (rev 8662) @@ -3507,6 +3507,36 @@ * @throws Exception if the test fails */ @Test + @Alerts(DEFAULT = "<ruby></ruby>", + IE8 = "<RUBY></RUBY>") + public void outerHTML_ruby() throws Exception { + loadPageWithAlerts2(outerHTML("ruby")); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "<rt></rt>", + IE8 = "<RT></RT>") + public void outerHTML_rt() throws Exception { + loadPageWithAlerts2(outerHTML("rt")); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "<rp></rp>", + IE8 = "<RP></RP>") + public void outerHTML_rp() throws Exception { + loadPageWithAlerts2(outerHTML("rp")); + } + + /** + * @throws Exception if the test fails + */ + @Test @Alerts(DEFAULT = "<img>", IE8 = "<IMG>") public void outerHTML_img() throws Exception { |