Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTMLElement::Offset{Parent,Left,Right} should call is_the_html_body_element. #13659

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

HTMLElement::Offset{Parent,Left,Right} should call is_the_html_body_e…

…lement.

Fixes #10520.
  • Loading branch information
frewsxcv committed Nov 4, 2016
commit ee9a5b7df1c32a859ef7767d339c41efba55ac11
@@ -272,9 +272,13 @@ impl HTMLElementMethods for HTMLElement {

// https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsetparent
fn GetOffsetParent(&self) -> Option<Root<Element>> {
if self.is::<HTMLBodyElement>() || self.is::<HTMLHtmlElement>() {
if self.is::<HTMLHtmlElement>() {

This comment has been minimized.

@nox

nox Nov 30, 2016

Member

This is incorrect, an html element can be the child of whatever. The test really needs to be about the root element.

This comment has been minimized.

@frewsxcv

frewsxcv Dec 1, 2016

Author Member

Yep, sounds right. I'm going to assume I just call https://doc.servo.org/script/dom/element/struct.Element.html#method.root_element and check if it's the same as self

This comment has been minimized.

@nox

nox Dec 1, 2016

Member

Should be better to compare self to its document's root element, rather than go up the whole hierarchy.

This comment has been minimized.

@nox

nox Dec 1, 2016

Member

Or even, that self's parent is a Document.

This comment has been minimized.

@frewsxcv

frewsxcv Dec 1, 2016

Author Member

👍

return None;
}
match self.downcast::<HTMLBodyElement>() {
Some(e) if e.is_the_html_body_element() => return None,
_ => (),
}

let node = self.upcast::<Node>();
let window = window_from_node(self);
@@ -285,8 +289,9 @@ impl HTMLElementMethods for HTMLElement {

// https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsettop
fn OffsetTop(&self) -> i32 {
if self.is::<HTMLBodyElement>() {
return 0;
match self.downcast::<HTMLBodyElement>() {
Some(e) if e.is_the_html_body_element() => return 0,
_ => (),
}

let node = self.upcast::<Node>();
@@ -298,8 +303,9 @@ impl HTMLElementMethods for HTMLElement {

// https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsetleft
fn OffsetLeft(&self) -> i32 {
if self.is::<HTMLBodyElement>() {
return 0;
match self.downcast::<HTMLBodyElement>() {
Some(e) if e.is_the_html_body_element() => return 0,
_ => (),
}

let node = self.upcast::<Node>();
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.