2001-09-25 05:32:19 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2006-03-25 08:47:31 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* representation of a declaration block (or style attribute) in a CSS
|
|
|
|
* stylesheet
|
|
|
|
*/
|
|
|
|
|
2010-06-29 02:49:35 +04:00
|
|
|
#ifndef mozilla_css_Declaration_h
|
|
|
|
#define mozilla_css_Declaration_h
|
|
|
|
|
|
|
|
// This header is in EXPORTS because it's used in several places in content/,
|
|
|
|
// but it's not really a public interface.
|
2013-03-16 08:31:38 +04:00
|
|
|
#ifndef MOZILLA_INTERNAL_API
|
|
|
|
#error "This file should only be included within libxul"
|
2010-06-29 02:49:35 +04:00
|
|
|
#endif
|
1998-04-14 00:24:54 +04:00
|
|
|
|
Bug 773296 - Part 2: Parse CSS variable declarations and store them on Declaration objects. p=ebassi,heycam r=dbaron
Patch co-authored by Emmanuele Bassi <ebassi@gmail.com>
This defines a CSSVariableDeclarations class that holds a set of
variable declarations. This is at the specified value stage, so values
can either be 'initial', 'inherit' or a token stream (which is what you
normally have). The variables are stored in a hash table. Although
it's a bit of a hack, we store 'initial' and 'inherit' using special
string values that can't be valid token streams (we use "!" and ";").
Declaration objects now can have two CSSVariableDeclarations objects
on them, to store normal and !important variable declarations. So that
we keep preserving the order of declarations on the object, we inflate
mOrder to store uint32_ts, where values from eCSSProperty_COUNT onwards
represent custom properties. mVariableOrder stores the names of the
variables corresponding to those entries in mOrder.
We also add a new nsCSSProperty value, eCSSPropertyExtra_variable, which
is used to represent any custom property name.
nsCSSProps::LookupProperty can return this value.
The changes to nsCSSParser are straightforward. Custom properties
are parsed and checked for syntactic validity (e.g. "var(a,)" being
invalid) and stored on the Declaration. We use nsCSSScanner's
recording ability to grab the unparsed CSS string corresponding to
the variable's value.
2013-12-12 06:09:40 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2016-10-18 07:29:03 +03:00
|
|
|
#include "mozilla/DeclarationBlock.h"
|
Bug 773296 - Part 2: Parse CSS variable declarations and store them on Declaration objects. p=ebassi,heycam r=dbaron
Patch co-authored by Emmanuele Bassi <ebassi@gmail.com>
This defines a CSSVariableDeclarations class that holds a set of
variable declarations. This is at the specified value stage, so values
can either be 'initial', 'inherit' or a token stream (which is what you
normally have). The variables are stored in a hash table. Although
it's a bit of a hack, we store 'initial' and 'inherit' using special
string values that can't be valid token streams (we use "!" and ";").
Declaration objects now can have two CSSVariableDeclarations objects
on them, to store normal and !important variable declarations. So that
we keep preserving the order of declarations on the object, we inflate
mOrder to store uint32_ts, where values from eCSSProperty_COUNT onwards
represent custom properties. mVariableOrder stores the names of the
variables corresponding to those entries in mOrder.
We also add a new nsCSSProperty value, eCSSPropertyExtra_variable, which
is used to represent any custom property name.
nsCSSProps::LookupProperty can return this value.
The changes to nsCSSParser are straightforward. Custom properties
are parsed and checked for syntactic validity (e.g. "var(a,)" being
invalid) and stored on the Declaration. We use nsCSSScanner's
recording ability to grab the unparsed CSS string corresponding to
the variable's value.
2013-12-12 06:09:40 +04:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
|
|
|
#include "CSSVariableDeclarations.h"
|
2010-08-19 23:33:44 +04:00
|
|
|
#include "nsCSSDataBlock.h"
|
2016-08-17 04:37:48 +03:00
|
|
|
#include "nsCSSPropertyID.h"
|
1999-07-18 04:33:53 +04:00
|
|
|
#include "nsCSSProps.h"
|
2015-11-05 11:44:08 +03:00
|
|
|
#include "nsIStyleRule.h"
|
2010-08-19 23:33:44 +04:00
|
|
|
#include "nsStringFwd.h"
|
2008-01-10 23:13:24 +03:00
|
|
|
#include "nsTArray.h"
|
2010-08-19 23:33:44 +04:00
|
|
|
#include <stdio.h>
|
2002-01-16 01:43:37 +03:00
|
|
|
|
2015-11-05 11:44:08 +03:00
|
|
|
// feec07b8-3fe6-491e-90d5-cc93f853e048
|
|
|
|
#define NS_CSS_DECLARATION_IMPL_CID \
|
|
|
|
{ 0xfeec07b8, 0x3fe6, 0x491e, \
|
|
|
|
{ 0x90, 0xd5, 0xcc, 0x93, 0xf8, 0x53, 0xe0, 0x48 } }
|
|
|
|
|
2015-11-09 10:57:16 +03:00
|
|
|
class nsHTMLCSSStyleSheet;
|
|
|
|
|
2010-06-29 02:49:35 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace css {
|
|
|
|
|
2015-11-05 11:44:08 +03:00
|
|
|
class Rule;
|
2015-11-05 11:44:09 +03:00
|
|
|
class Declaration;
|
|
|
|
|
2015-11-05 11:44:09 +03:00
|
|
|
/**
|
|
|
|
* ImportantStyleData is the implementation of nsIStyleRule (a source of
|
|
|
|
* style data) representing the style data coming from !important rules;
|
|
|
|
* the !important declarations need a separate nsIStyleRule object since
|
|
|
|
* they fit at a different point in the cascade.
|
|
|
|
*
|
|
|
|
* ImportantStyleData is allocated only as part of a Declaration object.
|
|
|
|
*/
|
2015-11-05 11:44:09 +03:00
|
|
|
class ImportantStyleData final : public nsIStyleRule
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2015-11-05 11:44:09 +03:00
|
|
|
inline ::mozilla::css::Declaration* Declaration();
|
|
|
|
|
2015-11-05 11:44:09 +03:00
|
|
|
// nsIStyleRule interface
|
|
|
|
virtual void MapRuleInfoInto(nsRuleData* aRuleData) override;
|
2015-11-17 07:09:55 +03:00
|
|
|
virtual bool MightMapInheritedStyleData() override;
|
2016-08-17 04:37:48 +03:00
|
|
|
virtual bool GetDiscretelyAnimatedCSSValue(nsCSSPropertyID aProperty,
|
2016-08-16 08:29:21 +03:00
|
|
|
nsCSSValue* aValue) override;
|
2015-11-05 11:44:09 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
|
|
|
|
#endif
|
|
|
|
|
2015-11-05 11:44:09 +03:00
|
|
|
private:
|
|
|
|
ImportantStyleData() {}
|
|
|
|
~ImportantStyleData() {}
|
2015-11-05 11:44:09 +03:00
|
|
|
|
2015-11-05 11:44:09 +03:00
|
|
|
friend class ::mozilla::css::Declaration;
|
2015-11-05 11:44:09 +03:00
|
|
|
};
|
2015-11-05 11:44:08 +03:00
|
|
|
|
2010-07-23 22:00:52 +04:00
|
|
|
// Declaration objects have unusual lifetime rules. Every declaration
|
|
|
|
// begins life in an invalid state which ends when InitializeEmpty or
|
|
|
|
// CompressFrom is called upon it. After that, it can be attached to
|
|
|
|
// exactly one style rule, and will be destroyed when that style rule
|
2015-11-05 11:44:10 +03:00
|
|
|
// is destroyed. A declaration becomes immutable (via a SetImmutable
|
|
|
|
// call) when it is matched (put in the rule tree); after that, it must
|
|
|
|
// be copied before it can be modified, which is taken care of by
|
|
|
|
// |EnsureMutable|.
|
2010-07-23 22:00:52 +04:00
|
|
|
|
2016-10-18 07:29:03 +03:00
|
|
|
class Declaration final : public DeclarationBlock
|
|
|
|
, public nsIStyleRule
|
|
|
|
{
|
1998-04-14 00:24:54 +04:00
|
|
|
public:
|
2003-06-08 02:14:42 +04:00
|
|
|
/**
|
2010-06-29 02:49:35 +04:00
|
|
|
* Construct an |Declaration| that is in an invalid state (null
|
2003-06-08 02:14:42 +04:00
|
|
|
* |mData|) and cannot be used until its |CompressFrom| method or
|
|
|
|
* |InitializeEmpty| method is called.
|
|
|
|
*/
|
2016-10-18 07:29:03 +03:00
|
|
|
Declaration() : DeclarationBlock(StyleBackendType::Gecko) {}
|
2000-04-20 17:00:08 +04:00
|
|
|
|
2010-06-29 02:49:35 +04:00
|
|
|
Declaration(const Declaration& aCopy);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2015-11-05 11:44:08 +03:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_CSS_DECLARATION_IMPL_CID)
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
2015-11-05 11:44:08 +03:00
|
|
|
|
|
|
|
private:
|
2010-07-23 22:00:52 +04:00
|
|
|
~Declaration();
|
|
|
|
|
2015-11-05 11:44:08 +03:00
|
|
|
public:
|
2015-11-05 11:44:08 +03:00
|
|
|
|
|
|
|
// nsIStyleRule implementation
|
|
|
|
virtual void MapRuleInfoInto(nsRuleData *aRuleData) override;
|
2015-11-17 07:09:55 +03:00
|
|
|
virtual bool MightMapInheritedStyleData() override;
|
2016-08-17 04:37:48 +03:00
|
|
|
virtual bool GetDiscretelyAnimatedCSSValue(nsCSSPropertyID aProperty,
|
2016-08-16 08:29:21 +03:00
|
|
|
nsCSSValue* aValue) override;
|
2015-11-05 11:44:08 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
|
|
|
|
#endif
|
|
|
|
|
2003-06-08 02:14:42 +04:00
|
|
|
/**
|
|
|
|
* |ValueAppended| must be called to maintain this declaration's
|
|
|
|
* |mOrder| whenever a property is parsed into an expanded data block
|
2009-03-06 07:05:01 +03:00
|
|
|
* for this declaration. aProperty must not be a shorthand.
|
2003-06-08 02:14:42 +04:00
|
|
|
*/
|
2016-08-17 04:37:48 +03:00
|
|
|
void ValueAppended(nsCSSPropertyID aProperty);
|
1998-06-26 09:51:55 +04:00
|
|
|
|
2016-11-03 06:41:02 +03:00
|
|
|
void GetPropertyValue(const nsAString& aProperty, nsAString& aValue) const;
|
|
|
|
void GetPropertyValueByID(nsCSSPropertyID aPropID, nsAString& aValue) const;
|
|
|
|
void GetAuthoredPropertyValue(const nsAString& aProperty,
|
|
|
|
nsAString& aValue) const;
|
|
|
|
bool GetPropertyIsImportant(const nsAString& aProperty) const;
|
|
|
|
void RemoveProperty(const nsAString& aProperty);
|
|
|
|
void RemovePropertyByID(nsCSSPropertyID aProperty);
|
2003-06-08 02:14:42 +04:00
|
|
|
|
2016-08-17 04:37:48 +03:00
|
|
|
bool HasProperty(nsCSSPropertyID aProperty) const;
|
2010-11-24 21:31:52 +03:00
|
|
|
|
2013-12-12 06:09:41 +04:00
|
|
|
bool HasImportantData() const {
|
|
|
|
return mImportantData || mImportantVariables;
|
|
|
|
}
|
1998-09-25 04:51:45 +04:00
|
|
|
|
Bug 773296 - Part 2: Parse CSS variable declarations and store them on Declaration objects. p=ebassi,heycam r=dbaron
Patch co-authored by Emmanuele Bassi <ebassi@gmail.com>
This defines a CSSVariableDeclarations class that holds a set of
variable declarations. This is at the specified value stage, so values
can either be 'initial', 'inherit' or a token stream (which is what you
normally have). The variables are stored in a hash table. Although
it's a bit of a hack, we store 'initial' and 'inherit' using special
string values that can't be valid token streams (we use "!" and ";").
Declaration objects now can have two CSSVariableDeclarations objects
on them, to store normal and !important variable declarations. So that
we keep preserving the order of declarations on the object, we inflate
mOrder to store uint32_ts, where values from eCSSProperty_COUNT onwards
represent custom properties. mVariableOrder stores the names of the
variables corresponding to those entries in mOrder.
We also add a new nsCSSProperty value, eCSSPropertyExtra_variable, which
is used to represent any custom property name.
nsCSSProps::LookupProperty can return this value.
The changes to nsCSSParser are straightforward. Custom properties
are parsed and checked for syntactic validity (e.g. "var(a,)" being
invalid) and stored on the Declaration. We use nsCSSScanner's
recording ability to grab the unparsed CSS string corresponding to
the variable's value.
2013-12-12 06:09:40 +04:00
|
|
|
/**
|
|
|
|
* Adds a custom property declaration to this object.
|
|
|
|
*
|
2014-04-02 07:32:16 +04:00
|
|
|
* @param aName The variable name (i.e., without the "--" prefix).
|
Bug 773296 - Part 2: Parse CSS variable declarations and store them on Declaration objects. p=ebassi,heycam r=dbaron
Patch co-authored by Emmanuele Bassi <ebassi@gmail.com>
This defines a CSSVariableDeclarations class that holds a set of
variable declarations. This is at the specified value stage, so values
can either be 'initial', 'inherit' or a token stream (which is what you
normally have). The variables are stored in a hash table. Although
it's a bit of a hack, we store 'initial' and 'inherit' using special
string values that can't be valid token streams (we use "!" and ";").
Declaration objects now can have two CSSVariableDeclarations objects
on them, to store normal and !important variable declarations. So that
we keep preserving the order of declarations on the object, we inflate
mOrder to store uint32_ts, where values from eCSSProperty_COUNT onwards
represent custom properties. mVariableOrder stores the names of the
variables corresponding to those entries in mOrder.
We also add a new nsCSSProperty value, eCSSPropertyExtra_variable, which
is used to represent any custom property name.
nsCSSProps::LookupProperty can return this value.
The changes to nsCSSParser are straightforward. Custom properties
are parsed and checked for syntactic validity (e.g. "var(a,)" being
invalid) and stored on the Declaration. We use nsCSSScanner's
recording ability to grab the unparsed CSS string corresponding to
the variable's value.
2013-12-12 06:09:40 +04:00
|
|
|
* @param aType The type of value the variable has.
|
|
|
|
* @param aValue The value of the variable, if aType is
|
|
|
|
* CSSVariableDeclarations::eTokenStream.
|
|
|
|
* @param aIsImportant Whether the declaration is !important.
|
2013-12-12 06:09:46 +04:00
|
|
|
* @param aOverrideImportant When aIsImportant is false, whether an
|
|
|
|
* existing !important declaration will be overridden.
|
Bug 773296 - Part 2: Parse CSS variable declarations and store them on Declaration objects. p=ebassi,heycam r=dbaron
Patch co-authored by Emmanuele Bassi <ebassi@gmail.com>
This defines a CSSVariableDeclarations class that holds a set of
variable declarations. This is at the specified value stage, so values
can either be 'initial', 'inherit' or a token stream (which is what you
normally have). The variables are stored in a hash table. Although
it's a bit of a hack, we store 'initial' and 'inherit' using special
string values that can't be valid token streams (we use "!" and ";").
Declaration objects now can have two CSSVariableDeclarations objects
on them, to store normal and !important variable declarations. So that
we keep preserving the order of declarations on the object, we inflate
mOrder to store uint32_ts, where values from eCSSProperty_COUNT onwards
represent custom properties. mVariableOrder stores the names of the
variables corresponding to those entries in mOrder.
We also add a new nsCSSProperty value, eCSSPropertyExtra_variable, which
is used to represent any custom property name.
nsCSSProps::LookupProperty can return this value.
The changes to nsCSSParser are straightforward. Custom properties
are parsed and checked for syntactic validity (e.g. "var(a,)" being
invalid) and stored on the Declaration. We use nsCSSScanner's
recording ability to grab the unparsed CSS string corresponding to
the variable's value.
2013-12-12 06:09:40 +04:00
|
|
|
*/
|
2016-11-03 06:41:02 +03:00
|
|
|
void AddVariable(const nsAString& aName,
|
|
|
|
CSSVariableDeclarations::Type aType,
|
|
|
|
const nsString& aValue,
|
|
|
|
bool aIsImportant,
|
|
|
|
bool aOverrideImportant);
|
Bug 773296 - Part 2: Parse CSS variable declarations and store them on Declaration objects. p=ebassi,heycam r=dbaron
Patch co-authored by Emmanuele Bassi <ebassi@gmail.com>
This defines a CSSVariableDeclarations class that holds a set of
variable declarations. This is at the specified value stage, so values
can either be 'initial', 'inherit' or a token stream (which is what you
normally have). The variables are stored in a hash table. Although
it's a bit of a hack, we store 'initial' and 'inherit' using special
string values that can't be valid token streams (we use "!" and ";").
Declaration objects now can have two CSSVariableDeclarations objects
on them, to store normal and !important variable declarations. So that
we keep preserving the order of declarations on the object, we inflate
mOrder to store uint32_ts, where values from eCSSProperty_COUNT onwards
represent custom properties. mVariableOrder stores the names of the
variables corresponding to those entries in mOrder.
We also add a new nsCSSProperty value, eCSSPropertyExtra_variable, which
is used to represent any custom property name.
nsCSSProps::LookupProperty can return this value.
The changes to nsCSSParser are straightforward. Custom properties
are parsed and checked for syntactic validity (e.g. "var(a,)" being
invalid) and stored on the Declaration. We use nsCSSScanner's
recording ability to grab the unparsed CSS string corresponding to
the variable's value.
2013-12-12 06:09:40 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes a custom property declaration from this object.
|
|
|
|
*
|
2014-04-02 07:32:16 +04:00
|
|
|
* @param aName The variable name (i.e., without the "--" prefix).
|
Bug 773296 - Part 2: Parse CSS variable declarations and store them on Declaration objects. p=ebassi,heycam r=dbaron
Patch co-authored by Emmanuele Bassi <ebassi@gmail.com>
This defines a CSSVariableDeclarations class that holds a set of
variable declarations. This is at the specified value stage, so values
can either be 'initial', 'inherit' or a token stream (which is what you
normally have). The variables are stored in a hash table. Although
it's a bit of a hack, we store 'initial' and 'inherit' using special
string values that can't be valid token streams (we use "!" and ";").
Declaration objects now can have two CSSVariableDeclarations objects
on them, to store normal and !important variable declarations. So that
we keep preserving the order of declarations on the object, we inflate
mOrder to store uint32_ts, where values from eCSSProperty_COUNT onwards
represent custom properties. mVariableOrder stores the names of the
variables corresponding to those entries in mOrder.
We also add a new nsCSSProperty value, eCSSPropertyExtra_variable, which
is used to represent any custom property name.
nsCSSProps::LookupProperty can return this value.
The changes to nsCSSParser are straightforward. Custom properties
are parsed and checked for syntactic validity (e.g. "var(a,)" being
invalid) and stored on the Declaration. We use nsCSSScanner's
recording ability to grab the unparsed CSS string corresponding to
the variable's value.
2013-12-12 06:09:40 +04:00
|
|
|
*/
|
2016-11-03 06:41:02 +03:00
|
|
|
void RemoveVariable(const nsAString& aName);
|
Bug 773296 - Part 2: Parse CSS variable declarations and store them on Declaration objects. p=ebassi,heycam r=dbaron
Patch co-authored by Emmanuele Bassi <ebassi@gmail.com>
This defines a CSSVariableDeclarations class that holds a set of
variable declarations. This is at the specified value stage, so values
can either be 'initial', 'inherit' or a token stream (which is what you
normally have). The variables are stored in a hash table. Although
it's a bit of a hack, we store 'initial' and 'inherit' using special
string values that can't be valid token streams (we use "!" and ";").
Declaration objects now can have two CSSVariableDeclarations objects
on them, to store normal and !important variable declarations. So that
we keep preserving the order of declarations on the object, we inflate
mOrder to store uint32_ts, where values from eCSSProperty_COUNT onwards
represent custom properties. mVariableOrder stores the names of the
variables corresponding to those entries in mOrder.
We also add a new nsCSSProperty value, eCSSPropertyExtra_variable, which
is used to represent any custom property name.
nsCSSProps::LookupProperty can return this value.
The changes to nsCSSParser are straightforward. Custom properties
are parsed and checked for syntactic validity (e.g. "var(a,)" being
invalid) and stored on the Declaration. We use nsCSSScanner's
recording ability to grab the unparsed CSS string corresponding to
the variable's value.
2013-12-12 06:09:40 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the string value for a custom property declaration of a variable
|
|
|
|
* with a given name.
|
|
|
|
*
|
2014-04-02 07:32:16 +04:00
|
|
|
* @param aName The variable name (i.e., without the "--" prefix).
|
Bug 773296 - Part 2: Parse CSS variable declarations and store them on Declaration objects. p=ebassi,heycam r=dbaron
Patch co-authored by Emmanuele Bassi <ebassi@gmail.com>
This defines a CSSVariableDeclarations class that holds a set of
variable declarations. This is at the specified value stage, so values
can either be 'initial', 'inherit' or a token stream (which is what you
normally have). The variables are stored in a hash table. Although
it's a bit of a hack, we store 'initial' and 'inherit' using special
string values that can't be valid token streams (we use "!" and ";").
Declaration objects now can have two CSSVariableDeclarations objects
on them, to store normal and !important variable declarations. So that
we keep preserving the order of declarations on the object, we inflate
mOrder to store uint32_ts, where values from eCSSProperty_COUNT onwards
represent custom properties. mVariableOrder stores the names of the
variables corresponding to those entries in mOrder.
We also add a new nsCSSProperty value, eCSSPropertyExtra_variable, which
is used to represent any custom property name.
nsCSSProps::LookupProperty can return this value.
The changes to nsCSSParser are straightforward. Custom properties
are parsed and checked for syntactic validity (e.g. "var(a,)" being
invalid) and stored on the Declaration. We use nsCSSScanner's
recording ability to grab the unparsed CSS string corresponding to
the variable's value.
2013-12-12 06:09:40 +04:00
|
|
|
* @param aValue Out parameter into which the variable's value will be
|
|
|
|
* stored. If the value is 'initial' or 'inherit', that exact string
|
|
|
|
* will be stored in aValue.
|
|
|
|
*/
|
2016-11-03 06:41:02 +03:00
|
|
|
void GetVariableValue(const nsAString& aName, nsAString& aValue) const;
|
Bug 773296 - Part 2: Parse CSS variable declarations and store them on Declaration objects. p=ebassi,heycam r=dbaron
Patch co-authored by Emmanuele Bassi <ebassi@gmail.com>
This defines a CSSVariableDeclarations class that holds a set of
variable declarations. This is at the specified value stage, so values
can either be 'initial', 'inherit' or a token stream (which is what you
normally have). The variables are stored in a hash table. Although
it's a bit of a hack, we store 'initial' and 'inherit' using special
string values that can't be valid token streams (we use "!" and ";").
Declaration objects now can have two CSSVariableDeclarations objects
on them, to store normal and !important variable declarations. So that
we keep preserving the order of declarations on the object, we inflate
mOrder to store uint32_ts, where values from eCSSProperty_COUNT onwards
represent custom properties. mVariableOrder stores the names of the
variables corresponding to those entries in mOrder.
We also add a new nsCSSProperty value, eCSSPropertyExtra_variable, which
is used to represent any custom property name.
nsCSSProps::LookupProperty can return this value.
The changes to nsCSSParser are straightforward. Custom properties
are parsed and checked for syntactic validity (e.g. "var(a,)" being
invalid) and stored on the Declaration. We use nsCSSScanner's
recording ability to grab the unparsed CSS string corresponding to
the variable's value.
2013-12-12 06:09:40 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the custom property declaration for a variable with
|
|
|
|
* the given name was !important.
|
|
|
|
*/
|
2016-11-03 06:41:02 +03:00
|
|
|
bool GetVariableIsImportant(const nsAString& aName) const;
|
Bug 773296 - Part 2: Parse CSS variable declarations and store them on Declaration objects. p=ebassi,heycam r=dbaron
Patch co-authored by Emmanuele Bassi <ebassi@gmail.com>
This defines a CSSVariableDeclarations class that holds a set of
variable declarations. This is at the specified value stage, so values
can either be 'initial', 'inherit' or a token stream (which is what you
normally have). The variables are stored in a hash table. Although
it's a bit of a hack, we store 'initial' and 'inherit' using special
string values that can't be valid token streams (we use "!" and ";").
Declaration objects now can have two CSSVariableDeclarations objects
on them, to store normal and !important variable declarations. So that
we keep preserving the order of declarations on the object, we inflate
mOrder to store uint32_ts, where values from eCSSProperty_COUNT onwards
represent custom properties. mVariableOrder stores the names of the
variables corresponding to those entries in mOrder.
We also add a new nsCSSProperty value, eCSSPropertyExtra_variable, which
is used to represent any custom property name.
nsCSSProps::LookupProperty can return this value.
The changes to nsCSSParser are straightforward. Custom properties
are parsed and checked for syntactic validity (e.g. "var(a,)" being
invalid) and stored on the Declaration. We use nsCSSScanner's
recording ability to grab the unparsed CSS string corresponding to
the variable's value.
2013-12-12 06:09:40 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t Count() const {
|
2010-06-29 02:49:35 +04:00
|
|
|
return mOrder.Length();
|
2008-01-10 23:13:24 +03:00
|
|
|
}
|
2012-08-24 08:08:08 +04:00
|
|
|
|
|
|
|
// Returns whether we actually had a property at aIndex
|
|
|
|
bool GetNthProperty(uint32_t aIndex, nsAString& aReturn) const;
|
1998-06-26 09:51:55 +04:00
|
|
|
|
2010-07-23 22:00:34 +04:00
|
|
|
void ToString(nsAString& aString) const;
|
1998-09-10 05:19:26 +04:00
|
|
|
|
2009-12-11 19:13:20 +03:00
|
|
|
nsCSSCompressedDataBlock* GetNormalBlock() const { return mData; }
|
|
|
|
nsCSSCompressedDataBlock* GetImportantBlock() const { return mImportantData; }
|
2003-06-08 02:14:42 +04:00
|
|
|
|
2016-11-03 06:41:02 +03:00
|
|
|
void AssertNotExpanded() const {
|
|
|
|
MOZ_ASSERT(mData, "should only be called when not expanded");
|
|
|
|
}
|
|
|
|
|
2003-06-08 02:14:42 +04:00
|
|
|
/**
|
2010-07-23 22:00:34 +04:00
|
|
|
* Initialize this declaration as holding no data. Cannot fail.
|
2003-06-08 02:14:42 +04:00
|
|
|
*/
|
2010-07-23 22:00:34 +04:00
|
|
|
void InitializeEmpty();
|
2003-06-08 02:14:42 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfer all of the state from |aExpandedData| into this declaration.
|
|
|
|
* After calling, |aExpandedData| should be in its initial state.
|
2012-02-20 00:49:34 +04:00
|
|
|
* Callers must make sure mOrder is updated as necessary.
|
2003-06-08 02:14:42 +04:00
|
|
|
*/
|
|
|
|
void CompressFrom(nsCSSExpandedDataBlock *aExpandedData) {
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!mData, "oops");
|
|
|
|
MOZ_ASSERT(!mImportantData, "oops");
|
2010-07-23 22:00:52 +04:00
|
|
|
aExpandedData->Compress(getter_Transfers(mData),
|
2014-12-19 06:32:34 +03:00
|
|
|
getter_Transfers(mImportantData),
|
|
|
|
mOrder);
|
2009-07-10 01:50:39 +04:00
|
|
|
aExpandedData->AssertInitialState();
|
2003-06-08 02:14:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfer all of the state from this declaration into
|
|
|
|
* |aExpandedData| and put this declaration temporarily into an
|
|
|
|
* invalid state (ended by |CompressFrom| or |InitializeEmpty|) that
|
|
|
|
* should last only during parsing. During this time only
|
|
|
|
* |ValueAppended| should be called.
|
|
|
|
*/
|
|
|
|
void ExpandTo(nsCSSExpandedDataBlock *aExpandedData) {
|
2010-07-23 22:00:49 +04:00
|
|
|
AssertMutable();
|
2003-06-08 02:14:42 +04:00
|
|
|
aExpandedData->AssertInitialState();
|
|
|
|
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(mData, "oops");
|
2010-07-23 22:00:52 +04:00
|
|
|
aExpandedData->Expand(mData.forget(), mImportantData.forget());
|
|
|
|
}
|
|
|
|
|
|
|
|
void MapImportantRuleInfoInto(nsRuleData *aRuleData) const {
|
2016-11-03 06:41:02 +03:00
|
|
|
AssertNotExpanded();
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(mImportantData || mImportantVariables,
|
|
|
|
"must have important data or variables");
|
2013-12-12 06:09:41 +04:00
|
|
|
if (mImportantData) {
|
|
|
|
mImportantData->MapRuleInfoInto(aRuleData);
|
|
|
|
}
|
|
|
|
if (mImportantVariables) {
|
|
|
|
mImportantVariables->MapRuleInfoInto(aRuleData);
|
|
|
|
}
|
2003-06-08 02:14:42 +04:00
|
|
|
}
|
|
|
|
|
2015-11-17 07:09:55 +03:00
|
|
|
bool MapsImportantInheritedStyleData() const;
|
|
|
|
|
2009-07-10 01:50:39 +04:00
|
|
|
/**
|
2010-08-19 23:33:44 +04:00
|
|
|
* Attempt to replace the value for |aProperty| stored in this
|
|
|
|
* declaration with the matching value from |aFromBlock|.
|
|
|
|
* This method may only be called on a mutable declaration.
|
2011-10-17 18:59:28 +04:00
|
|
|
* It will fail (returning false) if |aProperty| is shorthand,
|
2010-08-19 23:33:44 +04:00
|
|
|
* is not already in this declaration, or does not have the indicated
|
2011-10-17 18:59:28 +04:00
|
|
|
* importance level. If it returns true, it erases the value in
|
|
|
|
* |aFromBlock|. |aChanged| is set to true if the declaration
|
|
|
|
* changed as a result of the call, and to false otherwise.
|
2009-07-10 01:50:39 +04:00
|
|
|
*/
|
2016-08-17 04:37:48 +03:00
|
|
|
bool TryReplaceValue(nsCSSPropertyID aProperty, bool aIsImportant,
|
2010-08-19 23:33:44 +04:00
|
|
|
nsCSSExpandedDataBlock& aFromBlock,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool* aChanged)
|
2010-08-19 23:33:44 +04:00
|
|
|
{
|
2010-07-23 22:00:49 +04:00
|
|
|
AssertMutable();
|
2016-11-03 06:41:02 +03:00
|
|
|
AssertNotExpanded();
|
2010-07-23 22:00:39 +04:00
|
|
|
|
2009-07-10 01:50:39 +04:00
|
|
|
if (nsCSSProps::IsShorthand(aProperty)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
*aChanged = false;
|
|
|
|
return false;
|
2009-07-10 01:50:39 +04:00
|
|
|
}
|
2010-07-23 22:00:39 +04:00
|
|
|
nsCSSCompressedDataBlock *block = aIsImportant ? mImportantData : mData;
|
|
|
|
// mImportantData might be null
|
|
|
|
if (!block) {
|
2011-10-17 18:59:28 +04:00
|
|
|
*aChanged = false;
|
|
|
|
return false;
|
2010-07-23 22:00:39 +04:00
|
|
|
}
|
2009-07-10 01:50:39 +04:00
|
|
|
|
2010-07-23 22:00:39 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
{
|
|
|
|
nsCSSCompressedDataBlock *other = aIsImportant ? mData : mImportantData;
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!other || !other->ValueFor(aProperty) ||
|
|
|
|
!block->ValueFor(aProperty),
|
|
|
|
"Property both important and not?");
|
2010-07-23 22:00:39 +04:00
|
|
|
}
|
|
|
|
#endif
|
2010-08-19 23:33:44 +04:00
|
|
|
return block->TryReplaceValue(aProperty, aFromBlock, aChanged);
|
2009-07-10 01:50:39 +04:00
|
|
|
}
|
|
|
|
|
2016-08-17 04:37:48 +03:00
|
|
|
bool HasNonImportantValueFor(nsCSSPropertyID aProperty) const {
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!nsCSSProps::IsShorthand(aProperty), "must be longhand");
|
2010-08-19 23:33:44 +04:00
|
|
|
return !!mData->ValueFor(aProperty);
|
2009-12-11 19:13:19 +03:00
|
|
|
}
|
|
|
|
|
2003-06-08 02:14:42 +04:00
|
|
|
/**
|
|
|
|
* Clear the data, in preparation for its replacement with entirely
|
|
|
|
* new data by a call to |CompressFrom|.
|
|
|
|
*/
|
|
|
|
void ClearData() {
|
2010-07-23 22:00:49 +04:00
|
|
|
AssertMutable();
|
2012-07-30 18:20:58 +04:00
|
|
|
mData = nullptr;
|
|
|
|
mImportantData = nullptr;
|
Bug 773296 - Part 2: Parse CSS variable declarations and store them on Declaration objects. p=ebassi,heycam r=dbaron
Patch co-authored by Emmanuele Bassi <ebassi@gmail.com>
This defines a CSSVariableDeclarations class that holds a set of
variable declarations. This is at the specified value stage, so values
can either be 'initial', 'inherit' or a token stream (which is what you
normally have). The variables are stored in a hash table. Although
it's a bit of a hack, we store 'initial' and 'inherit' using special
string values that can't be valid token streams (we use "!" and ";").
Declaration objects now can have two CSSVariableDeclarations objects
on them, to store normal and !important variable declarations. So that
we keep preserving the order of declarations on the object, we inflate
mOrder to store uint32_ts, where values from eCSSProperty_COUNT onwards
represent custom properties. mVariableOrder stores the names of the
variables corresponding to those entries in mOrder.
We also add a new nsCSSProperty value, eCSSPropertyExtra_variable, which
is used to represent any custom property name.
nsCSSProps::LookupProperty can return this value.
The changes to nsCSSParser are straightforward. Custom properties
are parsed and checked for syntactic validity (e.g. "var(a,)" being
invalid) and stored on the Declaration. We use nsCSSScanner's
recording ability to grab the unparsed CSS string corresponding to
the variable's value.
2013-12-12 06:09:40 +04:00
|
|
|
mVariables = nullptr;
|
|
|
|
mImportantVariables = nullptr;
|
2005-04-29 00:19:24 +04:00
|
|
|
mOrder.Clear();
|
Bug 773296 - Part 2: Parse CSS variable declarations and store them on Declaration objects. p=ebassi,heycam r=dbaron
Patch co-authored by Emmanuele Bassi <ebassi@gmail.com>
This defines a CSSVariableDeclarations class that holds a set of
variable declarations. This is at the specified value stage, so values
can either be 'initial', 'inherit' or a token stream (which is what you
normally have). The variables are stored in a hash table. Although
it's a bit of a hack, we store 'initial' and 'inherit' using special
string values that can't be valid token streams (we use "!" and ";").
Declaration objects now can have two CSSVariableDeclarations objects
on them, to store normal and !important variable declarations. So that
we keep preserving the order of declarations on the object, we inflate
mOrder to store uint32_ts, where values from eCSSProperty_COUNT onwards
represent custom properties. mVariableOrder stores the names of the
variables corresponding to those entries in mOrder.
We also add a new nsCSSProperty value, eCSSPropertyExtra_variable, which
is used to represent any custom property name.
nsCSSProps::LookupProperty can return this value.
The changes to nsCSSParser are straightforward. Custom properties
are parsed and checked for syntactic validity (e.g. "var(a,)" being
invalid) and stored on the Declaration. We use nsCSSScanner's
recording ability to grab the unparsed CSS string corresponding to
the variable's value.
2013-12-12 06:09:40 +04:00
|
|
|
mVariableOrder.Clear();
|
2003-06-08 02:14:42 +04:00
|
|
|
}
|
|
|
|
|
2015-11-05 11:44:09 +03:00
|
|
|
ImportantStyleData* GetImportantStyleData() {
|
|
|
|
if (HasImportantData()) {
|
|
|
|
return &mImportantStyleData;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2002-01-16 01:43:37 +03:00
|
|
|
private:
|
2015-01-07 02:35:02 +03:00
|
|
|
Declaration& operator=(const Declaration& aCopy) = delete;
|
|
|
|
bool operator==(const Declaration& aCopy) const = delete;
|
2002-01-16 01:43:37 +03:00
|
|
|
|
2016-11-03 06:41:02 +03:00
|
|
|
void GetPropertyValueInternal(nsCSSPropertyID aProperty, nsAString& aValue,
|
|
|
|
nsCSSValue::Serialization aValueSerialization)
|
|
|
|
const;
|
|
|
|
bool GetPropertyIsImportantByID(nsCSSPropertyID aProperty) const;
|
2013-09-16 03:35:49 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static void AppendImportanceToString(bool aIsImportant, nsAString& aString);
|
2003-06-08 02:14:42 +04:00
|
|
|
// return whether there was a value in |aValue| (i.e., it had a non-null unit)
|
2016-08-17 04:37:48 +03:00
|
|
|
bool AppendValueToString(nsCSSPropertyID aProperty, nsAString& aResult) const;
|
|
|
|
bool AppendValueToString(nsCSSPropertyID aProperty, nsAString& aResult,
|
2013-09-16 03:35:49 +04:00
|
|
|
nsCSSValue::Serialization aValueSerialization) const;
|
2008-12-23 17:06:57 +03:00
|
|
|
// Helper for ToString with strange semantics regarding aValue.
|
2016-08-17 04:37:48 +03:00
|
|
|
void AppendPropertyAndValueToString(nsCSSPropertyID aProperty,
|
2010-07-23 22:00:52 +04:00
|
|
|
nsAutoString& aValue,
|
|
|
|
nsAString& aResult) const;
|
Bug 773296 - Part 2: Parse CSS variable declarations and store them on Declaration objects. p=ebassi,heycam r=dbaron
Patch co-authored by Emmanuele Bassi <ebassi@gmail.com>
This defines a CSSVariableDeclarations class that holds a set of
variable declarations. This is at the specified value stage, so values
can either be 'initial', 'inherit' or a token stream (which is what you
normally have). The variables are stored in a hash table. Although
it's a bit of a hack, we store 'initial' and 'inherit' using special
string values that can't be valid token streams (we use "!" and ";").
Declaration objects now can have two CSSVariableDeclarations objects
on them, to store normal and !important variable declarations. So that
we keep preserving the order of declarations on the object, we inflate
mOrder to store uint32_ts, where values from eCSSProperty_COUNT onwards
represent custom properties. mVariableOrder stores the names of the
variables corresponding to those entries in mOrder.
We also add a new nsCSSProperty value, eCSSPropertyExtra_variable, which
is used to represent any custom property name.
nsCSSProps::LookupProperty can return this value.
The changes to nsCSSParser are straightforward. Custom properties
are parsed and checked for syntactic validity (e.g. "var(a,)" being
invalid) and stored on the Declaration. We use nsCSSScanner's
recording ability to grab the unparsed CSS string corresponding to
the variable's value.
2013-12-12 06:09:40 +04:00
|
|
|
// helper for ToString that serializes a custom property declaration for
|
|
|
|
// a variable with the specified name
|
|
|
|
void AppendVariableAndValueToString(const nsAString& aName,
|
|
|
|
nsAString& aResult) const;
|
2010-06-29 02:49:35 +04:00
|
|
|
|
2016-01-28 08:28:00 +03:00
|
|
|
void GetImageLayerValue(nsCSSCompressedDataBlock *data,
|
|
|
|
nsAString& aValue,
|
|
|
|
nsCSSValue::Serialization aSerialization,
|
2016-08-17 04:37:48 +03:00
|
|
|
const nsCSSPropertyID aTable[]) const;
|
2016-04-29 21:12:10 +03:00
|
|
|
|
|
|
|
void GetImageLayerPositionValue(nsCSSCompressedDataBlock *data,
|
|
|
|
nsAString& aValue,
|
|
|
|
nsCSSValue::Serialization aSerialization,
|
2016-08-17 04:37:48 +03:00
|
|
|
const nsCSSPropertyID aTable[]) const;
|
2016-01-28 08:28:00 +03:00
|
|
|
|
2011-04-23 05:36:23 +04:00
|
|
|
public:
|
Bug 773296 - Part 2: Parse CSS variable declarations and store them on Declaration objects. p=ebassi,heycam r=dbaron
Patch co-authored by Emmanuele Bassi <ebassi@gmail.com>
This defines a CSSVariableDeclarations class that holds a set of
variable declarations. This is at the specified value stage, so values
can either be 'initial', 'inherit' or a token stream (which is what you
normally have). The variables are stored in a hash table. Although
it's a bit of a hack, we store 'initial' and 'inherit' using special
string values that can't be valid token streams (we use "!" and ";").
Declaration objects now can have two CSSVariableDeclarations objects
on them, to store normal and !important variable declarations. So that
we keep preserving the order of declarations on the object, we inflate
mOrder to store uint32_ts, where values from eCSSProperty_COUNT onwards
represent custom properties. mVariableOrder stores the names of the
variables corresponding to those entries in mOrder.
We also add a new nsCSSProperty value, eCSSPropertyExtra_variable, which
is used to represent any custom property name.
nsCSSProps::LookupProperty can return this value.
The changes to nsCSSParser are straightforward. Custom properties
are parsed and checked for syntactic validity (e.g. "var(a,)" being
invalid) and stored on the Declaration. We use nsCSSScanner's
recording ability to grab the unparsed CSS string corresponding to
the variable's value.
2013-12-12 06:09:40 +04:00
|
|
|
/**
|
|
|
|
* Returns the property at the given index in the ordered list of
|
|
|
|
* declarations. For custom properties, eCSSPropertyExtra_variable
|
|
|
|
* is returned.
|
|
|
|
*/
|
2016-08-17 04:37:48 +03:00
|
|
|
nsCSSPropertyID GetPropertyAt(uint32_t aIndex) const {
|
Bug 773296 - Part 2: Parse CSS variable declarations and store them on Declaration objects. p=ebassi,heycam r=dbaron
Patch co-authored by Emmanuele Bassi <ebassi@gmail.com>
This defines a CSSVariableDeclarations class that holds a set of
variable declarations. This is at the specified value stage, so values
can either be 'initial', 'inherit' or a token stream (which is what you
normally have). The variables are stored in a hash table. Although
it's a bit of a hack, we store 'initial' and 'inherit' using special
string values that can't be valid token streams (we use "!" and ";").
Declaration objects now can have two CSSVariableDeclarations objects
on them, to store normal and !important variable declarations. So that
we keep preserving the order of declarations on the object, we inflate
mOrder to store uint32_ts, where values from eCSSProperty_COUNT onwards
represent custom properties. mVariableOrder stores the names of the
variables corresponding to those entries in mOrder.
We also add a new nsCSSProperty value, eCSSPropertyExtra_variable, which
is used to represent any custom property name.
nsCSSProps::LookupProperty can return this value.
The changes to nsCSSParser are straightforward. Custom properties
are parsed and checked for syntactic validity (e.g. "var(a,)" being
invalid) and stored on the Declaration. We use nsCSSScanner's
recording ability to grab the unparsed CSS string corresponding to
the variable's value.
2013-12-12 06:09:40 +04:00
|
|
|
uint32_t value = mOrder[aIndex];
|
|
|
|
if (value >= eCSSProperty_COUNT) {
|
|
|
|
return eCSSPropertyExtra_variable;
|
|
|
|
}
|
2016-08-17 04:37:48 +03:00
|
|
|
return nsCSSPropertyID(value);
|
Bug 773296 - Part 2: Parse CSS variable declarations and store them on Declaration objects. p=ebassi,heycam r=dbaron
Patch co-authored by Emmanuele Bassi <ebassi@gmail.com>
This defines a CSSVariableDeclarations class that holds a set of
variable declarations. This is at the specified value stage, so values
can either be 'initial', 'inherit' or a token stream (which is what you
normally have). The variables are stored in a hash table. Although
it's a bit of a hack, we store 'initial' and 'inherit' using special
string values that can't be valid token streams (we use "!" and ";").
Declaration objects now can have two CSSVariableDeclarations objects
on them, to store normal and !important variable declarations. So that
we keep preserving the order of declarations on the object, we inflate
mOrder to store uint32_ts, where values from eCSSProperty_COUNT onwards
represent custom properties. mVariableOrder stores the names of the
variables corresponding to those entries in mOrder.
We also add a new nsCSSProperty value, eCSSPropertyExtra_variable, which
is used to represent any custom property name.
nsCSSProps::LookupProperty can return this value.
The changes to nsCSSParser are straightforward. Custom properties
are parsed and checked for syntactic validity (e.g. "var(a,)" being
invalid) and stored on the Declaration. We use nsCSSScanner's
recording ability to grab the unparsed CSS string corresponding to
the variable's value.
2013-12-12 06:09:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the name of the custom property at the given index in the ordered
|
|
|
|
* list of declarations.
|
|
|
|
*/
|
|
|
|
void GetCustomPropertyNameAt(uint32_t aIndex, nsAString& aResult) const {
|
|
|
|
MOZ_ASSERT(mOrder[aIndex] >= eCSSProperty_COUNT);
|
2014-01-02 09:33:57 +04:00
|
|
|
uint32_t variableIndex = mOrder[aIndex] - eCSSProperty_COUNT;
|
Bug 773296 - Part 2: Parse CSS variable declarations and store them on Declaration objects. p=ebassi,heycam r=dbaron
Patch co-authored by Emmanuele Bassi <ebassi@gmail.com>
This defines a CSSVariableDeclarations class that holds a set of
variable declarations. This is at the specified value stage, so values
can either be 'initial', 'inherit' or a token stream (which is what you
normally have). The variables are stored in a hash table. Although
it's a bit of a hack, we store 'initial' and 'inherit' using special
string values that can't be valid token streams (we use "!" and ";").
Declaration objects now can have two CSSVariableDeclarations objects
on them, to store normal and !important variable declarations. So that
we keep preserving the order of declarations on the object, we inflate
mOrder to store uint32_ts, where values from eCSSProperty_COUNT onwards
represent custom properties. mVariableOrder stores the names of the
variables corresponding to those entries in mOrder.
We also add a new nsCSSProperty value, eCSSPropertyExtra_variable, which
is used to represent any custom property name.
nsCSSProps::LookupProperty can return this value.
The changes to nsCSSParser are straightforward. Custom properties
are parsed and checked for syntactic validity (e.g. "var(a,)" being
invalid) and stored on the Declaration. We use nsCSSScanner's
recording ability to grab the unparsed CSS string corresponding to
the variable's value.
2013-12-12 06:09:40 +04:00
|
|
|
aResult.Truncate();
|
2014-04-02 07:32:16 +04:00
|
|
|
aResult.AppendLiteral("--");
|
2014-01-02 09:33:57 +04:00
|
|
|
aResult.Append(mVariableOrder[variableIndex]);
|
2003-06-08 02:14:42 +04:00
|
|
|
}
|
2002-01-16 01:43:37 +03:00
|
|
|
|
2013-06-23 16:03:39 +04:00
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2012-01-03 06:19:14 +04:00
|
|
|
|
2011-04-23 05:36:23 +04:00
|
|
|
private:
|
Bug 773296 - Part 2: Parse CSS variable declarations and store them on Declaration objects. p=ebassi,heycam r=dbaron
Patch co-authored by Emmanuele Bassi <ebassi@gmail.com>
This defines a CSSVariableDeclarations class that holds a set of
variable declarations. This is at the specified value stage, so values
can either be 'initial', 'inherit' or a token stream (which is what you
normally have). The variables are stored in a hash table. Although
it's a bit of a hack, we store 'initial' and 'inherit' using special
string values that can't be valid token streams (we use "!" and ";").
Declaration objects now can have two CSSVariableDeclarations objects
on them, to store normal and !important variable declarations. So that
we keep preserving the order of declarations on the object, we inflate
mOrder to store uint32_ts, where values from eCSSProperty_COUNT onwards
represent custom properties. mVariableOrder stores the names of the
variables corresponding to those entries in mOrder.
We also add a new nsCSSProperty value, eCSSPropertyExtra_variable, which
is used to represent any custom property name.
nsCSSProps::LookupProperty can return this value.
The changes to nsCSSParser are straightforward. Custom properties
are parsed and checked for syntactic validity (e.g. "var(a,)" being
invalid) and stored on the Declaration. We use nsCSSScanner's
recording ability to grab the unparsed CSS string corresponding to
the variable's value.
2013-12-12 06:09:40 +04:00
|
|
|
// The order of properties in this declaration. Longhand properties are
|
2016-08-17 04:37:48 +03:00
|
|
|
// represented by their nsCSSPropertyID value, and each custom property (--*)
|
Bug 773296 - Part 2: Parse CSS variable declarations and store them on Declaration objects. p=ebassi,heycam r=dbaron
Patch co-authored by Emmanuele Bassi <ebassi@gmail.com>
This defines a CSSVariableDeclarations class that holds a set of
variable declarations. This is at the specified value stage, so values
can either be 'initial', 'inherit' or a token stream (which is what you
normally have). The variables are stored in a hash table. Although
it's a bit of a hack, we store 'initial' and 'inherit' using special
string values that can't be valid token streams (we use "!" and ";").
Declaration objects now can have two CSSVariableDeclarations objects
on them, to store normal and !important variable declarations. So that
we keep preserving the order of declarations on the object, we inflate
mOrder to store uint32_ts, where values from eCSSProperty_COUNT onwards
represent custom properties. mVariableOrder stores the names of the
variables corresponding to those entries in mOrder.
We also add a new nsCSSProperty value, eCSSPropertyExtra_variable, which
is used to represent any custom property name.
nsCSSProps::LookupProperty can return this value.
The changes to nsCSSParser are straightforward. Custom properties
are parsed and checked for syntactic validity (e.g. "var(a,)" being
invalid) and stored on the Declaration. We use nsCSSScanner's
recording ability to grab the unparsed CSS string corresponding to
the variable's value.
2013-12-12 06:09:40 +04:00
|
|
|
// is represented by a value that begins at eCSSProperty_COUNT.
|
|
|
|
//
|
|
|
|
// Subtracting eCSSProperty_COUNT from those values that represent custom
|
|
|
|
// properties results in an index into mVariableOrder, which identifies the
|
|
|
|
// specific variable the custom property declaration is for.
|
2016-02-02 18:36:30 +03:00
|
|
|
AutoTArray<uint32_t, 8> mOrder;
|
Bug 773296 - Part 2: Parse CSS variable declarations and store them on Declaration objects. p=ebassi,heycam r=dbaron
Patch co-authored by Emmanuele Bassi <ebassi@gmail.com>
This defines a CSSVariableDeclarations class that holds a set of
variable declarations. This is at the specified value stage, so values
can either be 'initial', 'inherit' or a token stream (which is what you
normally have). The variables are stored in a hash table. Although
it's a bit of a hack, we store 'initial' and 'inherit' using special
string values that can't be valid token streams (we use "!" and ";").
Declaration objects now can have two CSSVariableDeclarations objects
on them, to store normal and !important variable declarations. So that
we keep preserving the order of declarations on the object, we inflate
mOrder to store uint32_ts, where values from eCSSProperty_COUNT onwards
represent custom properties. mVariableOrder stores the names of the
variables corresponding to those entries in mOrder.
We also add a new nsCSSProperty value, eCSSPropertyExtra_variable, which
is used to represent any custom property name.
nsCSSProps::LookupProperty can return this value.
The changes to nsCSSParser are straightforward. Custom properties
are parsed and checked for syntactic validity (e.g. "var(a,)" being
invalid) and stored on the Declaration. We use nsCSSScanner's
recording ability to grab the unparsed CSS string corresponding to
the variable's value.
2013-12-12 06:09:40 +04:00
|
|
|
|
|
|
|
// variable names of custom properties found in mOrder
|
|
|
|
nsTArray<nsString> mVariableOrder;
|
2010-07-23 22:00:49 +04:00
|
|
|
|
2010-07-23 22:00:52 +04:00
|
|
|
// never null, except while expanded, or before the first call to
|
|
|
|
// InitializeEmpty or CompressFrom.
|
|
|
|
nsAutoPtr<nsCSSCompressedDataBlock> mData;
|
2009-12-11 19:13:19 +03:00
|
|
|
|
2010-07-23 22:00:52 +04:00
|
|
|
// may be null
|
|
|
|
nsAutoPtr<nsCSSCompressedDataBlock> mImportantData;
|
2009-12-11 19:13:19 +03:00
|
|
|
|
Bug 773296 - Part 2: Parse CSS variable declarations and store them on Declaration objects. p=ebassi,heycam r=dbaron
Patch co-authored by Emmanuele Bassi <ebassi@gmail.com>
This defines a CSSVariableDeclarations class that holds a set of
variable declarations. This is at the specified value stage, so values
can either be 'initial', 'inherit' or a token stream (which is what you
normally have). The variables are stored in a hash table. Although
it's a bit of a hack, we store 'initial' and 'inherit' using special
string values that can't be valid token streams (we use "!" and ";").
Declaration objects now can have two CSSVariableDeclarations objects
on them, to store normal and !important variable declarations. So that
we keep preserving the order of declarations on the object, we inflate
mOrder to store uint32_ts, where values from eCSSProperty_COUNT onwards
represent custom properties. mVariableOrder stores the names of the
variables corresponding to those entries in mOrder.
We also add a new nsCSSProperty value, eCSSPropertyExtra_variable, which
is used to represent any custom property name.
nsCSSProps::LookupProperty can return this value.
The changes to nsCSSParser are straightforward. Custom properties
are parsed and checked for syntactic validity (e.g. "var(a,)" being
invalid) and stored on the Declaration. We use nsCSSScanner's
recording ability to grab the unparsed CSS string corresponding to
the variable's value.
2013-12-12 06:09:40 +04:00
|
|
|
// may be null
|
|
|
|
nsAutoPtr<CSSVariableDeclarations> mVariables;
|
|
|
|
|
|
|
|
// may be null
|
|
|
|
nsAutoPtr<CSSVariableDeclarations> mImportantVariables;
|
|
|
|
|
2015-11-05 11:44:09 +03:00
|
|
|
friend class ImportantStyleData;
|
|
|
|
ImportantStyleData mImportantStyleData;
|
1998-04-14 00:24:54 +04:00
|
|
|
};
|
|
|
|
|
2015-11-05 11:44:09 +03:00
|
|
|
inline ::mozilla::css::Declaration*
|
|
|
|
ImportantStyleData::Declaration()
|
|
|
|
{
|
|
|
|
union {
|
|
|
|
char* ch; /* for pointer arithmetic */
|
|
|
|
::mozilla::css::Declaration* declaration;
|
|
|
|
ImportantStyleData* importantData;
|
|
|
|
} u;
|
|
|
|
u.importantData = this;
|
|
|
|
u.ch -= offsetof(::mozilla::css::Declaration, mImportantStyleData);
|
|
|
|
return u.declaration;
|
|
|
|
}
|
|
|
|
|
2015-11-05 11:44:08 +03:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(Declaration, NS_CSS_DECLARATION_IMPL_CID)
|
|
|
|
|
2010-06-29 02:49:35 +04:00
|
|
|
} // namespace css
|
2010-06-29 02:49:35 +04:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2010-06-29 02:49:35 +04:00
|
|
|
#endif /* mozilla_css_Declaration_h */
|