Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. |
| 3 * Copyright (C) 2011 Apple Inc. All rights reserved. | 3 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 | 224 |
| 225 static String atomizeIfAllWhitespace(const String& string, WhitespaceMode whites paceMode) | 225 static String atomizeIfAllWhitespace(const String& string, WhitespaceMode whites paceMode) |
| 226 { | 226 { |
| 227 // Strings composed entirely of whitespace are likely to be repeated. | 227 // Strings composed entirely of whitespace are likely to be repeated. |
| 228 // Turn them into AtomicString so we share a single string for each. | 228 // Turn them into AtomicString so we share a single string for each. |
| 229 if (whitespaceMode == AllWhitespace || (whitespaceMode == WhitespaceUnknown && isAllWhitespace(string))) | 229 if (whitespaceMode == AllWhitespace || (whitespaceMode == WhitespaceUnknown && isAllWhitespace(string))) |
| 230 return AtomicString(string).string(); | 230 return AtomicString(string).string(); |
| 231 return string; | 231 return string; |
| 232 } | 232 } |
| 233 | 233 |
| 234 void HTMLConstructionSite::flushPendingText() | 234 void HTMLConstructionSite::flushPendingText(bool force) |
| 235 { | 235 { |
| 236 if (m_pendingText.isEmpty()) | 236 if (m_pendingText.isEmpty()) |
| 237 return; | 237 return; |
| 238 | 238 |
| 239 if (!force && !shouldUseLengthLimit(*m_pendingText.parent)) | |
| 240 return; | |
| 241 | |
| 239 PendingText pendingText; | 242 PendingText pendingText; |
| 240 // Hold onto the current pending text on the stack so that queueTask doesn't recurse infinitely. | 243 // Hold onto the current pending text on the stack so that queueTask doesn't recurse infinitely. |
| 241 m_pendingText.swap(pendingText); | 244 m_pendingText.swap(pendingText); |
| 242 ASSERT(m_pendingText.isEmpty()); | 245 ASSERT(m_pendingText.isEmpty()); |
| 243 | 246 |
| 244 // Splitting text nodes into smaller chunks contradicts HTML5 spec, but is n ecessary | 247 // Splitting text nodes into smaller chunks contradicts HTML5 spec, but is n ecessary |
| 245 // for performance, see: https://bugs.webkit.org/show_bug.cgi?id=55898 | 248 // for performance, see: https://bugs.webkit.org/show_bug.cgi?id=55898 |
| 246 unsigned lengthLimit = textLengthLimitForContainer(*pendingText.parent); | 249 unsigned lengthLimit = textLengthLimitForContainer(*pendingText.parent); |
| 247 | 250 |
| 248 unsigned currentPosition = 0; | 251 unsigned currentPosition = 0; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 262 | 265 |
| 263 ASSERT(breakIndex > currentPosition); | 266 ASSERT(breakIndex > currentPosition); |
| 264 ASSERT(breakIndex - currentPosition == substring.length()); | 267 ASSERT(breakIndex - currentPosition == substring.length()); |
| 265 ASSERT(toText(task.child.get())->length() == substring.length()); | 268 ASSERT(toText(task.child.get())->length() == substring.length()); |
| 266 currentPosition = breakIndex; | 269 currentPosition = breakIndex; |
| 267 } | 270 } |
| 268 } | 271 } |
| 269 | 272 |
| 270 void HTMLConstructionSite::queueTask(const HTMLConstructionSiteTask& task) | 273 void HTMLConstructionSite::queueTask(const HTMLConstructionSiteTask& task) |
| 271 { | 274 { |
| 272 flushPendingText(); | 275 flushPendingText(true); |
| 273 ASSERT(m_pendingText.isEmpty()); | 276 ASSERT(m_pendingText.isEmpty()); |
| 274 m_taskQueue.append(task); | 277 m_taskQueue.append(task); |
| 275 } | 278 } |
| 276 | 279 |
| 277 void HTMLConstructionSite::attachLater(ContainerNode* parent, PassRefPtrWillBeRa wPtr<Node> prpChild, bool selfClosing) | 280 void HTMLConstructionSite::attachLater(ContainerNode* parent, PassRefPtrWillBeRa wPtr<Node> prpChild, bool selfClosing) |
| 278 { | 281 { |
| 279 ASSERT(scriptingContentIsAllowed(m_parserContentPolicy) || !prpChild.get()-> isElementNode() || !toScriptLoaderIfPossible(toElement(prpChild.get()))); | 282 ASSERT(scriptingContentIsAllowed(m_parserContentPolicy) || !prpChild.get()-> isElementNode() || !toScriptLoaderIfPossible(toElement(prpChild.get()))); |
| 280 ASSERT(pluginContentIsAllowed(m_parserContentPolicy) || !isHTMLPlugInElement (prpChild)); | 283 ASSERT(pluginContentIsAllowed(m_parserContentPolicy) || !isHTMLPlugInElement (prpChild)); |
| 281 | 284 |
| 282 HTMLConstructionSiteTask task(HTMLConstructionSiteTask::Insert); | 285 HTMLConstructionSiteTask task(HTMLConstructionSiteTask::Insert); |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 682 findFosterSite(dummyTask); | 685 findFosterSite(dummyTask); |
| 683 | 686 |
| 684 // FIXME: This probably doesn't need to be done both here and in insert(Task ). | 687 // FIXME: This probably doesn't need to be done both here and in insert(Task ). |
| 685 if (isHTMLTemplateElement(*dummyTask.parent)) | 688 if (isHTMLTemplateElement(*dummyTask.parent)) |
| 686 dummyTask.parent = toHTMLTemplateElement(dummyTask.parent.get())->conten t(); | 689 dummyTask.parent = toHTMLTemplateElement(dummyTask.parent.get())->conten t(); |
| 687 | 690 |
| 688 // Unclear when parent != case occurs. Somehow we insert text into two separ ate nodes while processing the same Token. | 691 // Unclear when parent != case occurs. Somehow we insert text into two separ ate nodes while processing the same Token. |
| 689 // The nextChild != dummy.nextChild case occurs whenever foster parenting ha ppened and we hit a new text node "<table>a</table>b" | 692 // The nextChild != dummy.nextChild case occurs whenever foster parenting ha ppened and we hit a new text node "<table>a</table>b" |
| 690 // In either case we have to flush the pending text into the task queue befo re making more. | 693 // In either case we have to flush the pending text into the task queue befo re making more. |
| 691 if (!m_pendingText.isEmpty() && (m_pendingText.parent != dummyTask.parent || m_pendingText.nextChild != dummyTask.nextChild)) | 694 if (!m_pendingText.isEmpty() && (m_pendingText.parent != dummyTask.parent || m_pendingText.nextChild != dummyTask.nextChild)) |
| 692 flushPendingText(); | 695 flushPendingText(true); |
|
eseidel
2014/08/23 19:39:59
We'll need to fix this to be an enum (bools make f
eustas
2014/08/26 08:12:25
Added enum.
Now codesearch is working again. I've
| |
| 693 m_pendingText.append(dummyTask.parent, dummyTask.nextChild, string, whitespa ceMode); | 696 m_pendingText.append(dummyTask.parent, dummyTask.nextChild, string, whitespa ceMode); |
| 694 } | 697 } |
| 695 | 698 |
| 696 void HTMLConstructionSite::reparent(HTMLElementStack::ElementRecord* newParent, HTMLElementStack::ElementRecord* child) | 699 void HTMLConstructionSite::reparent(HTMLElementStack::ElementRecord* newParent, HTMLElementStack::ElementRecord* child) |
| 697 { | 700 { |
| 698 HTMLConstructionSiteTask task(HTMLConstructionSiteTask::Reparent); | 701 HTMLConstructionSiteTask task(HTMLConstructionSiteTask::Reparent); |
| 699 task.parent = newParent->node(); | 702 task.parent = newParent->node(); |
| 700 task.child = child->node(); | 703 task.child = child->node(); |
| 701 queueTask(task); | 704 queueTask(task); |
| 702 } | 705 } |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 871 } | 874 } |
| 872 | 875 |
| 873 void HTMLConstructionSite::PendingText::trace(Visitor* visitor) | 876 void HTMLConstructionSite::PendingText::trace(Visitor* visitor) |
| 874 { | 877 { |
| 875 visitor->trace(parent); | 878 visitor->trace(parent); |
| 876 visitor->trace(nextChild); | 879 visitor->trace(nextChild); |
| 877 } | 880 } |
| 878 | 881 |
| 879 | 882 |
| 880 } | 883 } |
| OLD | NEW |