Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 62 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ taffy = { version = "=0.11.0-experimental-cache-fix.3", default-features = false
"calc",
"detailed_layout_info",
] }
parley = { version = "0.10", default-features = false, features = ["std"] }
parley = { git = "https://github.com/linebender/parley", rev = "f9388f3ddff7efc500ce6389ce9b096f8086b3f0", default-features = false, features = ["std"] }
skrifa = { version = "0.42", default-features = false, features = [
"std",
] } # Should match parley and vello versions
Expand Down
18 changes: 14 additions & 4 deletions packages/blitz-dom/src/layout/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,18 @@ pub(crate) fn collect_layout_children(
.downcast_element()
.and_then(|el| el.attr(local_name!("type")));
if tag_name == "textarea" {
create_text_editor(doc, container_node_id, true);
create_text_editor(doc, container_node_id, true, false);
return;
} else if matches!(
type_attr,
None | Some("text" | "password" | "email" | "number" | "search" | "tel" | "url")
) {
create_text_editor(doc, container_node_id, false);
create_text_editor(
doc,
container_node_id,
false,
matches!(type_attr, Some("password")),
);
return;
} else if matches!(type_attr, Some("checkbox" | "radio")) {
create_checkbox_input(doc, container_node_id);
Expand Down Expand Up @@ -701,7 +706,12 @@ fn collect_complex_layout_children(
out.maybe_push_anon_block(doc);
}

fn create_text_editor(doc: &mut BaseDocument, input_element_id: usize, is_multiline: bool) {
fn create_text_editor(
doc: &mut BaseDocument,
input_element_id: usize,
is_multiline: bool,
is_password: bool,
) {
let node = &mut doc.nodes[input_element_id];
let parley_style = node
.primary_styles()
Expand All @@ -711,7 +721,7 @@ fn create_text_editor(doc: &mut BaseDocument, input_element_id: usize, is_multil

let element = &mut node.data.downcast_element_mut().unwrap();
if !matches!(element.special_data, SpecialElementData::TextInput(_)) {
let mut text_input_data = TextInputData::new(is_multiline);
let mut text_input_data = TextInputData::new(is_multiline, is_password);
let editor = &mut text_input_data.editor;
editor.set_text(element.attr(local_name!("value")).unwrap_or(" "));
element.special_data = SpecialElementData::TextInput(text_input_data);
Expand Down
7 changes: 4 additions & 3 deletions packages/blitz-dom/src/node/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,13 +546,14 @@ pub struct TextInputData {
// FIXME: Implement Clone for PlainEditor
impl Clone for TextInputData {
fn clone(&self) -> Self {
TextInputData::new(self.is_multiline)
TextInputData::new(self.is_multiline, self.editor.is_password())
}
}

impl TextInputData {
pub fn new(is_multiline: bool) -> Self {
let editor = Box::new(parley::PlainEditor::new(16.0));
pub fn new(is_multiline: bool, is_password: bool) -> Self {
let mut editor = Box::new(parley::PlainEditor::new(16.0));
editor.set_password(is_password);
Self {
editor,
is_multiline,
Expand Down
3 changes: 3 additions & 0 deletions packages/blitz-dom/src/stylo_to_parley.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,5 +218,8 @@ pub(crate) fn style(
strikethrough_offset: Default::default(),
strikethrough_size: Default::default(),
strikethrough_brush: Default::default(),

// Used for password masking, which we don't need for regular text
grapheme_replacement: None,
}
}
Loading