<https://webkit.org/b/119959> Add TextNodeTraversal

Reviewed by Andreas Kling.

Add TextNodeTraversal for cleaner and more compact traversal of Text nodes.
        
Use it where appropriate.

* WebCore.xcodeproj/project.pbxproj:
* dom/Attr.cpp:
(WebCore::Attr::childrenChanged):
* dom/NodeTraversal.h:
(WebCore::NodeTraversal::next):
* dom/ScriptElement.cpp:
(WebCore::ScriptElement::scriptContent):
* dom/Text.cpp:
(WebCore::Text::wholeText):
* dom/Text.h:
(WebCore::toText):
* dom/TextNodeTraversal.cpp: Added.
(WebCore::TextNodeTraversal::appendContents):
(WebCore::TextNodeTraversal::contentsAsString):
        
    Helpers for getting text content of a subtree.

* dom/TextNodeTraversal.h: Added.
(WebCore::TextNodeTraversal::firstTextChildTemplate):
(WebCore::TextNodeTraversal::firstChild):
(WebCore::TextNodeTraversal::firstTextWithinTemplate):
(WebCore::TextNodeTraversal::firstWithin):
(WebCore::TextNodeTraversal::traverseNextTextTemplate):
(WebCore::TextNodeTraversal::next):
(WebCore::TextNodeTraversal::nextSibling):
* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::joinChildTextNodes):
* html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::defaultValue):
(WebCore::HTMLTextAreaElement::setDefaultValue):
* html/HTMLTitleElement.cpp:
(WebCore::HTMLTitleElement::text):
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::determineTextDirection):
* page/Frame.cpp:
(WebCore::Frame::searchForLabelsAboveCell):
* xml/XPathUtil.cpp:
(WebCore::XPath::stringValue):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154240 268f45cc-cd09-0410-ab3c-d52691b4dbfc
<https://webkit.org/b/119960> Remove some optimizations made obsolete by use of StringBuilder

Reviewed by Andreas Kling.

* dom/ScriptElement.cpp:
(WebCore::ScriptElement::scriptContent):
        
    StringBuilder already optimizes for the single string case. If there is only one the original string is returned.

* dom/Text.cpp:
(WebCore::Text::wholeText):
        
    No need to traverse twice to compute the capacity. StringBuilder handles this efficiently. 
    Also in the common case there is only one string and the optimization here is actually hurting by disabling the StringBuilder one.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154241 268f45cc-cd09-0410-ab3c-d52691b4dbfc
<https://webkit.org/b/119963> Use TextNodeTraversal for getting sheet text in StyleElement

Reviewed by Andreas Kling.

* dom/StyleElement.cpp:
(WebCore::StyleElement::process):
        
    Use TextNodeTraversal::contentsAsString for the sheet text. The overflow check is removed as StringBuilder 
    (which is used by contentsAsString) does that itself. The behavior in case of overflow changes from empty
    sheet to CRASH(). Thats what we do elsewhere in similar situations too (scripts for example). Continuing
    with > 4GB of style sheet text nodes is probably not going to go well anyway.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154242 268f45cc-cd09-0410-ab3c-d52691b4dbfc