Bug 631473 - Don't consume mouse scroll events outside arrow panels on OS X. r=mstange r=enndeakin

This commit is contained in:
Frank Yan 2013-03-08 11:48:48 -08:00
parent 47b29112b3
commit 61b4e7cee5
6 changed files with 29 additions and 3 deletions

View File

@ -94,6 +94,7 @@ GK_ATOM(applyTemplates, "apply-templates")
GK_ATOM(mozapptype, "mozapptype") GK_ATOM(mozapptype, "mozapptype")
GK_ATOM(archive, "archive") GK_ATOM(archive, "archive")
GK_ATOM(area, "area") GK_ATOM(area, "area")
GK_ATOM(arrow, "arrow")
GK_ATOM(article, "article") GK_ATOM(article, "article")
GK_ATOM(ascending, "ascending") GK_ATOM(ascending, "ascending")
GK_ATOM(aside, "aside") GK_ATOM(aside, "aside")

View File

@ -178,6 +178,9 @@ public:
virtual bool ShouldRollupOnMouseWheelEvent() virtual bool ShouldRollupOnMouseWheelEvent()
{ return true; } { return true; }
virtual bool ShouldConsumeOnMouseWheelEvent()
{ return false; }
/** /**
* A combobox should not roll up if activated by a mouse activate message * A combobox should not roll up if activated by a mouse activate message
* (eg. X-mouse). * (eg. X-mouse).

View File

@ -288,6 +288,7 @@ public:
// nsIRollupListener // nsIRollupListener
virtual bool Rollup(uint32_t aCount, nsIContent** aLastRolledUp); virtual bool Rollup(uint32_t aCount, nsIContent** aLastRolledUp);
virtual bool ShouldRollupOnMouseWheelEvent(); virtual bool ShouldRollupOnMouseWheelEvent();
virtual bool ShouldConsumeOnMouseWheelEvent();
virtual bool ShouldRollupOnMouseActivate(); virtual bool ShouldRollupOnMouseActivate();
virtual uint32_t GetSubmenuWidgetChain(nsTArray<nsIWidget*> *aWidgetChain); virtual uint32_t GetSubmenuWidgetChain(nsTArray<nsIWidget*> *aWidgetChain);
virtual void NotifyGeometryChange() {} virtual void NotifyGeometryChange() {}

View File

@ -238,6 +238,21 @@ bool nsXULPopupManager::ShouldRollupOnMouseWheelEvent()
return StringBeginsWith(value, NS_LITERAL_STRING("autocomplete")); return StringBeginsWith(value, NS_LITERAL_STRING("autocomplete"));
} }
bool nsXULPopupManager::ShouldConsumeOnMouseWheelEvent()
{
nsMenuChainItem* item = GetTopVisibleMenu();
if (!item)
return false;
nsMenuPopupFrame* frame = item->Frame();
if (frame->PopupType() != ePopupTypePanel)
return true;
nsIContent* content = frame->GetContent();
return !(content && content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::arrow, eCaseMatters));
}
// a menu should not roll up if activated by a mouse activate message (eg. X-mouse) // a menu should not roll up if activated by a mouse activate message (eg. X-mouse)
bool nsXULPopupManager::ShouldRollupOnMouseActivate() bool nsXULPopupManager::ShouldRollupOnMouseActivate()
{ {

View File

@ -2867,8 +2867,9 @@ NSEvent* gLastDragMouseDownEvent = nil;
// check to see if scroll events should roll up the popup // check to see if scroll events should roll up the popup
if ([theEvent type] == NSScrollWheel) { if ([theEvent type] == NSScrollWheel) {
shouldRollup = rollupListener->ShouldRollupOnMouseWheelEvent(); shouldRollup = rollupListener->ShouldRollupOnMouseWheelEvent();
// always consume scroll events that aren't over the popup // consume scroll events that aren't over the popup
consumeEvent = YES; // unless the popup is an arrow panel
consumeEvent = rollupListener->ShouldConsumeOnMouseWheelEvent();
} }
// if we're dealing with menus, we probably have submenus and // if we're dealing with menus, we probably have submenus and

View File

@ -29,10 +29,15 @@ class nsIRollupListener {
virtual bool Rollup(uint32_t aCount, nsIContent** aLastRolledUp) = 0; virtual bool Rollup(uint32_t aCount, nsIContent** aLastRolledUp) = 0;
/** /**
* Asks the RollupListener if it should rollup on mousevents * Asks the RollupListener if it should rollup on mouse wheel events
*/ */
virtual bool ShouldRollupOnMouseWheelEvent() = 0; virtual bool ShouldRollupOnMouseWheelEvent() = 0;
/**
* Asks the RollupListener if it should consume mouse wheel events
*/
virtual bool ShouldConsumeOnMouseWheelEvent() = 0;
/** /**
* Asks the RollupListener if it should rollup on mouse activate, eg. X-Mouse * Asks the RollupListener if it should rollup on mouse activate, eg. X-Mouse
*/ */