зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1350010, part 1 - Implement the '-moz-context-properties' property. r=heycam
MozReview-Commit-ID: CyVQe0UfKdy
This commit is contained in:
Родитель
062487c44b
Коммит
e0f3ff607a
|
@ -925,6 +925,18 @@ exports.CSS_PROPERTIES = {
|
|||
"unset"
|
||||
]
|
||||
},
|
||||
"-moz-context-properties": {
|
||||
"isInherited": true,
|
||||
"subproperties": [
|
||||
"-moz-context-properties"
|
||||
],
|
||||
"supports": [],
|
||||
"values": [
|
||||
"inherit",
|
||||
"initial",
|
||||
"unset"
|
||||
]
|
||||
},
|
||||
"-moz-control-character-visibility": {
|
||||
"isInherited": true,
|
||||
"subproperties": [
|
||||
|
@ -2941,6 +2953,7 @@ exports.CSS_PROPERTIES = {
|
|||
"column-width",
|
||||
"contain",
|
||||
"content",
|
||||
"-moz-context-properties",
|
||||
"-moz-control-character-visibility",
|
||||
"counter-increment",
|
||||
"counter-reset",
|
||||
|
@ -3370,6 +3383,7 @@ exports.CSS_PROPERTIES = {
|
|||
"geometricprecision",
|
||||
"grab",
|
||||
"grabbing",
|
||||
"grayscale",
|
||||
"grid",
|
||||
"groove",
|
||||
"groupbox",
|
||||
|
|
|
@ -49,6 +49,7 @@ CSS_KEY(-moz-cellhighlighttext, _moz_cellhighlighttext)
|
|||
CSS_KEY(-moz-center, _moz_center)
|
||||
CSS_KEY(-moz-combobox, _moz_combobox)
|
||||
CSS_KEY(-moz-comboboxtext, _moz_comboboxtext)
|
||||
CSS_KEY(-moz-context-properties, _moz_context_properties)
|
||||
CSS_KEY(-moz-block-height, _moz_block_height)
|
||||
CSS_KEY(-moz-deck, _moz_deck)
|
||||
CSS_KEY(-moz-default-background-color, _moz_default_background_color)
|
||||
|
|
|
@ -924,6 +924,7 @@ protected:
|
|||
uint32_t& aVariantMask,
|
||||
bool *aHadFinalWS);
|
||||
bool ParseCalcTerm(nsCSSValue& aValue, uint32_t& aVariantMask);
|
||||
bool ParseContextProperties();
|
||||
bool RequireWhitespace();
|
||||
|
||||
// For "flex" shorthand property, defined in CSS Flexbox spec
|
||||
|
@ -8064,6 +8065,50 @@ CSSParserImpl::ParseCounter(nsCSSValue& aValue)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
CSSParserImpl::ParseContextProperties()
|
||||
{
|
||||
nsCSSValue listValue;
|
||||
nsCSSValueList* currentListValue = listValue.SetListValue();
|
||||
bool first = true;
|
||||
for (;;) {
|
||||
const uint32_t variantMask = VARIANT_IDENTIFIER |
|
||||
VARIANT_INHERIT |
|
||||
VARIANT_NONE;
|
||||
nsCSSValue value;
|
||||
if (!ParseSingleTokenVariant(value, variantMask, nullptr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (value.GetUnit() != eCSSUnit_Ident) {
|
||||
if (first) {
|
||||
AppendValue(eCSSProperty__moz_context_properties, value);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
value.AtomizeIdentValue();
|
||||
nsIAtom* atom = value.GetAtomValue();
|
||||
if (atom == nsGkAtoms::_default) {
|
||||
return false;
|
||||
}
|
||||
|
||||
currentListValue->mValue = Move(value);
|
||||
|
||||
if (!ExpectSymbol(',', true)) {
|
||||
break;
|
||||
}
|
||||
currentListValue->mNext = new nsCSSValueList;
|
||||
currentListValue = currentListValue->mNext;
|
||||
first = false;
|
||||
}
|
||||
|
||||
AppendValue(eCSSProperty__moz_context_properties, listValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CSSParserImpl::ParseAttr(nsCSSValue& aValue)
|
||||
{
|
||||
|
@ -11708,6 +11753,8 @@ CSSParserImpl::ParsePropertyByFunction(nsCSSPropertyID aPropID)
|
|||
return ParseBorderSide(kColumnRuleIDs, false);
|
||||
case eCSSProperty_content:
|
||||
return ParseContent();
|
||||
case eCSSProperty__moz_context_properties:
|
||||
return ParseContextProperties();
|
||||
case eCSSProperty_counter_increment:
|
||||
case eCSSProperty_counter_reset:
|
||||
return ParseCounterData(aPropID);
|
||||
|
|
|
@ -1616,6 +1616,19 @@ CSS_PROP_CONTENT(
|
|||
CSS_PROP_NO_OFFSET,
|
||||
eStyleAnimType_Discrete)
|
||||
#ifndef CSS_PROP_LIST_EXCLUDE_INTERNAL
|
||||
CSS_PROP_SVG(
|
||||
// Only intended to be used internally by Mozilla, so prefixed.
|
||||
-moz-context-properties,
|
||||
_moz_context_properties,
|
||||
CSS_PROP_DOMPROP_PREFIXED(ContextProperties),
|
||||
CSS_PROPERTY_PARSE_FUNCTION |
|
||||
CSS_PROPERTY_VALUE_LIST_USES_COMMAS |
|
||||
CSS_PROPERTY_INTERNAL,
|
||||
"",
|
||||
0,
|
||||
nullptr,
|
||||
CSS_PROP_NO_OFFSET,
|
||||
eStyleAnimType_None)
|
||||
CSS_PROP_TEXT(
|
||||
-moz-control-character-visibility,
|
||||
_moz_control_character_visibility,
|
||||
|
|
|
@ -6463,6 +6463,27 @@ nsComputedDOMStyle::DoGetMaskType()
|
|||
return val.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<CSSValue>
|
||||
nsComputedDOMStyle::DoGetContextProperties()
|
||||
{
|
||||
const nsTArray<nsCOMPtr<nsIAtom>>& contextProps = StyleSVG()->mContextProps;
|
||||
|
||||
if (contextProps.IsEmpty()) {
|
||||
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
|
||||
val->SetIdent(eCSSKeyword_none);
|
||||
return val.forget();
|
||||
}
|
||||
|
||||
RefPtr<nsDOMCSSValueList> valueList = GetROCSSValueList(true);
|
||||
for (const nsIAtom* ident : contextProps) {
|
||||
RefPtr<nsROCSSPrimitiveValue> property = new nsROCSSPrimitiveValue;
|
||||
property->SetString(nsDependentAtomString(ident));
|
||||
valueList->AppendCSSValue(property.forget());
|
||||
}
|
||||
|
||||
return valueList.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<CSSValue>
|
||||
nsComputedDOMStyle::DoGetPaintOrder()
|
||||
{
|
||||
|
|
|
@ -600,6 +600,8 @@ private:
|
|||
already_AddRefed<CSSValue> DoGetMaskType();
|
||||
already_AddRefed<CSSValue> DoGetPaintOrder();
|
||||
|
||||
already_AddRefed<CSSValue> DoGetContextProperties();
|
||||
|
||||
/* Custom properties */
|
||||
already_AddRefed<CSSValue> DoGetCustomProperty(const nsAString& aPropertyName);
|
||||
|
||||
|
|
|
@ -287,6 +287,7 @@ COMPUTED_STYLE_PROP(_moz_box_flex, BoxFlex)
|
|||
COMPUTED_STYLE_PROP(_moz_box_ordinal_group, BoxOrdinalGroup)
|
||||
COMPUTED_STYLE_PROP(_moz_box_orient, BoxOrient)
|
||||
COMPUTED_STYLE_PROP(_moz_box_pack, BoxPack)
|
||||
COMPUTED_STYLE_PROP(_moz_context_properties, ContextProperties)
|
||||
COMPUTED_STYLE_PROP(_moz_float_edge, FloatEdge)
|
||||
COMPUTED_STYLE_PROP(_moz_force_broken_image_icon, ForceBrokenImageIcon)
|
||||
COMPUTED_STYLE_PROP(_moz_image_region, ImageRegion)
|
||||
|
|
|
@ -9729,6 +9729,48 @@ nsRuleNode::ComputeSVGData(void* aStartStruct,
|
|||
parentSVG->mTextAnchor,
|
||||
NS_STYLE_TEXT_ANCHOR_START);
|
||||
|
||||
// -moz-context-properties:
|
||||
const nsCSSValue* contextPropsValue = aRuleData->ValueForContextProperties();
|
||||
switch (contextPropsValue->GetUnit()) {
|
||||
case eCSSUnit_Null:
|
||||
break;
|
||||
|
||||
case eCSSUnit_List:
|
||||
case eCSSUnit_ListDep: {
|
||||
svg->mContextProps.Clear();
|
||||
svg->mContextPropsBits = 0;
|
||||
for (const nsCSSValueList* item = contextPropsValue->GetListValue();
|
||||
item; item = item->mNext)
|
||||
{
|
||||
nsIAtom* atom = item->mValue.GetAtomValue();
|
||||
svg->mContextProps.AppendElement(atom);
|
||||
if (atom == nsGkAtoms::fill) {
|
||||
svg->mContextPropsBits |= NS_STYLE_CONTEXT_PROPERTY_FILL;
|
||||
} else if (atom == nsGkAtoms::stroke) {
|
||||
svg->mContextPropsBits |= NS_STYLE_CONTEXT_PROPERTY_STROKE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case eCSSUnit_Inherit:
|
||||
svg->mContextProps.Clear();
|
||||
svg->mContextProps.AppendElements(parentSVG->mContextProps);
|
||||
svg->mContextPropsBits = parentSVG->mContextPropsBits;
|
||||
conditions.SetUncacheable();
|
||||
break;
|
||||
|
||||
case eCSSUnit_Initial:
|
||||
case eCSSUnit_None:
|
||||
case eCSSUnit_Unset:
|
||||
svg->mContextProps.Clear();
|
||||
svg->mContextPropsBits = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
MOZ_ASSERT(false, "unrecognized -moz-context-properties value");
|
||||
}
|
||||
|
||||
COMPUTE_END_INHERITED(SVG, svg)
|
||||
}
|
||||
|
||||
|
|
|
@ -1053,6 +1053,10 @@ enum class StyleGridTrackBreadth : uint8_t {
|
|||
|
||||
// See nsStyleSVG
|
||||
|
||||
// -moz-context-properties
|
||||
#define NS_STYLE_CONTEXT_PROPERTY_FILL (1 << 0)
|
||||
#define NS_STYLE_CONTEXT_PROPERTY_STROKE (1 << 1)
|
||||
|
||||
// dominant-baseline
|
||||
#define NS_STYLE_DOMINANT_BASELINE_AUTO 0
|
||||
#define NS_STYLE_DOMINANT_BASELINE_USE_SCRIPT 1
|
||||
|
|
|
@ -876,6 +876,7 @@ nsStyleSVG::nsStyleSVG(const nsPresContext* aContext)
|
|||
, mStrokeLinecap(NS_STYLE_STROKE_LINECAP_BUTT)
|
||||
, mStrokeLinejoin(NS_STYLE_STROKE_LINEJOIN_MITER)
|
||||
, mTextAnchor(NS_STYLE_TEXT_ANCHOR_START)
|
||||
, mContextPropsBits(0)
|
||||
, mContextFlags((eStyleSVGOpacitySource_Normal << FILL_OPACITY_SOURCE_SHIFT) |
|
||||
(eStyleSVGOpacitySource_Normal << STROKE_OPACITY_SOURCE_SHIFT))
|
||||
{
|
||||
|
@ -894,6 +895,7 @@ nsStyleSVG::nsStyleSVG(const nsStyleSVG& aSource)
|
|||
, mMarkerMid(aSource.mMarkerMid)
|
||||
, mMarkerStart(aSource.mMarkerStart)
|
||||
, mStrokeDasharray(aSource.mStrokeDasharray)
|
||||
, mContextProps(aSource.mContextProps)
|
||||
, mStrokeDashoffset(aSource.mStrokeDashoffset)
|
||||
, mStrokeWidth(aSource.mStrokeWidth)
|
||||
, mFillOpacity(aSource.mFillOpacity)
|
||||
|
@ -908,6 +910,7 @@ nsStyleSVG::nsStyleSVG(const nsStyleSVG& aSource)
|
|||
, mStrokeLinecap(aSource.mStrokeLinecap)
|
||||
, mStrokeLinejoin(aSource.mStrokeLinejoin)
|
||||
, mTextAnchor(aSource.mTextAnchor)
|
||||
, mContextPropsBits(aSource.mContextPropsBits)
|
||||
, mContextFlags(aSource.mContextFlags)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsStyleSVG);
|
||||
|
@ -992,10 +995,17 @@ nsStyleSVG::CalcDifference(const nsStyleSVG& aNewData) const
|
|||
mPaintOrder != aNewData.mPaintOrder ||
|
||||
mShapeRendering != aNewData.mShapeRendering ||
|
||||
mStrokeDasharray != aNewData.mStrokeDasharray ||
|
||||
mContextFlags != aNewData.mContextFlags) {
|
||||
mContextFlags != aNewData.mContextFlags ||
|
||||
mContextPropsBits != aNewData.mContextPropsBits) {
|
||||
return hint | nsChangeHint_RepaintFrame;
|
||||
}
|
||||
|
||||
if (!hint) {
|
||||
if (mContextProps != aNewData.mContextProps) {
|
||||
hint = nsChangeHint_NeutralChange;
|
||||
}
|
||||
}
|
||||
|
||||
return hint;
|
||||
}
|
||||
|
||||
|
|
|
@ -3468,6 +3468,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleSVG
|
|||
RefPtr<mozilla::css::URLValue> mMarkerMid; // [inherited]
|
||||
RefPtr<mozilla::css::URLValue> mMarkerStart; // [inherited]
|
||||
nsTArray<nsStyleCoord> mStrokeDasharray; // [inherited] coord, percent, factor
|
||||
nsTArray<nsCOMPtr<nsIAtom>> mContextProps;
|
||||
|
||||
nsStyleCoord mStrokeDashoffset; // [inherited] coord, percent, factor
|
||||
nsStyleCoord mStrokeWidth; // [inherited] coord, percent, factor
|
||||
|
@ -3485,6 +3486,15 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleSVG
|
|||
uint8_t mStrokeLinecap; // [inherited] see nsStyleConsts.h
|
||||
uint8_t mStrokeLinejoin; // [inherited] see nsStyleConsts.h
|
||||
uint8_t mTextAnchor; // [inherited] see nsStyleConsts.h
|
||||
uint8_t mContextPropsBits; // [inherited] see nsStyleConsts.h.
|
||||
// Stores a bitfield representation of
|
||||
// the specified properties.
|
||||
|
||||
/// Returns true if style has been set to expose the computed values of
|
||||
/// certain properties (such as 'fill') to the contents of any linked images.
|
||||
bool ExposesContextProperties() const {
|
||||
return bool(mContextPropsBits);
|
||||
}
|
||||
|
||||
nsStyleSVGOpacitySource FillOpacitySource() const {
|
||||
uint8_t value = (mContextFlags & FILL_OPACITY_SOURCE_MASK) >>
|
||||
|
|
|
@ -106,6 +106,7 @@ const char *gInaccessibleProperties[] = {
|
|||
"-x-span",
|
||||
"-x-system-font",
|
||||
"-x-text-zoom",
|
||||
"-moz-context-properties",
|
||||
"-moz-control-character-visibility",
|
||||
"-moz-script-level", // parsed by UA sheets only
|
||||
"-moz-script-size-multiplier",
|
||||
|
|
|
@ -7872,4 +7872,13 @@ if (false) {
|
|||
other_values: [ "none", "menu", "tooltip", "sheet" ],
|
||||
invalid_values: []
|
||||
};
|
||||
|
||||
gCSSProperties["-moz-context-properties"] = {
|
||||
//domProp: "MozContextProperties",
|
||||
inherited: true,
|
||||
type: CSS_TYPE_LONGHAND,
|
||||
initial_values: [ "none" ],
|
||||
other_values: [ "fill", "stroke", "fill, stroke", "fill, stroke, fill", "fill, foo", "foo" ],
|
||||
invalid_values: [ "default", "fill, auto", "all, stroke", "none, fill", "fill, none", "fill, default", "2px" ]
|
||||
};
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче