servo: Merge #13539 - Regen bindings for upcoming resync (from Manishearth:regen); r=emilio

<s>The StyleComplexColor stuff has broken things, so the sync may take longer to fix.

cc @xidorn if you want to look into this. Otherwise I'll fix it monday.</s>

Source-Repo: https://github.com/servo/servo
Source-Revision: 97817da51dc46f2ffdfa7075881e18bf198869eb
This commit is contained in:
Manish Goregaokar 2016-10-01 23:19:10 -05:00
parent 16b43f0876
commit 27874b1bab
6 changed files with 845 additions and 800 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -7,3 +7,4 @@ mod ns_style_auto_array;
pub mod ns_style_coord;
mod ns_t_array;
pub mod ownership;
mod style_complex_color;

View File

@ -0,0 +1,47 @@
/* 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/. */
use cssparser::Color;
use gecko::values::{convert_nscolor_to_rgba, convert_rgba_to_nscolor};
use gecko_bindings::structs::{nscolor, StyleComplexColor};
impl From<nscolor> for StyleComplexColor {
fn from(other: nscolor) -> Self {
StyleComplexColor {
mColor: other,
mForegroundRatio: 0,
}
}
}
impl StyleComplexColor {
pub fn current_color() -> Self {
StyleComplexColor {
mColor: 0,
mForegroundRatio: 255,
}
}
}
impl From<Color> for StyleComplexColor {
fn from(other: Color) -> Self {
match other {
Color::RGBA(rgba) => convert_rgba_to_nscolor(&rgba).into(),
Color::CurrentColor => StyleComplexColor::current_color(),
}
}
}
impl From<StyleComplexColor> for Color {
fn from(other: StyleComplexColor) -> Self {
if other.mForegroundRatio == 0 {
Color::RGBA(convert_nscolor_to_rgba(other.mColor))
} else if other.mForegroundRatio == 255 {
Color::CurrentColor
} else {
// FIXME #13546 handle interpolation values
Color::CurrentColor
}
}
}

View File

@ -1726,6 +1726,8 @@ cfg_if! {
pub static nsGkAtoms_onpopuphidden: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms13onpopuphidingE"]
pub static nsGkAtoms_onpopuphiding: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms17onpopuppositionedE"]
pub static nsGkAtoms_onpopuppositioned: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms14onpopupshowingE"]
pub static nsGkAtoms_onpopupshowing: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms12onpopupshownE"]
@ -4316,10 +4318,6 @@ cfg_if! {
pub static nsGkAtoms_scrollbar_end_forward: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms28scrollbar_thumb_proportionalE"]
pub static nsGkAtoms_scrollbar_thumb_proportional: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms15images_in_menusE"]
pub static nsGkAtoms_images_in_menus: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms17images_in_buttonsE"]
pub static nsGkAtoms_images_in_buttons: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms18overlay_scrollbarsE"]
pub static nsGkAtoms_overlay_scrollbars: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms21windows_default_themeE"]
@ -4370,10 +4368,6 @@ cfg_if! {
pub static nsGkAtoms__moz_scrollbar_end_forward: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms33_moz_scrollbar_thumb_proportionalE"]
pub static nsGkAtoms__moz_scrollbar_thumb_proportional: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms20_moz_images_in_menusE"]
pub static nsGkAtoms__moz_images_in_menus: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms22_moz_images_in_buttonsE"]
pub static nsGkAtoms__moz_images_in_buttons: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms23_moz_overlay_scrollbarsE"]
pub static nsGkAtoms__moz_overlay_scrollbars: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms26_moz_windows_default_themeE"]
@ -6647,6 +6641,8 @@ cfg_if! {
pub static nsGkAtoms_onpopuphidden: *mut nsIAtom;
#[link_name = "?onpopuphiding@nsGkAtoms@@2PEAVnsIAtom@@EA"]
pub static nsGkAtoms_onpopuphiding: *mut nsIAtom;
#[link_name = "?onpopuppositioned@nsGkAtoms@@2PEAVnsIAtom@@EA"]
pub static nsGkAtoms_onpopuppositioned: *mut nsIAtom;
#[link_name = "?onpopupshowing@nsGkAtoms@@2PEAVnsIAtom@@EA"]
pub static nsGkAtoms_onpopupshowing: *mut nsIAtom;
#[link_name = "?onpopupshown@nsGkAtoms@@2PEAVnsIAtom@@EA"]
@ -9237,10 +9233,6 @@ cfg_if! {
pub static nsGkAtoms_scrollbar_end_forward: *mut nsIAtom;
#[link_name = "?scrollbar_thumb_proportional@nsGkAtoms@@2PEAVnsIAtom@@EA"]
pub static nsGkAtoms_scrollbar_thumb_proportional: *mut nsIAtom;
#[link_name = "?images_in_menus@nsGkAtoms@@2PEAVnsIAtom@@EA"]
pub static nsGkAtoms_images_in_menus: *mut nsIAtom;
#[link_name = "?images_in_buttons@nsGkAtoms@@2PEAVnsIAtom@@EA"]
pub static nsGkAtoms_images_in_buttons: *mut nsIAtom;
#[link_name = "?overlay_scrollbars@nsGkAtoms@@2PEAVnsIAtom@@EA"]
pub static nsGkAtoms_overlay_scrollbars: *mut nsIAtom;
#[link_name = "?windows_default_theme@nsGkAtoms@@2PEAVnsIAtom@@EA"]
@ -9291,10 +9283,6 @@ cfg_if! {
pub static nsGkAtoms__moz_scrollbar_end_forward: *mut nsIAtom;
#[link_name = "?_moz_scrollbar_thumb_proportional@nsGkAtoms@@2PEAVnsIAtom@@EA"]
pub static nsGkAtoms__moz_scrollbar_thumb_proportional: *mut nsIAtom;
#[link_name = "?_moz_images_in_menus@nsGkAtoms@@2PEAVnsIAtom@@EA"]
pub static nsGkAtoms__moz_images_in_menus: *mut nsIAtom;
#[link_name = "?_moz_images_in_buttons@nsGkAtoms@@2PEAVnsIAtom@@EA"]
pub static nsGkAtoms__moz_images_in_buttons: *mut nsIAtom;
#[link_name = "?_moz_overlay_scrollbars@nsGkAtoms@@2PEAVnsIAtom@@EA"]
pub static nsGkAtoms__moz_overlay_scrollbars: *mut nsIAtom;
#[link_name = "?_moz_windows_default_theme@nsGkAtoms@@2PEAVnsIAtom@@EA"]
@ -11568,6 +11556,8 @@ cfg_if! {
pub static nsGkAtoms_onpopuphidden: *mut nsIAtom;
#[link_name = "\x01?onpopuphiding@nsGkAtoms@@2PAVnsIAtom@@A"]
pub static nsGkAtoms_onpopuphiding: *mut nsIAtom;
#[link_name = "\x01?onpopuppositioned@nsGkAtoms@@2PAVnsIAtom@@A"]
pub static nsGkAtoms_onpopuppositioned: *mut nsIAtom;
#[link_name = "\x01?onpopupshowing@nsGkAtoms@@2PAVnsIAtom@@A"]
pub static nsGkAtoms_onpopupshowing: *mut nsIAtom;
#[link_name = "\x01?onpopupshown@nsGkAtoms@@2PAVnsIAtom@@A"]
@ -14158,10 +14148,6 @@ cfg_if! {
pub static nsGkAtoms_scrollbar_end_forward: *mut nsIAtom;
#[link_name = "\x01?scrollbar_thumb_proportional@nsGkAtoms@@2PAVnsIAtom@@A"]
pub static nsGkAtoms_scrollbar_thumb_proportional: *mut nsIAtom;
#[link_name = "\x01?images_in_menus@nsGkAtoms@@2PAVnsIAtom@@A"]
pub static nsGkAtoms_images_in_menus: *mut nsIAtom;
#[link_name = "\x01?images_in_buttons@nsGkAtoms@@2PAVnsIAtom@@A"]
pub static nsGkAtoms_images_in_buttons: *mut nsIAtom;
#[link_name = "\x01?overlay_scrollbars@nsGkAtoms@@2PAVnsIAtom@@A"]
pub static nsGkAtoms_overlay_scrollbars: *mut nsIAtom;
#[link_name = "\x01?windows_default_theme@nsGkAtoms@@2PAVnsIAtom@@A"]
@ -14212,10 +14198,6 @@ cfg_if! {
pub static nsGkAtoms__moz_scrollbar_end_forward: *mut nsIAtom;
#[link_name = "\x01?_moz_scrollbar_thumb_proportional@nsGkAtoms@@2PAVnsIAtom@@A"]
pub static nsGkAtoms__moz_scrollbar_thumb_proportional: *mut nsIAtom;
#[link_name = "\x01?_moz_images_in_menus@nsGkAtoms@@2PAVnsIAtom@@A"]
pub static nsGkAtoms__moz_images_in_menus: *mut nsIAtom;
#[link_name = "\x01?_moz_images_in_buttons@nsGkAtoms@@2PAVnsIAtom@@A"]
pub static nsGkAtoms__moz_images_in_buttons: *mut nsIAtom;
#[link_name = "\x01?_moz_overlay_scrollbars@nsGkAtoms@@2PAVnsIAtom@@A"]
pub static nsGkAtoms__moz_overlay_scrollbars: *mut nsIAtom;
#[link_name = "\x01?_moz_windows_default_theme@nsGkAtoms@@2PAVnsIAtom@@A"]
@ -15639,6 +15621,7 @@ macro_rules! atom {
("onpointerlockerror") => { $crate::string_cache::atom_macro::unsafe_atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_onpointerlockerror as *mut _) };
("onpopuphidden") => { $crate::string_cache::atom_macro::unsafe_atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_onpopuphidden as *mut _) };
("onpopuphiding") => { $crate::string_cache::atom_macro::unsafe_atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_onpopuphiding as *mut _) };
("onpopuppositioned") => { $crate::string_cache::atom_macro::unsafe_atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_onpopuppositioned as *mut _) };
("onpopupshowing") => { $crate::string_cache::atom_macro::unsafe_atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_onpopupshowing as *mut _) };
("onpopupshown") => { $crate::string_cache::atom_macro::unsafe_atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_onpopupshown as *mut _) };
("onposter") => { $crate::string_cache::atom_macro::unsafe_atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_onposter as *mut _) };
@ -16934,8 +16917,6 @@ macro_rules! atom {
("scrollbar-end-backward") => { $crate::string_cache::atom_macro::unsafe_atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_scrollbar_end_backward as *mut _) };
("scrollbar-end-forward") => { $crate::string_cache::atom_macro::unsafe_atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_scrollbar_end_forward as *mut _) };
("scrollbar-thumb-proportional") => { $crate::string_cache::atom_macro::unsafe_atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_scrollbar_thumb_proportional as *mut _) };
("images-in-menus") => { $crate::string_cache::atom_macro::unsafe_atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_images_in_menus as *mut _) };
("images-in-buttons") => { $crate::string_cache::atom_macro::unsafe_atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_images_in_buttons as *mut _) };
("overlay-scrollbars") => { $crate::string_cache::atom_macro::unsafe_atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_overlay_scrollbars as *mut _) };
("windows-default-theme") => { $crate::string_cache::atom_macro::unsafe_atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_windows_default_theme as *mut _) };
("mac-graphite-theme") => { $crate::string_cache::atom_macro::unsafe_atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_mac_graphite_theme as *mut _) };
@ -16961,8 +16942,6 @@ macro_rules! atom {
("-moz-scrollbar-end-backward") => { $crate::string_cache::atom_macro::unsafe_atom_from_static($crate::string_cache::atom_macro::nsGkAtoms__moz_scrollbar_end_backward as *mut _) };
("-moz-scrollbar-end-forward") => { $crate::string_cache::atom_macro::unsafe_atom_from_static($crate::string_cache::atom_macro::nsGkAtoms__moz_scrollbar_end_forward as *mut _) };
("-moz-scrollbar-thumb-proportional") => { $crate::string_cache::atom_macro::unsafe_atom_from_static($crate::string_cache::atom_macro::nsGkAtoms__moz_scrollbar_thumb_proportional as *mut _) };
("-moz-images-in-menus") => { $crate::string_cache::atom_macro::unsafe_atom_from_static($crate::string_cache::atom_macro::nsGkAtoms__moz_images_in_menus as *mut _) };
("-moz-images-in-buttons") => { $crate::string_cache::atom_macro::unsafe_atom_from_static($crate::string_cache::atom_macro::nsGkAtoms__moz_images_in_buttons as *mut _) };
("-moz-overlay-scrollbars") => { $crate::string_cache::atom_macro::unsafe_atom_from_static($crate::string_cache::atom_macro::nsGkAtoms__moz_overlay_scrollbars as *mut _) };
("-moz-windows-default-theme") => { $crate::string_cache::atom_macro::unsafe_atom_from_static($crate::string_cache::atom_macro::nsGkAtoms__moz_windows_default_theme as *mut _) };
("-moz-mac-graphite-theme") => { $crate::string_cache::atom_macro::unsafe_atom_from_static($crate::string_cache::atom_macro::nsGkAtoms__moz_mac_graphite_theme as *mut _) };

View File

@ -195,20 +195,20 @@ pub struct ${style_struct.gecko_struct_name} {
</%def>
<%!
def is_border_style_masked(ffi_name):
return ffi_name.split("[")[0] in ["mBorderStyle", "mOutlineStyle", "mTextDecorationStyle"]
def get_gecko_property(ffi_name):
if is_border_style_masked(ffi_name):
return "(self.gecko.%s & (structs::BORDER_STYLE_MASK as u8))" % ffi_name
return "self.gecko.%s" % ffi_name
def get_gecko_property(ffi_name, self_param = "self"):
if "mBorderColor" in ffi_name:
return ffi_name.replace("mBorderColor",
"unsafe { *%s.gecko.__bindgen_anon_1.mBorderColor.as_ref() }"
% self_param)
return "%s.gecko.%s" % (self_param, ffi_name)
def set_gecko_property(ffi_name, expr):
if is_border_style_masked(ffi_name):
return "self.gecko.%s &= !(structs::BORDER_STYLE_MASK as u8);" % ffi_name + \
"self.gecko.%s |= %s as u8;" % (ffi_name, expr)
elif ffi_name == "__LIST_STYLE_TYPE__":
if ffi_name == "__LIST_STYLE_TYPE__":
return "unsafe { Gecko_SetListStyleType(&mut self.gecko, %s as u32); }" % expr
if "mBorderColor" in ffi_name:
ffi_name = ffi_name.replace("mBorderColor",
"*self.gecko.__bindgen_anon_1.mBorderColor.as_mut()")
return "unsafe { %s = %s };" % (ffi_name, expr)
return "self.gecko.%s = %s;" % (ffi_name, expr)
%>
@ -240,71 +240,41 @@ def set_gecko_property(ffi_name, expr):
}
</%def>
<%def name="clear_color_flags(color_flags_ffi_name)">
% if color_flags_ffi_name:
self.gecko.${color_flags_ffi_name} &= !(structs::BORDER_COLOR_SPECIAL as u8);
% endif
</%def>
<%def name="set_current_color_flag(color_flags_ffi_name)">
% if color_flags_ffi_name:
self.gecko.${color_flags_ffi_name} |= structs::BORDER_COLOR_FOREGROUND as u8;
% else:
// FIXME(heycam): This is a Gecko property that doesn't store currentColor
// as a computed value. These are currently handled by converting
// currentColor to the current value of the color property at computed
// value time, but we don't have access to the Color struct here.
// In the longer term, Gecko should store currentColor as a computed
// value, so that we don't need to do this:
// https://bugzilla.mozilla.org/show_bug.cgi?id=760345
warn!("stylo: mishandling currentColor");
% endif
</%def>
<%def name="get_current_color_flag_from(field)">
(${field} & (structs::BORDER_COLOR_FOREGROUND as u8)) != 0
</%def>
<%def name="impl_color_setter(ident, gecko_ffi_name, color_flags_ffi_name=None)">
<%def name="impl_color_setter(ident, gecko_ffi_name, complex_color=True)">
#[allow(unreachable_code)]
#[allow(non_snake_case)]
pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
use cssparser::Color;
${clear_color_flags(color_flags_ffi_name)}
let result = match v {
Color::CurrentColor => {
${set_current_color_flag(color_flags_ffi_name)}
0
},
Color::RGBA(rgba) => convert_rgba_to_nscolor(&rgba),
};
% if complex_color:
let result = v.into();
% else:
use cssparser::Color;
let result = match v {
Color::RGBA(rgba) => convert_rgba_to_nscolor(&rgba),
// FIXME #13547
Color::CurrentColor => 0,
};
% endif
${set_gecko_property(gecko_ffi_name, "result")}
}
</%def>
<%def name="impl_color_copy(ident, gecko_ffi_name, color_flags_ffi_name=None)">
<%def name="impl_color_copy(ident, gecko_ffi_name, complex_color=True)">
#[allow(non_snake_case)]
pub fn copy_${ident}_from(&mut self, other: &Self) {
% if color_flags_ffi_name:
${clear_color_flags(color_flags_ffi_name)}
if ${get_current_color_flag_from("other.gecko." + color_flags_ffi_name)} {
${set_current_color_flag(color_flags_ffi_name)}
}
% endif
self.gecko.${gecko_ffi_name} = other.gecko.${gecko_ffi_name}
let color = ${get_gecko_property(gecko_ffi_name, self_param = "other")};
${set_gecko_property(gecko_ffi_name, "color")};
}
</%def>
<%def name="impl_color_clone(ident, gecko_ffi_name, color_flags_ffi_name=None)">
<%def name="impl_color_clone(ident, gecko_ffi_name, complex_color=True)">
#[allow(non_snake_case)]
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
use cssparser::Color;
% if color_flags_ffi_name:
if ${get_current_color_flag_from("self.gecko." + color_flags_ffi_name)} {
return Color::CurrentColor
}
% if complex_color:
${get_gecko_property(gecko_ffi_name)}.into()
% else:
use cssparser::Color;
Color::RGBA(convert_nscolor_to_rgba(${get_gecko_property(gecko_ffi_name)}))
% endif
Color::RGBA(convert_nscolor_to_rgba(${get_gecko_property(gecko_ffi_name)}))
}
</%def>
@ -324,11 +294,11 @@ def set_gecko_property(ffi_name, expr):
% endif
</%def>
<%def name="impl_color(ident, gecko_ffi_name, color_flags_ffi_name=None, need_clone=False)">
<%call expr="impl_color_setter(ident, gecko_ffi_name, color_flags_ffi_name)"></%call>
<%call expr="impl_color_copy(ident, gecko_ffi_name, color_flags_ffi_name)"></%call>
<%def name="impl_color(ident, gecko_ffi_name, need_clone=False, complex_color=True)">
<%call expr="impl_color_setter(ident, gecko_ffi_name, complex_color)"></%call>
<%call expr="impl_color_copy(ident, gecko_ffi_name, complex_color)"></%call>
% if need_clone:
<%call expr="impl_color_clone(ident, gecko_ffi_name, color_flags_ffi_name)"></%call>
<%call expr="impl_color_clone(ident, gecko_ffi_name, complex_color)"></%call>
% endif
</%def>
@ -645,8 +615,7 @@ fn static_assert() {
<% impl_keyword("border_%s_style" % side.ident, "mBorderStyle[%s]" % side.index, border_style_keyword,
need_clone=True) %>
<% impl_color("border_%s_color" % side.ident, "mBorderColor[%s]" % side.index,
color_flags_ffi_name="mBorderStyle[%s]" % side.index, need_clone=True) %>
<% impl_color("border_%s_color" % side.ident, "(mBorderColor)[%s]" % side.index, need_clone=True) %>
<% impl_app_units("border_%s_width" % side.ident, "mComputedBorder.%s" % side.ident, need_clone=True,
round_to_pixels=True) %>
@ -752,7 +721,7 @@ fn static_assert() {
<% impl_keyword("outline_style", "mOutlineStyle", border_style_keyword, need_clone=True) %>
<% impl_color("outline_color", "mOutlineColor", color_flags_ffi_name="mOutlineStyle", need_clone=True) %>
<% impl_color("outline_color", "mOutlineColor", need_clone=True) %>
<% impl_app_units("outline_width", "mActualOutlineWidth", need_clone=True,
round_to_pixels=True) %>
@ -1365,7 +1334,7 @@ fn static_assert() {
skip_longhands="${skip_background_longhands}"
skip_additionals="*">
<% impl_color("background_color", "mBackgroundColor", need_clone=True) %>
<% impl_color("background_color", "mBackgroundColor", need_clone=True, complex_color=False) %>
<% impl_common_image_layer_properties("background") %>
@ -1569,8 +1538,7 @@ fn static_assert() {
skip_longhands="text-decoration-color text-decoration-line"
skip_additionals="*">
${impl_color("text_decoration_color", "mTextDecorationColor",
color_flags_ffi_name="mTextDecorationStyle", need_clone=True)}
${impl_color("text_decoration_color", "mTextDecorationColor", need_clone=True)}
pub fn set_text_decoration_line(&mut self, v: longhands::text_decoration_line::computed_value::T) {
let mut bits: u8 = 0;
@ -1614,11 +1582,11 @@ clip-path
skip_longhands="${skip_svg_longhands}"
skip_additionals="*">
<% impl_color("flood_color", "mFloodColor") %>
<% impl_color("flood_color", "mFloodColor", complex_color=False) %>
<% impl_color("lighting_color", "mLightingColor") %>
<% impl_color("lighting_color", "mLightingColor", complex_color=False) %>
<% impl_color("stop_color", "mStopColor") %>
<% impl_color("stop_color", "mStopColor", complex_color=False) %>
<% impl_common_image_layer_properties("mask") %>