compass-core 1.0.0.alpha.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +22 -0
  3. data/VERSION +1 -0
  4. data/data/caniuse.json +1 -0
  5. data/data/caniuse_extras/css-placeholder.json +171 -0
  6. data/lib/compass-core.rb +1 -0
  7. data/lib/compass/browser_support.rb +62 -0
  8. data/lib/compass/configuration.rb +168 -0
  9. data/lib/compass/configuration/data.rb +178 -0
  10. data/lib/compass/configuration/defaults.rb +197 -0
  11. data/lib/compass/configuration/inheritance.rb +304 -0
  12. data/lib/compass/configuration/paths.rb +19 -0
  13. data/lib/compass/core.rb +64 -0
  14. data/lib/compass/core/caniuse.rb +282 -0
  15. data/lib/compass/core/sass_extensions.rb +10 -0
  16. data/lib/compass/core/sass_extensions/functions.rb +39 -0
  17. data/lib/compass/core/sass_extensions/functions/colors.rb +67 -0
  18. data/lib/compass/core/sass_extensions/functions/configuration.rb +162 -0
  19. data/lib/compass/core/sass_extensions/functions/constants.rb +74 -0
  20. data/lib/compass/core/sass_extensions/functions/cross_browser_support.rb +269 -0
  21. data/lib/compass/core/sass_extensions/functions/display.rb +32 -0
  22. data/lib/compass/core/sass_extensions/functions/enumerate.rb +7 -0
  23. data/lib/compass/core/sass_extensions/functions/env.rb +60 -0
  24. data/lib/compass/core/sass_extensions/functions/font_files.rb +41 -0
  25. data/lib/compass/core/sass_extensions/functions/gradient_support.rb +616 -0
  26. data/lib/compass/core/sass_extensions/functions/image_size.rb +117 -0
  27. data/lib/compass/core/sass_extensions/functions/inline_image.rb +64 -0
  28. data/lib/compass/core/sass_extensions/functions/lists.rb +101 -0
  29. data/lib/compass/core/sass_extensions/functions/math.rb +92 -0
  30. data/lib/compass/core/sass_extensions/functions/selectors.rb +64 -0
  31. data/lib/compass/core/sass_extensions/functions/urls.rb +297 -0
  32. data/lib/compass/core/sass_extensions/monkey_patches.rb +3 -0
  33. data/lib/compass/core/sass_extensions/monkey_patches/browser_support.rb +118 -0
  34. data/lib/compass/core/sass_extensions/monkey_patches/traversal.rb +23 -0
  35. data/lib/compass/core/version.rb +5 -0
  36. data/lib/compass/error.rb +5 -0
  37. data/stylesheets/_compass.scss +3 -0
  38. data/stylesheets/_lemonade.scss +38 -0
  39. data/stylesheets/compass/_configuration.scss +54 -0
  40. data/stylesheets/compass/_css3.scss +21 -0
  41. data/stylesheets/compass/_layout.scss +3 -0
  42. data/stylesheets/compass/_reset-legacy.scss +3 -0
  43. data/stylesheets/compass/_reset.scss +3 -0
  44. data/stylesheets/compass/_support.scss +441 -0
  45. data/stylesheets/compass/_typography.scss +4 -0
  46. data/stylesheets/compass/_utilities.scss +9 -0
  47. data/stylesheets/compass/css3/_animation.scss +122 -0
  48. data/stylesheets/compass/css3/_appearance.scss +17 -0
  49. data/stylesheets/compass/css3/_background-clip.scss +35 -0
  50. data/stylesheets/compass/css3/_background-origin.scss +37 -0
  51. data/stylesheets/compass/css3/_background-size.scss +19 -0
  52. data/stylesheets/compass/css3/_border-radius.scss +107 -0
  53. data/stylesheets/compass/css3/_box-shadow.scss +88 -0
  54. data/stylesheets/compass/css3/_box-sizing.scss +15 -0
  55. data/stylesheets/compass/css3/_box.scss +85 -0
  56. data/stylesheets/compass/css3/_columns.scss +210 -0
  57. data/stylesheets/compass/css3/_deprecated-support.scss +272 -0
  58. data/stylesheets/compass/css3/_filter.scss +50 -0
  59. data/stylesheets/compass/css3/_flexbox.scss +156 -0
  60. data/stylesheets/compass/css3/_font-face.scss +48 -0
  61. data/stylesheets/compass/css3/_hyphenation.scss +71 -0
  62. data/stylesheets/compass/css3/_images.scss +139 -0
  63. data/stylesheets/compass/css3/_inline-block.scss +31 -0
  64. data/stylesheets/compass/css3/_opacity.scss +23 -0
  65. data/stylesheets/compass/css3/_pie.scss +1 -0
  66. data/stylesheets/compass/css3/_regions.scss +27 -0
  67. data/stylesheets/compass/css3/_selection.scss +59 -0
  68. data/stylesheets/compass/css3/_shared.scss +5 -0
  69. data/stylesheets/compass/css3/_text-shadow.scss +82 -0
  70. data/stylesheets/compass/css3/_transform.scss +590 -0
  71. data/stylesheets/compass/css3/_transition.scss +171 -0
  72. data/stylesheets/compass/css3/_user-interface.scss +71 -0
  73. data/stylesheets/compass/layout/_grid-background.scss +178 -0
  74. data/stylesheets/compass/layout/_sticky-footer.scss +23 -0
  75. data/stylesheets/compass/layout/_stretching.scss +24 -0
  76. data/stylesheets/compass/reset/_utilities-legacy.scss +135 -0
  77. data/stylesheets/compass/reset/_utilities.scss +142 -0
  78. data/stylesheets/compass/typography/_links.scss +3 -0
  79. data/stylesheets/compass/typography/_lists.scss +4 -0
  80. data/stylesheets/compass/typography/_text.scss +4 -0
  81. data/stylesheets/compass/typography/_units.scss +152 -0
  82. data/stylesheets/compass/typography/_vertical_rhythm.scss +300 -0
  83. data/stylesheets/compass/typography/links/_hover-link.scss +5 -0
  84. data/stylesheets/compass/typography/links/_link-colors.scss +28 -0
  85. data/stylesheets/compass/typography/links/_unstyled-link.scss +7 -0
  86. data/stylesheets/compass/typography/lists/_bullets.scss +34 -0
  87. data/stylesheets/compass/typography/lists/_horizontal-list.scss +63 -0
  88. data/stylesheets/compass/typography/lists/_inline-block-list.scss +50 -0
  89. data/stylesheets/compass/typography/lists/_inline-list.scss +47 -0
  90. data/stylesheets/compass/typography/text/_ellipsis.scss +25 -0
  91. data/stylesheets/compass/typography/text/_force-wrap.scss +12 -0
  92. data/stylesheets/compass/typography/text/_nowrap.scss +2 -0
  93. data/stylesheets/compass/typography/text/_replacement.scss +68 -0
  94. data/stylesheets/compass/utilities/_color.scss +1 -0
  95. data/stylesheets/compass/utilities/_general.scss +6 -0
  96. data/stylesheets/compass/utilities/_links.scss +5 -0
  97. data/stylesheets/compass/utilities/_lists.scss +6 -0
  98. data/stylesheets/compass/utilities/_print.scss +17 -0
  99. data/stylesheets/compass/utilities/_sass.scss +2 -0
  100. data/stylesheets/compass/utilities/_sprites.scss +2 -0
  101. data/stylesheets/compass/utilities/_tables.scss +3 -0
  102. data/stylesheets/compass/utilities/_text.scss +5 -0
  103. data/stylesheets/compass/utilities/color/_brightness.scss +12 -0
  104. data/stylesheets/compass/utilities/color/_contrast.scss +52 -0
  105. data/stylesheets/compass/utilities/general/_clearfix.scss +44 -0
  106. data/stylesheets/compass/utilities/general/_float.scss +38 -0
  107. data/stylesheets/compass/utilities/general/_hacks.scss +65 -0
  108. data/stylesheets/compass/utilities/general/_min.scss +16 -0
  109. data/stylesheets/compass/utilities/general/_reset.scss +2 -0
  110. data/stylesheets/compass/utilities/general/_tabs.scss +1 -0
  111. data/stylesheets/compass/utilities/general/_tag-cloud.scss +18 -0
  112. data/stylesheets/compass/utilities/links/_hover-link.scss +3 -0
  113. data/stylesheets/compass/utilities/links/_link-colors.scss +3 -0
  114. data/stylesheets/compass/utilities/links/_unstyled-link.scss +3 -0
  115. data/stylesheets/compass/utilities/lists/_bullets.scss +3 -0
  116. data/stylesheets/compass/utilities/lists/_horizontal-list.scss +3 -0
  117. data/stylesheets/compass/utilities/lists/_inline-block-list.scss +3 -0
  118. data/stylesheets/compass/utilities/lists/_inline-list.scss +3 -0
  119. data/stylesheets/compass/utilities/sass/_lists.scss +16 -0
  120. data/stylesheets/compass/utilities/sass/_maps.scss +19 -0
  121. data/stylesheets/compass/utilities/sprites/_base.scss +92 -0
  122. data/stylesheets/compass/utilities/sprites/_sprite-img.scss +81 -0
  123. data/stylesheets/compass/utilities/tables/_alternating-rows-and-columns.scss +22 -0
  124. data/stylesheets/compass/utilities/tables/_borders.scss +38 -0
  125. data/stylesheets/compass/utilities/tables/_scaffolding.scss +9 -0
  126. data/stylesheets/compass/utilities/text/_ellipsis.scss +3 -0
  127. data/stylesheets/compass/utilities/text/_nowrap.scss +3 -0
  128. data/stylesheets/compass/utilities/text/_replacement.scss +3 -0
  129. data/templates/ellipsis/ellipsis.sass +9 -0
  130. data/templates/ellipsis/manifest.rb +27 -0
  131. data/templates/ellipsis/xml/ellipsis.xml +14 -0
  132. data/templates/extension/manifest.rb +26 -0
  133. data/templates/extension/stylesheets/main.sass +1 -0
  134. data/templates/extension/templates/project/manifest.rb +2 -0
  135. data/templates/extension/templates/project/screen.sass +2 -0
  136. data/templates/project/USAGE.markdown +32 -0
  137. data/templates/project/ie.sass +6 -0
  138. data/templates/project/manifest.rb +4 -0
  139. data/templates/project/print.sass +6 -0
  140. data/templates/project/screen.sass +7 -0
  141. metadata +241 -0
@@ -0,0 +1,3 @@
1
+ %w(traversal browser_support).each do |patch|
2
+ require "compass/core/sass_extensions/monkey_patches/#{patch}"
3
+ end
@@ -0,0 +1,118 @@
1
+ require 'sass/script'
2
+
3
+ module Sass::Script
4
+ module Value
5
+ class Base
6
+ NO_CHILDREN = []
7
+ def children
8
+ NO_CHILDREN
9
+ end
10
+
11
+ def opts(value)
12
+ value.options = options
13
+ value
14
+ end
15
+ end
16
+
17
+ class List < Base
18
+ def children
19
+ value
20
+ end
21
+ end
22
+
23
+ class ArgList < List
24
+ def children
25
+ super + @keywords.values
26
+ end
27
+ end
28
+
29
+ class Map < Base
30
+ def children
31
+ to_a
32
+ end
33
+ end
34
+ end
35
+ module HasSimpleCrossBrowserFunctionSupport
36
+ def supports?(aspect)
37
+ return true if Compass::BrowserSupport.supports?(name, aspect)
38
+ children.any? {|child| child.respond_to?(:supports?) && child.supports?(aspect) }
39
+ end
40
+
41
+ def has_aspect?(children = nil)
42
+ children ||= self.children
43
+ return true if Compass::BrowserSupport.has_aspect?(name)
44
+ children.any? {|child| child.respond_to?(:has_aspect?) && child.has_aspect? }
45
+ end
46
+ end
47
+
48
+ class CrossBrowserFunctionCall < Literal
49
+
50
+ attr_accessor :name, :args
51
+
52
+ include HasSimpleCrossBrowserFunctionSupport
53
+
54
+ def initialize(name, args)
55
+ self.name = name
56
+ self.args = args
57
+ end
58
+
59
+ def children
60
+ args
61
+ end
62
+
63
+ def inspect
64
+ to_s
65
+ end
66
+
67
+ def to_s(options = self.options)
68
+ s = "#{name}(#{args.join(", ")})"
69
+ end
70
+
71
+ %w(webkit moz o ms svg css2).each do |prefix|
72
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
73
+ def to_#{prefix}(options = self.options)
74
+ prefixed_args = args.map do |arg|
75
+ arg.respond_to?(:to_#{prefix}) ? arg.to_#{prefix}(options) : arg
76
+ end
77
+ prefixed_name = if Compass::BrowserSupport.supports?(name, "#{prefix}")
78
+ "-#{prefix}-\#{name}"
79
+ else
80
+ name
81
+ end
82
+ contents = prefixed_args.join(', ')
83
+ if contents.size > 0
84
+ opts(Sass::Script::String.new("\#{prefixed_name}(\#{contents})"))
85
+ else
86
+ opts(Sass::Script::String.new(""))
87
+ end
88
+ end
89
+ RUBY
90
+ end
91
+
92
+ end
93
+
94
+ class Funcall < Node
95
+ include HasSimpleCrossBrowserFunctionSupport
96
+
97
+ alias sass_to_value to_value
98
+
99
+ def to_value(args)
100
+ if has_aspect?(args)
101
+ CrossBrowserFunctionCall.new(name, args)
102
+ else
103
+ sass_to_value(args)
104
+ end
105
+ end
106
+ end
107
+
108
+ class List < Literal
109
+ def supports?(aspect)
110
+ children.any? {|child| child.respond_to?(:supports?) && child.supports?(aspect) }
111
+ end
112
+
113
+ def has_aspect?
114
+ children.any? {|child| child.respond_to?(:has_aspect?) && child.has_aspect? }
115
+ end
116
+ end
117
+
118
+ end
@@ -0,0 +1,23 @@
1
+ module Sass
2
+ module Tree
3
+ class Node
4
+ unless method_defined?(:visit_depth_first)
5
+ def visit_depth_first(visitor)
6
+ visitor.visit(self)
7
+ visitor.down(self) if children.any? and visitor.respond_to?(:down)
8
+ if is_a?(ImportNode) && visitor.import?(self)
9
+ root = Sass::Engine.for_file(import, @options).to_tree
10
+ imported_children = root.children
11
+ end
12
+
13
+ (imported_children || children).each do |child|
14
+ break if visitor.respond_to?(:stop?) && visitor.stop?
15
+ child.visit_depth_first(visitor)
16
+ end
17
+ visitor.up(self) if children.any?
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,5 @@
1
+ module Compass
2
+ module Core
3
+ VERSION = File.read(File.join(File.dirname(__FILE__), "..", "..", "..", "VERSION"))
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Compass
2
+ class Error < Sass::SyntaxError
3
+ end
4
+ end
5
+
@@ -0,0 +1,3 @@
1
+ @import "compass/utilities";
2
+ @import "compass/typography";
3
+ @import "compass/css3";
@@ -0,0 +1,38 @@
1
+ @mixin image-dimensions($file) {
2
+ height: image-height($file);
3
+ width: image-width($file);
4
+ }
5
+
6
+ @mixin sprite-image($file) {
7
+ background: sprite-image($file) $repeat;
8
+ }
9
+
10
+ @mixin sized-sprite-image($file) {
11
+ background: sprite-image($file);
12
+ @include image-dimensions($file);
13
+ }
14
+
15
+ @mixin sprite-folder($folder, $image-dimensions: false) {
16
+ .#{$folder} {
17
+ @if $image-dimensions {
18
+ background: sprite-url($folder);
19
+ }
20
+ @else {
21
+ background: sprite-url($folder) no-repeat;
22
+ }
23
+ }
24
+ @for $i from 0 to sprite-files-in-folder($folder) {
25
+ $file: sprite-file-from-folder($folder, $i);
26
+ .#{$folder}-#{image-basename($file)} {
27
+ @extend .#{$folder};
28
+ background-position: sprite-position(sprite-file-from-folder($folder, $i));
29
+ @if $image-dimensions {
30
+ @include image-dimensions($file);
31
+ }
32
+ }
33
+ }
34
+ }
35
+
36
+ @mixin sized-sprite-folder($folder) {
37
+ @include sprite-folder($folder, true);
38
+ }
@@ -0,0 +1,54 @@
1
+ $project-path: null !default;
2
+ $debug-configuration: false !default;
3
+ $compass-initialized: false !default;
4
+ $compass-configured: false !default;
5
+
6
+ @mixin debug-compass-configuration {
7
+ @if $debug-configuration {
8
+ /* Compass Configuration: */
9
+ @each $setting, $value in compass-configuration() {
10
+ /* #{$setting}: #{inspect($value)} */
11
+ }
12
+ }
13
+ }
14
+
15
+ // This mixin resets the compass configuration
16
+ // and then initializes it with the sass options
17
+ // set in the environment. It is immediately called during import.
18
+ // It's unlikely you'll need to call this mixin yourself.
19
+ @mixin compass-initializer($project-path: $project-path) {
20
+ @if not $compass-initialized and not using-compass-compiler() {
21
+ $default-configuration: reset-configuration();
22
+ $default-configuration: add-sass-configuration($project-path);
23
+ }
24
+ $compass-initialized: true !global;
25
+ @include debug-compass-configuration;
26
+ }
27
+ @include compass-initializer;
28
+
29
+ // `$options`:
30
+ // A map of compass configuration options.
31
+ // E.g. @include compass-configuration((asset-host:
32
+ // Keywords style ar
33
+ // `$reconfigure`:
34
+ // When unset, if compass-configuration is called more than once, a warning will
35
+ // be issued and all calls after the first will be ignored.
36
+ // When set to `false`, all subsequent calls will be ignored without a warning.
37
+ // When set to `true`, the configuration will be added to any existing configuration.
38
+ @mixin compass-configuration($options: (), $reconfigure: null, $arguments...) {
39
+ @if & != null {
40
+ // this should be @error once that exists.
41
+ @warn "include compass-configuration from the root level of your stylesheet."
42
+ }
43
+ @if not $compass-configured or $reconfigure {
44
+ $options: map-merge($options, keywords($arguments));
45
+ @if length($arguments) > 0 {
46
+ @warn "compass-configuration accepts keyword arguments or a single map of options. Got: #{inspect($arguments)}."
47
+ }
48
+ $invoke: add-configuration($options);
49
+ @include debug-compass-configuration;
50
+ $compass-configured: true !global;
51
+ } @else if $reconfigure == null {
52
+ @warn "Compass was already configured for this stylesheet."
53
+ }
54
+ }
@@ -0,0 +1,21 @@
1
+ @import "css3/border-radius";
2
+ @import "css3/inline-block";
3
+ @import "css3/opacity";
4
+ @import "css3/box-shadow";
5
+ @import "css3/text-shadow";
6
+ @import "css3/columns";
7
+ @import "css3/box-sizing";
8
+ @import "css3/flexbox";
9
+ @import "css3/images";
10
+ @import "css3/background-clip";
11
+ @import "css3/background-origin";
12
+ @import "css3/background-size";
13
+ @import "css3/font-face";
14
+ @import "css3/transform";
15
+ @import "css3/transition";
16
+ @import "css3/appearance";
17
+ @import "css3/animation";
18
+ @import "css3/regions";
19
+ @import "css3/hyphenation";
20
+ @import "css3/filter";
21
+ @import "css3/user-interface";
@@ -0,0 +1,3 @@
1
+ @import "layout/grid-background";
2
+ @import "layout/sticky-footer";
3
+ @import "layout/stretching";
@@ -0,0 +1,3 @@
1
+ @import "reset/utilities-legacy";
2
+
3
+ @include global-reset;
@@ -0,0 +1,3 @@
1
+ @import "reset/utilities";
2
+
3
+ @include global-reset;
@@ -0,0 +1,441 @@
1
+ // The list of browsers you want to support.
2
+ // Defaults to all.
3
+ $supported-browsers: browsers() !default;
4
+
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;
8
+
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;
12
+
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 in in context, but there is no current prefix
36
+ // That context is recorded here so other prefixes can be avoided.
37
+ $prefix-context: null;
38
+
39
+ // When a prefix is in a selector or directive scope, this is set to the
40
+ // current prefix value. When `null`, either there is no prefix in scope
41
+ // or the official prefix is being rendered. The `$prefix-context`
42
+ // variable can be used to make that distinction.
43
+ $current-prefix: null;
44
+
45
+ // When in a context that only exists in a particular version
46
+ // this variable is set to those versions.
47
+ $current-browser-versions: ();
48
+
49
+ // The legacy support CSS 2.1 Selectors.
50
+ // Defaults to the $critical-usage-threshold.
51
+ $css-sel2-support-threshold: $critical-usage-threshold !default;
52
+
53
+ // Check if the browser is in scope given the browser support and current prefix minimums.
54
+ @function browser-out-of-scope($browser, $version: null) {
55
+ @if not index($supported-browsers, $browser) {
56
+ @if $debug-browser-support {
57
+ @return "#{$browser} is not listed as a supported browser."
58
+ } @else {
59
+ @return true;
60
+ }
61
+ } @else if not ($current-prefix == null or $current-prefix == browser-prefix($browser)) {
62
+ @if $debug-browser-support {
63
+ @return "#{$browser} #{$version} is incompatible with #{$current-prefix}."
64
+ } @else {
65
+ @return true;
66
+ }
67
+ }
68
+ $current-range: map-get($current-browser-versions, $browser);
69
+ $current-min: if($current-range, nth($current-range, 1), null);
70
+ $current-max: if($current-range, nth($current-range, 2), null);
71
+ @if not ($version and $current-max) {
72
+ // We don't have any versions to compare
73
+ @return false;
74
+ } @else {
75
+ // If the version is less than the current min, it is not supported
76
+ $too-old: compare-browser-versions($browser, $version, $current-max) < 0;
77
+ @if $too-old {
78
+ @if $debug-browser-support {
79
+ @return "The current scope only works with #{display-browser-range($browser, $current-min, $current-max)}.";
80
+ } @else {
81
+ @return true;
82
+ }
83
+ } @else {
84
+ @return false;
85
+ }
86
+ }
87
+ }
88
+
89
+ // Check whether the browser is supported according to the supported browsers,
90
+ // declared minimum support and usage thresholds.
91
+ @function support-legacy-browser($browser, $min-version, $max-version: null, $threshold: $critical-usage-threshold) {
92
+ @if not index($supported-browsers, $browser) {
93
+ @return false;
94
+ }
95
+ // Check agaist usage stats and declared minimums
96
+ $min-required-version: map-get($browser-minimum-versions, $browser);
97
+ $usage: if($max-version,
98
+ omitted-usage($browser, $min-version, $max-version),
99
+ omitted-usage($browser, $min-version));
100
+ @return $usage > $threshold or
101
+ ($min-required-version and
102
+ compare-browser-versions($browser, $max-version or $min-version, $min-required-version) >= 0);
103
+ }
104
+
105
+ // Include content for a legacy browser
106
+ // Version can be a single version string or a list of versions ordered from oldest to newest.
107
+ @mixin for-legacy-browser($browser, $min-version, $max-version: $min-version,
108
+ $threshold: $critical-usage-threshold,
109
+ $ranges: ($browser: $min-version $max-version)) {
110
+ @if not browser-out-of-scope($browser, $max-version) and
111
+ support-legacy-browser($browser, $min-version, $max-version, $threshold)
112
+ {
113
+ @if $debug-browser-support {
114
+ /* Content for #{display-browser-range($browser, $min-version, $max-version)}.
115
+ Min version: #{map-get($browser-minimum-versions, $browser) or unspecified}.
116
+ User threshold to keep: #{$threshold}%. If #{display-browser-range($browser, $min-version, $max-version)} are omitted: #{omitted-usage($browser, $min-version, $max-version)}%. */
117
+ }
118
+ @include with-browser-ranges(intersect-browser-ranges($current-browser-versions, $ranges)) {
119
+ @content;
120
+ }
121
+ } @else if $debug-browser-support and browser-out-of-scope($browser, $max-version) {
122
+ /* Content for #{display-browser-range($browser, $min-version, $max-version)} omitted.
123
+ Not allowed in the current scope: #{browser-out-of-scope($browser, $max-version)} */
124
+ } @else if $debug-browser-support and not
125
+ support-legacy-browser($browser, $min-version, $max-version, $threshold) {
126
+ @if omitted-usage($browser, $min-version, $max-version) > $threshold {
127
+ /* Content for #{display-browser-range($browser, $min-version, $max-version)} omitted.
128
+ User threshold to keep: #{$threshold}%. If #{display-browser-range($browser, $min-version, $max-version)} and below are omitted: #{omitted-usage($browser, $min-version, $max-version)}%. */
129
+ } @else {
130
+ /* Content for #{display-browser-range($browser, $min-version, $max-version)} omitted.
131
+ Minimum support is #{map-get($browser-minimum-versions, $browser)}. */
132
+ }
133
+ }
134
+ }
135
+
136
+ @function display-browser-range($browser, $min-version, $max-version: $min-version) {
137
+ @return "#{unquote($browser)} #{unquote($min-version)}#{if($max-version != $min-version, unquote(' -') unquote($max-version), null)}";
138
+ }
139
+
140
+
141
+ // Renders the content once if any of the legacy browsers are supported.
142
+ // $browsers is a map of browser name to version ranges
143
+ @mixin for-legacy-browsers($browsers, $threshold: $critical-usage-threshold) {
144
+ $rendered: false;
145
+ @each $browser, $range in $browsers {
146
+ @if not $rendered {
147
+ @include for-legacy-browser($browser, $range..., $threshold: $threshold, $ranges: $browsers) {
148
+ $rendered: true;
149
+ @content;
150
+ }
151
+ }
152
+ }
153
+ }
154
+
155
+ // If there's a prefix context in scope, this will only output the content if the prefix matches.
156
+ // Otherwise, sets the current prefix scope and outputs the content.
157
+ @mixin with-prefix($prefix) {
158
+ @if $current-prefix or $prefix-context {
159
+ @if $current-prefix == $prefix or $prefix-context == $prefix {
160
+ @if $debug-browser-support {
161
+ @if $prefix {
162
+ /* content for #{$prefix} because #{$current-prefix or $prefix-context} is already in scope. */
163
+ } @else {
164
+ /* unprefixed content. #{$current-prefix or $prefix-context} is already in scope. */
165
+ }
166
+ }
167
+ $old-prefix-context: $prefix-context;
168
+ $old-prefix: $current-prefix;
169
+ $prefix-context: $prefix-context or $current-prefix !global;
170
+ $current-prefix: $prefix !global;
171
+ @content;
172
+ $prefix-context: $old-prefix-context !global;
173
+ $current-prefix: $old-prefix !global;
174
+ } @else if $prefix == null {
175
+ $old-prefix-context: $prefix-context;
176
+ $prefix-context: $prefix-context or $current-prefix !global;
177
+ $current-prefix: null !global;
178
+ @if $debug-browser-support {
179
+ /* Content for official syntax. Prefix context is still #{$prefix-context}. */
180
+ }
181
+ @content;
182
+ $current-prefix: $prefix-context !global;
183
+ $prefix-context: $old-prefix-context !global;
184
+ } @else if $debug-browser-support {
185
+ /* Omitting content for #{$prefix} because #{$current-prefix} is already in scope. */
186
+ }
187
+ } @else {
188
+ @if $debug-browser-support and $prefix {
189
+ /* Creating new #{$prefix} context. */
190
+ }
191
+ $prefix-context: $prefix !global;
192
+ $current-prefix: $prefix !global;
193
+ @content;
194
+ $current-prefix: null !global;
195
+ $prefix-context: null !global;
196
+ }
197
+ }
198
+
199
+ @function prefixes-for-capability($capability, $threshold, $capability-options: $default-capability-options) {
200
+ $result: ();
201
+ @each $prefix in browser-prefixes($supported-browsers) {
202
+ $result: map-merge($result,
203
+ ($prefix: use-prefix($prefix, $capability, $threshold, $capability-options)));
204
+ }
205
+ @return $result;
206
+ }
207
+
208
+ // Yields to the mixin content once for each prefix required.
209
+ // The current prefix is set to the $current-prefix global for use by the included content.
210
+ // Also yields to the content once with $current-prefix set to null for the official version
211
+ // as long as there's not already a prefix in scope.
212
+ @mixin with-each-prefix($capability, $threshold, $capability-options: $default-capability-options) {
213
+ @each $prefix, $should-use-prefix in prefixes-for-capability($capability, $threshold, $capability-options) {
214
+ @if $should-use-prefix {
215
+ @if $debug-browser-support and type-of($should-use-prefix) == list {
216
+ /* Capability #{$capability} is prefixed with #{$prefix} because #{$should-use-prefix} is required. */
217
+ } @else if $debug-browser-support and type-of($should-use-prefix) == number {
218
+ /* Capability #{$capability} is prefixed with #{$prefix} because #{$should-use-prefix}% of users need it which is more than the threshold of #{$threshold}%. */
219
+ }
220
+ @include with-prefix($prefix) {
221
+ @include with-browser-ranges($capability) {
222
+ @content;
223
+ }
224
+ }
225
+ } @else if $debug-browser-support {
226
+ /* Capability #{$capability} is not prefixed with #{$prefix} because #{prefix-usage($prefix, $capability, $capability-options)}% of users are affected which is less than the threshold of #{$threshold}. */
227
+ }
228
+ }
229
+ @include with-prefix(null) {
230
+ @include with-browser-ranges($capability) {
231
+ @content;
232
+ }
233
+ }
234
+ }
235
+
236
+ // Returns true if at least one browser-version pair in $subset-ranges
237
+ // is a higher (or same) version than the browser-version pairs in
238
+ // $ranges.
239
+ @function has-browser-subset($ranges, $subset-ranges) {
240
+ $found-mismatch: false;
241
+ @each $browser, $subset-range in $subset-ranges {
242
+ $range: map-get($ranges, $browser);
243
+ @if $range {
244
+ $min-1: nth($subset-range, 1);
245
+ $max-1: nth($subset-range, 2);
246
+ $min-2: nth($range, 1);
247
+ $max-2: nth($range, 2);
248
+ @if (compare-browser-versions($browser, $min-2, $min-1) <= 0 and
249
+ compare-browser-versions($browser, $min-1, $max-2) <= 0) or
250
+ (compare-browser-versions($browser, $min-2, $max-1) <= 0 and
251
+ compare-browser-versions($browser, $max-1, $max-2) <= 0) or
252
+ (compare-browser-versions($browser, $min-1, $min-2) <= 0 and
253
+ compare-browser-versions($browser, $max-1, $max-2) >= 0) or
254
+ (compare-browser-versions($browser, $min-1, $min-2) >= 0 and
255
+ compare-browser-versions($browser, $max-1, $max-2) <= 0) {
256
+ @return true;
257
+ } @else {
258
+ $found-mismatch: true
259
+ }
260
+ }
261
+ }
262
+ @return not $found-mismatch;
263
+ }
264
+
265
+ // When the same browser is in both maps, then the minimum will be set
266
+ // to the maximum of the two minimum versions, and the maximum will be
267
+ // set to the minmum of the two maximum versions.
268
+ @function intersect-browser-ranges($ranges, $new-ranges) {
269
+ @each $browser, $new-range in $new-ranges {
270
+ $old-range: map-get($ranges, $browser);
271
+ @if $old-range {
272
+ $old-min: nth($old-range, 1);
273
+ $old-max: nth($old-range, 2);
274
+ $new-min: nth($new-range, 1);
275
+ $new-max: nth($new-range, 2);
276
+ $maximin: if(compare-browser-versions($browser, $old-min, $new-min) > 0,
277
+ $old-min, $new-min);
278
+ $minimax: if(compare-browser-versions($browser, $old-max, $new-max) < 0,
279
+ $old-max, $new-max);
280
+ $ranges: map-merge($ranges, ($browser: $maximin $minimax));
281
+ } @else {
282
+ $ranges: map-merge($ranges, ($browser: $new-range));
283
+ }
284
+ }
285
+ @return $ranges;
286
+ }
287
+
288
+ // If passed a map, that will be the new browser ranges.
289
+ // Otherwise a range map will be created based on the given capability and prefix
290
+ // using the `browser-ranges($capability, $prefix)` function.
291
+ //
292
+ // If there are current ranges in scope and the new ranges have some overlap
293
+ // with the current,
294
+ //
295
+ // If there is no overlap, then the content will not be rendered.
296
+ @mixin with-browser-ranges($capability, $prefix: $current-prefix) {
297
+ $new-ranges: null;
298
+ @if type-of($capability) == map {
299
+ $new-ranges: $capability;
300
+ } @else {
301
+ $new-ranges: browser-ranges($capability, $prefix);
302
+ }
303
+
304
+ @if has-browser-subset($current-browser-versions, $new-ranges) {
305
+ $old-ranges: $current-browser-versions;
306
+ $current-browser-versions: intersect-browser-ranges($old-ranges, $new-ranges) !global;
307
+ @content;
308
+ $current-browser-versions: $old-ranges !global;
309
+ } @else if $debug-browser-support {
310
+ /* Excluding content because #{inspect($new-ranges)} is not included within
311
+ #{inspect($current-browser-versions)} */
312
+ }
313
+ }
314
+
315
+ // Returns true if the prefixed usage stats for the capability exceed the threshold
316
+ // or if the minimum version for a supported browser would require a prefix for the capability.
317
+ @function use-prefix($prefix, $capability, $threshold, $capability-options: $default-capability-options) {
318
+ $usage: prefix-usage($prefix, $capability, $capability-options);
319
+ @if $usage > $threshold {
320
+ @return $usage;
321
+ } @else {
322
+ @each $browser in browsers($prefix) {
323
+ @if index($supported-browsers, $browser) {
324
+ $min-version: map-get($browser-minimum-versions, $browser);
325
+ @if $min-version {
326
+ $actual-prefix: browser-requires-prefix($browser, $min-version, $capability, $capability-options);
327
+ @if $actual-prefix and $prefix == $actual-prefix {
328
+ @return $browser $min-version;
329
+ }
330
+ }
331
+ }
332
+ }
333
+ }
334
+ @return false;
335
+ }
336
+
337
+ @function prefix-identifier($ident, $prefix: $current-prefix) {
338
+ @return unquote("#{$prefix}#{if($prefix, '-', null)}#{$ident}");
339
+ }
340
+
341
+ // Output a property and value using the current prefix.
342
+ // It will be unprefixed if $current-prefix is null.
343
+ @mixin prefix-prop($property, $value, $prefix: $current-prefix) {
344
+ #{prefix-identifier($property, $prefix)}: $value;
345
+ }
346
+
347
+ // Emit a set of properties with the prefix governed by the capability and usage threshold given.
348
+ //
349
+ // Example:
350
+ //
351
+ // @include prefixed-properties(css-animation, $animation-support-threshold,
352
+ // (animation-name: foo, animation-duration: 2s)
353
+ // );
354
+ @mixin prefixed-properties($capability, $threshold, $properties, $capability-options: $default-capability-options) {
355
+ @include with-each-prefix($capability, $threshold, $capability-options) {
356
+ @each $prop, $value in $properties {
357
+ @include prefix-prop($prop, $value);
358
+ }
359
+ }
360
+ }
361
+
362
+
363
+ // @private
364
+ @function warn-about-old-variables() {
365
+ $old-variables-in-use: ();
366
+ @each $old-variable-name in
367
+ (legacy-support-for-ie, legacy-support-for-ie6, legacy-support-for-ie7,
368
+ legacy-support-for-ie8, legacy-support-for-mozilla, legacy-support-for-webkit,
369
+ experimental-support-for-mozilla, experimental-support-for-webkit,
370
+ experimental-support-for-opera, experimental-support-for-microsoft,
371
+ experimental-support-for-khtml, experimental-support-for-svg)
372
+ {
373
+ @if global-variable-exists($old-variable-name) {
374
+ $old-variables-in-use: append($old-variables-in-use,
375
+ unquote("$#{$old-variable-name}"), comma);
376
+ }
377
+ }
378
+ @if length($old-variables-in-use) > 0 {
379
+ @warn "Compass has changed how browser support is configured. " +
380
+ "See the CHANGELOG for more details. The following configuration variables " +
381
+ "are no longer supported: #{$old-variables-in-use}."
382
+ }
383
+ @return $old-variables-in-use;
384
+ }
385
+
386
+ // @private
387
+ @function warn-about-pie-removal() {
388
+ @if global-variable-exists(experimental-support-for-pie) {
389
+ @warn "Compass no longer supports css3pie.";
390
+ }
391
+ @return true;
392
+ }
393
+
394
+ // Enable browser support debugging within the content block.
395
+ // Or you can enable it for the whole stylesheet by setting `$debug-browser-support` to true.
396
+ @mixin with-browser-support-debugging {
397
+ $current-status: $debug-browser-support;
398
+ $debug-browser-support: true !global;
399
+ @content;
400
+ $debug-browser-support: $current-status !global;
401
+ }
402
+
403
+ // Set a default value if the given arglist is empty
404
+ @function set-arglist-default($arglist, $default) {
405
+ $default-index: index($arglist, default);
406
+ @if $default-index {
407
+ $arglist: set-nth($arglist, $default-index, $default)
408
+ }
409
+ @return if(length($arglist) > 0, $arglist, $default);
410
+ }
411
+
412
+
413
+ // @private
414
+ $old-variable-warnings-issued: warn-about-old-variables() !default;
415
+
416
+ // @private
417
+ $pie-removal-warnging-issued: warn-about-pie-removal() !default;
418
+
419
+ // @private
420
+ @function warn-about-useless-prefix-arguments($moz: null, $webkit: null, $o: null, $khtml: null, $official: null) {
421
+ @if $moz != null or $webkit != null or $o != null or $khtml != null or $official != null {
422
+ @warn "Browser prefix arguments to this mixin are no longer used and " +
423
+ "will be removed in the next release.";
424
+ }
425
+ @return true;
426
+ }
427
+
428
+ // coerce a list to be comma delimited or make a new, empty comma delimited list.
429
+ @function comma-list($list: ()) {
430
+ @return join((), $list, comma);
431
+ }
432
+
433
+ // @private Returns the legacy value for a given box-model
434
+ // - Used by background-clip and -origin.
435
+ @function legacy-box($box) {
436
+ $box: unquote($box);
437
+ @if $box == padding-box { $box: padding; }
438
+ @if $box == border-box { $box: border; }
439
+ @if $box == content-box { $box: content; }
440
+ @return $box;
441
+ }