mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Make the channel argument to TextInput::new be optional, to support the signature expected by the unit tests.
This commit is contained in:
parent
2d110e73b5
commit
cf6aef5d51
4 changed files with 25 additions and 20 deletions
|
@ -120,7 +120,7 @@ impl HTMLInputElement {
|
|||
checked_changed: Cell::new(false),
|
||||
value_changed: Cell::new(false),
|
||||
size: Cell::new(DEFAULT_INPUT_SIZE),
|
||||
textinput: DOMRefCell::new(TextInput::new(Single, "".to_owned(), chan)),
|
||||
textinput: DOMRefCell::new(TextInput::new(Single, "".to_owned(), Some(chan))),
|
||||
activation_state: DOMRefCell::new(InputActivationState::new())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ impl HTMLTextAreaElement {
|
|||
let chan = document.window().root().r().constellation_chan();
|
||||
HTMLTextAreaElement {
|
||||
htmlelement: HTMLElement::new_inherited(HTMLElementTypeId::HTMLTextAreaElement, localName, prefix, document),
|
||||
textinput: DOMRefCell::new(TextInput::new(Lines::Multiple, "".to_owned(), chan)),
|
||||
textinput: DOMRefCell::new(TextInput::new(Lines::Multiple, "".to_owned(), Some(chan))),
|
||||
cols: Cell::new(DEFAULT_COLS),
|
||||
rows: Cell::new(DEFAULT_ROWS),
|
||||
value_changed: Cell::new(false),
|
||||
|
|
|
@ -43,7 +43,7 @@ pub struct TextInput {
|
|||
selection_begin: Option<TextPoint>,
|
||||
/// Is this a multiline input?
|
||||
multiline: bool,
|
||||
constellation_channel: ConstellationChan
|
||||
constellation_channel: Option<ConstellationChan>
|
||||
}
|
||||
|
||||
/// Resulting action to be taken by the owner of a text input that is handling an event.
|
||||
|
@ -91,7 +91,7 @@ fn is_control_key(event: JSRef<KeyboardEvent>) -> bool {
|
|||
|
||||
impl TextInput {
|
||||
/// Instantiate a new text input control
|
||||
pub fn new(lines: Lines, initial: DOMString, cc: ConstellationChan) -> TextInput {
|
||||
pub fn new(lines: Lines, initial: DOMString, cc: Option<ConstellationChan>) -> TextInput {
|
||||
let mut i = TextInput {
|
||||
lines: vec!(),
|
||||
edit_point: Default::default(),
|
||||
|
@ -298,9 +298,14 @@ impl TextInput {
|
|||
},
|
||||
"v" if is_control_key(event) => {
|
||||
let (tx, rx) = channel();
|
||||
self.constellation_channel.0.send(ConstellationMsg::GetClipboardContents(tx)).unwrap();
|
||||
let contents = rx.recv().unwrap();
|
||||
self.insert_string(contents.as_slice());
|
||||
let mut contents = None;
|
||||
if let Some(ref cc) = self.constellation_channel {
|
||||
cc.0.send(ConstellationMsg::GetClipboardContents(tx)).unwrap();
|
||||
contents = Some(rx.recv().unwrap());
|
||||
}
|
||||
if let Some(contents) = contents {
|
||||
self.insert_string(contents.as_slice());
|
||||
}
|
||||
KeyReaction::DispatchInput
|
||||
},
|
||||
// printable characters have single-character key values
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue