compass 0.13.alpha.4 → 0.13.alpha.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +7 -0
  2. data/README.markdown +2 -3
  3. data/Rakefile +91 -5
  4. data/VERSION.yml +1 -1
  5. data/examples/compass/images/emblem-a043c4f148.png +0 -0
  6. data/examples/compass/images/flag-03c3b29b35.png +0 -0
  7. data/examples/compass/images/flag-21cfbfbfc8.png +0 -0
  8. data/examples/css3/extensions/fancy-fonts/templates/project/Prociono.otf +0 -0
  9. data/features/command_line.feature +2 -6
  10. data/features/step_definitions/command_line_steps.rb +1 -0
  11. data/frameworks/compass/stylesheets/compass/_css3.scss +0 -1
  12. data/frameworks/compass/stylesheets/compass/_support.scss +353 -35
  13. data/frameworks/compass/stylesheets/compass/css3/_animation.scss +49 -48
  14. data/frameworks/compass/stylesheets/compass/css3/_appearance.scss +4 -8
  15. data/frameworks/compass/stylesheets/compass/css3/_background-clip.scss +15 -19
  16. data/frameworks/compass/stylesheets/compass/css3/_background-origin.scss +17 -19
  17. data/frameworks/compass/stylesheets/compass/css3/_background-size.scss +4 -8
  18. data/frameworks/compass/stylesheets/compass/css3/_border-radius.scss +37 -39
  19. data/frameworks/compass/stylesheets/compass/css3/_box-shadow.scss +45 -20
  20. data/frameworks/compass/stylesheets/compass/css3/_box-sizing.scss +6 -8
  21. data/frameworks/compass/stylesheets/compass/css3/_box.scss +12 -13
  22. data/frameworks/compass/stylesheets/compass/css3/_columns.scss +46 -26
  23. data/frameworks/compass/stylesheets/compass/css3/_deprecated-support.scss +272 -0
  24. data/frameworks/compass/stylesheets/compass/css3/_filter.scss +17 -10
  25. data/frameworks/compass/stylesheets/compass/css3/_flexbox.scss +134 -281
  26. data/frameworks/compass/stylesheets/compass/css3/_font-face.scss +5 -5
  27. data/frameworks/compass/stylesheets/compass/css3/_hyphenation.scss +14 -11
  28. data/frameworks/compass/stylesheets/compass/css3/_images.scss +77 -67
  29. data/frameworks/compass/stylesheets/compass/css3/_inline-block.scss +15 -6
  30. data/frameworks/compass/stylesheets/compass/css3/_opacity.scss +6 -2
  31. data/frameworks/compass/stylesheets/compass/css3/_pie.scss +1 -73
  32. data/frameworks/compass/stylesheets/compass/css3/_regions.scss +7 -6
  33. data/frameworks/compass/stylesheets/compass/css3/_selection.scss +45 -17
  34. data/frameworks/compass/stylesheets/compass/css3/_shared.scss +4 -261
  35. data/frameworks/compass/stylesheets/compass/css3/_text-shadow.scss +1 -1
  36. data/frameworks/compass/stylesheets/compass/css3/_transform.scss +24 -32
  37. data/frameworks/compass/stylesheets/compass/css3/_transition.scss +102 -152
  38. data/frameworks/compass/stylesheets/compass/css3/_user-interface.scss +42 -27
  39. data/frameworks/compass/stylesheets/compass/typography/_vertical_rhythm.scss +2 -1
  40. data/frameworks/compass/stylesheets/compass/typography/links/_hover-link.scss +1 -1
  41. data/frameworks/compass/stylesheets/compass/typography/lists/_horizontal-list.scss +2 -2
  42. data/frameworks/compass/stylesheets/compass/typography/lists/_inline-list.scss +1 -1
  43. data/frameworks/compass/stylesheets/compass/typography/text/_ellipsis.scss +1 -1
  44. data/frameworks/compass/stylesheets/compass/utilities/_sass.scss +2 -0
  45. data/frameworks/compass/stylesheets/compass/utilities/color/_brightness.scss +12 -0
  46. data/frameworks/compass/stylesheets/compass/utilities/color/_contrast.scss +36 -12
  47. data/frameworks/compass/stylesheets/compass/utilities/general/_float.scss +6 -2
  48. data/frameworks/compass/stylesheets/compass/utilities/general/_hacks.scss +23 -4
  49. data/frameworks/compass/stylesheets/compass/utilities/general/_min.scss +1 -1
  50. data/frameworks/compass/stylesheets/compass/utilities/sass/_lists.scss +16 -0
  51. data/frameworks/compass/stylesheets/compass/utilities/sass/_maps.scss +19 -0
  52. data/frameworks/compass/stylesheets/compass/utilities/sprites/_base.scss +25 -18
  53. data/frameworks/compass/stylesheets/compass/utilities/sprites/_sprite-img.scss +3 -1
  54. data/frameworks/compass/stylesheets/compass/utilities/tables/_borders.scss +3 -3
  55. data/lib/compass.rb +1 -1
  56. data/lib/compass/browser_support.rb +1 -1
  57. data/lib/compass/caniuse.rb +247 -0
  58. data/lib/compass/configuration/adapters.rb +7 -1
  59. data/lib/compass/sass_extensions/functions.rb +5 -0
  60. data/lib/compass/sass_extensions/functions/constants.rb +2 -2
  61. data/lib/compass/sass_extensions/functions/cross_browser_support.rb +176 -1
  62. data/lib/compass/sass_extensions/functions/display.rb +24 -19
  63. data/lib/compass/sass_extensions/functions/env.rb +37 -8
  64. data/lib/compass/sass_extensions/functions/gradient_support.rb +10 -13
  65. data/lib/compass/sass_extensions/functions/math.rb +31 -13
  66. data/lib/compass/sass_extensions/functions/sprites.rb +48 -25
  67. data/lib/compass/sass_extensions/monkey_patches/browser_support.rb +42 -13
  68. data/lib/compass/sass_extensions/sprites/image.rb +14 -4
  69. data/lib/compass/sass_extensions/sprites/image_methods.rb +19 -3
  70. data/lib/compass/sprite_importer/content.erb +8 -7
  71. data/lib/compass/watcher/project_watcher.rb +75 -42
  72. data/lib/compass/watcher/watch.rb +35 -17
  73. data/test/fixtures/sprites/public/images/focus/ten-by-ten.png +0 -0
  74. data/test/fixtures/sprites/public/images/focus/ten-by-ten_active.png +0 -0
  75. data/test/fixtures/sprites/public/images/focus/ten-by-ten_focus.png +0 -0
  76. data/test/fixtures/sprites/public/images/focus/ten-by-ten_hover.png +0 -0
  77. data/test/fixtures/sprites/public/images/focus/ten-by-ten_target.png +0 -0
  78. data/test/fixtures/stylesheets/compass/config.rb +1 -0
  79. data/test/fixtures/stylesheets/compass/css/animation-with-legacy-ie.css +1 -9
  80. data/test/fixtures/stylesheets/compass/css/animation.css +1 -9
  81. data/test/fixtures/stylesheets/compass/css/appearance.css +3 -0
  82. data/test/fixtures/stylesheets/compass/css/background-clip.css +4 -8
  83. data/test/fixtures/stylesheets/compass/css/background-origin.css +4 -8
  84. data/test/fixtures/stylesheets/compass/css/background-size.css +3 -10
  85. data/test/fixtures/stylesheets/compass/css/border_radius.css +3 -3
  86. data/test/fixtures/stylesheets/compass/css/{box-sizeing.css → box-sizing.css} +2 -2
  87. data/test/fixtures/stylesheets/compass/css/box_shadow.css +15 -5
  88. data/test/fixtures/stylesheets/compass/css/brightness.css +14 -0
  89. data/test/fixtures/stylesheets/compass/css/browser-support.css +306 -0
  90. data/test/fixtures/stylesheets/compass/css/color.css +18 -0
  91. data/test/fixtures/stylesheets/compass/css/columns.css +27 -18
  92. data/test/fixtures/stylesheets/compass/css/filters.css +6 -6
  93. data/test/fixtures/stylesheets/compass/css/flexbox.css +84 -111
  94. data/test/fixtures/stylesheets/compass/css/fonts.css +1 -1
  95. data/test/fixtures/stylesheets/compass/css/gradients.css +53 -53
  96. data/test/fixtures/stylesheets/compass/css/grid_background.css +11 -11
  97. data/test/fixtures/stylesheets/compass/css/hyphenation.css +2 -4
  98. data/test/fixtures/stylesheets/compass/css/lists.css +6 -12
  99. data/test/fixtures/stylesheets/compass/css/regions.css +2 -2
  100. data/test/fixtures/stylesheets/compass/css/selection.css +41 -4
  101. data/test/fixtures/stylesheets/compass/css/sprites_with_explicit_separator.css +16 -0
  102. data/test/fixtures/stylesheets/compass/css/support.css +62 -0
  103. data/test/fixtures/stylesheets/compass/css/transform.css +64 -136
  104. data/test/fixtures/stylesheets/compass/css/transition.css +27 -45
  105. data/test/fixtures/stylesheets/compass/css/typography/links/hover-link.css +4 -0
  106. data/test/fixtures/stylesheets/compass/css/user-interface.css +34 -7
  107. data/test/fixtures/stylesheets/compass/css/utilities.css +7 -7
  108. data/test/fixtures/stylesheets/compass/css/vertical_rhythm.css +6 -9
  109. data/test/fixtures/stylesheets/compass/images/flag_states-sc42d7bf926.png +0 -0
  110. data/test/fixtures/stylesheets/compass/images/flag_states/foo.png +0 -0
  111. data/test/fixtures/stylesheets/compass/images/flag_states/foo_active.png +0 -0
  112. data/test/fixtures/stylesheets/compass/images/flag_states/foo_focus.png +0 -0
  113. data/test/fixtures/stylesheets/compass/images/flag_states/foo_hover.png +0 -0
  114. data/test/fixtures/stylesheets/compass/images/flag_states/foo_target.png +0 -0
  115. data/test/fixtures/stylesheets/compass/sass/animation-with-legacy-ie.scss +1 -3
  116. data/test/fixtures/stylesheets/compass/sass/appearance.scss +5 -0
  117. data/test/fixtures/stylesheets/compass/sass/background-clip.scss +0 -5
  118. data/test/fixtures/stylesheets/compass/sass/background-origin.scss +0 -5
  119. data/test/fixtures/stylesheets/compass/sass/background-size.scss +0 -5
  120. data/test/fixtures/stylesheets/compass/sass/{box-sizeing.scss → box-sizing.scss} +1 -1
  121. data/test/fixtures/stylesheets/compass/sass/box_shadow.scss +2 -0
  122. data/test/fixtures/stylesheets/compass/sass/brightness.scss +12 -0
  123. data/test/fixtures/stylesheets/compass/sass/browser-support.scss +30 -0
  124. data/test/fixtures/stylesheets/compass/sass/color.scss +22 -0
  125. data/test/fixtures/stylesheets/compass/sass/filters.scss +1 -0
  126. data/test/fixtures/stylesheets/compass/sass/flexbox.scss +84 -40
  127. data/test/fixtures/stylesheets/compass/sass/gradients.sass +3 -2
  128. data/test/fixtures/stylesheets/compass/sass/selection.scss +29 -4
  129. data/test/fixtures/stylesheets/compass/sass/sprites_with_explicit_separator.scss +7 -0
  130. data/test/fixtures/stylesheets/compass/sass/support.scss +137 -0
  131. data/test/fixtures/stylesheets/compass/sass/transition.scss +0 -3
  132. data/test/fixtures/stylesheets/compass/sass/typography/links/hover-link.scss +3 -0
  133. data/test/fixtures/stylesheets/compass/sass/user-interface.scss +16 -5
  134. data/test/fixtures/stylesheets/compass/sass/utilities.scss +4 -4
  135. data/test/fixtures/stylesheets/envtest/css/env.css +4 -4
  136. data/test/fixtures/stylesheets/envtest/tmp/env.css +4 -4
  137. data/test/integrations/sprites_test.rb +30 -1
  138. data/test/test_helper.rb +2 -2
  139. data/test/units/caniuse_test.rb +115 -0
  140. data/test/units/command_line_test.rb +1 -0
  141. data/test/units/sass_extensions_test.rb +5 -0
  142. data/test/units/sprites/image_test.rb +12 -0
  143. data/test/units/sprites/sprite_map_test.rb +11 -0
  144. data/test/units/watcher/project_watcher_test.rb +26 -18
  145. metadata +96 -42
  146. data/examples/compass/src/pie.scss +0 -110
  147. data/frameworks/compass/stylesheets/compass/css3/_transform-legacy.scss +0 -87
  148. data/frameworks/compass/templates/pie/LICENSE +0 -12
  149. data/frameworks/compass/templates/pie/LICENSE-APACHE2.txt +0 -13
  150. data/frameworks/compass/templates/pie/LICENSE-GPL2.txt +0 -278
  151. data/frameworks/compass/templates/pie/PIE.htc +0 -96
  152. data/frameworks/compass/templates/pie/manifest.rb +0 -39
  153. data/frameworks/compass/templates/pie/pie.scss +0 -74
  154. data/lib/compass/sass_extensions/functions/utility.rb +0 -10
  155. data/test/fixtures/stylesheets/compass/css/pie.css +0 -23
  156. data/test/fixtures/stylesheets/compass/sass/pie.scss +0 -47
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ee5da32e1abc5dbc8067fddb8a30e67e7df94666
4
+ data.tar.gz: d0cf1dd621e9e80ba6457560d23267f33a7669f5
5
+ SHA512:
6
+ metadata.gz: 691fc67fa9830a372bcb3f43b9b7aa5f21cb99d63b0d61d547a99fe9057830032d22965016c2465285bb44e4700725ef1c00d8da773fb1e82322f962bd006c07
7
+ data.tar.gz: ce6fd2a32e34cd4f0d7282c8a2c504541b2d095047a08c3413346d6f0202e29465aff72d4377122eb37ae67328d86e9d7e39a50448e73857b670f9a7dd731e92
@@ -11,15 +11,14 @@ Code Quality: [![Code Climate](https://codeclimate.com/github/chriseppstein/comp
11
11
  * [Compass Reference](http://compass-style.org/install/reference/)
12
12
 
13
13
  ## Author
14
- Compass is written by [Chris Eppstein](http://chriseppstein.github.com/).<br>
15
- Chris is the Software Architect of [Caring.com](http://caring.com) and a member of the [Sass](https://github.com/nex3/sass) core team.
14
+ Compass is written by [Chris Eppstein](http://chriseppstein.github.io/).<br>
15
+ Chris is a software engineer at [LinkedIn](http://www.linkedin.com/) and a member of the [Sass](https://github.com/nex3/sass) core team.
16
16
 
17
17
  ## Core Team Members
18
18
 
19
19
  * [Scott Davis](https://github.com/scottdavis)
20
20
  * [Eric Meyer](https://github.com/ericam)
21
21
  * [Brandon Mathis](https://github.com/imathis)
22
- * [Anthony Short](https://github.com/anthonyshort/)
23
22
 
24
23
  ## Major Contributors
25
24
 
data/Rakefile CHANGED
@@ -3,7 +3,12 @@ if ENV["PKG"]
3
3
  $: << File.expand_path(File.dirname(__FILE__))+"/lib"
4
4
  else
5
5
  require 'bundler'
6
- Bundler.setup
6
+ Bundler.setup
7
+ end
8
+
9
+ unless ENV['CI']
10
+ require 'colorize'
11
+ require 'fileutils'
7
12
  end
8
13
 
9
14
  begin
@@ -58,6 +63,22 @@ Rake::TestTask.new :integrations do |t|
58
63
  t.verbose = true
59
64
  end
60
65
 
66
+ desc "Download the latest browser stats data."
67
+ task :caniuse do
68
+ require 'uri'
69
+ require 'net/http'
70
+ require 'net/https'
71
+ uri = URI.parse("https://raw.github.com/Fyrd/caniuse/master/data.json")
72
+ https = Net::HTTP.new(uri.host,uri.port)
73
+ https.use_ssl = true
74
+ req = Net::HTTP::Get.new(uri.path)
75
+ res = https.request(req)
76
+ filename = File.join(File.dirname(__FILE__), "data", "caniuse.json")
77
+ open(filename, "wb") do |file|
78
+ file.write(res.body)
79
+ end
80
+ puts "#{filename} (#{res.body.size} bytes)"
81
+ end
61
82
 
62
83
  desc "Compile Examples into HTML and CSS"
63
84
  task :examples do
@@ -114,12 +135,12 @@ begin
114
135
  require 'cucumber/rake/task'
115
136
  require 'rcov/rcovtask'
116
137
  namespace :rcov do
117
- Cucumber::Rake::Task.new(:cucumber) do |t|
138
+ Cucumber::Rake::Task.new(:cucumber) do |t|
118
139
  t.rcov = true
119
140
  t.rcov_opts = %w{--exclude osx\/objc,gems\/,spec\/,features\/ --aggregate coverage.data}
120
141
  t.rcov_opts << %[-o "coverage"]
121
142
  end
122
-
143
+
123
144
  Rcov::RcovTask.new(:units) do |rcov|
124
145
  rcov.libs << 'lib'
125
146
  test_files = FileList['test/**/*_test.rb']
@@ -130,8 +151,8 @@ begin
130
151
  rcov.rcov_opts = %w{--exclude osx\/objc,gems\/,spec\/,features\/ --aggregate coverage.data}
131
152
  rcov.rcov_opts << %[-o "coverage" --sort coverage]
132
153
  end
133
-
134
-
154
+
155
+
135
156
  desc "Run both specs and features to generate aggregated coverage"
136
157
  task :all do |t|
137
158
  rm "coverage.data" if File.exist?("coverage.data")
@@ -160,3 +181,68 @@ begin
160
181
  rescue LoadError => e
161
182
  puts "WARNING: #{e}"
162
183
  end
184
+
185
+ namespace :test do
186
+ debug = false
187
+ desc "update test expectations if needed"
188
+ task :update do
189
+ Rake::Task['test:update:fixtures'].invoke
190
+ end
191
+ task :debug do
192
+ debug = true
193
+ Rake::Task['test:update:fixtures'].invoke
194
+ end
195
+ namespace :update do
196
+ EXPECTED = 'css'
197
+ TMP = 'tmp'
198
+ #desc "update fixture expectations for test cases if needed"
199
+ task :fixtures do
200
+ fixtures = File.join('test/fixtures/stylesheets/compass'.split('/'))
201
+ # remove any existing temporary files
202
+ FileUtils.rm_rf(File.join(File.dirname(__FILE__), fixtures, TMP, '.'))
203
+ # compile the fixtures
204
+ puts "checking test cases..."
205
+ CHECKMARK = "\u2713 "
206
+ filter = debug ? '--trace' : "| grep 'error.*#{fixtures}'"
207
+ errors = %x[compass compile #{fixtures} #{filter}]
208
+ # check for compilation errors
209
+ if not errors.empty?
210
+ puts "Please fix the following errors before proceeding:".colorize(:red) if not debug
211
+ puts errors
212
+ else
213
+ # check to see what's changed
214
+ diff = %x[diff -r #{File.join(fixtures, EXPECTED, '')} #{File.join(fixtures, TMP, '')}]
215
+ # ignore non-CSS files in css/
216
+ diff = diff.gsub(/^Only in .*\/css\/(.*)\:.*[^.css]/, '')
217
+ if diff.empty?
218
+ puts "#{CHECKMARK}Cool! Looks like all the tests are up to date".colorize(:green)
219
+ else
220
+ puts "The following changes were found:"
221
+ puts "===================================="
222
+ # check for new or removed expectations
223
+ diff.scan(/^Only in .*\/(#{EXPECTED}|#{TMP})\/(.*)\: (.*).css/).each do |match|
224
+ config = (match[0] == TMP) ? [:green, '>', 'NEW TEST'] : [:red, '<', 'DELETED']
225
+ puts "[#{File.join(match[1], match[2])}] #{config[2].colorize(config[0])}".colorize(:cyan)
226
+ new_file = File.join(File.dirname(__FILE__), fixtures, match[0], match[1], match[2]) + '.css'
227
+ puts File.read(new_file).gsub(/^(.*)/, config[1] + ' \1').colorize(config[0])
228
+ end
229
+ diff = diff.gsub(/^diff\s\-r\s.*\/tmp\/(.*).css/, '[\1]'.colorize(:cyan))
230
+ diff = diff.gsub(/^Only in .*\n?/, '')
231
+ diff = diff.gsub(/^(\<.*)/, '\1'.colorize(:red))
232
+ diff = diff.gsub(/^(\>.*)/, '\1'.colorize(:green))
233
+ diff = diff.gsub(/^(\d+.*)/, '\1'.colorize(:cyan))
234
+ puts diff
235
+ puts "===================================="
236
+ puts "Are all of these changes expected? [y/n]".colorize(:yellow)
237
+ if (($stdin.gets.chomp)[0] == 'y')
238
+ FileUtils.rm_rf(File.join(File.dirname(__FILE__), fixtures, EXPECTED, '.'))
239
+ FileUtils.cp_r(File.join(File.dirname(__FILE__), fixtures, TMP, '.'), File.join(File.dirname(__FILE__), fixtures, EXPECTED))
240
+ puts "#{CHECKMARK}Thanks! The test expectations have been updated".colorize(:green)
241
+ else
242
+ puts "Please manually update the test cases and expectations".colorize(:red)
243
+ end
244
+ end
245
+ end
246
+ end
247
+ end
248
+ end
@@ -2,5 +2,5 @@
2
2
  :major: 0
3
3
  :minor: 13
4
4
  :state: alpha
5
- :iteration: 4
5
+ :iteration: 5
6
6
  :name: Markab
@@ -115,11 +115,6 @@ Feature: Command Line
115
115
  And a sass file sass/reset.sass is not mentioned
116
116
  And a css file tmp/utilities.css is reported identical
117
117
 
118
- Scenario: Installing a pattern into a project
119
- Given I am using the existing project in test/fixtures/stylesheets/compass
120
- When I run: compass install compass/pie
121
- Then a sass file sass/pie.scss is created
122
-
123
118
  Scenario: Basic help
124
119
  When I run: compass help
125
120
  Then I should see the following "primary" commands:
@@ -179,12 +174,13 @@ Feature: Command Line
179
174
  | tmp/fonts.css |
180
175
  | images/flag-s5b4f509715.png |
181
176
 
177
+ @now
182
178
  Scenario: Watching a project for changes
183
179
  Given ruby supports fork
184
180
  Given I am using the existing project in test/fixtures/stylesheets/compass
185
181
  When I run: compass compile
186
182
  And I run in a separate process: compass watch
187
- And I wait 3 seconds
183
+ And I wait 4 seconds
188
184
  And I touch sass/layout.sass
189
185
  And I wait 2 seconds
190
186
  And I shutdown the other process
@@ -1,6 +1,7 @@
1
1
  $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '../../test')))
2
2
 
3
3
  require 'test_helper'
4
+ require 'true'
4
5
 
5
6
  require 'compass/exec'
6
7
  include Compass::TestCaseHelper
@@ -5,7 +5,6 @@
5
5
  @import "css3/text-shadow";
6
6
  @import "css3/columns";
7
7
  @import "css3/box-sizing";
8
- @import "css3/box";
9
8
  @import "css3/flexbox";
10
9
  @import "css3/images";
11
10
  @import "css3/background-clip";
@@ -1,40 +1,358 @@
1
- // Usually compass hacks apply to both ie6 & 7 -- set this to false to disable support for both.
2
- $legacy-support-for-ie: true !default;
1
+ // The list of browsers you want to support.
2
+ // Defaults to all.
3
+ $supported-browsers: browsers() !default;
3
4
 
4
- // Setting this to false will result in smaller output, but no support for ie6 hacks
5
- $legacy-support-for-ie6: $legacy-support-for-ie !default;
5
+ // The browser usage threshold for features that gracefully degrade
6
+ // Defaults to 1 user in 1,000.
7
+ $graceful-usage-threshold: 0.1 !default;
6
8
 
7
- // Setting this to false will result in smaller output, but no support for ie7 hacks
8
- $legacy-support-for-ie7: $legacy-support-for-ie !default;
9
+ // The browser usage threshold for features that cannot degrade gracefully
10
+ // Defaults to 1 user in 10,000.
11
+ $critical-usage-threshold: 0.01 !default;
9
12
 
10
- // Setting this to false will result in smaller output, but no support for legacy ie8 hacks
11
- $legacy-support-for-ie8: $legacy-support-for-ie !default;
13
+ // Set this to true to generate comments that will explain why a prefix was included or omitted.
14
+ $debug-browser-support: false !default;
15
+
16
+ // Minimum browser versions that must be supported.
17
+ // The keys of this map are any valid browser according to `browsers()`.
18
+ // The values of this map are the min version that is valid for that browser
19
+ // according to `browser-versions($browser)`
20
+ $browser-minimum-versions: (
21
+ 'chrome': null,
22
+ 'firefox': null,
23
+ 'ie': null,
24
+ 'safari': null,
25
+ 'opera': null
26
+ ) !default;
27
+
28
+
29
+ // @private
30
+ $default-capability-options: (
31
+ (full-support: true),
32
+ (partial-support: true)
33
+ );
34
+
35
+ // When a prefix is in a selector or directive scope, this is set to the current prefix value.
36
+ $current-prefix: null;
37
+
38
+ // When in a context that only exists in a particular version
39
+ // this variable is set to those versions.
40
+ $current-browser-minimum-versions: ();
41
+
42
+ // The legacy support CSS 2.1 Selectors.
43
+ // Defaults to the $critical-usage-threshold.
44
+ $css-sel2-support-threshold: $critical-usage-threshold !default;
45
+
46
+ // Check if the browser is in scope given the current prefix minimums.
47
+ @function browser-out-of-scope($browser, $version: null) {
48
+ @if not ($current-prefix == null or $current-prefix == browser-prefix($browser)) {
49
+ @if $debug-browser-support {
50
+ @return "The #{$browser} #{$version} is incompatible with #{$current-prefix}."
51
+ } @else {
52
+ @return true;
53
+ }
54
+ }
55
+ $current-min: map-get($current-browser-minimum-versions, $browser);
56
+ @if not ($version and $current-min) {
57
+ // We don't have any versions to compare
58
+ @return false;
59
+ } @else {
60
+ // If the version is less than the current min, it is not supported
61
+ $too-old: compare-browser-versions($browser, $version, $current-min) < 0;
62
+ @if $too-old {
63
+ @if $debug-browser-support {
64
+ @return "The current scope only works with #{$browser} #{$current-min} or greater.";
65
+ } @else {
66
+ @return true;
67
+ }
68
+ } @else {
69
+ @return false;
70
+ }
71
+ }
72
+ }
73
+
74
+ // Check whether the browser is supported according to the declared minimum support
75
+ // and usage thresholds.
76
+ @function support-legacy-browser($browser, $version, $threshold: $critical-usage-threshold) {
77
+ // Check agaist usage stats and declared minimums
78
+ $min-version: map-get($browser-minimum-versions, $browser);
79
+ @return omitted-usage($browser, $version) > $threshold or
80
+ ($min-version and compare-browser-versions($browser, $version, $min-version) >= 0);
81
+ }
82
+
83
+ // Include content for a legacy browser
84
+ // Version can be a single version string or a list of versions ordered from oldest to newest.
85
+ @mixin for-legacy-browser($browser, $version, $threshold: $critical-usage-threshold, $mins: ($browser: $version)) {
86
+ $latest-version: nth($version, -1);
87
+ @if not browser-out-of-scope($browser, $latest-version) and
88
+ support-legacy-browser($browser, $latest-version, $threshold)
89
+ {
90
+ @if $debug-browser-support {
91
+ /* Content for #{$browser} #{$version}.
92
+ Min version: #{map-get($browser-minimum-versions, $browser) or unspecified}.
93
+ User threshold to keep: #{$threshold}%. If #{$browser} #{$version} and below are omitted: #{omitted-usage($browser, $version)}%. */
94
+ }
95
+ @include with-browser-minimums(map-merge($current-browser-minimum-versions, $mins)) {
96
+ @content;
97
+ }
98
+ } @else if $debug-browser-support and browser-out-of-scope($browser, $latest-version) {
99
+ /* Content for #{$browser} #{$version} omitted.
100
+ Not allowed in the current scope: #{browser-out-of-scope($browser, $latest-version)} */
101
+ } @else if $debug-browser-support and not support-legacy-browser($browser, $latest-version, $threshold) {
102
+ @if omitted-usage($browser, $version) > $threshold {
103
+ /* Content for #{$browser} #{$version} omitted.
104
+ User threshold to keep: #{$threshold}%. If #{$browser} #{$version} and below are omitted: #{omitted-usage($browser, $version)}%. */
105
+ } @else {
106
+ /* Content for #{$browser} #{$version} omitted.
107
+ Minimum support is #{map-get($browser-minimum-versions, $browser)}. */
108
+ }
109
+ }
110
+ }
111
+
112
+ // Renders the content once if any of the legacy browsers are supported.
113
+ @mixin for-legacy-browsers($browsers, $threshold: $critical-usage-threshold) {
114
+ $rendered: false;
115
+ @each $browser, $version in $browsers {
116
+ @if not $rendered {
117
+ @include for-legacy-browser($browser, $version, $threshold, $mins: $browsers) {
118
+ $rendered: true;
119
+ @content;
120
+ }
121
+ }
122
+ }
123
+ }
124
+
125
+ // If there's a prefix context in scope, this will only output the content if the prefix matches.
126
+ // Otherwise, sets the current prefix scope and outputs the content.
127
+ @mixin with-prefix($prefix) {
128
+ @if $current-prefix {
129
+ @if $current-prefix == $prefix {
130
+ @content;
131
+ } @else if $debug-browser-support {
132
+ /* Omitting content for #{$prefix} because #{$current-prefix} is already in scope. */
133
+ }
134
+ } @else {
135
+ $current-prefix: $prefix;
136
+ @content;
137
+ $current-prefix: null;
138
+ }
139
+ }
140
+
141
+ @function prefixes-for-capability($capability, $threshold, $capability-options: $default-capability-options) {
142
+ $result: ();
143
+ @each $prefix in browser-prefixes($supported-browsers) {
144
+ $result: map-merge($result,
145
+ ($prefix: use-prefix($prefix, $capability, $threshold, $capability-options)));
146
+ }
147
+ @return $result;
148
+ }
149
+
150
+ // Yields to the mixin content once for each prefix required.
151
+ // The current prefix is set to the $current-prefix global for use by the included content.
152
+ // Also yields to the content once with $current-prefix set to null for the official version
153
+ // as long as there's not already a prefix in scope.
154
+ @mixin with-each-prefix($capability, $threshold, $capability-options: $default-capability-options) {
155
+ @each $prefix, $should-use-prefix in prefixes-for-capability($capability, $threshold, $capability-options) {
156
+ @if $should-use-prefix {
157
+ @if $debug-browser-support and type-of($should-use-prefix) == list {
158
+ /* Capability #{$capability} is prefixed with #{$prefix} because #{$should-use-prefix} is required. */
159
+ } @else if $debug-browser-support and type-of($should-use-prefix) == number {
160
+ /* Capability #{$capability} is prefixed with #{$prefix} because omitting it would affect #{$should-use-prefix}% of users and the threshold is #{$threshold}%. */
161
+ }
162
+ @include with-prefix($prefix) {
163
+ @include with-browser-minimums($capability) {
164
+ @content;
165
+ }
166
+ }
167
+ }
168
+ }
169
+ @if not $current-prefix {
170
+ @include with-browser-minimums($capability) {
171
+ @content;
172
+ }
173
+ } @else if $debug-browser-support {
174
+ /* Not including prefix-free content for #{$capability} because the #{$current-prefix} prefix is in scope. */
175
+ }
176
+ }
177
+
178
+ // Returns true if at least one browser-version pair in $subset-mins
179
+ // is a higher (or same) version than the browser-version pairs in $mins.
180
+ @function has-browser-subset($mins, $subset-mins) {
181
+ $found-mismatch: false;
182
+ @each $browser, $subset-min-version in $subset-mins {
183
+ $min-version: map-get($mins, $browser);
184
+ @if $min-version {
185
+ @if compare-browser-versions($browser, $min-version, $subset-min-version) <= 0 {
186
+ @return true;
187
+ } @else {
188
+ $found-mismatch: true
189
+ }
190
+ }
191
+ }
192
+ @return not $found-mismatch;
193
+ }
194
+
195
+ @function merge-browser-minumums($mins, $new-mins) {
196
+ @each $browser, $new-min in $new-mins {
197
+ $old-min: map-get($mins, $browser);
198
+ @if $old-min {
199
+ $max-min: if(compare-browser-versions($browser, $old-min, $new-min) > 0,
200
+ $old-min, $new-min);
201
+ $mins: map-merge($mins, ($browser: $max-min));
202
+ } @else {
203
+ $mins: map-merge($mins, ($browser: $new-min));
204
+ }
205
+ }
206
+ @return $mins;
207
+ }
208
+
209
+ // If passed a map, that will be the new browser minimums.
210
+ // Otherwise a minimum map will be created based on the given capability and prefix
211
+ // using the `browser-minimums($capability, $prefix)` function.
212
+ //
213
+ // If there are current minimums in scope and the new minimums have some overlap
214
+ // with the current, then the minimums will be set to the max version of each browser.
215
+ // If there is no overlap, then the content will not be rendered.
216
+ @mixin with-browser-minimums($capability, $prefix: $current-prefix) {
217
+ $new-mins: null;
218
+ @if type-of($capability) == map {
219
+ $new-mins: $capability;
220
+ } @else {
221
+ $new-mins: browser-minimums($capability, $prefix);
222
+ }
223
+
224
+ @if has-browser-subset($current-browser-minimum-versions, $new-mins) {
225
+ $old-minimums: $current-browser-minimum-versions;
226
+ $current-browser-minimum-versions: merge-browser-minumums($old-minimums, $new-mins);
227
+ @content;
228
+ $current-browser-minimum-versions: $old-minimums;
229
+ }
230
+ }
231
+
232
+ // Returns true if the prefixed usage stats for the capability exceed the threshold
233
+ // or if the minimum version for a supported browser would require a prefix for the capability.
234
+ @function use-prefix($prefix, $capability, $threshold, $capability-options: $default-capability-options) {
235
+ $usage: prefix-usage($prefix, $capability, $capability-options);
236
+ @if $usage > $threshold {
237
+ @return $usage;
238
+ } @else {
239
+ @each $browser in browsers($prefix) {
240
+ @if index($supported-browsers, $browser) {
241
+ $min-version: map-get($browser-minimum-versions, $browser);
242
+ @if $min-version {
243
+ $actual-prefix: browser-requires-prefix($browser, $min-version, $capability, $capability-options);
244
+ @if $actual-prefix and $prefix == $actual-prefix {
245
+ @return $browser $min-version;
246
+ }
247
+ }
248
+ }
249
+ }
250
+ }
251
+ @return false;
252
+ }
253
+
254
+ @function prefix-identifier($ident, $prefix: $current-prefix) {
255
+ @return unquote("#{$prefix}#{if($prefix, '-', null)}#{$ident}");
256
+ }
257
+
258
+ // Output a property and value using the current prefix.
259
+ // It will be unprefixed if $current-prefix is null.
260
+ @mixin prefix-prop($property, $value, $prefix: $current-prefix) {
261
+ #{prefix-identifier($property, $prefix)}: $value;
262
+ }
263
+
264
+ // Emit a set of properties with the prefix governed by the capability and usage threshold given.
265
+ //
266
+ // Example:
267
+ //
268
+ // @include prefixed-properties(css-animation, $animation-support-threshold,
269
+ // (animation-name: foo, animation-duration: 2s)
270
+ // );
271
+ @mixin prefixed-properties($capability, $threshold, $properties, $capability-options: $default-capability-options) {
272
+ @include with-each-prefix($capability, $threshold, $capability-options) {
273
+ @each $prop, $value in $properties {
274
+ @include prefix-prop($prop, $value);
275
+ }
276
+ }
277
+ }
278
+
279
+
280
+ // @private
281
+ @function warn-about-old-variables() {
282
+ $old-variables-in-use: ();
283
+ @each $old-variable-name in
284
+ (legacy-support-for-ie, legacy-support-for-ie6, legacy-support-for-ie7,
285
+ legacy-support-for-ie8, legacy-support-for-mozilla, legacy-support-for-webkit,
286
+ experimental-support-for-mozilla, experimental-support-for-webkit,
287
+ experimental-support-for-opera, experimental-support-for-microsoft,
288
+ experimental-support-for-khtml, experimental-support-for-svg)
289
+ {
290
+ @if global-variable-exists($old-variable-name) {
291
+ $old-variables-in-use: append($old-variables-in-use,
292
+ unquote("$#{$old-variable-name}"), comma);
293
+ }
294
+ }
295
+ @if length($old-variables-in-use) > 0 {
296
+ @warn "Compass has changed how browser support is configured. " +
297
+ "See the CHANGELOG for more details. The following configuration variables " +
298
+ "are no longer supported: #{$old-variables-in-use}."
299
+ }
300
+ @return $old-variables-in-use;
301
+ }
302
+
303
+ // @private
304
+ @function warn-about-pie-removal() {
305
+ @if global-variable-exists(experimental-support-for-pie) {
306
+ @warn "Compass no longer supports css3pie.";
307
+ }
308
+ @return true;
309
+ }
310
+
311
+ // Enable browser support debugging within the content block.
312
+ // Or you can enable it for the whole stylesheet by setting `$debug-browser-support` to true.
313
+ @mixin with-browser-support-debugging {
314
+ $current-status: $debug-browser-support;
315
+ $debug-browser-support: true;
316
+ @content;
317
+ $debug-browser-support: $current-status;
318
+ }
319
+
320
+ // Set a default value if the given arglist is empty
321
+ @function set-arglist-default($arglist, $default) {
322
+ $default-index: index($arglist, default);
323
+ @if $default-index {
324
+ $arglist: set-nth($arglist, $default-index, $default)
325
+ }
326
+ @return if(length($arglist) > 0, $arglist, $default);
327
+ }
328
+
329
+
330
+ // @private
331
+ $old-variable-warnings-issued: warn-about-old-variables() !default;
12
332
 
13
333
  // @private
14
- // The user can simply set $legacy-support-for-ie and 6, 7, and 8 will be set accordingly,
15
- // But in case the user set each of those explicitly, we need to sync the value of
16
- // this combined variable.
17
- $legacy-support-for-ie: $legacy-support-for-ie6 or $legacy-support-for-ie7 or $legacy-support-for-ie8;
18
-
19
- // Whether to output legacy support for mozilla.
20
- $legacy-support-for-mozilla: true !default;
21
-
22
- // Whether to output legacy support for webkit.
23
- $legacy-support-for-webkit: true !default;
24
-
25
- // Support for mozilla in experimental css3 properties (-moz).
26
- $experimental-support-for-mozilla : true !default;
27
- // Support for webkit in experimental css3 properties (-webkit).
28
- $experimental-support-for-webkit : true !default;
29
- // Support for opera in experimental css3 properties (-o).
30
- $experimental-support-for-opera : true !default;
31
- // Support for microsoft in experimental css3 properties (-ms).
32
- $experimental-support-for-microsoft : true !default;
33
- // Support for khtml in experimental css3 properties (-khtml).
34
- $experimental-support-for-khtml : false !default;
35
- // Support for svg in experimental css3 properties.
36
- // Setting this to true might add significant size to your
37
- // generated stylesheets.
38
- $experimental-support-for-svg : false !default;
39
- // Support for CSS PIE in experimental css3 properties (-pie).
40
- $experimental-support-for-pie : false !default;
334
+ $pie-removal-warnging-issued: warn-about-pie-removal() !default;
335
+
336
+ // @private
337
+ @function warn-about-useless-prefix-arguments($moz: null, $webkit: null, $o: null, $khtml: null, $official: null) {
338
+ @if $moz != null or $webkit != null or $o != null or $khtml != null or $official != null {
339
+ @warn "Browser prefix arguments to this mixin are no longer used and " +
340
+ "will be removed in the next release.";
341
+ }
342
+ @return true;
343
+ }
344
+
345
+ // coerce a list to be comma delimited or make a new, empty comma delimited list.
346
+ @function comma-list($list: ()) {
347
+ @return join((), $list, comma);
348
+ }
349
+
350
+ // @private Returns the legacy value for a given box-model
351
+ // - Used by background-clip and -origin.
352
+ @function legacy-box($box) {
353
+ $box: unquote($box);
354
+ @if $box == padding-box { $box: padding; }
355
+ @if $box == border-box { $box: border; }
356
+ @if $box == content-box { $box: content; }
357
+ @return $box;
358
+ }