mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Remove 'get_*' on getters as per RFC 0344 on various components
This commit is contained in:
parent
2733060564
commit
7320433cca
30 changed files with 167 additions and 168 deletions
|
@ -170,7 +170,7 @@ impl<'a> CanvasPaintTask<'a> {
|
|||
Canvas2dMsg::SetGlobalAlpha(alpha) => painter.set_global_alpha(alpha),
|
||||
Canvas2dMsg::SetGlobalComposition(op) => painter.set_global_composition(op),
|
||||
Canvas2dMsg::GetImageData(dest_rect, canvas_size, chan)
|
||||
=> painter.get_image_data(dest_rect, canvas_size, chan),
|
||||
=> painter.image_data(dest_rect, canvas_size, chan),
|
||||
Canvas2dMsg::PutImageData(imagedata, offset, image_data_size, dirty_rect)
|
||||
=> painter.put_image_data(imagedata, offset, image_data_size, dirty_rect),
|
||||
Canvas2dMsg::SetShadowOffsetX(value) => painter.set_shadow_offset_x(value),
|
||||
|
@ -516,7 +516,7 @@ impl<'a> CanvasPaintTask<'a> {
|
|||
unimplemented!()
|
||||
}
|
||||
|
||||
fn get_image_data(&self,
|
||||
fn image_data(&self,
|
||||
dest_rect: Rect<i32>,
|
||||
canvas_size: Size2D<f64>,
|
||||
chan: IpcSender<Vec<u8>>) {
|
||||
|
|
|
@ -57,7 +57,7 @@ impl WebGLPaintTask {
|
|||
pub fn handle_webgl_message(&self, message: CanvasWebGLMsg) {
|
||||
match message {
|
||||
CanvasWebGLMsg::GetContextAttributes(sender) =>
|
||||
self.get_context_attributes(sender),
|
||||
self.context_attributes(sender),
|
||||
CanvasWebGLMsg::ActiveTexture(target) =>
|
||||
gl::active_texture(target),
|
||||
CanvasWebGLMsg::BlendColor(r, g, b, a) =>
|
||||
|
@ -111,11 +111,11 @@ impl WebGLPaintTask {
|
|||
CanvasWebGLMsg::EnableVertexAttribArray(attrib_id) =>
|
||||
gl::enable_vertex_attrib_array(attrib_id),
|
||||
CanvasWebGLMsg::GetAttribLocation(program_id, name, chan) =>
|
||||
self.get_attrib_location(program_id, name, chan),
|
||||
self.attrib_location(program_id, name, chan),
|
||||
CanvasWebGLMsg::GetShaderParameter(shader_id, param_id, chan) =>
|
||||
self.get_shader_parameter(shader_id, param_id, chan),
|
||||
self.shader_parameter(shader_id, param_id, chan),
|
||||
CanvasWebGLMsg::GetUniformLocation(program_id, name, chan) =>
|
||||
self.get_uniform_location(program_id, name, chan),
|
||||
self.uniform_location(program_id, name, chan),
|
||||
CanvasWebGLMsg::CompileShader(shader_id, source) =>
|
||||
self.compile_shader(shader_id, source),
|
||||
CanvasWebGLMsg::CreateBuffer(chan) =>
|
||||
|
@ -214,7 +214,7 @@ impl WebGLPaintTask {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn get_context_attributes(&self, sender: IpcSender<GLContextAttributes>) {
|
||||
fn context_attributes(&self, sender: IpcSender<GLContextAttributes>) {
|
||||
sender.send(*self.gl_context.borrow_attributes()).unwrap()
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,7 @@ impl WebGLPaintTask {
|
|||
gl::compile_shader(shader_id);
|
||||
}
|
||||
|
||||
fn get_attrib_location(&self, program_id: u32, name: String, chan: IpcSender<Option<i32>> ) {
|
||||
fn attrib_location(&self, program_id: u32, name: String, chan: IpcSender<Option<i32>> ) {
|
||||
let attrib_location = gl::get_attrib_location(program_id, &name);
|
||||
|
||||
let attrib_location = if attrib_location == -1 {
|
||||
|
@ -317,7 +317,7 @@ impl WebGLPaintTask {
|
|||
chan.send(attrib_location).unwrap();
|
||||
}
|
||||
|
||||
fn get_shader_parameter(&self,
|
||||
fn shader_parameter(&self,
|
||||
shader_id: u32,
|
||||
param_id: u32,
|
||||
chan: IpcSender<WebGLShaderParameter>) {
|
||||
|
@ -332,7 +332,7 @@ impl WebGLPaintTask {
|
|||
chan.send(result).unwrap();
|
||||
}
|
||||
|
||||
fn get_uniform_location(&self, program_id: u32, name: String, chan: IpcSender<Option<i32>>) {
|
||||
fn uniform_location(&self, program_id: u32, name: String, chan: IpcSender<Option<i32>>) {
|
||||
let location = gl::get_uniform_location(program_id, &name);
|
||||
let location = if location == -1 {
|
||||
None
|
||||
|
|
|
@ -373,12 +373,12 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
ShutdownState::NotShuttingDown) => {
|
||||
self.set_frame_tree(&frame_tree, response_chan, new_constellation_chan);
|
||||
self.send_viewport_rects_for_all_layers();
|
||||
self.get_title_for_main_frame();
|
||||
self.title_for_main_frame();
|
||||
}
|
||||
|
||||
(Msg::InitializeLayersForPipeline(pipeline_id, epoch, properties),
|
||||
ShutdownState::NotShuttingDown) => {
|
||||
self.get_or_create_pipeline_details(pipeline_id).current_epoch = epoch;
|
||||
self.pipeline_details(pipeline_id).current_epoch = epoch;
|
||||
self.collect_old_layers(pipeline_id, &properties);
|
||||
for (index, layer_properties) in properties.iter().enumerate() {
|
||||
if index == 0 {
|
||||
|
@ -553,28 +553,28 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
animation_state: AnimationState) {
|
||||
match animation_state {
|
||||
AnimationState::AnimationsPresent => {
|
||||
self.get_or_create_pipeline_details(pipeline_id).animations_running = true;
|
||||
self.pipeline_details(pipeline_id).animations_running = true;
|
||||
self.composite_if_necessary(CompositingReason::Animation);
|
||||
}
|
||||
AnimationState::AnimationCallbacksPresent => {
|
||||
if self.get_or_create_pipeline_details(pipeline_id).animation_callbacks_running {
|
||||
if self.pipeline_details(pipeline_id).animation_callbacks_running {
|
||||
return
|
||||
}
|
||||
self.get_or_create_pipeline_details(pipeline_id).animation_callbacks_running =
|
||||
self.pipeline_details(pipeline_id).animation_callbacks_running =
|
||||
true;
|
||||
self.tick_animations_for_pipeline(pipeline_id);
|
||||
self.composite_if_necessary(CompositingReason::Animation);
|
||||
}
|
||||
AnimationState::NoAnimationsPresent => {
|
||||
self.get_or_create_pipeline_details(pipeline_id).animations_running = false;
|
||||
self.pipeline_details(pipeline_id).animations_running = false;
|
||||
}
|
||||
AnimationState::NoAnimationCallbacksPresent => {
|
||||
self.get_or_create_pipeline_details(pipeline_id).animation_callbacks_running = false;
|
||||
self.pipeline_details(pipeline_id).animation_callbacks_running = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_or_create_pipeline_details<'a>(&'a mut self,
|
||||
pub fn pipeline_details<'a>(&'a mut self,
|
||||
pipeline_id: PipelineId)
|
||||
-> &'a mut PipelineDetails {
|
||||
if !self.pipeline_details.contains_key(&pipeline_id) {
|
||||
|
@ -583,7 +583,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
return self.pipeline_details.get_mut(&pipeline_id).unwrap();
|
||||
}
|
||||
|
||||
pub fn get_pipeline<'a>(&'a self, pipeline_id: PipelineId) -> &'a CompositionPipeline {
|
||||
pub fn pipeline<'a>(&'a self, pipeline_id: PipelineId) -> &'a CompositionPipeline {
|
||||
match self.pipeline_details.get(&pipeline_id) {
|
||||
Some(ref details) => {
|
||||
match details.pipeline {
|
||||
|
@ -656,7 +656,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
WantsScrollEventsFlag::WantsScrollEvents,
|
||||
opts::get().tile_size);
|
||||
|
||||
self.get_or_create_pipeline_details(pipeline.id).pipeline = Some(pipeline.clone());
|
||||
self.pipeline_details(pipeline.id).pipeline = Some(pipeline.clone());
|
||||
|
||||
// All root layers mask to bounds.
|
||||
*root_layer.masks_to_bounds.borrow_mut() = true;
|
||||
|
@ -1306,7 +1306,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
if layer.extra_data.borrow().id == LayerId::null() {
|
||||
let layer_rect = Rect::new(-layer.extra_data.borrow().scroll_offset.to_untyped(),
|
||||
layer.bounds.borrow().size.to_untyped());
|
||||
let pipeline = self.get_pipeline(layer.pipeline_id());
|
||||
let pipeline = self.pipeline(layer.pipeline_id());
|
||||
pipeline.script_chan.send(ConstellationControlMsg::Viewport(pipeline.id.clone(), layer_rect)).unwrap();
|
||||
}
|
||||
|
||||
|
@ -1348,7 +1348,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
|
||||
for (pipeline_id, requests) in pipeline_requests {
|
||||
let msg = ChromeToPaintMsg::Paint(requests, self.frame_tree_id);
|
||||
let _ = self.get_pipeline(pipeline_id).chrome_to_paint_chan.send(msg);
|
||||
let _ = self.pipeline(pipeline_id).chrome_to_paint_chan.send(msg);
|
||||
}
|
||||
|
||||
true
|
||||
|
@ -1790,7 +1790,7 @@ impl<Window> CompositorEventListener for IOCompositor<Window> where Window: Wind
|
|||
self.viewport_zoom.get() as f32
|
||||
}
|
||||
|
||||
fn get_title_for_main_frame(&self) {
|
||||
fn title_for_main_frame(&self) {
|
||||
let root_pipeline_id = match self.root_pipeline {
|
||||
None => return,
|
||||
Some(ref root_pipeline) => root_pipeline.id,
|
||||
|
|
|
@ -404,7 +404,7 @@ impl CompositorLayer for Layer<CompositorData> {
|
|||
MouseUpEvent(button, event_point),
|
||||
};
|
||||
|
||||
let pipeline = compositor.get_pipeline(self.pipeline_id());
|
||||
let pipeline = compositor.pipeline(self.pipeline_id());
|
||||
let _ = pipeline.script_chan.send(ConstellationControlMsg::SendEvent(pipeline.id.clone(), message));
|
||||
}
|
||||
|
||||
|
@ -413,7 +413,7 @@ impl CompositorLayer for Layer<CompositorData> {
|
|||
cursor: TypedPoint2D<LayerPixel, f32>)
|
||||
where Window: WindowMethods {
|
||||
let message = MouseMoveEvent(cursor.to_untyped());
|
||||
let pipeline = compositor.get_pipeline(self.pipeline_id());
|
||||
let pipeline = compositor.pipeline(self.pipeline_id());
|
||||
let _ = pipeline.script_chan.send(ConstellationControlMsg::SendEvent(pipeline.id.clone(), message));
|
||||
}
|
||||
|
||||
|
|
|
@ -294,5 +294,5 @@ pub trait CompositorEventListener {
|
|||
fn shutdown(&mut self);
|
||||
fn pinch_zoom_level(&self) -> f32;
|
||||
/// Requests that the compositor send the title for the main frame as soon as possible.
|
||||
fn get_title_for_main_frame(&self);
|
||||
fn title_for_main_frame(&self);
|
||||
}
|
||||
|
|
|
@ -152,5 +152,5 @@ impl CompositorEventListener for NullCompositor {
|
|||
1.0
|
||||
}
|
||||
|
||||
fn get_title_for_main_frame(&self) {}
|
||||
fn title_for_main_frame(&self) {}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ impl ActorRegistry {
|
|||
}
|
||||
|
||||
/// Get shareable registry through threads
|
||||
pub fn get_shareable(&self) -> Arc<Mutex<ActorRegistry>> {
|
||||
pub fn shareable(&self) -> Arc<Mutex<ActorRegistry>> {
|
||||
self.shareable.as_ref().unwrap().clone()
|
||||
}
|
||||
|
||||
|
|
|
@ -204,7 +204,7 @@ impl Actor for TimelineActor {
|
|||
}
|
||||
}
|
||||
|
||||
let emitter = Emitter::new(self.name(), registry.get_shareable(),
|
||||
let emitter = Emitter::new(self.name(), registry.shareable(),
|
||||
registry.start_stamp(),
|
||||
stream.try_clone().unwrap(),
|
||||
self.memory_actor.borrow().clone(),
|
||||
|
|
|
@ -42,7 +42,7 @@ pub trait FontHandleMethods: Sized {
|
|||
fn glyph_h_advance(&self, GlyphId) -> Option<FractionalPixel>;
|
||||
fn glyph_h_kerning(&self, GlyphId, GlyphId) -> FractionalPixel;
|
||||
fn metrics(&self) -> FontMetrics;
|
||||
fn get_table_for_tag(&self, FontTableTag) -> Option<Box<FontTable>>;
|
||||
fn table_for_tag(&self, FontTableTag) -> Option<Box<FontTable>>;
|
||||
}
|
||||
|
||||
// Used to abstract over the shaper's choice of fixed int representation.
|
||||
|
@ -170,8 +170,8 @@ impl Font {
|
|||
self.shaper.as_ref().unwrap()
|
||||
}
|
||||
|
||||
pub fn get_table_for_tag(&self, tag: FontTableTag) -> Option<Box<FontTable>> {
|
||||
let result = self.handle.get_table_for_tag(tag);
|
||||
pub fn table_for_tag(&self, tag: FontTableTag) -> Option<Box<FontTable>> {
|
||||
let result = self.handle.table_for_tag(tag);
|
||||
let status = if result.is_some() { "Found" } else { "Didn't find" };
|
||||
|
||||
debug!("{} font table[{}] with family={}, face={}",
|
||||
|
|
|
@ -2,14 +2,13 @@
|
|||
* 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 platform::font_context::FontContextHandle;
|
||||
use platform::font_list::get_available_families;
|
||||
use platform::font_list::get_last_resort_font_families;
|
||||
use platform::font_list::get_system_default_family;
|
||||
use platform::font_list::get_variations_for_family;
|
||||
|
||||
use font_template::{FontTemplate, FontTemplateDescriptor};
|
||||
use net_traits::{ResourceTask, load_whole_resource};
|
||||
use platform::font_context::FontContextHandle;
|
||||
use platform::font_list::for_each_available_family;
|
||||
use platform::font_list::for_each_variation;
|
||||
use platform::font_list::last_resort_font_families;
|
||||
use platform::font_list::system_default_family;
|
||||
use platform::font_template::FontTemplateData;
|
||||
use std::borrow::ToOwned;
|
||||
use std::collections::HashMap;
|
||||
|
@ -42,7 +41,7 @@ impl FontFamily {
|
|||
// TODO(Issue #190): if not in the fast path above, do
|
||||
// expensive matching of weights, etc.
|
||||
for template in &mut self.templates {
|
||||
let maybe_template = template.get_if_matches(fctx, desc);
|
||||
let maybe_template = template.data_for_descriptor(fctx, desc);
|
||||
if maybe_template.is_some() {
|
||||
return maybe_template;
|
||||
}
|
||||
|
@ -103,7 +102,7 @@ struct FontCache {
|
|||
|
||||
fn add_generic_font(generic_fonts: &mut HashMap<LowercaseString, LowercaseString>,
|
||||
generic_name: &str, mapped_name: &str) {
|
||||
let opt_system_default = get_system_default_family(generic_name);
|
||||
let opt_system_default = system_default_family(generic_name);
|
||||
let family_name = match opt_system_default {
|
||||
Some(system_default) => LowercaseString::new(&system_default),
|
||||
None => LowercaseString::new(mapped_name),
|
||||
|
@ -119,11 +118,11 @@ impl FontCache {
|
|||
match msg {
|
||||
Command::GetFontTemplate(family, descriptor, result) => {
|
||||
let family = LowercaseString::new(&family);
|
||||
let maybe_font_template = self.get_font_template(&family, &descriptor);
|
||||
let maybe_font_template = self.find_font_template(&family, &descriptor);
|
||||
result.send(Reply::GetFontTemplateReply(maybe_font_template)).unwrap();
|
||||
}
|
||||
Command::GetLastResortFontTemplate(descriptor, result) => {
|
||||
let font_template = self.get_last_resort_font_template(&descriptor);
|
||||
let font_template = self.last_resort_font_template(&descriptor);
|
||||
result.send(Reply::GetFontTemplateReply(Some(font_template))).unwrap();
|
||||
}
|
||||
Command::AddWebFont(family_name, src, result) => {
|
||||
|
@ -149,7 +148,7 @@ impl FontCache {
|
|||
}
|
||||
Source::Local(ref local_family_name) => {
|
||||
let family = &mut self.web_families.get_mut(&family_name).unwrap();
|
||||
get_variations_for_family(&local_family_name, |path| {
|
||||
for_each_variation(&local_family_name, |path| {
|
||||
family.add_template(Atom::from_slice(&path), None);
|
||||
});
|
||||
}
|
||||
|
@ -166,7 +165,7 @@ impl FontCache {
|
|||
|
||||
fn refresh_local_families(&mut self) {
|
||||
self.local_families.clear();
|
||||
get_available_families(|family_name| {
|
||||
for_each_available_family(|family_name| {
|
||||
let family_name = LowercaseString::new(&family_name);
|
||||
if !self.local_families.contains_key(&family_name) {
|
||||
let family = FontFamily::new();
|
||||
|
@ -191,7 +190,7 @@ impl FontCache {
|
|||
let s = self.local_families.get_mut(family_name).unwrap();
|
||||
|
||||
if s.templates.is_empty() {
|
||||
get_variations_for_family(family_name, |path| {
|
||||
for_each_variation(family_name, |path| {
|
||||
s.add_template(Atom::from_slice(&path), None);
|
||||
});
|
||||
}
|
||||
|
@ -221,7 +220,7 @@ impl FontCache {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_font_template(&mut self, family: &LowercaseString, desc: &FontTemplateDescriptor)
|
||||
fn find_font_template(&mut self, family: &LowercaseString, desc: &FontTemplateDescriptor)
|
||||
-> Option<Arc<FontTemplateData>> {
|
||||
let transformed_family_name = self.transform_family(family);
|
||||
let mut maybe_template = self.find_font_in_web_family(&transformed_family_name, desc);
|
||||
|
@ -231,9 +230,9 @@ impl FontCache {
|
|||
maybe_template
|
||||
}
|
||||
|
||||
fn get_last_resort_font_template(&mut self, desc: &FontTemplateDescriptor)
|
||||
fn last_resort_font_template(&mut self, desc: &FontTemplateDescriptor)
|
||||
-> Arc<FontTemplateData> {
|
||||
let last_resort = get_last_resort_font_families();
|
||||
let last_resort = last_resort_font_families();
|
||||
|
||||
for family in &last_resort {
|
||||
let family = LowercaseString::new(family);
|
||||
|
@ -285,7 +284,7 @@ impl FontCacheTask {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_font_template(&self, family: String, desc: FontTemplateDescriptor)
|
||||
pub fn find_font_template(&self, family: String, desc: FontTemplateDescriptor)
|
||||
-> Option<Arc<FontTemplateData>> {
|
||||
|
||||
let (response_chan, response_port) = channel();
|
||||
|
@ -300,7 +299,7 @@ impl FontCacheTask {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_last_resort_font_template(&self, desc: FontTemplateDescriptor)
|
||||
pub fn last_resort_font_template(&self, desc: FontTemplateDescriptor)
|
||||
-> Arc<FontTemplateData> {
|
||||
|
||||
let (response_chan, response_port) = channel();
|
||||
|
|
|
@ -134,7 +134,7 @@ impl FontContext {
|
|||
/// Create a group of fonts for use in layout calculations. May return
|
||||
/// a cached font if this font instance has already been used by
|
||||
/// this context.
|
||||
pub fn get_layout_font_group_for_style(&mut self, style: Arc<SpecifiedFontStyle>)
|
||||
pub fn layout_font_group_for_style(&mut self, style: Arc<SpecifiedFontStyle>)
|
||||
-> Rc<FontGroup> {
|
||||
let address = &*style as *const SpecifiedFontStyle as usize;
|
||||
if let Some(ref cached_font_group) = self.layout_font_group_cache.get(&address) {
|
||||
|
@ -186,9 +186,9 @@ impl FontContext {
|
|||
}
|
||||
|
||||
if !cache_hit {
|
||||
let font_template = self.font_cache_task.get_font_template(family.name()
|
||||
.to_owned(),
|
||||
desc.clone());
|
||||
let font_template = self.font_cache_task.find_font_template(family.name()
|
||||
.to_owned(),
|
||||
desc.clone());
|
||||
match font_template {
|
||||
Some(font_template) => {
|
||||
let layout_font = self.create_layout_font(font_template,
|
||||
|
@ -236,7 +236,7 @@ impl FontContext {
|
|||
}
|
||||
|
||||
if !cache_hit {
|
||||
let font_template = self.font_cache_task.get_last_resort_font_template(desc.clone());
|
||||
let font_template = self.font_cache_task.last_resort_font_template(desc.clone());
|
||||
let layout_font = self.create_layout_font(font_template,
|
||||
desc.clone(),
|
||||
style.font_size,
|
||||
|
@ -261,7 +261,7 @@ impl FontContext {
|
|||
|
||||
/// Create a paint font for use with azure. May return a cached
|
||||
/// reference if already used by this font context.
|
||||
pub fn get_paint_font_from_template(&mut self,
|
||||
pub fn paint_font_from_template(&mut self,
|
||||
template: &Arc<FontTemplateData>,
|
||||
pt_size: Au)
|
||||
-> Rc<RefCell<ScaledFont>> {
|
||||
|
|
|
@ -88,7 +88,7 @@ impl FontTemplate {
|
|||
}
|
||||
|
||||
/// Get the data for creating a font if it matches a given descriptor.
|
||||
pub fn get_if_matches(&mut self,
|
||||
pub fn data_for_descriptor(&mut self,
|
||||
fctx: &FontContextHandle,
|
||||
requested_desc: &FontTemplateDescriptor)
|
||||
-> Option<Arc<FontTemplateData>> {
|
||||
|
@ -100,13 +100,13 @@ impl FontTemplate {
|
|||
match self.descriptor {
|
||||
Some(actual_desc) => {
|
||||
if *requested_desc == actual_desc {
|
||||
Some(self.get_data())
|
||||
Some(self.data())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
},
|
||||
None if self.is_valid => {
|
||||
let data = self.get_data();
|
||||
let data = self.data();
|
||||
let handle: Result<FontHandle, ()> =
|
||||
FontHandleMethods::new_from_template(fctx, data.clone(), None);
|
||||
match handle {
|
||||
|
@ -138,7 +138,7 @@ impl FontTemplate {
|
|||
/// Get the data for creating a font.
|
||||
pub fn get(&mut self) -> Option<Arc<FontTemplateData>> {
|
||||
if self.is_valid {
|
||||
Some(self.get_data())
|
||||
Some(self.data())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ impl FontTemplate {
|
|||
/// Get the font template data. If any strong references still
|
||||
/// exist, it will return a clone, otherwise it will load the
|
||||
/// font data and store a weak reference to it internally.
|
||||
pub fn get_data(&mut self) -> Arc<FontTemplateData> {
|
||||
pub fn data(&mut self) -> Arc<FontTemplateData> {
|
||||
let maybe_data = match self.weak_ref {
|
||||
Some(ref data) => data.upgrade(),
|
||||
None => None,
|
||||
|
|
|
@ -1272,7 +1272,7 @@ impl<'a> PaintContext<'a> {
|
|||
self.create_draw_target_for_blur_if_necessary(&text.base.bounds, text.blur_radius);
|
||||
{
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let font = self.font_context.get_paint_font_from_template(
|
||||
let font = self.font_context.paint_font_from_template(
|
||||
&text.text_run.font_template, text.text_run.actual_pt_size);
|
||||
font.borrow()
|
||||
.draw_text(&temporary_draw_target.draw_target,
|
||||
|
|
|
@ -320,7 +320,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
|
|||
}
|
||||
let new_buffers = (0..tile_count).map(|i| {
|
||||
let thread_id = i % self.worker_threads.len();
|
||||
self.worker_threads[thread_id].get_painted_tile_buffer()
|
||||
self.worker_threads[thread_id].painted_tile_buffer()
|
||||
}).collect();
|
||||
|
||||
let layer_buffer_set = box LayerBufferSet {
|
||||
|
@ -483,7 +483,7 @@ impl WorkerThreadProxy {
|
|||
self.sender.send(msg).unwrap()
|
||||
}
|
||||
|
||||
fn get_painted_tile_buffer(&mut self) -> Box<LayerBuffer> {
|
||||
fn painted_tile_buffer(&mut self) -> Box<LayerBuffer> {
|
||||
match self.receiver.recv().unwrap() {
|
||||
MsgFromWorkerThread::PaintedTile(layer_buffer) => layer_buffer,
|
||||
}
|
||||
|
|
|
@ -263,7 +263,7 @@ impl FontHandleMethods for FontHandle {
|
|||
return metrics;
|
||||
}
|
||||
|
||||
fn get_table_for_tag(&self, tag: FontTableTag) -> Option<Box<FontTable>> {
|
||||
fn table_for_tag(&self, tag: FontTableTag) -> Option<Box<FontTable>> {
|
||||
let tag = tag as FT_ULong;
|
||||
|
||||
unsafe {
|
||||
|
|
|
@ -27,7 +27,7 @@ static FC_FILE: &'static [u8] = b"file\0";
|
|||
static FC_INDEX: &'static [u8] = b"index\0";
|
||||
static FC_FONTFORMAT: &'static [u8] = b"fontformat\0";
|
||||
|
||||
pub fn get_available_families<F>(mut callback: F) where F: FnMut(String) {
|
||||
pub fn for_each_available_family<F>(mut callback: F) where F: FnMut(String) {
|
||||
unsafe {
|
||||
let config = FcConfigGetCurrent();
|
||||
let fontSet = FcConfigGetFonts(config, FcSetSystem);
|
||||
|
@ -57,7 +57,7 @@ pub fn get_available_families<F>(mut callback: F) where F: FnMut(String) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_variations_for_family<F>(family_name: &str, mut callback: F)
|
||||
pub fn for_each_variation<F>(family_name: &str, mut callback: F)
|
||||
where F: FnMut(String)
|
||||
{
|
||||
debug!("getting variations for {}", family_name);
|
||||
|
@ -111,7 +111,7 @@ pub fn get_variations_for_family<F>(family_name: &str, mut callback: F)
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_system_default_family(generic_name: &str) -> Option<String> {
|
||||
pub fn system_default_family(generic_name: &str) -> Option<String> {
|
||||
let generic_name_c = CString::new(generic_name).unwrap();
|
||||
let generic_name_ptr = generic_name_c.as_ptr();
|
||||
|
||||
|
@ -140,7 +140,7 @@ pub fn get_system_default_family(generic_name: &str) -> Option<String> {
|
|||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn get_last_resort_font_families() -> Vec<String> {
|
||||
pub fn last_resort_font_families() -> Vec<String> {
|
||||
vec!(
|
||||
"Fira Sans".to_owned(),
|
||||
"DejaVu Sans".to_owned(),
|
||||
|
@ -149,6 +149,6 @@ pub fn get_last_resort_font_families() -> Vec<String> {
|
|||
}
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
pub fn get_last_resort_font_families() -> Vec<String> {
|
||||
pub fn last_resort_font_families() -> Vec<String> {
|
||||
vec!("Roboto".to_owned())
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ impl FontHandleMethods for FontHandle {
|
|||
return metrics;
|
||||
}
|
||||
|
||||
fn get_table_for_tag(&self, tag: FontTableTag) -> Option<Box<FontTable>> {
|
||||
fn table_for_tag(&self, tag: FontTableTag) -> Option<Box<FontTable>> {
|
||||
let result: Option<CFData> = self.ctfont.get_font_table(tag);
|
||||
result.and_then(|data| {
|
||||
Some(box FontTable::wrap(data))
|
||||
|
|
|
@ -10,7 +10,7 @@ use core_text::font_descriptor::{CTFontDescriptor, CTFontDescriptorRef};
|
|||
use std::borrow::ToOwned;
|
||||
use std::mem;
|
||||
|
||||
pub fn get_available_families<F>(mut callback: F) where F: FnMut(String) {
|
||||
pub fn for_each_available_family<F>(mut callback: F) where F: FnMut(String) {
|
||||
let family_names = core_text::font_collection::get_family_names();
|
||||
for strref in family_names.iter() {
|
||||
let family_name_ref: CFStringRef = unsafe { mem::transmute(strref) };
|
||||
|
@ -20,7 +20,7 @@ pub fn get_available_families<F>(mut callback: F) where F: FnMut(String) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_variations_for_family<F>(family_name: &str, mut callback: F) where F: FnMut(String) {
|
||||
pub fn for_each_variation<F>(family_name: &str, mut callback: F) where F: FnMut(String) {
|
||||
debug!("Looking for faces of family: {}", family_name);
|
||||
|
||||
let family_collection = core_text::font_collection::create_for_family(family_name);
|
||||
|
@ -35,10 +35,10 @@ pub fn get_variations_for_family<F>(family_name: &str, mut callback: F) where F:
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_system_default_family(_generic_name: &str) -> Option<String> {
|
||||
pub fn system_default_family(_generic_name: &str) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn get_last_resort_font_families() -> Vec<String> {
|
||||
pub fn last_resort_font_families() -> Vec<String> {
|
||||
vec!("Arial Unicode MS".to_owned(), "Arial".to_owned())
|
||||
}
|
||||
|
|
|
@ -238,7 +238,7 @@ impl<'a> DetailedGlyphStore {
|
|||
self.lookup_is_sorted = false;
|
||||
}
|
||||
|
||||
fn get_detailed_glyphs_for_entry(&'a self, entry_offset: CharIndex, count: u16)
|
||||
fn detailed_glyphs_for_entry(&'a self, entry_offset: CharIndex, count: u16)
|
||||
-> &'a [DetailedGlyph] {
|
||||
debug!("Requesting detailed glyphs[n={}] for entry[off={:?}]", count, entry_offset);
|
||||
|
||||
|
@ -264,7 +264,7 @@ impl<'a> DetailedGlyphStore {
|
|||
&self.detail_buffer[i .. i + count as usize]
|
||||
}
|
||||
|
||||
fn get_detailed_glyph_with_index(&'a self,
|
||||
fn detailed_glyph_with_index(&'a self,
|
||||
entry_offset: CharIndex,
|
||||
detail_offset: u16)
|
||||
-> &'a DetailedGlyph {
|
||||
|
@ -357,7 +357,7 @@ impl<'a> GlyphInfo<'a> {
|
|||
match self {
|
||||
GlyphInfo::Simple(store, entry_i) => store.entry_buffer[entry_i.to_usize()].id(),
|
||||
GlyphInfo::Detail(store, entry_i, detail_j) => {
|
||||
store.detail_store.get_detailed_glyph_with_index(entry_i, detail_j).id
|
||||
store.detail_store.detailed_glyph_with_index(entry_i, detail_j).id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ impl<'a> GlyphInfo<'a> {
|
|||
match self {
|
||||
GlyphInfo::Simple(store, entry_i) => store.entry_buffer[entry_i.to_usize()].advance(),
|
||||
GlyphInfo::Detail(store, entry_i, detail_j) => {
|
||||
store.detail_store.get_detailed_glyph_with_index(entry_i, detail_j).advance
|
||||
store.detail_store.detailed_glyph_with_index(entry_i, detail_j).advance
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -377,7 +377,7 @@ impl<'a> GlyphInfo<'a> {
|
|||
match self {
|
||||
GlyphInfo::Simple(_, _) => None,
|
||||
GlyphInfo::Detail(store, entry_i, detail_j) => {
|
||||
Some(store.detail_store.get_detailed_glyph_with_index(entry_i, detail_j).offset)
|
||||
Some(store.detail_store.detailed_glyph_with_index(entry_i, detail_j).offset)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -608,7 +608,7 @@ impl<'a> GlyphIterator<'a> {
|
|||
#[inline(never)]
|
||||
fn next_complex_glyph(&mut self, entry: &GlyphEntry, i: CharIndex)
|
||||
-> Option<(CharIndex, GlyphInfo<'a>)> {
|
||||
let glyphs = self.store.detail_store.get_detailed_glyphs_for_entry(i, entry.glyph_count());
|
||||
let glyphs = self.store.detail_store.detailed_glyphs_for_entry(i, entry.glyph_count());
|
||||
self.glyph_range = Some(range::each_index(CharIndex(0), CharIndex(glyphs.len() as isize)));
|
||||
self.next()
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ impl ShapedGlyphData {
|
|||
}
|
||||
|
||||
/// Returns shaped glyph data for one glyph, and updates the y-position of the pen.
|
||||
pub fn get_entry_for_glyph(&self, i: usize, y_pos: &mut Au) -> ShapedGlyphEntry {
|
||||
pub fn entry_for_glyph(&self, i: usize, y_pos: &mut Au) -> ShapedGlyphEntry {
|
||||
assert!(i < self.count);
|
||||
|
||||
unsafe {
|
||||
|
@ -170,7 +170,7 @@ impl Shaper {
|
|||
options: *options,
|
||||
};
|
||||
let hb_face: *mut hb_face_t =
|
||||
RUST_hb_face_create_for_tables(get_font_table_func,
|
||||
RUST_hb_face_create_for_tables(font_table_func,
|
||||
(&mut *font_and_shaping_options)
|
||||
as *mut FontAndShapingOptions
|
||||
as *mut c_void,
|
||||
|
@ -448,7 +448,7 @@ impl Shaper {
|
|||
if is_bidi_control(character) {
|
||||
glyphs.add_nonglyph_for_char_index(char_idx, false, false);
|
||||
} else {
|
||||
let shape = glyph_data.get_entry_for_glyph(glyph_span.begin(), &mut y_pos);
|
||||
let shape = glyph_data.entry_for_glyph(glyph_span.begin(), &mut y_pos);
|
||||
let advance = self.advance_for_shaped_glyph(shape.advance, character, options);
|
||||
let data = GlyphData::new(shape.codepoint,
|
||||
advance,
|
||||
|
@ -463,7 +463,7 @@ impl Shaper {
|
|||
let mut datas = vec!();
|
||||
|
||||
for glyph_i in glyph_span.each_index() {
|
||||
let shape = glyph_data.get_entry_for_glyph(glyph_i, &mut y_pos);
|
||||
let shape = glyph_data.entry_for_glyph(glyph_i, &mut y_pos);
|
||||
datas.push(GlyphData::new(shape.codepoint,
|
||||
shape.advance,
|
||||
shape.offset,
|
||||
|
@ -601,7 +601,7 @@ extern fn glyph_h_kerning_func(_: *mut hb_font_t,
|
|||
}
|
||||
|
||||
// Callback to get a font table out of a font.
|
||||
extern fn get_font_table_func(_: *mut hb_face_t,
|
||||
extern fn font_table_func(_: *mut hb_face_t,
|
||||
tag: hb_tag_t,
|
||||
user_data: *mut c_void)
|
||||
-> *mut hb_blob_t {
|
||||
|
@ -613,7 +613,7 @@ extern fn get_font_table_func(_: *mut hb_face_t,
|
|||
assert!(!(*font_and_shaping_options).font.is_null());
|
||||
|
||||
// TODO(Issue #197): reuse font table data, which will change the unsound trickery here.
|
||||
match (*(*font_and_shaping_options).font).get_table_for_tag(tag as FontTableTag) {
|
||||
match (*(*font_and_shaping_options).font).table_for_tag(tag as FontTableTag) {
|
||||
None => ptr::null_mut(),
|
||||
Some(font_table) => {
|
||||
// `Box::into_raw` intentionally leaks the FontTable so we don't destroy the buffer
|
||||
|
|
|
@ -176,8 +176,8 @@ impl<'a> LayoutContext<'a> {
|
|||
pub fn get_or_request_image(&self, url: Url, use_placeholder: UsePlaceholder)
|
||||
-> Option<Arc<Image>> {
|
||||
// See if the image is already available
|
||||
let result = self.shared.image_cache_task.get_image_if_available(url.clone(),
|
||||
use_placeholder);
|
||||
let result = self.shared.image_cache_task.find_image(url.clone(),
|
||||
use_placeholder);
|
||||
|
||||
match result {
|
||||
Ok(image) => Some(image),
|
||||
|
|
|
@ -159,7 +159,7 @@ impl TextRunScanner {
|
|||
let in_fragment = self.clump.front().unwrap();
|
||||
let font_style = in_fragment.style().get_font_arc();
|
||||
let inherited_text_style = in_fragment.style().get_inheritedtext();
|
||||
fontgroup = font_context.get_layout_font_group_for_style(font_style);
|
||||
fontgroup = font_context.layout_font_group_for_style(font_style);
|
||||
compression = match in_fragment.white_space() {
|
||||
white_space::T::normal | white_space::T::nowrap => {
|
||||
CompressionMode::CompressWhitespaceNewline
|
||||
|
@ -358,7 +358,7 @@ fn bounding_box_for_run_metrics(metrics: &RunMetrics, writing_mode: WritingMode)
|
|||
#[inline]
|
||||
pub fn font_metrics_for_style(font_context: &mut FontContext, font_style: Arc<FontStyle>)
|
||||
-> FontMetrics {
|
||||
let fontgroup = font_context.get_layout_font_group_for_style(font_style);
|
||||
let fontgroup = font_context.layout_font_group_for_style(font_style);
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let font = fontgroup.fonts[0].borrow();
|
||||
font.metrics.clone()
|
||||
|
|
|
@ -58,7 +58,7 @@ impl StorageManager {
|
|||
self.set_item(sender, url, storage_type, name, value)
|
||||
}
|
||||
StorageTaskMsg::GetItem(sender, url, storage_type, name) => {
|
||||
self.get_item(sender, url, storage_type, name)
|
||||
self.request_item(sender, url, storage_type, name)
|
||||
}
|
||||
StorageTaskMsg::RemoveItem(sender, url, storage_type, name) => {
|
||||
self.remove_item(sender, url, storage_type, name)
|
||||
|
@ -90,7 +90,7 @@ impl StorageManager {
|
|||
}
|
||||
|
||||
fn length(&self, sender: IpcSender<usize>, url: Url, storage_type: StorageType) {
|
||||
let origin = self.get_origin_as_string(url);
|
||||
let origin = self.origin_as_string(url);
|
||||
let data = self.select_data(storage_type);
|
||||
sender.send(data.get(&origin).map_or(0, |entry| entry.len())).unwrap();
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ impl StorageManager {
|
|||
url: Url,
|
||||
storage_type: StorageType,
|
||||
index: u32) {
|
||||
let origin = self.get_origin_as_string(url);
|
||||
let origin = self.origin_as_string(url);
|
||||
let data = self.select_data(storage_type);
|
||||
sender.send(data.get(&origin)
|
||||
.and_then(|entry| entry.keys().nth(index as usize))
|
||||
|
@ -115,7 +115,7 @@ impl StorageManager {
|
|||
storage_type: StorageType,
|
||||
name: DOMString,
|
||||
value: DOMString) {
|
||||
let origin = self.get_origin_as_string(url);
|
||||
let origin = self.origin_as_string(url);
|
||||
let data = self.select_data_mut(storage_type);
|
||||
if !data.contains_key(&origin) {
|
||||
data.insert(origin.clone(), BTreeMap::new());
|
||||
|
@ -133,12 +133,12 @@ impl StorageManager {
|
|||
sender.send((changed, old_value)).unwrap();
|
||||
}
|
||||
|
||||
fn get_item(&self,
|
||||
fn request_item(&self,
|
||||
sender: IpcSender<Option<DOMString>>,
|
||||
url: Url,
|
||||
storage_type: StorageType,
|
||||
name: DOMString) {
|
||||
let origin = self.get_origin_as_string(url);
|
||||
let origin = self.origin_as_string(url);
|
||||
let data = self.select_data(storage_type);
|
||||
sender.send(data.get(&origin)
|
||||
.and_then(|entry| entry.get(&name))
|
||||
|
@ -151,7 +151,7 @@ impl StorageManager {
|
|||
url: Url,
|
||||
storage_type: StorageType,
|
||||
name: DOMString) {
|
||||
let origin = self.get_origin_as_string(url);
|
||||
let origin = self.origin_as_string(url);
|
||||
let data = self.select_data_mut(storage_type);
|
||||
let old_value = data.get_mut(&origin).and_then(|entry| {
|
||||
entry.remove(&name)
|
||||
|
@ -160,7 +160,7 @@ impl StorageManager {
|
|||
}
|
||||
|
||||
fn clear(&mut self, sender: IpcSender<bool>, url: Url, storage_type: StorageType) {
|
||||
let origin = self.get_origin_as_string(url);
|
||||
let origin = self.origin_as_string(url);
|
||||
let data = self.select_data_mut(storage_type);
|
||||
sender.send(data.get_mut(&origin)
|
||||
.map_or(false, |entry| {
|
||||
|
@ -172,7 +172,7 @@ impl StorageManager {
|
|||
}})).unwrap();
|
||||
}
|
||||
|
||||
fn get_origin_as_string(&self, url: Url) -> String {
|
||||
fn origin_as_string(&self, url: Url) -> String {
|
||||
let mut origin = "".to_string();
|
||||
origin.push_str(&url.scheme);
|
||||
origin.push_str("://");
|
||||
|
|
|
@ -111,7 +111,7 @@ impl ImageCacheTask {
|
|||
}
|
||||
|
||||
/// Get the current state of an image. See ImageCacheCommand::GetImageIfAvailable.
|
||||
pub fn get_image_if_available(&self, url: Url, use_placeholder: UsePlaceholder)
|
||||
pub fn find_image(&self, url: Url, use_placeholder: UsePlaceholder)
|
||||
-> Result<Arc<Image>, ImageState> {
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
let msg = ImageCacheCommand::GetImageIfAvailable(url, use_placeholder, sender);
|
||||
|
|
|
@ -386,33 +386,33 @@ mod system_reporter {
|
|||
};
|
||||
|
||||
// Virtual and physical memory usage, as reported by the OS.
|
||||
report(path!["vsize"], get_vsize());
|
||||
report(path!["resident"], get_resident());
|
||||
report(path!["vsize"], vsize());
|
||||
report(path!["resident"], resident());
|
||||
|
||||
// Memory segments, as reported by the OS.
|
||||
for seg in get_resident_segments() {
|
||||
for seg in resident_segments() {
|
||||
report(path!["resident-according-to-smaps", seg.0], Some(seg.1));
|
||||
}
|
||||
|
||||
// Total number of bytes allocated by the application on the system
|
||||
// heap.
|
||||
report(path![SYSTEM_HEAP_ALLOCATED_STR], get_system_heap_allocated());
|
||||
report(path![SYSTEM_HEAP_ALLOCATED_STR], system_heap_allocated());
|
||||
|
||||
// The descriptions of the following jemalloc measurements are taken
|
||||
// directly from the jemalloc documentation.
|
||||
|
||||
// "Total number of bytes allocated by the application."
|
||||
report(path![JEMALLOC_HEAP_ALLOCATED_STR], get_jemalloc_stat("stats.allocated"));
|
||||
report(path![JEMALLOC_HEAP_ALLOCATED_STR], jemalloc_stat("stats.allocated"));
|
||||
|
||||
// "Total number of bytes in active pages allocated by the application.
|
||||
// This is a multiple of the page size, and greater than or equal to
|
||||
// |stats.allocated|."
|
||||
report(path!["jemalloc-heap-active"], get_jemalloc_stat("stats.active"));
|
||||
report(path!["jemalloc-heap-active"], jemalloc_stat("stats.active"));
|
||||
|
||||
// "Total number of bytes in chunks mapped on behalf of the application.
|
||||
// This is a multiple of the chunk size, and is at least as large as
|
||||
// |stats.active|. This does not include inactive chunks."
|
||||
report(path!["jemalloc-heap-mapped"], get_jemalloc_stat("stats.mapped"));
|
||||
report(path!["jemalloc-heap-mapped"], jemalloc_stat("stats.mapped"));
|
||||
}
|
||||
|
||||
request.reports_channel.send(reports);
|
||||
|
@ -439,7 +439,7 @@ mod system_reporter {
|
|||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn get_system_heap_allocated() -> Option<usize> {
|
||||
fn system_heap_allocated() -> Option<usize> {
|
||||
let info: struct_mallinfo = unsafe { mallinfo() };
|
||||
|
||||
// The documentation in the glibc man page makes it sound like |uordblks| would suffice,
|
||||
|
@ -458,7 +458,7 @@ mod system_reporter {
|
|||
}
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
fn get_system_heap_allocated() -> Option<usize> {
|
||||
fn system_heap_allocated() -> Option<usize> {
|
||||
None
|
||||
}
|
||||
|
||||
|
@ -467,7 +467,7 @@ mod system_reporter {
|
|||
newp: *mut c_void, newlen: size_t) -> c_int;
|
||||
}
|
||||
|
||||
fn get_jemalloc_stat(value_name: &str) -> Option<usize> {
|
||||
fn jemalloc_stat(value_name: &str) -> Option<usize> {
|
||||
// Before we request the measurement of interest, we first send an "epoch"
|
||||
// request. Without that jemalloc gives cached statistics(!) which can be
|
||||
// highly inaccurate.
|
||||
|
@ -515,7 +515,7 @@ mod system_reporter {
|
|||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn get_proc_self_statm_field(field: usize) -> Option<usize> {
|
||||
fn proc_self_statm_field(field: usize) -> Option<usize> {
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
|
||||
|
@ -528,37 +528,37 @@ mod system_reporter {
|
|||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn get_vsize() -> Option<usize> {
|
||||
get_proc_self_statm_field(0)
|
||||
fn vsize() -> Option<usize> {
|
||||
proc_self_statm_field(0)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn get_resident() -> Option<usize> {
|
||||
get_proc_self_statm_field(1)
|
||||
fn resident() -> Option<usize> {
|
||||
proc_self_statm_field(1)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn get_vsize() -> Option<usize> {
|
||||
fn vsize() -> Option<usize> {
|
||||
virtual_size()
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn get_resident() -> Option<usize> {
|
||||
fn resident() -> Option<usize> {
|
||||
resident_size()
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
|
||||
fn get_vsize() -> Option<usize> {
|
||||
fn vsize() -> Option<usize> {
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
|
||||
fn get_resident() -> Option<usize> {
|
||||
fn resident() -> Option<usize> {
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn get_resident_segments() -> Vec<(String, usize)> {
|
||||
fn resident_segments() -> Vec<(String, usize)> {
|
||||
use regex::Regex;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::hash_map::Entry;
|
||||
|
@ -652,14 +652,14 @@ mod system_reporter {
|
|||
}
|
||||
|
||||
// Note that the sum of all these segments' RSS values differs from the "resident"
|
||||
// measurement obtained via /proc/<pid>/statm in get_resident(). It's unclear why this
|
||||
// measurement obtained via /proc/<pid>/statm in resident(). It's unclear why this
|
||||
// difference occurs; for some processes the measurements match, but for Servo they do not.
|
||||
let segs: Vec<(String, usize)> = seg_map.into_iter().collect();
|
||||
segs
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
fn get_resident_segments() -> Vec<(String, usize)> {
|
||||
fn resident_segments() -> Vec<(String, usize)> {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,8 +187,8 @@ impl Browser {
|
|||
self.compositor.pinch_zoom_level()
|
||||
}
|
||||
|
||||
pub fn get_title_for_main_frame(&self) {
|
||||
self.compositor.get_title_for_main_frame()
|
||||
pub fn request_title_for_main_frame(&self) {
|
||||
self.compositor.title_for_main_frame()
|
||||
}
|
||||
|
||||
pub fn shutdown(mut self) {
|
||||
|
|
|
@ -42,7 +42,7 @@ fn main() {
|
|||
env_logger::init().unwrap();
|
||||
|
||||
// Parse the command line options and store them globally
|
||||
opts::from_cmdline_args(&*get_args());
|
||||
opts::from_cmdline_args(&*args());
|
||||
|
||||
setup_logging();
|
||||
|
||||
|
@ -138,7 +138,7 @@ fn setup_logging() {
|
|||
}
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
fn get_args() -> Vec<String> {
|
||||
fn args() -> Vec<String> {
|
||||
vec![
|
||||
"servo".to_owned(),
|
||||
"http://en.wikipedia.org/wiki/Rust".to_owned()
|
||||
|
@ -146,7 +146,7 @@ fn get_args() -> Vec<String> {
|
|||
}
|
||||
|
||||
#[cfg(not(target_os = "android"))]
|
||||
fn get_args() -> Vec<String> {
|
||||
fn args() -> Vec<String> {
|
||||
use std::env;
|
||||
env::args().collect()
|
||||
}
|
||||
|
|
|
@ -85,12 +85,12 @@ impl Handler {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_root_pipeline(&self) -> WebDriverResult<PipelineId> {
|
||||
fn root_pipeline(&self) -> WebDriverResult<PipelineId> {
|
||||
let interval = 20;
|
||||
let iterations = 30_000 / interval;
|
||||
|
||||
for _ in 0..iterations {
|
||||
if let Some(x) = self.get_pipeline(None) {
|
||||
if let Some(x) = self.pipeline(None) {
|
||||
return Ok(x)
|
||||
};
|
||||
|
||||
|
@ -101,9 +101,9 @@ impl Handler {
|
|||
"Failed to get root window handle"))
|
||||
}
|
||||
|
||||
fn get_frame_pipeline(&self) -> WebDriverResult<PipelineId> {
|
||||
fn frame_pipeline(&self) -> WebDriverResult<PipelineId> {
|
||||
if let Some(ref session) = self.session {
|
||||
match self.get_pipeline(session.frame_id) {
|
||||
match self.pipeline(session.frame_id) {
|
||||
Some(x) => Ok(x),
|
||||
None => Err(WebDriverError::new(ErrorStatus::NoSuchFrame,
|
||||
"Frame got closed"))
|
||||
|
@ -113,7 +113,7 @@ impl Handler {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_session(&self) -> WebDriverResult<&WebDriverSession> {
|
||||
fn session(&self) -> WebDriverResult<&WebDriverSession> {
|
||||
match self.session {
|
||||
Some(ref x) => Ok(x),
|
||||
None => Err(WebDriverError::new(ErrorStatus::SessionNotCreated,
|
||||
|
@ -132,7 +132,7 @@ impl Handler {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_pipeline(&self, frame_id: Option<FrameId>) -> Option<PipelineId> {
|
||||
fn pipeline(&self, frame_id: Option<FrameId>) -> Option<PipelineId> {
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
let ConstellationChan(ref const_chan) = self.constellation_chan;
|
||||
const_chan.send(ConstellationMsg::GetPipeline(frame_id, sender)).unwrap();
|
||||
|
@ -169,7 +169,7 @@ impl Handler {
|
|||
"Invalid URL"))
|
||||
};
|
||||
|
||||
let pipeline_id = try!(self.get_root_pipeline());
|
||||
let pipeline_id = try!(self.root_pipeline());
|
||||
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
|
||||
|
@ -199,8 +199,8 @@ impl Handler {
|
|||
}
|
||||
}
|
||||
|
||||
fn handle_get_current_url(&self) -> WebDriverResult<WebDriverResponse> {
|
||||
let pipeline_id = try!(self.get_root_pipeline());
|
||||
fn handle_current_url(&self) -> WebDriverResult<WebDriverResponse> {
|
||||
let pipeline_id = try!(self.root_pipeline());
|
||||
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
|
||||
|
@ -227,7 +227,7 @@ impl Handler {
|
|||
}
|
||||
|
||||
fn handle_refresh(&self) -> WebDriverResult<WebDriverResponse> {
|
||||
let pipeline_id = try!(self.get_root_pipeline());
|
||||
let pipeline_id = try!(self.root_pipeline());
|
||||
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
|
||||
|
@ -238,8 +238,8 @@ impl Handler {
|
|||
self.wait_for_load(sender, receiver)
|
||||
}
|
||||
|
||||
fn handle_get_title(&self) -> WebDriverResult<WebDriverResponse> {
|
||||
let pipeline_id = try!(self.get_root_pipeline());
|
||||
fn handle_title(&self) -> WebDriverResult<WebDriverResponse> {
|
||||
let pipeline_id = try!(self.root_pipeline());
|
||||
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
let ConstellationChan(ref const_chan) = self.constellation_chan;
|
||||
|
@ -250,14 +250,14 @@ impl Handler {
|
|||
Ok(WebDriverResponse::Generic(ValueResponse::new(value.to_json())))
|
||||
}
|
||||
|
||||
fn handle_get_window_handle(&self) -> WebDriverResult<WebDriverResponse> {
|
||||
fn handle_window_handle(&self) -> WebDriverResult<WebDriverResponse> {
|
||||
// For now we assume there's only one window so just use the session
|
||||
// id as the window id
|
||||
let handle = self.session.as_ref().unwrap().id.to_string();
|
||||
Ok(WebDriverResponse::Generic(ValueResponse::new(handle.to_json())))
|
||||
}
|
||||
|
||||
fn handle_get_window_handles(&self) -> WebDriverResult<WebDriverResponse> {
|
||||
fn handle_window_handles(&self) -> WebDriverResult<WebDriverResponse> {
|
||||
// For now we assume there's only one window so just use the session
|
||||
// id as the window id
|
||||
let handles = vec![self.session.as_ref().unwrap().id.to_string().to_json()];
|
||||
|
@ -265,7 +265,7 @@ impl Handler {
|
|||
}
|
||||
|
||||
fn handle_find_element(&self, parameters: &LocatorParameters) -> WebDriverResult<WebDriverResponse> {
|
||||
let pipeline_id = try!(self.get_frame_pipeline());
|
||||
let pipeline_id = try!(self.frame_pipeline());
|
||||
|
||||
if parameters.using != LocatorStrategy::CSSSelector {
|
||||
return Err(WebDriverError::new(ErrorStatus::UnsupportedOperation,
|
||||
|
@ -311,7 +311,7 @@ impl Handler {
|
|||
return Err(WebDriverError::new(ErrorStatus::UnsupportedOperation,
|
||||
"Selecting frame by id not supported"));
|
||||
}
|
||||
let pipeline_id = try!(self.get_frame_pipeline());
|
||||
let pipeline_id = try!(self.frame_pipeline());
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
let cmd = WebDriverScriptCommand::GetFrameId(frame_id, sender);
|
||||
{
|
||||
|
@ -340,7 +340,7 @@ impl Handler {
|
|||
|
||||
|
||||
fn handle_find_elements(&self, parameters: &LocatorParameters) -> WebDriverResult<WebDriverResponse> {
|
||||
let pipeline_id = try!(self.get_frame_pipeline());
|
||||
let pipeline_id = try!(self.frame_pipeline());
|
||||
|
||||
if parameters.using != LocatorStrategy::CSSSelector {
|
||||
return Err(WebDriverError::new(ErrorStatus::UnsupportedOperation,
|
||||
|
@ -363,8 +363,8 @@ impl Handler {
|
|||
}
|
||||
}
|
||||
|
||||
fn handle_get_element_text(&self, element: &WebElement) -> WebDriverResult<WebDriverResponse> {
|
||||
let pipeline_id = try!(self.get_frame_pipeline());
|
||||
fn handle_element_text(&self, element: &WebElement) -> WebDriverResult<WebDriverResponse> {
|
||||
let pipeline_id = try!(self.frame_pipeline());
|
||||
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
let ConstellationChan(ref const_chan) = self.constellation_chan;
|
||||
|
@ -378,8 +378,8 @@ impl Handler {
|
|||
}
|
||||
}
|
||||
|
||||
fn handle_get_active_element(&self) -> WebDriverResult<WebDriverResponse> {
|
||||
let pipeline_id = try!(self.get_frame_pipeline());
|
||||
fn handle_active_element(&self) -> WebDriverResult<WebDriverResponse> {
|
||||
let pipeline_id = try!(self.frame_pipeline());
|
||||
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
let ConstellationChan(ref const_chan) = self.constellation_chan;
|
||||
|
@ -390,8 +390,8 @@ impl Handler {
|
|||
Ok(WebDriverResponse::Generic(ValueResponse::new(value.to_json())))
|
||||
}
|
||||
|
||||
fn handle_get_element_tag_name(&self, element: &WebElement) -> WebDriverResult<WebDriverResponse> {
|
||||
let pipeline_id = try!(self.get_frame_pipeline());
|
||||
fn handle_element_tag_name(&self, element: &WebElement) -> WebDriverResult<WebDriverResponse> {
|
||||
let pipeline_id = try!(self.frame_pipeline());
|
||||
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
let ConstellationChan(ref const_chan) = self.constellation_chan;
|
||||
|
@ -451,7 +451,7 @@ impl Handler {
|
|||
command: WebDriverScriptCommand,
|
||||
receiver: IpcReceiver<WebDriverJSResult>)
|
||||
-> WebDriverResult<WebDriverResponse> {
|
||||
let pipeline_id = try!(self.get_frame_pipeline());
|
||||
let pipeline_id = try!(self.frame_pipeline());
|
||||
|
||||
let ConstellationChan(ref const_chan) = self.constellation_chan;
|
||||
let cmd_msg = WebDriverCommandMsg::ScriptCommand(pipeline_id, command);
|
||||
|
@ -467,7 +467,7 @@ impl Handler {
|
|||
|
||||
fn handle_take_screenshot(&self) -> WebDriverResult<WebDriverResponse> {
|
||||
let mut img = None;
|
||||
let pipeline_id = try!(self.get_root_pipeline());
|
||||
let pipeline_id = try!(self.root_pipeline());
|
||||
|
||||
let interval = 20;
|
||||
let iterations = 30_000 / interval;
|
||||
|
@ -517,27 +517,27 @@ impl WebDriverHandler for Handler {
|
|||
match msg.command {
|
||||
WebDriverCommand::NewSession => {},
|
||||
_ => {
|
||||
try!(self.get_session());
|
||||
try!(self.session());
|
||||
}
|
||||
}
|
||||
|
||||
match msg.command {
|
||||
WebDriverCommand::NewSession => self.handle_new_session(),
|
||||
WebDriverCommand::Get(ref parameters) => self.handle_get(parameters),
|
||||
WebDriverCommand::GetCurrentUrl => self.handle_get_current_url(),
|
||||
WebDriverCommand::GetCurrentUrl => self.handle_current_url(),
|
||||
WebDriverCommand::GoBack => self.handle_go_back(),
|
||||
WebDriverCommand::GoForward => self.handle_go_forward(),
|
||||
WebDriverCommand::Refresh => self.handle_refresh(),
|
||||
WebDriverCommand::GetTitle => self.handle_get_title(),
|
||||
WebDriverCommand::GetWindowHandle => self.handle_get_window_handle(),
|
||||
WebDriverCommand::GetWindowHandles => self.handle_get_window_handles(),
|
||||
WebDriverCommand::GetTitle => self.handle_title(),
|
||||
WebDriverCommand::GetWindowHandle => self.handle_window_handle(),
|
||||
WebDriverCommand::GetWindowHandles => self.handle_window_handles(),
|
||||
WebDriverCommand::SwitchToFrame(ref parameters) => self.handle_switch_to_frame(parameters),
|
||||
WebDriverCommand::SwitchToParentFrame => self.handle_switch_to_parent_frame(),
|
||||
WebDriverCommand::FindElement(ref parameters) => self.handle_find_element(parameters),
|
||||
WebDriverCommand::FindElements(ref parameters) => self.handle_find_elements(parameters),
|
||||
WebDriverCommand::GetActiveElement => self.handle_get_active_element(),
|
||||
WebDriverCommand::GetElementText(ref element) => self.handle_get_element_text(element),
|
||||
WebDriverCommand::GetElementTagName(ref element) => self.handle_get_element_tag_name(element),
|
||||
WebDriverCommand::GetActiveElement => self.handle_active_element(),
|
||||
WebDriverCommand::GetElementText(ref element) => self.handle_element_text(element),
|
||||
WebDriverCommand::GetElementTagName(ref element) => self.handle_element_tag_name(element),
|
||||
WebDriverCommand::ExecuteScript(ref x) => self.handle_execute_script(x),
|
||||
WebDriverCommand::ExecuteAsyncScript(ref x) => self.handle_execute_async_script(x),
|
||||
WebDriverCommand::SetTimeouts(ref x) => self.handle_set_timeouts(x),
|
||||
|
|
|
@ -40,10 +40,10 @@ impl ServoBrowser {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_title_for_main_frame(&self) {
|
||||
pub fn request_title_for_main_frame(&self) {
|
||||
match *self {
|
||||
ServoBrowser::OnScreen(ref browser) => browser.get_title_for_main_frame(),
|
||||
ServoBrowser::OffScreen(ref browser) => browser.get_title_for_main_frame(),
|
||||
ServoBrowser::OnScreen(ref browser) => browser.request_title_for_main_frame(),
|
||||
ServoBrowser::OffScreen(ref browser) => browser.request_title_for_main_frame(),
|
||||
ServoBrowser::Invalid => {}
|
||||
}
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ impl ServoCefBrowser {
|
|||
pub trait ServoCefBrowserExtensions {
|
||||
fn init(&self, window_info: &cef_window_info_t);
|
||||
fn send_window_event(&self, event: WindowEvent);
|
||||
fn get_title_for_main_frame(&self);
|
||||
fn request_title_for_main_frame(&self);
|
||||
fn pinch_zoom_level(&self) -> f32;
|
||||
}
|
||||
|
||||
|
@ -207,8 +207,8 @@ impl ServoCefBrowserExtensions for CefBrowser {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_title_for_main_frame(&self) {
|
||||
self.downcast().servo_browser.borrow().get_title_for_main_frame()
|
||||
fn request_title_for_main_frame(&self) {
|
||||
self.downcast().servo_browser.borrow().request_title_for_main_frame()
|
||||
}
|
||||
|
||||
fn pinch_zoom_level(&self) -> f32 {
|
||||
|
|
|
@ -46,7 +46,7 @@ full_cef_class_impl! {
|
|||
fn get_text(&this, visitor: *mut cef_string_visitor_t [CefStringVisitor],) -> () {{
|
||||
let this = this.downcast();
|
||||
*this.title_visitor.borrow_mut() = Some(visitor);
|
||||
this.browser.borrow().as_ref().unwrap().get_title_for_main_frame();
|
||||
this.browser.borrow().as_ref().unwrap().request_title_for_main_frame();
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue