 Chromium Code Reviews
 Chromium Code Reviews Issue 494993002:
  HTMLConstructionSite: avoid n^2 running time for large scripts.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master
    
  
    Issue 494993002:
  HTMLConstructionSite: avoid n^2 running time for large scripts.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master| Index: Source/core/html/parser/HTMLConstructionSite.h | 
| diff --git a/Source/core/html/parser/HTMLConstructionSite.h b/Source/core/html/parser/HTMLConstructionSite.h | 
| index 48be3b05cd51924a4c44ada45cacdb078eef3c85..30c1768beefa5b8e6333a099d9151f083a1f9412 100644 | 
| --- a/Source/core/html/parser/HTMLConstructionSite.h | 
| +++ b/Source/core/html/parser/HTMLConstructionSite.h | 
| @@ -92,6 +92,14 @@ enum WhitespaceMode { | 
| AllWhitespace, | 
| }; | 
| +enum FlushMode { | 
| + // Flush pending text. Flush queued tasks. | 
| + FlushAlways, | 
| + | 
| + // Flush pending text if node has length limit. Flush queued tasks. | 
| + FlushIfAtTextLimit, | 
| +}; | 
| + | 
| class AtomicHTMLToken; | 
| class Document; | 
| class Element; | 
| @@ -113,14 +121,14 @@ public: | 
| void executeQueuedTasks(); | 
| // flushPendingText turns pending text into queued Text insertions, but does not execute them. | 
| - void flushPendingText(); | 
| + void flushPendingText(FlushMode); | 
| 
kouhei (in TOK)
2014/09/02 15:56:06
Nit: Can we make this method private? It is confus
 | 
| // Called before every token in HTMLTreeBuilder::processToken, thus inlined: | 
| - void flush() | 
| + void flush(FlushMode mode) | 
| { | 
| if (!hasPendingTasks()) | 
| return; | 
| - flushPendingText(); | 
| + flushPendingText(mode); | 
| executeQueuedTasks(); // NOTE: Possible reentrancy via JavaScript execution. | 
| ASSERT(!hasPendingTasks()); | 
| } |