mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Rustfmt layout crate
This commit is contained in:
parent
577830de90
commit
349047b096
37 changed files with 7177 additions and 4832 deletions
|
@ -25,73 +25,103 @@ use text::TextRunScanner;
|
|||
use traversal::InorderFlowTraversal;
|
||||
|
||||
// Decimal styles per CSS-COUNTER-STYLES § 6.1:
|
||||
static DECIMAL: [char; 10] = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ];
|
||||
static DECIMAL: [char; 10] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
|
||||
// TODO(pcwalton): `decimal-leading-zero`
|
||||
static ARABIC_INDIC: [char; 10] = [ '٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩' ];
|
||||
static ARABIC_INDIC: [char; 10] = ['٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'];
|
||||
// TODO(pcwalton): `armenian`, `upper-armenian`, `lower-armenian`
|
||||
static BENGALI: [char; 10] = [ '০', '১', '২', '৩', '৪', '৫', '৬', '৭', '৮', '৯' ];
|
||||
static CAMBODIAN: [char; 10] = [ '០', '១', '២', '៣', '៤', '៥', '៦', '៧', '៨', '៩' ];
|
||||
static BENGALI: [char; 10] = [
|
||||
'০', '১', '২', '৩', '৪', '৫', '৬', '৭', '৮', '৯',
|
||||
];
|
||||
static CAMBODIAN: [char; 10] = [
|
||||
'០', '១', '២', '៣', '៤', '៥', '៦', '៧', '៨', '៩',
|
||||
];
|
||||
// TODO(pcwalton): Suffix for CJK decimal.
|
||||
static CJK_DECIMAL: [char; 10] = [ '〇', '一', '二', '三', '四', '五', '六', '七', '八', '九' ];
|
||||
static DEVANAGARI: [char; 10] = [ '०', '१', '२', '३', '४', '५', '६', '७', '८', '९' ];
|
||||
static CJK_DECIMAL: [char; 10] = [
|
||||
'〇', '一', '二', '三', '四', '五', '六', '七', '八', '九',
|
||||
];
|
||||
static DEVANAGARI: [char; 10] = [
|
||||
'०', '१', '२', '३', '४', '५', '६', '७', '८', '९',
|
||||
];
|
||||
// TODO(pcwalton): `georgian`
|
||||
static GUJARATI: [char; 10] = ['૦', '૧', '૨', '૩', '૪', '૫', '૬', '૭', '૮', '૯'];
|
||||
static GURMUKHI: [char; 10] = ['੦', '੧', '੨', '੩', '੪', '੫', '੬', '੭', '੮', '੯'];
|
||||
static GUJARATI: [char; 10] = [
|
||||
'૦', '૧', '૨', '૩', '૪', '૫', '૬', '૭', '૮', '૯',
|
||||
];
|
||||
static GURMUKHI: [char; 10] = [
|
||||
'੦', '੧', '੨', '੩', '੪', '੫', '੬', '੭', '੮', '੯',
|
||||
];
|
||||
// TODO(pcwalton): `hebrew`
|
||||
static KANNADA: [char; 10] = ['೦', '೧', '೨', '೩', '೪', '೫', '೬', '೭', '೮', '೯'];
|
||||
static LAO: [char; 10] = ['໐', '໑', '໒', '໓', '໔', '໕', '໖', '໗', '໘', '໙'];
|
||||
static MALAYALAM: [char; 10] = ['൦', '൧', '൨', '൩', '൪', '൫', '൬', '൭', '൮', '൯'];
|
||||
static MONGOLIAN: [char; 10] = ['᠐', '᠑', '᠒', '᠓', '᠔', '᠕', '᠖', '᠗', '᠘', '᠙'];
|
||||
static MYANMAR: [char; 10] = ['၀', '၁', '၂', '၃', '၄', '၅', '၆', '၇', '၈', '၉'];
|
||||
static ORIYA: [char; 10] = ['୦', '୧', '୨', '୩', '୪', '୫', '୬', '୭', '୮', '୯'];
|
||||
static KANNADA: [char; 10] = [
|
||||
'೦', '೧', '೨', '೩', '೪', '೫', '೬', '೭', '೮', '೯',
|
||||
];
|
||||
static LAO: [char; 10] = [
|
||||
'໐', '໑', '໒', '໓', '໔', '໕', '໖', '໗', '໘', '໙',
|
||||
];
|
||||
static MALAYALAM: [char; 10] = [
|
||||
'൦', '൧', '൨', '൩', '൪', '൫', '൬', '൭', '൮', '൯',
|
||||
];
|
||||
static MONGOLIAN: [char; 10] = [
|
||||
'᠐', '᠑', '᠒', '᠓', '᠔', '᠕', '᠖', '᠗', '᠘', '᠙',
|
||||
];
|
||||
static MYANMAR: [char; 10] = [
|
||||
'၀', '၁', '၂', '၃', '၄', '၅', '၆', '၇', '၈', '၉',
|
||||
];
|
||||
static ORIYA: [char; 10] = [
|
||||
'୦', '୧', '୨', '୩', '୪', '୫', '୬', '୭', '୮', '୯',
|
||||
];
|
||||
static PERSIAN: [char; 10] = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'];
|
||||
// TODO(pcwalton): `lower-roman`, `upper-roman`
|
||||
static TELUGU: [char; 10] = ['౦', '౧', '౨', '౩', '౪', '౫', '౬', '౭', '౮', '౯'];
|
||||
static THAI: [char; 10] = ['๐', '๑', '๒', '๓', '๔', '๕', '๖', '๗', '๘', '๙'];
|
||||
static TIBETAN: [char; 10] = ['༠', '༡', '༢', '༣', '༤', '༥', '༦', '༧', '༨', '༩'];
|
||||
static TELUGU: [char; 10] = [
|
||||
'౦', '౧', '౨', '౩', '౪', '౫', '౬', '౭', '౮', '౯',
|
||||
];
|
||||
static THAI: [char; 10] = [
|
||||
'๐', '๑', '๒', '๓', '๔', '๕', '๖', '๗', '๘', '๙',
|
||||
];
|
||||
static TIBETAN: [char; 10] = [
|
||||
'༠', '༡', '༢', '༣', '༤', '༥', '༦', '༧', '༨', '༩',
|
||||
];
|
||||
|
||||
// Alphabetic styles per CSS-COUNTER-STYLES § 6.2:
|
||||
static LOWER_ALPHA: [char; 26] = [
|
||||
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
|
||||
't', 'u', 'v', 'w', 'x', 'y', 'z'
|
||||
't', 'u', 'v', 'w', 'x', 'y', 'z',
|
||||
];
|
||||
static UPPER_ALPHA: [char; 26] = [
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
|
||||
'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
|
||||
'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
||||
];
|
||||
static CJK_EARTHLY_BRANCH: [char; 12] = [
|
||||
'子', '丑', '寅', '卯', '辰', '巳', '午', '未', '申', '酉', '戌', '亥'
|
||||
'子', '丑', '寅', '卯', '辰', '巳', '午', '未', '申', '酉', '戌', '亥',
|
||||
];
|
||||
static CJK_HEAVENLY_STEM: [char; 10] = [
|
||||
'甲', '乙', '丙', '丁', '戊', '己', '庚', '辛', '壬', '癸'
|
||||
'甲', '乙', '丙', '丁', '戊', '己', '庚', '辛', '壬', '癸',
|
||||
];
|
||||
static LOWER_GREEK: [char; 24] = [
|
||||
'α', 'β', 'γ', 'δ', 'ε', 'ζ', 'η', 'θ', 'ι', 'κ', 'λ', 'μ', 'ν', 'ξ', 'ο', 'π', 'ρ', 'σ', 'τ',
|
||||
'υ', 'φ', 'χ', 'ψ', 'ω'
|
||||
'α', 'β', 'γ', 'δ', 'ε', 'ζ', 'η', 'θ', 'ι', 'κ', 'λ', 'μ', 'ν', 'ξ', 'ο', 'π',
|
||||
'ρ', 'σ', 'τ', 'υ', 'φ', 'χ', 'ψ', 'ω',
|
||||
];
|
||||
static HIRAGANA: [char; 48] = [
|
||||
'あ', 'い', 'う', 'え', 'お', 'か', 'き', 'く', 'け', 'こ', 'さ', 'し', 'す', 'せ', 'そ',
|
||||
'た', 'ち', 'つ', 'て', 'と', 'な', 'に', 'ぬ', 'ね', 'の', 'は', 'ひ', 'ふ', 'へ', 'ほ',
|
||||
'ま', 'み', 'む', 'め', 'も', 'や', 'ゆ', 'よ', 'ら', 'り', 'る', 'れ', 'ろ',
|
||||
'わ', 'ゐ', 'ゑ', 'を', 'ん'
|
||||
'あ', 'い', 'う', 'え', 'お', 'か', 'き', 'く', 'け', 'こ', 'さ', 'し', 'す',
|
||||
'せ', 'そ', 'た', 'ち', 'つ', 'て', 'と', 'な', 'に', 'ぬ', 'ね', 'の', 'は',
|
||||
'ひ', 'ふ', 'へ', 'ほ', 'ま', 'み', 'む', 'め', 'も', 'や', 'ゆ', 'よ', 'ら',
|
||||
'り', 'る', 'れ', 'ろ', 'わ', 'ゐ', 'ゑ', 'を', 'ん',
|
||||
];
|
||||
static HIRAGANA_IROHA: [char; 47] = [
|
||||
'い', 'ろ', 'は', 'に', 'ほ', 'へ', 'と', 'ち', 'り', 'ぬ', 'る', 'を', 'わ', 'か', 'よ',
|
||||
'た', 'れ', 'そ', 'つ', 'ね', 'な', 'ら', 'む', 'う', 'ゐ', 'の', 'お', 'く', 'や', 'ま',
|
||||
'け', 'ふ', 'こ', 'え', 'て', 'あ', 'さ', 'き', 'ゆ', 'め', 'み', 'し', 'ゑ',
|
||||
'ひ', 'も', 'せ', 'す'
|
||||
'い', 'ろ', 'は', 'に', 'ほ', 'へ', 'と', 'ち', 'り', 'ぬ', 'る', 'を', 'わ',
|
||||
'か', 'よ', 'た', 'れ', 'そ', 'つ', 'ね', 'な', 'ら', 'む', 'う', 'ゐ', 'の',
|
||||
'お', 'く', 'や', 'ま', 'け', 'ふ', 'こ', 'え', 'て', 'あ', 'さ', 'き', 'ゆ',
|
||||
'め', 'み', 'し', 'ゑ', 'ひ', 'も', 'せ', 'す',
|
||||
];
|
||||
static KATAKANA: [char; 48] = [
|
||||
'ア', 'イ', 'ウ', 'エ', 'オ', 'カ', 'キ', 'ク', 'ケ', 'コ', 'サ', 'シ', 'ス', 'セ', 'ソ',
|
||||
'タ', 'チ', 'ツ', 'テ', 'ト', 'ナ', 'ニ', 'ヌ', 'ネ', 'ノ', 'ハ', 'ヒ', 'フ', 'ヘ', 'ホ',
|
||||
'マ', 'ミ', 'ム', 'メ', 'モ', 'ヤ', 'ユ', 'ヨ', 'ラ', 'リ', 'ル', 'レ', 'ロ',
|
||||
'ワ', 'ヰ', 'ヱ', 'ヲ', 'ン'
|
||||
'ア', 'イ', 'ウ', 'エ', 'オ', 'カ', 'キ', 'ク', 'ケ', 'コ', 'サ', 'シ', 'ス',
|
||||
'セ', 'ソ', 'タ', 'チ', 'ツ', 'テ', 'ト', 'ナ', 'ニ', 'ヌ', 'ネ', 'ノ', 'ハ',
|
||||
'ヒ', 'フ', 'ヘ', 'ホ', 'マ', 'ミ', 'ム', 'メ', 'モ', 'ヤ', 'ユ', 'ヨ', 'ラ',
|
||||
'リ', 'ル', 'レ', 'ロ', 'ワ', 'ヰ', 'ヱ', 'ヲ', 'ン',
|
||||
];
|
||||
static KATAKANA_IROHA: [char; 47] = [
|
||||
'イ', 'ロ', 'ハ', 'ニ', 'ホ', 'ヘ', 'ト', 'チ', 'リ', 'ヌ', 'ル', 'ヲ', 'ワ', 'カ', 'ヨ',
|
||||
'タ', 'レ', 'ソ', 'ツ', 'ネ', 'ナ', 'ラ', 'ム', 'ウ', 'ヰ', 'ノ', 'オ', 'ク', 'ヤ', 'マ',
|
||||
'ケ', 'フ', 'コ', 'エ', 'テ', 'ア', 'サ', 'キ', 'ユ', 'メ', 'ミ', 'シ', 'ヱ',
|
||||
'ヒ', 'モ', 'セ', 'ス'
|
||||
'イ', 'ロ', 'ハ', 'ニ', 'ホ', 'ヘ', 'ト', 'チ', 'リ', 'ヌ', 'ル', 'ヲ', 'ワ',
|
||||
'カ', 'ヨ', 'タ', 'レ', 'ソ', 'ツ', 'ネ', 'ナ', 'ラ', 'ム', 'ウ', 'ヰ', 'ノ',
|
||||
'オ', 'ク', 'ヤ', 'マ', 'ケ', 'フ', 'コ', 'エ', 'テ', 'ア', 'サ', 'キ', 'ユ',
|
||||
'メ', 'ミ', 'シ', 'ヱ', 'ヒ', 'モ', 'セ', 'ス',
|
||||
];
|
||||
|
||||
/// The generated content resolution traversal.
|
||||
|
@ -132,8 +162,12 @@ impl<'a> InorderFlowTraversal for ResolveGeneratedContent<'a> {
|
|||
|
||||
#[inline]
|
||||
fn should_process_subtree(&mut self, flow: &mut Flow) -> bool {
|
||||
flow.base().restyle_damage.intersects(ServoRestyleDamage::RESOLVE_GENERATED_CONTENT) ||
|
||||
flow.base().flags.intersects(FlowFlags::AFFECTS_COUNTERS | FlowFlags::HAS_COUNTER_AFFECTING_CHILDREN)
|
||||
flow.base()
|
||||
.restyle_damage
|
||||
.intersects(ServoRestyleDamage::RESOLVE_GENERATED_CONTENT) ||
|
||||
flow.base().flags.intersects(
|
||||
FlowFlags::AFFECTS_COUNTERS | FlowFlags::HAS_COUNTER_AFFECTING_CHILDREN,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,81 +202,97 @@ impl<'a, 'b> ResolveGeneratedContentFragmentMutator<'a, 'b> {
|
|||
if let SpecificFragmentInfo::GeneratedContent(ref mut info) = fragment.specific {
|
||||
info
|
||||
} else {
|
||||
return
|
||||
return;
|
||||
};
|
||||
|
||||
match **info {
|
||||
GeneratedContentInfo::ListItem => {
|
||||
new_info = self.traversal.list_item.render(self.traversal.layout_context,
|
||||
fragment.node,
|
||||
fragment.pseudo.clone(),
|
||||
fragment.style.clone(),
|
||||
list_style_type,
|
||||
RenderingMode::Suffix(".\u{00a0}"))
|
||||
}
|
||||
new_info = self.traversal.list_item.render(
|
||||
self.traversal.layout_context,
|
||||
fragment.node,
|
||||
fragment.pseudo.clone(),
|
||||
fragment.style.clone(),
|
||||
list_style_type,
|
||||
RenderingMode::Suffix(".\u{00a0}"),
|
||||
)
|
||||
},
|
||||
GeneratedContentInfo::Empty |
|
||||
GeneratedContentInfo::ContentItem(ContentItem::String(_)) => {
|
||||
// Nothing to do here.
|
||||
}
|
||||
GeneratedContentInfo::ContentItem(ContentItem::Counter(ref counter_name,
|
||||
counter_style)) => {
|
||||
},
|
||||
GeneratedContentInfo::ContentItem(ContentItem::Counter(
|
||||
ref counter_name,
|
||||
counter_style,
|
||||
)) => {
|
||||
let temporary_counter = Counter::new();
|
||||
let counter = self.traversal
|
||||
let counter = self
|
||||
.traversal
|
||||
.counters
|
||||
.get(&*counter_name.0)
|
||||
.unwrap_or(&temporary_counter);
|
||||
new_info = counter.render(self.traversal.layout_context,
|
||||
fragment.node,
|
||||
fragment.pseudo.clone(),
|
||||
fragment.style.clone(),
|
||||
counter_style,
|
||||
RenderingMode::Plain)
|
||||
}
|
||||
GeneratedContentInfo::ContentItem(ContentItem::Counters(ref counter_name,
|
||||
ref separator,
|
||||
counter_style)) => {
|
||||
new_info = counter.render(
|
||||
self.traversal.layout_context,
|
||||
fragment.node,
|
||||
fragment.pseudo.clone(),
|
||||
fragment.style.clone(),
|
||||
counter_style,
|
||||
RenderingMode::Plain,
|
||||
)
|
||||
},
|
||||
GeneratedContentInfo::ContentItem(ContentItem::Counters(
|
||||
ref counter_name,
|
||||
ref separator,
|
||||
counter_style,
|
||||
)) => {
|
||||
let temporary_counter = Counter::new();
|
||||
let counter = self.traversal
|
||||
let counter = self
|
||||
.traversal
|
||||
.counters
|
||||
.get(&*counter_name.0)
|
||||
.unwrap_or(&temporary_counter);
|
||||
new_info = counter.render(self.traversal.layout_context,
|
||||
fragment.node,
|
||||
fragment.pseudo,
|
||||
fragment.style.clone(),
|
||||
counter_style,
|
||||
RenderingMode::All(&separator));
|
||||
}
|
||||
new_info = counter.render(
|
||||
self.traversal.layout_context,
|
||||
fragment.node,
|
||||
fragment.pseudo,
|
||||
fragment.style.clone(),
|
||||
counter_style,
|
||||
RenderingMode::All(&separator),
|
||||
);
|
||||
},
|
||||
GeneratedContentInfo::ContentItem(ContentItem::OpenQuote) => {
|
||||
new_info = render_text(self.traversal.layout_context,
|
||||
fragment.node,
|
||||
fragment.pseudo,
|
||||
fragment.style.clone(),
|
||||
self.quote(&*fragment.style, false));
|
||||
new_info = render_text(
|
||||
self.traversal.layout_context,
|
||||
fragment.node,
|
||||
fragment.pseudo,
|
||||
fragment.style.clone(),
|
||||
self.quote(&*fragment.style, false),
|
||||
);
|
||||
self.traversal.quote += 1
|
||||
}
|
||||
},
|
||||
GeneratedContentInfo::ContentItem(ContentItem::CloseQuote) => {
|
||||
if self.traversal.quote >= 1 {
|
||||
self.traversal.quote -= 1
|
||||
}
|
||||
|
||||
new_info = render_text(self.traversal.layout_context,
|
||||
fragment.node,
|
||||
fragment.pseudo,
|
||||
fragment.style.clone(),
|
||||
self.quote(&*fragment.style, true));
|
||||
}
|
||||
new_info = render_text(
|
||||
self.traversal.layout_context,
|
||||
fragment.node,
|
||||
fragment.pseudo,
|
||||
fragment.style.clone(),
|
||||
self.quote(&*fragment.style, true),
|
||||
);
|
||||
},
|
||||
GeneratedContentInfo::ContentItem(ContentItem::NoOpenQuote) => {
|
||||
self.traversal.quote += 1
|
||||
}
|
||||
},
|
||||
GeneratedContentInfo::ContentItem(ContentItem::NoCloseQuote) => {
|
||||
if self.traversal.quote >= 1 {
|
||||
self.traversal.quote -= 1
|
||||
}
|
||||
}
|
||||
},
|
||||
GeneratedContentInfo::ContentItem(ContentItem::Url(..)) => {
|
||||
unreachable!("Servo doesn't parse content: url(..) yet")
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -252,7 +302,7 @@ impl<'a, 'b> ResolveGeneratedContentFragmentMutator<'a, 'b> {
|
|||
// so that it isn't processed again on the next layout. FIXME (mbrubeck): When
|
||||
// processing an inline flow, this traversal should be allowed to insert or remove
|
||||
// fragments. Then we can just remove these fragments rather than adding placeholders.
|
||||
None => SpecificFragmentInfo::GeneratedContent(Box::new(GeneratedContentInfo::Empty))
|
||||
None => SpecificFragmentInfo::GeneratedContent(Box::new(GeneratedContentInfo::Empty)),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -263,9 +313,12 @@ impl<'a, 'b> ResolveGeneratedContentFragmentMutator<'a, 'b> {
|
|||
}
|
||||
|
||||
match list_style_type {
|
||||
ListStyleType::Disc | ListStyleType::None | ListStyleType::Circle |
|
||||
ListStyleType::Square | ListStyleType::DisclosureOpen |
|
||||
ListStyleType::DisclosureClosed => {}
|
||||
ListStyleType::Disc |
|
||||
ListStyleType::None |
|
||||
ListStyleType::Circle |
|
||||
ListStyleType::Square |
|
||||
ListStyleType::DisclosureOpen |
|
||||
ListStyleType::DisclosureClosed => {},
|
||||
_ => self.traversal.list_item.increment(self.level, 1),
|
||||
}
|
||||
|
||||
|
@ -278,25 +331,29 @@ impl<'a, 'b> ResolveGeneratedContentFragmentMutator<'a, 'b> {
|
|||
for pair in &*fragment.style().get_counters().counter_reset {
|
||||
let counter_name = &*pair.name.0;
|
||||
if let Some(ref mut counter) = self.traversal.counters.get_mut(counter_name) {
|
||||
counter.reset(self.level, pair.value);
|
||||
continue
|
||||
counter.reset(self.level, pair.value);
|
||||
continue;
|
||||
}
|
||||
|
||||
let mut counter = Counter::new();
|
||||
counter.reset(self.level, pair.value);
|
||||
self.traversal.counters.insert(counter_name.to_owned(), counter);
|
||||
self.traversal
|
||||
.counters
|
||||
.insert(counter_name.to_owned(), counter);
|
||||
}
|
||||
|
||||
for pair in &*fragment.style().get_counters().counter_increment {
|
||||
let counter_name = &*pair.name.0;
|
||||
if let Some(ref mut counter) = self.traversal.counters.get_mut(counter_name) {
|
||||
counter.increment(self.level, pair.value);
|
||||
continue
|
||||
continue;
|
||||
}
|
||||
|
||||
let mut counter = Counter::new();
|
||||
counter.increment(self.level, pair.value);
|
||||
self.traversal.counters.insert(counter_name.to_owned(), counter);
|
||||
self.traversal
|
||||
.counters
|
||||
.insert(counter_name.to_owned(), counter);
|
||||
}
|
||||
|
||||
self.incremented = true
|
||||
|
@ -305,14 +362,14 @@ impl<'a, 'b> ResolveGeneratedContentFragmentMutator<'a, 'b> {
|
|||
fn quote(&self, style: &ComputedValues, close: bool) -> String {
|
||||
let quotes = &style.get_list().quotes;
|
||||
if quotes.0.is_empty() {
|
||||
return String::new()
|
||||
return String::new();
|
||||
}
|
||||
let &(ref open_quote, ref close_quote) =
|
||||
if self.traversal.quote as usize >= quotes.0.len() {
|
||||
quotes.0.last().unwrap()
|
||||
} else {
|
||||
"es.0[self.traversal.quote as usize]
|
||||
};
|
||||
let &(ref open_quote, ref close_quote) = if self.traversal.quote as usize >= quotes.0.len()
|
||||
{
|
||||
quotes.0.last().unwrap()
|
||||
} else {
|
||||
"es.0[self.traversal.quote as usize]
|
||||
};
|
||||
if close {
|
||||
close_quote.to_string()
|
||||
} else {
|
||||
|
@ -329,9 +386,7 @@ struct Counter {
|
|||
|
||||
impl Counter {
|
||||
fn new() -> Counter {
|
||||
Counter {
|
||||
values: Vec::new(),
|
||||
}
|
||||
Counter { values: Vec::new() }
|
||||
}
|
||||
|
||||
fn reset(&mut self, level: u32, value: i32) {
|
||||
|
@ -339,7 +394,7 @@ impl Counter {
|
|||
if let Some(ref mut existing_value) = self.values.last_mut() {
|
||||
if level == existing_value.level {
|
||||
existing_value.value = value;
|
||||
return
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -359,7 +414,7 @@ impl Counter {
|
|||
fn increment(&mut self, level: u32, amount: i32) {
|
||||
if let Some(ref mut value) = self.values.last_mut() {
|
||||
value.value += amount;
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
self.values.push(CounterValue {
|
||||
|
@ -368,14 +423,15 @@ impl Counter {
|
|||
})
|
||||
}
|
||||
|
||||
fn render(&self,
|
||||
layout_context: &LayoutContext,
|
||||
node: OpaqueNode,
|
||||
pseudo: PseudoElementType,
|
||||
style: ::ServoArc<ComputedValues>,
|
||||
list_style_type: ListStyleType,
|
||||
mode: RenderingMode)
|
||||
-> Option<SpecificFragmentInfo> {
|
||||
fn render(
|
||||
&self,
|
||||
layout_context: &LayoutContext,
|
||||
node: OpaqueNode,
|
||||
pseudo: PseudoElementType,
|
||||
style: ::ServoArc<ComputedValues>,
|
||||
list_style_type: ListStyleType,
|
||||
mode: RenderingMode,
|
||||
) -> Option<SpecificFragmentInfo> {
|
||||
let mut string = String::new();
|
||||
match mode {
|
||||
RenderingMode::Plain => {
|
||||
|
@ -384,7 +440,7 @@ impl Counter {
|
|||
None => 0,
|
||||
};
|
||||
push_representation(value, list_style_type, &mut string)
|
||||
}
|
||||
},
|
||||
RenderingMode::Suffix(suffix) => {
|
||||
let value = match self.values.last() {
|
||||
Some(ref value) => value.value,
|
||||
|
@ -392,7 +448,7 @@ impl Counter {
|
|||
};
|
||||
push_representation(value, list_style_type, &mut string);
|
||||
string.push_str(suffix)
|
||||
}
|
||||
},
|
||||
RenderingMode::All(separator) => {
|
||||
let mut first = true;
|
||||
for value in &self.values {
|
||||
|
@ -402,7 +458,7 @@ impl Counter {
|
|||
first = false;
|
||||
push_representation(value.value, list_style_type, &mut string)
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
if string.is_empty() {
|
||||
|
@ -432,22 +488,26 @@ struct CounterValue {
|
|||
}
|
||||
|
||||
/// Creates fragment info for a literal string.
|
||||
fn render_text(layout_context: &LayoutContext,
|
||||
node: OpaqueNode,
|
||||
pseudo: PseudoElementType,
|
||||
style: ::ServoArc<ComputedValues>,
|
||||
string: String)
|
||||
-> Option<SpecificFragmentInfo> {
|
||||
fn render_text(
|
||||
layout_context: &LayoutContext,
|
||||
node: OpaqueNode,
|
||||
pseudo: PseudoElementType,
|
||||
style: ::ServoArc<ComputedValues>,
|
||||
string: String,
|
||||
) -> Option<SpecificFragmentInfo> {
|
||||
let mut fragments = LinkedList::new();
|
||||
let info = SpecificFragmentInfo::UnscannedText(
|
||||
Box::new(UnscannedTextFragmentInfo::new(string.into_boxed_str(), None))
|
||||
);
|
||||
fragments.push_back(Fragment::from_opaque_node_and_style(node,
|
||||
pseudo,
|
||||
style.clone(),
|
||||
style,
|
||||
RestyleDamage::rebuild_and_reflow(),
|
||||
info));
|
||||
let info = SpecificFragmentInfo::UnscannedText(Box::new(UnscannedTextFragmentInfo::new(
|
||||
string.into_boxed_str(),
|
||||
None,
|
||||
)));
|
||||
fragments.push_back(Fragment::from_opaque_node_and_style(
|
||||
node,
|
||||
pseudo,
|
||||
style.clone(),
|
||||
style,
|
||||
RestyleDamage::rebuild_and_reflow(),
|
||||
info,
|
||||
));
|
||||
// FIXME(pcwalton): This should properly handle multiple marker fragments. This could happen
|
||||
// due to text run splitting.
|
||||
let fragments = with_thread_local_font_context(layout_context, |font_context| {
|
||||
|
@ -464,39 +524,28 @@ fn render_text(layout_context: &LayoutContext,
|
|||
/// `list-style-type` onto the given string.
|
||||
fn push_representation(value: i32, list_style_type: ListStyleType, accumulator: &mut String) {
|
||||
match list_style_type {
|
||||
ListStyleType::None => {}
|
||||
ListStyleType::None => {},
|
||||
ListStyleType::Disc |
|
||||
ListStyleType::Circle |
|
||||
ListStyleType::Square |
|
||||
ListStyleType::DisclosureOpen |
|
||||
ListStyleType::DisclosureClosed => {
|
||||
accumulator.push(static_representation(list_style_type))
|
||||
}
|
||||
ListStyleType::DisclosureClosed => accumulator.push(static_representation(list_style_type)),
|
||||
ListStyleType::Decimal => push_numeric_representation(value, &DECIMAL, accumulator),
|
||||
ListStyleType::ArabicIndic => {
|
||||
push_numeric_representation(value, &ARABIC_INDIC, accumulator)
|
||||
}
|
||||
},
|
||||
ListStyleType::Bengali => push_numeric_representation(value, &BENGALI, accumulator),
|
||||
ListStyleType::Cambodian |
|
||||
ListStyleType::Khmer => {
|
||||
ListStyleType::Cambodian | ListStyleType::Khmer => {
|
||||
push_numeric_representation(value, &CAMBODIAN, accumulator)
|
||||
}
|
||||
ListStyleType::CjkDecimal => {
|
||||
push_numeric_representation(value, &CJK_DECIMAL, accumulator)
|
||||
}
|
||||
ListStyleType::Devanagari => {
|
||||
push_numeric_representation(value, &DEVANAGARI, accumulator)
|
||||
}
|
||||
},
|
||||
ListStyleType::CjkDecimal => push_numeric_representation(value, &CJK_DECIMAL, accumulator),
|
||||
ListStyleType::Devanagari => push_numeric_representation(value, &DEVANAGARI, accumulator),
|
||||
ListStyleType::Gujarati => push_numeric_representation(value, &GUJARATI, accumulator),
|
||||
ListStyleType::Gurmukhi => push_numeric_representation(value, &GURMUKHI, accumulator),
|
||||
ListStyleType::Kannada => push_numeric_representation(value, &KANNADA, accumulator),
|
||||
ListStyleType::Lao => push_numeric_representation(value, &LAO, accumulator),
|
||||
ListStyleType::Malayalam => {
|
||||
push_numeric_representation(value, &MALAYALAM, accumulator)
|
||||
}
|
||||
ListStyleType::Mongolian => {
|
||||
push_numeric_representation(value, &MONGOLIAN, accumulator)
|
||||
}
|
||||
ListStyleType::Malayalam => push_numeric_representation(value, &MALAYALAM, accumulator),
|
||||
ListStyleType::Mongolian => push_numeric_representation(value, &MONGOLIAN, accumulator),
|
||||
ListStyleType::Myanmar => push_numeric_representation(value, &MYANMAR, accumulator),
|
||||
ListStyleType::Oriya => push_numeric_representation(value, &ORIYA, accumulator),
|
||||
ListStyleType::Persian => push_numeric_representation(value, &PERSIAN, accumulator),
|
||||
|
@ -505,31 +554,27 @@ fn push_representation(value: i32, list_style_type: ListStyleType, accumulator:
|
|||
ListStyleType::Tibetan => push_numeric_representation(value, &TIBETAN, accumulator),
|
||||
ListStyleType::LowerAlpha => {
|
||||
push_alphabetic_representation(value, &LOWER_ALPHA, accumulator)
|
||||
}
|
||||
},
|
||||
ListStyleType::UpperAlpha => {
|
||||
push_alphabetic_representation(value, &UPPER_ALPHA, accumulator)
|
||||
}
|
||||
},
|
||||
ListStyleType::CjkEarthlyBranch => {
|
||||
push_alphabetic_representation(value, &CJK_EARTHLY_BRANCH, accumulator)
|
||||
}
|
||||
},
|
||||
ListStyleType::CjkHeavenlyStem => {
|
||||
push_alphabetic_representation(value, &CJK_HEAVENLY_STEM, accumulator)
|
||||
}
|
||||
},
|
||||
ListStyleType::LowerGreek => {
|
||||
push_alphabetic_representation(value, &LOWER_GREEK, accumulator)
|
||||
}
|
||||
ListStyleType::Hiragana => {
|
||||
push_alphabetic_representation(value, &HIRAGANA, accumulator)
|
||||
}
|
||||
},
|
||||
ListStyleType::Hiragana => push_alphabetic_representation(value, &HIRAGANA, accumulator),
|
||||
ListStyleType::HiraganaIroha => {
|
||||
push_alphabetic_representation(value, &HIRAGANA_IROHA, accumulator)
|
||||
}
|
||||
ListStyleType::Katakana => {
|
||||
push_alphabetic_representation(value, &KATAKANA, accumulator)
|
||||
}
|
||||
},
|
||||
ListStyleType::Katakana => push_alphabetic_representation(value, &KATAKANA, accumulator),
|
||||
ListStyleType::KatakanaIroha => {
|
||||
push_alphabetic_representation(value, &KATAKANA_IROHA, accumulator)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -572,7 +617,7 @@ fn push_numeric_representation(value: i32, system: &[char], accumulator: &mut St
|
|||
// Step 1.
|
||||
if abs_value == 0 {
|
||||
accumulator.push(system[0]);
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
// Step 2.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue