mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Implemeneted ModifyAttribute handler to update DOM elements.
This commit is contained in:
parent
ad9aedac77
commit
72a5ae7210
6 changed files with 208 additions and 93 deletions
|
@ -11,11 +11,13 @@
|
|||
#![allow(non_snake_case)]
|
||||
|
||||
extern crate "msg" as servo_msg;
|
||||
extern crate serialize;
|
||||
|
||||
/// This module contains shared types and messages for use by devtools/script.
|
||||
/// The traits are here instead of in script so that the devtools crate can be
|
||||
/// modified independently of the rest of Servo.
|
||||
|
||||
use serialize::{Decodable, Decoder};
|
||||
use servo_msg::constellation_msg::PipelineId;
|
||||
|
||||
pub type DevtoolsControlChan = Sender<DevtoolsControlMsg>;
|
||||
|
@ -73,6 +75,7 @@ pub enum DevtoolScriptControlMsg {
|
|||
GetDocumentElement(PipelineId, Sender<NodeInfo>),
|
||||
GetChildren(PipelineId, String, Sender<Vec<NodeInfo>>),
|
||||
GetLayout(PipelineId, String, Sender<(f32, f32)>),
|
||||
ModifyAttribute(PipelineId, String, Vec<Modification>),
|
||||
}
|
||||
|
||||
/// Messages to instruct devtools server to update its state relating to a particular
|
||||
|
@ -81,3 +84,23 @@ pub enum ScriptDevtoolControlMsg {
|
|||
/// Report a new JS error message
|
||||
ReportConsoleMsg(String),
|
||||
}
|
||||
|
||||
#[deriving(Encodable)]
|
||||
pub struct Modification{
|
||||
pub attributeName: String,
|
||||
pub newValue: Option<String>,
|
||||
}
|
||||
|
||||
impl<D:Decoder<E>, E> Decodable<D, E> for Modification {
|
||||
fn decode(d: &mut D) -> Result<Modification, E> {
|
||||
d.read_struct("Modification", 2u, |d|
|
||||
Ok(Modification {
|
||||
attributeName: try!(d.read_struct_field("attributeName", 0u, |d| Decodable::decode(d))),
|
||||
newValue: match d.read_struct_field("newValue", 1u, |d| Decodable::decode(d)) {
|
||||
Ok(opt) => opt,
|
||||
Err(_) => None
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue