Issue #2135 - Bug 1430303: Implement ShadowRoot.pointerLockElement

This commit is contained in:
FranklinDM 2023-03-03 19:15:21 +08:00 committed by roytam1
commit 3dfffeaeca
9 changed files with 138 additions and 29 deletions

View file

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "DocumentOrShadowRoot.h"
#include "mozilla/EventStateManager.h"
#include "mozilla/dom/StyleSheetList.h"
#include "nsDocument.h"
#include "nsFocusManager.h"
@ -144,5 +145,20 @@ DocumentOrShadowRoot::GetRetargetedFocusedElement()
return nullptr;
}
Element*
DocumentOrShadowRoot::GetPointerLockElement()
{
nsCOMPtr<Element> pointerLockedElement =
do_QueryReferent(EventStateManager::sPointerLockedElement);
if (!pointerLockedElement) {
return nullptr;
}
nsIContent* retargetedPointerLockedElement = Retarget(pointerLockedElement);
return
retargetedPointerLockedElement && retargetedPointerLockedElement->IsElement() ?
retargetedPointerLockedElement->AsElement() : nullptr;
}
}
}