sass 3.1.0 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CONTRIBUTING +1 -1
- data/MIT-LICENSE +2 -2
- data/README.md +29 -17
- data/Rakefile +43 -9
- data/VERSION +1 -1
- data/VERSION_DATE +1 -0
- data/VERSION_NAME +1 -1
- data/bin/sass +6 -1
- data/bin/sass-convert +6 -1
- data/bin/scss +6 -1
- data/ext/mkrf_conf.rb +27 -0
- data/lib/sass/cache_stores/base.rb +7 -3
- data/lib/sass/cache_stores/chain.rb +3 -2
- data/lib/sass/cache_stores/filesystem.rb +5 -7
- data/lib/sass/cache_stores/memory.rb +1 -1
- data/lib/sass/cache_stores/null.rb +2 -2
- data/lib/sass/callbacks.rb +2 -1
- data/lib/sass/css.rb +168 -53
- data/lib/sass/engine.rb +502 -174
- data/lib/sass/environment.rb +151 -111
- data/lib/sass/error.rb +7 -7
- data/lib/sass/exec.rb +176 -60
- data/lib/sass/features.rb +40 -0
- data/lib/sass/importers/base.rb +46 -7
- data/lib/sass/importers/deprecated_path.rb +51 -0
- data/lib/sass/importers/filesystem.rb +113 -30
- data/lib/sass/importers.rb +1 -0
- data/lib/sass/logger/base.rb +30 -0
- data/lib/sass/logger/log_level.rb +45 -0
- data/lib/sass/logger.rb +12 -0
- data/lib/sass/media.rb +213 -0
- data/lib/sass/plugin/compiler.rb +194 -104
- data/lib/sass/plugin/configuration.rb +18 -25
- data/lib/sass/plugin/merb.rb +1 -1
- data/lib/sass/plugin/staleness_checker.rb +37 -11
- data/lib/sass/plugin.rb +10 -13
- data/lib/sass/railtie.rb +2 -1
- data/lib/sass/repl.rb +5 -6
- data/lib/sass/script/css_lexer.rb +8 -4
- data/lib/sass/script/css_parser.rb +5 -2
- data/lib/sass/script/functions.rb +1547 -618
- data/lib/sass/script/lexer.rb +122 -72
- data/lib/sass/script/parser.rb +304 -135
- data/lib/sass/script/tree/funcall.rb +306 -0
- data/lib/sass/script/{interpolation.rb → tree/interpolation.rb} +43 -13
- data/lib/sass/script/tree/list_literal.rb +77 -0
- data/lib/sass/script/tree/literal.rb +45 -0
- data/lib/sass/script/tree/map_literal.rb +64 -0
- data/lib/sass/script/{node.rb → tree/node.rb} +30 -12
- data/lib/sass/script/{operation.rb → tree/operation.rb} +33 -21
- data/lib/sass/script/{string_interpolation.rb → tree/string_interpolation.rb} +14 -4
- data/lib/sass/script/{unary_operation.rb → tree/unary_operation.rb} +21 -9
- data/lib/sass/script/tree/variable.rb +57 -0
- data/lib/sass/script/tree.rb +15 -0
- data/lib/sass/script/value/arg_list.rb +36 -0
- data/lib/sass/script/value/base.rb +238 -0
- data/lib/sass/script/value/bool.rb +40 -0
- data/lib/sass/script/{color.rb → value/color.rb} +256 -74
- data/lib/sass/script/value/deprecated_false.rb +55 -0
- data/lib/sass/script/value/helpers.rb +155 -0
- data/lib/sass/script/value/list.rb +128 -0
- data/lib/sass/script/value/map.rb +70 -0
- data/lib/sass/script/value/null.rb +49 -0
- data/lib/sass/script/{number.rb → value/number.rb} +115 -62
- data/lib/sass/script/{string.rb → value/string.rb} +9 -11
- data/lib/sass/script/value.rb +12 -0
- data/lib/sass/script.rb +35 -9
- data/lib/sass/scss/css_parser.rb +2 -12
- data/lib/sass/scss/parser.rb +657 -230
- data/lib/sass/scss/rx.rb +17 -12
- data/lib/sass/scss/static_parser.rb +37 -6
- data/lib/sass/scss.rb +0 -1
- data/lib/sass/selector/abstract_sequence.rb +35 -3
- data/lib/sass/selector/comma_sequence.rb +29 -14
- data/lib/sass/selector/sequence.rb +371 -74
- data/lib/sass/selector/simple.rb +28 -13
- data/lib/sass/selector/simple_sequence.rb +163 -36
- data/lib/sass/selector.rb +138 -36
- data/lib/sass/shared.rb +3 -5
- data/lib/sass/source/map.rb +196 -0
- data/lib/sass/source/position.rb +39 -0
- data/lib/sass/source/range.rb +41 -0
- data/lib/sass/stack.rb +126 -0
- data/lib/sass/supports.rb +228 -0
- data/lib/sass/tree/at_root_node.rb +82 -0
- data/lib/sass/tree/comment_node.rb +34 -29
- data/lib/sass/tree/content_node.rb +9 -0
- data/lib/sass/tree/css_import_node.rb +60 -0
- data/lib/sass/tree/debug_node.rb +3 -3
- data/lib/sass/tree/directive_node.rb +33 -3
- data/lib/sass/tree/each_node.rb +9 -9
- data/lib/sass/tree/extend_node.rb +20 -6
- data/lib/sass/tree/for_node.rb +6 -6
- data/lib/sass/tree/function_node.rb +12 -4
- data/lib/sass/tree/if_node.rb +2 -15
- data/lib/sass/tree/import_node.rb +11 -5
- data/lib/sass/tree/media_node.rb +27 -11
- data/lib/sass/tree/mixin_def_node.rb +15 -4
- data/lib/sass/tree/mixin_node.rb +27 -7
- data/lib/sass/tree/node.rb +69 -35
- data/lib/sass/tree/prop_node.rb +47 -31
- data/lib/sass/tree/return_node.rb +4 -3
- data/lib/sass/tree/root_node.rb +20 -4
- data/lib/sass/tree/rule_node.rb +37 -26
- data/lib/sass/tree/supports_node.rb +38 -0
- data/lib/sass/tree/trace_node.rb +33 -0
- data/lib/sass/tree/variable_node.rb +10 -4
- data/lib/sass/tree/visitors/base.rb +5 -8
- data/lib/sass/tree/visitors/check_nesting.rb +67 -52
- data/lib/sass/tree/visitors/convert.rb +134 -53
- data/lib/sass/tree/visitors/cssize.rb +245 -51
- data/lib/sass/tree/visitors/deep_copy.rb +102 -0
- data/lib/sass/tree/visitors/extend.rb +68 -0
- data/lib/sass/tree/visitors/perform.rb +331 -105
- data/lib/sass/tree/visitors/set_options.rb +125 -0
- data/lib/sass/tree/visitors/to_css.rb +259 -95
- data/lib/sass/tree/warn_node.rb +3 -3
- data/lib/sass/tree/while_node.rb +3 -3
- data/lib/sass/util/cross_platform_random.rb +19 -0
- data/lib/sass/util/multibyte_string_scanner.rb +157 -0
- data/lib/sass/util/normalized_map.rb +130 -0
- data/lib/sass/util/ordered_hash.rb +192 -0
- data/lib/sass/util/subset_map.rb +11 -2
- data/lib/sass/util/test.rb +9 -0
- data/lib/sass/util.rb +565 -39
- data/lib/sass/version.rb +27 -15
- data/lib/sass.rb +39 -4
- data/test/sass/cache_test.rb +15 -0
- data/test/sass/compiler_test.rb +223 -0
- data/test/sass/conversion_test.rb +901 -107
- data/test/sass/css2sass_test.rb +94 -0
- data/test/sass/engine_test.rb +1059 -164
- data/test/sass/exec_test.rb +86 -0
- data/test/sass/extend_test.rb +933 -837
- data/test/sass/fixtures/test_staleness_check_across_importers.css +1 -0
- data/test/sass/fixtures/test_staleness_check_across_importers.scss +1 -0
- data/test/sass/functions_test.rb +995 -136
- data/test/sass/importer_test.rb +338 -18
- data/test/sass/logger_test.rb +58 -0
- data/test/sass/more_results/more_import.css +2 -2
- data/test/sass/plugin_test.rb +114 -30
- data/test/sass/results/cached_import_option.css +3 -0
- data/test/sass/results/filename_fn.css +3 -0
- data/test/sass/results/import.css +2 -2
- data/test/sass/results/import_charset.css +1 -0
- data/test/sass/results/import_charset_1_8.css +1 -0
- data/test/sass/results/import_charset_ibm866.css +1 -0
- data/test/sass/results/import_content.css +1 -0
- data/test/sass/results/script.css +1 -1
- data/test/sass/results/scss_import.css +2 -2
- data/test/sass/results/units.css +2 -2
- data/test/sass/script_conversion_test.rb +43 -1
- data/test/sass/script_test.rb +380 -36
- data/test/sass/scss/css_test.rb +257 -75
- data/test/sass/scss/scss_test.rb +2322 -110
- data/test/sass/source_map_test.rb +887 -0
- data/test/sass/templates/_cached_import_option_partial.scss +1 -0
- data/test/sass/templates/_double_import_loop2.sass +1 -0
- data/test/sass/templates/_filename_fn_import.scss +11 -0
- data/test/sass/templates/_imported_content.sass +3 -0
- data/test/sass/templates/_same_name_different_partiality.scss +1 -0
- data/test/sass/templates/bork5.sass +3 -0
- data/test/sass/templates/cached_import_option.scss +3 -0
- data/test/sass/templates/double_import_loop1.sass +1 -0
- data/test/sass/templates/filename_fn.scss +18 -0
- data/test/sass/templates/import_charset.sass +2 -0
- data/test/sass/templates/import_charset_1_8.sass +2 -0
- data/test/sass/templates/import_charset_ibm866.sass +2 -0
- data/test/sass/templates/import_content.sass +4 -0
- data/test/sass/templates/same_name_different_ext.sass +2 -0
- data/test/sass/templates/same_name_different_ext.scss +1 -0
- data/test/sass/templates/same_name_different_partiality.scss +1 -0
- data/test/sass/templates/single_import_loop.sass +1 -0
- data/test/sass/templates/subdir/import_up1.scss +1 -0
- data/test/sass/templates/subdir/import_up2.scss +1 -0
- data/test/sass/test_helper.rb +1 -1
- data/test/sass/util/multibyte_string_scanner_test.rb +147 -0
- data/test/sass/util/normalized_map_test.rb +51 -0
- data/test/sass/util_test.rb +183 -0
- data/test/sass/value_helpers_test.rb +181 -0
- data/test/test_helper.rb +45 -5
- data/vendor/listen/CHANGELOG.md +228 -0
- data/vendor/listen/CONTRIBUTING.md +38 -0
- data/vendor/listen/Gemfile +30 -0
- data/vendor/listen/Guardfile +8 -0
- data/vendor/{fssm → listen}/LICENSE +1 -1
- data/vendor/listen/README.md +315 -0
- data/vendor/listen/Rakefile +47 -0
- data/vendor/listen/Vagrantfile +96 -0
- data/vendor/listen/lib/listen/adapter.rb +214 -0
- data/vendor/listen/lib/listen/adapters/bsd.rb +112 -0
- data/vendor/listen/lib/listen/adapters/darwin.rb +85 -0
- data/vendor/listen/lib/listen/adapters/linux.rb +113 -0
- data/vendor/listen/lib/listen/adapters/polling.rb +67 -0
- data/vendor/listen/lib/listen/adapters/windows.rb +87 -0
- data/vendor/listen/lib/listen/dependency_manager.rb +126 -0
- data/vendor/listen/lib/listen/directory_record.rb +371 -0
- data/vendor/listen/lib/listen/listener.rb +225 -0
- data/vendor/listen/lib/listen/multi_listener.rb +143 -0
- data/vendor/listen/lib/listen/turnstile.rb +28 -0
- data/vendor/listen/lib/listen/version.rb +3 -0
- data/vendor/listen/lib/listen.rb +40 -0
- data/vendor/listen/listen.gemspec +22 -0
- data/vendor/listen/spec/listen/adapter_spec.rb +183 -0
- data/vendor/listen/spec/listen/adapters/bsd_spec.rb +36 -0
- data/vendor/listen/spec/listen/adapters/darwin_spec.rb +37 -0
- data/vendor/listen/spec/listen/adapters/linux_spec.rb +47 -0
- data/vendor/listen/spec/listen/adapters/polling_spec.rb +68 -0
- data/vendor/listen/spec/listen/adapters/windows_spec.rb +30 -0
- data/vendor/listen/spec/listen/dependency_manager_spec.rb +107 -0
- data/vendor/listen/spec/listen/directory_record_spec.rb +1225 -0
- data/vendor/listen/spec/listen/listener_spec.rb +169 -0
- data/vendor/listen/spec/listen/multi_listener_spec.rb +174 -0
- data/vendor/listen/spec/listen/turnstile_spec.rb +56 -0
- data/vendor/listen/spec/listen_spec.rb +73 -0
- data/vendor/listen/spec/spec_helper.rb +21 -0
- data/vendor/listen/spec/support/adapter_helper.rb +629 -0
- data/vendor/listen/spec/support/directory_record_helper.rb +55 -0
- data/vendor/listen/spec/support/fixtures_helper.rb +29 -0
- data/vendor/listen/spec/support/listeners_helper.rb +156 -0
- data/vendor/listen/spec/support/platform_helper.rb +15 -0
- metadata +344 -271
- data/lib/sass/less.rb +0 -382
- data/lib/sass/script/bool.rb +0 -18
- data/lib/sass/script/funcall.rb +0 -162
- data/lib/sass/script/list.rb +0 -76
- data/lib/sass/script/literal.rb +0 -245
- data/lib/sass/script/variable.rb +0 -54
- data/lib/sass/scss/sass_parser.rb +0 -11
- data/test/sass/less_conversion_test.rb +0 -653
- data/vendor/fssm/README.markdown +0 -55
- data/vendor/fssm/Rakefile +0 -59
- data/vendor/fssm/VERSION.yml +0 -5
- data/vendor/fssm/example.rb +0 -9
- data/vendor/fssm/fssm.gemspec +0 -77
- data/vendor/fssm/lib/fssm/backends/fsevents.rb +0 -36
- data/vendor/fssm/lib/fssm/backends/inotify.rb +0 -26
- data/vendor/fssm/lib/fssm/backends/polling.rb +0 -25
- data/vendor/fssm/lib/fssm/backends/rubycocoa/fsevents.rb +0 -131
- data/vendor/fssm/lib/fssm/monitor.rb +0 -26
- data/vendor/fssm/lib/fssm/path.rb +0 -91
- data/vendor/fssm/lib/fssm/pathname.rb +0 -502
- data/vendor/fssm/lib/fssm/state/directory.rb +0 -57
- data/vendor/fssm/lib/fssm/state/file.rb +0 -24
- data/vendor/fssm/lib/fssm/support.rb +0 -63
- data/vendor/fssm/lib/fssm/tree.rb +0 -176
- data/vendor/fssm/lib/fssm.rb +0 -33
- data/vendor/fssm/profile/prof-cache.rb +0 -40
- data/vendor/fssm/profile/prof-fssm-pathname.html +0 -1231
- data/vendor/fssm/profile/prof-pathname.rb +0 -68
- data/vendor/fssm/profile/prof-plain-pathname.html +0 -988
- data/vendor/fssm/profile/prof.html +0 -2379
- data/vendor/fssm/spec/path_spec.rb +0 -75
- data/vendor/fssm/spec/root/duck/quack.txt +0 -0
- data/vendor/fssm/spec/root/file.css +0 -0
- data/vendor/fssm/spec/root/file.rb +0 -0
- data/vendor/fssm/spec/root/file.yml +0 -0
- data/vendor/fssm/spec/root/moo/cow.txt +0 -0
- data/vendor/fssm/spec/spec_helper.rb +0 -14
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module Sass::Script
|
1
|
+
module Sass::Script::Value
|
4
2
|
# A SassScript object representing a CSS color.
|
5
3
|
#
|
6
4
|
# A color may be represented internally as RGBA, HSLA, or both.
|
@@ -15,34 +13,183 @@ module Sass::Script
|
|
15
13
|
# It's always stored, as 1 if nothing else is specified.
|
16
14
|
# If only the alpha channel is modified using \{#with},
|
17
15
|
# the cached RGB and HSL values are retained.
|
18
|
-
class Color <
|
19
|
-
|
16
|
+
class Color < Base
|
17
|
+
# @private
|
18
|
+
#
|
19
|
+
# Convert a ruby integer to a rgba components
|
20
|
+
# @param color [Fixnum]
|
21
|
+
# @return [Array<Fixnum>] Array of 4 numbers representing r,g,b and alpha
|
22
|
+
def self.int_to_rgba(color)
|
23
|
+
rgba = (0..3).map {|n| color >> (n << 3) & 0xff}.reverse
|
24
|
+
rgba[-1] = rgba[-1] / 255.0
|
25
|
+
rgba
|
26
|
+
end
|
27
|
+
|
28
|
+
ALTERNATE_COLOR_NAMES = Sass::Util.map_vals({
|
29
|
+
'aqua' => 0x00FFFFFF,
|
30
|
+
'darkgrey' => 0xA9A9A9FF,
|
31
|
+
'darkslategrey' => 0x2F4F4FFF,
|
32
|
+
'dimgrey' => 0x696969FF,
|
33
|
+
'fuchsia' => 0xFF00FFFF,
|
34
|
+
'grey' => 0x808080FF,
|
35
|
+
'lightgrey' => 0xD3D3D3FF,
|
36
|
+
'lightslategrey' => 0x778899FF,
|
37
|
+
'slategrey' => 0x708090FF,
|
38
|
+
}, &method(:int_to_rgba))
|
20
39
|
|
21
40
|
# A hash from color names to `[red, green, blue]` value arrays.
|
22
|
-
|
23
|
-
'
|
24
|
-
'
|
25
|
-
'
|
26
|
-
'
|
27
|
-
'
|
28
|
-
'
|
29
|
-
'
|
30
|
-
'
|
31
|
-
'
|
32
|
-
'
|
33
|
-
'
|
34
|
-
'
|
35
|
-
'
|
36
|
-
'
|
37
|
-
'
|
38
|
-
'
|
39
|
-
|
40
|
-
|
41
|
-
|
41
|
+
COLOR_NAMES = Sass::Util.map_vals({
|
42
|
+
'aliceblue' => 0xF0F8FFFF,
|
43
|
+
'antiquewhite' => 0xFAEBD7FF,
|
44
|
+
'aquamarine' => 0x7FFFD4FF,
|
45
|
+
'azure' => 0xF0FFFFFF,
|
46
|
+
'beige' => 0xF5F5DCFF,
|
47
|
+
'bisque' => 0xFFE4C4FF,
|
48
|
+
'black' => 0x000000FF,
|
49
|
+
'blanchedalmond' => 0xFFEBCDFF,
|
50
|
+
'blue' => 0x0000FFFF,
|
51
|
+
'blueviolet' => 0x8A2BE2FF,
|
52
|
+
'brown' => 0xA52A2AFF,
|
53
|
+
'burlywood' => 0xDEB887FF,
|
54
|
+
'cadetblue' => 0x5F9EA0FF,
|
55
|
+
'chartreuse' => 0x7FFF00FF,
|
56
|
+
'chocolate' => 0xD2691EFF,
|
57
|
+
'coral' => 0xFF7F50FF,
|
58
|
+
'cornflowerblue' => 0x6495EDFF,
|
59
|
+
'cornsilk' => 0xFFF8DCFF,
|
60
|
+
'crimson' => 0xDC143CFF,
|
61
|
+
'cyan' => 0x00FFFFFF,
|
62
|
+
'darkblue' => 0x00008BFF,
|
63
|
+
'darkcyan' => 0x008B8BFF,
|
64
|
+
'darkgoldenrod' => 0xB8860BFF,
|
65
|
+
'darkgray' => 0xA9A9A9FF,
|
66
|
+
'darkgreen' => 0x006400FF,
|
67
|
+
'darkkhaki' => 0xBDB76BFF,
|
68
|
+
'darkmagenta' => 0x8B008BFF,
|
69
|
+
'darkolivegreen' => 0x556B2FFF,
|
70
|
+
'darkorange' => 0xFF8C00FF,
|
71
|
+
'darkorchid' => 0x9932CCFF,
|
72
|
+
'darkred' => 0x8B0000FF,
|
73
|
+
'darksalmon' => 0xE9967AFF,
|
74
|
+
'darkseagreen' => 0x8FBC8FFF,
|
75
|
+
'darkslateblue' => 0x483D8BFF,
|
76
|
+
'darkslategray' => 0x2F4F4FFF,
|
77
|
+
'darkturquoise' => 0x00CED1FF,
|
78
|
+
'darkviolet' => 0x9400D3FF,
|
79
|
+
'deeppink' => 0xFF1493FF,
|
80
|
+
'deepskyblue' => 0x00BFFFFF,
|
81
|
+
'dimgray' => 0x696969FF,
|
82
|
+
'dodgerblue' => 0x1E90FFFF,
|
83
|
+
'firebrick' => 0xB22222FF,
|
84
|
+
'floralwhite' => 0xFFFAF0FF,
|
85
|
+
'forestgreen' => 0x228B22FF,
|
86
|
+
'gainsboro' => 0xDCDCDCFF,
|
87
|
+
'ghostwhite' => 0xF8F8FFFF,
|
88
|
+
'gold' => 0xFFD700FF,
|
89
|
+
'goldenrod' => 0xDAA520FF,
|
90
|
+
'gray' => 0x808080FF,
|
91
|
+
'green' => 0x008000FF,
|
92
|
+
'greenyellow' => 0xADFF2FFF,
|
93
|
+
'honeydew' => 0xF0FFF0FF,
|
94
|
+
'hotpink' => 0xFF69B4FF,
|
95
|
+
'indianred' => 0xCD5C5CFF,
|
96
|
+
'indigo' => 0x4B0082FF,
|
97
|
+
'ivory' => 0xFFFFF0FF,
|
98
|
+
'khaki' => 0xF0E68CFF,
|
99
|
+
'lavender' => 0xE6E6FAFF,
|
100
|
+
'lavenderblush' => 0xFFF0F5FF,
|
101
|
+
'lawngreen' => 0x7CFC00FF,
|
102
|
+
'lemonchiffon' => 0xFFFACDFF,
|
103
|
+
'lightblue' => 0xADD8E6FF,
|
104
|
+
'lightcoral' => 0xF08080FF,
|
105
|
+
'lightcyan' => 0xE0FFFFFF,
|
106
|
+
'lightgoldenrodyellow' => 0xFAFAD2FF,
|
107
|
+
'lightgreen' => 0x90EE90FF,
|
108
|
+
'lightgray' => 0xD3D3D3FF,
|
109
|
+
'lightpink' => 0xFFB6C1FF,
|
110
|
+
'lightsalmon' => 0xFFA07AFF,
|
111
|
+
'lightseagreen' => 0x20B2AAFF,
|
112
|
+
'lightskyblue' => 0x87CEFAFF,
|
113
|
+
'lightslategray' => 0x778899FF,
|
114
|
+
'lightsteelblue' => 0xB0C4DEFF,
|
115
|
+
'lightyellow' => 0xFFFFE0FF,
|
116
|
+
'lime' => 0x00FF00FF,
|
117
|
+
'limegreen' => 0x32CD32FF,
|
118
|
+
'linen' => 0xFAF0E6FF,
|
119
|
+
'magenta' => 0xFF00FFFF,
|
120
|
+
'maroon' => 0x800000FF,
|
121
|
+
'mediumaquamarine' => 0x66CDAAFF,
|
122
|
+
'mediumblue' => 0x0000CDFF,
|
123
|
+
'mediumorchid' => 0xBA55D3FF,
|
124
|
+
'mediumpurple' => 0x9370DBFF,
|
125
|
+
'mediumseagreen' => 0x3CB371FF,
|
126
|
+
'mediumslateblue' => 0x7B68EEFF,
|
127
|
+
'mediumspringgreen' => 0x00FA9AFF,
|
128
|
+
'mediumturquoise' => 0x48D1CCFF,
|
129
|
+
'mediumvioletred' => 0xC71585FF,
|
130
|
+
'midnightblue' => 0x191970FF,
|
131
|
+
'mintcream' => 0xF5FFFAFF,
|
132
|
+
'mistyrose' => 0xFFE4E1FF,
|
133
|
+
'moccasin' => 0xFFE4B5FF,
|
134
|
+
'navajowhite' => 0xFFDEADFF,
|
135
|
+
'navy' => 0x000080FF,
|
136
|
+
'oldlace' => 0xFDF5E6FF,
|
137
|
+
'olive' => 0x808000FF,
|
138
|
+
'olivedrab' => 0x6B8E23FF,
|
139
|
+
'orange' => 0xFFA500FF,
|
140
|
+
'orangered' => 0xFF4500FF,
|
141
|
+
'orchid' => 0xDA70D6FF,
|
142
|
+
'palegoldenrod' => 0xEEE8AAFF,
|
143
|
+
'palegreen' => 0x98FB98FF,
|
144
|
+
'paleturquoise' => 0xAFEEEEFF,
|
145
|
+
'palevioletred' => 0xDB7093FF,
|
146
|
+
'papayawhip' => 0xFFEFD5FF,
|
147
|
+
'peachpuff' => 0xFFDAB9FF,
|
148
|
+
'peru' => 0xCD853FFF,
|
149
|
+
'pink' => 0xFFC0CBFF,
|
150
|
+
'plum' => 0xDDA0DDFF,
|
151
|
+
'powderblue' => 0xB0E0E6FF,
|
152
|
+
'purple' => 0x800080FF,
|
153
|
+
'red' => 0xFF0000FF,
|
154
|
+
'rosybrown' => 0xBC8F8FFF,
|
155
|
+
'royalblue' => 0x4169E1FF,
|
156
|
+
'saddlebrown' => 0x8B4513FF,
|
157
|
+
'salmon' => 0xFA8072FF,
|
158
|
+
'sandybrown' => 0xF4A460FF,
|
159
|
+
'seagreen' => 0x2E8B57FF,
|
160
|
+
'seashell' => 0xFFF5EEFF,
|
161
|
+
'sienna' => 0xA0522DFF,
|
162
|
+
'silver' => 0xC0C0C0FF,
|
163
|
+
'skyblue' => 0x87CEEBFF,
|
164
|
+
'slateblue' => 0x6A5ACDFF,
|
165
|
+
'slategray' => 0x708090FF,
|
166
|
+
'snow' => 0xFFFAFAFF,
|
167
|
+
'springgreen' => 0x00FF7FFF,
|
168
|
+
'steelblue' => 0x4682B4FF,
|
169
|
+
'tan' => 0xD2B48CFF,
|
170
|
+
'teal' => 0x008080FF,
|
171
|
+
'thistle' => 0xD8BFD8FF,
|
172
|
+
'tomato' => 0xFF6347FF,
|
173
|
+
'transparent' => 0x00000000,
|
174
|
+
'turquoise' => 0x40E0D0FF,
|
175
|
+
'violet' => 0xEE82EEFF,
|
176
|
+
'wheat' => 0xF5DEB3FF,
|
177
|
+
'white' => 0xFFFFFFFF,
|
178
|
+
'whitesmoke' => 0xF5F5F5FF,
|
179
|
+
'yellow' => 0xFFFF00FF,
|
180
|
+
'yellowgreen' => 0x9ACD32FF
|
181
|
+
}, &method(:int_to_rgba))
|
182
|
+
|
183
|
+
# A hash from `[red, green, blue, alpha]` value arrays to color names.
|
184
|
+
COLOR_NAMES_REVERSE = COLOR_NAMES.invert.freeze
|
185
|
+
|
186
|
+
# We add the alternate color names after inverting because
|
187
|
+
# different ruby implementations and versions vary on the ordering of the result of invert.
|
188
|
+
COLOR_NAMES.update(ALTERNATE_COLOR_NAMES).freeze
|
42
189
|
|
43
190
|
# Constructs an RGB or HSL color object,
|
44
191
|
# optionally with an alpha channel.
|
45
|
-
#
|
192
|
+
#
|
46
193
|
# The RGB values must be between 0 and 255.
|
47
194
|
# The saturation and lightness values must be between 0 and 100.
|
48
195
|
# The alpha value must be between 0 and 1.
|
@@ -101,21 +248,34 @@ module Sass::Script
|
|
101
248
|
[:red, :green, :blue].each do |k|
|
102
249
|
next if @attrs[k].nil?
|
103
250
|
@attrs[k] = @attrs[k].to_i
|
104
|
-
|
105
|
-
raise ArgumentError.new("#{k.to_s.capitalize} value must be between 0 and 255")
|
251
|
+
Sass::Util.check_range("#{k.to_s.capitalize} value", 0..255, @attrs[k])
|
106
252
|
end
|
107
253
|
|
108
254
|
[:saturation, :lightness].each do |k|
|
109
255
|
next if @attrs[k].nil?
|
110
|
-
|
111
|
-
@attrs[k] =
|
112
|
-
next if (0..100).include?(@attrs[k])
|
113
|
-
raise ArgumentError.new("#{k.to_s.capitalize} must be between 0 and 100")
|
256
|
+
value = Number.new(@attrs[k], ['%']) # Get correct unit for error messages
|
257
|
+
@attrs[k] = Sass::Util.check_range("#{k.to_s.capitalize}", 0..100, value, '%')
|
114
258
|
end
|
115
259
|
|
116
|
-
|
117
|
-
|
260
|
+
@attrs[:alpha] = Sass::Util.check_range("Alpha channel", 0..1, @attrs[:alpha])
|
261
|
+
end
|
262
|
+
|
263
|
+
# Create a new color from a valid CSS hex string.
|
264
|
+
#
|
265
|
+
# The leading hash is optional.
|
266
|
+
#
|
267
|
+
# @return [Color]
|
268
|
+
def self.from_hex(hex_string, alpha = nil)
|
269
|
+
unless hex_string =~ /^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i ||
|
270
|
+
hex_string =~ /^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i
|
271
|
+
raise ArgumentError.new("#{hex_string.inspect} is not a valid hex color.")
|
118
272
|
end
|
273
|
+
red = $1.ljust(2, $1).to_i(16)
|
274
|
+
green = $2.ljust(2, $2).to_i(16)
|
275
|
+
blue = $3.ljust(2, $3).to_i(16)
|
276
|
+
attrs = {:red => red, :green => green, :blue => blue}
|
277
|
+
attrs[:alpha] = alpha if alpha
|
278
|
+
new(attrs)
|
119
279
|
end
|
120
280
|
|
121
281
|
# The red component of the color.
|
@@ -171,7 +331,7 @@ module Sass::Script
|
|
171
331
|
#
|
172
332
|
# @return [Fixnum]
|
173
333
|
def alpha
|
174
|
-
@attrs[:alpha]
|
334
|
+
@attrs[:alpha].to_f
|
175
335
|
end
|
176
336
|
|
177
337
|
# Returns whether this color object is translucent;
|
@@ -190,6 +350,14 @@ module Sass::Script
|
|
190
350
|
[red, green, blue].freeze
|
191
351
|
end
|
192
352
|
|
353
|
+
# Returns the red, green, blue, and alpha components of the color.
|
354
|
+
#
|
355
|
+
# @return [Array<Fixnum>] A frozen four-element array of the red, green,
|
356
|
+
# blue, and alpha values (respectively) of the color
|
357
|
+
def rgba
|
358
|
+
[red, green, blue, alpha].freeze
|
359
|
+
end
|
360
|
+
|
193
361
|
# Returns the hue, saturation, and lightness components of the color.
|
194
362
|
#
|
195
363
|
# @return [Array<Fixnum>] A frozen three-element array of the
|
@@ -198,18 +366,30 @@ module Sass::Script
|
|
198
366
|
[hue, saturation, lightness].freeze
|
199
367
|
end
|
200
368
|
|
369
|
+
# Returns the hue, saturation, lightness, and alpha components of the color.
|
370
|
+
#
|
371
|
+
# @return [Array<Fixnum>] A frozen four-element array of the hue,
|
372
|
+
# saturation, lightness, and alpha values (respectively) of the color
|
373
|
+
def hsla
|
374
|
+
[hue, saturation, lightness].freeze
|
375
|
+
end
|
376
|
+
|
201
377
|
# The SassScript `==` operation.
|
202
|
-
# **Note that this returns a {Sass::Script::Bool} object,
|
378
|
+
# **Note that this returns a {Sass::Script::Value::Bool} object,
|
203
379
|
# not a Ruby boolean**.
|
204
380
|
#
|
205
|
-
# @param other [
|
206
|
-
# @return [Bool] True if this
|
381
|
+
# @param other [Value] The right-hand side of the operator
|
382
|
+
# @return [Bool] True if this value is the same as the other,
|
207
383
|
# false otherwise
|
208
384
|
def eq(other)
|
209
|
-
Sass::Script::Bool.new(
|
385
|
+
Sass::Script::Value::Bool.new(
|
210
386
|
other.is_a?(Color) && rgb == other.rgb && alpha == other.alpha)
|
211
387
|
end
|
212
388
|
|
389
|
+
def hash
|
390
|
+
[rgb, alpha].hash
|
391
|
+
end
|
392
|
+
|
213
393
|
# Returns a copy of this color with one or more channels changed.
|
214
394
|
# RGB or HSL colors may be changed, but not both at once.
|
215
395
|
#
|
@@ -260,14 +440,14 @@ module Sass::Script
|
|
260
440
|
# {Color}
|
261
441
|
# : Adds each of the RGB color channels together.
|
262
442
|
#
|
263
|
-
# {
|
264
|
-
# : See {
|
443
|
+
# {Value}
|
444
|
+
# : See {Value::Base#plus}.
|
265
445
|
#
|
266
|
-
# @param other [
|
446
|
+
# @param other [Value] The right-hand side of the operator
|
267
447
|
# @return [Color] The resulting color
|
268
448
|
# @raise [Sass::SyntaxError] if `other` is a number with units
|
269
449
|
def plus(other)
|
270
|
-
if other.is_a?(Sass::Script::Number) || other.is_a?(Sass::Script::Color)
|
450
|
+
if other.is_a?(Sass::Script::Value::Number) || other.is_a?(Sass::Script::Value::Color)
|
271
451
|
piecewise(other, :+)
|
272
452
|
else
|
273
453
|
super
|
@@ -283,14 +463,14 @@ module Sass::Script
|
|
283
463
|
# {Color}
|
284
464
|
# : Subtracts each of the other color's RGB color channels from this color's.
|
285
465
|
#
|
286
|
-
# {
|
287
|
-
# : See {
|
466
|
+
# {Value}
|
467
|
+
# : See {Value::Base#minus}.
|
288
468
|
#
|
289
|
-
# @param other [
|
469
|
+
# @param other [Value] The right-hand side of the operator
|
290
470
|
# @return [Color] The resulting color
|
291
471
|
# @raise [Sass::SyntaxError] if `other` is a number with units
|
292
472
|
def minus(other)
|
293
|
-
if other.is_a?(Sass::Script::Number) || other.is_a?(Sass::Script::Color)
|
473
|
+
if other.is_a?(Sass::Script::Value::Number) || other.is_a?(Sass::Script::Value::Color)
|
294
474
|
piecewise(other, :-)
|
295
475
|
else
|
296
476
|
super
|
@@ -310,7 +490,7 @@ module Sass::Script
|
|
310
490
|
# @return [Color] The resulting color
|
311
491
|
# @raise [Sass::SyntaxError] if `other` is a number with units
|
312
492
|
def times(other)
|
313
|
-
if other.is_a?(Sass::Script::Number) || other.is_a?(Sass::Script::Color)
|
493
|
+
if other.is_a?(Sass::Script::Value::Number) || other.is_a?(Sass::Script::Value::Color)
|
314
494
|
piecewise(other, :*)
|
315
495
|
else
|
316
496
|
raise NoMethodError.new(nil, :times)
|
@@ -326,14 +506,15 @@ module Sass::Script
|
|
326
506
|
# {Color}
|
327
507
|
# : Divides each of this color's RGB color channels by the other color's.
|
328
508
|
#
|
329
|
-
# {
|
330
|
-
# : See {
|
509
|
+
# {Value}
|
510
|
+
# : See {Value::Base#div}.
|
331
511
|
#
|
332
|
-
# @param other [
|
512
|
+
# @param other [Value] The right-hand side of the operator
|
333
513
|
# @return [Color] The resulting color
|
334
514
|
# @raise [Sass::SyntaxError] if `other` is a number with units
|
335
515
|
def div(other)
|
336
|
-
if other.is_a?(Sass::Script::Number) ||
|
516
|
+
if other.is_a?(Sass::Script::Value::Number) ||
|
517
|
+
other.is_a?(Sass::Script::Value::Color)
|
337
518
|
piecewise(other, :/)
|
338
519
|
else
|
339
520
|
super
|
@@ -353,7 +534,8 @@ module Sass::Script
|
|
353
534
|
# @return [Color] The resulting color
|
354
535
|
# @raise [Sass::SyntaxError] if `other` is a number with units
|
355
536
|
def mod(other)
|
356
|
-
if other.is_a?(Sass::Script::Number) ||
|
537
|
+
if other.is_a?(Sass::Script::Value::Number) ||
|
538
|
+
other.is_a?(Sass::Script::Value::Color)
|
357
539
|
piecewise(other, :%)
|
358
540
|
else
|
359
541
|
raise NoMethodError.new(nil, :mod)
|
@@ -366,10 +548,9 @@ module Sass::Script
|
|
366
548
|
#
|
367
549
|
# @return [String] The string representation
|
368
550
|
def to_s(opts = {})
|
369
|
-
return rgba_str if alpha?
|
370
551
|
return smallest if options[:style] == :compressed
|
371
|
-
return
|
372
|
-
hex_str
|
552
|
+
return COLOR_NAMES_REVERSE[rgba] if COLOR_NAMES_REVERSE[rgba]
|
553
|
+
alpha? ? rgba_str : hex_str
|
373
554
|
end
|
374
555
|
alias_method :to_sass, :to_s
|
375
556
|
|
@@ -383,10 +564,10 @@ module Sass::Script
|
|
383
564
|
private
|
384
565
|
|
385
566
|
def smallest
|
386
|
-
|
387
|
-
return
|
388
|
-
color.size <=
|
389
|
-
|
567
|
+
small_explicit_str = alpha? ? rgba_str : hex_str.gsub(/^#(.)\1(.)\2(.)\3$/, '#\1\2\3')
|
568
|
+
return small_explicit_str unless (color = COLOR_NAMES_REVERSE[rgba]) &&
|
569
|
+
color.size <= small_explicit_str.size
|
570
|
+
color
|
390
571
|
end
|
391
572
|
|
392
573
|
def rgba_str
|
@@ -395,20 +576,21 @@ module Sass::Script
|
|
395
576
|
end
|
396
577
|
|
397
578
|
def hex_str
|
398
|
-
red, green, blue = rgb.map {
|
579
|
+
red, green, blue = rgb.map {|num| num.to_s(16).rjust(2, '0')}
|
399
580
|
"##{red}#{green}#{blue}"
|
400
581
|
end
|
401
582
|
|
402
583
|
def piecewise(other, operation)
|
403
584
|
other_num = other.is_a? Number
|
404
585
|
if other_num && !other.unitless?
|
405
|
-
raise Sass::SyntaxError.new(
|
586
|
+
raise Sass::SyntaxError.new(
|
587
|
+
"Cannot add a number with units (#{other}) to a color (#{self}).")
|
406
588
|
end
|
407
589
|
|
408
590
|
result = []
|
409
|
-
|
591
|
+
(0...3).each do |i|
|
410
592
|
res = rgb[i].send(operation, other_num ? other.value : other.rgb[i])
|
411
|
-
result[i] = [
|
593
|
+
result[i] = [[res, 255].min, 0].max
|
412
594
|
end
|
413
595
|
|
414
596
|
if !other_num && other.alpha != alpha
|
@@ -429,9 +611,9 @@ module Sass::Script
|
|
429
611
|
m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s
|
430
612
|
m1 = l * 2 - m2
|
431
613
|
@attrs[:red], @attrs[:green], @attrs[:blue] = [
|
432
|
-
hue_to_rgb(m1, m2, h + 1.0/3),
|
614
|
+
hue_to_rgb(m1, m2, h + 1.0 / 3),
|
433
615
|
hue_to_rgb(m1, m2, h),
|
434
|
-
hue_to_rgb(m1, m2, h - 1.0/3)
|
616
|
+
hue_to_rgb(m1, m2, h - 1.0 / 3)
|
435
617
|
].map {|c| (c * 0xff).round}
|
436
618
|
end
|
437
619
|
|
@@ -440,8 +622,8 @@ module Sass::Script
|
|
440
622
|
h -= 1 if h > 1
|
441
623
|
return m1 + (m2 - m1) * h * 6 if h * 6 < 1
|
442
624
|
return m2 if h * 2 < 1
|
443
|
-
return m1 + (m2 - m1) * (2.0/3 - h) * 6 if h * 3 < 2
|
444
|
-
|
625
|
+
return m1 + (m2 - m1) * (2.0 / 3 - h) * 6 if h * 3 < 2
|
626
|
+
m1
|
445
627
|
end
|
446
628
|
|
447
629
|
def rgb_to_hsl!
|
@@ -456,20 +638,20 @@ module Sass::Script
|
|
456
638
|
h =
|
457
639
|
case max
|
458
640
|
when min; 0
|
459
|
-
when r; 60 * (g-b)/d
|
460
|
-
when g; 60 * (b-r)/d + 120
|
461
|
-
when b; 60 * (r-g)/d + 240
|
641
|
+
when r; 60 * (g - b) / d
|
642
|
+
when g; 60 * (b - r) / d + 120
|
643
|
+
when b; 60 * (r - g) / d + 240
|
462
644
|
end
|
463
645
|
|
464
|
-
l = (max + min)/2.0
|
646
|
+
l = (max + min) / 2.0
|
465
647
|
|
466
648
|
s =
|
467
649
|
if max == min
|
468
650
|
0
|
469
651
|
elsif l < 0.5
|
470
|
-
d/(2*l)
|
652
|
+
d / (2 * l)
|
471
653
|
else
|
472
|
-
d/(2 - 2*l)
|
654
|
+
d / (2 - 2 * l)
|
473
655
|
end
|
474
656
|
|
475
657
|
@attrs[:hue] = h % 360
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Sass::Script::Value
|
2
|
+
# A SassScript object representing a `false` value that came from a call to
|
3
|
+
# `index()`. It will print deprecation warnings if it's used with `==`.
|
4
|
+
class DeprecatedFalse < Bool
|
5
|
+
def self.new(environment)
|
6
|
+
obj = allocate
|
7
|
+
obj.send(:initialize, environment)
|
8
|
+
obj
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(environment)
|
12
|
+
@value = false
|
13
|
+
@global_env = environment.global_env
|
14
|
+
if (frame = environment.stack.frames.last)
|
15
|
+
@filename = frame.filename
|
16
|
+
@line = frame.line
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def eq(other)
|
21
|
+
if other.value == false && !warned?
|
22
|
+
self.warned = true
|
23
|
+
Sass::Util.sass_warn <<WARNING + @global_env.stack.to_s.gsub(/^/, ' ')
|
24
|
+
DEPRECATION WARNING: The return value of index() will change from "false" to
|
25
|
+
"null" in future versions of Sass. For compatibility, avoid using "== false" on
|
26
|
+
the return value. For example, instead of "@if index(...) == false", just write
|
27
|
+
"@if index(...)".
|
28
|
+
WARNING
|
29
|
+
end
|
30
|
+
Bool.new(other.value == false)
|
31
|
+
end
|
32
|
+
|
33
|
+
def neq(other)
|
34
|
+
if other.value.nil? && !warned?
|
35
|
+
self.warned = true
|
36
|
+
Sass::Util.sass_warn <<WARNING + @global_env.stack.to_s.gsub(/^/, ' ')
|
37
|
+
DEPRECATION WARNING: The return value of index() will change from "false" to
|
38
|
+
"null" in future versions of Sass. For compatibility, avoid using "!= null" on
|
39
|
+
the return value.
|
40
|
+
WARNING
|
41
|
+
end
|
42
|
+
Bool.new(other.value != false)
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def warned?
|
48
|
+
@global_env.deprecated_false_warning_given.include?([@filename, @line])
|
49
|
+
end
|
50
|
+
|
51
|
+
def warned=(value)
|
52
|
+
@global_env.deprecated_false_warning_given << [@filename, @line]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|