Bug 793715 - Revert textbox.editor to a property, but one that wraps a field to cache the editor field once it is non-null. r=ehsan
authorJared Wein <jaws@mozilla.com>
Sun, 07 Oct 2012 18:18:42 -0400
changeset 115881 bf0aa600323fb6a0e6bbfb2d04c41eec930b597d
parent 115878 386f6fb98537f1b90c9f0f571851126df79c3a93
child 115882 9827af2a97cec5805dc0ed88ca34d1a71b8a092a
push id1708
push userakeybl@mozilla.com
push dateMon, 19 Nov 2012 21:10:21 +0000
treeherdermozilla-beta@27b14fe50103 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs793715
milestone18.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 793715 - Revert textbox.editor to a property, but one that wraps a field to cache the editor field once it is non-null. r=ehsan
toolkit/content/widgets/textbox.xml
--- a/toolkit/content/widgets/textbox.xml
+++ b/toolkit/content/widgets/textbox.xml
@@ -42,16 +42,17 @@
       <field name="crop">""</field>
       <field name="image">""</field>
       <field name="command">""</field>
       <field name="accessKey">""</field>
 
       <field name="mInputField">null</field>
       <field name="mIgnoreClick">false</field>
       <field name="mIgnoreFocus">false</field>
+      <field name="mEditor">false</field>
 
       <property name="inputField" readonly="true">
         <getter><![CDATA[
           if (!this.mInputField)
             this.mInputField = document.getAnonymousElementByAttribute(this, "anonid", "input");
           return this.mInputField;
         ]]></getter>
       </property>
@@ -87,19 +88,25 @@
                                          if (val) this.setAttribute('readonly', 'true');
                                          else this.removeAttribute('readonly'); return val;"
                                   onget="return this.inputField.readOnly;"/>
       <property name="clickSelectsAll"
                 onget="return this.getAttribute('clickSelectsAll') == 'true';"
                 onset="if (val) this.setAttribute('clickSelectsAll', 'true');
                        else this.removeAttribute('clickSelectsAll'); return val;" />
 
-      <field name="editor" readonly="true">
-        this.inputField.QueryInterface(Components.interfaces.nsIDOMNSEditableElement).editor;
-      </field>
+      <property name="editor" readonly="true">
+        <getter><![CDATA[
+          if (!this.mEditor) {
+            const nsIDOMNSEditableElement = Components.interfaces.nsIDOMNSEditableElement;
+            this.mEditor = this.inputField.QueryInterface(nsIDOMNSEditableElement).editor;
+          }
+          return this.mEditor;
+        ]]></getter>
+      </property>
 
       <method name="reset">
         <body><![CDATA[
           this.value = this.defaultValue;
           try {
             this.editor.transactionManager.clear();
             return true;
           }