1 diff -Nuar xulrunner-1.8.0.7/allmakefiles.sh xulrunner-1.8.0.7-mozlibthai/allmakefiles.sh
2 --- xulrunner-1.8.0.7/allmakefiles.sh 2006-10-07 14:18:07.000000000 +0700
3 +++ xulrunner-1.8.0.7-mozlibthai/allmakefiles.sh 2006-10-07 14:25:31.000000000 +0700
5 intl/locale/src/windows/Makefile
6 intl/locale/tests/Makefile
8 +intl/lwbrk/components/Makefile
9 +intl/lwbrk/components/libthai/Makefile
10 intl/lwbrk/src/Makefile
11 intl/lwbrk/public/Makefile
12 intl/lwbrk/tests/Makefile
13 diff -Nuar xulrunner-1.8.0.7/config/autoconf.mk.in xulrunner-1.8.0.7-mozlibthai/config/autoconf.mk.in
14 --- xulrunner-1.8.0.7/config/autoconf.mk.in 2006-10-07 14:19:38.000000000 +0700
15 +++ xulrunner-1.8.0.7-mozlibthai/config/autoconf.mk.in 2006-10-07 14:25:31.000000000 +0700
17 ENABLE_TESTS = @ENABLE_TESTS@
20 +MOZ_ENABLE_LIBTHAI_COMPONENT = @MOZ_ENABLE_LIBTHAI_COMPONENT@
21 +MOZ_LIBTHAI_CFLAGS = @MOZ_LIBTHAI_CFLAGS@
22 +MOZ_LIBTHAI_LIBS = @MOZ_LIBTHAI_LIBS@
23 ACCESSIBILITY = @ACCESSIBILITY@
24 MOZ_VIEW_SOURCE = @MOZ_VIEW_SOURCE@
25 MOZ_XPINSTALL = @MOZ_XPINSTALL@
26 diff -Nuar xulrunner-1.8.0.7/configure.in xulrunner-1.8.0.7-mozlibthai/configure.in
27 --- xulrunner-1.8.0.7/configure.in 2006-10-07 14:18:57.000000000 +0700
28 +++ xulrunner-1.8.0.7-mozlibthai/configure.in 2006-10-07 14:25:31.000000000 +0700
29 @@ -4634,6 +4634,23 @@
32 dnl ========================================================
33 +dnl mozlibthai word break component,
34 +dnl built on libthai existence
35 +dnl ========================================================
36 +MOZ_ENABLE_LIBTHAI_COMPONENT=
37 +MOZ_ARG_DISABLE_BOOL(libthai,
38 +[ --disable-libthai Disable Thai word break support with libthai],
39 + MOZ_ENABLE_LIBTHAI_COMPONENT=,
40 + MOZ_ENABLE_LIBTHAI_COMPONENT=1)
41 +if test "$MOZ_ENABLE_LIBTHAI_COMPONENT"; then
42 + PKG_CHECK_MODULES(MOZ_LIBTHAI, libthai,[
43 + MOZ_ENABLE_LIBTHAI_COMPONENT=1
45 + MOZ_ENABLE_LIBTHAI_COMPONENT=
49 +dnl ========================================================
50 dnl view source support on by default
51 dnl ========================================================
52 MOZ_ARG_DISABLE_BOOL(view-source,
54 AC_SUBST(ENABLE_TESTS)
57 +AC_SUBST(MOZ_ENABLE_LIBTHAI_COMPONENT)
58 AC_SUBST(ACCESSIBILITY)
59 AC_SUBST(MOZ_XPINSTALL)
60 AC_SUBST(MOZ_VIEW_SOURCE)
61 diff -Nuar xulrunner-1.8.0.7/intl/lwbrk/components/libthai/Makefile.in xulrunner-1.8.0.7-mozlibthai/intl/lwbrk/components/libthai/Makefile.in
62 --- xulrunner-1.8.0.7/intl/lwbrk/components/libthai/Makefile.in 1970-01-01 07:00:00.000000000 +0700
63 +++ xulrunner-1.8.0.7-mozlibthai/intl/lwbrk/components/libthai/Makefile.in 2006-10-07 14:28:10.000000000 +0700
65 +# ***** BEGIN LICENSE BLOCK *****
66 +# Version: MPL 1.1/GPL 2.0/LGPL 2.1
68 +# The contents of this file are subject to the Mozilla Public License Version
69 +# 1.1 (the "License"); you may not use this file except in compliance with
70 +# the License. You may obtain a copy of the License at
71 +# http://www.mozilla.org/MPL/
73 +# Software distributed under the License is distributed on an "AS IS" basis,
74 +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
75 +# for the specific language governing rights and limitations under the
78 +# The Original Code is the Mozilla GNOME integration code.
80 +# The Initial Developer of the Original Code is
82 +# Portions created by the Initial Developer are Copyright (C) 2004
83 +# the Initial Developer. All Rights Reserved.
87 +# Alternatively, the contents of this file may be used under the terms of
88 +# either the GNU General Public License Version 2 or later (the "GPL"), or
89 +# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
90 +# in which case the provisions of the GPL or the LGPL are applicable instead
91 +# of those above. If you wish to allow use of your version of this file only
92 +# under the terms of either the GPL or the LGPL, and not to allow others to
93 +# use your version of this file under the terms of the MPL, indicate your
94 +# decision by deleting the provisions above and replace them with the notice
95 +# and other provisions required by the GPL or the LGPL. If you do not delete
96 +# the provisions above, a recipient may use your version of this file under
97 +# the terms of any one of the MPL, the GPL or the LGPL.
99 +# ***** END LICENSE BLOCK *****
102 +topsrcdir = @top_srcdir@
106 +include $(DEPTH)/config/autoconf.mk
111 + nsIThaiLineBreaker.idl \
114 +ifeq ($(MOZ_ENABLE_LIBTHAI_COMPONENT), 1)
116 +LIBRARY_NAME = mozlibthai
117 +FORCE_SHARED_LIB = 1
126 + nsLibThaiLineBreaker.cpp \
127 + nsLibThaiModule.cpp \
130 +CXXFLAGS += $(MOZ_LIBTHAI_CFLAGS)
131 +EXTRA_DSO_LDOPTS += \
132 + $(XPCOM_STANDARD_GLUE_LDOPTS) \
134 + $(MOZ_LIBTHAI_LIBS) \
139 +include $(topsrcdir)/config/rules.mk
141 diff -Nuar xulrunner-1.8.0.7/intl/lwbrk/components/libthai/nsIThaiLineBreaker.idl xulrunner-1.8.0.7-mozlibthai/intl/lwbrk/components/libthai/nsIThaiLineBreaker.idl
142 --- xulrunner-1.8.0.7/intl/lwbrk/components/libthai/nsIThaiLineBreaker.idl 1970-01-01 07:00:00.000000000 +0700
143 +++ xulrunner-1.8.0.7-mozlibthai/intl/lwbrk/components/libthai/nsIThaiLineBreaker.idl 2006-10-07 14:28:10.000000000 +0700
145 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
146 +/* ***** BEGIN LICENSE BLOCK *****
147 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1
149 + * The contents of this file are subject to the Mozilla Public License Version
150 + * 1.1 (the "License"); you may not use this file except in compliance with
151 + * the License. You may obtain a copy of the License at
152 + * http://www.mozilla.org/MPL/
154 + * Software distributed under the License is distributed on an "AS IS" basis,
155 + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
156 + * for the specific language governing rights and limitations under the
159 + * The Original Code is mozilla.org code.
161 + * The Initial Developer of the Original Code is
162 + * Netscape Communications Corporation.
163 + * Portions created by the Initial Developer are Copyright (C) 1998
164 + * the Initial Developer. All Rights Reserved.
167 + * Theppitak Karoonboonyanan <thep@linux.thai.net>
169 + * Alternatively, the contents of this file may be used under the terms of
170 + * either of the GNU General Public License Version 2 or later (the "GPL"),
171 + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
172 + * in which case the provisions of the GPL or the LGPL are applicable instead
173 + * of those above. If you wish to allow use of your version of this file only
174 + * under the terms of either the GPL or the LGPL, and not to allow others to
175 + * use your version of this file under the terms of the MPL, indicate your
176 + * decision by deleting the provisions above and replace them with the notice
177 + * and other provisions required by the GPL or the LGPL. If you do not delete
178 + * the provisions above, a recipient may use your version of this file under
179 + * the terms of any one of the MPL, the GPL or the LGPL.
181 + * ***** END LICENSE BLOCK ***** */
183 +#include "nsISupports.idl"
186 +// {5E1CD5F3-C757-45A5-BDA2-60D530236473}
187 +#define NS_THAILINEBREAKER_CID { 0x5e1cd5f3, 0xc757, 0x45a5, { 0xbd, 0xa2, 0x60, 0xd5, 0x30, 0x23, 0x64, 0x73}}
188 +#define NS_THAILINEBREAKER_CONTRACTID "@mozilla.org/intl/thailinebreaker;1"
192 + * Provides Thai line breaker
194 +[scriptable, uuid(5e1cd5f3-c757-45a5-bda2-60d530236473)]
195 +interface nsIThaiLineBreaker : nsISupports {
196 + boolean breakInBetween (in wstring aText1, in unsigned long aTextLen1,
197 + in wstring aText2, in unsigned long aTextLen2);
199 + void next (in wstring aText, in unsigned long aLen, in unsigned long aPos,
200 + out unsigned long pos, out boolean needMoreText);
202 + void prev (in wstring aText, in unsigned long aLen, in unsigned long aPos,
203 + out unsigned long pos, out boolean needMoreText);
206 diff -Nuar xulrunner-1.8.0.7/intl/lwbrk/components/libthai/nsLibThaiLineBreaker.cpp xulrunner-1.8.0.7-mozlibthai/intl/lwbrk/components/libthai/nsLibThaiLineBreaker.cpp
207 --- xulrunner-1.8.0.7/intl/lwbrk/components/libthai/nsLibThaiLineBreaker.cpp 1970-01-01 07:00:00.000000000 +0700
208 +++ xulrunner-1.8.0.7-mozlibthai/intl/lwbrk/components/libthai/nsLibThaiLineBreaker.cpp 2006-10-07 14:28:10.000000000 +0700
210 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
211 +/* ***** BEGIN LICENSE BLOCK *****
212 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1
214 + * The contents of this file are subject to the Mozilla Public License Version
215 + * 1.1 (the "License"); you may not use this file except in compliance with
216 + * the License. You may obtain a copy of the License at
217 + * http://www.mozilla.org/MPL/
219 + * Software distributed under the License is distributed on an "AS IS" basis,
220 + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
221 + * for the specific language governing rights and limitations under the
224 + * The Original Code is mozilla.org code.
226 + * The Initial Developer of the Original Code is
227 + * Netscape Communications Corporation.
228 + * Portions created by the Initial Developer are Copyright (C) 1998
229 + * the Initial Developer. All Rights Reserved.
232 + * - Theppitak Karoonboonyanan <thep@linux.thai.net>
234 + * Alternatively, the contents of this file may be used under the terms of
235 + * either of the GNU General Public License Version 2 or later (the "GPL"),
236 + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
237 + * in which case the provisions of the GPL or the LGPL are applicable instead
238 + * of those above. If you wish to allow use of your version of this file only
239 + * under the terms of either the GPL or the LGPL, and not to allow others to
240 + * use your version of this file under the terms of the MPL, indicate your
241 + * decision by deleting the provisions above and replace them with the notice
242 + * and other provisions required by the GPL or the LGPL. If you do not delete
243 + * the provisions above, a recipient may use your version of this file under
244 + * the terms of any one of the MPL, the GPL or the LGPL.
246 + * ***** END LICENSE BLOCK ***** */
248 +#include <thai/thbrk.h>
249 +#include <thai/thwchar.h>
251 +#include "nsLibThaiLineBreaker.h"
254 +//// class BreakEntry implementation ////
256 +void BreakEntry::Set (const PRUnichar* pText, PRUint32 textLen,
257 + int* pvPos, int posLen)
261 + mText = new PRUnichar [textLen+1];
262 + for (PRUnichar i = 0; i < textLen; i++)
263 + mText[i] = pText[i];
264 + mText[textLen] = 0;
265 + mTextLen = textLen;
267 + mPos = new int [posLen];
268 + for (int j = 0; j < posLen; j++)
269 + mPos[j] = pvPos[j];
273 +//// class BreakCache implementation ////
275 +static PRUint16 StringHash (const PRUnichar* pText, PRUint32 textLen)
278 + for (PRUint32 i = 0; i < textLen; i++) {
279 + h = (h >> 12) ^ (h << 4) ^ pText[i];
284 +BreakEntry& BreakCache::LookUp (const PRUnichar* pText, PRUint32 textLen)
286 + return mvBucket [StringHash (pText, textLen) % N_BUCKETS];
290 +//// class nsLibThaiLineBreaker implementation ////
292 +static thchar_t* GetTISText (const PRUnichar* pText, PRUint32 textLen)
294 + thchar_t* pTISText = new thchar_t [textLen + 1];
296 + for (i = 0; i < textLen; i++)
297 + pTISText[i] = th_uni2tis (pText[i]);
298 + pTISText[i] = '\0';
303 +static void FreeTISText (thchar_t* pTISText)
308 +static PRBool IsStrEqual (const PRUnichar* pText1, PRUint32 len1,
309 + const PRUnichar* pText2, PRUint32 len2)
314 + for (PRUint32 i = 0; i < len1; ++i)
315 + if (pText1[i] != pText2[i])
321 +int nsLibThaiLineBreaker::GetBreaks (
322 + const PRUnichar* pText, PRUint32 textLen, int vPos[], int nPos)
324 + // Call the expensive th_brk() only if uncached
325 + BreakEntry& breakEntry = mBreakCache.LookUp (pText, textLen);
326 + if (!IsStrEqual (breakEntry.Text(), breakEntry.TextLength(), pText, textLen))
328 + thchar_t* pTISText = GetTISText (pText, textLen);
329 + int* pBreaks = new int [nPos];
330 + int nBreaks = th_brk (pTISText, pBreaks, nPos);
331 + FreeTISText (pTISText);
333 + breakEntry.Set (pText, textLen, pBreaks, nBreaks);
337 + for (int i = 0; i < breakEntry.PosLength(); ++i)
338 + vPos [i] = breakEntry.Pos (i);
339 + return breakEntry.PosLength();
342 +NS_IMPL_ISUPPORTS1 (nsLibThaiLineBreaker, nsIThaiLineBreaker)
345 +NS_IMETHODIMP nsLibThaiLineBreaker::BreakInBetween(
346 + const PRUnichar* aText1 , PRUint32 aTextLen1,
347 + const PRUnichar* aText2 , PRUint32 aTextLen2,
350 + if (!aText1 || !aText2 || (0 == aTextLen1) || (0 == aTextLen2))
352 + *oCanBreak = PR_FALSE;
356 + PRBool result = PR_FALSE;
358 + PRUnichar *pConcat = new PRUnichar [aTextLen1 + aTextLen2];
359 + for (PRUint32 i = 0; i < aTextLen1; i++)
360 + pConcat[i] = aText1[i];
361 + for (PRUint32 i = 0; i < aTextLen2; i++)
362 + pConcat[aTextLen1 + i] = aText2[i];
364 + int* pBreaks = new int [aTextLen1 + aTextLen2 + 1];
365 + int nBreaks = GetBreaks (pConcat, aTextLen1 + aTextLen2,
366 + pBreaks, int (aTextLen1 + aTextLen2 + 1));
367 + for (int i = 0; i < nBreaks; i++) {
368 + if (PRUint32 (pBreaks[i]) == aTextLen1) {
377 + *oCanBreak = result;
382 +NS_IMETHODIMP nsLibThaiLineBreaker::Next(
383 + const PRUnichar* aText, PRUint32 aLen, PRUint32 aPos,
384 + PRUint32* oNext, PRBool* oNeedMoreText)
386 + NS_ASSERTION(aText, "aText shouldn't be null");
387 + NS_ASSERTION(aLen > aPos, "Illegal value (length > position)");
389 + *oNeedMoreText = PR_TRUE;
392 + int* pBreaks = new int [aLen + 1];
393 + int nBreaks = GetBreaks (aText, aLen, pBreaks, int (aLen + 1));
394 + for (int i = 0; i < nBreaks; i++) {
395 + if (PRUint32 (pBreaks[i]) > aPos) {
396 + *oNext = pBreaks[i];
397 + *oNeedMoreText = PR_FALSE;
407 +NS_IMETHODIMP nsLibThaiLineBreaker::Prev(
408 + const PRUnichar* aText, PRUint32 aLen, PRUint32 aPos,
409 + PRUint32* oPrev, PRBool* oNeedMoreText)
411 + NS_ASSERTION(aText, "aText shouldn't be null");
412 + NS_ASSERTION(aLen > aPos, "Illegal value (length > position)");
414 + *oNeedMoreText = PR_TRUE;
417 + int* pBreaks = new int [aLen + 1];
418 + int nBreaks = GetBreaks (aText, aLen, pBreaks, int (aLen + 1));
419 + for (int i = nBreaks - 1; i >= 0; i--) {
420 + if (PRUint32 (pBreaks[i]) < aPos) {
421 + *oPrev = pBreaks[i];
422 + *oNeedMoreText = PR_FALSE;
431 diff -Nuar xulrunner-1.8.0.7/intl/lwbrk/components/libthai/nsLibThaiLineBreaker.h xulrunner-1.8.0.7-mozlibthai/intl/lwbrk/components/libthai/nsLibThaiLineBreaker.h
432 --- xulrunner-1.8.0.7/intl/lwbrk/components/libthai/nsLibThaiLineBreaker.h 1970-01-01 07:00:00.000000000 +0700
433 +++ xulrunner-1.8.0.7-mozlibthai/intl/lwbrk/components/libthai/nsLibThaiLineBreaker.h 2006-10-07 14:28:10.000000000 +0700
435 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
436 +/* ***** BEGIN LICENSE BLOCK *****
437 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1
439 + * The contents of this file are subject to the Mozilla Public License Version
440 + * 1.1 (the "License"); you may not use this file except in compliance with
441 + * the License. You may obtain a copy of the License at
442 + * http://www.mozilla.org/MPL/
444 + * Software distributed under the License is distributed on an "AS IS" basis,
445 + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
446 + * for the specific language governing rights and limitations under the
449 + * The Original Code is mozilla.org code.
451 + * The Initial Developer of the Original Code is
452 + * Netscape Communications Corporation.
453 + * Portions created by the Initial Developer are Copyright (C) 1998
454 + * the Initial Developer. All Rights Reserved.
457 + * - Theppitak Karoonboonyanan <thep@linux.thai.net>
459 + * Alternatively, the contents of this file may be used under the terms of
460 + * either of the GNU General Public License Version 2 or later (the "GPL"),
461 + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
462 + * in which case the provisions of the GPL or the LGPL are applicable instead
463 + * of those above. If you wish to allow use of your version of this file only
464 + * under the terms of either the GPL or the LGPL, and not to allow others to
465 + * use your version of this file under the terms of the MPL, indicate your
466 + * decision by deleting the provisions above and replace them with the notice
467 + * and other provisions required by the GPL or the LGPL. If you do not delete
468 + * the provisions above, a recipient may use your version of this file under
469 + * the terms of any one of the MPL, the GPL or the LGPL.
471 + * ***** END LICENSE BLOCK ***** */
473 +#ifndef nsLibThaiLineBreaker_h__
474 +#define nsLibThaiLineBreaker_h__
476 +#include "nsIThaiLineBreaker.h"
479 + * Break Positions Info Entry
486 + void Set (const PRUnichar* pText, PRUint32 textLen, int* pvPos, int posLen);
488 + const PRUnichar* Text() const;
489 + PRUint32 TextLength() const;
490 + int Pos(int index) const;
491 + int PosLength() const;
503 +inline BreakEntry::BreakEntry()
504 + : mText (nsnull), mTextLen (0), mPos (nsnull), mPosLen (0)
508 +inline BreakEntry::~BreakEntry()
513 +inline void BreakEntry::Clear()
521 +inline const PRUnichar* BreakEntry::Text() const
526 +inline PRUint32 BreakEntry::TextLength() const
531 +inline int BreakEntry::Pos (int index) const
533 + return (mPos && index < mPosLen) ? mPos[index] : -1;
536 +inline int BreakEntry::PosLength() const
543 + * Break Positions Info Cache
548 + BreakEntry& LookUp (const PRUnichar* pText, PRUint32 textLen);
551 + enum { N_BUCKETS = 19 };
552 + BreakEntry mvBucket[N_BUCKETS];
557 + * Thai Line Breaker using LibThai
559 +class nsLibThaiLineBreaker : public nsIThaiLineBreaker
564 + NS_IMETHOD BreakInBetween (const PRUnichar* aText1 , PRUint32 aTextLen1,
565 + const PRUnichar* aText2 , PRUint32 aTextLen2,
566 + PRBool* oCanBreak);
568 + NS_IMETHOD Next (const PRUnichar* aText, PRUint32 aLen, PRUint32 aPos,
569 + PRUint32* oNext, PRBool* oNeedMoreText);
571 + NS_IMETHOD Prev (const PRUnichar* aText, PRUint32 aLen, PRUint32 aPos,
572 + PRUint32* oPrev, PRBool* oNeedMoreText);
575 + int GetBreaks (const PRUnichar* pText, PRUint32 textLen,
576 + int vPos[], int nPos);
579 + BreakCache mBreakCache;
582 +#endif /* nsLibThaiLineBreaker_h__ */
583 diff -Nuar xulrunner-1.8.0.7/intl/lwbrk/components/libthai/nsLibThaiModule.cpp xulrunner-1.8.0.7-mozlibthai/intl/lwbrk/components/libthai/nsLibThaiModule.cpp
584 --- xulrunner-1.8.0.7/intl/lwbrk/components/libthai/nsLibThaiModule.cpp 1970-01-01 07:00:00.000000000 +0700
585 +++ xulrunner-1.8.0.7-mozlibthai/intl/lwbrk/components/libthai/nsLibThaiModule.cpp 2006-10-07 14:28:10.000000000 +0700
587 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
588 +/* ***** BEGIN LICENSE BLOCK *****
589 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1
591 + * The contents of this file are subject to the Mozilla Public License Version
592 + * 1.1 (the "License"); you may not use this file except in compliance with
593 + * the License. You may obtain a copy of the License at
594 + * http://www.mozilla.org/MPL/
596 + * Software distributed under the License is distributed on an "AS IS" basis,
597 + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
598 + * for the specific language governing rights and limitations under the
601 + * The Original Code is the Mozilla GNOME integration code.
603 + * The Initial Developer of the Original Code is
605 + * Portions created by the Initial Developer are Copyright (C) 2004
606 + * the Initial Developer. All Rights Reserved.
609 + * Theppitak Karoonboonyanan <thep@linux.thai.net>
611 + * Alternatively, the contents of this file may be used under the terms of
612 + * either the GNU General Public License Version 2 or later (the "GPL"), or
613 + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
614 + * in which case the provisions of the GPL or the LGPL are applicable instead
615 + * of those above. If you wish to allow use of your version of this file only
616 + * under the terms of either the GPL or the LGPL, and not to allow others to
617 + * use your version of this file under the terms of the MPL, indicate your
618 + * decision by deleting the provisions above and replace them with the notice
619 + * and other provisions required by the GPL or the LGPL. If you do not delete
620 + * the provisions above, a recipient may use your version of this file under
621 + * the terms of any one of the MPL, the GPL or the LGPL.
623 + * ***** END LICENSE BLOCK ***** */
625 +#include "nsLibThaiLineBreaker.h"
626 +#include "nsIGenericFactory.h"
628 +NS_GENERIC_FACTORY_CONSTRUCTOR(nsLibThaiLineBreaker)
630 +static const nsModuleComponentInfo components[] = {
631 + { "LibThai Line Breaker",
632 + NS_THAILINEBREAKER_CID,
633 + NS_THAILINEBREAKER_CONTRACTID,
634 + nsLibThaiLineBreakerConstructor }
637 +NS_IMPL_NSGETMODULE(mozlibthai, components)
639 diff -Nuar xulrunner-1.8.0.7/intl/lwbrk/components/Makefile.in xulrunner-1.8.0.7-mozlibthai/intl/lwbrk/components/Makefile.in
640 --- xulrunner-1.8.0.7/intl/lwbrk/components/Makefile.in 1970-01-01 07:00:00.000000000 +0700
641 +++ xulrunner-1.8.0.7-mozlibthai/intl/lwbrk/components/Makefile.in 2006-10-07 14:28:10.000000000 +0700
644 +# ***** BEGIN LICENSE BLOCK *****
645 +# Version: MPL 1.1/GPL 2.0/LGPL 2.1
647 +# The contents of this file are subject to the Mozilla Public License Version
648 +# 1.1 (the "License"); you may not use this file except in compliance with
649 +# the License. You may obtain a copy of the License at
650 +# http://www.mozilla.org/MPL/
652 +# Software distributed under the License is distributed on an "AS IS" basis,
653 +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
654 +# for the specific language governing rights and limitations under the
657 +# The Original Code is mozilla.org code.
659 +# The Initial Developer of the Original Code is
660 +# Netscape Communications Corporation.
661 +# Portions created by the Initial Developer are Copyright (C) 1998
662 +# the Initial Developer. All Rights Reserved.
666 +# Alternatively, the contents of this file may be used under the terms of
667 +# either of the GNU General Public License Version 2 or later (the "GPL"),
668 +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
669 +# in which case the provisions of the GPL or the LGPL are applicable instead
670 +# of those above. If you wish to allow use of your version of this file only
671 +# under the terms of either the GPL or the LGPL, and not to allow others to
672 +# use your version of this file under the terms of the MPL, indicate your
673 +# decision by deleting the provisions above and replace them with the notice
674 +# and other provisions required by the GPL or the LGPL. If you do not delete
675 +# the provisions above, a recipient may use your version of this file under
676 +# the terms of any one of the MPL, the GPL or the LGPL.
678 +# ***** END LICENSE BLOCK *****
681 +topsrcdir = @top_srcdir@
685 +include $(DEPTH)/config/autoconf.mk
689 +include $(topsrcdir)/config/rules.mk
691 diff -Nuar xulrunner-1.8.0.7/intl/lwbrk/Makefile.in xulrunner-1.8.0.7-mozlibthai/intl/lwbrk/Makefile.in
692 --- xulrunner-1.8.0.7/intl/lwbrk/Makefile.in 2006-10-07 14:20:53.000000000 +0700
693 +++ xulrunner-1.8.0.7-mozlibthai/intl/lwbrk/Makefile.in 2006-10-07 14:25:31.000000000 +0700
695 include $(DEPTH)/config/autoconf.mk
698 -DIRS = idl public src
699 +DIRS = idl public src components
703 diff -Nuar xulrunner-1.8.0.7/intl/lwbrk/src/Makefile.in xulrunner-1.8.0.7-mozlibthai/intl/lwbrk/src/Makefile.in
704 --- xulrunner-1.8.0.7/intl/lwbrk/src/Makefile.in 2006-10-07 14:21:55.000000000 +0700
705 +++ xulrunner-1.8.0.7-mozlibthai/intl/lwbrk/src/Makefile.in 2006-10-07 14:25:31.000000000 +0700
714 diff -Nuar xulrunner-1.8.0.7/intl/lwbrk/src/nsJISx4501LineBreaker.cpp xulrunner-1.8.0.7-mozlibthai/intl/lwbrk/src/nsJISx4501LineBreaker.cpp
715 --- xulrunner-1.8.0.7/intl/lwbrk/src/nsJISx4501LineBreaker.cpp 2006-10-07 14:22:43.000000000 +0700
716 +++ xulrunner-1.8.0.7-mozlibthai/intl/lwbrk/src/nsJISx4501LineBreaker.cpp 2006-10-07 14:25:31.000000000 +0700
719 #include "nsUnicharUtils.h"
721 +#include "nsIServiceManager.h"
729 +IS_THAI(PRUnichar u)
731 + return (0x0e01 <= (u) && (u) <= 0x0e5b);
735 IS_SPACE(PRUnichar u)
737 return ((u) == 0x0020 || (u) == 0x0009 || (u) == 0x000a || (u) == 0x000d || (u)==0x200b);
740 c = GETCLASSFROMTABLE(gLBClass00, l);
742 - else if(th_isthai(u))
743 + else if(IS_THAI(u))
747 @@ -342,11 +349,17 @@
748 return (0 == ((gPair[c1] >> c2 ) & 0x0001));
751 +nsCOMPtr<nsIThaiLineBreaker> nsJISx4051LineBreaker::GetThaiLineBreaker()
753 + if (!mThaiLineBreaker)
754 + mThaiLineBreaker = do_GetService (NS_THAILINEBREAKER_CONTRACTID);
755 + return mThaiLineBreaker;
758 nsJISx4051LineBreaker::nsJISx4051LineBreaker(
759 const PRUnichar* aNoBegin, PRInt32 aNoBeginLen,
760 const PRUnichar* aNoEnd, PRInt32 aNoEndLen
762 +) : mThaiLineBreaker(nsnull)
768 if (IS_SPACE(aText1[cur]))
770 - if (IS_CJK_CHAR(aText1[cur]))
771 + if (IS_CJK_CHAR(aText1[cur]) || IS_THAI(aText1[cur]))
772 goto ROUTE_CJK_BETWEEN;
777 if (IS_SPACE(aText2[cur]))
779 - if (IS_CJK_CHAR(aText2[cur]))
780 + if (IS_CJK_CHAR(aText2[cur]) || IS_THAI(aText2[cur]))
781 goto ROUTE_CJK_BETWEEN;
785 /* Handle cases for THAI */
786 if((CLASS_THAI == c1) && (CLASS_THAI == c2))
788 - *oCanBreak = (0 == TrbWordBreakPos(aText1, aTextLen1, aText2, aTextLen2));
789 + nsCOMPtr<nsIThaiLineBreaker> pThaiLineBreaker = GetThaiLineBreaker();
790 + if (pThaiLineBreaker)
791 + return pThaiLineBreaker->BreakInBetween(aText1, aTextLen1,
792 + aText2, aTextLen2, oCanBreak);
794 + *oCanBreak = (0 == TrbWordBreakPos(aText1, aTextLen1, aText2, aTextLen2));
799 *oNeedMoreText = PR_FALSE;
802 - if (IS_CJK_CHAR(aText[cur]))
803 + if (IS_CJK_CHAR(aText[cur]) || IS_THAI(aText[cur]))
811 - *oNext = PRUint32(TrbFollowing(aText, aLen, aPos));
812 - *oNeedMoreText = PR_FALSE;
814 + nsCOMPtr<nsIThaiLineBreaker> pThaiLineBreaker = GetThaiLineBreaker();
815 + if (pThaiLineBreaker) {
816 + return pThaiLineBreaker->Next(aText, aLen, aPos, oNext, oNeedMoreText);
818 + *oNext = PRUint32(TrbFollowing(aText, aLen, aPos));
819 + *oNeedMoreText = PR_FALSE;
824 for(cur++; cur <aLen; cur++)
826 *oNeedMoreText = PR_FALSE;
829 - if (IS_CJK_CHAR(aText[cur]))
830 + if (IS_CJK_CHAR(aText[cur]) || IS_THAI(aText[cur]))
834 @@ -582,10 +605,26 @@
836 c2 = this->GetClass(aText[cur-1]);
840 - // Should handle CLASS_THAI here
843 + if(CLASS_THAI == c2)
845 + nsCOMPtr<nsIThaiLineBreaker> pThaiLineBreaker = GetThaiLineBreaker();
846 + if (pThaiLineBreaker) {
847 + return pThaiLineBreaker->Prev(aText, aLen, aPos, oPrev, oNeedMoreText);
849 + // TODO: do some fallback analysis instead
850 + for (aPos--; aPos > 0; aPos--) {
851 + if (!IS_THAI(aText[aPos])) {
853 + *oNeedMoreText = PR_FALSE;
857 + *oNeedMoreText = PR_TRUE;
862 for(cur--; cur > 0; cur--)
864 if(NEED_CONTEXTUAL_ANALYSIS(aText[cur-1]))
865 diff -Nuar xulrunner-1.8.0.7/intl/lwbrk/src/nsJISx4501LineBreaker.h xulrunner-1.8.0.7-mozlibthai/intl/lwbrk/src/nsJISx4501LineBreaker.h
866 --- xulrunner-1.8.0.7/intl/lwbrk/src/nsJISx4501LineBreaker.h 2006-10-07 14:23:18.000000000 +0700
867 +++ xulrunner-1.8.0.7-mozlibthai/intl/lwbrk/src/nsJISx4501LineBreaker.h 2006-10-07 14:25:31.000000000 +0700
870 #include "nsILineBreaker.h"
872 +#include "nsCOMPtr.h"
873 +#include "nsIThaiLineBreaker.h"
875 class nsJISx4051LineBreaker : public nsILineBreaker
879 PRInt8 ContextualAnalysis(PRUnichar prev, PRUnichar cur, PRUnichar next );
880 PRBool GetPair(PRInt8 c1, PRInt8 c2);
882 + nsCOMPtr<nsIThaiLineBreaker> GetThaiLineBreaker();
885 + nsCOMPtr<nsIThaiLineBreaker> mThaiLineBreaker;
888 #endif /* nsJISx4501LineBreaker_h__ */