| OLD | NEW |
| 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 27 matching lines...) Expand all Loading... |
| 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_NEW(); | 41 DISALLOW_NEW(); |
| 42 | 42 |
| 43 public: | 43 public: |
| 44 HTMLFormattingElementList(); | 44 HTMLFormattingElementList(); |
| 45 ~HTMLFormattingElementList(); | 45 ~HTMLFormattingElementList(); |
| 46 | 46 |
| 47 // Ideally Entry would be private, but HTMLTreeBuilder has to coordinate | 47 // Ideally Entry would be private, but HTMLTreeBuilder has to coordinate |
| 48 // between the HTMLFormattingElementList and HTMLElementStack and needs | 48 // between the HTMLFormattingElementList and HTMLElementStack and needs access |
| 49 // access to Entry::isMarker() and Entry::replaceElement() to do so. | 49 // to Entry::isMarker() and Entry::replaceElement() to do so. |
| 50 class Entry { | 50 class Entry { |
| 51 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 51 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 52 | 52 |
| 53 public: | 53 public: |
| 54 // Inline because they're hot and Vector<T> uses them. | 54 // Inline because they're hot and Vector<T> uses them. |
| 55 explicit Entry(HTMLStackItem* item) : m_item(item) {} | 55 explicit Entry(HTMLStackItem* item) : m_item(item) {} |
| 56 enum MarkerEntryType { MarkerEntry }; | 56 enum MarkerEntryType { MarkerEntry }; |
| 57 explicit Entry(MarkerEntryType) : m_item(nullptr) {} | 57 explicit Entry(MarkerEntryType) : m_item(nullptr) {} |
| 58 ~Entry() {} | 58 ~Entry() {} |
| 59 | 59 |
| 60 bool isMarker() const { return !m_item; } | 60 bool isMarker() const { return !m_item; } |
| 61 | 61 |
| 62 HTMLStackItem* stackItem() const { return m_item; } | 62 HTMLStackItem* stackItem() const { return m_item; } |
| 63 Element* element() const { | 63 Element* element() const { |
| 64 // The fact that !m_item == isMarker() is an implementation detail | 64 // The fact that !m_item == isMarker() is an implementation detail callers |
| 65 // callers should check isMarker() before calling element(). | 65 // should check isMarker() before calling element(). |
| 66 ASSERT(m_item); | 66 ASSERT(m_item); |
| 67 return m_item->element(); | 67 return m_item->element(); |
| 68 } | 68 } |
| 69 void replaceElement(HTMLStackItem* item) { m_item = item; } | 69 void replaceElement(HTMLStackItem* item) { m_item = item; } |
| 70 | 70 |
| 71 // Needed for use with Vector. These are super-hot and must be inline. | 71 // Needed for use with Vector. These are super-hot and must be inline. |
| 72 bool operator==(Element* element) const { | 72 bool operator==(Element* element) const { |
| 73 return !m_item ? !element : m_item->element() == element; | 73 return !m_item ? !element : m_item->element() == element; |
| 74 } | 74 } |
| 75 bool operator!=(Element* element) const { | 75 bool operator!=(Element* element) const { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 DEFINE_INLINE_TRACE() { visitor->trace(m_entries); } | 124 DEFINE_INLINE_TRACE() { visitor->trace(m_entries); } |
| 125 | 125 |
| 126 #ifndef NDEBUG | 126 #ifndef NDEBUG |
| 127 void show(); | 127 void show(); |
| 128 #endif | 128 #endif |
| 129 | 129 |
| 130 private: | 130 private: |
| 131 Entry* first() { return &at(0); } | 131 Entry* first() { return &at(0); } |
| 132 | 132 |
| 133 // http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#li
st-of-active-formatting-elements | 133 // http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#li
st-of-active-formatting-elements |
| 134 // These functions enforce the "Noah's Ark" condition, which removes redundant
mis-nested elements. | 134 // These functions enforce the "Noah's Ark" condition, which removes redundant |
| 135 // mis-nested elements. |
| 135 void tryToEnsureNoahsArkConditionQuickly( | 136 void tryToEnsureNoahsArkConditionQuickly( |
| 136 HTMLStackItem*, | 137 HTMLStackItem*, |
| 137 HeapVector<Member<HTMLStackItem>>& remainingCandiates); | 138 HeapVector<Member<HTMLStackItem>>& remainingCandiates); |
| 138 void ensureNoahsArkCondition(HTMLStackItem*); | 139 void ensureNoahsArkCondition(HTMLStackItem*); |
| 139 | 140 |
| 140 HeapVector<Entry> m_entries; | 141 HeapVector<Entry> m_entries; |
| 141 }; | 142 }; |
| 142 | 143 |
| 143 } // namespace blink | 144 } // namespace blink |
| 144 | 145 |
| 145 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS( | 146 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS( |
| 146 blink::HTMLFormattingElementList::Entry); | 147 blink::HTMLFormattingElementList::Entry); |
| 147 | 148 |
| 148 #endif // HTMLFormattingElementList_h | 149 #endif // HTMLFormattingElementList_h |
| OLD | NEW |