@@ -18,7 +18,7 @@ use embedder_traits::{
18
18
} ;
19
19
use encoding_rs:: Encoding ;
20
20
use euclid:: { Point2D , Rect , Size2D } ;
21
- use html5ever:: { LocalName , Prefix , local_name, ns} ;
21
+ use html5ever:: { LocalName , Prefix , QualName , local_name, ns} ;
22
22
use js:: jsapi:: {
23
23
ClippedTime , DateGetMsecSinceEpoch , Handle , JS_ClearPendingException , JSObject , NewDateObject ,
24
24
NewUCRegExpObject , ObjectIsDate , RegExpFlag_UnicodeSets , RegExpFlags ,
@@ -60,14 +60,15 @@ use crate::dom::bindings::str::{DOMString, FromInputValueString, ToInputValueStr
60
60
use crate :: dom:: clipboardevent:: ClipboardEvent ;
61
61
use crate :: dom:: compositionevent:: CompositionEvent ;
62
62
use crate :: dom:: document:: Document ;
63
- use crate :: dom:: element:: { AttributeMutation , Element , LayoutElementHelpers } ;
63
+ use crate :: dom:: element:: {
64
+ AttributeMutation , CustomElementCreationMode , Element , ElementCreator , LayoutElementHelpers ,
65
+ } ;
64
66
use crate :: dom:: event:: { Event , EventBubbles , EventCancelable } ;
65
67
use crate :: dom:: eventtarget:: EventTarget ;
66
68
use crate :: dom:: file:: File ;
67
69
use crate :: dom:: filelist:: { FileList , LayoutFileListHelpers } ;
68
70
use crate :: dom:: globalscope:: GlobalScope ;
69
71
use crate :: dom:: html:: htmldatalistelement:: HTMLDataListElement ;
70
- use crate :: dom:: html:: htmldivelement:: HTMLDivElement ;
71
72
use crate :: dom:: html:: htmlelement:: HTMLElement ;
72
73
use crate :: dom:: html:: htmlfieldsetelement:: HTMLFieldSetElement ;
73
74
use crate :: dom:: html:: htmlformelement:: {
@@ -123,9 +124,9 @@ const DEFAULT_FILE_INPUT_VALUE: &str = "No file chosen";
123
124
// TextNode within an inline flow. Another example is the horizontal scroll.
124
125
// FIXME(#38263): Refactor these logics into a TextControl wrapper that would decouple all textual input.
125
126
struct InputTypeTextShadowTree {
126
- inner_container : Dom < HTMLDivElement > ,
127
- text_container : Dom < HTMLDivElement > ,
128
- placeholder_container : DomRefCell < Option < Dom < HTMLDivElement > > > ,
127
+ inner_container : Dom < Element > ,
128
+ text_container : Dom < Element > ,
129
+ placeholder_container : DomRefCell < Option < Dom < Element > > > ,
129
130
}
130
131
131
132
impl InputTypeTextShadowTree {
@@ -158,7 +159,7 @@ impl InputTypeTextShadowTree {
158
159
/// The shadow tree consists of a single div with the currently selected color as
159
160
/// the background.
160
161
struct InputTypeColorShadowTree {
161
- color_value : Dom < HTMLDivElement > ,
162
+ color_value : Dom < Element > ,
162
163
}
163
164
164
165
#[ derive( Clone , JSTraceable , MallocSizeOf ) ]
@@ -178,8 +179,17 @@ fn create_ua_widget_div_with_text_node(
178
179
implemented_pseudo : PseudoElement ,
179
180
as_first_child : bool ,
180
181
can_gc : CanGc ,
181
- ) -> DomRoot < HTMLDivElement > {
182
- let el = HTMLDivElement :: new ( local_name ! ( "div" ) , None , document, None , can_gc) ;
182
+ ) -> DomRoot < Element > {
183
+ let el = Element :: create (
184
+ QualName :: new ( None , ns ! ( html) , local_name ! ( "div" ) ) ,
185
+ None ,
186
+ document,
187
+ ElementCreator :: ScriptCreated ,
188
+ CustomElementCreationMode :: Asynchronous ,
189
+ None ,
190
+ can_gc,
191
+ ) ;
192
+
183
193
parent
184
194
. upcast :: < Node > ( )
185
195
. AppendChild ( el. upcast :: < Node > ( ) , can_gc)
@@ -1168,8 +1178,15 @@ impl HTMLInputElement {
1168
1178
let shadow_root = self . shadow_root ( can_gc) ;
1169
1179
Node :: replace_all ( None , shadow_root. upcast :: < Node > ( ) , can_gc) ;
1170
1180
1171
- let inner_container =
1172
- HTMLDivElement :: new ( local_name ! ( "div" ) , None , & document, None , can_gc) ;
1181
+ let inner_container = Element :: create (
1182
+ QualName :: new ( None , ns ! ( html) , local_name ! ( "div" ) ) ,
1183
+ None ,
1184
+ & document,
1185
+ ElementCreator :: ScriptCreated ,
1186
+ CustomElementCreationMode :: Asynchronous ,
1187
+ None ,
1188
+ can_gc,
1189
+ ) ;
1173
1190
shadow_root
1174
1191
. upcast :: < Node > ( )
1175
1192
. AppendChild ( inner_container. upcast :: < Node > ( ) , can_gc)
@@ -1223,7 +1240,15 @@ impl HTMLInputElement {
1223
1240
let shadow_root = self . shadow_root ( can_gc) ;
1224
1241
Node :: replace_all ( None , shadow_root. upcast :: < Node > ( ) , can_gc) ;
1225
1242
1226
- let color_value = HTMLDivElement :: new ( local_name ! ( "div" ) , None , & document, None , can_gc) ;
1243
+ let color_value = Element :: create (
1244
+ QualName :: new ( None , ns ! ( html) , local_name ! ( "div" ) ) ,
1245
+ None ,
1246
+ & document,
1247
+ ElementCreator :: ScriptCreated ,
1248
+ CustomElementCreationMode :: Asynchronous ,
1249
+ None ,
1250
+ can_gc,
1251
+ ) ;
1227
1252
shadow_root
1228
1253
. upcast :: < Node > ( )
1229
1254
. AppendChild ( color_value. upcast :: < Node > ( ) , can_gc)
@@ -1343,10 +1368,11 @@ impl HTMLInputElement {
1343
1368
value = DOMString :: from ( "#000000" ) ;
1344
1369
}
1345
1370
let style = format ! ( "background-color: {value}" ) ;
1346
- color_shadow_tree
1347
- . color_value
1348
- . upcast :: < Element > ( )
1349
- . set_string_attribute ( & local_name ! ( "style" ) , style. into ( ) , can_gc) ;
1371
+ color_shadow_tree. color_value . set_string_attribute (
1372
+ & local_name ! ( "style" ) ,
1373
+ style. into ( ) ,
1374
+ can_gc,
1375
+ ) ;
1350
1376
}
1351
1377
1352
1378
fn update_shadow_tree ( & self , can_gc : CanGc ) {
0 commit comments