OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Neither the name of Google Inc. nor the names of its | 10 * * Neither the name of Google Inc. nor the names of its |
(...skipping 11 matching lines...) Expand all Loading... |
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 */ | 25 */ |
26 | 26 |
27 #include "core/dom/PseudoElement.h" | 27 #include "core/dom/PseudoElement.h" |
28 | 28 |
29 #include "core/dom/FirstLetterPseudoElement.h" | 29 #include "core/dom/FirstLetterPseudoElement.h" |
30 #include "core/frame/UseCounter.h" | 30 #include "core/frame/UseCounter.h" |
31 #include "core/inspector/InspectorInstrumentation.h" | 31 #include "core/inspector/InspectorInstrumentation.h" |
| 32 #include "core/layout/GeneratedChildren.h" |
32 #include "core/layout/LayoutObject.h" | 33 #include "core/layout/LayoutObject.h" |
33 #include "core/layout/LayoutQuote.h" | 34 #include "core/layout/LayoutQuote.h" |
34 #include "core/style/ContentData.h" | 35 #include "core/style/ContentData.h" |
35 | 36 |
36 namespace blink { | 37 namespace blink { |
37 | 38 |
38 PseudoElement* PseudoElement::create(Element* parent, PseudoId pseudoId) | 39 PseudoElement* PseudoElement::create(Element* parent, PseudoId pseudoId) |
39 { | 40 { |
40 return new PseudoElement(parent, pseudoId); | 41 return new PseudoElement(parent, pseudoId); |
41 } | 42 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 void PseudoElement::attach(const AttachContext& context) | 118 void PseudoElement::attach(const AttachContext& context) |
118 { | 119 { |
119 DCHECK(!layoutObject()); | 120 DCHECK(!layoutObject()); |
120 | 121 |
121 Element::attach(context); | 122 Element::attach(context); |
122 | 123 |
123 LayoutObject* layoutObject = this->layoutObject(); | 124 LayoutObject* layoutObject = this->layoutObject(); |
124 if (!layoutObject) | 125 if (!layoutObject) |
125 return; | 126 return; |
126 | 127 |
| 128 // This is to ensure that bypassing the canHaveGeneratedChildren check in |
| 129 // StyleResolver::createPseudoElementIfNeeded does not result in the |
| 130 // backdrop pseudo element's layout object becoming the child of a layout |
| 131 // object that doesn't allow children. |
| 132 DCHECK(layoutObject->parent()); |
| 133 DCHECK(canHaveGeneratedChildren(*layoutObject->parent())); |
| 134 |
127 ComputedStyle& style = layoutObject->mutableStyleRef(); | 135 ComputedStyle& style = layoutObject->mutableStyleRef(); |
128 if (style.styleType() != PseudoIdBefore && style.styleType() != PseudoIdAfte
r) | 136 if (style.styleType() != PseudoIdBefore && style.styleType() != PseudoIdAfte
r) |
129 return; | 137 return; |
130 DCHECK(style.contentData()); | 138 DCHECK(style.contentData()); |
131 | 139 |
132 for (const ContentData* content = style.contentData(); content; content = co
ntent->next()) { | 140 for (const ContentData* content = style.contentData(); content; content = co
ntent->next()) { |
133 LayoutObject* child = content->createLayoutObject(document(), style); | 141 LayoutObject* child = content->createLayoutObject(document(), style); |
134 if (layoutObject->isChildAllowed(child, style)) { | 142 if (layoutObject->isChildAllowed(child, style)) { |
135 layoutObject->addChild(child); | 143 layoutObject->addChild(child); |
136 if (child->isQuote()) | 144 if (child->isQuote()) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 // us and our parent so make sure we skip over them. | 195 // us and our parent so make sure we skip over them. |
188 LayoutObject* ancestor = layoutObject()->parent(); | 196 LayoutObject* ancestor = layoutObject()->parent(); |
189 while (ancestor->isAnonymous() || (ancestor->node() && ancestor->node()->isP
seudoElement())) { | 197 while (ancestor->isAnonymous() || (ancestor->node() && ancestor->node()->isP
seudoElement())) { |
190 DCHECK(ancestor->parent()); | 198 DCHECK(ancestor->parent()); |
191 ancestor = ancestor->parent(); | 199 ancestor = ancestor->parent(); |
192 } | 200 } |
193 return ancestor->node(); | 201 return ancestor->node(); |
194 } | 202 } |
195 | 203 |
196 } // namespace blink | 204 } // namespace blink |
OLD | NEW |