2
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3
* Copyright (C) 2003-2019 Apple Inc. All rights reserved.
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Library General Public
7
* License as published by the Free Software Foundation; either
8
* version 2 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Library General Public License for more details.
15
* You should have received a copy of the GNU Library General Public License
16
* along with this library; see the file COPYING.LIB. If not, write to
17
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
* Boston, MA 02110-1301, USA.
24
#include "SelectorFilter.h"
25
#include "StyleRule.h"
30
enum PropertyWhitelistType {
31
PropertyWhitelistNone = 0,
32
PropertyWhitelistMarker,
33
#if ENABLE(VIDEO_TRACK)
38
enum class MatchBasedOnRuleHash : unsigned {
48
static const unsigned maximumSelectorComponentCount = 8192;
50
RuleData(const StyleRule&, unsigned selectorIndex, unsigned selectorListIndex, unsigned position);
52
unsigned position() const { return m_position; }
54
const StyleRule& styleRule() const { return *m_styleRule; }
56
const CSSSelector* selector() const { return m_styleRule->selectorList().selectorAt(m_selectorIndex); }
57
#if ENABLE(CSS_SELECTOR_JIT)
58
CompiledSelector& compiledSelector() const { return m_styleRule->compiledSelectorForListIndex(m_selectorListIndex); }
61
unsigned selectorIndex() const { return m_selectorIndex; }
62
unsigned selectorListIndex() const { return m_selectorListIndex; }
64
bool canMatchPseudoElement() const { return m_canMatchPseudoElement; }
65
MatchBasedOnRuleHash matchBasedOnRuleHash() const { return static_cast<MatchBasedOnRuleHash>(m_matchBasedOnRuleHash); }
66
bool containsUncommonAttributeSelector() const { return m_containsUncommonAttributeSelector; }
67
unsigned linkMatchType() const { return m_linkMatchType; }
68
PropertyWhitelistType propertyWhitelistType() const { return static_cast<PropertyWhitelistType>(m_propertyWhitelistType); }
69
bool isEnabled() const { return m_isEnabled; }
70
void setEnabled(bool value) { m_isEnabled = value; }
72
const SelectorFilter::Hashes& descendantSelectorIdentifierHashes() const { return m_descendantSelectorIdentifierHashes; }
74
void disableSelectorFiltering() { m_descendantSelectorIdentifierHashes[0] = 0; }
77
RefPtr<const StyleRule> m_styleRule;
78
// Keep in sync with RuleFeature's selectorIndex and selectorListIndex size.
79
unsigned m_selectorIndex : 16;
80
unsigned m_selectorListIndex : 16;
81
// If we have more rules than 2^bitcount here we'll get confused about rule order.
82
unsigned m_position : 22;
83
unsigned m_matchBasedOnRuleHash : 3;
84
unsigned m_canMatchPseudoElement : 1;
85
unsigned m_containsUncommonAttributeSelector : 1;
86
unsigned m_linkMatchType : 2; // SelectorChecker::LinkMatchMask
87
unsigned m_propertyWhitelistType : 2;
88
unsigned m_isEnabled : 1;
89
SelectorFilter::Hashes m_descendantSelectorIdentifierHashes;
93
} // namespace WebCore
97
// RuleData is simple enough that initializing to 0 and moving with memcpy will totally work.
98
template<> struct VectorTraits<WebCore::Style::RuleData> : SimpleClassVectorTraits { };