dom/smil/test/db_smilMappedAttrList.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/smil/test/db_smilMappedAttrList.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,131 @@
     1.4 +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim: set ts=2 sw=2 sts=2 et: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +/* List of SVG presentational attributes in the SVG 1.1 spec, for use in
    1.11 +   mochitests. (These are the attributes that are mapped to CSS properties) */
    1.12 +
    1.13 +var gMappedAttrList =
    1.14 +{
    1.15 +  // NOTE: The list here should match the MappedAttributeEntry arrays in
    1.16 +  // nsSVGElement.cpp
    1.17 +
    1.18 +  // PresentationAttributes-FillStroke
    1.19 +  fill:              new AdditiveAttribute("fill", "XML", "rect"),
    1.20 +  fill_opacity:      new AdditiveAttribute("fill-opacity", "XML", "rect"),
    1.21 +  fill_rule:         new NonAdditiveAttribute("fill-rule", "XML", "rect"),
    1.22 +  stroke:            new AdditiveAttribute("stroke", "XML", "rect"),
    1.23 +  stroke_dasharray:
    1.24 +    new NonAdditiveAttribute("stroke-dasharray", "XML", "rect"),
    1.25 +  stroke_dashoffset: new AdditiveAttribute("stroke-dashoffset", "XML", "rect"),
    1.26 +  stroke_linecap:    new NonAdditiveAttribute("stroke-linecap", "XML", "rect"),
    1.27 +  stroke_linejoin:   new NonAdditiveAttribute("stroke-linejoin", "XML", "rect"),
    1.28 +  stroke_miterlimit: new AdditiveAttribute("stroke-miterlimit", "XML", "rect"),
    1.29 +  stroke_opacity:    new AdditiveAttribute("stroke-opacity", "XML", "rect"),
    1.30 +  stroke_width:      new AdditiveAttribute("stroke-width", "XML", "rect"),
    1.31 +
    1.32 +  // PresentationAttributes-Graphics
    1.33 +  clip_path:         new NonAdditiveAttribute("clip-path", "XML", "rect"),
    1.34 +  clip_rule:         new NonAdditiveAttribute("clip-rule", "XML", "circle"),
    1.35 +  color_interpolation:
    1.36 +    new NonAdditiveAttribute("color-interpolation", "XML", "rect"),
    1.37 +  cursor:            new NonAdditiveAttribute("cursor", "XML", "rect"),
    1.38 +  display:           new NonAdditiveAttribute("display", "XML", "rect"),
    1.39 +  filter:            new NonAdditiveAttribute("filter", "XML", "rect"),
    1.40 +  image_rendering:
    1.41 +    NonAdditiveAttribute("image-rendering", "XML", "image"),
    1.42 +  mask:              new NonAdditiveAttribute("mask", "XML", "line"),
    1.43 +  pointer_events:    new NonAdditiveAttribute("pointer-events", "XML", "rect"),
    1.44 +  shape_rendering:   new NonAdditiveAttribute("shape-rendering", "XML", "rect"),
    1.45 +  text_rendering:    new NonAdditiveAttribute("text-rendering", "XML", "text"),
    1.46 +  visibility:        new NonAdditiveAttribute("visibility", "XML", "rect"),
    1.47 +
    1.48 +  // PresentationAttributes-TextContentElements
    1.49 +  // SKIP 'alignment-baseline' property: animatable but not supported by Mozilla
    1.50 +  // SKIP 'baseline-shift' property: animatable but not supported by Mozilla
    1.51 +  direction:         new NonAnimatableAttribute("direction", "XML", "text"),
    1.52 +  dominant_baseline:
    1.53 +    new NonAdditiveAttribute("dominant-baseline", "XML", "text"),
    1.54 +  glyph_orientation_horizontal:
    1.55 +    // NOTE: Not supported by Mozilla, but explicitly non-animatable
    1.56 +    NonAnimatableAttribute("glyph-orientation-horizontal", "XML", "text"),
    1.57 +  glyph_orientation_vertical:
    1.58 +    // NOTE: Not supported by Mozilla, but explicitly non-animatable
    1.59 +    NonAnimatableAttribute("glyph-orientation-horizontal", "XML", "text"),
    1.60 +  // SKIP 'kerning' property: animatable but not supported by Mozilla
    1.61 +  letter_spacing:    new AdditiveAttribute("letter-spacing", "XML", "text"),
    1.62 +  text_anchor:       new NonAdditiveAttribute("text-anchor", "XML", "text"),
    1.63 +  text_decoration:   new NonAdditiveAttribute("text-decoration", "XML", "text"),
    1.64 +  unicode_bidi:      new NonAnimatableAttribute("unicode-bidi", "XML", "text"),
    1.65 +  word_spacing:      new AdditiveAttribute("word-spacing", "XML", "text"),
    1.66 +
    1.67 +  // PresentationAttributes-FontSpecification
    1.68 +  font_family:       new NonAdditiveAttribute("font-family", "XML", "text"),
    1.69 +  font_size:         new AdditiveAttribute("font-size", "XML", "text"),
    1.70 +  font_size_adjust:
    1.71 +    new NonAdditiveAttribute("font-size-adjust", "XML", "text"),
    1.72 +  font_stretch:      new NonAdditiveAttribute("font-stretch", "XML", "text"),
    1.73 +  font_style:        new NonAdditiveAttribute("font-style", "XML", "text"),
    1.74 +  font_variant:      new NonAdditiveAttribute("font-variant", "XML", "text"),
    1.75 +  font_weight:       new NonAdditiveAttribute("font-weight", "XML", "text"),
    1.76 +
    1.77 +  // PresentationAttributes-GradientStop
    1.78 +  stop_color:        new AdditiveAttribute("stop-color", "XML", "stop"),
    1.79 +  stop_opacity:      new AdditiveAttribute("stop-opacity", "XML", "stop"),
    1.80 +
    1.81 +  // PresentationAttributes-Viewports
    1.82 +  overflow:          new NonAdditiveAttribute("overflow", "XML", "marker"),
    1.83 +  clip:              new AdditiveAttribute("clip", "XML", "marker"),
    1.84 +
    1.85 +  // PresentationAttributes-Makers
    1.86 +  marker_end:        new NonAdditiveAttribute("marker-end", "XML", "line"),
    1.87 +  marker_mid:        new NonAdditiveAttribute("marker-mid", "XML", "line"),
    1.88 +  marker_start:      new NonAdditiveAttribute("marker-start", "XML", "line"),
    1.89 +
    1.90 +  // PresentationAttributes-Color
    1.91 +  color:             new AdditiveAttribute("color", "XML", "rect"),
    1.92 +
    1.93 +  // PresentationAttributes-Filters
    1.94 +  color_interpolation_filters:
    1.95 +    new NonAdditiveAttribute("color-interpolation-filters", "XML",
    1.96 +                             "feFlood"),
    1.97 +
    1.98 +  // PresentationAttributes-feFlood
    1.99 +  flood_color:       new AdditiveAttribute("flood-color", "XML", "feFlood"),
   1.100 +  flood_opacity:     new AdditiveAttribute("flood-opacity", "XML", "feFlood"),
   1.101 +
   1.102 +  // PresentationAttributes-LightingEffects
   1.103 +  lighting_color:
   1.104 +    new AdditiveAttribute("lighting-color", "XML", "feDiffuseLighting"),
   1.105 +};
   1.106 +
   1.107 +// Utility method to copy a list of TestcaseBundle objects for CSS properties
   1.108 +// into a list of TestcaseBundles for the corresponding mapped attributes.
   1.109 +function convertCSSBundlesToMappedAttr(bundleList) {
   1.110 +  // Create mapping of property names to the corresponding
   1.111 +  // mapped-attribute object in gMappedAttrList.
   1.112 +  var propertyNameToMappedAttr = {};
   1.113 +  for (attributeLabel in gMappedAttrList) {
   1.114 +    var propName = gMappedAttrList[attributeLabel].attrName;
   1.115 +    propertyNameToMappedAttr[propName] = gMappedAttrList[attributeLabel];
   1.116 +  }
   1.117 +
   1.118 +  var convertedBundles = [];
   1.119 +  for (var bundleIdx in bundleList) {
   1.120 +    var origBundle = bundleList[bundleIdx];
   1.121 +    var propName = origBundle.animatedAttribute.attrName;
   1.122 +    if (propertyNameToMappedAttr[propName]) {
   1.123 +      // There's a mapped attribute by this name! Duplicate the TestcaseBundle,
   1.124 +      // using the Mapped Attribute instead of the CSS Property.
   1.125 +      is(origBundle.animatedAttribute.attrType, "CSS",
   1.126 +         "expecting to be converting from CSS to XML");
   1.127 +      convertedBundles.push(
   1.128 +        new TestcaseBundle(propertyNameToMappedAttr[propName],
   1.129 +                           origBundle.testcaseList,
   1.130 +                           origBundle.skipReason));
   1.131 +    }
   1.132 +  }
   1.133 +  return convertedBundles;
   1.134 +}

mercurial