/[suikacvs]/webroot/www/style/text/width.xbl
Suika

Contents of /webroot/www/style/text/width.xbl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Wed Jun 29 01:39:49 2005 UTC (18 years, 10 months ago) by wakaba
Branch: MAIN
CVS Tags: HEAD
New

1 <!DOCTYPE bindings [
2 <!ENTITY NS_WIDTH "http://suika.fam.cx/www/style/text/wrap#">
3 ]>
4 <bindings xmlns="http://www.mozilla.org/xbl">
5 <binding id="halfwidth">
6 <implementation>
7 <constructor type="application/x-javascript" xml:space="preserve">
8 var targetNode = this;
9 window.addEventListener ('load', function () {
10 if (!targetNode.widthTransformed ()) {
11 targetNode.setAttributeNS
12 ('&NS_WIDTH;', 'width:widthTransformed', '1');
13 var resolver = document.createNSResolver (targetNode);
14 var nodes = document.evaluate (
15 'descendant::*/child::text () | child::text ()',
16 targetNode, resolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null
17 );
18 var pattern = targetNode.WidthPattern;
19 var table = targetNode.WidthTable;
20 for (var i = 0; i &lt; nodes.snapshotLength; i++) {
21 var node = nodes.snapshotItem (i);
22 node.data = node.data.replace (pattern, function (m) {
23 return table[m] || table['#fallback'] || m;
24 });
25 }
26 }
27 }, false);
28 </constructor>
29 <field name="WidthPattern">
30 /[\u3001\u3002\u300C\u300D\u309B\u309C\u30A0-\u30FF]/g;
31 </field>
32 <field name="WidthTable">
33 var a = {};
34 a['\u3001'] = '\uFF64'; // IDEOGRAPHIC COMMA
35 a['\u3002'] = '\uFF61'; // IDEOGRAPHIC FULL STOP
36 a['\u300C'] = '\uFF62'; // open kagi-kakko
37 a['\u300D'] = '\uFF63'; // close kagi-kakko
38 a['\u3099'] = '\uFF9E'; // combining voiced sound mark
39 a['\u309A'] = '\uFF9F'; // combining semi-voiced sound mark
40 a['\u309B'] = '\uFF9E'; // KATAKANA-HIRAGANA VOICED SOUND MARK
41 a['\u309C'] = '\uFF9F'; // semi-voiced sound mark
42 a['\u30A0'] = '='; // KATAKANA DOUBLE HYPHEN
43 a['\u30A1'] = '\uFF67'; // KATAKANA SMALL LETTER A
44 a['\u30A2'] = '\uFF71'; // KATAKANA LETTER A
45 a['\u30A3'] = '\uFF68';
46 a['\u30A4'] = '\uFF72';
47 a['\u30A5'] = '\uFF69';
48 a['\u30A6'] = '\uFF73';
49 a['\u30A7'] = '\uFF6A';
50 a['\u30A8'] = '\uFF74';
51 a['\u30A9'] = '\uFF6B';
52 a['\u30AA'] = '\uFF75';
53 a['\u30AB'] = '\uFF76'; // KATAKANA LETTER KA
54 a['\u30AC'] = '\uFF76\uFF9E';
55 a['\u30AD'] = '\uFF77';
56 a['\u30AE'] = '\uFF77\uFF9E';
57 a['\u30AF'] = '\uFF78';
58 a['\u30B0'] = '\uFF78\uFF9E';
59 a['\u30B1'] = '\uFF79';
60 a['\u30B2'] = '\uFF79\uFF9E';
61 a['\u30B3'] = '\uFF7A';
62 a['\u30B4'] = '\uFF7A\uFF9E';
63 a['\u30B5'] = '\uFF7B'; // KATAKANA LETTER SA
64 a['\u30B6'] = '\uFF7B\uFF9E';
65 a['\u30B7'] = '\uFF7C';
66 a['\u30B8'] = '\uFF7C\uFF9E';
67 a['\u30B9'] = '\uFF7D';
68 a['\u30BA'] = '\uFF7D\uFF9E';
69 a['\u30BB'] = '\uFF7E';
70 a['\u30BC'] = '\uFF7E\uFF9E';
71 a['\u30BD'] = '\uFF7F';
72 a['\u30BE'] = '\uFF7F\uFF9E';
73 a['\u30BF'] = '\uFF80'; // KATAKANA LETTER TA
74 a['\u30C0'] = '\uFF80\uFF9E';
75 a['\u30C1'] = '\uFF81';
76 a['\u30C2'] = '\uFF81\uFF9E';
77 a['\u30C3'] = '\uFF6F'; // KATAKANA SMALL LETTER TU
78 a['\u30C4'] = '\uFF82';
79 a['\u30C5'] = '\uFF82\uFF9E';
80 a['\u30C6'] = '\uFF83';
81 a['\u30C7'] = '\uFF83\uFF9E';
82 a['\u30C8'] = '\uFF84';
83 a['\u30C9'] = '\uFF84\uFF9E';
84 a['\u30CA'] = '\uFF85'; // KATAKANA LETTER NA
85 a['\u30CB'] = '\uFF86';
86 a['\u30CC'] = '\uFF87';
87 a['\u30CD'] = '\uFF88';
88 a['\u30CE'] = '\uFF89';
89 a['\u30CF'] = '\uFF8A'; // KATAKANA LETTER HA
90 a['\u30D0'] = '\uFF8A\uFF9E';
91 a['\u30D1'] = '\uFF8A\uFF9F';
92 a['\u30D2'] = '\uFF8B';
93 a['\u30D3'] = '\uFF8B\uFF9E';
94 a['\u30D4'] = '\uFF8B\uFF9F';
95 a['\u30D5'] = '\uFF8C';
96 a['\u30D6'] = '\uFF8C\uFF9E';
97 a['\u30D7'] = '\uFF8C\uFF9F';
98 a['\u30D8'] = '\uFF8D';
99 a['\u30D9'] = '\uFF8D\uFF9E';
100 a['\u30DA'] = '\uFF8D\uFF9F';
101 a['\u30DB'] = '\uFF8E';
102 a['\u30DC'] = '\uFF8E\uFF9E';
103 a['\u30DD'] = '\uFF8E\uFF9F';
104 a['\u30DE'] = '\uFF8F'; // KATAKANA LETTER MA
105 a['\u30DF'] = '\uFF90';
106 a['\u30E0'] = '\uFF91';
107 a['\u30E1'] = '\uFF92';
108 a['\u30E2'] = '\uFF93';
109 a['\u30E3'] = '\uFF6C'; // KATAKANA LETTER SMALL YA
110 a['\u30E4'] = '\uFF94'; // KATAKANA LETTER YA
111 a['\u30E5'] = '\uFF6D';
112 a['\u30E6'] = '\uFF95';
113 a['\u30E7'] = '\uFF6E';
114 a['\u30E8'] = '\uFF96';
115 a['\u30E9'] = '\uFF97'; // KATAKANA LETTER RA
116 a['\u30EA'] = '\uFF98';
117 a['\u30EB'] = '\uFF99';
118 a['\u30EC'] = '\uFF9A';
119 a['\u30ED'] = '\uFF9B';
120 // U+30EE KATAKANA LETTER SMALL WA
121 a['\u30EF'] = '\uFF9C'; // KATAKANA LETTER WA
122 a['\u30F2'] = '\uFF66'; // KATAKANA LETTER WO
123 a['\u30F3'] = '\uFF9D'; // KATAKANA LETTER N
124 a['\u30F4'] = '\uFF73\uFF9E'; // vu
125 // U+30F5 KATAKANA LETTER SMALL KA
126 // U+30F6 KATAKANA LETTER SMALL KE
127 a['\u30F7'] = '\uFF9C\uFF9E'; // va
128 // U+30F8 vi
129 // U+30F9 ve
130 a['\u30FA'] = '\uFF9D\uFF9E'; // vo
131 a['\u30FB'] = '\uFF65'; // KATAKANA MIDDLE DOT
132 a['\u30FC'] = '\uFF70'; // KATAKANA-HIRAGANA PROLONGED SOUND MARK
133 // U+30FD katakana ditto
134 // U+30FE katakana ditto + voiced
135 // U+30FF katakana koto
136 a;
137 </field>
138 <method name="widthTransformed">
139 <body>
140 if (this.getAttributeNS ('&NS_WIDTH;', 'widthTransformed')) {
141 return true;
142 }
143 var parents = new Array (this.parentNode);
144 while (parents.length > 0) {
145 var node = parents.shift ();
146 if (node.nodeType == node.ELEMENT_NODE &amp;&amp;
147 node.getAttributeNS ('&NS_WIDTH;', 'widthTransformed')) {
148 return true;
149 } else if (node.parentNode) {
150 parents.push (node.parentNode);
151 }
152 }
153 return false;
154 </body>
155 </method>
156 </implementation>
157 </binding>
158 <binding id="fullwidth" extends="#halfwidth">
159 <implementation>
160 <field name="WidthPattern">
161 /[\u0020-\u007F]/g;
162 </field>
163 <field name="WidthTable">
164 var a = {};
165 a['\u0020'] = '\u3000';
166 a['\u0021'] = '\uFF01';
167 a['\u0022'] = '\uFF02';
168 a['\u0023'] = '\uFF03';
169 a['\u0024'] = '\uFF04';
170 a['\u0025'] = '\uFF05';
171 a['\u0026'] = '\uFF06';
172 a['\u0027'] = '\uFF07';
173 a['\u0028'] = '\uFF08';
174 a['\u0029'] = '\uFF09';
175 a['\u002A'] = '\uFF0A';
176 a['\u002B'] = '\uFF0B';
177 a['\u002C'] = '\uFF0C';
178 a['\u002D'] = '\uFF0D';
179 a['\u002E'] = '\uFF0E';
180 a['\u002F'] = '\uFF0F';
181 a['\u0030'] = '\uFF10';
182 a['\u0031'] = '\uFF11';
183 a['\u0032'] = '\uFF12';
184 a['\u0033'] = '\uFF13';
185 a['\u0034'] = '\uFF14';
186 a['\u0035'] = '\uFF15';
187 a['\u0036'] = '\uFF16';
188 a['\u0037'] = '\uFF17';
189 a['\u0038'] = '\uFF18';
190 a['\u0039'] = '\uFF19';
191 a['\u003A'] = '\uFF1A';
192 a['\u003B'] = '\uFF1B';
193 a['\u003C'] = '\uFF1C';
194 a['\u003D'] = '\uFF1D';
195 a['\u003E'] = '\uFF1E';
196 a['\u003F'] = '\uFF1F';
197 a['\u0040'] = '\uFF20';
198 a['\u0041'] = '\uFF21';
199 a['\u0042'] = '\uFF22';
200 a['\u0043'] = '\uFF23';
201 a['\u0044'] = '\uFF24';
202 a['\u0045'] = '\uFF25';
203 a['\u0046'] = '\uFF26';
204 a['\u0047'] = '\uFF27';
205 a['\u0048'] = '\uFF28';
206 a['\u0049'] = '\uFF29';
207 a['\u004A'] = '\uFF2A';
208 a['\u004B'] = '\uFF2B';
209 a['\u004C'] = '\uFF2C';
210 a['\u004D'] = '\uFF2D';
211 a['\u004E'] = '\uFF2E';
212 a['\u004F'] = '\uFF2F';
213 a['\u0050'] = '\uFF30';
214 a['\u0051'] = '\uFF31';
215 a['\u0052'] = '\uFF32';
216 a['\u0053'] = '\uFF33';
217 a['\u0054'] = '\uFF34';
218 a['\u0055'] = '\uFF35';
219 a['\u0056'] = '\uFF36';
220 a['\u0057'] = '\uFF37';
221 a['\u0058'] = '\uFF38';
222 a['\u0059'] = '\uFF39';
223 a['\u005A'] = '\uFF3A';
224 a['\u005B'] = '\uFF3B';
225 a['\u005C'] = '\uFF3C';
226 a['\u005D'] = '\uFF3D';
227 a['\u005E'] = '\uFF3E';
228 a['\u005F'] = '\uFF3F';
229 a['\u0060'] = '\uFF40';
230 a['\u0061'] = '\uFF41';
231 a['\u0062'] = '\uFF42';
232 a['\u0063'] = '\uFF43';
233 a['\u0064'] = '\uFF44';
234 a['\u0065'] = '\uFF45';
235 a['\u0066'] = '\uFF46';
236 a['\u0067'] = '\uFF47';
237 a['\u0068'] = '\uFF48';
238 a['\u0069'] = '\uFF49';
239 a['\u006A'] = '\uFF4A';
240 a['\u006B'] = '\uFF4B';
241 a['\u006C'] = '\uFF4C';
242 a['\u006D'] = '\uFF4D';
243 a['\u006E'] = '\uFF4E';
244 a['\u006F'] = '\uFF4F';
245 a['\u0070'] = '\uFF50';
246 a['\u0071'] = '\uFF51';
247 a['\u0072'] = '\uFF52';
248 a['\u0073'] = '\uFF53';
249 a['\u0074'] = '\uFF54';
250 a['\u0075'] = '\uFF55';
251 a['\u0076'] = '\uFF56';
252 a['\u0077'] = '\uFF57';
253 a['\u0078'] = '\uFF58';
254 a['\u0079'] = '\uFF59';
255 a['\u007A'] = '\uFF5A';
256 a['\u007B'] = '\uFF5B';
257 a['\u007C'] = '\uFF5C';
258 a['\u007D'] = '\uFF5D';
259 // U+007E TILDE
260 a;
261 </field>
262 </implementation>
263 </binding>
264 </bindings>
265 <!-- ***** BEGIN LICENSE BLOCK *****
266 - Version: MPL 1.1/GPL 2.0/LGPL 2.1
267 -
268 - The contents of this file are subject to the Mozilla Public License Version
269 - 1.1 (the "License"); you may not use this file except in compliance with
270 - the License. You may obtain a copy of the License at
271 - <http://www.mozilla.org/MPL/>
272 -
273 - Software distributed under the License is distributed on an "AS IS" basis,
274 - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
275 - for the specific language governing rights and limitations under the
276 - License.
277 -
278 - The Original Code is wrap.xbl code.
279 -
280 - The Initial Developer of the Original Code is Wakaba.
281 - Portions created by the Initial Developer are Copyright (C) 2005
282 - the Initial Developer. All Rights Reserved.
283 -
284 - Contributor(s):
285 - Wakaba <w@suika.fam.cx>
286 -
287 - Alternatively, the contents of this file may be used under the terms of
288 - either the GNU General Public License Version 2 or later (the "GPL"), or
289 - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
290 - in which case the provisions of the GPL or the LGPL are applicable instead
291 - of those above. If you wish to allow use of your version of this file only
292 - under the terms of either the GPL or the LGPL, and not to allow others to
293 - use your version of this file under the terms of the MPL, indicate your
294 - decision by deleting the provisions above and replace them with the notice
295 - and other provisions required by the LGPL or the GPL. If you do not delete
296 - the provisions above, a recipient may use your version of this file under
297 - the terms of any one of the MPL, the GPL or the LGPL.
298 -
299 - ***** END LICENSE BLOCK ***** -->

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24