Bug 987230 - use consumeanchor attribute to fix button click, r=enn,mconley

--HG--
extra : rebase_source : 8e52a377eeb708e258f0190fcbc5902c5477c2b8
This commit is contained in:
Gijs Kruitbosch 2014-07-01 01:09:43 +01:00
parent f9a6bfc044
commit 21c969cd34
6 changed files with 29 additions and 4 deletions

View File

@ -751,6 +751,7 @@
onkeypress="gIdentityHandler.handleIdentityButtonEvent(event);"
ondragstart="gIdentityHandler.onDragStart(event);">
<image id="page-proxy-favicon"
consumeanchor="identity-box"
onclick="PageProxyClickHandler(event);"
pageproxystate="invalid"/>
<hbox id="identity-icon-labels">
@ -976,6 +977,7 @@
<toolbarbutton id="PanelUI-menu-button"
class="toolbarbutton-1"
cui-areatype="toolbar"
consumeanchor="PanelUI-button"
label="&brandShortName;"
tooltiptext="&appmenu.tooltip;"/>
</toolbaritem>

View File

@ -363,6 +363,9 @@ const PanelUI = {
document.getAnonymousElementByAttribute(aAnchor, "class",
"toolbarbutton-icon");
if (iconAnchor && aAnchor.id) {
iconAnchor.setAttribute("consumeanchor", aAnchor.id);
}
tempPanel.openPopup(iconAnchor || aAnchor, "bottomcenter topright");
}
},

View File

@ -23,7 +23,8 @@
always be visible and must not move or resize when the indicator
state changes, otherwise the panel could change its position or lose
its arrow unexpectedly. -->
<stack id="downloads-indicator-anchor" class="toolbarbutton-icon">
<stack id="downloads-indicator-anchor" class="toolbarbutton-icon"
consumeanchor="downloads-button">
<vbox id="downloads-indicator-progress-area" pack="center">
<description id="downloads-indicator-counter"/>
<progressmeter id="downloads-indicator-progress" class="plain"

View File

@ -237,6 +237,7 @@ GK_ATOM(contentLocation, "content-location")
GK_ATOM(headerContentScriptType, "content-script-type")
GK_ATOM(headerContentStyleType, "content-style-type")
GK_ATOM(headerContentType, "content-type")
GK_ATOM(consumeanchor, "consumeanchor")
GK_ATOM(context, "context")
GK_ATOM(contextmenu, "contextmenu")
GK_ATOM(control, "control")

View File

@ -206,6 +206,24 @@ nsXULPopupManager::Rollup(uint32_t aCount, const nsIntPoint* pos, nsIContent** a
// clicking on a menu doesn't reopen the menu.
if (!consume && pos) {
nsCOMPtr<nsIContent> anchor = item->Frame()->GetAnchor();
// Check if the anchor has indicated another node to use for checking
// for roll-up. That way, we can anchor a popup on anonymous content or
// an individual icon, while clicking elsewhere within a button or other
// container doesn't result in us re-opening the popup.
if (anchor) {
nsAutoString consumeAnchor;
anchor->GetAttr(kNameSpaceID_None, nsGkAtoms::consumeanchor,
consumeAnchor);
if (!consumeAnchor.IsEmpty()) {
nsIDocument* doc = anchor->GetOwnerDocument();
nsIContent* newAnchor = doc->GetElementById(consumeAnchor);
if (newAnchor) {
anchor = newAnchor;
}
}
}
if (anchor && anchor->GetPrimaryFrame()) {
// It's possible that some other element is above the anchor at the same
// position, but the only thing that would happen is that the mouse

View File

@ -17,7 +17,7 @@
<content>
<children includes="observes|template|menupopup|panel|tooltip"/>
<xul:image class="toolbarbutton-icon" xbl:inherits="validate,src=image,label"/>
<xul:image class="toolbarbutton-icon" xbl:inherits="validate,src=image,label,consumeanchor"/>
<xul:label class="toolbarbutton-text" crop="right" flex="1"
xbl:inherits="value=label,accesskey,crop,wrap"/>
<xul:label class="toolbarbutton-multiline-text" flex="1"
@ -29,7 +29,7 @@
extends="chrome://global/content/bindings/toolbarbutton.xml#toolbarbutton">
<content>
<children includes="observes|template|menupopup|panel|tooltip"/>
<xul:image class="toolbarbutton-icon" xbl:inherits="validate,src=image,label,type"/>
<xul:image class="toolbarbutton-icon" xbl:inherits="validate,src=image,label,type,consumeanchor"/>
<xul:label class="toolbarbutton-text" crop="right" flex="1"
xbl:inherits="value=label,accesskey,crop,dragover-top,wrap"/>
<xul:label class="toolbarbutton-multiline-text" flex="1"
@ -45,7 +45,7 @@
<children includes="observes|template|menupopup|panel|tooltip"/>
<xul:hbox flex="1" align="center">
<xul:vbox flex="1" align="center">
<xul:image class="toolbarbutton-icon" xbl:inherits="validate,src=image,label"/>
<xul:image class="toolbarbutton-icon" xbl:inherits="validate,src=image,label,consumeanchor"/>
<xul:label class="toolbarbutton-text" crop="right" flex="1"
xbl:inherits="value=label,accesskey,crop,dragover-top,wrap"/>
<xul:label class="toolbarbutton-multiline-text" flex="1"