Replace Au-related free functions in util::geometry with Au methods.

This commit is contained in:
Simon Sapin 2015-05-05 17:34:01 +02:00
parent 49aed6555d
commit 32d5e24922
12 changed files with 50 additions and 92 deletions

View file

@ -21,7 +21,6 @@ use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
use dom::node::{document_from_node, Node, NodeTypeId, NodeHelpers, NodeDamage, window_from_node};
use dom::virtualmethods::VirtualMethods;
use dom::window::WindowHelpers;
use util::geometry::to_px;
use util::str::DOMString;
use string_cache::Atom;
@ -188,7 +187,7 @@ impl<'a> HTMLImageElementMethods for JSRef<'a, HTMLImageElement> {
fn Width(self) -> u32 {
let node: JSRef<Node> = NodeCast::from_ref(self);
let rect = node.get_bounding_content_box();
to_px(rect.size.width) as u32
rect.size.width.to_px() as u32
}
fn SetWidth(self, width: u32) {
@ -199,7 +198,7 @@ impl<'a> HTMLImageElementMethods for JSRef<'a, HTMLImageElement> {
fn Height(self) -> u32 {
let node: JSRef<Node> = NodeCast::from_ref(self);
let rect = node.get_bounding_content_box();
to_px(rect.size.height) as u32
rect.size.height.to_px() as u32
}
fn SetHeight(self, height: u32) {

View file

@ -917,10 +917,10 @@ impl Window {
}
fn should_move_clip_rect(clip_rect: Rect<Au>, new_viewport: Rect<f32>) -> bool{
let clip_rect = Rect(Point2D(geometry::to_frac_px(clip_rect.origin.x) as f32,
geometry::to_frac_px(clip_rect.origin.y) as f32),
Size2D(geometry::to_frac_px(clip_rect.size.width) as f32,
geometry::to_frac_px(clip_rect.size.height) as f32));
let clip_rect = Rect(Point2D(clip_rect.origin.x.to_frac32_px(),
clip_rect.origin.y.to_frac32_px()),
Size2D(clip_rect.size.width.to_frac32_px(),
clip_rect.size.height.to_frac32_px()));
// We only need to move the clip rect if the viewport is getting near the edge of
// our preexisting clip rect. We use half of the size of the viewport as a heuristic

View file

@ -70,7 +70,6 @@ use net_traits::LoadData as NetLoadData;
use net_traits::image_cache_task::{ImageCacheChan, ImageCacheTask, ImageCacheResult};
use net_traits::storage_task::StorageTask;
use string_cache::Atom;
use util::geometry::to_frac_px;
use util::str::DOMString;
use util::task::{spawn_named, spawn_named_with_send_on_failure};
use util::task_state;
@ -85,7 +84,6 @@ use js::rust::{Runtime, RtUtils};
use url::Url;
use libc;
use num::ToPrimitive;
use std::any::Any;
use std::borrow::ToOwned;
use std::cell::{Cell, RefCell};
@ -1182,8 +1180,7 @@ impl ScriptTask {
fn scroll_fragment_point(&self, pipeline_id: PipelineId, node: JSRef<Element>) {
let node: JSRef<Node> = NodeCast::from_ref(node);
let rect = node.get_bounding_content_box();
let point = Point2D(to_frac_px(rect.origin.x).to_f32().unwrap(),
to_frac_px(rect.origin.y).to_f32().unwrap());
let point = Point2D(rect.origin.x.to_frac32_px(), rect.origin.y.to_frac32_px());
// FIXME(#2003, pcwalton): This is pretty bogus when multiple layers are involved.
// Really what needs to happen is that this needs to go through layout to ask which
// layer the element belongs to, and have it send the scroll message to the