Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1365)

Unified Diff: Source/core/html/parser/HTMLConstructionSite.cpp

Issue 16005007: Mobile Gmail should use 220 kB less memory (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/Text.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/parser/HTMLConstructionSite.cpp
diff --git a/Source/core/html/parser/HTMLConstructionSite.cpp b/Source/core/html/parser/HTMLConstructionSite.cpp
index 171d1d3e2f00e36c732e24041ad1b47d0794ea12..4cecc3db4d99c44d5206d76ed647ef166d2a9986 100644
--- a/Source/core/html/parser/HTMLConstructionSite.cpp
+++ b/Source/core/html/parser/HTMLConstructionSite.cpp
@@ -51,7 +51,8 @@
#include "core/page/Settings.h"
#include "core/platform/LocalizedStrings.h"
#include "core/platform/NotImplemented.h"
-#include <wtf/UnusedParam.h>
+#include "wtf/UnusedParam.h"
+#include <limits>
namespace WebCore {
@@ -78,6 +79,13 @@ static bool hasImpliedEndTag(const HTMLStackItem* item)
|| item->hasTagName(rtTag);
}
+static bool shouldUseLengthLimit(const ContainerNode* node)
+{
+ return !node->hasTagName(scriptTag)
+ && !node->hasTagName(styleTag)
+ && !node->hasTagName(SVGNames::scriptTag);
+}
+
static inline bool isAllWhitespace(const String& string)
{
return string.isAllSpecialCharacters<isHTMLSpace>();
@@ -553,6 +561,7 @@ void HTMLConstructionSite::insertTextNode(const String& characters, WhitespaceMo
|| (whitespaceMode == WhitespaceUnknown && isAllWhitespace(characters));
unsigned currentPosition = 0;
+ unsigned lengthLimit = shouldUseLengthLimit(task.parent.get()) ? Text::defaultLengthLimit : std::numeric_limits<unsigned>::max();
// FIXME: Splitting text nodes into smaller chunks contradicts HTML5 spec, but is currently necessary
// for performance, see <https://bugs.webkit.org/show_bug.cgi?id=55898>.
@@ -562,11 +571,11 @@ void HTMLConstructionSite::insertTextNode(const String& characters, WhitespaceMo
// FIXME: We're only supposed to append to this text node if it
// was the last text node inserted by the parser.
CharacterData* textNode = static_cast<CharacterData*>(previousChild);
- currentPosition = textNode->parserAppendData(characters, 0, Text::defaultLengthLimit);
+ currentPosition = textNode->parserAppendData(characters, 0, lengthLimit);
}
while (currentPosition < characters.length()) {
- RefPtr<Text> textNode = Text::createWithLengthLimit(task.parent->document(), shouldUseAtomicString ? AtomicString(characters).string() : characters, currentPosition);
+ RefPtr<Text> textNode = Text::createWithLengthLimit(task.parent->document(), shouldUseAtomicString ? AtomicString(characters).string() : characters, currentPosition, lengthLimit);
// If we have a whole string of unbreakable characters the above could lead to an infinite loop. Exceeding the length limit is the lesser evil.
if (!textNode->length()) {
String substring = characters.substring(currentPosition);
« no previous file with comments | « Source/core/dom/Text.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698