Changeset 135888 in webkit
- Timestamp:
- Nov 27, 2012, 11:25:54 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r135887 r135888 1 2012-11-27 Christophe Dumez <christophe.dumez@intel.com> 2 3 Canvas does not draw any text if the font is not fully loaded yet 4 https://bugs.webkit.org/show_bug.cgi?id=103392 5 6 Reviewed by Kenneth Rohde Christiansen. 7 8 Add canvas test to check that text is drawn using a fallback font 9 if the primary font is not fully loaded yet. 10 11 * http/tests/canvas/canvas-slow-font-loading-expected.html: Added. 12 * http/tests/canvas/canvas-slow-font-loading.html: Added. 13 1 14 2012-11-27 Yael Aharon <yael.aharon@intel.com> 2 15 -
trunk/Source/WebCore/ChangeLog
r135886 r135888 1 2012-11-27 Christophe Dumez <christophe.dumez@intel.com> 2 3 Canvas does not draw any text if the font is not fully loaded yet 4 https://bugs.webkit.org/show_bug.cgi?id=103392 5 6 Reviewed by Kenneth Rohde Christiansen. 7 8 Update CanvasRenderingContext2D::drawTextInternal() so that the 9 text is being drawn, even if custom fonts are still being loaded. 10 Without this, WebKit was not drawing any text on the canvas if 11 the needed font is custom and is not fully loaded yet. This seems 12 broken. 13 14 The new behavior is according to specification: 15 http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html 16 17 The specification says: "If a font is used before it is fully 18 loaded, or if the font style source object does not have that 19 font in scope at the time the font is to be used, then it must be 20 treated as if it was an unknown font, falling back to another as 21 described by the relevant CSS specifications." 22 23 Test: http/tests/canvas/canvas-slow-font-loading.html 24 25 * html/canvas/CanvasRenderingContext2D.cpp: 26 (WebCore::CanvasRenderingContext2D::drawTextInternal): 27 * platform/graphics/Font.cpp: 28 (WebCore::Font::drawText): Add argument to specify the behavior 29 when custom fonts are not ready. By default, it will not draw 30 anything (same behavior as before). However, the Canvas code 31 can now request that a fallback font is used if the custom 32 font is not fully loaded yet. 33 * platform/graphics/Font.h: #undef Complex if defined to avoid 34 conflicting with Complex value in CodePath enum. X11/X.h is 35 defining Complex to 0. 36 * platform/graphics/GraphicsContext.cpp: 37 (WebCore::GraphicsContext::drawBidiText): 38 * platform/graphics/GraphicsContext.h: 39 (WebCore): 40 (GraphicsContext): 41 1 42 2012-11-27 Dean Jackson <dino@apple.com> 2 43 -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
r135848 r135888 2307 2307 // We draw when fontWidth is 0 so compositing operations (eg, a "copy" op) still work. 2308 2308 maskImageContext->scale(FloatSize((fontWidth > 0 ? (width / fontWidth) : 0), 1)); 2309 maskImageContext->drawBidiText(font, textRun, FloatPoint(0, 0) );2309 maskImageContext->drawBidiText(font, textRun, FloatPoint(0, 0), Font::UseFallbackIfFontNotReady); 2310 2310 } else { 2311 2311 maskImageContext->translate(-maskRect.x(), -maskRect.y()); 2312 maskImageContext->drawBidiText(font, textRun, location );2312 maskImageContext->drawBidiText(font, textRun, location, Font::UseFallbackIfFontNotReady); 2313 2313 } 2314 2314 … … 2334 2334 // We draw when fontWidth is 0 so compositing operations (eg, a "copy" op) still work. 2335 2335 c->scale(FloatSize((fontWidth > 0 ? (width / fontWidth) : 0), 1)); 2336 c->drawBidiText(font, textRun, FloatPoint(0, 0) );2336 c->drawBidiText(font, textRun, FloatPoint(0, 0), Font::UseFallbackIfFontNotReady); 2337 2337 } else 2338 c->drawBidiText(font, textRun, location );2338 c->drawBidiText(font, textRun, location, Font::UseFallbackIfFontNotReady); 2339 2339 2340 2340 didDraw(textRect); -
trunk/Source/WebCore/platform/graphics/Font.cpp
r133921 r135888 157 157 } 158 158 159 void Font::drawText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const 160 { 161 // Don't draw anything while we are using custom fonts that are in the process of loading. 162 if (loadingCustomFonts()) 159 void Font::drawText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to, CustomFontNotReadyAction customFontNotReadyAction) const 160 { 161 // Don't draw anything while we are using custom fonts that are in the process of loading, 162 // except if the 'force' argument is set to true (in which case it will use a fallback 163 // font). 164 if (loadingCustomFonts() && customFontNotReadyAction == DoNotPaintIfFontNotReady) 163 165 return; 164 166 -
trunk/Source/WebCore/platform/graphics/Font.h
r133534 r135888 43 43 #endif 44 44 45 // "X11/X.h" defines Complex to 0 and conflicts 46 // with Complex value in CodePath enum. 47 #ifdef Complex 48 #undef Complex 49 #endif 50 45 51 namespace WebCore { 46 52 … … 98 104 void update(PassRefPtr<FontSelector>) const; 99 105 100 void drawText(GraphicsContext*, const TextRun&, const FloatPoint&, int from = 0, int to = -1) const; 106 enum CustomFontNotReadyAction { DoNotPaintIfFontNotReady, UseFallbackIfFontNotReady }; 107 void drawText(GraphicsContext*, const TextRun&, const FloatPoint&, int from = 0, int to = -1, CustomFontNotReadyAction = DoNotPaintIfFontNotReady) const; 101 108 void drawEmphasisMarks(GraphicsContext*, const TextRun&, const AtomicString& mark, const FloatPoint&, int from = 0, int to = -1) const; 102 109 -
trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp
r134348 r135888 29 29 #include "BidiResolver.h" 30 30 #include "BitmapImage.h" 31 #include "Font.h"32 31 #include "Generator.h" 33 32 #include "ImageBuffer.h" … … 405 404 } 406 405 407 void GraphicsContext::drawBidiText(const Font& font, const TextRun& run, const FloatPoint& point )406 void GraphicsContext::drawBidiText(const Font& font, const TextRun& run, const FloatPoint& point, Font::CustomFontNotReadyAction customFontNotReadyAction) 408 407 { 409 408 if (paintingDisabled()) … … 429 428 subrun.setDirectionalOverride(bidiRun->dirOverride(false)); 430 429 431 font.drawText(this, subrun, currPoint );430 font.drawText(this, subrun, currPoint, 0, -1, customFontNotReadyAction); 432 431 433 432 bidiRun = bidiRun->next(); -
trunk/Source/WebCore/platform/graphics/GraphicsContext.h
r134348 r135888 31 31 #include "DashArray.h" 32 32 #include "FloatRect.h" 33 #include "Font.h" 33 34 #include "Gradient.h" 34 35 #include "Image.h" … … 115 116 class AffineTransform; 116 117 class DrawingBuffer; 117 class Font;118 118 class Generator; 119 119 #if !USE(SKIA) … … 356 356 void drawText(const Font&, const TextRun&, const FloatPoint&, int from = 0, int to = -1); 357 357 void drawEmphasisMarks(const Font&, const TextRun& , const AtomicString& mark, const FloatPoint&, int from = 0, int to = -1); 358 void drawBidiText(const Font&, const TextRun&, const FloatPoint& );358 void drawBidiText(const Font&, const TextRun&, const FloatPoint&, Font::CustomFontNotReadyAction = Font::DoNotPaintIfFontNotReady); 359 359 void drawHighlightForText(const Font&, const TextRun&, const FloatPoint&, int h, const Color& backgroundColor, ColorSpace, int from = 0, int to = -1); 360 360
Note:
See TracChangeset
for help on using the changeset viewer.