mirror of
https://github.com/servo/servo.git
synced 2025-08-07 22:45:34 +01:00
Update rustfmt to the 2024 style edition (#35764)
* Use 2024 style edition Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Reformat all code Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
parent
6300e820b4
commit
3d320fa96a
603 changed files with 1739 additions and 1648 deletions
|
@ -619,10 +619,10 @@ impl FontGroup {
|
|||
// Do not select this font if it goes against our emoji preference.
|
||||
match options.presentation_preference {
|
||||
EmojiPresentationPreference::Text if font.has_color_bitmap_or_colr_table() => {
|
||||
return false
|
||||
return false;
|
||||
},
|
||||
EmojiPresentationPreference::Emoji if !font.has_color_bitmap_or_colr_table() => {
|
||||
return false
|
||||
return false;
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
use std::collections::{HashMap, HashSet};
|
||||
use std::default::Default;
|
||||
use std::hash::{BuildHasherDefault, Hash, Hasher};
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
use app_units::Au;
|
||||
use base::id::WebViewId;
|
||||
|
@ -16,10 +16,11 @@ use log::{debug, trace};
|
|||
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use net_traits::request::{Destination, Referrer, RequestBuilder};
|
||||
use net_traits::{fetch_async, CoreResourceThread, FetchResponseMsg, ResourceThreads};
|
||||
use net_traits::{CoreResourceThread, FetchResponseMsg, ResourceThreads, fetch_async};
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use servo_arc::Arc as ServoArc;
|
||||
use servo_url::ServoUrl;
|
||||
use style::Atom;
|
||||
use style::computed_values::font_variant_caps::T as FontVariantCaps;
|
||||
use style::font_face::{
|
||||
FontFaceSourceFormat, FontFaceSourceFormatKeyword, Source, SourceList, UrlSource,
|
||||
|
@ -29,7 +30,6 @@ use style::properties::style_structs::Font as FontStyleStruct;
|
|||
use style::shared_lock::SharedRwLockReadGuard;
|
||||
use style::stylesheets::{CssRule, DocumentStyleSheet, FontFaceRule, StylesheetInDocument};
|
||||
use style::values::computed::font::{FamilyName, FontFamilyNameSyntax, SingleFontFamily};
|
||||
use style::Atom;
|
||||
use url::Url;
|
||||
use webrender_api::{FontInstanceFlags, FontInstanceKey, FontKey};
|
||||
use webrender_traits::CrossProcessCompositorApi;
|
||||
|
@ -502,7 +502,7 @@ pub trait FontContextWebFontMethods {
|
|||
);
|
||||
fn remove_all_web_fonts_from_stylesheet(&self, stylesheet: &DocumentStyleSheet);
|
||||
fn collect_unused_webrender_resources(&self, all: bool)
|
||||
-> (Vec<FontKey>, Vec<FontInstanceKey>);
|
||||
-> (Vec<FontKey>, Vec<FontInstanceKey>);
|
||||
}
|
||||
|
||||
impl FontContextWebFontMethods for Arc<FontContext> {
|
||||
|
@ -915,8 +915,7 @@ impl RemoteWebFontDownloader {
|
|||
FetchResponseMsg::ProcessResponseChunk(_, new_bytes) => {
|
||||
trace!(
|
||||
"@font-face {} chunk={:?}",
|
||||
self.web_font_family_name,
|
||||
new_bytes
|
||||
self.web_font_family_name, new_bytes
|
||||
);
|
||||
if self.response_valid {
|
||||
self.response_data.extend(new_bytes)
|
||||
|
@ -926,8 +925,7 @@ impl RemoteWebFontDownloader {
|
|||
FetchResponseMsg::ProcessResponseEOF(_, response) => {
|
||||
trace!(
|
||||
"@font-face {} EOF={:?}",
|
||||
self.web_font_family_name,
|
||||
response
|
||||
self.web_font_family_name, response
|
||||
);
|
||||
if response.is_err() || !self.response_valid {
|
||||
return DownloaderResponseResult::Failure;
|
||||
|
|
|
@ -25,7 +25,7 @@ use ipc_channel::ipc::IpcSharedMemory;
|
|||
pub use platform::LocalFontIdentifier;
|
||||
pub use shaper::*;
|
||||
pub use system_font_service::*;
|
||||
use unicode_properties::{emoji, EmojiStatus, UnicodeEmoji};
|
||||
use unicode_properties::{EmojiStatus, UnicodeEmoji, emoji};
|
||||
|
||||
/// A data structure to store data for fonts. Data is stored internally in an
|
||||
/// [`IpcSharedMemory`] handle, so that it can be send without serialization
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
use std::path::Path;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
use base::text::{is_cjk, UnicodeBlock, UnicodeBlockMethod};
|
||||
use base::text::{UnicodeBlock, UnicodeBlockMethod, is_cjk};
|
||||
use log::warn;
|
||||
use style::Atom;
|
||||
use style::values::computed::font::GenericFontFamily;
|
||||
use style::values::computed::{
|
||||
FontStretch as StyleFontStretch, FontStyle as StyleFontStyle, FontWeight as StyleFontWeight,
|
||||
};
|
||||
use style::Atom;
|
||||
|
||||
use super::xml::{Attribute, Node};
|
||||
use crate::{
|
||||
|
|
|
@ -9,30 +9,30 @@ use std::{mem, ptr};
|
|||
use app_units::Au;
|
||||
use euclid::default::{Point2D, Rect, Size2D};
|
||||
use freetype_sys::{
|
||||
ft_sfnt_head, ft_sfnt_os2, FT_Byte, FT_Done_Face, FT_Error, FT_F26Dot6, FT_Face, FT_Fixed,
|
||||
FT_Get_Char_Index, FT_Get_Kerning, FT_Get_Sfnt_Table, FT_GlyphSlot, FT_Int32, FT_Load_Glyph,
|
||||
FT_Long, FT_MulFix, FT_New_Face, FT_New_Memory_Face, FT_Pos, FT_Select_Size, FT_Set_Char_Size,
|
||||
FT_Short, FT_SizeRec, FT_Size_Metrics, FT_UInt, FT_ULong, FT_UShort, FT_Vector,
|
||||
FT_FACE_FLAG_COLOR, FT_FACE_FLAG_FIXED_SIZES, FT_FACE_FLAG_SCALABLE, FT_KERNING_DEFAULT,
|
||||
FT_LOAD_COLOR, FT_LOAD_DEFAULT, FT_LOAD_NO_HINTING, FT_STYLE_FLAG_ITALIC, TT_OS2,
|
||||
FT_Byte, FT_Done_Face, FT_Error, FT_F26Dot6, FT_FACE_FLAG_COLOR, FT_FACE_FLAG_FIXED_SIZES,
|
||||
FT_FACE_FLAG_SCALABLE, FT_Face, FT_Fixed, FT_Get_Char_Index, FT_Get_Kerning, FT_Get_Sfnt_Table,
|
||||
FT_GlyphSlot, FT_Int32, FT_KERNING_DEFAULT, FT_LOAD_COLOR, FT_LOAD_DEFAULT, FT_LOAD_NO_HINTING,
|
||||
FT_Load_Glyph, FT_Long, FT_MulFix, FT_New_Face, FT_New_Memory_Face, FT_Pos,
|
||||
FT_STYLE_FLAG_ITALIC, FT_Select_Size, FT_Set_Char_Size, FT_Short, FT_Size_Metrics, FT_SizeRec,
|
||||
FT_UInt, FT_ULong, FT_UShort, FT_Vector, TT_OS2, ft_sfnt_head, ft_sfnt_os2,
|
||||
};
|
||||
use log::debug;
|
||||
use parking_lot::ReentrantMutex;
|
||||
use style::Zero;
|
||||
use style::computed_values::font_stretch::T as FontStretch;
|
||||
use style::computed_values::font_weight::T as FontWeight;
|
||||
use style::values::computed::font::FontStyle;
|
||||
use style::Zero;
|
||||
use webrender_api::FontInstanceFlags;
|
||||
|
||||
use super::library_handle::FreeTypeLibraryHandle;
|
||||
use super::LocalFontIdentifier;
|
||||
use super::library_handle::FreeTypeLibraryHandle;
|
||||
use crate::FontData;
|
||||
use crate::font::{
|
||||
FontMetrics, FontTableMethods, FontTableTag, FractionalPixel, PlatformFontMethods,
|
||||
};
|
||||
use crate::font_template::FontTemplateDescriptor;
|
||||
use crate::glyph::GlyphId;
|
||||
use crate::system_font_service::FontIdentifier;
|
||||
use crate::FontData;
|
||||
|
||||
// This constant is not present in the freetype
|
||||
// bindings due to bindgen not handling the way
|
||||
|
|
|
@ -21,9 +21,9 @@ use fontconfig_sys::{
|
|||
};
|
||||
use libc::{c_char, c_int};
|
||||
use log::debug;
|
||||
use style::Atom;
|
||||
use style::values::computed::font::GenericFontFamily;
|
||||
use style::values::computed::{FontStretch, FontStyle, FontWeight};
|
||||
use style::Atom;
|
||||
use unicode_script::Script;
|
||||
|
||||
use super::LocalFontIdentifier;
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
use std::os::raw::{c_long, c_void};
|
||||
use std::ptr;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::sync::OnceLock;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
|
||||
use freetype_sys::{
|
||||
FT_Add_Default_Modules, FT_Done_Library, FT_Library, FT_Memory, FT_MemoryRec, FT_New_Library,
|
||||
|
|
|
@ -10,11 +10,11 @@ use std::{fs, io};
|
|||
|
||||
use base::text::{UnicodeBlock, UnicodeBlockMethod};
|
||||
use log::{debug, error, warn};
|
||||
use style::Atom;
|
||||
use style::values::computed::font::GenericFontFamily;
|
||||
use style::values::computed::{
|
||||
FontStretch as StyleFontStretch, FontStyle as StyleFontStyle, FontWeight as StyleFontWeight,
|
||||
};
|
||||
use style::Atom;
|
||||
use unicode_script::Script;
|
||||
|
||||
use crate::{
|
||||
|
|
|
@ -8,7 +8,7 @@ use std::sync::{Arc, OnceLock};
|
|||
use app_units::Au;
|
||||
use core_foundation::base::TCFType;
|
||||
use core_foundation::string::CFString;
|
||||
use core_foundation::url::{kCFURLPOSIXPathStyle, CFURL};
|
||||
use core_foundation::url::{CFURL, kCFURLPOSIXPathStyle};
|
||||
use core_graphics::data_provider::CGDataProvider;
|
||||
use core_graphics::display::CFDictionary;
|
||||
use core_graphics::font::CGFont;
|
||||
|
@ -16,8 +16,8 @@ use core_text::font::CTFont;
|
|||
use core_text::font_descriptor::kCTFontURLAttribute;
|
||||
use parking_lot::RwLock;
|
||||
|
||||
use crate::system_font_service::FontIdentifier;
|
||||
use crate::FontData;
|
||||
use crate::system_font_service::FontIdentifier;
|
||||
|
||||
/// A cache of `CTFont` to avoid having to create `CTFont` instances over and over. It is
|
||||
/// always possible to create a `CTFont` using a `FontTemplate` even if it isn't in this
|
||||
|
|
|
@ -14,7 +14,7 @@ use core_foundation::string::UniChar;
|
|||
use core_graphics::font::CGGlyph;
|
||||
use core_text::font::CTFont;
|
||||
use core_text::font_descriptor::{
|
||||
kCTFontDefaultOrientation, CTFontTraits, SymbolicTraitAccessors, TraitAccessors,
|
||||
CTFontTraits, SymbolicTraitAccessors, TraitAccessors, kCTFontDefaultOrientation,
|
||||
};
|
||||
use euclid::default::{Point2D, Rect, Size2D};
|
||||
use log::debug;
|
||||
|
@ -24,9 +24,9 @@ use webrender_api::FontInstanceFlags;
|
|||
use super::core_text_font_cache::CoreTextFontCache;
|
||||
use super::font_list::LocalFontIdentifier;
|
||||
use crate::{
|
||||
map_platform_values_to_style_values, FontData, FontIdentifier, FontMetrics, FontTableMethods,
|
||||
FontTableTag, FontTemplateDescriptor, FractionalPixel, GlyphId, PlatformFontMethods, CBDT,
|
||||
COLR, KERN, SBIX,
|
||||
CBDT, COLR, FontData, FontIdentifier, FontMetrics, FontTableMethods, FontTableTag,
|
||||
FontTemplateDescriptor, FractionalPixel, GlyphId, KERN, PlatformFontMethods, SBIX,
|
||||
map_platform_values_to_style_values,
|
||||
};
|
||||
|
||||
const KERN_PAIR_LEN: usize = 6;
|
||||
|
@ -149,7 +149,7 @@ impl CachedKernTable {
|
|||
match key.cmp(&query) {
|
||||
Ordering::Less => start = i + 1,
|
||||
Ordering::Equal => {
|
||||
return Some(BigEndian::read_i16(&pairs[i * KERN_PAIR_LEN + 4..]))
|
||||
return Some(BigEndian::read_i16(&pairs[i * KERN_PAIR_LEN + 4..]));
|
||||
},
|
||||
Ordering::Greater => end = i,
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
use std::fs::File;
|
||||
use std::path::Path;
|
||||
|
||||
use base::text::{unicode_plane, UnicodeBlock, UnicodeBlockMethod};
|
||||
use base::text::{UnicodeBlock, UnicodeBlockMethod, unicode_plane};
|
||||
use log::debug;
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use memmap2::Mmap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use style::values::computed::font::GenericFontFamily;
|
||||
use style::Atom;
|
||||
use style::values::computed::font::GenericFontFamily;
|
||||
use unicode_script::Script;
|
||||
use webrender_api::NativeFontHandle;
|
||||
|
||||
|
|
|
@ -15,20 +15,20 @@ use base::text::{UnicodeBlock, UnicodeBlockMethod};
|
|||
))]
|
||||
use unicode_script::Script;
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
pub use crate::platform::freetype::{font, font_list, LocalFontIdentifier};
|
||||
#[cfg(target_os = "macos")]
|
||||
pub use crate::platform::macos::{
|
||||
core_text_font_cache, font, font_list, font_list::LocalFontIdentifier,
|
||||
};
|
||||
#[cfg(target_os = "windows")]
|
||||
pub use crate::platform::windows::{font, font_list, font_list::LocalFontIdentifier};
|
||||
#[cfg(all(
|
||||
any(target_os = "linux", target_os = "macos"),
|
||||
not(target_os = "android"),
|
||||
not(target_env = "ohos")
|
||||
))]
|
||||
use crate::FallbackFontSelectionOptions;
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
pub use crate::platform::freetype::{LocalFontIdentifier, font, font_list};
|
||||
#[cfg(target_os = "macos")]
|
||||
pub use crate::platform::macos::{
|
||||
core_text_font_cache, font, font_list, font_list::LocalFontIdentifier,
|
||||
};
|
||||
#[cfg(target_os = "windows")]
|
||||
pub use crate::platform::windows::{font, font_list, font_list::LocalFontIdentifier};
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
pub mod freetype;
|
||||
|
|
|
@ -15,18 +15,18 @@ use app_units::Au;
|
|||
use dwrote::{FontCollection, FontFace, FontFile};
|
||||
use euclid::default::{Point2D, Rect, Size2D};
|
||||
use log::{debug, warn};
|
||||
use style::Zero;
|
||||
use style::computed_values::font_stretch::T as StyleFontStretch;
|
||||
use style::computed_values::font_weight::T as StyleFontWeight;
|
||||
use style::values::computed::font::FontStyle as StyleFontStyle;
|
||||
use style::Zero;
|
||||
use truetype::tables::WindowsMetrics;
|
||||
use truetype::value::Read;
|
||||
use webrender_api::FontInstanceFlags;
|
||||
|
||||
use super::font_list::LocalFontIdentifier;
|
||||
use crate::{
|
||||
ot_tag, FontData, FontIdentifier, FontMetrics, FontTableMethods, FontTableTag,
|
||||
FontTemplateDescriptor, FractionalPixel, GlyphId, PlatformFontMethods,
|
||||
FontData, FontIdentifier, FontMetrics, FontTableMethods, FontTableTag, FontTemplateDescriptor,
|
||||
FractionalPixel, GlyphId, PlatformFontMethods, ot_tag,
|
||||
};
|
||||
|
||||
// 1em = 12pt = 16px, assuming 72 points per inch and 96 px per inch
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use std::hash::Hash;
|
||||
use std::sync::Arc;
|
||||
|
||||
use base::text::{unicode_plane, UnicodeBlock, UnicodeBlockMethod};
|
||||
use base::text::{UnicodeBlock, UnicodeBlockMethod, unicode_plane};
|
||||
use dwrote::{Font, FontCollection, FontDescriptor, FontStretch, FontStyle};
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
|
|
@ -14,6 +14,8 @@ use euclid::default::Point2D;
|
|||
// Eventually we would like the shaper to be pluggable, as many operating systems have their own
|
||||
// shapers. For now, however, HarfBuzz is a hard dependency.
|
||||
use harfbuzz_sys::{
|
||||
HB_DIRECTION_LTR, HB_DIRECTION_RTL, HB_MEMORY_MODE_READONLY, HB_OT_LAYOUT_BASELINE_TAG_HANGING,
|
||||
HB_OT_LAYOUT_BASELINE_TAG_IDEO_EMBOX_BOTTOM_OR_LEFT, HB_OT_LAYOUT_BASELINE_TAG_ROMAN,
|
||||
hb_blob_create, hb_blob_t, hb_bool_t, hb_buffer_add_utf8, hb_buffer_create, hb_buffer_destroy,
|
||||
hb_buffer_get_glyph_infos, hb_buffer_get_glyph_positions, hb_buffer_get_length,
|
||||
hb_buffer_set_direction, hb_buffer_set_script, hb_buffer_t, hb_codepoint_t,
|
||||
|
@ -21,17 +23,15 @@ use harfbuzz_sys::{
|
|||
hb_font_destroy, hb_font_funcs_create, hb_font_funcs_set_glyph_h_advance_func,
|
||||
hb_font_funcs_set_nominal_glyph_func, hb_font_funcs_t, hb_font_set_funcs, hb_font_set_ppem,
|
||||
hb_font_set_scale, hb_font_t, hb_glyph_info_t, hb_glyph_position_t, hb_ot_layout_get_baseline,
|
||||
hb_position_t, hb_shape, hb_tag_t, HB_DIRECTION_LTR, HB_DIRECTION_RTL, HB_MEMORY_MODE_READONLY,
|
||||
HB_OT_LAYOUT_BASELINE_TAG_HANGING, HB_OT_LAYOUT_BASELINE_TAG_IDEO_EMBOX_BOTTOM_OR_LEFT,
|
||||
HB_OT_LAYOUT_BASELINE_TAG_ROMAN,
|
||||
hb_position_t, hb_shape, hb_tag_t,
|
||||
};
|
||||
use log::debug;
|
||||
use num_traits::Zero;
|
||||
|
||||
use crate::platform::font::FontTable;
|
||||
use crate::{
|
||||
fixed_to_float, float_to_fixed, ot_tag, ByteIndex, Font, FontBaseline, FontTableMethods,
|
||||
FontTableTag, GlyphData, GlyphId, GlyphStore, ShapingFlags, ShapingOptions, BASE, KERN,
|
||||
BASE, ByteIndex, Font, FontBaseline, FontTableMethods, FontTableTag, GlyphData, GlyphId,
|
||||
GlyphStore, KERN, ShapingFlags, ShapingOptions, fixed_to_float, float_to_fixed, ot_tag,
|
||||
};
|
||||
|
||||
const NO_GLYPH: i32 = -1;
|
||||
|
|
|
@ -30,10 +30,10 @@ use webrender_traits::CrossProcessCompositorApi;
|
|||
use crate::font::FontDescriptor;
|
||||
use crate::font_store::FontStore;
|
||||
use crate::font_template::{FontTemplate, FontTemplateRef};
|
||||
use crate::platform::LocalFontIdentifier;
|
||||
use crate::platform::font_list::{
|
||||
default_system_generic_font_family, for_each_available_family, for_each_variation,
|
||||
};
|
||||
use crate::platform::LocalFontIdentifier;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize)]
|
||||
pub enum FontIdentifier {
|
||||
|
|
|
@ -9,23 +9,24 @@ mod font_context {
|
|||
use std::collections::HashMap;
|
||||
use std::ffi::OsStr;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::atomic::{AtomicI32, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicI32, Ordering};
|
||||
use std::thread;
|
||||
|
||||
use app_units::Au;
|
||||
use fonts::platform::font::PlatformFont;
|
||||
use fonts::{
|
||||
fallback_font_families, FallbackFontSelectionOptions, FontContext, FontDescriptor,
|
||||
FontFamilyDescriptor, FontIdentifier, FontSearchScope, FontTemplate, FontTemplates,
|
||||
LocalFontIdentifier, PlatformFontMethods, SystemFontServiceMessage, SystemFontServiceProxy,
|
||||
SystemFontServiceProxySender,
|
||||
FallbackFontSelectionOptions, FontContext, FontDescriptor, FontFamilyDescriptor,
|
||||
FontIdentifier, FontSearchScope, FontTemplate, FontTemplates, LocalFontIdentifier,
|
||||
PlatformFontMethods, SystemFontServiceMessage, SystemFontServiceProxy,
|
||||
SystemFontServiceProxySender, fallback_font_families,
|
||||
};
|
||||
use ipc_channel::ipc::{self, IpcReceiver};
|
||||
use net_traits::ResourceThreads;
|
||||
use parking_lot::Mutex;
|
||||
use servo_arc::Arc as ServoArc;
|
||||
use servo_atoms::Atom;
|
||||
use style::ArcSlice;
|
||||
use style::properties::longhands::font_variant_caps::computed_value::T as FontVariantCaps;
|
||||
use style::properties::style_structs::Font as FontStyleStruct;
|
||||
use style::values::computed::font::{
|
||||
|
@ -34,7 +35,6 @@ mod font_context {
|
|||
};
|
||||
use style::values::computed::{FontLanguageOverride, XLang};
|
||||
use style::values::generics::font::LineHeight;
|
||||
use style::ArcSlice;
|
||||
use webrender_api::{FontInstanceKey, FontKey, IdNamespace};
|
||||
use webrender_traits::CrossProcessCompositorApi;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue