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 12 matching lines...) Expand all Loading... | |
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 #ifndef PseudoElement_h | 27 #ifndef PseudoElement_h |
28 #define PseudoElement_h | 28 #define PseudoElement_h |
29 | 29 |
30 #include "core/CoreExport.h" | 30 #include "core/CoreExport.h" |
31 #include "core/dom/Element.h" | 31 #include "core/dom/Element.h" |
32 #include "core/style/ComputedStyle.h" | 32 #include "core/style/ComputedStyle.h" |
33 #include "platform/heap/Handle.h" | |
33 | 34 |
34 namespace blink { | 35 namespace blink { |
35 | 36 |
36 class CORE_EXPORT PseudoElement : public Element { | 37 class CORE_EXPORT PseudoElement : public Element { |
37 public: | 38 public: |
38 static PseudoElement* create(Element* parent, PseudoId); | 39 static PseudoElement* create(Element* parent, PseudoId); |
39 | 40 |
40 PassRefPtr<ComputedStyle> customStyleForLayoutObject() override; | 41 PassRefPtr<ComputedStyle> customStyleForLayoutObject() override; |
41 void attach(const AttachContext& = AttachContext()) override; | 42 void attach(const AttachContext& = AttachContext()) override; |
42 bool layoutObjectIsNeeded(const ComputedStyle&) override; | 43 bool layoutObjectIsNeeded(const ComputedStyle&) override; |
(...skipping 10 matching lines...) Expand all Loading... | |
53 | 54 |
54 protected: | 55 protected: |
55 PseudoElement(Element*, PseudoId); | 56 PseudoElement(Element*, PseudoId); |
56 | 57 |
57 private: | 58 private: |
58 void didRecalcStyle(StyleRecalcChange) override; | 59 void didRecalcStyle(StyleRecalcChange) override; |
59 | 60 |
60 PseudoId m_pseudoId; | 61 PseudoId m_pseudoId; |
61 }; | 62 }; |
62 | 63 |
64 class PseudoElementData : public GarbageCollectedFinalized<PseudoElementData> { | |
Timothy Loh
2016/05/05 06:39:32
This should be in a separate file.
ramya.v
2016/05/05 08:57:09
Done.
| |
65 WTF_MAKE_NONCOPYABLE(PseudoElementData); | |
66 public: | |
67 static PseudoElementData* create(); | |
68 ~PseudoElementData(); | |
69 void setPseudoElement(PseudoId, PseudoElement*); | |
70 PseudoElement* pseudoElement(PseudoId) const; | |
71 bool hasPseudoElements() const; | |
72 void clearPseudoElements(); | |
73 DEFINE_INLINE_TRACE() | |
74 { | |
75 visitor->trace(m_generatedBefore); | |
76 visitor->trace(m_generatedAfter); | |
77 visitor->trace(m_generatedFirstLetter); | |
78 visitor->trace(m_backdrop); | |
79 } | |
80 private: | |
81 PseudoElementData(); | |
Timothy Loh
2016/05/05 06:39:33
You could write "PseudoElementData() = default;" i
ramya.v
2016/05/05 08:57:09
Done.
| |
82 Member<PseudoElement> m_generatedBefore; | |
83 Member<PseudoElement> m_generatedAfter; | |
84 Member<PseudoElement> m_generatedFirstLetter; | |
85 Member<PseudoElement> m_backdrop; | |
86 }; | |
87 | |
88 inline PseudoElementData* PseudoElementData::create() | |
89 { | |
90 return new PseudoElementData(); | |
91 } | |
92 | |
93 inline PseudoElementData::PseudoElementData() | |
94 { | |
95 } | |
96 | |
97 inline PseudoElementData::~PseudoElementData() | |
98 { | |
99 DCHECK(!m_generatedBefore); | |
100 DCHECK(!m_generatedAfter); | |
101 DCHECK(!m_generatedFirstLetter); | |
102 DCHECK(!m_backdrop); | |
103 } | |
104 | |
105 inline bool PseudoElementData::hasPseudoElements() const | |
106 { | |
107 return m_generatedBefore || m_generatedAfter || m_backdrop || m_generatedFir stLetter; | |
108 } | |
109 | |
110 inline void PseudoElementData::clearPseudoElements() | |
111 { | |
112 setPseudoElement(PseudoIdBefore, nullptr); | |
113 setPseudoElement(PseudoIdAfter, nullptr); | |
114 setPseudoElement(PseudoIdBackdrop, nullptr); | |
115 setPseudoElement(PseudoIdFirstLetter, nullptr); | |
116 } | |
117 | |
118 inline void PseudoElementData::setPseudoElement(PseudoId pseudoId, PseudoElement * element) | |
119 { | |
120 switch (pseudoId) { | |
121 case PseudoIdBefore: | |
122 if (m_generatedBefore) | |
123 m_generatedBefore->dispose(); | |
124 m_generatedBefore = element; | |
125 break; | |
126 case PseudoIdAfter: | |
127 if (m_generatedAfter) | |
128 m_generatedAfter->dispose(); | |
129 m_generatedAfter = element; | |
130 break; | |
131 case PseudoIdBackdrop: | |
132 if (m_backdrop) | |
133 m_backdrop->dispose(); | |
134 m_backdrop = element; | |
135 break; | |
136 case PseudoIdFirstLetter: | |
137 if (m_generatedFirstLetter) | |
138 m_generatedFirstLetter->dispose(); | |
139 m_generatedFirstLetter = element; | |
140 break; | |
141 default: | |
142 ASSERT_NOT_REACHED(); | |
143 } | |
144 } | |
145 | |
146 inline PseudoElement* PseudoElementData::pseudoElement(PseudoId pseudoId) const | |
147 { | |
148 switch (pseudoId) { | |
149 case PseudoIdBefore: | |
150 return m_generatedBefore.get(); | |
151 case PseudoIdAfter: | |
152 return m_generatedAfter.get(); | |
153 case PseudoIdBackdrop: | |
154 return m_backdrop.get(); | |
155 case PseudoIdFirstLetter: | |
156 return m_generatedFirstLetter.get(); | |
157 default: | |
158 return 0; | |
Timothy Loh
2016/05/05 06:39:33
nullptr
ramya.v
2016/05/05 08:57:09
Done.
| |
159 } | |
160 } | |
161 | |
63 const QualifiedName& pseudoElementTagName(); | 162 const QualifiedName& pseudoElementTagName(); |
64 | 163 |
65 inline bool pseudoElementLayoutObjectIsNeeded(const ComputedStyle* style) | 164 inline bool pseudoElementLayoutObjectIsNeeded(const ComputedStyle* style) |
66 { | 165 { |
67 if (!style) | 166 if (!style) |
68 return false; | 167 return false; |
69 if (style->display() == NONE) | 168 if (style->display() == NONE) |
70 return false; | 169 return false; |
71 if (style->styleType() == PseudoIdFirstLetter || style->styleType() == Pseud oIdBackdrop) | 170 if (style->styleType() == PseudoIdFirstLetter || style->styleType() == Pseud oIdBackdrop) |
72 return true; | 171 return true; |
73 return style->contentData(); | 172 return style->contentData(); |
74 } | 173 } |
75 | 174 |
76 DEFINE_ELEMENT_TYPE_CASTS(PseudoElement, isPseudoElement()); | 175 DEFINE_ELEMENT_TYPE_CASTS(PseudoElement, isPseudoElement()); |
77 | 176 |
78 } // namespace blink | 177 } // namespace blink |
79 | 178 |
80 #endif | 179 #endif |
OLD | NEW |