Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: sync changes from mozilla-central #23503

Merged
merged 17 commits into from Jun 4, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -1489,7 +1489,7 @@ impl Fragment {
state.add_display_item(DisplayItem::Rectangle(CommonDisplayItem::new(
base,
webrender_api::RectangleDisplayItem {
color: self.style().get_color().color.to_layout(),
color: self.style().get_inherited_text().color.to_layout(),
},
)));
}
@@ -1967,9 +1967,9 @@ impl Fragment {
// TODO(emilio): Allow changing more properties by ::selection
// Paint the text with the color as described in its styling.
let text_color = if text_fragment.selected() {
self.selected_style().get_color().color
self.selected_style().get_inherited_text().color
} else {
self.style().get_color().color
self.style().get_inherited_text().color
};

// Determine the orientation and cursor to use.
@@ -1519,7 +1519,7 @@ impl Fragment {
}

pub fn color(&self) -> Color {
self.style().get_color().color
self.style().get_inherited_text().color
}

/// Returns the text decoration line of this fragment, according to the style of the nearest ancestor
@@ -715,6 +715,14 @@ impl<'le> TElement for ServoLayoutElement<'le> {
.map(ServoShadowRoot::from_layout_js)
}
}

fn local_name(&self) -> &LocalName {
self.element.local_name()
}

fn namespace(&self) -> &Namespace {
self.element.namespace()
}
}

impl<'le> PartialEq for ServoLayoutElement<'le> {
@@ -879,13 +887,19 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
}

#[inline]
fn local_name(&self) -> &LocalName {
self.element.local_name()
fn has_local_name(&self, name: &LocalName) -> bool {
self.element.local_name() == name
}

#[inline]
fn namespace(&self) -> &Namespace {
self.element.namespace()
fn has_namespace(&self, ns: &Namespace) -> bool {
self.element.namespace() == ns
}

#[inline]
fn is_same_type(&self, other: &Self) -> bool {
self.element.local_name() == other.element.local_name() &&
self.element.namespace() == other.element.namespace()
}

fn is_pseudo_element(&self) -> bool {
@@ -1266,8 +1280,8 @@ where
loop {
let next_node = if let Some(ref node) = current_node {
if let Some(element) = node.as_element() {
if element.local_name() == &local_name!("summary") &&
element.namespace() == &ns!(html)
if element.has_local_name(&local_name!("summary")) &&
element.has_namespace(&ns!(html))
{
self.current_node = None;
return Some(node.clone());
@@ -1286,8 +1300,10 @@ where
let node = self.current_node.clone();
let node = node.and_then(|node| {
if node.is_element() &&
node.as_element().unwrap().local_name() == &local_name!("summary") &&
node.as_element().unwrap().namespace() == &ns!(html)
node.as_element()
.unwrap()
.has_local_name(&local_name!("summary")) &&
node.as_element().unwrap().has_namespace(&ns!(html))
{
unsafe { node.dangerous_next_sibling() }
} else {
@@ -1437,13 +1453,19 @@ impl<'le> ::selectors::Element for ServoThreadSafeLayoutElement<'le> {
}

#[inline]
fn local_name(&self) -> &LocalName {
self.element.local_name()
fn has_local_name(&self, name: &LocalName) -> bool {
self.element.local_name() == name
}

#[inline]
fn namespace(&self) -> &Namespace {
self.element.namespace()
fn has_namespace(&self, ns: &Namespace) -> bool {
self.element.namespace() == ns
}

#[inline]
fn is_same_type(&self, other: &Self) -> bool {
self.element.local_name() == other.element.local_name() &&
self.element.namespace() == other.element.namespace()
}

fn match_pseudo_element(
@@ -260,7 +260,7 @@ impl CanvasState {

match canvas_element.style() {
Some(ref s) if canvas_element.has_css_layout_box() => {
Ok(s.get_color().color)
Ok(s.get_inherited_text().color)
},
_ => Ok(RGBA::new(0, 0, 0, 255)),
}
@@ -3004,12 +3004,17 @@ impl<'a> SelectorsElement for DomRoot<Element> {
})
}

fn local_name(&self) -> &LocalName {
Element::local_name(self)
fn has_local_name(&self, local_name: &LocalName) -> bool {
Element::local_name(self) == local_name
}

fn namespace(&self) -> &Namespace {
Element::namespace(self)
fn has_namespace(&self, ns: &Namespace) -> bool {
Element::namespace(self) == ns
}

fn is_same_type(&self, other: &Self) -> bool {
Element::local_name(self) == Element::local_name(other) &&
Element::namespace(self) == Element::namespace(other)
}

fn match_non_ts_pseudo_class<F>(
@@ -391,7 +391,7 @@ pub trait ThreadSafeLayoutElement:

#[inline]
fn get_details_summary_pseudo(&self) -> Option<Self> {
if self.local_name() == &local_name!("details") && self.namespace() == &ns!(html) {
if self.has_local_name(&local_name!("details")) && self.has_namespace(&ns!(html)) {
Some(self.with_pseudo(PseudoElementType::DetailsSummary))
} else {
None
@@ -400,8 +400,8 @@ pub trait ThreadSafeLayoutElement:

#[inline]
fn get_details_content_pseudo(&self) -> Option<Self> {
if self.local_name() == &local_name!("details") &&
self.namespace() == &ns!(html) &&
if self.has_local_name(&local_name!("details")) &&
self.has_namespace(&ns!(html)) &&
self.get_attr(&ns!(), &local_name!("open")).is_some()
{
Some(self.with_pseudo(PseudoElementType::DetailsContent))
@@ -596,7 +596,7 @@ where
&local_name.lower_name,
)
.borrow();
element.local_name() == name
element.has_local_name(name)
}

/// Determines whether the given element matches the given compound selector.
@@ -681,11 +681,11 @@ where
Component::LocalName(ref local_name) => matches_local_name(element, local_name),
Component::ExplicitUniversalType | Component::ExplicitAnyNamespace => true,
Component::Namespace(_, ref url) | Component::DefaultNamespace(ref url) => {
element.namespace() == url.borrow()
element.has_namespace(&url.borrow())
},
Component::ExplicitNoNamespace => {
let ns = crate::parser::namespace_empty_string::<E::Impl>();
element.namespace() == ns.borrow()
element.has_namespace(&ns.borrow())
},
Component::ID(ref id) => {
element.has_id(id, context.shared.classes_and_ids_case_sensitivity())
@@ -897,11 +897,6 @@ where
}
}

#[inline]
fn same_type<E: Element>(a: &E, b: &E) -> bool {
a.local_name() == b.local_name() && a.namespace() == b.namespace()
}

#[inline]
fn nth_child_index<E>(
element: &E,
@@ -924,7 +919,7 @@ where
let mut curr = element.clone();
while let Some(e) = curr.prev_sibling_element() {
curr = e;
if !is_of_type || same_type(element, &curr) {
if !is_of_type || element.is_same_type(&curr) {
if let Some(i) = c.lookup(curr.opaque()) {
return i - index;
}
@@ -945,7 +940,7 @@ where
};
while let Some(e) = next(curr) {
curr = e;
if !is_of_type || same_type(element, &curr) {
if !is_of_type || element.is_same_type(&curr) {
// If we're computing indices from the left, check each element in the
// cache. We handle the indices-from-the-right case at the top of this
// function.
@@ -62,10 +62,13 @@ pub trait Element: Sized + Clone + Debug {

fn is_html_element_in_html_document(&self) -> bool;

fn local_name(&self) -> &<Self::Impl as SelectorImpl>::BorrowedLocalName;
fn has_local_name(&self, local_name: &<Self::Impl as SelectorImpl>::BorrowedLocalName) -> bool;

/// Empty string for no namespace
fn namespace(&self) -> &<Self::Impl as SelectorImpl>::BorrowedNamespaceUrl;
fn has_namespace(&self, ns: &<Self::Impl as SelectorImpl>::BorrowedNamespaceUrl) -> bool;

/// Whether this element and the `other` element have the same local name and namespace.
fn is_same_type(&self, other: &Self) -> bool;

fn attr_matches(
&self,
@@ -12,6 +12,7 @@ path = "lib.rs"

[features]
servo = ["serde"]
gecko_refcount_logging = []

[dependencies]
nodrop = {version = "0.1.8"}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.