зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #18405 - Handle dynamic font color change (from pylbrecht:dynamic.attribute.change); r=emilio
<!-- Please describe your changes on the following line: --> <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #18371. <!-- Either: --> - [X] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> r? @emilio Source-Repo: https://github.com/servo/servo Source-Revision: 85167c8b7d2fb0e0e90283db750b601d789cd6ea --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : 82f46bacb30cbb8519e1e11f7231234bf9969ad7
This commit is contained in:
Родитель
a42d5a4889
Коммит
4ea8d57560
|
@ -88,6 +88,7 @@ use dom::touchevent::TouchEvent;
|
|||
use dom::touchlist::TouchList;
|
||||
use dom::treewalker::TreeWalker;
|
||||
use dom::uievent::UIEvent;
|
||||
use dom::virtualmethods::vtable_for;
|
||||
use dom::webglcontextevent::WebGLContextEvent;
|
||||
use dom::window::{ReflowReason, Window};
|
||||
use dom::windowproxy::WindowProxy;
|
||||
|
@ -2499,10 +2500,7 @@ impl Document {
|
|||
entry.hint.insert(RESTYLE_STYLE_ATTRIBUTE);
|
||||
}
|
||||
|
||||
// FIXME(emilio): This should become something like
|
||||
// element.is_attribute_mapped(attr.local_name()).
|
||||
if attr.local_name() == &local_name!("width") ||
|
||||
attr.local_name() == &local_name!("height") {
|
||||
if vtable_for(el.upcast()).attribute_is_mapped(attr) {
|
||||
entry.hint.insert(RESTYLE_SELF);
|
||||
}
|
||||
|
||||
|
|
|
@ -2303,6 +2303,16 @@ impl VirtualMethods for Element {
|
|||
Some(self.upcast::<Node>() as &VirtualMethods)
|
||||
}
|
||||
|
||||
fn attribute_is_mapped(&self, attr: &Attr) -> bool {
|
||||
// FIXME: This should be more fine-grained, not all elements care about these.
|
||||
if attr.local_name() == &local_name!("width") ||
|
||||
attr.local_name() == &local_name!("height") {
|
||||
return true;
|
||||
}
|
||||
|
||||
self.super_type().unwrap().attribute_is_mapped(attr)
|
||||
}
|
||||
|
||||
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
||||
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
||||
let node = self.upcast::<Node>();
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use cssparser::RGBA;
|
||||
use dom::attr::Attr;
|
||||
use dom::bindings::codegen::Bindings::HTMLFontElementBinding;
|
||||
use dom::bindings::codegen::Bindings::HTMLFontElementBinding::HTMLFontElementMethods;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
|
@ -70,6 +71,15 @@ impl VirtualMethods for HTMLFontElement {
|
|||
Some(self.upcast::<HTMLElement>() as &VirtualMethods)
|
||||
}
|
||||
|
||||
fn attribute_is_mapped(&self, attr: &Attr) -> bool {
|
||||
if attr.local_name() == &local_name!("color") {
|
||||
return true;
|
||||
}
|
||||
|
||||
// FIXME: Should also return true for `size` and `face` changes!
|
||||
self.super_type().unwrap().attribute_is_mapped(attr)
|
||||
}
|
||||
|
||||
fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
|
||||
match name {
|
||||
&local_name!("face") => AttrValue::from_atomic(value.into()),
|
||||
|
|
|
@ -70,6 +70,15 @@ pub trait VirtualMethods {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if given attribute `attr` affects style of the
|
||||
/// given element.
|
||||
fn attribute_is_mapped(&self, attr: &Attr) -> bool {
|
||||
match self.super_type() {
|
||||
Some(s) => s.attribute_is_mapped(attr),
|
||||
None => false
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the right AttrValue variant for the attribute with name `name`
|
||||
/// on this element.
|
||||
fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
|
||||
|
|
Загрузка…
Ссылка в новой задаче