Skip to content

Commit

Permalink
Remove 'get_*' on getters as per RFC 0344 on various components
Browse files Browse the repository at this point in the history
  • Loading branch information
leaexplores committed Sep 13, 2015
1 parent 2733060 commit 7320433
Show file tree
Hide file tree
Showing 30 changed files with 167 additions and 168 deletions.
4 changes: 2 additions & 2 deletions components/canvas/canvas_paint_task.rs
Expand Up @@ -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),
Expand Down Expand Up @@ -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>>) {
Expand Down
16 changes: 8 additions & 8 deletions components/canvas/webgl_paint_task.rs
Expand Up @@ -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) =>
Expand Down Expand Up @@ -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) =>
Expand Down Expand Up @@ -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()
}

Expand Down Expand Up @@ -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 {
Expand All @@ -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>) {
Expand All @@ -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
Expand Down
26 changes: 13 additions & 13 deletions components/compositing/compositor.rs
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions components/compositing/compositor_layer.rs
Expand Up @@ -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));
}

Expand All @@ -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));
}

Expand Down
2 changes: 1 addition & 1 deletion components/compositing/compositor_task.rs
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion components/compositing/headless.rs
Expand Up @@ -152,5 +152,5 @@ impl CompositorEventListener for NullCompositor {
1.0
}

fn get_title_for_main_frame(&self) {}
fn title_for_main_frame(&self) {}
}
2 changes: 1 addition & 1 deletion components/devtools/actor.rs
Expand Up @@ -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()
}

Expand Down
2 changes: 1 addition & 1 deletion components/devtools/actors/timeline.rs
Expand Up @@ -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(),
Expand Down
6 changes: 3 additions & 3 deletions components/gfx/font.rs
Expand Up @@ -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.
Expand Down Expand Up @@ -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={}",
Expand Down
35 changes: 17 additions & 18 deletions components/gfx/font_cache_task.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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),
Expand All @@ -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) => {
Expand All @@ -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);
});
}
Expand All @@ -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();
Expand All @@ -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);
});
}
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit 7320433

Please sign in to comment.