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

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

Issue 1481383002: [Experimental] CSSSerializer Proof-of-concept Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: snapshot: top_25 sites ser/dser now works Created 4 years, 11 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) 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 11 matching lines...) Expand all
22 #ifndef CSSSelector_h 22 #ifndef CSSSelector_h
23 #define CSSSelector_h 23 #define CSSSelector_h
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 CSSDeserializeStream;
32 class CSSSelectorList; 33 class CSSSelectorList;
34 class CSSSerializeStream;
33 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 representat ive list of selectors is 38 // CSS selector representation is somewhat complicated and subtle. A representat ive list of selectors is
37 // in CSSSelectorTest; run it in a debug build to see useful debugging output. 39 // in CSSSelectorTest; run it in a debug build to see useful debugging output.
38 // 40 //
39 // ** tagHistory() and relation(): 41 // ** tagHistory() and relation():
40 // 42 //
41 // Selectors are represented as a linked list of simple selectors (defined more or less according to 43 // Selectors are represented as a linked list of simple selectors (defined more or less according to
42 // http://www.w3.org/TR/css3-selectors/#simple-selectors-dfn). The tagHistory() method returns the next 44 // http://www.w3.org/TR/css3-selectors/#simple-selectors-dfn). The tagHistory() method returns the next
(...skipping 29 matching lines...) Expand all
72 // ** Attribute selectors. 74 // ** Attribute selectors.
73 // 75 //
74 // Attribute selectors return the attribute name in the attribute() method. The value() method returns the value matched against 76 // Attribute selectors return the attribute name in the attribute() method. The value() method returns the value matched against
75 // in case of selectors like [attr="value"]. 77 // in case of selectors like [attr="value"].
76 // 78 //
77 class CORE_EXPORT CSSSelector { 79 class CORE_EXPORT CSSSelector {
78 USING_FAST_MALLOC_WITH_TYPE_NAME(blink::CSSSelector); 80 USING_FAST_MALLOC_WITH_TYPE_NAME(blink::CSSSelector);
79 public: 81 public:
80 CSSSelector(); 82 CSSSelector();
81 CSSSelector(const CSSSelector&); 83 CSSSelector(const CSSSelector&);
84 CSSSelector(CSSDeserializeStream*);
82 explicit CSSSelector(const QualifiedName&, bool tagIsImplicit = false); 85 explicit CSSSelector(const QualifiedName&, bool tagIsImplicit = false);
83 86
84 ~CSSSelector(); 87 ~CSSSelector();
85 88
86 String selectorText(const String& rightSide = "") const; 89 String selectorText(const String& rightSide = "") const;
87 90
88 bool operator==(const CSSSelector&) const; 91 bool operator==(const CSSSelector&) const;
89 92
90 // http://www.w3.org/TR/css3-selectors/#specificity 93 // http://www.w3.org/TR/css3-selectors/#specificity
91 // We use 256 as the base of the specificity number system. 94 // We use 256 as the base of the specificity number system.
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 283
281 enum LinkMatchMask { MatchLink = 1, MatchVisited = 2, MatchAll = MatchLink | MatchVisited }; 284 enum LinkMatchMask { MatchLink = 1, MatchVisited = 2, MatchAll = MatchLink | MatchVisited };
282 unsigned computeLinkMatchType() const; 285 unsigned computeLinkMatchType() const;
283 286
284 bool isForPage() const { return m_isForPage; } 287 bool isForPage() const { return m_isForPage; }
285 void setForPage() { m_isForPage = true; } 288 void setForPage() { m_isForPage = true; }
286 289
287 bool relationIsAffectedByPseudoContent() const { return m_relationIsAffected ByPseudoContent; } 290 bool relationIsAffectedByPseudoContent() const { return m_relationIsAffected ByPseudoContent; }
288 void setRelationIsAffectedByPseudoContent() { m_relationIsAffectedByPseudoCo ntent = true; } 291 void setRelationIsAffectedByPseudoContent() { m_relationIsAffectedByPseudoCo ntent = true; }
289 292
293 void serialize(CSSSerializeStream*) const;
294
290 private: 295 private:
291 unsigned m_relation : 3; // enum Relation 296 union {
292 unsigned m_match : 4; // enum Match 297 struct {
293 unsigned m_pseudoType : 8; // enum PseudoType 298 unsigned m_relation : 3; // enum Relation
294 unsigned m_isLastInSelectorList : 1; 299 unsigned m_match : 4; // enum Match
295 unsigned m_isLastInTagHistory : 1; 300 unsigned m_pseudoType : 8; // enum PseudoType
296 unsigned m_hasRareData : 1; 301 unsigned m_isLastInSelectorList : 1;
297 unsigned m_isForPage : 1; 302 unsigned m_isLastInTagHistory : 1;
298 unsigned m_tagIsImplicit : 1; 303 unsigned m_hasRareData : 1;
299 unsigned m_relationIsAffectedByPseudoContent : 1; 304 unsigned m_isForPage : 1;
305 unsigned m_tagIsImplicit : 1;
306 unsigned m_relationIsAffectedByPseudoContent : 1;
307 };
308 unsigned m_bitfields;
309 };
300 310
301 void setPseudoType(PseudoType pseudoType) 311 void setPseudoType(PseudoType pseudoType)
302 { 312 {
303 m_pseudoType = pseudoType; 313 m_pseudoType = pseudoType;
304 ASSERT(static_cast<PseudoType>(m_pseudoType) == pseudoType); // using a bitfield. 314 ASSERT(static_cast<PseudoType>(m_pseudoType) == pseudoType); // using a bitfield.
305 } 315 }
306 316
307 unsigned specificityForOneSelector() const; 317 unsigned specificityForOneSelector() const;
308 unsigned specificityForPage() const; 318 unsigned specificityForPage() const;
309 319
310 // Hide. 320 // Hide.
311 CSSSelector& operator=(const CSSSelector&); 321 CSSSelector& operator=(const CSSSelector&);
312 322
313 struct RareData : public RefCounted<RareData> { 323 struct RareData : public RefCounted<RareData> {
314 static PassRefPtr<RareData> create(const AtomicString& value) { return a doptRef(new RareData(value)); } 324 static PassRefPtr<RareData> create(const AtomicString& value) { return a doptRef(new RareData(value)); }
325 static PassRefPtr<RareData> deserialize(CSSDeserializeStream*);
315 ~RareData(); 326 ~RareData();
316 327
317 bool matchNth(int count); 328 bool matchNth(int count);
318 int nthAValue() const { return m_bits.m_nth.m_a; } 329 int nthAValue() const { return m_bits.m_nth.m_a; }
319 int nthBValue() const { return m_bits.m_nth.m_b; } 330 int nthBValue() const { return m_bits.m_nth.m_b; }
331 void serialize(CSSSerializeStream*);
320 332
321 AtomicString m_matchingValue; 333 AtomicString m_matchingValue;
322 AtomicString m_serializingValue; 334 AtomicString m_serializingValue;
323 union { 335 union {
324 struct { 336 struct {
325 int m_a; // Used for :nth-* 337 int m_a; // Used for :nth-*
326 int m_b; // Used for :nth-* 338 int m_b; // Used for :nth-*
327 } m_nth; 339 } m_nth;
328 AttributeMatchType m_attributeMatchType; // used for attribute selec tor (with value) 340 AttributeMatchType m_attributeMatchType; // used for attribute selec tor (with value)
329 } m_bits; 341 } m_bits;
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 if (m_hasRareData) 501 if (m_hasRareData)
490 return m_data.m_rareData->m_serializingValue; 502 return m_data.m_rareData->m_serializingValue;
491 // AtomicString is really just a StringImpl* so the cast below is safe. 503 // AtomicString is really just a StringImpl* so the cast below is safe.
492 // FIXME: Perhaps call sites could be changed to accept StringImpl? 504 // FIXME: Perhaps call sites could be changed to accept StringImpl?
493 return *reinterpret_cast<const AtomicString*>(&m_data.m_value); 505 return *reinterpret_cast<const AtomicString*>(&m_data.m_value);
494 } 506 }
495 507
496 } // namespace blink 508 } // namespace blink
497 509
498 #endif // CSSSelector_h 510 #endif // CSSSelector_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSQuadValue.cpp ('k') | third_party/WebKit/Source/core/css/CSSSelector.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698