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

Side by Side Diff: Source/core/css/CSSSelector.h

Issue 15657003: Make a '::distributed' pseudo element the first-ever client who can accept a relative selector. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Introduce m_relationIsForShadowDistributed Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/CSSParserValues.h ('k') | Source/core/css/CSSSelector.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * 1999 Waldo Bastian (bastian@kde.org) 3 * 1999 Waldo Bastian (bastian@kde.org)
4 * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 End, // css3: E[foo$="bar"] 72 End, // css3: E[foo$="bar"]
73 PagePseudoClass 73 PagePseudoClass
74 }; 74 };
75 75
76 enum Relation { 76 enum Relation {
77 Descendant = 0, 77 Descendant = 0,
78 Child, 78 Child,
79 DirectAdjacent, 79 DirectAdjacent,
80 IndirectAdjacent, 80 IndirectAdjacent,
81 SubSelector, 81 SubSelector,
82 ShadowPseudo, 82 ShadowPseudo
83 ShadowDistributed
84 }; 83 };
85 84
86 enum PseudoType { 85 enum PseudoType {
87 PseudoNotParsed = 0, 86 PseudoNotParsed = 0,
88 PseudoUnknown, 87 PseudoUnknown,
89 PseudoEmpty, 88 PseudoEmpty,
90 PseudoFirstChild, 89 PseudoFirstChild,
91 PseudoFirstOfType, 90 PseudoFirstOfType,
92 PseudoLastChild, 91 PseudoLastChild,
93 PseudoLastOfType, 92 PseudoLastOfType,
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 212
214 bool parseNth() const; 213 bool parseNth() const;
215 bool matchNth(int count) const; 214 bool matchNth(int count) const;
216 215
217 bool matchesPseudoElement() const; 216 bool matchesPseudoElement() const;
218 bool isUnknownPseudoElement() const; 217 bool isUnknownPseudoElement() const;
219 bool isCustomPseudoElement() const; 218 bool isCustomPseudoElement() const;
220 bool isSiblingSelector() const; 219 bool isSiblingSelector() const;
221 bool isAttributeSelector() const; 220 bool isAttributeSelector() const;
222 bool isDistributedPseudoElement() const; 221 bool isDistributedPseudoElement() const;
223 bool isShadowDistributed() const;
224 222
225 Relation relation() const { return static_cast<Relation>(m_relation); } 223 Relation relation() const { return static_cast<Relation>(m_relation); }
226 224
227 bool isLastInSelectorList() const { return m_isLastInSelectorList; } 225 bool isLastInSelectorList() const { return m_isLastInSelectorList; }
228 void setLastInSelectorList() { m_isLastInSelectorList = true; } 226 void setLastInSelectorList() { m_isLastInSelectorList = true; }
229 bool isLastInTagHistory() const { return m_isLastInTagHistory; } 227 bool isLastInTagHistory() const { return m_isLastInTagHistory; }
230 void setNotLastInTagHistory() { m_isLastInTagHistory = false; } 228 void setNotLastInTagHistory() { m_isLastInTagHistory = false; }
231 229
232 bool isSimple() const; 230 bool isSimple() const;
233 231
234 bool isForPage() const { return m_isForPage; } 232 bool isForPage() const { return m_isForPage; }
235 void setForPage() { m_isForPage = true; } 233 void setForPage() { m_isForPage = true; }
236 234
235 bool relationIsForShadowDistributed() const { return m_relationIsForShad owDistributed; }
236 void setRelationIsForShadowDistributed() { m_relationIsForShadowDistribu ted = true; }
237
237 unsigned m_relation : 3; // enum Relation 238 unsigned m_relation : 3; // enum Relation
238 mutable unsigned m_match : 4; // enum Match 239 mutable unsigned m_match : 4; // enum Match
239 mutable unsigned m_pseudoType : 8; // PseudoType 240 mutable unsigned m_pseudoType : 8; // PseudoType
240 241
241 private: 242 private:
242 mutable unsigned m_parsedNth : 1; // Used for :nth-* 243 mutable unsigned m_parsedNth : 1; // Used for :nth-*
243 unsigned m_isLastInSelectorList : 1; 244 unsigned m_isLastInSelectorList : 1;
244 unsigned m_isLastInTagHistory : 1; 245 unsigned m_isLastInTagHistory : 1;
245 unsigned m_hasRareData : 1; 246 unsigned m_hasRareData : 1;
246 unsigned m_isForPage : 1; 247 unsigned m_isForPage : 1;
247 unsigned m_tagIsForNamespaceRule : 1; 248 unsigned m_tagIsForNamespaceRule : 1;
249 unsigned m_relationIsForShadowDistributed : 1;
248 250
249 unsigned specificityForOneSelector() const; 251 unsigned specificityForOneSelector() const;
250 unsigned specificityForPage() const; 252 unsigned specificityForPage() const;
251 void extractPseudoType() const; 253 void extractPseudoType() const;
252 254
253 // Hide. 255 // Hide.
254 CSSSelector& operator=(const CSSSelector&); 256 CSSSelector& operator=(const CSSSelector&);
255 257
256 struct RareData : public RefCounted<RareData> { 258 struct RareData : public RefCounted<RareData> {
257 static PassRefPtr<RareData> create(PassRefPtr<AtomicStringImpl> valu e) { return adoptRef(new RareData(value)); } 259 static PassRefPtr<RareData> create(PassRefPtr<AtomicStringImpl> valu e) { return adoptRef(new RareData(value)); }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 || m_match == CSSSelector::Contain 333 || m_match == CSSSelector::Contain
332 || m_match == CSSSelector::Begin 334 || m_match == CSSSelector::Begin
333 || m_match == CSSSelector::End; 335 || m_match == CSSSelector::End;
334 } 336 }
335 337
336 inline bool CSSSelector::isDistributedPseudoElement() const 338 inline bool CSSSelector::isDistributedPseudoElement() const
337 { 339 {
338 return m_match == PseudoElement && pseudoType() == PseudoDistributed; 340 return m_match == PseudoElement && pseudoType() == PseudoDistributed;
339 } 341 }
340 342
341 inline bool CSSSelector::isShadowDistributed() const
342 {
343 return m_relation == CSSSelector::ShadowDistributed;
344 }
345
346 inline void CSSSelector::setValue(const AtomicString& value) 343 inline void CSSSelector::setValue(const AtomicString& value)
347 { 344 {
348 ASSERT(m_match != Tag); 345 ASSERT(m_match != Tag);
349 ASSERT(m_pseudoType == PseudoNotParsed); 346 ASSERT(m_pseudoType == PseudoNotParsed);
350 // Need to do ref counting manually for the union. 347 // Need to do ref counting manually for the union.
351 if (m_hasRareData) { 348 if (m_hasRareData) {
352 if (m_data.m_rareData->m_value) 349 if (m_data.m_rareData->m_value)
353 m_data.m_rareData->m_value->deref(); 350 m_data.m_rareData->m_value->deref();
354 m_data.m_rareData->m_value = value.impl(); 351 m_data.m_rareData->m_value = value.impl();
355 m_data.m_rareData->m_value->ref(); 352 m_data.m_rareData->m_value->ref();
356 return; 353 return;
357 } 354 }
358 if (m_data.m_value) 355 if (m_data.m_value)
359 m_data.m_value->deref(); 356 m_data.m_value->deref();
360 m_data.m_value = value.impl(); 357 m_data.m_value = value.impl();
361 m_data.m_value->ref(); 358 m_data.m_value->ref();
362 } 359 }
363 360
364 inline CSSSelector::CSSSelector() 361 inline CSSSelector::CSSSelector()
365 : m_relation(Descendant) 362 : m_relation(Descendant)
366 , m_match(Unknown) 363 , m_match(Unknown)
367 , m_pseudoType(PseudoNotParsed) 364 , m_pseudoType(PseudoNotParsed)
368 , m_parsedNth(false) 365 , m_parsedNth(false)
369 , m_isLastInSelectorList(false) 366 , m_isLastInSelectorList(false)
370 , m_isLastInTagHistory(true) 367 , m_isLastInTagHistory(true)
371 , m_hasRareData(false) 368 , m_hasRareData(false)
372 , m_isForPage(false) 369 , m_isForPage(false)
373 , m_tagIsForNamespaceRule(false) 370 , m_tagIsForNamespaceRule(false)
371 , m_relationIsForShadowDistributed(false)
374 { 372 {
375 } 373 }
376 374
377 inline CSSSelector::CSSSelector(const QualifiedName& tagQName, bool tagIsForName spaceRule) 375 inline CSSSelector::CSSSelector(const QualifiedName& tagQName, bool tagIsForName spaceRule)
378 : m_relation(Descendant) 376 : m_relation(Descendant)
379 , m_match(Tag) 377 , m_match(Tag)
380 , m_pseudoType(PseudoNotParsed) 378 , m_pseudoType(PseudoNotParsed)
381 , m_parsedNth(false) 379 , m_parsedNth(false)
382 , m_isLastInSelectorList(false) 380 , m_isLastInSelectorList(false)
383 , m_isLastInTagHistory(true) 381 , m_isLastInTagHistory(true)
384 , m_hasRareData(false) 382 , m_hasRareData(false)
385 , m_isForPage(false) 383 , m_isForPage(false)
386 , m_tagIsForNamespaceRule(tagIsForNamespaceRule) 384 , m_tagIsForNamespaceRule(tagIsForNamespaceRule)
385 , m_relationIsForShadowDistributed(false)
387 { 386 {
388 m_data.m_tagQName = tagQName.impl(); 387 m_data.m_tagQName = tagQName.impl();
389 m_data.m_tagQName->ref(); 388 m_data.m_tagQName->ref();
390 } 389 }
391 390
392 inline CSSSelector::CSSSelector(const CSSSelector& o) 391 inline CSSSelector::CSSSelector(const CSSSelector& o)
393 : m_relation(o.m_relation) 392 : m_relation(o.m_relation)
394 , m_match(o.m_match) 393 , m_match(o.m_match)
395 , m_pseudoType(o.m_pseudoType) 394 , m_pseudoType(o.m_pseudoType)
396 , m_parsedNth(o.m_parsedNth) 395 , m_parsedNth(o.m_parsedNth)
397 , m_isLastInSelectorList(o.m_isLastInSelectorList) 396 , m_isLastInSelectorList(o.m_isLastInSelectorList)
398 , m_isLastInTagHistory(o.m_isLastInTagHistory) 397 , m_isLastInTagHistory(o.m_isLastInTagHistory)
399 , m_hasRareData(o.m_hasRareData) 398 , m_hasRareData(o.m_hasRareData)
400 , m_isForPage(o.m_isForPage) 399 , m_isForPage(o.m_isForPage)
401 , m_tagIsForNamespaceRule(o.m_tagIsForNamespaceRule) 400 , m_tagIsForNamespaceRule(o.m_tagIsForNamespaceRule)
401 , m_relationIsForShadowDistributed(o.m_relationIsForShadowDistributed)
402 { 402 {
403 if (o.m_match == Tag) { 403 if (o.m_match == Tag) {
404 m_data.m_tagQName = o.m_data.m_tagQName; 404 m_data.m_tagQName = o.m_data.m_tagQName;
405 m_data.m_tagQName->ref(); 405 m_data.m_tagQName->ref();
406 } else if (o.m_hasRareData) { 406 } else if (o.m_hasRareData) {
407 m_data.m_rareData = o.m_data.m_rareData; 407 m_data.m_rareData = o.m_data.m_rareData;
408 m_data.m_rareData->ref(); 408 m_data.m_rareData->ref();
409 } else if (o.m_data.m_value) { 409 } else if (o.m_data.m_value) {
410 m_data.m_value = o.m_data.m_value; 410 m_data.m_value = o.m_data.m_value;
411 m_data.m_value->ref(); 411 m_data.m_value->ref();
(...skipping 21 matching lines...) Expand all
433 ASSERT(m_match != Tag); 433 ASSERT(m_match != Tag);
434 // AtomicString is really just an AtomicStringImpl* so the cast below is saf e. 434 // AtomicString is really just an AtomicStringImpl* so the cast below is saf e.
435 // FIXME: Perhaps call sites could be changed to accept AtomicStringImpl? 435 // FIXME: Perhaps call sites could be changed to accept AtomicStringImpl?
436 return *reinterpret_cast<const AtomicString*>(m_hasRareData ? &m_data.m_rare Data->m_value : &m_data.m_value); 436 return *reinterpret_cast<const AtomicString*>(m_hasRareData ? &m_data.m_rare Data->m_value : &m_data.m_value);
437 } 437 }
438 438
439 439
440 } // namespace WebCore 440 } // namespace WebCore
441 441
442 #endif // CSSSelector_h 442 #endif // CSSSelector_h
OLDNEW
« no previous file with comments | « Source/core/css/CSSParserValues.h ('k') | Source/core/css/CSSSelector.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698