mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 1686395 - Remove [Un]RegisterAccessKey calls in frame code (idempotent change). r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D101556
This commit is contained in:
parent
ca5460eda2
commit
7b6d28bc4a
@ -9,7 +9,6 @@
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "mozilla/dom/HTMLInputElement.h"
|
||||
#include "mozilla/EventStateManager.h"
|
||||
#include "mozilla/LookAndFeel.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "nsDeviceContext.h"
|
||||
@ -34,13 +33,6 @@ nsCheckboxRadioFrame::nsCheckboxRadioFrame(ComputedStyle* aStyle,
|
||||
|
||||
nsCheckboxRadioFrame::~nsCheckboxRadioFrame() = default;
|
||||
|
||||
void nsCheckboxRadioFrame::DestroyFrom(nsIFrame* aDestructRoot,
|
||||
PostDestroyData& aPostDestroyData) {
|
||||
// Unregister the access key registered in reflow
|
||||
nsCheckboxRadioFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
|
||||
nsAtomicContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData);
|
||||
}
|
||||
|
||||
NS_IMPL_FRAMEARENA_HELPERS(nsCheckboxRadioFrame)
|
||||
|
||||
NS_QUERYFRAME_HEAD(nsCheckboxRadioFrame)
|
||||
@ -118,10 +110,6 @@ void nsCheckboxRadioFrame::Reflow(nsPresContext* aPresContext,
|
||||
("enter nsCheckboxRadioFrame::Reflow: aMaxSize=%d,%d",
|
||||
aReflowInput.AvailableWidth(), aReflowInput.AvailableHeight()));
|
||||
|
||||
if (mState & NS_FRAME_FIRST_REFLOW) {
|
||||
RegUnRegAccessKey(static_cast<nsIFrame*>(this), true);
|
||||
}
|
||||
|
||||
const auto wm = aReflowInput.GetWritingMode();
|
||||
aDesiredSize.SetSize(wm, aReflowInput.ComputedSizeWithBorderPadding(wm));
|
||||
|
||||
@ -140,30 +128,6 @@ void nsCheckboxRadioFrame::Reflow(nsPresContext* aPresContext,
|
||||
FinishAndStoreOverflow(&aDesiredSize);
|
||||
}
|
||||
|
||||
nsresult nsCheckboxRadioFrame::RegUnRegAccessKey(nsIFrame* aFrame,
|
||||
bool aDoReg) {
|
||||
NS_ENSURE_ARG_POINTER(aFrame);
|
||||
|
||||
nsPresContext* presContext = aFrame->PresContext();
|
||||
|
||||
NS_ASSERTION(presContext, "aPresContext is NULL in RegUnRegAccessKey!");
|
||||
|
||||
nsAutoString accessKey;
|
||||
|
||||
Element* content = aFrame->GetContent()->AsElement();
|
||||
content->GetAttr(kNameSpaceID_None, nsGkAtoms::accesskey, accessKey);
|
||||
if (!accessKey.IsEmpty()) {
|
||||
EventStateManager* stateManager = presContext->EventStateManager();
|
||||
if (aDoReg) {
|
||||
stateManager->RegisterAccessKey(content, (uint32_t)accessKey.First());
|
||||
} else {
|
||||
stateManager->UnregisterAccessKey(content, (uint32_t)accessKey.First());
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
void nsCheckboxRadioFrame::SetFocus(bool aOn, bool aRepaint) {}
|
||||
|
||||
nsresult nsCheckboxRadioFrame::HandleEvent(nsPresContext* aPresContext,
|
||||
|
@ -14,8 +14,8 @@
|
||||
|
||||
/**
|
||||
* nsCheckboxRadioFrame is used for radio buttons and checkboxes.
|
||||
* It also has two static methods (RegUnRegAccessKey and
|
||||
* GetScreenHeight) that are used by other form controls.
|
||||
* It also has a static method (GetUsableScreenRect) that is used by
|
||||
* other form controls.
|
||||
*/
|
||||
class nsCheckboxRadioFrame final : public nsAtomicContainerFrame,
|
||||
public nsIFormControlFrame {
|
||||
@ -75,9 +75,6 @@ class nsCheckboxRadioFrame final : public nsAtomicContainerFrame,
|
||||
const ReflowInput& aReflowInput,
|
||||
nsReflowStatus& aStatus) override;
|
||||
|
||||
virtual void DestroyFrom(nsIFrame* aDestructRoot,
|
||||
PostDestroyData& aPostDestroyData) override;
|
||||
|
||||
// new behavior
|
||||
|
||||
virtual void SetFocus(bool aOn = true, bool aRepaint = false) override;
|
||||
@ -86,9 +83,6 @@ class nsCheckboxRadioFrame final : public nsAtomicContainerFrame,
|
||||
virtual nsresult SetFormProperty(nsAtom* aName,
|
||||
const nsAString& aValue) override;
|
||||
|
||||
// AccessKey Helper function
|
||||
static nsresult RegUnRegAccessKey(nsIFrame* aFrame, bool aDoReg);
|
||||
|
||||
/**
|
||||
* Returns the usable screen rect in app units, eg the rect where we can
|
||||
* draw dropdowns.
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsCSSPseudoElements.h"
|
||||
#include "nsCheckboxRadioFrame.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
@ -41,7 +40,6 @@ NS_QUERYFRAME_TAIL_INHERITING(nsHTMLButtonControlFrame)
|
||||
|
||||
void nsColorControlFrame::DestroyFrom(nsIFrame* aDestructRoot,
|
||||
PostDestroyData& aPostDestroyData) {
|
||||
nsCheckboxRadioFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
|
||||
aPostDestroyData.AddAnonymousContent(mColorContent.forget());
|
||||
nsHTMLButtonControlFrame::DestroyFrom(aDestructRoot, aPostDestroyData);
|
||||
}
|
||||
|
@ -1359,8 +1359,6 @@ void nsComboboxControlFrame::DestroyFrom(nsIFrame* aDestructRoot,
|
||||
// Revoke any pending RedisplayTextEvent
|
||||
mRedisplayTextEvent.Revoke();
|
||||
|
||||
nsCheckboxRadioFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
|
||||
|
||||
if (mDroppedDown) {
|
||||
MOZ_ASSERT(mDropdownFrame, "mDroppedDown without frame");
|
||||
nsView* view = mDropdownFrame->GetView();
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsButtonFrameRenderer.h"
|
||||
#include "nsCSSAnonBoxes.h"
|
||||
#include "nsCheckboxRadioFrame.h"
|
||||
#include "nsNameSpaceManager.h"
|
||||
#include "nsDisplayList.h"
|
||||
#include <algorithm>
|
||||
@ -36,12 +35,6 @@ nsHTMLButtonControlFrame::nsHTMLButtonControlFrame(ComputedStyle* aStyle,
|
||||
|
||||
nsHTMLButtonControlFrame::~nsHTMLButtonControlFrame() = default;
|
||||
|
||||
void nsHTMLButtonControlFrame::DestroyFrom(nsIFrame* aDestructRoot,
|
||||
PostDestroyData& aPostDestroyData) {
|
||||
nsCheckboxRadioFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
|
||||
nsContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData);
|
||||
}
|
||||
|
||||
void nsHTMLButtonControlFrame::Init(nsIContent* aContent,
|
||||
nsContainerFrame* aParent,
|
||||
nsIFrame* aPrevInFlow) {
|
||||
@ -160,10 +153,6 @@ void nsHTMLButtonControlFrame::Reflow(nsPresContext* aPresContext,
|
||||
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
|
||||
MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
|
||||
|
||||
if (mState & NS_FRAME_FIRST_REFLOW) {
|
||||
nsCheckboxRadioFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), true);
|
||||
}
|
||||
|
||||
// Reflow the child
|
||||
nsIFrame* firstKid = mFrames.FirstChild();
|
||||
|
||||
|
@ -24,9 +24,6 @@ class nsHTMLButtonControlFrame : public nsContainerFrame,
|
||||
|
||||
~nsHTMLButtonControlFrame();
|
||||
|
||||
virtual void DestroyFrom(nsIFrame* aDestructRoot,
|
||||
PostDestroyData& aPostDestroyData) override;
|
||||
|
||||
NS_DECL_QUERYFRAME
|
||||
NS_DECL_FRAMEARENA_HELPERS(nsHTMLButtonControlFrame)
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "nsPresContext.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsCheckboxRadioFrame.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsIContent.h"
|
||||
|
||||
@ -25,7 +24,6 @@ class nsImageControlFrame final : public nsImageFrame,
|
||||
nsPresContext* aPresContext);
|
||||
~nsImageControlFrame() final;
|
||||
|
||||
void DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData&) final;
|
||||
void Init(nsIContent* aContent, nsContainerFrame* aParent,
|
||||
nsIFrame* aPrevInFlow) final;
|
||||
|
||||
@ -60,14 +58,6 @@ nsImageControlFrame::nsImageControlFrame(ComputedStyle* aStyle,
|
||||
|
||||
nsImageControlFrame::~nsImageControlFrame() = default;
|
||||
|
||||
void nsImageControlFrame::DestroyFrom(nsIFrame* aDestructRoot,
|
||||
PostDestroyData& aPostDestroyData) {
|
||||
if (!GetPrevInFlow()) {
|
||||
nsCheckboxRadioFrame::RegUnRegAccessKey(this, false);
|
||||
}
|
||||
nsImageFrame::DestroyFrom(aDestructRoot, aPostDestroyData);
|
||||
}
|
||||
|
||||
nsIFrame* NS_NewImageControlFrame(PresShell* aPresShell,
|
||||
ComputedStyle* aStyle) {
|
||||
return new (aPresShell)
|
||||
@ -109,9 +99,6 @@ void nsImageControlFrame::Reflow(nsPresContext* aPresContext,
|
||||
DO_GLOBAL_REFLOW_COUNT("nsImageControlFrame");
|
||||
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
|
||||
MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
|
||||
if (!GetPrevInFlow() && (mState & NS_FRAME_FIRST_REFLOW)) {
|
||||
nsCheckboxRadioFrame::RegUnRegAccessKey(this, true);
|
||||
}
|
||||
return nsImageFrame::Reflow(aPresContext, aDesiredSize, aReflowInput,
|
||||
aStatus);
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsListControlFrame.h"
|
||||
#include "nsCheckboxRadioFrame.h" // for COMPARE macro
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsComboboxControlFrame.h"
|
||||
#include "nsFontMetrics.h"
|
||||
@ -141,7 +140,6 @@ void nsListControlFrame::DestroyFrom(nsIFrame* aDestructRoot,
|
||||
CanBubble::eYes, ChromeOnlyDispatch::eYes));
|
||||
}
|
||||
|
||||
nsCheckboxRadioFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
|
||||
nsHTMLScrollFrame::DestroyFrom(aDestructRoot, aPostDestroyData);
|
||||
}
|
||||
|
||||
@ -356,10 +354,6 @@ void nsListControlFrame::Reflow(nsPresContext* aPresContext,
|
||||
}
|
||||
}
|
||||
|
||||
if (HasAnyStateBits(NS_FRAME_FIRST_REFLOW)) {
|
||||
nsCheckboxRadioFrame::RegUnRegAccessKey(this, true);
|
||||
}
|
||||
|
||||
if (IsInDropDownMode()) {
|
||||
ReflowAsDropdown(aPresContext, aDesiredSize, aReflowInput, aStatus);
|
||||
return;
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "nsNameSpaceManager.h"
|
||||
#include "nsNodeInfoManager.h"
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsCheckboxRadioFrame.h"
|
||||
#include "nsFontMetrics.h"
|
||||
#include "nsCSSPseudoElements.h"
|
||||
#include "nsStyleConsts.h"
|
||||
@ -43,7 +42,6 @@ void nsMeterFrame::DestroyFrom(nsIFrame* aDestructRoot,
|
||||
NS_ASSERTION(!GetPrevContinuation(),
|
||||
"nsMeterFrame should not have continuations; if it does we "
|
||||
"need to call RegUnregAccessKey only for the first.");
|
||||
nsCheckboxRadioFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
|
||||
aPostDestroyData.AddAnonymousContent(mBarDiv.forget());
|
||||
nsContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData);
|
||||
}
|
||||
@ -90,10 +88,6 @@ void nsMeterFrame::Reflow(nsPresContext* aPresContext,
|
||||
"nsMeterFrame should not have continuations; if it does we "
|
||||
"need to call RegUnregAccessKey only for the first.");
|
||||
|
||||
if (mState & NS_FRAME_FIRST_REFLOW) {
|
||||
nsCheckboxRadioFrame::RegUnRegAccessKey(this, true);
|
||||
}
|
||||
|
||||
nsIFrame* barFrame = mBarDiv->GetPrimaryFrame();
|
||||
NS_ASSERTION(barFrame, "The meter frame should have a child with a frame!");
|
||||
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "nsNameSpaceManager.h"
|
||||
#include "nsNodeInfoManager.h"
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsCheckboxRadioFrame.h"
|
||||
#include "nsFontMetrics.h"
|
||||
#include "nsCSSPseudoElements.h"
|
||||
#include "nsStyleConsts.h"
|
||||
@ -42,7 +41,6 @@ void nsProgressFrame::DestroyFrom(nsIFrame* aDestructRoot,
|
||||
NS_ASSERTION(!GetPrevContinuation(),
|
||||
"nsProgressFrame should not have continuations; if it does we "
|
||||
"need to call RegUnregAccessKey only for the first.");
|
||||
nsCheckboxRadioFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
|
||||
aPostDestroyData.AddAnonymousContent(mBarDiv.forget());
|
||||
nsContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData);
|
||||
}
|
||||
@ -98,10 +96,6 @@ void nsProgressFrame::Reflow(nsPresContext* aPresContext,
|
||||
"nsProgressFrame should not have continuations; if it does we "
|
||||
"need to call RegUnregAccessKey only for the first.");
|
||||
|
||||
if (mState & NS_FRAME_FIRST_REFLOW) {
|
||||
nsCheckboxRadioFrame::RegUnRegAccessKey(this, true);
|
||||
}
|
||||
|
||||
const auto wm = aReflowInput.GetWritingMode();
|
||||
aDesiredSize.SetSize(wm, aReflowInput.ComputedSizeWithBorderPadding(wm));
|
||||
aDesiredSize.SetOverflowAreasToDesiredBounds();
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsCSSPseudoElements.h"
|
||||
#include "nsCSSRendering.h"
|
||||
#include "nsCheckboxRadioFrame.h"
|
||||
#include "nsIContent.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "nsNameSpaceManager.h"
|
||||
@ -61,7 +60,6 @@ void nsRangeFrame::DestroyFrom(nsIFrame* aDestructRoot,
|
||||
"nsRangeFrame should not have continuations; if it does we "
|
||||
"need to call RegUnregAccessKey only for the first.");
|
||||
|
||||
nsCheckboxRadioFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
|
||||
aPostDestroyData.AddAnonymousContent(mTrackDiv.forget());
|
||||
aPostDestroyData.AddAnonymousContent(mProgressDiv.forget());
|
||||
aPostDestroyData.AddAnonymousContent(mThumbDiv.forget());
|
||||
@ -158,10 +156,6 @@ void nsRangeFrame::Reflow(nsPresContext* aPresContext,
|
||||
"nsRangeFrame should not have continuations; if it does we "
|
||||
"need to call RegUnregAccessKey only for the first.");
|
||||
|
||||
if (mState & NS_FRAME_FIRST_REFLOW) {
|
||||
nsCheckboxRadioFrame::RegUnRegAccessKey(this, true);
|
||||
}
|
||||
|
||||
WritingMode wm = aReflowInput.GetWritingMode();
|
||||
nscoord computedBSize = aReflowInput.ComputedBSize();
|
||||
if (computedBSize == NS_UNCONSTRAINEDSIZE) {
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsTextFragment.h"
|
||||
#include "nsNameSpaceManager.h"
|
||||
#include "nsCheckboxRadioFrame.h" //for registering accesskeys
|
||||
|
||||
#include "nsIContent.h"
|
||||
#include "nsPresContext.h"
|
||||
@ -143,8 +142,6 @@ void nsTextControlFrame::DestroyFrom(nsIFrame* aDestructRoot,
|
||||
MOZ_ASSERT(textControlElement);
|
||||
textControlElement->UnbindFromFrame(this);
|
||||
|
||||
nsCheckboxRadioFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
|
||||
|
||||
if (mMutationObserver) {
|
||||
mRootNode->RemoveMutationObserver(mMutationObserver);
|
||||
mMutationObserver = nullptr;
|
||||
@ -629,11 +626,6 @@ void nsTextControlFrame::Reflow(nsPresContext* aPresContext,
|
||||
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
|
||||
MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
|
||||
|
||||
// make sure that the form registers itself on the initial/first reflow
|
||||
if (mState & NS_FRAME_FIRST_REFLOW) {
|
||||
nsCheckboxRadioFrame::RegUnRegAccessKey(this, true);
|
||||
}
|
||||
|
||||
// set values of reflow's out parameters
|
||||
WritingMode wm = aReflowInput.GetWritingMode();
|
||||
aDesiredSize.SetSize(wm, aReflowInput.ComputedSizeWithBorderPadding(wm));
|
||||
|
Loading…
Reference in New Issue
Block a user