/src/libsass/src/extension.hpp
Line | Count | Source |
1 | | #ifndef SASS_EXTENSION_H |
2 | | #define SASS_EXTENSION_H |
3 | | |
4 | | // sass.hpp must go before all system headers to get the |
5 | | // __EXTENSIONS__ fix on Solaris. |
6 | | #include "sass.hpp" |
7 | | |
8 | | #include <unordered_map> |
9 | | #include <unordered_set> |
10 | | #include "ast_fwd_decl.hpp" |
11 | | #include "backtrace.hpp" |
12 | | |
13 | | namespace Sass { |
14 | | |
15 | | class Extension { |
16 | | |
17 | | public: |
18 | | |
19 | | // The selector in which the `@extend` appeared. |
20 | | ComplexSelectorObj extender; |
21 | | |
22 | | // The selector that's being extended. |
23 | | // `null` for one-off extensions. |
24 | | SimpleSelectorObj target; |
25 | | |
26 | | // The minimum specificity required for any |
27 | | // selector generated from this extender. |
28 | | size_t specificity; |
29 | | |
30 | | // Whether this extension is optional. |
31 | | bool isOptional; |
32 | | |
33 | | // Whether this is a one-off extender representing a selector that was |
34 | | // originally in the document, rather than one defined with `@extend`. |
35 | | bool isOriginal; |
36 | | |
37 | | bool isSatisfied; |
38 | | |
39 | | // The media query context to which this extend is restricted, |
40 | | // or `null` if it can apply within any context. |
41 | | CssMediaRuleObj mediaContext; |
42 | | |
43 | | // Creates a one-off extension that's not intended to be modified over time. |
44 | | // If [specificity] isn't passed, it defaults to `extender.maxSpecificity`. |
45 | | Extension(ComplexSelectorObj extender) : |
46 | 0 | extender(extender), |
47 | 0 | target({}), |
48 | 0 | specificity(0), |
49 | 0 | isOptional(true), |
50 | 0 | isOriginal(false), |
51 | 0 | isSatisfied(false), |
52 | 0 | mediaContext({}) { |
53 | |
|
54 | 0 | } |
55 | | |
56 | | // Copy constructor |
57 | | Extension(const Extension& extension) : |
58 | 0 | extender(extension.extender), |
59 | 0 | target(extension.target), |
60 | 0 | specificity(extension.specificity), |
61 | 0 | isOptional(extension.isOptional), |
62 | 0 | isOriginal(extension.isOriginal), |
63 | 0 | isSatisfied(extension.isSatisfied), |
64 | 0 | mediaContext(extension.mediaContext) { |
65 | |
|
66 | 0 | } |
67 | | |
68 | | // Default constructor |
69 | | Extension() : |
70 | 4 | extender({}), |
71 | 4 | target({}), |
72 | 4 | specificity(0), |
73 | 4 | isOptional(false), |
74 | 4 | isOriginal(false), |
75 | 4 | isSatisfied(false), |
76 | 4 | mediaContext({}) { |
77 | 4 | } |
78 | | |
79 | | // Asserts that the [mediaContext] for a selector is |
80 | | // compatible with the query context for this extender. |
81 | | void assertCompatibleMediaContext(CssMediaRuleObj mediaContext, Backtraces& traces) const; |
82 | | |
83 | | Extension withExtender(const ComplexSelectorObj& newExtender) const; |
84 | | |
85 | | }; |
86 | | |
87 | | } |
88 | | |
89 | | #endif |