| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 return before; | 78 return before; |
| 79 default: | 79 default: |
| 80 return emptyString(); | 80 return emptyString(); |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 | 83 |
| 84 PseudoElement::PseudoElement(Element* parent, PseudoId pseudoId) | 84 PseudoElement::PseudoElement(Element* parent, PseudoId pseudoId) |
| 85 : Element(pseudoElementTagName(pseudoId), &parent->document(), CreateElement
) | 85 : Element(pseudoElementTagName(pseudoId), &parent->document(), CreateElement
) |
| 86 , m_pseudoId(pseudoId) | 86 , m_pseudoId(pseudoId) |
| 87 { | 87 { |
| 88 ASSERT(pseudoId != PseudoIdNone); | 88 DCHECK_NE(pseudoId, PseudoIdNone); |
| 89 parent->treeScope().adoptIfNeeded(*this); | 89 parent->treeScope().adoptIfNeeded(*this); |
| 90 setParentOrShadowHostNode(parent); | 90 setParentOrShadowHostNode(parent); |
| 91 setHasCustomStyleCallbacks(); | 91 setHasCustomStyleCallbacks(); |
| 92 if ((pseudoId == PseudoIdBefore || pseudoId == PseudoIdAfter) && parent->has
TagName(HTMLNames::inputTag)) | 92 if ((pseudoId == PseudoIdBefore || pseudoId == PseudoIdAfter) && parent->has
TagName(HTMLNames::inputTag)) |
| 93 UseCounter::count(parent->document(), UseCounter::PseudoBeforeAfterForIn
putElement); | 93 UseCounter::count(parent->document(), UseCounter::PseudoBeforeAfterForIn
putElement); |
| 94 } | 94 } |
| 95 | 95 |
| 96 PassRefPtr<ComputedStyle> PseudoElement::customStyleForLayoutObject() | 96 PassRefPtr<ComputedStyle> PseudoElement::customStyleForLayoutObject() |
| 97 { | 97 { |
| 98 return parentOrShadowHostElement()->layoutObject()->getCachedPseudoStyle(m_p
seudoId); | 98 return parentOrShadowHostElement()->layoutObject()->getCachedPseudoStyle(m_p
seudoId); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void PseudoElement::dispose() | 101 void PseudoElement::dispose() |
| 102 { | 102 { |
| 103 ASSERT(parentOrShadowHostElement()); | 103 DCHECK(parentOrShadowHostElement()); |
| 104 | 104 |
| 105 InspectorInstrumentation::pseudoElementDestroyed(this); | 105 InspectorInstrumentation::pseudoElementDestroyed(this); |
| 106 | 106 |
| 107 ASSERT(!nextSibling()); | 107 DCHECK(!nextSibling()); |
| 108 ASSERT(!previousSibling()); | 108 DCHECK(!previousSibling()); |
| 109 | 109 |
| 110 detach(); | 110 detach(); |
| 111 RawPtr<Element> parent = parentOrShadowHostElement(); | 111 RawPtr<Element> parent = parentOrShadowHostElement(); |
| 112 document().adoptIfNeeded(*this); | 112 document().adoptIfNeeded(*this); |
| 113 setParentOrShadowHostNode(0); | 113 setParentOrShadowHostNode(0); |
| 114 removedFrom(parent.get()); | 114 removedFrom(parent.get()); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void PseudoElement::attach(const AttachContext& context) | 117 void PseudoElement::attach(const AttachContext& context) |
| 118 { | 118 { |
| 119 ASSERT(!layoutObject()); | 119 DCHECK(!layoutObject()); |
| 120 | 120 |
| 121 Element::attach(context); | 121 Element::attach(context); |
| 122 | 122 |
| 123 LayoutObject* layoutObject = this->layoutObject(); | 123 LayoutObject* layoutObject = this->layoutObject(); |
| 124 if (!layoutObject) | 124 if (!layoutObject) |
| 125 return; | 125 return; |
| 126 | 126 |
| 127 ComputedStyle& style = layoutObject->mutableStyleRef(); | 127 ComputedStyle& style = layoutObject->mutableStyleRef(); |
| 128 if (style.styleType() != PseudoIdBefore && style.styleType() != PseudoIdAfte
r) | 128 if (style.styleType() != PseudoIdBefore && style.styleType() != PseudoIdAfte
r) |
| 129 return; | 129 return; |
| 130 ASSERT(style.contentData()); | 130 DCHECK(style.contentData()); |
| 131 | 131 |
| 132 for (const ContentData* content = style.contentData(); content; content = co
ntent->next()) { | 132 for (const ContentData* content = style.contentData(); content; content = co
ntent->next()) { |
| 133 LayoutObject* child = content->createLayoutObject(document(), style); | 133 LayoutObject* child = content->createLayoutObject(document(), style); |
| 134 if (layoutObject->isChildAllowed(child, style)) { | 134 if (layoutObject->isChildAllowed(child, style)) { |
| 135 layoutObject->addChild(child); | 135 layoutObject->addChild(child); |
| 136 if (child->isQuote()) | 136 if (child->isQuote()) |
| 137 toLayoutQuote(child)->attachQuote(); | 137 toLayoutQuote(child)->attachQuote(); |
| 138 } else { | 138 } else { |
| 139 child->destroy(); | 139 child->destroy(); |
| 140 } | 140 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 // first-letter pseudo element. So, by walking up the Layout tree we know | 173 // first-letter pseudo element. So, by walking up the Layout tree we know |
| 174 // we will get the parent and not some other ancestor. | 174 // we will get the parent and not some other ancestor. |
| 175 Node* PseudoElement::findAssociatedNode() const | 175 Node* PseudoElement::findAssociatedNode() const |
| 176 { | 176 { |
| 177 // The ::backdrop element is parented to the LayoutView, not to the node | 177 // The ::backdrop element is parented to the LayoutView, not to the node |
| 178 // that it's associated with. We need to make sure ::backdrop sends the | 178 // that it's associated with. We need to make sure ::backdrop sends the |
| 179 // events to the parent node correctly. | 179 // events to the parent node correctly. |
| 180 if (getPseudoId() == PseudoIdBackdrop) | 180 if (getPseudoId() == PseudoIdBackdrop) |
| 181 return parentOrShadowHostNode(); | 181 return parentOrShadowHostNode(); |
| 182 | 182 |
| 183 ASSERT(layoutObject()); | 183 DCHECK(layoutObject()); |
| 184 ASSERT(layoutObject()->parent()); | 184 DCHECK(layoutObject()->parent()); |
| 185 | 185 |
| 186 // We can have any number of anonymous layout objects inserted between | 186 // We can have any number of anonymous layout objects inserted between |
| 187 // us and our parent so make sure we skip over them. | 187 // us and our parent so make sure we skip over them. |
| 188 LayoutObject* ancestor = layoutObject()->parent(); | 188 LayoutObject* ancestor = layoutObject()->parent(); |
| 189 while (ancestor->isAnonymous() || (ancestor->node() && ancestor->node()->isP
seudoElement())) { | 189 while (ancestor->isAnonymous() || (ancestor->node() && ancestor->node()->isP
seudoElement())) { |
| 190 ASSERT(ancestor->parent()); | 190 DCHECK(ancestor->parent()); |
| 191 ancestor = ancestor->parent(); | 191 ancestor = ancestor->parent(); |
| 192 } | 192 } |
| 193 return ancestor->node(); | 193 return ancestor->node(); |
| 194 } | 194 } |
| 195 | 195 |
| 196 } // namespace blink | 196 } // namespace blink |
| OLD | NEW |