Skip to content

Commit

Permalink
Bug 1770133 - part 2: Make IMEStateManager::sFocusedContent store i…
Browse files Browse the repository at this point in the history
…t as `Element` r=m_kato

`nsFocusManager` defines that focused content is at least `dom::Element`.
So `IMEStateManager` can handle focused content with `dom::Element` too.

Additionally, this patch makes `IMEStateManager` methods take references instead
of pointers as far as possible if they just return error for `nullptr`.

Differential Revision: https://phabricator.services.mozilla.com/D147133
  • Loading branch information
masayuki-nakano committed May 26, 2022
1 parent 609478f commit 6817b54
Show file tree
Hide file tree
Showing 7 changed files with 229 additions and 232 deletions.
8 changes: 4 additions & 4 deletions dom/base/nsFocusManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5276,12 +5276,12 @@ void nsFocusManager::SetFocusedWindowInternal(nsPIDOMWindowOuter* aWindow,
}
}

void nsFocusManager::NotifyOfReFocus(nsIContent& aContent) {
nsPIDOMWindowOuter* window = GetCurrentWindow(&aContent);
void nsFocusManager::NotifyOfReFocus(Element& aElement) {
nsPIDOMWindowOuter* window = GetCurrentWindow(&aElement);
if (!window || window != mFocusedWindow) {
return;
}
if (!aContent.IsInComposedDoc() || IsNonFocusableRoot(&aContent)) {
if (!aElement.IsInComposedDoc() || IsNonFocusableRoot(&aElement)) {
return;
}
nsIDocShell* docShell = window->GetDocShell();
Expand All @@ -5296,7 +5296,7 @@ void nsFocusManager::NotifyOfReFocus(nsIContent& aContent) {
if (!presContext) {
return;
}
IMEStateManager::OnReFocus(*presContext, aContent);
IMEStateManager::OnReFocus(*presContext, aElement);
}

void nsFocusManager::MarkUncollectableForCCGeneration(uint32_t aGeneration) {
Expand Down
6 changes: 3 additions & 3 deletions dom/base/nsFocusManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,11 @@ class nsFocusManager final : public nsIFocusManager,
static InputContextAction::Cause GetFocusMoveActionCause(uint32_t aFlags);

/**
* Notify of re-focus to same content.
* Notify of re-focus to same element.
*
* aContent is focused content.
* aElement is focused element.
*/
MOZ_CAN_RUN_SCRIPT void NotifyOfReFocus(nsIContent& aContent);
MOZ_CAN_RUN_SCRIPT void NotifyOfReFocus(mozilla::dom::Element& aElement);

static void MarkUncollectableForCCGeneration(uint32_t aGeneration);

Expand Down
7 changes: 5 additions & 2 deletions dom/events/EventStateManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5821,8 +5821,11 @@ void EventStateManager::ContentRemoved(Document* aDocument,
element->LeaveLink(element->GetPresContext(Element::eForComposedDoc));
}

if (RefPtr<nsPresContext> presContext = mPresContext) {
IMEStateManager::OnRemoveContent(*presContext, *aContent);
if (aContent->IsElement()) {
if (RefPtr<nsPresContext> presContext = mPresContext) {
IMEStateManager::OnRemoveContent(*presContext,
MOZ_KnownLive(*aContent->AsElement()));
}
}

// inform the focus manager that the content is being removed. If this
Expand Down
Loading

0 comments on commit 6817b54

Please sign in to comment.