mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Auto merge of #27299 - avr1254:master, r=jdm
Implemented get element target algorithm Added check for area and anchor element Finished issue: Implemented get target and no opener algorithm Implemented get element target and get element noopener algorithms. <!-- Please describe your changes on the following line: --> Used the algorithms in html spec to implement target and no opener algorithms. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #27253 (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
commit
b83433fb14
10 changed files with 90 additions and 59 deletions
|
@ -32,6 +32,7 @@ use crate::dom::file::File;
|
|||
use crate::dom::formdata::FormData;
|
||||
use crate::dom::formdataevent::FormDataEvent;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::htmlanchorelement::{get_element_noopener, get_element_target};
|
||||
use crate::dom::htmlbuttonelement::HTMLButtonElement;
|
||||
use crate::dom::htmlcollection::CollectionFilter;
|
||||
use crate::dom::htmldatalistelement::HTMLDataListElement;
|
||||
|
@ -595,12 +596,12 @@ impl HTMLFormElementMethods for HTMLFormElement {
|
|||
return names_vec;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-form-checkvalidity
|
||||
/// https://html.spec.whatwg.org/multipage/#dom-form-checkvalidity
|
||||
fn CheckValidity(&self) -> bool {
|
||||
self.static_validation().is_ok()
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-form-reportvalidity
|
||||
/// https://html.spec.whatwg.org/multipage/#dom-form-reportvalidity
|
||||
fn ReportValidity(&self) -> bool {
|
||||
self.interactive_validation().is_ok()
|
||||
}
|
||||
|
@ -765,10 +766,26 @@ impl HTMLFormElement {
|
|||
let enctype = submitter.enctype();
|
||||
let method = submitter.method();
|
||||
|
||||
// Step 17-21
|
||||
let target_attribute_value = submitter.target();
|
||||
// Step 17
|
||||
let target_attribute_value =
|
||||
if submitter.is_submit_button() && submitter.target() != DOMString::new() {
|
||||
Some(submitter.target())
|
||||
} else {
|
||||
let form_owner = submitter.form_owner();
|
||||
let form = form_owner.as_ref().map(|form| &**form).unwrap_or(self);
|
||||
get_element_target(form.upcast::<Element>())
|
||||
};
|
||||
|
||||
// Step 18
|
||||
let noopener =
|
||||
get_element_noopener(self.upcast::<Element>(), target_attribute_value.clone());
|
||||
|
||||
// Step 19
|
||||
let source = doc.browsing_context().unwrap();
|
||||
let (maybe_chosen, _new) = source.choose_browsing_context(target_attribute_value, false);
|
||||
let (maybe_chosen, _new) = source
|
||||
.choose_browsing_context(target_attribute_value.unwrap_or(DOMString::new()), noopener);
|
||||
|
||||
// Step 20
|
||||
let chosen = match maybe_chosen {
|
||||
Some(proxy) => proxy,
|
||||
None => return,
|
||||
|
@ -777,6 +794,7 @@ impl HTMLFormElement {
|
|||
Some(doc) => doc,
|
||||
None => return,
|
||||
};
|
||||
// Step 21
|
||||
let target_window = target_document.window();
|
||||
let mut load_data = LoadData::new(
|
||||
LoadOrigin::Script(doc.origin().immutable().clone()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue