{@inheritDoc}
(final boolean deep)
| 2061 | * {@inheritDoc} |
| 2062 | */ |
| 2063 | @Override |
| 2064 | public HtmlPage cloneNode(final boolean deep) { |
| 2065 | // we need the ScriptObject clone before cloning the kids. |
| 2066 | final HtmlPage result = (HtmlPage) super.cloneNode(false); |
| 2067 | if (getWebClient().isJavaScriptEnabled()) { |
| 2068 | final HtmlUnitScriptable jsObjClone = getScriptableObject().clone(); |
| 2069 | jsObjClone.setDomNode(result); |
| 2070 | } |
| 2071 | |
| 2072 | // if deep, clone the kids too, and re initialize parts of the clone |
| 2073 | if (deep) { |
| 2074 | // this was previously synchronized but that makes not sense, why |
| 2075 | // lock the source against a copy only one has a reference too, |
| 2076 | // because result is a local reference |
| 2077 | result.attributeListeners_ = null; |
| 2078 | |
| 2079 | result.selectionRanges_ = new ArrayList<>(3); |
| 2080 | // the original one is synchronized so we should do that here too, shouldn't we? |
| 2081 | result.afterLoadActions_ = Collections.synchronizedList(new ArrayList<>()); |
| 2082 | result.frameElements_ = new ArrayList<>(); |
| 2083 | for (DomNode child = getFirstChild(); child != null; child = child.getNextSibling()) { |
| 2084 | result.appendChild(child.cloneNode(true)); |
| 2085 | } |
| 2086 | } |
| 2087 | return result; |
| 2088 | } |
| 2089 | |
| 2090 | /** |
| 2091 | * Adds an HtmlAttributeChangeListener to the listener list. |