sassc 2.2.1 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +13 -0
- data/Rakefile +1 -3
- data/ext/extconf.rb +13 -5
- data/ext/libsass/VERSION +1 -1
- data/ext/libsass/include/sass/base.h +2 -1
- data/ext/libsass/include/sass/context.h +1 -0
- data/ext/libsass/src/ast.cpp +49 -59
- data/ext/libsass/src/ast.hpp +263 -102
- data/ext/libsass/src/ast_def_macros.hpp +8 -0
- data/ext/libsass/src/ast_fwd_decl.cpp +2 -1
- data/ext/libsass/src/ast_fwd_decl.hpp +40 -116
- data/ext/libsass/src/ast_helpers.hpp +292 -0
- data/ext/libsass/src/ast_sel_cmp.cpp +209 -722
- data/ext/libsass/src/ast_sel_super.cpp +539 -0
- data/ext/libsass/src/ast_sel_unify.cpp +207 -212
- data/ext/libsass/src/ast_sel_weave.cpp +616 -0
- data/ext/libsass/src/ast_selectors.cpp +559 -1001
- data/ext/libsass/src/ast_selectors.hpp +311 -367
- data/ext/libsass/src/ast_supports.cpp +1 -17
- data/ext/libsass/src/ast_values.cpp +216 -29
- data/ext/libsass/src/ast_values.hpp +42 -33
- data/ext/libsass/src/bind.cpp +1 -1
- data/ext/libsass/src/cencode.c +4 -6
- data/ext/libsass/src/check_nesting.cpp +5 -6
- data/ext/libsass/src/check_nesting.hpp +4 -0
- data/ext/libsass/src/color_maps.cpp +11 -10
- data/ext/libsass/src/color_maps.hpp +0 -8
- data/ext/libsass/src/constants.cpp +5 -0
- data/ext/libsass/src/constants.hpp +6 -0
- data/ext/libsass/src/context.cpp +30 -60
- data/ext/libsass/src/context.hpp +8 -20
- data/ext/libsass/src/cssize.cpp +36 -120
- data/ext/libsass/src/cssize.hpp +4 -10
- data/ext/libsass/src/dart_helpers.hpp +199 -0
- data/ext/libsass/src/debugger.hpp +364 -207
- data/ext/libsass/src/emitter.cpp +3 -4
- data/ext/libsass/src/emitter.hpp +0 -2
- data/ext/libsass/src/environment.hpp +5 -0
- data/ext/libsass/src/error_handling.cpp +21 -0
- data/ext/libsass/src/error_handling.hpp +25 -3
- data/ext/libsass/src/eval.cpp +33 -153
- data/ext/libsass/src/eval.hpp +11 -13
- data/ext/libsass/src/eval_selectors.cpp +75 -0
- data/ext/libsass/src/expand.cpp +214 -167
- data/ext/libsass/src/expand.hpp +26 -6
- data/ext/libsass/src/extender.cpp +1186 -0
- data/ext/libsass/src/extender.hpp +399 -0
- data/ext/libsass/src/extension.cpp +43 -0
- data/ext/libsass/src/extension.hpp +89 -0
- data/ext/libsass/src/file.cpp +15 -14
- data/ext/libsass/src/file.hpp +5 -12
- data/ext/libsass/src/fn_colors.cpp +12 -10
- data/ext/libsass/src/fn_lists.cpp +12 -11
- data/ext/libsass/src/fn_miscs.cpp +22 -34
- data/ext/libsass/src/fn_numbers.cpp +13 -6
- data/ext/libsass/src/fn_selectors.cpp +94 -124
- data/ext/libsass/src/fn_strings.cpp +16 -14
- data/ext/libsass/src/fn_utils.cpp +5 -6
- data/ext/libsass/src/fn_utils.hpp +9 -3
- data/ext/libsass/src/inspect.cpp +154 -117
- data/ext/libsass/src/inspect.hpp +10 -8
- data/ext/libsass/src/lexer.cpp +17 -81
- data/ext/libsass/src/lexer.hpp +5 -16
- data/ext/libsass/src/listize.cpp +22 -36
- data/ext/libsass/src/listize.hpp +8 -9
- data/ext/libsass/src/memory/SharedPtr.hpp +39 -5
- data/ext/libsass/src/operation.hpp +27 -17
- data/ext/libsass/src/operators.cpp +1 -0
- data/ext/libsass/src/ordered_map.hpp +112 -0
- data/ext/libsass/src/output.cpp +30 -49
- data/ext/libsass/src/output.hpp +1 -1
- data/ext/libsass/src/parser.cpp +211 -381
- data/ext/libsass/src/parser.hpp +17 -15
- data/ext/libsass/src/parser_selectors.cpp +189 -0
- data/ext/libsass/src/permutate.hpp +140 -0
- data/ext/libsass/src/position.hpp +1 -1
- data/ext/libsass/src/prelexer.cpp +6 -6
- data/ext/libsass/src/remove_placeholders.cpp +55 -56
- data/ext/libsass/src/remove_placeholders.hpp +21 -18
- data/ext/libsass/src/sass.hpp +1 -0
- data/ext/libsass/src/sass2scss.cpp +4 -4
- data/ext/libsass/src/sass_context.cpp +42 -91
- data/ext/libsass/src/sass_context.hpp +2 -2
- data/ext/libsass/src/sass_functions.cpp +1 -1
- data/ext/libsass/src/sass_values.cpp +0 -1
- data/ext/libsass/src/stylesheet.cpp +22 -0
- data/ext/libsass/src/stylesheet.hpp +57 -0
- data/ext/libsass/src/to_value.cpp +2 -2
- data/ext/libsass/src/to_value.hpp +1 -1
- data/ext/libsass/src/units.cpp +5 -3
- data/ext/libsass/src/util.cpp +10 -12
- data/ext/libsass/src/util.hpp +2 -3
- data/ext/libsass/src/util_string.cpp +111 -61
- data/ext/libsass/src/util_string.hpp +61 -8
- data/lib/sassc/engine.rb +5 -3
- data/lib/sassc/functions_handler.rb +8 -8
- data/lib/sassc/native.rb +1 -1
- data/lib/sassc/script.rb +4 -4
- data/lib/sassc/version.rb +1 -1
- data/test/functions_test.rb +18 -1
- data/test/native_test.rb +1 -1
- metadata +17 -12
- data/ext/libsass/src/extend.cpp +0 -2132
- data/ext/libsass/src/extend.hpp +0 -86
- data/ext/libsass/src/node.cpp +0 -322
- data/ext/libsass/src/node.hpp +0 -118
- data/ext/libsass/src/paths.hpp +0 -71
- data/ext/libsass/src/sass_util.cpp +0 -152
- data/ext/libsass/src/sass_util.hpp +0 -256
- data/ext/libsass/src/subset_map.cpp +0 -58
- data/ext/libsass/src/subset_map.hpp +0 -76
data/ext/libsass/src/bind.cpp
CHANGED
data/ext/libsass/src/cencode.c
CHANGED
@@ -46,9 +46,8 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out,
|
|
46
46
|
result = (fragment & 0x0fc) >> 2;
|
47
47
|
*codechar++ = base64_encode_value(result);
|
48
48
|
result = (fragment & 0x003) << 4;
|
49
|
-
|
50
|
-
|
51
|
-
#endif
|
49
|
+
/* fall through */
|
50
|
+
|
52
51
|
case step_B:
|
53
52
|
if (plainchar == plaintextend)
|
54
53
|
{
|
@@ -60,9 +59,8 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out,
|
|
60
59
|
result |= (fragment & 0x0f0) >> 4;
|
61
60
|
*codechar++ = base64_encode_value(result);
|
62
61
|
result = (fragment & 0x00f) << 2;
|
63
|
-
|
64
|
-
|
65
|
-
#endif
|
62
|
+
/* fall through */
|
63
|
+
|
66
64
|
case step_C:
|
67
65
|
if (plainchar == plaintextend)
|
68
66
|
{
|
@@ -1,9 +1,7 @@
|
|
1
1
|
// sass.hpp must go before all system headers to get the
|
2
2
|
// __EXTENSIONS__ fix on Solaris.
|
3
3
|
#include "sass.hpp"
|
4
|
-
|
5
|
-
#include <vector>
|
6
|
-
|
4
|
+
#include "ast.hpp"
|
7
5
|
#include "check_nesting.hpp"
|
8
6
|
|
9
7
|
namespace Sass {
|
@@ -145,7 +143,7 @@ namespace Sass {
|
|
145
143
|
if (is_charset(node))
|
146
144
|
{ this->invalid_charset_parent(this->parent, node); }
|
147
145
|
|
148
|
-
if (Cast<
|
146
|
+
if (Cast<ExtendRule>(node))
|
149
147
|
{ this->invalid_extend_parent(this->parent, node); }
|
150
148
|
|
151
149
|
// if (Cast<Import>(node))
|
@@ -388,7 +386,8 @@ namespace Sass {
|
|
388
386
|
{
|
389
387
|
return Cast<Directive>(n) ||
|
390
388
|
Cast<Import>(n) ||
|
391
|
-
|
392
|
-
|
389
|
+
Cast<MediaRule>(n) ||
|
390
|
+
Cast<CssMediaRule>(n) ||
|
391
|
+
Cast<Supports_Block>(n);
|
393
392
|
}
|
394
393
|
}
|
@@ -1,8 +1,12 @@
|
|
1
1
|
#ifndef SASS_CHECK_NESTING_H
|
2
2
|
#define SASS_CHECK_NESTING_H
|
3
3
|
|
4
|
+
// sass.hpp must go before all system headers to get the
|
5
|
+
// __EXTENSIONS__ fix on Solaris.
|
6
|
+
#include "sass.hpp"
|
4
7
|
#include "ast.hpp"
|
5
8
|
#include "operation.hpp"
|
9
|
+
#include <vector>
|
6
10
|
|
7
11
|
namespace Sass {
|
8
12
|
|
@@ -4,6 +4,7 @@
|
|
4
4
|
|
5
5
|
#include "ast.hpp"
|
6
6
|
#include "color_maps.hpp"
|
7
|
+
#include "util_string.hpp"
|
7
8
|
|
8
9
|
namespace Sass {
|
9
10
|
|
@@ -313,7 +314,7 @@ namespace Sass {
|
|
313
314
|
const Color_RGBA transparent(color_table, 0, 0, 0, 0);
|
314
315
|
}
|
315
316
|
|
316
|
-
const std::
|
317
|
+
static const auto* const colors_to_names = new std::unordered_map<int, const char*> {
|
317
318
|
{ 240 * 0x10000 + 248 * 0x100 + 255, ColorNames::aliceblue },
|
318
319
|
{ 250 * 0x10000 + 235 * 0x100 + 215, ColorNames::antiquewhite },
|
319
320
|
{ 0 * 0x10000 + 255 * 0x100 + 255, ColorNames::cyan },
|
@@ -455,7 +456,7 @@ namespace Sass {
|
|
455
456
|
{ 102 * 0x10000 + 51 * 0x100 + 153, ColorNames::rebeccapurple }
|
456
457
|
};
|
457
458
|
|
458
|
-
const std::
|
459
|
+
static const auto *const names_to_colors = new std::unordered_map<std::string, const Color_RGBA*>
|
459
460
|
{
|
460
461
|
{ ColorNames::aliceblue, &Colors::aliceblue },
|
461
462
|
{ ColorNames::antiquewhite, &Colors::antiquewhite },
|
@@ -616,23 +617,23 @@ namespace Sass {
|
|
616
617
|
const Color_RGBA* name_to_color(const std::string& key)
|
617
618
|
{
|
618
619
|
// case insensitive lookup. See #2462
|
619
|
-
std::string lower
|
620
|
-
|
620
|
+
std::string lower = key;
|
621
|
+
Util::ascii_str_tolower(&lower);
|
621
622
|
|
622
|
-
auto p = names_to_colors
|
623
|
-
if (p != names_to_colors
|
623
|
+
auto p = names_to_colors->find(lower);
|
624
|
+
if (p != names_to_colors->end()) {
|
624
625
|
return p->second;
|
625
626
|
}
|
626
|
-
return
|
627
|
+
return nullptr;
|
627
628
|
}
|
628
629
|
|
629
630
|
const char* color_to_name(const int key)
|
630
631
|
{
|
631
|
-
auto p = colors_to_names
|
632
|
-
if (p != colors_to_names
|
632
|
+
auto p = colors_to_names->find(key);
|
633
|
+
if (p != colors_to_names->end()) {
|
633
634
|
return p->second;
|
634
635
|
}
|
635
|
-
return
|
636
|
+
return nullptr;
|
636
637
|
}
|
637
638
|
|
638
639
|
const char* color_to_name(const double key)
|
@@ -45,6 +45,7 @@ namespace Sass {
|
|
45
45
|
extern const char for_kwd[] = "@for";
|
46
46
|
extern const char from_kwd[] = "from";
|
47
47
|
extern const char to_kwd[] = "to";
|
48
|
+
extern const char of_kwd[] = "of";
|
48
49
|
extern const char through_kwd[] = "through";
|
49
50
|
extern const char each_kwd[] = "@each";
|
50
51
|
extern const char in_kwd[] = "in";
|
@@ -161,6 +162,10 @@ namespace Sass {
|
|
161
162
|
extern const char uri_chars[] = ":;/?!%&#@|[]{}'`^\"*+-.,_=~";
|
162
163
|
extern const char real_uri_chars[] = "#%&";
|
163
164
|
|
165
|
+
extern const char selector_combinator_child[] = ">";
|
166
|
+
extern const char selector_combinator_general[] = "~";
|
167
|
+
extern const char selector_combinator_adjacent[] = "+";
|
168
|
+
|
164
169
|
// some specific constant character classes
|
165
170
|
// they must be static to be useable by lexer
|
166
171
|
extern const char static_ops[] = "*/%";
|
@@ -43,6 +43,7 @@ namespace Sass {
|
|
43
43
|
extern const char for_kwd[];
|
44
44
|
extern const char from_kwd[];
|
45
45
|
extern const char to_kwd[];
|
46
|
+
extern const char of_kwd[];
|
46
47
|
extern const char through_kwd[];
|
47
48
|
extern const char each_kwd[];
|
48
49
|
extern const char in_kwd[];
|
@@ -161,6 +162,11 @@ namespace Sass {
|
|
161
162
|
extern const char uri_chars[];
|
162
163
|
extern const char real_uri_chars[];
|
163
164
|
|
165
|
+
// constants for selector combinators
|
166
|
+
extern const char selector_combinator_child[];
|
167
|
+
extern const char selector_combinator_general[];
|
168
|
+
extern const char selector_combinator_adjacent[];
|
169
|
+
|
164
170
|
// some specific constant character classes
|
165
171
|
// they must be static to be useable by lexer
|
166
172
|
extern const char static_ops[];
|
data/ext/libsass/src/context.cpp
CHANGED
@@ -1,44 +1,22 @@
|
|
1
1
|
// sass.hpp must go before all system headers to get the
|
2
2
|
// __EXTENSIONS__ fix on Solaris.
|
3
3
|
#include "sass.hpp"
|
4
|
-
|
5
|
-
#include <string>
|
6
|
-
#include <cstdlib>
|
7
|
-
#include <cstring>
|
8
|
-
#include <iomanip>
|
9
|
-
#include <sstream>
|
10
|
-
#include <iostream>
|
11
|
-
|
12
4
|
#include "ast.hpp"
|
13
|
-
|
14
|
-
#include "sass.h"
|
15
|
-
#include "context.hpp"
|
16
|
-
#include "plugins.hpp"
|
17
|
-
#include "constants.hpp"
|
18
|
-
#include "parser.hpp"
|
19
|
-
#include "file.hpp"
|
20
|
-
#include "inspect.hpp"
|
21
|
-
#include "output.hpp"
|
22
|
-
#include "expand.hpp"
|
23
|
-
#include "eval.hpp"
|
24
|
-
#include "check_nesting.hpp"
|
25
|
-
#include "cssize.hpp"
|
26
|
-
#include "listize.hpp"
|
27
|
-
#include "extend.hpp"
|
5
|
+
|
28
6
|
#include "remove_placeholders.hpp"
|
29
7
|
#include "sass_functions.hpp"
|
30
|
-
#include "
|
31
|
-
#include "
|
32
|
-
#include "
|
33
|
-
#include "
|
34
|
-
#include "
|
8
|
+
#include "check_nesting.hpp"
|
9
|
+
#include "fn_selectors.hpp"
|
10
|
+
#include "fn_strings.hpp"
|
11
|
+
#include "fn_numbers.hpp"
|
12
|
+
#include "fn_colors.hpp"
|
35
13
|
#include "fn_miscs.hpp"
|
36
|
-
#include "fn_maps.hpp"
|
37
14
|
#include "fn_lists.hpp"
|
38
|
-
#include "
|
39
|
-
#include "
|
40
|
-
#include "
|
41
|
-
#include "
|
15
|
+
#include "fn_maps.hpp"
|
16
|
+
#include "context.hpp"
|
17
|
+
#include "expand.hpp"
|
18
|
+
#include "parser.hpp"
|
19
|
+
#include "cssize.hpp"
|
42
20
|
|
43
21
|
namespace Sass {
|
44
22
|
using namespace Constants;
|
@@ -50,23 +28,17 @@ namespace Sass {
|
|
50
28
|
|
51
29
|
static std::string safe_input(const char* in_path)
|
52
30
|
{
|
53
|
-
|
54
|
-
|
55
|
-
std::string safe_path(in_path ? in_path : "");
|
56
|
-
return safe_path == "" ? "stdin" : safe_path;
|
31
|
+
if (in_path == nullptr || in_path[0] == '\0') return "stdin";
|
32
|
+
return in_path;
|
57
33
|
}
|
58
34
|
|
59
|
-
static std::string safe_output(const char* out_path,
|
35
|
+
static std::string safe_output(const char* out_path, std::string input_path)
|
60
36
|
{
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
int lastindex = static_cast<int>(input_path.find_last_of("."));
|
65
|
-
return (lastindex > -1 ? input_path.substr(0, lastindex) : input_path) + ".css";
|
37
|
+
if (out_path == nullptr || out_path[0] == '\0') {
|
38
|
+
if (input_path.empty()) return "stdout";
|
39
|
+
return input_path.substr(0, input_path.find_last_of(".")) + ".css";
|
66
40
|
}
|
67
|
-
|
68
|
-
// used to create relative file links
|
69
|
-
return safe_path == "" ? "stdout" : safe_path;
|
41
|
+
return out_path;
|
70
42
|
}
|
71
43
|
|
72
44
|
Context::Context(struct Sass_Context& c_ctx)
|
@@ -81,10 +53,10 @@ namespace Sass {
|
|
81
53
|
strings(),
|
82
54
|
resources(),
|
83
55
|
sheets(),
|
84
|
-
subset_map(),
|
85
56
|
import_stack(),
|
86
57
|
callee_stack(),
|
87
58
|
traces(),
|
59
|
+
extender(Extender::NORMAL, traces),
|
88
60
|
c_compiler(NULL),
|
89
61
|
|
90
62
|
c_headers (std::vector<Sass_Importer_Entry>()),
|
@@ -160,7 +132,7 @@ namespace Sass {
|
|
160
132
|
}
|
161
133
|
// clear inner structures (vectors) and input source
|
162
134
|
resources.clear(); import_stack.clear();
|
163
|
-
|
135
|
+
sheets.clear();
|
164
136
|
}
|
165
137
|
|
166
138
|
Data_Context::~Data_Context()
|
@@ -405,7 +377,7 @@ namespace Sass {
|
|
405
377
|
// if (protocol.compare("file") && true) { }
|
406
378
|
}
|
407
379
|
|
408
|
-
// add urls (protocol other than file) and urls without
|
380
|
+
// add urls (protocol other than file) and urls without protocol to `urls` member
|
409
381
|
// ToDo: if ctx_path is already a file resource, we should not add it here?
|
410
382
|
if (imp->import_queries() || protocol != "file" || imp_path.substr(0, 2) == "//") {
|
411
383
|
imp->urls().push_back(SASS_MEMORY_NEW(String_Quoted, imp->pstate(), load_path));
|
@@ -529,7 +501,7 @@ namespace Sass {
|
|
529
501
|
OutputBuffer emitted = emitter.get_buffer();
|
530
502
|
// should we append a source map url?
|
531
503
|
if (!c_options.omit_source_map_url) {
|
532
|
-
// generate an
|
504
|
+
// generate an embedded source map
|
533
505
|
if (c_options.source_map_embed) {
|
534
506
|
emitted.buffer += linefeed;
|
535
507
|
emitted.buffer += format_embedded_source_map();
|
@@ -649,8 +621,6 @@ namespace Sass {
|
|
649
621
|
return compile();
|
650
622
|
}
|
651
623
|
|
652
|
-
|
653
|
-
|
654
624
|
// parse root block from includes
|
655
625
|
Block_Obj Context::compile()
|
656
626
|
{
|
@@ -678,23 +648,23 @@ namespace Sass {
|
|
678
648
|
}
|
679
649
|
// expand and eval the tree
|
680
650
|
root = expand(root);
|
651
|
+
|
652
|
+
Extension unsatisfied;
|
653
|
+
// check that all extends were used
|
654
|
+
if (extender.checkForUnsatisfiedExtends(unsatisfied)) {
|
655
|
+
throw Exception::UnsatisfiedExtend(traces, unsatisfied);
|
656
|
+
}
|
657
|
+
|
681
658
|
// check nesting
|
682
659
|
check_nesting(root);
|
683
660
|
// merge and bubble certain rules
|
684
661
|
root = cssize(root);
|
685
|
-
// should we extend something?
|
686
|
-
if (!subset_map.empty()) {
|
687
|
-
// create crtp visitor object
|
688
|
-
Extend extend(subset_map);
|
689
|
-
extend.setEval(expand.eval);
|
690
|
-
// extend tree nodes
|
691
|
-
extend(root);
|
692
|
-
}
|
693
662
|
|
694
663
|
// clean up by removing empty placeholders
|
695
664
|
// ToDo: maybe we can do this somewhere else?
|
696
665
|
Remove_Placeholders remove_placeholders;
|
697
666
|
root->perform(&remove_placeholders);
|
667
|
+
|
698
668
|
// return processed tree
|
699
669
|
return root;
|
700
670
|
}
|
data/ext/libsass/src/context.hpp
CHANGED
@@ -1,27 +1,19 @@
|
|
1
1
|
#ifndef SASS_CONTEXT_H
|
2
2
|
#define SASS_CONTEXT_H
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
#include
|
4
|
+
// sass.hpp must go before all system headers to get the
|
5
|
+
// __EXTENSIONS__ fix on Solaris.
|
6
|
+
#include "sass.hpp"
|
7
|
+
#include "ast.hpp"
|
8
|
+
|
7
9
|
|
8
10
|
#define BUFFERSIZE 255
|
9
11
|
#include "b64/encode.h"
|
10
12
|
|
11
|
-
#include "ast_fwd_decl.hpp"
|
12
|
-
#include "kwd_arg_macros.hpp"
|
13
|
-
#include "ast_fwd_decl.hpp"
|
14
13
|
#include "sass_context.hpp"
|
15
|
-
#include "
|
16
|
-
#include "source_map.hpp"
|
17
|
-
#include "subset_map.hpp"
|
18
|
-
#include "backtrace.hpp"
|
19
|
-
#include "output.hpp"
|
14
|
+
#include "stylesheet.hpp"
|
20
15
|
#include "plugins.hpp"
|
21
|
-
#include "
|
22
|
-
|
23
|
-
|
24
|
-
struct Sass_Function;
|
16
|
+
#include "output.hpp"
|
25
17
|
|
26
18
|
namespace Sass {
|
27
19
|
|
@@ -52,10 +44,10 @@ namespace Sass {
|
|
52
44
|
std::vector<char*> strings;
|
53
45
|
std::vector<Resource> resources;
|
54
46
|
std::map<const std::string, StyleSheet> sheets;
|
55
|
-
Subset_Map subset_map;
|
56
47
|
ImporterStack import_stack;
|
57
48
|
std::vector<Sass_Callee> callee_stack;
|
58
49
|
std::vector<Backtrace> traces;
|
50
|
+
Extender extender;
|
59
51
|
|
60
52
|
struct Sass_Compiler* c_compiler;
|
61
53
|
|
@@ -68,10 +60,6 @@ namespace Sass {
|
|
68
60
|
std::vector<std::string> plugin_paths; // relative paths to load plugins
|
69
61
|
std::vector<std::string> include_paths; // lookup paths for includes
|
70
62
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
63
|
void apply_custom_headers(Block_Obj root, const char* path, ParserState pstate);
|
76
64
|
|
77
65
|
std::vector<Sass_Importer_Entry> c_headers;
|
data/ext/libsass/src/cssize.cpp
CHANGED
@@ -12,8 +12,7 @@
|
|
12
12
|
namespace Sass {
|
13
13
|
|
14
14
|
Cssize::Cssize(Context& ctx)
|
15
|
-
:
|
16
|
-
traces(ctx.traces),
|
15
|
+
: traces(ctx.traces),
|
17
16
|
block_stack(BlockStack()),
|
18
17
|
p_stack(std::vector<Statement*>())
|
19
18
|
{ }
|
@@ -149,7 +148,7 @@ namespace Sass {
|
|
149
148
|
// this can return a string schema
|
150
149
|
// string schema is not a statement!
|
151
150
|
// r->block() is already a string schema
|
152
|
-
// and that is
|
151
|
+
// and that is coming from propset expand
|
153
152
|
Block* bb = operator()(r->block());
|
154
153
|
// this should protect us (at least a bit) from our mess
|
155
154
|
// fixing this properly is harder that it should be ...
|
@@ -215,20 +214,23 @@ namespace Sass {
|
|
215
214
|
return 0;
|
216
215
|
}
|
217
216
|
|
218
|
-
Statement* Cssize::operator()(
|
217
|
+
Statement* Cssize::operator()(CssMediaRule* m)
|
219
218
|
{
|
220
219
|
if (parent()->statement_type() == Statement::RULESET)
|
221
|
-
{
|
220
|
+
{
|
221
|
+
return bubble(m);
|
222
|
+
}
|
222
223
|
|
223
224
|
if (parent()->statement_type() == Statement::MEDIA)
|
224
|
-
{
|
225
|
+
{
|
226
|
+
return SASS_MEMORY_NEW(Bubble, m->pstate(), m);
|
227
|
+
}
|
225
228
|
|
226
229
|
p_stack.push_back(m);
|
227
230
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
operator()(m->block()));
|
231
|
+
CssMediaRuleObj mm = SASS_MEMORY_NEW(CssMediaRule, m->pstate(), m->block());
|
232
|
+
mm->concat(m->elements());
|
233
|
+
mm->block(operator()(m->block()));
|
232
234
|
mm->tabs(m->tabs());
|
233
235
|
|
234
236
|
p_stack.pop_back();
|
@@ -352,24 +354,24 @@ namespace Sass {
|
|
352
354
|
return bubble;
|
353
355
|
}
|
354
356
|
|
355
|
-
Statement* Cssize::bubble(
|
357
|
+
Statement* Cssize::bubble(CssMediaRule* m)
|
356
358
|
{
|
357
359
|
Ruleset_Obj parent = Cast<Ruleset>(SASS_MEMORY_COPY(this->parent()));
|
358
360
|
|
359
361
|
Block* bb = SASS_MEMORY_NEW(Block, parent->block()->pstate());
|
360
362
|
Ruleset* new_rule = SASS_MEMORY_NEW(Ruleset,
|
361
|
-
|
362
|
-
|
363
|
-
|
363
|
+
parent->pstate(),
|
364
|
+
parent->selector(),
|
365
|
+
bb);
|
364
366
|
new_rule->tabs(parent->tabs());
|
365
367
|
new_rule->block()->concat(m->block());
|
366
368
|
|
367
369
|
Block* wrapper_block = SASS_MEMORY_NEW(Block, m->block()->pstate());
|
368
370
|
wrapper_block->append(new_rule);
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
371
|
+
CssMediaRuleObj mm = SASS_MEMORY_NEW(CssMediaRule,
|
372
|
+
m->pstate(),
|
373
|
+
wrapper_block);
|
374
|
+
mm->concat(m->elements());
|
373
375
|
|
374
376
|
mm->tabs(m->tabs());
|
375
377
|
|
@@ -381,12 +383,12 @@ namespace Sass {
|
|
381
383
|
return Cast<Ruleset>(s) || s->bubbles();
|
382
384
|
}
|
383
385
|
|
384
|
-
Block* Cssize::flatten(Block* b)
|
386
|
+
Block* Cssize::flatten(const Block* b)
|
385
387
|
{
|
386
388
|
Block* result = SASS_MEMORY_NEW(Block, b->pstate(), 0, b->is_root());
|
387
389
|
for (size_t i = 0, L = b->length(); i < L; ++i) {
|
388
390
|
Statement* ss = b->at(i);
|
389
|
-
if (Block* bb = Cast<Block>(ss)) {
|
391
|
+
if (const Block* bb = Cast<Block>(ss)) {
|
390
392
|
Block_Obj bs = flatten(bb);
|
391
393
|
for (size_t j = 0, K = bs->length(); j < K; ++j) {
|
392
394
|
result->append(bs->at(j));
|
@@ -440,7 +442,7 @@ namespace Sass {
|
|
440
442
|
previous_parent->block()->concat(slice);
|
441
443
|
}
|
442
444
|
else {
|
443
|
-
previous_parent =
|
445
|
+
previous_parent = SASS_MEMORY_COPY(parent);
|
444
446
|
previous_parent->block(slice);
|
445
447
|
previous_parent->tabs(parent->tabs());
|
446
448
|
|
@@ -451,36 +453,24 @@ namespace Sass {
|
|
451
453
|
|
452
454
|
for (size_t j = 0, K = slice->length(); j < K; ++j)
|
453
455
|
{
|
454
|
-
|
456
|
+
Statement_Obj ss;
|
455
457
|
Statement_Obj stm = slice->at(j);
|
456
458
|
// this has to go now here (too bad)
|
457
459
|
Bubble_Obj node = Cast<Bubble>(stm);
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
if (
|
462
|
-
if (
|
463
|
-
|
464
|
-
node->node()->statement_type() != Statement::MEDIA ||
|
465
|
-
(m1 && m2 && *m1->media_queries() == *m2->media_queries())
|
466
|
-
)
|
467
|
-
{
|
468
|
-
ss = node->node();
|
469
|
-
}
|
470
|
-
else
|
471
|
-
{
|
472
|
-
List_Obj mq = merge_media_queries(
|
473
|
-
Cast<Media_Block>(node->node()),
|
474
|
-
Cast<Media_Block>(parent)
|
475
|
-
);
|
476
|
-
if (!mq->length()) continue;
|
477
|
-
if (Media_Block* b = Cast<Media_Block>(node->node())) {
|
478
|
-
b->media_queries(mq);
|
479
|
-
}
|
460
|
+
|
461
|
+
CssMediaRule* rule1 = NULL;
|
462
|
+
CssMediaRule* rule2 = NULL;
|
463
|
+
if (parent) rule1 = Cast<CssMediaRule>(parent);
|
464
|
+
if (node) rule2 = Cast<CssMediaRule>(node->node());
|
465
|
+
if (rule1 || rule2) {
|
480
466
|
ss = node->node();
|
481
467
|
}
|
482
468
|
|
483
|
-
|
469
|
+
ss = node->node();
|
470
|
+
|
471
|
+
if (!ss) {
|
472
|
+
continue;
|
473
|
+
}
|
484
474
|
|
485
475
|
ss->tabs(ss->tabs() + node->tabs());
|
486
476
|
ss->group_end(node->group_end());
|
@@ -516,7 +506,7 @@ namespace Sass {
|
|
516
506
|
{
|
517
507
|
for (size_t i = 0, L = b->length(); i < L; ++i) {
|
518
508
|
Statement_Obj ith = b->at(i)->perform(this);
|
519
|
-
if (
|
509
|
+
if (Block_Obj bb = Cast<Block>(ith)) {
|
520
510
|
for (size_t j = 0, K = bb->length(); j < K; ++j) {
|
521
511
|
cur->append(bb->at(j));
|
522
512
|
}
|
@@ -527,78 +517,4 @@ namespace Sass {
|
|
527
517
|
}
|
528
518
|
}
|
529
519
|
|
530
|
-
List* Cssize::merge_media_queries(Media_Block* m1, Media_Block* m2)
|
531
|
-
{
|
532
|
-
List* qq = SASS_MEMORY_NEW(List,
|
533
|
-
m1->media_queries()->pstate(),
|
534
|
-
m1->media_queries()->length(),
|
535
|
-
SASS_COMMA);
|
536
|
-
|
537
|
-
for (size_t i = 0, L = m1->media_queries()->length(); i < L; i++) {
|
538
|
-
for (size_t j = 0, K = m2->media_queries()->length(); j < K; j++) {
|
539
|
-
Expression_Obj l1 = m1->media_queries()->at(i);
|
540
|
-
Expression_Obj l2 = m2->media_queries()->at(j);
|
541
|
-
Media_Query* mq1 = Cast<Media_Query>(l1);
|
542
|
-
Media_Query* mq2 = Cast<Media_Query>(l2);
|
543
|
-
Media_Query* mq = merge_media_query(mq1, mq2);
|
544
|
-
if (mq) qq->append(mq);
|
545
|
-
}
|
546
|
-
}
|
547
|
-
|
548
|
-
return qq;
|
549
|
-
}
|
550
|
-
|
551
|
-
|
552
|
-
Media_Query* Cssize::merge_media_query(Media_Query* mq1, Media_Query* mq2)
|
553
|
-
{
|
554
|
-
|
555
|
-
std::string type;
|
556
|
-
std::string mod;
|
557
|
-
|
558
|
-
std::string m1 = std::string(mq1->is_restricted() ? "only" : mq1->is_negated() ? "not" : "");
|
559
|
-
std::string t1 = mq1->media_type() ? mq1->media_type()->to_string(ctx.c_options) : "";
|
560
|
-
std::string m2 = std::string(mq2->is_restricted() ? "only" : mq2->is_negated() ? "not" : "");
|
561
|
-
std::string t2 = mq2->media_type() ? mq2->media_type()->to_string(ctx.c_options) : "";
|
562
|
-
|
563
|
-
|
564
|
-
if (t1.empty()) t1 = t2;
|
565
|
-
if (t2.empty()) t2 = t1;
|
566
|
-
|
567
|
-
if ((m1 == "not") ^ (m2 == "not")) {
|
568
|
-
if (t1 == t2) {
|
569
|
-
return 0;
|
570
|
-
}
|
571
|
-
type = m1 == "not" ? t2 : t1;
|
572
|
-
mod = m1 == "not" ? m2 : m1;
|
573
|
-
}
|
574
|
-
else if (m1 == "not" && m2 == "not") {
|
575
|
-
if (t1 != t2) {
|
576
|
-
return 0;
|
577
|
-
}
|
578
|
-
type = t1;
|
579
|
-
mod = "not";
|
580
|
-
}
|
581
|
-
else if (t1 != t2) {
|
582
|
-
return 0;
|
583
|
-
} else {
|
584
|
-
type = t1;
|
585
|
-
mod = m1.empty() ? m2 : m1;
|
586
|
-
}
|
587
|
-
|
588
|
-
Media_Query* mm = SASS_MEMORY_NEW(Media_Query,
|
589
|
-
mq1->pstate(),
|
590
|
-
{},
|
591
|
-
mq1->length() + mq2->length(),
|
592
|
-
mod == "not",
|
593
|
-
mod == "only");
|
594
|
-
|
595
|
-
if (!type.empty()) {
|
596
|
-
mm->media_type(SASS_MEMORY_NEW(String_Quoted, mq1->pstate(), type));
|
597
|
-
}
|
598
|
-
|
599
|
-
mm->concat(mq2);
|
600
|
-
mm->concat(mq1);
|
601
|
-
|
602
|
-
return mm;
|
603
|
-
}
|
604
520
|
}
|