Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Side by Side Diff: third_party/WebKit/Source/core/dom/PseudoElement.cpp

Issue 1765933003: style: Rename the PseudoId enum values to CamelCase and prefix them. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: enum-clash-PseudoId: none Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 25 matching lines...) Expand all
36 namespace blink { 36 namespace blink {
37 37
38 PassRefPtrWillBeRawPtr<PseudoElement> PseudoElement::create(Element* parent, Pse udoId pseudoId) 38 PassRefPtrWillBeRawPtr<PseudoElement> PseudoElement::create(Element* parent, Pse udoId pseudoId)
39 { 39 {
40 return adoptRefWillBeNoop(new PseudoElement(parent, pseudoId)); 40 return adoptRefWillBeNoop(new PseudoElement(parent, pseudoId));
41 } 41 }
42 42
43 const QualifiedName& pseudoElementTagName(PseudoId pseudoId) 43 const QualifiedName& pseudoElementTagName(PseudoId pseudoId)
44 { 44 {
45 switch (pseudoId) { 45 switch (pseudoId) {
46 case AFTER: { 46 case PseudoIdAfter: {
47 DEFINE_STATIC_LOCAL(QualifiedName, after, (nullAtom, "<pseudo:after>", n ullAtom)); 47 DEFINE_STATIC_LOCAL(QualifiedName, after, (nullAtom, "<pseudo:after>", n ullAtom));
48 return after; 48 return after;
49 } 49 }
50 case BEFORE: { 50 case PseudoIdBefore: {
51 DEFINE_STATIC_LOCAL(QualifiedName, before, (nullAtom, "<pseudo:before>", nullAtom)); 51 DEFINE_STATIC_LOCAL(QualifiedName, before, (nullAtom, "<pseudo:before>", nullAtom));
52 return before; 52 return before;
53 } 53 }
54 case BACKDROP: { 54 case PseudoIdBackdrop: {
55 DEFINE_STATIC_LOCAL(QualifiedName, backdrop, (nullAtom, "<pseudo:backdro p>", nullAtom)); 55 DEFINE_STATIC_LOCAL(QualifiedName, backdrop, (nullAtom, "<pseudo:backdro p>", nullAtom));
56 return backdrop; 56 return backdrop;
57 } 57 }
58 case FIRST_LETTER: { 58 case PseudoIdFirstLetter: {
59 DEFINE_STATIC_LOCAL(QualifiedName, firstLetter, (nullAtom, "<pseudo:firs t-letter>", nullAtom)); 59 DEFINE_STATIC_LOCAL(QualifiedName, firstLetter, (nullAtom, "<pseudo:firs t-letter>", nullAtom));
60 return firstLetter; 60 return firstLetter;
61 } 61 }
62 default: { 62 default: {
63 ASSERT_NOT_REACHED(); 63 ASSERT_NOT_REACHED();
64 } 64 }
65 } 65 }
66 DEFINE_STATIC_LOCAL(QualifiedName, name, (nullAtom, "<pseudo>", nullAtom)); 66 DEFINE_STATIC_LOCAL(QualifiedName, name, (nullAtom, "<pseudo>", nullAtom));
67 return name; 67 return name;
68 } 68 }
69 69
70 String PseudoElement::pseudoElementNameForEvents(PseudoId pseudoId) 70 String PseudoElement::pseudoElementNameForEvents(PseudoId pseudoId)
71 { 71 {
72 DEFINE_STATIC_LOCAL(const String, after, ("::after")); 72 DEFINE_STATIC_LOCAL(const String, after, ("::after"));
73 DEFINE_STATIC_LOCAL(const String, before, ("::before")); 73 DEFINE_STATIC_LOCAL(const String, before, ("::before"));
74 switch (pseudoId) { 74 switch (pseudoId) {
75 case AFTER: 75 case PseudoIdAfter:
76 return after; 76 return after;
77 case BEFORE: 77 case PseudoIdBefore:
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 != NOPSEUDO); 88 ASSERT(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 == BEFORE || pseudoId == AFTER) && parent->hasTagName(HTMLName s::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 {
(...skipping 15 matching lines...) Expand all
118 { 118 {
119 ASSERT(!layoutObject()); 119 ASSERT(!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() != BEFORE && style.styleType() != AFTER) 128 if (style.styleType() != PseudoIdBefore && style.styleType() != PseudoIdAfte r)
129 return; 129 return;
130 ASSERT(style.contentData()); 130 ASSERT(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 {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 // pseudo element we will get some arbitrary ancestor of the LayoutObject. 170 // pseudo element we will get some arbitrary ancestor of the LayoutObject.
171 // 171 //
172 // For hit testing, we need the parent Node of the LayoutObject for the 172 // For hit testing, we need the parent Node of the LayoutObject for the
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() == BACKDROP) 180 if (getPseudoId() == PseudoIdBackdrop)
181 return parentOrShadowHostNode(); 181 return parentOrShadowHostNode();
182 182
183 ASSERT(layoutObject()); 183 ASSERT(layoutObject());
184 ASSERT(layoutObject()->parent()); 184 ASSERT(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 ASSERT(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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/PseudoElement.h ('k') | third_party/WebKit/Source/core/events/EventPathTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698