mirror of
https://github.com/servo/servo.git
synced 2025-08-15 10:25:32 +01:00
Merge pull request #435 from metajack/syntax-futurism
Update to latest Rust
This commit is contained in:
commit
6e395af88c
20 changed files with 113 additions and 143 deletions
2
src/rust
2
src/rust
|
@ -1 +1 @@
|
||||||
Subproject commit 9d966aef060030b1d13a55f6768a8e3afb9a842f
|
Subproject commit d546493096f35e68cbcd9b5d3d7654e7a9345744
|
|
@ -1 +1 @@
|
||||||
Subproject commit e57128019bb804ec99ef1d6cebd57f5e6c221a3e
|
Subproject commit 98e2d7e3870759fe91c93ba520452a700fec8756
|
|
@ -1 +1 @@
|
||||||
Subproject commit 0a95e429655d51e96de45af91a5ee02fad5a99f6
|
Subproject commit aaa25872d7f6ba5eb4c61651f369d8d06e759d87
|
|
@ -25,6 +25,6 @@ pub struct LayerBufferSet {
|
||||||
/// submit them to be drawn to the display.
|
/// submit them to be drawn to the display.
|
||||||
pub trait Compositor {
|
pub trait Compositor {
|
||||||
fn begin_drawing(&self, next_dt: comm::Chan<LayerBufferSet>);
|
fn begin_drawing(&self, next_dt: comm::Chan<LayerBufferSet>);
|
||||||
fn draw(&self, next_dt: comm::Chan<LayerBufferSet>, +draw_me: LayerBufferSet);
|
fn draw(&self, next_dt: comm::Chan<LayerBufferSet>, draw_me: LayerBufferSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -386,7 +386,7 @@ pub impl Font {
|
||||||
advance += glyph.advance();
|
advance += glyph.advance();
|
||||||
}
|
}
|
||||||
let bounds = Rect(Point2D(Au(0), -self.metrics.ascent),
|
let bounds = Rect(Point2D(Au(0), -self.metrics.ascent),
|
||||||
Size2D(advance, self.metrics.ascent + self.metrics.descent));
|
Size2D(advance, self.metrics.ascent + self.metrics.descent));
|
||||||
|
|
||||||
// TODO(Issue #125): support loose and tight bounding boxes; using the
|
// TODO(Issue #125): support loose and tight bounding boxes; using the
|
||||||
// ascent+descent and advance is sometimes too generous and
|
// ascent+descent and advance is sometimes too generous and
|
||||||
|
|
|
@ -96,10 +96,9 @@ impl FontFamily {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_family_variations(@mut self, list: &FontListHandle) {
|
fn load_family_variations(@mut self, list: &FontListHandle) {
|
||||||
let this : &mut FontFamily = self; // FIXME: borrow checker workaround
|
if self.entries.len() > 0 { return; }
|
||||||
if this.entries.len() > 0 { return; }
|
|
||||||
list.load_variations_for_family(self);
|
list.load_variations_for_family(self);
|
||||||
assert!(this.entries.len() > 0);
|
assert!(self.entries.len() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn find_font_for_style(@mut self, list: &FontListHandle, style: &SpecifiedFontStyle)
|
pub fn find_font_for_style(@mut self, list: &FontListHandle, style: &SpecifiedFontStyle)
|
||||||
|
|
|
@ -22,8 +22,8 @@ impl Mul<Au,Au> for Au {
|
||||||
fn mul(&self, other: &Au) -> Au { Au(**self * **other) }
|
fn mul(&self, other: &Au) -> Au { Au(**self * **other) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Quot<Au,Au> for Au {
|
impl Div<Au,Au> for Au {
|
||||||
fn quot(&self, other: &Au) -> Au { Au(**self / **other) }
|
fn div(&self, other: &Au) -> Au { Au(**self / **other) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Rem<Au,Au> for Au {
|
impl Rem<Au,Au> for Au {
|
||||||
|
|
|
@ -16,7 +16,7 @@ use geometry::Au;
|
||||||
use platform::macos::font_context::FontContextHandle;
|
use platform::macos::font_context::FontContextHandle;
|
||||||
use text::glyph::GlyphIndex;
|
use text::glyph::GlyphIndex;
|
||||||
|
|
||||||
use core_foundation::base::{CFIndex, CFWrapper};
|
use core_foundation::base::CFIndex;
|
||||||
use core_foundation::data::CFData;
|
use core_foundation::data::CFData;
|
||||||
use core_foundation::string::UniChar;
|
use core_foundation::string::UniChar;
|
||||||
use core_graphics::data_provider::CGDataProvider;
|
use core_graphics::data_provider::CGDataProvider;
|
||||||
|
@ -106,7 +106,7 @@ impl FontHandleMethods for FontHandle {
|
||||||
|
|
||||||
fn boldness(&self) -> CSSFontWeight {
|
fn boldness(&self) -> CSSFontWeight {
|
||||||
// -1.0 to 1.0
|
// -1.0 to 1.0
|
||||||
let normalized = unsafe { self.ctfont.all_traits().normalized_weight() };
|
let normalized = self.ctfont.all_traits().normalized_weight();
|
||||||
// 0.0 to 9.0
|
// 0.0 to 9.0
|
||||||
let normalized = (normalized + 1.0) / 2.0 * 9.0;
|
let normalized = (normalized + 1.0) / 2.0 * 9.0;
|
||||||
if normalized < 1.0 { return FontWeight100; }
|
if normalized < 1.0 { return FontWeight100; }
|
||||||
|
@ -146,13 +146,11 @@ impl FontHandleMethods for FontHandle {
|
||||||
|
|
||||||
fn glyph_h_advance(&self, glyph: GlyphIndex) -> Option<FractionalPixel> {
|
fn glyph_h_advance(&self, glyph: GlyphIndex) -> Option<FractionalPixel> {
|
||||||
let glyphs = [glyph as CGGlyph];
|
let glyphs = [glyph as CGGlyph];
|
||||||
unsafe {
|
let advance = self.ctfont.get_advances_for_glyphs(kCTFontDefaultOrientation,
|
||||||
let advance = self.ctfont.get_advances_for_glyphs(kCTFontDefaultOrientation,
|
&glyphs[0],
|
||||||
&glyphs[0],
|
ptr::null(),
|
||||||
ptr::null(),
|
1);
|
||||||
1);
|
Some(advance as FractionalPixel)
|
||||||
return Some(advance as FractionalPixel);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_metrics(&self) -> FontMetrics {
|
fn get_metrics(&self) -> FontMetrics {
|
||||||
|
|
|
@ -42,11 +42,9 @@ pub impl FontListHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_variations_for_family(&self, family: @mut FontFamily) {
|
fn load_variations_for_family(&self, family: @mut FontFamily) {
|
||||||
let fam: &mut FontFamily = family; // FIXME: borrow checker workaround
|
debug!("Looking for faces of family: %s", family.family_name);
|
||||||
let family_name = &fam.family_name;
|
|
||||||
debug!("Looking for faces of family: %s", *family_name);
|
|
||||||
|
|
||||||
let family_collection = core_text::font_collection::create_for_family(*family_name);
|
let family_collection = core_text::font_collection::create_for_family(family.family_name);
|
||||||
for family_collection.get_descriptors().each |descref: &CTFontDescriptorRef| {
|
for family_collection.get_descriptors().each |descref: &CTFontDescriptorRef| {
|
||||||
let desc = CFWrapper::wrap_shared(*descref);
|
let desc = CFWrapper::wrap_shared(*descref);
|
||||||
let font = core_text::font::new_from_descriptor(&desc, 0.0);
|
let font = core_text::font::new_from_descriptor(&desc, 0.0);
|
||||||
|
|
|
@ -373,20 +373,13 @@ impl ImageCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
priv fn purge_waiters(&self, url: Url, f: &fn() -> ImageResponseMsg) {
|
priv fn purge_waiters(&self, url: Url, f: &fn() -> ImageResponseMsg) {
|
||||||
match self.wait_map.find(&url) {
|
match self.wait_map.pop(&url) {
|
||||||
Some(waiters) => {
|
Some(waiters) => {
|
||||||
let waiters = *waiters;
|
for waiters.each |response| {
|
||||||
let mut new_waiters = ~[];
|
response.send(f());
|
||||||
new_waiters <-> *waiters;
|
}
|
||||||
|
|
||||||
for new_waiters.each |response| {
|
|
||||||
response.send(f());
|
|
||||||
}
|
}
|
||||||
|
None => ()
|
||||||
*waiters <-> new_waiters;
|
|
||||||
self.wait_map.remove(&url);
|
|
||||||
}
|
|
||||||
None => ()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,13 +403,11 @@ impl ImageCache {
|
||||||
|
|
||||||
Prefetching(DoDecode) | Decoding => {
|
Prefetching(DoDecode) | Decoding => {
|
||||||
// We don't have this image yet
|
// We don't have this image yet
|
||||||
match self.wait_map.find(&url) {
|
if self.wait_map.contains_key(&url) {
|
||||||
Some(waiters) => {
|
let waiters = self.wait_map.find_mut(&url).unwrap();
|
||||||
vec::push(*waiters, response);
|
waiters.push(response);
|
||||||
}
|
} else {
|
||||||
None => {
|
self.wait_map.insert(url, @mut ~[response]);
|
||||||
self.wait_map.insert(url, @mut ~[response]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,12 +76,9 @@ pub impl LocalImageCache {
|
||||||
|
|
||||||
match state.last_response {
|
match state.last_response {
|
||||||
ImageReady(ref image) => {
|
ImageReady(ref image) => {
|
||||||
// FIXME: appease borrowck
|
let (port, chan) = comm::stream();
|
||||||
unsafe {
|
chan.send(ImageReady(clone_arc(image)));
|
||||||
let (port, chan) = comm::stream();
|
return port;
|
||||||
chan.send(ImageReady(clone_arc(image)));
|
|
||||||
return port;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ImageNotReady => {
|
ImageNotReady => {
|
||||||
if last_round == self.round_number {
|
if last_round == self.round_number {
|
||||||
|
@ -138,18 +135,14 @@ pub impl LocalImageCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
priv fn get_state(&self, url: &Url) -> @mut ImageState {
|
priv fn get_state(&self, url: &Url) -> @mut ImageState {
|
||||||
match self.state_map.find(url) {
|
*do self.state_map.find_or_insert_with(url.clone()) |_| {
|
||||||
Some(state) => *state,
|
let new_state = @mut ImageState {
|
||||||
None => {
|
prefetched: false,
|
||||||
let new_state = @mut ImageState {
|
decoded: false,
|
||||||
prefetched: false,
|
last_request_round: 0,
|
||||||
decoded: false,
|
last_response: ImageNotReady
|
||||||
last_request_round: 0,
|
};
|
||||||
last_response: ImageNotReady
|
new_state
|
||||||
};
|
|
||||||
self.state_map.insert(copy *url, new_state);
|
|
||||||
self.get_state(url)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ Create a URL object from a string. Does various helpful browsery things like
|
||||||
*/
|
*/
|
||||||
#[allow(non_implicitly_copyable_typarams)]
|
#[allow(non_implicitly_copyable_typarams)]
|
||||||
pub fn make_url(str_url: ~str, current_url: Option<Url>) -> Url {
|
pub fn make_url(str_url: ~str, current_url: Option<Url>) -> Url {
|
||||||
let mut schm = url::get_scheme(str_url);
|
let schm = url::get_scheme(str_url);
|
||||||
let str_url = if result::is_err(&schm) {
|
let str_url = if result::is_err(&schm) {
|
||||||
if current_url.is_none() {
|
if current_url.is_none() {
|
||||||
// Assume we've been given a file path. If it's absolute just return
|
// Assume we've been given a file path. If it's absolute just return
|
||||||
|
|
|
@ -288,7 +288,10 @@ fn Surface(backend: BackendType) -> Surface {
|
||||||
/// A function for spawning into the platform's main thread.
|
/// A function for spawning into the platform's main thread.
|
||||||
fn on_osmain<T: Owned>(f: ~fn(po: Port<T>)) -> Chan<T> {
|
fn on_osmain<T: Owned>(f: ~fn(po: Port<T>)) -> Chan<T> {
|
||||||
let (setup_po, setup_ch) = comm::stream();
|
let (setup_po, setup_ch) = comm::stream();
|
||||||
do task::task().sched_mode(task::PlatformThread).spawn {
|
// FIXME: rust#6399
|
||||||
|
let mut main_task = task::task();
|
||||||
|
main_task.sched_mode(task::PlatformThread);
|
||||||
|
do main_task.spawn {
|
||||||
let (po, ch) = comm::stream();
|
let (po, ch) = comm::stream();
|
||||||
setup_ch.send(ch);
|
setup_ch.send(ch);
|
||||||
f(po);
|
f(po);
|
||||||
|
|
|
@ -65,7 +65,10 @@ pub fn ContentTask(layout_task: LayoutTask,
|
||||||
let dom_event_port = Cell(dom_event_port);
|
let dom_event_port = Cell(dom_event_port);
|
||||||
let dom_event_chan = Cell(dom_event_chan);
|
let dom_event_chan = Cell(dom_event_chan);
|
||||||
|
|
||||||
do task().sched_mode(SingleThreaded).spawn {
|
// FIXME: rust#6399
|
||||||
|
let mut the_task = task();
|
||||||
|
the_task.sched_mode(SingleThreaded);
|
||||||
|
do the_task.spawn {
|
||||||
let content = Content(layout_task.clone(),
|
let content = Content(layout_task.clone(),
|
||||||
control_port.take(),
|
control_port.take(),
|
||||||
control_chan_copy.clone(),
|
control_chan_copy.clone(),
|
||||||
|
@ -150,7 +153,7 @@ pub fn Content(layout_task: LayoutTask,
|
||||||
};
|
};
|
||||||
|
|
||||||
cx.set_cx_private(ptr::to_unsafe_ptr(&*content) as *());
|
cx.set_cx_private(ptr::to_unsafe_ptr(&*content) as *());
|
||||||
unsafe { task::local_data::local_data_set(global_content_key, cast::transmute(content)); }
|
unsafe { local_data::local_data_set(global_content_key, cast::transmute(content)); }
|
||||||
|
|
||||||
content
|
content
|
||||||
}
|
}
|
||||||
|
@ -159,7 +162,7 @@ fn global_content_key(_: @Content) {}
|
||||||
|
|
||||||
pub fn global_content() -> @Content {
|
pub fn global_content() -> @Content {
|
||||||
unsafe {
|
unsafe {
|
||||||
return task::local_data::local_data_get(global_content_key).get();
|
return local_data::local_data_get(global_content_key).get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +173,7 @@ pub fn task_from_context(cx: *JSContext) -> *mut Content {
|
||||||
#[unsafe_destructor]
|
#[unsafe_destructor]
|
||||||
impl Drop for Content {
|
impl Drop for Content {
|
||||||
fn finalize(&self) {
|
fn finalize(&self) {
|
||||||
unsafe { task::local_data::local_data_pop(global_content_key) };
|
unsafe { local_data::local_data_pop(global_content_key) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +186,7 @@ pub impl Content {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_msg(&mut self) -> bool {
|
fn handle_msg(&mut self) -> bool {
|
||||||
match select2i(&self.control_port, &self.event_port) {
|
match select2i(&mut self.control_port, &mut self.event_port) {
|
||||||
either::Left(*) => {
|
either::Left(*) => {
|
||||||
let msg = self.control_port.recv();
|
let msg = self.control_port.recv();
|
||||||
self.handle_control_msg(msg)
|
self.handle_control_msg(msg)
|
||||||
|
|
|
@ -608,8 +608,8 @@ pub fn WrapNewBindingObject(cx: *JSContext, scope: *JSObject,
|
||||||
mut value: @mut CacheableWrapper,
|
mut value: @mut CacheableWrapper,
|
||||||
vp: *mut JSVal) -> bool {
|
vp: *mut JSVal) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut cache = value.get_wrappercache();
|
let cache = value.get_wrappercache();
|
||||||
let mut obj = cache.get_wrapper();
|
let obj = cache.get_wrapper();
|
||||||
if obj.is_not_null() /*&& js::GetObjectCompartment(obj) == js::GetObjectCompartment(scope)*/ {
|
if obj.is_not_null() /*&& js::GetObjectCompartment(obj) == js::GetObjectCompartment(scope)*/ {
|
||||||
*vp = RUST_OBJECT_TO_JSVAL(obj);
|
*vp = RUST_OBJECT_TO_JSVAL(obj);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -65,14 +65,12 @@ impl BlockLayout for FlowContext {
|
||||||
fn with_block_box(&self, callback: &fn(box: RenderBox) -> ()) -> () {
|
fn with_block_box(&self, callback: &fn(box: RenderBox) -> ()) -> () {
|
||||||
match *self {
|
match *self {
|
||||||
BlockFlow(*) => {
|
BlockFlow(*) => {
|
||||||
let box = self.block().box;
|
for self.block().box.each |&b| {
|
||||||
for box.each |&b| {
|
|
||||||
callback(b);
|
callback(b);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
RootFlow(*) => {
|
RootFlow(*) => {
|
||||||
let mut box = self.root().box;
|
for self.root().box.each |&b| {
|
||||||
for box.each |&b| {
|
|
||||||
callback(b);
|
callback(b);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -30,7 +30,7 @@ use servo_net::image::holder::ImageHolder;
|
||||||
use servo_net::local_image_cache::LocalImageCache;
|
use servo_net::local_image_cache::LocalImageCache;
|
||||||
use servo_util::range::*;
|
use servo_util::range::*;
|
||||||
use std::arc;
|
use std::arc;
|
||||||
use std::cmp::FuzzyEq;
|
use core::cmp::ApproxEq;
|
||||||
use std::net::url::Url;
|
use std::net::url::Url;
|
||||||
|
|
||||||
/// Render boxes (`struct RenderBox`) are the leaves of the layout tree. They cannot position
|
/// Render boxes (`struct RenderBox`) are the leaves of the layout tree. They cannot position
|
||||||
|
@ -168,15 +168,12 @@ pub impl RenderBox {
|
||||||
match *self {
|
match *self {
|
||||||
GenericRenderBoxClass(generic_box) => callback(generic_box),
|
GenericRenderBoxClass(generic_box) => callback(generic_box),
|
||||||
ImageRenderBoxClass(image_box) => {
|
ImageRenderBoxClass(image_box) => {
|
||||||
let image_box = &*image_box; // FIXME: Borrow check workaround.
|
|
||||||
callback(&image_box.base)
|
callback(&image_box.base)
|
||||||
}
|
}
|
||||||
TextRenderBoxClass(text_box) => {
|
TextRenderBoxClass(text_box) => {
|
||||||
let text_box = &*text_box; // FIXME: Borrow check workaround.
|
|
||||||
callback(&text_box.base)
|
callback(&text_box.base)
|
||||||
}
|
}
|
||||||
UnscannedTextRenderBoxClass(unscanned_text_box) => {
|
UnscannedTextRenderBoxClass(unscanned_text_box) => {
|
||||||
let unscanned_text_box = &*unscanned_text_box; // FIXME: Borrow check workaround.
|
|
||||||
callback(&unscanned_text_box.base)
|
callback(&unscanned_text_box.base)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,16 +185,12 @@ pub impl RenderBox {
|
||||||
match *self {
|
match *self {
|
||||||
GenericRenderBoxClass(generic_box) => callback(generic_box),
|
GenericRenderBoxClass(generic_box) => callback(generic_box),
|
||||||
ImageRenderBoxClass(image_box) => {
|
ImageRenderBoxClass(image_box) => {
|
||||||
let image_box = &mut *image_box; // FIXME: Borrow check workaround.
|
|
||||||
callback(&mut image_box.base)
|
callback(&mut image_box.base)
|
||||||
}
|
}
|
||||||
TextRenderBoxClass(text_box) => {
|
TextRenderBoxClass(text_box) => {
|
||||||
let text_box = &mut *text_box; // FIXME: Borrow check workaround.
|
|
||||||
callback(&mut text_box.base)
|
callback(&mut text_box.base)
|
||||||
}
|
}
|
||||||
UnscannedTextRenderBoxClass(unscanned_text_box) => {
|
UnscannedTextRenderBoxClass(unscanned_text_box) => {
|
||||||
// FIXME: Borrow check workaround.
|
|
||||||
let unscanned_text_box = &mut *unscanned_text_box;
|
|
||||||
callback(&mut unscanned_text_box.base)
|
callback(&mut unscanned_text_box.base)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,7 +231,6 @@ pub impl RenderBox {
|
||||||
fn is_whitespace_only(&self) -> bool {
|
fn is_whitespace_only(&self) -> bool {
|
||||||
match *self {
|
match *self {
|
||||||
UnscannedTextRenderBoxClass(unscanned_text_box) => {
|
UnscannedTextRenderBoxClass(unscanned_text_box) => {
|
||||||
let mut unscanned_text_box = &mut *unscanned_text_box; // FIXME: Borrow check.
|
|
||||||
unscanned_text_box.text.is_whitespace()
|
unscanned_text_box.text.is_whitespace()
|
||||||
}
|
}
|
||||||
_ => false
|
_ => false
|
||||||
|
@ -269,8 +261,6 @@ pub impl RenderBox {
|
||||||
}
|
}
|
||||||
|
|
||||||
TextRenderBoxClass(text_box) => {
|
TextRenderBoxClass(text_box) => {
|
||||||
let text_box = &mut *text_box; // FIXME: Borrow check.
|
|
||||||
|
|
||||||
let mut pieces_processed_count: uint = 0;
|
let mut pieces_processed_count: uint = 0;
|
||||||
let mut remaining_width: Au = max_width;
|
let mut remaining_width: Au = max_width;
|
||||||
let mut left_range = Range::new(text_box.text_data.range.begin(), 0);
|
let mut left_range = Range::new(text_box.text_data.range.begin(), 0);
|
||||||
|
@ -379,7 +369,6 @@ pub impl RenderBox {
|
||||||
}
|
}
|
||||||
|
|
||||||
TextRenderBoxClass(text_box) => {
|
TextRenderBoxClass(text_box) => {
|
||||||
let mut text_box = &mut *text_box; // FIXME: Borrow check.
|
|
||||||
text_box.text_data.run.min_width_for_range(&text_box.text_data.range)
|
text_box.text_data.run.min_width_for_range(&text_box.text_data.range)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,8 +390,6 @@ pub impl RenderBox {
|
||||||
}
|
}
|
||||||
|
|
||||||
TextRenderBoxClass(text_box) => {
|
TextRenderBoxClass(text_box) => {
|
||||||
let mut text_box = &mut *text_box; // FIXME: Borrow check bug.
|
|
||||||
|
|
||||||
// A text box cannot span lines, so assume that this is an unsplit text box.
|
// A text box cannot span lines, so assume that this is an unsplit text box.
|
||||||
//
|
//
|
||||||
// TODO: If text boxes have been split to wrap lines, then they could report a
|
// TODO: If text boxes have been split to wrap lines, then they could report a
|
||||||
|
@ -567,8 +554,6 @@ pub impl RenderBox {
|
||||||
match *self {
|
match *self {
|
||||||
UnscannedTextRenderBoxClass(*) => fail!(~"Shouldn't see unscanned boxes here."),
|
UnscannedTextRenderBoxClass(*) => fail!(~"Shouldn't see unscanned boxes here."),
|
||||||
TextRenderBoxClass(text_box) => {
|
TextRenderBoxClass(text_box) => {
|
||||||
let text_box = &mut *text_box; // FIXME: Borrow check bug.
|
|
||||||
|
|
||||||
let nearest_ancestor_element = self.nearest_ancestor_element();
|
let nearest_ancestor_element = self.nearest_ancestor_element();
|
||||||
let color = nearest_ancestor_element.style().color().to_gfx_color();
|
let color = nearest_ancestor_element.style().color().to_gfx_color();
|
||||||
|
|
||||||
|
@ -650,7 +635,7 @@ pub impl RenderBox {
|
||||||
let nearest_ancestor_element = self.nearest_ancestor_element();
|
let nearest_ancestor_element = self.nearest_ancestor_element();
|
||||||
|
|
||||||
let bgcolor = nearest_ancestor_element.style().background_color();
|
let bgcolor = nearest_ancestor_element.style().background_color();
|
||||||
if !bgcolor.alpha.fuzzy_eq(&0.0) {
|
if !bgcolor.alpha.approx_eq(&0.0) {
|
||||||
let mut l = list.take(); // FIXME: use with_mut_ref when available
|
let mut l = list.take(); // FIXME: use with_mut_ref when available
|
||||||
l.append_item(~DisplayItem::new_SolidColor(absolute_bounds, bgcolor.to_gfx_color()));
|
l.append_item(~DisplayItem::new_SolidColor(absolute_bounds, bgcolor.to_gfx_color()));
|
||||||
list.put_back(l);
|
list.put_back(l);
|
||||||
|
@ -783,13 +768,11 @@ impl DebugMethods for RenderBox {
|
||||||
GenericRenderBoxClass(*) => ~"GenericRenderBox",
|
GenericRenderBoxClass(*) => ~"GenericRenderBox",
|
||||||
ImageRenderBoxClass(*) => ~"ImageRenderBox",
|
ImageRenderBoxClass(*) => ~"ImageRenderBox",
|
||||||
TextRenderBoxClass(text_box) => {
|
TextRenderBoxClass(text_box) => {
|
||||||
let mut text_box = &mut *text_box; // FIXME: Borrow check bug.
|
|
||||||
fmt!("TextRenderBox(text=%s)", str::substr(text_box.text_data.run.text,
|
fmt!("TextRenderBox(text=%s)", str::substr(text_box.text_data.run.text,
|
||||||
text_box.text_data.range.begin(),
|
text_box.text_data.range.begin(),
|
||||||
text_box.text_data.range.length()))
|
text_box.text_data.range.length()))
|
||||||
}
|
}
|
||||||
UnscannedTextRenderBoxClass(text_box) => {
|
UnscannedTextRenderBoxClass(text_box) => {
|
||||||
let mut text_box = &mut *text_box; // FIXME: Borrow check bug.
|
|
||||||
fmt!("UnscannedTextRenderBox(%s)", text_box.text)
|
fmt!("UnscannedTextRenderBox(%s)", text_box.text)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -125,7 +125,6 @@ impl BoxGenerator {
|
||||||
// depending on flow, make a box for this node.
|
// depending on flow, make a box for this node.
|
||||||
match self.flow {
|
match self.flow {
|
||||||
InlineFlow(inline) => {
|
InlineFlow(inline) => {
|
||||||
let mut inline = &mut *inline;
|
|
||||||
let node_range_start = inline.boxes.len();
|
let node_range_start = inline.boxes.len();
|
||||||
self.range_stack.push(node_range_start);
|
self.range_stack.push(node_range_start);
|
||||||
|
|
||||||
|
@ -387,24 +386,38 @@ pub impl LayoutTreeBuilder {
|
||||||
// check first/last child for whitespace-ness
|
// check first/last child for whitespace-ness
|
||||||
for first_child.each |first_flow| {
|
for first_child.each |first_flow| {
|
||||||
if first_flow.starts_inline_flow() {
|
if first_flow.starts_inline_flow() {
|
||||||
let boxes = &mut first_flow.inline().boxes;
|
// FIXME: workaround for rust#6393
|
||||||
|
let mut do_remove = false;
|
||||||
|
{
|
||||||
|
let boxes = &first_flow.inline().boxes;
|
||||||
if boxes.len() == 1 && boxes[0].is_whitespace_only() {
|
if boxes.len() == 1 && boxes[0].is_whitespace_only() {
|
||||||
debug!("LayoutTreeBuilder: pruning whitespace-only first child flow \
|
debug!("LayoutTreeBuilder: pruning whitespace-only first child flow \
|
||||||
f%d from parent f%d",
|
f%d from parent f%d",
|
||||||
first_flow.id(),
|
first_flow.id(),
|
||||||
parent_flow.id());
|
parent_flow.id());
|
||||||
|
do_remove = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (do_remove) {
|
||||||
parent_flow.remove_child(*first_flow);
|
parent_flow.remove_child(*first_flow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for last_child.each |last_flow| {
|
for last_child.each |last_flow| {
|
||||||
if last_flow.starts_inline_flow() {
|
if last_flow.starts_inline_flow() {
|
||||||
let boxes = &mut last_flow.inline().boxes;
|
// FIXME: workaround for rust#6393
|
||||||
|
let mut do_remove = false;
|
||||||
|
{
|
||||||
|
let boxes = &last_flow.inline().boxes;
|
||||||
if boxes.len() == 1 && boxes.last().is_whitespace_only() {
|
if boxes.len() == 1 && boxes.last().is_whitespace_only() {
|
||||||
debug!("LayoutTreeBuilder: pruning whitespace-only last child flow \
|
debug!("LayoutTreeBuilder: pruning whitespace-only last child flow \
|
||||||
f%d from parent f%d",
|
f%d from parent f%d",
|
||||||
last_flow.id(),
|
last_flow.id(),
|
||||||
parent_flow.id());
|
parent_flow.id());
|
||||||
|
do_remove = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (do_remove) {
|
||||||
parent_flow.remove_child(*last_flow);
|
parent_flow.remove_child(*last_flow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,17 +76,14 @@ impl TreeNodeRef<FlowData> for FlowContext {
|
||||||
match *self {
|
match *self {
|
||||||
AbsoluteFlow(info) => callback(info),
|
AbsoluteFlow(info) => callback(info),
|
||||||
BlockFlow(info) => {
|
BlockFlow(info) => {
|
||||||
let info = &*info; // FIXME: Borrow check workaround.
|
|
||||||
callback(&info.common)
|
callback(&info.common)
|
||||||
}
|
}
|
||||||
FloatFlow(info) => callback(info),
|
FloatFlow(info) => callback(info),
|
||||||
InlineBlockFlow(info) => callback(info),
|
InlineBlockFlow(info) => callback(info),
|
||||||
InlineFlow(info) => {
|
InlineFlow(info) => {
|
||||||
let info = &*info; // FIXME: Borrow check workaround.
|
|
||||||
callback(&info.common)
|
callback(&info.common)
|
||||||
}
|
}
|
||||||
RootFlow(info) => {
|
RootFlow(info) => {
|
||||||
let info = &*info; // FIXME: Borrow check workaround.
|
|
||||||
callback(&info.common)
|
callback(&info.common)
|
||||||
}
|
}
|
||||||
TableFlow(info) => callback(info),
|
TableFlow(info) => callback(info),
|
||||||
|
@ -96,17 +93,14 @@ impl TreeNodeRef<FlowData> for FlowContext {
|
||||||
match *self {
|
match *self {
|
||||||
AbsoluteFlow(info) => callback(info),
|
AbsoluteFlow(info) => callback(info),
|
||||||
BlockFlow(info) => {
|
BlockFlow(info) => {
|
||||||
let info = &mut *info; // FIXME: Borrow check workaround.
|
|
||||||
callback(&mut info.common)
|
callback(&mut info.common)
|
||||||
}
|
}
|
||||||
FloatFlow(info) => callback(info),
|
FloatFlow(info) => callback(info),
|
||||||
InlineBlockFlow(info) => callback(info),
|
InlineBlockFlow(info) => callback(info),
|
||||||
InlineFlow(info) => {
|
InlineFlow(info) => {
|
||||||
let info = &mut *info; // FIXME: Borrow check workaround.
|
|
||||||
callback(&mut info.common)
|
callback(&mut info.common)
|
||||||
}
|
}
|
||||||
RootFlow(info) => {
|
RootFlow(info) => {
|
||||||
let info = &mut *info; // FIXME: Borrow check workaround.
|
|
||||||
callback(&mut info.common)
|
callback(&mut info.common)
|
||||||
}
|
}
|
||||||
TableFlow(info) => callback(info),
|
TableFlow(info) => callback(info),
|
||||||
|
@ -388,7 +382,6 @@ impl DebugMethods for FlowContext {
|
||||||
fn debug_str(&self) -> ~str {
|
fn debug_str(&self) -> ~str {
|
||||||
let repr = match *self {
|
let repr = match *self {
|
||||||
InlineFlow(inline) => {
|
InlineFlow(inline) => {
|
||||||
let inline = &mut *inline;
|
|
||||||
let mut s = inline.boxes.foldl(~"InlineFlow(children=", |s, box| {
|
let mut s = inline.boxes.foldl(~"InlineFlow(children=", |s, box| {
|
||||||
fmt!("%s b%d", *s, box.id())
|
fmt!("%s b%d", *s, box.id())
|
||||||
});
|
});
|
||||||
|
@ -396,14 +389,12 @@ impl DebugMethods for FlowContext {
|
||||||
s
|
s
|
||||||
},
|
},
|
||||||
BlockFlow(block) => {
|
BlockFlow(block) => {
|
||||||
let block = &mut *block;
|
|
||||||
match block.box {
|
match block.box {
|
||||||
Some(box) => fmt!("BlockFlow(box=b%d)", box.id()),
|
Some(box) => fmt!("BlockFlow(box=b%d)", box.id()),
|
||||||
None => ~"BlockFlow",
|
None => ~"BlockFlow",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
RootFlow(root) => {
|
RootFlow(root) => {
|
||||||
let root = &mut *root;
|
|
||||||
match root.box {
|
match root.box {
|
||||||
Some(box) => fmt!("RootFlow(box=b%d)", box.id()),
|
Some(box) => fmt!("RootFlow(box=b%d)", box.id()),
|
||||||
None => ~"RootFlow",
|
None => ~"RootFlow",
|
||||||
|
|
|
@ -173,7 +173,7 @@ impl TextRunScanner {
|
||||||
|
|
||||||
impl TextRunScanner {
|
impl TextRunScanner {
|
||||||
fn scan_for_runs(&mut self, ctx: &mut LayoutContext, flow: FlowContext) {
|
fn scan_for_runs(&mut self, ctx: &mut LayoutContext, flow: FlowContext) {
|
||||||
let inline = &mut *flow.inline();
|
let inline = flow.inline();
|
||||||
assert!(inline.boxes.len() > 0);
|
assert!(inline.boxes.len() > 0);
|
||||||
debug!("TextRunScanner: scanning %u boxes for text runs...", inline.boxes.len());
|
debug!("TextRunScanner: scanning %u boxes for text runs...", inline.boxes.len());
|
||||||
|
|
||||||
|
@ -334,8 +334,7 @@ impl TextRunScanner {
|
||||||
debug!("------------------");
|
debug!("------------------");
|
||||||
|
|
||||||
debug!("--- Elem ranges: ---");
|
debug!("--- Elem ranges: ---");
|
||||||
let elems: &mut ElementMapping = &mut flow.inline().elems;
|
for flow.inline().elems.eachi_mut |i: uint, nr: &NodeRange| {
|
||||||
for elems.eachi_mut |i: uint, nr: &NodeRange| {
|
|
||||||
debug!("%u: %? --> %s", i, nr.range, nr.node.debug_str()); ()
|
debug!("%u: %? --> %s", i, nr.range, nr.node.debug_str()); ()
|
||||||
}
|
}
|
||||||
debug!("--------------------");
|
debug!("--------------------");
|
||||||
|
@ -386,43 +385,46 @@ impl LineboxScanner {
|
||||||
pub fn scan_for_lines(&mut self, ctx: &LayoutContext) {
|
pub fn scan_for_lines(&mut self, ctx: &LayoutContext) {
|
||||||
self.reset_scanner();
|
self.reset_scanner();
|
||||||
|
|
||||||
let boxes = &mut self.flow.inline().boxes;
|
{ // FIXME: manually control borrow length
|
||||||
let mut i = 0u;
|
let inline: &InlineFlowData = self.flow.inline();
|
||||||
|
let mut i = 0u;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
// acquire the next box to lay out from work list or box list
|
// acquire the next box to lay out from work list or box list
|
||||||
let cur_box = if self.work_list.is_empty() {
|
let cur_box = if self.work_list.is_empty() {
|
||||||
if i == boxes.len() {
|
if i == inline.boxes.len() {
|
||||||
break
|
break
|
||||||
|
}
|
||||||
|
let box = inline.boxes[i]; i += 1;
|
||||||
|
debug!("LineboxScanner: Working with box from box list: b%d", box.id());
|
||||||
|
box
|
||||||
|
} else {
|
||||||
|
let box = self.work_list.pop_front();
|
||||||
|
debug!("LineboxScanner: Working with box from work list: b%d", box.id());
|
||||||
|
box
|
||||||
|
};
|
||||||
|
|
||||||
|
let box_was_appended = self.try_append_to_line(ctx, cur_box);
|
||||||
|
if !box_was_appended {
|
||||||
|
debug!("LineboxScanner: Box wasn't appended, because line %u was full.",
|
||||||
|
self.line_spans.len());
|
||||||
|
self.flush_current_line();
|
||||||
|
} else {
|
||||||
|
debug!("LineboxScanner: appended a box to line %u", self.line_spans.len());
|
||||||
}
|
}
|
||||||
let box = boxes[i]; i += 1;
|
}
|
||||||
debug!("LineboxScanner: Working with box from box list: b%d", box.id());
|
|
||||||
box
|
|
||||||
} else {
|
|
||||||
let box = self.work_list.pop_front();
|
|
||||||
debug!("LineboxScanner: Working with box from work list: b%d", box.id());
|
|
||||||
box
|
|
||||||
};
|
|
||||||
|
|
||||||
let box_was_appended = self.try_append_to_line(ctx, cur_box);
|
if self.pending_line.range.length() > 0 {
|
||||||
if !box_was_appended {
|
debug!("LineboxScanner: Partially full linebox %u left at end of scanning.",
|
||||||
debug!("LineboxScanner: Box wasn't appended, because line %u was full.",
|
|
||||||
self.line_spans.len());
|
self.line_spans.len());
|
||||||
self.flush_current_line();
|
self.flush_current_line();
|
||||||
} else {
|
|
||||||
debug!("LineboxScanner: appended a box to line %u", self.line_spans.len());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.pending_line.range.length() > 0 {
|
{ // FIXME: scope the borrow
|
||||||
debug!("LineboxScanner: Partially full linebox %u left at end of scanning.",
|
let inline: &mut InlineFlowData = self.flow.inline();
|
||||||
self.line_spans.len());
|
inline.elems.repair_for_box_changes(inline.boxes, self.new_boxes);
|
||||||
self.flush_current_line();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let boxes = &mut self.flow.inline().boxes;
|
|
||||||
let elems = &mut self.flow.inline().elems;
|
|
||||||
elems.repair_for_box_changes(*boxes, self.new_boxes);
|
|
||||||
self.swap_out_results();
|
self.swap_out_results();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,10 +433,9 @@ impl LineboxScanner {
|
||||||
self.line_spans.len(),
|
self.line_spans.len(),
|
||||||
self.flow.id());
|
self.flow.id());
|
||||||
|
|
||||||
let inline_boxes = &mut self.flow.inline().boxes;
|
let inline: &mut InlineFlowData = self.flow.inline();
|
||||||
util::swap(inline_boxes, &mut self.new_boxes);
|
util::swap(&mut inline.boxes, &mut self.new_boxes);
|
||||||
let lines = &mut self.flow.inline().lines;
|
util::swap(&mut inline.lines, &mut self.line_spans);
|
||||||
util::swap(lines, &mut self.line_spans);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flush_current_line(&mut self) {
|
fn flush_current_line(&mut self) {
|
||||||
|
@ -763,7 +764,6 @@ impl InlineFlowData {
|
||||||
// TODO: We can use font metrics directly instead of re-measuring for the
|
// TODO: We can use font metrics directly instead of re-measuring for the
|
||||||
// bounding box.
|
// bounding box.
|
||||||
TextRenderBoxClass(text_box) => {
|
TextRenderBoxClass(text_box) => {
|
||||||
let text_box = &mut *text_box; // FIXME: borrow check workaround
|
|
||||||
let range = &text_box.text_data.range;
|
let range = &text_box.text_data.range;
|
||||||
let run = &text_box.text_data.run;
|
let run = &text_box.text_data.run;
|
||||||
let text_bounds = run.metrics_for_range(range).bounding_box;
|
let text_bounds = run.metrics_for_range(range).bounding_box;
|
||||||
|
@ -814,7 +814,7 @@ impl InlineFlowData {
|
||||||
self.common.position.size.height = cur_y;
|
self.common.position.size.height = cur_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_display_list_inline(&mut self,
|
pub fn build_display_list_inline(&self,
|
||||||
builder: &DisplayListBuilder,
|
builder: &DisplayListBuilder,
|
||||||
dirty: &Rect<Au>,
|
dirty: &Rect<Au>,
|
||||||
offset: &Point2D<Au>,
|
offset: &Point2D<Au>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue