2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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
|
|
|
|
|
|
|
/*
|
|
|
|
* methods for dealing with CSS properties and tables of the keyword
|
|
|
|
* values they accept
|
|
|
|
*/
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
#ifndef nsCSSProps_h___
|
|
|
|
#define nsCSSProps_h___
|
|
|
|
|
2016-07-28 10:40:09 +03:00
|
|
|
#include <limits>
|
|
|
|
#include <type_traits>
|
2018-07-30 18:32:17 +03:00
|
|
|
#include "nsString.h"
|
2016-08-17 04:37:48 +03:00
|
|
|
#include "nsCSSPropertyID.h"
|
2013-09-16 05:06:52 +04:00
|
|
|
#include "nsStyleStructFwd.h"
|
2004-10-01 21:15:15 +04:00
|
|
|
#include "nsCSSKeywords.h"
|
2016-05-10 11:44:05 +03:00
|
|
|
#include "mozilla/CSSEnabledState.h"
|
2018-04-26 08:00:50 +03:00
|
|
|
#include "mozilla/CSSPropFlags.h"
|
2015-06-03 22:21:24 +03:00
|
|
|
#include "mozilla/UseCounter.h"
|
2016-09-07 05:20:16 +03:00
|
|
|
#include "mozilla/EnumTypeTraits.h"
|
2017-03-17 00:43:17 +03:00
|
|
|
#include "mozilla/Preferences.h"
|
|
|
|
#include "nsXULAppAPI.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2014-04-02 07:32:16 +04:00
|
|
|
// Length of the "--" prefix on custom names (such as custom property names,
|
|
|
|
// and, in the future, custom media query names).
|
|
|
|
#define CSS_CUSTOM_NAME_PREFIX_LENGTH 2
|
|
|
|
|
2018-07-06 05:57:38 +03:00
|
|
|
namespace mozilla {
|
|
|
|
class ComputedStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
nsCSSPropertyID Servo_ResolveLogicalProperty(nsCSSPropertyID,
|
|
|
|
const mozilla::ComputedStyle*);
|
2018-07-30 18:32:17 +03:00
|
|
|
nsCSSPropertyID Servo_Property_LookupEnabledForAllContent(const nsACString*);
|
2018-07-30 19:04:05 +03:00
|
|
|
const uint8_t* Servo_Property_GetName(nsCSSPropertyID, uint32_t* aLength);
|
2018-07-06 05:57:38 +03:00
|
|
|
}
|
|
|
|
|
2018-04-29 14:17:26 +03:00
|
|
|
struct nsCSSKTableEntry {
|
|
|
|
// nsCSSKTableEntry objects can be initialized either with an int16_t value
|
|
|
|
// or a value of an enumeration type that can fit within an int16_t.
|
2016-05-10 11:44:05 +03:00
|
|
|
|
2018-04-29 14:17:26 +03:00
|
|
|
constexpr nsCSSKTableEntry(nsCSSKeyword aKeyword, int16_t aValue)
|
|
|
|
: mKeyword(aKeyword), mValue(aValue) {}
|
2016-07-28 10:40:09 +03:00
|
|
|
|
2018-04-29 14:17:26 +03:00
|
|
|
template <typename T,
|
|
|
|
typename = typename std::enable_if<std::is_enum<T>::value>::type>
|
|
|
|
constexpr nsCSSKTableEntry(nsCSSKeyword aKeyword, T aValue)
|
|
|
|
: mKeyword(aKeyword), mValue(static_cast<int16_t>(aValue)) {
|
|
|
|
static_assert(mozilla::EnumTypeFitsWithin<T, int16_t>::value,
|
|
|
|
"aValue must be an enum that fits within mValue");
|
|
|
|
}
|
2016-07-28 10:40:09 +03:00
|
|
|
|
2018-04-29 14:17:26 +03:00
|
|
|
bool IsSentinel() const {
|
|
|
|
return mKeyword == eCSSKeyword_UNKNOWN && mValue == -1;
|
|
|
|
}
|
2016-07-28 10:40:09 +03:00
|
|
|
|
2018-04-29 14:17:26 +03:00
|
|
|
nsCSSKeyword mKeyword;
|
|
|
|
int16_t mValue;
|
|
|
|
};
|
2018-01-15 19:14:55 +03:00
|
|
|
|
2018-04-29 14:17:26 +03:00
|
|
|
class nsCSSProps {
|
|
|
|
public:
|
|
|
|
typedef mozilla::CSSEnabledState EnabledState;
|
|
|
|
typedef mozilla::CSSPropFlags Flags;
|
|
|
|
typedef nsCSSKTableEntry KTableEntry;
|
2014-02-05 15:10:44 +04:00
|
|
|
|
1999-07-18 04:32:32 +04:00
|
|
|
static void AddRefTable(void);
|
|
|
|
static void ReleaseTable(void);
|
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
|
|
|
// Looks up the property with name aProperty and returns its corresponding
|
2016-08-17 04:37:48 +03:00
|
|
|
// nsCSSPropertyID value. If aProperty is the name of a 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
|
|
|
// then eCSSPropertyExtra_variable will be returned.
|
2018-07-30 18:32:17 +03:00
|
|
|
//
|
|
|
|
// This only returns properties enabled for all content, and resolves aliases
|
|
|
|
// to return the aliased property.
|
|
|
|
static nsCSSPropertyID LookupProperty(const nsACString& aProperty) {
|
|
|
|
return Servo_Property_LookupEnabledForAllContent(&aProperty);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsCSSPropertyID LookupProperty(const nsAString& aProperty) {
|
|
|
|
NS_ConvertUTF16toUTF8 utf8(aProperty);
|
|
|
|
return LookupProperty(utf8);
|
|
|
|
}
|
|
|
|
|
2015-10-22 11:22:37 +03:00
|
|
|
// As above, but looked up using a property's IDL name.
|
|
|
|
// eCSSPropertyExtra_variable won't be returned from these methods.
|
2016-08-17 04:37:48 +03:00
|
|
|
static nsCSSPropertyID LookupPropertyByIDLName(
|
2015-10-22 11:22:37 +03:00
|
|
|
const nsAString& aPropertyIDLName, EnabledState aEnabled);
|
2016-08-17 04:37:48 +03:00
|
|
|
static nsCSSPropertyID LookupPropertyByIDLName(
|
2015-10-22 11:22:37 +03:00
|
|
|
const nsACString& aPropertyIDLName, EnabledState aEnabled);
|
|
|
|
|
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 aProperty is a custom property name, i.e. begins with
|
2014-04-02 07:32:16 +04:00
|
|
|
// "--". This assumes that the CSS Variables pref has been enabled.
|
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
|
|
|
static bool IsCustomPropertyName(const nsAString& aProperty);
|
1998-07-18 03:00:54 +04:00
|
|
|
|
2018-07-06 05:57:38 +03:00
|
|
|
static bool IsShorthand(nsCSSPropertyID aProperty) {
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(0 <= aProperty && aProperty < eCSSProperty_COUNT,
|
|
|
|
"out of range");
|
2003-06-08 02:14:42 +04:00
|
|
|
return (aProperty >= eCSSProperty_COUNT_no_shorthands);
|
|
|
|
}
|
|
|
|
|
2008-08-08 03:15:40 +04:00
|
|
|
// Same but for @font-face descriptors
|
|
|
|
static nsCSSFontDesc LookupFontDesc(const nsAString& aProperty);
|
2014-06-12 05:10:00 +04:00
|
|
|
|
1999-07-18 04:32:32 +04:00
|
|
|
// Given a property enum, get the string value
|
2018-07-30 19:04:05 +03:00
|
|
|
//
|
|
|
|
// This string is static.
|
|
|
|
static const nsDependentCSubstring GetStringValue(nsCSSPropertyID aProperty) {
|
|
|
|
uint32_t len;
|
|
|
|
const uint8_t* chars = Servo_Property_GetName(aProperty, &len);
|
|
|
|
return nsDependentCSubstring(reinterpret_cast<const char*>(chars), len);
|
|
|
|
}
|
|
|
|
|
2017-06-20 12:19:05 +03:00
|
|
|
static const nsCString& GetStringValue(nsCSSFontDesc aFontDesc);
|
|
|
|
static const nsCString& GetStringValue(nsCSSCounterDesc aCounterDesc);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2012-10-03 09:04:50 +04:00
|
|
|
// Returns the index of |aKeyword| in |aTable|, if it exists there;
|
|
|
|
// otherwise, returns -1.
|
|
|
|
// NOTE: Generally, clients should call FindKeyword() instead of this method.
|
2014-02-05 15:10:44 +04:00
|
|
|
static int32_t FindIndexOfKeyword(nsCSSKeyword aKeyword,
|
2015-11-20 05:09:07 +03:00
|
|
|
const KTableEntry aTable[]);
|
2012-10-03 09:04:50 +04:00
|
|
|
|
2004-10-01 21:15:15 +04:00
|
|
|
// Find |aKeyword| in |aTable|, if found set |aValue| to its corresponding
|
2011-10-17 18:59:28 +04:00
|
|
|
// value. If not found, return false and do not set |aValue|.
|
2015-11-20 05:09:07 +03:00
|
|
|
static bool FindKeyword(nsCSSKeyword aKeyword, const KTableEntry aTable[],
|
2014-02-05 15:10:44 +04:00
|
|
|
int32_t& aValue);
|
2004-10-01 21:15:15 +04:00
|
|
|
// Return the first keyword in |aTable| that has the corresponding value
|
|
|
|
// |aValue|. Return |eCSSKeyword_UNKNOWN| if not found.
|
2016-07-29 11:18:48 +03:00
|
|
|
static nsCSSKeyword ValueToKeywordEnum(int32_t aValue,
|
2015-11-20 05:09:07 +03:00
|
|
|
const KTableEntry aTable[]);
|
2016-07-29 11:18:48 +03:00
|
|
|
template <typename T,
|
|
|
|
typename = typename std::enable_if<std::is_enum<T>::value>::type>
|
|
|
|
static nsCSSKeyword ValueToKeywordEnum(T aValue, const KTableEntry aTable[]) {
|
2016-09-07 05:20:16 +03:00
|
|
|
static_assert(
|
|
|
|
mozilla::EnumTypeFitsWithin<T, int16_t>::value,
|
2016-07-29 11:18:48 +03:00
|
|
|
"aValue must be an enum that fits within KTableEntry::mValue");
|
|
|
|
return ValueToKeywordEnum(static_cast<int16_t>(aValue), aTable);
|
|
|
|
}
|
2004-10-01 21:15:15 +04:00
|
|
|
// Ditto but as a string, return "" when not found.
|
2017-06-20 12:19:05 +03:00
|
|
|
static const nsCString& ValueToKeyword(int32_t aValue,
|
|
|
|
const KTableEntry aTable[]);
|
2016-07-29 11:18:48 +03:00
|
|
|
template <typename T,
|
|
|
|
typename = typename std::enable_if<std::is_enum<T>::value>::type>
|
2017-06-20 12:19:05 +03:00
|
|
|
static const nsCString& ValueToKeyword(T aValue, const KTableEntry aTable[]) {
|
2016-09-07 05:20:16 +03:00
|
|
|
static_assert(
|
|
|
|
mozilla::EnumTypeFitsWithin<T, int16_t>::value,
|
2016-07-29 11:18:48 +03:00
|
|
|
"aValue must be an enum that fits within KTableEntry::mValue");
|
|
|
|
return ValueToKeyword(static_cast<int16_t>(aValue), aTable);
|
|
|
|
}
|
2001-03-03 03:44:19 +03:00
|
|
|
|
2008-10-27 20:55:51 +03:00
|
|
|
private:
|
2018-04-26 08:00:50 +03:00
|
|
|
static const Flags kFlagsTable[eCSSProperty_COUNT];
|
2003-06-08 02:14:42 +04:00
|
|
|
|
2008-12-23 17:06:57 +03:00
|
|
|
public:
|
2018-07-06 05:57:38 +03:00
|
|
|
static bool PropHasFlags(nsCSSPropertyID aProperty, Flags aFlags) {
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(0 <= aProperty && aProperty < eCSSProperty_COUNT,
|
|
|
|
"out of range");
|
2008-12-23 17:06:57 +03:00
|
|
|
return (nsCSSProps::kFlagsTable[aProperty] & aFlags) == aFlags;
|
|
|
|
}
|
|
|
|
|
2018-07-06 05:57:38 +03:00
|
|
|
static nsCSSPropertyID Physicalize(nsCSSPropertyID aProperty,
|
|
|
|
const mozilla::ComputedStyle& aStyle) {
|
2019-01-15 04:27:44 +03:00
|
|
|
MOZ_ASSERT(!IsShorthand(aProperty));
|
2018-07-06 05:57:38 +03:00
|
|
|
if (PropHasFlags(aProperty, Flags::IsLogical)) {
|
|
|
|
return Servo_ResolveLogicalProperty(aProperty, &aStyle);
|
|
|
|
}
|
|
|
|
return aProperty;
|
|
|
|
}
|
|
|
|
|
2008-12-23 17:06:57 +03:00
|
|
|
private:
|
2003-06-08 02:14:42 +04:00
|
|
|
// A table for shorthand properties. The appropriate index is the
|
|
|
|
// property ID minus eCSSProperty_COUNT_no_shorthands.
|
2018-07-06 05:57:38 +03:00
|
|
|
static const nsCSSPropertyID* const
|
2003-06-08 02:14:42 +04:00
|
|
|
kSubpropertyTable[eCSSProperty_COUNT - eCSSProperty_COUNT_no_shorthands];
|
|
|
|
|
|
|
|
public:
|
2018-07-06 05:57:38 +03:00
|
|
|
static const nsCSSPropertyID* SubpropertyEntryFor(nsCSSPropertyID aProperty) {
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(eCSSProperty_COUNT_no_shorthands <= aProperty &&
|
|
|
|
aProperty < eCSSProperty_COUNT,
|
|
|
|
"out of range");
|
2003-06-08 02:14:42 +04:00
|
|
|
return nsCSSProps::kSubpropertyTable[aProperty -
|
|
|
|
eCSSProperty_COUNT_no_shorthands];
|
|
|
|
}
|
|
|
|
|
2012-07-14 03:59:05 +04:00
|
|
|
private:
|
2013-03-13 20:58:39 +04:00
|
|
|
static bool gPropertyEnabled[eCSSProperty_COUNT_with_aliases];
|
2012-07-14 03:59:05 +04:00
|
|
|
|
2015-09-22 08:58:20 +03:00
|
|
|
private:
|
|
|
|
// Defined in the generated nsCSSPropsGenerated.inc.
|
|
|
|
static const char* const kIDLNameTable[eCSSProperty_COUNT];
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Returns the IDL name of the specified property, which must be a
|
|
|
|
* longhand, logical or shorthand property. The IDL name is the property
|
|
|
|
* name with any hyphen-lowercase character pairs replaced by an
|
|
|
|
* uppercase character:
|
|
|
|
* https://drafts.csswg.org/cssom/#css-property-to-idl-attribute
|
|
|
|
*
|
|
|
|
* As a special case, the string "cssFloat" is returned for the float
|
|
|
|
* property. nullptr is returned for internal properties.
|
|
|
|
*/
|
2016-08-17 04:37:48 +03:00
|
|
|
static const char* PropertyIDLName(nsCSSPropertyID aProperty) {
|
2015-09-22 08:58:20 +03:00
|
|
|
MOZ_ASSERT(0 <= aProperty && aProperty < eCSSProperty_COUNT,
|
|
|
|
"out of range");
|
|
|
|
return kIDLNameTable[aProperty];
|
|
|
|
}
|
|
|
|
|
2015-09-23 01:37:17 +03:00
|
|
|
private:
|
|
|
|
static const int32_t kIDLNameSortPositionTable[eCSSProperty_COUNT];
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Returns the position of the specified property in a list of all
|
|
|
|
* properties sorted by their IDL name.
|
|
|
|
*/
|
2016-08-17 04:37:48 +03:00
|
|
|
static int32_t PropertyIDLNameSortPosition(nsCSSPropertyID aProperty) {
|
2015-09-23 01:37:17 +03:00
|
|
|
MOZ_ASSERT(0 <= aProperty && aProperty < eCSSProperty_COUNT,
|
|
|
|
"out of range");
|
|
|
|
return kIDLNameSortPositionTable[aProperty];
|
|
|
|
}
|
|
|
|
|
2016-08-17 04:37:48 +03:00
|
|
|
static bool IsEnabled(nsCSSPropertyID aProperty) {
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(0 <= aProperty && aProperty < eCSSProperty_COUNT_with_aliases,
|
|
|
|
"out of range");
|
2017-11-30 01:14:32 +03:00
|
|
|
// In the child process, assert that we're not trying to parse stylesheets
|
|
|
|
// before we've gotten all our prefs.
|
|
|
|
MOZ_ASSERT_IF(!XRE_IsParentProcess(),
|
2018-03-08 07:47:24 +03:00
|
|
|
mozilla::Preferences::ArePrefsInitedInContentProcess());
|
2012-07-14 03:59:05 +04:00
|
|
|
return gPropertyEnabled[aProperty];
|
|
|
|
}
|
|
|
|
|
2015-06-03 22:21:24 +03:00
|
|
|
// A table for the use counter associated with each CSS property. If a
|
|
|
|
// property does not have a use counter defined in UseCounters.conf, then
|
|
|
|
// its associated entry is |eUseCounter_UNKNOWN|.
|
|
|
|
static const mozilla::UseCounter
|
|
|
|
gPropertyUseCounter[eCSSProperty_COUNT_no_shorthands];
|
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
public:
|
2016-08-17 04:37:48 +03:00
|
|
|
static mozilla::UseCounter UseCounterFor(nsCSSPropertyID aProperty) {
|
2015-06-03 22:21:24 +03:00
|
|
|
MOZ_ASSERT(0 <= aProperty && aProperty < eCSSProperty_COUNT_no_shorthands,
|
|
|
|
"out of range");
|
|
|
|
return gPropertyUseCounter[aProperty];
|
|
|
|
}
|
|
|
|
|
2016-08-17 04:37:48 +03:00
|
|
|
static bool IsEnabled(nsCSSPropertyID aProperty, EnabledState aEnabled) {
|
2014-03-07 21:14:23 +04:00
|
|
|
if (IsEnabled(aProperty)) {
|
|
|
|
return true;
|
|
|
|
}
|
2016-05-10 11:44:05 +03:00
|
|
|
if (aEnabled == EnabledState::eIgnoreEnabledState) {
|
2014-03-07 21:14:23 +04:00
|
|
|
return true;
|
|
|
|
}
|
2016-05-10 11:44:05 +03:00
|
|
|
if ((aEnabled & EnabledState::eInUASheets) &&
|
2018-04-26 08:00:50 +03:00
|
|
|
PropHasFlags(aProperty, Flags::EnabledInUASheets)) {
|
2015-10-03 04:12:09 +03:00
|
|
|
return true;
|
|
|
|
}
|
2016-05-10 11:44:05 +03:00
|
|
|
if ((aEnabled & EnabledState::eInChrome) &&
|
2018-04-26 08:00:50 +03:00
|
|
|
PropHasFlags(aProperty, Flags::EnabledInChrome)) {
|
2014-03-07 21:14:23 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2014-02-22 05:18:23 +04:00
|
|
|
}
|
|
|
|
|
2008-12-23 17:06:57 +03:00
|
|
|
public:
|
2018-05-31 06:49:25 +03:00
|
|
|
struct PropertyPref {
|
|
|
|
nsCSSPropertyID mPropID;
|
|
|
|
const char* mPref;
|
|
|
|
};
|
|
|
|
static const PropertyPref kPropertyPrefTable[];
|
2008-10-27 20:55:51 +03:00
|
|
|
|
2016-08-17 04:37:48 +03:00
|
|
|
// Storing the enabledstate_ value in an nsCSSPropertyID variable is a small
|
2015-01-17 07:55:07 +03:00
|
|
|
// hack to avoid needing a separate variable declaration for its real type
|
2016-05-10 11:44:05 +03:00
|
|
|
// (CSSEnabledState), which would then require using a block and
|
2015-01-17 07:55:07 +03:00
|
|
|
// therefore a pair of macros by consumers for the start and end of the loop.
|
2016-05-12 03:28:56 +03:00
|
|
|
#define CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(it_, prop_, enabledstate_) \
|
2016-08-17 04:37:48 +03:00
|
|
|
for (const nsCSSPropertyID * \
|
|
|
|
it_ = nsCSSProps::SubpropertyEntryFor(prop_), \
|
|
|
|
es_ = (nsCSSPropertyID)((enabledstate_) | CSSEnabledState(0)); \
|
2016-05-12 03:28:56 +03:00
|
|
|
*it_ != eCSSProperty_UNKNOWN; ++it_) \
|
2016-05-10 11:44:05 +03:00
|
|
|
if (nsCSSProps::IsEnabled(*it_, (mozilla::CSSEnabledState)es_))
|
1998-10-27 02:16:27 +03:00
|
|
|
|
|
|
|
// Keyword/Enum value tables
|
2016-04-14 11:28:06 +03:00
|
|
|
// Not const because we modify its entries when the pref
|
|
|
|
// "layout.css.background-clip.text" changes:
|
2015-11-20 05:09:07 +03:00
|
|
|
static const KTableEntry kShapeRadiusKTable[];
|
|
|
|
static const KTableEntry kFilterFunctionKTable[];
|
|
|
|
static const KTableEntry kBoxShadowTypeKTable[];
|
|
|
|
static const KTableEntry kCursorKTable[];
|
2017-07-06 15:00:35 +03:00
|
|
|
// Not const because we modify its entries when various
|
2014-11-20 21:24:09 +03:00
|
|
|
// "layout.css.*.enabled" prefs changes:
|
2015-11-20 05:09:07 +03:00
|
|
|
static KTableEntry kDisplayKTable[];
|
2018-12-05 21:44:03 +03:00
|
|
|
// clang-format off
|
|
|
|
// -- tables for auto-completion of the {align,justify}-{content,items,self} properties --
|
2016-02-08 19:35:01 +03:00
|
|
|
static const KTableEntry kAutoCompletionAlignJustifySelf[];
|
|
|
|
static const KTableEntry kAutoCompletionAlignItems[];
|
|
|
|
static const KTableEntry kAutoCompletionAlignJustifyContent[];
|
2015-11-03 17:18:05 +03:00
|
|
|
// ------------------------------------------------------------------
|
2018-12-05 21:44:03 +03:00
|
|
|
// clang-format on
|
2015-11-20 05:09:07 +03:00
|
|
|
static const KTableEntry kFontSmoothingKTable[];
|
|
|
|
static const KTableEntry kGridAutoFlowKTable[];
|
|
|
|
static const KTableEntry kGridTrackBreadthKTable[];
|
|
|
|
static const KTableEntry kLineHeightKTable[];
|
2018-10-24 23:32:16 +03:00
|
|
|
static const KTableEntry kTextAlignKTable[];
|
2015-11-20 05:09:07 +03:00
|
|
|
static const KTableEntry kTextDecorationStyleKTable[];
|
2015-11-28 03:56:33 +03:00
|
|
|
static const KTableEntry kTextEmphasisStyleShapeKTable[];
|
2015-11-20 05:09:07 +03:00
|
|
|
static const KTableEntry kTextOverflowKTable[];
|
|
|
|
static const KTableEntry kVerticalAlignKTable[];
|
1998-04-14 00:24:54 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsCSSProps_h___ */
|