Bug 1878976 - Remove plugin-related code in EventStateManager; r=emilio

`nsIFrame::GetCursor()` can never return `Nothing()` after bug 1687239, which
removes `nsPluginFrame`. Therefore `mLastFrameConsumedSetCursor` in
`EventStateManager` can never be true.

Differential Revision: https://phabricator.services.mozilla.com/D200890
This commit is contained in:
Edgar Chen
2024-02-07 12:35:27 +00:00
parent b653f9b9e8
commit 7c3453d032
13 changed files with 24 additions and 40 deletions

View File

@@ -4348,23 +4348,9 @@ void EventStateManager::UpdateCursor(nsPresContext* aPresContext,
// If not locked, look for correct cursor // If not locked, look for correct cursor
nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo( nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(
aEvent, RelativeTo{aTargetFrame}); aEvent, RelativeTo{aTargetFrame});
Maybe<nsIFrame::Cursor> framecursor = aTargetFrame->GetCursor(pt); const nsIFrame::Cursor framecursor = aTargetFrame->GetCursor(pt);
// Avoid setting cursor when the mouse is over a windowless plugin.
if (!framecursor) {
if (XRE_IsContentProcess()) {
mLastFrameConsumedSetCursor = true;
}
return;
}
// Make sure cursors get reset after the mouse leaves a
// windowless plugin frame.
if (mLastFrameConsumedSetCursor) {
ClearCachedWidgetCursor(aTargetFrame);
mLastFrameConsumedSetCursor = false;
}
const CursorImage customCursor = const CursorImage customCursor =
ComputeCustomCursor(aPresContext, aEvent, *aTargetFrame, *framecursor); ComputeCustomCursor(aPresContext, aEvent, *aTargetFrame, framecursor);
// If the current cursor is from the same frame, and it is now // If the current cursor is from the same frame, and it is now
// loading some new image for the cursor, we should wait for a // loading some new image for the cursor, we should wait for a
@@ -4375,7 +4361,7 @@ void EventStateManager::UpdateCursor(nsPresContext* aPresContext,
TimeDuration::FromMilliseconds(kCursorLoadingTimeout)) { TimeDuration::FromMilliseconds(kCursorLoadingTimeout)) {
return; return;
} }
cursor = framecursor->mCursor; cursor = framecursor.mCursor;
container = std::move(customCursor.mContainer); container = std::move(customCursor.mContainer);
resolution = customCursor.mResolution; resolution = customCursor.mResolution;
hotspot = Some(customCursor.mHotspot); hotspot = Some(customCursor.mHotspot);

View File

@@ -1233,7 +1233,6 @@ class EventStateManager : public nsSupportsWeakReference, public nsIObserver {
// These variables are only relevant if we're the cursor-setting manager. // These variables are only relevant if we're the cursor-setting manager.
StyleCursorKind mLockCursor; StyleCursorKind mLockCursor;
bool mLastFrameConsumedSetCursor = false;
bool mHidingCursorWhileTyping = false; bool mHidingCursorWhileTyping = false;
// Last mouse event screen point (in device pixel) when mouse was locked, used // Last mouse event screen point (in device pixel) when mouse was locked, used

View File

@@ -45,7 +45,7 @@ class nsImageControlFrame final : public nsImageFrame,
} }
#endif #endif
Maybe<Cursor> GetCursor(const nsPoint&) final; Cursor GetCursor(const nsPoint&) final;
// nsIFormContromFrame // nsIFormContromFrame
void SetFocus(bool aOn, bool aRepaint) final; void SetFocus(bool aOn, bool aRepaint) final;
@@ -137,12 +137,12 @@ nsresult nsImageControlFrame::HandleEvent(nsPresContext* aPresContext,
void nsImageControlFrame::SetFocus(bool aOn, bool aRepaint) {} void nsImageControlFrame::SetFocus(bool aOn, bool aRepaint) {}
Maybe<nsIFrame::Cursor> nsImageControlFrame::GetCursor(const nsPoint&) { nsIFrame::Cursor nsImageControlFrame::GetCursor(const nsPoint&) {
StyleCursorKind kind = StyleUI()->Cursor().keyword; StyleCursorKind kind = StyleUI()->Cursor().keyword;
if (kind == StyleCursorKind::Auto) { if (kind == StyleCursorKind::Auto) {
kind = StyleCursorKind::Pointer; kind = StyleCursorKind::Pointer;
} }
return Some(Cursor{kind, AllowCustomCursorImage::Yes}); return Cursor{kind, AllowCustomCursorImage::Yes};
} }
nsresult nsImageControlFrame::SetFormProperty(nsAtom* aName, nsresult nsImageControlFrame::SetFormProperty(nsAtom* aName,

View File

@@ -89,7 +89,7 @@ class nsHTMLFramesetBorderFrame final : public nsLeafFrame {
WidgetGUIEvent* aEvent, WidgetGUIEvent* aEvent,
nsEventStatus* aEventStatus) override; nsEventStatus* aEventStatus) override;
Maybe<Cursor> GetCursor(const nsPoint&) override; Cursor GetCursor(const nsPoint&) override;
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists) override; const nsDisplayListSet& aLists) override;
@@ -630,13 +630,13 @@ nsresult nsHTMLFramesetFrame::HandleEvent(nsPresContext* aPresContext,
return NS_OK; return NS_OK;
} }
Maybe<nsIFrame::Cursor> nsHTMLFramesetFrame::GetCursor(const nsPoint&) { nsIFrame::Cursor nsHTMLFramesetFrame::GetCursor(const nsPoint&) {
auto kind = StyleCursorKind::Default; auto kind = StyleCursorKind::Default;
if (mDragger) { if (mDragger) {
kind = mDragger->mVertical ? StyleCursorKind::EwResize kind = mDragger->mVertical ? StyleCursorKind::EwResize
: StyleCursorKind::NsResize; : StyleCursorKind::NsResize;
} }
return Some(Cursor{kind, AllowCustomCursorImage::No}); return Cursor{kind, AllowCustomCursorImage::No};
} }
void nsHTMLFramesetFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, void nsHTMLFramesetFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
@@ -1454,12 +1454,12 @@ nsresult nsHTMLFramesetBorderFrame::HandleEvent(nsPresContext* aPresContext,
return NS_OK; return NS_OK;
} }
Maybe<nsIFrame::Cursor> nsHTMLFramesetBorderFrame::GetCursor(const nsPoint&) { nsIFrame::Cursor nsHTMLFramesetBorderFrame::GetCursor(const nsPoint&) {
auto kind = StyleCursorKind::Default; auto kind = StyleCursorKind::Default;
if (mCanResize) { if (mCanResize) {
kind = mVertical ? StyleCursorKind::EwResize : StyleCursorKind::NsResize; kind = mVertical ? StyleCursorKind::EwResize : StyleCursorKind::NsResize;
} }
return Some(Cursor{kind, AllowCustomCursorImage::No}); return Cursor{kind, AllowCustomCursorImage::No};
} }
#ifdef DEBUG_FRAME_DUMP #ifdef DEBUG_FRAME_DUMP

View File

@@ -88,7 +88,7 @@ class nsHTMLFramesetFrame final : public nsContainerFrame {
mozilla::WidgetGUIEvent* aEvent, mozilla::WidgetGUIEvent* aEvent,
nsEventStatus* aEventStatus) override; nsEventStatus* aEventStatus) override;
mozilla::Maybe<Cursor> GetCursor(const nsPoint&) override; Cursor GetCursor(const nsPoint&) override;
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists) override; const nsDisplayListSet& aLists) override;

View File

@@ -5890,7 +5890,7 @@ StyleTouchAction nsIFrame::UsedTouchAction() const {
return disp.mTouchAction; return disp.mTouchAction;
} }
Maybe<nsIFrame::Cursor> nsIFrame::GetCursor(const nsPoint&) { nsIFrame::Cursor nsIFrame::GetCursor(const nsPoint&) {
StyleCursorKind kind = StyleUI()->Cursor().keyword; StyleCursorKind kind = StyleUI()->Cursor().keyword;
if (kind == StyleCursorKind::Auto) { if (kind == StyleCursorKind::Auto) {
// If this is editable, I-beam cursor is better for most elements. // If this is editable, I-beam cursor is better for most elements.
@@ -5903,7 +5903,7 @@ Maybe<nsIFrame::Cursor> nsIFrame::GetCursor(const nsPoint&) {
kind = StyleCursorKind::VerticalText; kind = StyleCursorKind::VerticalText;
} }
return Some(Cursor{kind, AllowCustomCursorImage::Yes}); return Cursor{kind, AllowCustomCursorImage::Yes};
} }
// Resize and incremental reflow // Resize and incremental reflow

View File

@@ -2338,7 +2338,7 @@ class nsIFrame : public nsQueryFrame {
/** /**
* Get the cursor for a given frame. * Get the cursor for a given frame.
*/ */
virtual Maybe<Cursor> GetCursor(const nsPoint&); virtual Cursor GetCursor(const nsPoint&);
/** /**
* Get a point (in the frame's coordinate space) given an offset into * Get a point (in the frame's coordinate space) given an offset into

View File

@@ -2773,7 +2773,7 @@ nsresult nsImageFrame::HandleEvent(nsPresContext* aPresContext,
aEventStatus); aEventStatus);
} }
Maybe<nsIFrame::Cursor> nsImageFrame::GetCursor(const nsPoint& aPoint) { nsIFrame::Cursor nsImageFrame::GetCursor(const nsPoint& aPoint) {
nsImageMap* map = GetImageMap(); nsImageMap* map = GetImageMap();
if (!map) { if (!map) {
return nsIFrame::GetCursor(aPoint); return nsIFrame::GetCursor(aPoint);
@@ -2796,7 +2796,7 @@ Maybe<nsIFrame::Cursor> nsImageFrame::GetCursor(const nsPoint& aPoint) {
if (kind == StyleCursorKind::Auto) { if (kind == StyleCursorKind::Auto) {
kind = StyleCursorKind::Default; kind = StyleCursorKind::Default;
} }
return Some(Cursor{kind, AllowCustomCursorImage::Yes, std::move(areaStyle)}); return Cursor{kind, AllowCustomCursorImage::Yes, std::move(areaStyle)};
} }
nsresult nsImageFrame::AttributeChanged(int32_t aNameSpaceID, nsresult nsImageFrame::AttributeChanged(int32_t aNameSpaceID,

View File

@@ -90,7 +90,7 @@ class nsImageFrame : public nsAtomicContainerFrame, public nsIReflowCallback {
nsIContent** aContent) final; nsIContent** aContent) final;
nsresult HandleEvent(nsPresContext*, mozilla::WidgetGUIEvent*, nsresult HandleEvent(nsPresContext*, mozilla::WidgetGUIEvent*,
nsEventStatus*) override; nsEventStatus*) override;
mozilla::Maybe<Cursor> GetCursor(const nsPoint&) override; Cursor GetCursor(const nsPoint&) override;
nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute, nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
int32_t aModType) final; int32_t aModType) final;

View File

@@ -4368,7 +4368,7 @@ NS_IMPL_FRAMEARENA_HELPERS(nsContinuingTextFrame)
nsTextFrame::~nsTextFrame() = default; nsTextFrame::~nsTextFrame() = default;
Maybe<nsIFrame::Cursor> nsTextFrame::GetCursor(const nsPoint& aPoint) { nsIFrame::Cursor nsTextFrame::GetCursor(const nsPoint& aPoint) {
StyleCursorKind kind = StyleUI()->Cursor().keyword; StyleCursorKind kind = StyleUI()->Cursor().keyword;
if (kind == StyleCursorKind::Auto) { if (kind == StyleCursorKind::Auto) {
if (!IsSelectable(nullptr)) { if (!IsSelectable(nullptr)) {
@@ -4378,7 +4378,7 @@ Maybe<nsIFrame::Cursor> nsTextFrame::GetCursor(const nsPoint& aPoint) {
: StyleCursorKind::Text; : StyleCursorKind::Text;
} }
} }
return Some(Cursor{kind, AllowCustomCursorImage::Yes}); return Cursor{kind, AllowCustomCursorImage::Yes};
} }
nsTextFrame* nsTextFrame::LastInFlow() const { nsTextFrame* nsTextFrame::LastInFlow() const {

View File

@@ -219,7 +219,7 @@ class nsTextFrame : public nsIFrame {
void Destroy(DestroyContext&) override; void Destroy(DestroyContext&) override;
mozilla::Maybe<Cursor> GetCursor(const nsPoint&) final; Cursor GetCursor(const nsPoint&) final;
nsresult CharacterDataChanged(const CharacterDataChangeInfo&) final; nsresult CharacterDataChanged(const CharacterDataChangeInfo&) final;

View File

@@ -2220,7 +2220,7 @@ nscoord nsTreeBodyFrame::CalcHorzWidth(const ScrollParts& aParts) {
return width; return width;
} }
Maybe<nsIFrame::Cursor> nsTreeBodyFrame::GetCursor(const nsPoint& aPoint) { nsIFrame::Cursor nsTreeBodyFrame::GetCursor(const nsPoint& aPoint) {
// Check the GetScriptHandlingObject so we don't end up running code when // Check the GetScriptHandlingObject so we don't end up running code when
// the document is a zombie. // the document is a zombie.
bool dummy; bool dummy;
@@ -2237,8 +2237,7 @@ Maybe<nsIFrame::Cursor> nsTreeBodyFrame::GetCursor(const nsPoint& aPoint) {
if (kind == StyleCursorKind::Auto) { if (kind == StyleCursorKind::Auto) {
kind = StyleCursorKind::Default; kind = StyleCursorKind::Default;
} }
return Some( return Cursor{kind, AllowCustomCursorImage::Yes, std::move(childContext)};
Cursor{kind, AllowCustomCursorImage::Yes, std::move(childContext)});
} }
} }
return SimpleXULLeafFrame::GetCursor(aPoint); return SimpleXULLeafFrame::GetCursor(aPoint);

View File

@@ -159,7 +159,7 @@ class nsTreeBodyFrame final : public mozilla::SimpleXULLeafFrame,
nsIFrame* aPrevInFlow) override; nsIFrame* aPrevInFlow) override;
void Destroy(DestroyContext&) override; void Destroy(DestroyContext&) override;
mozilla::Maybe<Cursor> GetCursor(const nsPoint&) override; Cursor GetCursor(const nsPoint&) override;
nsresult HandleEvent(nsPresContext* aPresContext, nsresult HandleEvent(nsPresContext* aPresContext,
mozilla::WidgetGUIEvent* aEvent, mozilla::WidgetGUIEvent* aEvent,