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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 return tagName == tableTag | 76 return tagName == tableTag |
77 || tagName == tbodyTag | 77 || tagName == tbodyTag |
78 || tagName == tfootTag | 78 || tagName == tfootTag |
79 || tagName == theadTag | 79 || tagName == theadTag |
80 || tagName == trTag; | 80 || tagName == trTag; |
81 } | 81 } |
82 | 82 |
83 } // namespace | 83 } // namespace |
84 | 84 |
85 template<typename ChildType> | 85 template<typename ChildType> |
86 PassRefPtr<ChildType> HTMLConstructionSite::attach(ContainerNode* parent, PassRe
fPtr<ChildType> prpChild) | 86 PassRefPtr<ChildType> HTMLConstructionSite::attach(ContainerNode* rawParent, Pas
sRefPtr<ChildType> prpChild) |
87 { | 87 { |
88 RefPtr<ChildType> child = prpChild; | 88 RefPtr<ChildType> child = prpChild; |
| 89 RefPtr<ContainerNode> parent = rawParent; |
89 | 90 |
90 // FIXME: It's confusing that HTMLConstructionSite::attach does the magic | 91 // FIXME: It's confusing that HTMLConstructionSite::attach does the magic |
91 // redirection to the foster parent but HTMLConstructionSite::attachAtSite | 92 // redirection to the foster parent but HTMLConstructionSite::attachAtSite |
92 // doesn't. It feels like we're missing a concept somehow. | 93 // doesn't. It feels like we're missing a concept somehow. |
93 if (shouldFosterParent()) { | 94 if (shouldFosterParent()) { |
94 fosterParent(child.get()); | 95 fosterParent(child.get()); |
95 ASSERT(child->attached() || !child->parentNode() || !child->parentNode()
->attached()); | 96 ASSERT(child->attached() || !child->parentNode() || !child->parentNode()
->attached()); |
96 return child.release(); | 97 return child.release(); |
97 } | 98 } |
98 | 99 |
99 parent->parserAddChild(child); | 100 parent->parserAddChild(child); |
100 | 101 |
101 // An event handler (DOM Mutation, beforeload, et al.) could have removed | 102 // An event handler (DOM Mutation, beforeload, et al.) could have removed |
102 // the child, in which case we shouldn't try attaching it. | 103 // the child, in which case we shouldn't try attaching it. |
103 if (!child->parentNode()) | 104 if (!child->parentNode()) |
104 return child.release(); | 105 return child.release(); |
105 | 106 |
106 // It's slightly unfortunate that we need to hold a reference to child | |
107 // here to call attach(). We should investigate whether we can rely on | |
108 // |parent| to hold a ref at this point. In the common case (at least | |
109 // for elements), however, we'll get to use this ref in the stack of | |
110 // open elements. | |
111 if (parent->attached() && !child->attached()) | 107 if (parent->attached() && !child->attached()) |
112 child->attach(); | 108 child->attach(); |
113 return child.release(); | 109 return child.release(); |
114 } | 110 } |
115 | 111 |
116 void HTMLConstructionSite::attachAtSite(const AttachmentSite& site, PassRefPtr<N
ode> prpChild) | 112 void HTMLConstructionSite::attachAtSite(const AttachmentSite& site, PassRefPtr<N
ode> prpChild) |
117 { | 113 { |
118 // FIXME: It's unfortunate that we need to hold a reference to child | 114 // FIXME: It's unfortunate that we need to hold a reference to child |
119 // here to call attach(). We should investigate whether we can rely on | 115 // here to call attach(). We should investigate whether we can rely on |
120 // |site.parent| to hold a ref at this point. | 116 // |site.parent| to hold a ref at this point. |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 } | 492 } |
497 | 493 |
498 void HTMLConstructionSite::fosterParent(Node* node) | 494 void HTMLConstructionSite::fosterParent(Node* node) |
499 { | 495 { |
500 AttachmentSite site; | 496 AttachmentSite site; |
501 findFosterSite(site); | 497 findFosterSite(site); |
502 attachAtSite(site, node); | 498 attachAtSite(site, node); |
503 } | 499 } |
504 | 500 |
505 } | 501 } |
OLD | NEW |