Changeset 146855 in webkit
- Timestamp:
- Mar 26, 2013 12:51:39 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r146853 r146855 1 2013-03-26 Dominik Röttsches <dominik.rottsches@intel.com> 2 3 Remove HarfBuzzShaperBase 4 https://bugs.webkit.org/show_bug.cgi?id=112087 5 6 Reviewed by Martin Robinson. 7 8 Folding HarfBuzzShaperBase into HarfBuzzShaper since 9 there is no harfbuzz-old vs. harfbuzz-ng distinction anymore. 10 11 No new tests, no change in behavior. 12 13 * GNUmakefile.list.am: Removing HarfBuzzShaperBase.* 14 * PlatformEfl.cmake: Removing HarfBuzzShaperBase.* 15 * WebCore.gypi: Removing HarfBuzzShaperBase.* 16 * platform/graphics/harfbuzz/HarfBuzzShaper.cpp: Folding base class members and methods into HarfBuzzShaper. 17 (WebCore::HarfBuzzShaper::HarfBuzzShaper): 18 (WebCore::normalizeSpacesAndMirrorChars): 19 (WebCore): 20 (WebCore::HarfBuzzShaper::setNormalizedBuffer): 21 (WebCore::HarfBuzzShaper::isWordEnd): 22 (WebCore::HarfBuzzShaper::determineWordBreakSpacing): 23 (WebCore::HarfBuzzShaper::setPadding): 24 * platform/graphics/harfbuzz/HarfBuzzShaper.h: Folding base class members and methods into HarfBuzzShaper. 25 (HarfBuzzShaper): 26 (WebCore::HarfBuzzShaper::isCodepointSpace): 27 * platform/graphics/harfbuzz/HarfBuzzShaperBase.cpp: Removed. 28 * platform/graphics/harfbuzz/HarfBuzzShaperBase.h: Removed. 29 1 30 2013-03-22 Hajime Morrita <morrita@google.com> 2 31 -
trunk/Source/WebCore/GNUmakefile.list.am
r146833 r146855 4334 4334 Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp \ 4335 4335 Source/WebCore/platform/graphics/freetype/UTF16UChar32Iterator.h \ 4336 Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaperBase.cpp \4337 Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaperBase.h \4338 4336 Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFace.cpp \ 4339 4337 Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFace.h \ -
trunk/Source/WebCore/PlatformEfl.cmake
r146458 r146855 131 131 platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp 132 132 133 platform/graphics/harfbuzz/HarfBuzzShaperBase.cpp134 133 platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp 135 134 platform/graphics/harfbuzz/HarfBuzzFace.cpp -
trunk/Source/WebCore/WebCore.gypi
r146851 r146855 4235 4235 'platform/graphics/harfbuzz/HarfBuzzShaper.cpp', 4236 4236 'platform/graphics/harfbuzz/HarfBuzzShaper.h', 4237 'platform/graphics/harfbuzz/HarfBuzzShaperBase.cpp',4238 'platform/graphics/harfbuzz/HarfBuzzShaperBase.h',4239 4237 'platform/graphics/mac/ColorMac.mm', 4240 4238 'platform/graphics/mac/ComplexTextController.cpp', -
trunk/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.cpp
r144646 r146855 185 185 186 186 HarfBuzzShaper::HarfBuzzShaper(const Font* font, const TextRun& run) 187 : HarfBuzzShaperBase(font, run) 187 : m_font(font) 188 , m_normalizedBufferLength(0) 189 , m_run(run) 190 , m_wordSpacingAdjustment(font->wordSpacing()) 191 , m_padding(0) 192 , m_padPerWordBreak(0) 193 , m_padError(0) 194 , m_letterSpacing(font->letterSpacing()) 188 195 , m_fromIndex(0) 189 196 , m_toIndex(m_run.length()) … … 199 206 { 200 207 } 208 209 static void normalizeSpacesAndMirrorChars(const UChar* source, UChar* destination, int length, HarfBuzzShaper::NormalizeMode normalizeMode) 210 { 211 int position = 0; 212 bool error = false; 213 // Iterate characters in source and mirror character if needed. 214 while (position < length) { 215 UChar32 character; 216 int nextPosition = position; 217 U16_NEXT(source, nextPosition, length, character); 218 // Don't normalize tabs as they are not treated as spaces for word-end 219 if (Font::treatAsSpace(character) && character != '\t') 220 character = ' '; 221 else if (Font::treatAsZeroWidthSpace(character)) 222 character = zeroWidthSpace; 223 else if (normalizeMode == HarfBuzzShaper::NormalizeMirrorChars) 224 character = u_charMirror(character); 225 U16_APPEND(destination, position, length, character, error); 226 ASSERT_UNUSED(error, !error); 227 position = nextPosition; 228 } 229 } 230 231 void HarfBuzzShaper::setNormalizedBuffer(NormalizeMode normalizeMode) 232 { 233 // Normalize the text run in three ways: 234 // 1) Convert the |originalRun| to NFC normalized form if combining diacritical marks 235 // (U+0300..) are used in the run. This conversion is necessary since most OpenType 236 // fonts (e.g., Arial) don't have substitution rules for the diacritical marks in 237 // their GSUB tables. 238 // 239 // Note that we don't use the icu::Normalizer::isNormalized(UNORM_NFC) API here since 240 // the API returns FALSE (= not normalized) for complex runs that don't require NFC 241 // normalization (e.g., Arabic text). Unless the run contains the diacritical marks, 242 // HarfBuzz will do the same thing for us using the GSUB table. 243 // 2) Convert spacing characters into plain spaces, as some fonts will provide glyphs 244 // for characters like '\n' otherwise. 245 // 3) Convert mirrored characters such as parenthesis for rtl text. 246 247 // Convert to NFC form if the text has diacritical marks. 248 icu::UnicodeString normalizedString; 249 UErrorCode error = U_ZERO_ERROR; 250 251 const UChar* runCharacters; 252 String stringFor8BitRun; 253 if (m_run.is8Bit()) { 254 stringFor8BitRun = String::make16BitFrom8BitSource(m_run.characters8(), m_run.length()); 255 runCharacters = stringFor8BitRun.characters16(); 256 } else 257 runCharacters = m_run.characters16(); 258 259 for (int i = 0; i < m_run.length(); ++i) { 260 UChar ch = runCharacters[i]; 261 if (::ublock_getCode(ch) == UBLOCK_COMBINING_DIACRITICAL_MARKS) { 262 icu::Normalizer::normalize(icu::UnicodeString(runCharacters, 263 m_run.length()), UNORM_NFC, 0 /* no options */, 264 normalizedString, error); 265 if (U_FAILURE(error)) 266 normalizedString.remove(); 267 break; 268 } 269 } 270 271 const UChar* sourceText; 272 if (normalizedString.isEmpty()) { 273 m_normalizedBufferLength = m_run.length(); 274 sourceText = runCharacters; 275 } else { 276 m_normalizedBufferLength = normalizedString.length(); 277 sourceText = normalizedString.getBuffer(); 278 } 279 280 m_normalizedBuffer = adoptArrayPtr(new UChar[m_normalizedBufferLength + 1]); 281 normalizeSpacesAndMirrorChars(sourceText, m_normalizedBuffer.get(), m_normalizedBufferLength, normalizeMode); 282 } 283 284 bool HarfBuzzShaper::isWordEnd(unsigned index) 285 { 286 // This could refer a high-surrogate, but should work. 287 return index && isCodepointSpace(m_normalizedBuffer[index]); 288 } 289 290 int HarfBuzzShaper::determineWordBreakSpacing() 291 { 292 int wordBreakSpacing = m_wordSpacingAdjustment; 293 294 if (m_padding > 0) { 295 int toPad = roundf(m_padPerWordBreak + m_padError); 296 m_padError += m_padPerWordBreak - toPad; 297 298 if (m_padding < toPad) 299 toPad = m_padding; 300 m_padding -= toPad; 301 wordBreakSpacing += toPad; 302 } 303 return wordBreakSpacing; 304 } 305 306 // setPadding sets a number of pixels to be distributed across the TextRun. 307 // WebKit uses this to justify text. 308 void HarfBuzzShaper::setPadding(int padding) 309 { 310 m_padding = padding; 311 m_padError = 0; 312 if (!m_padding) 313 return; 314 315 // If we have padding to distribute, then we try to give an equal 316 // amount to each space. The last space gets the smaller amount, if 317 // any. 318 unsigned numWordEnds = 0; 319 320 for (unsigned i = 0; i < m_normalizedBufferLength; i++) { 321 if (isWordEnd(i)) 322 numWordEnds++; 323 } 324 325 if (numWordEnds) 326 m_padPerWordBreak = m_padding / numWordEnds; 327 else 328 m_padPerWordBreak = 0; 329 } 330 201 331 202 332 void HarfBuzzShaper::setDrawRange(int from, int to) -
trunk/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.h
r141291 r146855 34 34 #include "FloatPoint.h" 35 35 #include "GlyphBuffer.h" 36 #include "HarfBuzzShaperBase.h"37 36 #include "TextRun.h" 38 37 #include "hb.h" 39 38 #include <wtf/HashSet.h> 39 #include <wtf/OwnArrayPtr.h> 40 40 #include <wtf/OwnPtr.h> 41 41 #include <wtf/PassOwnPtr.h> 42 42 #include <wtf/Vector.h> 43 #include <wtf/unicode/CharacterNames.h> 43 44 44 45 namespace WebCore { … … 47 48 class SimpleFontData; 48 49 49 class HarfBuzzShaper : public HarfBuzzShaperBase{50 class HarfBuzzShaper { 50 51 public: 52 enum NormalizeMode { 53 DoNotNormalizeMirrorChars, 54 NormalizeMirrorChars 55 }; 56 51 57 HarfBuzzShaper(const Font*, const TextRun&); 52 58 virtual ~HarfBuzzShaper(); … … 102 108 }; 103 109 110 void setNormalizedBuffer(NormalizeMode = DoNotNormalizeMirrorChars); 111 112 bool isWordEnd(unsigned); 113 int determineWordBreakSpacing(); 114 // setPadding sets a number of pixels to be distributed across the TextRun. 115 // WebKit uses this to justify text. 116 void setPadding(int); 117 118 // In complex text word-spacing affects each line-break, space (U+0020) and non-breaking space (U+00A0). 119 static bool isCodepointSpace(UChar c) { return c == ' ' || c == noBreakSpace || c == '\n'; } 120 104 121 void setFontFeatures(); 105 122 … … 111 128 112 129 GlyphBufferAdvance createGlyphBufferAdvance(float, float); 130 131 const Font* m_font; 132 OwnArrayPtr<UChar> m_normalizedBuffer; 133 unsigned m_normalizedBufferLength; 134 const TextRun& m_run; 135 136 int m_wordSpacingAdjustment; // Delta adjustment (pixels) for each word break. 137 float m_padding; // Pixels to be distributed over the line at word breaks. 138 float m_padPerWordBreak; // Pixels to be added to each word break. 139 float m_padError; // m_padPerWordBreak might have a fractional component. Since we only add a whole number of padding pixels at each word break we accumulate error. This is the number of pixels that we are behind so far. 140 int m_letterSpacing; // Pixels to be added after each glyph. 113 141 114 142 Vector<hb_feature_t, 4> m_features;
Note: See TracChangeset
for help on using the changeset viewer.