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

Side by Side Diff: Source/core/html/parser/HTMLInputStream.h

Issue 1306413003: Make classes and structures in core/html fast-allocated. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 10 matching lines...) Expand all
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #ifndef HTMLInputStream_h 26 #ifndef HTMLInputStream_h
27 #define HTMLInputStream_h 27 #define HTMLInputStream_h
28 28
29 #include "core/html/parser/InputStreamPreprocessor.h" 29 #include "core/html/parser/InputStreamPreprocessor.h"
30 #include "platform/text/SegmentedString.h" 30 #include "platform/text/SegmentedString.h"
31 #include "wtf/Allocator.h"
31 32
32 namespace blink { 33 namespace blink {
33 34
34 // The InputStream is made up of a sequence of SegmentedStrings: 35 // The InputStream is made up of a sequence of SegmentedStrings:
35 // 36 //
36 // [--current--][--next--][--next--] ... [--next--] 37 // [--current--][--next--][--next--] ... [--next--]
37 // /\ (also called m_last) 38 // /\ (also called m_last)
38 // L_ current insertion point 39 // L_ current insertion point
39 // 40 //
40 // The current segmented string is stored in InputStream. Each of the 41 // The current segmented string is stored in InputStream. Each of the
41 // afterInsertionPoint buffers are stored in InsertionPointRecords on the 42 // afterInsertionPoint buffers are stored in InsertionPointRecords on the
42 // stack. 43 // stack.
43 // 44 //
44 // We remove characters from the "current" string in the InputStream. 45 // We remove characters from the "current" string in the InputStream.
45 // document.write() will add characters at the current insertion point, 46 // document.write() will add characters at the current insertion point,
46 // which appends them to the "current" string. 47 // which appends them to the "current" string.
47 // 48 //
48 // m_last is a pointer to the last of the afterInsertionPoint strings. 49 // m_last is a pointer to the last of the afterInsertionPoint strings.
49 // The network adds data at the end of the InputStream, which appends 50 // The network adds data at the end of the InputStream, which appends
50 // them to the "last" string. 51 // them to the "last" string.
51 class HTMLInputStream { 52 class HTMLInputStream {
53 DISALLOW_ALLOCATION();
52 WTF_MAKE_NONCOPYABLE(HTMLInputStream); 54 WTF_MAKE_NONCOPYABLE(HTMLInputStream);
53 public: 55 public:
54 HTMLInputStream() 56 HTMLInputStream()
55 : m_last(&m_first) 57 : m_last(&m_first)
56 { 58 {
57 } 59 }
58 60
59 void appendToEnd(const SegmentedString& string) 61 void appendToEnd(const SegmentedString& string)
60 { 62 {
61 m_last->append(string); 63 m_last->append(string);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 m_first.close(); 119 m_first.close();
118 } 120 }
119 } 121 }
120 122
121 private: 123 private:
122 SegmentedString m_first; 124 SegmentedString m_first;
123 SegmentedString* m_last; 125 SegmentedString* m_last;
124 }; 126 };
125 127
126 class InsertionPointRecord { 128 class InsertionPointRecord {
129 STACK_ALLOCATED();
127 WTF_MAKE_NONCOPYABLE(InsertionPointRecord); 130 WTF_MAKE_NONCOPYABLE(InsertionPointRecord);
128 public: 131 public:
129 explicit InsertionPointRecord(HTMLInputStream& inputStream) 132 explicit InsertionPointRecord(HTMLInputStream& inputStream)
130 : m_inputStream(&inputStream) 133 : m_inputStream(&inputStream)
131 { 134 {
132 m_line = m_inputStream->current().currentLine(); 135 m_line = m_inputStream->current().currentLine();
133 m_column = m_inputStream->current().currentColumn(); 136 m_column = m_inputStream->current().currentColumn();
134 m_inputStream->splitInto(m_next); 137 m_inputStream->splitInto(m_next);
135 // We 'fork' current position and use it for the generated script part. 138 // We 'fork' current position and use it for the generated script part.
136 // This is a bit weird, because generated part does not have positions w ithin an HTML document. 139 // This is a bit weird, because generated part does not have positions w ithin an HTML document.
(...skipping 13 matching lines...) Expand all
150 private: 153 private:
151 HTMLInputStream* m_inputStream; 154 HTMLInputStream* m_inputStream;
152 SegmentedString m_next; 155 SegmentedString m_next;
153 OrdinalNumber m_line; 156 OrdinalNumber m_line;
154 OrdinalNumber m_column; 157 OrdinalNumber m_column;
155 }; 158 };
156 159
157 } 160 }
158 161
159 #endif 162 #endif
OLDNEW
« no previous file with comments | « Source/core/html/parser/HTMLFormattingElementList.h ('k') | Source/core/html/parser/HTMLParserOptions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698