Contents of /trunk/mozilla-firefox/patches/mozilla-firefox-1.0.7-pango-bidi-justify.patch
Parent Directory | Revision Log
Revision 153 -
(show annotations)
(download)
Tue May 8 20:52:56 2007 UTC (17 years, 4 months ago) by niro
File size: 7086 byte(s)
Tue May 8 20:52:56 2007 UTC (17 years, 4 months ago) by niro
File size: 7086 byte(s)
-import
1 | --- ./layout/html/base/src/nsTextFrame.cpp.SCREW 2005-05-03 15:53:09.000000000 -0400 |
2 | +++ ./layout/html/base/src/nsTextFrame.cpp 2005-05-03 16:45:25.000000000 -0400 |
3 | @@ -2967,12 +2967,21 @@ |
4 | |
5 | if (0 != textLength) { |
6 | #ifdef IBMBIDI |
7 | + PRBool isRightToLeftOnBidiPlatform = PR_FALSE; |
8 | + PRBool isBidiSystem = PR_FALSE; |
9 | + PRUint32 hints = 0; |
10 | + aRenderingContext.GetHints(hints); |
11 | + PRBool paintCharByChar = (0 == (hints & NS_RENDERING_HINT_REORDER_SPACED_TEXT)) && |
12 | + ((0 != aTextStyle.mLetterSpacing) || |
13 | + (0 != aTextStyle.mWordSpacing) || |
14 | + aTextStyle.mJustifying); |
15 | PRBool bidiEnabled; |
16 | PRUint8 level = 0; |
17 | nsCharType charType = eCharType_LeftToRight; |
18 | aPresContext->GetBidiEnabled(&bidiEnabled); |
19 | |
20 | if (bidiEnabled) { |
21 | + isBidiSystem = aPresContext->IsBidiSystem(); |
22 | nsBidiPresUtils* bidiUtils; |
23 | aPresContext->GetBidiUtils(&bidiUtils); |
24 | |
25 | @@ -2985,8 +2994,19 @@ |
26 | PRInt32 rememberTextLength = textLength; |
27 | #endif |
28 | // Since we paint char by char, handle the text like on non-bidi platform |
29 | + isRightToLeftOnBidiPlatform = (!paintCharByChar && |
30 | + isBidiSystem && |
31 | + (eCharType_RightToLeft == charType || |
32 | + eCharType_RightToLeftArabic == charType)); |
33 | + if (isRightToLeftOnBidiPlatform) { |
34 | + // indicate that the platform should use its native |
35 | + // capabilities to reorder the text with right-to-left |
36 | + // base direction |
37 | + aRenderingContext.SetRightToLeftText(PR_TRUE); |
38 | + } |
39 | + // If we will be painting char by char, handle the text like on non-bidi platform |
40 | bidiUtils->ReorderUnicodeText(text, textLength, charType, |
41 | - level & 1, PR_FALSE); |
42 | + level & 1, (paintCharByChar) ? PR_FALSE : isBidiSystem); |
43 | NS_ASSERTION(rememberTextLength == textLength, "Bidi formatting changed text length"); |
44 | } |
45 | } |
46 | @@ -3028,7 +3048,9 @@ |
47 | sdptr->mStart = ip[sdptr->mStart] - mContentOffset; |
48 | sdptr->mEnd = ip[sdptr->mEnd] - mContentOffset; |
49 | #ifdef IBMBIDI |
50 | - AdjustSelectionPointsForBidi(sdptr, textLength, CHARTYPE_IS_RTL(charType), level & 1, PR_FALSE); |
51 | + AdjustSelectionPointsForBidi(sdptr, textLength, |
52 | + CHARTYPE_IS_RTL(charType), level & 1, |
53 | + (paintCharByChar) ? PR_FALSE : isBidiSystem); |
54 | #endif |
55 | sdptr = sdptr->mNext; |
56 | } |
57 | @@ -3036,19 +3058,32 @@ |
58 | DrawSelectionIterator iter(content, details,text,(PRUint32)textLength,aTextStyle, selectionValue, aPresContext, mStyleContext); |
59 | if (!iter.IsDone() && iter.First()) |
60 | { |
61 | - nscoord currentX = dx; |
62 | - nsTextDimensions newDimensions;//temp |
63 | - while (!iter.IsDone()) |
64 | - { |
65 | - PRUnichar *currenttext = iter.CurrentTextUnicharPtr(); |
66 | - PRUint32 currentlength= iter.CurrentLength(); |
67 | - //TextStyle ¤tStyle = iter.CurrentStyle(); |
68 | - nscolor currentFGColor = iter.CurrentForeGroundColor(); |
69 | - nscolor currentBKColor; |
70 | - PRBool isCurrentBKColorTransparent; |
71 | - GetTextDimensions(aRenderingContext,aTextStyle,currenttext, (PRInt32)currentlength,&newDimensions); |
72 | - if (newDimensions.width) |
73 | - { |
74 | + nscoord currentX = dx; |
75 | + nsTextDimensions newDimensions;//temp |
76 | +#ifdef IBMBIDI // Simon - display substrings RTL in RTL frame |
77 | + if (isRightToLeftOnBidiPlatform) |
78 | + { |
79 | + nsTextDimensions frameDimensions; |
80 | + GetTextDimensions(aRenderingContext, aTextStyle, text, |
81 | + (PRInt32)textLength, &frameDimensions); |
82 | + currentX = dx + frameDimensions.width; |
83 | + } |
84 | +#endif |
85 | + while (!iter.IsDone()) |
86 | + { |
87 | + PRUnichar *currenttext = iter.CurrentTextUnicharPtr(); |
88 | + PRUint32 currentlength= iter.CurrentLength(); |
89 | + //TextStyle ¤tStyle = iter.CurrentStyle(); |
90 | + nscolor currentFGColor = iter.CurrentForeGroundColor(); |
91 | + nscolor currentBKColor; |
92 | + PRBool isCurrentBKColorTransparent; |
93 | + GetTextDimensions(aRenderingContext,aTextStyle,currenttext, (PRInt32)currentlength,&newDimensions); |
94 | + if (newDimensions.width) |
95 | + { |
96 | +#ifdef IBMBIDI |
97 | + if (isRightToLeftOnBidiPlatform) |
98 | + currentX -= newDimensions.width; |
99 | +#endif |
100 | if (iter.CurrentBackGroundColor(currentBKColor, &isCurrentBKColorTransparent)) |
101 | {//DRAW RECT HERE!!! |
102 | if (!isCurrentBKColorTransparent) { |
103 | @@ -3057,7 +3092,7 @@ |
104 | } |
105 | currentFGColor = EnsureDifferentColors(currentFGColor, currentBKColor); |
106 | } |
107 | - } |
108 | + } |
109 | |
110 | if (isPaginated && !iter.IsBeforeOrAfter()) { |
111 | aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,canDarkenColor)); |
112 | @@ -3071,11 +3106,13 @@ |
113 | dy, width, details); |
114 | } |
115 | |
116 | +#ifdef IBMBIDI |
117 | + if (!isRightToLeftOnBidiPlatform) |
118 | +#endif |
119 | //increment twips X start but remember to get ready for next draw by reducing current x by letter spacing amount |
120 | - currentX+=newDimensions.width;// + aTextStyle.mLetterSpacing; |
121 | - |
122 | - iter.Next(); |
123 | - } |
124 | + currentX+=newDimensions.width;// + aTextStyle.mLetterSpacing; |
125 | + iter.Next(); |
126 | + } |
127 | } |
128 | else if (!isPaginated) |
129 | { |
130 | @@ -3093,8 +3130,15 @@ |
131 | delete details; |
132 | } |
133 | } |
134 | +#ifdef IBMBIDI |
135 | + if (isRightToLeftOnBidiPlatform) { |
136 | + // indicate that future text should not be reordered with |
137 | + // right-to-left base direction |
138 | + aRenderingContext.SetRightToLeftText(PR_FALSE); |
139 | + } |
140 | +#endif // IBMBIDI |
141 | } |
142 | -} |
143 | +} |
144 | |
145 | void |
146 | nsTextFrame::PaintAsciiText(nsIPresContext* aPresContext, |
147 | --- ./gfx/public/nsIRenderingContext.h.SCREW 2005-05-03 15:53:09.000000000 -0400 |
148 | +++ ./gfx/public/nsIRenderingContext.h 2005-05-03 15:53:09.000000000 -0400 |
149 | @@ -932,6 +932,14 @@ |
150 | */ |
151 | #define NS_RENDERING_HINT_TEXT_CLUSTERS 0x20 |
152 | |
153 | +/** |
154 | + * This bit, when set, indicates that gfx performs glyph reordering of complex |
155 | + * text after applying character or word spacing, and so expects to be passed |
156 | + * text in logical order. When this bit is not set, gfx must be passed text in |
157 | + * visual order if characters and word spacing are to be applied. |
158 | + */ |
159 | +#define NS_RENDERING_HINT_REORDER_SPACED_TEXT 0x40 |
160 | + |
161 | //flags for copy CopyOffScreenBits |
162 | |
163 | //when performing the blit, use the region, if any, |
164 | --- ./gfx/src/gtk/nsFontMetricsPango.cpp.SCREW 2005-05-03 15:53:09.000000000 -0400 |
165 | +++ ./gfx/src/gtk/nsFontMetricsPango.cpp 2005-05-03 15:53:09.000000000 -0400 |
166 | @@ -1138,7 +1138,8 @@ |
167 | return (NS_RENDERING_HINT_BIDI_REORDERING | |
168 | NS_RENDERING_HINT_ARABIC_SHAPING | |
169 | NS_RENDERING_HINT_FAST_MEASURE | |
170 | - NS_RENDERING_HINT_TEXT_CLUSTERS); |
171 | + NS_RENDERING_HINT_TEXT_CLUSTERS | |
172 | + NS_RENDERING_HINT_REORDER_SPACED_TEXT); |
173 | } |
174 | |
175 | /* static */ |