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

Changeset 273798 in webkit


Ignore:
Timestamp:
Mar 2, 2021, 7:09:02 PM (6 years ago)
Author:
Alan Coon
Message:

Cherry-pick r273512. rdar://problem/74953022

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.

git-svn-id: ​https://svn.webkit.org/repository/webkit/trunk@273512 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-612.1.5-branch
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-612.1.5-branch/LayoutTests/ChangeLog

    r273794 r273798  
     12021-03-02  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r273512. rdar://problem/74953022
     4
     5    REGRESSION(r269957): Empty font names passed to canvas2d cause all text routines to crash
     6    https://bugs.webkit.org/show_bug.cgi?id=222402
     7    <rdar://problem/72621268>
     8   
     9    Reviewed by Darin Adler and Chris Lord.
     10   
     11    Source/WebCore:
     12   
     13    It looks like it was simply an oversight from that patch. If the font name is empty,
     14    CanvasRenderingContext2D::setFont() will set the font object to one that doesn't have
     15    its internal FontCascadeFonts pointer set.
     16   
     17    Tests: fast/text/canvas-font-resolution-2.html
     18           fast/text/canvas-font-resolution.html
     19   
     20    * html/canvas/CanvasRenderingContext2D.cpp:
     21    (WebCore::CanvasRenderingContext2D::setFont):
     22    * html/canvas/CanvasRenderingContext2DBase.h:
     23    (WebCore::CanvasRenderingContext2DBase::FontProxy::isPopulated const):
     24    * style/StyleResolveForFontRaw.cpp:
     25    (WebCore::Style::resolveForFontRaw):
     26   
     27    LayoutTests:
     28   
     29    * fast/text/canvas-font-resolution-2-expected.html: Added.
     30    * fast/text/canvas-font-resolution-2.html: Added.
     31    * fast/text/canvas-font-resolution-expected.txt: Added.
     32    * fast/text/canvas-font-resolution.html: Added.
     33   
     34   
     35    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273512 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     36
     37    2021-02-25  Myles C. Maxfield  <mmaxfield@apple.com>
     38
     39            REGRESSION(r269957): Empty font names passed to canvas2d cause all text routines to crash
     40            https://bugs.webkit.org/show_bug.cgi?id=222402
     41            <rdar://problem/72621268>
     42
     43            Reviewed by Darin Adler and Chris Lord.
     44
     45            * fast/text/canvas-font-resolution-2-expected.html: Added.
     46            * fast/text/canvas-font-resolution-2.html: Added.
     47            * fast/text/canvas-font-resolution-expected.txt: Added.
     48            * fast/text/canvas-font-resolution.html: Added.
     49
    1502021-03-02  Alan Coon  <alancoon@apple.com>
    251
  • branches/safari-612.1.5-branch/Source/WebCore/ChangeLog

    r273797 r273798  
     12021-03-02  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r273512. rdar://problem/74953022
     4
     5    REGRESSION(r269957): Empty font names passed to canvas2d cause all text routines to crash
     6    https://bugs.webkit.org/show_bug.cgi?id=222402
     7    <rdar://problem/72621268>
     8   
     9    Reviewed by Darin Adler and Chris Lord.
     10   
     11    Source/WebCore:
     12   
     13    It looks like it was simply an oversight from that patch. If the font name is empty,
     14    CanvasRenderingContext2D::setFont() will set the font object to one that doesn't have
     15    its internal FontCascadeFonts pointer set.
     16   
     17    Tests: fast/text/canvas-font-resolution-2.html
     18           fast/text/canvas-font-resolution.html
     19   
     20    * html/canvas/CanvasRenderingContext2D.cpp:
     21    (WebCore::CanvasRenderingContext2D::setFont):
     22    * html/canvas/CanvasRenderingContext2DBase.h:
     23    (WebCore::CanvasRenderingContext2DBase::FontProxy::isPopulated const):
     24    * style/StyleResolveForFontRaw.cpp:
     25    (WebCore::Style::resolveForFontRaw):
     26   
     27    LayoutTests:
     28   
     29    * fast/text/canvas-font-resolution-2-expected.html: Added.
     30    * fast/text/canvas-font-resolution-2.html: Added.
     31    * fast/text/canvas-font-resolution-expected.txt: Added.
     32    * fast/text/canvas-font-resolution.html: Added.
     33   
     34   
     35    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273512 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     36
     37    2021-02-25  Myles C. Maxfield  <mmaxfield@apple.com>
     38
     39            REGRESSION(r269957): Empty font names passed to canvas2d cause all text routines to crash
     40            https://bugs.webkit.org/show_bug.cgi?id=222402
     41            <rdar://problem/72621268>
     42
     43            Reviewed by Darin Adler and Chris Lord.
     44
     45            It looks like it was simply an oversight from that patch. If the font name is empty,
     46            CanvasRenderingContext2D::setFont() will set the font object to one that doesn't have
     47            its internal FontCascadeFonts pointer set.
     48
     49            Tests: fast/text/canvas-font-resolution-2.html
     50                   fast/text/canvas-font-resolution.html
     51
     52            * html/canvas/CanvasRenderingContext2D.cpp:
     53            (WebCore::CanvasRenderingContext2D::setFont):
     54            * html/canvas/CanvasRenderingContext2DBase.h:
     55            (WebCore::CanvasRenderingContext2DBase::FontProxy::isPopulated const):
     56            * style/StyleResolveForFontRaw.cpp:
     57            (WebCore::Style::resolveForFontRaw):
     58
    1592021-03-02  Alan Coon  <alancoon@apple.com>
    260
  • branches/safari-612.1.5-branch/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r270197 r273798  
    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
  • branches/safari-612.1.5-branch/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h

    r271646 r273798  
    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&);
  • branches/safari-612.1.5-branch/Source/WebCore/style/StyleResolveForFontRaw.cpp

    r272805 r273798  
    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.