From de5550d56eca7a1ae8485fea7df8792423d225f3 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 22 Oct 2014 14:45:35 -0600 Subject: [PATCH] servo: Merge #3765 - util: Make some minor formatting cleanups to profiling and gfx (from pcwalton:profiler-cleanups); r=cgaebel The only real user-visible change this effects is to trim URLs to 30 characters so they don't make huge lines on the terminal. r? @cgaebel Source-Repo: https://github.com/servo/servo Source-Revision: a6f0159cb85e3b84a826c41ae5ad1b6aea09d7cc --- servo/components/gfx/font_context.rs | 3 +- servo/components/util/time.rs | 17 ++++--- servo/ports/glfw/window.rs | 67 +++++++--------------------- 3 files changed, 29 insertions(+), 58 deletions(-) diff --git a/servo/components/gfx/font_context.rs b/servo/components/gfx/font_context.rs index e70e7de0f02c..5ad81019d3a1 100644 --- a/servo/components/gfx/font_context.rs +++ b/servo/components/gfx/font_context.rs @@ -215,7 +215,8 @@ impl FontContext { /// reference if already used by this font context. pub fn get_render_font_from_template(&mut self, template: &Arc, - pt_size: Au) -> Rc> { + pt_size: Au) + -> Rc> { for cached_font in self.render_font_cache.iter() { if cached_font.pt_size == pt_size && cached_font.identifier == template.identifier { diff --git a/servo/components/util/time.rs b/servo/components/util/time.rs index 596b8931be2e..232e73b38029 100644 --- a/servo/components/util/time.rs +++ b/servo/components/util/time.rs @@ -27,9 +27,9 @@ impl TimeProfilerChan { #[deriving(PartialEq, Clone, PartialOrd, Eq, Ord)] pub struct TimerMetadata { - url: String, - iframe: bool, - first_reflow: bool, + url: String, + iframe: bool, + incremental: bool, } pub trait Formatable { @@ -42,9 +42,14 @@ impl Formatable for Option { // TODO(cgaebel): Center-align in the format strings as soon as rustc supports it. &Some(ref meta) => { let url = meta.url.as_slice(); - let first_reflow = if meta.first_reflow { " yes" } else { " no " }; + let url = if url.len() > 30 { + url.slice_to(30) + } else { + url + }; + let incremental = if meta.incremental { " yes" } else { " no " }; let iframe = if meta.iframe { " yes" } else { " no " }; - format!(" {:14} {:9} {:30}", first_reflow, iframe, url) + format!(" {:14} {:9} {:30}", incremental, iframe, url) }, &None => format!(" {:14} {:9} {:30}", " N/A", " N/A", " N/A") @@ -256,7 +261,7 @@ pub fn profile(category: TimeProfilerCategory, TimerMetadata { url: url.serialize(), iframe: iframe, - first_reflow: first_reflow, + incremental: !first_reflow, }); time_profiler_chan.send(TimeMsg((category, meta), ms)); return val; diff --git a/servo/ports/glfw/window.rs b/servo/ports/glfw/window.rs index 50be31f05db8..597175ebfac8 100644 --- a/servo/ports/glfw/window.rs +++ b/servo/ports/glfw/window.rs @@ -4,65 +4,28 @@ //! A windowing implementation using GLFW. -use compositing::windowing::{WindowEvent, WindowMethods}; -use compositing::windowing::{IdleWindowEvent, ResizeWindowEvent, LoadUrlWindowEvent, MouseWindowEventClass, MouseWindowMoveEventClass}; -use compositing::windowing::{ScrollWindowEvent, ZoomWindowEvent, PinchZoomWindowEvent, NavigationWindowEvent, FinishedWindowEvent}; -use compositing::windowing::{QuitWindowEvent, MouseWindowClickEvent, MouseWindowMouseDownEvent, MouseWindowMouseUpEvent}; -use compositing::windowing::RefreshWindowEvent; -use compositing::windowing::{Forward, Back}; - use alert::{Alert, AlertMethods}; -use libc::c_int; -use time; -use time::Timespec; -use std::cell::{Cell, RefCell}; -use std::comm::Receiver; -use std::rc::Rc; - +use compositing::windowing::{WindowEvent, WindowMethods}; +use compositing::windowing::{IdleWindowEvent, ResizeWindowEvent, LoadUrlWindowEvent}; +use compositing::windowing::{MouseWindowEventClass, MouseWindowMoveEventClass, ScrollWindowEvent}; +use compositing::windowing::{ZoomWindowEvent, PinchZoomWindowEvent, NavigationWindowEvent}; +use compositing::windowing::{FinishedWindowEvent, QuitWindowEvent, MouseWindowClickEvent}; +use compositing::windowing::{MouseWindowMouseDownEvent, MouseWindowMouseUpEvent}; +use compositing::windowing::{RefreshWindowEvent, Forward, Back}; use geom::point::{Point2D, TypedPoint2D}; use geom::scale_factor::ScaleFactor; use geom::size::TypedSize2D; +use glfw::{mod, Context}; use layers::geometry::DevicePixel; +use libc::c_int; use msg::compositor_msg::{IdleRenderState, RenderState, RenderingRenderState}; use msg::compositor_msg::{FinishedLoading, Blank, Loading, PerformingLayout, ReadyState}; +use std::cell::{Cell, RefCell}; +use std::comm::Receiver; +use std::rc::Rc; +use time::{mod, Timespec}; use util::geometry::ScreenPx; -use glfw; -use glfw::Context; - -/// A structure responsible for setting up and tearing down the entire windowing system. -macro_rules! glfw_callback( - ( - $callback:path ($($arg:ident: $arg_ty:ty),*) $block:expr - ) => ({ - struct GlfwCallback; - impl $callback for GlfwCallback { - fn call(&self $(, $arg: $arg_ty)*) { - $block - } - } - ~GlfwCallback - }); - - ( - [$($state:ident: $state_ty:ty),*], - $callback:path ($($arg:ident: $arg_ty:ty),*) $block:expr - ) => ({ - struct GlfwCallback { - $($state: $state_ty,)* - } - impl $callback for GlfwCallback { - fn call(&self $(, $arg: $arg_ty)*) { - $block - } - } - ~GlfwCallback { - $($state: $state,)* - } - }); -) - - /// The type of a window. pub struct Window { glfw: glfw::Glfw, @@ -337,7 +300,8 @@ impl Window { pixel_dist.y * pixel_dist.y) as f64).sqrt(); if pixel_dist < max_pixel_dist { let click_event = MouseWindowClickEvent(button as uint, - TypedPoint2D(x as f32, y as f32)); + TypedPoint2D(x as f32, + y as f32)); self.event_queue.borrow_mut().push(MouseWindowEventClass(click_event)); } } @@ -363,3 +327,4 @@ impl Window { } } } +