From 466faac2a507c833b282e274a28f6ae533c628f9 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 17 Dec 2014 10:42:52 +0100 Subject: [PATCH] Update rustc to revision 3dcd2157403163789aaf21a9ab3c4d30a7c6494d. --- components/canvas/canvas_paint_task.rs | 10 +- components/compositing/Cargo.toml | 3 + components/compositing/compositor.rs | 167 ++-- components/compositing/compositor_layer.rs | 34 +- components/compositing/compositor_task.rs | 60 +- components/compositing/constellation.rs | 39 +- components/compositing/headless.rs | 32 +- components/compositing/scrolling.rs | 12 +- components/compositing/windowing.rs | 46 +- components/devtools/actors/console.rs | 1 + components/devtools/actors/inspector.rs | 1 + components/gfx/Cargo.toml | 2 + components/gfx/display_list/mod.rs | 3 + components/gfx/font_cache_task.rs | 9 +- components/gfx/paint_context.rs | 70 +- components/gfx/paint_task.rs | 4 + components/gfx/platform/freetype/font.rs | 1 + components/gfx/platform/macos/font.rs | 1 + components/gfx/text/glyph.rs | 3 + components/gfx/text/util.rs | 2 + components/layout/block.rs | 344 ++++----- components/layout/construct.rs | 270 ++++--- components/layout/css/matching.rs | 28 +- components/layout/css/node_style.rs | 14 +- components/layout/display_list_builder.rs | 114 ++- components/layout/floats.rs | 38 +- components/layout/flow.rs | 93 ++- components/layout/fragment.rs | 310 ++++---- components/layout/inline.rs | 36 +- components/layout/layout_task.rs | 76 +- components/layout/list_item.rs | 4 +- components/layout/model.rs | 106 +-- components/layout/table.rs | 38 +- components/layout/table_caption.rs | 4 +- components/layout/table_cell.rs | 12 +- components/layout/table_colgroup.rs | 10 +- components/layout/table_row.rs | 24 +- components/layout/table_rowgroup.rs | 8 +- components/layout/table_wrapper.rs | 55 +- components/layout/text.rs | 8 +- components/layout/traversal.rs | 6 +- components/layout/util.rs | 8 +- components/layout/wrapper.rs | 58 +- components/msg/constellation_msg.rs | 240 +++--- components/net/Cargo.toml | 3 + components/net/about_loader.rs | 8 +- components/net/data_loader.rs | 7 +- components/net/fetch/cors_cache.rs | 3 + components/net/fetch/request.rs | 6 + components/net/fetch/response.rs | 3 + components/net/file_loader.rs | 3 +- components/net/http_loader.rs | 3 +- components/net/image/holder.rs | 2 +- components/net/image_cache_task.rs | 89 ++- components/net/local_image_cache.rs | 5 +- components/net/resource_task.rs | 18 +- components/net/storage_task.rs | 3 + components/plugins/lints.rs | 1 - components/script/Cargo.toml | 4 +- components/script/cors.rs | 36 +- components/script/devtools.rs | 4 +- components/script/dom/attr.rs | 35 +- .../dom/bindings/codegen/CodegenRust.py | 82 +- components/script/dom/bindings/conversions.rs | 6 +- components/script/dom/bindings/global.rs | 4 + components/script/dom/bindings/str.rs | 26 +- components/script/dom/bindings/utils.rs | 26 +- components/script/dom/blob.rs | 14 +- components/script/dom/characterdata.rs | 13 +- components/script/dom/comment.rs | 8 +- components/script/dom/create.rs | 2 +- components/script/dom/customevent.rs | 6 +- .../script/dom/dedicatedworkerglobalscope.rs | 22 +- components/script/dom/document.rs | 74 +- components/script/dom/documentfragment.rs | 8 +- components/script/dom/documenttype.rs | 8 +- components/script/dom/domexception.rs | 75 +- components/script/dom/domimplementation.rs | 16 +- components/script/dom/domparser.rs | 25 +- components/script/dom/domrect.rs | 1 + components/script/dom/domtokenlist.rs | 3 +- components/script/dom/element.rs | 226 +++--- components/script/dom/errorevent.rs | 13 +- components/script/dom/event.rs | 34 +- components/script/dom/eventdispatcher.rs | 18 +- components/script/dom/eventtarget.rs | 40 +- components/script/dom/file.rs | 6 +- components/script/dom/formdata.rs | 17 +- components/script/dom/htmlanchorelement.rs | 10 +- components/script/dom/htmlappletelement.rs | 10 +- components/script/dom/htmlareaelement.rs | 10 +- components/script/dom/htmlaudioelement.rs | 10 +- components/script/dom/htmlbaseelement.rs | 10 +- components/script/dom/htmlbodyelement.rs | 10 +- components/script/dom/htmlbrelement.rs | 10 +- components/script/dom/htmlbuttonelement.rs | 10 +- components/script/dom/htmlcanvaselement.rs | 10 +- components/script/dom/htmlcollection.rs | 14 +- components/script/dom/htmldataelement.rs | 10 +- components/script/dom/htmldatalistelement.rs | 10 +- components/script/dom/htmldirectoryelement.rs | 10 +- components/script/dom/htmldivelement.rs | 10 +- components/script/dom/htmldlistelement.rs | 10 +- components/script/dom/htmlelement.rs | 12 +- components/script/dom/htmlembedelement.rs | 10 +- components/script/dom/htmlfieldsetelement.rs | 27 +- components/script/dom/htmlfontelement.rs | 10 +- components/script/dom/htmlformelement.rs | 89 +-- components/script/dom/htmlframeelement.rs | 10 +- components/script/dom/htmlframesetelement.rs | 10 +- components/script/dom/htmlheadelement.rs | 10 +- components/script/dom/htmlheadingelement.rs | 10 +- components/script/dom/htmlhrelement.rs | 10 +- components/script/dom/htmlhtmlelement.rs | 10 +- components/script/dom/htmliframeelement.rs | 26 +- components/script/dom/htmlimageelement.rs | 14 +- components/script/dom/htmlinputelement.rs | 118 +-- components/script/dom/htmllabelelement.rs | 10 +- components/script/dom/htmllegendelement.rs | 10 +- components/script/dom/htmllielement.rs | 10 +- components/script/dom/htmllinkelement.rs | 10 +- components/script/dom/htmlmapelement.rs | 10 +- components/script/dom/htmlmediaelement.rs | 10 +- components/script/dom/htmlmetaelement.rs | 10 +- components/script/dom/htmlmeterelement.rs | 10 +- components/script/dom/htmlmodelement.rs | 10 +- components/script/dom/htmlobjectelement.rs | 10 +- components/script/dom/htmlolistelement.rs | 10 +- components/script/dom/htmloptgroupelement.rs | 10 +- components/script/dom/htmloptionelement.rs | 10 +- components/script/dom/htmloutputelement.rs | 10 +- components/script/dom/htmlparagraphelement.rs | 10 +- components/script/dom/htmlparamelement.rs | 10 +- components/script/dom/htmlpreelement.rs | 10 +- components/script/dom/htmlprogresselement.rs | 10 +- components/script/dom/htmlquoteelement.rs | 10 +- components/script/dom/htmlscriptelement.rs | 19 +- components/script/dom/htmlselectelement.rs | 14 +- components/script/dom/htmlserializer.rs | 19 +- components/script/dom/htmlsourceelement.rs | 10 +- components/script/dom/htmlspanelement.rs | 10 +- components/script/dom/htmlstyleelement.rs | 15 +- .../script/dom/htmltablecaptionelement.rs | 10 +- components/script/dom/htmltablecellelement.rs | 17 +- components/script/dom/htmltablecolelement.rs | 10 +- .../script/dom/htmltabledatacellelement.rs | 10 +- components/script/dom/htmltableelement.rs | 16 +- .../script/dom/htmltableheadercellelement.rs | 10 +- components/script/dom/htmltablerowelement.rs | 10 +- .../script/dom/htmltablesectionelement.rs | 10 +- components/script/dom/htmltemplateelement.rs | 10 +- components/script/dom/htmltextareaelement.rs | 32 +- components/script/dom/htmltimeelement.rs | 10 +- components/script/dom/htmltitleelement.rs | 10 +- components/script/dom/htmltrackelement.rs | 10 +- components/script/dom/htmlulistelement.rs | 10 +- components/script/dom/htmlunknownelement.rs | 10 +- components/script/dom/htmlvideoelement.rs | 10 +- components/script/dom/keyboardevent.rs | 720 +++++++++--------- components/script/dom/messageevent.rs | 6 +- components/script/dom/mouseevent.rs | 6 +- components/script/dom/node.rs | 314 ++++---- components/script/dom/nodelist.rs | 12 +- .../script/dom/processinginstruction.rs | 8 +- components/script/dom/progressevent.rs | 6 +- components/script/dom/testbinding.rs | 10 +- components/script/dom/text.rs | 8 +- components/script/dom/treewalker.rs | 24 +- components/script/dom/uievent.rs | 6 +- components/script/dom/urlsearchparams.rs | 7 +- components/script/dom/virtualmethods.rs | 82 +- components/script/dom/websocket.rs | 4 +- components/script/dom/window.rs | 21 +- components/script/dom/worker.rs | 10 +- components/script/dom/workerglobalscope.rs | 23 +- components/script/dom/xmlhttprequest.rs | 64 +- .../script/dom/xmlhttprequesteventtarget.rs | 16 +- components/script/dom/xmlhttprequestupload.rs | 8 +- components/script/layout_interface.rs | 4 + components/script/lib.rs | 2 +- components/script/page.rs | 10 +- components/script/parse/html.rs | 13 +- components/script/script_task.rs | 106 +-- components/script/textinput.rs | 45 +- components/script/timers.rs | 14 +- components/servo/Cargo.lock | 174 +++-- components/servo/Cargo.toml | 3 + components/servo/lib.rs | 2 +- components/servo/main.rs | 10 +- components/style/font_face.rs | 24 +- components/style/legacy.rs | 57 +- components/style/lib.rs | 23 +- components/style/media_queries.rs | 193 +++-- components/style/properties/common_types.rs | 218 +++--- components/style/properties/mod.rs.mako | 432 ++++++----- components/style/selector_matching.rs | 186 +++-- components/style/selectors.rs | 233 +++--- components/style/stylesheets.rs | 20 +- components/util/Cargo.toml | 3 + components/util/geometry.rs | 2 +- components/util/memory.rs | 18 +- components/util/opts.rs | 6 +- components/util/range.rs | 82 +- components/util/rtinstrument.rs | 27 +- components/util/smallvec.rs | 4 +- components/util/str.rs | 34 +- components/util/task.rs | 4 +- components/util/time.rs | 95 +-- components/util/workqueue.rs | 36 +- ports/cef/Cargo.lock | 173 +++-- ports/cef/browser.rs | 16 +- ports/cef/browser_host.rs | 100 ++- ports/cef/core.rs | 16 +- ports/cef/frame.rs | 4 +- ports/cef/render_handler.rs | 2 +- ports/cef/window.rs | 4 +- ports/glfw/Cargo.toml | 3 + ports/glfw/window.rs | 305 ++++---- ports/glutin/Cargo.toml | 3 + ports/gonk/Cargo.lock | 39 +- ports/gonk/Cargo.toml | 3 + rust-snapshot-hash | 2 +- tests/reftest.rs | 12 +- 223 files changed, 4414 insertions(+), 4105 deletions(-) diff --git a/components/canvas/canvas_paint_task.rs b/components/canvas/canvas_paint_task.rs index ee71bd16483..4d8adef0478 100644 --- a/components/canvas/canvas_paint_task.rs +++ b/components/canvas/canvas_paint_task.rs @@ -42,11 +42,11 @@ impl CanvasPaintTask { loop { match port.recv() { - FillRect(ref rect) => painter.fill_rect(rect), - StrokeRect(ref rect) => painter.stroke_rect(rect), - ClearRect(ref rect) => painter.clear_rect(rect), - Recreate(size) => painter.recreate(size), - Close => break, + CanvasMsg::FillRect(ref rect) => painter.fill_rect(rect), + CanvasMsg::StrokeRect(ref rect) => painter.stroke_rect(rect), + CanvasMsg::ClearRect(ref rect) => painter.clear_rect(rect), + CanvasMsg::Recreate(size) => painter.recreate(size), + CanvasMsg::Close => break, } } }); diff --git a/components/compositing/Cargo.toml b/components/compositing/Cargo.toml index d24be54918e..6fb0ed57ca1 100644 --- a/components/compositing/Cargo.toml +++ b/components/compositing/Cargo.toml @@ -54,3 +54,6 @@ git = "https://github.com/servo/rust-core-text" [dependencies.gleam] git = "https://github.com/servo/gleam" + +[dependencies.time] +git = "https://github.com/rust-lang/time" diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 21cfcfdcd86..0b18124f53a 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -2,25 +2,14 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use compositor_layer::{CompositorData, CompositorLayer, DoesntWantScrollEvents}; -use compositor_layer::{WantsScrollEvents}; -use compositor_task; -use compositor_task::{ChangePageLoadData, ChangePageTitle, ChangePaintState, ChangeReadyState}; -use compositor_task::{CompositorEventListener, CompositorProxy, CompositorReceiver}; -use compositor_task::{CompositorTask, CreateOrUpdateDescendantLayer, CreateOrUpdateRootLayer}; -use compositor_task::{Exit, FrameTreeUpdateMsg, GetGraphicsMetadata, LayerProperties}; -use compositor_task::{LoadComplete, Msg, Paint, PaintMsgDiscarded, ScrollFragmentPoint}; -use compositor_task::{ScrollTimeout, SetIds, SetLayerOrigin, ShutdownComplete}; +use compositor_layer::{CompositorData, CompositorLayer, WantsScrollEventsFlag}; +use compositor_task::{CompositorEventListener, CompositorProxy, CompositorReceiver, CompositorTask}; +use compositor_task::{LayerProperties, Msg}; use constellation::{FrameId, FrameTreeDiff, SendableFrameTree}; use pipeline::CompositionPipeline; use scrolling::ScrollingTimerProxy; use windowing; -use windowing::{IdleWindowEvent, InitializeCompositingWindowEvent}; -use windowing::{KeyEvent, LoadUrlWindowEvent, MouseWindowClickEvent, MouseWindowEvent}; -use windowing::{MouseWindowEventClass, MouseWindowMouseDownEvent, MouseWindowMouseUpEvent}; -use windowing::{MouseWindowMoveEventClass, NavigationWindowEvent, PinchZoomWindowEvent}; -use windowing::{QuitWindowEvent, RefreshWindowEvent, ResizeWindowEvent, ScrollWindowEvent}; -use windowing::{WindowEvent, WindowMethods, WindowNavigateMsg, ZoomWindowEvent}; +use windowing::{MouseWindowEvent, WindowEvent, WindowMethods, WindowNavigateMsg}; use azure::azure_hl; use std::cmp; @@ -54,6 +43,7 @@ use servo_util::{memory, time}; use std::collections::HashMap; use std::collections::hash_map::{Occupied, Vacant}; use std::path::Path; +use std::num::FloatMath; use std::rc::Rc; use std::slice::bytes::copy_memory; use time::{precise_time_ns, precise_time_s}; @@ -192,9 +182,9 @@ impl IOCompositor { window_size: window_size, hidpi_factor: hidpi_factor, scrolling_timer: ScrollingTimerProxy::new(sender), - composition_request: NoCompositingNecessary, + composition_request: CompositionRequest::NoCompositingNecessary, pending_scroll_events: Vec::new(), - shutdown_state: NotShuttingDown, + shutdown_state: ShutdownState::NotShuttingDown, page_zoom: ScaleFactor(1.0), viewport_zoom: ScaleFactor(1.0), zoom_action: false, @@ -237,83 +227,88 @@ impl IOCompositor { fn handle_browser_message(&mut self, msg: Msg) -> bool { match (msg, self.shutdown_state) { - (_, FinishedShuttingDown) => + (_, ShutdownState::FinishedShuttingDown) => panic!("compositor shouldn't be handling messages after shutting down"), - (Exit(chan), _) => { + (Msg::Exit(chan), _) => { debug!("shutting down the constellation"); let ConstellationChan(ref con_chan) = self.constellation_chan; con_chan.send(ExitMsg); chan.send(()); - self.shutdown_state = ShuttingDown; + self.shutdown_state = ShutdownState::ShuttingDown; } - (ShutdownComplete, _) => { + (Msg::ShutdownComplete, _) => { debug!("constellation completed shutdown"); - self.shutdown_state = FinishedShuttingDown; + self.shutdown_state = ShutdownState::FinishedShuttingDown; return false; } - (ChangeReadyState(pipeline_id, ready_state), NotShuttingDown) => { + (Msg::ChangeReadyState(pipeline_id, ready_state), ShutdownState::NotShuttingDown) => { self.change_ready_state(pipeline_id, ready_state); } - (ChangePaintState(pipeline_id, paint_state), NotShuttingDown) => { + (Msg::ChangePaintState(pipeline_id, paint_state), ShutdownState::NotShuttingDown) => { self.change_paint_state(pipeline_id, paint_state); } - (ChangePageTitle(pipeline_id, title), NotShuttingDown) => { + (Msg::ChangePageTitle(pipeline_id, title), ShutdownState::NotShuttingDown) => { self.change_page_title(pipeline_id, title); } - (ChangePageLoadData(frame_id, load_data), NotShuttingDown) => { + (Msg::ChangePageLoadData(frame_id, load_data), ShutdownState::NotShuttingDown) => { self.change_page_load_data(frame_id, load_data); } - (PaintMsgDiscarded, NotShuttingDown) => { + (Msg::PaintMsgDiscarded, ShutdownState::NotShuttingDown) => { self.remove_outstanding_paint_msg(); } - (SetIds(frame_tree, response_chan, new_constellation_chan), NotShuttingDown) => { + (Msg::SetIds(frame_tree, response_chan, new_constellation_chan), + ShutdownState::NotShuttingDown) => { self.set_frame_tree(&frame_tree, response_chan, new_constellation_chan); self.send_viewport_rects_for_all_layers(); } - (FrameTreeUpdateMsg(frame_tree_diff, response_channel), NotShuttingDown) => { + (Msg::FrameTreeUpdate(frame_tree_diff, response_channel), + ShutdownState::NotShuttingDown) => { self.update_frame_tree(&frame_tree_diff); response_channel.send(()); } - (CreateOrUpdateRootLayer(layer_properties), NotShuttingDown) => { + (Msg::CreateOrUpdateRootLayer(layer_properties), ShutdownState::NotShuttingDown) => { self.create_or_update_root_layer(layer_properties); } - (CreateOrUpdateDescendantLayer(layer_properties), NotShuttingDown) => { + (Msg::CreateOrUpdateDescendantLayer(layer_properties), + ShutdownState::NotShuttingDown) => { self.create_or_update_descendant_layer(layer_properties); } - (GetGraphicsMetadata(chan), NotShuttingDown) => { + (Msg::GetGraphicsMetadata(chan), ShutdownState::NotShuttingDown) => { chan.send(Some(self.window.native_metadata())); } - (SetLayerOrigin(pipeline_id, layer_id, origin), NotShuttingDown) => { + (Msg::SetLayerOrigin(pipeline_id, layer_id, origin), + ShutdownState::NotShuttingDown) => { self.set_layer_origin(pipeline_id, layer_id, origin); } - (Paint(pipeline_id, epoch, replies), NotShuttingDown) => { + (Msg::Paint(pipeline_id, epoch, replies), ShutdownState::NotShuttingDown) => { for (layer_id, new_layer_buffer_set) in replies.into_iter() { self.paint(pipeline_id, layer_id, new_layer_buffer_set, epoch); } self.remove_outstanding_paint_msg(); } - (ScrollFragmentPoint(pipeline_id, layer_id, point), NotShuttingDown) => { + (Msg::ScrollFragmentPoint(pipeline_id, layer_id, point), + ShutdownState::NotShuttingDown) => { self.scroll_fragment_to_point(pipeline_id, layer_id, point); } - (LoadComplete, NotShuttingDown) => { + (Msg::LoadComplete, ShutdownState::NotShuttingDown) => { self.got_load_complete_message = true; // If we're painting in headless mode, schedule a recomposite. @@ -327,24 +322,26 @@ impl IOCompositor { self.window.load_end(); } - (ScrollTimeout(timestamp), NotShuttingDown) => { + (Msg::ScrollTimeout(timestamp), ShutdownState::NotShuttingDown) => { debug!("scroll timeout, drawing unpainted content!"); match self.composition_request { - CompositeOnScrollTimeout(this_timestamp) if timestamp == this_timestamp => { - self.composition_request = CompositeNow + CompositionRequest::CompositeOnScrollTimeout(this_timestamp) => { + if timestamp == this_timestamp { + self.composition_request = CompositionRequest::CompositeNow + } } _ => {} } } - (compositor_task::KeyEvent(key, modified), NotShuttingDown) => { + (Msg::KeyEvent(key, modified), ShutdownState::NotShuttingDown) => { self.window.handle_key(key, modified); } // When we are shutting_down, we need to avoid performing operations // such as Paint that may crash because we have begun tearing down // the rest of our resources. - (_, ShuttingDown) => { } + (_, ShutdownState::ShuttingDown) => { } } true @@ -502,10 +499,11 @@ impl IOCompositor { root_layer.update_layer_except_size(layer_properties); let root_layer_pipeline = root_layer.extra_data.borrow().pipeline.clone(); - let first_child = CompositorData::new_layer(root_layer_pipeline.clone(), - layer_properties, - DoesntWantScrollEvents, - opts::get().tile_size); + let first_child = CompositorData::new_layer( + root_layer_pipeline.clone(), + layer_properties, + WantsScrollEventsFlag::DoesntWantScrollEvents, + opts::get().tile_size); // Add the first child / base layer to the front of the child list, so that // child iframe layers are painted on top of the base layer. These iframe @@ -533,7 +531,7 @@ impl IOCompositor { let root_layer_pipeline = root_layer.extra_data.borrow().pipeline.clone(); let new_layer = CompositorData::new_layer(root_layer_pipeline, layer_properties, - DoesntWantScrollEvents, + WantsScrollEventsFlag::DoesntWantScrollEvents, root_layer.tile_size); root_layer.add_child(new_layer); } @@ -558,7 +556,7 @@ impl IOCompositor { -> bool { match self.find_layer_with_pipeline_and_layer_id(pipeline_id, layer_id) { Some(ref layer) => { - if layer.extra_data.borrow().wants_scroll_events == WantsScrollEvents { + if layer.wants_scroll_events() == WantsScrollEventsFlag::WantsScrollEvents { layer.clamp_scroll_offset_and_scroll_layer(TypedPoint2D(0f32, 0f32) - origin); } true @@ -584,13 +582,14 @@ impl IOCompositor { fn start_scrolling_timer_if_necessary(&mut self) { match self.composition_request { - CompositeNow | CompositeOnScrollTimeout(_) => return, - NoCompositingNecessary => {} + CompositionRequest::CompositeNow | CompositionRequest::CompositeOnScrollTimeout(_) => + return, + CompositionRequest::NoCompositingNecessary => {} } let timestamp = precise_time_ns(); self.scrolling_timer.scroll_event_processed(timestamp); - self.composition_request = CompositeOnScrollTimeout(timestamp); + self.composition_request = CompositionRequest::CompositeOnScrollTimeout(timestamp); } fn set_layer_origin(&mut self, @@ -651,57 +650,57 @@ impl IOCompositor { fn handle_window_message(&mut self, event: WindowEvent) { match event { - IdleWindowEvent => {} + WindowEvent::Idle => {} - RefreshWindowEvent => { + WindowEvent::Refresh => { self.composite(); } - InitializeCompositingWindowEvent => { + WindowEvent::InitializeCompositing => { self.initialize_compositing(); } - ResizeWindowEvent(size) => { + WindowEvent::Resize(size) => { self.on_resize_window_event(size); } - LoadUrlWindowEvent(url_string) => { + WindowEvent::LoadUrl(url_string) => { self.on_load_url_window_event(url_string); } - MouseWindowEventClass(mouse_window_event) => { + WindowEvent::MouseWindowEventClass(mouse_window_event) => { self.on_mouse_window_event_class(mouse_window_event); } - MouseWindowMoveEventClass(cursor) => { + WindowEvent::MouseWindowMoveEventClass(cursor) => { self.on_mouse_window_move_event_class(cursor); } - ScrollWindowEvent(delta, cursor) => { + WindowEvent::Scroll(delta, cursor) => { self.on_scroll_window_event(delta, cursor); } - ZoomWindowEvent(magnification) => { + WindowEvent::Zoom(magnification) => { self.on_zoom_window_event(magnification); } - PinchZoomWindowEvent(magnification) => { + WindowEvent::PinchZoom(magnification) => { self.on_pinch_zoom_window_event(magnification); } - NavigationWindowEvent(direction) => { + WindowEvent::Navigation(direction) => { self.on_navigation_window_event(direction); } - KeyEvent(key, state, modifiers) => { + WindowEvent::KeyEvent(key, state, modifiers) => { self.on_key_event(key, state, modifiers); } - QuitWindowEvent => { - debug!("shutting down the constellation for QuitWindowEvent"); + WindowEvent::Quit => { + debug!("shutting down the constellation for WindowEvent::Quit"); let ConstellationChan(ref chan) = self.constellation_chan; chan.send(ExitMsg); - self.shutdown_state = ShuttingDown; + self.shutdown_state = ShutdownState::ShuttingDown; } } } @@ -731,7 +730,7 @@ impl IOCompositor { self.got_load_complete_message = false; let root_pipeline_id = match self.scene.root { Some(ref layer) => layer.extra_data.borrow().pipeline.id.clone(), - None => panic!("Compositor: Received LoadUrlWindowEvent without initialized compositor \ + None => panic!("Compositor: Received WindowEvent::LoadUrl without initialized compositor \ layers"), }; @@ -743,9 +742,9 @@ impl IOCompositor { fn on_mouse_window_event_class(&self, mouse_window_event: MouseWindowEvent) { let point = match mouse_window_event { - MouseWindowClickEvent(_, p) => p, - MouseWindowMouseDownEvent(_, p) => p, - MouseWindowMouseUpEvent(_, p) => p, + MouseWindowEvent::MouseWindowClickEvent(_, p) => p, + MouseWindowEvent::MouseWindowMouseDownEvent(_, p) => p, + MouseWindowEvent::MouseWindowMouseUpEvent(_, p) => p, }; match self.find_topmost_layer_at_point(point / self.scene.scale) { Some(result) => result.layer.send_mouse_event(mouse_window_event, result.point), @@ -853,8 +852,8 @@ impl IOCompositor { fn on_navigation_window_event(&self, direction: WindowNavigateMsg) { let direction = match direction { - windowing::Forward => constellation_msg::Forward, - windowing::Back => constellation_msg::Back, + windowing::WindowNavigateMsg::Forward => constellation_msg::Forward, + windowing::WindowNavigateMsg::Back => constellation_msg::Back, }; let ConstellationChan(ref chan) = self.constellation_chan; chan.send(NavigateMsg(direction)) @@ -1077,7 +1076,7 @@ impl IOCompositor { debug!("shutting down the constellation after generating an output file"); let ConstellationChan(ref chan) = self.constellation_chan; chan.send(ExitMsg); - self.shutdown_state = ShuttingDown; + self.shutdown_state = ShutdownState::ShuttingDown; } // Perform the page flip. This will likely block for a while. @@ -1085,13 +1084,13 @@ impl IOCompositor { self.last_composite_time = precise_time_ns(); - self.composition_request = NoCompositingNecessary; + self.composition_request = CompositionRequest::NoCompositingNecessary; self.process_pending_scroll_events(); } fn composite_if_necessary(&mut self) { - if self.composition_request == NoCompositingNecessary { - self.composition_request = CompositeNow + if self.composition_request == CompositionRequest::NoCompositingNecessary { + self.composition_request = CompositionRequest::CompositeNow } } @@ -1208,7 +1207,7 @@ fn create_root_layer_for_pipeline_and_rect(pipeline: &CompositionPipeline, let root_layer = CompositorData::new_layer(pipeline.clone(), layer_properties, - WantsScrollEvents, + WantsScrollEventsFlag::WantsScrollEvents, opts::get().tile_size); // All root layers mask to bounds. @@ -1239,7 +1238,7 @@ impl CompositorEventListener for IOCompositor where Window: Wind } } - if self.shutdown_state == FinishedShuttingDown { + if self.shutdown_state == ShutdownState::FinishedShuttingDown { // We have exited the compositor and passing window // messages to script may crash. debug!("Exiting the compositor due to a request from script."); @@ -1257,11 +1256,11 @@ impl CompositorEventListener for IOCompositor where Window: Wind } match self.composition_request { - NoCompositingNecessary | CompositeOnScrollTimeout(_) => {} - CompositeNow => self.composite(), + CompositionRequest::NoCompositingNecessary | CompositionRequest::CompositeOnScrollTimeout(_) => {} + CompositionRequest::CompositeNow => self.composite(), } - self.shutdown_state != FinishedShuttingDown + self.shutdown_state != ShutdownState::FinishedShuttingDown } /// Repaints and recomposites synchronously. You must be careful when calling this, as if a @@ -1269,10 +1268,10 @@ impl CompositorEventListener for IOCompositor where Window: Wind /// /// This is used when resizing the window. fn repaint_synchronously(&mut self) { - while self.shutdown_state != ShuttingDown { + while self.shutdown_state != ShutdownState::ShuttingDown { let msg = self.port.recv_compositor_msg(); let is_paint = match msg { - Paint(..) => true, + Msg::Paint(..) => true, _ => false, }; let keep_going = self.handle_browser_message(msg); @@ -1299,10 +1298,10 @@ impl CompositorEventListener for IOCompositor where Window: Wind // Tell the profiler, memory profiler, and scrolling timer to shut down. let TimeProfilerChan(ref time_profiler_chan) = self.time_profiler_chan; - time_profiler_chan.send(time::ExitMsg); + time_profiler_chan.send(time::TimeProfilerMsg::Exit); let MemoryProfilerChan(ref memory_profiler_chan) = self.memory_profiler_chan; - memory_profiler_chan.send(memory::ExitMsg); + memory_profiler_chan.send(memory::MemoryProfilerMsg::Exit); self.scrolling_timer.shutdown(); } diff --git a/components/compositing/compositor_layer.rs b/components/compositing/compositor_layer.rs index 804ebb8625a..00324bd34c4 100644 --- a/components/compositing/compositor_layer.rs +++ b/components/compositing/compositor_layer.rs @@ -4,9 +4,7 @@ use compositor_task::LayerProperties; use pipeline::CompositionPipeline; -use windowing::{MouseWindowEvent, MouseWindowClickEvent, MouseWindowMouseDownEvent}; -use windowing::MouseWindowMouseUpEvent; -use windowing::WindowMethods; +use windowing::{MouseWindowEvent, WindowMethods}; use azure::azure_hl; use geom::length::Length; @@ -22,6 +20,8 @@ use layers::platform::surface::NativeSurfaceMethods; use script_traits::{ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent, SendEventMsg}; use script_traits::{ScriptControlChan}; use servo_msg::compositor_msg::{Epoch, FixedPosition, LayerId, ScrollPolicy}; +use std::num::Float; +use std::num::FloatMath; use std::rc::Rc; pub struct CompositorData { @@ -117,6 +117,9 @@ pub trait CompositorLayer { fn scroll_layer_and_all_child_layers(&self, new_offset: TypedPoint2D) -> bool; + + /// Return a flag describing how this layer deals with scroll events. + fn wants_scroll_events(&self) -> WantsScrollEventsFlag; } #[deriving(PartialEq, Clone)] @@ -260,8 +263,8 @@ impl CompositorLayer for Layer { -> ScrollEventResult { // If this layer doesn't want scroll events, neither it nor its children can handle scroll // events. - if self.extra_data.borrow().wants_scroll_events != WantsScrollEvents { - return ScrollEventUnhandled; + if self.wants_scroll_events() != WantsScrollEventsFlag::WantsScrollEvents { + return ScrollEventResult::ScrollEventUnhandled; } //// Allow children to scroll. @@ -271,7 +274,7 @@ impl CompositorLayer for Layer { let child_bounds = child.bounds.borrow(); if child_bounds.contains(&new_cursor) { let result = child.handle_scroll_event(delta, new_cursor - child_bounds.origin); - if result != ScrollEventUnhandled { + if result != ScrollEventResult::ScrollEventUnhandled { return result; } } @@ -292,7 +295,7 @@ impl CompositorLayer for Layer { Length(new_offset.y.get().clamp(&min_y, &0.0))); if self.extra_data.borrow().scroll_offset == new_offset { - return ScrollPositionUnchanged; + return ScrollEventResult::ScrollPositionUnchanged; } // The scroll offset is just a record of the scroll position of this scrolling root, @@ -305,9 +308,9 @@ impl CompositorLayer for Layer { } if result { - return ScrollPositionChanged; + return ScrollEventResult::ScrollPositionChanged; } else { - return ScrollPositionUnchanged; + return ScrollEventResult::ScrollPositionUnchanged; } } @@ -316,9 +319,12 @@ impl CompositorLayer for Layer { cursor: TypedPoint2D) { let event_point = cursor.to_untyped(); let message = match event { - MouseWindowClickEvent(button, _) => ClickEvent(button, event_point), - MouseWindowMouseDownEvent(button, _) => MouseDownEvent(button, event_point), - MouseWindowMouseUpEvent(button, _) => MouseUpEvent(button, event_point), + MouseWindowEvent::MouseWindowClickEvent(button, _) => + ClickEvent(button, event_point), + MouseWindowEvent::MouseWindowMouseDownEvent(button, _) => + MouseDownEvent(button, event_point), + MouseWindowEvent::MouseWindowMouseUpEvent(button, _) => + MouseUpEvent(button, event_point), }; let pipeline = &self.extra_data.borrow().pipeline; let ScriptControlChan(ref chan) = pipeline.script_chan; @@ -356,4 +362,8 @@ impl CompositorLayer for Layer { return result; } + fn wants_scroll_events(&self) -> WantsScrollEventsFlag { + self.extra_data.borrow().wants_scroll_events + } + } diff --git a/components/compositing/compositor_task.rs b/components/compositing/compositor_task.rs index 733637b1b95..0fc99cc1884 100644 --- a/components/compositing/compositor_task.rs +++ b/components/compositing/compositor_task.rs @@ -62,7 +62,7 @@ impl CompositorReceiver for Receiver { /// Implementation of the abstract `ScriptListener` interface. impl ScriptListener for Box { fn set_ready_state(&mut self, pipeline_id: PipelineId, ready_state: ReadyState) { - let msg = ChangeReadyState(pipeline_id, ready_state); + let msg = Msg::ChangeReadyState(pipeline_id, ready_state); self.send(msg); } @@ -70,12 +70,12 @@ impl ScriptListener for Box { pipeline_id: PipelineId, layer_id: LayerId, point: Point2D) { - self.send(ScrollFragmentPoint(pipeline_id, layer_id, point)); + self.send(Msg::ScrollFragmentPoint(pipeline_id, layer_id, point)); } fn close(&mut self) { let (chan, port) = channel(); - self.send(Exit(chan)); + self.send(Msg::Exit(chan)); port.recv(); } @@ -84,12 +84,12 @@ impl ScriptListener for Box { } fn set_title(&mut self, pipeline_id: PipelineId, title: Option) { - self.send(ChangePageTitle(pipeline_id, title)) + self.send(Msg::ChangePageTitle(pipeline_id, title)) } fn send_key_event(&mut self, key: Key, state: KeyState, modifiers: KeyModifiers) { if state == Pressed { - self.send(KeyEvent(key, modifiers)); + self.send(Msg::KeyEvent(key, modifiers)); } } } @@ -124,7 +124,7 @@ impl LayerProperties { impl PaintListener for Box { fn get_graphics_metadata(&mut self) -> Option { let (chan, port) = channel(); - self.send(GetGraphicsMetadata(chan)); + self.send(Msg::GetGraphicsMetadata(chan)); port.recv() } @@ -132,7 +132,7 @@ impl PaintListener for Box { pipeline_id: PipelineId, epoch: Epoch, replies: Vec<(LayerId, Box)>) { - self.send(Paint(pipeline_id, epoch, replies)); + self.send(Msg::Paint(pipeline_id, epoch, replies)); } fn initialize_layers_for_pipeline(&mut self, @@ -146,20 +146,20 @@ impl PaintListener for Box { for metadata in metadata.iter() { let layer_properties = LayerProperties::new(pipeline_id, epoch, metadata); if first { - self.send(CreateOrUpdateRootLayer(layer_properties)); + self.send(Msg::CreateOrUpdateRootLayer(layer_properties)); first = false } else { - self.send(CreateOrUpdateDescendantLayer(layer_properties)); + self.send(Msg::CreateOrUpdateDescendantLayer(layer_properties)); } } } fn paint_msg_discarded(&mut self) { - self.send(PaintMsgDiscarded); + self.send(Msg::PaintMsgDiscarded); } fn set_paint_state(&mut self, pipeline_id: PipelineId, paint_state: PaintState) { - self.send(ChangePaintState(pipeline_id, paint_state)) + self.send(Msg::ChangePaintState(pipeline_id, paint_state)) } } @@ -205,7 +205,7 @@ pub enum Msg { /// Sets the channel to the current layout and paint tasks, along with their ID. SetIds(SendableFrameTree, Sender<()>, ConstellationChan), /// Sends an updated version of the frame tree. - FrameTreeUpdateMsg(FrameTreeDiff, Sender<()>), + FrameTreeUpdate(FrameTreeDiff, Sender<()>), /// The load of a page has completed. LoadComplete, /// Indicates that the scrolling timeout with the given starting timestamp has happened and a @@ -218,24 +218,24 @@ pub enum Msg { impl Show for Msg { fn fmt(&self, f: &mut Formatter) -> Result<(),FormatError> { match *self { - Exit(..) => write!(f, "Exit"), - ShutdownComplete(..) => write!(f, "ShutdownComplete"), - GetGraphicsMetadata(..) => write!(f, "GetGraphicsMetadata"), - CreateOrUpdateRootLayer(..) => write!(f, "CreateOrUpdateRootLayer"), - CreateOrUpdateDescendantLayer(..) => write!(f, "CreateOrUpdateDescendantLayer"), - SetLayerOrigin(..) => write!(f, "SetLayerOrigin"), - ScrollFragmentPoint(..) => write!(f, "ScrollFragmentPoint"), - Paint(..) => write!(f, "Paint"), - ChangeReadyState(..) => write!(f, "ChangeReadyState"), - ChangePaintState(..) => write!(f, "ChangePaintState"), - ChangePageTitle(..) => write!(f, "ChangePageTitle"), - ChangePageLoadData(..) => write!(f, "ChangePageLoadData"), - PaintMsgDiscarded(..) => write!(f, "PaintMsgDiscarded"), - SetIds(..) => write!(f, "SetIds"), - FrameTreeUpdateMsg(..) => write!(f, "FrameTreeUpdateMsg"), - LoadComplete => write!(f, "LoadComplete"), - ScrollTimeout(..) => write!(f, "ScrollTimeout"), - KeyEvent(..) => write!(f, "KeyEvent"), + Msg::Exit(..) => write!(f, "Exit"), + Msg::ShutdownComplete(..) => write!(f, "ShutdownComplete"), + Msg::GetGraphicsMetadata(..) => write!(f, "GetGraphicsMetadata"), + Msg::CreateOrUpdateRootLayer(..) => write!(f, "CreateOrUpdateRootLayer"), + Msg::CreateOrUpdateDescendantLayer(..) => write!(f, "CreateOrUpdateDescendantLayer"), + Msg::SetLayerOrigin(..) => write!(f, "SetLayerOrigin"), + Msg::ScrollFragmentPoint(..) => write!(f, "ScrollFragmentPoint"), + Msg::Paint(..) => write!(f, "Paint"), + Msg::ChangeReadyState(..) => write!(f, "ChangeReadyState"), + Msg::ChangePaintState(..) => write!(f, "ChangePaintState"), + Msg::ChangePageTitle(..) => write!(f, "ChangePageTitle"), + Msg::ChangePageLoadData(..) => write!(f, "ChangePageLoadData"), + Msg::PaintMsgDiscarded(..) => write!(f, "PaintMsgDiscarded"), + Msg::SetIds(..) => write!(f, "SetIds"), + Msg::FrameTreeUpdate(..) => write!(f, "FrameTreeUpdateMsg"), + Msg::LoadComplete => write!(f, "LoadComplete"), + Msg::ScrollTimeout(..) => write!(f, "ScrollTimeout"), + Msg::KeyEvent(..) => write!(f, "KeyEvent"), } } } diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs index 44f26e97565..fe756a5c7b9 100644 --- a/components/compositing/constellation.rs +++ b/components/compositing/constellation.rs @@ -4,8 +4,8 @@ use pipeline::{Pipeline, CompositionPipeline}; -use compositor_task::{ChangePageLoadData, ChangePageTitle, CompositorProxy, FrameTreeUpdateMsg}; -use compositor_task::{LoadComplete, SetLayerOrigin, SetIds, ShutdownComplete}; +use compositor_task::CompositorProxy; +use compositor_task::Msg as CompositorMsg; use devtools_traits; use devtools_traits::DevtoolsControlChan; use geom::rect::{Rect, TypedRect}; @@ -22,9 +22,10 @@ use servo_msg::constellation_msg::{ConstellationChan, ExitMsg, FailureMsg, Failu use servo_msg::constellation_msg::{GetPipelineTitleMsg}; use servo_msg::constellation_msg::{IFrameSandboxState, IFrameUnsandboxed, InitLoadUrlMsg}; use servo_msg::constellation_msg::{KeyEvent, Key, KeyState, KeyModifiers, LoadCompleteMsg}; -use servo_msg::constellation_msg::{LoadData, LoadUrlMsg, Msg, NavigateMsg, NavigationType}; +use servo_msg::constellation_msg::{LoadData, LoadUrlMsg, NavigateMsg, NavigationType}; use servo_msg::constellation_msg::{PainterReadyMsg, PipelineId, ResizedWindowMsg}; use servo_msg::constellation_msg::{ScriptLoadedURLInIFrameMsg, SubpageId, WindowSizeData}; +use servo_msg::constellation_msg::Msg as ConstellationMsg; use servo_msg::constellation_msg; use servo_net::image_cache_task::{ImageCacheTask, ImageCacheTaskClient}; use servo_net::resource_task::ResourceTask; @@ -48,7 +49,7 @@ pub struct Constellation { pub chan: ConstellationChan, /// Receives messages. - pub request_port: Receiver, + pub request_port: Receiver, /// A channel (the implementation of which is port-specific) through which messages can be sent /// to the compositor. @@ -203,12 +204,12 @@ impl FrameTreeTraversal for Rc { match child { Some(child) => { *new_child.parent.borrow_mut() = child.frame_tree.parent.borrow().clone(); - return ReplacedNode(replace(&mut child.frame_tree, new_child)); + return ReplaceResult::ReplacedNode(replace(&mut child.frame_tree, new_child)); } None => (), } } - OriginalNode(new_child) + ReplaceResult::OriginalNode(new_child) } fn iter(&self) -> FrameTreeIterator { @@ -333,8 +334,9 @@ impl NavigationContext { /// compositor of the new URLs. fn set_current(&mut self, new_frame: Rc, compositor_proxy: &mut CompositorProxy) { self.current = Some(new_frame.clone()); - compositor_proxy.send(ChangePageLoadData(new_frame.id, - new_frame.pipeline.load_data.clone())); + compositor_proxy.send(CompositorMsg::ChangePageLoadData( + new_frame.id, + new_frame.pipeline.load_data.clone())); } } @@ -442,7 +444,7 @@ impl Constellation { } /// Handles loading pages, navigation, and granting access to the compositor - fn handle_request(&mut self, request: Msg) -> bool { + fn handle_request(&mut self, request: ConstellationMsg) -> bool { match request { ExitMsg => { debug!("constellation exiting"); @@ -481,7 +483,7 @@ impl Constellation { // script, and reflow messages have been sent. LoadCompleteMsg => { debug!("constellation got load complete message"); - self.compositor_proxy.send(LoadComplete); + self.compositor_proxy.send(CompositorMsg::LoadComplete); } // Handle a forward or back request NavigateMsg(direction) => { @@ -520,7 +522,7 @@ impl Constellation { }); self.storage_task.send(storage_task::Exit); self.font_cache_task.exit(); - self.compositor_proxy.send(ShutdownComplete); + self.compositor_proxy.send(CompositorMsg::ShutdownComplete); } fn handle_failure_msg(&mut self, pipeline_id: PipelineId, subpage_id: Option) { @@ -681,9 +683,10 @@ impl Constellation { initial_viewport: rect.size * ScaleFactor(1.0), device_pixel_ratio: device_pixel_ratio, })); - compositor_proxy.send(SetLayerOrigin(pipeline.id, - LayerId::null(), - rect.to_untyped().origin)); + compositor_proxy.send(CompositorMsg::SetLayerOrigin( + pipeline.id, + LayerId::null(), + rect.to_untyped().origin)); } else { already_sent.insert(pipeline.id); } @@ -843,7 +846,7 @@ impl Constellation { fn handle_get_pipeline_title_msg(&mut self, pipeline_id: PipelineId) { match self.pipelines.get(&pipeline_id) { - None => self.compositor_proxy.send(ChangePageTitle(pipeline_id, None)), + None => self.compositor_proxy.send(CompositorMsg::ChangePageTitle(pipeline_id, None)), Some(pipeline) => { let ScriptControlChan(ref script_channel) = pipeline.script_chan; script_channel.send(GetTitleMsg(pipeline_id)); @@ -1018,7 +1021,9 @@ impl Constellation { fn set_ids(&mut self, frame_tree: &Rc) { let (chan, port) = channel(); debug!("Constellation sending SetIds"); - self.compositor_proxy.send(SetIds(frame_tree.to_sendable(), chan, self.chan.clone())); + self.compositor_proxy.send(CompositorMsg::SetIds(frame_tree.to_sendable(), + chan, + self.chan.clone())); match port.recv_opt() { Ok(()) => { let mut iter = frame_tree.iter(); @@ -1075,7 +1080,7 @@ impl Constellation { }; let (chan, port) = channel(); - self.compositor_proxy.send(FrameTreeUpdateMsg(sendable_frame_tree_diff, chan)); + self.compositor_proxy.send(CompositorMsg::FrameTreeUpdate(sendable_frame_tree_diff, chan)); match port.recv_opt() { Ok(()) => { child.frame_tree.has_compositor_layer.set(true); diff --git a/components/compositing/headless.rs b/components/compositing/headless.rs index c9cf6a25132..4a9ed6d5c56 100644 --- a/components/compositing/headless.rs +++ b/components/compositing/headless.rs @@ -2,11 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use compositor_task::{GetGraphicsMetadata, CreateOrUpdateRootLayer, CreateOrUpdateDescendantLayer}; -use compositor_task::{Exit, ChangeReadyState, LoadComplete, Paint, ScrollFragmentPoint, SetIds}; -use compositor_task::{SetLayerOrigin, ShutdownComplete, ChangePaintState, PaintMsgDiscarded}; -use compositor_task::{CompositorEventListener, CompositorReceiver, ScrollTimeout, ChangePageTitle}; -use compositor_task::{ChangePageLoadData, FrameTreeUpdateMsg, KeyEvent}; +use compositor_task::{CompositorEventListener, CompositorReceiver, Msg}; use windowing::WindowEvent; use geom::scale_factor::ScaleFactor; @@ -73,27 +69,27 @@ impl NullCompositor { impl CompositorEventListener for NullCompositor { fn handle_event(&mut self, _: WindowEvent) -> bool { match self.port.recv_compositor_msg() { - Exit(chan) => { + Msg::Exit(chan) => { debug!("shutting down the constellation"); let ConstellationChan(ref con_chan) = self.constellation_chan; con_chan.send(ExitMsg); chan.send(()); } - ShutdownComplete => { + Msg::ShutdownComplete => { debug!("constellation completed shutdown"); return false } - GetGraphicsMetadata(chan) => { + Msg::GetGraphicsMetadata(chan) => { chan.send(None); } - SetIds(_, response_chan, _) => { + Msg::SetIds(_, response_chan, _) => { response_chan.send(()); } - FrameTreeUpdateMsg(_, response_channel) => { + Msg::FrameTreeUpdate(_, response_channel) => { response_channel.send(()); } @@ -101,12 +97,12 @@ impl CompositorEventListener for NullCompositor { // we'll notice and think about whether it needs a response, like // SetIds. - CreateOrUpdateRootLayer(..) | - CreateOrUpdateDescendantLayer(..) | - SetLayerOrigin(..) | Paint(..) | - ChangeReadyState(..) | ChangePaintState(..) | ScrollFragmentPoint(..) | - LoadComplete | PaintMsgDiscarded(..) | ScrollTimeout(..) | ChangePageTitle(..) | - ChangePageLoadData(..) | KeyEvent(..) => () + Msg::CreateOrUpdateRootLayer(..) | + Msg::CreateOrUpdateDescendantLayer(..) | + Msg::SetLayerOrigin(..) | Msg::Paint(..) | + Msg::ChangeReadyState(..) | Msg::ChangePaintState(..) | Msg::ScrollFragmentPoint(..) | + Msg::LoadComplete | Msg::PaintMsgDiscarded(..) | Msg::ScrollTimeout(..) | Msg::ChangePageTitle(..) | + Msg::ChangePageLoadData(..) | Msg::KeyEvent(..) => () } true } @@ -118,8 +114,8 @@ impl CompositorEventListener for NullCompositor { // another task from finishing (i.e. SetIds) while self.port.try_recv_compositor_msg().is_some() {} - self.time_profiler_chan.send(time::ExitMsg); - self.memory_profiler_chan.send(memory::ExitMsg); + self.time_profiler_chan.send(time::TimeProfilerMsg::Exit); + self.memory_profiler_chan.send(memory::MemoryProfilerMsg::Exit); } fn pinch_zoom_level(&self) -> f32 { diff --git a/components/compositing/scrolling.rs b/components/compositing/scrolling.rs index d3dfb6a8fdb..d36674b69e9 100644 --- a/components/compositing/scrolling.rs +++ b/components/compositing/scrolling.rs @@ -4,7 +4,7 @@ //! A timer thread that gives the painting task a little time to catch up when the user scrolls. -use compositor_task::{CompositorProxy, ScrollTimeout}; +use compositor_task::{CompositorProxy, Msg}; use native::task::NativeTaskBuilder; use std::io::timer; @@ -47,11 +47,11 @@ impl ScrollingTimerProxy { } pub fn scroll_event_processed(&mut self, timestamp: u64) { - self.sender.send(ScrollEventProcessedMsg(timestamp)) + self.sender.send(ToScrollingTimerMsg::ScrollEventProcessedMsg(timestamp)) } pub fn shutdown(&mut self) { - self.sender.send(ExitMsg); + self.sender.send(ToScrollingTimerMsg::ExitMsg); } } @@ -59,13 +59,13 @@ impl ScrollingTimer { pub fn run(&mut self) { loop { match self.receiver.recv_opt() { - Ok(ScrollEventProcessedMsg(timestamp)) => { + Ok(ToScrollingTimerMsg::ScrollEventProcessedMsg(timestamp)) => { let target = timestamp as i64 + TIMEOUT; let delta = target - (time::precise_time_ns() as i64); timer::sleep(Duration::nanoseconds(delta)); - self.compositor_proxy.send(ScrollTimeout(timestamp)); + self.compositor_proxy.send(Msg::ScrollTimeout(timestamp)); } - Ok(ExitMsg) | Err(_) => break, + Ok(ToScrollingTimerMsg::ExitMsg) | Err(_) => break, } } } diff --git a/components/compositing/windowing.rs b/components/compositing/windowing.rs index fdfc93c559e..e33a5f9fe75 100644 --- a/components/compositing/windowing.rs +++ b/components/compositing/windowing.rs @@ -36,32 +36,32 @@ pub enum WindowEvent { /// FIXME(pcwalton): This is kind of ugly and may not work well with multiprocess Servo. /// It's possible that this should be something like /// `CompositorMessageWindowEvent(compositor_task::Msg)` instead. - IdleWindowEvent, + Idle, /// Sent when part of the window is marked dirty and needs to be redrawn. Before sending this /// message, the window must make the same GL context as in `PrepareRenderingEvent` current. - RefreshWindowEvent, + Refresh, /// Sent to initialize the GL context. The windowing system must have a valid, current GL /// context when this message is sent. - InitializeCompositingWindowEvent, + InitializeCompositing, /// Sent when the window is resized. - ResizeWindowEvent(TypedSize2D), + Resize(TypedSize2D), /// Sent when a new URL is to be loaded. - LoadUrlWindowEvent(String), + LoadUrl(String), /// Sent when a mouse hit test is to be performed. MouseWindowEventClass(MouseWindowEvent), /// Sent when a mouse move. MouseWindowMoveEventClass(TypedPoint2D), /// Sent when the user scrolls. The first point is the delta and the second point is the /// origin. - ScrollWindowEvent(TypedPoint2D, TypedPoint2D), + Scroll(TypedPoint2D, TypedPoint2D), /// Sent when the user zooms. - ZoomWindowEvent(f32), + Zoom(f32), /// Simulated "pinch zoom" gesture for non-touch platforms (e.g. ctrl-scrollwheel). - PinchZoomWindowEvent(f32), + PinchZoom(f32), /// Sent when the user uses chrome navigation (i.e. backspace or shift-backspace). - NavigationWindowEvent(WindowNavigateMsg), + Navigation(WindowNavigateMsg), /// Sent when the user quits the application - QuitWindowEvent, + Quit, /// Sent when a key input state changes KeyEvent(Key, KeyState, KeyModifiers), } @@ -69,19 +69,19 @@ pub enum WindowEvent { impl Show for WindowEvent { fn fmt(&self, f: &mut Formatter) -> Result<(),FormatError> { match *self { - IdleWindowEvent => write!(f, "Idle"), - RefreshWindowEvent => write!(f, "Refresh"), - InitializeCompositingWindowEvent => write!(f, "InitializeCompositing"), - ResizeWindowEvent(..) => write!(f, "Resize"), - KeyEvent(..) => write!(f, "Key"), - LoadUrlWindowEvent(..) => write!(f, "LoadUrl"), - MouseWindowEventClass(..) => write!(f, "Mouse"), - MouseWindowMoveEventClass(..) => write!(f, "MouseMove"), - ScrollWindowEvent(..) => write!(f, "Scroll"), - ZoomWindowEvent(..) => write!(f, "Zoom"), - PinchZoomWindowEvent(..) => write!(f, "PinchZoom"), - NavigationWindowEvent(..) => write!(f, "Navigation"), - QuitWindowEvent => write!(f, "Quit"), + WindowEvent::Idle => write!(f, "Idle"), + WindowEvent::Refresh => write!(f, "Refresh"), + WindowEvent::InitializeCompositing => write!(f, "InitializeCompositing"), + WindowEvent::Resize(..) => write!(f, "Resize"), + WindowEvent::KeyEvent(..) => write!(f, "Key"), + WindowEvent::LoadUrl(..) => write!(f, "LoadUrl"), + WindowEvent::MouseWindowEventClass(..) => write!(f, "Mouse"), + WindowEvent::MouseWindowMoveEventClass(..) => write!(f, "MouseMove"), + WindowEvent::Scroll(..) => write!(f, "Scroll"), + WindowEvent::Zoom(..) => write!(f, "Zoom"), + WindowEvent::PinchZoom(..) => write!(f, "PinchZoom"), + WindowEvent::Navigation(..) => write!(f, "Navigation"), + WindowEvent::Quit => write!(f, "Quit"), } } } diff --git a/components/devtools/actors/console.rs b/components/devtools/actors/console.rs index 545fbb34e78..3e0c934bddb 100644 --- a/components/devtools/actors/console.rs +++ b/components/devtools/actors/console.rs @@ -18,6 +18,7 @@ use core::cell::RefCell; use serialize::json; use serialize::json::ToJson; use std::io::TcpStream; +use std::num::Float; #[deriving(Encodable)] struct StartedListenersTraits { diff --git a/components/devtools/actors/inspector.rs b/components/devtools/actors/inspector.rs index 471e379e693..f35ae3d9f40 100644 --- a/components/devtools/actors/inspector.rs +++ b/components/devtools/actors/inspector.rs @@ -16,6 +16,7 @@ use serialize::json; use serialize::json::ToJson; use std::cell::RefCell; use std::io::TcpStream; +use std::num::Float; pub struct InspectorActor { pub name: String, diff --git a/components/gfx/Cargo.toml b/components/gfx/Cargo.toml index 0c0f84ec105..dbdd1246897 100644 --- a/components/gfx/Cargo.toml +++ b/components/gfx/Cargo.toml @@ -62,3 +62,5 @@ git = "https://github.com/servo/rust-core-text" [dependencies.script_traits] path = "../script_traits" +[dependencies.time] +git = "https://github.com/rust-lang/time" diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs index df998d42da6..b0cb1e609a6 100644 --- a/components/gfx/display_list/mod.rs +++ b/components/gfx/display_list/mod.rs @@ -14,6 +14,9 @@ //! They are therefore not exactly analogous to constructs like Skia pictures, which consist of //! low-level drawing primitives. +use self::DisplayItem::*; +use self::DisplayItemIterator::*; + use color::Color; use display_list::optimizer::DisplayListOptimizer; use paint_context::{PaintContext, ToAzureRect}; diff --git a/components/gfx/font_cache_task.rs b/components/gfx/font_cache_task.rs index 3af5bd0d8d4..ec724c87f26 100644 --- a/components/gfx/font_cache_task.rs +++ b/components/gfx/font_cache_task.rs @@ -2,6 +2,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +use self::Command::*; +use self::Reply::*; + use platform::font_list::get_available_families; use platform::font_list::get_system_default_family; use platform::font_list::get_variations_for_family; @@ -16,7 +19,7 @@ use platform::font_template::FontTemplateData; use servo_net::resource_task::{ResourceTask, load_whole_resource}; use servo_util::task::spawn_named; use servo_util::str::LowercaseString; -use style::{Source, LocalSource, UrlSource_}; +use style::Source; /// A list of font templates that make up a given font family. struct FontFamily { @@ -128,7 +131,7 @@ impl FontCache { } match src { - UrlSource_(ref url_source) => { + Source::Url(ref url_source) => { let url = &url_source.url; let maybe_resource = load_whole_resource(&self.resource_task, url.clone()); match maybe_resource { @@ -141,7 +144,7 @@ impl FontCache { } } } - LocalSource(ref local_family_name) => { + Source::Local(ref local_family_name) => { let family = &mut self.web_families[family_name]; get_variations_for_family(local_family_name.as_slice(), |path| { family.add_template(path.as_slice(), None); diff --git a/components/gfx/paint_context.rs b/components/gfx/paint_context.rs index f34b62559f8..81cbd806fbc 100644 --- a/components/gfx/paint_context.rs +++ b/components/gfx/paint_context.rs @@ -13,8 +13,8 @@ use azure::azure_hl::{StrokeOptions}; use azure::scaled_font::ScaledFont; use azure::{AZ_CAP_BUTT, AzFloat, struct__AzDrawOptions, struct__AzGlyph}; use azure::{struct__AzGlyphBuffer, struct__AzPoint, AzDrawTargetFillGlyphs}; -use display_list::{BOX_SHADOW_INFLATION_FACTOR, BorderRadii, SidewaysLeft, SidewaysRight}; -use display_list::{TextDisplayItem, Upright}; +use display_list::{BOX_SHADOW_INFLATION_FACTOR, TextDisplayItem, BorderRadii}; +use display_list::TextOrientation::{SidewaysLeft, SidewaysRight, Upright}; use font_context::FontContext; use geom::matrix2d::Matrix2D; use geom::point::Point2D; @@ -86,10 +86,10 @@ impl<'a> PaintContext<'a> { self.draw_target.make_current(); - self.draw_border_segment(Top, bounds, border, &radius, color, style); - self.draw_border_segment(Right, bounds, border, &radius, color, style); - self.draw_border_segment(Bottom, bounds, border, &radius, color, style); - self.draw_border_segment(Left, bounds, border, &radius, color, style); + self.draw_border_segment(Direction::Top, bounds, border, &radius, color, style); + self.draw_border_segment(Direction::Right, bounds, border, &radius, color, style); + self.draw_border_segment(Direction::Bottom, bounds, border, &radius, color, style); + self.draw_border_segment(Direction::Left, bounds, border, &radius, color, style); } pub fn draw_line(&self, @@ -171,10 +171,10 @@ impl<'a> PaintContext<'a> { color: SideOffsets2D, style: SideOffsets2D) { let (style_select, color_select) = match direction { - Top => (style.top, color.top), - Left => (style.left, color.left), - Right => (style.right, color.right), - Bottom => (style.bottom, color.bottom) + Direction::Top => (style.top, color.top), + Direction::Left => (style.left, color.left), + Direction::Right => (style.right, color.right), + Direction::Bottom => (style.bottom, color.bottom) }; match style_select{ @@ -184,10 +184,10 @@ impl<'a> PaintContext<'a> { } //FIXME(sammykim): This doesn't work with dash_pattern and cap_style well. I referred firefox code. border_style::dotted => { - self.draw_dashed_border_segment(direction, bounds, border, color_select, DottedBorder); + self.draw_dashed_border_segment(direction, bounds, border, color_select, DashSize::DottedBorder); } border_style::dashed => { - self.draw_dashed_border_segment(direction, bounds, border, color_select, DashedBorder); + self.draw_dashed_border_segment(direction, bounds, border, color_select, DashSize::DashedBorder); } border_style::solid => { self.draw_solid_border_segment(direction,bounds,border,radius,color_select); @@ -210,22 +210,22 @@ impl<'a> PaintContext<'a> { match style { border_style::none | border_style::hidden => {} border_style::dotted => { - self.draw_dashed_border_segment(Right, bounds, border, color, DottedBorder); + self.draw_dashed_border_segment(Direction::Right, bounds, border, color, DashSize::DottedBorder); } border_style::dashed => { - self.draw_dashed_border_segment(Right, bounds, border, color, DashedBorder); + self.draw_dashed_border_segment(Direction::Right, bounds, border, color, DashSize::DashedBorder); } border_style::solid => { - self.draw_solid_border_segment(Right, bounds, border, radius, color); + self.draw_solid_border_segment(Direction::Right, bounds, border, radius, color); } border_style::double => { - self.draw_double_border_segment(Right, bounds, border, radius, color); + self.draw_double_border_segment(Direction::Right, bounds, border, radius, color); } border_style::groove | border_style::ridge => { - self.draw_groove_ridge_border_segment(Right, bounds, border, radius, color, style); + self.draw_groove_ridge_border_segment(Direction::Right, bounds, border, radius, color, style); } border_style::inset | border_style::outset => { - self.draw_inset_outset_border_segment(Right, bounds, border, radius, color, style); + self.draw_inset_outset_border_segment(Direction::Right, bounds, border, radius, color, style); } } } @@ -354,7 +354,7 @@ impl<'a> PaintContext<'a> { } match direction { - Top => { + Direction::Top => { let edge_TL = box_TL + dx(radius.top_left.max(border.left)); let edge_TR = box_TR + dx(-radius.top_right.max(border.right)); let edge_BR = edge_TR + dy(border.top); @@ -387,7 +387,7 @@ impl<'a> PaintContext<'a> { path_builder.arc(origin, radius.top_left, rad_TL, rad_T, false); } } - Left => { + Direction::Left => { let edge_TL = box_TL + dy(radius.top_left.max(border.top)); let edge_BL = box_BL + dy(-radius.bottom_left.max(border.bottom)); let edge_TR = edge_TL + dx(border.left); @@ -418,7 +418,7 @@ impl<'a> PaintContext<'a> { path_builder.arc(origin, radius.bottom_left, rad_BL, rad_L, false); } } - Right => { + Direction::Right => { let edge_TR = box_TR + dy(radius.top_right.max(border.top)); let edge_BR = box_BR + dy(-radius.bottom_right.max(border.bottom)); let edge_TL = edge_TR + dx(-border.right); @@ -449,7 +449,7 @@ impl<'a> PaintContext<'a> { path_builder.arc(origin, distance_to_elbow, rad_BR, rad_R, true); } } - Bottom => { + Direction::Bottom => { let edge_BL = box_BL + dx(radius.bottom_left.max(border.left)); let edge_BR = box_BR + dx(-radius.bottom_right.max(border.right)); let edge_TL = edge_BL + dy(-border.bottom); @@ -500,10 +500,10 @@ impl<'a> PaintContext<'a> { stroke_opts.set_cap_style(AZ_CAP_BUTT as u8); let border_width = match direction { - Top => border.top, - Left => border.left, - Right => border.right, - Bottom => border.bottom + Direction::Top => border.top, + Direction::Left => border.left, + Direction::Right => border.right, + Direction::Bottom => border.bottom }; stroke_opts.line_width = border_width; @@ -513,25 +513,25 @@ impl<'a> PaintContext<'a> { stroke_opts.mDashLength = dash.len() as size_t; let (start, end) = match direction { - Top => { + Direction::Top => { let y = rect.origin.y + border.top * 0.5; let start = Point2D(rect.origin.x, y); let end = Point2D(rect.origin.x + rect.size.width, y); (start, end) } - Left => { + Direction::Left => { let x = rect.origin.x + border.left * 0.5; let start = Point2D(x, rect.origin.y + rect.size.height); let end = Point2D(x, rect.origin.y + border.top); (start, end) } - Right => { + Direction::Right => { let x = rect.origin.x + rect.size.width - border.right * 0.5; let start = Point2D(x, rect.origin.y); let end = Point2D(x, rect.origin.y + rect.size.height); (start, end) } - Bottom => { + Direction::Bottom => { let y = rect.origin.y + rect.size.height - border.bottom * 0.5; let start = Point2D(rect.origin.x + rect.size.width, y); let end = Point2D(rect.origin.x + border.left, y); @@ -617,8 +617,10 @@ impl<'a> PaintContext<'a> { } let (outer_color, inner_color) = match (direction, is_groove) { - (Top, true) | (Left, true) | (Right, false) | (Bottom, false) => (darker_color, lighter_color), - (Top, false) | (Left, false) | (Right, true) | (Bottom, true) => (lighter_color, darker_color) + (Direction::Top, true) | (Direction::Left, true) | + (Direction::Right, false) | (Direction::Bottom, false) => (darker_color, lighter_color), + (Direction::Top, false) | (Direction::Left, false) | + (Direction::Right, true) | (Direction::Bottom, true) => (lighter_color, darker_color) }; // outer portion of the border self.draw_border_path(&original_bounds, direction, scaled_border, radius, outer_color); @@ -642,8 +644,8 @@ impl<'a> PaintContext<'a> { let original_bounds = self.get_scaled_bounds(bounds, border, 0.0); // select and scale the color appropriately. let scaled_color = match direction { - Top | Left => self.scale_color(color, if is_inset { 2.0/3.0 } else { 1.0 }), - Right | Bottom => self.scale_color(color, if is_inset { 1.0 } else { 2.0/3.0 }) + Direction::Top | Direction::Left => self.scale_color(color, if is_inset { 2.0/3.0 } else { 1.0 }), + Direction::Right | Direction::Bottom => self.scale_color(color, if is_inset { 1.0 } else { 2.0/3.0 }) }; self.draw_border_path(&original_bounds, direction, border, radius, scaled_color); } diff --git a/components/gfx/paint_task.rs b/components/gfx/paint_task.rs index 2f1dad3b436..d6a6010701b 100644 --- a/components/gfx/paint_task.rs +++ b/components/gfx/paint_task.rs @@ -4,6 +4,10 @@ //! The task that handles all painting. +use self::Msg::*; +use self::MsgFromWorkerThread::*; +use self::MsgToWorkerThread::*; + use buffer_map::BufferMap; use display_list::{mod, StackingContext}; use font_cache_task::FontCacheTask; diff --git a/components/gfx/platform/freetype/font.rs b/components/gfx/platform/freetype/font.rs index 90179b377a3..5896a335585 100644 --- a/components/gfx/platform/freetype/font.rs +++ b/components/gfx/platform/freetype/font.rs @@ -26,6 +26,7 @@ use freetype::freetype::{ft_sfnt_os2}; use freetype::tt_os2::TT_OS2; use std::mem; +use std::num::Float; use std::ptr; use std::string; diff --git a/components/gfx/platform/macos/font.rs b/components/gfx/platform/macos/font.rs index 529bdcf615d..d73a22d7d41 100644 --- a/components/gfx/platform/macos/font.rs +++ b/components/gfx/platform/macos/font.rs @@ -27,6 +27,7 @@ use core_text::font::CTFont; use core_text::font_descriptor::{SymbolicTraitAccessors, TraitAccessors}; use core_text::font_descriptor::{kCTFontDefaultOrientation}; +use std::num::Float; use std::ptr; use sync::Arc; diff --git a/components/gfx/text/glyph.rs b/components/gfx/text/glyph.rs index c1d601b8120..4f9407f8bbf 100644 --- a/components/gfx/text/glyph.rs +++ b/components/gfx/text/glyph.rs @@ -2,6 +2,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +use self::BreakType::*; +use self::GlyphInfo::*; + use servo_util::vec::*; use servo_util::range; use servo_util::range::{Range, RangeIndex, IntRangeIndex, EachIndex}; diff --git a/components/gfx/text/util.rs b/components/gfx/text/util.rs index 05b257688fb..63d73c76dab 100644 --- a/components/gfx/text/util.rs +++ b/components/gfx/text/util.rs @@ -2,6 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +use self::CompressionMode::*; + use text::glyph::CharIndex; #[deriving(PartialEq)] diff --git a/components/layout/block.rs b/components/layout/block.rs index 079a1961073..6ff01eaf684 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -31,9 +31,9 @@ use construct::FlowConstructor; use context::LayoutContext; use css::node_style::StyledNode; use display_list_builder::{BlockFlowDisplayListBuilding, FragmentDisplayListBuilding}; -use floats::{ClearBoth, ClearLeft, ClearRight, FloatKind, FloatLeft, Floats, PlacementInfo}; -use flow::{AbsolutePositionInfo, BaseFlow, BlockFlowClass, FloatIfNecessary, FlowClass, Flow}; -use flow::{ForceNonfloated, ImmutableFlowUtils, MutableFlowUtils, PreorderFlowTraversal}; +use floats::{ClearType, FloatKind, Floats, PlacementInfo}; +use flow::{AbsolutePositionInfo, BaseFlow, ForceNonfloatedFlag, FlowClass, Flow}; +use flow::{ImmutableFlowUtils, MutableFlowUtils, PreorderFlowTraversal}; use flow::{PostorderFlowTraversal, mut_base}; use flow::{HAS_LEFT_FLOATED_DESCENDANTS, HAS_RIGHT_FLOATED_DESCENDANTS}; use flow::{IMPACTED_BY_LEFT_FLOATS, IMPACTED_BY_RIGHT_FLOATS}; @@ -41,12 +41,11 @@ use flow::{LAYERS_NEEDED_FOR_DESCENDANTS, NEEDS_LAYER}; use flow::{IS_ABSOLUTELY_POSITIONED}; use flow::{CLEARS_LEFT, CLEARS_RIGHT}; use flow; -use fragment::{Fragment, ImageFragment, InlineBlockFragment, FragmentBoundsIterator}; -use fragment::ScannedTextFragment; +use fragment::{Fragment, FragmentBoundsIterator, SpecificFragmentInfo}; use incremental::{REFLOW, REFLOW_OUT_OF_FLOW}; use layout_debug; -use model::{Auto, IntrinsicISizes, MarginCollapseInfo, MarginsCollapse, MarginsCollapseThrough}; -use model::{MaybeAuto, NoCollapsibleMargins, Specified, specified, specified_or_none}; +use model::{IntrinsicISizes, MarginCollapseInfo}; +use model::{MaybeAuto, CollapsibleMargins, specified, specified_or_none}; use table::ColumnComputedInlineSize; use wrapper::ThreadSafeLayoutNode; @@ -60,8 +59,8 @@ use servo_util::opts; use std::cmp::{max, min}; use std::fmt; use style::ComputedValues; -use style::computed_values::{LPA_Auto, LPA_Length, LPA_Percentage, LPN_Length, LPN_None}; -use style::computed_values::{LPN_Percentage, LP_Length, LP_Percentage, box_sizing, display, float}; +use style::computed_values::{LengthOrPercentageOrAuto, LengthOrPercentageOrNone}; +use style::computed_values::{LengthOrPercentage, box_sizing, display, float}; use style::computed_values::{overflow, position}; use sync::Arc; @@ -138,7 +137,7 @@ impl BSizeConstraintSolution { let static_position_block_start = static_b_offset; let (block_start, block_end, block_size, margin_block_start, margin_block_end) = match (block_start, block_end, block_size) { - (Auto, Auto, Auto) => { + (MaybeAuto::Auto, MaybeAuto::Auto, MaybeAuto::Auto) => { let margin_block_start = block_start_margin.specified_or_zero(); let margin_block_end = block_end_margin.specified_or_zero(); let block_start = static_position_block_start; @@ -149,23 +148,23 @@ impl BSizeConstraintSolution { let sum = block_start + block_size + margin_block_start + margin_block_end; (block_start, available_block_size - sum, block_size, margin_block_start, margin_block_end) } - (Specified(block_start), Specified(block_end), Specified(block_size)) => { + (MaybeAuto::Specified(block_start), MaybeAuto::Specified(block_end), MaybeAuto::Specified(block_size)) => { match (block_start_margin, block_end_margin) { - (Auto, Auto) => { + (MaybeAuto::Auto, MaybeAuto::Auto) => { let total_margin_val = available_block_size - block_start - block_end - block_size; (block_start, block_end, block_size, total_margin_val.scale_by(0.5), total_margin_val.scale_by(0.5)) } - (Specified(margin_block_start), Auto) => { + (MaybeAuto::Specified(margin_block_start), MaybeAuto::Auto) => { let sum = block_start + block_end + block_size + margin_block_start; (block_start, block_end, block_size, margin_block_start, available_block_size - sum) } - (Auto, Specified(margin_block_end)) => { + (MaybeAuto::Auto, MaybeAuto::Specified(margin_block_end)) => { let sum = block_start + block_end + block_size + margin_block_end; (block_start, block_end, block_size, available_block_size - sum, margin_block_end) } - (Specified(margin_block_start), Specified(margin_block_end)) => { + (MaybeAuto::Specified(margin_block_start), MaybeAuto::Specified(margin_block_end)) => { // Values are over-constrained. Ignore value for 'block-end'. let sum = block_start + block_size + margin_block_start + margin_block_end; (block_start, available_block_size - sum, block_size, margin_block_start, margin_block_end) @@ -176,19 +175,19 @@ impl BSizeConstraintSolution { // For the rest of the cases, auto values for margin are set to 0 // If only one is Auto, solve for it - (Auto, Specified(block_end), Specified(block_size)) => { + (MaybeAuto::Auto, MaybeAuto::Specified(block_end), MaybeAuto::Specified(block_size)) => { let margin_block_start = block_start_margin.specified_or_zero(); let margin_block_end = block_end_margin.specified_or_zero(); let sum = block_end + block_size + margin_block_start + margin_block_end; (available_block_size - sum, block_end, block_size, margin_block_start, margin_block_end) } - (Specified(block_start), Auto, Specified(block_size)) => { + (MaybeAuto::Specified(block_start), MaybeAuto::Auto, MaybeAuto::Specified(block_size)) => { let margin_block_start = block_start_margin.specified_or_zero(); let margin_block_end = block_end_margin.specified_or_zero(); let sum = block_start + block_size + margin_block_start + margin_block_end; (block_start, available_block_size - sum, block_size, margin_block_start, margin_block_end) } - (Specified(block_start), Specified(block_end), Auto) => { + (MaybeAuto::Specified(block_start), MaybeAuto::Specified(block_end), MaybeAuto::Auto) => { let margin_block_start = block_start_margin.specified_or_zero(); let margin_block_end = block_end_margin.specified_or_zero(); let sum = block_start + block_end + margin_block_start + margin_block_end; @@ -197,14 +196,14 @@ impl BSizeConstraintSolution { // If block-size is auto, then block-size is content block-size. Solve for the // non-auto value. - (Specified(block_start), Auto, Auto) => { + (MaybeAuto::Specified(block_start), MaybeAuto::Auto, MaybeAuto::Auto) => { let margin_block_start = block_start_margin.specified_or_zero(); let margin_block_end = block_end_margin.specified_or_zero(); let block_size = content_block_size; let sum = block_start + block_size + margin_block_start + margin_block_end; (block_start, available_block_size - sum, block_size, margin_block_start, margin_block_end) } - (Auto, Specified(block_end), Auto) => { + (MaybeAuto::Auto, MaybeAuto::Specified(block_end), MaybeAuto::Auto) => { let margin_block_start = block_start_margin.specified_or_zero(); let margin_block_end = block_end_margin.specified_or_zero(); let block_size = content_block_size; @@ -212,7 +211,7 @@ impl BSizeConstraintSolution { (available_block_size - sum, block_end, block_size, margin_block_start, margin_block_end) } - (Auto, Auto, Specified(block_size)) => { + (MaybeAuto::Auto, MaybeAuto::Auto, MaybeAuto::Specified(block_size)) => { let margin_block_start = block_start_margin.specified_or_zero(); let margin_block_end = block_end_margin.specified_or_zero(); let block_start = static_position_block_start; @@ -249,30 +248,30 @@ impl BSizeConstraintSolution { let static_position_block_start = static_b_offset; let (block_start, block_end, block_size, margin_block_start, margin_block_end) = match (block_start, block_end) { - (Auto, Auto) => { + (MaybeAuto::Auto, MaybeAuto::Auto) => { let margin_block_start = block_start_margin.specified_or_zero(); let margin_block_end = block_end_margin.specified_or_zero(); let block_start = static_position_block_start; let sum = block_start + block_size + margin_block_start + margin_block_end; (block_start, available_block_size - sum, block_size, margin_block_start, margin_block_end) } - (Specified(block_start), Specified(block_end)) => { + (MaybeAuto::Specified(block_start), MaybeAuto::Specified(block_end)) => { match (block_start_margin, block_end_margin) { - (Auto, Auto) => { + (MaybeAuto::Auto, MaybeAuto::Auto) => { let total_margin_val = available_block_size - block_start - block_end - block_size; (block_start, block_end, block_size, total_margin_val.scale_by(0.5), total_margin_val.scale_by(0.5)) } - (Specified(margin_block_start), Auto) => { + (MaybeAuto::Specified(margin_block_start), MaybeAuto::Auto) => { let sum = block_start + block_end + block_size + margin_block_start; (block_start, block_end, block_size, margin_block_start, available_block_size - sum) } - (Auto, Specified(margin_block_end)) => { + (MaybeAuto::Auto, MaybeAuto::Specified(margin_block_end)) => { let sum = block_start + block_end + block_size + margin_block_end; (block_start, block_end, block_size, available_block_size - sum, margin_block_end) } - (Specified(margin_block_start), Specified(margin_block_end)) => { + (MaybeAuto::Specified(margin_block_start), MaybeAuto::Specified(margin_block_end)) => { // Values are over-constrained. Ignore value for 'block-end'. let sum = block_start + block_size + margin_block_start + margin_block_end; (block_start, available_block_size - sum, block_size, margin_block_start, margin_block_end) @@ -281,13 +280,13 @@ impl BSizeConstraintSolution { } // If only one is Auto, solve for it - (Auto, Specified(block_end)) => { + (MaybeAuto::Auto, MaybeAuto::Specified(block_end)) => { let margin_block_start = block_start_margin.specified_or_zero(); let margin_block_end = block_end_margin.specified_or_zero(); let sum = block_end + block_size + margin_block_start + margin_block_end; (available_block_size - sum, block_end, block_size, margin_block_start, margin_block_end) } - (Specified(block_start), Auto) => { + (MaybeAuto::Specified(block_start), MaybeAuto::Auto) => { let margin_block_start = block_start_margin.specified_or_zero(); let margin_block_end = block_end_margin.specified_or_zero(); let sum = block_start + block_size + margin_block_start + margin_block_end; @@ -325,25 +324,26 @@ impl CandidateBSizeIterator { // `min-height` and `max-height`, percentage values are ignored. let block_size = match (fragment.style.content_block_size(), block_container_block_size) { - (LPA_Percentage(percent), Some(block_container_block_size)) => { - Specified(block_container_block_size.scale_by(percent)) + (LengthOrPercentageOrAuto::Percentage(percent), Some(block_container_block_size)) => { + MaybeAuto::Specified(block_container_block_size.scale_by(percent)) } - (LPA_Percentage(_), None) | (LPA_Auto, _) => Auto, - (LPA_Length(length), _) => Specified(length), + (LengthOrPercentageOrAuto::Percentage(_), None) | (LengthOrPercentageOrAuto::Auto, _) => MaybeAuto::Auto, + (LengthOrPercentageOrAuto::Length(length), _) => MaybeAuto::Specified(length), }; let max_block_size = match (fragment.style.max_block_size(), block_container_block_size) { - (LPN_Percentage(percent), Some(block_container_block_size)) => { + (LengthOrPercentageOrNone::Percentage(percent), Some(block_container_block_size)) => { Some(block_container_block_size.scale_by(percent)) } - (LPN_Percentage(_), None) | (LPN_None, _) => None, - (LPN_Length(length), _) => Some(length), + (LengthOrPercentageOrNone::Percentage(_), None) | + (LengthOrPercentageOrNone::None, _) => None, + (LengthOrPercentageOrNone::Length(length), _) => Some(length), }; let min_block_size = match (fragment.style.min_block_size(), block_container_block_size) { - (LP_Percentage(percent), Some(block_container_block_size)) => { + (LengthOrPercentage::Percentage(percent), Some(block_container_block_size)) => { block_container_block_size.scale_by(percent) } - (LP_Percentage(_), None) => Au(0), - (LP_Length(length), _) => length, + (LengthOrPercentage::Percentage(_), None) => Au(0), + (LengthOrPercentage::Length(length), _) => length, }; // If the style includes `box-sizing: border-box`, subtract the border and padding. @@ -357,7 +357,7 @@ impl CandidateBSizeIterator { max_block_size: max_block_size.map(|size| adjust(size, adjustment_for_box_sizing)), min_block_size: adjust(min_block_size, adjustment_for_box_sizing), candidate_value: Au(0), - status: InitialCandidateBSizeStatus, + status: CandidateBSizeIteratorStatus::Initial, }; fn adjust(size: Au, delta: Au) -> Au { @@ -369,48 +369,48 @@ impl CandidateBSizeIterator { impl Iterator for CandidateBSizeIterator { fn next(&mut self) -> Option { self.status = match self.status { - InitialCandidateBSizeStatus => TryingBSizeCandidateBSizeStatus, - TryingBSizeCandidateBSizeStatus => { + CandidateBSizeIteratorStatus::Initial => CandidateBSizeIteratorStatus::Trying, + CandidateBSizeIteratorStatus::Trying => { match self.max_block_size { Some(max_block_size) if self.candidate_value > max_block_size => { - TryingMaxCandidateBSizeStatus + CandidateBSizeIteratorStatus::TryingMax } - _ if self.candidate_value < self.min_block_size => TryingMinCandidateBSizeStatus, - _ => FoundCandidateBSizeStatus, + _ if self.candidate_value < self.min_block_size => CandidateBSizeIteratorStatus::TryingMin, + _ => CandidateBSizeIteratorStatus::Found, } } - TryingMaxCandidateBSizeStatus => { + CandidateBSizeIteratorStatus::TryingMax => { if self.candidate_value < self.min_block_size { - TryingMinCandidateBSizeStatus + CandidateBSizeIteratorStatus::TryingMin } else { - FoundCandidateBSizeStatus + CandidateBSizeIteratorStatus::Found } } - TryingMinCandidateBSizeStatus | FoundCandidateBSizeStatus => { - FoundCandidateBSizeStatus + CandidateBSizeIteratorStatus::TryingMin | CandidateBSizeIteratorStatus::Found => { + CandidateBSizeIteratorStatus::Found } }; match self.status { - TryingBSizeCandidateBSizeStatus => Some(self.block_size), - TryingMaxCandidateBSizeStatus => { - Some(Specified(self.max_block_size.unwrap())) + CandidateBSizeIteratorStatus::Trying => Some(self.block_size), + CandidateBSizeIteratorStatus::TryingMax => { + Some(MaybeAuto::Specified(self.max_block_size.unwrap())) } - TryingMinCandidateBSizeStatus => { - Some(Specified(self.min_block_size)) + CandidateBSizeIteratorStatus::TryingMin => { + Some(MaybeAuto::Specified(self.min_block_size)) } - FoundCandidateBSizeStatus => None, - InitialCandidateBSizeStatus => panic!(), + CandidateBSizeIteratorStatus::Found => None, + CandidateBSizeIteratorStatus::Initial => panic!(), } } } enum CandidateBSizeIteratorStatus { - InitialCandidateBSizeStatus, - TryingBSizeCandidateBSizeStatus, - TryingMaxCandidateBSizeStatus, - TryingMinCandidateBSizeStatus, - FoundCandidateBSizeStatus, + Initial, + Trying, + TryingMax, + TryingMin, + Found, } // A helper function used in block-size calculation. @@ -479,12 +479,12 @@ impl<'a> PostorderFlowTraversal for AbsoluteStoreOverflowTraversal<'a> { } pub enum BlockType { - BlockReplacedType, - BlockNonReplacedType, - AbsoluteReplacedType, - AbsoluteNonReplacedType, - FloatReplacedType, - FloatNonReplacedType, + Replaced, + NonReplaced, + AbsoluteReplaced, + AbsoluteNonReplaced, + FloatReplaced, + FloatNonReplaced, } #[deriving(Clone, PartialEq)] @@ -495,9 +495,9 @@ pub enum MarginsMayCollapseFlag { #[deriving(PartialEq)] enum FormattingContextType { - NonformattingContext, - BlockFormattingContext, - OtherFormattingContext, + None, + Block, + Other, } // Propagates the `layers_needed_for_descendants` flag appropriately from a child. This is called @@ -571,7 +571,7 @@ impl BlockFlow { pub fn from_node(constructor: &mut FlowConstructor, node: &ThreadSafeLayoutNode) -> BlockFlow { let writing_mode = node.style().writing_mode; BlockFlow { - base: BaseFlow::new(Some((*node).clone()), writing_mode, ForceNonfloated), + base: BaseFlow::new(Some((*node).clone()), writing_mode, ForceNonfloatedFlag::ForceNonfloated), fragment: Fragment::new(constructor, node), static_b_offset: Au::new(0), inline_size_of_preceding_left_floats: Au(0), @@ -585,7 +585,7 @@ impl BlockFlow { pub fn from_node_and_fragment(node: &ThreadSafeLayoutNode, fragment: Fragment) -> BlockFlow { let writing_mode = node.style().writing_mode; BlockFlow { - base: BaseFlow::new(Some((*node).clone()), writing_mode, ForceNonfloated), + base: BaseFlow::new(Some((*node).clone()), writing_mode, ForceNonfloatedFlag::ForceNonfloated), fragment: fragment, static_b_offset: Au::new(0), inline_size_of_preceding_left_floats: Au(0), @@ -602,7 +602,7 @@ impl BlockFlow { -> BlockFlow { let writing_mode = node.style().writing_mode; BlockFlow { - base: BaseFlow::new(Some((*node).clone()), writing_mode, FloatIfNecessary), + base: BaseFlow::new(Some((*node).clone()), writing_mode, ForceNonfloatedFlag::FloatIfNecessary), fragment: Fragment::new(constructor, node), static_b_offset: Au::new(0), inline_size_of_preceding_left_floats: Au(0), @@ -619,7 +619,7 @@ impl BlockFlow { -> BlockFlow { let writing_mode = node.style().writing_mode; BlockFlow { - base: BaseFlow::new(Some((*node).clone()), writing_mode, FloatIfNecessary), + base: BaseFlow::new(Some((*node).clone()), writing_mode, ForceNonfloatedFlag::FloatIfNecessary), fragment: fragment, static_b_offset: Au::new(0), inline_size_of_preceding_left_floats: Au(0), @@ -637,21 +637,21 @@ impl BlockFlow { pub fn block_type(&self) -> BlockType { if self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) { if self.is_replaced_content() { - AbsoluteReplacedType + BlockType::AbsoluteReplaced } else { - AbsoluteNonReplacedType + BlockType::AbsoluteNonReplaced } } else if self.base.flags.is_float() { if self.is_replaced_content() { - FloatReplacedType + BlockType::FloatReplaced } else { - FloatNonReplacedType + BlockType::FloatNonReplaced } } else { if self.is_replaced_content() { - BlockReplacedType + BlockType::Replaced } else { - BlockNonReplacedType + BlockType::NonReplaced } } } @@ -662,27 +662,27 @@ impl BlockFlow { containing_block_inline_size: Au) { let block_type = self.block_type(); match block_type { - AbsoluteReplacedType => { + BlockType::AbsoluteReplaced => { let inline_size_computer = AbsoluteReplaced; inline_size_computer.compute_used_inline_size(self, ctx, containing_block_inline_size); } - AbsoluteNonReplacedType => { + BlockType::AbsoluteNonReplaced => { let inline_size_computer = AbsoluteNonReplaced; inline_size_computer.compute_used_inline_size(self, ctx, containing_block_inline_size); } - FloatReplacedType => { + BlockType::FloatReplaced => { let inline_size_computer = FloatReplaced; inline_size_computer.compute_used_inline_size(self, ctx, containing_block_inline_size); } - FloatNonReplacedType => { + BlockType::FloatNonReplaced => { let inline_size_computer = FloatNonReplaced; inline_size_computer.compute_used_inline_size(self, ctx, containing_block_inline_size); } - BlockReplacedType => { + BlockType::Replaced => { let inline_size_computer = BlockReplaced; inline_size_computer.compute_used_inline_size(self, ctx, containing_block_inline_size); } - BlockNonReplacedType => { + BlockType::NonReplaced => { let inline_size_computer = BlockNonReplaced; inline_size_computer.compute_used_inline_size(self, ctx, containing_block_inline_size); } @@ -767,7 +767,7 @@ impl BlockFlow { /// and image fragments. fn is_replaced_content(&self) -> bool { match self.fragment.specific { - ScannedTextFragment(_) | ImageFragment(_) | InlineBlockFragment(_) => true, + SpecificFragmentInfo::ScannedText(_) | SpecificFragmentInfo::Image(_) | SpecificFragmentInfo::InlineBlock(_) => true, _ => false, } } @@ -793,11 +793,11 @@ impl BlockFlow { } let (block_start_margin_value, block_end_margin_value) = match self.base.collapsible_margins { - MarginsCollapseThrough(_) => panic!("Margins unexpectedly collapsed through root flow."), - MarginsCollapse(block_start_margin, block_end_margin) => { + CollapsibleMargins::CollapseThrough(_) => panic!("Margins unexpectedly collapsed through root flow."), + CollapsibleMargins::Collapse(block_start_margin, block_end_margin) => { (block_start_margin.collapse(), block_end_margin.collapse()) } - NoCollapsibleMargins(block_start, block_end) => (block_start, block_end), + CollapsibleMargins::None(block_start, block_end) => (block_start, block_end), }; // Shift all kids down (or up, if margins are negative) if necessary. @@ -840,7 +840,7 @@ impl BlockFlow { // Absolute positioning establishes a block formatting context. Don't propagate floats // in or out. (But do propagate them between kids.) if self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) || - margins_may_collapse != MarginsMayCollapse { + margins_may_collapse != MarginsMayCollapseFlag::MarginsMayCollapse { self.base.floats = Floats::new(self.fragment.style.writing_mode); } @@ -853,7 +853,7 @@ impl BlockFlow { translate_including_floats(&mut cur_b, block_start_offset, &mut self.base.floats); let can_collapse_block_start_margin_with_kids = - margins_may_collapse == MarginsMayCollapse && + margins_may_collapse == MarginsMayCollapseFlag::MarginsMayCollapse && !self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) && self.fragment.border_padding.block_start == Au(0); margin_collapse_info.initialize_block_start_margin( @@ -924,9 +924,9 @@ impl BlockFlow { let clearance = match (flow::base(kid).flags.contains(CLEARS_LEFT), flow::base(kid).flags.contains(CLEARS_RIGHT)) { (false, false) => Au(0), - (true, false) => floats.clearance(ClearLeft), - (false, true) => floats.clearance(ClearRight), - (true, true) => floats.clearance(ClearBoth), + (true, false) => floats.clearance(ClearType::Left), + (false, true) => floats.clearance(ClearType::Right), + (true, true) => floats.clearance(ClearType::Both), }; translate_including_floats(&mut cur_b, clearance, &mut floats); @@ -961,7 +961,7 @@ impl BlockFlow { // Add in our block-end margin and compute our collapsible margins. let can_collapse_block_end_margin_with_kids = - margins_may_collapse == MarginsMayCollapse && + margins_may_collapse == MarginsMayCollapseFlag::MarginsMayCollapse && !self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) && self.fragment.border_padding.block_end == Au(0); let (collapsible_margins, delta) = @@ -983,11 +983,11 @@ impl BlockFlow { block_size = Au::max(screen_size.block, block_size) } - if is_root || self.formatting_context_type() != NonformattingContext || + if is_root || self.formatting_context_type() != FormattingContextType::None || self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) { // The content block-size includes all the floats per CSS 2.1 § 10.6.7. The easiest // way to handle this is to just treat it as clearance. - block_size = block_size + floats.clearance(ClearBoth); + block_size = block_size + floats.clearance(ClearType::Both); } if self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) { @@ -1014,8 +1014,8 @@ impl BlockFlow { Some(candidate_block_size) => { candidate_block_size_iterator.candidate_value = match candidate_block_size { - Auto => block_size, - Specified(value) => value + MaybeAuto::Auto => block_size, + MaybeAuto::Specified(value) => value } } None => break, @@ -1069,7 +1069,7 @@ impl BlockFlow { // Also don't remove the dirty bits if we're a block formatting context since our inline // size has not yet been computed. (See `assign_inline_position_for_formatting_context()`.) if (self.base.flags.is_float() || - self.formatting_context_type() == NonformattingContext) && + self.formatting_context_type() == FormattingContextType::None) && !self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) { self.base.restyle_damage.remove(REFLOW_OUT_OF_FLOW | REFLOW); } @@ -1147,12 +1147,12 @@ impl BlockFlow { // calculated during assign-inline-size. let margin = self.fragment.style().logical_margin(); let margin_block_start = match margin.block_start { - LPA_Auto => Auto, - _ => Specified(self.fragment.margin.block_start) + LengthOrPercentageOrAuto::Auto => MaybeAuto::Auto, + _ => MaybeAuto::Specified(self.fragment.margin.block_start) }; let margin_block_end = match margin.block_end { - LPA_Auto => Auto, - _ => Specified(self.fragment.margin.block_end) + LengthOrPercentageOrAuto::Auto => MaybeAuto::Auto, + _ => MaybeAuto::Specified(self.fragment.margin.block_end) }; let block_start; @@ -1292,7 +1292,7 @@ impl BlockFlow { // direction.) let mut inline_size_of_preceding_left_floats = Au(0); let mut inline_size_of_preceding_right_floats = Au(0); - if self.formatting_context_type() == NonformattingContext { + if self.formatting_context_type() == FormattingContextType::None { inline_size_of_preceding_left_floats = self.inline_size_of_preceding_left_floats; inline_size_of_preceding_right_floats = self.inline_size_of_preceding_right_floats; } @@ -1301,11 +1301,11 @@ impl BlockFlow { let content_block_size = self.fragment.style().content_block_size(); let explicit_content_size = match (content_block_size, self.base.block_container_explicit_block_size) { - (LPA_Percentage(percent), Some(container_size)) => { + (LengthOrPercentageOrAuto::Percentage(percent), Some(container_size)) => { Some(container_size.scale_by(percent)) } - (LPA_Percentage(_), None) | (LPA_Auto, _) => None, - (LPA_Length(length), _) => Some(length), + (LengthOrPercentageOrAuto::Percentage(_), None) | (LengthOrPercentageOrAuto::Auto, _) => None, + (LengthOrPercentageOrAuto::Length(length), _) => Some(length), }; // Calculate containing block inline size. @@ -1410,14 +1410,14 @@ impl BlockFlow { fn formatting_context_type(&self) -> FormattingContextType { let style = self.fragment.style(); if style.get_box().float != float::none { - return OtherFormattingContext + return FormattingContextType::Other } match style.get_box().display { display::table_cell | display::table_caption | display::inline_block => { - OtherFormattingContext + FormattingContextType::Other } - _ if style.get_box().overflow != overflow::visible => BlockFormattingContext, - _ => NonformattingContext, + _ if style.get_box().overflow != overflow::visible => FormattingContextType::Block, + _ => FormattingContextType::None, } } @@ -1435,7 +1435,7 @@ impl BlockFlow { /// /// FIXME(pcwalton): This code is not incremental-reflow-safe (i.e. not idempotent). fn assign_inline_position_for_formatting_context(&mut self) { - debug_assert!(self.formatting_context_type() != NonformattingContext); + debug_assert!(self.formatting_context_type() != FormattingContextType::None); if !self.base.restyle_damage.intersects(REFLOW_OUT_OF_FLOW | REFLOW) { return @@ -1449,7 +1449,7 @@ impl BlockFlow { self.fragment.border_box.size.block), ceiling: self.base.position.start.b, max_inline_size: MAX_AU, - kind: FloatLeft, + kind: FloatKind::Left, }; // Offset our position by whatever displacement is needed to not impact the floats. @@ -1482,7 +1482,7 @@ impl BlockFlow { impl Flow for BlockFlow { fn class(&self) -> FlowClass { - BlockFlowClass + FlowClass::Block } fn as_block<'a>(&'a mut self) -> &'a mut BlockFlow { @@ -1510,7 +1510,7 @@ impl Flow for BlockFlow { // and preferred width, rather than bubbling up children inline // width. let fixed_width = match self.fragment.style().get_box().width { - LPA_Length(_) => true, + LengthOrPercentageOrAuto::Length(_) => true, _ => false, }; @@ -1602,8 +1602,8 @@ impl Flow for BlockFlow { // Formatting contexts are never impacted by floats. match self.formatting_context_type() { - NonformattingContext => {} - BlockFormattingContext => { + FormattingContextType::None => {} + FormattingContextType::Block => { self.base.flags.remove(IMPACTED_BY_LEFT_FLOATS); self.base.flags.remove(IMPACTED_BY_RIGHT_FLOATS); @@ -1615,7 +1615,7 @@ impl Flow for BlockFlow { self.inline_size_of_preceding_left_floats - self.inline_size_of_preceding_right_floats; } - OtherFormattingContext => { + FormattingContextType::Other => { self.base.flags.remove(IMPACTED_BY_LEFT_FLOATS); self.base.flags.remove(IMPACTED_BY_RIGHT_FLOATS); } @@ -1646,7 +1646,7 @@ impl Flow for BlockFlow { return false } - let is_formatting_context = self.formatting_context_type() != NonformattingContext; + let is_formatting_context = self.formatting_context_type() != FormattingContextType::None; if !self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) && is_formatting_context { self.assign_inline_position_for_formatting_context(); } @@ -1687,10 +1687,10 @@ impl Flow for BlockFlow { } else if self.is_root() || self.base.flags.is_float() || self.is_inline_block() { // Root element margins should never be collapsed according to CSS § 8.3.1. debug!("assign_block_size: assigning block_size for root flow"); - self.assign_block_size_block_base(ctx, MarginsMayNotCollapse); + self.assign_block_size_block_base(ctx, MarginsMayCollapseFlag::MarginsMayNotCollapse); } else { debug!("assign_block_size: assigning block_size for block"); - self.assign_block_size_block_base(ctx, MarginsMayCollapse); + self.assign_block_size_block_base(ctx, MarginsMayCollapseFlag::MarginsMayCollapse); } } @@ -1839,16 +1839,16 @@ impl Flow for BlockFlow { fn update_late_computed_inline_position_if_necessary(&mut self, inline_position: Au) { if self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) && - self.fragment.style().logical_position().inline_start == LPA_Auto && - self.fragment.style().logical_position().inline_end == LPA_Auto { + self.fragment.style().logical_position().inline_start == LengthOrPercentageOrAuto::Auto && + self.fragment.style().logical_position().inline_end == LengthOrPercentageOrAuto::Auto { self.base.position.start.i = inline_position } } fn update_late_computed_block_position_if_necessary(&mut self, block_position: Au) { if self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) && - self.fragment.style().logical_position().block_start == LPA_Auto && - self.fragment.style().logical_position().block_end == LPA_Auto { + self.fragment.style().logical_position().block_start == LengthOrPercentageOrAuto::Auto && + self.fragment.style().logical_position().block_end == LengthOrPercentageOrAuto::Auto { self.base.position.start.b = block_position } } @@ -1976,11 +1976,11 @@ pub trait ISizeAndMarginsComputer { let style = block.fragment.style(); match (computed_inline_size, style.get_box().box_sizing) { - (Specified(size), box_sizing::border_box) => { + (MaybeAuto::Specified(size), box_sizing::border_box) => { computed_inline_size = - Specified(size - block.fragment.border_padding.inline_start_end()) + MaybeAuto::Specified(size - block.fragment.border_padding.inline_start_end()) } - (Auto, box_sizing::border_box) | (_, box_sizing::content_box) => {} + (MaybeAuto::Auto, box_sizing::border_box) | (_, box_sizing::content_box) => {} } // The text alignment of a block flow is the text alignment of its box's style. @@ -2090,7 +2090,7 @@ pub trait ISizeAndMarginsComputer { match specified_or_none(block.fragment().style().max_inline_size(), containing_block_inline_size) { Some(max_inline_size) if max_inline_size < solution.inline_size => { - input.computed_inline_size = Specified(max_inline_size); + input.computed_inline_size = MaybeAuto::Specified(max_inline_size); solution = self.solve_inline_size_constraints(block, &input); } _ => {} @@ -2102,7 +2102,7 @@ pub trait ISizeAndMarginsComputer { let computed_min_inline_size = specified(block.fragment().style().min_inline_size(), containing_block_inline_size); if computed_min_inline_size > solution.inline_size { - input.computed_inline_size = Specified(computed_min_inline_size); + input.computed_inline_size = MaybeAuto::Specified(computed_min_inline_size); solution = self.solve_inline_size_constraints(block, &input); } @@ -2131,13 +2131,13 @@ pub trait ISizeAndMarginsComputer { // If inline-size is not 'auto', and inline-size + margins > available_inline-size, all // 'auto' margins are treated as 0. let (inline_start_margin, inline_end_margin) = match computed_inline_size { - Auto => (inline_start_margin, inline_end_margin), - Specified(inline_size) => { + MaybeAuto::Auto => (inline_start_margin, inline_end_margin), + MaybeAuto::Specified(inline_size) => { let inline_start = inline_start_margin.specified_or_zero(); let inline_end = inline_end_margin.specified_or_zero(); if (inline_start + inline_end + inline_size) > available_inline_size { - (Specified(inline_start), Specified(inline_end)) + (MaybeAuto::Specified(inline_start), MaybeAuto::Specified(inline_end)) } else { (inline_start_margin, inline_end_margin) } @@ -2150,31 +2150,31 @@ pub trait ISizeAndMarginsComputer { match (inline_start_margin, computed_inline_size, inline_end_margin) { // If all have a computed value other than 'auto', the system is // over-constrained so we discard the end margin. - (Specified(margin_start), Specified(inline_size), Specified(_margin_end)) => + (MaybeAuto::Specified(margin_start), MaybeAuto::Specified(inline_size), MaybeAuto::Specified(_margin_end)) => (margin_start, inline_size, available_inline_size - (margin_start + inline_size)), // If exactly one value is 'auto', solve for it - (Auto, Specified(inline_size), Specified(margin_end)) => + (MaybeAuto::Auto, MaybeAuto::Specified(inline_size), MaybeAuto::Specified(margin_end)) => (available_inline_size - (inline_size + margin_end), inline_size, margin_end), - (Specified(margin_start), Auto, Specified(margin_end)) => + (MaybeAuto::Specified(margin_start), MaybeAuto::Auto, MaybeAuto::Specified(margin_end)) => (margin_start, available_inline_size - (margin_start + margin_end), margin_end), - (Specified(margin_start), Specified(inline_size), Auto) => + (MaybeAuto::Specified(margin_start), MaybeAuto::Specified(inline_size), MaybeAuto::Auto) => (margin_start, inline_size, available_inline_size - (margin_start + inline_size)), // If inline-size is set to 'auto', any other 'auto' value becomes '0', // and inline-size is solved for - (Auto, Auto, Specified(margin_end)) => + (MaybeAuto::Auto, MaybeAuto::Auto, MaybeAuto::Specified(margin_end)) => (Au::new(0), available_inline_size - margin_end, margin_end), - (Specified(margin_start), Auto, Auto) => + (MaybeAuto::Specified(margin_start), MaybeAuto::Auto, MaybeAuto::Auto) => (margin_start, available_inline_size - margin_start, Au::new(0)), - (Auto, Auto, Auto) => + (MaybeAuto::Auto, MaybeAuto::Auto, MaybeAuto::Auto) => (Au::new(0), available_inline_size, Au::new(0)), // If inline-start and inline-end margins are auto, they become equal - (Auto, Specified(inline_size), Auto) => { + (MaybeAuto::Auto, MaybeAuto::Specified(inline_size), MaybeAuto::Auto) => { let margin = (available_inline_size - inline_size).scale_by(0.5); (margin, inline_size, margin) } @@ -2229,7 +2229,7 @@ impl ISizeAndMarginsComputer for AbsoluteNonReplaced { let static_position_inline_start = static_i_offset; let (inline_start, inline_end, inline_size, margin_inline_start, margin_inline_end) = match (inline_start, inline_end, computed_inline_size) { - (Auto, Auto, Auto) => { + (MaybeAuto::Auto, MaybeAuto::Auto, MaybeAuto::Auto) => { let margin_start = inline_start_margin.specified_or_zero(); let margin_end = inline_end_margin.specified_or_zero(); let inline_start = static_position_inline_start; @@ -2242,9 +2242,9 @@ impl ISizeAndMarginsComputer for AbsoluteNonReplaced { let sum = inline_start + inline_size + margin_start + margin_end; (inline_start, available_inline_size - sum, inline_size, margin_start, margin_end) } - (Specified(inline_start), Specified(inline_end), Specified(inline_size)) => { + (MaybeAuto::Specified(inline_start), MaybeAuto::Specified(inline_end), MaybeAuto::Specified(inline_size)) => { match (inline_start_margin, inline_end_margin) { - (Auto, Auto) => { + (MaybeAuto::Auto, MaybeAuto::Auto) => { let total_margin_val = available_inline_size - inline_start - inline_end - inline_size; if total_margin_val < Au(0) { // margin-inline-start becomes 0 because direction is 'ltr'. @@ -2257,15 +2257,15 @@ impl ISizeAndMarginsComputer for AbsoluteNonReplaced { total_margin_val.scale_by(0.5)) } } - (Specified(margin_start), Auto) => { + (MaybeAuto::Specified(margin_start), MaybeAuto::Auto) => { let sum = inline_start + inline_end + inline_size + margin_start; (inline_start, inline_end, inline_size, margin_start, available_inline_size - sum) } - (Auto, Specified(margin_end)) => { + (MaybeAuto::Auto, MaybeAuto::Specified(margin_end)) => { let sum = inline_start + inline_end + inline_size + margin_end; (inline_start, inline_end, inline_size, available_inline_size - sum, margin_end) } - (Specified(margin_start), Specified(margin_end)) => { + (MaybeAuto::Specified(margin_start), MaybeAuto::Specified(margin_end)) => { // Values are over-constrained. // Ignore value for 'inline-end' cos direction is 'ltr'. // TODO: Handle 'rtl' when it is implemented. @@ -2277,19 +2277,19 @@ impl ISizeAndMarginsComputer for AbsoluteNonReplaced { // For the rest of the cases, auto values for margin are set to 0 // If only one is Auto, solve for it - (Auto, Specified(inline_end), Specified(inline_size)) => { + (MaybeAuto::Auto, MaybeAuto::Specified(inline_end), MaybeAuto::Specified(inline_size)) => { let margin_start = inline_start_margin.specified_or_zero(); let margin_end = inline_end_margin.specified_or_zero(); let sum = inline_end + inline_size + margin_start + margin_end; (available_inline_size - sum, inline_end, inline_size, margin_start, margin_end) } - (Specified(inline_start), Auto, Specified(inline_size)) => { + (MaybeAuto::Specified(inline_start), MaybeAuto::Auto, MaybeAuto::Specified(inline_size)) => { let margin_start = inline_start_margin.specified_or_zero(); let margin_end = inline_end_margin.specified_or_zero(); let sum = inline_start + inline_size + margin_start + margin_end; (inline_start, available_inline_size - sum, inline_size, margin_start, margin_end) } - (Specified(inline_start), Specified(inline_end), Auto) => { + (MaybeAuto::Specified(inline_start), MaybeAuto::Specified(inline_end), MaybeAuto::Auto) => { let margin_start = inline_start_margin.specified_or_zero(); let margin_end = inline_end_margin.specified_or_zero(); let sum = inline_start + inline_end + margin_start + margin_end; @@ -2298,7 +2298,7 @@ impl ISizeAndMarginsComputer for AbsoluteNonReplaced { // If inline-size is auto, then inline-size is shrink-to-fit. Solve for the // non-auto value. - (Specified(inline_start), Auto, Auto) => { + (MaybeAuto::Specified(inline_start), MaybeAuto::Auto, MaybeAuto::Auto) => { let margin_start = inline_start_margin.specified_or_zero(); let margin_end = inline_end_margin.specified_or_zero(); // Set inline-end to zero to calculate inline-size @@ -2307,7 +2307,7 @@ impl ISizeAndMarginsComputer for AbsoluteNonReplaced { let sum = inline_start + inline_size + margin_start + margin_end; (inline_start, available_inline_size - sum, inline_size, margin_start, margin_end) } - (Auto, Specified(inline_end), Auto) => { + (MaybeAuto::Auto, MaybeAuto::Specified(inline_end), MaybeAuto::Auto) => { let margin_start = inline_start_margin.specified_or_zero(); let margin_end = inline_end_margin.specified_or_zero(); // Set inline-start to zero to calculate inline-size @@ -2317,7 +2317,7 @@ impl ISizeAndMarginsComputer for AbsoluteNonReplaced { (available_inline_size - sum, inline_end, inline_size, margin_start, margin_end) } - (Auto, Auto, Specified(inline_size)) => { + (MaybeAuto::Auto, MaybeAuto::Auto, MaybeAuto::Specified(inline_size)) => { let margin_start = inline_start_margin.specified_or_zero(); let margin_end = inline_end_margin.specified_or_zero(); // Setting 'inline-start' to static position because direction is 'ltr'. @@ -2374,7 +2374,7 @@ impl ISizeAndMarginsComputer for AbsoluteReplaced { // TODO: Handle all the cases for 'rtl' direction. let inline_size = match computed_inline_size { - Specified(w) => w, + MaybeAuto::Specified(w) => w, _ => panic!("{} {}", "The used value for inline_size for absolute replaced flow", "should have already been calculated by now.") @@ -2386,7 +2386,7 @@ impl ISizeAndMarginsComputer for AbsoluteReplaced { let static_position_inline_start = static_i_offset; let (inline_start, inline_end, inline_size, margin_inline_start, margin_inline_end) = match (inline_start, inline_end) { - (Auto, Auto) => { + (MaybeAuto::Auto, MaybeAuto::Auto) => { let inline_start = static_position_inline_start; let margin_start = inline_start_margin.specified_or_zero(); let margin_end = inline_end_margin.specified_or_zero(); @@ -2394,21 +2394,21 @@ impl ISizeAndMarginsComputer for AbsoluteReplaced { (inline_start, available_inline_size - sum, inline_size, margin_start, margin_end) } // If only one is Auto, solve for it - (Auto, Specified(inline_end)) => { + (MaybeAuto::Auto, MaybeAuto::Specified(inline_end)) => { let margin_start = inline_start_margin.specified_or_zero(); let margin_end = inline_end_margin.specified_or_zero(); let sum = inline_end + inline_size + margin_start + margin_end; (available_inline_size - sum, inline_end, inline_size, margin_start, margin_end) } - (Specified(inline_start), Auto) => { + (MaybeAuto::Specified(inline_start), MaybeAuto::Auto) => { let margin_start = inline_start_margin.specified_or_zero(); let margin_end = inline_end_margin.specified_or_zero(); let sum = inline_start + inline_size + margin_start + margin_end; (inline_start, available_inline_size - sum, inline_size, margin_start, margin_end) } - (Specified(inline_start), Specified(inline_end)) => { + (MaybeAuto::Specified(inline_start), MaybeAuto::Specified(inline_end)) => { match (inline_start_margin, inline_end_margin) { - (Auto, Auto) => { + (MaybeAuto::Auto, MaybeAuto::Auto) => { let total_margin_val = available_inline_size - inline_start - inline_end - inline_size; if total_margin_val < Au(0) { // margin-inline-start becomes 0 because direction is 'ltr'. @@ -2420,15 +2420,15 @@ impl ISizeAndMarginsComputer for AbsoluteReplaced { total_margin_val.scale_by(0.5)) } } - (Specified(margin_start), Auto) => { + (MaybeAuto::Specified(margin_start), MaybeAuto::Auto) => { let sum = inline_start + inline_end + inline_size + margin_start; (inline_start, inline_end, inline_size, margin_start, available_inline_size - sum) } - (Auto, Specified(margin_end)) => { + (MaybeAuto::Auto, MaybeAuto::Specified(margin_end)) => { let sum = inline_start + inline_end + inline_size + margin_end; (inline_start, inline_end, inline_size, available_inline_size - sum, margin_end) } - (Specified(margin_start), Specified(margin_end)) => { + (MaybeAuto::Specified(margin_start), MaybeAuto::Specified(margin_end)) => { // Values are over-constrained. // Ignore value for 'inline-end' cos direction is 'ltr'. let sum = inline_start + inline_size + margin_start + margin_end; @@ -2452,7 +2452,7 @@ impl ISizeAndMarginsComputer for AbsoluteReplaced { fragment.assign_replaced_inline_size_if_necessary(containing_block_inline_size); // For replaced absolute flow, the rest of the constraint solving will // take inline-size to be specified as the value computed here. - Specified(fragment.content_inline_size()) + MaybeAuto::Specified(fragment.content_inline_size()) } fn containing_block_inline_size(&self, block: &mut BlockFlow, _: Au, ctx: &LayoutContext) -> Au { @@ -2485,8 +2485,8 @@ impl ISizeAndMarginsComputer for BlockReplaced { input: &ISizeConstraintInput) -> ISizeConstraintSolution { match input.computed_inline_size { - Specified(_) => {}, - Auto => panic!("BlockReplaced: inline_size should have been computed by now") + MaybeAuto::Specified(_) => {}, + MaybeAuto::Auto => panic!("BlockReplaced: inline_size should have been computed by now") }; self.solve_block_inline_size_constraints(block, input) } @@ -2501,7 +2501,7 @@ impl ISizeAndMarginsComputer for BlockReplaced { fragment.assign_replaced_inline_size_if_necessary(parent_flow_inline_size); // For replaced block flow, the rest of the constraint solving will // take inline-size to be specified as the value computed here. - Specified(fragment.content_inline_size()) + MaybeAuto::Specified(fragment.content_inline_size()) } } @@ -2540,8 +2540,8 @@ impl ISizeAndMarginsComputer for FloatReplaced { let margin_inline_start = inline_start_margin.specified_or_zero(); let margin_inline_end = inline_end_margin.specified_or_zero(); let inline_size = match computed_inline_size { - Specified(w) => w, - Auto => panic!("FloatReplaced: inline_size should have been computed by now") + MaybeAuto::Specified(w) => w, + MaybeAuto::Auto => panic!("FloatReplaced: inline_size should have been computed by now") }; debug!("assign_inline_sizes_float -- inline_size: {}", inline_size); ISizeConstraintSolution::new(inline_size, margin_inline_start, margin_inline_end) @@ -2557,7 +2557,7 @@ impl ISizeAndMarginsComputer for FloatReplaced { fragment.assign_replaced_inline_size_if_necessary(parent_flow_inline_size); // For replaced block flow, the rest of the constraint solving will // take inline-size to be specified as the value computed here. - Specified(fragment.content_inline_size()) + MaybeAuto::Specified(fragment.content_inline_size()) } } diff --git a/components/layout/construct.rs b/components/layout/construct.rs index ec8533058cd..f59afba4696 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -22,12 +22,12 @@ use flow::{Descendants, AbsDescendants}; use flow::{IS_ABSOLUTELY_POSITIONED}; use flow; use flow_ref::FlowRef; -use fragment::{Fragment, GenericFragment, IframeFragment, IframeFragmentInfo, ImageFragment}; -use fragment::{ImageFragmentInfo, InlineAbsoluteHypotheticalFragment}; -use fragment::{InlineAbsoluteHypotheticalFragmentInfo, InlineBlockFragment}; -use fragment::{InlineBlockFragmentInfo, SpecificFragmentInfo, TableCellFragment}; -use fragment::{TableColumnFragment, TableColumnFragmentInfo, TableFragment, TableRowFragment}; -use fragment::{TableWrapperFragment, UnscannedTextFragment, UnscannedTextFragmentInfo}; +use fragment::{Fragment, IframeFragmentInfo}; +use fragment::ImageFragmentInfo; +use fragment::InlineAbsoluteHypotheticalFragmentInfo; +use fragment::{InlineBlockFragmentInfo, SpecificFragmentInfo}; +use fragment::TableColumnFragmentInfo; +use fragment::UnscannedTextFragmentInfo; use incremental::{RECONSTRUCT_FLOW, RestyleDamage}; use inline::InlineFlow; use list_item::{mod, ListItemFlow}; @@ -41,19 +41,11 @@ use table_row::TableRowFlow; use table_cell::TableCellFlow; use text::TextRunScanner; use util::{HAS_NEWLY_CONSTRUCTED_FLOW, LayoutDataAccess, OpaqueNodeMethods, LayoutDataWrapper}; -use wrapper::{PostorderNodeMutTraversal, TLayoutNode, ThreadSafeLayoutNode}; -use wrapper::{Before, After, Normal}; +use wrapper::{PostorderNodeMutTraversal, PseudoElementType, TLayoutNode, ThreadSafeLayoutNode}; use gfx::display_list::OpaqueNode; -use script::dom::element::{HTMLIFrameElementTypeId, HTMLImageElementTypeId}; -use script::dom::element::{HTMLObjectElementTypeId, HTMLInputElementTypeId}; -use script::dom::element::{HTMLTableColElementTypeId, HTMLTableDataCellElementTypeId}; -use script::dom::element::{HTMLTableElementTypeId, HTMLTableHeaderCellElementTypeId}; -use script::dom::element::{HTMLTableRowElementTypeId, HTMLTableSectionElementTypeId}; -use script::dom::element::HTMLTextAreaElementTypeId; -use script::dom::node::{CommentNodeTypeId, DoctypeNodeTypeId, DocumentFragmentNodeTypeId}; -use script::dom::node::{DocumentNodeTypeId, ElementNodeTypeId, ProcessingInstructionNodeTypeId}; -use script::dom::node::{TextNodeTypeId}; +use script::dom::element::ElementTypeId; +use script::dom::node::NodeTypeId; use script::dom::htmlobjectelement::is_image_data; use servo_util::opts; use std::collections::DList; @@ -69,22 +61,22 @@ use url::Url; pub enum ConstructionResult { /// This node contributes nothing at all (`display: none`). Alternately, this is what newly /// created nodes have their `ConstructionResult` set to. - NoConstructionResult, + None, /// This node contributed a flow at the proper position in the tree. /// Nothing more needs to be done for this node. It has bubbled up fixed /// and absolute descendant flows that have a containing block above it. - FlowConstructionResult(FlowRef, AbsDescendants), + Flow(FlowRef, AbsDescendants), /// This node contributed some object or objects that will be needed to construct a proper flow /// later up the tree, but these objects have not yet found their home. - ConstructionItemConstructionResult(ConstructionItem), + ConstructionItem(ConstructionItem), } impl ConstructionResult { pub fn swap_out(&mut self) -> ConstructionResult { if opts::get().nonincremental_layout { - return mem::replace(self, NoConstructionResult) + return mem::replace(self, ConstructionResult::None) } (*self).clone() @@ -92,9 +84,9 @@ impl ConstructionResult { pub fn debug_id(&self) -> uint { match self { - &NoConstructionResult => 0u, - &ConstructionItemConstructionResult(_) => 0u, - &FlowConstructionResult(ref flow_ref, _) => flow::base(flow_ref.deref()).debug_id(), + &ConstructionResult::None => 0u, + &ConstructionResult::ConstructionItem(_) => 0u, + &ConstructionResult::Flow(ref flow_ref, _) => flow::base(flow_ref.deref()).debug_id(), } } } @@ -105,11 +97,11 @@ impl ConstructionResult { #[deriving(Clone)] pub enum ConstructionItem { /// Inline fragments and associated {ib} splits that have not yet found flows. - InlineFragmentsConstructionItem(InlineFragmentsConstructionResult), + InlineFragments(InlineFragmentsConstructionResult), /// Potentially ignorable whitespace. - WhitespaceConstructionItem(OpaqueNode, Arc, RestyleDamage), + Whitespace(OpaqueNode, Arc, RestyleDamage), /// TableColumn Fragment - TableColumnFragmentConstructionItem(Fragment), + TableColumnFragment(Fragment), } /// Represents inline fragments and {ib} splits that are bubbling up from an inline. @@ -139,7 +131,7 @@ pub struct InlineFragmentsConstructionResult { /// The resulting `ConstructionItem` for the outer `span` will be: /// /// ```ignore -/// InlineFragmentsConstructionItem(Some(~[ +/// ConstructionItem::InlineFragments(Some(~[ /// InlineBlockSplit { /// predecessor_fragments: ~[ /// A @@ -213,9 +205,9 @@ impl InlineFragmentsAccumulator { } enum WhitespaceStrippingMode { - NoWhitespaceStripping, - StripWhitespaceFromStart, - StripWhitespaceFromEnd, + None, + FromStart, + FromEnd, } /// An object that knows how to create flows. @@ -237,11 +229,11 @@ impl<'a> FlowConstructor<'a> { fn build_fragment_info_for_image(&mut self, node: &ThreadSafeLayoutNode, url: Option) -> SpecificFragmentInfo { match url { - None => GenericFragment, + None => SpecificFragmentInfo::Generic, Some(url) => { // FIXME(pcwalton): The fact that image fragments store the cache within them makes // little sense to me. - ImageFragment(box ImageFragmentInfo::new(node, + SpecificFragmentInfo::Image(box ImageFragmentInfo::new(node, url, self.layout_context .shared @@ -260,28 +252,28 @@ impl<'a> FlowConstructor<'a> { pub fn build_specific_fragment_info_for_node(&mut self, node: &ThreadSafeLayoutNode) -> SpecificFragmentInfo { match node.type_id() { - Some(ElementNodeTypeId(HTMLIFrameElementTypeId)) => { - IframeFragment(box IframeFragmentInfo::new(node)) + Some(NodeTypeId::Element(ElementTypeId::HTMLIFrameElement)) => { + SpecificFragmentInfo::Iframe(box IframeFragmentInfo::new(node)) } - Some(ElementNodeTypeId(HTMLImageElementTypeId)) => { + Some(NodeTypeId::Element(ElementTypeId::HTMLImageElement)) => { self.build_fragment_info_for_image(node, node.image_url()) } - Some(ElementNodeTypeId(HTMLObjectElementTypeId)) => { + Some(NodeTypeId::Element(ElementTypeId::HTMLObjectElement)) => { let data = node.get_object_data(); self.build_fragment_info_for_image(node, data) } - Some(ElementNodeTypeId(HTMLTableElementTypeId)) => TableWrapperFragment, - Some(ElementNodeTypeId(HTMLTableColElementTypeId)) => { - TableColumnFragment(TableColumnFragmentInfo::new(node)) + Some(NodeTypeId::Element(ElementTypeId::HTMLTableElement)) => SpecificFragmentInfo::TableWrapper, + Some(NodeTypeId::Element(ElementTypeId::HTMLTableColElement)) => { + SpecificFragmentInfo::TableColumn(TableColumnFragmentInfo::new(node)) } - Some(ElementNodeTypeId(HTMLTableDataCellElementTypeId)) | - Some(ElementNodeTypeId(HTMLTableHeaderCellElementTypeId)) => TableCellFragment, - Some(ElementNodeTypeId(HTMLTableRowElementTypeId)) | - Some(ElementNodeTypeId(HTMLTableSectionElementTypeId)) => TableRowFragment, - Some(TextNodeTypeId) => UnscannedTextFragment(UnscannedTextFragmentInfo::new(node)), + Some(NodeTypeId::Element(ElementTypeId::HTMLTableDataCellElement)) | + Some(NodeTypeId::Element(ElementTypeId::HTMLTableHeaderCellElement)) => SpecificFragmentInfo::TableCell, + Some(NodeTypeId::Element(ElementTypeId::HTMLTableRowElement)) | + Some(NodeTypeId::Element(ElementTypeId::HTMLTableSectionElement)) => SpecificFragmentInfo::TableRow, + Some(NodeTypeId::Text) => SpecificFragmentInfo::UnscannedText(UnscannedTextFragmentInfo::new(node)), _ => { // This includes pseudo-elements. - GenericFragment + SpecificFragmentInfo::Generic } } } @@ -304,14 +296,14 @@ impl<'a> FlowConstructor<'a> { }; match whitespace_stripping { - NoWhitespaceStripping => {} - StripWhitespaceFromStart => { + WhitespaceStrippingMode::None => {} + WhitespaceStrippingMode::FromStart => { strip_ignorable_whitespace_from_start(&mut fragments); if fragments.is_empty() { return }; } - StripWhitespaceFromEnd => { + WhitespaceStrippingMode::FromEnd => { strip_ignorable_whitespace_from_end(&mut fragments); if fragments.is_empty() { return @@ -323,8 +315,8 @@ impl<'a> FlowConstructor<'a> { let mut inline_block_flows = vec!(); for f in fragments.iter() { match f.specific { - InlineBlockFragment(ref info) => inline_block_flows.push(info.flow_ref.clone()), - InlineAbsoluteHypotheticalFragment(ref info) => { + SpecificFragmentInfo::InlineBlock(ref info) => inline_block_flows.push(info.flow_ref.clone()), + SpecificFragmentInfo::InlineAbsoluteHypothetical(ref info) => { inline_block_flows.push(info.flow_ref.clone()) } _ => {} @@ -374,12 +366,12 @@ impl<'a> FlowConstructor<'a> { abs_descendants: &mut Descendants, first_fragment: &mut bool) { match kid.swap_out_construction_result() { - NoConstructionResult => {} - FlowConstructionResult(kid_flow, kid_abs_descendants) => { + ConstructionResult::None => {} + ConstructionResult::Flow(kid_flow, kid_abs_descendants) => { // If kid_flow is TableCaptionFlow, kid_flow should be added under // TableWrapperFlow. if flow.is_table() && kid_flow.deref().is_table_caption() { - kid.set_flow_construction_result(FlowConstructionResult(kid_flow, + kid.set_flow_construction_result(ConstructionResult::Flow(kid_flow, Descendants::new())) } else if flow.need_anonymous_flow(&*kid_flow) { consecutive_siblings.push(kid_flow) @@ -393,7 +385,7 @@ impl<'a> FlowConstructor<'a> { InlineFragmentsAccumulator::new()), flow, consecutive_siblings, - StripWhitespaceFromStart, + WhitespaceStrippingMode::FromStart, node); if !consecutive_siblings.is_empty() { let consecutive_siblings = mem::replace(consecutive_siblings, vec!()); @@ -403,7 +395,7 @@ impl<'a> FlowConstructor<'a> { } abs_descendants.push_descendants(kid_abs_descendants); } - ConstructionItemConstructionResult(InlineFragmentsConstructionItem( + ConstructionResult::ConstructionItem(ConstructionItem::InlineFragments( InlineFragmentsConstructionResult { splits, fragments: successor_fragments, @@ -423,9 +415,9 @@ impl<'a> FlowConstructor<'a> { // whitespace per CSS 2.1 § 9.2.1.1. let whitespace_stripping = if *first_fragment { *first_fragment = false; - StripWhitespaceFromStart + WhitespaceStrippingMode::FromStart } else { - NoWhitespaceStripping + WhitespaceStrippingMode::None }; // Flush any inline fragments that we were gathering up. @@ -452,20 +444,20 @@ impl<'a> FlowConstructor<'a> { inline_fragment_accumulator.push_all(successor_fragments); abs_descendants.push_descendants(kid_abs_descendants); } - ConstructionItemConstructionResult(WhitespaceConstructionItem(whitespace_node, + ConstructionResult::ConstructionItem(ConstructionItem::Whitespace(whitespace_node, whitespace_style, whitespace_damage)) => { // Add whitespace results. They will be stripped out later on when // between block elements, and retained when between inline elements. let fragment_info = - UnscannedTextFragment(UnscannedTextFragmentInfo::from_text(" ".to_string())); + SpecificFragmentInfo::UnscannedText(UnscannedTextFragmentInfo::from_text(" ".to_string())); let fragment = Fragment::from_opaque_node_and_style(whitespace_node, whitespace_style, whitespace_damage, fragment_info); inline_fragment_accumulator.fragments.push_back(fragment); } - ConstructionItemConstructionResult(TableColumnFragmentConstructionItem(_)) => { + ConstructionResult::ConstructionItem(ConstructionItem::TableColumnFragment(_)) => { // TODO: Implement anonymous table objects for missing parents // CSS 2.1 § 17.2.1, step 3-2 } @@ -495,7 +487,7 @@ impl<'a> FlowConstructor<'a> { // List of absolute descendants, in tree order. let mut abs_descendants = Descendants::new(); for kid in node.children() { - if kid.get_pseudo_element_type() != Normal { + if kid.get_pseudo_element_type() != PseudoElementType::Normal { self.process(&kid); } @@ -514,7 +506,7 @@ impl<'a> FlowConstructor<'a> { self.flush_inline_fragments_to_flow_or_list(inline_fragment_accumulator, &mut flow, &mut consecutive_siblings, - StripWhitespaceFromEnd, + WhitespaceStrippingMode::FromEnd, node); if !consecutive_siblings.is_empty() { self.generate_anonymous_missing_child(consecutive_siblings, &mut flow, node); @@ -537,7 +529,7 @@ impl<'a> FlowConstructor<'a> { abs_descendants.push(flow.clone()); } } - FlowConstructionResult(flow, abs_descendants) + ConstructionResult::Flow(flow, abs_descendants) } /// Constructs a flow for the given block node and its children. This method creates an @@ -553,19 +545,19 @@ impl<'a> FlowConstructor<'a> { /// `