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

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

Issue 1099963003: Support type selector for camel-cased SVG elements in HTML. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix performance regression. tagMatches() became too big to be inlined on Linux. Created 5 years, 8 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
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 13 matching lines...) Expand all
24 24
25 #include "core/CoreExport.h" 25 #include "core/CoreExport.h"
26 #include "core/dom/QualifiedName.h" 26 #include "core/dom/QualifiedName.h"
27 #include "core/style/ComputedStyleConstants.h" 27 #include "core/style/ComputedStyleConstants.h"
28 #include "wtf/OwnPtr.h" 28 #include "wtf/OwnPtr.h"
29 #include "wtf/PassOwnPtr.h" 29 #include "wtf/PassOwnPtr.h"
30 30
31 namespace blink { 31 namespace blink {
32 class CSSSelectorList; 32 class CSSSelectorList;
33 33
34 enum TagSelectorCase { TagLowerCase, TagCamelCase };
35
34 // This class represents a selector for a StyleRule. 36 // This class represents a selector for a StyleRule.
35 37
36 // CSS selector representation is somewhat complicated and subtle. A represe ntative list of selectors is 38 // CSS selector representation is somewhat complicated and subtle. A represe ntative list of selectors is
37 // in CSSSelectorTest; run it in a debug build to see useful debugging outpu t. 39 // in CSSSelectorTest; run it in a debug build to see useful debugging outpu t.
38 // 40 //
39 // ** tagHistory() and relation(): 41 // ** tagHistory() and relation():
40 // 42 //
41 // Selectors are represented as a linked list of simple selectors (defined m ore or less according to 43 // Selectors are represented as a linked list of simple selectors (defined m ore or less according to
42 // http://www.w3.org/TR/css3-selectors/#simple-selectors-dfn). The tagHistor y() method returns the next 44 // http://www.w3.org/TR/css3-selectors/#simple-selectors-dfn). The tagHistor y() method returns the next
43 // simple selector in the list. The relation() method returns the relationsh ip of the current simple selector to 45 // simple selector in the list. The relation() method returns the relationsh ip of the current simple selector to
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // ** isCustomPseudoElement(): 79 // ** isCustomPseudoElement():
78 // 80 //
79 // It appears this is used only for pseudo elements that appear in user-agen t shadow DOM. They are not exposed to author-created 81 // It appears this is used only for pseudo elements that appear in user-agen t shadow DOM. They are not exposed to author-created
80 // shadow DOM. 82 // shadow DOM.
81 83
82 class CORE_EXPORT CSSSelector { 84 class CORE_EXPORT CSSSelector {
83 WTF_MAKE_FAST_ALLOCATED(CSSSelector); 85 WTF_MAKE_FAST_ALLOCATED(CSSSelector);
84 public: 86 public:
85 CSSSelector(); 87 CSSSelector();
86 CSSSelector(const CSSSelector&); 88 CSSSelector(const CSSSelector&);
87 explicit CSSSelector(const QualifiedName&, bool tagIsImplicit = false); 89 explicit CSSSelector(const QualifiedName&, bool tagIsImplicit = false, T agSelectorCase = TagLowerCase);
88 90
89 ~CSSSelector(); 91 ~CSSSelector();
90 92
91 /** 93 /**
92 * Re-create selector text from selector's data 94 * Re-create selector text from selector's data
93 */ 95 */
94 String selectorText(const String& = "") const; 96 String selectorText(const String& = "") const;
95 97
96 // checks if the 2 selectors (including sub selectors) agree. 98 // checks if the 2 selectors (including sub selectors) agree.
97 bool operator==(const CSSSelector&) const; 99 bool operator==(const CSSSelector&) const;
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 void setNotLastInTagHistory() { m_isLastInTagHistory = false; } 315 void setNotLastInTagHistory() { m_isLastInTagHistory = false; }
314 316
315 // http://dev.w3.org/csswg/selectors4/#compound 317 // http://dev.w3.org/csswg/selectors4/#compound
316 bool isCompound() const; 318 bool isCompound() const;
317 319
318 bool isForPage() const { return m_isForPage; } 320 bool isForPage() const { return m_isForPage; }
319 void setForPage() { m_isForPage = true; } 321 void setForPage() { m_isForPage = true; }
320 322
321 bool relationIsAffectedByPseudoContent() const { return m_relationIsAffe ctedByPseudoContent; } 323 bool relationIsAffectedByPseudoContent() const { return m_relationIsAffe ctedByPseudoContent; }
322 void setRelationIsAffectedByPseudoContent() { m_relationIsAffectedByPseu doContent = true; } 324 void setRelationIsAffectedByPseudoContent() { m_relationIsAffectedByPseu doContent = true; }
325 bool tagIsCamelCase() const { return m_tagSelectorCase == TagCamelCase; }
326 void setTagIsCamelCase() { m_tagSelectorCase = TagCamelCase; }
323 327
324 private: 328 private:
325 unsigned m_relation : 3; // enum Relation 329 unsigned m_relation : 3; // enum Relation
326 mutable unsigned m_match : 4; // enum Match 330 mutable unsigned m_match : 4; // enum Match
327 mutable unsigned m_pseudoType : 8; // PseudoType 331 mutable unsigned m_pseudoType : 8; // PseudoType
328 mutable unsigned m_parsedNth : 1; // Used for :nth-* 332 mutable unsigned m_parsedNth : 1; // Used for :nth-*
329 unsigned m_isLastInSelectorList : 1; 333 unsigned m_isLastInSelectorList : 1;
330 unsigned m_isLastInTagHistory : 1; 334 unsigned m_isLastInTagHistory : 1;
331 unsigned m_hasRareData : 1; 335 unsigned m_hasRareData : 1;
332 unsigned m_isForPage : 1; 336 unsigned m_isForPage : 1;
333 unsigned m_tagIsImplicit : 1; 337 unsigned m_tagIsImplicit : 1;
338 unsigned m_tagSelectorCase : 1; // enum TagSelectorCase
334 unsigned m_relationIsAffectedByPseudoContent : 1; 339 unsigned m_relationIsAffectedByPseudoContent : 1;
335 340
336 unsigned specificityForOneSelector() const; 341 unsigned specificityForOneSelector() const;
337 unsigned specificityForPage() const; 342 unsigned specificityForPage() const;
338 void extractPseudoType() const; 343 void extractPseudoType() const;
339 344
340 // Hide. 345 // Hide.
341 CSSSelector& operator=(const CSSSelector&); 346 CSSSelector& operator=(const CSSSelector&);
342 347
343 struct RareData : public RefCounted<RareData> { 348 struct RareData : public RefCounted<RareData> {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 inline CSSSelector::CSSSelector() 474 inline CSSSelector::CSSSelector()
470 : m_relation(SubSelector) 475 : m_relation(SubSelector)
471 , m_match(Unknown) 476 , m_match(Unknown)
472 , m_pseudoType(PseudoNotParsed) 477 , m_pseudoType(PseudoNotParsed)
473 , m_parsedNth(false) 478 , m_parsedNth(false)
474 , m_isLastInSelectorList(false) 479 , m_isLastInSelectorList(false)
475 , m_isLastInTagHistory(true) 480 , m_isLastInTagHistory(true)
476 , m_hasRareData(false) 481 , m_hasRareData(false)
477 , m_isForPage(false) 482 , m_isForPage(false)
478 , m_tagIsImplicit(false) 483 , m_tagIsImplicit(false)
484 , m_tagSelectorCase(TagLowerCase)
479 , m_relationIsAffectedByPseudoContent(false) 485 , m_relationIsAffectedByPseudoContent(false)
480 { 486 {
481 } 487 }
482 488
483 inline CSSSelector::CSSSelector(const QualifiedName& tagQName, bool tagIsImplici t) 489 inline CSSSelector::CSSSelector(const QualifiedName& tagQName, bool tagIsImplici t, TagSelectorCase tagSelectorCase)
484 : m_relation(SubSelector) 490 : m_relation(SubSelector)
485 , m_match(Tag) 491 , m_match(Tag)
486 , m_pseudoType(PseudoNotParsed) 492 , m_pseudoType(PseudoNotParsed)
487 , m_parsedNth(false) 493 , m_parsedNth(false)
488 , m_isLastInSelectorList(false) 494 , m_isLastInSelectorList(false)
489 , m_isLastInTagHistory(true) 495 , m_isLastInTagHistory(true)
490 , m_hasRareData(false) 496 , m_hasRareData(false)
491 , m_isForPage(false) 497 , m_isForPage(false)
492 , m_tagIsImplicit(tagIsImplicit) 498 , m_tagIsImplicit(tagIsImplicit)
499 , m_tagSelectorCase(tagSelectorCase)
493 , m_relationIsAffectedByPseudoContent(false) 500 , m_relationIsAffectedByPseudoContent(false)
494 { 501 {
495 m_data.m_tagQName = tagQName.impl(); 502 m_data.m_tagQName = tagQName.impl();
496 m_data.m_tagQName->ref(); 503 m_data.m_tagQName->ref();
497 } 504 }
498 505
499 inline CSSSelector::CSSSelector(const CSSSelector& o) 506 inline CSSSelector::CSSSelector(const CSSSelector& o)
500 : m_relation(o.m_relation) 507 : m_relation(o.m_relation)
501 , m_match(o.m_match) 508 , m_match(o.m_match)
502 , m_pseudoType(o.m_pseudoType) 509 , m_pseudoType(o.m_pseudoType)
503 , m_parsedNth(o.m_parsedNth) 510 , m_parsedNth(o.m_parsedNth)
504 , m_isLastInSelectorList(o.m_isLastInSelectorList) 511 , m_isLastInSelectorList(o.m_isLastInSelectorList)
505 , m_isLastInTagHistory(o.m_isLastInTagHistory) 512 , m_isLastInTagHistory(o.m_isLastInTagHistory)
506 , m_hasRareData(o.m_hasRareData) 513 , m_hasRareData(o.m_hasRareData)
507 , m_isForPage(o.m_isForPage) 514 , m_isForPage(o.m_isForPage)
508 , m_tagIsImplicit(o.m_tagIsImplicit) 515 , m_tagIsImplicit(o.m_tagIsImplicit)
516 , m_tagSelectorCase(o.m_tagSelectorCase)
509 , m_relationIsAffectedByPseudoContent(o.m_relationIsAffectedByPseudoContent) 517 , m_relationIsAffectedByPseudoContent(o.m_relationIsAffectedByPseudoContent)
510 { 518 {
511 if (o.m_match == Tag) { 519 if (o.m_match == Tag) {
512 m_data.m_tagQName = o.m_data.m_tagQName; 520 m_data.m_tagQName = o.m_data.m_tagQName;
513 m_data.m_tagQName->ref(); 521 m_data.m_tagQName->ref();
514 } else if (o.m_hasRareData) { 522 } else if (o.m_hasRareData) {
515 m_data.m_rareData = o.m_data.m_rareData; 523 m_data.m_rareData = o.m_data.m_rareData;
516 m_data.m_rareData->ref(); 524 m_data.m_rareData->ref();
517 } else if (o.m_data.m_value) { 525 } else if (o.m_data.m_value) {
518 m_data.m_value = o.m_data.m_value; 526 m_data.m_value = o.m_data.m_value;
(...skipping 23 matching lines...) Expand all
542 if (m_hasRareData) 550 if (m_hasRareData)
543 return m_data.m_rareData->m_value; 551 return m_data.m_rareData->m_value;
544 // AtomicString is really just a StringImpl* so the cast below is safe. 552 // AtomicString is really just a StringImpl* so the cast below is safe.
545 // FIXME: Perhaps call sites could be changed to accept StringImpl? 553 // FIXME: Perhaps call sites could be changed to accept StringImpl?
546 return *reinterpret_cast<const AtomicString*>(&m_data.m_value); 554 return *reinterpret_cast<const AtomicString*>(&m_data.m_value);
547 } 555 }
548 556
549 } // namespace blink 557 } // namespace blink
550 558
551 #endif // CSSSelector_h 559 #endif // CSSSelector_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698