mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Update rustc to revision 2cfb5acb5a2751c759627377e602bac4f88f2d19.
This commit is contained in:
parent
cf616b90a2
commit
16c7060bc8
153 changed files with 2095 additions and 1298 deletions
|
@ -10,6 +10,7 @@ use servo_util::task::spawn_named;
|
|||
|
||||
use std::comm;
|
||||
|
||||
#[deriving(Copy)]
|
||||
pub enum CanvasMsg {
|
||||
FillRect(Rect<f32>),
|
||||
ClearRect(Rect<f32>),
|
||||
|
|
|
@ -29,9 +29,9 @@ use png;
|
|||
use gleam::gl::types::{GLint, GLsizei};
|
||||
use gleam::gl;
|
||||
use script_traits::{ConstellationControlMsg, ScriptControlChan};
|
||||
use servo_msg::compositor_msg::{Blank, Epoch, FinishedLoading, LayerId};
|
||||
use servo_msg::compositor_msg::{ReadyState, PaintState, Scrollable};
|
||||
use servo_msg::constellation_msg::{mod, ConstellationChan};
|
||||
use servo_msg::compositor_msg::{Epoch, LayerId};
|
||||
use servo_msg::compositor_msg::{ReadyState, PaintState, ScrollPolicy};
|
||||
use servo_msg::constellation_msg::{ConstellationChan, NavigationDirection};
|
||||
use servo_msg::constellation_msg::Msg as ConstellationMsg;
|
||||
use servo_msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData};
|
||||
use servo_msg::constellation_msg::{PipelineId, WindowSizeData};
|
||||
|
@ -147,7 +147,7 @@ enum CompositionRequest {
|
|||
CompositeNow,
|
||||
}
|
||||
|
||||
#[deriving(PartialEq, Show)]
|
||||
#[deriving(Copy, PartialEq, Show)]
|
||||
enum ShutdownState {
|
||||
NotShuttingDown,
|
||||
ShuttingDown,
|
||||
|
@ -380,9 +380,10 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
|
||||
fn get_earliest_pipeline_ready_state(&self) -> ReadyState {
|
||||
if self.ready_states.len() == 0 {
|
||||
return Blank;
|
||||
return ReadyState::Blank;
|
||||
}
|
||||
return self.ready_states.values().fold(FinishedLoading, |a, &b| cmp::min(a, b));
|
||||
return self.ready_states.values().fold(ReadyState::FinishedLoading,
|
||||
|a, &b| cmp::min(a, b));
|
||||
|
||||
}
|
||||
|
||||
|
@ -477,7 +478,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
id: LayerId::null(),
|
||||
rect: Rect::zero(),
|
||||
background_color: azure_hl::Color::new(0., 0., 0., 0.),
|
||||
scroll_policy: Scrollable,
|
||||
scroll_policy: ScrollPolicy::Scrollable,
|
||||
};
|
||||
|
||||
let root_layer = CompositorData::new_layer(pipeline.clone(),
|
||||
|
@ -504,7 +505,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
frame_rect: Option<TypedRect<PagePx, f32>>)
|
||||
-> Rc<Layer<CompositorData>> {
|
||||
// Initialize the ReadyState and PaintState for this pipeline.
|
||||
self.ready_states.insert(frame_tree.pipeline.id, Blank);
|
||||
self.ready_states.insert(frame_tree.pipeline.id, ReadyState::Blank);
|
||||
self.paint_states.insert(frame_tree.pipeline.id, PaintState::Painting);
|
||||
|
||||
let root_layer = self.create_root_layer_for_pipeline_and_rect(&frame_tree.pipeline,
|
||||
|
@ -907,8 +908,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
|
||||
fn on_navigation_window_event(&self, direction: WindowNavigateMsg) {
|
||||
let direction = match direction {
|
||||
windowing::WindowNavigateMsg::Forward => constellation_msg::Forward,
|
||||
windowing::WindowNavigateMsg::Back => constellation_msg::Back,
|
||||
windowing::WindowNavigateMsg::Forward => NavigationDirection::Forward,
|
||||
windowing::WindowNavigateMsg::Back => NavigationDirection::Back,
|
||||
};
|
||||
let ConstellationChan(ref chan) = self.constellation_chan;
|
||||
chan.send(ConstellationMsg::Navigate(direction))
|
||||
|
@ -916,7 +917,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
|
||||
fn on_key_event(&self, key: Key, state: KeyState, modifiers: KeyModifiers) {
|
||||
let ConstellationChan(ref chan) = self.constellation_chan;
|
||||
chan.send(constellation_msg::KeyEvent(key, state, modifiers))
|
||||
chan.send(ConstellationMsg::KeyEvent(key, state, modifiers))
|
||||
}
|
||||
|
||||
fn convert_buffer_requests_to_pipeline_requests_map(&self,
|
||||
|
@ -1025,7 +1026,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
return false;
|
||||
}
|
||||
|
||||
if self.get_earliest_pipeline_ready_state() != FinishedLoading {
|
||||
if self.get_earliest_pipeline_ready_state() != ReadyState::FinishedLoading {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1123,7 +1124,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
let mut img = png::Image {
|
||||
width: width as u32,
|
||||
height: height as u32,
|
||||
pixels: png::RGB8(pixels),
|
||||
pixels: png::PixelsByColorType::RGB8(pixels),
|
||||
};
|
||||
let res = png::store_png(&mut img, &path);
|
||||
assert!(res.is_ok());
|
||||
|
|
|
@ -17,9 +17,9 @@ use layers::color::Color;
|
|||
use layers::geometry::LayerPixel;
|
||||
use layers::layers::{Layer, LayerBufferSet};
|
||||
use layers::platform::surface::NativeSurfaceMethods;
|
||||
use script_traits::{ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent};
|
||||
use script_traits::CompositorEvent::{ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent};
|
||||
use script_traits::{ScriptControlChan, ConstellationControlMsg};
|
||||
use servo_msg::compositor_msg::{Epoch, FixedPosition, LayerId, ScrollPolicy};
|
||||
use servo_msg::compositor_msg::{Epoch, LayerId, ScrollPolicy};
|
||||
use std::num::Float;
|
||||
use std::num::FloatMath;
|
||||
use std::rc::Rc;
|
||||
|
@ -122,7 +122,7 @@ pub trait CompositorLayer {
|
|||
fn wants_scroll_events(&self) -> WantsScrollEventsFlag;
|
||||
}
|
||||
|
||||
#[deriving(PartialEq, Clone)]
|
||||
#[deriving(Copy, PartialEq, Clone)]
|
||||
pub enum WantsScrollEventsFlag {
|
||||
WantsScrollEvents,
|
||||
DoesntWantScrollEvents,
|
||||
|
@ -343,7 +343,7 @@ impl CompositorLayer for Layer<CompositorData> {
|
|||
let mut result = false;
|
||||
|
||||
// Only scroll this layer if it's not fixed-positioned.
|
||||
if self.extra_data.borrow().scroll_policy != FixedPosition {
|
||||
if self.extra_data.borrow().scroll_policy != ScrollPolicy::FixedPosition {
|
||||
let new_offset = new_offset.to_untyped();
|
||||
*self.transform.borrow_mut() = identity().translate(new_offset.x, new_offset.y, 0.0);
|
||||
*self.content_offset.borrow_mut() = Point2D::from_untyped(&new_offset);
|
||||
|
|
|
@ -20,12 +20,12 @@ use layers::layers::LayerBufferSet;
|
|||
use servo_msg::compositor_msg::{Epoch, LayerId, LayerMetadata, ReadyState};
|
||||
use servo_msg::compositor_msg::{PaintListener, PaintState, ScriptListener, ScrollPolicy};
|
||||
use servo_msg::constellation_msg::{ConstellationChan, LoadData, PipelineId};
|
||||
use servo_msg::constellation_msg::{Key, KeyState, KeyModifiers, Pressed};
|
||||
use servo_msg::constellation_msg::{Key, KeyState, KeyModifiers};
|
||||
use servo_util::cursor::Cursor;
|
||||
use servo_util::memory::MemoryProfilerChan;
|
||||
use servo_util::time::TimeProfilerChan;
|
||||
use std::comm::{channel, Sender, Receiver};
|
||||
use std::fmt::{FormatError, Formatter, Show};
|
||||
use std::fmt::{Error, Formatter, Show};
|
||||
use std::rc::Rc;
|
||||
|
||||
/// Sends messages to the compositor. This is a trait supplied by the port because the method used
|
||||
|
@ -89,13 +89,14 @@ impl ScriptListener for Box<CompositorProxy+'static+Send> {
|
|||
}
|
||||
|
||||
fn send_key_event(&mut self, key: Key, state: KeyState, modifiers: KeyModifiers) {
|
||||
if state == Pressed {
|
||||
if state == KeyState::Pressed {
|
||||
self.send(Msg::KeyEvent(key, modifiers));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Information about each layer that the compositor keeps.
|
||||
#[deriving(Copy)]
|
||||
pub struct LayerProperties {
|
||||
pub pipeline_id: PipelineId,
|
||||
pub epoch: Epoch,
|
||||
|
@ -221,7 +222,7 @@ pub enum Msg {
|
|||
}
|
||||
|
||||
impl Show for Msg {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result<(),FormatError> {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result<(),Error> {
|
||||
match *self {
|
||||
Msg::Exit(..) => write!(f, "Exit"),
|
||||
Msg::ShutdownComplete(..) => write!(f, "ShutdownComplete"),
|
||||
|
|
|
@ -14,12 +14,12 @@ use gfx::font_cache_task::FontCacheTask;
|
|||
use layers::geometry::DevicePixel;
|
||||
use layout_traits::LayoutTaskFactory;
|
||||
use libc;
|
||||
use script_traits::{mod, ConstellationControlMsg};
|
||||
use script_traits::{CompositorEvent, ConstellationControlMsg};
|
||||
use script_traits::{ScriptControlChan, ScriptTaskFactory};
|
||||
use servo_msg::compositor_msg::LayerId;
|
||||
use servo_msg::constellation_msg::{mod, ConstellationChan, Failure};
|
||||
use servo_msg::constellation_msg::{IFrameSandboxState, IFrameUnsandboxed};
|
||||
use servo_msg::constellation_msg::{KeyEvent, Key, KeyState, KeyModifiers};
|
||||
use servo_msg::constellation_msg::{IFrameSandboxState, NavigationDirection};
|
||||
use servo_msg::constellation_msg::{Key, KeyState, KeyModifiers};
|
||||
use servo_msg::constellation_msg::{LoadData, NavigationType};
|
||||
use servo_msg::constellation_msg::{PipelineExitType, PipelineId};
|
||||
use servo_msg::constellation_msg::{SubpageId, WindowSizeData};
|
||||
|
@ -27,8 +27,7 @@ use servo_msg::constellation_msg::Msg as ConstellationMsg;
|
|||
use servo_net::image_cache_task::{ImageCacheTask, ImageCacheTaskClient};
|
||||
use servo_net::resource_task::ResourceTask;
|
||||
use servo_net::resource_task;
|
||||
use servo_net::storage_task::StorageTask;
|
||||
use servo_net::storage_task;
|
||||
use servo_net::storage_task::{StorageTask, StorageTaskMsg};
|
||||
use servo_util::cursor::Cursor;
|
||||
use servo_util::geometry::{PagePx, ViewportPx};
|
||||
use servo_util::opts;
|
||||
|
@ -91,6 +90,7 @@ pub struct Constellation<LTF, STF> {
|
|||
}
|
||||
|
||||
/// A unique ID used to identify a frame.
|
||||
#[deriving(Copy)]
|
||||
pub struct FrameId(u32);
|
||||
|
||||
/// One frame in the hierarchy.
|
||||
|
@ -515,11 +515,11 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
|||
pipeline.exit(PipelineExitType::Complete);
|
||||
}
|
||||
self.image_cache_task.exit();
|
||||
self.resource_task.send(resource_task::Exit);
|
||||
self.resource_task.send(resource_task::ControlMsg::Exit);
|
||||
self.devtools_chan.as_ref().map(|chan| {
|
||||
chan.send(devtools_traits::ServerExitMsg);
|
||||
});
|
||||
self.storage_task.send(storage_task::Exit);
|
||||
self.storage_task.send(StorageTaskMsg::Exit);
|
||||
self.font_cache_task.exit();
|
||||
self.compositor_proxy.send(CompositorMsg::ShutdownComplete);
|
||||
}
|
||||
|
@ -571,7 +571,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
|||
|
||||
self.browse(Some(pipeline_id),
|
||||
Rc::new(FrameTree::new(new_frame_id, pipeline.clone(), None)),
|
||||
constellation_msg::Load);
|
||||
NavigationType::Load);
|
||||
|
||||
self.pipelines.insert(new_id, pipeline);
|
||||
}
|
||||
|
@ -596,7 +596,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
|||
let pipeline = self.new_pipeline(next_pipeline_id, None, None, LoadData::new(url));
|
||||
self.browse(None,
|
||||
Rc::new(FrameTree::new(next_frame_id, pipeline.clone(), None)),
|
||||
constellation_msg::Load);
|
||||
NavigationType::Load);
|
||||
self.pipelines.insert(pipeline.id, pipeline);
|
||||
}
|
||||
|
||||
|
@ -718,7 +718,8 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
|||
let source_url = source_pipeline.load_data.url.clone();
|
||||
|
||||
let same_script = (source_url.host() == url.host() &&
|
||||
source_url.port() == url.port()) && sandbox == IFrameUnsandboxed;
|
||||
source_url.port() == url.port()) &&
|
||||
sandbox == IFrameSandboxState::IFrameUnsandboxed;
|
||||
// FIXME(tkuehn): Need to follow the standardized spec for checking same-origin
|
||||
// Reuse the script task if the URL is same-origin
|
||||
let script_pipeline = if same_script {
|
||||
|
@ -785,7 +786,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
|||
Rc::new(FrameTree::new(next_frame_id,
|
||||
pipeline.clone(),
|
||||
parent.borrow().clone())),
|
||||
constellation_msg::Load);
|
||||
NavigationType::Load);
|
||||
self.pipelines.insert(pipeline.id, pipeline);
|
||||
}
|
||||
|
||||
|
@ -797,7 +798,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
|||
// navigation always has navigation priority, and after that new page loading is
|
||||
// first come, first served.
|
||||
let destination_frame = match direction {
|
||||
constellation_msg::Forward => {
|
||||
NavigationDirection::Forward => {
|
||||
if self.navigation_context.next.is_empty() {
|
||||
debug!("no next page to navigate to");
|
||||
return;
|
||||
|
@ -809,7 +810,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
|||
}
|
||||
self.navigation_context.forward(&mut *self.compositor_proxy)
|
||||
}
|
||||
constellation_msg::Back => {
|
||||
NavigationDirection::Back => {
|
||||
if self.navigation_context.previous.is_empty() {
|
||||
debug!("no previous page to navigate to");
|
||||
return;
|
||||
|
@ -826,7 +827,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
|||
for frame in destination_frame.iter() {
|
||||
frame.pipeline.load();
|
||||
}
|
||||
self.grant_paint_permission(destination_frame, constellation_msg::Navigate);
|
||||
self.grant_paint_permission(destination_frame, NavigationType::Navigate);
|
||||
|
||||
}
|
||||
|
||||
|
@ -838,7 +839,8 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
|||
fn handle_key_msg(&self, key: Key, state: KeyState, mods: KeyModifiers) {
|
||||
self.current_frame().as_ref().map(|frame| {
|
||||
let ScriptControlChan(ref chan) = frame.pipeline.script_chan;
|
||||
chan.send(ConstellationControlMsg::SendEvent(frame.pipeline.id, script_traits::KeyEvent(key, state, mods)));
|
||||
chan.send(ConstellationControlMsg::SendEvent(
|
||||
frame.pipeline.id, CompositorEvent::KeyEvent(key, state, mods)));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1005,7 +1007,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
|||
// Don't call navigation_context.load() on a Navigate type (or None, as in the case of
|
||||
// parsed iframes that finish loading)
|
||||
match navigation_type {
|
||||
constellation_msg::Load => {
|
||||
NavigationType::Load => {
|
||||
debug!("evicting old frames due to load");
|
||||
let evicted = self.navigation_context.load(frame_tree,
|
||||
&mut *self.compositor_proxy);
|
||||
|
|
|
@ -3,13 +3,12 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use CompositorProxy;
|
||||
use layout_traits::{ExitNowMsg, LayoutTaskFactory, LayoutControlChan};
|
||||
use layout_traits::{LayoutControlMsg, LayoutTaskFactory, LayoutControlChan};
|
||||
use script_traits::{ScriptControlChan, ScriptTaskFactory};
|
||||
use script_traits::{NewLayoutInfo, ConstellationControlMsg};
|
||||
|
||||
use devtools_traits::DevtoolsControlChan;
|
||||
use gfx::paint_task::Msg as PaintMsg;
|
||||
use gfx::paint_task::{PaintPermissionGranted, PaintPermissionRevoked};
|
||||
use gfx::paint_task::{PaintChan, PaintTask};
|
||||
use servo_msg::constellation_msg::{ConstellationChan, Failure, PipelineId, SubpageId};
|
||||
use servo_msg::constellation_msg::{LoadData, WindowSizeData, PipelineExitType};
|
||||
|
@ -166,12 +165,12 @@ impl Pipeline {
|
|||
}
|
||||
|
||||
pub fn grant_paint_permission(&self) {
|
||||
let _ = self.paint_chan.send_opt(PaintPermissionGranted);
|
||||
let _ = self.paint_chan.send_opt(PaintMsg::PaintPermissionGranted);
|
||||
}
|
||||
|
||||
pub fn revoke_paint_permission(&self) {
|
||||
debug!("pipeline revoking paint channel paint permission");
|
||||
let _ = self.paint_chan.send_opt(PaintPermissionRevoked);
|
||||
let _ = self.paint_chan.send_opt(PaintMsg::PaintPermissionRevoked);
|
||||
}
|
||||
|
||||
pub fn exit(&self, exit_type: PipelineExitType) {
|
||||
|
@ -196,7 +195,7 @@ impl Pipeline {
|
|||
PipelineExitType::PipelineOnly));
|
||||
let _ = self.paint_chan.send_opt(PaintMsg::Exit(None, PipelineExitType::PipelineOnly));
|
||||
let LayoutControlChan(ref layout_channel) = self.layout_chan;
|
||||
let _ = layout_channel.send_opt(ExitNowMsg(PipelineExitType::PipelineOnly));
|
||||
let _ = layout_channel.send_opt(LayoutControlMsg::ExitNowMsg(PipelineExitType::PipelineOnly));
|
||||
}
|
||||
|
||||
pub fn to_sendable(&self) -> CompositionPipeline {
|
||||
|
|
|
@ -15,21 +15,24 @@ use servo_msg::compositor_msg::{PaintState, ReadyState};
|
|||
use servo_msg::constellation_msg::{Key, KeyState, KeyModifiers, LoadData};
|
||||
use servo_util::cursor::Cursor;
|
||||
use servo_util::geometry::ScreenPx;
|
||||
use std::fmt::{FormatError, Formatter, Show};
|
||||
use std::fmt::{Error, Formatter, Show};
|
||||
use std::rc::Rc;
|
||||
|
||||
#[deriving(Clone)]
|
||||
pub enum MouseWindowEvent {
|
||||
Click(uint, TypedPoint2D<DevicePixel, f32>),
|
||||
MouseDown(uint, TypedPoint2D<DevicePixel, f32>),
|
||||
MouseUp(uint, TypedPoint2D<DevicePixel, f32>),
|
||||
}
|
||||
|
||||
#[deriving(Clone)]
|
||||
pub enum WindowNavigateMsg {
|
||||
Forward,
|
||||
Back,
|
||||
}
|
||||
|
||||
/// Events that the windowing system sends to Servo.
|
||||
#[deriving(Clone)]
|
||||
pub enum WindowEvent {
|
||||
/// Sent when no message has arrived, but the event loop was kicked for some reason (perhaps
|
||||
/// by another Servo subsystem).
|
||||
|
@ -68,7 +71,7 @@ pub enum WindowEvent {
|
|||
}
|
||||
|
||||
impl Show for WindowEvent {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result<(),FormatError> {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result<(),Error> {
|
||||
match *self {
|
||||
WindowEvent::Idle => write!(f, "Idle"),
|
||||
WindowEvent::Refresh => write!(f, "Refresh"),
|
||||
|
|
|
@ -20,7 +20,7 @@ pub trait Actor : Any {
|
|||
fn handle_message(&self,
|
||||
registry: &ActorRegistry,
|
||||
msg_type: &String,
|
||||
msg: &json::JsonObject,
|
||||
msg: &json::Object,
|
||||
stream: &mut TcpStream) -> Result<bool, ()>;
|
||||
fn name(&self) -> String;
|
||||
}
|
||||
|
@ -149,14 +149,14 @@ impl ActorRegistry {
|
|||
/// Attempt to process a message as directed by its `to` property. If the actor is not
|
||||
/// found or does not indicate that it knew how to process the message, ignore the failure.
|
||||
pub fn handle_message(&mut self,
|
||||
msg: &json::JsonObject,
|
||||
msg: &json::Object,
|
||||
stream: &mut TcpStream)
|
||||
-> Result<(), ()> {
|
||||
let to = msg.get(&"to".to_string()).unwrap().as_string().unwrap();
|
||||
let to = msg.get("to").unwrap().as_string().unwrap();
|
||||
match self.actors.get(&to.to_string()) {
|
||||
None => println!("message received for unknown actor \"{}\"", to),
|
||||
Some(actor) => {
|
||||
let msg_type = msg.get(&"type".to_string()).unwrap().as_string().unwrap();
|
||||
let msg_type = msg.get("type").unwrap().as_string().unwrap();
|
||||
if !try!(actor.handle_message(self, &msg_type.to_string(), msg, stream)) {
|
||||
println!("unexpected message type \"{}\" found for actor \"{}\"",
|
||||
msg_type, to);
|
||||
|
|
|
@ -15,8 +15,7 @@ use servo_msg::constellation_msg::PipelineId;
|
|||
|
||||
use collections::TreeMap;
|
||||
use core::cell::RefCell;
|
||||
use serialize::json;
|
||||
use serialize::json::ToJson;
|
||||
use serialize::json::{mod, Json, ToJson};
|
||||
use std::io::TcpStream;
|
||||
use std::num::Float;
|
||||
|
||||
|
@ -76,7 +75,7 @@ enum ConsoleMessageType {
|
|||
#[deriving(Encodable)]
|
||||
struct GetCachedMessagesReply {
|
||||
from: String,
|
||||
messages: Vec<json::JsonObject>,
|
||||
messages: Vec<json::Object>,
|
||||
}
|
||||
|
||||
#[deriving(Encodable)]
|
||||
|
@ -96,11 +95,11 @@ struct AutocompleteReply {
|
|||
struct EvaluateJSReply {
|
||||
from: String,
|
||||
input: String,
|
||||
result: json::Json,
|
||||
result: Json,
|
||||
timestamp: uint,
|
||||
exception: json::Json,
|
||||
exception: Json,
|
||||
exceptionMessage: String,
|
||||
helperResult: json::Json,
|
||||
helperResult: Json,
|
||||
}
|
||||
|
||||
pub struct ConsoleActor {
|
||||
|
@ -118,11 +117,11 @@ impl Actor for ConsoleActor {
|
|||
fn handle_message(&self,
|
||||
_registry: &ActorRegistry,
|
||||
msg_type: &String,
|
||||
msg: &json::JsonObject,
|
||||
msg: &json::Object,
|
||||
stream: &mut TcpStream) -> Result<bool, ()> {
|
||||
Ok(match msg_type.as_slice() {
|
||||
"getCachedMessages" => {
|
||||
let types = msg.get(&"messageTypes".to_string()).unwrap().as_list().unwrap();
|
||||
let types = msg.get(&"messageTypes".to_string()).unwrap().as_array().unwrap();
|
||||
let /*mut*/ messages = vec!();
|
||||
for msg_type in types.iter() {
|
||||
let msg_type = msg_type.as_string().unwrap();
|
||||
|
@ -196,7 +195,7 @@ impl Actor for ConsoleActor {
|
|||
from: self.name(),
|
||||
stoppedListeners: msg.get(&"listeners".to_string())
|
||||
.unwrap()
|
||||
.as_list()
|
||||
.as_array()
|
||||
.unwrap_or(&vec!())
|
||||
.iter()
|
||||
.map(|listener| listener.as_string().unwrap().to_string())
|
||||
|
@ -228,19 +227,19 @@ impl Actor for ConsoleActor {
|
|||
VoidValue => {
|
||||
let mut m = TreeMap::new();
|
||||
m.insert("type".to_string(), "undefined".to_string().to_json());
|
||||
json::Object(m)
|
||||
Json::Object(m)
|
||||
}
|
||||
NullValue => {
|
||||
let mut m = TreeMap::new();
|
||||
m.insert("type".to_string(), "null".to_string().to_json());
|
||||
json::Object(m)
|
||||
Json::Object(m)
|
||||
}
|
||||
BooleanValue(val) => val.to_json(),
|
||||
NumberValue(val) => {
|
||||
if val.is_nan() {
|
||||
let mut m = TreeMap::new();
|
||||
m.insert("type".to_string(), "NaN".to_string().to_json());
|
||||
json::Object(m)
|
||||
Json::Object(m)
|
||||
} else if val.is_infinite() {
|
||||
let mut m = TreeMap::new();
|
||||
if val < 0. {
|
||||
|
@ -248,11 +247,11 @@ impl Actor for ConsoleActor {
|
|||
} else {
|
||||
m.insert("type".to_string(), "Infinity".to_string().to_json());
|
||||
}
|
||||
json::Object(m)
|
||||
Json::Object(m)
|
||||
} else if val == Float::neg_zero() {
|
||||
let mut m = TreeMap::new();
|
||||
m.insert("type".to_string(), "-0".to_string().to_json());
|
||||
json::Object(m)
|
||||
Json::Object(m)
|
||||
} else {
|
||||
val.to_json()
|
||||
}
|
||||
|
@ -267,7 +266,7 @@ impl Actor for ConsoleActor {
|
|||
m.insert("extensible".to_string(), true.to_json());
|
||||
m.insert("frozen".to_string(), false.to_json());
|
||||
m.insert("sealed".to_string(), false.to_json());
|
||||
json::Object(m)
|
||||
Json::Object(m)
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -277,9 +276,9 @@ impl Actor for ConsoleActor {
|
|||
input: input,
|
||||
result: result,
|
||||
timestamp: 0,
|
||||
exception: json::Object(TreeMap::new()),
|
||||
exception: Json::Object(TreeMap::new()),
|
||||
exceptionMessage: "".to_string(),
|
||||
helperResult: json::Object(TreeMap::new()),
|
||||
helperResult: Json::Object(TreeMap::new()),
|
||||
};
|
||||
stream.write_json_packet(&msg);
|
||||
true
|
||||
|
|
|
@ -12,8 +12,7 @@ use protocol::JsonPacketStream;
|
|||
|
||||
use collections::TreeMap;
|
||||
use servo_msg::constellation_msg::PipelineId;
|
||||
use serialize::json;
|
||||
use serialize::json::ToJson;
|
||||
use serialize::json::{mod, Json, ToJson};
|
||||
use std::cell::RefCell;
|
||||
use std::io::TcpStream;
|
||||
use std::num::Float;
|
||||
|
@ -66,7 +65,7 @@ impl Actor for HighlighterActor {
|
|||
fn handle_message(&self,
|
||||
_registry: &ActorRegistry,
|
||||
msg_type: &String,
|
||||
_msg: &json::JsonObject,
|
||||
_msg: &json::Object,
|
||||
stream: &mut TcpStream) -> Result<bool, ()> {
|
||||
Ok(match msg_type.as_slice() {
|
||||
"showBoxModel" => {
|
||||
|
@ -103,12 +102,12 @@ impl Actor for NodeActor {
|
|||
fn handle_message(&self,
|
||||
registry: &ActorRegistry,
|
||||
msg_type: &String,
|
||||
msg: &json::JsonObject,
|
||||
msg: &json::Object,
|
||||
stream: &mut TcpStream) -> Result<bool, ()> {
|
||||
Ok(match msg_type.as_slice() {
|
||||
"modifyAttributes" => {
|
||||
let target = msg.get(&"to".to_string()).unwrap().as_string().unwrap();
|
||||
let mods = msg.get(&"modifications".to_string()).unwrap().as_list().unwrap();
|
||||
let mods = msg.get(&"modifications".to_string()).unwrap().as_array().unwrap();
|
||||
let modifications = mods.iter().map(|json_mod| {
|
||||
json::decode(json_mod.to_string().as_slice()).unwrap()
|
||||
}).collect();
|
||||
|
@ -276,7 +275,7 @@ impl Actor for WalkerActor {
|
|||
fn handle_message(&self,
|
||||
registry: &ActorRegistry,
|
||||
msg_type: &String,
|
||||
msg: &json::JsonObject,
|
||||
msg: &json::Object,
|
||||
stream: &mut TcpStream) -> Result<bool, ()> {
|
||||
Ok(match msg_type.as_slice() {
|
||||
"querySelector" => {
|
||||
|
@ -368,7 +367,7 @@ struct GetComputedReply {
|
|||
#[deriving(Encodable)]
|
||||
struct AppliedEntry {
|
||||
rule: String,
|
||||
pseudoElement: json::Json,
|
||||
pseudoElement: Json,
|
||||
isSystem: bool,
|
||||
matchedSelectors: Vec<String>,
|
||||
}
|
||||
|
@ -400,7 +399,7 @@ struct AppliedSheet {
|
|||
struct GetLayoutReply {
|
||||
width: int,
|
||||
height: int,
|
||||
autoMargins: json::Json,
|
||||
autoMargins: Json,
|
||||
from: String,
|
||||
}
|
||||
|
||||
|
@ -421,7 +420,7 @@ impl Actor for PageStyleActor {
|
|||
fn handle_message(&self,
|
||||
registry: &ActorRegistry,
|
||||
msg_type: &String,
|
||||
msg: &json::JsonObject,
|
||||
msg: &json::Object,
|
||||
stream: &mut TcpStream) -> Result<bool, ()> {
|
||||
Ok(match msg_type.as_slice() {
|
||||
"getApplied" => {
|
||||
|
@ -469,9 +468,9 @@ impl Actor for PageStyleActor {
|
|||
m.insert("bottom".to_string(), "auto".to_string().to_json());
|
||||
m.insert("left".to_string(), "auto".to_string().to_json());
|
||||
m.insert("right".to_string(), "auto".to_string().to_json());
|
||||
json::Object(m)
|
||||
Json::Object(m)
|
||||
} else {
|
||||
json::Null
|
||||
Json::Null
|
||||
},
|
||||
from: self.name(),
|
||||
};
|
||||
|
@ -492,7 +491,7 @@ impl Actor for InspectorActor {
|
|||
fn handle_message(&self,
|
||||
registry: &ActorRegistry,
|
||||
msg_type: &String,
|
||||
_msg: &json::JsonObject,
|
||||
_msg: &json::Object,
|
||||
stream: &mut TcpStream) -> Result<bool, ()> {
|
||||
Ok(match msg_type.as_slice() {
|
||||
"getWalker" => {
|
||||
|
|
|
@ -53,7 +53,7 @@ impl Actor for RootActor {
|
|||
fn handle_message(&self,
|
||||
registry: &ActorRegistry,
|
||||
msg_type: &String,
|
||||
_msg: &json::JsonObject,
|
||||
_msg: &json::Object,
|
||||
stream: &mut TcpStream) -> Result<bool, ()> {
|
||||
Ok(match msg_type.as_slice() {
|
||||
"listAddons" => {
|
||||
|
|
|
@ -77,7 +77,7 @@ impl Actor for TabActor {
|
|||
fn handle_message(&self,
|
||||
registry: &ActorRegistry,
|
||||
msg_type: &String,
|
||||
_msg: &json::JsonObject,
|
||||
_msg: &json::Object,
|
||||
stream: &mut TcpStream) -> Result<bool, ()> {
|
||||
Ok(match msg_type.as_slice() {
|
||||
"reconfigure" => {
|
||||
|
|
|
@ -21,7 +21,6 @@ extern crate collections;
|
|||
extern crate core;
|
||||
extern crate devtools_traits;
|
||||
extern crate serialize;
|
||||
extern crate sync;
|
||||
extern crate "msg" as servo_msg;
|
||||
extern crate "util" as servo_util;
|
||||
|
||||
|
@ -42,7 +41,7 @@ use std::comm;
|
|||
use std::comm::{Disconnected, Empty};
|
||||
use std::io::{TcpListener, TcpStream};
|
||||
use std::io::{Acceptor, Listener, TimedOut};
|
||||
use sync::{Arc, Mutex};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
mod actor;
|
||||
/// Corresponds to http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/
|
||||
|
|
|
@ -5,12 +5,13 @@
|
|||
/// Low-level wire protocol implementation. Currently only supports [JSON packets](https://wiki.mozilla.org/Remote_Debugging_Protocol_Stream_Transport#JSON_Packets).
|
||||
|
||||
use serialize::{json, Encodable};
|
||||
use serialize::json::Json;
|
||||
use std::io::{IoError, OtherIoError, EndOfFile, TcpStream, IoResult};
|
||||
use std::num;
|
||||
|
||||
pub trait JsonPacketStream {
|
||||
fn write_json_packet<'a, T: Encodable<json::Encoder<'a>,IoError>>(&mut self, obj: &T);
|
||||
fn read_json_packet(&mut self) -> IoResult<json::Json>;
|
||||
fn read_json_packet(&mut self) -> IoResult<Json>;
|
||||
}
|
||||
|
||||
impl JsonPacketStream for TcpStream {
|
||||
|
@ -22,7 +23,7 @@ impl JsonPacketStream for TcpStream {
|
|||
self.write_str(s.as_slice()).unwrap();
|
||||
}
|
||||
|
||||
fn read_json_packet<'a>(&mut self) -> IoResult<json::Json> {
|
||||
fn read_json_packet<'a>(&mut self) -> IoResult<Json> {
|
||||
// https://wiki.mozilla.org/Remote_Debugging_Protocol_Stream_Transport
|
||||
// In short, each JSON packet is [ascii length]:[JSON data of given length]
|
||||
let mut buffer = vec!();
|
||||
|
|
|
@ -27,7 +27,7 @@ pub struct BufferMap {
|
|||
}
|
||||
|
||||
/// A key with which to store buffers. It is based on the size of the buffer.
|
||||
#[deriving(Eq)]
|
||||
#[deriving(Eq, Copy)]
|
||||
struct BufferKey([uint, ..2]);
|
||||
|
||||
impl Hash for BufferKey {
|
||||
|
|
|
@ -42,7 +42,7 @@ use std::slice::Items;
|
|||
use style::ComputedValues;
|
||||
use style::computed_values::border_style;
|
||||
use style::computed_values::cursor;
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
|
||||
// It seems cleaner to have layout code not mention Azure directly, so let's just reexport this for
|
||||
// layout to use.
|
||||
|
@ -61,7 +61,7 @@ pub static BOX_SHADOW_INFLATION_FACTOR: i32 = 3;
|
|||
/// Because the script task's GC does not trace layout, node data cannot be safely stored in layout
|
||||
/// data structures. Also, layout code tends to be faster when the DOM is not being accessed, for
|
||||
/// locality reasons. Using `OpaqueNode` enforces this invariant.
|
||||
#[deriving(Clone, PartialEq)]
|
||||
#[deriving(Clone, PartialEq, Copy)]
|
||||
pub struct OpaqueNode(pub uintptr_t);
|
||||
|
||||
impl OpaqueNode {
|
||||
|
@ -628,7 +628,7 @@ impl ClippingRegion {
|
|||
/// Metadata attached to each display item. This is useful for performing auxiliary tasks with
|
||||
/// the display list involving hit testing: finding the originating DOM node and determining the
|
||||
/// cursor to use when the element is hovered over.
|
||||
#[deriving(Clone)]
|
||||
#[deriving(Clone, Copy)]
|
||||
pub struct DisplayItemMetadata {
|
||||
/// The DOM node from which this display item originated.
|
||||
pub node: OpaqueNode,
|
||||
|
@ -739,7 +739,7 @@ pub struct BorderDisplayItem {
|
|||
/// Information about the border radii.
|
||||
///
|
||||
/// TODO(pcwalton): Elliptical radii.
|
||||
#[deriving(Clone, Default, PartialEq, Show)]
|
||||
#[deriving(Clone, Default, PartialEq, Show, Copy)]
|
||||
pub struct BorderRadii<T> {
|
||||
pub top_left: T,
|
||||
pub top_right: T,
|
||||
|
|
|
@ -9,7 +9,7 @@ use display_list::{DisplayItem, DisplayList, StackingContext};
|
|||
use collections::dlist::DList;
|
||||
use geom::rect::Rect;
|
||||
use servo_util::geometry::{mod, Au};
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Transforms a display list to produce a visually-equivalent, but cheaper-to-paint, one.
|
||||
pub struct DisplayListOptimizer {
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
|
||||
use geom::{Point2D, Rect, Size2D};
|
||||
use std::mem;
|
||||
use std::string;
|
||||
use std::slice;
|
||||
use std::rc::Rc;
|
||||
use std::cell::RefCell;
|
||||
use servo_util::cache::{Cache, HashCache};
|
||||
use servo_util::smallvec::{SmallVec, SmallVec8};
|
||||
use style::computed_values::{font_variant, font_weight};
|
||||
use style::style_structs::Font as FontStyle;
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
|
||||
use collections::hash::Hash;
|
||||
use platform::font_context::FontContextHandle;
|
||||
|
@ -56,11 +56,10 @@ pub trait FontTableTagConversions {
|
|||
impl FontTableTagConversions for FontTableTag {
|
||||
fn tag_to_str(&self) -> String {
|
||||
unsafe {
|
||||
let reversed = string::raw::from_buf_len(mem::transmute(self), 4);
|
||||
return String::from_chars([reversed.as_slice().char_at(3),
|
||||
reversed.as_slice().char_at(2),
|
||||
reversed.as_slice().char_at(1),
|
||||
reversed.as_slice().char_at(0)]);
|
||||
let pointer = mem::transmute::<&u32, *const u8>(self);
|
||||
let mut bytes = slice::from_raw_buf(&pointer, 4).to_vec();
|
||||
bytes.reverse();
|
||||
String::from_utf8_unchecked(bytes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -101,6 +100,7 @@ pub struct Font {
|
|||
}
|
||||
|
||||
bitflags! {
|
||||
#[deriving(Copy)]
|
||||
flags ShapingFlags: u8 {
|
||||
#[doc="Set if the text is entirely whitespace."]
|
||||
const IS_WHITESPACE_SHAPING_FLAG = 0x01,
|
||||
|
@ -110,7 +110,7 @@ bitflags! {
|
|||
}
|
||||
|
||||
/// Various options that control text shaping.
|
||||
#[deriving(Clone, Eq, PartialEq, Hash)]
|
||||
#[deriving(Clone, Eq, PartialEq, Hash, Copy)]
|
||||
pub struct ShapingOptions {
|
||||
/// Spacing to add between each letter. Corresponds to the CSS 2.1 `letter-spacing` property.
|
||||
/// NB: You will probably want to set the `IGNORE_LIGATURES_SHAPING_FLAG` if this is non-null.
|
||||
|
|
|
@ -10,7 +10,7 @@ use platform::font_context::FontContextHandle;
|
|||
|
||||
use collections::str::Str;
|
||||
use std::collections::HashMap;
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
use font_template::{FontTemplate, FontTemplateDescriptor};
|
||||
use platform::font_template::FontTemplateData;
|
||||
use servo_net::resource_task::{ResourceTask, load_whole_resource};
|
||||
|
|
|
@ -19,7 +19,7 @@ use servo_util::arc_ptr_eq;
|
|||
|
||||
use std::rc::Rc;
|
||||
use std::cell::RefCell;
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
|
||||
use azure::AzFloat;
|
||||
use azure::azure_hl::BackendType;
|
||||
|
|
|
@ -7,14 +7,14 @@ use platform::font_context::FontContextHandle;
|
|||
use platform::font::FontHandle;
|
||||
use platform::font_template::FontTemplateData;
|
||||
|
||||
use sync::{Arc, Weak};
|
||||
use std::sync::{Arc, Weak};
|
||||
use font::FontHandleMethods;
|
||||
|
||||
/// Describes how to select a font from a given family.
|
||||
/// This is very basic at the moment and needs to be
|
||||
/// expanded or refactored when we support more of the
|
||||
/// font styling parameters.
|
||||
#[deriving(Clone)]
|
||||
#[deriving(Clone, Copy)]
|
||||
pub struct FontTemplateDescriptor {
|
||||
pub weight: font_weight::T,
|
||||
pub italic: bool,
|
||||
|
|
|
@ -29,7 +29,6 @@ extern crate "net" as servo_net;
|
|||
extern crate "util" as servo_util;
|
||||
extern crate "msg" as servo_msg;
|
||||
extern crate style;
|
||||
extern crate sync;
|
||||
extern crate time;
|
||||
extern crate url;
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ use std::mem;
|
|||
use std::num::{Float, FloatMath};
|
||||
use std::ptr;
|
||||
use style::computed_values::border_style;
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
use text::TextRun;
|
||||
use text::glyph::CharIndex;
|
||||
|
||||
|
@ -52,6 +52,7 @@ pub struct PaintContext<'a> {
|
|||
pub transient_clip: Option<ClippingRegion>,
|
||||
}
|
||||
|
||||
#[deriving(Copy)]
|
||||
enum Direction {
|
||||
Top,
|
||||
Left,
|
||||
|
@ -59,6 +60,7 @@ enum Direction {
|
|||
Bottom
|
||||
}
|
||||
|
||||
#[deriving(Copy)]
|
||||
enum DashSize {
|
||||
DottedBorder = 1,
|
||||
DashedBorder = 3
|
||||
|
|
|
@ -35,7 +35,7 @@ use servo_util::time::{TimeProfilerChan, TimeProfilerCategory, profile};
|
|||
use std::comm::{Receiver, Sender, channel};
|
||||
use std::mem;
|
||||
use std::task::TaskBuilder;
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Information about a hardware graphics layer that layout sends to the painting task.
|
||||
#[deriving(Clone)]
|
||||
|
|
|
@ -30,7 +30,7 @@ use std::num::Float;
|
|||
use std::ptr;
|
||||
use std::string;
|
||||
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
|
||||
fn float_to_fixed_ft(f: f64) -> i32 {
|
||||
float_to_fixed(6, f)
|
||||
|
|
|
@ -29,7 +29,7 @@ use core_text::font_descriptor::{kCTFontDefaultOrientation};
|
|||
|
||||
use std::num::Float;
|
||||
use std::ptr;
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct FontTable {
|
||||
data: CFData,
|
||||
|
@ -100,15 +100,15 @@ impl FontHandleMethods for FontHandle {
|
|||
let normalized = self.ctfont.all_traits().normalized_weight();
|
||||
// 0.0 to 9.0
|
||||
let normalized = (normalized + 1.0) / 2.0 * 9.0;
|
||||
if normalized < 1.0 { return font_weight::Weight100; }
|
||||
if normalized < 2.0 { return font_weight::Weight200; }
|
||||
if normalized < 3.0 { return font_weight::Weight300; }
|
||||
if normalized < 4.0 { return font_weight::Weight400; }
|
||||
if normalized < 5.0 { return font_weight::Weight500; }
|
||||
if normalized < 6.0 { return font_weight::Weight600; }
|
||||
if normalized < 7.0 { return font_weight::Weight700; }
|
||||
if normalized < 8.0 { return font_weight::Weight800; }
|
||||
return font_weight::Weight900;
|
||||
if normalized < 1.0 { return font_weight::T::Weight100; }
|
||||
if normalized < 2.0 { return font_weight::T::Weight200; }
|
||||
if normalized < 3.0 { return font_weight::T::Weight300; }
|
||||
if normalized < 4.0 { return font_weight::T::Weight400; }
|
||||
if normalized < 5.0 { return font_weight::T::Weight500; }
|
||||
if normalized < 6.0 { return font_weight::T::Weight600; }
|
||||
if normalized < 7.0 { return font_weight::T::Weight700; }
|
||||
if normalized < 8.0 { return font_weight::T::Weight800; }
|
||||
return font_weight::T::Weight900;
|
||||
}
|
||||
|
||||
fn glyph_index(&self, codepoint: char) -> Option<GlyphId> {
|
||||
|
@ -179,7 +179,7 @@ impl FontHandleMethods for FontHandle {
|
|||
average_advance: average_advance,
|
||||
line_gap: Au::from_frac_px(line_gap),
|
||||
};
|
||||
debug!("Font metrics (@{:f} pt): {}", self.ctfont.pt_size() as f64, metrics);
|
||||
debug!("Font metrics (@{} pt): {}", self.ctfont.pt_size() as f64, metrics);
|
||||
return metrics;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ pub struct FontContextHandle {
|
|||
ctx: ()
|
||||
}
|
||||
|
||||
#[deriving(Clone)]
|
||||
impl FontContextHandle {
|
||||
// this is a placeholder until NSFontManager or whatever is bound in here.
|
||||
pub fn new() -> FontContextHandle {
|
||||
|
|
|
@ -22,7 +22,7 @@ use geom::point::Point2D;
|
|||
/// In the uncommon case (multiple glyphs per unicode character, large glyph index/advance, or
|
||||
/// glyph offsets), we pack the glyph count into GlyphEntry, and store the other glyph information
|
||||
/// in DetailedGlyphStore.
|
||||
#[deriving(Clone, Show)]
|
||||
#[deriving(Clone, Show, Copy)]
|
||||
struct GlyphEntry {
|
||||
value: u32,
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ impl GlyphEntry {
|
|||
pub type GlyphId = u32;
|
||||
|
||||
// TODO: unify with bit flags?
|
||||
#[deriving(PartialEq)]
|
||||
#[deriving(PartialEq, Copy)]
|
||||
pub enum BreakType {
|
||||
None,
|
||||
Normal,
|
||||
|
@ -251,7 +251,7 @@ impl GlyphEntry {
|
|||
|
||||
// Stores data for a detailed glyph, in the case that several glyphs
|
||||
// correspond to one character, or the glyph's data couldn't be packed.
|
||||
#[deriving(Clone, Show)]
|
||||
#[deriving(Clone, Show, Copy)]
|
||||
struct DetailedGlyph {
|
||||
id: GlyphId,
|
||||
// glyph's advance, in the text's direction (RTL or RTL)
|
||||
|
@ -270,7 +270,7 @@ impl DetailedGlyph {
|
|||
}
|
||||
}
|
||||
|
||||
#[deriving(PartialEq, Clone, Eq, Show)]
|
||||
#[deriving(PartialEq, Clone, Eq, Show, Copy)]
|
||||
struct DetailedGlyphRecord {
|
||||
// source string offset/GlyphEntry offset in the TextRun
|
||||
entry_offset: CharIndex,
|
||||
|
@ -411,6 +411,7 @@ impl<'a> DetailedGlyphStore {
|
|||
|
||||
// This struct is used by GlyphStore clients to provide new glyph data.
|
||||
// It should be allocated on the stack and passed by reference to GlyphStore.
|
||||
#[deriving(Copy)]
|
||||
pub struct GlyphData {
|
||||
id: GlyphId,
|
||||
advance: Au,
|
||||
|
@ -443,6 +444,7 @@ impl GlyphData {
|
|||
// through glyphs (either for a particular TextRun offset, or all glyphs).
|
||||
// Rather than eagerly assembling and copying glyph data, it only retrieves
|
||||
// values as they are needed from the GlyphStore, using provided offsets.
|
||||
#[deriving(Copy)]
|
||||
pub enum GlyphInfo<'a> {
|
||||
Simple(&'a GlyphStore, CharIndex),
|
||||
Detail(&'a GlyphStore, CharIndex, u16),
|
||||
|
|
|
@ -503,7 +503,7 @@ impl Shaper {
|
|||
// space (U+00A0) left in the text after the white space processing rules have been
|
||||
// applied. The effect of the property on other word-separator characters is undefined."
|
||||
// We elect to only space the two required code points.
|
||||
if character == ' ' || character == '\u00a0' {
|
||||
if character == ' ' || character == '\u{a0}' {
|
||||
advance = advance + options.word_spacing
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ use servo_util::geometry::Au;
|
|||
use servo_util::range::Range;
|
||||
use servo_util::vec::{Comparator, FullBinarySearchMethods};
|
||||
use std::slice::Items;
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
use text::glyph::{CharIndex, GlyphStore};
|
||||
|
||||
/// A single "paragraph" of text in one font size and style.
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use text::glyph::CharIndex;
|
||||
|
||||
#[deriving(PartialEq)]
|
||||
#[deriving(PartialEq, Eq, Copy)]
|
||||
pub enum CompressionMode {
|
||||
CompressNone,
|
||||
CompressWhitespace,
|
||||
|
|
|
@ -34,9 +34,6 @@ path = "../util"
|
|||
[dependencies.cssparser]
|
||||
git = "https://github.com/servo/rust-cssparser"
|
||||
|
||||
[dependencies.encoding]
|
||||
git = "https://github.com/lifthrasiir/rust-encoding"
|
||||
|
||||
[dependencies.geom]
|
||||
git = "https://github.com/servo/rust-geom"
|
||||
|
||||
|
@ -48,3 +45,6 @@ git = "https://github.com/servo/string-cache"
|
|||
|
||||
[dependencies.string_cache_macros]
|
||||
git = "https://github.com/servo/string-cache"
|
||||
|
||||
[dependencies]
|
||||
encoding = "0.2"
|
||||
|
|
|
@ -61,7 +61,7 @@ use style::ComputedValues;
|
|||
use style::computed_values::{LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
|
||||
use style::computed_values::{LengthOrPercentage, box_sizing, display, float};
|
||||
use style::computed_values::{overflow, position};
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Information specific to floated blocks.
|
||||
#[deriving(Clone, Encodable)]
|
||||
|
@ -92,6 +92,7 @@ impl FloatedBlockInfo {
|
|||
}
|
||||
|
||||
/// The solutions for the block-size-and-margins constraint equation.
|
||||
#[deriving(Copy)]
|
||||
struct BSizeConstraintSolution {
|
||||
block_start: Au,
|
||||
_block_end: Au,
|
||||
|
@ -347,8 +348,8 @@ impl CandidateBSizeIterator {
|
|||
|
||||
// If the style includes `box-sizing: border-box`, subtract the border and padding.
|
||||
let adjustment_for_box_sizing = match fragment.style.get_box().box_sizing {
|
||||
box_sizing::border_box => fragment.border_padding.block_start_end(),
|
||||
box_sizing::content_box => Au(0),
|
||||
box_sizing::T::border_box => fragment.border_padding.block_start_end(),
|
||||
box_sizing::T::content_box => Au(0),
|
||||
};
|
||||
|
||||
return CandidateBSizeIterator {
|
||||
|
@ -1323,12 +1324,12 @@ impl BlockFlow {
|
|||
}
|
||||
|
||||
match flow::base(kid).flags.float_kind() {
|
||||
float::none => {}
|
||||
float::left => {
|
||||
float::T::none => {}
|
||||
float::T::left => {
|
||||
inline_size_of_preceding_left_floats = inline_size_of_preceding_left_floats +
|
||||
flow::base(kid).intrinsic_inline_sizes.preferred_inline_size;
|
||||
}
|
||||
float::right => {
|
||||
float::T::right => {
|
||||
inline_size_of_preceding_right_floats = inline_size_of_preceding_right_floats +
|
||||
flow::base(kid).intrinsic_inline_sizes.preferred_inline_size;
|
||||
}
|
||||
|
@ -1408,14 +1409,16 @@ impl BlockFlow {
|
|||
/// `FormattingContextType`.
|
||||
fn formatting_context_type(&self) -> FormattingContextType {
|
||||
let style = self.fragment.style();
|
||||
if style.get_box().float != float::none {
|
||||
if style.get_box().float != float::T::none {
|
||||
return FormattingContextType::Other
|
||||
}
|
||||
match style.get_box().display {
|
||||
display::table_cell | display::table_caption | display::inline_block => {
|
||||
display::T::table_cell |
|
||||
display::T::table_caption |
|
||||
display::T::inline_block => {
|
||||
FormattingContextType::Other
|
||||
}
|
||||
_ if style.get_box().overflow != overflow::visible => FormattingContextType::Block,
|
||||
_ if style.get_box().overflow != overflow::T::visible => FormattingContextType::Block,
|
||||
_ => FormattingContextType::None,
|
||||
}
|
||||
}
|
||||
|
@ -1462,7 +1465,7 @@ impl BlockFlow {
|
|||
}
|
||||
|
||||
fn is_inline_block(&self) -> bool {
|
||||
self.fragment.style().get_box().display == display::inline_block
|
||||
self.fragment.style().get_box().display == display::T::inline_block
|
||||
}
|
||||
|
||||
/// Computes the content portion (only) of the intrinsic inline sizes of this flow. This is
|
||||
|
@ -1527,16 +1530,16 @@ impl Flow for BlockFlow {
|
|||
child_base.intrinsic_inline_sizes.minimum_inline_size);
|
||||
|
||||
match float_kind {
|
||||
float::none => {
|
||||
float::T::none => {
|
||||
computation.content_intrinsic_sizes.preferred_inline_size =
|
||||
max(computation.content_intrinsic_sizes.preferred_inline_size,
|
||||
child_base.intrinsic_inline_sizes.preferred_inline_size);
|
||||
}
|
||||
float::left => {
|
||||
float::T::left => {
|
||||
left_float_width = left_float_width +
|
||||
child_base.intrinsic_inline_sizes.preferred_inline_size;
|
||||
}
|
||||
float::right => {
|
||||
float::T::right => {
|
||||
right_float_width = right_float_width +
|
||||
child_base.intrinsic_inline_sizes.preferred_inline_size;
|
||||
}
|
||||
|
@ -1556,9 +1559,9 @@ impl Flow for BlockFlow {
|
|||
self.base.intrinsic_inline_sizes = computation.finish();
|
||||
|
||||
match self.fragment.style().get_box().float {
|
||||
float::none => {}
|
||||
float::left => flags.insert(HAS_LEFT_FLOATED_DESCENDANTS),
|
||||
float::right => flags.insert(HAS_RIGHT_FLOATED_DESCENDANTS),
|
||||
float::T::none => {}
|
||||
float::T::left => flags.insert(HAS_LEFT_FLOATED_DESCENDANTS),
|
||||
float::T::right => flags.insert(HAS_RIGHT_FLOATED_DESCENDANTS),
|
||||
}
|
||||
self.base.flags = flags
|
||||
}
|
||||
|
@ -1911,7 +1914,7 @@ impl fmt::Show for BlockFlow {
|
|||
}
|
||||
|
||||
/// The inputs for the inline-sizes-and-margins constraint equation.
|
||||
#[deriving(Show)]
|
||||
#[deriving(Show, Copy)]
|
||||
pub struct ISizeConstraintInput {
|
||||
pub computed_inline_size: MaybeAuto,
|
||||
pub inline_start_margin: MaybeAuto,
|
||||
|
@ -1944,7 +1947,7 @@ impl ISizeConstraintInput {
|
|||
}
|
||||
|
||||
/// The solutions for the inline-size-and-margins constraint equation.
|
||||
#[deriving(Show)]
|
||||
#[deriving(Copy, Show)]
|
||||
pub struct ISizeConstraintSolution {
|
||||
pub inline_start: Au,
|
||||
pub inline_end: Au,
|
||||
|
@ -2006,11 +2009,12 @@ pub trait ISizeAndMarginsComputer {
|
|||
|
||||
let style = block.fragment.style();
|
||||
match (computed_inline_size, style.get_box().box_sizing) {
|
||||
(MaybeAuto::Specified(size), box_sizing::border_box) => {
|
||||
(MaybeAuto::Specified(size), box_sizing::T::border_box) => {
|
||||
computed_inline_size =
|
||||
MaybeAuto::Specified(size - block.fragment.border_padding.inline_start_end())
|
||||
}
|
||||
(MaybeAuto::Auto, box_sizing::border_box) | (_, box_sizing::content_box) => {}
|
||||
(MaybeAuto::Auto, box_sizing::T::border_box) |
|
||||
(_, box_sizing::T::content_box) => {}
|
||||
}
|
||||
|
||||
// The text alignment of a block flow is the text alignment of its box's style.
|
||||
|
|
|
@ -55,7 +55,7 @@ use std::sync::atomic::Relaxed;
|
|||
use style::computed_values::{caption_side, display, empty_cells, float, list_style_position};
|
||||
use style::computed_values::{position};
|
||||
use style::{mod, ComputedValues};
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
use url::Url;
|
||||
|
||||
/// The results of flow construction for a DOM node.
|
||||
|
@ -701,7 +701,7 @@ impl<'a> FlowConstructor<'a> {
|
|||
// `<div style="position:absolute">foo bar baz</div>`. The fragments for `foo`, `bar`, and
|
||||
// `baz` had better not be absolutely positioned!
|
||||
let mut style = (*node.style()).clone();
|
||||
if style.get_box().display != display::inline {
|
||||
if style.get_box().display != display::T::inline {
|
||||
style = Arc::new(style::make_inline(&*style))
|
||||
}
|
||||
|
||||
|
@ -859,7 +859,7 @@ impl<'a> FlowConstructor<'a> {
|
|||
float_value: float::T) -> ConstructionResult {
|
||||
let fragment = Fragment::new_from_specific_info(node, SpecificFragmentInfo::TableWrapper);
|
||||
let wrapper_flow = match float_value {
|
||||
float::none => box TableWrapperFlow::from_node_and_fragment(node, fragment),
|
||||
float::T::none => box TableWrapperFlow::from_node_and_fragment(node, fragment),
|
||||
_ => {
|
||||
let float_kind = FloatKind::from_property(float_value);
|
||||
box TableWrapperFlow::float_from_node_and_fragment(node, fragment, float_kind)
|
||||
|
@ -882,7 +882,7 @@ impl<'a> FlowConstructor<'a> {
|
|||
// value of `caption-side`.
|
||||
self.place_table_caption_under_table_wrapper_on_side(&mut wrapper_flow,
|
||||
node,
|
||||
caption_side::top);
|
||||
caption_side::T::top);
|
||||
|
||||
match construction_result {
|
||||
ConstructionResult::Flow(table_flow, table_abs_descendants) => {
|
||||
|
@ -895,7 +895,7 @@ impl<'a> FlowConstructor<'a> {
|
|||
// If the value of `caption-side` is `bottom`, place it now.
|
||||
self.place_table_caption_under_table_wrapper_on_side(&mut wrapper_flow,
|
||||
node,
|
||||
caption_side::bottom);
|
||||
caption_side::T::bottom);
|
||||
|
||||
// The flow is done.
|
||||
wrapper_flow.finish();
|
||||
|
@ -954,10 +954,12 @@ impl<'a> FlowConstructor<'a> {
|
|||
// Determine if the table cell should be hidden. Per CSS 2.1 § 17.6.1.1, this will be true
|
||||
// if the cell has any in-flow elements (even empty ones!) and has `empty-cells` set to
|
||||
// `hide`.
|
||||
let hide = node.style().get_inheritedtable().empty_cells == empty_cells::hide &&
|
||||
let hide = node.style().get_inheritedtable().empty_cells == empty_cells::T::hide &&
|
||||
node.children().all(|kid| {
|
||||
let position = kid.style().get_box().position;
|
||||
!kid.is_content() || position == position::absolute || position == position::fixed
|
||||
!kid.is_content() ||
|
||||
position == position::T::absolute ||
|
||||
position == position::T::fixed
|
||||
});
|
||||
|
||||
let flow = box TableCellFlow::from_node_fragment_and_visibility_flag(node, fragment, !hide)
|
||||
|
@ -1003,11 +1005,11 @@ impl<'a> FlowConstructor<'a> {
|
|||
let flow;
|
||||
let initial_fragment;
|
||||
match node.style().get_list().list_style_position {
|
||||
list_style_position::outside => {
|
||||
list_style_position::T::outside => {
|
||||
flow = box ListItemFlow::from_node_and_marker(self, node, marker_fragment);
|
||||
initial_fragment = None;
|
||||
}
|
||||
list_style_position::inside => {
|
||||
list_style_position::T::inside => {
|
||||
flow = box ListItemFlow::from_node_and_marker(self, node, None);
|
||||
initial_fragment = marker_fragment;
|
||||
}
|
||||
|
@ -1117,7 +1119,7 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> {
|
|||
// Pseudo-element.
|
||||
let style = node.style();
|
||||
let display = match node.get_pseudo_element_type() {
|
||||
PseudoElementType::Normal => display::inline,
|
||||
PseudoElementType::Normal => display::T::inline,
|
||||
PseudoElementType::Before(display) => display,
|
||||
PseudoElementType::After(display) => display,
|
||||
};
|
||||
|
@ -1126,20 +1128,20 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> {
|
|||
Some(NodeTypeId::Element(_)) => {
|
||||
let style = node.style();
|
||||
let munged_display = if style.get_box()._servo_display_for_hypothetical_box ==
|
||||
display::inline {
|
||||
display::inline
|
||||
display::T::inline {
|
||||
display::T::inline
|
||||
} else {
|
||||
style.get_box().display
|
||||
};
|
||||
(munged_display, style.get_box().float, style.get_box().position)
|
||||
}
|
||||
Some(NodeTypeId::Text) => (display::inline, float::none, position::static_),
|
||||
Some(NodeTypeId::Text) => (display::T::inline, float::T::none, position::T::static_),
|
||||
Some(NodeTypeId::Comment) |
|
||||
Some(NodeTypeId::DocumentType) |
|
||||
Some(NodeTypeId::DocumentFragment) |
|
||||
Some(NodeTypeId::Document) |
|
||||
Some(NodeTypeId::ProcessingInstruction) => {
|
||||
(display::none, float::none, position::static_)
|
||||
(display::T::none, float::T::none, position::T::static_)
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1149,14 +1151,14 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> {
|
|||
match (display, float, positioning) {
|
||||
// `display: none` contributes no flow construction result. Nuke the flow construction
|
||||
// results of children.
|
||||
(display::none, _, _) => {
|
||||
(display::T::none, _, _) => {
|
||||
for child in node.children() {
|
||||
drop(child.swap_out_construction_result())
|
||||
}
|
||||
}
|
||||
|
||||
// Table items contribute table flow construction results.
|
||||
(display::table, float_value, _) => {
|
||||
(display::T::table, float_value, _) => {
|
||||
let construction_result = self.build_flow_for_table_wrapper(node, float_value);
|
||||
node.set_flow_construction_result(construction_result)
|
||||
}
|
||||
|
@ -1167,18 +1169,19 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> {
|
|||
// positioned, but inline we shouldn't try to construct a block
|
||||
// flow here - instead, let it match the inline case
|
||||
// below.
|
||||
(display::block, _, position::absolute) | (_, _, position::fixed) => {
|
||||
(display::T::block, _, position::T::absolute) |
|
||||
(_, _, position::T::fixed) => {
|
||||
node.set_flow_construction_result(self.build_flow_for_nonfloated_block(node))
|
||||
}
|
||||
|
||||
// List items contribute their own special flows.
|
||||
(display::list_item, _, _) => {
|
||||
(display::T::list_item, _, _) => {
|
||||
node.set_flow_construction_result(self.build_flow_for_list_item(node))
|
||||
}
|
||||
|
||||
// Inline items that are absolutely-positioned contribute inline fragment construction
|
||||
// results with a hypothetical fragment.
|
||||
(display::inline, _, position::absolute) => {
|
||||
(display::T::inline, _, position::T::absolute) => {
|
||||
let construction_result =
|
||||
self.build_fragment_for_absolutely_positioned_inline(node);
|
||||
node.set_flow_construction_result(construction_result)
|
||||
|
@ -1187,50 +1190,51 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> {
|
|||
// Inline items contribute inline fragment construction results.
|
||||
//
|
||||
// FIXME(pcwalton, #3307): This is not sufficient to handle floated generated content.
|
||||
(display::inline, float::none, _) => {
|
||||
(display::T::inline, float::T::none, _) => {
|
||||
let construction_result = self.build_fragments_for_inline(node);
|
||||
node.set_flow_construction_result(construction_result)
|
||||
}
|
||||
|
||||
// Inline-block items contribute inline fragment construction results.
|
||||
(display::inline_block, float::none, _) => {
|
||||
(display::T::inline_block, float::T::none, _) => {
|
||||
let construction_result = self.build_fragment_for_inline_block(node);
|
||||
node.set_flow_construction_result(construction_result)
|
||||
}
|
||||
|
||||
// Table items contribute table flow construction results.
|
||||
(display::table_caption, _, _) => {
|
||||
(display::T::table_caption, _, _) => {
|
||||
let construction_result = self.build_flow_for_table_caption(node);
|
||||
node.set_flow_construction_result(construction_result)
|
||||
}
|
||||
|
||||
// Table items contribute table flow construction results.
|
||||
(display::table_column_group, _, _) => {
|
||||
(display::T::table_column_group, _, _) => {
|
||||
let construction_result = self.build_flow_for_table_colgroup(node);
|
||||
node.set_flow_construction_result(construction_result)
|
||||
}
|
||||
|
||||
// Table items contribute table flow construction results.
|
||||
(display::table_column, _, _) => {
|
||||
(display::T::table_column, _, _) => {
|
||||
let construction_result = self.build_fragments_for_table_column(node);
|
||||
node.set_flow_construction_result(construction_result)
|
||||
}
|
||||
|
||||
// Table items contribute table flow construction results.
|
||||
(display::table_row_group, _, _) | (display::table_header_group, _, _) |
|
||||
(display::table_footer_group, _, _) => {
|
||||
(display::T::table_row_group, _, _) |
|
||||
(display::T::table_header_group, _, _) |
|
||||
(display::T::table_footer_group, _, _) => {
|
||||
let construction_result = self.build_flow_for_table_rowgroup(node);
|
||||
node.set_flow_construction_result(construction_result)
|
||||
}
|
||||
|
||||
// Table items contribute table flow construction results.
|
||||
(display::table_row, _, _) => {
|
||||
(display::T::table_row, _, _) => {
|
||||
let construction_result = self.build_flow_for_table_row(node);
|
||||
node.set_flow_construction_result(construction_result)
|
||||
}
|
||||
|
||||
// Table items contribute table flow construction results.
|
||||
(display::table_cell, _, _) => {
|
||||
(display::T::table_cell, _, _) => {
|
||||
let construction_result = self.build_flow_for_table_cell(node);
|
||||
node.set_flow_construction_result(construction_result)
|
||||
}
|
||||
|
@ -1240,7 +1244,7 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> {
|
|||
// TODO(pcwalton): Make this only trigger for blocks and handle the other `display`
|
||||
// properties separately.
|
||||
|
||||
(_, float::none, _) => {
|
||||
(_, float::T::none, _) => {
|
||||
node.set_flow_construction_result(self.build_flow_for_nonfloated_block(node))
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,10 @@ use script_traits::UntrustedNodeAddress;
|
|||
use servo_msg::constellation_msg::ConstellationChan;
|
||||
use servo_net::local_image_cache::LocalImageCache;
|
||||
use servo_util::geometry::Au;
|
||||
use sync::{Arc, Mutex};
|
||||
use std::cell::Cell;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use style::Stylist;
|
||||
use url::Url;
|
||||
|
||||
|
@ -26,25 +28,21 @@ struct LocalLayoutContext {
|
|||
style_sharing_candidate_cache: StyleSharingCandidateCache,
|
||||
}
|
||||
|
||||
local_data_key!(local_context_key: *mut LocalLayoutContext)
|
||||
thread_local!(static local_context_key: Cell<*mut LocalLayoutContext> = Cell::new(ptr::null_mut()))
|
||||
|
||||
fn create_or_get_local_context(shared_layout_context: &SharedLayoutContext) -> *mut LocalLayoutContext {
|
||||
let maybe_context = local_context_key.get();
|
||||
|
||||
let context = match maybe_context {
|
||||
None => {
|
||||
local_context_key.with(|ref r| {
|
||||
if r.get().is_null() {
|
||||
let context = box LocalLayoutContext {
|
||||
font_context: FontContext::new(shared_layout_context.font_cache_task.clone()),
|
||||
applicable_declarations_cache: ApplicableDeclarationsCache::new(),
|
||||
style_sharing_candidate_cache: StyleSharingCandidateCache::new(),
|
||||
};
|
||||
local_context_key.replace(Some(unsafe { mem::transmute(context) }));
|
||||
local_context_key.get().unwrap()
|
||||
},
|
||||
Some(context) => context
|
||||
};
|
||||
r.set(unsafe { mem::transmute(context) });
|
||||
}
|
||||
|
||||
*context
|
||||
r.get()
|
||||
})
|
||||
}
|
||||
|
||||
pub struct SharedLayoutContext {
|
||||
|
|
|
@ -20,7 +20,7 @@ use std::slice::Items;
|
|||
use string_cache::{Atom, Namespace};
|
||||
use style::{mod, PseudoElement, ComputedValues, DeclarationBlock, Stylist, TElement, TNode};
|
||||
use style::{CommonStyleAffectingAttributeMode, CommonStyleAffectingAttributes, cascade};
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct ApplicableDeclarations {
|
||||
pub normal: SmallVec16<DeclarationBlock>,
|
||||
|
|
|
@ -8,7 +8,7 @@ use wrapper::{PseudoElementType, ThreadSafeLayoutNode};
|
|||
|
||||
use std::mem;
|
||||
use style::ComputedValues;
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Node mixin providing `style` method that returns a `NodeStyle`
|
||||
pub trait StyledNode {
|
||||
|
|
|
@ -28,15 +28,15 @@ use gfx::display_list::{BorderRadii, BoxShadowDisplayItem, ClippingRegion};
|
|||
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::display_list::TextOrientation;
|
||||
use gfx::display_list::{SolidColorDisplayItem};
|
||||
use gfx::display_list::{StackingContext, TextDisplayItem};
|
||||
use gfx::paint_task::PaintLayer;
|
||||
use servo_msg::compositor_msg::{FixedPosition, Scrollable};
|
||||
use servo_msg::compositor_msg::ScrollPolicy;
|
||||
use servo_msg::constellation_msg::Msg as ConstellationMsg;
|
||||
use servo_msg::constellation_msg::ConstellationChan;
|
||||
use servo_net::image::holder::ImageHolder;
|
||||
use servo_util::cursor::{DefaultCursor, TextCursor, VerticalTextCursor};
|
||||
use servo_util::cursor::Cursor;
|
||||
use servo_util::geometry::{mod, Au};
|
||||
use servo_util::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize};
|
||||
use servo_util::opts;
|
||||
|
@ -48,7 +48,7 @@ use style::computed_values::{background_attachment, background_repeat, border_st
|
|||
use style::computed_values::{position, visibility};
|
||||
use style::style_structs::Border;
|
||||
use style::{ComputedValues, RGBA};
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
use url::Url;
|
||||
|
||||
/// The results of display list building for a single flow.
|
||||
|
@ -253,7 +253,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
base: BaseDisplayItem::new(*absolute_bounds,
|
||||
DisplayItemMetadata::new(self.node,
|
||||
style,
|
||||
DefaultCursor),
|
||||
Cursor::DefaultCursor),
|
||||
clip.clone()),
|
||||
color: background_color.to_gfx_color(),
|
||||
}), level);
|
||||
|
@ -319,10 +319,10 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
|
||||
// Use background-attachment to get the initial virtual origin
|
||||
let (virtual_origin_x, virtual_origin_y) = match background.background_attachment {
|
||||
background_attachment::scroll => {
|
||||
background_attachment::T::scroll => {
|
||||
(absolute_bounds.origin.x, absolute_bounds.origin.y)
|
||||
}
|
||||
background_attachment::fixed => {
|
||||
background_attachment::T::fixed => {
|
||||
(Au(0), Au(0))
|
||||
}
|
||||
};
|
||||
|
@ -338,25 +338,25 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
|
||||
// Adjust origin and size based on background-repeat
|
||||
match background.background_repeat {
|
||||
background_repeat::no_repeat => {
|
||||
background_repeat::T::no_repeat => {
|
||||
bounds.origin.x = abs_x;
|
||||
bounds.origin.y = abs_y;
|
||||
bounds.size.width = image_width;
|
||||
bounds.size.height = image_height;
|
||||
}
|
||||
background_repeat::repeat_x => {
|
||||
background_repeat::T::repeat_x => {
|
||||
bounds.origin.y = abs_y;
|
||||
bounds.size.height = image_height;
|
||||
ImageFragmentInfo::tile_image(&mut bounds.origin.x, &mut bounds.size.width,
|
||||
abs_x, image.width);
|
||||
}
|
||||
background_repeat::repeat_y => {
|
||||
background_repeat::T::repeat_y => {
|
||||
bounds.origin.x = abs_x;
|
||||
bounds.size.width = image_width;
|
||||
ImageFragmentInfo::tile_image(&mut bounds.origin.y, &mut bounds.size.height,
|
||||
abs_y, image.height);
|
||||
}
|
||||
background_repeat::repeat => {
|
||||
background_repeat::T::repeat => {
|
||||
ImageFragmentInfo::tile_image(&mut bounds.origin.x, &mut bounds.size.width,
|
||||
abs_x, image.width);
|
||||
ImageFragmentInfo::tile_image(&mut bounds.origin.y, &mut bounds.size.height,
|
||||
|
@ -367,7 +367,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
// Create the image display item.
|
||||
display_list.push(DisplayItem::ImageClass(box ImageDisplayItem {
|
||||
base: BaseDisplayItem::new(bounds,
|
||||
DisplayItemMetadata::new(self.node, style, DefaultCursor),
|
||||
DisplayItemMetadata::new(self.node, style, Cursor::DefaultCursor),
|
||||
clip),
|
||||
image: image.clone(),
|
||||
stretch_size: Size2D(Au::from_px(image.width as int),
|
||||
|
@ -477,7 +477,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
|
||||
let gradient_display_item = DisplayItem::GradientClass(box GradientDisplayItem {
|
||||
base: BaseDisplayItem::new(*absolute_bounds,
|
||||
DisplayItemMetadata::new(self.node, style, DefaultCursor),
|
||||
DisplayItemMetadata::new(self.node, style, Cursor::DefaultCursor),
|
||||
clip),
|
||||
start_point: center - delta,
|
||||
end_point: center + delta,
|
||||
|
@ -505,7 +505,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
base: BaseDisplayItem::new(bounds,
|
||||
DisplayItemMetadata::new(self.node,
|
||||
style,
|
||||
DefaultCursor),
|
||||
Cursor::DefaultCursor),
|
||||
(*clip).clone()),
|
||||
box_bounds: *absolute_bounds,
|
||||
color: style.resolve_color(box_shadow.color).to_gfx_color(),
|
||||
|
@ -536,7 +536,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
// Append the border to the display list.
|
||||
display_list.push(DisplayItem::BorderClass(box BorderDisplayItem {
|
||||
base: BaseDisplayItem::new(*abs_bounds,
|
||||
DisplayItemMetadata::new(self.node, style, DefaultCursor),
|
||||
DisplayItemMetadata::new(self.node, style, Cursor::DefaultCursor),
|
||||
(*clip).clone()),
|
||||
border_widths: border.to_physical(style.writing_mode),
|
||||
color: SideOffsets2D::new(top_color.to_gfx_color(),
|
||||
|
@ -562,7 +562,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
}
|
||||
|
||||
let outline_style = style.get_outline().outline_style;
|
||||
if outline_style == border_style::none {
|
||||
if outline_style == border_style::T::none {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -578,7 +578,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
let color = style.resolve_color(style.get_outline().outline_color).to_gfx_color();
|
||||
display_list.outlines.push_back(DisplayItem::BorderClass(box BorderDisplayItem {
|
||||
base: BaseDisplayItem::new(bounds,
|
||||
DisplayItemMetadata::new(self.node, style, DefaultCursor),
|
||||
DisplayItemMetadata::new(self.node, style, Cursor::DefaultCursor),
|
||||
(*clip).clone()),
|
||||
border_widths: SideOffsets2D::new_all_same(width),
|
||||
color: SideOffsets2D::new_all_same(color),
|
||||
|
@ -600,11 +600,11 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
// Compute the text fragment bounds and draw a border surrounding them.
|
||||
display_list.content.push_back(DisplayItem::BorderClass(box BorderDisplayItem {
|
||||
base: BaseDisplayItem::new(*stacking_relative_border_box,
|
||||
DisplayItemMetadata::new(self.node, style, DefaultCursor),
|
||||
DisplayItemMetadata::new(self.node, style, Cursor::DefaultCursor),
|
||||
(*clip).clone()),
|
||||
border_widths: SideOffsets2D::new_all_same(Au::from_px(1)),
|
||||
color: SideOffsets2D::new_all_same(color::rgb(0, 0, 200)),
|
||||
style: SideOffsets2D::new_all_same(border_style::solid),
|
||||
style: SideOffsets2D::new_all_same(border_style::T::solid),
|
||||
radius: Default::default(),
|
||||
}));
|
||||
|
||||
|
@ -618,10 +618,10 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
|
||||
let line_display_item = box LineDisplayItem {
|
||||
base: BaseDisplayItem::new(baseline,
|
||||
DisplayItemMetadata::new(self.node, style, DefaultCursor),
|
||||
DisplayItemMetadata::new(self.node, style, Cursor::DefaultCursor),
|
||||
(*clip).clone()),
|
||||
color: color::rgb(0, 200, 0),
|
||||
style: border_style::dashed,
|
||||
style: border_style::T::dashed,
|
||||
};
|
||||
display_list.content.push_back(DisplayItem::LineClass(line_display_item));
|
||||
}
|
||||
|
@ -635,11 +635,11 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
base: BaseDisplayItem::new(*stacking_relative_border_box,
|
||||
DisplayItemMetadata::new(self.node,
|
||||
&*self.style,
|
||||
DefaultCursor),
|
||||
Cursor::DefaultCursor),
|
||||
(*clip).clone()),
|
||||
border_widths: SideOffsets2D::new_all_same(Au::from_px(1)),
|
||||
color: SideOffsets2D::new_all_same(color::rgb(0, 0, 200)),
|
||||
style: SideOffsets2D::new_all_same(border_style::solid),
|
||||
style: SideOffsets2D::new_all_same(border_style::T::solid),
|
||||
radius: Default::default(),
|
||||
}));
|
||||
}
|
||||
|
@ -651,7 +651,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
// Account for `clip` per CSS 2.1 § 11.1.2.
|
||||
let style_clip_rect = match (self.style().get_box().position,
|
||||
self.style().get_effects().clip) {
|
||||
(position::absolute, Some(style_clip_rect)) => style_clip_rect,
|
||||
(position::T::absolute, Some(style_clip_rect)) => style_clip_rect,
|
||||
_ => return (*parent_clip).clone(),
|
||||
};
|
||||
|
||||
|
@ -686,7 +686,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
stacking_relative_flow_origin,
|
||||
self);
|
||||
|
||||
if self.style().get_inheritedbox().visibility != visibility::visible {
|
||||
if self.style().get_inheritedbox().visibility != visibility::T::visible {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -848,7 +848,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
base: BaseDisplayItem::new(stacking_relative_content_box,
|
||||
DisplayItemMetadata::new(self.node,
|
||||
&*self.style,
|
||||
DefaultCursor),
|
||||
Cursor::DefaultCursor),
|
||||
(*clip).clone()),
|
||||
image: image.clone(),
|
||||
stretch_size: stacking_relative_content_box.size,
|
||||
|
@ -899,7 +899,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
|
||||
// Only clip if `overflow` tells us to.
|
||||
match self.style.get_box().overflow {
|
||||
overflow::hidden | overflow::auto | overflow::scroll => {
|
||||
overflow::T::hidden | overflow::T::auto | overflow::T::scroll => {
|
||||
// Create a new clip rect.
|
||||
current_clip.intersect_rect(stacking_relative_border_box)
|
||||
}
|
||||
|
@ -916,12 +916,12 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
// Determine the orientation and cursor to use.
|
||||
let (orientation, cursor) = if self.style.writing_mode.is_vertical() {
|
||||
if self.style.writing_mode.is_sideways_left() {
|
||||
(SidewaysLeft, VerticalTextCursor)
|
||||
(TextOrientation::SidewaysLeft, Cursor::VerticalTextCursor)
|
||||
} else {
|
||||
(SidewaysRight, VerticalTextCursor)
|
||||
(TextOrientation::SidewaysRight, Cursor::VerticalTextCursor)
|
||||
}
|
||||
} else {
|
||||
(Upright, TextCursor)
|
||||
(TextOrientation::Upright, Cursor::TextCursor)
|
||||
};
|
||||
|
||||
// Compute location of the baseline.
|
||||
|
@ -995,7 +995,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
let stacking_relative_box = stacking_relative_box.to_physical(self.style.writing_mode,
|
||||
container_size);
|
||||
|
||||
let metadata = DisplayItemMetadata::new(self.node, &*self.style, DefaultCursor);
|
||||
let metadata = DisplayItemMetadata::new(self.node, &*self.style, Cursor::DefaultCursor);
|
||||
display_list.content.push_back(DisplayItem::SolidColorClass(box SolidColorDisplayItem {
|
||||
base: BaseDisplayItem::new(stacking_relative_box, metadata, (*clip).clone()),
|
||||
color: color.to_gfx_color(),
|
||||
|
@ -1083,9 +1083,9 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
|
|||
|
||||
// If we got here, then we need a new layer.
|
||||
let scroll_policy = if self.is_fixed() {
|
||||
FixedPosition
|
||||
ScrollPolicy::FixedPosition
|
||||
} else {
|
||||
Scrollable
|
||||
ScrollPolicy::Scrollable
|
||||
};
|
||||
|
||||
let transparent = color::rgba(1.0, 1.0, 1.0, 0.0);
|
||||
|
@ -1163,7 +1163,7 @@ impl InlineFlowDisplayListBuilding for InlineFlow {
|
|||
fn build_display_list_for_inline(&mut self, layout_context: &LayoutContext) {
|
||||
// TODO(#228): Once we form lines and have their cached bounds, we can be smarter and
|
||||
// not recurse on a line if nothing in it can intersect the dirty region.
|
||||
debug!("Flow: building display list for {:u} inline fragments", self.fragments.len());
|
||||
debug!("Flow: building display list for {} inline fragments", self.fragments.len());
|
||||
|
||||
let mut display_list = box DisplayList::new();
|
||||
for fragment in self.fragments.fragments.iter_mut() {
|
||||
|
@ -1227,6 +1227,7 @@ impl ListItemFlowDisplayListBuilding for ListItemFlow {
|
|||
}
|
||||
|
||||
// A helper data structure for gradients.
|
||||
#[deriving(Copy)]
|
||||
struct StopRun {
|
||||
start_offset: f32,
|
||||
end_offset: f32,
|
||||
|
@ -1250,7 +1251,7 @@ fn position_to_offset(position: LengthOrPercentage, Au(total_length): Au) -> f32
|
|||
}
|
||||
|
||||
/// "Steps" as defined by CSS 2.1 § E.2.
|
||||
#[deriving(Clone, PartialEq, Show)]
|
||||
#[deriving(Clone, PartialEq, Show, Copy)]
|
||||
pub enum StackingLevel {
|
||||
/// The border and backgrounds for the root of this stacking context: steps 1 and 2.
|
||||
BackgroundAndBorders,
|
||||
|
|
|
@ -12,7 +12,7 @@ use std::fmt;
|
|||
use style::computed_values::float;
|
||||
|
||||
/// The kind of float: left or right.
|
||||
#[deriving(Clone, Encodable, Show)]
|
||||
#[deriving(Clone, Encodable, Show, Copy)]
|
||||
pub enum FloatKind {
|
||||
Left,
|
||||
Right
|
||||
|
@ -21,14 +21,15 @@ pub enum FloatKind {
|
|||
impl FloatKind {
|
||||
pub fn from_property(property: float::T) -> FloatKind {
|
||||
match property {
|
||||
float::none => panic!("can't create a float type from an unfloated property"),
|
||||
float::left => FloatKind::Left,
|
||||
float::right => FloatKind::Right,
|
||||
float::T::none => panic!("can't create a float type from an unfloated property"),
|
||||
float::T::left => FloatKind::Left,
|
||||
float::T::right => FloatKind::Right,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The kind of clearance: left, right, or both.
|
||||
#[deriving(Copy)]
|
||||
pub enum ClearType {
|
||||
Left,
|
||||
Right,
|
||||
|
@ -36,7 +37,7 @@ pub enum ClearType {
|
|||
}
|
||||
|
||||
/// Information about a single float.
|
||||
#[deriving(Clone)]
|
||||
#[deriving(Clone, Copy)]
|
||||
struct Float {
|
||||
/// The boundaries of this float.
|
||||
bounds: LogicalRect<Au>,
|
||||
|
|
|
@ -60,7 +60,7 @@ use std::sync::atomic::{AtomicUint, SeqCst};
|
|||
use std::slice::MutItems;
|
||||
use style::computed_values::{clear, empty_cells, float, position, text_align};
|
||||
use style::ComputedValues;
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Virtual methods that make up a float context.
|
||||
///
|
||||
|
@ -255,12 +255,12 @@ pub trait Flow: fmt::Show + ToString + Sync {
|
|||
|
||||
/// The 'position' property of this flow.
|
||||
fn positioning(&self) -> position::T {
|
||||
position::static_
|
||||
position::T::static_
|
||||
}
|
||||
|
||||
/// Return true if this flow has position 'fixed'.
|
||||
fn is_fixed(&self) -> bool {
|
||||
self.positioning() == position::fixed
|
||||
self.positioning() == position::T::fixed
|
||||
}
|
||||
|
||||
fn is_positioned(&self) -> bool {
|
||||
|
@ -268,7 +268,7 @@ pub trait Flow: fmt::Show + ToString + Sync {
|
|||
}
|
||||
|
||||
fn is_relatively_positioned(&self) -> bool {
|
||||
self.positioning() == position::relative
|
||||
self.positioning() == position::T::relative
|
||||
}
|
||||
|
||||
/// Return true if this is the root of an absolute flow tree.
|
||||
|
@ -471,6 +471,7 @@ pub trait PostorderFlowTraversal {
|
|||
|
||||
bitflags! {
|
||||
#[doc = "Flags used in flows."]
|
||||
#[deriving(Copy)]
|
||||
flags FlowFlags: u16 {
|
||||
// floated descendants flags
|
||||
#[doc = "Whether this flow has descendants that float left in the same block formatting"]
|
||||
|
@ -575,11 +576,11 @@ impl FlowFlags {
|
|||
#[inline]
|
||||
pub fn float_kind(&self) -> float::T {
|
||||
if self.contains(FLOATS_LEFT) {
|
||||
float::left
|
||||
float::T::left
|
||||
} else if self.contains(FLOATS_RIGHT) {
|
||||
float::right
|
||||
float::T::right
|
||||
} else {
|
||||
float::none
|
||||
float::T::none
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -658,8 +659,8 @@ pub struct DescendantIter<'a> {
|
|||
iter: MutItems<'a, FlowRef>,
|
||||
}
|
||||
|
||||
impl<'a> Iterator<&'a mut Flow + 'a> for DescendantIter<'a> {
|
||||
fn next(&mut self) -> Option<&'a mut Flow + 'a> {
|
||||
impl<'a> Iterator<&'a mut (Flow + 'a)> for DescendantIter<'a> {
|
||||
fn next(&mut self) -> Option<&'a mut (Flow + 'a)> {
|
||||
self.iter.next().map(|flow| &mut **flow)
|
||||
}
|
||||
}
|
||||
|
@ -668,7 +669,7 @@ pub type DescendantOffsetIter<'a> = Zip<DescendantIter<'a>, MutItems<'a, Au>>;
|
|||
|
||||
/// Information needed to compute absolute (i.e. viewport-relative) flow positions (not to be
|
||||
/// confused with absolutely-positioned flows).
|
||||
#[deriving(Encodable)]
|
||||
#[deriving(Encodable, Copy)]
|
||||
pub struct AbsolutePositionInfo {
|
||||
/// The size of the containing block for relatively-positioned descendants.
|
||||
pub relative_containing_block_size: LogicalSize<Au>,
|
||||
|
@ -863,7 +864,7 @@ impl BaseFlow {
|
|||
Some(node) => {
|
||||
let node_style = node.style();
|
||||
match node_style.get_box().position {
|
||||
position::absolute | position::fixed => {
|
||||
position::T::absolute | position::T::fixed => {
|
||||
flags.insert(IS_ABSOLUTELY_POSITIONED)
|
||||
}
|
||||
_ => {}
|
||||
|
@ -871,17 +872,17 @@ impl BaseFlow {
|
|||
|
||||
if force_nonfloated == ForceNonfloatedFlag::FloatIfNecessary {
|
||||
match node_style.get_box().float {
|
||||
float::none => {}
|
||||
float::left => flags.insert(FLOATS_LEFT),
|
||||
float::right => flags.insert(FLOATS_RIGHT),
|
||||
float::T::none => {}
|
||||
float::T::left => flags.insert(FLOATS_LEFT),
|
||||
float::T::right => flags.insert(FLOATS_RIGHT),
|
||||
}
|
||||
}
|
||||
|
||||
match node_style.get_box().clear {
|
||||
clear::none => {}
|
||||
clear::left => flags.insert(CLEARS_LEFT),
|
||||
clear::right => flags.insert(CLEARS_RIGHT),
|
||||
clear::both => {
|
||||
clear::T::none => {}
|
||||
clear::T::left => flags.insert(CLEARS_LEFT),
|
||||
clear::T::right => flags.insert(CLEARS_RIGHT),
|
||||
clear::T::both => {
|
||||
flags.insert(CLEARS_LEFT);
|
||||
flags.insert(CLEARS_RIGHT);
|
||||
}
|
||||
|
@ -962,7 +963,7 @@ impl BaseFlow {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> ImmutableFlowUtils for &'a Flow + 'a {
|
||||
impl<'a> ImmutableFlowUtils for &'a (Flow + 'a) {
|
||||
/// Returns true if this flow is a block flow.
|
||||
fn is_block_like(self) -> bool {
|
||||
match self.class() {
|
||||
|
@ -1064,7 +1065,7 @@ impl<'a> ImmutableFlowUtils for &'a Flow + 'a {
|
|||
let fragment =
|
||||
Fragment::new_anonymous_from_specific_info(node,
|
||||
SpecificFragmentInfo::TableCell);
|
||||
let hide = node.style().get_inheritedtable().empty_cells == empty_cells::hide;
|
||||
let hide = node.style().get_inheritedtable().empty_cells == empty_cells::T::hide;
|
||||
box TableCellFlow::from_node_fragment_and_visibility_flag(node, fragment, !hide) as
|
||||
Box<Flow>
|
||||
},
|
||||
|
@ -1138,7 +1139,7 @@ impl<'a> ImmutableFlowUtils for &'a Flow + 'a {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> MutableFlowUtils for &'a mut Flow + 'a {
|
||||
impl<'a> MutableFlowUtils for &'a mut (Flow + 'a) {
|
||||
/// Traverses the tree in preorder.
|
||||
fn traverse_preorder<T:PreorderFlowTraversal>(self, traversal: &T) {
|
||||
if traversal.should_process(self) {
|
||||
|
|
|
@ -105,9 +105,9 @@ impl FlowList {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> Iterator<&'a Flow + 'a> for FlowListIterator<'a> {
|
||||
impl<'a> Iterator<&'a (Flow + 'a)> for FlowListIterator<'a> {
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<&'a Flow + 'a> {
|
||||
fn next(&mut self) -> Option<&'a (Flow + 'a)> {
|
||||
self.it.next().map(|x| x.deref())
|
||||
}
|
||||
|
||||
|
@ -117,9 +117,9 @@ impl<'a> Iterator<&'a Flow + 'a> for FlowListIterator<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> Iterator<&'a mut Flow + 'a> for MutFlowListIterator<'a> {
|
||||
impl<'a> Iterator<&'a mut (Flow + 'a)> for MutFlowListIterator<'a> {
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<&'a mut Flow + 'a> {
|
||||
fn next(&mut self) -> Option<&'a mut (Flow + 'a)> {
|
||||
self.it.next().map(|x| x.deref_mut())
|
||||
}
|
||||
|
||||
|
|
|
@ -34,17 +34,17 @@ impl FlowRef {
|
|||
}
|
||||
|
||||
impl<'a> Deref<Flow + 'a> for FlowRef {
|
||||
fn deref(&self) -> &Flow + 'a {
|
||||
fn deref(&self) -> &(Flow + 'a) {
|
||||
unsafe {
|
||||
mem::transmute_copy::<raw::TraitObject, &Flow + 'a>(&self.object)
|
||||
mem::transmute_copy::<raw::TraitObject, &(Flow + 'a)>(&self.object)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> DerefMut<Flow + 'a> for FlowRef {
|
||||
fn deref_mut<'a>(&mut self) -> &mut Flow + 'a {
|
||||
fn deref_mut<'a>(&mut self) -> &mut (Flow + 'a) {
|
||||
unsafe {
|
||||
mem::transmute_copy::<raw::TraitObject, &mut Flow + 'a>(&self.object)
|
||||
mem::transmute_copy::<raw::TraitObject, &mut (Flow + 'a)>(&self.object)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ use style::computed_values::{LengthOrPercentage, LengthOrPercentageOrAuto};
|
|||
use style::computed_values::{LengthOrPercentageOrNone};
|
||||
use style::computed_values::{clear, overflow_wrap, position, text_align};
|
||||
use style::computed_values::{text_decoration, vertical_align, white_space};
|
||||
use sync::{Arc, Mutex};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use url::Url;
|
||||
|
||||
/// Fragments (`struct Fragment`) are the leaves of the layout tree. They cannot position
|
||||
|
@ -398,7 +398,7 @@ impl ScannedTextFragmentInfo {
|
|||
|
||||
/// Describes how to split a fragment. This is used during line breaking as part of the return
|
||||
/// value of `find_split_info_for_inline_size()`.
|
||||
#[deriving(Show)]
|
||||
#[deriving(Show, Clone)]
|
||||
pub struct SplitInfo {
|
||||
// TODO(bjz): this should only need to be a single character index, but both values are
|
||||
// currently needed for splitting in the `inline::try_append_*` functions.
|
||||
|
@ -455,7 +455,7 @@ impl UnscannedTextFragmentInfo {
|
|||
}
|
||||
|
||||
/// A fragment that represents a table column.
|
||||
#[deriving(Clone)]
|
||||
#[deriving(Copy, Clone)]
|
||||
pub struct TableColumnFragmentInfo {
|
||||
/// the number of columns a <col> element should span
|
||||
pub span: int,
|
||||
|
@ -877,7 +877,7 @@ impl Fragment {
|
|||
}
|
||||
|
||||
// Go over the ancestor fragments and add all relative offsets (if any).
|
||||
let mut rel_pos = if self.style().get_box().position == position::relative {
|
||||
let mut rel_pos = if self.style().get_box().position == position::T::relative {
|
||||
from_style(self.style(), containing_block_size)
|
||||
} else {
|
||||
LogicalSize::zero(self.style.writing_mode)
|
||||
|
@ -887,7 +887,7 @@ impl Fragment {
|
|||
None => {}
|
||||
Some(ref inline_fragment_context) => {
|
||||
for style in inline_fragment_context.styles.iter() {
|
||||
if style.get_box().position == position::relative {
|
||||
if style.get_box().position == position::T::relative {
|
||||
rel_pos = rel_pos + from_style(&**style, containing_block_size);
|
||||
}
|
||||
}
|
||||
|
@ -903,10 +903,10 @@ impl Fragment {
|
|||
pub fn clear(&self) -> Option<ClearType> {
|
||||
let style = self.style();
|
||||
match style.get_box().clear {
|
||||
clear::none => None,
|
||||
clear::left => Some(ClearType::Left),
|
||||
clear::right => Some(ClearType::Right),
|
||||
clear::both => Some(ClearType::Both),
|
||||
clear::T::none => None,
|
||||
clear::T::left => Some(ClearType::Left),
|
||||
clear::T::right => Some(ClearType::Right),
|
||||
clear::T::both => Some(ClearType::Both),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1152,7 +1152,7 @@ impl Fragment {
|
|||
let mut flags = SplitOptions::empty();
|
||||
if starts_line {
|
||||
flags.insert(STARTS_LINE);
|
||||
if self.style().get_inheritedtext().overflow_wrap == overflow_wrap::break_word {
|
||||
if self.style().get_inheritedtext().overflow_wrap == overflow_wrap::T::break_word {
|
||||
flags.insert(RETRY_AT_CHARACTER_BOUNDARIES)
|
||||
}
|
||||
}
|
||||
|
@ -1279,8 +1279,8 @@ impl Fragment {
|
|||
/// whitespace that should be stripped.
|
||||
pub fn is_ignorable_whitespace(&self) -> bool {
|
||||
match self.white_space() {
|
||||
white_space::pre => return false,
|
||||
white_space::normal | white_space::nowrap => {}
|
||||
white_space::T::pre => return false,
|
||||
white_space::T::normal | white_space::T::nowrap => {}
|
||||
}
|
||||
match self.specific {
|
||||
SpecificFragmentInfo::UnscannedText(ref text_fragment_info) => {
|
||||
|
@ -1616,12 +1616,12 @@ impl Fragment {
|
|||
return true
|
||||
}
|
||||
match self.style().get_box().position {
|
||||
position::absolute | position::fixed => {
|
||||
position::T::absolute | position::T::fixed => {
|
||||
// FIXME(pcwalton): This should only establish a new stacking context when
|
||||
// `z-index` is not `auto`. But this matches what we did before.
|
||||
true
|
||||
}
|
||||
position::relative | position::static_ => {
|
||||
position::T::relative | position::T::static_ => {
|
||||
// FIXME(pcwalton): `position: relative` establishes a new stacking context if
|
||||
// `z-index` is not `auto`. But this matches what we did before.
|
||||
false
|
||||
|
|
|
@ -12,6 +12,7 @@ use style::ComputedValues;
|
|||
|
||||
bitflags! {
|
||||
#[doc = "Individual layout actions that may be necessary after restyling."]
|
||||
#[deriving(Copy)]
|
||||
flags RestyleDamage: u8 {
|
||||
#[doc = "Repaint the node itself."]
|
||||
#[doc = "Currently unused; need to decide how this propagates."]
|
||||
|
@ -87,7 +88,7 @@ impl RestyleDamage {
|
|||
}
|
||||
|
||||
impl fmt::Show for RestyleDamage {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::FormatError> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||
let mut first_elem = true;
|
||||
|
||||
let to_iter =
|
||||
|
@ -181,7 +182,7 @@ pub trait LayoutDamageComputation {
|
|||
fn reflow_entire_document(self);
|
||||
}
|
||||
|
||||
impl<'a> LayoutDamageComputation for &'a mut Flow+'a {
|
||||
impl<'a> LayoutDamageComputation for &'a mut (Flow + 'a) {
|
||||
fn compute_layout_damage(self) -> SpecialRestyleDamage {
|
||||
let mut special_damage = SpecialRestyleDamage::empty();
|
||||
let is_absolutely_positioned = flow::base(self).flags.contains(IS_ABSOLUTELY_POSITIONED);
|
||||
|
@ -203,7 +204,7 @@ impl<'a> LayoutDamageComputation for &'a mut Flow+'a {
|
|||
}
|
||||
|
||||
let self_base = flow::base(self);
|
||||
if self_base.flags.float_kind() != float::none &&
|
||||
if self_base.flags.float_kind() != float::T::none &&
|
||||
self_base.restyle_damage.intersects(REFLOW) {
|
||||
special_damage.insert(REFLOW_ENTIRE_DOCUMENT);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ use std::mem;
|
|||
use std::u16;
|
||||
use style::computed_values::{text_align, vertical_align, white_space};
|
||||
use style::ComputedValues;
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
|
||||
// From gfxFontConstants.h in Firefox
|
||||
static FONT_SUBSCRIPT_OFFSET_RATIO: f64 = 0.20;
|
||||
|
@ -65,7 +65,7 @@ static FONT_SUPERSCRIPT_OFFSET_RATIO: f64 = 0.34;
|
|||
/// with a float or a horizontal wall of the containing block. The block-start
|
||||
/// inline-start corner of the green zone is the same as that of the line, but
|
||||
/// the green zone can be taller and wider than the line itself.
|
||||
#[deriving(Encodable, Show)]
|
||||
#[deriving(Encodable, Show, Copy)]
|
||||
pub struct Line {
|
||||
/// A range of line indices that describe line breaks.
|
||||
///
|
||||
|
@ -267,14 +267,14 @@ impl LineBreaker {
|
|||
|
||||
// Set up our reflow flags.
|
||||
let flags = match fragment.style().get_inheritedtext().white_space {
|
||||
white_space::normal => InlineReflowFlags::empty(),
|
||||
white_space::pre | white_space::nowrap => NO_WRAP_INLINE_REFLOW_FLAG,
|
||||
white_space::T::normal => InlineReflowFlags::empty(),
|
||||
white_space::T::pre | white_space::T::nowrap => NO_WRAP_INLINE_REFLOW_FLAG,
|
||||
};
|
||||
|
||||
// Try to append the fragment, and commit the line (so we can try again with the next
|
||||
// line) if we couldn't.
|
||||
match fragment.style().get_inheritedtext().white_space {
|
||||
white_space::normal | white_space::nowrap => {
|
||||
white_space::T::normal | white_space::T::nowrap => {
|
||||
if !self.append_fragment_to_line_if_possible(fragment,
|
||||
flow,
|
||||
layout_context,
|
||||
|
@ -282,7 +282,7 @@ impl LineBreaker {
|
|||
self.flush_current_line()
|
||||
}
|
||||
}
|
||||
white_space::pre => {
|
||||
white_space::T::pre => {
|
||||
// FIXME(pcwalton): Surely we can unify
|
||||
// `append_fragment_to_line_if_possible` and
|
||||
// `try_append_to_line_by_new_line` by adding another bit in the reflow
|
||||
|
@ -602,8 +602,8 @@ impl LineBreaker {
|
|||
fragment.border_box.size.block);
|
||||
fragment.transform(size, info)
|
||||
};
|
||||
(split_result.inline_start.map(|x| split_fragment(x)),
|
||||
split_result.inline_end.map(|x| split_fragment(x)))
|
||||
(split_result.inline_start.as_ref().map(|x| split_fragment(x.clone())),
|
||||
split_result.inline_end.as_ref().map(|x| split_fragment(x.clone())))
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -769,53 +769,53 @@ impl InlineFlow {
|
|||
layout_context: &LayoutContext)
|
||||
-> (Au, bool) {
|
||||
match fragment.vertical_align() {
|
||||
vertical_align::baseline => (-ascent, false),
|
||||
vertical_align::middle => {
|
||||
vertical_align::T::baseline => (-ascent, false),
|
||||
vertical_align::T::middle => {
|
||||
// TODO: x-height value should be used from font info.
|
||||
// TODO: The code below passes our current reftests but doesn't work in all
|
||||
// situations. Add vertical align reftests and fix this.
|
||||
(-ascent, false)
|
||||
},
|
||||
vertical_align::sub => {
|
||||
vertical_align::T::sub => {
|
||||
let sub_offset = (parent_text_block_start + parent_text_block_end)
|
||||
.scale_by(FONT_SUBSCRIPT_OFFSET_RATIO);
|
||||
(sub_offset - ascent, false)
|
||||
},
|
||||
vertical_align::super_ => {
|
||||
vertical_align::T::super_ => {
|
||||
let super_offset = (parent_text_block_start + parent_text_block_end)
|
||||
.scale_by(FONT_SUPERSCRIPT_OFFSET_RATIO);
|
||||
(-super_offset - ascent, false)
|
||||
},
|
||||
vertical_align::text_top => {
|
||||
vertical_align::T::text_top => {
|
||||
let fragment_block_size = *block_size_above_baseline + *depth_below_baseline;
|
||||
let prev_depth_below_baseline = *depth_below_baseline;
|
||||
*block_size_above_baseline = parent_text_block_start;
|
||||
*depth_below_baseline = fragment_block_size - *block_size_above_baseline;
|
||||
(*depth_below_baseline - prev_depth_below_baseline - ascent, false)
|
||||
},
|
||||
vertical_align::text_bottom => {
|
||||
vertical_align::T::text_bottom => {
|
||||
let fragment_block_size = *block_size_above_baseline + *depth_below_baseline;
|
||||
let prev_depth_below_baseline = *depth_below_baseline;
|
||||
*depth_below_baseline = parent_text_block_end;
|
||||
*block_size_above_baseline = fragment_block_size - *depth_below_baseline;
|
||||
(*depth_below_baseline - prev_depth_below_baseline - ascent, false)
|
||||
},
|
||||
vertical_align::top => {
|
||||
vertical_align::T::top => {
|
||||
*largest_block_size_for_top_fragments =
|
||||
max(*largest_block_size_for_top_fragments,
|
||||
*block_size_above_baseline + *depth_below_baseline);
|
||||
let offset_top = *block_size_above_baseline - ascent;
|
||||
(offset_top, true)
|
||||
},
|
||||
vertical_align::bottom => {
|
||||
vertical_align::T::bottom => {
|
||||
*largest_block_size_for_bottom_fragments =
|
||||
max(*largest_block_size_for_bottom_fragments,
|
||||
*block_size_above_baseline + *depth_below_baseline);
|
||||
let offset_bottom = -(*depth_below_baseline + ascent);
|
||||
(offset_bottom, true)
|
||||
},
|
||||
vertical_align::Length(length) => (-(length + ascent), false),
|
||||
vertical_align::Percentage(p) => {
|
||||
vertical_align::T::Length(length) => (-(length + ascent), false),
|
||||
vertical_align::T::Percentage(p) => {
|
||||
let line_height = fragment.calculate_line_height(layout_context);
|
||||
let percent_offset = line_height.scale_by(p);
|
||||
(-(percent_offset + ascent), false)
|
||||
|
@ -838,9 +838,9 @@ impl InlineFlow {
|
|||
// coordinates.
|
||||
//
|
||||
// TODO(burg, issue #213): Implement `text-align: justify`.
|
||||
text_align::left | text_align::justify => Au(0),
|
||||
text_align::center => slack_inline_size.scale_by(0.5),
|
||||
text_align::right => slack_inline_size,
|
||||
text_align::T::left | text_align::T::justify => Au(0),
|
||||
text_align::T::center => slack_inline_size.scale_by(0.5),
|
||||
text_align::T::right => slack_inline_size,
|
||||
};
|
||||
|
||||
for fragment_index in range(line.range.begin(), line.range.end()) {
|
||||
|
@ -866,11 +866,11 @@ impl InlineFlow {
|
|||
for fragment_index in range(line.range.begin(), line.range.end()) {
|
||||
let fragment = fragments.get_mut(fragment_index.to_uint());
|
||||
match fragment.vertical_align() {
|
||||
vertical_align::top => {
|
||||
vertical_align::T::top => {
|
||||
fragment.border_box.start.b = fragment.border_box.start.b +
|
||||
line_distance_from_flow_block_start
|
||||
}
|
||||
vertical_align::bottom => {
|
||||
vertical_align::T::bottom => {
|
||||
fragment.border_box.start.b = fragment.border_box.start.b +
|
||||
line_distance_from_flow_block_start + baseline_distance_from_block_start +
|
||||
largest_depth_below_baseline
|
||||
|
|
|
@ -14,7 +14,7 @@ use std::cell::RefCell;
|
|||
use std::io::File;
|
||||
use std::sync::atomic::{AtomicUint, SeqCst, INIT_ATOMIC_UINT};
|
||||
|
||||
local_data_key!(state_key: RefCell<State>)
|
||||
thread_local!(static state_key: RefCell<Option<State>> = RefCell::new(None))
|
||||
|
||||
static mut DEBUG_ID_COUNTER: AtomicUint = INIT_ATOMIC_UINT;
|
||||
|
||||
|
@ -59,16 +59,16 @@ struct State {
|
|||
/// will be output at the beginning and end of this scope.
|
||||
impl Scope {
|
||||
pub fn new(name: String) -> Scope {
|
||||
let maybe_refcell = state_key.get();
|
||||
match maybe_refcell {
|
||||
Some(refcell) => {
|
||||
let mut state = refcell.borrow_mut();
|
||||
state_key.with(|ref r| {
|
||||
match &mut *r.borrow_mut() {
|
||||
&Some(ref mut state) => {
|
||||
let flow_trace = json::encode(&flow::base(state.flow_root.deref()));
|
||||
let data = box ScopeData::new(name, flow_trace);
|
||||
let data = box ScopeData::new(name.clone(), flow_trace);
|
||||
state.scope_stack.push(data);
|
||||
}
|
||||
None => {}
|
||||
&None => {}
|
||||
}
|
||||
});
|
||||
Scope
|
||||
}
|
||||
}
|
||||
|
@ -76,17 +76,17 @@ impl Scope {
|
|||
#[cfg(not(ndebug))]
|
||||
impl Drop for Scope {
|
||||
fn drop(&mut self) {
|
||||
let maybe_refcell = state_key.get();
|
||||
match maybe_refcell {
|
||||
Some(refcell) => {
|
||||
let mut state = refcell.borrow_mut();
|
||||
state_key.with(|ref r| {
|
||||
match &mut *r.borrow_mut() {
|
||||
&Some(ref mut state) => {
|
||||
let mut current_scope = state.scope_stack.pop().unwrap();
|
||||
current_scope.post = json::encode(&flow::base(state.flow_root.deref()));
|
||||
let previous_scope = state.scope_stack.last_mut().unwrap();
|
||||
previous_scope.children.push(current_scope);
|
||||
}
|
||||
None => {}
|
||||
&None => {}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,22 +100,23 @@ pub fn generate_unique_debug_id() -> u16 {
|
|||
/// Begin a layout debug trace. If this has not been called,
|
||||
/// creating debug scopes has no effect.
|
||||
pub fn begin_trace(flow_root: FlowRef) {
|
||||
assert!(state_key.get().is_none());
|
||||
assert!(state_key.with(|ref r| r.borrow().is_none()));
|
||||
|
||||
state_key.with(|ref r| {
|
||||
let flow_trace = json::encode(&flow::base(flow_root.deref()));
|
||||
let state = State {
|
||||
scope_stack: vec![box ScopeData::new("root".into_string(), flow_trace)],
|
||||
flow_root: flow_root,
|
||||
flow_root: flow_root.clone(),
|
||||
};
|
||||
state_key.replace(Some(RefCell::new(state)));
|
||||
*r.borrow_mut() = Some(state);
|
||||
});
|
||||
}
|
||||
|
||||
/// End the debug layout trace. This will write the layout
|
||||
/// trace to disk in the current directory. The output
|
||||
/// file can then be viewed with an external tool.
|
||||
pub fn end_trace() {
|
||||
let task_state_cell = state_key.replace(None).unwrap();
|
||||
let mut task_state = task_state_cell.borrow_mut();
|
||||
let mut task_state = state_key.with(|ref r| r.borrow_mut().take().unwrap());
|
||||
assert!(task_state.scope_stack.len() == 1);
|
||||
let mut root_scope = task_state.scope_stack.pop().unwrap();
|
||||
root_scope.post = json::encode(&flow::base(task_state.flow_root.deref()));
|
||||
|
|
|
@ -30,27 +30,27 @@ use gfx::display_list::{StackingContext};
|
|||
use gfx::font_cache_task::FontCacheTask;
|
||||
use gfx::paint_task::{PaintChan, PaintLayer};
|
||||
use gfx::paint_task::Msg as PaintMsg;
|
||||
use layout_traits::{mod, LayoutControlMsg, LayoutTaskFactory};
|
||||
use layout_traits::{LayoutControlMsg, LayoutTaskFactory};
|
||||
use log;
|
||||
use script::dom::bindings::js::JS;
|
||||
use script::dom::node::{LayoutDataRef, Node, NodeTypeId};
|
||||
use script::dom::element::ElementTypeId;
|
||||
use script::dom::htmlelement::HTMLElementTypeId;
|
||||
use script::layout_interface::{ContentBoxResponse, ContentBoxesResponse};
|
||||
use script::layout_interface::{ContentBoxesQuery, ContentBoxQuery};
|
||||
use script::layout_interface::ReflowQueryType;
|
||||
use script::layout_interface::{HitTestResponse, LayoutChan, LayoutRPC};
|
||||
use script::layout_interface::{MouseOverResponse, Msg, NoQuery};
|
||||
use script::layout_interface::{MouseOverResponse, Msg};
|
||||
use script::layout_interface::{Reflow, ReflowGoal, ScriptLayoutChan, TrustedNodeAddress};
|
||||
use script_traits::{ConstellationControlMsg, ReflowEvent, OpaqueScriptLayoutChannel};
|
||||
use script_traits::{ConstellationControlMsg, CompositorEvent, OpaqueScriptLayoutChannel};
|
||||
use script_traits::{ScriptControlChan, UntrustedNodeAddress};
|
||||
use servo_msg::compositor_msg::Scrollable;
|
||||
use servo_msg::compositor_msg::ScrollPolicy;
|
||||
use servo_msg::constellation_msg::Msg as ConstellationMsg;
|
||||
use servo_msg::constellation_msg::{ConstellationChan, Failure, PipelineExitType};
|
||||
use servo_msg::constellation_msg::PipelineId;
|
||||
use servo_net::image_cache_task::{ImageCacheTask, ImageResponseMsg};
|
||||
use servo_net::local_image_cache::{ImageResponder, LocalImageCache};
|
||||
use servo_net::resource_task::{ResourceTask, load_bytes_iter};
|
||||
use servo_util::cursor::DefaultCursor;
|
||||
use servo_util::cursor::Cursor;
|
||||
use servo_util::geometry::Au;
|
||||
use servo_util::logical_geometry::LogicalPoint;
|
||||
use servo_util::opts;
|
||||
|
@ -66,7 +66,7 @@ use std::mem;
|
|||
use std::ptr;
|
||||
use style::{StylesheetOrigin, Stylesheet, Stylist, TNode, iter_font_face_rules};
|
||||
use style::{MediaType, Device};
|
||||
use sync::{Arc, Mutex, MutexGuard};
|
||||
use std::sync::{Arc, Mutex, MutexGuard};
|
||||
use url::Url;
|
||||
|
||||
/// Mutable data belonging to the LayoutTask.
|
||||
|
@ -161,7 +161,8 @@ impl ImageResponder<UntrustedNodeAddress> for LayoutImageResponder {
|
|||
debug!("Dirtying {:x}", node_address as uint);
|
||||
let mut nodes = SmallVec1::new();
|
||||
nodes.vec_push(node_address);
|
||||
drop(chan.send_opt(ConstellationControlMsg::SendEvent(id.clone(), ReflowEvent(nodes))))
|
||||
drop(chan.send_opt(ConstellationControlMsg::SendEvent(
|
||||
id.clone(), CompositorEvent::ReflowEvent(nodes))))
|
||||
};
|
||||
f
|
||||
}
|
||||
|
@ -346,7 +347,7 @@ impl LayoutTask {
|
|||
match port_to_read {
|
||||
PortToRead::Pipeline => {
|
||||
match self.pipeline_port.recv() {
|
||||
layout_traits::ExitNowMsg(exit_type) => {
|
||||
LayoutControlMsg::ExitNowMsg(exit_type) => {
|
||||
self.handle_script_request(Msg::ExitNow(exit_type), possibly_locked_rw_data)
|
||||
}
|
||||
}
|
||||
|
@ -690,7 +691,7 @@ impl LayoutTask {
|
|||
.add_to(&mut *display_list);
|
||||
let paint_layer = Arc::new(PaintLayer::new(layout_root.layer_id(0),
|
||||
color,
|
||||
Scrollable));
|
||||
ScrollPolicy::Scrollable));
|
||||
let origin = Rect(Point2D(Au(0), Au(0)), root_size);
|
||||
let stacking_context = Arc::new(StackingContext::new(display_list,
|
||||
&origin,
|
||||
|
@ -846,13 +847,13 @@ impl LayoutTask {
|
|||
}
|
||||
|
||||
match data.query_type {
|
||||
ContentBoxQuery(node) => {
|
||||
ReflowQueryType::ContentBoxQuery(node) => {
|
||||
self.process_content_box_request(node, &mut layout_root, &mut rw_data)
|
||||
}
|
||||
ContentBoxesQuery(node) => {
|
||||
ReflowQueryType::ContentBoxesQuery(node) => {
|
||||
self.process_content_boxes_request(node, &mut layout_root, &mut rw_data)
|
||||
}
|
||||
NoQuery => {}
|
||||
ReflowQueryType::NoQuery => {}
|
||||
}
|
||||
|
||||
self.first_reflow.set(false);
|
||||
|
@ -999,7 +1000,7 @@ impl LayoutRPC for LayoutRPCImpl {
|
|||
let cursor = if !mouse_over_list.is_empty() {
|
||||
mouse_over_list[0].cursor
|
||||
} else {
|
||||
DefaultCursor
|
||||
Cursor::DefaultCursor
|
||||
};
|
||||
let ConstellationChan(ref constellation_chan) = rw_data.constellation_chan;
|
||||
constellation_chan.send(ConstellationMsg::SetCursor(cursor));
|
||||
|
|
|
@ -33,7 +33,6 @@ extern crate string_cache;
|
|||
extern crate collections;
|
||||
extern crate encoding;
|
||||
extern crate libc;
|
||||
extern crate sync;
|
||||
extern crate url;
|
||||
|
||||
// Listed first because of macro definitions
|
||||
|
|
|
@ -21,7 +21,7 @@ use servo_util::geometry::Au;
|
|||
use servo_util::opts;
|
||||
use style::ComputedValues;
|
||||
use style::computed_values::list_style_type;
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// A block with the CSS `display` property equal to `list-item`.
|
||||
#[deriving(Show)]
|
||||
|
@ -131,12 +131,12 @@ pub fn static_text_for_list_style_type(list_style_type: list_style_type::T)
|
|||
// Just to keep things simple, use a nonbreaking space (Unicode 0xa0) to provide the marker
|
||||
// separation.
|
||||
match list_style_type {
|
||||
list_style_type::none => None,
|
||||
list_style_type::disc => Some("•\u00a0"),
|
||||
list_style_type::circle => Some("◦\u00a0"),
|
||||
list_style_type::square => Some("▪\u00a0"),
|
||||
list_style_type::disclosure_open => Some("▾\u00a0"),
|
||||
list_style_type::disclosure_closed => Some("‣\u00a0"),
|
||||
list_style_type::T::none => None,
|
||||
list_style_type::T::disc => Some("•\u{a0}"),
|
||||
list_style_type::T::circle => Some("◦\u{a0}"),
|
||||
list_style_type::T::square => Some("▪\u{a0}"),
|
||||
list_style_type::T::disclosure_open => Some("▾\u{a0}"),
|
||||
list_style_type::T::disclosure_closed => Some("‣\u{a0}"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ use std::cmp::{max, min};
|
|||
use std::fmt;
|
||||
|
||||
/// A collapsible margin. See CSS 2.1 § 8.3.1.
|
||||
#[deriving(Copy)]
|
||||
pub struct AdjoiningMargins {
|
||||
/// The value of the greatest positive margin.
|
||||
pub most_positive: Au,
|
||||
|
@ -60,6 +61,7 @@ impl AdjoiningMargins {
|
|||
}
|
||||
|
||||
/// Represents the block-start and block-end margins of a flow with collapsible margins. See CSS 2.1 § 8.3.1.
|
||||
#[deriving(Copy)]
|
||||
pub enum CollapsibleMargins {
|
||||
/// Margins may not collapse with this flow.
|
||||
None(Au, Au),
|
||||
|
@ -237,6 +239,7 @@ impl MarginCollapseInfo {
|
|||
}
|
||||
}
|
||||
|
||||
#[deriving(Copy)]
|
||||
pub enum MarginCollapseState {
|
||||
AccumulatingCollapsibleTopMargin,
|
||||
AccumulatingMarginIn,
|
||||
|
@ -322,7 +325,7 @@ impl IntrinsicISizesContribution {
|
|||
}
|
||||
|
||||
/// Useful helper data type when computing values for blocks and positioned elements.
|
||||
#[deriving(PartialEq, Show)]
|
||||
#[deriving(Copy, PartialEq, Show)]
|
||||
pub enum MaybeAuto {
|
||||
Auto,
|
||||
Specified(Au),
|
||||
|
|
|
@ -27,7 +27,7 @@ use std::cmp::max;
|
|||
use std::fmt;
|
||||
use style::{ComputedValues, CSSFloat};
|
||||
use style::computed_values::{LengthOrPercentageOrAuto, table_layout};
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// A table flow corresponded to the table's internal table fragment under a table wrapper flow.
|
||||
/// The properties `position`, `float`, and `margin-*` are used on the table wrapper fragment,
|
||||
|
@ -54,7 +54,7 @@ impl TableFlow {
|
|||
-> TableFlow {
|
||||
let mut block_flow = BlockFlow::from_node_and_fragment(node, fragment);
|
||||
let table_layout = if block_flow.fragment().style().get_table().table_layout ==
|
||||
table_layout::fixed {
|
||||
table_layout::T::fixed {
|
||||
TableLayout::Fixed
|
||||
} else {
|
||||
TableLayout::Auto
|
||||
|
@ -72,7 +72,7 @@ impl TableFlow {
|
|||
-> TableFlow {
|
||||
let mut block_flow = BlockFlow::from_node(constructor, node);
|
||||
let table_layout = if block_flow.fragment().style().get_table().table_layout ==
|
||||
table_layout::fixed {
|
||||
table_layout::T::fixed {
|
||||
TableLayout::Fixed
|
||||
} else {
|
||||
TableLayout::Auto
|
||||
|
@ -91,7 +91,7 @@ impl TableFlow {
|
|||
-> TableFlow {
|
||||
let mut block_flow = BlockFlow::float_from_node(constructor, node, float_kind);
|
||||
let table_layout = if block_flow.fragment().style().get_table().table_layout ==
|
||||
table_layout::fixed {
|
||||
table_layout::T::fixed {
|
||||
TableLayout::Fixed
|
||||
} else {
|
||||
TableLayout::Auto
|
||||
|
@ -441,7 +441,7 @@ impl ISizeAndMarginsComputer for InternalTable {
|
|||
/// maximum of 100 pixels and 20% of the table), the preceding constraint means that we must
|
||||
/// potentially store both a specified width *and* a specified percentage, so that the inline-size
|
||||
/// assignment phase of layout will know which one to pick.
|
||||
#[deriving(Clone, Encodable, Show)]
|
||||
#[deriving(Clone, Encodable, Show, Copy)]
|
||||
pub struct ColumnIntrinsicInlineSize {
|
||||
/// The preferred intrinsic inline size.
|
||||
pub preferred: Au,
|
||||
|
@ -485,7 +485,7 @@ impl ColumnIntrinsicInlineSize {
|
|||
///
|
||||
/// TODO(pcwalton): There will probably be some `border-collapse`-related info in here too
|
||||
/// eventually.
|
||||
#[deriving(Encodable)]
|
||||
#[deriving(Encodable, Copy)]
|
||||
pub struct ColumnComputedInlineSize {
|
||||
/// The computed size of this inline column.
|
||||
pub size: Au,
|
||||
|
|
|
@ -17,7 +17,7 @@ use geom::{Point2D, Rect};
|
|||
use servo_util::geometry::Au;
|
||||
use std::fmt;
|
||||
use style::ComputedValues;
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// A table formatting context.
|
||||
pub struct TableCaptionFlow {
|
||||
|
|
|
@ -19,7 +19,7 @@ use geom::{Point2D, Rect};
|
|||
use servo_util::geometry::Au;
|
||||
use std::fmt;
|
||||
use style::{UnsignedIntegerAttribute, ComputedValues};
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// A table formatting context.
|
||||
#[deriving(Encodable)]
|
||||
|
|
|
@ -19,7 +19,7 @@ use std::cmp::max;
|
|||
use std::fmt;
|
||||
use style::computed_values::LengthOrPercentageOrAuto;
|
||||
use style::ComputedValues;
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// A table formatting context.
|
||||
pub struct TableColGroupFlow {
|
||||
|
|
|
@ -24,7 +24,7 @@ use std::cmp::max;
|
|||
use std::fmt;
|
||||
use style::ComputedValues;
|
||||
use style::computed_values::LengthOrPercentageOrAuto;
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// A single row of a table.
|
||||
#[deriving(Encodable)]
|
||||
|
@ -39,7 +39,7 @@ pub struct TableRowFlow {
|
|||
}
|
||||
|
||||
/// Information about the column inline size and span for each cell.
|
||||
#[deriving(Encodable)]
|
||||
#[deriving(Encodable, Copy)]
|
||||
pub struct CellIntrinsicInlineSize {
|
||||
/// Inline sizes that this cell contributes to the column.
|
||||
pub column_size: ColumnIntrinsicInlineSize,
|
||||
|
|
|
@ -19,7 +19,7 @@ use geom::{Point2D, Rect};
|
|||
use servo_util::geometry::Au;
|
||||
use std::fmt;
|
||||
use style::ComputedValues;
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// A table formatting context.
|
||||
#[deriving(Encodable)]
|
||||
|
|
|
@ -29,9 +29,9 @@ use std::cmp::{max, min};
|
|||
use std::fmt;
|
||||
use style::{ComputedValues, CSSFloat};
|
||||
use style::computed_values::table_layout;
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[deriving(Encodable, Show)]
|
||||
#[deriving(Copy, Encodable, Show)]
|
||||
pub enum TableLayout {
|
||||
Fixed,
|
||||
Auto
|
||||
|
@ -55,7 +55,7 @@ impl TableWrapperFlow {
|
|||
-> TableWrapperFlow {
|
||||
let mut block_flow = BlockFlow::from_node_and_fragment(node, fragment);
|
||||
let table_layout = if block_flow.fragment().style().get_table().table_layout ==
|
||||
table_layout::fixed {
|
||||
table_layout::T::fixed {
|
||||
TableLayout::Fixed
|
||||
} else {
|
||||
TableLayout::Auto
|
||||
|
@ -72,7 +72,7 @@ impl TableWrapperFlow {
|
|||
-> TableWrapperFlow {
|
||||
let mut block_flow = BlockFlow::from_node(constructor, node);
|
||||
let table_layout = if block_flow.fragment().style().get_table().table_layout ==
|
||||
table_layout::fixed {
|
||||
table_layout::T::fixed {
|
||||
TableLayout::Fixed
|
||||
} else {
|
||||
TableLayout::Auto
|
||||
|
@ -90,7 +90,7 @@ impl TableWrapperFlow {
|
|||
-> TableWrapperFlow {
|
||||
let mut block_flow = BlockFlow::float_from_node_and_fragment(node, fragment, float_kind);
|
||||
let table_layout = if block_flow.fragment().style().get_table().table_layout ==
|
||||
table_layout::fixed {
|
||||
table_layout::T::fixed {
|
||||
TableLayout::Fixed
|
||||
} else {
|
||||
TableLayout::Auto
|
||||
|
@ -487,7 +487,7 @@ impl Add<AutoLayoutCandidateGuess,AutoLayoutCandidateGuess> for AutoLayoutCandid
|
|||
|
||||
/// The `CSSFloat` member specifies the weight of the smaller of the two guesses, on a scale from
|
||||
/// 0.0 to 1.0.
|
||||
#[deriving(PartialEq, Show)]
|
||||
#[deriving(Copy, PartialEq, Show)]
|
||||
enum SelectedAutoLayoutCandidateGuess {
|
||||
UseMinimumGuess,
|
||||
InterpolateBetweenMinimumGuessAndMinimumPercentageGuess(CSSFloat),
|
||||
|
|
|
@ -14,7 +14,7 @@ use gfx::font::{ShapingOptions};
|
|||
use gfx::font_context::FontContext;
|
||||
use gfx::text::glyph::CharIndex;
|
||||
use gfx::text::text_run::TextRun;
|
||||
use gfx::text::util::{mod, CompressWhitespaceNewline, CompressNone};
|
||||
use gfx::text::util::{mod, CompressionMode};
|
||||
use servo_util::dlist;
|
||||
use servo_util::geometry::Au;
|
||||
use servo_util::logical_geometry::{LogicalSize, WritingMode};
|
||||
|
@ -25,7 +25,7 @@ use std::mem;
|
|||
use style::ComputedValues;
|
||||
use style::computed_values::{line_height, text_orientation, text_transform, white_space};
|
||||
use style::style_structs::Font as FontStyle;
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// A stack-allocated object for scanning an inline flow into `TextRun`-containing `TextFragment`s.
|
||||
pub struct TextRunScanner {
|
||||
|
@ -114,8 +114,8 @@ impl TextRunScanner {
|
|||
let inherited_text_style = in_fragment.style().get_inheritedtext();
|
||||
fontgroup = font_context.get_layout_font_group_for_style(font_style);
|
||||
compression = match in_fragment.white_space() {
|
||||
white_space::normal | white_space::nowrap => CompressWhitespaceNewline,
|
||||
white_space::pre => CompressNone,
|
||||
white_space::T::normal | white_space::T::nowrap => CompressionMode::CompressWhitespaceNewline,
|
||||
white_space::T::pre => CompressionMode::CompressNone,
|
||||
};
|
||||
text_transform = inherited_text_style.text_transform;
|
||||
letter_spacing = inherited_text_style.letter_spacing;
|
||||
|
@ -213,22 +213,22 @@ impl TextRunScanner {
|
|||
string: &mut String,
|
||||
text_transform: text_transform::T) {
|
||||
match text_transform {
|
||||
text_transform::none => {}
|
||||
text_transform::uppercase => {
|
||||
text_transform::T::none => {}
|
||||
text_transform::T::uppercase => {
|
||||
let length = string.len();
|
||||
let original = mem::replace(string, String::with_capacity(length));
|
||||
for character in original.chars() {
|
||||
string.push(character.to_uppercase())
|
||||
}
|
||||
}
|
||||
text_transform::lowercase => {
|
||||
text_transform::T::lowercase => {
|
||||
let length = string.len();
|
||||
let original = mem::replace(string, String::with_capacity(length));
|
||||
for character in original.chars() {
|
||||
string.push(character.to_lowercase())
|
||||
}
|
||||
}
|
||||
text_transform::capitalize => {
|
||||
text_transform::T::capitalize => {
|
||||
let length = string.len();
|
||||
let original = mem::replace(string, String::with_capacity(length));
|
||||
let mut capitalize_next_letter = true;
|
||||
|
@ -266,9 +266,9 @@ fn bounding_box_for_run_metrics(metrics: &RunMetrics, writing_mode: WritingMode)
|
|||
// This will be a reminder to update the code below.
|
||||
let dummy: Option<text_orientation::T> = None;
|
||||
match dummy {
|
||||
Some(text_orientation::sideways_right) |
|
||||
Some(text_orientation::sideways_left) |
|
||||
Some(text_orientation::sideways) |
|
||||
Some(text_orientation::T::sideways_right) |
|
||||
Some(text_orientation::T::sideways_left) |
|
||||
Some(text_orientation::T::sideways) |
|
||||
None => {}
|
||||
}
|
||||
|
||||
|
@ -296,8 +296,8 @@ pub fn font_metrics_for_style(font_context: &mut FontContext, font_style: Arc<Fo
|
|||
pub fn line_height_from_style(style: &ComputedValues, metrics: &FontMetrics) -> Au {
|
||||
let font_size = style.get_font().font_size;
|
||||
match style.get_inheritedbox().line_height {
|
||||
line_height::Normal => metrics.line_gap,
|
||||
line_height::Number(l) => font_size.scale_by(l),
|
||||
line_height::Length(l) => l
|
||||
line_height::T::Normal => metrics.line_gap,
|
||||
line_height::T::Number(l) => font_size.scale_by(l),
|
||||
line_height::T::Length(l) => l
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,9 @@ use servo_util::opts;
|
|||
use servo_util::tid::tid;
|
||||
use style::TNode;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::mem;
|
||||
|
||||
/// Every time we do another layout, the old bloom filters are invalid. This is
|
||||
/// detected by ticking a generation number every layout.
|
||||
type Generation = uint;
|
||||
|
@ -45,7 +48,7 @@ type Generation = uint;
|
|||
/// Since a work-stealing queue is used for styling, sometimes, the bloom filter
|
||||
/// will no longer be the for the parent of the node we're currently on. When
|
||||
/// this happens, the task local bloom filter will be thrown away and rebuilt.
|
||||
local_data_key!(style_bloom: (Box<BloomFilter>, UnsafeLayoutNode, Generation))
|
||||
thread_local!(static STYLE_BLOOM: RefCell<Option<(Box<BloomFilter>, UnsafeLayoutNode, Generation)>> = RefCell::new(None))
|
||||
|
||||
/// Returns the task local bloom filter.
|
||||
///
|
||||
|
@ -53,7 +56,8 @@ local_data_key!(style_bloom: (Box<BloomFilter>, UnsafeLayoutNode, Generation))
|
|||
/// it will be thrown out and a new one will be made for you.
|
||||
fn take_task_local_bloom_filter(parent_node: Option<LayoutNode>, layout_context: &LayoutContext)
|
||||
-> Box<BloomFilter> {
|
||||
match (parent_node, style_bloom.replace(None)) {
|
||||
STYLE_BLOOM.with(|style_bloom| {
|
||||
match (parent_node, style_bloom.borrow_mut().take()) {
|
||||
// Root node. Needs new bloom filter.
|
||||
(None, _ ) => {
|
||||
debug!("[{}] No parent, but new bloom filter!", tid());
|
||||
|
@ -71,7 +75,7 @@ fn take_task_local_bloom_filter(parent_node: Option<LayoutNode>, layout_context:
|
|||
if old_node == layout_node_to_unsafe_layout_node(&parent) &&
|
||||
old_generation == layout_context.shared.generation {
|
||||
debug!("[{}] Parent matches (={}). Reusing bloom filter.", tid(), old_node.val0());
|
||||
bloom_filter
|
||||
bloom_filter.clone()
|
||||
} else {
|
||||
// Oh no. the cached parent is stale. I guess we need a new one. Reuse the existing
|
||||
// allocation to avoid malloc churn.
|
||||
|
@ -81,15 +85,19 @@ fn take_task_local_bloom_filter(parent_node: Option<LayoutNode>, layout_context:
|
|||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn put_task_local_bloom_filter(bf: Box<BloomFilter>,
|
||||
unsafe_node: &UnsafeLayoutNode,
|
||||
layout_context: &LayoutContext) {
|
||||
match style_bloom.replace(Some((bf, *unsafe_node, layout_context.shared.generation))) {
|
||||
None => {},
|
||||
Some(_) => panic!("Putting into a never-taken task-local bloom filter"),
|
||||
}
|
||||
let bf: *mut BloomFilter = unsafe { mem::transmute(bf) };
|
||||
STYLE_BLOOM.with(|style_bloom| {
|
||||
assert!(style_bloom.borrow().is_none(),
|
||||
"Putting into a never-taken task-local bloom filter");
|
||||
let bf: Box<BloomFilter> = unsafe { mem::transmute(bf) };
|
||||
*style_bloom.borrow_mut() = Some((bf, *unsafe_node, layout_context.shared.generation));
|
||||
})
|
||||
}
|
||||
|
||||
/// "Ancestors" in this context is inclusive of ourselves.
|
||||
|
@ -112,6 +120,7 @@ fn insert_ancestors_into_bloom_filter(bf: &mut Box<BloomFilter>,
|
|||
|
||||
/// The recalc-style-for-node traversal, which styles each node and must run before
|
||||
/// layout computation. This computes the styles applied to each node.
|
||||
#[deriving(Copy)]
|
||||
pub struct RecalcStyleForNode<'a> {
|
||||
pub layout_context: &'a LayoutContext<'a>,
|
||||
}
|
||||
|
@ -200,6 +209,7 @@ impl<'a> PreorderDomTraversal for RecalcStyleForNode<'a> {
|
|||
}
|
||||
|
||||
/// The flow construction traversal, which builds flows for styled nodes.
|
||||
#[deriving(Copy)]
|
||||
pub struct ConstructFlows<'a> {
|
||||
pub layout_context: &'a LayoutContext<'a>,
|
||||
}
|
||||
|
@ -238,9 +248,10 @@ impl<'a> PostorderDomTraversal for ConstructFlows<'a> {
|
|||
let unsafe_layout_node = layout_node_to_unsafe_layout_node(&node);
|
||||
|
||||
let (mut bf, old_node, old_generation) =
|
||||
style_bloom
|
||||
.replace(None)
|
||||
.expect("The bloom filter should have been set by style recalc.");
|
||||
STYLE_BLOOM.with(|style_bloom| {
|
||||
mem::replace(&mut *style_bloom.borrow_mut(), None)
|
||||
.expect("The bloom filter should have been set by style recalc.")
|
||||
});
|
||||
|
||||
assert_eq!(old_node, unsafe_layout_node);
|
||||
assert_eq!(old_generation, self.layout_context.shared.generation);
|
||||
|
@ -297,6 +308,7 @@ impl<'a> PostorderFlowTraversal for BubbleISizes<'a> {
|
|||
}
|
||||
|
||||
/// The assign-inline-sizes traversal. In Gecko this corresponds to `Reflow`.
|
||||
#[deriving(Copy)]
|
||||
pub struct AssignISizes<'a> {
|
||||
pub layout_context: &'a LayoutContext<'a>,
|
||||
}
|
||||
|
@ -317,6 +329,7 @@ impl<'a> PreorderFlowTraversal for AssignISizes<'a> {
|
|||
/// layout computation. Determines the final block-sizes for all layout objects, computes
|
||||
/// positions, and computes overflow regions. In Gecko this corresponds to `Reflow` and
|
||||
/// `FinishAndStoreOverflow`.
|
||||
#[deriving(Copy)]
|
||||
pub struct AssignBSizesAndStoreOverflow<'a> {
|
||||
pub layout_context: &'a LayoutContext<'a>,
|
||||
}
|
||||
|
@ -341,6 +354,7 @@ impl<'a> PostorderFlowTraversal for AssignBSizesAndStoreOverflow<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[deriving(Copy)]
|
||||
pub struct ComputeAbsolutePositions<'a> {
|
||||
pub layout_context: &'a LayoutContext<'a>,
|
||||
}
|
||||
|
@ -352,6 +366,7 @@ impl<'a> PreorderFlowTraversal for ComputeAbsolutePositions<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[deriving(Copy)]
|
||||
pub struct BuildDisplayList<'a> {
|
||||
pub layout_context: &'a LayoutContext<'a>,
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ use std::mem;
|
|||
use std::cell::{Ref, RefMut};
|
||||
use style::ComputedValues;
|
||||
use style;
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Data that layout associates with a node.
|
||||
pub struct PrivateLayoutData {
|
||||
|
@ -64,6 +64,7 @@ impl PrivateLayoutData {
|
|||
}
|
||||
|
||||
bitflags! {
|
||||
#[deriving(Copy)]
|
||||
flags LayoutDataFlags: u8 {
|
||||
#[doc="Whether a flow has been newly constructed."]
|
||||
const HAS_NEWLY_CONSTRUCTED_FLOW = 0x01
|
||||
|
|
|
@ -137,6 +137,7 @@ pub trait TLayoutNode {
|
|||
|
||||
/// A wrapper so that layout can access only the methods that it should have access to. Layout must
|
||||
/// only ever see these and must never see instances of `JS`.
|
||||
#[deriving(Copy)]
|
||||
pub struct LayoutNode<'a> {
|
||||
/// The wrapped node.
|
||||
node: JS<Node>,
|
||||
|
@ -476,6 +477,7 @@ impl<'a> Iterator<LayoutNode<'a>> for LayoutTreeIterator<'a> {
|
|||
}
|
||||
|
||||
/// A wrapper around elements that ensures layout can only ever access safe properties.
|
||||
#[deriving(Copy)]
|
||||
pub struct LayoutElement<'le> {
|
||||
element: &'le Element,
|
||||
}
|
||||
|
@ -631,10 +633,10 @@ impl<'le> TElementAttributes for LayoutElement<'le> {
|
|||
|
||||
fn get_content(content_list: &content::T) -> String {
|
||||
match *content_list {
|
||||
content::Content(ref value) => {
|
||||
content::T::Content(ref value) => {
|
||||
let iter = &mut value.clone().into_iter().peekable();
|
||||
match iter.next() {
|
||||
Some(content::StringContent(content)) => content,
|
||||
Some(content::ContentItem::StringContent(content)) => content,
|
||||
_ => "".into_string(),
|
||||
}
|
||||
}
|
||||
|
@ -642,7 +644,7 @@ fn get_content(content_list: &content::T) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
#[deriving(PartialEq, Clone)]
|
||||
#[deriving(Copy, PartialEq, Clone)]
|
||||
pub enum PseudoElementType {
|
||||
Normal,
|
||||
Before(display::T),
|
||||
|
@ -667,7 +669,7 @@ impl PseudoElementType {
|
|||
|
||||
/// A thread-safe version of `LayoutNode`, used during flow construction. This type of layout
|
||||
/// node does not allow any parents or siblings of nodes to be accessed, to avoid races.
|
||||
#[deriving(Clone)]
|
||||
#[deriving(Copy, Clone)]
|
||||
pub struct ThreadSafeLayoutNode<'ln> {
|
||||
/// The wrapped node.
|
||||
node: LayoutNode<'ln>,
|
||||
|
@ -716,9 +718,9 @@ impl<'ln> TLayoutNode for ThreadSafeLayoutNode<'ln> {
|
|||
let pseudo_before_node = self.with_pseudo(PseudoElementType::Before(self.get_before_display()));
|
||||
return Some(pseudo_before_node)
|
||||
}
|
||||
PseudoElementType::Before(display::inline) => {}
|
||||
PseudoElementType::Before(display::T::inline) => {}
|
||||
PseudoElementType::Before(_) => {
|
||||
let pseudo_before_node = self.with_pseudo(PseudoElementType::Before(display::inline));
|
||||
let pseudo_before_node = self.with_pseudo(PseudoElementType::Before(display::T::inline));
|
||||
return Some(pseudo_before_node)
|
||||
}
|
||||
_ => {}
|
||||
|
@ -922,7 +924,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
|
|||
// If you implement other values for this property, you will almost certainly
|
||||
// want to update this check.
|
||||
match self.style().get_inheritedtext().white_space {
|
||||
white_space::normal => true,
|
||||
white_space::T::normal => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,13 +14,13 @@ use std::fmt;
|
|||
use constellation_msg::PipelineId;
|
||||
|
||||
/// The status of the painter.
|
||||
#[deriving(PartialEq, Clone)]
|
||||
#[deriving(PartialEq, Eq, Clone, Copy)]
|
||||
pub enum PaintState {
|
||||
Idle,
|
||||
Painting,
|
||||
}
|
||||
|
||||
#[deriving(Eq, Ord, PartialEq, PartialOrd, Clone, Show)]
|
||||
#[deriving(Eq, Ord, PartialEq, PartialOrd, Clone, Show, Copy)]
|
||||
pub enum ReadyState {
|
||||
/// Informs the compositor that nothing has been done yet. Used for setting status
|
||||
Blank,
|
||||
|
@ -33,7 +33,7 @@ pub enum ReadyState {
|
|||
}
|
||||
|
||||
/// A newtype struct for denoting the age of messages; prevents race conditions.
|
||||
#[deriving(PartialEq, Show)]
|
||||
#[deriving(PartialEq, Eq, Show, Copy)]
|
||||
pub struct Epoch(pub uint);
|
||||
|
||||
impl Epoch {
|
||||
|
@ -43,7 +43,7 @@ impl Epoch {
|
|||
}
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq)]
|
||||
#[deriving(Clone, PartialEq, Eq, Copy)]
|
||||
pub struct LayerId(pub uint, pub uint);
|
||||
|
||||
impl Show for LayerId {
|
||||
|
@ -61,7 +61,7 @@ impl LayerId {
|
|||
}
|
||||
|
||||
/// The scrolling policy of a layer.
|
||||
#[deriving(Clone, PartialEq)]
|
||||
#[deriving(Clone, PartialEq, Eq, Copy)]
|
||||
pub enum ScrollPolicy {
|
||||
/// These layers scroll when the parent receives a scrolling message.
|
||||
Scrollable,
|
||||
|
@ -71,6 +71,7 @@ pub enum ScrollPolicy {
|
|||
|
||||
/// All layer-specific information that the painting task sends to the compositor other than the
|
||||
/// buffer contents of the layer itself.
|
||||
#[deriving(Copy)]
|
||||
pub struct LayerMetadata {
|
||||
/// An opaque ID. This is usually the address of the flow and index of the box within it.
|
||||
pub id: LayerId,
|
||||
|
|
|
@ -26,19 +26,20 @@ impl ConstellationChan {
|
|||
}
|
||||
}
|
||||
|
||||
#[deriving(PartialEq)]
|
||||
#[deriving(PartialEq, Eq, Copy)]
|
||||
pub enum IFrameSandboxState {
|
||||
IFrameSandboxed,
|
||||
IFrameUnsandboxed
|
||||
}
|
||||
|
||||
// We pass this info to various tasks, so it lives in a separate, cloneable struct.
|
||||
#[deriving(Clone)]
|
||||
#[deriving(Clone, Copy)]
|
||||
pub struct Failure {
|
||||
pub pipeline_id: PipelineId,
|
||||
pub subpage_id: Option<SubpageId>,
|
||||
}
|
||||
|
||||
#[deriving(Copy)]
|
||||
pub struct WindowSizeData {
|
||||
/// The size of the initial layout viewport, before parsing an
|
||||
/// http://www.w3.org/TR/css-device-adapt/#initial-viewport
|
||||
|
@ -51,7 +52,7 @@ pub struct WindowSizeData {
|
|||
pub device_pixel_ratio: ScaleFactor<ViewportPx, DevicePixel, f32>,
|
||||
}
|
||||
|
||||
#[deriving(PartialEq)]
|
||||
#[deriving(PartialEq, Eq, Copy, Clone)]
|
||||
pub enum KeyState {
|
||||
Pressed,
|
||||
Released,
|
||||
|
@ -59,7 +60,7 @@ pub enum KeyState {
|
|||
}
|
||||
|
||||
//N.B. Straight up copied from glfw-rs
|
||||
#[deriving(Show)]
|
||||
#[deriving(Show, PartialEq, Eq, Copy, Clone)]
|
||||
pub enum Key {
|
||||
Space,
|
||||
Apostrophe,
|
||||
|
@ -185,6 +186,7 @@ pub enum Key {
|
|||
}
|
||||
|
||||
bitflags! {
|
||||
#[deriving(Copy)]
|
||||
flags KeyModifiers: u8 {
|
||||
const SHIFT = 0x01,
|
||||
const CONTROL = 0x02,
|
||||
|
@ -236,26 +238,27 @@ impl LoadData {
|
|||
}
|
||||
|
||||
/// Represents the two different ways to which a page can be navigated
|
||||
#[deriving(Clone, PartialEq, Hash, Show)]
|
||||
#[deriving(Clone, PartialEq, Eq, Copy, Hash, Show)]
|
||||
pub enum NavigationType {
|
||||
Load, // entered or clicked on a url
|
||||
Navigate, // browser forward/back buttons
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, Hash, Show)]
|
||||
#[deriving(Clone, PartialEq, Eq, Copy, Hash, Show)]
|
||||
pub enum NavigationDirection {
|
||||
Forward,
|
||||
Back,
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, Eq, Hash, Show)]
|
||||
#[deriving(Clone, PartialEq, Eq, Copy, Hash, Show)]
|
||||
pub struct PipelineId(pub uint);
|
||||
|
||||
#[deriving(Clone, PartialEq, Eq, Hash, Show)]
|
||||
#[deriving(Clone, PartialEq, Eq, Copy, Hash, Show)]
|
||||
pub struct SubpageId(pub uint);
|
||||
|
||||
// The type of pipeline exit. During complete shutdowns, pipelines do not have to
|
||||
// release resources automatically released on process termination.
|
||||
#[deriving(Copy)]
|
||||
pub enum PipelineExitType {
|
||||
PipelineOnly,
|
||||
Complete,
|
||||
|
|
|
@ -11,7 +11,6 @@ use hyper::http::RawStatus;
|
|||
use servo_util::resource_files::resources_dir_path;
|
||||
|
||||
use std::io::fs::PathExtensions;
|
||||
use std::str::Slice;
|
||||
|
||||
pub fn factory(mut load_data: LoadData, start_chan: Sender<TargetedLoadResponse>) {
|
||||
let senders = ResponseSenders {
|
||||
|
@ -25,7 +24,7 @@ pub fn factory(mut load_data: LoadData, start_chan: Sender<TargetedLoadResponse>
|
|||
content_type: Some(("text".to_string(), "html".to_string())),
|
||||
charset: Some("utf-8".to_string()),
|
||||
headers: None,
|
||||
status: Some(RawStatus(200, Slice("OK")))
|
||||
status: Some(RawStatus(200, "OK".into_string()))
|
||||
});
|
||||
chan.send(Done(Ok(())));
|
||||
return
|
||||
|
|
|
@ -11,6 +11,7 @@ use fetch::cors_cache::CORSCache;
|
|||
use fetch::response::Response;
|
||||
|
||||
/// A [request context](http://fetch.spec.whatwg.org/#concept-request-context)
|
||||
#[deriving(Copy)]
|
||||
pub enum Context {
|
||||
Audio, Beacon, CSPreport, Download, Embed, Eventsource,
|
||||
Favicon, Fetch, Font, Form, Frame, Hyperlink, IFrame, Image,
|
||||
|
@ -20,6 +21,7 @@ pub enum Context {
|
|||
}
|
||||
|
||||
/// A [request context frame type](http://fetch.spec.whatwg.org/#concept-request-context-frame-type)
|
||||
#[deriving(Copy)]
|
||||
pub enum ContextFrameType {
|
||||
Auxiliary,
|
||||
TopLevel,
|
||||
|
@ -35,6 +37,7 @@ pub enum Referer {
|
|||
}
|
||||
|
||||
/// A [request mode](http://fetch.spec.whatwg.org/#concept-request-mode)
|
||||
#[deriving(Copy)]
|
||||
pub enum RequestMode {
|
||||
SameOrigin,
|
||||
NoCORS,
|
||||
|
@ -43,6 +46,7 @@ pub enum RequestMode {
|
|||
}
|
||||
|
||||
/// Request [credentials mode](http://fetch.spec.whatwg.org/#concept-request-credentials-mode)
|
||||
#[deriving(Copy)]
|
||||
pub enum CredentialsMode {
|
||||
Omit,
|
||||
CredentialsSameOrigin,
|
||||
|
@ -50,6 +54,7 @@ pub enum CredentialsMode {
|
|||
}
|
||||
|
||||
/// [Response tainting](http://fetch.spec.whatwg.org/#concept-request-response-tainting)
|
||||
#[deriving(Copy)]
|
||||
pub enum ResponseTainting {
|
||||
Basic,
|
||||
CORSTainting,
|
||||
|
|
|
@ -9,7 +9,7 @@ use std::ascii::AsciiExt;
|
|||
use std::comm::Receiver;
|
||||
|
||||
/// [Response type](http://fetch.spec.whatwg.org/#concept-response-type)
|
||||
#[deriving(Clone, PartialEq)]
|
||||
#[deriving(Clone, PartialEq, Copy)]
|
||||
pub enum ResponseType {
|
||||
Basic,
|
||||
CORS,
|
||||
|
@ -19,7 +19,7 @@ pub enum ResponseType {
|
|||
}
|
||||
|
||||
/// [Response termination reason](http://fetch.spec.whatwg.org/#concept-response-termination-reason)
|
||||
#[deriving(Clone)]
|
||||
#[deriving(Clone, Copy)]
|
||||
pub enum TerminationReason {
|
||||
EndUserAbort,
|
||||
Fatal,
|
||||
|
|
|
@ -85,7 +85,7 @@ fn load(load_data: LoadData, start_chan: Sender<TargetedLoadResponse>) {
|
|||
// FIXME(seanmonstar): use AcceptEncoding from Hyper once available
|
||||
//if !req.headers.has::<AcceptEncoding>() {
|
||||
// We currently don't support HTTP Compression (FIXME #2587)
|
||||
req.headers_mut().set_raw("Accept-Encoding", vec![b"identity".to_vec()]);
|
||||
req.headers_mut().set_raw("Accept-Encoding".into_string(), vec![b"identity".to_vec()]);
|
||||
//}
|
||||
let writer = match load_data.data {
|
||||
Some(ref data) => {
|
||||
|
|
|
@ -7,7 +7,7 @@ use image_cache_task::ImageResponseMsg;
|
|||
use local_image_cache::LocalImageCache;
|
||||
|
||||
use geom::size::Size2D;
|
||||
use sync::{Arc, Mutex};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use url::Url;
|
||||
|
||||
// FIXME: Nasty coupling here This will be a problem if we want to factor out image handling from
|
||||
|
|
|
@ -13,7 +13,7 @@ use std::comm::{channel, Receiver, Sender};
|
|||
use std::collections::HashMap;
|
||||
use std::collections::hash_map::{Occupied, Vacant};
|
||||
use std::mem::replace;
|
||||
use sync::{Arc, Mutex};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use serialize::{Encoder, Encodable};
|
||||
use url::Url;
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ extern crate log;
|
|||
extern crate serialize;
|
||||
extern crate "util" as servo_util;
|
||||
extern crate stb_image;
|
||||
extern crate sync;
|
||||
extern crate time;
|
||||
extern crate url;
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ use hyper::mime::{Mime, Attr};
|
|||
use url::Url;
|
||||
|
||||
use std::comm::{channel, Receiver, Sender};
|
||||
use std::str::Slice;
|
||||
|
||||
pub enum ControlMsg {
|
||||
/// Request the data associated with a particular URL
|
||||
|
@ -86,7 +85,8 @@ impl Metadata {
|
|||
content_type: None,
|
||||
charset: None,
|
||||
headers: None,
|
||||
status: Some(RawStatus(200, Slice("OK"))) // http://fetch.spec.whatwg.org/#concept-response-status-message
|
||||
// http://fetch.spec.whatwg.org/#concept-response-status-message
|
||||
status: Some(RawStatus(200, "OK".into_string()))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
extern crate syntax;
|
||||
#[phase(plugin, link)]
|
||||
extern crate rustc;
|
||||
#[cfg(test)]
|
||||
extern crate sync;
|
||||
|
||||
use rustc::lint::LintPassObject;
|
||||
use rustc::plugin::Registry;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
use syntax::{ast, ast_util};
|
||||
use rustc::lint::{Context, LintPass, LintArray, Level};
|
||||
use rustc::middle::{ty, def};
|
||||
use rustc::middle::typeck::astconv::AstConv;
|
||||
|
||||
use utils::match_lang_ty;
|
||||
|
||||
|
@ -42,7 +41,7 @@ impl LintPass for InheritancePass {
|
|||
.map(|(_, f)| f.span);
|
||||
// Find all #[dom_struct] fields
|
||||
let dom_spans: Vec<_> = def.fields.iter().enumerate().filter_map(|(ctr, f)| {
|
||||
if let ast::TyPath(_, _, ty_id) = f.node.ty.node {
|
||||
if let ast::TyPath(_, ty_id) = f.node.ty.node {
|
||||
if let Some(def::DefTy(def_id, _)) = cx.tcx.def_map.borrow().get(&ty_id).cloned() {
|
||||
if ty::has_attr(cx.tcx, def_id, "_dom_struct_marker") {
|
||||
// If the field is not the first, it's probably
|
||||
|
|
|
@ -7,7 +7,6 @@ use syntax::ast::Public;
|
|||
use syntax::attr::AttrMetaMethods;
|
||||
use rustc::lint::{Context, LintPass, LintArray};
|
||||
use rustc::middle::ty;
|
||||
use rustc::middle::typeck::astconv::AstConv;
|
||||
|
||||
declare_lint!(PRIVATIZE, Deny,
|
||||
"Allows to enforce private fields for struct definitions")
|
||||
|
|
|
@ -6,7 +6,6 @@ use syntax::ast;
|
|||
use rustc::lint::{Context, LintPass, LintArray};
|
||||
use rustc::middle::ty::expr_ty;
|
||||
use rustc::middle::ty;
|
||||
use rustc::middle::typeck::astconv::AstConv;
|
||||
|
||||
declare_lint!(STR_TO_STRING, Deny,
|
||||
"Warn when a String could use into_string() instead of to_string()")
|
||||
|
@ -33,13 +32,13 @@ impl LintPass for StrToStringPass {
|
|||
}
|
||||
|
||||
fn is_str(cx: &Context, expr: &ast::Expr) -> bool {
|
||||
fn walk_ty<'t>(ty: ty::t) -> ty::t {
|
||||
match ty::get(ty).sty {
|
||||
fn walk_ty<'t>(ty: ty::Ty<'t>) -> ty::Ty<'t> {
|
||||
match ty.sty {
|
||||
ty::ty_ptr(ref tm) | ty::ty_rptr(_, ref tm) => walk_ty(tm.ty),
|
||||
_ => ty
|
||||
}
|
||||
}
|
||||
match ty::get(walk_ty(expr_ty(cx.tcx, expr))).sty {
|
||||
match walk_ty(expr_ty(cx.tcx, expr)).sty {
|
||||
ty::ty_str => true,
|
||||
_ => false
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ use syntax::ast;
|
|||
use syntax::attr::AttrMetaMethods;
|
||||
use rustc::lint::{Context, LintPass, LintArray};
|
||||
use rustc::middle::ty::expr_ty;
|
||||
use rustc::middle::typeck::astconv::AstConv;
|
||||
use rustc::util::ppaux::Repr;
|
||||
|
||||
declare_lint!(TRANSMUTE_TYPE_LINT, Allow,
|
||||
|
@ -31,7 +30,7 @@ impl LintPass for TransmutePass {
|
|||
if path.segments.last()
|
||||
.map_or(false, |ref segment| segment.identifier.name.as_str() == "transmute")
|
||||
&& args.len() == 1 {
|
||||
let tcx = cx.tcx();
|
||||
let tcx = cx.tcx;
|
||||
cx.span_lint(TRANSMUTE_TYPE_LINT, ex.span,
|
||||
format!("Transmute to {} from {} detected",
|
||||
expr_ty(tcx, ex).repr(tcx),
|
||||
|
|
|
@ -7,7 +7,6 @@ use syntax::attr::AttrMetaMethods;
|
|||
use rustc::lint::{Context, LintPass, LintArray};
|
||||
use rustc::middle::ty::expr_ty;
|
||||
use rustc::middle::{ty, def};
|
||||
use rustc::middle::typeck::astconv::AstConv;
|
||||
use rustc::util::ppaux::Repr;
|
||||
use utils::unsafe_context;
|
||||
|
||||
|
@ -24,6 +23,7 @@ declare_lint!(UNROOTED_MUST_ROOT, Deny,
|
|||
/// - Not being bound locally in a `let` statement, assignment, `for` loop, or `match` statement.
|
||||
///
|
||||
/// This helps catch most situations where pointers like `JS<T>` are used in a way that they can be invalidated by a GC pass.
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub struct UnrootedPass;
|
||||
|
||||
// Checks if a type has the #[must_root] annotation.
|
||||
|
@ -33,7 +33,7 @@ fn lint_unrooted_ty(cx: &Context, ty: &ast::Ty, warning: &str) {
|
|||
match ty.node {
|
||||
ast::TyVec(ref t) | ast::TyFixedLengthVec(ref t, _) |
|
||||
ast::TyPtr(ast::MutTy { ty: ref t, ..}) | ast::TyRptr(_, ast::MutTy { ty: ref t, ..}) => lint_unrooted_ty(cx, &**t, warning),
|
||||
ast::TyPath(_, _, id) => {
|
||||
ast::TyPath(_, id) => {
|
||||
match cx.tcx.def_map.borrow()[id].clone() {
|
||||
def::DefTy(def_id, _) => {
|
||||
if ty::has_attr(cx.tcx, def_id, "must_root") {
|
||||
|
@ -146,7 +146,7 @@ impl LintPass for UnrootedPass {
|
|||
};
|
||||
|
||||
let t = expr_ty(cx.tcx, &*expr);
|
||||
match ty::get(t).sty {
|
||||
match t.sty {
|
||||
ty::ty_struct(did, _) |
|
||||
ty::ty_enum(did, _) => {
|
||||
if ty::has_attr(cx.tcx, did, "must_root") {
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
use rustc::lint::Context;
|
||||
use rustc::middle::{ty, def};
|
||||
use rustc::middle::typeck::astconv::AstConv;
|
||||
|
||||
use syntax::ptr::P;
|
||||
use syntax::{ast, ast_map};
|
||||
|
@ -17,7 +16,7 @@ use syntax::attr::mark_used;
|
|||
/// Try not to use this for types defined in crates you own, use match_lang_ty instead (for lint passes)
|
||||
pub fn match_ty_unwrap<'a>(ty: &'a Ty, segments: &[&str]) -> Option<&'a [P<Ty>]> {
|
||||
match ty.node {
|
||||
TyPath(Path {segments: ref seg, ..}, _, _) => {
|
||||
TyPath(Path {segments: ref seg, ..}, _) => {
|
||||
// So ast::Path isn't the full path, just the tokens that were provided.
|
||||
// I could muck around with the maps and find the full path
|
||||
// however the more efficient way is to simply reverse the iterators and zip them
|
||||
|
@ -40,7 +39,7 @@ pub fn match_ty_unwrap<'a>(ty: &'a Ty, segments: &[&str]) -> Option<&'a [P<Ty>]>
|
|||
/// Checks if a type has a #[servo_lang = "str"] attribute
|
||||
pub fn match_lang_ty(cx: &Context, ty: &Ty, value: &str) -> bool {
|
||||
let mut found = false;
|
||||
if let TyPath(_, _, ty_id) = ty.node {
|
||||
if let TyPath(_, ty_id) = ty.node {
|
||||
if let Some(def::DefTy(def_id, _)) = cx.tcx.def_map.borrow().get(&ty_id).cloned() {
|
||||
// Iterating through attributes is hard because of cross-crate defs
|
||||
ty::each_attr(cx.tcx, def_id, |attr| {
|
||||
|
|
|
@ -48,9 +48,6 @@ git = "https://github.com/servo/rust-geom"
|
|||
[dependencies.html5ever]
|
||||
git = "https://github.com/servo/html5ever"
|
||||
|
||||
[dependencies.encoding]
|
||||
git = "https://github.com/lifthrasiir/rust-encoding"
|
||||
|
||||
[dependencies.hyper]
|
||||
git = "https://github.com/servo/hyper"
|
||||
branch = "servo"
|
||||
|
@ -72,3 +69,6 @@ git = "https://github.com/servo/string-cache"
|
|||
|
||||
[dependencies.time]
|
||||
git = "https://github.com/rust-lang/time"
|
||||
|
||||
[dependencies]
|
||||
encoding = "0.2"
|
||||
|
|
|
@ -40,7 +40,7 @@ pub struct CORSRequest {
|
|||
/// http://fetch.spec.whatwg.org/#concept-request-mode
|
||||
/// This only covers some of the request modes. The
|
||||
/// `same-origin` and `no CORS` modes are unnecessary for XHR.
|
||||
#[deriving(PartialEq, Clone)]
|
||||
#[deriving(PartialEq, Copy, Clone)]
|
||||
pub enum RequestMode {
|
||||
CORS, // CORS
|
||||
ForcedPreflight // CORS-with-forced-preflight
|
||||
|
|
|
@ -16,6 +16,7 @@ use js::jsval::{JSVal, UndefinedValue};
|
|||
use std::ptr;
|
||||
|
||||
/// The exception handling used for a call.
|
||||
#[deriving(Copy)]
|
||||
pub enum ExceptionHandling {
|
||||
/// Report any exception and don't throw it to the caller code.
|
||||
ReportExceptions,
|
||||
|
@ -28,7 +29,7 @@ pub enum ExceptionHandling {
|
|||
}
|
||||
|
||||
/// A common base class for representing IDL callback function types.
|
||||
#[deriving(Clone,PartialEq)]
|
||||
#[deriving(Copy, Clone,PartialEq)]
|
||||
#[jstraceable]
|
||||
pub struct CallbackFunction {
|
||||
object: CallbackObject
|
||||
|
@ -46,7 +47,7 @@ impl CallbackFunction {
|
|||
}
|
||||
|
||||
/// A common base class for representing IDL callback interface types.
|
||||
#[deriving(Clone,PartialEq)]
|
||||
#[deriving(Copy, Clone,PartialEq)]
|
||||
#[jstraceable]
|
||||
pub struct CallbackInterface {
|
||||
object: CallbackObject
|
||||
|
@ -55,7 +56,7 @@ pub struct CallbackInterface {
|
|||
/// A common base class for representing IDL callback function and
|
||||
/// callback interface types.
|
||||
#[allow(raw_pointer_deriving)]
|
||||
#[deriving(Clone,PartialEq)]
|
||||
#[deriving(Copy, Clone,PartialEq)]
|
||||
#[jstraceable]
|
||||
struct CallbackObject {
|
||||
/// The underlying `JSObject`.
|
||||
|
|
|
@ -2763,7 +2763,7 @@ class CGEnum(CGThing):
|
|||
|
||||
decl = """\
|
||||
#[repr(uint)]
|
||||
#[deriving(PartialEq)]
|
||||
#[deriving(PartialEq, Copy)]
|
||||
#[jstraceable]
|
||||
pub enum %s {
|
||||
%s
|
||||
|
@ -4693,7 +4693,7 @@ class CGCallback(CGClass):
|
|||
bases=[ClassBase(baseName)],
|
||||
constructors=self.getConstructors(),
|
||||
methods=realMethods+getters+setters,
|
||||
decorators="#[deriving(PartialEq,Clone)]#[jstraceable]")
|
||||
decorators="#[deriving(PartialEq,Copy,Clone)]#[jstraceable]")
|
||||
|
||||
def getConstructors(self):
|
||||
return [ClassConstructor(
|
||||
|
@ -5189,8 +5189,8 @@ class GlobalGenRoots():
|
|||
return CGList([
|
||||
CGGeneric(AUTOGENERATED_WARNING_COMMENT),
|
||||
CGGeneric("pub const MAX_PROTO_CHAIN_LENGTH: uint = %d;\n\n" % config.maxProtoChainLength),
|
||||
CGNonNamespacedEnum('ID', protos, [0], deriving="PartialEq"),
|
||||
CGNonNamespacedEnum('Proxies', proxies, [0], deriving="PartialEq"),
|
||||
CGNonNamespacedEnum('ID', protos, [0], deriving="PartialEq, Copy"),
|
||||
CGNonNamespacedEnum('Proxies', proxies, [0], deriving="PartialEq, Copy"),
|
||||
])
|
||||
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ use url::Url;
|
|||
use std::ptr;
|
||||
|
||||
/// A freely-copyable reference to a rooted global object.
|
||||
#[deriving(Copy)]
|
||||
pub enum GlobalRef<'a> {
|
||||
Window(JSRef<'a, window::Window>),
|
||||
Worker(JSRef<'a, WorkerGlobalScope>),
|
||||
|
|
|
@ -70,6 +70,15 @@ pub struct Temporary<T> {
|
|||
_js_ptr: *mut JSObject,
|
||||
}
|
||||
|
||||
impl<T> Clone for Temporary<T> {
|
||||
fn clone(&self) -> Temporary<T> {
|
||||
Temporary {
|
||||
inner: self.inner,
|
||||
_js_ptr: self._js_ptr,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> PartialEq for Temporary<T> {
|
||||
fn eq(&self, other: &Temporary<T>) -> bool {
|
||||
self.inner == other.inner
|
||||
|
@ -92,10 +101,12 @@ impl<T: Reflectable> Temporary<T> {
|
|||
|
||||
/// Create a stack-bounded root for this value.
|
||||
pub fn root(self) -> Root<T> {
|
||||
let collection = StackRoots.get().unwrap();
|
||||
StackRoots.with(|ref collection| {
|
||||
let RootCollectionPtr(collection) = collection.get().unwrap();
|
||||
unsafe {
|
||||
Root::new(&**collection, &self.inner)
|
||||
Root::new(&*collection, &self.inner)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
unsafe fn inner(&self) -> JS<T> {
|
||||
|
@ -114,6 +125,8 @@ pub struct JS<T> {
|
|||
ptr: *const T
|
||||
}
|
||||
|
||||
impl<T> Copy for JS<T> {}
|
||||
|
||||
impl<T> PartialEq for JS<T> {
|
||||
#[allow(unrooted_must_root)]
|
||||
fn eq(&self, other: &JS<T>) -> bool {
|
||||
|
@ -151,10 +164,12 @@ impl<T: Reflectable> JS<T> {
|
|||
|
||||
/// Root this JS-owned value to prevent its collection as garbage.
|
||||
pub fn root(&self) -> Root<T> {
|
||||
let collection = StackRoots.get().unwrap();
|
||||
StackRoots.with(|ref collection| {
|
||||
let RootCollectionPtr(collection) = collection.get().unwrap();
|
||||
unsafe {
|
||||
Root::new(&**collection, self)
|
||||
Root::new(&*collection, self)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -270,7 +285,7 @@ impl<T: Reflectable> MutNullableJS<T> {
|
|||
Some(inner) => inner,
|
||||
None => {
|
||||
let inner = cb();
|
||||
self.assign(Some(inner));
|
||||
self.assign(Some(inner.clone()));
|
||||
inner
|
||||
},
|
||||
}
|
||||
|
@ -450,6 +465,10 @@ pub struct RootCollection {
|
|||
roots: UnsafeCell<SmallVec16<*mut JSObject>>,
|
||||
}
|
||||
|
||||
pub struct RootCollectionPtr(pub *const RootCollection);
|
||||
|
||||
impl Copy for RootCollectionPtr {}
|
||||
|
||||
impl RootCollection {
|
||||
/// Create an empty collection of roots
|
||||
pub fn new() -> RootCollection {
|
||||
|
@ -548,6 +567,8 @@ pub struct JSRef<'a, T> {
|
|||
chain: ContravariantLifetime<'a>,
|
||||
}
|
||||
|
||||
impl<'a, T> Copy for JSRef<'a, T> {}
|
||||
|
||||
impl<'a, T> Clone for JSRef<'a, T> {
|
||||
fn clone(&self) -> JSRef<'a, T> {
|
||||
JSRef {
|
||||
|
|
|
@ -33,9 +33,11 @@ use js::jsapi::{JS_AddObjectRoot, JS_RemoveObjectRoot, JSContext};
|
|||
use libc;
|
||||
use std::cell::RefCell;
|
||||
use std::collections::hash_map::{HashMap, Vacant, Occupied};
|
||||
use std::rc::Rc;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
local_data_key!(pub LiveReferences: LiveDOMReferences)
|
||||
thread_local!(pub static LiveReferences: Rc<RefCell<Option<LiveDOMReferences>>> = Rc::new(RefCell::new(None)))
|
||||
|
||||
|
||||
/// A safe wrapper around a raw pointer to a DOM object that can be
|
||||
/// shared among tasks for use in asynchronous operations. The underlying
|
||||
|
@ -55,24 +57,28 @@ impl<T: Reflectable> Trusted<T> {
|
|||
/// be prevented from being GCed for the duration of the resulting `Trusted<T>` object's
|
||||
/// lifetime.
|
||||
pub fn new(cx: *mut JSContext, ptr: JSRef<T>, script_chan: Box<ScriptChan + Send>) -> Trusted<T> {
|
||||
let live_references = LiveReferences.get().unwrap();
|
||||
LiveReferences.with(|ref r| {
|
||||
let r = r.borrow();
|
||||
let live_references = r.as_ref().unwrap();
|
||||
let refcount = live_references.addref(cx, &*ptr as *const T);
|
||||
Trusted {
|
||||
ptr: &*ptr as *const T as *const libc::c_void,
|
||||
refcount: refcount,
|
||||
script_chan: script_chan,
|
||||
script_chan: script_chan.clone(),
|
||||
owner_thread: (&*live_references) as *const _ as *const libc::c_void,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// Obtain a usable DOM pointer from a pinned `Trusted<T>` value. Fails if used on
|
||||
/// a different thread than the original value from which this `Trusted<T>` was
|
||||
/// obtained.
|
||||
pub fn to_temporary(&self) -> Temporary<T> {
|
||||
assert!({
|
||||
let live_references = LiveReferences.get().unwrap();
|
||||
assert!(LiveReferences.with(|ref r| {
|
||||
let r = r.borrow();
|
||||
let live_references = r.as_ref().unwrap();
|
||||
self.owner_thread == (&*live_references) as *const _ as *const libc::c_void
|
||||
});
|
||||
}));
|
||||
unsafe {
|
||||
Temporary::new(JS::from_raw(self.ptr as *const T))
|
||||
}
|
||||
|
@ -117,9 +123,11 @@ pub struct LiveDOMReferences {
|
|||
impl LiveDOMReferences {
|
||||
/// Set up the task-local data required for storing the outstanding DOM references.
|
||||
pub fn initialize() {
|
||||
LiveReferences.replace(Some(LiveDOMReferences {
|
||||
LiveReferences.with(|ref r| {
|
||||
*r.borrow_mut() = Some(LiveDOMReferences {
|
||||
table: RefCell::new(HashMap::new()),
|
||||
}));
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
fn addref<T: Reflectable>(&self, cx: *mut JSContext, ptr: *const T) -> Arc<Mutex<uint>> {
|
||||
|
@ -144,7 +152,9 @@ impl LiveDOMReferences {
|
|||
|
||||
/// Unpin the given DOM object if its refcount is 0.
|
||||
pub fn cleanup(cx: *mut JSContext, raw_reflectable: *const libc::c_void) {
|
||||
let live_references = LiveReferences.get().unwrap();
|
||||
LiveReferences.with(|ref r| {
|
||||
let r = r.borrow();
|
||||
let live_references = r.as_ref().unwrap();
|
||||
let reflectable = raw_reflectable as *const Reflector;
|
||||
let mut table = live_references.table.borrow_mut();
|
||||
match table.entry(raw_reflectable) {
|
||||
|
@ -168,6 +178,7 @@ impl LiveDOMReferences {
|
|||
info!("attempt to cleanup an unrecognized reflector");
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -129,6 +129,7 @@ pub struct NativePropertyHooks {
|
|||
}
|
||||
|
||||
/// The struct that holds inheritance information for DOM object reflectors.
|
||||
#[deriving(Copy)]
|
||||
pub struct DOMClass {
|
||||
/// A list of interfaces that this object implements, in order of decreasing
|
||||
/// derivedness.
|
||||
|
@ -139,6 +140,7 @@ pub struct DOMClass {
|
|||
}
|
||||
|
||||
/// The JSClass used for DOM object reflectors.
|
||||
#[deriving(Copy)]
|
||||
pub struct DOMJSClass {
|
||||
/// The actual JSClass.
|
||||
pub base: js::Class,
|
||||
|
@ -586,18 +588,18 @@ pub fn xml_name_type(name: &str) -> XMLName {
|
|||
'A' ... 'Z' |
|
||||
'_' |
|
||||
'a' ... 'z' |
|
||||
'\u00C0' ... '\u00D6' |
|
||||
'\u00D8' ... '\u00F6' |
|
||||
'\u00F8' ... '\u02FF' |
|
||||
'\u0370' ... '\u037D' |
|
||||
'\u037F' ... '\u1FFF' |
|
||||
'\u200C' ... '\u200D' |
|
||||
'\u2070' ... '\u218F' |
|
||||
'\u2C00' ... '\u2FEF' |
|
||||
'\u3001' ... '\uD7FF' |
|
||||
'\uF900' ... '\uFDCF' |
|
||||
'\uFDF0' ... '\uFFFD' |
|
||||
'\U00010000' ... '\U000EFFFF' => true,
|
||||
'\u{C0}' ... '\u{D6}' |
|
||||
'\u{D8}' ... '\u{F6}' |
|
||||
'\u{F8}' ... '\u{2FF}' |
|
||||
'\u{370}' ... '\u{37D}' |
|
||||
'\u{37F}' ... '\u{1FFF}' |
|
||||
'\u{200C}' ... '\u{200D}' |
|
||||
'\u{2070}' ... '\u{218F}' |
|
||||
'\u{2C00}' ... '\u{2FEF}' |
|
||||
'\u{3001}' ... '\u{D7FF}' |
|
||||
'\u{F900}' ... '\u{FDCF}' |
|
||||
'\u{FDF0}' ... '\u{FFFD}' |
|
||||
'\u{10000}' ... '\u{EFFFF}' => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -607,9 +609,9 @@ pub fn xml_name_type(name: &str) -> XMLName {
|
|||
'-' |
|
||||
'.' |
|
||||
'0' ... '9' |
|
||||
'\u00B7' |
|
||||
'\u0300' ... '\u036F' |
|
||||
'\u203F' ... '\u2040' => true,
|
||||
'\u{B7}' |
|
||||
'\u{300}' ... '\u{36F}' |
|
||||
'\u{203F}' ... '\u{2040}' => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ use dom::bindings::utils::{Reflector, reflect_dom_object};
|
|||
use servo_util::str::DOMString;
|
||||
|
||||
#[repr(uint)]
|
||||
#[deriving(Show)]
|
||||
#[deriving(Copy, Show)]
|
||||
#[jstraceable]
|
||||
pub enum DOMErrorName {
|
||||
IndexSizeError = DOMExceptionConstants::INDEX_SIZE_ERR as uint,
|
||||
|
|
|
@ -86,7 +86,7 @@ impl ElementDerived for EventTarget {
|
|||
}
|
||||
}
|
||||
|
||||
#[deriving(PartialEq, Show)]
|
||||
#[deriving(Copy, PartialEq, Show)]
|
||||
#[jstraceable]
|
||||
pub enum ElementTypeId {
|
||||
HTMLElement(HTMLElementTypeId),
|
||||
|
@ -591,7 +591,7 @@ pub trait AttributeHandlers {
|
|||
|
||||
impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
||||
fn get_attribute(self, namespace: Namespace, local_name: &Atom) -> Option<Temporary<Attr>> {
|
||||
self.get_attributes(local_name).iter().map(|attr| attr.root())
|
||||
self.get_attributes(local_name).into_iter().map(|attr| attr.root())
|
||||
.find(|attr| *attr.r().namespace() == namespace)
|
||||
.map(|x| Temporary::from_rooted(x.r()))
|
||||
}
|
||||
|
@ -841,9 +841,9 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
|||
Some(ref prefix) => {
|
||||
(format!("{}:{}",
|
||||
prefix.as_slice(),
|
||||
self.local_name.as_slice())).into_maybe_owned()
|
||||
self.local_name.as_slice())).into_cow()
|
||||
},
|
||||
None => self.local_name.as_slice().into_maybe_owned()
|
||||
None => self.local_name.as_slice().into_cow()
|
||||
};
|
||||
if self.html_element_in_html_document() {
|
||||
qualified_name.as_slice().to_ascii_upper()
|
||||
|
@ -1290,7 +1290,7 @@ impl<'a> style::TElement<'a> for JSRef<'a, Element> {
|
|||
})
|
||||
}
|
||||
fn get_attrs(self, attr: &Atom) -> Vec<&'a str> {
|
||||
self.get_attributes(attr).iter().map(|attr| attr.root()).map(|attr| {
|
||||
self.get_attributes(attr).into_iter().map(|attr| attr.root()).map(|attr| {
|
||||
// This transmute is used to cheat the lifetime restriction.
|
||||
unsafe { mem::transmute(attr.r().value().as_slice()) }
|
||||
}).collect()
|
||||
|
|
|
@ -17,6 +17,7 @@ use std::default::Default;
|
|||
use time;
|
||||
|
||||
#[jstraceable]
|
||||
#[deriving(Copy)]
|
||||
pub enum EventPhase {
|
||||
None = EventConstants::NONE as int,
|
||||
Capturing = EventConstants::CAPTURING_PHASE as int,
|
||||
|
|
|
@ -28,14 +28,14 @@ use url::Url;
|
|||
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[deriving(PartialEq)]
|
||||
#[deriving(Copy, PartialEq)]
|
||||
#[jstraceable]
|
||||
pub enum ListenerPhase {
|
||||
Capturing,
|
||||
Bubbling,
|
||||
}
|
||||
|
||||
#[deriving(PartialEq)]
|
||||
#[deriving(Copy, PartialEq)]
|
||||
#[jstraceable]
|
||||
pub enum EventTargetTypeId {
|
||||
Node(NodeTypeId),
|
||||
|
@ -46,7 +46,7 @@ pub enum EventTargetTypeId {
|
|||
XMLHttpRequestEventTarget(XMLHttpRequestEventTargetTypeId)
|
||||
}
|
||||
|
||||
#[deriving(PartialEq)]
|
||||
#[deriving(Copy, PartialEq)]
|
||||
#[jstraceable]
|
||||
pub enum EventListenerType {
|
||||
Additive(EventListener),
|
||||
|
@ -62,7 +62,7 @@ impl EventListenerType {
|
|||
}
|
||||
}
|
||||
|
||||
#[deriving(PartialEq)]
|
||||
#[deriving(Copy, PartialEq)]
|
||||
#[jstraceable]
|
||||
#[privatize]
|
||||
pub struct EventListenerEntry {
|
||||
|
|
|
@ -119,7 +119,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLCanvasElement> {
|
|||
if recreate {
|
||||
let (w, h) = (self.width.get() as i32, self.height.get() as i32);
|
||||
match self.context.get() {
|
||||
Some(ref context) => context.root().r().recreate(Size2D(w, h)),
|
||||
Some(context) => context.root().r().recreate(Size2D(w, h)),
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLCanvasElement> {
|
|||
if recreate {
|
||||
let (w, h) = (self.width.get() as i32, self.height.get() as i32);
|
||||
match self.context.get() {
|
||||
Some(ref context) => context.root().r().recreate(Size2D(w, h)),
|
||||
Some(context) => context.root().r().recreate(Size2D(w, h)),
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ fn to_snake_case(name: DOMString) -> DOMString {
|
|||
impl<'a> HTMLElementCustomAttributeHelpers for JSRef<'a, HTMLElement> {
|
||||
fn set_custom_attr(self, name: DOMString, value: DOMString) -> ErrorResult {
|
||||
if name.as_slice().chars()
|
||||
.skip_while(|&ch| ch != '\u002d')
|
||||
.skip_while(|&ch| ch != '\u{2d}')
|
||||
.nth(1).map_or(false, |ch| ch as u8 - b'a' < 26) {
|
||||
return Err(Syntax);
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLElement> {
|
|||
}
|
||||
}
|
||||
|
||||
#[deriving(PartialEq, Show)]
|
||||
#[deriving(Copy, PartialEq, Show)]
|
||||
#[jstraceable]
|
||||
pub enum HTMLElementTypeId {
|
||||
HTMLElement,
|
||||
|
|
|
@ -129,11 +129,13 @@ impl<'a> HTMLFormElementMethods for JSRef<'a, HTMLFormElement> {
|
|||
}
|
||||
}
|
||||
|
||||
#[deriving(Copy)]
|
||||
pub enum SubmittedFrom {
|
||||
FromFormSubmitMethod,
|
||||
NotFromFormSubmitMethod
|
||||
}
|
||||
|
||||
#[deriving(Copy)]
|
||||
pub enum ResetFrom {
|
||||
FromFormResetMethod,
|
||||
NotFromFormResetMethod
|
||||
|
@ -396,18 +398,21 @@ pub struct FormDatum {
|
|||
pub value: DOMString
|
||||
}
|
||||
|
||||
#[deriving(Copy)]
|
||||
pub enum FormEncType {
|
||||
TextPlainEncoded,
|
||||
UrlEncoded,
|
||||
FormDataEncoded
|
||||
}
|
||||
|
||||
#[deriving(Copy)]
|
||||
pub enum FormMethod {
|
||||
FormGet,
|
||||
FormPost,
|
||||
FormDialog
|
||||
}
|
||||
|
||||
#[deriving(Copy)]
|
||||
pub enum FormSubmitter<'a> {
|
||||
FormElement(JSRef<'a, HTMLFormElement>),
|
||||
InputElement(JSRef<'a, HTMLInputElement>)
|
||||
|
|
|
@ -56,6 +56,7 @@ impl HTMLIFrameElementDerived for EventTarget {
|
|||
|
||||
#[jstraceable]
|
||||
#[privatize]
|
||||
#[deriving(Copy)]
|
||||
pub struct IFrameSize {
|
||||
pipeline_id: PipelineId,
|
||||
subpage_id: SubpageId,
|
||||
|
|
|
@ -45,7 +45,7 @@ const DEFAULT_SUBMIT_VALUE: &'static str = "Submit";
|
|||
const DEFAULT_RESET_VALUE: &'static str = "Reset";
|
||||
|
||||
#[jstraceable]
|
||||
#[deriving(PartialEq)]
|
||||
#[deriving(PartialEq, Copy)]
|
||||
#[allow(dead_code)]
|
||||
enum InputType {
|
||||
InputSubmit,
|
||||
|
|
|
@ -38,7 +38,7 @@ impl HTMLMediaElement {
|
|||
}
|
||||
}
|
||||
|
||||
#[deriving(PartialEq, Show)]
|
||||
#[deriving(Copy, PartialEq, Show)]
|
||||
#[jstraceable]
|
||||
pub enum HTMLMediaElementTypeId {
|
||||
HTMLAudioElement,
|
||||
|
|
|
@ -156,7 +156,7 @@ fn escape(string: &str, attr_mode: bool, html: &mut String) {
|
|||
for c in string.chars() {
|
||||
match c {
|
||||
'&' => html.push_str("&"),
|
||||
'\u00A0' => html.push_str(" "),
|
||||
'\u{A0}' => html.push_str(" "),
|
||||
'"' if attr_mode => html.push_str("""),
|
||||
'<' if !attr_mode => html.push_str("<"),
|
||||
'>' if !attr_mode => html.push_str(">"),
|
||||
|
|
|
@ -16,7 +16,7 @@ use cssparser::RGBA;
|
|||
use servo_util::str::{mod, DOMString, LengthOrPercentageOrAuto};
|
||||
use std::cell::Cell;
|
||||
|
||||
#[deriving(PartialEq, Show)]
|
||||
#[deriving(Copy, PartialEq, Show)]
|
||||
#[jstraceable]
|
||||
pub enum HTMLTableCellElementTypeId {
|
||||
HTMLTableDataCellElement,
|
||||
|
|
|
@ -59,7 +59,7 @@ use std::default::Default;
|
|||
use std::iter::{FilterMap, Peekable};
|
||||
use std::mem;
|
||||
use style::{mod, ComputedValues};
|
||||
use sync::Arc;
|
||||
use std::sync::Arc;
|
||||
use uuid;
|
||||
use string_cache::QualName;
|
||||
|
||||
|
@ -121,6 +121,7 @@ impl NodeDerived for EventTarget {
|
|||
bitflags! {
|
||||
#[doc = "Flags for node items."]
|
||||
#[jstraceable]
|
||||
#[deriving(Copy)]
|
||||
flags NodeFlags: u16 {
|
||||
#[doc = "Specifies whether this node is in a document."]
|
||||
const IS_IN_DOC = 0x01,
|
||||
|
@ -180,6 +181,7 @@ impl Drop for Node {
|
|||
/// suppress observers flag
|
||||
/// http://dom.spec.whatwg.org/#concept-node-insert
|
||||
/// http://dom.spec.whatwg.org/#concept-node-remove
|
||||
#[deriving(Copy)]
|
||||
enum SuppressObserver {
|
||||
Suppressed,
|
||||
Unsuppressed
|
||||
|
@ -252,7 +254,7 @@ impl LayoutDataRef {
|
|||
}
|
||||
|
||||
/// The different types of nodes.
|
||||
#[deriving(PartialEq, Show)]
|
||||
#[deriving(Copy, PartialEq, Show)]
|
||||
#[jstraceable]
|
||||
pub enum NodeTypeId {
|
||||
DocumentType,
|
||||
|
@ -1146,7 +1148,7 @@ impl<'a> Iterator<JSRef<'a, Node>> for NodeIterator {
|
|||
}
|
||||
|
||||
/// Specifies whether children must be recursively cloned or not.
|
||||
#[deriving(PartialEq)]
|
||||
#[deriving(Copy, PartialEq)]
|
||||
pub enum CloneChildrenFlag {
|
||||
CloneChildren,
|
||||
DoNotCloneChildren
|
||||
|
@ -2175,7 +2177,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
|||
/// and are also used in the HTML parser interface.
|
||||
|
||||
#[allow(raw_pointer_deriving)]
|
||||
#[deriving(Clone, PartialEq, Eq)]
|
||||
#[deriving(Clone, PartialEq, Eq, Copy)]
|
||||
pub struct TrustedNodeAddress(pub *const c_void);
|
||||
|
||||
pub fn document_from_node<T: NodeBase+Reflectable>(derived: JSRef<T>) -> Temporary<Document> {
|
||||
|
@ -2284,7 +2286,7 @@ impl<'a> style::TNode<'a, JSRef<'a, Element>> for JSRef<'a, Node> {
|
|||
.map_or(false, |attr| test(attr.r().value().as_slice()))
|
||||
},
|
||||
style::NamespaceConstraint::Any => {
|
||||
self.as_element().get_attributes(name).iter()
|
||||
self.as_element().get_attributes(name).into_iter()
|
||||
.map(|attr| attr.root())
|
||||
.any(|attr| test(attr.r().value().as_slice()))
|
||||
}
|
||||
|
@ -2357,7 +2359,7 @@ impl<'a> DisabledStateHelpers for JSRef<'a, Node> {
|
|||
}
|
||||
|
||||
/// A summary of the changes that happened to a node.
|
||||
#[deriving(Clone, PartialEq)]
|
||||
#[deriving(Copy, Clone, PartialEq)]
|
||||
pub enum NodeDamage {
|
||||
/// The node's `style` attribute changed.
|
||||
NodeStyleDamaged,
|
||||
|
|
|
@ -256,9 +256,9 @@ impl<'a> PrivateTreeWalkerHelpers<'a> for JSRef<'a, TreeWalker> {
|
|||
// "5. If result is FILTER_REJECT or sibling is null,
|
||||
// then set sibling to node's next sibling if type is next,
|
||||
// and node's previous sibling if type is previous."
|
||||
match (result, sibling_op) {
|
||||
match (result, &sibling_op) {
|
||||
(Ok(NodeFilterConstants::FILTER_REJECT), _)
|
||||
| (_, None) => sibling_op = next_sibling(node),
|
||||
| (_, &None) => sibling_op = next_sibling(node),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue