From: <asa...@us...> - 2010-05-08 13:30:34
|
Revision: 5707 http://htmlunit.svn.sourceforge.net/htmlunit/?rev=5707&view=rev Author: asashour Date: 2010-05-08 13:30:27 +0000 (Sat, 08 May 2010) Log Message: ----------- More uses of BrowserVersionFeatures Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNode.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlButton.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/FF2.properties trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/FF3.6.properties trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/FF3.properties trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/IE6.properties trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/IE7.properties trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/IE8.properties Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2010-05-08 13:02:26 UTC (rev 5706) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2010-05-08 13:30:27 UTC (rev 5707) @@ -24,6 +24,9 @@ */ public enum BrowserVersionFeatures { + /** If the "type" attribute of HtmlButton should be evaluated to 'button' if not specified. */ + BUTTON_EMPTY_TYPE_BUTTON, + /** Indicates that a blur event should be triggered before an onchange event. */ BLUR_BEFORE_ONCHANGE, @@ -39,6 +42,15 @@ /** Indicates that "\n" are replaced by "\r\n" in textarea values. */ DISPLAYED_COLLAPSE, + /** IE removes all child text nodes, but FF preserves the first. */ + DOM_NORMALIZE_REMOVE_CHILDREN, + + /** Triggers "input" event. */ + EVENT_INPUT, + + /** Triggers "propertychange" event. */ + EVENT_PROPERTY_CHANGE, + /** Indicates that document.execCommand() should throw an exception when called with an illegal command. */ EXECCOMMAND_THROWS_ON_WRONG_COMMAND, Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNode.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNode.java 2010-05-08 13:02:26 UTC (rev 5706) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNode.java 2010-05-08 13:30:27 UTC (rev 5707) @@ -415,7 +415,8 @@ public void normalize() { for (DomNode child = getFirstChild(); child != null; child = child.getNextSibling()) { if (child instanceof DomText) { - final boolean ie = getPage().getWebClient().getBrowserVersion().isIE(); + final boolean removeChildTextNodes = getPage().getWebClient().getBrowserVersion() + .hasFeature(BrowserVersionFeatures.DOM_NORMALIZE_REMOVE_CHILDREN); final StringBuilder dataBuilder = new StringBuilder(); DomNode toRemove = child; DomText firstText = null; @@ -423,7 +424,7 @@ while (toRemove instanceof DomText && !(toRemove instanceof DomCDataSection)) { final DomNode nextChild = toRemove.getNextSibling(); dataBuilder.append(toRemove.getTextContent()); - if (ie || firstText != null) { + if (removeChildTextNodes || firstText != null) { toRemove.remove(); } if (firstText == null) { @@ -432,7 +433,7 @@ toRemove = nextChild; } if (firstText != null) { - if (ie) { + if (removeChildTextNodes) { final DomText newText = new DomText(getPage(), dataBuilder.toString()); insertBefore(newText, toRemove); } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlButton.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlButton.java 2010-05-08 13:02:26 UTC (rev 5706) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlButton.java 2010-05-08 13:30:27 UTC (rev 5707) @@ -20,7 +20,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import com.gargoylesoftware.htmlunit.BrowserVersion; +import com.gargoylesoftware.htmlunit.BrowserVersionFeatures; import com.gargoylesoftware.htmlunit.SgmlPage; import com.gargoylesoftware.htmlunit.util.NameValuePair; @@ -194,8 +194,8 @@ public final String getTypeAttribute() { String type = getAttribute("type"); if (type == HtmlElement.ATTRIBUTE_NOT_DEFINED) { - final BrowserVersion browser = getPage().getWebClient().getBrowserVersion(); - if (browser.isIE()) { + if (getPage().getWebClient().getBrowserVersion() + .hasFeature(BrowserVersionFeatures.BUTTON_EMPTY_TYPE_BUTTON)) { type = "button"; } else { Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java 2010-05-08 13:02:26 UTC (rev 5706) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java 2010-05-08 13:30:27 UTC (rev 5707) @@ -42,6 +42,7 @@ import org.w3c.dom.ProcessingInstruction; import org.w3c.dom.Text; +import com.gargoylesoftware.htmlunit.BrowserVersionFeatures; import com.gargoylesoftware.htmlunit.ElementNotFoundException; import com.gargoylesoftware.htmlunit.Page; import com.gargoylesoftware.htmlunit.ScriptResult; @@ -164,7 +165,7 @@ fireHtmlAttributeReplaced(htmlEvent); ((HtmlPage) getPage()).fireHtmlAttributeReplaced(htmlEvent); } - if (getPage().getWebClient().getBrowserVersion().isIE()) { + if (getPage().getWebClient().getBrowserVersion().hasFeature(BrowserVersionFeatures.EVENT_PROPERTY_CHANGE)) { fireEvent(Event.createPropertyChangeEvent(this, qualifiedName)); } } @@ -476,8 +477,7 @@ doType(c, shiftKey, ctrlKey, altKey); } - final boolean ie = page.getWebClient().getBrowserVersion().isIE(); - if (!ie + if (page.getWebClient().getBrowserVersion().hasFeature(BrowserVersionFeatures.EVENT_INPUT) && (this instanceof HtmlTextInput || this instanceof HtmlTextArea || this instanceof HtmlPasswordInput)) { @@ -490,7 +490,8 @@ final HtmlForm form = getEnclosingForm(); if (form != null && c == '\n' && isSubmittableByEnter()) { - if (!ie) { + if (!getPage().getWebClient().getBrowserVersion() + .hasFeature(BrowserVersionFeatures.BUTTON_EMPTY_TYPE_BUTTON)) { final HtmlSubmitInput submit = form.getFirstByXPath(".//input[@type='submit']"); if (submit != null) { return submit.click(); @@ -1124,7 +1125,7 @@ final HtmlPage page = (HtmlPage) getPage(); page.setFocusedElement(this); final WebClient webClient = page.getWebClient(); - if (webClient.getBrowserVersion().isIE()) { + if (webClient.getBrowserVersion().hasFeature(BrowserVersionFeatures.WINDOW_ACTIVE_ELEMENT_FOCUSED)) { final HTMLElement jsElt = (HTMLElement) getScriptObject(); jsElt.jsxFunction_setActive(); } Modified: trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/FF2.properties =================================================================== --- trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/FF2.properties 2010-05-08 13:02:26 UTC (rev 5706) +++ trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/FF2.properties 2010-05-08 13:30:27 UTC (rev 5707) @@ -1,8 +1,9 @@ BLUR_BEFORE_ONCHANGE -DISPLAYED_COLLAPSE CAN_INHERIT_CSS_PROPERTY_VALUES CREATEEVENT_INITALIZES_TARGET DIALOGWINDOW_REFERER +DISPLAYED_COLLAPSE +EVENT_INPUT EXECCOMMAND_THROWS_ON_WRONG_COMMAND JS_FRAME_RESOLVE_URL_WITH_PARENT_WINDOW SET_READONLY_PROPERTIES Modified: trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/FF3.6.properties =================================================================== --- trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/FF3.6.properties 2010-05-08 13:02:26 UTC (rev 5706) +++ trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/FF3.6.properties 2010-05-08 13:30:27 UTC (rev 5707) @@ -1,6 +1,7 @@ CAN_INHERIT_CSS_PROPERTY_VALUES +DIALOGWINDOW_REFERER DISPLAYED_COLLAPSE -DIALOGWINDOW_REFERER +EVENT_INPUT JS_FRAME_RESOLVE_URL_WITH_PARENT_WINDOW STRING_TRIM STYLESHEET_HREF_EXPANDURL Modified: trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/FF3.properties =================================================================== --- trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/FF3.properties 2010-05-08 13:02:26 UTC (rev 5706) +++ trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/FF3.properties 2010-05-08 13:30:27 UTC (rev 5707) @@ -1,6 +1,7 @@ CAN_INHERIT_CSS_PROPERTY_VALUES DISPLAYED_COLLAPSE DIALOGWINDOW_REFERER +EVENT_INPUT JS_FRAME_RESOLVE_URL_WITH_PARENT_WINDOW STYLESHEET_HREF_EXPANDURL STYLESHEET_HREF_STYLE_NULL Modified: trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/IE6.properties =================================================================== --- trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/IE6.properties 2010-05-08 13:02:26 UTC (rev 5706) +++ trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/IE6.properties 2010-05-08 13:30:27 UTC (rev 5707) @@ -1,3 +1,6 @@ +BUTTON_EMPTY_TYPE_BUTTON +DOM_NORMALIZE_REMOVE_CHILDREN +EVENT_PROPERTY_CHANGE EXECCOMMAND_THROWS_ON_WRONG_COMMAND HEADER_CONTENT_DISPOSITION_ABSOLUTE_PATH HTMLOPTION_PREVENT_DISABLED Modified: trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/IE7.properties =================================================================== --- trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/IE7.properties 2010-05-08 13:02:26 UTC (rev 5706) +++ trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/IE7.properties 2010-05-08 13:30:27 UTC (rev 5707) @@ -1,3 +1,6 @@ +BUTTON_EMPTY_TYPE_BUTTON +DOM_NORMALIZE_REMOVE_CHILDREN +EVENT_PROPERTY_CHANGE EXECCOMMAND_THROWS_ON_WRONG_COMMAND HEADER_CONTENT_DISPOSITION_ABSOLUTE_PATH HTMLOPTION_PREVENT_DISABLED Modified: trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/IE8.properties =================================================================== --- trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/IE8.properties 2010-05-08 13:02:26 UTC (rev 5706) +++ trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/IE8.properties 2010-05-08 13:30:27 UTC (rev 5707) @@ -1,3 +1,6 @@ +BUTTON_EMPTY_TYPE_BUTTON +DOM_NORMALIZE_REMOVE_CHILDREN +EVENT_PROPERTY_CHANGE EXECCOMMAND_THROWS_ON_WRONG_COMMAND HEADER_CONTENT_DISPOSITION_ABSOLUTE_PATH HTMLOPTION_PREVENT_DISABLED This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |