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 1578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1589 for (; record; record = record->next()) { | 1589 for (; record; record = record->next()) { |
1590 if (record->element() == formattingElement) | 1590 if (record->element() == formattingElement) |
1591 return furthestBlock; | 1591 return furthestBlock; |
1592 if (isSpecialNode(record->element())) | 1592 if (isSpecialNode(record->element())) |
1593 furthestBlock = record; | 1593 furthestBlock = record; |
1594 } | 1594 } |
1595 ASSERT_NOT_REACHED(); | 1595 ASSERT_NOT_REACHED(); |
1596 return 0; | 1596 return 0; |
1597 } | 1597 } |
1598 | 1598 |
1599 // FIXME: This should have a whitty name. | |
1600 // FIXME: This must be implemented in many other places in WebCore. | |
1601 void HTMLTreeBuilder::reparentChildren(Element* oldParent, Element* newParent) | |
1602 { | |
1603 Node* child = oldParent->firstChild(); | |
1604 while (child) { | |
1605 Node* nextChild = child->nextSibling(); | |
1606 oldParent->parserRemoveChild(child); | |
1607 newParent->parserAddChild(child); | |
1608 if (newParent->attached() && !child->attached()) | |
1609 child->attach(); | |
1610 child = nextChild; | |
1611 } | |
1612 } | |
1613 | |
1614 // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html
#parsing-main-inbody | 1599 // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html
#parsing-main-inbody |
1615 void HTMLTreeBuilder::callTheAdoptionAgency(AtomicHTMLToken& token) | 1600 void HTMLTreeBuilder::callTheAdoptionAgency(AtomicHTMLToken& token) |
1616 { | 1601 { |
1617 // The adoption agency algorithm is N^2. We limit the number of iterations | 1602 // The adoption agency algorithm is N^2. We limit the number of iterations |
1618 // to stop from hanging the whole browser. This limit is copied from the | 1603 // to stop from hanging the whole browser. This limit is copied from the |
1619 // legacy tree builder and might need to be tweaked in the future. | 1604 // legacy tree builder and might need to be tweaked in the future. |
1620 static const int adoptionAgencyIterationLimit = 10; | 1605 static const int adoptionAgencyIterationLimit = 10; |
1621 | 1606 |
1622 for (int i = 0; i < adoptionAgencyIterationLimit; ++i) { | 1607 for (int i = 0; i < adoptionAgencyIterationLimit; ++i) { |
1623 // 1. | 1608 // 1. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1696 || isTableBodyContextTag(commonAncestorTag)) | 1681 || isTableBodyContextTag(commonAncestorTag)) |
1697 m_tree.fosterParent(lastNode->element()); | 1682 m_tree.fosterParent(lastNode->element()); |
1698 else { | 1683 else { |
1699 commonAncestor->parserAddChild(lastNode->element()); | 1684 commonAncestor->parserAddChild(lastNode->element()); |
1700 if (lastNode->element()->parentElement()->attached() && !lastNode->e
lement()->attached()) | 1685 if (lastNode->element()->parentElement()->attached() && !lastNode->e
lement()->attached()) |
1701 lastNode->element()->lazyAttach(); | 1686 lastNode->element()->lazyAttach(); |
1702 } | 1687 } |
1703 // 8 | 1688 // 8 |
1704 RefPtr<Element> newElement = m_tree.createHTMLElementFromElementRecord(f
ormattingElementRecord); | 1689 RefPtr<Element> newElement = m_tree.createHTMLElementFromElementRecord(f
ormattingElementRecord); |
1705 // 9 | 1690 // 9 |
1706 reparentChildren(furthestBlock->element(), newElement.get()); | 1691 newElement->takeAllChildrenFrom(furthestBlock->element()); |
1707 // 10 | 1692 // 10 |
1708 Element* furthestBlockElement = furthestBlock->element(); | 1693 Element* furthestBlockElement = furthestBlock->element(); |
1709 // FIXME: All this creation / parserAddChild / attach business should | 1694 // FIXME: All this creation / parserAddChild / attach business should |
1710 // be in HTMLConstructionSite. My guess is that steps 8--12 | 1695 // be in HTMLConstructionSite. My guess is that steps 8--12 |
1711 // should all be in some HTMLConstructionSite function. | 1696 // should all be in some HTMLConstructionSite function. |
1712 furthestBlockElement->parserAddChild(newElement); | 1697 furthestBlockElement->parserAddChild(newElement); |
1713 if (furthestBlockElement->attached() && !newElement->attached()) { | 1698 if (furthestBlockElement->attached() && !newElement->attached()) { |
1714 // Notice that newElement might already be attached if, for example,
one of the reparented | 1699 // Notice that newElement might already be attached if, for example,
one of the reparented |
1715 // children is a style element, which attaches itself automatically. | 1700 // children is a style element, which attaches itself automatically. |
1716 newElement->attach(); | 1701 newElement->attach(); |
(...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2851 return false; | 2836 return false; |
2852 // -0 -> 0 | 2837 // -0 -> 0 |
2853 if (!value) | 2838 if (!value) |
2854 value = 0; | 2839 value = 0; |
2855 if (out) | 2840 if (out) |
2856 *out = value; | 2841 *out = value; |
2857 return true; | 2842 return true; |
2858 } | 2843 } |
2859 | 2844 |
2860 } | 2845 } |
OLD | NEW |