Avoid multiple copies of inline script & style strings
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Jun 2013 21:20:40 +0000 (21:20 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Jun 2013 21:20:40 +0000 (21:20 +0000)
commitaaae947bd0bea11f8cfcb288b67aa1777ad2f906
tree1dc12fd4c8961cdaf009fa3d872dac4e9b93435b
parent21c8a2fa223cdf78103b20aec5b6763b775fdb80
Avoid multiple copies of inline script & style strings
https://bugs.webkit.org/show_bug.cgi?id=117202

Patch by Arunprasad Rajkumar <arurajku@cisco.com> on 2013-06-05
Reviewed by Darin Adler.

Merge from https://chromiumcodereview.appspot.com/16005007.

No new tests needed.

The HTML parser breaks up large text nodes into small chunks to avoid some
O(n^2) editing algorithms. This fix skips that workaround for <script> and
<style> elements, which aren't likely to need editing. As a result, <script>
ends up with a single text node, containing a contiguous String, which is the
source code of that inline script block.

Prior this fix, we could end up with two copies of large inline scripts: one
monolithic string retained by JSC and a number of shards retained by the DOM.
After this fix, both the DOM and JSC use the same monolithic string, removing a
copy.

* dom/Text.cpp:
(WebCore::Text::createWithLengthLimit):
* html/parser/HTMLConstructionSite.cpp:
(WebCore::shouldUseLengthLimit):
(WebCore::HTMLConstructionSite::insertTextNode):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@151236 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/dom/Text.cpp
Source/WebCore/html/parser/HTMLConstructionSite.cpp