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

Side by Side Diff: sky/engine/core/html/parser/HTMLElementStack.h

Issue 1215103007: Remove remaining HTML elements (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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
(Empty)
1 /*
2 * Copyright (C) 2010 Google, Inc. All Rights Reserved.
3 * Copyright (C) 2011 Apple Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27 #ifndef SKY_ENGINE_CORE_HTML_PARSER_HTMLELEMENTSTACK_H_
28 #define SKY_ENGINE_CORE_HTML_PARSER_HTMLELEMENTSTACK_H_
29
30 #include "sky/engine/core/dom/Element.h"
31 #include "sky/engine/wtf/Forward.h"
32 #include "sky/engine/wtf/Noncopyable.h"
33 #include "sky/engine/wtf/OwnPtr.h"
34 #include "sky/engine/wtf/PassOwnPtr.h"
35 #include "sky/engine/wtf/RefPtr.h"
36
37 namespace blink {
38
39 class ContainerNode;
40 class DocumentFragment;
41 class Element;
42 class QualifiedName;
43
44 // NOTE: The HTML5 spec uses a backwards (grows downward) stack. We're using
45 // more standard (grows upwards) stack terminology here.
46 class HTMLElementStack {
47 WTF_MAKE_NONCOPYABLE(HTMLElementStack);
48 DISALLOW_ALLOCATION();
49 public:
50 HTMLElementStack();
51 ~HTMLElementStack();
52
53 class ElementRecord {
54 WTF_MAKE_NONCOPYABLE(ElementRecord); WTF_MAKE_FAST_ALLOCATED;
55 public:
56 ElementRecord(PassRefPtr<ContainerNode>, PassOwnPtr<ElementRecord>);
57 ~ElementRecord();
58
59 Element* element() const { return toElement(m_node.get()); }
60 ContainerNode* node() const { return m_node.get(); }
61
62 ElementRecord* next() const { return m_next.get(); }
63
64 PassOwnPtr<ElementRecord> releaseNext() { return m_next.release(); }
65 void setNext(PassOwnPtr<ElementRecord> next) { m_next = next; }
66
67 private:
68 RefPtr<ContainerNode> m_node;
69 OwnPtr<ElementRecord> m_next;
70 };
71
72 unsigned stackDepth() const { return m_stackDepth; }
73
74 bool preserveWhiteSpace() const { return m_preserveWhiteSpaceCount; }
75
76 // Inlining this function is a (small) performance win on the parsing
77 // benchmark.
78 Element* top() const
79 {
80 ASSERT(m_top->element());
81 return m_top->element();
82 }
83
84 ContainerNode* topNode() const
85 {
86 ASSERT(m_top->node());
87 return m_top->node();
88 }
89
90 ElementRecord* topRecord() const;
91
92 void push(PassRefPtr<ContainerNode>);
93 void pushRootNode(PassRefPtr<ContainerNode>);
94
95 void pop();
96 void popUntilPopped(Element*);
97 void popAll();
98
99 #ifndef NDEBUG
100 void show();
101 #endif
102
103 private:
104 void popUntil(Element*);
105 void pushCommon(PassRefPtr<ContainerNode>);
106 void popCommon();
107
108 OwnPtr<ElementRecord> m_top;
109
110 ContainerNode* m_rootNode;
111 unsigned m_stackDepth;
112 unsigned m_preserveWhiteSpaceCount;
113 };
114
115 } // namespace blink
116
117 #endif // SKY_ENGINE_CORE_HTML_PARSER_HTMLELEMENTSTACK_H_
OLDNEW
« no previous file with comments | « sky/engine/core/html/parser/HTMLDocumentParser.cpp ('k') | sky/engine/core/html/parser/HTMLElementStack.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698