| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 // not execute them. | 126 // not execute them. |
| 127 void flushPendingText(FlushMode); | 127 void flushPendingText(FlushMode); |
| 128 | 128 |
| 129 // Called before every token in HTMLTreeBuilder::processToken, thus inlined: | 129 // Called before every token in HTMLTreeBuilder::processToken, thus inlined: |
| 130 void flush(FlushMode mode) { | 130 void flush(FlushMode mode) { |
| 131 if (!hasPendingTasks()) | 131 if (!hasPendingTasks()) |
| 132 return; | 132 return; |
| 133 flushPendingText(mode); | 133 flushPendingText(mode); |
| 134 // NOTE: Possible reentrancy via JavaScript execution. | 134 // NOTE: Possible reentrancy via JavaScript execution. |
| 135 executeQueuedTasks(); | 135 executeQueuedTasks(); |
| 136 ASSERT(mode == FlushIfAtTextLimit || !hasPendingTasks()); | 136 DCHECK(mode == FlushIfAtTextLimit || !hasPendingTasks()); |
| 137 } | 137 } |
| 138 | 138 |
| 139 bool hasPendingTasks() { | 139 bool hasPendingTasks() { |
| 140 return !m_pendingText.isEmpty() || !m_taskQueue.isEmpty(); | 140 return !m_pendingText.isEmpty() || !m_taskQueue.isEmpty(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void setDefaultCompatibilityMode(); | 143 void setDefaultCompatibilityMode(); |
| 144 void processEndOfFile(); | 144 void processEndOfFile(); |
| 145 void finishedParsing(); | 145 void finishedParsing(); |
| 146 | 146 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 class PendingText final { | 284 class PendingText final { |
| 285 DISALLOW_NEW(); | 285 DISALLOW_NEW(); |
| 286 | 286 |
| 287 public: | 287 public: |
| 288 PendingText() : whitespaceMode(WhitespaceUnknown) {} | 288 PendingText() : whitespaceMode(WhitespaceUnknown) {} |
| 289 | 289 |
| 290 void append(ContainerNode* newParent, | 290 void append(ContainerNode* newParent, |
| 291 Node* newNextChild, | 291 Node* newNextChild, |
| 292 const StringView& newString, | 292 const StringView& newString, |
| 293 WhitespaceMode newWhitespaceMode) { | 293 WhitespaceMode newWhitespaceMode) { |
| 294 ASSERT(!parent || parent == newParent); | 294 DCHECK(!parent || parent == newParent); |
| 295 parent = newParent; | 295 parent = newParent; |
| 296 ASSERT(!nextChild || nextChild == newNextChild); | 296 DCHECK(!nextChild || nextChild == newNextChild); |
| 297 nextChild = newNextChild; | 297 nextChild = newNextChild; |
| 298 stringBuilder.append(newString); | 298 stringBuilder.append(newString); |
| 299 whitespaceMode = std::min(whitespaceMode, newWhitespaceMode); | 299 whitespaceMode = std::min(whitespaceMode, newWhitespaceMode); |
| 300 } | 300 } |
| 301 | 301 |
| 302 void swap(PendingText& other) { | 302 void swap(PendingText& other) { |
| 303 std::swap(whitespaceMode, other.whitespaceMode); | 303 std::swap(whitespaceMode, other.whitespaceMode); |
| 304 parent.swap(other.parent); | 304 parent.swap(other.parent); |
| 305 nextChild.swap(other.nextChild); | 305 nextChild.swap(other.nextChild); |
| 306 stringBuilder.swap(other.stringBuilder); | 306 stringBuilder.swap(other.stringBuilder); |
| 307 } | 307 } |
| 308 | 308 |
| 309 void discard() { | 309 void discard() { |
| 310 PendingText discardedText; | 310 PendingText discardedText; |
| 311 swap(discardedText); | 311 swap(discardedText); |
| 312 } | 312 } |
| 313 | 313 |
| 314 bool isEmpty() { | 314 bool isEmpty() { |
| 315 // When the stringbuilder is empty, the parent and whitespace should also | 315 // When the stringbuilder is empty, the parent and whitespace should also |
| 316 // be "empty". | 316 // be "empty". |
| 317 ASSERT(stringBuilder.isEmpty() == !parent); | 317 DCHECK_EQ(stringBuilder.isEmpty(), !parent); |
| 318 ASSERT(!stringBuilder.isEmpty() || !nextChild); | 318 DCHECK(!stringBuilder.isEmpty() || !nextChild); |
| 319 ASSERT(!stringBuilder.isEmpty() || (whitespaceMode == WhitespaceUnknown)); | 319 DCHECK(!stringBuilder.isEmpty() || (whitespaceMode == WhitespaceUnknown)); |
| 320 return stringBuilder.isEmpty(); | 320 return stringBuilder.isEmpty(); |
| 321 } | 321 } |
| 322 | 322 |
| 323 DECLARE_TRACE(); | 323 DECLARE_TRACE(); |
| 324 | 324 |
| 325 Member<ContainerNode> parent; | 325 Member<ContainerNode> parent; |
| 326 Member<Node> nextChild; | 326 Member<Node> nextChild; |
| 327 StringBuilder stringBuilder; | 327 StringBuilder stringBuilder; |
| 328 WhitespaceMode whitespaceMode; | 328 WhitespaceMode whitespaceMode; |
| 329 }; | 329 }; |
| 330 | 330 |
| 331 PendingText m_pendingText; | 331 PendingText m_pendingText; |
| 332 | 332 |
| 333 ParserContentPolicy m_parserContentPolicy; | 333 ParserContentPolicy m_parserContentPolicy; |
| 334 bool m_isParsingFragment; | 334 bool m_isParsingFragment; |
| 335 | 335 |
| 336 // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.ht
ml#parsing-main-intable | 336 // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.ht
ml#parsing-main-intable |
| 337 // In the "in table" insertion mode, we sometimes get into a state where | 337 // In the "in table" insertion mode, we sometimes get into a state where |
| 338 // "whenever a node would be inserted into the current node, it must instead | 338 // "whenever a node would be inserted into the current node, it must instead |
| 339 // be foster parented." This flag tracks whether we're in that state. | 339 // be foster parented." This flag tracks whether we're in that state. |
| 340 bool m_redirectAttachToFosterParent; | 340 bool m_redirectAttachToFosterParent; |
| 341 | 341 |
| 342 bool m_inQuirksMode; | 342 bool m_inQuirksMode; |
| 343 }; | 343 }; |
| 344 | 344 |
| 345 } // namespace blink | 345 } // namespace blink |
| 346 | 346 |
| 347 #endif // HTMLConstructionSite_h | 347 #endif // HTMLConstructionSite_h |
| OLD | NEW |