Permalink
Browse files

Bug 631473 - Don't consume mouse scroll events outside arrow panels o…

…n OS X. r=mstange r=enndeakin
  • Loading branch information...
Frank Yan
Frank Yan committed Mar 8, 2013
1 parent b0738a7 commit 4e9f3c7ae9086e8329a1f3ba26f3760a2fabb011
@@ -94,6 +94,7 @@ GK_ATOM(applyTemplates, "apply-templates")
GK_ATOM(mozapptype, "mozapptype")
GK_ATOM(archive, "archive")
GK_ATOM(area, "area")
+GK_ATOM(arrow, "arrow")
GK_ATOM(article, "article")
GK_ATOM(ascending, "ascending")
GK_ATOM(aside, "aside")
@@ -178,6 +178,9 @@ class nsComboboxControlFrame : public nsBlockFrame,
virtual bool ShouldRollupOnMouseWheelEvent()
{ return true; }
+ virtual bool ShouldConsumeOnMouseWheelEvent()
+ { return false; }
+
/**
* A combobox should not roll up if activated by a mouse activate message
* (eg. X-mouse).
@@ -288,6 +288,7 @@ class nsXULPopupManager MOZ_FINAL : public nsIDOMEventListener,
// nsIRollupListener
virtual bool Rollup(uint32_t aCount, nsIContent** aLastRolledUp);
virtual bool ShouldRollupOnMouseWheelEvent();
+ virtual bool ShouldConsumeOnMouseWheelEvent();
virtual bool ShouldRollupOnMouseActivate();
virtual uint32_t GetSubmenuWidgetChain(nsTArray<nsIWidget*> *aWidgetChain);
virtual void NotifyGeometryChange() {}
@@ -238,6 +238,21 @@ bool nsXULPopupManager::ShouldRollupOnMouseWheelEvent()
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)
bool nsXULPopupManager::ShouldRollupOnMouseActivate()
{
@@ -2867,8 +2867,9 @@ - (BOOL)maybeRollup:(NSEvent*)theEvent
// check to see if scroll events should roll up the popup
if ([theEvent type] == NSScrollWheel) {
shouldRollup = rollupListener->ShouldRollupOnMouseWheelEvent();
- // always consume scroll events that aren't over the popup
- consumeEvent = YES;
+ // consume scroll events that aren't over the popup
+ // unless the popup is an arrow panel
+ consumeEvent = rollupListener->ShouldConsumeOnMouseWheelEvent();
}
// if we're dealing with menus, we probably have submenus and
@@ -29,10 +29,15 @@ class nsIRollupListener {
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;
+ /**
+ * 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
*/

0 comments on commit 4e9f3c7

Please sign in to comment.