Bug 1676952 - Fix HTMLImageElement.x/y to match the spec. r=emilio
Per https://drafts.csswg.org/cssom-view/#extensions-to-the-htmlimageelement-interface: > The x attribute, on getting, must return the x-coordinate of the left > border edge of the first CSS layout box associated with the element, > relative to the initial containing block origin, ignoring any > transforms that apply to the element and its ancestors, or zero if > there is no CSS layout box. But we were using GetClosestLayer which stops at the first abspos containing block or scroll frame. Differential Revision: https://phabricator.services.mozilla.com/D151263
This commit is contained in:
@@ -5,9 +5,10 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/HTMLImageElement.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/dom/BindContext.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/HTMLImageElementBinding.h"
|
||||
#include "mozilla/dom/BindContext.h"
|
||||
#include "mozilla/dom/NameSpaceConstants.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsGkAtoms.h"
|
||||
@@ -189,9 +190,8 @@ CSSIntPoint HTMLImageElement::GetXY() {
|
||||
if (!frame) {
|
||||
return CSSIntPoint(0, 0);
|
||||
}
|
||||
|
||||
nsIFrame* layer = nsLayoutUtils::GetClosestLayer(frame->GetParent());
|
||||
return CSSIntPoint::FromAppUnitsRounded(frame->GetOffsetTo(layer));
|
||||
return CSSIntPoint::FromAppUnitsRounded(
|
||||
frame->GetOffsetTo(frame->PresShell()->GetRootFrame()));
|
||||
}
|
||||
|
||||
int32_t HTMLImageElement::X() { return GetXY().x; }
|
||||
|
||||
Reference in New Issue
Block a user