mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
DataTransfer: propagate CanGc argument (#35062)
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
This commit is contained in:
parent
17b70c5178
commit
1bd34a5781
5 changed files with 41 additions and 18 deletions
|
@ -83,6 +83,18 @@ DOMInterfaces = {
|
|||
'canGc': ['WhenDefined'],
|
||||
},
|
||||
|
||||
'DataTransfer': {
|
||||
'canGc': ['Files']
|
||||
},
|
||||
|
||||
'DataTransferItem': {
|
||||
'canGc': ['GetAsFile']
|
||||
},
|
||||
|
||||
'DataTransferItemList': {
|
||||
'canGc': ['IndexedGetter', 'Add', 'Add_']
|
||||
},
|
||||
|
||||
'Document': {
|
||||
'canGc': ['Close', 'CreateElement', 'CreateElementNS', 'ImportNode', 'SetTitle', 'Write', 'Writeln', 'CreateEvent', 'CreateRange', 'Open', 'Open_', 'CreateComment', 'CreateAttribute', 'CreateAttributeNS', 'CreateDocumentFragment', 'CreateTextNode', 'CreateCDATASection', 'CreateProcessingInstruction', 'Prepend', 'Append', 'ReplaceChildren', 'SetBgColor', 'SetFgColor', 'Fonts', 'ElementFromPoint', 'ElementsFromPoint', 'ExitFullscreen', 'CreateExpression', 'CreateNSResolver', 'Evaluate'],
|
||||
},
|
||||
|
@ -600,4 +612,4 @@ Unions = {
|
|||
'StringOrUnsignedLong': {
|
||||
'derives': ['Clone'],
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ impl DataTransfer {
|
|||
can_gc: CanGc,
|
||||
data_store: Rc<RefCell<Option<DragDataStore>>>,
|
||||
) -> DomRoot<DataTransfer> {
|
||||
let item_list = DataTransferItemList::new(window, Rc::clone(&data_store));
|
||||
let item_list = DataTransferItemList::new(window, Rc::clone(&data_store), can_gc);
|
||||
|
||||
reflect_dom_object_with_proto(
|
||||
Box::new(DataTransfer::new_inherited(data_store, &item_list)),
|
||||
|
@ -251,13 +251,13 @@ impl DataTransferMethods<crate::DomTypeHolder> for DataTransfer {
|
|||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-datatransfer-files>
|
||||
fn Files(&self) -> DomRoot<FileList> {
|
||||
fn Files(&self, can_gc: CanGc) -> DomRoot<FileList> {
|
||||
// Step 1 Start with an empty list.
|
||||
let mut files = Vec::new();
|
||||
|
||||
// Step 2 If the DataTransfer is not associated with a data store return the empty list.
|
||||
if let Some(data_store) = self.data_store.borrow().as_ref() {
|
||||
data_store.files(&self.global(), &mut files);
|
||||
data_store.files(&self.global(), can_gc, &mut files);
|
||||
}
|
||||
|
||||
// Step 5
|
||||
|
|
|
@ -34,11 +34,15 @@ impl DataTransferItem {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn new(global: &GlobalScope, item: Kind) -> DomRoot<DataTransferItem> {
|
||||
pub(crate) fn new(
|
||||
global: &GlobalScope,
|
||||
can_gc: CanGc,
|
||||
item: Kind,
|
||||
) -> DomRoot<DataTransferItem> {
|
||||
reflect_dom_object(
|
||||
Box::new(DataTransferItem::new_inherited(item)),
|
||||
global,
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +69,7 @@ impl DataTransferItemMethods<crate::DomTypeHolder> for DataTransferItem {
|
|||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-datatransferitem-getasfile>
|
||||
fn GetAsFile(&self) -> Option<DomRoot<File>> {
|
||||
self.item.as_file(&self.global())
|
||||
fn GetAsFile(&self, can_gc: CanGc) -> Option<DomRoot<File>> {
|
||||
self.item.as_file(&self.global(), can_gc)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,11 +42,12 @@ impl DataTransferItemList {
|
|||
pub(crate) fn new(
|
||||
window: &Window,
|
||||
data_store: Rc<RefCell<Option<DragDataStore>>>,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<DataTransferItemList> {
|
||||
reflect_dom_object(
|
||||
Box::new(DataTransferItemList::new_inherited(data_store)),
|
||||
window,
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -80,7 +81,7 @@ impl DataTransferItemListMethods<crate::DomTypeHolder> for DataTransferItemList
|
|||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-datatransferitemlist-item>
|
||||
fn IndexedGetter(&self, index: u32) -> Option<DomRoot<DataTransferItem>> {
|
||||
fn IndexedGetter(&self, index: u32, can_gc: CanGc) -> Option<DomRoot<DataTransferItem>> {
|
||||
// Step 1 Return null if it isn't associated with a data store
|
||||
let option = self.data_store.borrow();
|
||||
let data_store = match option.as_ref() {
|
||||
|
@ -91,7 +92,7 @@ impl DataTransferItemListMethods<crate::DomTypeHolder> for DataTransferItemList
|
|||
// Step 2
|
||||
data_store
|
||||
.get_item(index as usize)
|
||||
.map(|item| DataTransferItem::new(&self.global(), item))
|
||||
.map(|item| DataTransferItem::new(&self.global(), can_gc, item))
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-datatransferitemlist-add>
|
||||
|
@ -99,6 +100,7 @@ impl DataTransferItemListMethods<crate::DomTypeHolder> for DataTransferItemList
|
|||
&self,
|
||||
data: DOMString,
|
||||
mut type_: DOMString,
|
||||
can_gc: CanGc,
|
||||
) -> Fallible<Option<DomRoot<DataTransferItem>>> {
|
||||
// Step 1 If the DataTransferItemList object is not in the read/write mode, return null.
|
||||
let mut option = self.data_store.borrow_mut();
|
||||
|
@ -120,13 +122,13 @@ impl DataTransferItemListMethods<crate::DomTypeHolder> for DataTransferItemList
|
|||
let index = data_store.list_len() - 1;
|
||||
let item = data_store
|
||||
.get_item(index)
|
||||
.map(|item| DataTransferItem::new(&self.global(), item));
|
||||
.map(|item| DataTransferItem::new(&self.global(), can_gc, item));
|
||||
|
||||
Ok(item)
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-datatransferitemlist-add>
|
||||
fn Add_(&self, data: &File) -> Fallible<Option<DomRoot<DataTransferItem>>> {
|
||||
fn Add_(&self, data: &File, can_gc: CanGc) -> Fallible<Option<DomRoot<DataTransferItem>>> {
|
||||
// Step 1 If the DataTransferItemList object is not in the read/write mode, return null.
|
||||
let mut option = self.data_store.borrow_mut();
|
||||
let data_store = match option.as_mut() {
|
||||
|
@ -154,7 +156,7 @@ impl DataTransferItemListMethods<crate::DomTypeHolder> for DataTransferItemList
|
|||
let index = data_store.list_len() - 1;
|
||||
let item = data_store
|
||||
.get_item(index)
|
||||
.map(|item| DataTransferItem::new(&self.global(), item));
|
||||
.map(|item| DataTransferItem::new(&self.global(), can_gc, item));
|
||||
|
||||
Ok(item)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue