Title: [154242] trunk/Source/WebCore
- Revision
- 154242
- Author
- [email protected]
- Date
- 2013-08-17 15:46:16 -0700 (Sat, 17 Aug 2013)
Log Message
<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.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (154241 => 154242)
--- trunk/Source/WebCore/ChangeLog 2013-08-17 22:05:27 UTC (rev 154241)
+++ trunk/Source/WebCore/ChangeLog 2013-08-17 22:46:16 UTC (rev 154242)
@@ -1,5 +1,19 @@
2013-08-17 Antti Koivisto <[email protected]>
+ <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.
+
+2013-08-17 Antti Koivisto <[email protected]>
+
<https://webkit.org/b/119960> Remove some optimizations made obsolete by use of StringBuilder
Reviewed by Andreas Kling.
Modified: trunk/Source/WebCore/dom/StyleElement.cpp (154241 => 154242)
--- trunk/Source/WebCore/dom/StyleElement.cpp 2013-08-17 22:05:27 UTC (rev 154241)
+++ trunk/Source/WebCore/dom/StyleElement.cpp 2013-08-17 22:46:16 UTC (rev 154242)
@@ -30,18 +30,12 @@
#include "MediaQueryEvaluator.h"
#include "ScriptableDocumentParser.h"
#include "StyleSheetContents.h"
+#include "TextNodeTraversal.h"
#include <wtf/text/StringBuilder.h>
#include <wtf/text/TextPosition.h>
namespace WebCore {
-static bool isValidStyleChild(Node* node)
-{
- ASSERT(node);
- Node::NodeType nodeType = node->nodeType();
- return nodeType == Node::TEXT_NODE || nodeType == Node::CDATA_SECTION_NODE;
-}
-
static bool isCSS(Element* element, const AtomicString& type)
{
return type.isEmpty() || (element->isHTMLElement() ? equalIgnoringCase(type, "text/css") : (type == "text/css"));
@@ -110,33 +104,14 @@
m_createdByParser = false;
}
-void StyleElement::process(Element* e)
+void StyleElement::process(Element* element)
{
- if (!e || !e->inDocument())
+ if (!element || !element->inDocument())
return;
- unsigned resultLength = 0;
- for (Node* c = e->firstChild(); c; c = c->nextSibling()) {
- if (isValidStyleChild(c)) {
- unsigned length = c->nodeValue().length();
- if (length > std::numeric_limits<unsigned>::max() - resultLength) {
- createSheet(e, m_startLineNumber, "");
- return;
- }
- resultLength += length;
- }
- }
- StringBuilder sheetText;
- sheetText.reserveCapacity(resultLength);
+ String sheetText = TextNodeTraversal::contentsAsString(element);
- for (Node* c = e->firstChild(); c; c = c->nextSibling()) {
- if (isValidStyleChild(c)) {
- sheetText.append(c->nodeValue());
- }
- }
- ASSERT(sheetText.length() == resultLength);
-
- createSheet(e, m_startLineNumber, sheetText.toString());
+ createSheet(element, m_startLineNumber, sheetText);
}
void StyleElement::clearSheet()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes