mirror of
https://github.com/servo/servo.git
synced 2025-08-12 00:45:33 +01:00
Implements multi line text input for TextArea
This commit is contained in:
parent
fd65b5f438
commit
29241699fd
6 changed files with 115 additions and 11 deletions
|
@ -49,6 +49,7 @@ use script::dom::element::{HTMLObjectElementTypeId, HTMLInputElementTypeId};
|
|||
use script::dom::element::{HTMLTableColElementTypeId, HTMLTableDataCellElementTypeId};
|
||||
use script::dom::element::{HTMLTableElementTypeId, HTMLTableHeaderCellElementTypeId};
|
||||
use script::dom::element::{HTMLTableRowElementTypeId, HTMLTableSectionElementTypeId};
|
||||
use script::dom::element::HTMLTextAreaElementTypeId;
|
||||
use script::dom::node::{CommentNodeTypeId, DoctypeNodeTypeId, DocumentFragmentNodeTypeId};
|
||||
use script::dom::node::{DocumentNodeTypeId, ElementNodeTypeId, ProcessingInstructionNodeTypeId};
|
||||
use script::dom::node::{TextNodeTypeId};
|
||||
|
@ -273,7 +274,8 @@ impl<'a> FlowConstructor<'a> {
|
|||
TableColumnFragment(TableColumnFragmentInfo::new(node))
|
||||
}
|
||||
Some(ElementNodeTypeId(HTMLTableDataCellElementTypeId)) |
|
||||
Some(ElementNodeTypeId(HTMLTableHeaderCellElementTypeId)) => TableCellFragment,
|
||||
Some(ElementNodeTypeId(HTMLTableHeaderCellElementTypeId)) |
|
||||
Some(ElementNodeTypeId(HTMLTextAreaElementTypeId)) => TableCellFragment,
|
||||
Some(ElementNodeTypeId(HTMLTableRowElementTypeId)) |
|
||||
Some(ElementNodeTypeId(HTMLTableSectionElementTypeId)) => TableRowFragment,
|
||||
Some(TextNodeTypeId) => UnscannedTextFragment(UnscannedTextFragmentInfo::new(node)),
|
||||
|
@ -487,7 +489,16 @@ impl<'a> FlowConstructor<'a> {
|
|||
// Special case: If this is generated content, then we need to initialize the accumulator
|
||||
// with the fragment corresponding to that content.
|
||||
if node.get_pseudo_element_type() != Normal ||
|
||||
node.type_id() == Some(ElementNodeTypeId(HTMLInputElementTypeId)) {
|
||||
node.type_id() == Some(ElementNodeTypeId(HTMLInputElementTypeId)) ||
|
||||
node.type_id() == Some(ElementNodeTypeId(HTMLTextAreaElementTypeId)) {
|
||||
// A TextArea's text contents are displayed through the input text
|
||||
// box, so don't construct them.
|
||||
// TODO Maybe this belongs somewhere else?
|
||||
if node.type_id() == Some(ElementNodeTypeId(HTMLTextAreaElementTypeId)) {
|
||||
for kid in node.children() {
|
||||
kid.set_flow_construction_result(NoConstructionResult)
|
||||
}
|
||||
}
|
||||
let fragment_info = UnscannedTextFragment(UnscannedTextFragmentInfo::new(node));
|
||||
let fragment = Fragment::new_from_specific_info(node, fragment_info);
|
||||
inline_fragment_accumulator.fragments.push_back(fragment);
|
||||
|
|
|
@ -39,13 +39,14 @@ use util::{PrivateLayoutData};
|
|||
use gfx::display_list::OpaqueNode;
|
||||
use script::dom::bindings::codegen::InheritTypes::{ElementCast, HTMLIFrameElementCast};
|
||||
use script::dom::bindings::codegen::InheritTypes::{HTMLImageElementCast, HTMLInputElementCast};
|
||||
use script::dom::bindings::codegen::InheritTypes::{NodeCast, TextCast};
|
||||
use script::dom::bindings::codegen::InheritTypes::{HTMLTextAreaElementCast, NodeCast, TextCast};
|
||||
use script::dom::bindings::js::JS;
|
||||
use script::dom::element::{Element, HTMLAreaElementTypeId, HTMLAnchorElementTypeId};
|
||||
use script::dom::element::{HTMLLinkElementTypeId, LayoutElementHelpers, RawLayoutElementHelpers};
|
||||
use script::dom::htmliframeelement::HTMLIFrameElement;
|
||||
use script::dom::htmlimageelement::LayoutHTMLImageElementHelpers;
|
||||
use script::dom::htmlinputelement::LayoutHTMLInputElementHelpers;
|
||||
use script::dom::htmltextareaelement::LayoutHTMLTextAreaElementHelpers;
|
||||
use script::dom::node::{DocumentNodeTypeId, ElementNodeTypeId, Node, NodeTypeId};
|
||||
use script::dom::node::{LayoutNodeHelpers, RawLayoutNodeHelpers, SharedLayoutData};
|
||||
use script::dom::node::{HAS_CHANGED, IS_DIRTY, HAS_DIRTY_SIBLINGS, HAS_DIRTY_DESCENDANTS};
|
||||
|
@ -188,7 +189,10 @@ impl<'ln> TLayoutNode for LayoutNode<'ln> {
|
|||
Some(text) => (*text.unsafe_get()).characterdata().data_for_layout().to_string(),
|
||||
None => match HTMLInputElementCast::to_js(self.get_jsmanaged()) {
|
||||
Some(input) => input.get_value_for_layout(),
|
||||
None => panic!("not text!")
|
||||
None => match HTMLTextAreaElementCast::to_js(self.get_jsmanaged()) {
|
||||
Some(area) => area.get_value_for_layout(),
|
||||
None => panic!("not text!")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue