diff options
author | Chris Burdess <dog@bluezoo.org> | 2005-03-14 21:10:55 +0000 |
---|---|---|
committer | Chris Burdess <dog@bluezoo.org> | 2005-03-14 21:10:55 +0000 |
commit | 979240c8070a8c66ab7cea9af3c83e110f1cb183 (patch) | |
tree | eb3d6c35c5896c24ba267c9d2ce57b44344ce20b | |
parent | f519552dd3a17e6c8896050a9e2c767db5f21734 (diff) | |
download | classpath-979240c8070a8c66ab7cea9af3c83e110f1cb183.tar.gz |
2005-03-14 Chris Burdess <dog@gnu.org>
* gnu/xml/dom/DomImpl.java,
gnu/xml/dom/html2/DomHTMLAnchorElement.java,
gnu/xml/dom/html2/DomHTMLDocument.java,
gnu/xml/dom/html2/DomHTMLElement.java,
gnu/xml/dom/html2/DomHTMLFormElement.java,
gnu/xml/dom/html2/DomHTMLFrameElement.java,
gnu/xml/dom/html2/DomHTMLIFrameElement.java,
gnu/xml/dom/html2/DomHTMLImpl.java,
gnu/xml/dom/html2/DomHTMLInputElement.java,
gnu/xml/dom/html2/DomHTMLObjectElement.java,
gnu/xml/dom/html2/DomHTMLOptionElement.java,
gnu/xml/dom/html2/DomHTMLSelectElement.java,
gnu/xml/dom/html2/DomHTMLTableCellElement.java,
gnu/xml/dom/html2/DomHTMLTableElement.java,
gnu/xml/dom/html2/DomHTMLTableRowElement.java,
gnu/xml/dom/html2/DomHTMLTableSectionElement.java,
gnu/xml/dom/html2/DomHTMLTextAreaElement.java: JAXP integration,
UI events, and tree utility functions.
-rw-r--r-- | ChangeLog | 21 | ||||
-rw-r--r-- | gnu/xml/dom/DomImpl.java | 19 | ||||
-rw-r--r-- | gnu/xml/dom/html2/DomHTMLAnchorElement.java | 4 | ||||
-rw-r--r-- | gnu/xml/dom/html2/DomHTMLDocument.java | 43 | ||||
-rw-r--r-- | gnu/xml/dom/html2/DomHTMLElement.java | 49 | ||||
-rw-r--r-- | gnu/xml/dom/html2/DomHTMLFormElement.java | 4 | ||||
-rw-r--r-- | gnu/xml/dom/html2/DomHTMLFrameElement.java | 2 | ||||
-rw-r--r-- | gnu/xml/dom/html2/DomHTMLIFrameElement.java | 2 | ||||
-rw-r--r-- | gnu/xml/dom/html2/DomHTMLImpl.java | 67 | ||||
-rw-r--r-- | gnu/xml/dom/html2/DomHTMLInputElement.java | 8 | ||||
-rw-r--r-- | gnu/xml/dom/html2/DomHTMLObjectElement.java | 2 | ||||
-rw-r--r-- | gnu/xml/dom/html2/DomHTMLOptionElement.java | 3 | ||||
-rw-r--r-- | gnu/xml/dom/html2/DomHTMLSelectElement.java | 4 | ||||
-rw-r--r-- | gnu/xml/dom/html2/DomHTMLTableCellElement.java | 3 | ||||
-rw-r--r-- | gnu/xml/dom/html2/DomHTMLTableElement.java | 179 | ||||
-rw-r--r-- | gnu/xml/dom/html2/DomHTMLTableRowElement.java | 94 | ||||
-rw-r--r-- | gnu/xml/dom/html2/DomHTMLTableSectionElement.java | 42 | ||||
-rw-r--r-- | gnu/xml/dom/html2/DomHTMLTextAreaElement.java | 6 |
18 files changed, 490 insertions, 62 deletions
@@ -1,3 +1,24 @@ +2005-03-14 Chris Burdess <dog@gnu.org> + + * gnu/xml/dom/DomImpl.java, + gnu/xml/dom/html2/DomHTMLAnchorElement.java, + gnu/xml/dom/html2/DomHTMLDocument.java, + gnu/xml/dom/html2/DomHTMLElement.java, + gnu/xml/dom/html2/DomHTMLFormElement.java, + gnu/xml/dom/html2/DomHTMLFrameElement.java, + gnu/xml/dom/html2/DomHTMLIFrameElement.java, + gnu/xml/dom/html2/DomHTMLImpl.java, + gnu/xml/dom/html2/DomHTMLInputElement.java, + gnu/xml/dom/html2/DomHTMLObjectElement.java, + gnu/xml/dom/html2/DomHTMLOptionElement.java, + gnu/xml/dom/html2/DomHTMLSelectElement.java, + gnu/xml/dom/html2/DomHTMLTableCellElement.java, + gnu/xml/dom/html2/DomHTMLTableElement.java, + gnu/xml/dom/html2/DomHTMLTableRowElement.java, + gnu/xml/dom/html2/DomHTMLTableSectionElement.java, + gnu/xml/dom/html2/DomHTMLTextAreaElement.java: JAXP integration, + UI events, and tree utility functions. + 2005-03-14 Patrik Reali <reali@acm.org> * doc/www.gnu.org/newsitems.txt: news on gui branch and calientra diff --git a/gnu/xml/dom/DomImpl.java b/gnu/xml/dom/DomImpl.java index feb7ea703..a23f57d93 100644 --- a/gnu/xml/dom/DomImpl.java +++ b/gnu/xml/dom/DomImpl.java @@ -47,6 +47,7 @@ import org.w3c.dom.ls.LSInput; import org.w3c.dom.ls.LSOutput; import org.w3c.dom.ls.LSParser; import org.w3c.dom.ls.LSSerializer; +import gnu.xml.dom.html2.DomHTMLImpl; import gnu.xml.dom.ls.DomLSInput; import gnu.xml.dom.ls.DomLSOutput; import gnu.xml.dom.ls.DomLSParser; @@ -150,6 +151,12 @@ public class DomImpl "".equals(version) || "3.0".equals(version)); } + else if ("html".equals(name) || "xhtml".equals(name)) + { + return (version == null || + "".equals(version) || + "2.0".equals(version)); + } // views // stylesheets @@ -199,7 +206,7 @@ public class DomImpl String rootName, DocumentType doctype) { - Document doc = new DomDocument(this); + Document doc = createDocument(); Element root = null; if (rootName != null) @@ -223,12 +230,22 @@ public class DomImpl return doc; } + protected Document createDocument() + { + return new DomDocument(this); + } + // DOM Level 3 public Object getFeature(String feature, String version) { if (hasFeature(feature, version)) { + if ("html".equalsIgnoreCase(feature) || + "xhtml".equalsIgnoreCase(feature)) + { + return new DomHTMLImpl(); + } return this; } return null; diff --git a/gnu/xml/dom/html2/DomHTMLAnchorElement.java b/gnu/xml/dom/html2/DomHTMLAnchorElement.java index 041666f6d..625fa6c93 100644 --- a/gnu/xml/dom/html2/DomHTMLAnchorElement.java +++ b/gnu/xml/dom/html2/DomHTMLAnchorElement.java @@ -177,12 +177,12 @@ public class DomHTMLAnchorElement public void blur() { - // TODO + dispatchUIEvent("blur"); } public void focus() { - // TODO + dispatchUIEvent("focus"); } } diff --git a/gnu/xml/dom/html2/DomHTMLDocument.java b/gnu/xml/dom/html2/DomHTMLDocument.java index 9a3182916..74b3878fd 100644 --- a/gnu/xml/dom/html2/DomHTMLDocument.java +++ b/gnu/xml/dom/html2/DomHTMLDocument.java @@ -133,10 +133,21 @@ public class DomHTMLDocument map.put("thead", DomHTMLTableSectionElement.class); map.put("tfoot", DomHTMLTableSectionElement.class); map.put("tbody", DomHTMLTableSectionElement.class); - // TODO others + map.put("textarea", DomHTMLTextAreaElement.class); + map.put("title", DomHTMLTitleElement.class); + map.put("ul", DomHTMLUListElement.class); ELEMENT_CLASSES = Collections.unmodifiableMap(map); } + /** + * Constructor. + * This is called by the implementation. + */ + protected DomHTMLDocument(DomHTMLImpl impl) + { + super(impl); + } + private Node getChildNodeByName(Node parent, String name) { for (Node ctx = parent.getFirstChild(); ctx != null; @@ -209,7 +220,7 @@ public class DomHTMLDocument public String getReferrer() { - // TODO + // TODO getReferrer return null; } @@ -248,7 +259,21 @@ public class DomHTMLDocument public void setBody(HTMLElement body) { - // TODO + Node html = getDocumentElement(); + if (html == null) + { + html = createElement("html"); + appendChild(html); + } + Node ref = getBody(); + if (ref == null) + { + html.appendChild(body); + } + else + { + html.replaceChild(body, ref); + } } public HTMLCollection getImages() @@ -296,33 +321,33 @@ public class DomHTMLDocument public String getCookie() { - // TODO + // TODO getCookie return null; } public void setCookie(String cookie) { - // TODO + // TODO setCookie } public void open() { - // TODO + // TODO open } public void close() { - // TODO + // TODO close } public void write(String text) { - // TODO + // TODO write } public void writeln(String text) { - // TODO + // TODO write } public NodeList getElementsByName(String name) diff --git a/gnu/xml/dom/html2/DomHTMLElement.java b/gnu/xml/dom/html2/DomHTMLElement.java index b204139fa..b2952e8b4 100644 --- a/gnu/xml/dom/html2/DomHTMLElement.java +++ b/gnu/xml/dom/html2/DomHTMLElement.java @@ -37,9 +37,13 @@ exception statement from your version. */ package gnu.xml.dom.html2; +import gnu.xml.dom.DomDOMException; import gnu.xml.dom.DomElement; +import gnu.xml.dom.DomEvent; +import org.w3c.dom.DOMException; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; +import org.w3c.dom.events.UIEvent; import org.w3c.dom.html2.HTMLElement; /** @@ -166,6 +170,51 @@ public abstract class DomHTMLElement return null; } + /** + * Returns the first child element with the specified name. + */ + protected Node getChildElement(String name) + { + for (Node child = getFirstChild(); child != null; + child = child.getNextSibling()) + { + if (name.equalsIgnoreCase(child.getLocalName())) + { + return child; + } + } + return null; + } + + /** + * Returns the index of this element among elements of the same name, + * relative to its parent. + */ + protected int getIndex() + { + int index = 0; + Node parent = getParentNode(); + if (parent != null) + { + for (Node ctx = parent.getFirstChild(); ctx != null; + ctx = ctx.getNextSibling()) + { + if (ctx == this) + { + return index; + } + index++; + } + } + throw new DomDOMException(DOMException.NOT_FOUND_ERR); + } + + protected void dispatchUIEvent(String name) + { + UIEvent event = new DomEvent.DomUIEvent(name); + dispatchEvent(event); + } + public String getId() { return getHTMLAttribute("id"); diff --git a/gnu/xml/dom/html2/DomHTMLFormElement.java b/gnu/xml/dom/html2/DomHTMLFormElement.java index 041e15eb4..0785cc989 100644 --- a/gnu/xml/dom/html2/DomHTMLFormElement.java +++ b/gnu/xml/dom/html2/DomHTMLFormElement.java @@ -138,12 +138,12 @@ public class DomHTMLFormElement public void submit() { - // TODO + dispatchUIEvent("submit"); } public void reset() { - // TODO + dispatchUIEvent("reset"); } } diff --git a/gnu/xml/dom/html2/DomHTMLFrameElement.java b/gnu/xml/dom/html2/DomHTMLFrameElement.java index 5912cacb6..db3cbfe00 100644 --- a/gnu/xml/dom/html2/DomHTMLFrameElement.java +++ b/gnu/xml/dom/html2/DomHTMLFrameElement.java @@ -138,7 +138,7 @@ public class DomHTMLFrameElement public Document getContentDocument() { - // TODO + // TODO getContentDocument return null; } diff --git a/gnu/xml/dom/html2/DomHTMLIFrameElement.java b/gnu/xml/dom/html2/DomHTMLIFrameElement.java index 8799cbc7a..def7b967d 100644 --- a/gnu/xml/dom/html2/DomHTMLIFrameElement.java +++ b/gnu/xml/dom/html2/DomHTMLIFrameElement.java @@ -158,7 +158,7 @@ public class DomHTMLIFrameElement public Document getContentDocument() { - // TODO + // TODO getContentDocument return null; } diff --git a/gnu/xml/dom/html2/DomHTMLImpl.java b/gnu/xml/dom/html2/DomHTMLImpl.java new file mode 100644 index 000000000..6f5538e71 --- /dev/null +++ b/gnu/xml/dom/html2/DomHTMLImpl.java @@ -0,0 +1,67 @@ +/* DomHTMLImpl.java -- + Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package gnu.xml.dom.html2; + +import gnu.xml.dom.DomImpl; +import org.w3c.dom.Document; + +/** + * Specialised DOMImplementation for creating HTML documents. + * + * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> + */ +public class DomHTMLImpl + extends DomImpl +{ + + protected Document createDocument() + { + return new DomHTMLDocument(this); + } + + public Object getFeature(String feature, String version) + { + if (hasFeature(feature, version)) + { + return this; + } + return null; + } + +} + diff --git a/gnu/xml/dom/html2/DomHTMLInputElement.java b/gnu/xml/dom/html2/DomHTMLInputElement.java index 1a3a8a082..787be536a 100644 --- a/gnu/xml/dom/html2/DomHTMLInputElement.java +++ b/gnu/xml/dom/html2/DomHTMLInputElement.java @@ -244,22 +244,22 @@ public class DomHTMLInputElement public void blur() { - // TODO + dispatchUIEvent("blur"); } public void focus() { - // TODO + dispatchUIEvent("focus"); } public void select() { - // TODO + dispatchUIEvent("select"); } public void click() { - // TODO + dispatchUIEvent("click"); } } diff --git a/gnu/xml/dom/html2/DomHTMLObjectElement.java b/gnu/xml/dom/html2/DomHTMLObjectElement.java index d4dded5a0..8b8abe7ed 100644 --- a/gnu/xml/dom/html2/DomHTMLObjectElement.java +++ b/gnu/xml/dom/html2/DomHTMLObjectElement.java @@ -234,7 +234,7 @@ public class DomHTMLObjectElement public Document getContentDocument() { - // TODO + // TODO getContentDocument return null; } diff --git a/gnu/xml/dom/html2/DomHTMLOptionElement.java b/gnu/xml/dom/html2/DomHTMLOptionElement.java index b1c808fa6..21952e6de 100644 --- a/gnu/xml/dom/html2/DomHTMLOptionElement.java +++ b/gnu/xml/dom/html2/DomHTMLOptionElement.java @@ -80,8 +80,7 @@ public class DomHTMLOptionElement public int getIndex() { - // TODO - return -1; + return super.getIndex(); } public boolean getDisabled() diff --git a/gnu/xml/dom/html2/DomHTMLSelectElement.java b/gnu/xml/dom/html2/DomHTMLSelectElement.java index 6bc9bfc20..b888b57e6 100644 --- a/gnu/xml/dom/html2/DomHTMLSelectElement.java +++ b/gnu/xml/dom/html2/DomHTMLSelectElement.java @@ -199,12 +199,12 @@ public class DomHTMLSelectElement public void blur() { - // TODO + dispatchUIEvent("blur"); } public void focus() { - // TODO + dispatchUIEvent("focus"); } } diff --git a/gnu/xml/dom/html2/DomHTMLTableCellElement.java b/gnu/xml/dom/html2/DomHTMLTableCellElement.java index b89c012a6..6338b88d0 100644 --- a/gnu/xml/dom/html2/DomHTMLTableCellElement.java +++ b/gnu/xml/dom/html2/DomHTMLTableCellElement.java @@ -58,8 +58,7 @@ public class DomHTMLTableCellElement public int getCellIndex() { - // TODO - return -1; + return getIndex(); } public String getAbbr() diff --git a/gnu/xml/dom/html2/DomHTMLTableElement.java b/gnu/xml/dom/html2/DomHTMLTableElement.java index 570b3f1e0..95e295733 100644 --- a/gnu/xml/dom/html2/DomHTMLTableElement.java +++ b/gnu/xml/dom/html2/DomHTMLTableElement.java @@ -37,6 +37,9 @@ exception statement from your version. */ package gnu.xml.dom.html2; +import gnu.xml.dom.DomDOMException; +import org.w3c.dom.DOMException; +import org.w3c.dom.Node; import org.w3c.dom.html2.HTMLCollection; import org.w3c.dom.html2.HTMLElement; import org.w3c.dom.html2.HTMLTableCaptionElement; @@ -61,35 +64,56 @@ public class DomHTMLTableElement public HTMLTableCaptionElement getCaption() { - // TODO - return null; + return (HTMLTableCaptionElement) getChildElement("caption"); } public void setCaption(HTMLTableCaptionElement caption) { - // TODO + HTMLTableCaptionElement ref = getCaption(); + if (ref == null) + { + appendChild(caption); + } + else + { + replaceChild(caption, ref); + } } public HTMLTableSectionElement getTHead() { - // TODO - return null; + return (HTMLTableSectionElement) getChildElement("thead"); } public void setTHead(HTMLTableSectionElement tHead) { - // TODO + HTMLTableSectionElement ref = getTHead(); + if (ref == null) + { + appendChild(tHead); + } + else + { + replaceChild(tHead, ref); + } } public HTMLTableSectionElement getTFoot() { - // TODO - return null; + return (HTMLTableSectionElement) getChildElement("tfoot"); } public void setTFoot(HTMLTableSectionElement tFoot) { - // TODO + HTMLTableSectionElement ref = getTFoot(); + if (ref == null) + { + appendChild(tFoot); + } + else + { + replaceChild(tFoot, ref); + } } public HTMLCollection getRows() @@ -202,47 +226,158 @@ public class DomHTMLTableElement public HTMLElement createTHead() { - // TODO - return null; + HTMLTableSectionElement ref = getTHead(); + if (ref == null) + { + return (HTMLElement) getOwnerDocument().createElement("thead"); + } + else + { + return ref; + } } public void deleteTHead() { - // TODO + HTMLTableSectionElement ref = getTHead(); + if (ref != null) + { + removeChild(ref); + } } public HTMLElement createTFoot() { - // TODO - return null; + HTMLTableSectionElement ref = getTFoot(); + if (ref == null) + { + return (HTMLElement) getOwnerDocument().createElement("tfoot"); + } + else + { + return ref; + } } public void deleteTFoot() { - // TODO + HTMLTableSectionElement ref = getTFoot(); + if (ref != null) + { + removeChild(ref); + } } public HTMLElement createCaption() { - // TODO - return null; + HTMLTableCaptionElement ref = getCaption(); + if (ref == null) + { + return (HTMLElement) getOwnerDocument().createElement("caption"); + } + else + { + return ref; + } } public void deleteCaption() { - // TODO + HTMLTableCaptionElement ref = getCaption(); + if (ref != null) + { + removeChild(ref); + } } public HTMLElement insertRow(int index) { - // TODO - return null; + Node ref = getRow(index); + Node row = getOwnerDocument().createElement("tr"); + if (ref == null) + { + Node tbody = getChildElement("tbody"); + if (tbody == null) + { + tbody = getOwnerDocument().createElement("tfoot"); + appendChild(tbody); + } + tbody.appendChild(row); + } + else + { + ref.getParentNode().insertBefore(row, ref); + } + return (HTMLElement) row; } public void deleteRow(int index) { - // TODO + Node ref = getRow(index); + if (ref == null) + { + throw new DomDOMException(DOMException.INDEX_SIZE_ERR); + } + ref.getParentNode().removeChild(ref); + } + + Node getRow(final int index) + { + int i = 0; + Node thead = getChildElement("thead"); + if (thead != null) + { + for (Node ctx = thead.getFirstChild(); ctx != null; + ctx = ctx.getNextSibling()) + { + if (!"tr".equalsIgnoreCase(ctx.getLocalName())) + { + continue; + } + if (index == i) + { + return ctx; + } + i++; + } + } + Node tbody = getChildElement("tbody"); + if (tbody == null) + { + tbody = this; + } + for (Node ctx = tbody.getFirstChild(); ctx != null; + ctx = ctx.getNextSibling()) + { + if (!"tr".equalsIgnoreCase(ctx.getLocalName())) + { + continue; + } + if (index == i) + { + return ctx; + } + i++; + } + Node tfoot = getChildElement("tfoot"); + if (tfoot != null) + { + for (Node ctx = tfoot.getFirstChild(); ctx != null; + ctx = ctx.getNextSibling()) + { + if (!"tr".equalsIgnoreCase(ctx.getLocalName())) + { + continue; + } + if (index == i) + { + return ctx; + } + i++; + } + } + return null; } - + } diff --git a/gnu/xml/dom/html2/DomHTMLTableRowElement.java b/gnu/xml/dom/html2/DomHTMLTableRowElement.java index 6b40b34e6..e21e158b4 100644 --- a/gnu/xml/dom/html2/DomHTMLTableRowElement.java +++ b/gnu/xml/dom/html2/DomHTMLTableRowElement.java @@ -37,6 +37,9 @@ exception statement from your version. */ package gnu.xml.dom.html2; +import gnu.xml.dom.DomDOMException; +import org.w3c.dom.DOMException; +import org.w3c.dom.Node; import org.w3c.dom.html2.HTMLCollection; import org.w3c.dom.html2.HTMLElement; import org.w3c.dom.html2.HTMLTableRowElement; @@ -60,14 +63,56 @@ public class DomHTMLTableRowElement public int getRowIndex() { - // TODO - return -1; + return getIndex(); } public int getSectionRowIndex() { - // TODO - return -1; + int index = 0; + DomHTMLElement parent = (DomHTMLElement) getParentElement("table"); + if (parent != null) + { + Node thead = parent.getChildElement("thead"); + if (thead != null) + { + for (Node ctx = thead.getFirstChild(); ctx != null; + ctx = ctx.getNextSibling()) + { + if (ctx == this) + { + return index; + } + index++; + } + } + Node tbody = parent.getChildElement("tbody"); + if (tbody != null) + { + for (Node ctx = tbody.getFirstChild(); ctx != null; + ctx = ctx.getNextSibling()) + { + if (ctx == this) + { + return index; + } + index++; + } + } + Node tfoot = parent.getChildElement("tfoot"); + if (tfoot != null) + { + for (Node ctx = tfoot.getFirstChild(); ctx != null; + ctx = ctx.getNextSibling()) + { + if (ctx == this) + { + return index; + } + index++; + } + } + } + throw new DomDOMException(DOMException.NOT_FOUND_ERR); } public HTMLCollection getCells() @@ -132,13 +177,48 @@ public class DomHTMLTableRowElement public HTMLElement insertCell(int index) { - // TODO - return null; + Node ref = getCell(index); + Node cell = getOwnerDocument().createElement("td"); + if (ref == null) + { + appendChild(cell); + } + else + { + insertBefore(cell, ref); + } + return (HTMLElement) cell; } public void deleteCell(int index) { - // TODO + Node ref = getCell(index); + if (ref == null) + { + throw new DomDOMException(DOMException.INDEX_SIZE_ERR); + } + removeChild(ref); + } + + Node getCell(final int index) + { + int i = 0; + for (Node ctx = getFirstChild(); ctx != null; + ctx = ctx.getNextSibling()) + { + String name = ctx.getLocalName(); + if (!"td".equalsIgnoreCase(name) && + !"th".equalsIgnoreCase(name)) + { + continue; + } + if (index == i) + { + return ctx; + } + i++; + } + return null; } } diff --git a/gnu/xml/dom/html2/DomHTMLTableSectionElement.java b/gnu/xml/dom/html2/DomHTMLTableSectionElement.java index c2247dfb7..45dd67110 100644 --- a/gnu/xml/dom/html2/DomHTMLTableSectionElement.java +++ b/gnu/xml/dom/html2/DomHTMLTableSectionElement.java @@ -37,6 +37,9 @@ exception statement from your version. */ package gnu.xml.dom.html2; +import gnu.xml.dom.DomDOMException; +import org.w3c.dom.DOMException; +import org.w3c.dom.Node; import org.w3c.dom.html2.HTMLCollection; import org.w3c.dom.html2.HTMLElement; import org.w3c.dom.html2.HTMLTableSectionElement; @@ -109,13 +112,46 @@ public class DomHTMLTableSectionElement public HTMLElement insertRow(int index) { - // TODO - return null; + Node ref = getRow(index); + Node row = getOwnerDocument().createElement("tr"); + if (ref == null) + { + appendChild(row); + } + else + { + insertBefore(row, ref); + } + return (HTMLElement) row; } public void deleteRow(int index) { - // TODO + Node ref = getRow(index); + if (ref == null) + { + throw new DomDOMException(DOMException.INDEX_SIZE_ERR); + } + removeChild(ref); + } + + Node getRow(final int index) + { + int i = 0; + for (Node ctx = getFirstChild(); ctx != null; + ctx = ctx.getNextSibling()) + { + if (!"tr".equalsIgnoreCase(ctx.getLocalName())) + { + continue; + } + if (index == i) + { + return ctx; + } + i++; + } + return null; } } diff --git a/gnu/xml/dom/html2/DomHTMLTextAreaElement.java b/gnu/xml/dom/html2/DomHTMLTextAreaElement.java index 9ef9b185c..93a918ab9 100644 --- a/gnu/xml/dom/html2/DomHTMLTextAreaElement.java +++ b/gnu/xml/dom/html2/DomHTMLTextAreaElement.java @@ -165,17 +165,17 @@ public class DomHTMLTextAreaElement public void blur() { - // TODO + dispatchUIEvent("blur"); } public void focus() { - // TODO + dispatchUIEvent("focus"); } public void select() { - // TODO + dispatchUIEvent("select"); } } |