WIP adding css property names to string cache

This commit is contained in:
Tyler Hallada 2020-03-19 14:34:24 -04:00
parent f6f8088b64
commit 0d07cd8ed8
7 changed files with 1366 additions and 10 deletions

13
Cargo.lock generated
View File

@ -469,6 +469,7 @@ dependencies = [
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"string_cache 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"string_cache_codegen 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"typed-arena 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "typed-arena 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -556,6 +557,17 @@ dependencies = [
"string_cache_shared 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache_shared 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "string_cache_codegen"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"phf_generator 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"phf_shared 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "string_cache_shared" name = "string_cache_shared"
version = "0.3.0" version = "0.3.0"
@ -728,6 +740,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum string_cache 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "25d70109977172b127fe834e5449e5ab1740b9ba49fa18a2020f509174f25423" "checksum string_cache 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "25d70109977172b127fe834e5449e5ab1740b9ba49fa18a2020f509174f25423"
"checksum string_cache 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2940c75beb4e3bf3a494cef919a747a2cb81e52571e212bfbd185074add7208a" "checksum string_cache 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2940c75beb4e3bf3a494cef919a747a2cb81e52571e212bfbd185074add7208a"
"checksum string_cache_codegen 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1eea1eee654ef80933142157fdad9dd8bc43cf7c74e999e369263496f04ff4da" "checksum string_cache_codegen 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1eea1eee654ef80933142157fdad9dd8bc43cf7c74e999e369263496f04ff4da"
"checksum string_cache_codegen 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f24c8e5e19d22a726626f1a5e16fe15b132dcf21d10177fa5a45ce7962996b97"
"checksum string_cache_shared 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b1884d1bc09741d466d9b14e6d37ac89d6909cbcac41dd9ae982d4d063bbedfc" "checksum string_cache_shared 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b1884d1bc09741d466d9b14e6d37ac89d6909cbcac41dd9ae982d4d063bbedfc"
"checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9" "checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9"
"checksum syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)" = "123bd9499cfb380418d509322d7a6d52e5315f064fe4b3ad18a53d6b92c07859" "checksum syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)" = "123bd9499cfb380418d509322d7a6d52e5315f064fe4b3ad18a53d6b92c07859"

View File

@ -12,3 +12,6 @@ maplit = "1.0.2"
string_cache = "0.8" string_cache = "0.8"
typed-arena = "2.0.1" typed-arena = "2.0.1"
url = "2.1.1" url = "2.1.1"
[build-dependencies]
string_cache_codegen = "0.5"

655
build.rs Normal file
View File

@ -0,0 +1,655 @@
extern crate string_cache_codegen;
use std::env;
use std::path::Path;
fn main() {
string_cache_codegen::AtomType::new("css_property::CssProperty", "css_property!")
.atoms(vec![
"-moz-appearance",
"-moz-background-inline-policy",
"-moz-box-sizing",
"-moz-column-count",
"-moz-column-fill",
"-moz-column-gap",
"-moz-column-rule",
"-moz-column-rule-color",
"-moz-column-rule-style",
"-moz-column-rule-width",
"-moz-column-width",
"-moz-font-feature-settings",
"-moz-font-language-override",
"-moz-hyphens",
"-moz-text-align-last",
"-moz-text-decoration-color",
"-moz-text-decoration-line",
"-moz-text-decoration-style",
"-moz-text-size-adjust",
"-ms-background-position-x",
"-ms-background-position-y",
"-ms-block-progression",
"-ms-content-zoom-chaining",
"-ms-content-zoom-limit",
"-ms-content-zoom-limit-max",
"-ms-content-zoom-limit-min",
"-ms-content-zoom-snap",
"-ms-content-zoom-snap-points",
"-ms-content-zoom-snap-type",
"-ms-content-zooming",
"-ms-filter",
"-ms-flex",
"-ms-flex-align",
"-ms-flex-direction",
"-ms-flex-order",
"-ms-flex-pack",
"-ms-flex-wrap",
"-ms-flow-from",
"-ms-flow-into",
"-ms-grid-column",
"-ms-grid-column-align",
"-ms-grid-column-span",
"-ms-grid-columns",
"-ms-grid-row",
"-ms-grid-row-align",
"-ms-grid-row-span",
"-ms-grid-rows",
"-ms-high-contrast-adjust",
"-ms-hyphenate-limit-chars",
"-ms-hyphenate-limit-lines",
"-ms-hyphenate-limit-zone",
"-ms-hyphens",
"-ms-ime-mode",
"-ms-interpolation-mode",
"-ms-layout-flow",
"-ms-layout-grid",
"-ms-layout-grid-char",
"-ms-layout-grid-line",
"-ms-layout-grid-mode",
"-ms-layout-grid-type",
"-ms-overflow-style",
"-ms-overflow-x",
"-ms-overflow-y",
"-ms-progress-appearance",
"-ms-scroll-chaining",
"-ms-scroll-limit",
"-ms-scroll-limit-x-max",
"-ms-scroll-limit-x-min",
"-ms-scroll-limit-y-max",
"-ms-scroll-limit-y-min",
"-ms-scroll-rails",
"-ms-scroll-snap-points-x",
"-ms-scroll-snap-points-y",
"-ms-scroll-snap-type",
"-ms-scroll-snap-x",
"-ms-scroll-snap-y",
"-ms-scroll-translation",
"-ms-scrollbar-arrow-color",
"-ms-scrollbar-base-color",
"-ms-scrollbar-darkshadow-color",
"-ms-scrollbar-face-color",
"-ms-scrollbar-highlight-color",
"-ms-scrollbar-shadow-color",
"-ms-scrollbar-track-color",
"-ms-text-align-last",
"-ms-text-autospace",
"-ms-text-justify",
"-ms-text-kashida-space",
"-ms-text-overflow",
"-ms-text-size-adjust",
"-ms-text-underline-position",
"-ms-touch-action",
"-ms-user-select",
"-ms-word-break",
"-ms-word-wrap",
"-ms-wrap-flow",
"-ms-wrap-margin",
"-ms-wrap-through",
"-ms-writing-mode",
"-ms-zoom",
"-webkit-align-content",
"-webkit-align-items",
"-webkit-align-self",
"-webkit-animation",
"-webkit-animation-delay",
"-webkit-animation-direction",
"-webkit-animation-duration",
"-webkit-animation-fill-mode",
"-webkit-animation-iteration-count",
"-webkit-animation-name",
"-webkit-animation-play-state",
"-webkit-animation-timing-function",
"-webkit-appearance",
"-webkit-backface-visibility",
"-webkit-background-blend-mode",
"-webkit-background-clip",
"-webkit-background-composite",
"-webkit-background-origin",
"-webkit-background-size",
"-webkit-blend-mode",
"-webkit-border-after",
"-webkit-border-after-color",
"-webkit-border-after-style",
"-webkit-border-after-width",
"-webkit-border-before",
"-webkit-border-before-color",
"-webkit-border-before-style",
"-webkit-border-before-width",
"-webkit-border-bottom-left-radius",
"-webkit-border-bottom-right-radius",
"-webkit-border-end",
"-webkit-border-end-color",
"-webkit-border-end-style",
"-webkit-border-end-width",
"-webkit-border-fit",
"-webkit-border-image",
"-webkit-border-radius",
"-webkit-border-start",
"-webkit-border-start-color",
"-webkit-border-start-style",
"-webkit-border-start-width",
"-webkit-border-top-left-radius",
"-webkit-border-top-right-radius",
"-webkit-box-align",
"-webkit-box-decoration-break",
"-webkit-box-flex",
"-webkit-box-flex-group",
"-webkit-box-lines",
"-webkit-box-ordinal-group",
"-webkit-box-orient",
"-webkit-box-pack",
"-webkit-box-reflect",
"-webkit-box-shadow",
"-webkit-box-sizing",
"-webkit-clip-path",
"-webkit-column-axis",
"-webkit-column-break-after",
"-webkit-column-break-before",
"-webkit-column-break-inside",
"-webkit-column-count",
"-webkit-column-gap",
"-webkit-column-progression",
"-webkit-column-rule",
"-webkit-column-rule-color",
"-webkit-column-rule-style",
"-webkit-column-rule-width",
"-webkit-column-span",
"-webkit-column-width",
"-webkit-columns",
"-webkit-filter",
"-webkit-flex",
"-webkit-flex-basis",
"-webkit-flex-direction",
"-webkit-flex-flow",
"-webkit-flex-grow",
"-webkit-flex-shrink",
"-webkit-flex-wrap",
"-webkit-flow-from",
"-webkit-flow-into",
"-webkit-font-size-delta",
"-webkit-font-smoothing",
"-webkit-grid-area",
"-webkit-grid-auto-columns",
"-webkit-grid-auto-flow",
"-webkit-grid-auto-rows",
"-webkit-grid-column",
"-webkit-grid-column-end",
"-webkit-grid-column-start",
"-webkit-grid-definition-columns",
"-webkit-grid-definition-rows",
"-webkit-grid-row",
"-webkit-grid-row-end",
"-webkit-grid-row-start",
"-webkit-justify-content",
"-webkit-line-clamp",
"-webkit-logical-height",
"-webkit-logical-width",
"-webkit-margin-after",
"-webkit-margin-after-collapse",
"-webkit-margin-before",
"-webkit-margin-before-collapse",
"-webkit-margin-bottom-collapse",
"-webkit-margin-collapse",
"-webkit-margin-end",
"-webkit-margin-start",
"-webkit-margin-top-collapse",
"-webkit-marquee",
"-webkit-marquee-direction",
"-webkit-marquee-increment",
"-webkit-marquee-repetition",
"-webkit-marquee-speed",
"-webkit-marquee-style",
"-webkit-mask",
"-webkit-mask-box-image",
"-webkit-mask-box-image-outset",
"-webkit-mask-box-image-repeat",
"-webkit-mask-box-image-slice",
"-webkit-mask-box-image-source",
"-webkit-mask-box-image-width",
"-webkit-mask-clip",
"-webkit-mask-composite",
"-webkit-mask-image",
"-webkit-mask-origin",
"-webkit-mask-position",
"-webkit-mask-position-x",
"-webkit-mask-position-y",
"-webkit-mask-repeat",
"-webkit-mask-repeat-x",
"-webkit-mask-repeat-y",
"-webkit-mask-size",
"-webkit-mask-source-type",
"-webkit-max-logical-height",
"-webkit-max-logical-width",
"-webkit-min-logical-height",
"-webkit-min-logical-width",
"-webkit-opacity",
"-webkit-order",
"-webkit-padding-after",
"-webkit-padding-before",
"-webkit-padding-end",
"-webkit-padding-start",
"-webkit-perspective",
"-webkit-perspective-origin",
"-webkit-perspective-origin-x",
"-webkit-perspective-origin-y",
"-webkit-region-break-after",
"-webkit-region-break-before",
"-webkit-region-break-inside",
"-webkit-region-fragment",
"-webkit-shape-inside",
"-webkit-shape-margin",
"-webkit-shape-outside",
"-webkit-shape-padding",
"-webkit-svg-shadow",
"-webkit-tap-highlight-color",
"-webkit-text-decoration",
"-webkit-text-decoration-color",
"-webkit-text-decoration-line",
"-webkit-text-decoration-style",
"-webkit-text-size-adjust",
"-webkit-touch-callout",
"-webkit-transform",
"-webkit-transform-origin",
"-webkit-transform-origin-x",
"-webkit-transform-origin-y",
"-webkit-transform-origin-z",
"-webkit-transform-style",
"-webkit-transition",
"-webkit-transition-delay",
"-webkit-transition-duration",
"-webkit-transition-property",
"-webkit-transition-timing-function",
"-webkit-user-drag",
"-webkit-wrap-flow",
"-webkit-wrap-through",
"align-content",
"align-items",
"align-self",
"alignment-adjust",
"alignment-baseline",
"all",
"anchor-point",
"animation",
"animation-delay",
"animation-direction",
"animation-duration",
"animation-fill-mode",
"animation-iteration-count",
"animation-name",
"animation-play-state",
"animation-timing-function",
"azimuth",
"backface-visibility",
"background",
"background-attachment",
"background-clip",
"background-color",
"background-image",
"background-origin",
"background-position",
"background-repeat",
"background-size",
"baseline-shift",
"binding",
"bleed",
"bookmark-label",
"bookmark-level",
"bookmark-state",
"border",
"border-bottom",
"border-bottom-color",
"border-bottom-left-radius",
"border-bottom-right-radius",
"border-bottom-style",
"border-bottom-width",
"border-collapse",
"border-color",
"border-image",
"border-image-outset",
"border-image-repeat",
"border-image-slice",
"border-image-source",
"border-image-width",
"border-left",
"border-left-color",
"border-left-style",
"border-left-width",
"border-radius",
"border-right",
"border-right-color",
"border-right-style",
"border-right-width",
"border-spacing",
"border-style",
"border-top",
"border-top-color",
"border-top-left-radius",
"border-top-right-radius",
"border-top-style",
"border-top-width",
"border-width",
"bottom",
"box-decoration-break",
"box-shadow",
"box-sizing",
"box-snap",
"box-suppress",
"break-after",
"break-before",
"break-inside",
"caption-side",
"chains",
"clear",
"clip",
"clip-path",
"clip-rule",
"color",
"color-interpolation",
"color-interpolation-filters",
"color-profile",
"color-rendering",
"column-count",
"column-fill",
"column-gap",
"column-rule",
"column-rule-color",
"column-rule-style",
"column-rule-width",
"column-span",
"column-width",
"columns",
"contain",
"content",
"counter-increment",
"counter-reset",
"counter-set",
"crop",
"cue",
"cue-after",
"cue-before",
"cursor",
"direction",
"display",
"display-inside",
"display-list",
"display-outside",
"dominant-baseline",
"elevation",
"empty-cells",
"enable-background",
"fill",
"fill-opacity",
"fill-rule",
"filter",
"flex",
"flex-basis",
"flex-direction",
"flex-flow",
"flex-grow",
"flex-shrink",
"flex-wrap",
"float",
"float-offset",
"flood-color",
"flood-opacity",
"flow-from",
"flow-into",
"font",
"font-family",
"font-feature-settings",
"font-kerning",
"font-language-override",
"font-size",
"font-size-adjust",
"font-stretch",
"font-style",
"font-synthesis",
"font-variant",
"font-variant-alternates",
"font-variant-caps",
"font-variant-east-asian",
"font-variant-ligatures",
"font-variant-numeric",
"font-variant-position",
"font-weight",
"glyph-orientation-horizontal",
"glyph-orientation-vertical",
"grid",
"grid-area",
"grid-auto-columns",
"grid-auto-flow",
"grid-auto-rows",
"grid-column",
"grid-column-end",
"grid-column-start",
"grid-row",
"grid-row-end",
"grid-row-start",
"grid-template",
"grid-template-areas",
"grid-template-columns",
"grid-template-rows",
"hanging-punctuation",
"height",
"hyphens",
"icon",
"image-orientation",
"image-rendering",
"image-resolution",
"ime-mode",
"initial-letters",
"inline-box-align",
"justify-content",
"justify-items",
"justify-self",
"kerning",
"left",
"letter-spacing",
"lighting-color",
"line-box-contain",
"line-break",
"line-grid",
"line-height",
"line-snap",
"line-stacking",
"line-stacking-ruby",
"line-stacking-shift",
"line-stacking-strategy",
"list-style",
"list-style-image",
"list-style-position",
"list-style-type",
"margin",
"margin-bottom",
"margin-left",
"margin-right",
"margin-top",
"marker",
"marker-end",
"marker-mid",
"marker-offset",
"marker-side",
"marker-start",
"marks",
"mask",
"mask-box",
"mask-box-outset",
"mask-box-repeat",
"mask-box-slice",
"mask-box-source",
"mask-box-width",
"mask-clip",
"mask-image",
"mask-origin",
"mask-position",
"mask-repeat",
"mask-size",
"mask-source-type",
"mask-type",
"max-height",
"max-lines",
"max-width",
"min-height",
"min-width",
"move-to",
"nav-down",
"nav-index",
"nav-left",
"nav-right",
"nav-up",
"object-fit",
"object-position",
"opacity",
"order",
"orphans",
"outline",
"outline-color",
"outline-offset",
"outline-style",
"outline-width",
"overflow",
"overflow-wrap",
"overflow-x",
"overflow-y",
"padding",
"padding-bottom",
"padding-left",
"padding-right",
"padding-top",
"page",
"page-break-after",
"page-break-before",
"page-break-inside",
"page-policy",
"pause",
"pause-after",
"pause-before",
"perspective",
"perspective-origin",
"pitch",
"pitch-range",
"play-during",
"pointer-events",
"position",
"presentation-level",
"quotes",
"region-fragment",
"resize",
"rest",
"rest-after",
"rest-before",
"richness",
"right",
"rotation",
"rotation-point",
"ruby-align",
"ruby-merge",
"ruby-position",
"shape-image-threshold",
"shape-margin",
"shape-outside",
"shape-rendering",
"size",
"speak",
"speak-as",
"speak-header",
"speak-numeral",
"speak-punctuation",
"speech-rate",
"stop-color",
"stop-opacity",
"stress",
"string-set",
"stroke",
"stroke-dasharray",
"stroke-dashoffset",
"stroke-linecap",
"stroke-linejoin",
"stroke-miterlimit",
"stroke-opacity",
"stroke-width",
"tab-size",
"table-layout",
"text-align",
"text-align-last",
"text-anchor",
"text-combine-horizontal",
"text-combine-upright",
"text-decoration",
"text-decoration-color",
"text-decoration-line",
"text-decoration-skip",
"text-decoration-style",
"text-emphasis",
"text-emphasis-color",
"text-emphasis-position",
"text-emphasis-style",
"text-height",
"text-indent",
"text-justify",
"text-orientation",
"text-overflow",
"text-rendering",
"text-shadow",
"text-size-adjust",
"text-space-collapse",
"text-transform",
"text-underline-position",
"text-wrap",
"top",
"touch-action",
"transform",
"transform-origin",
"transform-style",
"transition",
"transition-delay",
"transition-duration",
"transition-property",
"transition-timing-function",
"unicode-bidi",
"unicode-range",
"vertical-align",
"visibility",
"voice-balance",
"voice-duration",
"voice-family",
"voice-pitch",
"voice-range",
"voice-rate",
"voice-stress",
"voice-volume",
"volume",
"white-space",
"widows",
"width",
"will-change",
"word-break",
"word-spacing",
"word-wrap",
"wrap-flow",
"wrap-through",
"writing-mode",
"z-index",
])
.write_to_file(&Path::new(&env::var("OUT_DIR").unwrap()).join("css_property.rs"))
.unwrap()
}

View File

@ -69,4 +69,5 @@ lazy_static! {
local_name!("cite") => hashset!{"http", "https"}, local_name!("cite") => hashset!{"http", "https"},
}, },
}; };
pub static ref CSS_PROPERTIES: Vec<String> = vec![];
} }

View File

@ -4,9 +4,17 @@ use std::collections::{HashMap, HashSet};
use super::basic::{ use super::basic::{
ADD_ATTRIBUTES as BASIC_ADD_ATTRIBUTES, ALL_ATTRIBUTES as BASIC_ALL_ATTRIBUTES, ADD_ATTRIBUTES as BASIC_ADD_ATTRIBUTES, ALL_ATTRIBUTES as BASIC_ALL_ATTRIBUTES,
ATTRIBUTES as BASIC_ATTRIBUTES, ELEMENTS as BASIC_ELEMENTS, ATTRIBUTES as BASIC_ATTRIBUTES, CSS_PROPERTIES as BASIC_CSS_PROPERTIES,
ELEMENTS as BASIC_ELEMENTS,
}; };
#[macro_use]
mod css_property {
include!(concat!(env!("OUT_DIR"), "/css_property.rs"));
}
use css_property::{CssProperty};
lazy_static! { lazy_static! {
pub static ref ELEMENTS: HashSet<LocalName> = BASIC_ELEMENTS pub static ref ELEMENTS: HashSet<LocalName> = BASIC_ELEMENTS
.union(&hashset!( .union(&hashset!(
@ -196,4 +204,649 @@ lazy_static! {
local_name!("cite") => hashset!{"http", "https"}, local_name!("cite") => hashset!{"http", "https"},
}, },
}; };
pub static ref CSS_PROPERTIES: Vec<CssProperty> = vec![
css_property!("-moz-appearance"),
css_property!("-moz-background-inline-policy"),
css_property!("-moz-box-sizing"),
css_property!("-moz-column-count"),
css_property!("-moz-column-fill"),
css_property!("-moz-column-gap"),
css_property!("-moz-column-rule"),
css_property!("-moz-column-rule-color"),
css_property!("-moz-column-rule-style"),
css_property!("-moz-column-rule-width"),
css_property!("-moz-column-width"),
css_property!("-moz-font-feature-settings"),
css_property!("-moz-font-language-override"),
css_property!("-moz-hyphens"),
css_property!("-moz-text-align-last"),
css_property!("-moz-text-decoration-color"),
css_property!("-moz-text-decoration-line"),
css_property!("-moz-text-decoration-style"),
css_property!("-moz-text-size-adjust"),
css_property!("-ms-background-position-x"),
css_property!("-ms-background-position-y"),
css_property!("-ms-block-progression"),
css_property!("-ms-content-zoom-chaining"),
css_property!("-ms-content-zoom-limit"),
css_property!("-ms-content-zoom-limit-max"),
css_property!("-ms-content-zoom-limit-min"),
css_property!("-ms-content-zoom-snap"),
css_property!("-ms-content-zoom-snap-points"),
css_property!("-ms-content-zoom-snap-type"),
css_property!("-ms-content-zooming"),
css_property!("-ms-filter"),
css_property!("-ms-flex"),
css_property!("-ms-flex-align"),
css_property!("-ms-flex-direction"),
css_property!("-ms-flex-order"),
css_property!("-ms-flex-pack"),
css_property!("-ms-flex-wrap"),
css_property!("-ms-flow-from"),
css_property!("-ms-flow-into"),
css_property!("-ms-grid-column"),
css_property!("-ms-grid-column-align"),
css_property!("-ms-grid-column-span"),
css_property!("-ms-grid-columns"),
css_property!("-ms-grid-row"),
css_property!("-ms-grid-row-align"),
css_property!("-ms-grid-row-span"),
css_property!("-ms-grid-rows"),
css_property!("-ms-high-contrast-adjust"),
css_property!("-ms-hyphenate-limit-chars"),
css_property!("-ms-hyphenate-limit-lines"),
css_property!("-ms-hyphenate-limit-zone"),
css_property!("-ms-hyphens"),
css_property!("-ms-ime-mode"),
css_property!("-ms-interpolation-mode"),
css_property!("-ms-layout-flow"),
css_property!("-ms-layout-grid"),
css_property!("-ms-layout-grid-char"),
css_property!("-ms-layout-grid-line"),
css_property!("-ms-layout-grid-mode"),
css_property!("-ms-layout-grid-type"),
css_property!("-ms-overflow-style"),
css_property!("-ms-overflow-x"),
css_property!("-ms-overflow-y"),
css_property!("-ms-progress-appearance"),
css_property!("-ms-scroll-chaining"),
css_property!("-ms-scroll-limit"),
css_property!("-ms-scroll-limit-x-max"),
css_property!("-ms-scroll-limit-x-min"),
css_property!("-ms-scroll-limit-y-max"),
css_property!("-ms-scroll-limit-y-min"),
css_property!("-ms-scroll-rails"),
css_property!("-ms-scroll-snap-points-x"),
css_property!("-ms-scroll-snap-points-y"),
css_property!("-ms-scroll-snap-type"),
css_property!("-ms-scroll-snap-x"),
css_property!("-ms-scroll-snap-y"),
css_property!("-ms-scroll-translation"),
css_property!("-ms-scrollbar-arrow-color"),
css_property!("-ms-scrollbar-base-color"),
css_property!("-ms-scrollbar-darkshadow-color"),
css_property!("-ms-scrollbar-face-color"),
css_property!("-ms-scrollbar-highlight-color"),
css_property!("-ms-scrollbar-shadow-color"),
css_property!("-ms-scrollbar-track-color"),
css_property!("-ms-text-align-last"),
css_property!("-ms-text-autospace"),
css_property!("-ms-text-justify"),
css_property!("-ms-text-kashida-space"),
css_property!("-ms-text-overflow"),
css_property!("-ms-text-size-adjust"),
css_property!("-ms-text-underline-position"),
css_property!("-ms-touch-action"),
css_property!("-ms-user-select"),
css_property!("-ms-word-break"),
css_property!("-ms-word-wrap"),
css_property!("-ms-wrap-flow"),
css_property!("-ms-wrap-margin"),
css_property!("-ms-wrap-through"),
css_property!("-ms-writing-mode"),
css_property!("-ms-zoom"),
css_property!("-webkit-align-content"),
css_property!("-webkit-align-items"),
css_property!("-webkit-align-self"),
css_property!("-webkit-animation"),
css_property!("-webkit-animation-delay"),
css_property!("-webkit-animation-direction"),
css_property!("-webkit-animation-duration"),
css_property!("-webkit-animation-fill-mode"),
css_property!("-webkit-animation-iteration-count"),
css_property!("-webkit-animation-name"),
css_property!("-webkit-animation-play-state"),
css_property!("-webkit-animation-timing-function"),
css_property!("-webkit-appearance"),
css_property!("-webkit-backface-visibility"),
css_property!("-webkit-background-blend-mode"),
css_property!("-webkit-background-clip"),
css_property!("-webkit-background-composite"),
css_property!("-webkit-background-origin"),
css_property!("-webkit-background-size"),
css_property!("-webkit-blend-mode"),
css_property!("-webkit-border-after"),
css_property!("-webkit-border-after-color"),
css_property!("-webkit-border-after-style"),
css_property!("-webkit-border-after-width"),
css_property!("-webkit-border-before"),
css_property!("-webkit-border-before-color"),
css_property!("-webkit-border-before-style"),
css_property!("-webkit-border-before-width"),
css_property!("-webkit-border-bottom-left-radius"),
css_property!("-webkit-border-bottom-right-radius"),
css_property!("-webkit-border-end"),
css_property!("-webkit-border-end-color"),
css_property!("-webkit-border-end-style"),
css_property!("-webkit-border-end-width"),
css_property!("-webkit-border-fit"),
css_property!("-webkit-border-image"),
css_property!("-webkit-border-radius"),
css_property!("-webkit-border-start"),
css_property!("-webkit-border-start-color"),
css_property!("-webkit-border-start-style"),
css_property!("-webkit-border-start-width"),
css_property!("-webkit-border-top-left-radius"),
css_property!("-webkit-border-top-right-radius"),
css_property!("-webkit-box-align"),
css_property!("-webkit-box-decoration-break"),
css_property!("-webkit-box-flex"),
css_property!("-webkit-box-flex-group"),
css_property!("-webkit-box-lines"),
css_property!("-webkit-box-ordinal-group"),
css_property!("-webkit-box-orient"),
css_property!("-webkit-box-pack"),
css_property!("-webkit-box-reflect"),
css_property!("-webkit-box-shadow"),
css_property!("-webkit-box-sizing"),
css_property!("-webkit-clip-path"),
css_property!("-webkit-column-axis"),
css_property!("-webkit-column-break-after"),
css_property!("-webkit-column-break-before"),
css_property!("-webkit-column-break-inside"),
css_property!("-webkit-column-count"),
css_property!("-webkit-column-gap"),
css_property!("-webkit-column-progression"),
css_property!("-webkit-column-rule"),
css_property!("-webkit-column-rule-color"),
css_property!("-webkit-column-rule-style"),
css_property!("-webkit-column-rule-width"),
css_property!("-webkit-column-span"),
css_property!("-webkit-column-width"),
css_property!("-webkit-columns"),
css_property!("-webkit-filter"),
css_property!("-webkit-flex"),
css_property!("-webkit-flex-basis"),
css_property!("-webkit-flex-direction"),
css_property!("-webkit-flex-flow"),
css_property!("-webkit-flex-grow"),
css_property!("-webkit-flex-shrink"),
css_property!("-webkit-flex-wrap"),
css_property!("-webkit-flow-from"),
css_property!("-webkit-flow-into"),
css_property!("-webkit-font-size-delta"),
css_property!("-webkit-font-smoothing"),
css_property!("-webkit-grid-area"),
css_property!("-webkit-grid-auto-columns"),
css_property!("-webkit-grid-auto-flow"),
css_property!("-webkit-grid-auto-rows"),
css_property!("-webkit-grid-column"),
css_property!("-webkit-grid-column-end"),
css_property!("-webkit-grid-column-start"),
css_property!("-webkit-grid-definition-columns"),
css_property!("-webkit-grid-definition-rows"),
css_property!("-webkit-grid-row"),
css_property!("-webkit-grid-row-end"),
css_property!("-webkit-grid-row-start"),
css_property!("-webkit-justify-content"),
css_property!("-webkit-line-clamp"),
css_property!("-webkit-logical-height"),
css_property!("-webkit-logical-width"),
css_property!("-webkit-margin-after"),
css_property!("-webkit-margin-after-collapse"),
css_property!("-webkit-margin-before"),
css_property!("-webkit-margin-before-collapse"),
css_property!("-webkit-margin-bottom-collapse"),
css_property!("-webkit-margin-collapse"),
css_property!("-webkit-margin-end"),
css_property!("-webkit-margin-start"),
css_property!("-webkit-margin-top-collapse"),
css_property!("-webkit-marquee"),
css_property!("-webkit-marquee-direction"),
css_property!("-webkit-marquee-increment"),
css_property!("-webkit-marquee-repetition"),
css_property!("-webkit-marquee-speed"),
css_property!("-webkit-marquee-style"),
css_property!("-webkit-mask"),
css_property!("-webkit-mask-box-image"),
css_property!("-webkit-mask-box-image-outset"),
css_property!("-webkit-mask-box-image-repeat"),
css_property!("-webkit-mask-box-image-slice"),
css_property!("-webkit-mask-box-image-source"),
css_property!("-webkit-mask-box-image-width"),
css_property!("-webkit-mask-clip"),
css_property!("-webkit-mask-composite"),
css_property!("-webkit-mask-image"),
css_property!("-webkit-mask-origin"),
css_property!("-webkit-mask-position"),
css_property!("-webkit-mask-position-x"),
css_property!("-webkit-mask-position-y"),
css_property!("-webkit-mask-repeat"),
css_property!("-webkit-mask-repeat-x"),
css_property!("-webkit-mask-repeat-y"),
css_property!("-webkit-mask-size"),
css_property!("-webkit-mask-source-type"),
css_property!("-webkit-max-logical-height"),
css_property!("-webkit-max-logical-width"),
css_property!("-webkit-min-logical-height"),
css_property!("-webkit-min-logical-width"),
css_property!("-webkit-opacity"),
css_property!("-webkit-order"),
css_property!("-webkit-padding-after"),
css_property!("-webkit-padding-before"),
css_property!("-webkit-padding-end"),
css_property!("-webkit-padding-start"),
css_property!("-webkit-perspective"),
css_property!("-webkit-perspective-origin"),
css_property!("-webkit-perspective-origin-x"),
css_property!("-webkit-perspective-origin-y"),
css_property!("-webkit-region-break-after"),
css_property!("-webkit-region-break-before"),
css_property!("-webkit-region-break-inside"),
css_property!("-webkit-region-fragment"),
css_property!("-webkit-shape-inside"),
css_property!("-webkit-shape-margin"),
css_property!("-webkit-shape-outside"),
css_property!("-webkit-shape-padding"),
css_property!("-webkit-svg-shadow"),
css_property!("-webkit-tap-highlight-color"),
css_property!("-webkit-text-decoration"),
css_property!("-webkit-text-decoration-color"),
css_property!("-webkit-text-decoration-line"),
css_property!("-webkit-text-decoration-style"),
css_property!("-webkit-text-size-adjust"),
css_property!("-webkit-touch-callout"),
css_property!("-webkit-transform"),
css_property!("-webkit-transform-origin"),
css_property!("-webkit-transform-origin-x"),
css_property!("-webkit-transform-origin-y"),
css_property!("-webkit-transform-origin-z"),
css_property!("-webkit-transform-style"),
css_property!("-webkit-transition"),
css_property!("-webkit-transition-delay"),
css_property!("-webkit-transition-duration"),
css_property!("-webkit-transition-property"),
css_property!("-webkit-transition-timing-function"),
css_property!("-webkit-user-drag"),
css_property!("-webkit-wrap-flow"),
css_property!("-webkit-wrap-through"),
css_property!("align-content"),
css_property!("align-items"),
css_property!("align-self"),
css_property!("alignment-adjust"),
css_property!("alignment-baseline"),
css_property!("all"),
css_property!("anchor-point"),
css_property!("animation"),
css_property!("animation-delay"),
css_property!("animation-direction"),
css_property!("animation-duration"),
css_property!("animation-fill-mode"),
css_property!("animation-iteration-count"),
css_property!("animation-name"),
css_property!("animation-play-state"),
css_property!("animation-timing-function"),
css_property!("azimuth"),
css_property!("backface-visibility"),
css_property!("background"),
css_property!("background-attachment"),
css_property!("background-clip"),
css_property!("background-color"),
css_property!("background-image"),
css_property!("background-origin"),
css_property!("background-position"),
css_property!("background-repeat"),
css_property!("background-size"),
css_property!("baseline-shift"),
css_property!("binding"),
css_property!("bleed"),
css_property!("bookmark-label"),
css_property!("bookmark-level"),
css_property!("bookmark-state"),
css_property!("border"),
css_property!("border-bottom"),
css_property!("border-bottom-color"),
css_property!("border-bottom-left-radius"),
css_property!("border-bottom-right-radius"),
css_property!("border-bottom-style"),
css_property!("border-bottom-width"),
css_property!("border-collapse"),
css_property!("border-color"),
css_property!("border-image"),
css_property!("border-image-outset"),
css_property!("border-image-repeat"),
css_property!("border-image-slice"),
css_property!("border-image-source"),
css_property!("border-image-width"),
css_property!("border-left"),
css_property!("border-left-color"),
css_property!("border-left-style"),
css_property!("border-left-width"),
css_property!("border-radius"),
css_property!("border-right"),
css_property!("border-right-color"),
css_property!("border-right-style"),
css_property!("border-right-width"),
css_property!("border-spacing"),
css_property!("border-style"),
css_property!("border-top"),
css_property!("border-top-color"),
css_property!("border-top-left-radius"),
css_property!("border-top-right-radius"),
css_property!("border-top-style"),
css_property!("border-top-width"),
css_property!("border-width"),
css_property!("bottom"),
css_property!("box-decoration-break"),
css_property!("box-shadow"),
css_property!("box-sizing"),
css_property!("box-snap"),
css_property!("box-suppress"),
css_property!("break-after"),
css_property!("break-before"),
css_property!("break-inside"),
css_property!("caption-side"),
css_property!("chains"),
css_property!("clear"),
css_property!("clip"),
css_property!("clip-path"),
css_property!("clip-rule"),
css_property!("color"),
css_property!("color-interpolation"),
css_property!("color-interpolation-filters"),
css_property!("color-profile"),
css_property!("color-rendering"),
css_property!("column-count"),
css_property!("column-fill"),
css_property!("column-gap"),
css_property!("column-rule"),
css_property!("column-rule-color"),
css_property!("column-rule-style"),
css_property!("column-rule-width"),
css_property!("column-span"),
css_property!("column-width"),
css_property!("columns"),
css_property!("contain"),
css_property!("content"),
css_property!("counter-increment"),
css_property!("counter-reset"),
css_property!("counter-set"),
css_property!("crop"),
css_property!("cue"),
css_property!("cue-after"),
css_property!("cue-before"),
css_property!("cursor"),
css_property!("direction"),
css_property!("display"),
css_property!("display-inside"),
css_property!("display-list"),
css_property!("display-outside"),
css_property!("dominant-baseline"),
css_property!("elevation"),
css_property!("empty-cells"),
css_property!("enable-background"),
css_property!("fill"),
css_property!("fill-opacity"),
css_property!("fill-rule"),
css_property!("filter"),
css_property!("flex"),
css_property!("flex-basis"),
css_property!("flex-direction"),
css_property!("flex-flow"),
css_property!("flex-grow"),
css_property!("flex-shrink"),
css_property!("flex-wrap"),
css_property!("float"),
css_property!("float-offset"),
css_property!("flood-color"),
css_property!("flood-opacity"),
css_property!("flow-from"),
css_property!("flow-into"),
css_property!("font"),
css_property!("font-family"),
css_property!("font-feature-settings"),
css_property!("font-kerning"),
css_property!("font-language-override"),
css_property!("font-size"),
css_property!("font-size-adjust"),
css_property!("font-stretch"),
css_property!("font-style"),
css_property!("font-synthesis"),
css_property!("font-variant"),
css_property!("font-variant-alternates"),
css_property!("font-variant-caps"),
css_property!("font-variant-east-asian"),
css_property!("font-variant-ligatures"),
css_property!("font-variant-numeric"),
css_property!("font-variant-position"),
css_property!("font-weight"),
css_property!("glyph-orientation-horizontal"),
css_property!("glyph-orientation-vertical"),
css_property!("grid"),
css_property!("grid-area"),
css_property!("grid-auto-columns"),
css_property!("grid-auto-flow"),
css_property!("grid-auto-rows"),
css_property!("grid-column"),
css_property!("grid-column-end"),
css_property!("grid-column-start"),
css_property!("grid-row"),
css_property!("grid-row-end"),
css_property!("grid-row-start"),
css_property!("grid-template"),
css_property!("grid-template-areas"),
css_property!("grid-template-columns"),
css_property!("grid-template-rows"),
css_property!("hanging-punctuation"),
css_property!("height"),
css_property!("hyphens"),
css_property!("icon"),
css_property!("image-orientation"),
css_property!("image-rendering"),
css_property!("image-resolution"),
css_property!("ime-mode"),
css_property!("initial-letters"),
css_property!("inline-box-align"),
css_property!("justify-content"),
css_property!("justify-items"),
css_property!("justify-self"),
css_property!("kerning"),
css_property!("left"),
css_property!("letter-spacing"),
css_property!("lighting-color"),
css_property!("line-box-contain"),
css_property!("line-break"),
css_property!("line-grid"),
css_property!("line-height"),
css_property!("line-snap"),
css_property!("line-stacking"),
css_property!("line-stacking-ruby"),
css_property!("line-stacking-shift"),
css_property!("line-stacking-strategy"),
css_property!("list-style"),
css_property!("list-style-image"),
css_property!("list-style-position"),
css_property!("list-style-type"),
css_property!("margin"),
css_property!("margin-bottom"),
css_property!("margin-left"),
css_property!("margin-right"),
css_property!("margin-top"),
css_property!("marker"),
css_property!("marker-end"),
css_property!("marker-mid"),
css_property!("marker-offset"),
css_property!("marker-side"),
css_property!("marker-start"),
css_property!("marks"),
css_property!("mask"),
css_property!("mask-box"),
css_property!("mask-box-outset"),
css_property!("mask-box-repeat"),
css_property!("mask-box-slice"),
css_property!("mask-box-source"),
css_property!("mask-box-width"),
css_property!("mask-clip"),
css_property!("mask-image"),
css_property!("mask-origin"),
css_property!("mask-position"),
css_property!("mask-repeat"),
css_property!("mask-size"),
css_property!("mask-source-type"),
css_property!("mask-type"),
css_property!("max-height"),
css_property!("max-lines"),
css_property!("max-width"),
css_property!("min-height"),
css_property!("min-width"),
css_property!("move-to"),
css_property!("nav-down"),
css_property!("nav-index"),
css_property!("nav-left"),
css_property!("nav-right"),
css_property!("nav-up"),
css_property!("object-fit"),
css_property!("object-position"),
css_property!("opacity"),
css_property!("order"),
css_property!("orphans"),
css_property!("outline"),
css_property!("outline-color"),
css_property!("outline-offset"),
css_property!("outline-style"),
css_property!("outline-width"),
css_property!("overflow"),
css_property!("overflow-wrap"),
css_property!("overflow-x"),
css_property!("overflow-y"),
css_property!("padding"),
css_property!("padding-bottom"),
css_property!("padding-left"),
css_property!("padding-right"),
css_property!("padding-top"),
css_property!("page"),
css_property!("page-break-after"),
css_property!("page-break-before"),
css_property!("page-break-inside"),
css_property!("page-policy"),
css_property!("pause"),
css_property!("pause-after"),
css_property!("pause-before"),
css_property!("perspective"),
css_property!("perspective-origin"),
css_property!("pitch"),
css_property!("pitch-range"),
css_property!("play-during"),
css_property!("pointer-events"),
css_property!("position"),
css_property!("presentation-level"),
css_property!("quotes"),
css_property!("region-fragment"),
css_property!("resize"),
css_property!("rest"),
css_property!("rest-after"),
css_property!("rest-before"),
css_property!("richness"),
css_property!("right"),
css_property!("rotation"),
css_property!("rotation-point"),
css_property!("ruby-align"),
css_property!("ruby-merge"),
css_property!("ruby-position"),
css_property!("shape-image-threshold"),
css_property!("shape-margin"),
css_property!("shape-outside"),
css_property!("shape-rendering"),
css_property!("size"),
css_property!("speak"),
css_property!("speak-as"),
css_property!("speak-header"),
css_property!("speak-numeral"),
css_property!("speak-punctuation"),
css_property!("speech-rate"),
css_property!("stop-color"),
css_property!("stop-opacity"),
css_property!("stress"),
css_property!("string-set"),
css_property!("stroke"),
css_property!("stroke-dasharray"),
css_property!("stroke-dashoffset"),
css_property!("stroke-linecap"),
css_property!("stroke-linejoin"),
css_property!("stroke-miterlimit"),
css_property!("stroke-opacity"),
css_property!("stroke-width"),
css_property!("tab-size"),
css_property!("table-layout"),
css_property!("text-align"),
css_property!("text-align-last"),
css_property!("text-anchor"),
css_property!("text-combine-horizontal"),
css_property!("text-combine-upright"),
css_property!("text-decoration"),
css_property!("text-decoration-color"),
css_property!("text-decoration-line"),
css_property!("text-decoration-skip"),
css_property!("text-decoration-style"),
css_property!("text-emphasis"),
css_property!("text-emphasis-color"),
css_property!("text-emphasis-position"),
css_property!("text-emphasis-style"),
css_property!("text-height"),
css_property!("text-indent"),
css_property!("text-justify"),
css_property!("text-orientation"),
css_property!("text-overflow"),
css_property!("text-rendering"),
css_property!("text-shadow"),
css_property!("text-size-adjust"),
css_property!("text-space-collapse"),
css_property!("text-transform"),
css_property!("text-underline-position"),
css_property!("text-wrap"),
css_property!("top"),
css_property!("touch-action"),
css_property!("transform"),
css_property!("transform-origin"),
css_property!("transform-style"),
css_property!("transition"),
css_property!("transition-delay"),
css_property!("transition-duration"),
css_property!("transition-property"),
css_property!("transition-timing-function"),
css_property!("unicode-bidi"),
css_property!("unicode-range"),
css_property!("vertical-align"),
css_property!("visibility"),
css_property!("voice-balance"),
css_property!("voice-duration"),
css_property!("voice-family"),
css_property!("voice-pitch"),
css_property!("voice-range"),
css_property!("voice-rate"),
css_property!("voice-stress"),
css_property!("voice-volume"),
css_property!("volume"),
css_property!("white-space"),
css_property!("widows"),
css_property!("width"),
css_property!("will-change"),
css_property!("word-break"),
css_property!("word-spacing"),
css_property!("word-wrap"),
css_property!("wrap-flow"),
css_property!("wrap-through"),
css_property!("writing-mode"),
css_property!("z-index"),
];
} }

View File

@ -2,8 +2,12 @@ use cssparser::{
AtRuleParser, CowRcStr, DeclarationListParser, DeclarationParser, ParseError, Parser, AtRuleParser, CowRcStr, DeclarationListParser, DeclarationParser, ParseError, Parser,
ParserInput, QualifiedRuleParser, RuleListParser, SourceLocation, ParserInput, QualifiedRuleParser, RuleListParser, SourceLocation,
}; };
use std::fmt;
use std::convert::Into;
use std::error::Error; use std::error::Error;
// TODO: try to use CowRcStr instead of Strings in these structs.
// I tried to do it earlier but I ended up in lifetime hell in parse_block().
#[derive(Debug)] #[derive(Debug)]
pub struct CssRule { pub struct CssRule {
pub selectors: String, pub selectors: String,
@ -39,10 +43,7 @@ impl<'i> QualifiedRuleParser<'i> for CssParser {
&mut self, &mut self,
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
) -> Result<Self::Prelude, CssParseError<'i>> { ) -> Result<Self::Prelude, CssParseError<'i>> {
let location = input.current_source_location();
dbg!(&location);
let position = input.position(); let position = input.position();
dbg!(&position);
while input.next().is_ok() {} while input.next().is_ok() {}
Ok(input.slice_from(position).to_string()) Ok(input.slice_from(position).to_string())
} }
@ -53,7 +54,6 @@ impl<'i> QualifiedRuleParser<'i> for CssParser {
_location: SourceLocation, _location: SourceLocation,
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
) -> Result<CssRule, CssParseError<'i>> { ) -> Result<CssRule, CssParseError<'i>> {
dbg!(&selectors);
Ok(CssRule { Ok(CssRule {
selectors, selectors,
declarations: parse_declarations(input).unwrap(), declarations: parse_declarations(input).unwrap(),
@ -100,9 +100,18 @@ impl<'i> DeclarationParser<'i> for CssDeclarationParser {
fn parse_value<'t>( fn parse_value<'t>(
&mut self, &mut self,
name: CowRcStr<'i>, name: CowRcStr<'i>,
mut input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
) -> Result<Self::Declaration, ParseError<'i, CssError>> { ) -> Result<Self::Declaration, ParseError<'i, CssError>> {
Ok(vec![]) dbg!(&name);
let start = input.position();
input.next()?;
let value = input.slice_from(start);
dbg!(&value);
Ok(vec![CssDeclaration {
property: name.to_string(),
value: value.trim().to_string(),
}])
} }
} }
@ -134,3 +143,15 @@ pub fn parse_declarations<'i>(
Ok(declarations) Ok(declarations)
} }
impl fmt::Display for CssDeclaration {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}: {};", self.property, self.value)
}
}
impl Into<String> for CssDeclaration {
fn into(self) -> String {
format!("{}: {};", self.property, self.value)
}
}

View File

@ -7,6 +7,7 @@ extern crate html5ever;
extern crate maplit; extern crate maplit;
extern crate typed_arena; extern crate typed_arena;
extern crate cssparser; extern crate cssparser;
extern crate string_cache;
use std::collections::HashSet; use std::collections::HashSet;
use std::default::Default; use std::default::Default;
@ -73,7 +74,6 @@ fn transform_node<'arena>(node: Ref<'arena>, arena: Arena<'arena>) {
| NodeData::Comment { .. } | NodeData::Comment { .. }
| NodeData::ProcessingInstruction { .. } => {} | NodeData::ProcessingInstruction { .. } => {}
NodeData::Text { ref contents } => { NodeData::Text { ref contents } => {
dbg!(contents);
// TODO: seems rather expensive to lookup the parent on every Text node. Better // TODO: seems rather expensive to lookup the parent on every Text node. Better
// solution would be to pass some sort of context from the parent that marks that this // solution would be to pass some sort of context from the parent that marks that this
// Text node is inside a <style>. // Text node is inside a <style>.
@ -107,9 +107,19 @@ fn transform_node<'arena>(node: Ref<'arena>, arena: Arena<'arena>) {
} else { } else {
if attrs[i].name.local == local_name!("style") { if attrs[i].name.local == local_name!("style") {
let css_str = &attrs[i].value; let css_str = &attrs[i].value;
dbg!(&css_str);
let declarations = parse_css_style_attribute(css_str); let declarations = parse_css_style_attribute(css_str);
dbg!(&declarations); dbg!(&declarations);
let mut sanitized_css = String::new();
for (index, declaration) in declarations.iter().enumerate() {
if declaration.property == "color" {
sanitized_css += &declaration.to_string();
if index != declarations.len() - 1 {
sanitized_css += " ";
}
}
}
dbg!(&sanitized_css);
attrs[i].value = StrTendril::from(sanitized_css);
} }
i += 1; i += 1;
} }
@ -168,7 +178,7 @@ fn transform_node<'arena>(node: Ref<'arena>, arena: Arena<'arena>) {
} }
} }
fn maybe_unwrap_node<'arena>(node: Ref<'arena>) -> Option<Option<Ref<'arena>>> { fn maybe_unwrap_node(node: Ref) -> Option<Option<Ref>> {
match node.data { match node.data {
NodeData::Document NodeData::Document
| NodeData::Doctype { .. } | NodeData::Doctype { .. }