| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 // NOTE: The HTML5 spec uses a backwards (grows downward) stack. We're using | 43 // NOTE: The HTML5 spec uses a backwards (grows downward) stack. We're using |
| 44 // more standard (grows upwards) stack terminology here. | 44 // more standard (grows upwards) stack terminology here. |
| 45 class HTMLElementStack { | 45 class HTMLElementStack { |
| 46 WTF_MAKE_NONCOPYABLE(HTMLElementStack); | 46 WTF_MAKE_NONCOPYABLE(HTMLElementStack); |
| 47 DISALLOW_NEW(); | 47 DISALLOW_NEW(); |
| 48 public: | 48 public: |
| 49 HTMLElementStack(); | 49 HTMLElementStack(); |
| 50 ~HTMLElementStack(); | 50 ~HTMLElementStack(); |
| 51 | 51 |
| 52 class ElementRecord final : public NoBaseWillBeGarbageCollected<ElementRecor
d> { | 52 class ElementRecord final : public GarbageCollected<ElementRecord> { |
| 53 WTF_MAKE_NONCOPYABLE(ElementRecord); USING_FAST_MALLOC_WILL_BE_REMOVED(E
lementRecord); | 53 WTF_MAKE_NONCOPYABLE(ElementRecord); |
| 54 public: | 54 public: |
| 55 #if !ENABLE(OILPAN) | 55 #if !ENABLE(OILPAN) |
| 56 ~ElementRecord(); // Public for ~PassOwnPtr() | 56 ~ElementRecord(); // Public for ~PassOwnPtr() |
| 57 #endif | 57 #endif |
| 58 | 58 |
| 59 Element* element() const { return m_item->element(); } | 59 Element* element() const { return m_item->element(); } |
| 60 ContainerNode* node() const { return m_item->node(); } | 60 ContainerNode* node() const { return m_item->node(); } |
| 61 const AtomicString& namespaceURI() const { return m_item->namespaceURI()
; } | 61 const AtomicString& namespaceURI() const { return m_item->namespaceURI()
; } |
| 62 PassRefPtrWillBeRawPtr<HTMLStackItem> stackItem() const { return m_item;
} | 62 RawPtr<HTMLStackItem> stackItem() const { return m_item; } |
| 63 void replaceElement(PassRefPtrWillBeRawPtr<HTMLStackItem>); | 63 void replaceElement(RawPtr<HTMLStackItem>); |
| 64 | 64 |
| 65 bool isAbove(ElementRecord*) const; | 65 bool isAbove(ElementRecord*) const; |
| 66 | 66 |
| 67 ElementRecord* next() const { return m_next.get(); } | 67 ElementRecord* next() const { return m_next.get(); } |
| 68 | 68 |
| 69 DECLARE_TRACE(); | 69 DECLARE_TRACE(); |
| 70 private: | 70 private: |
| 71 friend class HTMLElementStack; | 71 friend class HTMLElementStack; |
| 72 | 72 |
| 73 ElementRecord(PassRefPtrWillBeRawPtr<HTMLStackItem>, PassOwnPtrWillBeRaw
Ptr<ElementRecord>); | 73 ElementRecord(RawPtr<HTMLStackItem>, RawPtr<ElementRecord>); |
| 74 | 74 |
| 75 PassOwnPtrWillBeRawPtr<ElementRecord> releaseNext() { return m_next.rele
ase(); } | 75 RawPtr<ElementRecord> releaseNext() { return m_next.release(); } |
| 76 void setNext(PassOwnPtrWillBeRawPtr<ElementRecord> next) { m_next = next
; } | 76 void setNext(RawPtr<ElementRecord> next) { m_next = next; } |
| 77 | 77 |
| 78 RefPtrWillBeMember<HTMLStackItem> m_item; | 78 Member<HTMLStackItem> m_item; |
| 79 OwnPtrWillBeMember<ElementRecord> m_next; | 79 Member<ElementRecord> m_next; |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 unsigned stackDepth() const { return m_stackDepth; } | 82 unsigned stackDepth() const { return m_stackDepth; } |
| 83 | 83 |
| 84 // Inlining this function is a (small) performance win on the parsing | 84 // Inlining this function is a (small) performance win on the parsing |
| 85 // benchmark. | 85 // benchmark. |
| 86 Element* top() const | 86 Element* top() const |
| 87 { | 87 { |
| 88 ASSERT(m_top->element()); | 88 ASSERT(m_top->element()); |
| 89 return m_top->element(); | 89 return m_top->element(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 100 ASSERT(m_top->stackItem()); | 100 ASSERT(m_top->stackItem()); |
| 101 return m_top->stackItem().get(); | 101 return m_top->stackItem().get(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 HTMLStackItem* oneBelowTop() const; | 104 HTMLStackItem* oneBelowTop() const; |
| 105 ElementRecord* topRecord() const; | 105 ElementRecord* topRecord() const; |
| 106 ElementRecord* find(Element*) const; | 106 ElementRecord* find(Element*) const; |
| 107 ElementRecord* furthestBlockForFormattingElement(Element*) const; | 107 ElementRecord* furthestBlockForFormattingElement(Element*) const; |
| 108 ElementRecord* topmost(const AtomicString& tagName) const; | 108 ElementRecord* topmost(const AtomicString& tagName) const; |
| 109 | 109 |
| 110 void insertAbove(PassRefPtrWillBeRawPtr<HTMLStackItem>, ElementRecord*); | 110 void insertAbove(RawPtr<HTMLStackItem>, ElementRecord*); |
| 111 | 111 |
| 112 void push(PassRefPtrWillBeRawPtr<HTMLStackItem>); | 112 void push(RawPtr<HTMLStackItem>); |
| 113 void pushRootNode(PassRefPtrWillBeRawPtr<HTMLStackItem>); | 113 void pushRootNode(RawPtr<HTMLStackItem>); |
| 114 void pushHTMLHtmlElement(PassRefPtrWillBeRawPtr<HTMLStackItem>); | 114 void pushHTMLHtmlElement(RawPtr<HTMLStackItem>); |
| 115 void pushHTMLHeadElement(PassRefPtrWillBeRawPtr<HTMLStackItem>); | 115 void pushHTMLHeadElement(RawPtr<HTMLStackItem>); |
| 116 void pushHTMLBodyElement(PassRefPtrWillBeRawPtr<HTMLStackItem>); | 116 void pushHTMLBodyElement(RawPtr<HTMLStackItem>); |
| 117 | 117 |
| 118 void pop(); | 118 void pop(); |
| 119 void popUntil(const AtomicString& tagName); | 119 void popUntil(const AtomicString& tagName); |
| 120 void popUntil(Element*); | 120 void popUntil(Element*); |
| 121 void popUntilPopped(const AtomicString& tagName); | 121 void popUntilPopped(const AtomicString& tagName); |
| 122 void popUntilPopped(const QualifiedName& tagName) { popUntilPopped(tagName.l
ocalName()); } | 122 void popUntilPopped(const QualifiedName& tagName) { popUntilPopped(tagName.l
ocalName()); } |
| 123 | 123 |
| 124 void popUntilPopped(Element*); | 124 void popUntilPopped(Element*); |
| 125 void popUntilNumberedHeaderElementPopped(); | 125 void popUntilNumberedHeaderElementPopped(); |
| 126 void popUntilTableScopeMarker(); // "clear the stack back to a table context
" in the spec. | 126 void popUntilTableScopeMarker(); // "clear the stack back to a table context
" in the spec. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 163 |
| 164 ContainerNode* rootNode() const; | 164 ContainerNode* rootNode() const; |
| 165 | 165 |
| 166 DECLARE_TRACE(); | 166 DECLARE_TRACE(); |
| 167 | 167 |
| 168 #ifndef NDEBUG | 168 #ifndef NDEBUG |
| 169 void show(); | 169 void show(); |
| 170 #endif | 170 #endif |
| 171 | 171 |
| 172 private: | 172 private: |
| 173 void pushCommon(PassRefPtrWillBeRawPtr<HTMLStackItem>); | 173 void pushCommon(RawPtr<HTMLStackItem>); |
| 174 void pushRootNodeCommon(PassRefPtrWillBeRawPtr<HTMLStackItem>); | 174 void pushRootNodeCommon(RawPtr<HTMLStackItem>); |
| 175 void popCommon(); | 175 void popCommon(); |
| 176 void removeNonTopCommon(Element*); | 176 void removeNonTopCommon(Element*); |
| 177 | 177 |
| 178 OwnPtrWillBeMember<ElementRecord> m_top; | 178 Member<ElementRecord> m_top; |
| 179 | 179 |
| 180 // We remember the root node, <head> and <body> as they are pushed. Their | 180 // We remember the root node, <head> and <body> as they are pushed. Their |
| 181 // ElementRecords keep them alive. The root node is never popped. | 181 // ElementRecords keep them alive. The root node is never popped. |
| 182 // FIXME: We don't currently require type-specific information about | 182 // FIXME: We don't currently require type-specific information about |
| 183 // these elements so we haven't yet bothered to plumb the types all the | 183 // these elements so we haven't yet bothered to plumb the types all the |
| 184 // way down through createElement, etc. | 184 // way down through createElement, etc. |
| 185 RawPtrWillBeMember<ContainerNode> m_rootNode; | 185 Member<ContainerNode> m_rootNode; |
| 186 RawPtrWillBeMember<Element> m_headElement; | 186 Member<Element> m_headElement; |
| 187 RawPtrWillBeMember<Element> m_bodyElement; | 187 Member<Element> m_bodyElement; |
| 188 unsigned m_stackDepth; | 188 unsigned m_stackDepth; |
| 189 }; | 189 }; |
| 190 | 190 |
| 191 WILL_NOT_BE_EAGERLY_TRACED_CLASS(HTMLElementStack::ElementRecord); | 191 WILL_NOT_BE_EAGERLY_TRACED_CLASS(HTMLElementStack::ElementRecord); |
| 192 | 192 |
| 193 } // namespace blink | 193 } // namespace blink |
| 194 | 194 |
| 195 #endif // HTMLElementStack_h | 195 #endif // HTMLElementStack_h |
| OLD | NEW |