mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #18968 - mbrubeck:try, r=emilio
Use try syntax for Option where appropriate - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes do not require tests because they are refactoring only <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18968) <!-- Reviewable:end -->
This commit is contained in:
commit
2b03a9974c
19 changed files with 65 additions and 180 deletions
|
@ -591,15 +591,11 @@ impl WindowMethods for Window {
|
|||
// https://html.spec.whatwg.org/multipage/#dom-frameelement
|
||||
fn GetFrameElement(&self) -> Option<DomRoot<Element>> {
|
||||
// Steps 1-3.
|
||||
let window_proxy = match self.window_proxy.get() {
|
||||
None => return None,
|
||||
Some(window_proxy) => window_proxy,
|
||||
};
|
||||
let window_proxy = self.window_proxy.get()?;
|
||||
|
||||
// Step 4-5.
|
||||
let container = match window_proxy.frame_element() {
|
||||
None => return None,
|
||||
Some(container) => container,
|
||||
};
|
||||
let container = window_proxy.frame_element()?;
|
||||
|
||||
// Step 6.
|
||||
let container_doc = document_from_node(container);
|
||||
let current_doc = GlobalScope::current().expect("No current global object").as_window().Document();
|
||||
|
@ -687,10 +683,8 @@ impl WindowMethods for Window {
|
|||
// https://html.spec.whatwg.org/multipage/#dom-parent
|
||||
fn GetParent(&self) -> Option<DomRoot<WindowProxy>> {
|
||||
// Steps 1-3.
|
||||
let window_proxy = match self.undiscarded_window_proxy() {
|
||||
Some(window_proxy) => window_proxy,
|
||||
None => return None,
|
||||
};
|
||||
let window_proxy = self.undiscarded_window_proxy()?;
|
||||
|
||||
// Step 4.
|
||||
if let Some(parent) = window_proxy.parent() {
|
||||
return Some(DomRoot::from_ref(parent));
|
||||
|
@ -702,10 +696,8 @@ impl WindowMethods for Window {
|
|||
// https://html.spec.whatwg.org/multipage/#dom-top
|
||||
fn GetTop(&self) -> Option<DomRoot<WindowProxy>> {
|
||||
// Steps 1-3.
|
||||
let window_proxy = match self.undiscarded_window_proxy() {
|
||||
Some(window_proxy) => window_proxy,
|
||||
None => return None,
|
||||
};
|
||||
let window_proxy = self.undiscarded_window_proxy()?;
|
||||
|
||||
// Steps 4-5.
|
||||
Some(DomRoot::from_ref(window_proxy.top()))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue