⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 273512 in webkit


Ignore:
Timestamp:
Feb 25, 2021, 2:14:16 PM (6 years ago)
Author:
mmaxfield@apple.com
Message:

REGRESSION(r269957): Empty font names passed to canvas2d cause all text routines to crash
​https://bugs.webkit.org/show_bug.cgi?id=222402
<rdar://problem/72621268>

Reviewed by Darin Adler and Chris Lord.

Source/WebCore:

It looks like it was simply an oversight from that patch. If the font name is empty,
CanvasRenderingContext2D::setFont() will set the font object to one that doesn't have
its internal FontCascadeFonts pointer set.

Tests: fast/text/canvas-font-resolution-2.html

fast/text/canvas-font-resolution.html

  • html/canvas/CanvasRenderingContext2D.cpp:

(WebCore::CanvasRenderingContext2D::setFont):

  • html/canvas/CanvasRenderingContext2DBase.h:

(WebCore::CanvasRenderingContext2DBase::FontProxy::isPopulated const):

  • style/StyleResolveForFontRaw.cpp:

(WebCore::Style::resolveForFontRaw):

LayoutTests:

  • fast/text/canvas-font-resolution-2-expected.html: Added.
  • fast/text/canvas-font-resolution-2.html: Added.
  • fast/text/canvas-font-resolution-expected.txt: Added.
  • fast/text/canvas-font-resolution.html: Added.
Location:
trunk
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r273507 r273512  
     12021-02-25  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        REGRESSION(r269957): Empty font names passed to canvas2d cause all text routines to crash
     4        https://bugs.webkit.org/show_bug.cgi?id=222402
     5        <rdar://problem/72621268>
     6
     7        Reviewed by Darin Adler and Chris Lord.
     8
     9        * fast/text/canvas-font-resolution-2-expected.html: Added.
     10        * fast/text/canvas-font-resolution-2.html: Added.
     11        * fast/text/canvas-font-resolution-expected.txt: Added.
     12        * fast/text/canvas-font-resolution.html: Added.
     13
    1142021-02-25  Amir Mark Jr  <amir_mark@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r273511 r273512  
     12021-02-25  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        REGRESSION(r269957): Empty font names passed to canvas2d cause all text routines to crash
     4        https://bugs.webkit.org/show_bug.cgi?id=222402
     5        <rdar://problem/72621268>
     6
     7        Reviewed by Darin Adler and Chris Lord.
     8
     9        It looks like it was simply an oversight from that patch. If the font name is empty,
     10        CanvasRenderingContext2D::setFont() will set the font object to one that doesn't have
     11        its internal FontCascadeFonts pointer set.
     12
     13        Tests: fast/text/canvas-font-resolution-2.html
     14               fast/text/canvas-font-resolution.html
     15
     16        * html/canvas/CanvasRenderingContext2D.cpp:
     17        (WebCore::CanvasRenderingContext2D::setFont):
     18        * html/canvas/CanvasRenderingContext2DBase.h:
     19        (WebCore::CanvasRenderingContext2DBase::FontProxy::isPopulated const):
     20        * style/StyleResolveForFontRaw.cpp:
     21        (WebCore::Style::resolveForFontRaw):
     22
    1232021-02-25  Alex Christensen  <achristensen@webkit.org>
    224
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r270197 r273512  
    113113        return;
    114114
    115     // The parse succeeded.
    116     String newFontSafeCopy(newFont); // Create a string copy since newFont can be deleted inside realizeSaves.
    117     realizeSaves();
    118     modifiableState().unparsedFont = newFontSafeCopy;
    119 
    120115    // Map the <canvas> font into the text style. If the font uses keywords like larger/smaller, these will work
    121116    // relative to the canvas.
    … …  
    132127    }
    133128
    134     if (auto fontStyle = Style::resolveForFontRaw(*fontRaw, WTFMove(fontDescription), document))
    135         modifiableState().font.initialize(document.fontSelector(), *fontStyle);
     129    auto fontStyle = Style::resolveForFontRaw(*fontRaw, WTFMove(fontDescription), document);
     130    if (!fontStyle)
     131        return;
     132
     133    String newFontSafeCopy(newFont); // Create a string copy since newFont can be deleted inside realizeSaves.
     134    realizeSaves();
     135    modifiableState().unparsedFont = newFontSafeCopy;
     136
     137    modifiableState().font.initialize(document.fontSelector(), *fontStyle);
     138    ASSERT(state().font.realized());
     139    ASSERT(state().font.isPopulated());
    136140}
    137141
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h

    r271646 r273512  
    242242        void drawBidiText(GraphicsContext&, const TextRun&, const FloatPoint&, FontCascade::CustomFontNotReadyAction) const;
    243243
     244#if ASSERT_ENABLED
     245        bool isPopulated() const { return m_font.fonts(); }
     246#endif
     247
    244248    private:
    245249        void update(FontSelector&);
  • trunk/Source/WebCore/style/StyleResolveForFontRaw.cpp

    r272805 r273512  
    7474        switchOn(item, [&] (CSSValueID ident) {
    7575            isGenericFamily = ident != CSSValueWebkitBody;
    76             family = isGenericFamily ? CSSPropertyParserHelpers::genericFontFamilyFromValueID(ident)
    77                 : AtomString(document.settings().standardFontFamily());
     76            family = isGenericFamily ? CSSPropertyParserHelpers::genericFontFamilyFromValueID(ident) : AtomString(document.settings().standardFontFamily());
    7877        }, [&] (const String& familyString) {
    7978            family = familyString;
Note: See TracChangeset for help on using the changeset viewer.