Upgrade stylo to 2024-05-31 (#32474)

* Upgrade stylo to 2024-05-31

* Fixup for https://phabricator.services.mozilla.com/D211731

* Fixup for https://phabricator.services.mozilla.com/D207779

* Fixup for https://phabricator.services.mozilla.com/D207781

* Update test expectations
This commit is contained in:
Oriol Brufau 2024-06-24 22:03:50 +02:00 committed by GitHub
parent 680735ed73
commit b1fdfb88bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 45 additions and 49 deletions

View file

@ -6,7 +6,7 @@ use std::borrow::Cow;
use std::char::{ToLowercase, ToUppercase};
use style::computed_values::white_space_collapse::T as WhiteSpaceCollapse;
use style::values::computed::{TextDecorationLine, TextTransform};
use style::values::computed::TextDecorationLine;
use style::values::specified::text::TextTransformCase;
use unicode_segmentation::UnicodeSegmentation;
@ -185,10 +185,13 @@ impl InlineFormattingContextBuilder {
self.last_inline_box_ended_with_collapsible_white_space,
);
let text_transform = info.style.clone_text_transform();
// TODO: Not all text transforms are about case, this logic should stop ignoring
// TextTransform::FULL_WIDTH and TextTransform::FULL_SIZE_KANA.
let text_transform = info.style.clone_text_transform().case();
let capitalized_text: String;
let char_iterator: Box<dyn Iterator<Item = char>> =
if text_transform.case_ == TextTransformCase::Capitalize {
let char_iterator: Box<dyn Iterator<Item = char>> = match text_transform {
TextTransformCase::None => Box::new(collapsed),
TextTransformCase::Capitalize => {
// `TextTransformation` doesn't support capitalization, so we must capitalize the whole
// string at once and make a copy. Here `on_word_boundary` indicates whether or not the
// inline formatting context as a whole is on a word boundary. This is different from
@ -198,13 +201,13 @@ impl InlineFormattingContextBuilder {
let collapsed_string: String = collapsed.collect();
capitalized_text = capitalize_string(&collapsed_string, self.on_word_boundary);
Box::new(capitalized_text.chars())
} else if !text_transform.is_none() {
},
_ => {
// If `text-transform` is active, wrap the `WhitespaceCollapse` iterator in
// a `TextTransformation` iterator.
Box::new(TextTransformation::new(collapsed, text_transform))
} else {
Box::new(collapsed)
};
},
};
let white_space_collapse = info.style.clone_white_space_collapse();
let new_text: String = char_iterator
@ -509,14 +512,14 @@ pub struct TextTransformation<InputIterator> {
/// The input character iterator.
char_iterator: InputIterator,
/// The `text-transform` value to use.
text_transform: TextTransform,
text_transform: TextTransformCase,
/// If an uppercasing or lowercasing produces more than one character, this
/// caches them so that they can be returned in subsequent iterator calls.
pending_case_conversion_result: Option<PendingCaseConversionResult>,
}
impl<InputIterator> TextTransformation<InputIterator> {
pub fn new(char_iterator: InputIterator, text_transform: TextTransform) -> Self {
pub fn new(char_iterator: InputIterator, text_transform: TextTransformCase) -> Self {
Self {
char_iterator,
text_transform,
@ -542,7 +545,7 @@ where
self.pending_case_conversion_result = None;
for character in self.char_iterator.by_ref() {
match self.text_transform.case_ {
match self.text_transform {
TextTransformCase::None => return Some(character),
TextTransformCase::Uppercase => {
let mut pending_result =
@ -562,8 +565,7 @@ where
},
// `text-transform: capitalize` currently cannot work on a per-character basis,
// so must be handled outside of this iterator.
// TODO: Add support for `full-width` and `full-size-kana`.
_ => return Some(character),
TextTransformCase::Capitalize => return Some(character),
}
}
None