Why destructor of an extended binding is not called when extending binding is removed? - firefox-addon

Creating a XulRunner application for Windows I found that if binding B extends binding A. And B is being removed, then only destructor of B is called, not followed by a call of A's destructor.
Is there something wrong with my code, or this is a XulRunner bug (I haven't find matching bug in bugzilla)?
Here is an example that I tested on XulRunner 23 and 35:
main.xul:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="main" title="My App" width="500" height="300" sizemode="normal"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<script><![CDATA[
function print(aString) {
document.getElementById("log_msg").value += aString + "\n";
}
function removeElementById(aId) {
document.getElementById(aId).remove();
};
function callF(aId) {
document.getElementById(aId).f();
}
]]></script>
<vbox flex="1">
<label onclick="removeElementById('A')">remove A</label>
<label onclick="removeElementById('B')">remove B</label>
<label onclick="callF('A')">Call A.f()</label>
<label onclick="callF('B')">Call B.f()</label>
<!--<binding-a id="A" style="-moz-binding: url('binding.xml#binding-a')"/>-->
<binding-b id="B" style="-moz-binding: url('binding.xml#binding-b')"/>
<textbox id="log_msg" label="Text" placeholder="placeholder" multiline="true" rows="6"/>
</vbox>
</window>
binding.xml:
<?xml version="1.0"?>
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="binding-a">
<content>
<xul:label anonid="label" value="Binding A"/>
</content>
<implementation>
<constructor><![CDATA[
var label = document.getAnonymousElementByAttribute(this, "anonid", "label");
label.value = label.value + " A.constructor";
window.print("A.constructor");
]]></constructor>
<destructor><![CDATA[
window.print("A.destructor");
]]></destructor>
<method name="f">
<body><![CDATA[
window.print("A.f");
]]></body>
</method>
</implementation>
</binding>
<binding id="binding-b" extends="#binding-a">
<content>
<xul:label anonid="label" value="Binding B"/>
</content>
<implementation>
<constructor><![CDATA[
window.print("B.constructor");
]]></constructor>
<destructor><![CDATA[
window.print("B.destructor");
]]></destructor>
</implementation>
</binding>
</bindings>

here is the solution for your problem:
bindings.xml:
<?xml version="1.0"?>
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="binding-a">
<content>
<xul:label anonid="label" value="Binding A"/>
</content>
<implementation>
<constructor><![CDATA[
var label = document.getAnonymousElementByAttribute(this, "anonid", "label");
label.value = label.value + " A.constructor";
window.print("A.constructor");
]]></constructor>
<destructor><![CDATA[
this.destruct();
]]></destructor>
<method name="f">
<body><![CDATA[
window.print("A.f");
]]></body>
</method>
<method name="destruct">
<body><![CDATA[
window.print("A.destructor");
]]></body>
</method>
</implementation>
</binding>
<binding id="binding-b" extends="#binding-a">
<content>
<xul:label anonid="label" value="Binding B"/>
</content>
<implementation>
<constructor><![CDATA[
window.print("B.constructor");
]]></constructor>
<destructor><![CDATA[
this.destruct();
]]></destructor>
<method name="destruct">
<body><![CDATA[
this.__proto__.__proto__.destruct.call(this);
window.print("B.destructor");
]]></body>
</method>
</implementation>
</binding>
</bindings>
bindings.css:
#namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
binding-a { -moz-binding: url("bindings.xml#binding-a"); }
binding-b { -moz-binding: url("bindings.xml#binding-b"); }
main.xul:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="bindings.css" type="text/css"?>
<window id="main" title="My App" width="500" height="300" sizemode="normal"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<script><![CDATA[
function print(aString) {
document.getElementById("log_msg").value += aString + "\n";
}
function removeElementById(aId) {
document.getElementById(aId).remove();
};
function callF(aId) {
document.getElementById(aId).f();
}
]]></script>
<vbox flex="1">
<label onclick="removeElementById('A')">remove A</label>
<label onclick="removeElementById('B')">remove B</label>
<label onclick="callF('A')">Call A.f()</label>
<label onclick="callF('B')">Call B.f()</label>
<binding-a id="A"/>
<binding-b id="B"/>
<textbox id="log_msg" label="Text" placeholder="placeholder" multiline="true" rows="6"/>
</vbox>
</window>
I know that it is a hack in fact but it works.

Related

SAPUI5 PlanningCalendar - binding two entities

I have the following problem:
I'm developing an APP using the flameworks PlanningCalendar, but I have two EntitySet:
Salas(3):
CAPACIDADE: 6
ID: 3
NOME: "SALA 3"
NavReservas: {__deferred: {…}}
__metadata: {type: "room_sfsf.rooms.SalasType", uri: "https://leandrp822648trial.hanatrial.ondemand.com:443/room_sfsf/rooms.xsodata/Salas(3)"}
__proto__: Object
__proto__: Object
and:
Reservas(1):
DATA_FIM: Tue Sep 18 2018 14:00:00 GMT-0300 (Horário Padrão de Brasília) {}
DATA_INICIO: Tue Sep 18 2018 12:00:00 GMT-0300 (Horário Padrão de Brasília) {}
ID: 1
ID_SALA: 3
NOME: "caio"
USUARIO: "caio.amorim"
__metadata:
type: "room_sfsf.rooms.ReservasType"
uri: "https://leandrp822648trial.hanatrial.ondemand.com:443/room_sfsf/rooms.xsodata/Reservas(1)
"
but I can not get the two to appear on the screen, but I can not get the two to appear on the related screen, Below is the view file:
<mvc:View
controllerName="br.com.successfactors.itz.MeetingRoomSuccessfactors.controller.Main"
xmlns:mvc="sap.ui.core.mvc"
xmlns:unified="sap.ui.unified"
xmlns="sap.m">
<VBox class="sapUiSmallMargin">
<PlanningCalendar
id="PC1"
startDate="{path: '/startDate'}"
rows="{path : '/Salas', parameters:{$expand: 'NavReservas'}}"
appointmentSelect="handleAppointmentSelect"
>
<toolbarContent>
<Title text="{i18n>title}" titleStyle="H4"/>
<ToolbarSpacer/>
<Button id="addButton" icon="sap-icon://add" press="handleAppointmentCreate" tooltip="Add"/>
</toolbarContent>
<rows>
<PlanningCalendarRow
id="PCR"
title="{NOME}"
text="{i18n>QuantRoom} {CAPACIDADE}"
appointments="{path: '/Reservas', templateShareable: 'true'}"
>
<!--intervalHeaders="{path: 'Employees', templateShareable: 'true'}">-->
<appointments >
<unified:CalendarAppointment
startDate="{DATA_INICIO}"
endDate="{DATA_FIM}"
icon="{}"
title="{NOME}"
text="{USER}"
type="{}"
tentative="{}"
>
</unified:CalendarAppointment>
</appointments>
<!-- <intervalHeaders>
<unified:CalendarAppointment
startDate="{start}"
endDate="{end}"
icon="{pic}"
title="{title}"
type="{type}">
</unified:CalendarAppointment>
</intervalHeaders>-->
</PlanningCalendarRow>
</rows>
</PlanningCalendar>
</VBox>
</mvc:View>
below the metadata file:
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" Version="1.0">
<edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="2.0">
<Schema xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://schemas.microsoft.com/ado/2008/09/edm"
Namespace="room_sfsf.rooms">
<EntityType Name="SalasType">
<Key><PropertyRef Name="ID"/></Key><Property Name="ID" Type="Edm.Int32" Nullable="false"/><Property Name="NOME" Type="Edm.String" MaxLength="30"/><Property Name="CAPACIDADE" Type="Edm.Int32"/><NavigationProperty Name="NavReservas" Relationship="room_sfsf.rooms.Nav_ReservasType" FromRole="SalasPrincipal" ToRole="ReservasDependent"/></EntityType>
<EntityType Name="ReservasType">
<Key><PropertyRef Name="ID"/></Key><Property Name="ID" Type="Edm.Int32" Nullable="false"/><Property Name="NOME" Type="Edm.String" Nullable="false" MaxLength="30"/><Property Name="USUARIO" Type="Edm.String" MaxLength="20"/><Property Name="DATA_INICIO" Type="Edm.DateTime" Nullable="false"/><Property Name="DATA_FIM" Type="Edm.DateTime" Nullable="false"/><Property Name="ID_SALA" Type="Edm.Int32"/></EntityType>
<Association Name="Nav_ReservasType"><End Type="room_sfsf.rooms.SalasType" Role="SalasPrincipal" Multiplicity="1"/><End Type="room_sfsf.rooms.ReservasType" Role="ReservasDependent" Multiplicity="*"/>
<ReferentialConstraint>
<Principal Role="SalasPrincipal"><PropertyRef Name="ID"/></Principal>
<Dependent Role="ReservasDependent"><PropertyRef Name="ID_SALA"/></Dependent>
</ReferentialConstraint>
</Association>
<EntityContainer Name="rooms" m:IsDefaultEntityContainer="true"><EntitySet Name="Salas" EntityType="room_sfsf.rooms.SalasType"/><EntitySet Name="Reservas" EntityType="room_sfsf.rooms.ReservasType"/>
<AssociationSet Name="Nav_Reservas" Association="room_sfsf.rooms.Nav_ReservasType"><End Role="SalasPrincipal" EntitySet="Salas"/><End Role="ReservasDependent" EntitySet="Reservas"/></AssociationSet>
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
image with the result on screen:
enter image description here
image the EntitySet:
enter image description here
Does anyone have any idea how I can solve this problem?
thank you so much.
ADD NEW COMMENT
I changed View after comment the Jorg, but not work, below:
<mvc:View
controllerName="br.com.successfactors.itz.MeetingRoomSuccessfactors.controller.Main"
xmlns:mvc="sap.ui.core.mvc"
xmlns:unified="sap.ui.unified"
xmlns="sap.m">
<VBox class="sapUiSmallMargin">
<PlanningCalendar
id="PC1"
startDate="{path: '/startDate'}"
rows="{path : '/Salas', parameters:{$expand: 'NavReservas'}}"
appointmentSelect="handleAppointmentSelect"
>
<toolbarContent>
<Title text="{i18n>title}" titleStyle="H4"/>
<ToolbarSpacer/>
<Button id="addButton" icon="sap-icon://add" press="handleAppointmentCreate" tooltip="Add"/>
</toolbarContent>
<rows>
<PlanningCalendarRow
id="PCR"
title="{NOME}"
text="{i18n>QuantRoom} {CAPACIDADE}"
appointments="{path: 'NavReservas', templateShareable: 'true'}"
>
<!--intervalHeaders="{path: 'Employees', templateShareable: 'true'}">-->
<appointments >
<unified:CalendarAppointment
startDate="{DATA_INICIO}"
endDate="{DATA_FIM}"
icon="{}"
title="{NOME}"
text="{USER}"
type="{}"
tentative="{}"
>
</unified:CalendarAppointment>
</appointments>
<!-- <intervalHeaders>
<unified:CalendarAppointment
startDate="{start}"
endDate="{end}"
icon="{pic}"
title="{title}"
type="{type}">
</unified:CalendarAppointment>
</intervalHeaders>-->
</PlanningCalendarRow>
</rows>
</PlanningCalendar>
</VBox>
</mvc:View>
Detail the error:
Uncaught Error: "[object Object]" is of type object, expected
sap.ui.core.URI for property "icon" of Element
sap.ui.unified.CalendarAppointment#__appointment0-__xmlview0--PCR-__xmlview0--PC1-0-0
at f.g.validateProperty (sap-ui-core.js:423)
at f.M.validateProperty (/resources/sap/ui/core/library-preload.js?eval:181)
at f.g.setProperty (sap-ui-core.js:421)
at f.setIcon (sap-ui-core.js:509)
at f.g.updateProperty (sap-ui-core.js:464)
at constructor.v (sap-ui-core.js:462)
at constructor.a.fireEvent (sap-ui-core.js:397)
at constructor.B._fireChange (sap-ui-core.js:1463)
at constructor.O.checkUpdate (/resources/sap/ui/core/library-preload.js?eval:2480)
at constructor.O.initialize (/resources/sap/ui/core/library-preload.js?eval:2475)
Image Result:
enter image description here
the browser it work!
{"d":{"results":[{"__metadata": {"type":"room_sfsf.rooms.ReservasType","uri":"https://leandrp822648trial.hanatrial.ondemand.com:443/room_sfsf/rooms.xsodata/Reservas(1)"},"ID":1,"NOME":"caio","USUARIO":"caio.amorim","DATA_INICIO":"\/Date(1537311600000)\/","DATA_FIM":"\/Date(1537318800000)\/","ID_SALA":3}]}}
enter image description here
Thanks.

Expand/Collapse not working in Telerik RadGrid

I am using Telerik RadGrid with NestedViewTemplate to display data in my MVC applicaiton.
Following is my code
<telerik:RadGrid ID="rgNutritionLog" runat="server" OnInit="rgNutritionLog_Init"
OnNeedDataSource="rgNutritionLog_NeedDataSource" OnPreRender="rgNutritionLog_PreRender" OnItemCommand="rgNutritionLog_ItemCommand" OnItemDataBound="rgNutritionLog_ItemDataBound"OnItemCreated="rgNutritionLog_ItemCreated">
<GroupingSettings CaseSensitive="false" />
<HeaderStyle Width="120px" CssClass="tableHeader" />
<ClientSettings AllowColumnsReorder="true" AllowExpandCollapse="true">
<Selecting AllowRowSelect="true" />
<Scrolling AllowScroll="true" UseStaticHeaders="true" FrozenColumnsCount="1" />
<ClientEvents OnGridCreated="GridCreated" OnHeaderMenuShowing="HeaderMenuShowing" />
</ClientSettings>
<HeaderContextMenu OnClientItemClosed="OnClientItemClosed" OnItemCreated="HeaderContextMenu_ItemCreated"
OnClientItemOpening="OnClientItemOpening" BackColor="AliceBlue" BorderColor="Black">
</HeaderContextMenu>
<MasterTableView AllowFilteringByColumn="true" ShowFooter="false" ClientDataKeyNames="ID"
DataKeyNames="ID" TableLayout="Fixed">
<Columns>
<telerik:GridBoundColumn DataField="ID" HeaderText="ID"
ShowFilterIcon="false" UniqueName="intFunctionalTestId" SortExpression="ID"
FilterControlWidth="100px" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
Visible="false">
<HeaderStyle Width="120px" />
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn DataField="AthleteName" HeaderText="Athlete Name"
ShowFilterIcon="false" UniqueName="AthleteName" SortExpression="AthleteName"
FilterControlWidth="100px" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
Visible="true">
<ItemTemplate>
<%#Eval("AthleteName") %>
</ItemTemplate>
<HeaderStyle Width="120px" />
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="EnergyIncludingDietaryKjProposed" HeaderText="Proposed Energy Including Dietary Fibre (Kj)" ShowFilterIcon="true"
UniqueName="EnergyIncludingDietaryKjProposed" SortExpression="EnergyIncludingDietaryKjProposed" FilterControlWidth="80px"
AutoPostBackOnFilter="false" CurrentFilterFunction="NoFilter">
<HeaderStyle Width="120px" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="EnergyIncludingDietaryKjActual" HeaderText="Actual Energy Including Dietary Fibre (Kj)" ShowFilterIcon="true"
UniqueName="EnergyIncludingDietaryKjActual" SortExpression="EnergyIncludingDietaryKjActual" FilterControlWidth="80px"
AutoPostBackOnFilter="false" CurrentFilterFunction="NoFilter">
<HeaderStyle Width="120px" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="CarbohydrtProposed" HeaderText="Proposed Carbohydrates (g)" ShowFilterIcon="true"
UniqueName="CarbohydrtProposed" SortExpression="CarbohydrtProposed" FilterControlWidth="80px"
AutoPostBackOnFilter="false" CurrentFilterFunction="NoFilter">
<HeaderStyle Width="120px" />
</telerik:GridBoundColumn>
</Columns>
<NestedViewSettings>
<ParentTableRelation>
<telerik:GridRelationFields DetailKeyField="ID" MasterKeyField="ID" />
</ParentTableRelation>
</NestedViewSettings>
<NestedViewTemplate>
<div style="overflow-y: scroll;">
<fieldset style="padding: 2px;">
<telerik:RadGrid ID="rgAssignedDetails" AutoGenerateColumns="false" runat="server"
AllowSorting="true" OnNeedDataSource="rgAssignedDetails_NeedDataSource">
<ClientSettings AllowColumnsReorder="true">
</ClientSettings>
<MasterTableView>
<Columns>
<telerik:GridBoundColumn DataField="Meal" HeaderText="Meal" UniqueName="Meal">
<HeaderStyle Width="150px" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="EnergyIncludingDietaryKjProposed" HeaderText="Proposed Energy Including Dietary Fibre (Kj)"
UniqueName="EnergyIncludingDietaryKjProposedMeal">
<HeaderStyle Width="120px" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="EnergyIncludingDietaryKjActual" HeaderText="Actual Energy Including Dietary Fibre (Kj)"
UniqueName="EnergyIncludingDietaryKjActual">
<HeaderStyle Width="120px" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="CarbohydrtProposed" HeaderText="Proposed Carbohydrates (g)"
UniqueName="CarbohydrtProposed">
<HeaderStyle Width="120px" />
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
Any suggestion?
How can I do Expand/Collapse? Also is there any way to make nested grid scroll able?
I could not perform expand/collapse from server side so I did it using javascript following is the solution
var imageButtonPath = null;
function RowClicked(sender, eventArgs) {
var grid = sender;
var rowIndex = eventArgs.get_itemIndexHierarchical();
if (rowIndex.indexOf(':') != -1) {
rowIndex = rowIndex.substr(rowIndex.lastIndexOf('_') + 1);
}
var tableView = eventArgs.get_tableView();
var row = tableView.get_dataItems()[rowIndex];
if (tableView.getCellByColumnUniqueName(row, "ExpandColumn")) {
if (row.get_expanded() == false) {
row.set_expanded(true);
imageButton = tableView.getCellByColumnUniqueName(row, "ExpandColumn").childNodes[0];
imageButton.className = "rgCollapse";
}
else {
row.set_expanded(false);
imageButton = tableView.getCellByColumnUniqueName(row, "ExpandColumn").childNodes[0];
imageButton.className = "rgExpand";
}
}
GridCreated(sender, eventArgs)
}
I called this javascript function on row click event.

collect data from child links by web harvest

Is there any way to collect data from child link for Web Harvest?
Below is a xml segment I use:
<loop item="item" index="i">
<list><var name="products"/></list>
<body>
<xquery>
<xq-param name="item"><var name="item"/></xq-param>
<xq-expression><![CDATA[
declare variable $item as node() external;
for $i in $item//div[1]/p/a[#trace='auction'][1]
let $url := data($i/#href)
How can I grab data base on this new url which now is $url?
Please help me. Thx.
You just need to create another to contain this information. I have created a sample for you to understand it with ease. Please have a look:
SCRIPT:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<var-def name="MainSite">http://www.appszoom.com/android_games/arcade_and_action</var-def>
<loop item="titles" index="i">
<list>
<xpath expression="//li[#class='app captureLinkBox']/div/div/span/a">
<html-to-xml>
<http url="${MainSite}"></http>
</html-to-xml>
</xpath>
</list>
<body>
<var-def name="titleURL">
<xpath expression="data(/a/#href)">
<var name="titles"/>
</xpath>
</var-def>
<file action="append" path="D:\navin.xml">
<xquery>
<xq-param name="titles"><template>${titles}</template></xq-param>
<xq-param name="titleURLContent">
<html-to-xml>
<http url="${titleURL}"></http>
</html-to-xml>
</xq-param>
<xq-expression>
<![CDATA[
declare variable $titles as node() external;
declare variable $titleURLContent as node() external;
<game>
<title>{$titles/a/text()}</title>
<downloads>{$titleURLContent//*[#id="left-bar"]/p[2]/span/text()}</downloads>
</game>
]]>
</xq-expression>
</xquery>
</file>
</body>
</loop>
</config>
OUTPUT:
<game>
<title>Clash of Clans</title>
<downloads>10,000,000 - 50,000,000</downloads>
</game>
<game>
<title>DEER HUNTER 2014</title>
<downloads>10,000,000 - 50,000,000</downloads>
</game>
<game>
<title>Subway Surfers</title>
<downloads>100,000,000 - 500,000,000</downloads>
</game>
<game>
<title>RoboCop™</title>
<downloads>5,000,000 - 10,000,000</downloads>
</game><game>
<title>DragonFlight for Kakao</title>
<downloads>10,000,000 - 50,000,000</downloads>
</game>
<game>
<title>Castle Clash</title>
<downloads>10,000,000 - 50,000,000</downloads>
</game>
<game>
<title>Sonic Dash</title>
<downloads>10,000,000 - 50,000,000</downloads>
</game>
<game>
<title>Injustice: Gods Among Us</title>
<downloads>1,000,000 - 5,000,000</downloads>
</game>
<game>
<title>Banana Kong</title>
<downloads>10,000,000 - 50,000,000</downloads>
</game>
<game>
<title>Temple Run 2</title>
<downloads>100,000,000 - 500,000,000</downloads>
</game>
You do not give full code, for me to check running, but this should get you on your way:
<config>
<loop item="item" index="i">
<list><var name="products"/></list>
<body>
<var-def name="new_url">
<xquery>
<xq-param name="item"><var name="item"/></xq-param>
<xq-expression><![CDATA[
declare variable $item as node() external;
for $i in $item//div[1]/p/a[#trace='auction'][1]
let $url := data($i/#href)
return
{$url}
]]></xq-expression>
</xquery>
</var-def>
<!-- now your new url is saved in webharvest variable new_url and you are free to run a
new webharvest http request using it -->
<var-def name="new_page_content">
<http url="${new_url}"/>
</var-def>
<!-- now the content of the new page has been downloaded and saved in new variable
new_page_content and you are free to query it further should you want to -->
<var-def name="contact">
<xpath expression="//a[contains(., 'contact')]/#href">
<var name="new_page_content"/>
</xpath>
</body>
</loop>
</config>

Nested tool-bar button in xul

I am having a toolbar-button with type "menu-button". Can I have two toolbar-buttons inside this one?
Since you would like to have a button inside a menu-button, here you go. But, this is not a pretty good UI.
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<window id="main-window">
<toolbox id="navigator-toolbox">
<toolbar id="xulschoolhello-toolbar" toolbarname="xulschoolhello.toolbarName.label;"
customizable="true" mode="icons" context="toolbar-context-menu"
defaultset="xulschoolhello-hello-world-button"
insertbefore="PersonalToolbar" />
<hbox>
<row> <button flex="1" type="menu" label="Menu">
<menupopup>
<menuitem label="Option 1" oncommand="setText('menu-text','Option 1');" />
<menuitem label="Option 2" oncommand="setText('menu-text','Option 2');" />
<menuitem label="Option 3" oncommand="setText('menu-text','Option 3');" />
<menuitem label="Option 4" oncommand="setText('menu-text','Option 4');" />
</menupopup>
</button> </row>
<row> <button flex="1" type="menu-button" label="MenuButton" oncommand="alert('Button was pressed!');">
<menupopup>
<menuitem label="Option A" oncommand="setText('menu-text','Option A');" />
<menuitem label="Option B" oncommand="setText('menu-text','Option B');" />
<menuitem label="Option C" oncommand="setText('menu-text','Option C');" />
<menuitem label="Option D" oncommand="setText('menu-text','Option D');" />
</menupopup>
</button></row>
</hbox>
<hbox pack="center">
<description id="menu-text" value="Testing" />
</hbox>
</toolbox>
</window>
</window>

<prefwindow> sizing itself to the wrong tab when browser.preferences.animateFadeIn == true

I've run into (yet another) bug with the preferences screen of my extension. When browser.preferences.animateFadeIn is set to true (as it is on Mac), the window size should change to fit the content exactly on switching panes. Instead it is sized to the largest pane when the window is opened, but it changes by as much as it should when switching panes. If that's not too clear, here is a screencast: http://files.droplr.com/files/22337488/4IVT.ScreenFlow.mov
Even after removing all <script> elements, and most of the panes, the error still happens:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css" type="text/css"?>
<?xml-stylesheet href="chrome://nextplease/skin/nextpleasePreferences.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://nextplease/locale/nextplease.dtd">
<prefwindow id="nextpleaseprefs" title="&options.title;"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<prefpane id="nextplease.images" label="&options.images.title;" image="chrome://nextplease/skin/Image.png">
<preferences>
<preference id="nextimages" name="nextplease.nextimage.expr0" type="unichar"/>
<preference id="previmages" name="nextplease.previmage.expr0" type="unichar"/>
<preference id="firstimages" name="nextplease.firstimage.expr0" type="unichar"/>
<preference id="lastimages" name="nextplease.lastimage.expr0" type="unichar"/>
</preferences>
<hbox flex="1">
<listbox width="80" onselect="nextplease.selectedPanelChanged(this);">
<listitem label="&options.next;" selected="true"/>
<listitem label="&options.prev;"/>
<listitem label="&options.first;"/>
<listitem label="&options.last;"/>
</listbox>
<separator class="groove" orient="vertical" style="opacity: 0.5; margin-top: 5px; margin-bottom: 5px;"/>
<vbox flex="1">
<deck flex="1">
<listbox id="Next_Image_list" seltype="multiple" flex="1"
onkeypress="nextplease.removeSelectedOnDelete(event, this);" onselect="nextplease.enableDisableRemoveButton(this);" onchange="nextplease.syncListboxToPref(this);"/>
<listbox id="Prev_Image_list" seltype="multiple" flex="1"
onkeypress="nextplease.removeSelectedOnDelete(event, this);" onselect="nextplease.enableDisableRemoveButton(this);" onchange="nextplease.syncListboxToPref(this);"/>
<listbox id="First_Image_list" seltype="multiple" flex="1"
onkeypress="nextplease.removeSelectedOnDelete(event, this);" onselect="nextplease.enableDisableRemoveButton(this);" onchange="nextplease.syncListboxToPref(this);"/>
<listbox id="Last_Image_list" seltype="multiple" flex="1"
onkeypress="nextplease.removeSelectedOnDelete(event, this);" onselect="nextplease.enableDisableRemoveButton(this);" onchange="nextplease.syncListboxToPref(this);"/>
</deck>
<hbox id="images_dummy_texts" collapsed="true">
<textbox id="Next_Image_dummy_text" preference="nextimages" onchange="nextplease.syncPrefToListbox(this);"/>
<textbox id="Prev_Image_dummy_text" preference="previmages" onchange="nextplease.syncPrefToListbox(this);"/>
<textbox id="First_Image_dummy_text" preference="firstimages" onchange="nextplease.syncPrefToListbox(this);"/>
<textbox id="Last_Image_dummy_text" preference="lastimages" onchange="nextplease.syncPrefToListbox(this);"/>
</hbox>
<separator class="thin"/>
<hbox align="stretch">
<textbox type="text" maxlength="256" onkeypress="nextplease.addOnReturn(event, this);"/>
<button label="&options.add;" style="margin-left: 0"
oncommand="nextplease.addToListbox(this);"/>
<spacer flex="1" minwidth="15"/>
<button label="&options.removeSelected;" disabled="true" style="margin-right: 2px"
oncommand="nextplease.removeSelectedFromListbox(this);"/>
<spacer flex="1" minwidth="40"/>
<button label="&options.restoreDefault;"
oncommand="nextplease.restoreDefaultListbox(this);"/>
</hbox>
</vbox>
</hbox>
</prefpane>
<prefpane id="nextplease.debug" label="&options.debug.title;" image="chrome://nextplease/skin/Settings.png">
<preferences>
<preference id="log" name="nextplease.log" type="bool"/>
<preference id="log.detailed" name="nextplease.log.detailed" type="bool"/>
<preference id="log.file" name="nextplease.log.file" type="bool"/>
<preference id="highlight" name="nextplease.highlight" type="bool"/>
<preference id="highlight.color" name="nextplease.highlight.color" type="string"/>
<preference id="highlight.prefetched" name="nextplease.highlight.prefetched" type="bool"/>
<preference id="highlight.prefetched.color" name="nextplease.highlight.prefetched.color" type="string"/>
</preferences>
<vbox>
<checkbox label="&options.log.normal;" preference="log"/>
<checkbox label="&options.log.detailed;" preference="log.detailed"/>
<!--<checkbox id="nextplease.log.file" label="&options.log.file;" preference="log.file/>-->
<separator/>
<hbox>
<checkbox label="&options.highlight;"
preference="highlight"
oncommand="nextplease.enableDisableHighlightColorPickers();"/>
<colorpicker type="button" preference="highlight.color"/>
</hbox>
<hbox>
<checkbox label="&options.highlight.prefetched;"
preference="highlight.prefetched"
oncommand="nextplease.enableDisableHighlightColorPickers();"/>
<colorpicker type="button" preference="highlight.prefetched.color"/>
</hbox>
</vbox>
</prefpane>
</prefwindow>
Yes, I'd agree that it's a bug. When the first pane loads, the prefwindow sizes itself to its content. In your case, this includes several "background" panes. Unfortunately the code to detect this gets bypassed in the animating case. The current code looks something like this:
if (animation) {
if (switching)
animate();
} else {
if (panes > 1)
fixHeight();
}
It should instead look something like this:
if (animation && switching)
animate();
else if (panes > 1)
fixHeight();
This would fix the height of the first pane even when animation was enabled. (If there is only one pane then there is nothing to do of course.)

Resources