summaryrefslogtreecommitdiffstats
path: root/webbrowser/components/statusbar/content/tabbrowser.xml
blob: 2f475771d1b683fec164254a81b99b825aa427d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<?xml version="1.0" encoding="UTF-8"?>

<!-- This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. -->

<bindings id="status4evar-bindings"
          xmlns="http://www.mozilla.org/xbl"
          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
          xmlns:xbl="http://www.mozilla.org/xbl">

  <binding id="statuspanel" display="xul:hbox" extends="chrome://browser/content/tabbrowser.xml#statuspanel">
    <implementation>
      <!--                          -->
      <!-- Inverted mirror handling -->
      <!--                          -->

      <field name="_invertMirror"><![CDATA[
        false
      ]]></field>

      <property name="invertMirror">
        <setter><![CDATA[
          this._invertMirror = val;
          this.mirror = this._isMirrored;
          return val;
        ]]></setter>
        <getter><![CDATA[
          return this._invertMirror;
        ]]></getter>
      </property>

      <!--                       -->
      <!-- Mouse mirror handling -->
      <!--                       -->

      <field name="_mouseMirror"><![CDATA[
        true
      ]]></field>

      <field name="_mouseMirrorListen"><![CDATA[
        false
      ]]></field>

      <property name="mouseMirror">
        <setter><![CDATA[
          this._mouseMirror = val;
          this.setupMouseMirror(this.value);
          return val;
        ]]></setter>
        <getter><![CDATA[
          return this._mouseMirror;
        ]]></getter>
      </property>

      <method name="setupMouseMirror">
        <parameter name="val"/>
        <body><![CDATA[
          if(val && this._mouseMirror)
          {
            this._calcMouseTargetRect();
            if(!this._mouseMirrorListen)
            {
              MousePosTracker.addListener(this);
              this._mouseMirrorListen = true;
            }
          }
          else
          {
            this.mirror = false;
            if(this._mouseMirrorListen)
            {
              MousePosTracker.removeListener(this);
              this._mouseMirrorListen = false;
            }
          }
        ]]></body>
      </method>

      <method name="_calcMouseTargetRect">
        <body><![CDATA[
          let alignRight = false;
          let isRTL = (getComputedStyle(document.documentElement).direction == "rtl");
          if((this._invertMirror && !isRTL) || (!this._invertMirror && isRTL))
          {
            alignRight = true;
          }

          let rect = this.getBoundingClientRect();
          this._mouseTargetRect =
          {
            top:    rect.top,
            bottom: rect.bottom,
            left:   ((alignRight) ? window.innerWidth - rect.width : 0),
            right:  ((alignRight) ? window.innerWidth : rect.width)
          };
        ]]></body>
      </method>

      <method name="onMouseEnter">
        <body><![CDATA[
          this.mirror = true;
        ]]></body>
      </method>

      <method name="onMouseLeave">
        <body><![CDATA[
          this.mirror = false;
        ]]></body>
      </method>

      <!--                 -->
      <!-- Mirror handling -->
      <!--                 -->

      <field name="_isMirrored"><![CDATA[
        false
      ]]></field>

      <property name="mirror">
        <setter><![CDATA[
          this._isMirrored = val;
          if(this._invertMirror)
          {
            val = !val;
          }

          this.setBooleanAttr("mirror", val);
        ]]></setter>
        <getter><![CDATA[
          return this._isMirrored;
        ]]></getter>
      </property>

      <method name="_mirror">
        <body><![CDATA[
          this.mirror = !this._isMirrored;
        ]]></body>
      </method>

      <!--                -->
      <!-- Value handling -->
      <!--                -->

      <property name="label">
        <setter><![CDATA[
          if(window.caligon && window.caligon.status4evar)
          {
            window.caligon.status4evar.statusService.setStatusText(val);
          }
          return undefined;
        ]]></setter>
        <getter><![CDATA[
          if(window.caligon && window.caligon.status4evar)
          {
            return window.caligon.status4evar.statusService.getStatusText();
          }
          return "";
        ]]></getter>
      </property>

      <property name="value">
        <setter><![CDATA[
          this.setValue(val);
          this.setupMouseMirror(val);
          return val;
        ]]></setter>
        <getter><![CDATA[
          return ((this.hasAttribute("inactive")) ? "" : this.getAttribute("label"));
        ]]></getter>
      </property>

      <method name="setValue">
        <parameter name="val"/>
        <body><![CDATA[
          if((this.getAttribute("type") || "").indexOf("network") > -1 && (this.getAttribute("previoustype") || "").indexOf("network") > -1)
          {
            this.style.minWidth = getComputedStyle(this).width;
          }
          else
          {
            this.style.minWidth = "";
          }

          if(val)
          {
            this.setAttribute("label", val);
            this.setBooleanAttr("inactive", false);
          }
          else
          {
            this.setBooleanAttr("inactive", true);
          }
        ]]></body>
      </method>

      <!--         -->
      <!-- Helpers -->
      <!--         -->

      <method name="setBooleanAttr">
        <parameter name="name"/>
        <parameter name="val"/>
        <body><![CDATA[
          if(val)
          {
            this.setAttribute(name, "true");
          }
          else
          {
            this.removeAttribute(name);
          }
        ]]></body>
      </method>
    </implementation>
  </binding>
</bindings>