| 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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 // If we have a whole string of unbreakable characters the above could l
ead to an infinite loop. Exceeding the length limit is the lesser evil. | 385 // If we have a whole string of unbreakable characters the above could l
ead to an infinite loop. Exceeding the length limit is the lesser evil. |
| 386 if (!textNode->length()) { | 386 if (!textNode->length()) { |
| 387 String substring = characters.substring(currentPosition); | 387 String substring = characters.substring(currentPosition); |
| 388 textNode = Text::create(task.parent->document(), shouldUseAtomicStri
ng ? AtomicString(substring).string() : substring); | 388 textNode = Text::create(task.parent->document(), shouldUseAtomicStri
ng ? AtomicString(substring).string() : substring); |
| 389 } | 389 } |
| 390 | 390 |
| 391 currentPosition += textNode->length(); | 391 currentPosition += textNode->length(); |
| 392 ASSERT(currentPosition <= characters.length()); | 392 ASSERT(currentPosition <= characters.length()); |
| 393 task.child = textNode.release(); | 393 task.child = textNode.release(); |
| 394 | 394 |
| 395 if (task.parent->document() != task.child->document()) | |
| 396 task.parent->document()->adoptNode(task.child, ASSERT_NO_EXCEPTION); | |
| 397 | |
| 398 executeTask(task); | 395 executeTask(task); |
| 399 } | 396 } |
| 400 } | 397 } |
| 401 | 398 |
| 402 PassRefPtr<Element> HTMLConstructionSite::createElement(AtomicHTMLToken* token,
const AtomicString& namespaceURI) | 399 PassRefPtr<Element> HTMLConstructionSite::createElement(AtomicHTMLToken* token,
const AtomicString& namespaceURI) |
| 403 { | 400 { |
| 404 QualifiedName tagName(nullAtom, token->name(), namespaceURI); | 401 QualifiedName tagName(nullAtom, token->name(), namespaceURI); |
| 405 RefPtr<Element> element = ownerDocumentForCurrentNode()->createElement(tagNa
me, true); | 402 RefPtr<Element> element = ownerDocumentForCurrentNode()->createElement(tagNa
me, true); |
| 406 element->parserSetAttributes(token->attributes(), m_fragmentScriptingPermiss
ion); | 403 element->parserSetAttributes(token->attributes(), m_fragmentScriptingPermiss
ion); |
| 407 return element.release(); | 404 return element.release(); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 while (hasImpliedEndTag(currentStackItem())) | 480 while (hasImpliedEndTag(currentStackItem())) |
| 484 m_openElements.pop(); | 481 m_openElements.pop(); |
| 485 } | 482 } |
| 486 | 483 |
| 487 void HTMLConstructionSite::findFosterSite(HTMLConstructionSiteTask& task) | 484 void HTMLConstructionSite::findFosterSite(HTMLConstructionSiteTask& task) |
| 488 { | 485 { |
| 489 #if ENABLE(TEMPLATE_ELEMENT) | 486 #if ENABLE(TEMPLATE_ELEMENT) |
| 490 // When a node is to be foster parented, the last template element with no t
able element is below it in the stack of open elements is the foster parent elem
ent (NOT the template's parent!) | 487 // When a node is to be foster parented, the last template element with no t
able element is below it in the stack of open elements is the foster parent elem
ent (NOT the template's parent!) |
| 491 HTMLElementStack::ElementRecord* lastTemplateElement = m_openElements.topmos
t(templateTag.localName()); | 488 HTMLElementStack::ElementRecord* lastTemplateElement = m_openElements.topmos
t(templateTag.localName()); |
| 492 if (lastTemplateElement && !m_openElements.inTableScope(tableTag)) { | 489 if (lastTemplateElement && !m_openElements.inTableScope(tableTag)) { |
| 493 task.parent = toHTMLTemplateElement(lastTemplateElement->element())->con
tent(); | 490 task.parent = lastTemplateElement->element(); |
| 494 return; | 491 return; |
| 495 } | 492 } |
| 496 | 493 |
| 497 #endif | 494 #endif |
| 498 | 495 |
| 499 HTMLElementStack::ElementRecord* lastTableElementRecord = m_openElements.top
most(tableTag.localName()); | 496 HTMLElementStack::ElementRecord* lastTableElementRecord = m_openElements.top
most(tableTag.localName()); |
| 500 if (lastTableElementRecord) { | 497 if (lastTableElementRecord) { |
| 501 Element* lastTableElement = lastTableElementRecord->element(); | 498 Element* lastTableElement = lastTableElementRecord->element(); |
| 502 ContainerNode* parent = lastTableElement->parentNode(); | 499 ContainerNode* parent = lastTableElement->parentNode(); |
| 503 // When parsing HTML fragments, we skip step 4.2 ("Let root be a new htm
l element with no attributes") for efficiency, | 500 // When parsing HTML fragments, we skip step 4.2 ("Let root be a new htm
l element with no attributes") for efficiency, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 521 && currentStackItem()->causesFosterParenting(); | 518 && currentStackItem()->causesFosterParenting(); |
| 522 } | 519 } |
| 523 | 520 |
| 524 void HTMLConstructionSite::fosterParent(PassRefPtr<Node> node) | 521 void HTMLConstructionSite::fosterParent(PassRefPtr<Node> node) |
| 525 { | 522 { |
| 526 HTMLConstructionSiteTask task; | 523 HTMLConstructionSiteTask task; |
| 527 findFosterSite(task); | 524 findFosterSite(task); |
| 528 task.child = node; | 525 task.child = node; |
| 529 ASSERT(task.parent); | 526 ASSERT(task.parent); |
| 530 | 527 |
| 531 if (task.parent->document() != task.child->document()) | |
| 532 task.parent->document()->adoptNode(task.child, ASSERT_NO_EXCEPTION); | |
| 533 | |
| 534 m_attachmentQueue.append(task); | 528 m_attachmentQueue.append(task); |
| 535 } | 529 } |
| 536 | 530 |
| 537 } | 531 } |
| OLD | NEW |