mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #7559 - ddrmanxbxfr:RFC-0344-Work, r=nox
Remove 'get_*' on getters as per RFC 0344 on canevas, compositing, devtools, gfx, layout, net, profile, servo and webdriver_server Hi guys, I just gave a big pass of RFC-0344 as per issue #6224 . Pretty much renamed all the get_* fn that were used to fetch values. I hope I didn't rename too much. As said in the issue discussion, I didn't touch at the scripts folder so we keep the unsafe ones pretty explicit. I've ran the whole pass of test, everything seems to be still working right :). Please give feedback on this PR. Thanks for looking into it. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7559) <!-- Reviewable:end -->
This commit is contained in:
commit
b05f4aa3aa
30 changed files with 167 additions and 168 deletions
|
@ -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;
|
||||
}
|
||||
|
@ -99,7 +98,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),
|
||||
|
@ -115,11 +114,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) => {
|
||||
|
@ -145,7 +144,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);
|
||||
});
|
||||
}
|
||||
|
@ -162,7 +161,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();
|
||||
|
@ -187,7 +186,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);
|
||||
});
|
||||
}
|
||||
|
@ -217,7 +216,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);
|
||||
|
@ -227,9 +226,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);
|
||||
|
@ -281,7 +280,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();
|
||||
|
@ -296,7 +295,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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue