Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

layout: Re-enable parallel layout and refactor boxes significantly #2174

Merged
merged 1 commit into from May 2, 2014
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

layout: Re-enable parallel layout by removing all `RefCell` instances

from `Flow`s; in the process, remove `InlineInfo` in favor of the
range-based design that was originally planned and halfway implemented.

Now, the DOM tree structure for inline flows is reflected not by a
series of arrays but instead by a flat list of ranges into the list of
boxes. As part of this, the `border` and `padding` fields, which were
incorrect in the case of inlines and necessitated separate
`noncontent_inline_foo` methods, have been merged into a single
`border_padding` field that is always guaranteed to be correct after
width assignment, even for inlines.
  • Loading branch information
pcwalton committed May 2, 2014
commit 27276c0305d6dc5079c536f4f27d23efbc56eb3e
@@ -228,6 +228,16 @@ pub struct SolidColorDisplayItem {
pub color: Color,
}

/// Text decoration information.
pub struct TextDecorations {
/// The color to use for underlining, if any.
pub underline: Option<Color>,
/// The color to use for overlining, if any.
pub overline: Option<Color>,
/// The color to use for line-through, if any.
pub line_through: Option<Color>,
}

/// Renders text.
pub struct TextDisplayItem {
/// Fields common to all display items.
@@ -242,31 +252,10 @@ pub struct TextDisplayItem {
/// The color of the text.
pub text_color: Color,

/// A bitfield of flags for text display items.
pub flags: TextDisplayItemFlags,

/// The color of text-decorations
pub underline_color: Color,
pub overline_color: Color,
pub line_through_color: Color,
}

/// Flags for text display items.
pub struct TextDisplayItemFlags(pub u8);

impl TextDisplayItemFlags {
pub fn new() -> TextDisplayItemFlags {
TextDisplayItemFlags(0)
}
/// Text decorations in effect.
pub text_decorations: TextDecorations,
}

// Whether underlining is forced on.
bitfield!(TextDisplayItemFlags, override_underline, set_override_underline, 0x01)
// Whether overlining is forced on.
bitfield!(TextDisplayItemFlags, override_overline, set_override_overline, 0x02)
// Whether line-through is forced on.
bitfield!(TextDisplayItemFlags, override_line_through, set_override_line_through, 0x04)

/// Renders an image.
pub struct ImageDisplayItem {
pub base: BaseDisplayItem,
@@ -369,22 +358,24 @@ impl DisplayItem {
let strikeout_size = font_metrics.strikeout_size;
let strikeout_offset = font_metrics.strikeout_offset;

if text_run.decoration.underline || text.flags.override_underline() {
for underline_color in text.text_decorations.underline.iter() {
let underline_y = baseline_origin.y - underline_offset;
let underline_bounds = Rect(Point2D(baseline_origin.x, underline_y),
Size2D(width, underline_size));
render_context.draw_solid_color(&underline_bounds, text.underline_color);
render_context.draw_solid_color(&underline_bounds, *underline_color);
}
if text_run.decoration.overline || text.flags.override_overline() {

for overline_color in text.text_decorations.overline.iter() {
let overline_bounds = Rect(Point2D(baseline_origin.x, origin.y),
Size2D(width, underline_size));
render_context.draw_solid_color(&overline_bounds, text.overline_color);
render_context.draw_solid_color(&overline_bounds, *overline_color);
}
if text_run.decoration.line_through || text.flags.override_line_through() {

for line_through_color in text.text_decorations.line_through.iter() {
let strikeout_y = baseline_origin.y - strikeout_offset;
let strikeout_bounds = Rect(Point2D(baseline_origin.x, strikeout_y),
Size2D(width, strikeout_size));
render_context.draw_solid_color(&strikeout_bounds, text.line_through_color);
render_context.draw_solid_color(&strikeout_bounds, *line_through_color);
}
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.