зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1089005, add a third consume option that never consumes even over the anchor. This allows clicks on the location field to adjust the caret position, r=dao
This commit is contained in:
Родитель
8d967098a2
Коммит
f6a2d05cfe
|
@ -973,7 +973,7 @@
|
|||
<resources>
|
||||
<stylesheet src="chrome://browser/skin/searchbar.css"/>
|
||||
</resources>
|
||||
<content ignorekeys="true" level="top">
|
||||
<content ignorekeys="true" level="top" consumeoutsideclicks="never">
|
||||
<xul:hbox xbl:inherits="collapsed=showonlysettings" anonid="searchbar-engine"
|
||||
class="search-panel-header search-panel-current-engine">
|
||||
<xul:image class="searchbar-engine-image" xbl:inherits="src"/>
|
||||
|
|
|
@ -901,10 +901,6 @@
|
|||
// ourselves.
|
||||
popup.hidden = false;
|
||||
|
||||
// showHistoryPopup sets consumeoutsideclicks to true so reset it
|
||||
// here
|
||||
popup.setAttribute("consumeoutsideclicks", "false");
|
||||
|
||||
popup.mInput = this;
|
||||
popup.view = this.controller.QueryInterface(Components.interfaces.nsITreeView);
|
||||
popup.invalidate();
|
||||
|
|
|
@ -1507,27 +1507,32 @@ void nsMenuPopupFrame::CanAdjustEdges(int8_t aHorizontalSide, int8_t aVerticalSi
|
|||
}
|
||||
}
|
||||
|
||||
bool nsMenuPopupFrame::ConsumeOutsideClicks()
|
||||
ConsumeOutsideClicksResult nsMenuPopupFrame::ConsumeOutsideClicks()
|
||||
{
|
||||
// If the popup has explicitly set a consume mode, honor that.
|
||||
if (mConsumeRollupEvent != PopupBoxObject::ROLLUP_DEFAULT) {
|
||||
return (mConsumeRollupEvent == PopupBoxObject::ROLLUP_CONSUME);
|
||||
return (mConsumeRollupEvent == PopupBoxObject::ROLLUP_CONSUME) ?
|
||||
ConsumeOutsideClicks_True : ConsumeOutsideClicks_ParentOnly;
|
||||
}
|
||||
|
||||
if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::consumeoutsideclicks,
|
||||
nsGkAtoms::_true, eCaseMatters)) {
|
||||
return true;
|
||||
return ConsumeOutsideClicks_True;
|
||||
}
|
||||
if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::consumeoutsideclicks,
|
||||
nsGkAtoms::_false, eCaseMatters)) {
|
||||
return false;
|
||||
return ConsumeOutsideClicks_ParentOnly;
|
||||
}
|
||||
if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::consumeoutsideclicks,
|
||||
nsGkAtoms::never, eCaseMatters)) {
|
||||
return ConsumeOutsideClicks_Never;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> parentContent = mContent->GetParent();
|
||||
if (parentContent) {
|
||||
dom::NodeInfo *ni = parentContent->NodeInfo();
|
||||
if (ni->Equals(nsGkAtoms::menulist, kNameSpaceID_XUL)) {
|
||||
return true; // Consume outside clicks for combo boxes on all platforms
|
||||
return ConsumeOutsideClicks_True; // Consume outside clicks for combo boxes on all platforms
|
||||
}
|
||||
#if defined(XP_WIN)
|
||||
// Don't consume outside clicks for menus in Windows
|
||||
|
@ -1540,19 +1545,19 @@ bool nsMenuPopupFrame::ConsumeOutsideClicks()
|
|||
nsGkAtoms::menu, eCaseMatters) ||
|
||||
parentContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
||||
nsGkAtoms::menuButton, eCaseMatters)))) {
|
||||
return false;
|
||||
return ConsumeOutsideClicks_Never;
|
||||
}
|
||||
#endif
|
||||
if (ni->Equals(nsGkAtoms::textbox, kNameSpaceID_XUL)) {
|
||||
// Don't consume outside clicks for autocomplete widget
|
||||
if (parentContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
||||
nsGkAtoms::autocomplete, eCaseMatters)) {
|
||||
return false;
|
||||
return ConsumeOutsideClicks_Never;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return ConsumeOutsideClicks_True;
|
||||
}
|
||||
|
||||
// XXXroc this is megalame. Fossicking around for a frame of the right
|
||||
|
|
|
@ -63,6 +63,12 @@ enum nsPopupState {
|
|||
ePopupInvisible
|
||||
};
|
||||
|
||||
enum ConsumeOutsideClicksResult {
|
||||
ConsumeOutsideClicks_ParentOnly = 0, // Only consume clicks on the parent anchor
|
||||
ConsumeOutsideClicks_True = 1, // Always consume clicks
|
||||
ConsumeOutsideClicks_Never = 2 // Never consume clicks
|
||||
};
|
||||
|
||||
// How a popup may be flipped. Flipping to the outside edge is like how
|
||||
// a submenu would work. The entire popup is flipped to the opposite side
|
||||
// of the anchor.
|
||||
|
@ -188,7 +194,7 @@ public:
|
|||
* Unix Eat No Eat
|
||||
*
|
||||
*/
|
||||
bool ConsumeOutsideClicks();
|
||||
ConsumeOutsideClicksResult ConsumeOutsideClicks();
|
||||
|
||||
virtual bool IsContextMenu() MOZ_OVERRIDE { return mIsContextMenu; }
|
||||
|
||||
|
|
|
@ -202,10 +202,13 @@ nsXULPopupManager::Rollup(uint32_t aCount, bool aFlush,
|
|||
*aLastRolledUp = first->Content();
|
||||
}
|
||||
|
||||
consume = item->Frame()->ConsumeOutsideClicks();
|
||||
// If the click was over the anchor, always consume the click. This way,
|
||||
// clicking on a menu doesn't reopen the menu.
|
||||
if (!consume && pos) {
|
||||
ConsumeOutsideClicksResult consumeResult = item->Frame()->ConsumeOutsideClicks();
|
||||
consume = (consumeResult == ConsumeOutsideClicks_True);
|
||||
|
||||
// If ConsumeOutsideClicks_ParentOnly was returned, then only consume the
|
||||
// click is it was over the anchor. This way, clicking on a menu doesn't
|
||||
// reopen the menu.
|
||||
if (consumeResult == ConsumeOutsideClicks_ParentOnly && pos) {
|
||||
nsCOMPtr<nsIContent> anchor = item->Frame()->GetAnchor();
|
||||
|
||||
// Check if the anchor has indicated another node to use for checking
|
||||
|
|
|
@ -355,7 +355,6 @@
|
|||
|
||||
<method name="closePopup">
|
||||
<body><![CDATA[
|
||||
this.popup.setAttribute("consumeoutsideclicks", "false");
|
||||
this.popup.closePopup();
|
||||
]]></body>
|
||||
</method>
|
||||
|
@ -372,7 +371,6 @@
|
|||
input.setAttribute("open", "true");
|
||||
function onHide() {
|
||||
input.removeAttribute("open");
|
||||
popup.setAttribute("consumeoutsideclicks", "false");
|
||||
popup.removeEventListener("popuphiding", onHide, false);
|
||||
}
|
||||
popup.addEventListener("popuphiding", onHide, false);
|
||||
|
@ -392,7 +390,6 @@
|
|||
// Ensure that we have focus.
|
||||
if (!this.focused)
|
||||
this.focus();
|
||||
this.popup.setAttribute("consumeoutsideclicks", "true");
|
||||
this.attachController();
|
||||
this.mController.startSearch("");
|
||||
]]></body>
|
||||
|
@ -613,7 +610,7 @@
|
|||
<stylesheet src="chrome://global/skin/autocomplete.css"/>
|
||||
</resources>
|
||||
|
||||
<content ignorekeys="true" level="top" consumeoutsideclicks="false">
|
||||
<content ignorekeys="true" level="top" consumeoutsideclicks="never">
|
||||
<xul:tree anonid="tree" class="autocomplete-tree plain" hidecolumnpicker="true" flex="1" seltype="single">
|
||||
<xul:treecols anonid="treecols">
|
||||
<xul:treecol id="treecolAutoCompleteValue" class="autocomplete-treecol" flex="1" overflow="true"/>
|
||||
|
@ -966,7 +963,7 @@ extends="chrome://global/content/bindings/popup.xml#popup">
|
|||
<stylesheet src="chrome://global/skin/autocomplete.css"/>
|
||||
</resources>
|
||||
|
||||
<content ignorekeys="true" level="top" consumeoutsideclicks="false">
|
||||
<content ignorekeys="true" level="top" consumeoutsideclicks="never">
|
||||
<xul:richlistbox anonid="richlistbox" class="autocomplete-richlistbox" flex="1"/>
|
||||
<xul:hbox>
|
||||
<children/>
|
||||
|
|
Загрузка…
Ссылка в новой задаче