Bug 1535165 - Use cbindgen for touch-action. r=dholbert

And rename the constants to not be prefixed by TOUCH_ACTION_, since that's part
of the type name anyway.

Differential Revision: https://phabricator.services.mozilla.com/D23413

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2019-03-18 18:01:55 +00:00
Родитель e66fb8488c
Коммит 70e3f8ffcd
18 изменённых файлов: 47 добавлений и 115 удалений

Просмотреть файл

@ -14,20 +14,20 @@
namespace mozilla {
namespace layers {
void TouchActionHelper::UpdateAllowedBehavior(
uint32_t aTouchActionValue, bool aConsiderPanning,
TouchBehaviorFlags& aOutBehavior) {
if (aTouchActionValue != NS_STYLE_TOUCH_ACTION_AUTO) {
static void UpdateAllowedBehavior(StyleTouchAction aTouchActionValue,
bool aConsiderPanning,
TouchBehaviorFlags& aOutBehavior) {
if (aTouchActionValue != StyleTouchAction_AUTO) {
// Double-tap-zooming need property value AUTO
aOutBehavior &= ~AllowedTouchBehavior::DOUBLE_TAP_ZOOM;
if (aTouchActionValue != NS_STYLE_TOUCH_ACTION_MANIPULATION) {
if (aTouchActionValue != StyleTouchAction_MANIPULATION) {
// Pinch-zooming need value AUTO or MANIPULATION
aOutBehavior &= ~AllowedTouchBehavior::PINCH_ZOOM;
}
}
if (aConsiderPanning) {
if (aTouchActionValue == NS_STYLE_TOUCH_ACTION_NONE) {
if (aTouchActionValue == StyleTouchAction_NONE) {
aOutBehavior &= ~AllowedTouchBehavior::VERTICAL_PAN;
aOutBehavior &= ~AllowedTouchBehavior::HORIZONTAL_PAN;
}
@ -35,11 +35,11 @@ void TouchActionHelper::UpdateAllowedBehavior(
// Values pan-x and pan-y set at the same time to the same element do not
// affect panning constraints. Therefore we need to check whether pan-x is
// set without pan-y and the same for pan-y.
if ((aTouchActionValue & NS_STYLE_TOUCH_ACTION_PAN_X) &&
!(aTouchActionValue & NS_STYLE_TOUCH_ACTION_PAN_Y)) {
if ((aTouchActionValue & StyleTouchAction_PAN_X) &&
!(aTouchActionValue & StyleTouchAction_PAN_Y)) {
aOutBehavior &= ~AllowedTouchBehavior::VERTICAL_PAN;
} else if ((aTouchActionValue & NS_STYLE_TOUCH_ACTION_PAN_Y) &&
!(aTouchActionValue & NS_STYLE_TOUCH_ACTION_PAN_X)) {
} else if ((aTouchActionValue & StyleTouchAction_PAN_Y) &&
!(aTouchActionValue & StyleTouchAction_PAN_X)) {
aOutBehavior &= ~AllowedTouchBehavior::HORIZONTAL_PAN;
}
}

Просмотреть файл

@ -20,11 +20,6 @@ namespace layers {
* the touch-action spec.
*/
class TouchActionHelper {
private:
static void UpdateAllowedBehavior(uint32_t aTouchActionValue,
bool aConsiderPanning,
TouchBehaviorFlags& aOutBehavior);
public:
/*
* Performs hit testing on content, finds frame that corresponds to the aPoint

Просмотреть файл

@ -9159,10 +9159,9 @@ bool nsLayoutUtils::ContainsMetricsWithId(const Layer* aLayer,
}
/* static */
uint32_t nsLayoutUtils::GetTouchActionFromFrame(nsIFrame* aFrame) {
// If aFrame is null then return default value
StyleTouchAction nsLayoutUtils::GetTouchActionFromFrame(nsIFrame* aFrame) {
if (!aFrame) {
return NS_STYLE_TOUCH_ACTION_AUTO;
return StyleTouchAction_AUTO;
}
// The touch-action CSS property applies to: all elements except:
@ -9171,13 +9170,13 @@ uint32_t nsLayoutUtils::GetTouchActionFromFrame(nsIFrame* aFrame) {
bool isNonReplacedInlineElement =
aFrame->IsFrameOfType(nsIFrame::eLineParticipant);
if (isNonReplacedInlineElement) {
return NS_STYLE_TOUCH_ACTION_AUTO;
return StyleTouchAction_AUTO;
}
const nsStyleDisplay* disp = aFrame->StyleDisplay();
bool isTableElement = disp->IsInternalTableStyleExceptCell();
if (isTableElement) {
return NS_STYLE_TOUCH_ACTION_AUTO;
return StyleTouchAction_AUTO;
}
return disp->mTouchAction;

Просмотреть файл

@ -2620,7 +2620,7 @@ class nsLayoutUtils {
/**
* Helper method to get touch action behaviour from the frame
*/
static uint32_t GetTouchActionFromFrame(nsIFrame* aFrame);
static mozilla::StyleTouchAction GetTouchActionFromFrame(nsIFrame* aFrame);
/**
* Helper method to transform |aBounds| from aFrame to aAncestorFrame,

Просмотреть файл

@ -10898,13 +10898,13 @@ CompositorHitTestInfo nsIFrame::GetCompositorHitTestInfo(
result += inheritedTouchAction;
const uint32_t touchAction =
const StyleTouchAction touchAction =
nsLayoutUtils::GetTouchActionFromFrame(touchActionFrame);
// The CSS allows the syntax auto | none | [pan-x || pan-y] | manipulation
// so we can eliminate some combinations of things.
if (touchAction == NS_STYLE_TOUCH_ACTION_AUTO) {
if (touchAction == StyleTouchAction_AUTO) {
// nothing to do
} else if (touchAction & NS_STYLE_TOUCH_ACTION_MANIPULATION) {
} else if (touchAction & StyleTouchAction_MANIPULATION) {
result += CompositorHitTestFlags::eTouchActionDoubleTapZoomDisabled;
} else {
// This path handles the cases none | [pan-x || pan-y] and so both
@ -10912,13 +10912,13 @@ CompositorHitTestInfo nsIFrame::GetCompositorHitTestInfo(
result += CompositorHitTestFlags::eTouchActionPinchZoomDisabled;
result += CompositorHitTestFlags::eTouchActionDoubleTapZoomDisabled;
if (!(touchAction & NS_STYLE_TOUCH_ACTION_PAN_X)) {
if (!(touchAction & StyleTouchAction_PAN_X)) {
result += CompositorHitTestFlags::eTouchActionPanXDisabled;
}
if (!(touchAction & NS_STYLE_TOUCH_ACTION_PAN_Y)) {
if (!(touchAction & StyleTouchAction_PAN_Y)) {
result += CompositorHitTestFlags::eTouchActionPanYDisabled;
}
if (touchAction & NS_STYLE_TOUCH_ACTION_NONE) {
if (touchAction & StyleTouchAction_NONE) {
// all the touch-action disabling flags will already have been set above
MOZ_ASSERT(result.contains(CompositorHitTestTouchActionMask));
}

Просмотреть файл

@ -449,6 +449,7 @@ cbindgen-types = [
{ gecko = "StyleGenericLineHeight", servo = "values::generics::text::LineHeight" },
{ gecko = "StyleContain", servo = "values::computed::Contain" },
{ gecko = "StyleRestyleHint", servo = "invalidation::element::restyle_hints::RestyleHint" },
{ gecko = "StyleTouchAction", servo = "values::computed::TouchAction" },
{ gecko = "StyleTextDecorationLine", servo = "values::computed::TextDecorationLine" },
]

Просмотреть файл

@ -118,7 +118,6 @@ LONGHANDS_NOT_SERIALIZED_WITH_SERVO = [
"text-emphasis-style",
"text-overflow",
"text-shadow",
"touch-action",
"transition-delay",
"transition-duration",
"transition-property",

Просмотреть файл

@ -381,14 +381,6 @@ const KTableEntry nsCSSProps::kTextOverflowKTable[] = {
{eCSSKeyword_ellipsis, NS_STYLE_TEXT_OVERFLOW_ELLIPSIS},
{eCSSKeyword_UNKNOWN, -1}};
const KTableEntry nsCSSProps::kTouchActionKTable[] = {
{eCSSKeyword_none, NS_STYLE_TOUCH_ACTION_NONE},
{eCSSKeyword_auto, NS_STYLE_TOUCH_ACTION_AUTO},
{eCSSKeyword_pan_x, NS_STYLE_TOUCH_ACTION_PAN_X},
{eCSSKeyword_pan_y, NS_STYLE_TOUCH_ACTION_PAN_Y},
{eCSSKeyword_manipulation, NS_STYLE_TOUCH_ACTION_MANIPULATION},
{eCSSKeyword_UNKNOWN, -1}};
const KTableEntry nsCSSProps::kVerticalAlignKTable[] = {
{eCSSKeyword_baseline, NS_STYLE_VERTICAL_ALIGN_BASELINE},
{eCSSKeyword_sub, NS_STYLE_VERTICAL_ALIGN_SUB},

Просмотреть файл

@ -309,7 +309,6 @@ class nsCSSProps {
static const KTableEntry kTextDecorationStyleKTable[];
static const KTableEntry kTextEmphasisStyleShapeKTable[];
static const KTableEntry kTextOverflowKTable[];
static const KTableEntry kTouchActionKTable[];
static const KTableEntry kVerticalAlignKTable[];
};

Просмотреть файл

@ -2249,22 +2249,6 @@ already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetWillChange() {
return valueList.forget();
}
already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetTouchAction() {
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
int32_t intValue = StyleDisplay()->mTouchAction;
// None and Auto and Manipulation values aren't allowed
// to be in conjunction with other values.
// But there are all checks in CSSParserImpl::ParseTouchAction
nsAutoString valueStr;
nsStyleUtil::AppendBitmaskCSSValue(
nsCSSProps::kTouchActionKTable, intValue, NS_STYLE_TOUCH_ACTION_NONE,
NS_STYLE_TOUCH_ACTION_MANIPULATION, valueStr);
val->SetString(valueStr);
return val.forget();
}
already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetHeight() {
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;

Просмотреть файл

@ -318,7 +318,6 @@ class nsComputedDOMStyle final : public nsDOMCSSDeclaration,
already_AddRefed<CSSValue> DoGetBinding();
already_AddRefed<CSSValue> DoGetDisplay();
already_AddRefed<CSSValue> DoGetWillChange();
already_AddRefed<CSSValue> DoGetTouchAction();
already_AddRefed<CSSValue> DoGetTransform();
already_AddRefed<CSSValue> DoGetTransformOrigin();
already_AddRefed<CSSValue> DoGetPerspectiveOrigin();

Просмотреть файл

@ -585,13 +585,6 @@ enum class StyleGridTrackBreadth : uint8_t {
#define NS_STYLE_TEXT_TRANSFORM_FULL_WIDTH 4
#define NS_STYLE_TEXT_TRANSFORM_FULL_SIZE_KANA 5
// 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)
#define NS_STYLE_TOUCH_ACTION_MANIPULATION (1 << 4)
// See nsStyleDisplay
#define NS_STYLE_TOP_LAYER_NONE 0 // not in the top layer
#define NS_STYLE_TOP_LAYER_TOP 1 // in the top layer

Просмотреть файл

@ -2924,7 +2924,7 @@ nsStyleDisplay::nsStyleDisplay(const Document& aDocument)
mIsolation(NS_STYLE_ISOLATION_AUTO),
mTopLayer(NS_STYLE_TOP_LAYER_NONE),
mWillChangeBitField(0),
mTouchAction(NS_STYLE_TOUCH_ACTION_AUTO),
mTouchAction(StyleTouchAction_AUTO),
mScrollBehavior(NS_STYLE_SCROLL_BEHAVIOR_AUTO),
mOverscrollBehaviorX(StyleOverscrollBehavior::Auto),
mOverscrollBehaviorY(StyleOverscrollBehavior::Auto),

Просмотреть файл

@ -1888,7 +1888,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay {
// require a stacking context.
nsTArray<RefPtr<nsAtom>> mWillChange;
uint8_t mTouchAction; // NS_STYLE_TOUCH_ACTION_*
mozilla::StyleTouchAction mTouchAction;
uint8_t mScrollBehavior; // NS_STYLE_SCROLL_BEHAVIOR_*
mozilla::StyleOverscrollBehavior mOverscrollBehaviorX;
mozilla::StyleOverscrollBehavior mOverscrollBehaviorY;

Просмотреть файл

@ -105,6 +105,7 @@ include = [
"WordBreak",
"Contain",
"RestyleHint",
"TouchAction",
"TextDecorationLine",
]
item_types = ["enums", "structs", "typedefs"]

Просмотреть файл

@ -2582,7 +2582,7 @@ fn static_assert() {
transform-style
rotate scroll-snap-points-x scroll-snap-points-y
scroll-snap-coordinate -moz-binding will-change
offset-path shape-outside touch-action
offset-path shape-outside
translate scale""" %>
<%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}">
#[inline]
@ -3002,8 +3002,6 @@ fn static_assert() {
<% impl_shape_source("shape_outside", "mShapeOutside") %>
${impl_simple_type_with_conversion("touch_action")}
pub fn set_offset_path(&mut self, v: longhands::offset_path::computed_value::T) {
use crate::gecko_bindings::bindings::{Gecko_NewStyleMotion, Gecko_SetStyleMotion};
use crate::gecko_bindings::structs::StyleShapeSourceType;

Просмотреть файл

@ -650,21 +650,22 @@ impl Parse for WillChange {
}
bitflags! {
/// Values for the `touch-action` property.
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[derive(SpecifiedValueInfo, ToComputedValue)]
/// These constants match Gecko's `NS_STYLE_TOUCH_ACTION_*` constants.
#[value_info(other_values = "auto,none,manipulation,pan-x,pan-y")]
#[repr(C)]
pub struct TouchAction: u8 {
/// `none` variant
const TOUCH_ACTION_NONE = 1 << 0;
const NONE = 1 << 0;
/// `auto` variant
const TOUCH_ACTION_AUTO = 1 << 1;
const AUTO = 1 << 1;
/// `pan-x` variant
const TOUCH_ACTION_PAN_X = 1 << 2;
const PAN_X = 1 << 2;
/// `pan-y` variant
const TOUCH_ACTION_PAN_Y = 1 << 3;
const PAN_Y = 1 << 3;
/// `manipulation` variant
const TOUCH_ACTION_MANIPULATION = 1 << 4;
const MANIPULATION = 1 << 4;
}
}
@ -672,7 +673,7 @@ impl TouchAction {
#[inline]
/// Get default `touch-action` as `auto`
pub fn auto() -> TouchAction {
TouchAction::TOUCH_ACTION_AUTO
TouchAction::AUTO
}
}
@ -682,16 +683,14 @@ impl ToCss for TouchAction {
W: Write,
{
match *self {
TouchAction::TOUCH_ACTION_NONE => dest.write_str("none"),
TouchAction::TOUCH_ACTION_AUTO => dest.write_str("auto"),
TouchAction::TOUCH_ACTION_MANIPULATION => dest.write_str("manipulation"),
_ if self
.contains(TouchAction::TOUCH_ACTION_PAN_X | TouchAction::TOUCH_ACTION_PAN_Y) =>
{
TouchAction::NONE => dest.write_str("none"),
TouchAction::AUTO => dest.write_str("auto"),
TouchAction::MANIPULATION => dest.write_str("manipulation"),
_ if self.contains(TouchAction::PAN_X | TouchAction::PAN_Y) => {
dest.write_str("pan-x pan-y")
},
_ if self.contains(TouchAction::TOUCH_ACTION_PAN_X) => dest.write_str("pan-x"),
_ if self.contains(TouchAction::TOUCH_ACTION_PAN_Y) => dest.write_str("pan-y"),
_ if self.contains(TouchAction::PAN_X) => dest.write_str("pan-x"),
_ if self.contains(TouchAction::PAN_Y) => dest.write_str("pan-y"),
_ => panic!("invalid touch-action value"),
}
}
@ -703,53 +702,27 @@ impl Parse for TouchAction {
input: &mut Parser<'i, 't>,
) -> Result<TouchAction, ParseError<'i>> {
try_match_ident_ignore_ascii_case! { input,
"auto" => Ok(TouchAction::TOUCH_ACTION_AUTO),
"none" => Ok(TouchAction::TOUCH_ACTION_NONE),
"manipulation" => Ok(TouchAction::TOUCH_ACTION_MANIPULATION),
"auto" => Ok(TouchAction::AUTO),
"none" => Ok(TouchAction::NONE),
"manipulation" => Ok(TouchAction::MANIPULATION),
"pan-x" => {
if input.try(|i| i.expect_ident_matching("pan-y")).is_ok() {
Ok(TouchAction::TOUCH_ACTION_PAN_X | TouchAction::TOUCH_ACTION_PAN_Y)
Ok(TouchAction::PAN_X | TouchAction::PAN_Y)
} else {
Ok(TouchAction::TOUCH_ACTION_PAN_X)
Ok(TouchAction::PAN_X)
}
},
"pan-y" => {
if input.try(|i| i.expect_ident_matching("pan-x")).is_ok() {
Ok(TouchAction::TOUCH_ACTION_PAN_X | TouchAction::TOUCH_ACTION_PAN_Y)
Ok(TouchAction::PAN_X | TouchAction::PAN_Y)
} else {
Ok(TouchAction::TOUCH_ACTION_PAN_Y)
Ok(TouchAction::PAN_Y)
}
},
}
}
}
#[cfg(feature = "gecko")]
impl_bitflags_conversions!(TouchAction);
/// Asserts that all touch-action matches its NS_STYLE_TOUCH_ACTION_* value.
#[cfg(feature = "gecko")]
#[inline]
pub fn assert_touch_action_matches() {
use crate::gecko_bindings::structs;
macro_rules! check_touch_action {
( $( $a:ident => $b:path),*, ) => {
$(
debug_assert_eq!(structs::$a as u8, $b.bits());
)*
}
}
check_touch_action! {
NS_STYLE_TOUCH_ACTION_NONE => TouchAction::TOUCH_ACTION_NONE,
NS_STYLE_TOUCH_ACTION_AUTO => TouchAction::TOUCH_ACTION_AUTO,
NS_STYLE_TOUCH_ACTION_PAN_X => TouchAction::TOUCH_ACTION_PAN_X,
NS_STYLE_TOUCH_ACTION_PAN_Y => TouchAction::TOUCH_ACTION_PAN_Y,
NS_STYLE_TOUCH_ACTION_MANIPULATION => TouchAction::TOUCH_ACTION_MANIPULATION,
}
}
bitflags! {
#[derive(MallocSizeOf, SpecifiedValueInfo, ToComputedValue)]
#[value_info(other_values = "none,strict,content,size,layout,paint")]

Просмотреть файл

@ -244,7 +244,6 @@ pub unsafe extern "C" fn Servo_Initialize(dummy_url_data: *mut URLExtraData) {
traversal_flags::assert_traversal_flags_match();
specified::font::assert_variant_east_asian_matches();
specified::font::assert_variant_ligatures_matches();
specified::box_::assert_touch_action_matches();
DUMMY_URL_DATA = dummy_url_data;
}