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

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

Issue 298043008: [Oilpan]: Move HTMLStackItem and friends to the oilpan heap. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix windows build Created 6 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 unified diff | Download patch | Annotate | Revision Log
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 20 matching lines...) Expand all
31 #include "wtf/RefPtr.h" 31 #include "wtf/RefPtr.h"
32 #include "wtf/Vector.h" 32 #include "wtf/Vector.h"
33 33
34 namespace WebCore { 34 namespace WebCore {
35 35
36 class Element; 36 class Element;
37 37
38 // This may end up merged into HTMLElementStack. 38 // This may end up merged into HTMLElementStack.
39 class HTMLFormattingElementList { 39 class HTMLFormattingElementList {
40 WTF_MAKE_NONCOPYABLE(HTMLFormattingElementList); 40 WTF_MAKE_NONCOPYABLE(HTMLFormattingElementList);
41 DISALLOW_ALLOCATION();
41 public: 42 public:
42 HTMLFormattingElementList(); 43 HTMLFormattingElementList();
43 ~HTMLFormattingElementList(); 44 ~HTMLFormattingElementList();
44 45
45 // Ideally Entry would be private, but HTMLTreeBuilder has to coordinate 46 // Ideally Entry would be private, but HTMLTreeBuilder has to coordinate
46 // between the HTMLFormattingElementList and HTMLElementStack and needs 47 // between the HTMLFormattingElementList and HTMLElementStack and needs
47 // access to Entry::isMarker() and Entry::replaceElement() to do so. 48 // access to Entry::isMarker() and Entry::replaceElement() to do so.
48 class Entry { 49 class Entry {
50 ALLOW_ONLY_INLINE_ALLOCATION();
49 public: 51 public:
50 // Inline because they're hot and Vector<T> uses them. 52 // Inline because they're hot and Vector<T> uses them.
51 explicit Entry(PassRefPtr<HTMLStackItem> item) 53 explicit Entry(PassRefPtrWillBeRawPtr<HTMLStackItem> item)
52 : m_item(item) 54 : m_item(item)
53 { 55 {
54 } 56 }
55 enum MarkerEntryType { MarkerEntry }; 57 enum MarkerEntryType { MarkerEntry };
56 explicit Entry(MarkerEntryType) 58 explicit Entry(MarkerEntryType)
57 : m_item(nullptr) 59 : m_item(nullptr)
58 { 60 {
59 } 61 }
60 ~Entry() {} 62 ~Entry() {}
61 63
62 bool isMarker() const { return !m_item; } 64 bool isMarker() const { return !m_item; }
63 65
64 PassRefPtr<HTMLStackItem> stackItem() const { return m_item; } 66 PassRefPtrWillBeRawPtr<HTMLStackItem> stackItem() const { return m_item; }
65 Element* element() const 67 Element* element() const
66 { 68 {
67 // The fact that !m_item == isMarker() is an implementation detail 69 // The fact that !m_item == isMarker() is an implementation detail
68 // callers should check isMarker() before calling element(). 70 // callers should check isMarker() before calling element().
69 ASSERT(m_item); 71 ASSERT(m_item);
70 return m_item->element(); 72 return m_item->element();
71 } 73 }
72 void replaceElement(PassRefPtr<HTMLStackItem> item) { m_item = item; } 74 void replaceElement(PassRefPtrWillBeRawPtr<HTMLStackItem> item) { m_item = item; }
73 75
74 // Needed for use with Vector. These are super-hot and must be inline. 76 // Needed for use with Vector. These are super-hot and must be inline.
75 bool operator==(Element* element) const { return !m_item ? !element : m_ item->element() == element; } 77 bool operator==(Element* element) const { return !m_item ? !element : m_ item->element() == element; }
76 bool operator!=(Element* element) const { return !m_item ? !!element : m _item->element() != element; } 78 bool operator!=(Element* element) const { return !m_item ? !!element : m _item->element() != element; }
77 79
80 void trace(Visitor* visitor) { visitor->trace(m_item); }
81
78 private: 82 private:
79 RefPtr<HTMLStackItem> m_item; 83 RefPtrWillBeMember<HTMLStackItem> m_item;
80 }; 84 };
81 85
82 class Bookmark { 86 class Bookmark {
83 public: 87 public:
84 explicit Bookmark(Entry* entry) 88 explicit Bookmark(Entry* entry)
85 : m_hasBeenMoved(false) 89 : m_hasBeenMoved(false)
86 , m_mark(entry) 90 , m_mark(entry)
87 { 91 {
88 } 92 }
89 93
(...skipping 11 matching lines...) Expand all
101 Entry* m_mark; 105 Entry* m_mark;
102 }; 106 };
103 107
104 bool isEmpty() const { return !size(); } 108 bool isEmpty() const { return !size(); }
105 size_t size() const { return m_entries.size(); } 109 size_t size() const { return m_entries.size(); }
106 110
107 Element* closestElementInScopeWithName(const AtomicString&); 111 Element* closestElementInScopeWithName(const AtomicString&);
108 112
109 Entry* find(Element*); 113 Entry* find(Element*);
110 bool contains(Element*); 114 bool contains(Element*);
111 void append(PassRefPtr<HTMLStackItem>); 115 void append(PassRefPtrWillBeRawPtr<HTMLStackItem>);
112 void remove(Element*); 116 void remove(Element*);
113 117
114 Bookmark bookmarkFor(Element*); 118 Bookmark bookmarkFor(Element*);
115 void swapTo(Element* oldElement, PassRefPtr<HTMLStackItem> newItem, const Bo okmark&); 119 void swapTo(Element* oldElement, PassRefPtrWillBeRawPtr<HTMLStackItem> newIt em, const Bookmark&);
116 120
117 void appendMarker(); 121 void appendMarker();
118 // clearToLastMarker also clears the marker (per the HTML5 spec). 122 // clearToLastMarker also clears the marker (per the HTML5 spec).
119 void clearToLastMarker(); 123 void clearToLastMarker();
120 124
121 const Entry& at(size_t i) const { return m_entries[i]; } 125 const Entry& at(size_t i) const { return m_entries[i]; }
122 Entry& at(size_t i) { return m_entries[i]; } 126 Entry& at(size_t i) { return m_entries[i]; }
123 127
128 void trace(Visitor* visitor) { visitor->trace(m_entries); }
129
124 #ifndef NDEBUG 130 #ifndef NDEBUG
125 void show(); 131 void show();
126 #endif 132 #endif
127 133
128 private: 134 private:
129 Entry* first() { return &at(0); } 135 Entry* first() { return &at(0); }
130 136
131 // http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html# list-of-active-formatting-elements 137 // http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html# list-of-active-formatting-elements
132 // These functions enforce the "Noah's Ark" condition, which removes redunda nt mis-nested elements. 138 // These functions enforce the "Noah's Ark" condition, which removes redunda nt mis-nested elements.
133 void tryToEnsureNoahsArkConditionQuickly(HTMLStackItem*, Vector<HTMLStackIte m*>& remainingCandiates); 139 void tryToEnsureNoahsArkConditionQuickly(HTMLStackItem*, WillBeHeapVector<Ra wPtrWillBeMember<HTMLStackItem> >& remainingCandiates);
134 void ensureNoahsArkCondition(HTMLStackItem*); 140 void ensureNoahsArkCondition(HTMLStackItem*);
135 141
136 Vector<Entry> m_entries; 142 WillBeHeapVector<Entry> m_entries;
137 }; 143 };
138 144
139 } 145 } // namespace WebCore
146
147 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(WebCore::HTMLFormattingElementList::E ntry);
140 148
141 #endif // HTMLFormattingElementList_h 149 #endif // HTMLFormattingElementList_h
OLDNEW
« no previous file with comments | « Source/core/html/parser/HTMLElementStack.cpp ('k') | Source/core/html/parser/HTMLFormattingElementList.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698