From 1c1a9786690b0c625b8f5aadf26664978967bca9 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 27 Jun 2012 12:09:38 -0700 Subject: [PATCH] servo: Update for languages changes. Build still busted Source-Repo: https://github.com/servo/servo Source-Revision: 259ba8ce9332ae1b36e59cf90d598a83e6086ad9 --- servo/src/servo/dom/rcu.rs | 30 +++++++++++++++--------------- servo/src/servo/layout/text.rs | 2 +- servo/src/servo/servo.rc | 2 -- servo/src/servo/text/font.rs | 32 +++++++++++--------------------- servo/src/servo/text/text_run.rs | 6 +++--- 5 files changed, 30 insertions(+), 42 deletions(-) diff --git a/servo/src/servo/dom/rcu.rs b/servo/src/servo/dom/rcu.rs index 794146ac47ef..7931d06639bb 100644 --- a/servo/src/servo/dom/rcu.rs +++ b/servo/src/servo/dom/rcu.rs @@ -69,7 +69,7 @@ class ScopeResource { self.d = d; } drop unsafe { - for d.free_list.each { |h| free_handle(h); } + for self.d.free_list.each { |h| free_handle(h); } } } @@ -165,20 +165,20 @@ fn Scope() -> Scope { impl WriterMethods for Scope { fn is_reader_forked() -> bool { - self.layout_active + self.d.layout_active } fn reader_forked() { - assert !self.layout_active; - assert self.first_dirty.is_null(); - self.layout_active = true; + assert !self.d.layout_active; + assert self.d.first_dirty.is_null(); + self.d.layout_active = true; } fn reader_joined() unsafe { - assert self.layout_active; + assert self.d.layout_active; - if self.first_dirty.is_not_null() { - let mut handle = self.first_dirty; + if self.d.first_dirty.is_not_null() { + let mut handle = self.d.first_dirty; while (*handle).is_not_null() { free(handle.read_ptr()); @@ -187,11 +187,11 @@ impl WriterMethods for Scope { handle.set_next_dirty(null_handle()); handle = next_handle; } - self.first_dirty = null_handle(); + self.d.first_dirty = null_handle(); } - assert self.first_dirty.is_null(); - self.layout_active = false; + assert self.d.first_dirty.is_null(); + self.d.layout_active = false; } fn read(h: Handle, f: fn(T) -> U) -> U unsafe { @@ -200,11 +200,11 @@ impl WriterMethods for Scope { } fn write(h: Handle, f: fn(T) -> U) -> U unsafe { - if self.layout_active && h.read_ptr() == h.write_ptr() { + if self.d.layout_active && h.read_ptr() == h.write_ptr() { #debug["marking handle %? as dirty", h]; h.set_write_ptr(unsafe::reinterpret_cast(self.clone(h.read_ptr()))); - h.set_next_dirty(self.first_dirty); - self.first_dirty = h; + h.set_next_dirty(self.d.first_dirty); + self.d.first_dirty = h; } f(*h.write_ptr()) } @@ -219,7 +219,7 @@ impl WriterMethods for Scope { (*d).read_aux = ptr::null(); (*d).next_dirty = null_handle(); let h = _Handle(d); - self.free_list += [h]; + self.d.free_list += [h]; ret h; } } diff --git a/servo/src/servo/layout/text.rs b/servo/src/servo/layout/text.rs index 99277ec9f7fb..b1ada58279c7 100644 --- a/servo/src/servo/layout/text.rs +++ b/servo/src/servo/layout/text.rs @@ -27,7 +27,7 @@ impl text_layout_methods for @Box { // FIXME: The font library should not be initialized here let flib = FontLibrary(); let font = flib.get_test_font(); - let run = TextRun(font, subbox.text); + let run = TextRun(*font, subbox.text); self.bounds.size = run.size(); subbox.run = some(run); } diff --git a/servo/src/servo/servo.rc b/servo/src/servo/servo.rc index 9c4a64849d6e..f0fa4e3e793e 100755 --- a/servo/src/servo/servo.rc +++ b/servo/src/servo/servo.rc @@ -7,8 +7,6 @@ #[license = "MPL"]; #[crate_type = "lib"]; -#[warn(no_oldvecs)]; - use std; use sdl; use azure; diff --git a/servo/src/servo/text/font.rs b/servo/src/servo/text/font.rs index 5c0254e3ea93..1d35bcf65bcd 100644 --- a/servo/src/servo/text/font.rs +++ b/servo/src/servo/text/font.rs @@ -23,34 +23,24 @@ import azure::cairo::bindgen::{ // FIXME (rust 2708): convert this to a class -type Font = FontDtor; - #[doc = " A font handle. Layout can use this to calculate glyph metrics and the renderer can use it to render text. "] -resource FontDtor(state: FontState) { - state.font_dtor(); -} +class Font { + let fontbuf: @[u8]; + let cairo_font: *cairo_scaled_font_t; + let font_dtor: fn@(); -type FontState = { - fontbuf: @[u8], - cairo_font: *cairo_scaled_font_t, - font_dtor: fn@() -}; + new(-fontbuf: [u8]) { + let (cairo_font, font_dtor) = get_cairo_font(© fontbuf); + assert cairo_font.is_not_null(); -fn Font(-fontbuf: [u8]) -> Font { - let (cairo_font, font_dtor) = get_cairo_font(© fontbuf); - assert cairo_font.is_not_null(); + self.fontbuf = @fontbuf; + self.cairo_font = cairo_font; + self.font_dtor = font_dtor; + } - ret FontDtor({ - fontbuf: @fontbuf, - cairo_font: cairo_font, - font_dtor: font_dtor - }); -} - -impl Font for Font { fn buf() -> @[u8] { self.fontbuf } diff --git a/servo/src/servo/text/text_run.rs b/servo/src/servo/text/text_run.rs index 26422a4704c1..91bc8fc0b316 100644 --- a/servo/src/servo/text/text_run.rs +++ b/servo/src/servo/text/text_run.rs @@ -11,8 +11,8 @@ import shaper::shape_text; class TextRun { let glyphs: [Glyph]; - new(font: &Font, text: str) { - self.glyphs = shape_text(font, text); + new(font: Font, text: str) { + self.glyphs = shape_text(&font, text); } fn size() -> Size2D { @@ -34,7 +34,7 @@ fn should_calculate_the_total_size() { let flib = FontLibrary(); let font = flib.get_test_font(); - let run = TextRun(font, "firecracker"); + let run = TextRun(*font, "firecracker"); let expected = Size2D(px_to_au(84), px_to_au(20)); assert run.size() == expected; }