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 26 matching lines...) Expand all Loading... | |
| 37 namespace WebCore { | 37 namespace WebCore { |
| 38 | 38 |
| 39 class ContainerNode; | 39 class ContainerNode; |
| 40 class DocumentFragment; | 40 class DocumentFragment; |
| 41 class Element; | 41 class Element; |
| 42 class QualifiedName; | 42 class QualifiedName; |
| 43 | 43 |
| 44 // NOTE: The HTML5 spec uses a backwards (grows downward) stack. We're using | 44 // NOTE: The HTML5 spec uses a backwards (grows downward) stack. We're using |
| 45 // more standard (grows upwards) stack terminology here. | 45 // more standard (grows upwards) stack terminology here. |
| 46 class HTMLElementStack { | 46 class HTMLElementStack { |
| 47 WTF_MAKE_NONCOPYABLE(HTMLElementStack); WTF_MAKE_FAST_ALLOCATED; | 47 WTF_MAKE_NONCOPYABLE(HTMLElementStack); |
| 48 DISALLOW_ALLOCATION(); | |
| 48 public: | 49 public: |
| 49 HTMLElementStack(); | 50 HTMLElementStack(); |
| 50 ~HTMLElementStack(); | 51 ~HTMLElementStack(); |
| 51 | 52 |
| 52 class ElementRecord { | 53 class ElementRecord : public NoBaseWillBeGarbageCollected<ElementRecord> { |
|
Mads Ager (chromium)
2014/05/27 10:32:03
add FINAL since the trace method is not virtual?
wibling-chromium
2014/05/27 10:45:46
Done.
| |
| 53 WTF_MAKE_NONCOPYABLE(ElementRecord); WTF_MAKE_FAST_ALLOCATED; | 54 WTF_MAKE_NONCOPYABLE(ElementRecord); WTF_MAKE_FAST_ALLOCATED_WILL_BE_REM OVED; |
| 54 public: | 55 public: |
| 56 #if !ENABLE(OILPAN) | |
| 55 ~ElementRecord(); // Public for ~PassOwnPtr() | 57 ~ElementRecord(); // Public for ~PassOwnPtr() |
| 58 #endif | |
|
haraken
2014/05/27 10:48:22
You can use DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOV
wibling-chromium
2014/05/27 11:16:36
I tried it, but it doesn't work since it is a nest
| |
| 56 | 59 |
| 57 Element* element() const { return m_item->element(); } | 60 Element* element() const { return m_item->element(); } |
| 58 ContainerNode* node() const { return m_item->node(); } | 61 ContainerNode* node() const { return m_item->node(); } |
| 59 const AtomicString& namespaceURI() const { return m_item->namespaceURI() ; } | 62 const AtomicString& namespaceURI() const { return m_item->namespaceURI() ; } |
| 60 PassRefPtr<HTMLStackItem> stackItem() const { return m_item; } | 63 PassRefPtrWillBeRawPtr<HTMLStackItem> stackItem() const { return m_item; } |
| 61 void replaceElement(PassRefPtr<HTMLStackItem>); | 64 void replaceElement(PassRefPtrWillBeRawPtr<HTMLStackItem>); |
| 62 | 65 |
| 63 bool isAbove(ElementRecord*) const; | 66 bool isAbove(ElementRecord*) const; |
| 64 | 67 |
| 65 ElementRecord* next() const { return m_next.get(); } | 68 ElementRecord* next() const { return m_next.get(); } |
| 69 | |
| 70 void trace(Visitor*); | |
| 66 private: | 71 private: |
| 67 friend class HTMLElementStack; | 72 friend class HTMLElementStack; |
| 68 | 73 |
| 69 ElementRecord(PassRefPtr<HTMLStackItem>, PassOwnPtr<ElementRecord>); | 74 ElementRecord(PassRefPtrWillBeRawPtr<HTMLStackItem>, PassOwnPtrWillBeRaw Ptr<ElementRecord>); |
| 70 | 75 |
| 71 PassOwnPtr<ElementRecord> releaseNext() { return m_next.release(); } | 76 PassOwnPtrWillBeRawPtr<ElementRecord> releaseNext() { return m_next.rele ase(); } |
| 72 void setNext(PassOwnPtr<ElementRecord> next) { m_next = next; } | 77 void setNext(PassOwnPtrWillBeRawPtr<ElementRecord> next) { m_next = next ; } |
| 73 | 78 |
| 74 RefPtr<HTMLStackItem> m_item; | 79 RefPtrWillBeMember<HTMLStackItem> m_item; |
| 75 OwnPtr<ElementRecord> m_next; | 80 OwnPtrWillBeMember<ElementRecord> m_next; |
| 76 }; | 81 }; |
| 77 | 82 |
| 78 unsigned stackDepth() const { return m_stackDepth; } | 83 unsigned stackDepth() const { return m_stackDepth; } |
| 79 | 84 |
| 80 // Inlining this function is a (small) performance win on the parsing | 85 // Inlining this function is a (small) performance win on the parsing |
| 81 // benchmark. | 86 // benchmark. |
| 82 Element* top() const | 87 Element* top() const |
| 83 { | 88 { |
| 84 ASSERT(m_top->element()); | 89 ASSERT(m_top->element()); |
| 85 return m_top->element(); | 90 return m_top->element(); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 96 ASSERT(m_top->stackItem()); | 101 ASSERT(m_top->stackItem()); |
| 97 return m_top->stackItem().get(); | 102 return m_top->stackItem().get(); |
| 98 } | 103 } |
| 99 | 104 |
| 100 HTMLStackItem* oneBelowTop() const; | 105 HTMLStackItem* oneBelowTop() const; |
| 101 ElementRecord* topRecord() const; | 106 ElementRecord* topRecord() const; |
| 102 ElementRecord* find(Element*) const; | 107 ElementRecord* find(Element*) const; |
| 103 ElementRecord* furthestBlockForFormattingElement(Element*) const; | 108 ElementRecord* furthestBlockForFormattingElement(Element*) const; |
| 104 ElementRecord* topmost(const AtomicString& tagName) const; | 109 ElementRecord* topmost(const AtomicString& tagName) const; |
| 105 | 110 |
| 106 void insertAbove(PassRefPtr<HTMLStackItem>, ElementRecord*); | 111 void insertAbove(PassRefPtrWillBeRawPtr<HTMLStackItem>, ElementRecord*); |
| 107 | 112 |
| 108 void push(PassRefPtr<HTMLStackItem>); | 113 void push(PassRefPtrWillBeRawPtr<HTMLStackItem>); |
| 109 void pushRootNode(PassRefPtr<HTMLStackItem>); | 114 void pushRootNode(PassRefPtrWillBeRawPtr<HTMLStackItem>); |
| 110 void pushHTMLHtmlElement(PassRefPtr<HTMLStackItem>); | 115 void pushHTMLHtmlElement(PassRefPtrWillBeRawPtr<HTMLStackItem>); |
| 111 void pushHTMLHeadElement(PassRefPtr<HTMLStackItem>); | 116 void pushHTMLHeadElement(PassRefPtrWillBeRawPtr<HTMLStackItem>); |
| 112 void pushHTMLBodyElement(PassRefPtr<HTMLStackItem>); | 117 void pushHTMLBodyElement(PassRefPtrWillBeRawPtr<HTMLStackItem>); |
| 113 | 118 |
| 114 void pop(); | 119 void pop(); |
| 115 void popUntil(const AtomicString& tagName); | 120 void popUntil(const AtomicString& tagName); |
| 116 void popUntil(Element*); | 121 void popUntil(Element*); |
| 117 void popUntilPopped(const AtomicString& tagName); | 122 void popUntilPopped(const AtomicString& tagName); |
| 118 void popUntilPopped(const QualifiedName& tagName) { popUntilPopped(tagName.l ocalName()); } | 123 void popUntilPopped(const QualifiedName& tagName) { popUntilPopped(tagName.l ocalName()); } |
| 119 | 124 |
| 120 void popUntilPopped(Element*); | 125 void popUntilPopped(Element*); |
| 121 void popUntilNumberedHeaderElementPopped(); | 126 void popUntilNumberedHeaderElementPopped(); |
| 122 void popUntilTableScopeMarker(); // "clear the stack back to a table context " in the spec. | 127 void popUntilTableScopeMarker(); // "clear the stack back to a table context " in the spec. |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 152 | 157 |
| 153 bool hasOnlyOneElement() const; | 158 bool hasOnlyOneElement() const; |
| 154 bool secondElementIsHTMLBodyElement() const; | 159 bool secondElementIsHTMLBodyElement() const; |
| 155 bool hasTemplateInHTMLScope() const; | 160 bool hasTemplateInHTMLScope() const; |
| 156 Element* htmlElement() const; | 161 Element* htmlElement() const; |
| 157 Element* headElement() const; | 162 Element* headElement() const; |
| 158 Element* bodyElement() const; | 163 Element* bodyElement() const; |
| 159 | 164 |
| 160 ContainerNode* rootNode() const; | 165 ContainerNode* rootNode() const; |
| 161 | 166 |
| 167 void trace(Visitor*); | |
| 168 | |
| 162 #ifndef NDEBUG | 169 #ifndef NDEBUG |
| 163 void show(); | 170 void show(); |
| 164 #endif | 171 #endif |
| 165 | 172 |
| 166 private: | 173 private: |
| 167 void pushCommon(PassRefPtr<HTMLStackItem>); | 174 void pushCommon(PassRefPtrWillBeRawPtr<HTMLStackItem>); |
| 168 void pushRootNodeCommon(PassRefPtr<HTMLStackItem>); | 175 void pushRootNodeCommon(PassRefPtrWillBeRawPtr<HTMLStackItem>); |
| 169 void popCommon(); | 176 void popCommon(); |
| 170 void removeNonTopCommon(Element*); | 177 void removeNonTopCommon(Element*); |
| 171 | 178 |
| 172 OwnPtr<ElementRecord> m_top; | 179 OwnPtrWillBeMember<ElementRecord> m_top; |
| 173 | 180 |
| 174 // We remember the root node, <head> and <body> as they are pushed. Their | 181 // We remember the root node, <head> and <body> as they are pushed. Their |
| 175 // ElementRecords keep them alive. The root node is never popped. | 182 // ElementRecords keep them alive. The root node is never popped. |
| 176 // FIXME: We don't currently require type-specific information about | 183 // FIXME: We don't currently require type-specific information about |
| 177 // these elements so we haven't yet bothered to plumb the types all the | 184 // these elements so we haven't yet bothered to plumb the types all the |
| 178 // way down through createElement, etc. | 185 // way down through createElement, etc. |
| 179 ContainerNode* m_rootNode; | 186 ContainerNode* m_rootNode; |
| 180 Element* m_headElement; | 187 Element* m_headElement; |
| 181 Element* m_bodyElement; | 188 Element* m_bodyElement; |
|
haraken
2014/05/27 10:48:22
Shall we make these pointers Members? I'm not real
wibling-chromium
2014/05/27 11:16:36
Done.
| |
| 182 unsigned m_stackDepth; | 189 unsigned m_stackDepth; |
| 183 }; | 190 }; |
| 184 | 191 |
| 185 } // namespace WebCore | 192 } // namespace WebCore |
| 186 | 193 |
| 187 #endif // HTMLElementStack_h | 194 #endif // HTMLElementStack_h |
| OLD | NEW |