mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 159346 part.1 Scrollbar button should capture mouse events and do scroll only when cursor is on it r=enndeakin
This commit is contained in:
parent
001f03627c
commit
006c75e2dd
@ -84,15 +84,30 @@ nsScrollbarButtonFrame::HandleEvent(nsPresContext* aPresContext,
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX hack until handle release is actually called in nsframe.
|
switch (aEvent->message) {
|
||||||
if (aEvent->message == NS_MOUSE_EXIT_SYNTH ||
|
case NS_MOUSE_BUTTON_DOWN:
|
||||||
aEvent->message == NS_MOUSE_BUTTON_UP)
|
mCursorOnThis = true;
|
||||||
HandleRelease(aPresContext, aEvent, aEventStatus);
|
// if we didn't handle the press ourselves, pass it on to the superclass
|
||||||
|
if (HandleButtonPress(aPresContext, aEvent, aEventStatus)) {
|
||||||
// if we didn't handle the press ourselves, pass it on to the superclass
|
return NS_OK;
|
||||||
if (!HandleButtonPress(aPresContext, aEvent, aEventStatus))
|
}
|
||||||
return nsButtonBoxFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
break;
|
||||||
return NS_OK;
|
case NS_MOUSE_BUTTON_UP:
|
||||||
|
HandleRelease(aPresContext, aEvent, aEventStatus);
|
||||||
|
break;
|
||||||
|
case NS_MOUSE_EXIT_SYNTH:
|
||||||
|
mCursorOnThis = false;
|
||||||
|
break;
|
||||||
|
case NS_MOUSE_MOVE: {
|
||||||
|
nsPoint cursor =
|
||||||
|
nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this);
|
||||||
|
nsRect frameRect(nsPoint(0, 0), GetSize());
|
||||||
|
mCursorOnThis = frameRect.Contains(cursor);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nsButtonBoxFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -103,18 +118,13 @@ nsScrollbarButtonFrame::HandleButtonPress(nsPresContext* aPresContext,
|
|||||||
{
|
{
|
||||||
// Get the desired action for the scrollbar button.
|
// Get the desired action for the scrollbar button.
|
||||||
LookAndFeel::IntID tmpAction;
|
LookAndFeel::IntID tmpAction;
|
||||||
if (aEvent->eventStructType == NS_MOUSE_EVENT &&
|
PRUint16 button = static_cast<nsMouseEvent*>(aEvent)->button;
|
||||||
aEvent->message == NS_MOUSE_BUTTON_DOWN) {
|
if (button == nsMouseEvent::eLeftButton) {
|
||||||
PRUint16 button = static_cast<nsMouseEvent*>(aEvent)->button;
|
tmpAction = LookAndFeel::eIntID_ScrollButtonLeftMouseButtonAction;
|
||||||
if (button == nsMouseEvent::eLeftButton) {
|
} else if (button == nsMouseEvent::eMiddleButton) {
|
||||||
tmpAction = LookAndFeel::eIntID_ScrollButtonLeftMouseButtonAction;
|
tmpAction = LookAndFeel::eIntID_ScrollButtonMiddleMouseButtonAction;
|
||||||
} else if (button == nsMouseEvent::eMiddleButton) {
|
} else if (button == nsMouseEvent::eRightButton) {
|
||||||
tmpAction = LookAndFeel::eIntID_ScrollButtonMiddleMouseButtonAction;
|
tmpAction = LookAndFeel::eIntID_ScrollButtonRightMouseButtonAction;
|
||||||
} else if (button == nsMouseEvent::eRightButton) {
|
|
||||||
tmpAction = LookAndFeel::eIntID_ScrollButtonRightMouseButtonAction;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -180,6 +190,8 @@ nsScrollbarButtonFrame::HandleButtonPress(nsPresContext* aPresContext,
|
|||||||
nsWeakFrame weakFrame(this);
|
nsWeakFrame weakFrame(this);
|
||||||
mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::active, NS_LITERAL_STRING("true"), true);
|
mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::active, NS_LITERAL_STRING("true"), true);
|
||||||
|
|
||||||
|
nsIPresShell::SetCapturingContent(mContent, CAPTURE_IGNOREALLOWED);
|
||||||
|
|
||||||
if (weakFrame.IsAlive()) {
|
if (weakFrame.IsAlive()) {
|
||||||
DoButtonAction(smoothScroll);
|
DoButtonAction(smoothScroll);
|
||||||
}
|
}
|
||||||
@ -193,6 +205,7 @@ nsScrollbarButtonFrame::HandleRelease(nsPresContext* aPresContext,
|
|||||||
nsGUIEvent* aEvent,
|
nsGUIEvent* aEvent,
|
||||||
nsEventStatus* aEventStatus)
|
nsEventStatus* aEventStatus)
|
||||||
{
|
{
|
||||||
|
nsIPresShell::SetCapturingContent(nsnull, 0);
|
||||||
// we're not active anymore
|
// we're not active anymore
|
||||||
mContent->UnsetAttr(kNameSpaceID_None, nsGkAtoms::active, true);
|
mContent->UnsetAttr(kNameSpaceID_None, nsGkAtoms::active, true);
|
||||||
StopRepeat();
|
StopRepeat();
|
||||||
@ -203,7 +216,9 @@ void nsScrollbarButtonFrame::Notify()
|
|||||||
{
|
{
|
||||||
// Since this is only going to get called if we're scrolling a page length
|
// Since this is only going to get called if we're scrolling a page length
|
||||||
// or a line increment, we will always use smooth scrolling.
|
// or a line increment, we will always use smooth scrolling.
|
||||||
DoButtonAction(true);
|
if (mCursorOnThis) {
|
||||||
|
DoButtonAction(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -57,7 +57,7 @@ public:
|
|||||||
NS_DECL_FRAMEARENA_HELPERS
|
NS_DECL_FRAMEARENA_HELPERS
|
||||||
|
|
||||||
nsScrollbarButtonFrame(nsIPresShell* aPresShell, nsStyleContext* aContext):
|
nsScrollbarButtonFrame(nsIPresShell* aPresShell, nsStyleContext* aContext):
|
||||||
nsButtonBoxFrame(aPresShell, aContext) {}
|
nsButtonBoxFrame(aPresShell, aContext), mCursorOnThis(false) {}
|
||||||
|
|
||||||
// Overrides
|
// Overrides
|
||||||
virtual void DestroyFrom(nsIFrame* aDestructRoot);
|
virtual void DestroyFrom(nsIFrame* aDestructRoot);
|
||||||
@ -105,6 +105,7 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
PRInt32 mIncrement;
|
PRInt32 mIncrement;
|
||||||
|
bool mCursorOnThis;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user