Avoid reparsing the style attribute when cloning elements.
authorkling@webkit.org <kling@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 May 2012 19:31:40 +0000 (19:31 +0000)
committerkling@webkit.org <kling@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 May 2012 19:31:40 +0000 (19:31 +0000)
commitc4ff9765bdf4c69c74debfdfc9d2eab8bfa33f75
tree41c05cfc9141d88999130e5c41fed17131a41725
parent5e046a2a5f5ad75608276540b3a270e5017e08a8
Avoid reparsing the style attribute when cloning elements.
<http://webkit.org/b/86574>

Reviewed by Antti Koivisto.

Refactor cloning of attributes a bit to dodge the styleAttr reparse previously
caused by ElementAttributeData::setAttributes().

Introduced Element::cloneDataFromElement() which takes care of cloning the
ElementAttributeData as well as "non-attribute properties" (which is currently
specific to HTMLInputElement.)

Also includes some additional dodging of attribute vector traversal to find
old/new 'id' and 'name' attributes.

I'm seeing a ~10% improvement on PerformanceTests/DOM/CloneNodes locally.

* dom/Document.cpp:
(WebCore::Document::importNode):
* dom/Element.cpp:
(WebCore::Element::cloneElementWithoutChildren):
(WebCore::Element::cloneAttributesFromElement):
(WebCore::Element::cloneDataFromElement):
* dom/Element.h:
(WebCore::Element::copyNonAttributePropertiesFromElement):
* dom/ElementAttributeData.cpp:
(WebCore::ElementAttributeData::cloneDataFrom):
* dom/ElementAttributeData.h:
(ElementAttributeData):
* dom/Node.h:
* dom/StyledElement.cpp:
(WebCore::StyledElement::styleAttributeChanged):
(WebCore::StyledElement::parseAttribute):
* dom/StyledElement.h:
* editing/ReplaceNodeWithSpanCommand.cpp:
(WebCore::swapInNodePreservingAttributesAndChildren):
* html/HTMLElement.cpp:
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::copyNonAttributePropertiesFromElement):
* html/HTMLInputElement.h:
* inspector/DOMPatchSupport.cpp:
(WebCore::DOMPatchSupport::innerPatchNode):
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::setNodeName):
* svg/SVGUseElement.cpp:
(WebCore::SVGUseElement::expandSymbolElementsInShadowTree):
(WebCore::SVGUseElement::transferUseAttributesToReplacedElement):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117323 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/dom/ElementAttributeData.cpp
Source/WebCore/dom/ElementAttributeData.h
Source/WebCore/dom/Node.h
Source/WebCore/dom/StyledElement.cpp
Source/WebCore/dom/StyledElement.h
Source/WebCore/editing/ReplaceNodeWithSpanCommand.cpp
Source/WebCore/html/HTMLElement.cpp
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLInputElement.h
Source/WebCore/inspector/DOMPatchSupport.cpp
Source/WebCore/inspector/InspectorDOMAgent.cpp
Source/WebCore/svg/SVGUseElement.cpp