| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 if (task.child->parentNode() && task.parent->attached() && !task.child->atta
ched()) | 100 if (task.child->parentNode() && task.parent->attached() && !task.child->atta
ched()) |
| 101 task.child->attach(); | 101 task.child->attach(); |
| 102 | 102 |
| 103 task.child->beginParsingChildren(); | 103 task.child->beginParsingChildren(); |
| 104 | 104 |
| 105 if (task.selfClosing) | 105 if (task.selfClosing) |
| 106 task.child->finishParsingChildren(); | 106 task.child->finishParsingChildren(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void HTMLConstructionSite::attachLater(ContainerNode* parent, PassRefPtr<Node> p
rpChild) | 109 void HTMLConstructionSite::attachLater(ContainerNode* parent, PassRefPtr<Node> p
rpChild, bool selfClosing) |
| 110 { | 110 { |
| 111 HTMLConstructionSiteTask task; | 111 HTMLConstructionSiteTask task; |
| 112 task.parent = parent; | 112 task.parent = parent; |
| 113 task.child = prpChild; | 113 task.child = prpChild; |
| 114 task.selfClosing = selfClosing; |
| 114 | 115 |
| 115 if (shouldFosterParent()) { | 116 if (shouldFosterParent()) { |
| 116 fosterParent(task.child); | 117 fosterParent(task.child); |
| 117 return; | 118 return; |
| 118 } | 119 } |
| 119 | 120 |
| 120 // Add as a sibling of the parent if we have reached the maximum depth allow
ed. | 121 // Add as a sibling of the parent if we have reached the maximum depth allow
ed. |
| 121 if (m_openElements.stackDepth() > m_maximumDOMTreeDepth && task.parent->pare
ntNode()) | 122 if (m_openElements.stackDepth() > m_maximumDOMTreeDepth && task.parent->pare
ntNode()) |
| 122 task.parent = task.parent->parentNode(); | 123 task.parent = task.parent->parentNode(); |
| 123 | 124 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 void HTMLConstructionSite::insertHTMLElement(AtomicHTMLToken& token) | 309 void HTMLConstructionSite::insertHTMLElement(AtomicHTMLToken& token) |
| 309 { | 310 { |
| 310 RefPtr<Element> element = createHTMLElement(token); | 311 RefPtr<Element> element = createHTMLElement(token); |
| 311 attachLater(currentNode(), element); | 312 attachLater(currentNode(), element); |
| 312 m_openElements.push(element.release()); | 313 m_openElements.push(element.release()); |
| 313 } | 314 } |
| 314 | 315 |
| 315 void HTMLConstructionSite::insertSelfClosingHTMLElement(AtomicHTMLToken& token) | 316 void HTMLConstructionSite::insertSelfClosingHTMLElement(AtomicHTMLToken& token) |
| 316 { | 317 { |
| 317 ASSERT(token.type() == HTMLTokenTypes::StartTag); | 318 ASSERT(token.type() == HTMLTokenTypes::StartTag); |
| 318 attachLater(currentNode(), createHTMLElement(token)); | |
| 319 // Normally HTMLElementStack is responsible for calling finishParsingChildre
n, | 319 // Normally HTMLElementStack is responsible for calling finishParsingChildre
n, |
| 320 // but self-closing elements are never in the element stack so the stack | 320 // but self-closing elements are never in the element stack so the stack |
| 321 // doesn't get a chance to tell them that we're done parsing their children. | 321 // doesn't get a chance to tell them that we're done parsing their children. |
| 322 m_attachmentQueue.last().selfClosing = true; | 322 attachLater(currentNode(), createHTMLElement(token), true); |
| 323 // FIXME: Do we want to acknowledge the token's self-closing flag? | 323 // FIXME: Do we want to acknowledge the token's self-closing flag? |
| 324 // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.
html#acknowledge-self-closing-flag | 324 // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.
html#acknowledge-self-closing-flag |
| 325 } | 325 } |
| 326 | 326 |
| 327 void HTMLConstructionSite::insertFormattingElement(AtomicHTMLToken& token) | 327 void HTMLConstructionSite::insertFormattingElement(AtomicHTMLToken& token) |
| 328 { | 328 { |
| 329 // http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#
the-stack-of-open-elements | 329 // http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#
the-stack-of-open-elements |
| 330 // Possible active formatting elements include: | 330 // Possible active formatting elements include: |
| 331 // a, b, big, code, em, font, i, nobr, s, small, strike, strong, tt, and u. | 331 // a, b, big, code, em, font, i, nobr, s, small, strike, strong, tt, and u. |
| 332 insertHTMLElement(token); | 332 insertHTMLElement(token); |
| 333 m_activeFormattingElements.append(currentElement()); | 333 m_activeFormattingElements.append(currentElement()); |
| 334 } | 334 } |
| 335 | 335 |
| 336 void HTMLConstructionSite::insertScriptElement(AtomicHTMLToken& token) | 336 void HTMLConstructionSite::insertScriptElement(AtomicHTMLToken& token) |
| 337 { | 337 { |
| 338 RefPtr<HTMLScriptElement> element = HTMLScriptElement::create(scriptTag, cur
rentNode()->document(), true); | 338 RefPtr<HTMLScriptElement> element = HTMLScriptElement::create(scriptTag, cur
rentNode()->document(), true); |
| 339 if (m_fragmentScriptingPermission == FragmentScriptingAllowed) | 339 if (m_fragmentScriptingPermission == FragmentScriptingAllowed) |
| 340 element->parserSetAttributes(token.attributes(), m_fragmentScriptingPerm
ission); | 340 element->parserSetAttributes(token.attributes(), m_fragmentScriptingPerm
ission); |
| 341 attachLater(currentNode(), element); | 341 attachLater(currentNode(), element); |
| 342 m_openElements.push(element.release()); | 342 m_openElements.push(element.release()); |
| 343 } | 343 } |
| 344 | 344 |
| 345 void HTMLConstructionSite::insertForeignElement(AtomicHTMLToken& token, const At
omicString& namespaceURI) | 345 void HTMLConstructionSite::insertForeignElement(AtomicHTMLToken& token, const At
omicString& namespaceURI) |
| 346 { | 346 { |
| 347 ASSERT(token.type() == HTMLTokenTypes::StartTag); | 347 ASSERT(token.type() == HTMLTokenTypes::StartTag); |
| 348 notImplemented(); // parseError when xmlns or xmlns:xlink are wrong. | 348 notImplemented(); // parseError when xmlns or xmlns:xlink are wrong. |
| 349 | 349 |
| 350 RefPtr<Element> element = createElement(token, namespaceURI); | 350 RefPtr<Element> element = createElement(token, namespaceURI); |
| 351 attachLater(currentNode(), element); | 351 attachLater(currentNode(), element, token.selfClosing()); |
| 352 // FIXME: Don't we need to set the selfClosing flag on the task if we're | |
| 353 // not going to push the element on to the stack of open elements? | |
| 354 if (!token.selfClosing()) | 352 if (!token.selfClosing()) |
| 355 m_openElements.push(element.release()); | 353 m_openElements.push(element.release()); |
| 356 } | 354 } |
| 357 | 355 |
| 358 void HTMLConstructionSite::insertTextNode(const String& characters, WhitespaceMo
de whitespaceMode) | 356 void HTMLConstructionSite::insertTextNode(const String& characters, WhitespaceMo
de whitespaceMode) |
| 359 { | 357 { |
| 360 HTMLConstructionSiteTask task; | 358 HTMLConstructionSiteTask task; |
| 361 task.parent = currentNode(); | 359 task.parent = currentNode(); |
| 362 | 360 |
| 363 if (shouldFosterParent()) | 361 if (shouldFosterParent()) |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 void HTMLConstructionSite::fosterParent(PassRefPtr<Node> node) | 511 void HTMLConstructionSite::fosterParent(PassRefPtr<Node> node) |
| 514 { | 512 { |
| 515 HTMLConstructionSiteTask task; | 513 HTMLConstructionSiteTask task; |
| 516 findFosterSite(task); | 514 findFosterSite(task); |
| 517 task.child = node; | 515 task.child = node; |
| 518 ASSERT(task.parent); | 516 ASSERT(task.parent); |
| 519 m_attachmentQueue.append(task); | 517 m_attachmentQueue.append(task); |
| 520 } | 518 } |
| 521 | 519 |
| 522 } | 520 } |
| OLD | NEW |