示例#1
0
        public override float GetDecimal(RenderableData context, CssProperty property)
        {
            float result;

            float.TryParse(GetText(context, property), out result);
            return(result);
        }
示例#2
0
 public void Svg()
 {
     Assert.Equal(CssProperty.Fill, CssProperty.Get("fill"));
     Assert.Equal(CssProperty.Stroke, CssProperty.Get("stroke"));
     Assert.Equal(CssProperty.StrokeLinecap, CssProperty.Get("stroke-linecap"));
     Assert.Equal(CssProperty.StrokeWidth, CssProperty.Get("stroke-width"));
 }
示例#3
0
        public void ReEvaluate(Node context, CssProperty property)
        {
            Property = property;
            IRenderableNode rdr = (context.parentNode_ as IRenderableNode);

            if (rdr != null)
            {
                // Inherit right now:
                Context = rdr.RenderData;
                From_   = rdr.ComputedStyle[property];

                Inherit inher = From_ as Inherit;

                if (inher != null)
                {
                    // Collapse the cascade - Pull the inner value instead:
                    From_   = inher.From;
                    Context = inher.Context;
                }
            }

            if (From_ == null)
            {
                From_ = property.InitialValue;
            }

            if (Context == null)
            {
                Context = (context as IRenderableNode).RenderData;
            }

            Type = From_.Type;
        }
 public String this[CssProperty style]
 {
     get
     {
         var item = GetItem(style);
         return(item == null ? "" : item.Value);
     }
     set
     {
         var item = GetItem(style);
         if (String.IsNullOrEmpty(value))
         {
             if (item != null)
             {
                 Remove(item);
             }
             return;
         }
         else if (item == null)
         {
             item = new HtmlStyleItem(style, value);
             Add(item);
         }
         else
         {
             item.Value = value;
         }
     }
 }
示例#5
0
        public override float GetDecimal(RenderableData context, CssProperty property)
        {
            if (From_ == null)
            {
                // Initial:
                return(Property.InitialValue.GetDecimal(context, property));
            }

            // ValueScale is actually context.ValueScale;
            float valueScale = 0f;

            if (Context != null)
            {
                valueScale         = Context.ValueScale;
                Context.ValueScale = context.ValueScale;
            }

            // Get now:
            float result = From_.GetDecimal(Context, property);

            if (Context != null)
            {
                // Restore:
                Context.ValueScale = valueScale;
            }

            return(result);
        }
示例#6
0
        /// <summary>Loads the set of CSS properties.</summary>
        public static void LoadAvailableProperties()
        {
            // The result list:
            List <string> properties = new List <string>();

            // For each one..
            foreach (KeyValuePair <string, CssProperty> kvp in CssProperties.All)
            {
                // Get the property:
                CssProperty property = kvp.Value;

                // Skip internal properties:
                if (property.Internal)
                {
                    continue;
                }

                // Add it to the list:
                properties.Add(kvp.Key);
            }

            // Sort it:
            properties.Sort();

            // Ok!
            Properties = properties.ToArray();
        }
示例#7
0
 public void Clipping()
 {
     Assert.Equal(CssProperty.ClipPath, CssProperty.Get("clip-path"));
     Assert.Equal(CssProperty.ClipRule, CssProperty.Get("clip-rule"));
     Assert.Equal(CssProperty.StrokeLinecap, CssProperty.Get("stroke-linecap"));
     Assert.Equal(CssProperty.StrokeWidth, CssProperty.Get("stroke-width"));
 }
示例#8
0
        public override string GetText(RenderableData context, CssProperty property)
        {
            if (context == null)
            {
                return("");
            }

            // Get the document:
            ReflowDocument doc = context.computedStyle.reflowDocument;

            if (System_ == null)
            {
                // Get the system by name:
                Css.Value style = Style;

                if (style != null)
                {
                    System_ = doc.GetCounter(style.Text);
                }
                else
                {
                    System_ = null;
                }

                if (System_ == null)
                {
                    // Default to decimal:
                    System_ = CounterSystems.Decimal;
                }
            }

            return(System_.Get(doc.Renderer.GetCounter(Counter), false));
        }
        public void Compress(out nsCSSCompressedDataBlock aNormalBlock, out nsCSSCompressedDataBlock aImportantBlock)
        {
            int numPropsNormal, numPropsImportant;

            ComputeNumProps(out numPropsNormal, out numPropsImportant);

            var result_normal    = new nsCSSCompressedDataBlock(numPropsNormal);
            var result_important = numPropsImportant != 0 ? new nsCSSCompressedDataBlock(numPropsImportant) : null;

            int i_normal = 0, i_important = 0;

            for (CssProperty iProp = 0; iProp < CssProperty.PropertyCountNoShorthands; iProp++)
            {
                if (!mPropertiesSet.HasProperty(iProp))
                {
                    continue;
                }
                if (mPropertiesImportant.HasProperty(iProp))
                {
                    CompressProperty(result_important, iProp, ref i_important);
                }
                else
                {
                    CompressProperty(result_normal, iProp, ref i_normal);
                }
            }

            mPropertiesSet.Empty();
            mPropertiesImportant.Empty();
            AssertInitialState();
            aNormalBlock    = result_normal;
            aImportantBlock = result_important;
        }
示例#10
0
        public IPropertyValue Construct(CssProperty[] properties)
        {
            var valueList = new List <List <CssToken> > [properties.Length];
            var dummies   = new CssProperty[properties.Length];
            var max       = 0;

            for (var i = 0; i < properties.Length; i++)
            {
                var value = properties[i].DeclaredValue;
                valueList[i] = value != null?value.Original.ToList() : new List <List <CssToken> >();

                dummies[i] = Factory.Properties.CreateLonghand(properties[i].Name);
                max        = Math.Max(max, valueList[i].Count);
            }

            var values = new IPropertyValue[max];

            for (int i = 0; i < max; i++)
            {
                for (int j = 0; j < dummies.Length; j++)
                {
                    var list   = valueList[j];
                    var tokens = list.Count > i ? list[i] : Enumerable.Empty <CssToken>();
                    dummies[j].TrySetValue(new CssValue(tokens));
                }

                var converter = (i < max - 1) ? _listConverter : _endConverter;
                values[i] = converter.Construct(dummies);
            }

            return(new ListValue(values, Enumerable.Empty <CssToken>()));
        }
示例#11
0
        public override string GetText(RenderableData context, CssProperty property)
        {
            string result = "";

            int count = Count;

            for (int i = 0; i < count; i++)
            {
                // Grab the value:
                Css.Value par = this[i];

                if (par == null)
                {
                    continue;
                }

                // Add the textual value to result:
                result += par.GetText(context, property);
            }

            // Great - map to attrib:
            result = context.Node[result];

            return(result);
        }
示例#12
0
 public void ClearProperty(CssProperty aPropID)
 {
     if (!nsCSSProps.IsShorthand(aPropID))
         ClearLonghandProperty(aPropID);
     else
         foreach (CssProperty p in nsCSSProps.SubpropertyEntryFor(aPropID, true))
             ClearLonghandProperty(p);
 }
示例#13
0
 private void CompressProperty(nsCSSCompressedDataBlock result, CssProperty aPropID, ref int ip)
 {
     result.mData[ip].mProperty = aPropID;
     result.mData[ip].mValue    = mValues[(int)aPropID];
     mValues[(int)aPropID].Reset();
     ip++;
     result.mStyleBits |= nsCachedStyleData.GetBitForSID(nsCSSProps.kSIDTable[(int)aPropID]);
 }
示例#14
0
文件: scroll.cs 项目: ru-ace/spark
        public override void Aliases()
        {
            Alias("scroll-top", ValueAxis.Y, 0);
            Alias("scroll-left", ValueAxis.X, 1);

            Top  = GetAliased(0);
            Left = GetAliased(1);
        }
示例#15
0
        public override void Aliases()
        {
            // A set of point aliases, e.g. background-size-x:
            PointAliases2D();

            GlobalPropertyX = GetAliased(0);
            GlobalPropertyY = GetAliased(1);
        }
示例#16
0
        public override float GetDecimal(RenderableData context, CssProperty property)
        {
            // try it as a float:
            float result;

            float.TryParse(RawValue, out result);
            return(result);
        }
        public override string GetText(RenderableData context, CssProperty property)
        {
            if (context == null)
            {
                return("");
            }

            // Get the document:
            ReflowDocument doc = context.computedStyle.reflowDocument;

            if (System_ == null)
            {
                // Get the system by name:
                Css.Value style = Style;

                if (style != null)
                {
                    System_ = doc.GetCounter(style.Text);
                }
                else
                {
                    System_ = null;
                }

                if (System_ == null)
                {
                    // Default to decimal:
                    System_ = CounterSystems.Decimal;
                }
            }

            // Get all counters from the system and join them:
            List <CssCounter> counters = doc.Renderer.Counters;

            if (counters == null)
            {
                return("");
            }

            // Go forward here:
            string result = "";

            for (int i = 0; i < counters.Count; i++)
            {
                if (counters[i].Name == Counter)
                {
                    // Got one! Add it on:
                    if (result != "")
                    {
                        result += Separator;
                    }

                    result += System_.Get(counters[i].Count, false);
                }
            }

            return(result);
        }
示例#18
0
		/// <summary>Sets the named css property from the given style if the property exists in the style.</summary>
		/// <param name="property">The css property, e.g. color.</param>
		/// <param name="style">The style to load value of the property from. This should be the computed style for the parent element.</param>
		private void SetValue(CssProperty property,ComputedStyle style){
			// Get the current value:
			Value value=style[property];
			
			if(value!=null){
				// Apply it:
				property.Apply(style,value);
			}
		}
示例#19
0
        public override float GetDecimal(RenderableData context, CssProperty property)
        {
            if (Value == null)
            {
                return(0f);
            }

            return(Value.GetDecimal(context, property));
        }
示例#20
0
        public override bool GetBoolean(RenderableData context, CssProperty property)
        {
            if (Value == null)
            {
                return(false);
            }

            return(Value.GetBoolean(context, property));
        }
示例#21
0
        public override string GetText(RenderableData context, CssProperty property)
        {
            if (Value == null)
            {
                return(null);
            }

            return(Value.GetText(context, property));
        }
示例#22
0
        /// <summary>
        /// Updates the property which is used as a fallback if there is nothing to inherit from.
        /// </summary>
        public void SetProperty(CssProperty prop)
        {
            if (prop == null)
            {
                return;
            }

            Property = prop;
        }
示例#23
0
        public void Remove(CssProperty htmlStyle)
        {
            var item = GetItem(htmlStyle);

            if (item != null)
            {
                Remove(item);
            }
        }
示例#24
0
        public override string GetText(RenderableData context, CssProperty property)
        {
            if (Count == 0)
            {
                return("");
            }

            return(this[0].Text);
        }
示例#25
0
        public override string GetText(RenderableData context, CssProperty property)
        {
            if (Url == null)
            {
                Url = GetUrl(context, property);
            }

            return(Url);
        }
示例#26
0
        /// <summary>Creates a new animated property.</summary>
        /// <param name="animation">The animation that this property is a part of.</param>
        /// <param name="property">The property being animated.</param>
        /// <param name="targetValue">The value that this property will be when the animation is over.</param>
        /// <param name="constantSpeedTime">How long the animation will change the value at a constant speed for.</param>
        /// <param name="timeToAccelerateFor">How long the animation will accelerate for. This produces a smoother animation.</param>
        /// <param name="timeToDecelerateFor">How long the animation will decelerate for. This produces a smoother animation.</param>
        /// <param name="updateCss">True if this particular property should flush its changes to css/the screen.</param>
        public AnimatedProperty(UIAnimation animation, CssProperty property, int innerIndex, Css.Value targetValue, float constantSpeedTime, float timeToAccelerateFor, float timeToDecelerateFor, bool updateCss)
        {
            Animation    = animation;
            PropertyInfo = property;
            InnerIndex   = innerIndex;
            Css.ValueType type = targetValue.Type;

            if (!Animation.ElementStyle.Properties.TryGetValue(property, out ValueObject))
            {
                ComputedStyle computed = Animation.ElementStyle.Computed;

                if (computed != null && computed.Properties.TryGetValue(property, out ValueObject))
                {
                    // Let's derive from the computed form.
                    ValueObject = ValueObject.Copy();
                }
                else
                {
                    ValueObject = new Css.Value();

                    if (innerIndex != -1 || type == Css.ValueType.Null)
                    {
                        type = Css.ValueType.Rectangle;
                    }

                    property.SetDefault(ValueObject, type);
                }

                Animation.ElementStyle.Properties[property] = ValueObject;
            }

            if (ValueObject.Type == Css.ValueType.Inherit)
            {
                // Special case - we need to duplicate it.
                Animation.ElementStyle.Properties[property] = ValueObject = ValueObject.Copy();
                ValueObject.Type = type;
            }

            PropertyValueObject = ValueObject;

            if (innerIndex != -1)
            {
                Css.Value innerValue = ValueObject[innerIndex];

                if (innerValue == null)
                {
                    ValueObject[innerIndex] = innerValue = new Css.Value();
                }

                ValueObject = innerValue;
            }

            // Set our starting value:
            ActiveValue = ValueObject.ToFloat();
            Animate(Animation, targetValue, constantSpeedTime, timeToAccelerateFor, timeToDecelerateFor, updateCss);
        }
示例#27
0
        public override float GetDecimal(RenderableData context, CssProperty property)
        {
            if (Operator == null)
            {
                return(0f);
            }

            // Run the calc here!
            return(Operator.GetDecimal(context, property));
        }
示例#28
0
        /// <summary>Gets the value as an image, if it is one.</summary>
        public override PowerUI.ImageFormat GetImage(RenderableData context, CssProperty property)
        {
            if (From_ == null)
            {
                // Initial:
                return(Property.InitialValue.GetImage(context, property));
            }

            return(From_.GetImage(Context, property));
        }
示例#29
0
 public bool TransferFromBlock(nsCSSExpandedDataBlock aFromBlock, CssProperty aPropID,
     bool aIsImportant, bool aOverrideImportant, bool aMustCallValueAppended, CssDeclaration aDeclaration)
 {
     if (!nsCSSProps.IsShorthand(aPropID))
         return DoTransferFromBlock(aFromBlock, aPropID, aIsImportant, aOverrideImportant, aMustCallValueAppended, aDeclaration);
     bool changed = false;
     foreach (CssProperty p in nsCSSProps.SubpropertyEntryFor(aPropID, true))
         changed |= DoTransferFromBlock(aFromBlock, p, aIsImportant, aOverrideImportant, aMustCallValueAppended, aDeclaration);
     return changed;
 }
示例#30
0
        public override string GetText(RenderableData context, CssProperty property)
        {
            if (From_ == null)
            {
                // Initial:
                return(Property.InitialValue.GetText(context, property));
            }

            return(From_.GetText(Context, property));
        }
示例#31
0
        public static T ClearCss <T>(this T control, CssProperty css) where T : HtmlObject
        {
            var item = control.Styles.FirstOrDefault(s => s.Style == css);

            if (item != null)
            {
                control.Styles.Remove(item);
            }
            return(control);
        }
        public override float GetDecimal(RenderableData context, CssProperty property)
        {
            if (property is Css.Properties.TextAlignLast)
            {
                return(HorizontalAlignMode.Start);
            }

            // As used by transitions
            return(0f);
        }
 internal int IndexFor(CssProperty aProperty)
 {
     Debug.Assert(!nsCSSProps.IsShorthand(aProperty), "Don't call for shorthands");
     if ((nsCachedStyleData.GetBitForSID(nsCSSProps.kSIDTable[(int)aProperty]) & mStyleBits) == 0)
         return -1;
     for (int i = 0; i < mData.Length; i++)
         if (mData[i].mProperty == aProperty)
             return i;
     return -1;
 }
示例#34
0
        public override bool GetBoolean(RenderableData context, CssProperty property)
        {
            if (From_ == null)
            {
                // Initial:
                return(Property.InitialValue.GetBoolean(context, property));
            }

            return(From_.GetBoolean(Context, property));
        }
示例#35
0
 public CssValue GetValue(CssProperty prop)
 {
     int index = mData.IndexFor(prop);
     if (index != -1)
         return mData.mData[index].Value;
     if (mImportantData == null)
         return CssValue.NullValue;
     index = mImportantData.IndexFor(prop);
     if (index != -1)
         return mImportantData.mData[index].Value;
     return CssValue.NullValue;
 }
        public bool TryReplaceValue(CssProperty aProperty, nsCSSExpandedDataBlock aFromBlock, ref bool aChanged)
        {
            CssValue newValue = aFromBlock.mValues[(int)aProperty];

            int oldValue = IndexFor(aProperty);
            if (oldValue == -1) {
                aChanged = false;
                return false;
            }

            aChanged = MoveValue(ref newValue, ref mData[oldValue].mValue);
            aFromBlock.mPropertiesSet.RemoveProperty(aProperty);
            return true;
        }
示例#37
0
        internal bool ParsePropertyByFunction(nsCSSProperty aPropID)
        {
            switch (aPropID) {  // handle shorthand or multiple properties
              case nsCSSProperty.Background:
            return ParseBackground();
              case nsCSSProperty.BackgroundRepeat:
            return ParseBackgroundRepeat();
              case nsCSSProperty.BackgroundPosition:
            return ParseBackgroundPosition();
              case nsCSSProperty.BackgroundSize:
            return ParseBackgroundSize();
              case nsCSSProperty.Border:
            return ParseBorderSide(kBorderTopIDs, true);
              case nsCSSProperty.BorderColor:
            return ParseBorderColor();
              case nsCSSProperty.BorderSpacing:
            return ParseBorderSpacing();
              case nsCSSProperty.BorderStyle:
            return ParseBorderStyle();
              case nsCSSProperty.BorderBottom:
            return ParseBorderSide(kBorderBottomIDs, false);
              case nsCSSProperty.BorderEnd:
            return ParseDirectionalBorderSide(kBorderEndIDs,
                                              nsStyle.BOXPROP_SOURCE_LOGICAL);
              case nsCSSProperty.BorderLeft:
            return ParseDirectionalBorderSide(kBorderLeftIDs,
                                              nsStyle.BOXPROP_SOURCE_PHYSICAL);
              case nsCSSProperty.BorderRight:
            return ParseDirectionalBorderSide(kBorderRightIDs,
                                              nsStyle.BOXPROP_SOURCE_PHYSICAL);
              case nsCSSProperty.BorderStart:
            return ParseDirectionalBorderSide(kBorderStartIDs,
                                              nsStyle.BOXPROP_SOURCE_LOGICAL);
              case nsCSSProperty.BorderTop:
            return ParseBorderSide(kBorderTopIDs, false);
              case nsCSSProperty.BorderBottomColors:
              case nsCSSProperty.BorderLeftColors:
              case nsCSSProperty.BorderRightColors:
              case nsCSSProperty.BorderTopColors:
            return ParseBorderColors(aPropID);
              case nsCSSProperty.BorderImageSlice:
            { bool? _ = null; return ParseBorderImageSlice(true, ref _); }
            goto case nsCSSProperty.BorderImageWidth;
              case nsCSSProperty.BorderImageWidth:
            return ParseBorderImageWidth(true);
              case nsCSSProperty.BorderImageOutset:
            return ParseBorderImageOutset(true);
              case nsCSSProperty.BorderImageRepeat:
            return ParseBorderImageRepeat(true);
              case nsCSSProperty.BorderImage:
            return ParseBorderImage();
              case nsCSSProperty.BorderWidth:
            return ParseBorderWidth();
              case nsCSSProperty.BorderEndColor:
            return ParseDirectionalBoxProperty(nsCSSProperty.BorderEndColor,
                                               nsStyle.BOXPROP_SOURCE_LOGICAL);
              case nsCSSProperty.BorderLeftColor:
            return ParseDirectionalBoxProperty(nsCSSProperty.BorderLeftColor,
                                               nsStyle.BOXPROP_SOURCE_PHYSICAL);
              case nsCSSProperty.BorderRightColor:
            return ParseDirectionalBoxProperty(nsCSSProperty.BorderRightColor,
                                               nsStyle.BOXPROP_SOURCE_PHYSICAL);
              case nsCSSProperty.BorderStartColor:
            return ParseDirectionalBoxProperty(nsCSSProperty.BorderStartColor,
                                               nsStyle.BOXPROP_SOURCE_LOGICAL);
              case nsCSSProperty.BorderEndWidth:
            return ParseDirectionalBoxProperty(nsCSSProperty.BorderEndWidth,
                                               nsStyle.BOXPROP_SOURCE_LOGICAL);
              case nsCSSProperty.BorderLeftWidth:
            return ParseDirectionalBoxProperty(nsCSSProperty.BorderLeftWidth,
                                               nsStyle.BOXPROP_SOURCE_PHYSICAL);
              case nsCSSProperty.BorderRightWidth:
            return ParseDirectionalBoxProperty(nsCSSProperty.BorderRightWidth,
                                               nsStyle.BOXPROP_SOURCE_PHYSICAL);
              case nsCSSProperty.BorderStartWidth:
            return ParseDirectionalBoxProperty(nsCSSProperty.BorderStartWidth,
                                               nsStyle.BOXPROP_SOURCE_LOGICAL);
              case nsCSSProperty.BorderEndStyle:
            return ParseDirectionalBoxProperty(nsCSSProperty.BorderEndStyle,
                                               nsStyle.BOXPROP_SOURCE_LOGICAL);
              case nsCSSProperty.BorderLeftStyle:
            return ParseDirectionalBoxProperty(nsCSSProperty.BorderLeftStyle,
                                               nsStyle.BOXPROP_SOURCE_PHYSICAL);
              case nsCSSProperty.BorderRightStyle:
            return ParseDirectionalBoxProperty(nsCSSProperty.BorderRightStyle,
                                               nsStyle.BOXPROP_SOURCE_PHYSICAL);
              case nsCSSProperty.BorderStartStyle:
            return ParseDirectionalBoxProperty(nsCSSProperty.BorderStartStyle,
                                               nsStyle.BOXPROP_SOURCE_LOGICAL);
              case nsCSSProperty.BorderRadius:
            return ParseBoxCornerRadii(kBorderRadiusIDs);
              case nsCSSProperty.MozOutlineRadius:
            return ParseBoxCornerRadii(kOutlineRadiusIDs);

              case nsCSSProperty.BorderTopLeftRadius:
              case nsCSSProperty.BorderTopRightRadius:
              case nsCSSProperty.BorderBottomRightRadius:
              case nsCSSProperty.BorderBottomLeftRadius:
              case nsCSSProperty.MozOutlineRadiusTopLeft:
              case nsCSSProperty.MozOutlineRadiusTopRight:
              case nsCSSProperty.MozOutlineRadiusBottomRight:
              case nsCSSProperty.MozOutlineRadiusBottomLeft:
            return ParseBoxCornerRadius(aPropID);

              case nsCSSProperty.BoxShadow:
              case nsCSSProperty.TextShadow:
            return ParseShadowList(aPropID);

              case nsCSSProperty.Clip:
            return ParseRect(nsCSSProperty.Clip);
              case nsCSSProperty.MozColumns:
            return ParseColumns();
              case nsCSSProperty.MozColumnRule:
            return ParseBorderSide(kColumnRuleIDs, false);
              case nsCSSProperty.Content:
            return ParseContent();
              case nsCSSProperty.CounterIncrement:
              case nsCSSProperty.CounterReset:
            return ParseCounterData(aPropID);
              case nsCSSProperty.Cursor:
            return ParseCursor();
            #if MOZ_FLEXBOX
            goto case nsCSSProperty.Flex;
              case nsCSSProperty.Flex:
            return ParseFlex();
            #endif // MOZ_FLEXBOX
            goto case nsCSSProperty.Font;
              case nsCSSProperty.Font:
            return ParseFont();
              case nsCSSProperty.ImageRegion:
            return ParseRect(nsCSSProperty.ImageRegion);
              case nsCSSProperty.ListStyle:
            return ParseListStyle();
              case nsCSSProperty.Margin:
            return ParseMargin();
              case nsCSSProperty.MarginEnd:
            return ParseDirectionalBoxProperty(nsCSSProperty.MarginEnd,
                                               nsStyle.BOXPROP_SOURCE_LOGICAL);
              case nsCSSProperty.MarginLeft:
            return ParseDirectionalBoxProperty(nsCSSProperty.MarginLeft,
                                               nsStyle.BOXPROP_SOURCE_PHYSICAL);
              case nsCSSProperty.MarginRight:
            return ParseDirectionalBoxProperty(nsCSSProperty.MarginRight,
                                               nsStyle.BOXPROP_SOURCE_PHYSICAL);
              case nsCSSProperty.MarginStart:
            return ParseDirectionalBoxProperty(nsCSSProperty.MarginStart,
                                               nsStyle.BOXPROP_SOURCE_LOGICAL);
              case nsCSSProperty.Outline:
            return ParseOutline();
              case nsCSSProperty.Overflow:
            return ParseOverflow();
              case nsCSSProperty.Padding:
            return ParsePadding();
              case nsCSSProperty.PaddingEnd:
            return ParseDirectionalBoxProperty(nsCSSProperty.PaddingEnd,
                                               nsStyle.BOXPROP_SOURCE_LOGICAL);
              case nsCSSProperty.PaddingLeft:
            return ParseDirectionalBoxProperty(nsCSSProperty.PaddingLeft,
                                               nsStyle.BOXPROP_SOURCE_PHYSICAL);
              case nsCSSProperty.PaddingRight:
            return ParseDirectionalBoxProperty(nsCSSProperty.PaddingRight,
                                               nsStyle.BOXPROP_SOURCE_PHYSICAL);
              case nsCSSProperty.PaddingStart:
            return ParseDirectionalBoxProperty(nsCSSProperty.PaddingStart,
                                               nsStyle.BOXPROP_SOURCE_LOGICAL);
              case nsCSSProperty.Quotes:
            return ParseQuotes();
              case nsCSSProperty.Size:
            return ParseSize();
              case nsCSSProperty.TextDecoration:
            return ParseTextDecoration();
              case nsCSSProperty.Transform:
            return ParseTransform(false);
              case nsCSSProperty.MozTransform:
            return ParseTransform(true);
              case nsCSSProperty.TransformOrigin:
            return ParseTransformOrigin(false);
              case nsCSSProperty.PerspectiveOrigin:
            return ParseTransformOrigin(true);
              case nsCSSProperty.Transition:
            return ParseTransition();
              case nsCSSProperty.Animation:
            return ParseAnimation();
              case nsCSSProperty.TransitionProperty:
            return ParseTransitionProperty();
              case nsCSSProperty.Fill:
              case nsCSSProperty.Stroke:
            return ParsePaint(aPropID);
              case nsCSSProperty.StrokeDasharray:
            return ParseDasharray();
              case nsCSSProperty.Marker:
            return ParseMarker();
              case nsCSSProperty.PaintOrder:
            return ParsePaintOrder();
              default:
            Debug.Assert(false, "should not be called");
            return false;
              }
        }
示例#38
0
 internal void InitBoxPropsAsPhysical(nsCSSProperty[] aSourceProperties)
 {
     var physical = new nsCSSValue(nsStyle.BOXPROP_SOURCE_PHYSICAL, nsCSSUnit.Enumerated);
       AppendValues(aSourceProperties, physical);
 }
示例#39
0
        internal bool ParseProperty(nsCSSProperty aPropID)
        {
            // Can't use AutoRestore<bool> because it's a bitfield.
              Debug.Assert(!mHashlessColorQuirk,
                            "hashless color quirk should not be set");
              Debug.Assert(!mUnitlessLengthQuirk,
                            "unitless length quirk should not be set");
              if (mNavQuirkMode) {
            mHashlessColorQuirk =
              nsCSSProps.PropHasFlags(aPropID, nsCSSProps.HASHLESS_COLOR_QUIRK);
            mUnitlessLengthQuirk =
              nsCSSProps.PropHasFlags(aPropID, nsCSSProps.UNITLESS_LENGTH_QUIRK);
              }

              Debug.Assert(aPropID < nsCSSProperty.PropertyCount, "index out of range");
              bool result;
              switch (nsCSSProps.PropertyParseType(aPropID)) {
            case nsCSSProps.PARSE_INACCESSIBLE: {
              // The user can't use these
              { if (!mSuppressErrors) mReporter.ReportUnexpected("PEInaccessibleProperty2"); };
              result = false;
              break;
            }
              goto case nsCSSProps.PARSE_FUNCTION;
            case nsCSSProps.PARSE_FUNCTION: {
              result = ParsePropertyByFunction(aPropID);
              break;
            }
              goto case nsCSSProps.PARSE_VALUE;
            case nsCSSProps.PARSE_VALUE: {
              result = false;
              var value = new nsCSSValue();
              if (ParseSingleValueProperty(ref value, aPropID)) {
                if (ExpectEndProperty()) {
                  AppendValue(aPropID, value);
                  result = true;
                }
                // XXX Report errors?
              }
              // XXX Report errors?
              break;
            }
              goto case nsCSSProps.PARSE_VALUE_LIST;
            case nsCSSProps.PARSE_VALUE_LIST: {
              result = ParseValueList(aPropID);
              break;
            }
              goto default;
            default: {
              result = false;
              Debug.Assert(false,
                                "Property's flags field in nsCSSPropList.h is missing one of the nsCSSProps.PARSE_* constants");
              break;
            }
            break;
              }

              if (mNavQuirkMode) {
            mHashlessColorQuirk = false;
            mUnitlessLengthQuirk = false;
              }

              return result;
        }
示例#40
0
        internal bool ParsePaint(nsCSSProperty aPropID)
        {
            nsCSSValue x = new nsCSSValue(), y = new nsCSSValue();
              if (!ParseVariant(ref x, VARIANT_HCK | VARIANT_NONE | VARIANT_URL,
                            nsCSSProps.kObjectPatternKTable)) {
            return false;
              }

              bool canHaveFallback = x.GetUnit() == nsCSSUnit.Url ||
                                 x.GetUnit() == nsCSSUnit.Enumerated;
              if (canHaveFallback) {
            if (!ParseVariant(ref y, VARIANT_COLOR | VARIANT_NONE, null))
              y.SetNoneValue();
              }
              if (!ExpectEndProperty())
            return false;

              if (!canHaveFallback) {
            AppendValue(aPropID, x);
              } else {
            var val = new nsCSSValue();
            val.SetPairValue(x, y);
            AppendValue(aPropID, val);
              }
              return true;
        }
示例#41
0
        internal nsresult ParseProperty(nsCSSProperty aPropID,
                                     string aPropValue,
                                     Uri aSheetURI,
                                     Uri aBaseURI,
                                     nsIPrincipal aSheetPrincipal,
                                     Declaration aDeclaration,
                                     ref bool aChanged,
                                     bool aIsImportant,
                                     bool aIsSVGMode)
        {
            if (aSheetPrincipal == null) throw new ArgumentException("Must have principal here!");
              if (aBaseURI == null) throw new ArgumentException("need base URI");
              if (aDeclaration == null) throw new ArgumentException("Need declaration to parse into!");

              mData.AssertInitialState();
              mTempData.AssertInitialState();
              aDeclaration.AssertMutable();

              var scanner = new nsCSSScanner(aPropValue, 0);
              var reporter = new ErrorReporter(scanner, mSheet, mChildLoader, aSheetURI);
              InitScanner(scanner, reporter, aSheetURI, aBaseURI, aSheetPrincipal);
              mSection = nsCSSSection.General;
              scanner.SetSVGMode(aIsSVGMode);

              aChanged = false;

              // Check for unknown or preffed off properties
              if (nsCSSProperty.Unknown == aPropID || !nsCSSProps.IsEnabled(aPropID)) {
            string propName = nsCSSProps.GetStringValue(aPropID);
            { if (!mSuppressErrors) mReporter.ReportUnexpected("PEUnknownProperty", propName); };
            { if (!mSuppressErrors) mReporter.ReportUnexpected("PEDeclDropped"); };
            mReporter.OutputError();
            ReleaseScanner();
            return nsresult.OK;
              }

              bool parsedOK = ParseProperty(aPropID);
              // We should now be at EOF
              if (parsedOK && GetToken(true)) {
            { if (!mSuppressErrors) mReporter.ReportUnexpected("PEExpectEndValue", mToken); };
            parsedOK = false;
              }

              if (!parsedOK) {
            string propName = nsCSSProps.GetStringValue(aPropID);
            { if (!mSuppressErrors) mReporter.ReportUnexpected("PEValueParsingError", propName); };
            { if (!mSuppressErrors) mReporter.ReportUnexpected("PEDeclDropped"); };
            mReporter.OutputError();
            mTempData.ClearProperty(aPropID);
              } else {

            // We know we don't need to force a ValueAppended call for the new
            // value.  So if we are not processing a shorthand, and there's
            // already a value for this property in the declaration at the
            // same importance level, then we can just copy our parsed value
            // directly into the declaration without going through the whole
            // expand/compress thing.
            if (!aDeclaration.TryReplaceValue(aPropID, aIsImportant, mTempData, ref aChanged)) {
              // Do it the slow way
              aDeclaration.ExpandTo(mData);
              aChanged = mData.TransferFromBlock(mTempData, aPropID, aIsImportant,
                                                  true, false, aDeclaration);
              aDeclaration.CompressFrom(mData);
            }
            mReporter.ClearError();
              }

              mTempData.AssertInitialState();

              ReleaseScanner();
              return nsresult.OK;
        }
示例#42
0
        internal ParseAnimationOrTransitionShorthandResult ParseAnimationOrTransitionShorthand(
                         nsCSSProperty[] aProperties,
                         nsCSSValue[] aInitialValues,
                         ref nsCSSValue[] aValues,
                         size_t aNumProperties)
        {
            var tempValue = new nsCSSValue();
              // first see if 'inherit' or 'initial' is specified.  If one is,
              // it can be the only thing specified, so don't attempt to parse any
              // additional properties
              if (ParseVariant(ref tempValue, VARIANT_INHERIT, null)) {
            for (uint32_t i = 0; i < aNumProperties; ++i) {
              AppendValue(aProperties[i], tempValue);
            }
            return ParseAnimationOrTransitionShorthandResult.Inherit;
              }

              const size_t maxNumProperties = 7;
              Debug.Assert(aNumProperties <= maxNumProperties,
                            "can't handle this many properties");
              var cur = new nsCSSValueList[maxNumProperties];
              var parsedProperty = new bool[maxNumProperties];

              for (size_t i = 0; i < aNumProperties; ++i) {
            cur[i] = null;
              }
              bool atEOP = false; // at end of property?
              for (;;) { // loop over comma-separated transitions or animations
            // whether a particular subproperty was specified for this
            // transition or animation
            for (size_t i = 0; i < aNumProperties; ++i) {
              parsedProperty[i] = false;
            }
            for (;;) { // loop over values within a transition or animation
              bool foundProperty = false;
              // check to see if we're at the end of one full transition or
              // animation definition (either because we hit a comma or because
              // we hit the end of the property definition)
              if (ExpectSymbol(',', true))
                break;
              if (CheckEndProperty()) {
                atEOP = true;
                break;
              }

              // else, try to parse the next transition or animation sub-property
              for (uint32_t i = 0; !foundProperty && i < aNumProperties; ++i) {
                if (!parsedProperty[i]) {
                  // if we haven't found this property yet, try to parse it
                  if (ParseSingleValueProperty(ref tempValue, aProperties[i])) {
                    parsedProperty[i] = true;
                    cur[i] = AppendValueToList(ref aValues[i], cur[i], tempValue);
                    foundProperty = true;
                    break; // out of inner loop; continue looking for next sub-property
                  }
                }
              }
              if (!foundProperty) {
                // We're not at a ',' or at the end of the property, but we couldn't
                // parse any of the sub-properties, so the declaration is invalid.
                return ParseAnimationOrTransitionShorthandResult.Error;
              }
            }

            // We hit the end of the property or the end of one transition
            // or animation definition, add its components to the list.
            for (uint32_t i = 0; i < aNumProperties; ++i) {
              // If all of the subproperties were not explicitly specified, fill
              // in the missing ones with initial values.
              if (!parsedProperty[i]) {
                cur[i] = AppendValueToList(ref aValues[i], cur[i], aInitialValues[i]);
              }
            }

            if (atEOP)
              break;
            // else we just hit a ',' so continue parsing the next compound transition
              }

              return ParseAnimationOrTransitionShorthandResult.Values;
        }
示例#43
0
 internal bool ParseBorderColors(nsCSSProperty aProperty)
 {
     var value = new nsCSSValue();
       if (ParseVariant(ref value, VARIANT_INHERIT | VARIANT_NONE, null)) {
     // 'inherit', 'initial', and 'none' are only allowed on their own
     if (!ExpectEndProperty()) {
       return false;
     }
       } else {
     nsCSSValueList cur = value.SetListValue();
     for (;;) {
       if (!ParseVariant(ref cur.mValue, VARIANT_COLOR | VARIANT_KEYWORD,
                         nsCSSProps.kBorderColorKTable)) {
         return false;
       }
       if (CheckEndProperty()) {
         break;
       }
       cur.mNext = new nsCSSValueList();
       cur = cur.mNext;
     }
       }
       AppendValue(aProperty, value);
       return true;
 }
示例#44
0
 // This function is very similar to ParseBackgroundPosition and
 // ParseBackgroundSize.
 internal bool ParseValueList(nsCSSProperty aPropID)
 {
     // aPropID is a single value prop-id
       var value = new nsCSSValue();
       if (ParseVariant(ref value, VARIANT_INHERIT, null)) {
     // 'initial' and 'inherit' stand alone, no list permitted.
     if (!ExpectEndProperty()) {
       return false;
     }
       } else {
     nsCSSValueList item = value.SetListValue();
     for (;;) {
       if (!ParseSingleValueProperty(ref item.mValue, aPropID)) {
         return false;
       }
       if (CheckEndProperty()) {
         break;
       }
       if (!ExpectSymbol(',', true)) {
         return false;
       }
       item.mNext = new nsCSSValueList();
       item = item.mNext;
     }
       }
       AppendValue(aPropID, value);
       return true;
 }
示例#45
0
 public static int ValueRestrictions(CssProperty aProperty)
 {
     return kFlagsTable[(int)aProperty] & VALUE_RESTRICTION_MASK;
 }
示例#46
0
        /**
         * Parse a "box" property. Box properties have 1 to 4 values. When less
         * than 4 values are provided a standard mapping is used to replicate
         * existing values.
         */
        internal bool ParseBoxProperties(nsCSSProperty[] aPropIDs)
        {
            // Get up to four values for the property
              int32_t count = 0;
              var result = new nsCSSRect();
              for (Side index = nsStyle.SIDE_TOP; index <= nsStyle.SIDE_LEFT; index++) {
            if (! ParseSingleValueProperty(result.GetSide(index), v => result.SetSide(index, v),
                                           aPropIDs[(int)index])) {
              break;
            }
            count++;
              }
              if ((count == 0) || (false == ExpectEndProperty())) {
            return false;
              }

              if (1 < count) { // verify no more than single inherit or initial
            for (Side index = nsStyle.SIDE_TOP; index <= nsStyle.SIDE_LEFT; index++) {
              nsCSSUnit unit = (result.GetSide(index)).GetUnit();
              if (nsCSSUnit.Inherit == unit || nsCSSUnit.Initial == unit) {
                return false;
              }
            }
              }

              // Provide missing values by replicating some of the values found
              switch (count) {
            case 1: // Make right == top
              result.mRight = result.mTop;
              goto case 2;
            case 2: // Make bottom == top
              result.mBottom = result.mTop;
              goto case 3;
            case 3: // Make left == right
              result.mLeft = result.mRight;
            break;
              }

              for (Side index = nsStyle.SIDE_TOP; index <= nsStyle.SIDE_LEFT; index++) {
            AppendValue(aPropIDs[(int)index], result.GetSide(index));
              }
              return true;
        }
示例#47
0
 private void AppendValues(CssProperty[] aPropIDs, CssValue aValue)
 {
     foreach (CssProperty aPropId in aPropIDs)
         if (aPropId != CssProperty.Unknown)
             AppendValue(aPropId, aValue);
 }
示例#48
0
        internal bool ParseBoxCornerRadius(nsCSSProperty aPropID)
        {
            nsCSSValue dimenX = new nsCSSValue(), dimenY = new nsCSSValue();
              // required first value
              if (! ParseNonNegativeVariant(ref dimenX, VARIANT_HLP | VARIANT_CALC, null))
            return false;

              // optional second value (forbidden if first value is inherit/initial)
              if (dimenX.GetUnit() != nsCSSUnit.Inherit &&
              dimenX.GetUnit() != nsCSSUnit.Initial) {
            ParseNonNegativeVariant(ref dimenY, VARIANT_LP | VARIANT_CALC, null);
              }

              if (dimenX == dimenY || dimenY.GetUnit() == nsCSSUnit.Null) {
            AppendValue(aPropID, dimenX);
              } else {
            var value = new nsCSSValue();
            value.SetPairValue(dimenX, dimenY);
            AppendValue(aPropID, value);
              }
              return true;
        }
示例#49
0
        internal bool ParseBoxCornerRadii(nsCSSProperty[] aPropIDs)
        {
            // Rectangles are used as scratch storage.
              // top => top-left, right => top-right,
              // bottom => bottom-right, left => bottom-left.
              nsCSSRect dimenX = new nsCSSRect(), dimenY = new nsCSSRect();
              int32_t countX = 0, countY = 0;

              for (Side side = nsStyle.SIDE_TOP; side <= nsStyle.SIDE_LEFT; side++) {
            if (! ParseNonNegativeVariant(dimenX.GetSide(side), v => dimenX.SetSide(side, v),
                                          (side > 0 ? 0 : VARIANT_INHERIT) |
                                            VARIANT_LP | VARIANT_CALC,
                                          null))
              break;
            countX++;
              }
              if (countX == 0)
            return false;

              if (ExpectSymbol('/', true)) {
            for (Side side = nsStyle.SIDE_TOP; side <= nsStyle.SIDE_LEFT; side++) {
              if (! ParseNonNegativeVariant(dimenY.GetSide(side), v => dimenY.SetSide(side, v),
                                            VARIANT_LP | VARIANT_CALC, null))
                break;
              countY++;
            }
            if (countY == 0)
              return false;
              }
              if (!ExpectEndProperty())
            return false;

              // if 'initial' or 'inherit' was used, it must be the only value
              if (countX > 1 || countY > 0) {
            nsCSSUnit unit = dimenX.mTop.GetUnit();
            if (nsCSSUnit.Inherit == unit || nsCSSUnit.Initial == unit)
              return false;
              }

              // if we have no Y-values, use the X-values
              if (countY == 0) {
            dimenY = dimenX;
            countY = countX;
              }

              // Provide missing values by replicating some of the values found
              switch (countX) {
            case 1: dimenX.mRight = dimenX.mTop;  // top-right same as top-left, and
              goto case 2;
            case 2: dimenX.mBottom = dimenX.mTop; // bottom-right same as top-left, and
              goto case 3;
            case 3: dimenX.mLeft = dimenX.mRight; // bottom-left same as top-right
            break;
              }

              switch (countY) {
            case 1: dimenY.mRight = dimenY.mTop;  // top-right same as top-left, and
              goto case 2;
            case 2: dimenY.mBottom = dimenY.mTop; // bottom-right same as top-left, and
              goto case 3;
            case 3: dimenY.mLeft = dimenY.mRight; // bottom-left same as top-right
            break;
              }

              for (Side side = nsStyle.SIDE_TOP; side <= nsStyle.SIDE_LEFT; side++) {
            nsCSSValue x = dimenX.GetSide(side);
            nsCSSValue y = dimenY.GetSide(side);

            if (x == y) {
              AppendValue(aPropIDs[(int)side], x);
            } else {
              var pair = new nsCSSValue();
              pair.SetPairValue(x, y);
              AppendValue(aPropIDs[(int)side], pair);
            }
              }
              return true;
        }
示例#50
0
        internal bool ParseBorderSide(nsCSSProperty[] aPropIDs,
                                       bool aSetAllSides)
        {
            uint32_t numProps = 3;
              var values = new nsCSSValue[numProps];

              int32_t found = ParseChoice(ref values, aPropIDs, numProps);
              if ((found < 1) || (false == ExpectEndProperty())) {
            return false;
              }

              if ((found & 1) == 0) { // Provide default border-width
            values[0].SetIntValue(nsStyle.BORDER_WIDTH_MEDIUM, nsCSSUnit.Enumerated);
              }
              if ((found & 2) == 0) { // Provide default border-style
            values[1].SetIntValue(nsStyle.BORDER_STYLE_NONE, nsCSSUnit.Enumerated);
              }
              if ((found & 4) == 0) { // text color will be used
            values[2].SetIntValue(nsStyle.COLOR_MOZ_USE_TEXT_COLOR, nsCSSUnit.Enumerated);
              }

              if (aSetAllSides) {
            /*TODO: static*/ nsCSSProperty[] kBorderSources = {
              nsCSSProperty.BorderLeftColorLtrSource,
              nsCSSProperty.BorderLeftColorRtlSource,
              nsCSSProperty.BorderRightColorLtrSource,
              nsCSSProperty.BorderRightColorRtlSource,
              nsCSSProperty.BorderLeftStyleLtrSource,
              nsCSSProperty.BorderLeftStyleRtlSource,
              nsCSSProperty.BorderRightStyleLtrSource,
              nsCSSProperty.BorderRightStyleRtlSource,
              nsCSSProperty.BorderLeftWidthLtrSource,
              nsCSSProperty.BorderLeftWidthRtlSource,
              nsCSSProperty.BorderRightWidthLtrSource,
              nsCSSProperty.BorderRightWidthRtlSource,
              nsCSSProperty.Unknown
            };

            InitBoxPropsAsPhysical(kBorderSources);

            // Parsing "border" shorthand; set all four sides to the same thing
            for (int32_t index = 0; index < 4; index++) {
              Debug.Assert(numProps == 3, "This code needs updating");
              AppendValue(kBorderWidthIDs[index], values[0]);
              AppendValue(kBorderStyleIDs[index], values[1]);
              AppendValue(kBorderColorIDs[index], values[2]);
            }

            /*TODO: static*/ nsCSSProperty[] kBorderColorsProps = {
              nsCSSProperty.BorderTopColors,
              nsCSSProperty.BorderRightColors,
              nsCSSProperty.BorderBottomColors,
              nsCSSProperty.BorderLeftColors
            };

            // Set the other properties that the border shorthand sets to their
            // initial values.
            var extraValue = new nsCSSValue();
            switch (values[0].GetUnit()) {
            case nsCSSUnit.Inherit:
            case nsCSSUnit.Initial:
              extraValue = values[0];
              // Set value of border-image properties to initial/inherit
              AppendValue(nsCSSProperty.BorderImageSource, extraValue);
              AppendValue(nsCSSProperty.BorderImageSlice, extraValue);
              AppendValue(nsCSSProperty.BorderImageWidth, extraValue);
              AppendValue(nsCSSProperty.BorderImageOutset, extraValue);
              AppendValue(nsCSSProperty.BorderImageRepeat, extraValue);
              break;
            default:
              extraValue.SetNoneValue();
              SetBorderImageInitialValues();
              break;
            }
            for (Side side = nsStyle.SIDE_TOP; side <= nsStyle.SIDE_LEFT; side++) {
              AppendValue(kBorderColorsProps[(int)side], extraValue);
            }
              }
              else {
            // Just set our one side
            for (int32_t index = 0; index < numProps; index++) {
              AppendValue(aPropIDs[(int)index], values[index]);
            }
              }
              return true;
        }
示例#51
0
        internal bool ParseRect(nsCSSProperty aPropID)
        {
            if (! GetToken(true)) {
            return false;
              }

              var val = new nsCSSValue();

              if (mToken.mType == nsCSSTokenType.Ident) {
            nsCSSKeyword keyword = nsCSSKeywords.LookupKeyword(mToken.mIdentStr);
            switch (keyword) {
              case nsCSSKeyword.auto:
                if (!ExpectEndProperty()) {
                  return false;
                }
                val.SetAutoValue();
                break;
              case nsCSSKeyword.inherit:
                if (!ExpectEndProperty()) {
                  return false;
                }
                val.SetInheritValue();
                break;
              case nsCSSKeyword.initial:
              case nsCSSKeyword._moz_initial:
                if (!ExpectEndProperty()) {
                  return false;
                }
                val.SetInitialValue();
                break;
              default:
                UngetToken();
                return false;
            }
              } else if (mToken.mType == nsCSSTokenType.Function &&
                     mToken.mIdentStr.LowerCaseEqualsLiteral("rect")) {
            nsCSSRect rect = val.SetRectValue();
            bool useCommas = false;
            for (Side side = nsStyle.SIDE_TOP; side <= nsStyle.SIDE_LEFT; side++) {
              if (! ParseVariant(rect.GetSide(side), v => rect.SetSide(side, v),
                                 VARIANT_AL, null)) {
                return false;
              }
              if (side == 0) {
                useCommas = ExpectSymbol(',', true);
              } else if (useCommas && (int)side < 3) {
                // Skip optional commas between elements, but only if the first
                // separator was a comma.
                if (!ExpectSymbol(',', true)) {
                  return false;
                }
              }
            }
            if (!ExpectSymbol(')', true)) {
              return false;
            }
            if (!ExpectEndProperty()) {
              return false;
            }
              } else {
            UngetToken();
            return false;
              }

              AppendValue(aPropID, val);
              return true;
        }
示例#52
0
        internal bool ParseDirectionalBoxProperty(nsCSSProperty aProperty,
                                                   int32_t aSourceType)
        {
            nsCSSProperty[] subprops = nsCSSProps.SubpropertyEntryFor(aProperty);
              Debug.Assert(subprops[3] == nsCSSProperty.Unknown,
                       "not box property with physical vs. logical cascading");
              var value = new nsCSSValue();
              if (!ParseSingleValueProperty(ref value, subprops[0]) ||
              !ExpectEndProperty())
            return false;

              AppendValue(subprops[0], value);
              var typeVal = new nsCSSValue(aSourceType, nsCSSUnit.Enumerated);
              AppendValue(subprops[1], typeVal);
              AppendValue(subprops[2], typeVal);
              return true;
        }
示例#53
0
        internal bool ParseShadowList(nsCSSProperty aProperty)
        {
            using (/*var compound = */new nsAutoParseCompoundProperty(this)) {
            bool isBoxShadow = aProperty == nsCSSProperty.BoxShadow;

            var value = new nsCSSValue();
            if (ParseVariant(ref value, VARIANT_INHERIT | VARIANT_NONE, null)) {
              // 'inherit', 'initial', and 'none' must be alone
              if (!ExpectEndProperty()) {
                return false;
              }
            } else {
              nsCSSValueList cur = value.SetListValue();
              for (;;) {
                if (!ParseShadowItem(ref cur.mValue, isBoxShadow)) {
                  return false;
                }
                if (CheckEndProperty()) {
                  break;
                }
                if (!ExpectSymbol(',', true)) {
                  return false;
                }
                cur.mNext = new nsCSSValueList();
                cur = cur.mNext;
              }
            }
            AppendValue(aProperty, value);
            return true;
              }
        }
示例#54
0
 internal void AppendValue(nsCSSProperty aPropID, nsCSSValue aValue)
 {
     mTempData.AddLonghandProperty(aPropID, aValue);
 }
示例#55
0
        // Bits used in determining which background position info we have
        internal bool ParseSingleValueProperty(ref nsCSSValue aValue,
                                                nsCSSProperty aPropID)
        {
            if (aPropID == nsCSSProperty.ExtraXNoneValue) {
            return ParseVariant(ref aValue, VARIANT_NONE | VARIANT_INHERIT, null);
              }

              if (aPropID == nsCSSProperty.ExtraXAutoValue) {
            return ParseVariant(ref aValue, VARIANT_AUTO | VARIANT_INHERIT, null);
              }

              if (aPropID < 0 || aPropID >= nsCSSProperty.PropertyCountNoShorthands) {
            Debug.Assert(false, "not a single value property");
            return false;
              }

              if (nsCSSProps.PropHasFlags(aPropID, nsCSSProps.VALUE_PARSER_FUNCTION)) {
            switch (aPropID) {
              case nsCSSProperty.FontFamily:
                return ParseFamily(ref aValue);
              case nsCSSProperty.FontFeatureSettings:
                return ParseFontFeatureSettings(ref aValue);
              case nsCSSProperty.FontWeight:
                return ParseFontWeight(ref aValue);
              case nsCSSProperty.Marks:
                return ParseMarks(ref aValue);
              case nsCSSProperty.TextDecorationLine:
                return ParseTextDecorationLine(ref aValue);
              case nsCSSProperty.TextOverflow:
                return ParseTextOverflow(ref aValue);
              default:
                Debug.Assert(false, "should not reach here");
                return false;
            }
              }

              uint32_t variant = nsCSSProps.ParserVariant(aPropID);
              if (variant == 0) {
            Debug.Assert(false, "not a single value property");
            return false;
              }

              // We only allow 'script-level' when unsafe rules are enabled, because
              // otherwise it could interfere with rulenode optimizations if used in
              // a non-MathML-enabled document.
              if (aPropID == nsCSSProperty.ScriptLevel && !mUnsafeRulesEnabled)
            return false;

              int32_t[] kwtable = nsCSSProps.kKeywordTableTable[(int)aPropID];
              switch (nsCSSProps.ValueRestrictions(aPropID)) {
            default:
              Debug.Assert(false, "should not be reached");
              goto case 0;
            case 0:
              return ParseVariant(ref aValue, variant, kwtable);
            case nsCSSProps.VALUE_NONNEGATIVE:
              return ParseNonNegativeVariant(ref aValue, variant, kwtable);
            case nsCSSProps.VALUE_AT_LEAST_ONE:
              return ParseOneOrLargerVariant(ref aValue, variant, kwtable);
              }
        }
示例#56
0
 private bool ParseSingleValueProperty(CssValue aValue, Action<CssValue> setValue, CssProperty _1)
 {
     var res = ParseSingleValueProperty(ref aValue, _1);
     setValue(aValue);
     return res;
 }
示例#57
0
        internal int32_t ParseChoice(ref nsCSSValue[] aValues,
                                   nsCSSProperty[] aPropIDs, int32_t aNumIDs)
        {
            int32_t found = 0;
              using (/*var compound = */new nsAutoParseCompoundProperty(this)) {

            int32_t loop = 0;
            for (loop = 0; loop < aNumIDs; loop++) {
              // Try each property parser in order
              int32_t hadFound = found;
              int32_t index = 0;
              for (index = 0; index < aNumIDs; index++) {
                int32_t bit = 1 << index;
                if ((found & bit) == 0) {
                  if (ParseSingleValueProperty(ref aValues[index], aPropIDs[(int)index])) {
                    found |= bit;
                    // It's more efficient to break since it will reset |hadFound|
                    // to |found|.  Furthermore, ParseListStyle depends on our going
                    // through the properties in order for each value..
                    break;
                  }
                }
              }
              if (found == hadFound) {  // found nothing new
                break;
              }
            }
            if (0 < found) {
              if (1 == found) { // only first property
                if (nsCSSUnit.Inherit == aValues[0].GetUnit()) { // one inherit, all inherit
                  for (loop = 1; loop < aNumIDs; loop++) {
                    aValues[loop].SetInheritValue();
                  }
                  found = ((1 << aNumIDs) - 1);
                }
                else if (nsCSSUnit.Initial == aValues[0].GetUnit()) { // one initial, all initial
                  for (loop = 1; loop < aNumIDs; loop++) {
                    aValues[loop].SetInitialValue();
                  }
                  found = ((1 << aNumIDs) - 1);
                }
              }
              else {  // more than one value, verify no inherits or initials
                for (loop = 0; loop < aNumIDs; loop++) {
                  if (nsCSSUnit.Inherit == aValues[loop].GetUnit()) {
                    found = -1;
                    break;
                  }
                  else if (nsCSSUnit.Initial == aValues[loop].GetUnit()) {
                    found = -1;
                    break;
                  }
                }
              }
            }
            return found;
              }
        }
示例#58
0
        internal bool ParseDirectionalBorderSide(nsCSSProperty[] aPropIDs,
                                                  int32_t aSourceType)
        {
            uint32_t numProps = 3;
              var values = new nsCSSValue[numProps];

              int32_t found = ParseChoice(ref values, aPropIDs, numProps);
              if ((found < 1) || (false == ExpectEndProperty())) {
            return false;
              }

              if ((found & 1) == 0) { // Provide default border-width
            values[0].SetIntValue(nsStyle.BORDER_WIDTH_MEDIUM, nsCSSUnit.Enumerated);
              }
              if ((found & 2) == 0) { // Provide default border-style
            values[1].SetIntValue(nsStyle.BORDER_STYLE_NONE, nsCSSUnit.Enumerated);
              }
              if ((found & 4) == 0) { // text color will be used
            values[2].SetIntValue(nsStyle.COLOR_MOZ_USE_TEXT_COLOR, nsCSSUnit.Enumerated);
              }
              for (int32_t index = 0; index < numProps; index++) {
            nsCSSProperty[] subprops =
              nsCSSProps.SubpropertyEntryFor(aPropIDs[index + numProps]);
            Debug.Assert(subprops[3] == nsCSSProperty.Unknown,
                         "not box property with physical vs. logical cascading");
            AppendValue(subprops[0], values[index]);
            var typeVal = new nsCSSValue(aSourceType, nsCSSUnit.Enumerated);
            AppendValue(subprops[1], typeVal);
            AppendValue(subprops[2], typeVal);
              }
              return true;
        }
示例#59
0
 public static CssProperty[] SubpropertyEntryFor(CssProperty aProperty, bool skipUnknown = false)
 {
     CssProperty[] res = kSubpropertyTable[aProperty - CssProperty.PropertyCountNoShorthands];
     return skipUnknown ? res.Where(p => p != CssProperty.Unknown).ToArray() : res;
 }
示例#60
0
        internal bool ParseCounterData(nsCSSProperty aPropID)
        {
            var value = new nsCSSValue();
              if (!ParseVariant(ref value, VARIANT_INHERIT | VARIANT_NONE, null)) {
            if (!GetToken(true) || mToken.mType != nsCSSTokenType.Ident) {
              return false;
            }

            nsCSSValuePairList cur = value.SetPairListValue();
            for (;;) {
              cur.mXValue.SetStringValue(mToken.mIdentStr, nsCSSUnit.Ident);
              if (!GetToken(true)) {
                break;
              }
              if (mToken.mType == nsCSSTokenType.Number && mToken.mIntegerValid) {
                cur.mYValue.SetIntValue(mToken.mInteger, nsCSSUnit.Integer);
              } else {
                UngetToken();
              }
              if (CheckEndProperty()) {
                break;
              }
              if (!GetToken(true) || mToken.mType != nsCSSTokenType.Ident) {
                return false;
              }
              cur.mNext = new nsCSSValuePairList();
              cur = cur.mNext;
            }
              }
              AppendValue(aPropID, value);
              return true;
        }