Bug 880701 - Add capability for PanelUI to ignore mutations in panelviews. r=jaws.

This commit is contained in:
Mike Conley 2013-06-14 11:57:09 -04:00
parent 8f6497c4a7
commit e5bfb55411
2 changed files with 48 additions and 4 deletions

View File

@ -114,9 +114,19 @@ const PanelUI = {
* method is exposed so that CustomizationMode can force registration in the
* event that customization mode is started before the panel has had a chance
* to register itself.
*
* @param aCustomizing (optional) set to true if this was called while entering
* customization mode. If that's the case, we trust that customization
* mode will handle calling beginBatchUpdate and endBatchUpdate.
*/
ensureRegistered: function() {
CustomizableUI.registerMenuPanel(this.contents);
ensureRegistered: function(aCustomizing=false) {
if (aCustomizing) {
CustomizableUI.registerMenuPanel(this.contents);
} else {
this.beginBatchUpdate();
CustomizableUI.registerMenuPanel(this.contents);
this.endBatchUpdate();
}
},
/**
@ -191,6 +201,23 @@ const PanelUI = {
}
},
/**
* Signal that we're about to make a lot of changes to the contents of the
* panels all at once. For performance, we ignore the mutations.
*/
beginBatchUpdate: function() {
this.multiView.ignoreMutations = true;
},
/**
* Signal that we're done making bulk changes to the panel. We now pay
* attention to mutations. This automatically synchronizes the multiview
* container with whichever view is displayed if the panel is open.
*/
endBatchUpdate: function(aReason) {
this.multiView.ignoreMutations = false;
},
/**
* Sets the anchor node into the open or closed state, depending
* on the state of the panel.

View File

@ -89,6 +89,7 @@
<field name="_mainViewHeight">0</field>
<field name="_subViewObserver">null</field>
<field name="_transitioning">false</field>
<field name="_ignoreMutations">false</field>
<property name="showingSubView" readonly="true"
onget="return this._viewStack.getAttribute('view') == 'subview'"/>
@ -96,6 +97,22 @@
<property name="_mainView" readonly="true"
onget="return document.getElementById(this._mainViewId);"/>
<property name="ignoreMutations">
<getter>
return this._ignoreMutations;
</getter>
<setter><![CDATA[
this._ignoreMutations = val;
if (!val && this._panel.state == "open") {
if (this.showingSubView) {
this._syncContainerWithSubView();
} else {
this._syncContainerWithMainView();
}
}
]]></setter>
</property>
<constructor><![CDATA[
this._clickCapturer.addEventListener("click", this);
this._panel.addEventListener("popupshowing", this);
@ -284,7 +301,7 @@
<method name="_syncContainerWithSubView">
<body><![CDATA[
if (this.showingSubView) {
if (!this.ignoreMutations && this.showingSubView) {
this._viewContainer.style.height =
this._subViews.scrollHeight + "px";
}
@ -292,7 +309,7 @@
</method>
<method name="_syncContainerWithMainView">
<body><![CDATA[
if (!this.showingSubView && !this._transitioning) {
if (!this.ignoreMutations && !this.showingSubView && !this._transitioning) {
this._viewContainer.style.height =
this._mainViewContainer.scrollHeight + "px";
}