| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 ContainerNode* oldParent() | 66 ContainerNode* oldParent() |
| 67 { | 67 { |
| 68 // It's sort of ugly, but we store the |oldParent| in the |child| field | 68 // It's sort of ugly, but we store the |oldParent| in the |child| field |
| 69 // of the task so that we don't bloat the HTMLConstructionSiteTask | 69 // of the task so that we don't bloat the HTMLConstructionSiteTask |
| 70 // object in the common case of the Insert operation. | 70 // object in the common case of the Insert operation. |
| 71 return toContainerNode(child.get()); | 71 return toContainerNode(child.get()); |
| 72 } | 72 } |
| 73 | 73 |
| 74 Operation operation; | 74 Operation operation; |
| 75 RefPtrWillBeMember<ContainerNode> parent; | 75 Member<ContainerNode> parent; |
| 76 RefPtrWillBeMember<Node> nextChild; | 76 Member<Node> nextChild; |
| 77 RefPtrWillBeMember<Node> child; | 77 Member<Node> child; |
| 78 bool selfClosing; | 78 bool selfClosing; |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 } // namespace blink | 81 } // namespace blink |
| 82 | 82 |
| 83 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::HTMLConstructionSiteTa
sk); | 83 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::HTMLConstructionSiteTa
sk); |
| 84 | 84 |
| 85 namespace blink { | 85 namespace blink { |
| 86 | 86 |
| 87 // Note: These are intentionally ordered so that when we concatonate | 87 // Note: These are intentionally ordered so that when we concatonate |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 void insertHTMLBodyStartTagInBody(AtomicHTMLToken*); | 161 void insertHTMLBodyStartTagInBody(AtomicHTMLToken*); |
| 162 | 162 |
| 163 void reparent(HTMLElementStack::ElementRecord* newParent, HTMLElementStack::
ElementRecord* child); | 163 void reparent(HTMLElementStack::ElementRecord* newParent, HTMLElementStack::
ElementRecord* child); |
| 164 void reparent(HTMLElementStack::ElementRecord* newParent, HTMLStackItem* chi
ld); | 164 void reparent(HTMLElementStack::ElementRecord* newParent, HTMLStackItem* chi
ld); |
| 165 // insertAlreadyParsedChild assumes that |child| has already been parsed (i.
e., we're just | 165 // insertAlreadyParsedChild assumes that |child| has already been parsed (i.
e., we're just |
| 166 // moving it around in the tree rather than parsing it for the first time).
That means | 166 // moving it around in the tree rather than parsing it for the first time).
That means |
| 167 // this function doesn't call beginParsingChildren / finishParsingChildren. | 167 // this function doesn't call beginParsingChildren / finishParsingChildren. |
| 168 void insertAlreadyParsedChild(HTMLStackItem* newParent, HTMLElementStack::El
ementRecord* child); | 168 void insertAlreadyParsedChild(HTMLStackItem* newParent, HTMLElementStack::El
ementRecord* child); |
| 169 void takeAllChildren(HTMLStackItem* newParent, HTMLElementStack::ElementReco
rd* oldParent); | 169 void takeAllChildren(HTMLStackItem* newParent, HTMLElementStack::ElementReco
rd* oldParent); |
| 170 | 170 |
| 171 PassRefPtrWillBeRawPtr<HTMLStackItem> createElementFromSavedToken(HTMLStackI
tem*); | 171 RawPtr<HTMLStackItem> createElementFromSavedToken(HTMLStackItem*); |
| 172 | 172 |
| 173 bool shouldFosterParent() const; | 173 bool shouldFosterParent() const; |
| 174 void fosterParent(PassRefPtrWillBeRawPtr<Node>); | 174 void fosterParent(RawPtr<Node>); |
| 175 | 175 |
| 176 bool indexOfFirstUnopenFormattingElement(unsigned& firstUnopenElementIndex)
const; | 176 bool indexOfFirstUnopenFormattingElement(unsigned& firstUnopenElementIndex)
const; |
| 177 void reconstructTheActiveFormattingElements(); | 177 void reconstructTheActiveFormattingElements(); |
| 178 | 178 |
| 179 void generateImpliedEndTags(); | 179 void generateImpliedEndTags(); |
| 180 void generateImpliedEndTagsWithExclusion(const AtomicString& tagName); | 180 void generateImpliedEndTagsWithExclusion(const AtomicString& tagName); |
| 181 | 181 |
| 182 bool inQuirksMode(); | 182 bool inQuirksMode(); |
| 183 | 183 |
| 184 bool isEmpty() const { return !m_openElements.stackDepth(); } | 184 bool isEmpty() const { return !m_openElements.stackDepth(); } |
| 185 HTMLElementStack::ElementRecord* currentElementRecord() const { return m_ope
nElements.topRecord(); } | 185 HTMLElementStack::ElementRecord* currentElementRecord() const { return m_ope
nElements.topRecord(); } |
| 186 Element* currentElement() const { return m_openElements.top(); } | 186 Element* currentElement() const { return m_openElements.top(); } |
| 187 ContainerNode* currentNode() const { return m_openElements.topNode(); } | 187 ContainerNode* currentNode() const { return m_openElements.topNode(); } |
| 188 HTMLStackItem* currentStackItem() const { return m_openElements.topStackItem
(); } | 188 HTMLStackItem* currentStackItem() const { return m_openElements.topStackItem
(); } |
| 189 HTMLStackItem* oneBelowTop() const { return m_openElements.oneBelowTop(); } | 189 HTMLStackItem* oneBelowTop() const { return m_openElements.oneBelowTop(); } |
| 190 Document& ownerDocumentForCurrentNode(); | 190 Document& ownerDocumentForCurrentNode(); |
| 191 HTMLElementStack* openElements() const { return &m_openElements; } | 191 HTMLElementStack* openElements() const { return &m_openElements; } |
| 192 HTMLFormattingElementList* activeFormattingElements() const { return &m_acti
veFormattingElements; } | 192 HTMLFormattingElementList* activeFormattingElements() const { return &m_acti
veFormattingElements; } |
| 193 bool currentIsRootNode() { return m_openElements.topNode() == m_openElements
.rootNode(); } | 193 bool currentIsRootNode() { return m_openElements.topNode() == m_openElements
.rootNode(); } |
| 194 | 194 |
| 195 Element* head() const { return m_head->element(); } | 195 Element* head() const { return m_head->element(); } |
| 196 HTMLStackItem* headStackItem() const { return m_head.get(); } | 196 HTMLStackItem* headStackItem() const { return m_head.get(); } |
| 197 | 197 |
| 198 void setForm(HTMLFormElement*); | 198 void setForm(HTMLFormElement*); |
| 199 HTMLFormElement* form() const { return m_form.get(); } | 199 HTMLFormElement* form() const { return m_form.get(); } |
| 200 PassRefPtrWillBeRawPtr<HTMLFormElement> takeForm(); | 200 RawPtr<HTMLFormElement> takeForm(); |
| 201 | 201 |
| 202 ParserContentPolicy getParserContentPolicy() { return m_parserContentPolicy;
} | 202 ParserContentPolicy getParserContentPolicy() { return m_parserContentPolicy;
} |
| 203 | 203 |
| 204 class RedirectToFosterParentGuard { | 204 class RedirectToFosterParentGuard { |
| 205 STACK_ALLOCATED(); | 205 STACK_ALLOCATED(); |
| 206 WTF_MAKE_NONCOPYABLE(RedirectToFosterParentGuard); | 206 WTF_MAKE_NONCOPYABLE(RedirectToFosterParentGuard); |
| 207 public: | 207 public: |
| 208 RedirectToFosterParentGuard(HTMLConstructionSite& tree) | 208 RedirectToFosterParentGuard(HTMLConstructionSite& tree) |
| 209 : m_tree(tree) | 209 : m_tree(tree) |
| 210 , m_wasRedirectingBefore(tree.m_redirectAttachToFosterParent) | 210 , m_wasRedirectingBefore(tree.m_redirectAttachToFosterParent) |
| 211 { | 211 { |
| 212 m_tree.m_redirectAttachToFosterParent = true; | 212 m_tree.m_redirectAttachToFosterParent = true; |
| 213 } | 213 } |
| 214 | 214 |
| 215 ~RedirectToFosterParentGuard() | 215 ~RedirectToFosterParentGuard() |
| 216 { | 216 { |
| 217 m_tree.m_redirectAttachToFosterParent = m_wasRedirectingBefore; | 217 m_tree.m_redirectAttachToFosterParent = m_wasRedirectingBefore; |
| 218 } | 218 } |
| 219 | 219 |
| 220 private: | 220 private: |
| 221 HTMLConstructionSite& m_tree; | 221 HTMLConstructionSite& m_tree; |
| 222 bool m_wasRedirectingBefore; | 222 bool m_wasRedirectingBefore; |
| 223 }; | 223 }; |
| 224 | 224 |
| 225 private: | 225 private: |
| 226 // In the common case, this queue will have only one task because most | 226 // In the common case, this queue will have only one task because most |
| 227 // tokens produce only one DOM mutation. | 227 // tokens produce only one DOM mutation. |
| 228 typedef WillBeHeapVector<HTMLConstructionSiteTask, 1> TaskQueue; | 228 typedef HeapVector<HTMLConstructionSiteTask, 1> TaskQueue; |
| 229 | 229 |
| 230 void setCompatibilityMode(Document::CompatibilityMode); | 230 void setCompatibilityMode(Document::CompatibilityMode); |
| 231 void setCompatibilityModeFromDoctype(const String& name, const String& publi
cId, const String& systemId); | 231 void setCompatibilityModeFromDoctype(const String& name, const String& publi
cId, const String& systemId); |
| 232 | 232 |
| 233 void attachLater(ContainerNode* parent, PassRefPtrWillBeRawPtr<Node> child,
bool selfClosing = false); | 233 void attachLater(ContainerNode* parent, RawPtr<Node> child, bool selfClosing
= false); |
| 234 | 234 |
| 235 void findFosterSite(HTMLConstructionSiteTask&); | 235 void findFosterSite(HTMLConstructionSiteTask&); |
| 236 | 236 |
| 237 PassRefPtrWillBeRawPtr<HTMLElement> createHTMLElement(AtomicHTMLToken*); | 237 RawPtr<HTMLElement> createHTMLElement(AtomicHTMLToken*); |
| 238 PassRefPtrWillBeRawPtr<Element> createElement(AtomicHTMLToken*, const Atomic
String& namespaceURI); | 238 RawPtr<Element> createElement(AtomicHTMLToken*, const AtomicString& namespac
eURI); |
| 239 | 239 |
| 240 void mergeAttributesFromTokenIntoElement(AtomicHTMLToken*, Element*); | 240 void mergeAttributesFromTokenIntoElement(AtomicHTMLToken*, Element*); |
| 241 void dispatchDocumentElementAvailableIfNeeded(); | 241 void dispatchDocumentElementAvailableIfNeeded(); |
| 242 | 242 |
| 243 void executeTask(HTMLConstructionSiteTask&); | 243 void executeTask(HTMLConstructionSiteTask&); |
| 244 void queueTask(const HTMLConstructionSiteTask&); | 244 void queueTask(const HTMLConstructionSiteTask&); |
| 245 | 245 |
| 246 RawPtrWillBeMember<Document> m_document; | 246 Member<Document> m_document; |
| 247 | 247 |
| 248 // This is the root ContainerNode to which the parser attaches all newly | 248 // This is the root ContainerNode to which the parser attaches all newly |
| 249 // constructed nodes. It points to a DocumentFragment when parsing fragments | 249 // constructed nodes. It points to a DocumentFragment when parsing fragments |
| 250 // and a Document in all other cases. | 250 // and a Document in all other cases. |
| 251 RawPtrWillBeMember<ContainerNode> m_attachmentRoot; | 251 Member<ContainerNode> m_attachmentRoot; |
| 252 | 252 |
| 253 RefPtrWillBeMember<HTMLStackItem> m_head; | 253 Member<HTMLStackItem> m_head; |
| 254 RefPtrWillBeMember<HTMLFormElement> m_form; | 254 Member<HTMLFormElement> m_form; |
| 255 mutable HTMLElementStack m_openElements; | 255 mutable HTMLElementStack m_openElements; |
| 256 mutable HTMLFormattingElementList m_activeFormattingElements; | 256 mutable HTMLFormattingElementList m_activeFormattingElements; |
| 257 | 257 |
| 258 TaskQueue m_taskQueue; | 258 TaskQueue m_taskQueue; |
| 259 | 259 |
| 260 class PendingText final { | 260 class PendingText final { |
| 261 DISALLOW_NEW(); | 261 DISALLOW_NEW(); |
| 262 public: | 262 public: |
| 263 PendingText() | 263 PendingText() |
| 264 : whitespaceMode(WhitespaceUnknown) | 264 : whitespaceMode(WhitespaceUnknown) |
| 265 { | 265 { |
| 266 } | 266 } |
| 267 | 267 |
| 268 void append(PassRefPtrWillBeRawPtr<ContainerNode> newParent, PassRefPtrW
illBeRawPtr<Node> newNextChild, const String& newString, WhitespaceMode newWhite
spaceMode) | 268 void append(RawPtr<ContainerNode> newParent, RawPtr<Node> newNextChild,
const String& newString, WhitespaceMode newWhitespaceMode) |
| 269 { | 269 { |
| 270 ASSERT(!parent || parent == newParent); | 270 ASSERT(!parent || parent == newParent); |
| 271 parent = newParent; | 271 parent = newParent; |
| 272 ASSERT(!nextChild || nextChild == newNextChild); | 272 ASSERT(!nextChild || nextChild == newNextChild); |
| 273 nextChild = newNextChild; | 273 nextChild = newNextChild; |
| 274 stringBuilder.append(newString); | 274 stringBuilder.append(newString); |
| 275 whitespaceMode = std::min(whitespaceMode, newWhitespaceMode); | 275 whitespaceMode = std::min(whitespaceMode, newWhitespaceMode); |
| 276 } | 276 } |
| 277 | 277 |
| 278 void swap(PendingText& other) | 278 void swap(PendingText& other) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 293 { | 293 { |
| 294 // When the stringbuilder is empty, the parent and whitespace should
also be "empty". | 294 // When the stringbuilder is empty, the parent and whitespace should
also be "empty". |
| 295 ASSERT(stringBuilder.isEmpty() == !parent); | 295 ASSERT(stringBuilder.isEmpty() == !parent); |
| 296 ASSERT(!stringBuilder.isEmpty() || !nextChild); | 296 ASSERT(!stringBuilder.isEmpty() || !nextChild); |
| 297 ASSERT(!stringBuilder.isEmpty() || (whitespaceMode == WhitespaceUnkn
own)); | 297 ASSERT(!stringBuilder.isEmpty() || (whitespaceMode == WhitespaceUnkn
own)); |
| 298 return stringBuilder.isEmpty(); | 298 return stringBuilder.isEmpty(); |
| 299 } | 299 } |
| 300 | 300 |
| 301 DECLARE_TRACE(); | 301 DECLARE_TRACE(); |
| 302 | 302 |
| 303 RefPtrWillBeMember<ContainerNode> parent; | 303 Member<ContainerNode> parent; |
| 304 RefPtrWillBeMember<Node> nextChild; | 304 Member<Node> nextChild; |
| 305 StringBuilder stringBuilder; | 305 StringBuilder stringBuilder; |
| 306 WhitespaceMode whitespaceMode; | 306 WhitespaceMode whitespaceMode; |
| 307 }; | 307 }; |
| 308 | 308 |
| 309 PendingText m_pendingText; | 309 PendingText m_pendingText; |
| 310 | 310 |
| 311 ParserContentPolicy m_parserContentPolicy; | 311 ParserContentPolicy m_parserContentPolicy; |
| 312 bool m_isParsingFragment; | 312 bool m_isParsingFragment; |
| 313 | 313 |
| 314 // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.
html#parsing-main-intable | 314 // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.
html#parsing-main-intable |
| 315 // In the "in table" insertion mode, we sometimes get into a state where | 315 // In the "in table" insertion mode, we sometimes get into a state where |
| 316 // "whenever a node would be inserted into the current node, it must instead | 316 // "whenever a node would be inserted into the current node, it must instead |
| 317 // be foster parented." This flag tracks whether we're in that state. | 317 // be foster parented." This flag tracks whether we're in that state. |
| 318 bool m_redirectAttachToFosterParent; | 318 bool m_redirectAttachToFosterParent; |
| 319 | 319 |
| 320 bool m_inQuirksMode; | 320 bool m_inQuirksMode; |
| 321 }; | 321 }; |
| 322 | 322 |
| 323 } // namespace blink | 323 } // namespace blink |
| 324 | 324 |
| 325 #endif | 325 #endif |
| OLD | NEW |