mirror of
https://github.com/servo/servo.git
synced 2025-08-10 07:55:33 +01:00
Auto merge of #18085 - dadaa:make-content-animatable, r=hiro
Make content animatable <!-- 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 <!-- Either: --> - [X] There are tests for these changes. The test codes are patch part 3 and 4 in https://bugzilla.mozilla.org/show_bug.cgi?id=1382136 <!-- 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. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18085) <!-- Reviewable:end -->
This commit is contained in:
commit
41fb10c589
4 changed files with 94 additions and 16 deletions
|
@ -5579,6 +5579,80 @@ clip-path
|
|||
self.copy_content_from(other)
|
||||
}
|
||||
|
||||
pub fn clone_content(&self) -> longhands::content::computed_value::T {
|
||||
use gecko::conversions::string_from_chars_pointer;
|
||||
use gecko_bindings::structs::nsStyleContentType::*;
|
||||
use properties::longhands::content::computed_value::{T, ContentItem};
|
||||
use values::generics::CounterStyleOrNone;
|
||||
use values::specified::url::SpecifiedUrl;
|
||||
use values::specified::Attr;
|
||||
|
||||
if self.gecko.mContents.is_empty() {
|
||||
return T::Normal;
|
||||
}
|
||||
|
||||
if self.gecko.mContents.len() == 1 &&
|
||||
self.gecko.mContents[0].mType == eStyleContentType_AltContent {
|
||||
return T::MozAltContent;
|
||||
}
|
||||
|
||||
T::Items(
|
||||
self.gecko.mContents.iter().map(|gecko_content| {
|
||||
match gecko_content.mType {
|
||||
eStyleContentType_OpenQuote => ContentItem::OpenQuote,
|
||||
eStyleContentType_CloseQuote => ContentItem::CloseQuote,
|
||||
eStyleContentType_NoOpenQuote => ContentItem::NoOpenQuote,
|
||||
eStyleContentType_NoCloseQuote => ContentItem::NoCloseQuote,
|
||||
eStyleContentType_String => {
|
||||
let gecko_chars = unsafe { gecko_content.mContent.mString.as_ref() };
|
||||
let string = unsafe { string_from_chars_pointer(*gecko_chars) };
|
||||
ContentItem::String(string)
|
||||
},
|
||||
eStyleContentType_Attr => {
|
||||
let gecko_chars = unsafe { gecko_content.mContent.mString.as_ref() };
|
||||
let string = unsafe { string_from_chars_pointer(*gecko_chars) };
|
||||
let (namespace, attribute) =
|
||||
match string.find('|') {
|
||||
None => (None, string),
|
||||
Some(index) => {
|
||||
let (_, val) = string.split_at(index);
|
||||
// FIXME: We should give NamespaceId as well to make Attr
|
||||
// struct. However, there is no field for it in Gecko.
|
||||
debug_assert!(false, "Attr with namespace does not support yet");
|
||||
(None, val.to_string())
|
||||
}
|
||||
};
|
||||
ContentItem::Attr(Attr { namespace, attribute })
|
||||
},
|
||||
eStyleContentType_Counter | eStyleContentType_Counters => {
|
||||
let gecko_function =
|
||||
unsafe { &**gecko_content.mContent.mCounters.as_ref() };
|
||||
let ident = gecko_function.mIdent.to_string();
|
||||
let style =
|
||||
CounterStyleOrNone::from_gecko_value(&gecko_function.mCounterStyle);
|
||||
if gecko_content.mType == eStyleContentType_Counter {
|
||||
ContentItem::Counter(ident, style)
|
||||
} else {
|
||||
let separator = gecko_function.mSeparator.to_string();
|
||||
ContentItem::Counters(ident, separator, style)
|
||||
}
|
||||
},
|
||||
eStyleContentType_Image => {
|
||||
unsafe {
|
||||
let gecko_image_request =
|
||||
unsafe { &**gecko_content.mContent.mImage.as_ref() };
|
||||
ContentItem::Url(
|
||||
SpecifiedUrl::from_image_request(gecko_image_request)
|
||||
.expect("mContent could not convert to SpecifiedUrl")
|
||||
)
|
||||
}
|
||||
},
|
||||
x => panic!("Found unexpected value in style struct for content property: {:?}", x),
|
||||
}
|
||||
}).collect()
|
||||
)
|
||||
}
|
||||
|
||||
% for counter_property in ["Increment", "Reset"]:
|
||||
pub fn set_counter_${counter_property.lower()}(&mut self, v: longhands::counter_increment::computed_value::T) {
|
||||
unsafe {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue