зеркало из https://github.com/mozilla/gecko-dev.git
#4406 Source-Repo: https://github.com/servo/servo Source-Revision: a425bb528957fd77cf8300b17e153f8fc3777483
This commit is contained in:
Родитель
fa63e17acb
Коммит
4c1092dbf9
|
@ -357,7 +357,7 @@ impl StackingContext {
|
|||
continue
|
||||
}
|
||||
match *item {
|
||||
BorderDisplayItemClass(ref border) => {
|
||||
DisplayItem::BorderClass(ref border) => {
|
||||
// If the point is inside the border, it didn't hit the border!
|
||||
let interior_rect =
|
||||
Rect(Point2D(border.base.bounds.origin.x + border.border_widths.left,
|
||||
|
@ -459,13 +459,13 @@ pub fn find_stacking_context_with_layer_id(this: &Arc<StackingContext>, layer_id
|
|||
/// One drawing command in the list.
|
||||
#[deriving(Clone)]
|
||||
pub enum DisplayItem {
|
||||
SolidColorDisplayItemClass(Box<SolidColorDisplayItem>),
|
||||
TextDisplayItemClass(Box<TextDisplayItem>),
|
||||
ImageDisplayItemClass(Box<ImageDisplayItem>),
|
||||
BorderDisplayItemClass(Box<BorderDisplayItem>),
|
||||
GradientDisplayItemClass(Box<GradientDisplayItem>),
|
||||
LineDisplayItemClass(Box<LineDisplayItem>),
|
||||
BoxShadowDisplayItemClass(Box<BoxShadowDisplayItem>),
|
||||
SolidColorClass(Box<SolidColorDisplayItem>),
|
||||
TextClass(Box<TextDisplayItem>),
|
||||
ImageClass(Box<ImageDisplayItem>),
|
||||
BorderClass(Box<BorderDisplayItem>),
|
||||
GradientClass(Box<GradientDisplayItem>),
|
||||
LineClass(Box<LineDisplayItem>),
|
||||
BoxShadowClass(Box<BoxShadowDisplayItem>),
|
||||
}
|
||||
|
||||
/// Information common to all display items.
|
||||
|
@ -656,16 +656,16 @@ pub struct BoxShadowDisplayItem {
|
|||
}
|
||||
|
||||
pub enum DisplayItemIterator<'a> {
|
||||
EmptyDisplayItemIterator,
|
||||
ParentDisplayItemIterator(dlist::Items<'a,DisplayItem>),
|
||||
Empty,
|
||||
Parent(dlist::Items<'a,DisplayItem>),
|
||||
}
|
||||
|
||||
impl<'a> Iterator<&'a DisplayItem> for DisplayItemIterator<'a> {
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<&'a DisplayItem> {
|
||||
match *self {
|
||||
EmptyDisplayItemIterator => None,
|
||||
ParentDisplayItemIterator(ref mut subiterator) => subiterator.next(),
|
||||
DisplayItemIterator::Empty => None,
|
||||
DisplayItemIterator::Parent(ref mut subiterator) => subiterator.next(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -683,16 +683,16 @@ impl DisplayItem {
|
|||
}
|
||||
|
||||
match *self {
|
||||
SolidColorDisplayItemClass(ref solid_color) => {
|
||||
DisplayItem::SolidColorClass(ref solid_color) => {
|
||||
paint_context.draw_solid_color(&solid_color.base.bounds, solid_color.color)
|
||||
}
|
||||
|
||||
TextDisplayItemClass(ref text) => {
|
||||
DisplayItem::TextClass(ref text) => {
|
||||
debug!("Drawing text at {}.", text.base.bounds);
|
||||
paint_context.draw_text(&**text);
|
||||
}
|
||||
|
||||
ImageDisplayItemClass(ref image_item) => {
|
||||
DisplayItem::ImageClass(ref image_item) => {
|
||||
debug!("Drawing image at {}.", image_item.base.bounds);
|
||||
|
||||
let mut y_offset = Au(0);
|
||||
|
@ -713,7 +713,7 @@ impl DisplayItem {
|
|||
}
|
||||
}
|
||||
|
||||
BorderDisplayItemClass(ref border) => {
|
||||
DisplayItem::BorderClass(ref border) => {
|
||||
paint_context.draw_border(&border.base.bounds,
|
||||
border.border_widths,
|
||||
&border.radius,
|
||||
|
@ -721,20 +721,20 @@ impl DisplayItem {
|
|||
border.style)
|
||||
}
|
||||
|
||||
GradientDisplayItemClass(ref gradient) => {
|
||||
DisplayItem::GradientClass(ref gradient) => {
|
||||
paint_context.draw_linear_gradient(&gradient.base.bounds,
|
||||
&gradient.start_point,
|
||||
&gradient.end_point,
|
||||
gradient.stops.as_slice());
|
||||
}
|
||||
|
||||
LineDisplayItemClass(ref line) => {
|
||||
DisplayItem::LineClass(ref line) => {
|
||||
paint_context.draw_line(&line.base.bounds,
|
||||
line.color,
|
||||
line.style)
|
||||
}
|
||||
|
||||
BoxShadowDisplayItemClass(ref box_shadow) => {
|
||||
DisplayItem::BoxShadowClass(ref box_shadow) => {
|
||||
paint_context.draw_box_shadow(&box_shadow.box_bounds,
|
||||
&box_shadow.offset,
|
||||
box_shadow.color,
|
||||
|
@ -747,25 +747,25 @@ impl DisplayItem {
|
|||
|
||||
pub fn base<'a>(&'a self) -> &'a BaseDisplayItem {
|
||||
match *self {
|
||||
SolidColorDisplayItemClass(ref solid_color) => &solid_color.base,
|
||||
TextDisplayItemClass(ref text) => &text.base,
|
||||
ImageDisplayItemClass(ref image_item) => &image_item.base,
|
||||
BorderDisplayItemClass(ref border) => &border.base,
|
||||
GradientDisplayItemClass(ref gradient) => &gradient.base,
|
||||
LineDisplayItemClass(ref line) => &line.base,
|
||||
BoxShadowDisplayItemClass(ref box_shadow) => &box_shadow.base,
|
||||
DisplayItem::SolidColorClass(ref solid_color) => &solid_color.base,
|
||||
DisplayItem::TextClass(ref text) => &text.base,
|
||||
DisplayItem::ImageClass(ref image_item) => &image_item.base,
|
||||
DisplayItem::BorderClass(ref border) => &border.base,
|
||||
DisplayItem::GradientClass(ref gradient) => &gradient.base,
|
||||
DisplayItem::LineClass(ref line) => &line.base,
|
||||
DisplayItem::BoxShadowClass(ref box_shadow) => &box_shadow.base,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn mut_base<'a>(&'a mut self) -> &'a mut BaseDisplayItem {
|
||||
match *self {
|
||||
SolidColorDisplayItemClass(ref mut solid_color) => &mut solid_color.base,
|
||||
TextDisplayItemClass(ref mut text) => &mut text.base,
|
||||
ImageDisplayItemClass(ref mut image_item) => &mut image_item.base,
|
||||
BorderDisplayItemClass(ref mut border) => &mut border.base,
|
||||
GradientDisplayItemClass(ref mut gradient) => &mut gradient.base,
|
||||
LineDisplayItemClass(ref mut line) => &mut line.base,
|
||||
BoxShadowDisplayItemClass(ref mut box_shadow) => &mut box_shadow.base,
|
||||
DisplayItem::SolidColorClass(ref mut solid_color) => &mut solid_color.base,
|
||||
DisplayItem::TextClass(ref mut text) => &mut text.base,
|
||||
DisplayItem::ImageClass(ref mut image_item) => &mut image_item.base,
|
||||
DisplayItem::BorderClass(ref mut border) => &mut border.base,
|
||||
DisplayItem::GradientClass(ref mut gradient) => &mut gradient.base,
|
||||
DisplayItem::LineClass(ref mut line) => &mut line.base,
|
||||
DisplayItem::BoxShadowClass(ref mut box_shadow) => &mut box_shadow.base,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -786,13 +786,13 @@ impl fmt::Show for DisplayItem {
|
|||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{} @ {} ({:x})",
|
||||
match *self {
|
||||
SolidColorDisplayItemClass(_) => "SolidColor",
|
||||
TextDisplayItemClass(_) => "Text",
|
||||
ImageDisplayItemClass(_) => "Image",
|
||||
BorderDisplayItemClass(_) => "Border",
|
||||
GradientDisplayItemClass(_) => "Gradient",
|
||||
LineDisplayItemClass(_) => "Line",
|
||||
BoxShadowDisplayItemClass(_) => "BoxShadow",
|
||||
DisplayItem::SolidColorClass(_) => "SolidColor",
|
||||
DisplayItem::TextClass(_) => "Text",
|
||||
DisplayItem::ImageClass(_) => "Image",
|
||||
DisplayItem::BorderClass(_) => "Border",
|
||||
DisplayItem::GradientClass(_) => "Gradient",
|
||||
DisplayItem::LineClass(_) => "Line",
|
||||
DisplayItem::BoxShadowClass(_) => "BoxShadow",
|
||||
},
|
||||
self.base().bounds,
|
||||
self.base().metadata.node.id()
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use self::Command::*;
|
||||
use self::Reply::*;
|
||||
|
||||
use platform::font_list::get_available_families;
|
||||
use platform::font_list::get_system_default_family;
|
||||
use platform::font_list::get_variations_for_family;
|
||||
|
@ -114,16 +111,16 @@ impl FontCache {
|
|||
let msg = self.port.recv();
|
||||
|
||||
match msg {
|
||||
GetFontTemplate(family, descriptor, result) => {
|
||||
Command::GetFontTemplate(family, descriptor, result) => {
|
||||
let family = LowercaseString::new(family.as_slice());
|
||||
let maybe_font_template = self.get_font_template(&family, &descriptor);
|
||||
result.send(GetFontTemplateReply(maybe_font_template));
|
||||
result.send(Reply::GetFontTemplateReply(maybe_font_template));
|
||||
}
|
||||
GetLastResortFontTemplate(descriptor, result) => {
|
||||
Command::GetLastResortFontTemplate(descriptor, result) => {
|
||||
let font_template = self.get_last_resort_font_template(&descriptor);
|
||||
result.send(GetFontTemplateReply(Some(font_template)));
|
||||
result.send(Reply::GetFontTemplateReply(Some(font_template)));
|
||||
}
|
||||
AddWebFont(family_name, src, result) => {
|
||||
Command::AddWebFont(family_name, src, result) => {
|
||||
let family_name = LowercaseString::new(family_name.as_slice());
|
||||
if !self.web_families.contains_key(&family_name) {
|
||||
let family = FontFamily::new();
|
||||
|
@ -153,7 +150,7 @@ impl FontCache {
|
|||
}
|
||||
result.send(());
|
||||
}
|
||||
Exit(result) => {
|
||||
Command::Exit(result) => {
|
||||
result.send(());
|
||||
break;
|
||||
}
|
||||
|
@ -286,12 +283,12 @@ impl FontCacheTask {
|
|||
-> Option<Arc<FontTemplateData>> {
|
||||
|
||||
let (response_chan, response_port) = channel();
|
||||
self.chan.send(GetFontTemplate(family, desc, response_chan));
|
||||
self.chan.send(Command::GetFontTemplate(family, desc, response_chan));
|
||||
|
||||
let reply = response_port.recv();
|
||||
|
||||
match reply {
|
||||
GetFontTemplateReply(data) => {
|
||||
Reply::GetFontTemplateReply(data) => {
|
||||
data
|
||||
}
|
||||
}
|
||||
|
@ -301,12 +298,12 @@ impl FontCacheTask {
|
|||
-> Arc<FontTemplateData> {
|
||||
|
||||
let (response_chan, response_port) = channel();
|
||||
self.chan.send(GetLastResortFontTemplate(desc, response_chan));
|
||||
self.chan.send(Command::GetLastResortFontTemplate(desc, response_chan));
|
||||
|
||||
let reply = response_port.recv();
|
||||
|
||||
match reply {
|
||||
GetFontTemplateReply(data) => {
|
||||
Reply::GetFontTemplateReply(data) => {
|
||||
data.unwrap()
|
||||
}
|
||||
}
|
||||
|
@ -314,13 +311,13 @@ impl FontCacheTask {
|
|||
|
||||
pub fn add_web_font(&self, family: String, src: Source) {
|
||||
let (response_chan, response_port) = channel();
|
||||
self.chan.send(AddWebFont(family, src, response_chan));
|
||||
self.chan.send(Command::AddWebFont(family, src, response_chan));
|
||||
response_port.recv();
|
||||
}
|
||||
|
||||
pub fn exit(&self) {
|
||||
let (response_chan, response_port) = channel();
|
||||
self.chan.send(Exit(response_chan));
|
||||
self.chan.send(Command::Exit(response_chan));
|
||||
response_port.recv();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,10 +4,6 @@
|
|||
|
||||
//! The task that handles all painting.
|
||||
|
||||
use self::Msg::*;
|
||||
use self::MsgFromWorkerThread::*;
|
||||
use self::MsgToWorkerThread::*;
|
||||
|
||||
use buffer_map::BufferMap;
|
||||
use display_list::{mod, StackingContext};
|
||||
use font_cache_task::FontCacheTask;
|
||||
|
@ -231,7 +227,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send {
|
|||
|
||||
loop {
|
||||
match self.port.recv() {
|
||||
PaintInitMsg(stacking_context) => {
|
||||
Msg::PaintInitMsg(stacking_context) => {
|
||||
self.epoch.next();
|
||||
self.root_stacking_context = Some(stacking_context.clone());
|
||||
|
||||
|
@ -247,7 +243,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send {
|
|||
self.epoch,
|
||||
&*stacking_context);
|
||||
}
|
||||
PaintMsg(requests) => {
|
||||
Msg::PaintMsg(requests) => {
|
||||
if !self.paint_permission {
|
||||
debug!("paint_task: paint ready msg");
|
||||
let ConstellationChan(ref mut c) = self.constellation_chan;
|
||||
|
@ -272,12 +268,12 @@ impl<C> PaintTask<C> where C: PaintListener + Send {
|
|||
debug!("paint_task: returning surfaces");
|
||||
self.compositor.paint(self.id, self.epoch, replies);
|
||||
}
|
||||
UnusedBufferMsg(unused_buffers) => {
|
||||
Msg::UnusedBufferMsg(unused_buffers) => {
|
||||
for buffer in unused_buffers.into_iter().rev() {
|
||||
self.buffer_map.insert(native_graphics_context!(self), buffer);
|
||||
}
|
||||
}
|
||||
PaintPermissionGranted => {
|
||||
Msg::PaintPermissionGranted => {
|
||||
self.paint_permission = true;
|
||||
|
||||
match self.root_stacking_context {
|
||||
|
@ -291,10 +287,10 @@ impl<C> PaintTask<C> where C: PaintListener + Send {
|
|||
}
|
||||
}
|
||||
}
|
||||
PaintPermissionRevoked => {
|
||||
Msg::PaintPermissionRevoked => {
|
||||
self.paint_permission = false;
|
||||
}
|
||||
ExitMsg(response_ch) => {
|
||||
Msg::ExitMsg(response_ch) => {
|
||||
debug!("paint_task: exitmsg response send");
|
||||
response_ch.map(|ch| ch.send(()));
|
||||
break;
|
||||
|
@ -431,17 +427,17 @@ impl WorkerThreadProxy {
|
|||
layer_buffer: Option<Box<LayerBuffer>>,
|
||||
stacking_context: Arc<StackingContext>,
|
||||
scale: f32) {
|
||||
self.sender.send(PaintTileMsgToWorkerThread(tile, layer_buffer, stacking_context, scale))
|
||||
self.sender.send(MsgToWorkerThread::PaintTile(tile, layer_buffer, stacking_context, scale))
|
||||
}
|
||||
|
||||
fn get_painted_tile_buffer(&mut self) -> Box<LayerBuffer> {
|
||||
match self.receiver.recv() {
|
||||
PaintedTileMsgFromWorkerThread(layer_buffer) => layer_buffer,
|
||||
MsgFromWorkerThread::PaintedTile(layer_buffer) => layer_buffer,
|
||||
}
|
||||
}
|
||||
|
||||
fn exit(&mut self) {
|
||||
self.sender.send(ExitMsgToWorkerThread)
|
||||
self.sender.send(MsgToWorkerThread::Exit)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -474,14 +470,14 @@ impl WorkerThread {
|
|||
fn main(&mut self) {
|
||||
loop {
|
||||
match self.receiver.recv() {
|
||||
ExitMsgToWorkerThread => break,
|
||||
PaintTileMsgToWorkerThread(tile, layer_buffer, stacking_context, scale) => {
|
||||
MsgToWorkerThread::Exit => break,
|
||||
MsgToWorkerThread::PaintTile(tile, layer_buffer, stacking_context, scale) => {
|
||||
let draw_target = self.optimize_and_paint_tile(&tile, stacking_context, scale);
|
||||
let buffer = self.create_layer_buffer_for_painted_tile(&tile,
|
||||
layer_buffer,
|
||||
draw_target,
|
||||
scale);
|
||||
self.sender.send(PaintedTileMsgFromWorkerThread(buffer))
|
||||
self.sender.send(MsgFromWorkerThread::PaintedTile(buffer))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -586,10 +582,10 @@ impl WorkerThread {
|
|||
}
|
||||
|
||||
enum MsgToWorkerThread {
|
||||
ExitMsgToWorkerThread,
|
||||
PaintTileMsgToWorkerThread(BufferRequest, Option<Box<LayerBuffer>>, Arc<StackingContext>, f32),
|
||||
Exit,
|
||||
PaintTile(BufferRequest, Option<Box<LayerBuffer>>, Arc<StackingContext>, f32),
|
||||
}
|
||||
|
||||
enum MsgFromWorkerThread {
|
||||
PaintedTileMsgFromWorkerThread(Box<LayerBuffer>),
|
||||
PaintedTile(Box<LayerBuffer>),
|
||||
}
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use self::BreakType::*;
|
||||
use self::GlyphInfo::*;
|
||||
|
||||
use servo_util::vec::*;
|
||||
use servo_util::range;
|
||||
use servo_util::range::{Range, RangeIndex, EachIndex};
|
||||
|
@ -92,9 +89,9 @@ pub type GlyphId = u32;
|
|||
// TODO: unify with bit flags?
|
||||
#[deriving(PartialEq)]
|
||||
pub enum BreakType {
|
||||
BreakTypeNone,
|
||||
BreakTypeNormal,
|
||||
BreakTypeHyphen,
|
||||
None,
|
||||
Normal,
|
||||
Hyphen,
|
||||
}
|
||||
|
||||
static BREAK_TYPE_NONE: u8 = 0x0;
|
||||
|
@ -103,19 +100,19 @@ static BREAK_TYPE_HYPHEN: u8 = 0x2;
|
|||
|
||||
fn break_flag_to_enum(flag: u8) -> BreakType {
|
||||
if (flag & BREAK_TYPE_NORMAL) != 0 {
|
||||
BreakTypeNormal
|
||||
BreakType::Normal
|
||||
} else if (flag & BREAK_TYPE_HYPHEN) != 0 {
|
||||
BreakTypeHyphen
|
||||
BreakType::Hyphen
|
||||
} else {
|
||||
BreakTypeNone
|
||||
BreakType::None
|
||||
}
|
||||
}
|
||||
|
||||
fn break_enum_to_flag(e: BreakType) -> u8 {
|
||||
match e {
|
||||
BreakTypeNone => BREAK_TYPE_NONE,
|
||||
BreakTypeNormal => BREAK_TYPE_NORMAL,
|
||||
BreakTypeHyphen => BREAK_TYPE_HYPHEN,
|
||||
BreakType::None => BREAK_TYPE_NONE,
|
||||
BreakType::Normal => BREAK_TYPE_NORMAL,
|
||||
BreakType::Hyphen => BREAK_TYPE_HYPHEN,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -447,15 +444,15 @@ impl GlyphData {
|
|||
// Rather than eagerly assembling and copying glyph data, it only retrieves
|
||||
// values as they are needed from the GlyphStore, using provided offsets.
|
||||
pub enum GlyphInfo<'a> {
|
||||
SimpleGlyphInfo(&'a GlyphStore, CharIndex),
|
||||
DetailGlyphInfo(&'a GlyphStore, CharIndex, u16),
|
||||
Simple(&'a GlyphStore, CharIndex),
|
||||
Detail(&'a GlyphStore, CharIndex, u16),
|
||||
}
|
||||
|
||||
impl<'a> GlyphInfo<'a> {
|
||||
pub fn id(self) -> GlyphId {
|
||||
match self {
|
||||
SimpleGlyphInfo(store, entry_i) => store.entry_buffer[entry_i.to_uint()].id(),
|
||||
DetailGlyphInfo(store, entry_i, detail_j) => {
|
||||
GlyphInfo::Simple(store, entry_i) => store.entry_buffer[entry_i.to_uint()].id(),
|
||||
GlyphInfo::Detail(store, entry_i, detail_j) => {
|
||||
store.detail_store.get_detailed_glyph_with_index(entry_i, detail_j).id
|
||||
}
|
||||
}
|
||||
|
@ -465,8 +462,8 @@ impl<'a> GlyphInfo<'a> {
|
|||
// FIXME: Resolution conflicts with IteratorUtil trait so adding trailing _
|
||||
pub fn advance(self) -> Au {
|
||||
match self {
|
||||
SimpleGlyphInfo(store, entry_i) => store.entry_buffer[entry_i.to_uint()].advance(),
|
||||
DetailGlyphInfo(store, entry_i, detail_j) => {
|
||||
GlyphInfo::Simple(store, entry_i) => store.entry_buffer[entry_i.to_uint()].advance(),
|
||||
GlyphInfo::Detail(store, entry_i, detail_j) => {
|
||||
store.detail_store.get_detailed_glyph_with_index(entry_i, detail_j).advance
|
||||
}
|
||||
}
|
||||
|
@ -474,8 +471,8 @@ impl<'a> GlyphInfo<'a> {
|
|||
|
||||
pub fn offset(self) -> Option<Point2D<Au>> {
|
||||
match self {
|
||||
SimpleGlyphInfo(_, _) => None,
|
||||
DetailGlyphInfo(store, entry_i, detail_j) => {
|
||||
GlyphInfo::Simple(_, _) => None,
|
||||
GlyphInfo::Detail(store, entry_i, detail_j) => {
|
||||
Some(store.detail_store.get_detailed_glyph_with_index(entry_i, detail_j).offset)
|
||||
}
|
||||
}
|
||||
|
@ -705,7 +702,7 @@ impl<'a> GlyphIterator<'a> {
|
|||
fn next_glyph_range(&mut self) -> Option<(CharIndex, GlyphInfo<'a>)> {
|
||||
match self.glyph_range.as_mut().unwrap().next() {
|
||||
Some(j) => Some((self.char_index,
|
||||
DetailGlyphInfo(self.store, self.char_index, j.get() as u16 /* ??? */))),
|
||||
GlyphInfo::Detail(self.store, self.char_index, j.get() as u16 /* ??? */))),
|
||||
None => {
|
||||
// No more glyphs for current character. Try to get another.
|
||||
self.glyph_range = None;
|
||||
|
@ -744,7 +741,7 @@ impl<'a> Iterator<(CharIndex, GlyphInfo<'a>)> for GlyphIterator<'a> {
|
|||
assert!(i < self.store.char_len());
|
||||
let entry = self.store.entry_buffer[i.to_uint()];
|
||||
if entry.is_simple() {
|
||||
Some((self.char_index, SimpleGlyphInfo(self.store, i)))
|
||||
Some((self.char_index, GlyphInfo::Simple(self.store, i)))
|
||||
} else {
|
||||
// Fall back to the slow path.
|
||||
self.next_complex_glyph(&entry, i)
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use self::CompressionMode::*;
|
||||
|
||||
use text::glyph::CharIndex;
|
||||
|
||||
#[deriving(PartialEq)]
|
||||
|
@ -31,7 +29,7 @@ pub fn transform_text(text: &str,
|
|||
new_line_pos: &mut Vec<CharIndex>)
|
||||
-> bool {
|
||||
let out_whitespace = match mode {
|
||||
CompressNone | DiscardNewline => {
|
||||
CompressionMode::CompressNone | CompressionMode::DiscardNewline => {
|
||||
let mut new_line_index = CharIndex(0);
|
||||
for ch in text.chars() {
|
||||
if is_discardable_char(ch, mode) {
|
||||
|
@ -56,7 +54,7 @@ pub fn transform_text(text: &str,
|
|||
text.len() > 0 && is_in_whitespace(text.char_at_reverse(0), mode)
|
||||
},
|
||||
|
||||
CompressWhitespace | CompressWhitespaceNewline => {
|
||||
CompressionMode::CompressWhitespace | CompressionMode::CompressWhitespaceNewline => {
|
||||
let mut in_whitespace: bool = incoming_whitespace;
|
||||
for ch in text.chars() {
|
||||
// TODO: discard newlines between CJK chars
|
||||
|
@ -92,7 +90,7 @@ pub fn transform_text(text: &str,
|
|||
match (ch, mode) {
|
||||
(' ', _) => true,
|
||||
('\t', _) => true,
|
||||
('\n', CompressWhitespaceNewline) => true,
|
||||
('\n', CompressionMode::CompressWhitespaceNewline) => true,
|
||||
(_, _) => false
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +100,7 @@ pub fn transform_text(text: &str,
|
|||
return true;
|
||||
}
|
||||
match mode {
|
||||
DiscardNewline | CompressWhitespaceNewline => ch == '\n',
|
||||
CompressionMode::DiscardNewline | CompressionMode::CompressWhitespaceNewline => ch == '\n',
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
@ -155,7 +153,7 @@ fn test_transform_compress_none() {
|
|||
"foo bar baz",
|
||||
"foobarbaz\n\n"
|
||||
);
|
||||
let mode = CompressNone;
|
||||
let mode = CompressionMode::CompressNone;
|
||||
|
||||
for test in test_strs.iter() {
|
||||
let mut new_line_pos = vec!();
|
||||
|
@ -188,7 +186,7 @@ fn test_transform_discard_newline() {
|
|||
);
|
||||
|
||||
assert_eq!(test_strs.len(), oracle_strs.len());
|
||||
let mode = DiscardNewline;
|
||||
let mode = CompressionMode::DiscardNewline;
|
||||
|
||||
for (test, oracle) in test_strs.iter().zip(oracle_strs.iter()) {
|
||||
let mut new_line_pos = vec!();
|
||||
|
@ -246,7 +244,7 @@ fn test_transform_compress_whitespace_newline() {
|
|||
"foobarbaz ".to_string()];
|
||||
|
||||
assert_eq!(test_strs.len(), oracle_strs.len());
|
||||
let mode = CompressWhitespaceNewline;
|
||||
let mode = CompressionMode::CompressWhitespaceNewline;
|
||||
|
||||
for i in range(0, test_strs.len()) {
|
||||
let mut new_line_pos = ~[];
|
||||
|
@ -281,7 +279,7 @@ fn test_transform_compress_whitespace_newline_no_incoming() {
|
|||
);
|
||||
|
||||
assert_eq!(test_strs.len(), oracle_strs.len());
|
||||
let mode = CompressWhitespaceNewline;
|
||||
let mode = CompressionMode::CompressWhitespaceNewline;
|
||||
|
||||
for (test, oracle) in test_strs.iter().zip(oracle_strs.iter()) {
|
||||
let mut new_line_pos = vec!();
|
||||
|
|
|
@ -23,13 +23,13 @@ use geom::approxeq::ApproxEq;
|
|||
use geom::{Point2D, Rect, Size2D, SideOffsets2D};
|
||||
use gfx::color;
|
||||
use gfx::display_list::{BOX_SHADOW_INFLATION_FACTOR, BaseDisplayItem, BorderDisplayItem};
|
||||
use gfx::display_list::{BorderDisplayItemClass, BorderRadii, BoxShadowDisplayItem};
|
||||
use gfx::display_list::{BoxShadowDisplayItemClass, DisplayItem, DisplayItemMetadata, DisplayList};
|
||||
use gfx::display_list::{GradientDisplayItem, GradientDisplayItemClass};
|
||||
use gfx::display_list::{GradientStop, ImageDisplayItem, ImageDisplayItemClass, LineDisplayItem};
|
||||
use gfx::display_list::{LineDisplayItemClass, SidewaysLeft};
|
||||
use gfx::display_list::{SidewaysRight, SolidColorDisplayItem, SolidColorDisplayItemClass};
|
||||
use gfx::display_list::{StackingContext, TextDisplayItem, TextDisplayItemClass, Upright};
|
||||
use gfx::display_list::{BorderRadii, BoxShadowDisplayItem};
|
||||
use gfx::display_list::{DisplayItem, DisplayList, DisplayItemMetadata};
|
||||
use gfx::display_list::{GradientDisplayItem};
|
||||
use gfx::display_list::{GradientStop, ImageDisplayItem, LineDisplayItem};
|
||||
use gfx::display_list::{SidewaysLeft};
|
||||
use gfx::display_list::{SidewaysRight, SolidColorDisplayItem};
|
||||
use gfx::display_list::{StackingContext, TextDisplayItem, Upright};
|
||||
use gfx::paint_task::PaintLayer;
|
||||
use servo_msg::compositor_msg::{FixedPosition, Scrollable};
|
||||
use servo_msg::constellation_msg::{ConstellationChan, FrameRectMsg};
|
||||
|
@ -198,7 +198,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
// doesn't have a fragment".
|
||||
let background_color = style.resolve_color(style.get_background().background_color);
|
||||
if !background_color.alpha.approx_eq(&0.0) {
|
||||
display_list.push(SolidColorDisplayItemClass(box SolidColorDisplayItem {
|
||||
display_list.push(DisplayItem::SolidColorClass(box SolidColorDisplayItem {
|
||||
base: BaseDisplayItem::new(*absolute_bounds,
|
||||
DisplayItemMetadata::new(self.node,
|
||||
style,
|
||||
|
@ -314,7 +314,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
};
|
||||
|
||||
// Create the image display item.
|
||||
display_list.push(ImageDisplayItemClass(box ImageDisplayItem {
|
||||
display_list.push(DisplayItem::ImageClass(box ImageDisplayItem {
|
||||
base: BaseDisplayItem::new(bounds,
|
||||
DisplayItemMetadata::new(self.node, style, DefaultCursor),
|
||||
clip_rect),
|
||||
|
@ -424,7 +424,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
let center = Point2D(absolute_bounds.origin.x + absolute_bounds.size.width / 2,
|
||||
absolute_bounds.origin.y + absolute_bounds.size.height / 2);
|
||||
|
||||
let gradient_display_item = GradientDisplayItemClass(box GradientDisplayItem {
|
||||
let gradient_display_item = DisplayItem::GradientClass(box GradientDisplayItem {
|
||||
base: BaseDisplayItem::new(*absolute_bounds,
|
||||
DisplayItemMetadata::new(self.node, style, DefaultCursor),
|
||||
clip_rect),
|
||||
|
@ -450,7 +450,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
let bounds =
|
||||
absolute_bounds.translate(&Point2D(box_shadow.offset_x, box_shadow.offset_y))
|
||||
.inflate(inflation, inflation);
|
||||
list.push(BoxShadowDisplayItemClass(box BoxShadowDisplayItem {
|
||||
list.push(DisplayItem::BoxShadowClass(box BoxShadowDisplayItem {
|
||||
base: BaseDisplayItem::new(bounds,
|
||||
DisplayItemMetadata::new(self.node,
|
||||
style,
|
||||
|
@ -483,7 +483,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
let left_color = style.resolve_color(style.get_border().border_left_color);
|
||||
|
||||
// Append the border to the display list.
|
||||
display_list.push(BorderDisplayItemClass(box BorderDisplayItem {
|
||||
display_list.push(DisplayItem::BorderClass(box BorderDisplayItem {
|
||||
base: BaseDisplayItem::new(*abs_bounds,
|
||||
DisplayItemMetadata::new(self.node, style, DefaultCursor),
|
||||
*clip_rect),
|
||||
|
@ -525,7 +525,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
|
||||
// Append the outline to the display list.
|
||||
let color = style.resolve_color(style.get_outline().outline_color).to_gfx_color();
|
||||
display_list.outlines.push_back(BorderDisplayItemClass(box BorderDisplayItem {
|
||||
display_list.outlines.push_back(DisplayItem::BorderClass(box BorderDisplayItem {
|
||||
base: BaseDisplayItem::new(bounds,
|
||||
DisplayItemMetadata::new(self.node, style, DefaultCursor),
|
||||
*clip_rect),
|
||||
|
@ -551,7 +551,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
fragment_bounds.size);
|
||||
|
||||
// Compute the text fragment bounds and draw a border surrounding them.
|
||||
display_list.content.push_back(BorderDisplayItemClass(box BorderDisplayItem {
|
||||
display_list.content.push_back(DisplayItem::BorderClass(box BorderDisplayItem {
|
||||
base: BaseDisplayItem::new(absolute_fragment_bounds,
|
||||
DisplayItemMetadata::new(self.node, style, DefaultCursor),
|
||||
*clip_rect),
|
||||
|
@ -576,7 +576,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
color: color::rgb(0, 200, 0),
|
||||
style: border_style::dashed,
|
||||
};
|
||||
display_list.content.push_back(LineDisplayItemClass(line_display_item));
|
||||
display_list.content.push_back(DisplayItem::LineClass(line_display_item));
|
||||
}
|
||||
|
||||
fn build_debug_borders_around_fragment(&self,
|
||||
|
@ -592,7 +592,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
fragment_bounds.size);
|
||||
|
||||
// This prints a debug border around the border of this fragment.
|
||||
display_list.content.push_back(BorderDisplayItemClass(box BorderDisplayItem {
|
||||
display_list.content.push_back(DisplayItem::BorderClass(box BorderDisplayItem {
|
||||
base: BaseDisplayItem::new(absolute_fragment_bounds,
|
||||
DisplayItemMetadata::new(self.node,
|
||||
&*self.style,
|
||||
|
@ -776,7 +776,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
+ flow_origin
|
||||
};
|
||||
|
||||
display_list.content.push_back(TextDisplayItemClass(box TextDisplayItem {
|
||||
display_list.content.push_back(DisplayItem::TextClass(box TextDisplayItem {
|
||||
base: BaseDisplayItem::new(absolute_content_box,
|
||||
DisplayItemMetadata::new(self.node,
|
||||
self.style(),
|
||||
|
@ -798,7 +798,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
None => {}
|
||||
Some(color) => {
|
||||
let bounds = rect_to_absolute(self.style.writing_mode, rect());
|
||||
display_list.content.push_back(SolidColorDisplayItemClass(
|
||||
display_list.content.push_back(DisplayItem::SolidColorClass(
|
||||
box SolidColorDisplayItem {
|
||||
base: BaseDisplayItem::new(
|
||||
bounds,
|
||||
|
@ -859,7 +859,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
debug!("(building display list) building image fragment");
|
||||
|
||||
// Place the image into the display list.
|
||||
display_list.content.push_back(ImageDisplayItemClass(box ImageDisplayItem {
|
||||
display_list.content.push_back(DisplayItem::ImageClass(box ImageDisplayItem {
|
||||
base: BaseDisplayItem::new(absolute_content_box,
|
||||
DisplayItemMetadata::new(self.node,
|
||||
&*self.style,
|
||||
|
|
Загрузка…
Ссылка в новой задаче