aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/gfx/font_cache_thread.rs25
-rw-r--r--components/layout/flow_ref.rs2
-rw-r--r--components/layout/sequential.rs2
-rw-r--r--components/net_traits/bluetooth_scanfilter.rs12
-rw-r--r--components/script/dom/bindings/trace.rs3
-rw-r--r--components/script/dom/element.rs2
-rw-r--r--components/script/dom/htmlanchorelement.rs2
-rw-r--r--components/script/dom/htmlhrelement.rs2
-rw-r--r--components/script/dom/htmliframeelement.rs2
-rw-r--r--components/script/dom/htmlimageelement.rs2
-rw-r--r--components/script/dom/htmltablecellelement.rs2
-rw-r--r--components/script/dom/htmltableelement.rs3
-rw-r--r--components/style/attr.rs11
-rw-r--r--components/util/str.rs31
14 files changed, 45 insertions, 56 deletions
diff --git a/components/gfx/font_cache_thread.rs b/components/gfx/font_cache_thread.rs
index a43490036b9..2a1a1e7764c 100644
--- a/components/gfx/font_cache_thread.rs
+++ b/components/gfx/font_cache_thread.rs
@@ -17,6 +17,7 @@ use platform::font_template::FontTemplateData;
use std::borrow::ToOwned;
use std::collections::HashMap;
use std::mem;
+use std::ops::Deref;
use std::sync::{Arc, Mutex};
use std::u32;
use string_cache::Atom;
@@ -24,7 +25,6 @@ use style::font_face::Source;
use style::properties::longhands::font_family::computed_value::FontFamily;
use url::Url;
use util::prefs;
-use util::str::LowercaseString;
use util::thread::spawn_named;
use webrender_traits;
@@ -460,3 +460,26 @@ fn is_supported_font_type(toplevel: &TopLevel, sublevel: &SubLevel) -> bool {
_ => false,
}
}
+
+
+#[derive(Clone, Eq, PartialEq, Hash, Debug, Deserialize, Serialize)]
+pub struct LowercaseString {
+ inner: String,
+}
+
+impl LowercaseString {
+ pub fn new(s: &str) -> LowercaseString {
+ LowercaseString {
+ inner: s.to_lowercase(),
+ }
+ }
+}
+
+impl Deref for LowercaseString {
+ type Target = str;
+
+ #[inline]
+ fn deref(&self) -> &str {
+ &*self.inner
+ }
+}
diff --git a/components/layout/flow_ref.rs b/components/layout/flow_ref.rs
index b2dcc5c34fa..d1717ef2000 100644
--- a/components/layout/flow_ref.rs
+++ b/components/layout/flow_ref.rs
@@ -20,7 +20,7 @@ pub type WeakFlowRef = Weak<Flow>;
/// See https://github.com/servo/servo/issues/6503
/// Use Arc::get_mut instead when possible (e.g. on an Arc that was just created).
#[allow(unsafe_code)]
-pub fn deref_mut<'a>(r: &mut FlowRef) -> &'a mut Flow {
+pub fn deref_mut<'a>(r: &'a mut FlowRef) -> &'a mut Flow {
let ptr: *const Flow = &**r;
unsafe {
&mut *(ptr as *mut Flow)
diff --git a/components/layout/sequential.rs b/components/layout/sequential.rs
index d652d19b773..6663843f572 100644
--- a/components/layout/sequential.rs
+++ b/components/layout/sequential.rs
@@ -87,7 +87,7 @@ pub fn build_display_list_for_subtree(root: &mut FlowRef,
&mut root_stacking_context.children);
let mut build_display_list = BuildDisplayList {
state: DisplayListBuildState::new(&layout_context,
- flow::base(&**root).stacking_context_id),
+ flow::base(&*flow_root).stacking_context_id),
};
build_display_list.traverse(&mut *flow_root);
build_display_list.state.items
diff --git a/components/net_traits/bluetooth_scanfilter.rs b/components/net_traits/bluetooth_scanfilter.rs
index ae51ad6714e..2dd7f14d725 100644
--- a/components/net_traits/bluetooth_scanfilter.rs
+++ b/components/net_traits/bluetooth_scanfilter.rs
@@ -19,11 +19,7 @@ impl ServiceUUIDSequence {
}
fn get_services_set(&self) -> HashSet<String> {
- let mut set = HashSet::new();
- for s in self.0.iter() {
- set.insert(s.clone());
- }
- set
+ self.0.iter().map(String::clone).collect()
}
}
@@ -80,11 +76,7 @@ impl BluetoothScanfilterSequence {
}
fn get_services_set(&self) -> HashSet<String> {
- let mut set = HashSet::new();
- for filter in self.iter() {
- set = &set | &filter.services.get_services_set();
- }
- set
+ self.iter().flat_map(|filter| filter.services.get_services_set()).collect()
}
}
diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs
index 8a4913bfe20..f33a8834a08 100644
--- a/components/script/dom/bindings/trace.rs
+++ b/components/script/dom/bindings/trace.rs
@@ -83,7 +83,7 @@ use std::sync::atomic::{AtomicBool, AtomicUsize};
use std::sync::mpsc::{Receiver, Sender};
use std::time::SystemTime;
use string_cache::{Atom, Namespace, QualName};
-use style::attr::{AttrIdentifier, AttrValue};
+use style::attr::{AttrIdentifier, AttrValue, LengthOrPercentageOrAuto};
use style::element_state::*;
use style::properties::PropertyDeclarationBlock;
use style::restyle_hints::ElementSnapshot;
@@ -91,7 +91,6 @@ use style::selector_impl::PseudoElement;
use style::values::specified::Length;
use url::Origin as UrlOrigin;
use url::Url;
-use util::str::LengthOrPercentageOrAuto;
use uuid::Uuid;
use webrender_traits::WebGLError;
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index bb6b83e32fe..fc4160f1843 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -85,6 +85,7 @@ use std::mem;
use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering};
use string_cache::{Atom, BorrowedAtom, BorrowedNamespace, Namespace, QualName};
+use style::attr::LengthOrPercentageOrAuto;
use style::element_state::*;
use style::parser::ParserContextExtraData;
use style::properties::DeclaredValue;
@@ -93,7 +94,6 @@ use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, parse_sty
use style::selector_impl::{NonTSPseudoClass, ServoSelectorImpl};
use style::values::CSSFloat;
use style::values::specified::{self, CSSColor, CSSRGBA, LengthOrPercentage};
-use util::str::LengthOrPercentageOrAuto;
// TODO: Update focus state when the top-level browsing context gains or loses system focus,
// and when the element enters or leaves a browsing context container.
diff --git a/components/script/dom/htmlanchorelement.rs b/components/script/dom/htmlanchorelement.rs
index c69e61cae80..4fb575dd1e2 100644
--- a/components/script/dom/htmlanchorelement.rs
+++ b/components/script/dom/htmlanchorelement.rs
@@ -64,7 +64,7 @@ impl HTMLAnchorElement {
let attribute = self.upcast::<Element>().get_attribute(&ns!(), &atom!("href"));
*self.url.borrow_mut() = attribute.and_then(|attribute| {
let document = document_from_node(self);
- document.url().join(&attribute.value()).ok()
+ document.base_url().join(&attribute.value()).ok()
});
}
diff --git a/components/script/dom/htmlhrelement.rs b/components/script/dom/htmlhrelement.rs
index 7259814fdd9..1041319f907 100644
--- a/components/script/dom/htmlhrelement.rs
+++ b/components/script/dom/htmlhrelement.rs
@@ -14,7 +14,7 @@ use dom::htmlelement::HTMLElement;
use dom::node::Node;
use dom::virtualmethods::VirtualMethods;
use string_cache::Atom;
-use util::str::LengthOrPercentageOrAuto;
+use style::attr::LengthOrPercentageOrAuto;
#[dom_struct]
pub struct HTMLHRElement {
diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs
index 4c5fb336c69..bc37f526f88 100644
--- a/components/script/dom/htmliframeelement.rs
+++ b/components/script/dom/htmliframeelement.rs
@@ -42,10 +42,10 @@ use script_traits::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandboxed};
use script_traits::{IFrameLoadInfo, MozBrowserEvent, ScriptMsg as ConstellationMsg};
use std::cell::Cell;
use string_cache::Atom;
+use style::attr::LengthOrPercentageOrAuto;
use style::context::ReflowGoal;
use url::Url;
use util::prefs::mozbrowser_enabled;
-use util::str::LengthOrPercentageOrAuto;
#[derive(HeapSizeOf)]
enum SandboxAllowance {
diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs
index 8bd29e7678f..49f771824d3 100644
--- a/components/script/dom/htmlimageelement.rs
+++ b/components/script/dom/htmlimageelement.rs
@@ -31,8 +31,8 @@ use script_runtime::ScriptThreadEventCategory::UpdateReplacedElement;
use script_thread::Runnable;
use std::sync::Arc;
use string_cache::Atom;
+use style::attr::LengthOrPercentageOrAuto;
use url::Url;
-use util::str::LengthOrPercentageOrAuto;
#[derive(JSTraceable, HeapSizeOf)]
#[allow(dead_code)]
diff --git a/components/script/dom/htmltablecellelement.rs b/components/script/dom/htmltablecellelement.rs
index 036771e178a..ae54b915342 100644
--- a/components/script/dom/htmltablecellelement.rs
+++ b/components/script/dom/htmltablecellelement.rs
@@ -16,7 +16,7 @@ use dom::htmltablerowelement::HTMLTableRowElement;
use dom::node::Node;
use dom::virtualmethods::VirtualMethods;
use string_cache::Atom;
-use util::str::LengthOrPercentageOrAuto;
+use style::attr::LengthOrPercentageOrAuto;
const DEFAULT_COLSPAN: u32 = 1;
diff --git a/components/script/dom/htmltableelement.rs b/components/script/dom/htmltableelement.rs
index 26a373a3630..a86381967b4 100644
--- a/components/script/dom/htmltableelement.rs
+++ b/components/script/dom/htmltableelement.rs
@@ -24,8 +24,7 @@ use dom::node::{Node, document_from_node, window_from_node};
use dom::virtualmethods::VirtualMethods;
use std::cell::Cell;
use string_cache::Atom;
-use style::attr::parse_unsigned_integer;
-use util::str::LengthOrPercentageOrAuto;
+use style::attr::{LengthOrPercentageOrAuto, parse_unsigned_integer};
#[dom_struct]
pub struct HTMLTableElement {
diff --git a/components/style/attr.rs b/components/style/attr.rs
index 8d5777bc34f..42fdbbc853b 100644
--- a/components/style/attr.rs
+++ b/components/style/attr.rs
@@ -10,13 +10,20 @@ use std::ascii::AsciiExt;
use std::str::FromStr;
use string_cache::{Atom, Namespace};
use url::Url;
-use util::str::{LengthOrPercentageOrAuto, HTML_SPACE_CHARACTERS};
-use util::str::{read_exponent, read_fraction, read_numbers, split_commas, split_html_space_chars};
+use util::str::{HTML_SPACE_CHARACTERS, read_exponent, read_fraction};
+use util::str::{read_numbers, split_commas, split_html_space_chars};
use values::specified::Length;
// Duplicated from script::dom::values.
const UNSIGNED_LONG_MAX: u32 = 2147483647;
+#[derive(Clone, Copy, Debug, HeapSizeOf, PartialEq)]
+pub enum LengthOrPercentageOrAuto {
+ Auto,
+ Percentage(f32),
+ Length(Au),
+}
+
#[derive(PartialEq, Clone, HeapSizeOf)]
pub enum AttrValue {
String(String),
diff --git a/components/util/str.rs b/components/util/str.rs
index 7df67e1b421..73518625b6e 100644
--- a/components/util/str.rs
+++ b/components/util/str.rs
@@ -2,11 +2,9 @@
* 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 app_units::Au;
use num_traits::ToPrimitive;
use std::convert::AsRef;
use std::iter::{Filter, Peekable};
-use std::ops::Deref;
use std::str::Split;
pub type StaticCharVec = &'static [char];
@@ -118,35 +116,6 @@ pub fn read_exponent<I: Iterator<Item=char>>(mut iter: Peekable<I>) -> Option<i3
}
}
-#[derive(Clone, Copy, Debug, HeapSizeOf, PartialEq)]
-pub enum LengthOrPercentageOrAuto {
- Auto,
- Percentage(f32),
- Length(Au),
-}
-
-#[derive(Clone, Eq, PartialEq, Hash, Debug, Deserialize, Serialize)]
-pub struct LowercaseString {
- inner: String,
-}
-
-impl LowercaseString {
- pub fn new(s: &str) -> LowercaseString {
- LowercaseString {
- inner: s.to_lowercase(),
- }
- }
-}
-
-impl Deref for LowercaseString {
- type Target = str;
-
- #[inline]
- fn deref(&self) -> &str {
- &*self.inner
- }
-}
-
pub fn str_join<I, T>(strs: I, join: &str) -> String
where I: IntoIterator<Item=T>, T: AsRef<str>,
{