Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Document.createElementNS() #1391

Closed
Closed
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b3aaa4b
Document.creatElementNS() and reftest
therealglazou Dec 12, 2013
6666929
merge upstream
therealglazou Feb 21, 2014
4f8acae
Merge remote-tracking branch 'upstream/master' into therealglazou/cre…
therealglazou Feb 21, 2014
28933b1
new version of Document.createElementNS
therealglazou Feb 21, 2014
9f0e696
De-@mut pipeline
larsbergstrom Feb 11, 2014
2ec9649
Shut down the profiler in headless compositing mode
pcwalton Feb 21, 2014
4fe305c
Prevent '&nbsp' from stripping as whitespace
june0cho Feb 21, 2014
26cd50d
Fix: whitespace is considered as spaces(U+0020), tabs(U+0009), and li…
june0cho Feb 21, 2014
735d826
De-@mut the FrameTree.
larsbergstrom Feb 14, 2014
d39f028
Update rust-layers submodule
larsbergstrom Feb 19, 2014
998a561
Remove commented-out parts of Document.webidl and HTMLDocument.webidl.
Ms2ger Feb 22, 2014
f345b69
Create a Line DisplayItem
ngsankha Feb 17, 2014
a8716ad
add Element::new
therealglazou Feb 24, 2014
b4d5184
trailing ws
therealglazou Feb 24, 2014
99f02d1
reuse get_attribute_parts
therealglazou Feb 24, 2014
d5a5fb6
no lowercasing for html element names
therealglazou Feb 24, 2014
0f764df
adding comment with spec URL
therealglazou Feb 24, 2014
77bd9b0
simplify match in CreateElementNS
therealglazou Feb 24, 2014
916c5d1
simplify match in CreateElementNS
therealglazou Feb 24, 2014
f1d60a7
simplify namespace error cases
therealglazou Feb 24, 2014
575c25e
simplify namespace error cases
therealglazou Feb 24, 2014
1308285
remove the ': Namesapce'
therealglazou Feb 24, 2014
3c28d06
better test
therealglazou Feb 24, 2014
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -127,6 +127,7 @@ pub enum DisplayItem<E> {
TextDisplayItemClass(~TextDisplayItem<E>),
ImageDisplayItemClass(~ImageDisplayItem<E>),
BorderDisplayItemClass(~BorderDisplayItem<E>),
LineDisplayItemClass(~LineDisplayItem<E>),
ClipDisplayItemClass(~ClipDisplayItem<E>)
}

@@ -206,6 +207,17 @@ pub struct BorderDisplayItem<E> {
style: SideOffsets2D<border_style::T>
}

/// Renders a line segment
pub struct LineDisplayItem<E> {
base: BaseDisplayItem<E>,

/// The line segment color.
color: Color,

/// The line segemnt style.
style: border_style::T
}

pub struct ClipDisplayItem<E> {
base: BaseDisplayItem<E>,
child_list: ~[DisplayItem<E>],
@@ -303,6 +315,12 @@ impl<E> DisplayItem<E> {
border.color,
border.style)
}

LineDisplayItemClass(ref line) => {
render_context.draw_line(&line.base.bounds,
line.color,
line.style)
}
}
}

@@ -314,6 +332,7 @@ impl<E> DisplayItem<E> {
TextDisplayItemClass(ref text) => transmute_region(&text.base),
ImageDisplayItemClass(ref image_item) => transmute_region(&image_item.base),
BorderDisplayItemClass(ref border) => transmute_region(&border.base),
LineDisplayItemClass(ref line) => transmute_region(&line.base),
ClipDisplayItemClass(ref clip) => transmute_region(&clip.base),
}
}
@@ -329,7 +348,8 @@ impl<E> DisplayItem<E> {
SolidColorDisplayItemClass(..) |
TextDisplayItemClass(..) |
ImageDisplayItemClass(..) |
BorderDisplayItemClass(..) => EmptyDisplayItemIterator,
BorderDisplayItemClass(..) |
LineDisplayItemClass(..) => EmptyDisplayItemIterator,
}
}

@@ -350,6 +370,7 @@ impl<E> DisplayItem<E> {
TextDisplayItemClass(_) => "Text",
ImageDisplayItemClass(_) => "Image",
BorderDisplayItemClass(_) => "Border",
LineDisplayItemClass(_) => "Line",
ClipDisplayItemClass(_) => "Clip",
};
format!("{} @ {:?}", class, self.base().bounds)
@@ -62,6 +62,15 @@ impl<'a> RenderContext<'a> {
self.draw_border_segment(Left, bounds, border, color, style);
}

pub fn draw_line(&self,
bounds: &Rect<Au>,
color: Color,
style: border_style::T) {
self.draw_target.make_current();

self.draw_line_segment(bounds, color, style);
}

pub fn draw_push_clip(&self, bounds: &Rect<Au>) {
let rect = bounds.to_azure_rect();
let path_builder = self.draw_target.create_path_builder();
@@ -148,6 +157,25 @@ impl<'a> RenderContext<'a> {
}
}

fn draw_line_segment(&self, bounds: &Rect<Au>, color: Color, style: border_style::T) {
let border = SideOffsets2D::new_all_same(bounds.size.width).to_float_px();

match style{
border_style::none | border_style::hidden => {}
border_style::dotted => {
//FIXME(sankha93): Dotted style should be implemented.
}
border_style::dashed => {
self.draw_dashed_border_segment(Right,bounds,border,color);
}
border_style::solid => {
self.draw_solid_border_segment(Right,bounds,border,color);
}
//FIXME(sankha93): Five more styles should be implemented.
//double, groove, ridge, inset, outset
}
}

fn draw_dashed_border_segment(&self, direction: Direction, bounds: &Rect<Au>, border: SideOffsets2D<f32>, color: Color) {
let rect = bounds.to_azure_rect();
let draw_opts = DrawOptions(1 as AzFloat, 0 as uint16_t);
@@ -39,12 +39,16 @@ use servo_util::{time, url};
use std::comm::Port;
use std::num::Orderable;
use std::path::Path;
use std::rc::Rc;

//FIXME: switch to std::rc when we upgrade Rust
use layers::temp_rc::Rc;
//use std::rc::Rc;

use std::rc;

pub struct IOCompositor {
/// The application window.
window: Rc<Window>,
window: rc::Rc<Window>,

/// The port on which we receive messages.
port: Port<Msg>,
@@ -53,7 +57,7 @@ pub struct IOCompositor {
context: RenderContext,

/// The root ContainerLayer.
root_layer: @mut ContainerLayer,
root_layer: Rc<ContainerLayer>,

/// The canvas to paint a page.
scene: Scene,
@@ -116,21 +120,21 @@ impl IOCompositor {
port: Port<Msg>,
constellation_chan: ConstellationChan,
profiler_chan: ProfilerChan) -> IOCompositor {
let window: Rc<Window> = WindowMethods::new(app);
let window: rc::Rc<Window> = WindowMethods::new(app);

// Create an initial layer tree.
//
// TODO: There should be no initial layer tree until the renderer creates one from the display
// list. This is only here because we don't have that logic in the renderer yet.
let root_layer = @mut ContainerLayer();
let root_layer = Rc::new(ContainerLayer());
let window_size = window.borrow().size();

IOCompositor {
window: window,
port: port,
opts: opts,
context: rendergl::init_render_context(),
root_layer: root_layer,
root_layer: root_layer.clone(),
scene: Scene(ContainerLayerKind(root_layer), window_size, identity()),
window_size: Size2D(window_size.width as uint, window_size.height as uint),
graphics_context: CompositorTask::create_graphics_context(),
@@ -317,16 +321,22 @@ impl IOCompositor {
response_chan.send(());

// This assumes there is at most one child, which should be the case.
match self.root_layer.first_child {
Some(old_layer) => self.root_layer.remove_child(old_layer),
None => {}
// NOTE: work around borrowchk
{
let tmp = self.root_layer.borrow().first_child.borrow();
match *tmp.get() {
Some(ref old_layer) => ContainerLayer::remove_child(self.root_layer.clone(),
old_layer.clone()),
None => {}
}
}

let layer = CompositorLayer::from_frame_tree(frame_tree,
self.opts.tile_size,
Some(10000000u),
self.opts.cpu_painting);
self.root_layer.add_child_start(ContainerLayerKind(layer.root_layer));
ContainerLayer::add_child_start(self.root_layer.clone(),
ContainerLayerKind(layer.root_layer.clone()));

// If there's already a root layer, destroy it cleanly.
match self.compositor_layer {
@@ -360,13 +370,17 @@ impl IOCompositor {
Some(10000000u),
self.opts.cpu_painting);

let current_child = self.root_layer.first_child;
// This assumes there is at most one child, which should be the case.
match current_child {
Some(old_layer) => self.root_layer.remove_child(old_layer),
None => {}
{
let current_child = self.root_layer.borrow().first_child.borrow();
// This assumes there is at most one child, which should be the case.
match *current_child.get() {
Some(ref old_layer) => ContainerLayer::remove_child(self.root_layer.clone(),
old_layer.clone()),
None => {}
}
}
self.root_layer.add_child_start(ContainerLayerKind(new_layer.root_layer));
ContainerLayer::add_child_start(self.root_layer.clone(),
ContainerLayerKind(new_layer.root_layer.clone()));
self.compositor_layer = Some(new_layer);

self.ask_for_tiles();
@@ -617,7 +631,7 @@ impl IOCompositor {
self.world_zoom = (self.world_zoom * magnification).max(&1.0);
let world_zoom = self.world_zoom;

self.root_layer.common.set_transform(identity().scale(world_zoom, world_zoom, 1f32));
self.root_layer.borrow().common.with_mut(|common| common.set_transform(identity().scale(world_zoom, world_zoom, 1f32)));

// Scroll as needed
let page_delta = Point2D(window_size.width as f32 * (1.0 / world_zoom - 1.0 / old_world_zoom) * 0.5,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.