mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-16 22:04:36 +00:00
Bug 795567 - Part 1: Add touch-action css property to the style system. r=dbaron
This commit is contained in:
parent
39e3c5ac7f
commit
8f48b7bbc6
@ -416,6 +416,8 @@ CSS_KEY(overlay, overlay)
|
||||
CSS_KEY(overline, overline)
|
||||
CSS_KEY(padding-box, padding_box)
|
||||
CSS_KEY(painted, painted)
|
||||
CSS_KEY(pan-x, pan_x)
|
||||
CSS_KEY(pan-y, pan_y)
|
||||
CSS_KEY(paused, paused)
|
||||
CSS_KEY(pc, pc)
|
||||
CSS_KEY(perspective, perspective)
|
||||
|
@ -651,6 +651,7 @@ protected:
|
||||
bool ParseTextDecorationLine(nsCSSValue& aValue);
|
||||
bool ParseTextCombineHorizontal(nsCSSValue& aValue);
|
||||
bool ParseTextOverflow(nsCSSValue& aValue);
|
||||
bool ParseTouchAction(nsCSSValue& aValue);
|
||||
|
||||
bool ParseShadowItem(nsCSSValue& aValue, bool aIsBoxShadow);
|
||||
bool ParseShadowList(nsCSSProperty aProperty);
|
||||
@ -7919,6 +7920,8 @@ CSSParserImpl::ParseSingleValueProperty(nsCSSValue& aValue,
|
||||
return ParseTextCombineHorizontal(aValue);
|
||||
case eCSSProperty_text_overflow:
|
||||
return ParseTextOverflow(aValue);
|
||||
case eCSSProperty_touch_action:
|
||||
return ParseTouchAction(aValue);
|
||||
default:
|
||||
NS_ABORT_IF_FALSE(false, "should not reach here");
|
||||
return false;
|
||||
@ -11087,6 +11090,36 @@ CSSParserImpl::ParseTextOverflow(nsCSSValue& aValue)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CSSParserImpl::ParseTouchAction(nsCSSValue& aValue)
|
||||
{
|
||||
if (!ParseVariant(aValue, VARIANT_HK | VARIANT_NONE | VARIANT_AUTO,
|
||||
nsCSSProps::kTouchActionKTable)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Auto and None keywords aren't allowed in conjunction with others.
|
||||
// Also inherit, initial and unset values are available.
|
||||
if (eCSSUnit_Enumerated != aValue.GetUnit()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t intValue = aValue.GetIntValue();
|
||||
nsCSSValue nextValue;
|
||||
if (ParseEnum(nextValue, nsCSSProps::kTouchActionKTable)) {
|
||||
int32_t nextIntValue = nextValue.GetIntValue();
|
||||
|
||||
// duplicates aren't allowed.
|
||||
if (nextIntValue & intValue) {
|
||||
return false;
|
||||
}
|
||||
|
||||
aValue.SetIntValue(nextIntValue | intValue, eCSSUnit_Enumerated);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CSSParserImpl::ParseTextCombineHorizontal(nsCSSValue& aValue)
|
||||
{
|
||||
|
@ -3035,6 +3035,17 @@ CSS_PROP_POSITION(
|
||||
nullptr,
|
||||
offsetof(nsStylePosition, mOffset),
|
||||
eStyleAnimType_Sides_Top)
|
||||
CSS_PROP_DISPLAY(
|
||||
touch-action,
|
||||
touch_action,
|
||||
TouchAction,
|
||||
CSS_PROPERTY_PARSE_VALUE |
|
||||
CSS_PROPERTY_VALUE_PARSER_FUNCTION,
|
||||
"layout.css.touch_action.enabled",
|
||||
VARIANT_HK,
|
||||
kTouchActionKTable,
|
||||
CSS_PROP_NO_OFFSET,
|
||||
eStyleAnimType_None)
|
||||
CSS_PROP_SHORTHAND(
|
||||
transition,
|
||||
transition,
|
||||
|
@ -1596,6 +1596,12 @@ const int32_t nsCSSProps::kTextTransformKTable[] = {
|
||||
eCSSKeyword_UNKNOWN,-1
|
||||
};
|
||||
|
||||
const int32_t nsCSSProps::kTouchActionKTable[] = {
|
||||
eCSSKeyword_pan_x, NS_STYLE_TOUCH_ACTION_PAN_X,
|
||||
eCSSKeyword_pan_y, NS_STYLE_TOUCH_ACTION_PAN_Y,
|
||||
eCSSKeyword_UNKNOWN, -1
|
||||
};
|
||||
|
||||
const int32_t nsCSSProps::kTransitionTimingFunctionKTable[] = {
|
||||
eCSSKeyword_ease, NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE,
|
||||
eCSSKeyword_linear, NS_STYLE_TRANSITION_TIMING_FUNCTION_LINEAR,
|
||||
|
@ -560,6 +560,7 @@ public:
|
||||
static const int32_t kTextOrientationKTable[];
|
||||
static const int32_t kTextOverflowKTable[];
|
||||
static const int32_t kTextTransformKTable[];
|
||||
static const int32_t kTouchActionKTable[];
|
||||
static const int32_t kTransitionTimingFunctionKTable[];
|
||||
static const int32_t kUnicodeBidiKTable[];
|
||||
static const int32_t kUserFocusKTable[];
|
||||
|
@ -1007,6 +1007,13 @@ nsCSSValue::AppendToString(nsCSSProperty aProperty, nsAString& aResult,
|
||||
aResult);
|
||||
break;
|
||||
|
||||
case eCSSProperty_touch_action:
|
||||
nsStyleUtil::AppendBitmaskCSSValue(aProperty, intValue,
|
||||
NS_STYLE_TOUCH_ACTION_PAN_X,
|
||||
NS_STYLE_TOUCH_ACTION_PAN_Y,
|
||||
aResult);
|
||||
break;
|
||||
|
||||
default:
|
||||
const nsAFlatCString& name = nsCSSProps::LookupPropertyValue(aProperty, intValue);
|
||||
AppendASCIItoUTF16(name, aResult);
|
||||
|
@ -3787,6 +3787,30 @@ nsComputedDOMStyle::DoGetPageBreakInside()
|
||||
return val;
|
||||
}
|
||||
|
||||
CSSValue*
|
||||
nsComputedDOMStyle::DoGetTouchAction()
|
||||
{
|
||||
nsROCSSPrimitiveValue *val = new nsROCSSPrimitiveValue;
|
||||
|
||||
int32_t intValue = StyleDisplay()->mTouchAction;
|
||||
|
||||
// None and Auto values aren't allowed to be in conjunction with
|
||||
// other values.
|
||||
if (NS_STYLE_TOUCH_ACTION_AUTO == intValue) {
|
||||
val->SetIdent(eCSSKeyword_auto);
|
||||
} else if (NS_STYLE_TOUCH_ACTION_NONE == intValue) {
|
||||
val->SetIdent(eCSSKeyword_none);
|
||||
} else {
|
||||
nsAutoString valueStr;
|
||||
nsStyleUtil::AppendBitmaskCSSValue(eCSSProperty_touch_action,
|
||||
intValue, NS_STYLE_TOUCH_ACTION_PAN_X,
|
||||
NS_STYLE_TOUCH_ACTION_PAN_Y, valueStr);
|
||||
val->SetString(valueStr);
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
CSSValue*
|
||||
nsComputedDOMStyle::DoGetHeight()
|
||||
{
|
||||
|
@ -399,6 +399,7 @@ private:
|
||||
mozilla::dom::CSSValue* DoGetPageBreakAfter();
|
||||
mozilla::dom::CSSValue* DoGetPageBreakBefore();
|
||||
mozilla::dom::CSSValue* DoGetPageBreakInside();
|
||||
mozilla::dom::CSSValue* DoGetTouchAction();
|
||||
mozilla::dom::CSSValue* DoGetTransform();
|
||||
mozilla::dom::CSSValue* DoGetTransformOrigin();
|
||||
mozilla::dom::CSSValue* DoGetPerspective();
|
||||
|
@ -190,6 +190,7 @@ COMPUTED_STYLE_PROP(text_overflow, TextOverflow)
|
||||
COMPUTED_STYLE_PROP(text_shadow, TextShadow)
|
||||
COMPUTED_STYLE_PROP(text_transform, TextTransform)
|
||||
COMPUTED_STYLE_PROP(top, Top)
|
||||
COMPUTED_STYLE_PROP(touch_action, TouchAction)
|
||||
COMPUTED_STYLE_PROP(transform, Transform)
|
||||
COMPUTED_STYLE_PROP(transform_origin, TransformOrigin)
|
||||
COMPUTED_STYLE_PROP(transform_style, TransformStyle)
|
||||
|
@ -5240,6 +5240,16 @@ nsRuleNode::ComputeDisplayData(void* aStartStruct,
|
||||
parentDisplay->mBreakInside,
|
||||
NS_STYLE_PAGE_BREAK_AUTO, 0, 0, 0, 0);
|
||||
|
||||
// touch-action: none, auto, enum, inherit, initial
|
||||
SetDiscrete(*aRuleData->ValueForTouchAction(), display->mTouchAction,
|
||||
canStoreInRuleTree,
|
||||
SETDSC_ENUMERATED | SETDSC_AUTO | SETDSC_NONE |
|
||||
SETDSC_UNSET_INITIAL,
|
||||
parentDisplay->mTouchAction,
|
||||
NS_STYLE_TOUCH_ACTION_AUTO,
|
||||
NS_STYLE_TOUCH_ACTION_AUTO,
|
||||
NS_STYLE_TOUCH_ACTION_NONE, 0, 0);
|
||||
|
||||
// float: enum, inherit, initial
|
||||
SetDiscrete(*aRuleData->ValueForFloat(),
|
||||
display->mFloats, canStoreInRuleTree,
|
||||
|
@ -746,6 +746,12 @@ static inline mozilla::css::Side operator++(mozilla::css::Side& side, int) {
|
||||
#define NS_STYLE_TEXT_TRANSFORM_UPPERCASE 3
|
||||
#define NS_STYLE_TEXT_TRANSFORM_FULLWIDTH 4
|
||||
|
||||
// See nsStyleDisplay
|
||||
#define NS_STYLE_TOUCH_ACTION_NONE (1 << 0)
|
||||
#define NS_STYLE_TOUCH_ACTION_AUTO (1 << 1)
|
||||
#define NS_STYLE_TOUCH_ACTION_PAN_X (1 << 2)
|
||||
#define NS_STYLE_TOUCH_ACTION_PAN_Y (1 << 3)
|
||||
|
||||
// See nsStyleDisplay
|
||||
#define NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE 0
|
||||
#define NS_STYLE_TRANSITION_TIMING_FUNCTION_LINEAR 1
|
||||
|
@ -2337,6 +2337,7 @@ nsStyleDisplay::nsStyleDisplay()
|
||||
mTransformStyle = NS_STYLE_TRANSFORM_STYLE_FLAT;
|
||||
mOrient = NS_STYLE_ORIENT_AUTO;
|
||||
mMixBlendMode = NS_STYLE_BLEND_NORMAL;
|
||||
mTouchAction = NS_STYLE_TOUCH_ACTION_AUTO;
|
||||
|
||||
mTransitions.AppendElement();
|
||||
NS_ABORT_IF_FALSE(mTransitions.Length() == 1,
|
||||
@ -2381,6 +2382,7 @@ nsStyleDisplay::nsStyleDisplay(const nsStyleDisplay& aSource)
|
||||
, mClipFlags(aSource.mClipFlags)
|
||||
, mOrient(aSource.mOrient)
|
||||
, mMixBlendMode(aSource.mMixBlendMode)
|
||||
, mTouchAction(aSource.mTouchAction)
|
||||
, mBackfaceVisibility(aSource.mBackfaceVisibility)
|
||||
, mTransformStyle(aSource.mTransformStyle)
|
||||
, mSpecifiedTransform(aSource.mSpecifiedTransform)
|
||||
|
@ -1794,6 +1794,7 @@ struct nsStyleDisplay {
|
||||
uint8_t mClipFlags; // [reset] see nsStyleConsts.h
|
||||
uint8_t mOrient; // [reset] see nsStyleConsts.h
|
||||
uint8_t mMixBlendMode; // [reset] see nsStyleConsts.h
|
||||
uint8_t mTouchAction; // [reset] see nsStyleConsts.h
|
||||
|
||||
// mSpecifiedTransform is the list of transform functions as
|
||||
// specified, or null to indicate there is no transform. (inherit or
|
||||
|
@ -4330,6 +4330,19 @@ function get_computed_value(cs, property)
|
||||
return cs.getPropertyValue(property);
|
||||
}
|
||||
|
||||
if (SpecialPowers.getBoolPref("layout.css.touch_action.enabled")) {
|
||||
gCSSProperties["touch-action"] = {
|
||||
domProp: "touchAction",
|
||||
inherited: false,
|
||||
type: CSS_TYPE_LONGHAND,
|
||||
initial_values: ["auto"],
|
||||
other_values: ["none", "pan-x", "pan-y", "pan-x pan-y", "pan-y pan-x"],
|
||||
invalid_values: ["zoom", "pinch", "tap", "10px", "2", "auto pan-x", "pan-x auto", "none pan-x", "pan-x none",
|
||||
"auto pan-y", "pan-y auto", "none pan-y", "pan-y none",
|
||||
"pan-x pan-y none", "none pan-x pan-y", "pan-x pan-y auto", "auto pan-x pan-y"]
|
||||
};
|
||||
}
|
||||
|
||||
if (SpecialPowers.getBoolPref("layout.css.vertical-text.enabled")) {
|
||||
var verticalTextProperties = {
|
||||
"writing-mode": {
|
||||
|
@ -72,7 +72,8 @@ var gProps = {
|
||||
"layout.css.font-features.enabled": ["font-kerning", "font-synthesis", "font-variant-alternates", "font-variant-caps", "font-variant-east-asian", "font-variant-ligatures", "font-variant-numeric", "font-variant-position"],
|
||||
"layout.css.image-orientation.enabled": ["image-orientation"],
|
||||
"layout.css.mix-blend-mode.enabled": ["mix-blend-mode"],
|
||||
"layout.css.masking.enabled": ["mask-type"]
|
||||
"layout.css.masking.enabled": ["mask-type"],
|
||||
"layout.css.touch_action.enabled": ["touch-action"]
|
||||
};
|
||||
|
||||
var gCS = getComputedStyle(document.body, "");
|
||||
|
@ -4241,6 +4241,9 @@ pref("dom.w3c_touch_events.enabled", 2);
|
||||
// W3C draft pointer events
|
||||
pref("dom.w3c_pointer_events.enabled", false);
|
||||
|
||||
// W3C touch-action css property (related to touch and pointer events)
|
||||
pref("layout.css.touch_action.enabled", false);
|
||||
|
||||
// enable JS dump() function.
|
||||
pref("browser.dom.window.dump.enabled", false);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user