mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #6876 - metajack:slice_chars-layout, r=pcwalton
Use local slice_chars StrExt::slice_chars is deprecated and will be removed in Rust. This lifts the implementation from Rust libstd and puts it in util::str. This fixes a bunch of deprecation warnings in Servo. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6876) <!-- Reviewable:end -->
This commit is contained in:
commit
a54404c921
7 changed files with 41 additions and 17 deletions
|
@ -46,7 +46,7 @@ use url::Url;
|
|||
use util::geometry::{Au, ZERO_POINT};
|
||||
use util::logical_geometry::{LogicalRect, LogicalSize, LogicalMargin, WritingMode};
|
||||
use util::range::*;
|
||||
use util::str::is_whitespace;
|
||||
use util::str::{is_whitespace, slice_chars};
|
||||
use util;
|
||||
|
||||
/// Fragments (`struct Fragment`) are the leaves of the layout tree. They cannot position
|
||||
|
@ -204,8 +204,8 @@ impl fmt::Debug for SpecificFragmentInfo {
|
|||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
SpecificFragmentInfo::ScannedText(ref info) => {
|
||||
write!(f, " \"{}\"", info.run.text.slice_chars(info.range.begin().get() as usize,
|
||||
info.range.end().get() as usize))
|
||||
write!(f, " \"{}\"", slice_chars(&*info.run.text, info.range.begin().get() as usize,
|
||||
info.range.end().get() as usize))
|
||||
}
|
||||
_ => Ok(())
|
||||
}
|
||||
|
@ -2094,7 +2094,8 @@ impl Fragment {
|
|||
|
||||
let mut leading_whitespace_character_count = 0;
|
||||
{
|
||||
let text = scanned_text_fragment_info.run.text.slice_chars(
|
||||
let text = slice_chars(
|
||||
&*scanned_text_fragment_info.run.text,
|
||||
scanned_text_fragment_info.range.begin().to_usize(),
|
||||
scanned_text_fragment_info.range.end().to_usize());
|
||||
for character in text.chars() {
|
||||
|
|
|
@ -35,6 +35,7 @@ use unicode_bidi;
|
|||
use util::geometry::{Au, MAX_AU, ZERO_RECT};
|
||||
use util::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
|
||||
use util::range::{Range, RangeIndex};
|
||||
use util::str::slice_chars;
|
||||
use util;
|
||||
|
||||
// From gfxFontConstants.h in Firefox
|
||||
|
@ -1801,7 +1802,7 @@ fn strip_trailing_whitespace_if_necessary(text_run: &TextRun, range: &mut Range<
|
|||
debug!("stripping trailing whitespace: range={:?}, len={}",
|
||||
range,
|
||||
text_run.text.chars().count());
|
||||
let text = text_run.text.slice_chars(range.begin().to_usize(), range.end().to_usize());
|
||||
let text = slice_chars(&*text_run.text, range.begin().to_usize(), range.end().to_usize());
|
||||
let mut trailing_whitespace_character_count = 0;
|
||||
for ch in text.chars().rev() {
|
||||
if util::str::char_is_whitespace(ch) {
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#![feature(mpsc_select)]
|
||||
#![feature(plugin)]
|
||||
#![feature(raw)]
|
||||
#![feature(slice_chars)]
|
||||
#![feature(step_by)]
|
||||
#![feature(str_char)]
|
||||
#![feature(unsafe_no_drop_flag)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue