mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
add RareFlowFlags
This commit is contained in:
parent
dac1176d15
commit
baad6e3963
2 changed files with 111 additions and 12 deletions
|
@ -778,9 +778,9 @@ impl Box {
|
||||||
text_run: text_box.run.clone(),
|
text_run: text_box.run.clone(),
|
||||||
range: text_box.range,
|
range: text_box.range,
|
||||||
text_color: text_color,
|
text_color: text_color,
|
||||||
overline_color: flow_flags.overline_color,
|
overline_color: flow_flags.overline_color(text_color),
|
||||||
underline_color: flow_flags.underline_color,
|
underline_color: flow_flags.underline_color(text_color),
|
||||||
line_through_color: flow_flags.line_through_color,
|
line_through_color: flow_flags.line_through_color(text_color),
|
||||||
flags: text_flags,
|
flags: text_flags,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -263,6 +263,11 @@ pub struct FlowFlagsInfo{
|
||||||
flags: FlowFlags,
|
flags: FlowFlags,
|
||||||
|
|
||||||
/// text-decoration colors
|
/// text-decoration colors
|
||||||
|
rare_flow_flags: Option<RareFlowFlags>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[deriving(Clone)]
|
||||||
|
pub struct RareFlowFlags {
|
||||||
underline_color: Color,
|
underline_color: Color,
|
||||||
overline_color: Color,
|
overline_color: Color,
|
||||||
line_through_color: Color,
|
line_through_color: Color,
|
||||||
|
@ -296,27 +301,116 @@ impl FlowFlagsInfo {
|
||||||
flags.set_override_line_through(text_decoration.line_through);
|
flags.set_override_line_through(text_decoration.line_through);
|
||||||
|
|
||||||
// TODO(ksh8281) compute text-decoration-color,style,line
|
// TODO(ksh8281) compute text-decoration-color,style,line
|
||||||
let underline_color = style.Color.color.to_gfx_color();
|
let rare_flow_flags = if flags.is_text_decoration_enable() {
|
||||||
let overline_color = style.Color.color.to_gfx_color();
|
Some(RareFlowFlags {
|
||||||
let line_through_color = style.Color.color.to_gfx_color();
|
underline_color: style.Color.color.to_gfx_color(),
|
||||||
|
overline_color: style.Color.color.to_gfx_color(),
|
||||||
|
line_through_color: style.Color.color.to_gfx_color(),
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
FlowFlagsInfo {
|
FlowFlagsInfo {
|
||||||
flags: flags,
|
flags: flags,
|
||||||
underline_color: underline_color,
|
rare_flow_flags: rare_flow_flags,
|
||||||
overline_color: overline_color,
|
}
|
||||||
line_through_color: line_through_color,
|
}
|
||||||
|
|
||||||
|
pub fn underline_color(&self, default_color: Color) -> Color {
|
||||||
|
match self.rare_flow_flags {
|
||||||
|
Some(ref data) => {
|
||||||
|
data.underline_color
|
||||||
|
},
|
||||||
|
None => {
|
||||||
|
default_color
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn overline_color(&self, default_color: Color) -> Color {
|
||||||
|
match self.rare_flow_flags {
|
||||||
|
Some(ref data) => {
|
||||||
|
data.overline_color
|
||||||
|
},
|
||||||
|
None => {
|
||||||
|
default_color
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn line_through_color(&self, default_color: Color) -> Color {
|
||||||
|
match self.rare_flow_flags {
|
||||||
|
Some(ref data) => {
|
||||||
|
data.line_through_color
|
||||||
|
},
|
||||||
|
None => {
|
||||||
|
default_color
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Propagates text decoration flags from an appropriate parent flow per CSS 2.1 § 16.3.1.
|
/// Propagates text decoration flags from an appropriate parent flow per CSS 2.1 § 16.3.1.
|
||||||
pub fn propagate_text_decoration_from_parent(&mut self, parent: FlowFlagsInfo) {
|
pub fn propagate_text_decoration_from_parent(&mut self, parent: FlowFlagsInfo) {
|
||||||
|
if !parent.flags.is_text_decoration_enable() {
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if !self.flags.is_text_decoration_enable() && parent.flags.is_text_decoration_enable() {
|
||||||
|
self.rare_flow_flags = parent.rare_flow_flags.clone();
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
if !self.flags.override_underline() && parent.flags.override_underline() {
|
if !self.flags.override_underline() && parent.flags.override_underline() {
|
||||||
self.underline_color = parent.underline_color;
|
match parent.rare_flow_flags {
|
||||||
|
Some(ref parent_data) => {
|
||||||
|
match self.rare_flow_flags {
|
||||||
|
Some(ref mut data) => {
|
||||||
|
data.underline_color = parent_data.underline_color;
|
||||||
|
},
|
||||||
|
None => {
|
||||||
|
fail!("if flow has text-decoration, it must have rare_flow_flags");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
None => {
|
||||||
|
fail!("if flow has text-decoration, it must have rare_flow_flags");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if !self.flags.override_overline() && parent.flags.override_overline() {
|
if !self.flags.override_overline() && parent.flags.override_overline() {
|
||||||
self.overline_color = parent.overline_color;
|
match parent.rare_flow_flags {
|
||||||
|
Some(ref parent_data) => {
|
||||||
|
match self.rare_flow_flags {
|
||||||
|
Some(ref mut data) => {
|
||||||
|
data.overline_color = parent_data.overline_color;
|
||||||
|
},
|
||||||
|
None => {
|
||||||
|
fail!("if flow has text-decoration, it must have rare_flow_flags");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
None => {
|
||||||
|
fail!("if flow has text-decoration, it must have rare_flow_flags");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if !self.flags.override_line_through() && parent.flags.override_line_through() {
|
if !self.flags.override_line_through() && parent.flags.override_line_through() {
|
||||||
self.line_through_color = parent.line_through_color;
|
match parent.rare_flow_flags {
|
||||||
|
Some(ref parent_data) => {
|
||||||
|
match self.rare_flow_flags {
|
||||||
|
Some(ref mut data) => {
|
||||||
|
data.line_through_color = parent_data.line_through_color;
|
||||||
|
},
|
||||||
|
None => {
|
||||||
|
fail!("if flow has text-decoration, it must have rare_flow_flags");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
None => {
|
||||||
|
fail!("if flow has text-decoration, it must have rare_flow_flags");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
self.flags.set_text_decoration_override(parent.flags);
|
self.flags.set_text_decoration_override(parent.flags);
|
||||||
}
|
}
|
||||||
|
@ -366,6 +460,11 @@ impl FlowFlags {
|
||||||
pub fn set_text_decoration_override(&mut self, parent: FlowFlags) {
|
pub fn set_text_decoration_override(&mut self, parent: FlowFlags) {
|
||||||
*self = FlowFlags(**self | (*parent & TEXT_DECORATION_OVERRIDE_BITMASK));
|
*self = FlowFlags(**self | (*parent & TEXT_DECORATION_OVERRIDE_BITMASK));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn is_text_decoration_enable(&self) -> bool {
|
||||||
|
(**self & TEXT_DECORATION_OVERRIDE_BITMASK) != 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Data common to all flows.
|
/// Data common to all flows.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue