Bug 1519952, add screenX and screenY properties to XULElement in order to replace places that currently get the screen coordinates of an element via the box object, r=bz

This commit is contained in:
Neil Deakin 2019-02-15 15:26:08 -05:00
parent a65713e112
commit 65399694b4
3 changed files with 17 additions and 0 deletions

View File

@ -60,6 +60,10 @@ interface XULElement : Element {
[SetterThrows]
attribute DOMString top;
// Return the screen coordinates of the element.
readonly attribute long screenX;
readonly attribute long screenY;
// Tooltip
[SetterThrows]
attribute DOMString tooltipText;

View File

@ -472,6 +472,16 @@ bool nsXULElement::IsFocusableInternal(int32_t* aTabIndex, bool aWithMouse) {
return shouldFocus;
}
int32_t nsXULElement::ScreenX() {
nsIFrame* frame = GetPrimaryFrame(FlushType::Layout);
return frame ? frame->GetScreenRect().x: 0;
}
int32_t nsXULElement::ScreenY() {
nsIFrame* frame = GetPrimaryFrame(FlushType::Layout);
return frame ? frame->GetScreenRect().y : 0;
}
bool nsXULElement::HasMenu() {
nsMenuFrame* menu = do_QueryFrame(GetPrimaryFrame());
return menu != nullptr;

View File

@ -337,6 +337,9 @@ class nsXULElement : public nsStyledElement {
bool aDumpAll) const override {}
#endif
MOZ_CAN_RUN_SCRIPT int32_t ScreenX();
MOZ_CAN_RUN_SCRIPT int32_t ScreenY();
bool HasMenu();
MOZ_CAN_RUN_SCRIPT void OpenMenu(bool aOpenFlag);