sassc 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +5 -0
- data/ext/libsass/VERSION +1 -1
- data/ext/libsass/include/sass/context.h +3 -0
- data/ext/libsass/src/MurmurHash2.hpp +91 -0
- data/ext/libsass/src/ast.cpp +117 -117
- data/ext/libsass/src/ast.hpp +160 -162
- data/ext/libsass/src/ast_def_macros.hpp +10 -10
- data/ext/libsass/src/ast_fwd_decl.cpp +2 -2
- data/ext/libsass/src/ast_fwd_decl.hpp +61 -52
- data/ext/libsass/src/ast_helpers.hpp +5 -5
- data/ext/libsass/src/ast_sel_cmp.cpp +18 -18
- data/ext/libsass/src/ast_sel_super.cpp +52 -52
- data/ext/libsass/src/ast_sel_unify.cpp +16 -16
- data/ext/libsass/src/ast_sel_weave.cpp +62 -62
- data/ext/libsass/src/ast_selectors.cpp +87 -77
- data/ext/libsass/src/ast_selectors.hpp +72 -62
- data/ext/libsass/src/ast_supports.cpp +35 -35
- data/ext/libsass/src/ast_supports.hpp +29 -29
- data/ext/libsass/src/ast_values.cpp +58 -58
- data/ext/libsass/src/ast_values.hpp +75 -75
- data/ext/libsass/src/backtrace.cpp +9 -9
- data/ext/libsass/src/backtrace.hpp +5 -5
- data/ext/libsass/src/base64vlq.cpp +2 -2
- data/ext/libsass/src/base64vlq.hpp +1 -1
- data/ext/libsass/src/bind.cpp +17 -17
- data/ext/libsass/src/bind.hpp +1 -1
- data/ext/libsass/src/c2ast.cpp +3 -3
- data/ext/libsass/src/c2ast.hpp +1 -1
- data/ext/libsass/src/check_nesting.cpp +36 -36
- data/ext/libsass/src/check_nesting.hpp +2 -2
- data/ext/libsass/src/color_maps.cpp +5 -5
- data/ext/libsass/src/color_maps.hpp +1 -1
- data/ext/libsass/src/context.cpp +63 -60
- data/ext/libsass/src/context.hpp +33 -33
- data/ext/libsass/src/cssize.cpp +30 -29
- data/ext/libsass/src/cssize.hpp +13 -13
- data/ext/libsass/src/dart_helpers.hpp +5 -5
- data/ext/libsass/src/debugger.hpp +127 -128
- data/ext/libsass/src/emitter.cpp +12 -12
- data/ext/libsass/src/emitter.hpp +10 -10
- data/ext/libsass/src/environment.cpp +27 -27
- data/ext/libsass/src/environment.hpp +24 -24
- data/ext/libsass/src/error_handling.cpp +42 -42
- data/ext/libsass/src/error_handling.hpp +38 -50
- data/ext/libsass/src/eval.cpp +138 -132
- data/ext/libsass/src/eval.hpp +17 -17
- data/ext/libsass/src/eval_selectors.cpp +3 -3
- data/ext/libsass/src/expand.cpp +70 -64
- data/ext/libsass/src/expand.hpp +12 -12
- data/ext/libsass/src/extender.cpp +55 -53
- data/ext/libsass/src/extender.hpp +14 -14
- data/ext/libsass/src/file.cpp +66 -58
- data/ext/libsass/src/file.hpp +23 -25
- data/ext/libsass/src/fn_colors.cpp +9 -9
- data/ext/libsass/src/fn_lists.cpp +18 -18
- data/ext/libsass/src/fn_maps.cpp +3 -3
- data/ext/libsass/src/fn_miscs.cpp +15 -15
- data/ext/libsass/src/fn_numbers.cpp +7 -7
- data/ext/libsass/src/fn_selectors.cpp +8 -8
- data/ext/libsass/src/fn_strings.cpp +34 -22
- data/ext/libsass/src/fn_utils.cpp +29 -26
- data/ext/libsass/src/fn_utils.hpp +10 -10
- data/ext/libsass/src/inspect.cpp +35 -34
- data/ext/libsass/src/inspect.hpp +21 -21
- data/ext/libsass/src/lexer.cpp +3 -1
- data/ext/libsass/src/listize.cpp +2 -2
- data/ext/libsass/src/mapping.hpp +1 -0
- data/ext/libsass/src/memory.hpp +12 -0
- data/ext/libsass/src/memory/allocator.cpp +48 -0
- data/ext/libsass/src/memory/allocator.hpp +138 -0
- data/ext/libsass/src/memory/config.hpp +20 -0
- data/ext/libsass/src/memory/memory_pool.hpp +186 -0
- data/ext/libsass/src/memory/{SharedPtr.cpp → shared_ptr.cpp} +2 -2
- data/ext/libsass/src/memory/{SharedPtr.hpp → shared_ptr.hpp} +18 -6
- data/ext/libsass/src/operation.hpp +44 -44
- data/ext/libsass/src/operators.cpp +18 -18
- data/ext/libsass/src/operators.hpp +11 -11
- data/ext/libsass/src/ordered_map.hpp +18 -18
- data/ext/libsass/src/output.cpp +16 -16
- data/ext/libsass/src/output.hpp +5 -5
- data/ext/libsass/src/parser.cpp +327 -345
- data/ext/libsass/src/parser.hpp +77 -87
- data/ext/libsass/src/parser_selectors.cpp +6 -6
- data/ext/libsass/src/permutate.hpp +39 -15
- data/ext/libsass/src/plugins.cpp +7 -7
- data/ext/libsass/src/plugins.hpp +8 -8
- data/ext/libsass/src/position.cpp +7 -26
- data/ext/libsass/src/position.hpp +44 -21
- data/ext/libsass/src/remove_placeholders.cpp +4 -4
- data/ext/libsass/src/remove_placeholders.hpp +3 -3
- data/ext/libsass/src/sass.cpp +16 -15
- data/ext/libsass/src/sass.hpp +9 -5
- data/ext/libsass/src/sass_context.cpp +52 -34
- data/ext/libsass/src/sass_values.cpp +8 -10
- data/ext/libsass/src/settings.hpp +19 -0
- data/ext/libsass/src/source.cpp +69 -0
- data/ext/libsass/src/source.hpp +95 -0
- data/ext/libsass/src/source_data.hpp +32 -0
- data/ext/libsass/src/source_map.cpp +22 -18
- data/ext/libsass/src/source_map.hpp +12 -9
- data/ext/libsass/src/units.cpp +19 -19
- data/ext/libsass/src/units.hpp +8 -8
- data/ext/libsass/src/utf8_string.cpp +9 -10
- data/ext/libsass/src/utf8_string.hpp +7 -6
- data/ext/libsass/src/util.cpp +38 -38
- data/ext/libsass/src/util.hpp +18 -18
- data/ext/libsass/src/util_string.cpp +13 -13
- data/ext/libsass/src/util_string.hpp +9 -8
- data/ext/libsass/src/values.cpp +12 -12
- data/lib/sassc/native.rb +3 -5
- data/lib/sassc/version.rb +1 -1
- data/test/native_test.rb +4 -4
- metadata +14 -5
- data/lib/sassc/native/lib_c.rb +0 -21
data/ext/libsass/src/expand.hpp
CHANGED
@@ -54,35 +54,35 @@ namespace Sass {
|
|
54
54
|
|
55
55
|
private:
|
56
56
|
|
57
|
-
|
57
|
+
sass::vector<CssMediaQuery_Obj> mergeMediaQueries(const sass::vector<CssMediaQuery_Obj>& lhs, const sass::vector<CssMediaQuery_Obj>& rhs);
|
58
58
|
|
59
59
|
public:
|
60
60
|
Expand(Context&, Env*, SelectorStack* stack = nullptr, SelectorStack* original = nullptr);
|
61
61
|
~Expand() { }
|
62
62
|
|
63
63
|
Block* operator()(Block*);
|
64
|
-
Statement* operator()(
|
64
|
+
Statement* operator()(StyleRule*);
|
65
65
|
|
66
66
|
Statement* operator()(MediaRule*);
|
67
67
|
|
68
|
-
// Css
|
68
|
+
// Css StyleRule is already static
|
69
69
|
// Statement* operator()(CssMediaRule*);
|
70
70
|
|
71
|
-
Statement* operator()(
|
72
|
-
Statement* operator()(
|
73
|
-
Statement* operator()(
|
71
|
+
Statement* operator()(SupportsRule*);
|
72
|
+
Statement* operator()(AtRootRule*);
|
73
|
+
Statement* operator()(AtRule*);
|
74
74
|
Statement* operator()(Declaration*);
|
75
75
|
Statement* operator()(Assignment*);
|
76
76
|
Statement* operator()(Import*);
|
77
77
|
Statement* operator()(Import_Stub*);
|
78
|
-
Statement* operator()(
|
79
|
-
Statement* operator()(
|
80
|
-
Statement* operator()(
|
78
|
+
Statement* operator()(WarningRule*);
|
79
|
+
Statement* operator()(ErrorRule*);
|
80
|
+
Statement* operator()(DebugRule*);
|
81
81
|
Statement* operator()(Comment*);
|
82
82
|
Statement* operator()(If*);
|
83
|
-
Statement* operator()(
|
84
|
-
Statement* operator()(
|
85
|
-
Statement* operator()(
|
83
|
+
Statement* operator()(ForRule*);
|
84
|
+
Statement* operator()(EachRule*);
|
85
|
+
Statement* operator()(WhileRule*);
|
86
86
|
Statement* operator()(Return*);
|
87
87
|
Statement* operator()(ExtendRule*);
|
88
88
|
Statement* operator()(Definition*);
|
@@ -142,10 +142,12 @@ namespace Sass {
|
|
142
142
|
// ##########################################################################
|
143
143
|
bool Extender::checkForUnsatisfiedExtends(Extension& unsatisfied) const
|
144
144
|
{
|
145
|
+
if (selectors.empty()) return false;
|
145
146
|
ExtSmplSelSet originals = getSimpleSelectors();
|
146
147
|
for (auto target : extensions) {
|
147
148
|
SimpleSelector* key = target.first;
|
148
149
|
ExtSelExtMapEntry& val = target.second;
|
150
|
+
if (val.empty()) continue;
|
149
151
|
if (originals.find(key) == originals.end()) {
|
150
152
|
const Extension& extension = val.front().second;
|
151
153
|
if (extension.isOptional) continue;
|
@@ -387,7 +389,7 @@ namespace Sass {
|
|
387
389
|
CssMediaRuleObj mediaContext;
|
388
390
|
if (mediaContexts.hasKey(rule)) mediaContext = mediaContexts.get(rule);
|
389
391
|
SelectorListObj ext = extendList(rule, newExtensions, mediaContext);
|
390
|
-
// If no extends actually
|
392
|
+
// If no extends actually happened (for example because unification
|
391
393
|
// failed), we don't need to re-register the selector.
|
392
394
|
if (ObjEqualityFn(oldValue, ext)) continue;
|
393
395
|
rule->elements(ext->elements());
|
@@ -417,7 +419,7 @@ namespace Sass {
|
|
417
419
|
// ##########################################################################
|
418
420
|
ExtSelExtMap Extender::extendExistingExtensions(
|
419
421
|
// Taking in a reference here makes MSVC debug stuck!?
|
420
|
-
const
|
422
|
+
const sass::vector<Extension>& oldExtensions,
|
421
423
|
const ExtSelExtMap& newExtensions)
|
422
424
|
{
|
423
425
|
|
@@ -429,7 +431,7 @@ namespace Sass {
|
|
429
431
|
for (size_t i = 0, iL = oldExtensions.size(); i < iL; i += 1) {
|
430
432
|
const Extension& extension = oldExtensions[i];
|
431
433
|
ExtSelExtMapEntry& sources = extensions[extension.target];
|
432
|
-
|
434
|
+
sass::vector<ComplexSelectorObj> selectors(extendComplex(
|
433
435
|
extension.extender,
|
434
436
|
newExtensions,
|
435
437
|
extension.mediaContext
|
@@ -503,10 +505,10 @@ namespace Sass {
|
|
503
505
|
|
504
506
|
// This could be written more simply using [List.map], but we want to
|
505
507
|
// avoid any allocations in the common case where no extends apply.
|
506
|
-
|
508
|
+
sass::vector<ComplexSelectorObj> extended;
|
507
509
|
for (size_t i = 0; i < list->length(); i++) {
|
508
510
|
const ComplexSelectorObj& complex = list->get(i);
|
509
|
-
|
511
|
+
sass::vector<ComplexSelectorObj> result =
|
510
512
|
extendComplex(complex, extensions, mediaQueryContext);
|
511
513
|
if (result.empty()) {
|
512
514
|
if (!extended.empty()) {
|
@@ -540,7 +542,7 @@ namespace Sass {
|
|
540
542
|
// Extends [complex] using [extensions], and
|
541
543
|
// returns the contents of a [SelectorList].
|
542
544
|
// ##########################################################################
|
543
|
-
|
545
|
+
sass::vector<ComplexSelectorObj> Extender::extendComplex(
|
544
546
|
// Taking in a reference here makes MSVC debug stuck!?
|
545
547
|
const ComplexSelectorObj& complex,
|
546
548
|
const ExtSelExtMap& extensions,
|
@@ -565,13 +567,13 @@ namespace Sass {
|
|
565
567
|
// This could be written more simply using [List.map], but we want to avoid
|
566
568
|
// any allocations in the common case where no extends apply.
|
567
569
|
|
568
|
-
|
569
|
-
|
570
|
+
sass::vector<ComplexSelectorObj> result;
|
571
|
+
sass::vector<sass::vector<ComplexSelectorObj>> extendedNotExpanded;
|
570
572
|
bool isOriginal = originals.find(complex) != originals.end();
|
571
573
|
for (size_t i = 0; i < complex->length(); i += 1) {
|
572
574
|
const SelectorComponentObj& component = complex->get(i);
|
573
575
|
if (CompoundSelector* compound = Cast<CompoundSelector>(component)) {
|
574
|
-
|
576
|
+
sass::vector<ComplexSelectorObj> extended = extendCompound(
|
575
577
|
compound, extensions, mediaQueryContext, isOriginal);
|
576
578
|
if (extended.empty()) {
|
577
579
|
if (!extendedNotExpanded.empty()) {
|
@@ -610,19 +612,19 @@ namespace Sass {
|
|
610
612
|
bool first = true;
|
611
613
|
|
612
614
|
// ToDo: either change weave or paths to work with the same data?
|
613
|
-
|
615
|
+
sass::vector<sass::vector<ComplexSelectorObj>>
|
614
616
|
paths = permutate(extendedNotExpanded);
|
615
617
|
|
616
|
-
for (const
|
618
|
+
for (const sass::vector<ComplexSelectorObj>& path : paths) {
|
617
619
|
// Unpack the inner complex selector to component list
|
618
|
-
|
620
|
+
sass::vector<sass::vector<SelectorComponentObj>> _paths;
|
619
621
|
for (const ComplexSelectorObj& sel : path) {
|
620
622
|
_paths.insert(_paths.end(), sel->elements());
|
621
623
|
}
|
622
624
|
|
623
|
-
|
625
|
+
sass::vector<sass::vector<SelectorComponentObj>> weaved = weave(_paths);
|
624
626
|
|
625
|
-
for (
|
627
|
+
for (sass::vector<SelectorComponentObj>& components : weaved) {
|
626
628
|
|
627
629
|
ComplexSelectorObj cplx = SASS_MEMORY_NEW(ComplexSelector, "[phony]");
|
628
630
|
cplx->hasPreLineFeed(complex->hasPreLineFeed());
|
@@ -671,9 +673,9 @@ namespace Sass {
|
|
671
673
|
// ##########################################################################
|
672
674
|
Extension Extender::extensionForCompound(
|
673
675
|
// Taking in a reference here makes MSVC debug stuck!?
|
674
|
-
const
|
676
|
+
const sass::vector<SimpleSelectorObj>& simples) const
|
675
677
|
{
|
676
|
-
CompoundSelectorObj compound = SASS_MEMORY_NEW(CompoundSelector,
|
678
|
+
CompoundSelectorObj compound = SASS_MEMORY_NEW(CompoundSelector, SourceSpan("[ext]"));
|
677
679
|
compound->concat(simples);
|
678
680
|
Extension extension(compound->wrapInComplex());
|
679
681
|
// extension.specificity = sourceSpecificity[simple];
|
@@ -688,7 +690,7 @@ namespace Sass {
|
|
688
690
|
// indicates whether this is in an original complex selector,
|
689
691
|
// meaning that [compound] should not be trimmed out.
|
690
692
|
// ##########################################################################
|
691
|
-
|
693
|
+
sass::vector<ComplexSelectorObj> Extender::extendCompound(
|
692
694
|
const CompoundSelectorObj& compound,
|
693
695
|
const ExtSelExtMap& extensions,
|
694
696
|
const CssMediaRuleObj& mediaQueryContext,
|
@@ -705,9 +707,9 @@ namespace Sass {
|
|
705
707
|
targetsUsed = &targetsUsed2;
|
706
708
|
}
|
707
709
|
|
708
|
-
|
710
|
+
sass::vector<ComplexSelectorObj> result;
|
709
711
|
// The complex selectors produced from each component of [compound].
|
710
|
-
|
712
|
+
sass::vector<sass::vector<Extension>> options;
|
711
713
|
|
712
714
|
for (size_t i = 0; i < compound->length(); i++) {
|
713
715
|
const SimpleSelectorObj& simple = compound->get(i);
|
@@ -720,7 +722,7 @@ namespace Sass {
|
|
720
722
|
else {
|
721
723
|
if (options.empty()) {
|
722
724
|
if (i != 0) {
|
723
|
-
|
725
|
+
sass::vector<SimpleSelectorObj> in;
|
724
726
|
for (size_t n = 0; n < i; n += 1) {
|
725
727
|
in.push_back(compound->get(n));
|
726
728
|
}
|
@@ -750,7 +752,7 @@ namespace Sass {
|
|
750
752
|
// Optimize for the simple case of a single simple
|
751
753
|
// selector that doesn't need any unification.
|
752
754
|
if (options.size() == 1) {
|
753
|
-
|
755
|
+
sass::vector<Extension> exts = options[0];
|
754
756
|
for (size_t n = 0; n < exts.size(); n += 1) {
|
755
757
|
exts[n].assertCompatibleMediaContext(mediaQueryContext, traces);
|
756
758
|
result.push_back(exts[n].extender);
|
@@ -784,12 +786,12 @@ namespace Sass {
|
|
784
786
|
// ]
|
785
787
|
|
786
788
|
bool first = mode != ExtendMode::REPLACE;
|
787
|
-
|
788
|
-
|
789
|
+
sass::vector<ComplexSelectorObj> unifiedPaths;
|
790
|
+
sass::vector<sass::vector<Extension>> prePaths = permutate(options);
|
789
791
|
|
790
792
|
for (size_t i = 0; i < prePaths.size(); i += 1) {
|
791
|
-
|
792
|
-
const
|
793
|
+
sass::vector<sass::vector<SelectorComponentObj>> complexes;
|
794
|
+
const sass::vector<Extension>& path = prePaths[i];
|
793
795
|
if (first) {
|
794
796
|
// The first path is always the original selector. We can't just
|
795
797
|
// return [compound] directly because pseudo selectors may be
|
@@ -806,8 +808,8 @@ namespace Sass {
|
|
806
808
|
complexes.push_back({ mergedSelector });
|
807
809
|
}
|
808
810
|
else {
|
809
|
-
|
810
|
-
|
811
|
+
sass::vector<SimpleSelectorObj> originals;
|
812
|
+
sass::vector<sass::vector<SelectorComponentObj>> toUnify;
|
811
813
|
|
812
814
|
for (auto& state : path) {
|
813
815
|
if (state.isOriginal) {
|
@@ -841,7 +843,7 @@ namespace Sass {
|
|
841
843
|
// specificity = math.max(specificity, state.specificity);
|
842
844
|
}
|
843
845
|
|
844
|
-
for (
|
846
|
+
for (sass::vector<SelectorComponentObj>& components : complexes) {
|
845
847
|
auto sel = SASS_MEMORY_NEW(ComplexSelector, "[ext]");
|
846
848
|
sel->hasPreLineFeed(lineBreak);
|
847
849
|
sel->elements(components);
|
@@ -858,7 +860,7 @@ namespace Sass {
|
|
858
860
|
// Extends [simple] without extending the
|
859
861
|
// contents of any selector pseudos it contains.
|
860
862
|
// ##########################################################################
|
861
|
-
|
863
|
+
sass::vector<Extension> Extender::extendWithoutPseudo(
|
862
864
|
const SimpleSelectorObj& simple,
|
863
865
|
const ExtSelExtMap& extensions,
|
864
866
|
ExtSmplSelSet* targetsUsed) const
|
@@ -875,9 +877,9 @@ namespace Sass {
|
|
875
877
|
return extenders.values();
|
876
878
|
}
|
877
879
|
|
878
|
-
const
|
880
|
+
const sass::vector<Extension>&
|
879
881
|
values = extenders.values();
|
880
|
-
|
882
|
+
sass::vector<Extension> result;
|
881
883
|
result.reserve(values.size() + 1);
|
882
884
|
result.push_back(extensionForSimple(simple));
|
883
885
|
result.insert(result.end(), values.begin(), values.end());
|
@@ -889,20 +891,20 @@ namespace Sass {
|
|
889
891
|
// Extends [simple] and also extending the
|
890
892
|
// contents of any selector pseudos it contains.
|
891
893
|
// ##########################################################################
|
892
|
-
|
894
|
+
sass::vector<sass::vector<Extension>> Extender::extendSimple(
|
893
895
|
const SimpleSelectorObj& simple,
|
894
896
|
const ExtSelExtMap& extensions,
|
895
897
|
const CssMediaRuleObj& mediaQueryContext,
|
896
898
|
ExtSmplSelSet* targetsUsed)
|
897
899
|
{
|
898
|
-
if (
|
900
|
+
if (PseudoSelector* pseudo = Cast<PseudoSelector>(simple)) {
|
899
901
|
if (pseudo->selector()) {
|
900
|
-
|
901
|
-
|
902
|
+
sass::vector<sass::vector<Extension>> merged;
|
903
|
+
sass::vector<PseudoSelectorObj> extended =
|
902
904
|
extendPseudo(pseudo, extensions, mediaQueryContext);
|
903
|
-
for (
|
905
|
+
for (PseudoSelectorObj& extend : extended) {
|
904
906
|
SimpleSelectorObj simple = extend;
|
905
|
-
|
907
|
+
sass::vector<Extension> result =
|
906
908
|
extendWithoutPseudo(simple, extensions, targetsUsed);
|
907
909
|
if (result.empty()) result = { extensionForSimple(extend) };
|
908
910
|
merged.push_back(result);
|
@@ -912,7 +914,7 @@ namespace Sass {
|
|
912
914
|
}
|
913
915
|
}
|
914
916
|
}
|
915
|
-
|
917
|
+
sass::vector<Extension> result =
|
916
918
|
extendWithoutPseudo(simple, extensions, targetsUsed);
|
917
919
|
if (result.empty()) return {};
|
918
920
|
return { result };
|
@@ -922,9 +924,9 @@ namespace Sass {
|
|
922
924
|
// ##########################################################################
|
923
925
|
// Inner loop helper for [extendPseudo] function
|
924
926
|
// ##########################################################################
|
925
|
-
|
927
|
+
sass::vector<ComplexSelectorObj> Extender::extendPseudoComplex(
|
926
928
|
const ComplexSelectorObj& complex,
|
927
|
-
const
|
929
|
+
const PseudoSelectorObj& pseudo,
|
928
930
|
const CssMediaRuleObj& mediaQueryContext)
|
929
931
|
{
|
930
932
|
|
@@ -932,11 +934,11 @@ namespace Sass {
|
|
932
934
|
auto compound = Cast<CompoundSelector>(complex->get(0));
|
933
935
|
if (compound == nullptr) { return { complex }; }
|
934
936
|
if (compound->length() != 1) { return { complex }; }
|
935
|
-
auto innerPseudo = Cast<
|
937
|
+
auto innerPseudo = Cast<PseudoSelector>(compound->get(0));
|
936
938
|
if (innerPseudo == nullptr) { return { complex }; }
|
937
939
|
if (!innerPseudo->selector()) { return { complex }; }
|
938
940
|
|
939
|
-
|
941
|
+
sass::string name(pseudo->normalized());
|
940
942
|
|
941
943
|
if (name == "not") {
|
942
944
|
// In theory, if there's a `:not` nested within another `:not`, the
|
@@ -972,8 +974,8 @@ namespace Sass {
|
|
972
974
|
// Extends [pseudo] using [extensions], and returns
|
973
975
|
// a list of resulting pseudo selectors.
|
974
976
|
// ##########################################################################
|
975
|
-
|
976
|
-
const
|
977
|
+
sass::vector<PseudoSelectorObj> Extender::extendPseudo(
|
978
|
+
const PseudoSelectorObj& pseudo,
|
977
979
|
const ExtSelExtMap& extensions,
|
978
980
|
const CssMediaRuleObj& mediaQueryContext)
|
979
981
|
{
|
@@ -988,7 +990,7 @@ namespace Sass {
|
|
988
990
|
// writing. We can keep them if either the original selector had a complex
|
989
991
|
// selector, or the result of extending has only complex selectors, because
|
990
992
|
// either way we aren't breaking anything that isn't already broken.
|
991
|
-
|
993
|
+
sass::vector<ComplexSelectorObj> complexes = extended->elements();
|
992
994
|
|
993
995
|
if (pseudo->normalized() == "not") {
|
994
996
|
if (!hasAny(pseudo->selector()->elements(), hasMoreThanOne)) {
|
@@ -1003,7 +1005,7 @@ namespace Sass {
|
|
1003
1005
|
}
|
1004
1006
|
}
|
1005
1007
|
|
1006
|
-
|
1008
|
+
sass::vector<ComplexSelectorObj> expanded = expand(
|
1007
1009
|
complexes, extendPseudoComplex, pseudo, mediaQueryContext);
|
1008
1010
|
|
1009
1011
|
// Older browsers support `:not`, but only with a single complex selector.
|
@@ -1011,7 +1013,7 @@ namespace Sass {
|
|
1011
1013
|
// unless it originally contained a selector list.
|
1012
1014
|
if (pseudo->normalized() == "not") {
|
1013
1015
|
if (pseudo->selector()->length() == 1) {
|
1014
|
-
|
1016
|
+
sass::vector<PseudoSelectorObj> pseudos;
|
1015
1017
|
for (size_t i = 0; i < expanded.size(); i += 1) {
|
1016
1018
|
pseudos.push_back(pseudo->withSelector(
|
1017
1019
|
expanded[i]->wrapInList()
|
@@ -1033,7 +1035,7 @@ namespace Sass {
|
|
1033
1035
|
// one index higher, looping the final element back to [start].
|
1034
1036
|
// ##########################################################################
|
1035
1037
|
void Extender::rotateSlice(
|
1036
|
-
|
1038
|
+
sass::vector<ComplexSelectorObj>& list,
|
1037
1039
|
size_t start, size_t end)
|
1038
1040
|
{
|
1039
1041
|
auto element = list[end - 1];
|
@@ -1053,8 +1055,8 @@ namespace Sass {
|
|
1053
1055
|
// Note: for adaption I pass in the set directly, there is some
|
1054
1056
|
// code path in selector-trim that might need this special callback
|
1055
1057
|
// ##########################################################################
|
1056
|
-
|
1057
|
-
const
|
1058
|
+
sass::vector<ComplexSelectorObj> Extender::trim(
|
1059
|
+
const sass::vector<ComplexSelectorObj>& selectors,
|
1058
1060
|
const ExtCplxSelSet& existing) const
|
1059
1061
|
{
|
1060
1062
|
|
@@ -1062,17 +1064,17 @@ namespace Sass {
|
|
1062
1064
|
// TODO(nweiz): I think there may be a way to get perfect trimming
|
1063
1065
|
// without going quadratic by building some sort of trie-like
|
1064
1066
|
// data structure that can be used to look up superselectors.
|
1065
|
-
// TODO(mgreter): Check how this
|
1067
|
+
// TODO(mgreter): Check how this performs in C++ (up the limit)
|
1066
1068
|
if (selectors.size() > 100) return selectors;
|
1067
1069
|
|
1068
1070
|
// This is n² on the sequences, but only comparing between separate sequences
|
1069
1071
|
// should limit the quadratic behavior. We iterate from last to first and reverse
|
1070
1072
|
// the result so that, if two selectors are identical, we keep the first one.
|
1071
|
-
|
1073
|
+
sass::vector<ComplexSelectorObj> result; size_t numOriginals = 0;
|
1072
1074
|
|
1073
1075
|
size_t i = selectors.size();
|
1074
1076
|
outer: // Use label to continue loop
|
1075
|
-
while (--i !=
|
1077
|
+
while (--i != sass::string::npos) {
|
1076
1078
|
|
1077
1079
|
const ComplexSelectorObj& complex1 = selectors[i];
|
1078
1080
|
// Check if selector in known in existing "originals"
|
@@ -60,7 +60,7 @@ namespace Sass {
|
|
60
60
|
|
61
61
|
typedef std::unordered_map <
|
62
62
|
SimpleSelectorObj,
|
63
|
-
|
63
|
+
sass::vector<
|
64
64
|
Extension
|
65
65
|
>,
|
66
66
|
ObjHash,
|
@@ -267,7 +267,7 @@ namespace Sass {
|
|
267
267
|
// ##########################################################################
|
268
268
|
ExtSelExtMap extendExistingExtensions(
|
269
269
|
// Taking in a reference here makes MSVC debug stuck!?
|
270
|
-
const
|
270
|
+
const sass::vector<Extension>& extensions,
|
271
271
|
const ExtSelExtMap& newExtensions);
|
272
272
|
|
273
273
|
// ##########################################################################
|
@@ -282,7 +282,7 @@ namespace Sass {
|
|
282
282
|
// Extends [complex] using [extensions], and
|
283
283
|
// returns the contents of a [SelectorList].
|
284
284
|
// ##########################################################################
|
285
|
-
|
285
|
+
sass::vector<ComplexSelectorObj> extendComplex(
|
286
286
|
// Taking in a reference here makes MSVC debug stuck!?
|
287
287
|
const ComplexSelectorObj& list,
|
288
288
|
const ExtSelExtMap& extensions,
|
@@ -301,7 +301,7 @@ namespace Sass {
|
|
301
301
|
// ##########################################################################
|
302
302
|
Extension extensionForCompound(
|
303
303
|
// Taking in a reference here makes MSVC debug stuck!?
|
304
|
-
const
|
304
|
+
const sass::vector<SimpleSelectorObj>& simples) const;
|
305
305
|
|
306
306
|
// ##########################################################################
|
307
307
|
// Extends [compound] using [extensions], and returns the
|
@@ -309,7 +309,7 @@ namespace Sass {
|
|
309
309
|
// indicates whether this is in an original complex selector,
|
310
310
|
// meaning that [compound] should not be trimmed out.
|
311
311
|
// ##########################################################################
|
312
|
-
|
312
|
+
sass::vector<ComplexSelectorObj> extendCompound(
|
313
313
|
const CompoundSelectorObj& compound,
|
314
314
|
const ExtSelExtMap& extensions,
|
315
315
|
const CssMediaRuleObj& mediaQueryContext,
|
@@ -319,7 +319,7 @@ namespace Sass {
|
|
319
319
|
// Extends [simple] without extending the
|
320
320
|
// contents of any selector pseudos it contains.
|
321
321
|
// ##########################################################################
|
322
|
-
|
322
|
+
sass::vector<Extension> extendWithoutPseudo(
|
323
323
|
const SimpleSelectorObj& simple,
|
324
324
|
const ExtSelExtMap& extensions,
|
325
325
|
ExtSmplSelSet* targetsUsed) const;
|
@@ -328,7 +328,7 @@ namespace Sass {
|
|
328
328
|
// Extends [simple] and also extending the
|
329
329
|
// contents of any selector pseudos it contains.
|
330
330
|
// ##########################################################################
|
331
|
-
|
331
|
+
sass::vector<sass::vector<Extension>> extendSimple(
|
332
332
|
const SimpleSelectorObj& simple,
|
333
333
|
const ExtSelExtMap& extensions,
|
334
334
|
const CssMediaRuleObj& mediaQueryContext,
|
@@ -337,17 +337,17 @@ namespace Sass {
|
|
337
337
|
// ##########################################################################
|
338
338
|
// Inner loop helper for [extendPseudo] function
|
339
339
|
// ##########################################################################
|
340
|
-
static
|
340
|
+
static sass::vector<ComplexSelectorObj> extendPseudoComplex(
|
341
341
|
const ComplexSelectorObj& complex,
|
342
|
-
const
|
342
|
+
const PseudoSelectorObj& pseudo,
|
343
343
|
const CssMediaRuleObj& mediaQueryContext);
|
344
344
|
|
345
345
|
// ##########################################################################
|
346
346
|
// Extends [pseudo] using [extensions], and returns
|
347
347
|
// a list of resulting pseudo selectors.
|
348
348
|
// ##########################################################################
|
349
|
-
|
350
|
-
const
|
349
|
+
sass::vector<PseudoSelectorObj> extendPseudo(
|
350
|
+
const PseudoSelectorObj& pseudo,
|
351
351
|
const ExtSelExtMap& extensions,
|
352
352
|
const CssMediaRuleObj& mediaQueryContext);
|
353
353
|
|
@@ -356,7 +356,7 @@ namespace Sass {
|
|
356
356
|
// one index higher, looping the final element back to [start].
|
357
357
|
// ##########################################################################
|
358
358
|
static void rotateSlice(
|
359
|
-
|
359
|
+
sass::vector<ComplexSelectorObj>& list,
|
360
360
|
size_t start, size_t end);
|
361
361
|
|
362
362
|
// ##########################################################################
|
@@ -364,8 +364,8 @@ namespace Sass {
|
|
364
364
|
// elements. The [isOriginal] callback indicates which selectors are
|
365
365
|
// original to the document, and thus should never be trimmed.
|
366
366
|
// ##########################################################################
|
367
|
-
|
368
|
-
const
|
367
|
+
sass::vector<ComplexSelectorObj> trim(
|
368
|
+
const sass::vector<ComplexSelectorObj>& selectors,
|
369
369
|
const ExtCplxSelSet& set) const;
|
370
370
|
|
371
371
|
// ##########################################################################
|