<prefwindow>在browser.preferences.animateFadeIn == true </prefwindow>时将自身大小调整到错误的选项卡

时间:2011-01-16 20:00:43

标签: firefox-addon xul

我在扩展程序的首选项屏幕上遇到了(又一个)错误。当browser.preferences.animateFadeIn设置为true(因为它在Mac上)时,窗口大小更改以适应切换窗格中的内容。而是在打开窗口时将其大小调整为<​​em>最大窗格,但在切换窗格时它会发生变化。如果这不太清楚,这是一个截屏视频:http://files.droplr.com/files/22337488/4IVT.ScreenFlow.mov

即使删除了所有<script>元素和大多数窗格,错误仍然会发生:

<?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>

1 个答案:

答案 0 :(得分:1)

是的,我同意这是一个错误。加载第一个窗格时,prefwindow会根据其内容调整自身的大小。在您的情况下,这包括几个“背景”窗格。不幸的是,在动画案例中绕过了检测它的代码。当前代码如下所示:

if (animation) {
  if (switching)
    animate();
} else {
  if (panes > 1)
    fixHeight();
}

它应该看起来像这样:

if (animation && switching)
  animate();
else if (panes > 1)
  fixHeight();

即使启用了动画,这也会修复第一个窗格的高度。 (如果只有一个窗格,那么当然没有任何事情要做。)