Changeset 84264 in webkit
- Timestamp:
- Apr 19, 2011 10:40:45 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r84256 r84264 1 2011-04-19 Jungshik Shin <jshin@chromium.org> 2 3 Reviewed by David Levin 4 5 Add a complex-script version of zero-width-characters.html. 6 and add U+FEFF to zero-width-characters.html 7 Chromium Linux fails the test because U+FEFF is rendered 8 with a non-zero width glyph. 9 Filed http://bugs.webkit.org/show_bug.cgi?id=58741 and noted 10 as such in test_expectation.txt. 11 12 https://bugs.webkit.org/show_bug.cgi?id=48860 13 14 * fast/text/zero-width-characters-complex-script-expected.txt: Added. 15 * fast/text/zero-width-characters-complex-script.html: Added. 16 * fast/text/zero-width-characters.html: 17 * platform/chromium/test_expectations.txt: 18 1 19 2011-04-19 Kristóf Kosztyó <Kosztyo.Kristof@stud.u-szeged.hu> 2 20 -
trunk/LayoutTests/fast/text/zero-width-characters.html
r58042 r84264 14 14 testString += String.fromCharCode(0x200E); 15 15 testString += String.fromCharCode(0x200F); 16 testString += String.fromCharCode(0xFEFF); 16 17 testString += String.fromCharCode(0xFFFC); 17 18 var span = document.getElementById("characters"); -
trunk/LayoutTests/platform/chromium/test_expectations.txt
r84255 r84264 3487 3487 3488 3488 BUGWK58619 GPU LINUX WIN : media/video-volume-slider.html = IMAGE 3489 BUGWK58741 LINUX : fast/text/zero-width-characters-complex-script.html = FAIL 3489 3490 3490 3491 // Broken by skia shadow code change in r83936 -
trunk/Source/JavaScriptCore/ChangeLog
r84252 r84264 1 2011-04-19 Jungshik Shin <jshin@chromium.org> 2 3 Reviewed by David Levin 4 5 Add U+FEFF (Zero width no-break space) to CharacterNames.h. 6 It's added to the list of characters to treat as zero-width 7 in WebCore. 8 9 https://bugs.webkit.org/show_bug.cgi?id=48860 10 11 * wtf/unicode/CharacterNames.h: 12 1 13 2011-04-19 Csaba Osztrogonác <ossy@webkit.org> 2 14 -
trunk/Source/JavaScriptCore/wtf/unicode/CharacterNames.h
r77062 r84264 86 86 const UChar zeroWidthNonJoiner = 0x200C; 87 87 const UChar zeroWidthSpace = 0x200B; 88 const UChar zeroWidthNoBreakSpace = 0xFEFF; 88 89 89 90 } // namespace Unicode … … 139 140 using WTF::Unicode::zeroWidthNonJoiner; 140 141 using WTF::Unicode::zeroWidthSpace; 142 using WTF::Unicode::zeroWidthNoBreakSpace; 141 143 142 144 #endif // CharacterNames_h -
trunk/Source/WebCore/ChangeLog
r84261 r84264 1 2011-04-19 Jungshik Shin <jshin@chromium.org> 2 3 Reviewed by David Levin 4 5 Make U+FEFF be treated as a zero-width character in both 6 simple script and complex script code paths. In Chromium 7 Windows, UniscribeHelper needs a rather extensive changes 8 summarized below. Other ports need minor changes. 9 10 https://bugs.webkit.org/show_bug.cgi?id=48860 11 12 Test: fast/text/zero-width-characters-complex-script.html 13 14 * platform/graphics/Font.h: 15 (WebCore::Font::treatAsZeroWidthSpace): U+FEFF is added to the list 16 (WebCore::Font::treatAsZeroWidthSpaceInComplexScript): Added. Same as the above except that ZWNJ and ZWJ are excluded. 17 * platform/graphics/GlyphPageTreeNode.cpp: 18 (WebCore::GlyphPageTreeNode::initializePage): U+FEFF is made to have zero-width characters in simple script (fast) code path. 19 * platform/graphics/chromium/FontUtilsChromiumWin.cpp: 20 (WebCore::FontMap::getSpaceGlyph): Added to get the gid for space glyph to use in adjustSpaceAdvance when zero-width glyph character has a non-zero width and potentially 'visible' glyph. 21 (WebCore::FontMap::FontData::FontData): spaceGlyph member added. 22 (WebCore::getDerivedFontData): spaceGlyph is retrieved as well. 23 * platform/graphics/chromium/FontUtilsChromiumWin.h: 24 * platform/graphics/chromium/UniscribeHelper.cpp: 25 (WebCore::UniscribeHelper::UniscribeHelper): m_spaceGlyph added. 26 (WebCore::UniscribeHelper::shape): spaceGlyph is obtained stored for a font tried for each item. 27 (WebCore::UniscribeHelper::adjustSpaceAdvances): For zero-width complex script characters, set the advance width to zero and replace a non-zero-width/visible glyph with a space glyph. 28 (WebCore::UniscribeHelper::applySpacing): 29 (WebCore::UniscribeHelper::containsMissingGlyphs): turned to a member function because it cannot work on glyphs alone any more but need to take into account a character corresponding to a glyph 30 * platform/graphics/chromium/UniscribeHelper.h: 31 (WebCore::UniscribeHelper::Shaping::Shaping): m_spaceGlyph is added 32 * platform/graphics/chromium/UniscribeHelperTextRun.cpp: 33 (WebCore::UniscribeHelperTextRun::UniscribeHelperTextRun): When calling UniscriberHelper, add a new argument for spaceGlyph. 34 1 35 2011-04-19 Brent Fulgham <bfulgham@webkit.org> 2 36 -
trunk/Source/WebCore/platform/graphics/Font.h
r81684 r84264 204 204 FontSelector* fontSelector() const; 205 205 static bool treatAsSpace(UChar c) { return c == ' ' || c == '\t' || c == '\n' || c == noBreakSpace; } 206 static bool treatAsZeroWidthSpace(UChar c) { return c < 0x20 || (c >= 0x7F && c < 0xA0) || c == softHyphen || (c >= 0x200c && c <= 0x200f) || (c >= 0x202a && c <= 0x202e) || c == objectReplacementCharacter; } 206 static bool treatAsZeroWidthSpace(UChar c) { return treatAsZeroWidthSpaceInComplexScript(c) || c == 0x200c || c == 0x200d; } 207 static bool treatAsZeroWidthSpaceInComplexScript(UChar c) { return c < 0x20 || (c >= 0x7F && c < 0xA0) || c == softHyphen || (c >= 0x200e && c <= 0x200f) || (c >= 0x202a && c <= 0x202e) || c == zeroWidthNoBreakSpace || c == objectReplacementCharacter; } 207 208 static bool canReceiveTextEmphasis(UChar32 c); 208 209 -
trunk/Source/WebCore/platform/graphics/GlyphPageTreeNode.cpp
r77062 r84264 192 192 // Object replacement character must not render at all. 193 193 buffer[objectReplacementCharacter - start] = zeroWidthSpace; 194 } else if (start == (zeroWidthNoBreakSpace & ~(GlyphPage::size - 1))) { 195 // ZWNBS/BOM must not render at all. 196 buffer[zeroWidthNoBreakSpace - start] = zeroWidthSpace; 194 197 } 195 198 } else { -
trunk/Source/WebCore/platform/graphics/chromium/FontUtilsChromiumWin.cpp
r72498 r84264 251 251 } 252 252 253 WORD getSpaceGlyph(HFONT hfont) 254 { 255 HDC dc = GetDC(0); 256 HGDIOBJ oldFont = SelectObject(dc, hfont); 257 WCHAR space = L' '; 258 WORD spaceGlyph = 0; 259 GetGlyphIndices(dc, &space, 1, &spaceGlyph, 0); 260 SelectObject(dc, oldFont); 261 ReleaseDC(0, dc); 262 return spaceGlyph; 263 } 264 253 265 struct FontData { 254 266 FontData() … … 256 268 , ascent(kUndefinedAscent) 257 269 , scriptCache(0) 270 , spaceGlyph(0) 258 271 { 259 272 } … … 262 275 int ascent; 263 276 mutable SCRIPT_CACHE scriptCache; 277 WORD spaceGlyph; 264 278 }; 265 279 … … 380 394 int* ascent, 381 395 HFONT* hfont, 382 SCRIPT_CACHE** scriptCache) 396 SCRIPT_CACHE** scriptCache, 397 WORD* spaceGlyph) 383 398 { 384 399 ASSERT(logfont); … … 409 424 // more for HFONT next time. 410 425 derived->ascent = getAscent(derived->hfont); 426 derived->spaceGlyph = getSpaceGlyph(derived->hfont); 411 427 } else { 412 428 derived = &iter->second; … … 420 436 *ascent = derived->ascent; 421 437 *scriptCache = &(derived->scriptCache); 438 *spaceGlyph = derived->spaceGlyph; 422 439 return *ascent != kUndefinedAscent; 423 440 } -
trunk/Source/WebCore/platform/graphics/chromium/FontUtilsChromiumWin.h
r61663 r84264 79 79 // the current version although the subsequent 9 passes take about the 80 80 // same time. 81 bool getDerivedFontData(const UChar* family, int style, LOGFONT*, int* ascent, HFONT*, SCRIPT_CACHE** );81 bool getDerivedFontData(const UChar* family, int style, LOGFONT*, int* ascent, HFONT*, SCRIPT_CACHE**, WORD* spaceGlyph); 82 82 83 83 enum { -
trunk/Source/WebCore/platform/graphics/chromium/UniscribeHelper.cpp
r57595 r84264 32 32 #include "UniscribeHelper.h" 33 33 34 #include <windows.h> 35 34 #include "Font.h" 36 35 #include "FontUtilsChromiumWin.h" 37 36 #include "PlatformContextSkia.h" 38 37 #include "SkiaFontWin.h" 39 38 #include "SkPoint.h" 39 #include <windows.h> 40 40 #include <wtf/Assertions.h> 41 41 42 42 namespace WebCore { 43 44 // This function is used to see where word spacing should be applied inside45 // runs. Note that this must match Font::treatAsSpace so we all agree where46 // and how much space this is, so we don't want to do more general Unicode47 // "is this a word break" thing.48 static bool treatAsSpace(UChar c)49 {50 return c == ' ' || c == '\t' || c == '\n' || c == 0x00A0;51 }52 53 // SCRIPT_FONTPROPERTIES contains glyph indices for default, invalid54 // and blank glyphs. Just because ScriptShape succeeds does not mean55 // that a text run is rendered correctly. Some characters may be rendered56 // with default/invalid/blank glyphs. Therefore, we need to check if the glyph57 // array returned by ScriptShape contains any of those glyphs to make58 // sure that the text run is rendered successfully.59 static bool containsMissingGlyphs(WORD *glyphs,60 int length,61 SCRIPT_FONTPROPERTIES* properties)62 {63 for (int i = 0; i < length; ++i) {64 if (glyphs[i] == properties->wgDefault65 || (glyphs[i] == properties->wgInvalid66 && glyphs[i] != properties->wgBlank))67 return true;68 }69 70 return false;71 }72 43 73 44 // HFONT is the 'incarnation' of 'everything' about font, but it's an opaque … … 103 74 HFONT hfont, 104 75 SCRIPT_CACHE* scriptCache, 105 SCRIPT_FONTPROPERTIES* fontProperties) 76 SCRIPT_FONTPROPERTIES* fontProperties, 77 WORD spaceGlyph) 106 78 : m_input(input) 107 79 , m_inputLength(inputLength) … … 110 82 , m_scriptCache(scriptCache) 111 83 , m_fontProperties(fontProperties) 84 , m_spaceGlyph(spaceGlyph) 112 85 , m_directionalOverride(false) 113 86 , m_inhibitLigate(false) … … 547 520 SCRIPT_FONTPROPERTIES* fontProperties = m_fontProperties; 548 521 int ascent = m_ascent; 522 WORD spaceGlyph = m_spaceGlyph; 549 523 HDC tempDC = 0; 550 524 HGDIOBJ oldFont = 0; … … 602 576 numGlyphs *= 2; 603 577 continue; 604 } else if (SUCCEEDED(hr) && (lastFallbackTried || !containsMissingGlyphs( &shaping.m_glyphs[0], generatedGlyphs, fontProperties)))578 } else if (SUCCEEDED(hr) && (lastFallbackTried || !containsMissingGlyphs(shaping, run, fontProperties))) 605 579 break; 606 580 … … 633 607 FontDescription::StandardFamily, 0, 0); 634 608 bool fontOk = getDerivedFontData(family, m_style, &m_logfont, 635 &ascent, &hfont, &scriptCache); 609 &ascent, &hfont, &scriptCache, 610 &spaceGlyph); 611 636 612 637 613 if (!fontOk) { … … 645 621 // Try again. 646 622 fontOk = getDerivedFontData(family, m_style, &m_logfont, 647 &ascent, &hfont, &scriptCache); 623 &ascent, &hfont, &scriptCache, 624 &spaceGlyph); 648 625 ASSERT(fontOk); 649 626 } … … 674 651 shaping.m_hfont = hfont; 675 652 shaping.m_scriptCache = scriptCache; 653 shaping.m_spaceGlyph = spaceGlyph; 676 654 677 655 // The ascent of a font for this run can be different from … … 807 785 Shaping& shaping = m_shapes[run]; 808 786 787 // FIXME: This loop is not UTF-16-safe. Unicode 6.0 has a couple 788 // of complex script blocks in Plane 1. 809 789 for (int i = 0; i < shaping.charLength(); i++) { 810 if (!treatAsSpace(m_input[m_runs[run].iCharPos + i])) 790 UChar c = m_input[m_runs[run].iCharPos + i]; 791 bool treatAsSpace = Font::treatAsSpace(c); 792 if (!treatAsSpace && !Font::treatAsZeroWidthSpaceInComplexScript(c)) 811 793 continue; 812 794 … … 814 796 int currentAdvance = shaping.m_advance[glyphIndex]; 815 797 816 // currentAdvance does not include additional letter-spacing, but 817 // space_width does. Here we find out how off we are from the 818 // correct width for the space not including letter-spacing, then 819 // just subtract that diff. 820 int diff = currentAdvance - spaceWidthWithoutLetterSpacing; 821 // The shaping can consist of a run of text, so only subtract the 822 // difference in the width of the glyph. 823 shaping.m_advance[glyphIndex] -= diff; 824 shaping.m_abc.abcB -= diff; 798 if (treatAsSpace) { 799 // currentAdvance does not include additional letter-spacing, 800 // but m_spaceWidth does. Here we find out how off we are from 801 // the correct width (spaceWidthWithoutLetterSpacing) and 802 // just subtract that diff. 803 int diff = currentAdvance - spaceWidthWithoutLetterSpacing; 804 // The shaping can consist of a run of text, so only subtract 805 // the difference in the width of the glyph. 806 shaping.m_advance[glyphIndex] -= diff; 807 shaping.m_abc.abcB -= diff; 808 continue; 809 } 810 811 // For characters treated as zero-width space in complex 812 // scripts, set the advance width to zero, adjust 813 // |abcB| of the current run accordingly and set 814 // the glyph to m_spaceGlyph (invisible). 815 shaping.m_advance[glyphIndex] = 0; 816 shaping.m_abc.abcB -= currentAdvance; 817 shaping.m_offsets[glyphIndex].du = 0; 818 shaping.m_offsets[glyphIndex].dv = 0; 819 shaping.m_glyphs[glyphIndex] = shaping.m_spaceGlyph; 825 820 } 826 821 } … … 873 868 if (m_wordSpacing != 0) { 874 869 for (int i = 0; i < shaping.charLength(); i++) { 875 if (! treatAsSpace(m_input[m_runs[run].iCharPos + i]))870 if (!Font::treatAsSpace(m_input[m_runs[run].iCharPos + i])) 876 871 continue; 877 872 … … 930 925 } 931 926 927 // SCRIPT_FONTPROPERTIES contains glyph indices for default, invalid 928 // and blank glyphs. Just because ScriptShape succeeds does not mean 929 // that a text run is rendered correctly. Some characters may be rendered 930 // with default/invalid/blank glyphs. Therefore, we need to check if the glyph 931 // array returned by ScriptShape contains any of those glyphs to make 932 // sure that the text run is rendered successfully. 933 // However, we should not subject zero-width characters to this test. 934 935 bool UniscribeHelper::containsMissingGlyphs(const Shaping& shaping, 936 const SCRIPT_ITEM& run, 937 const SCRIPT_FONTPROPERTIES* properties) const 938 { 939 for (int i = 0; i < shaping.charLength(); i++) { 940 UChar c = m_input[run.iCharPos + i]; 941 // Skip zero-width space characters because they're not considered to be missing in a font. 942 if (Font::treatAsZeroWidthSpaceInComplexScript(c)) 943 continue; 944 int glyphIndex = shaping.m_logs[i]; 945 WORD glyph = shaping.m_glyphs[glyphIndex]; 946 if (glyph == properties->wgDefault 947 || (glyph == properties->wgInvalid && glyph != properties->wgBlank)) 948 return true; 949 } 950 return false; 951 } 952 953 932 954 } // namespace WebCore -
trunk/Source/WebCore/platform/graphics/chromium/UniscribeHelper.h
r40812 r84264 77 77 HFONT, 78 78 SCRIPT_CACHE*, 79 SCRIPT_FONTPROPERTIES*); 79 SCRIPT_FONTPROPERTIES*, 80 WORD); 80 81 81 82 virtual ~UniscribeHelper(); … … 226 227 , m_hfont(NULL) 227 228 , m_scriptCache(NULL) 228 , m_ascentOffset(0) { 229 , m_ascentOffset(0) 230 , m_spaceGlyph(0) 231 { 229 232 m_abc.abcA = 0; 230 233 m_abc.abcB = 0; … … 320 323 // different fonts. 321 324 int m_ascentOffset; 325 326 WORD m_spaceGlyph; 322 327 }; 323 328 … … 343 348 // Returns the total width of a single item. 344 349 int advanceForItem(int) const; 350 351 bool containsMissingGlyphs(const Shaping&, 352 const SCRIPT_ITEM&, 353 const SCRIPT_FONTPROPERTIES*) const; 345 354 346 355 // Shapes a run (pointed to by |input|) using |hfont| first. … … 385 394 LOGFONT m_logfont; 386 395 int m_style; 396 WORD m_spaceGlyph; 387 397 388 398 // Options, see the getters/setters above. -
trunk/Source/WebCore/platform/graphics/chromium/UniscribeHelperTextRun.cpp
r76743 r84264 44 44 font.primaryFont()->platformData().hfont(), 45 45 font.primaryFont()->platformData().scriptCache(), 46 font.primaryFont()->platformData().scriptFontProperties()) 46 font.primaryFont()->platformData().scriptFontProperties(), 47 font.primaryFont()->spaceGlyph()) 47 48 , m_font(&font) 48 49 , m_fontIndex(0) … … 70 71 SCRIPT_FONTPROPERTIES* fontProperties) 71 72 : UniscribeHelper(input, inputLength, isRtl, hfont, 72 scriptCache, fontProperties )73 scriptCache, fontProperties, 0) 73 74 , m_font(0) 74 75 , m_fontIndex(-1)
Note: See TracChangeset
for help on using the changeset viewer.