Changeset 62016 in webkit


Ignore:
Timestamp:
Jun 28, 2010 10:00:39 AM (14 years ago)
Author:
commit-queue@webkit.org
Message:

2010-06-28 Robin Cao <robin.cao@torchmobile.com.cn>

Reviewed by Dan Bernstein.

canvas fillText with @font-face crashes
https://bugs.webkit.org/show_bug.cgi?id=35486

The font object in CanvasRenderingContext2D may become invalid at some point.
Override recalcStyle() in HTMLCanvasElement, and update the font object from there if needed.

A test already exists: canvas/philip/tests/2d.text.draw.fontface.repeat.html

  • html/HTMLCanvasElement.cpp: (WebCore::HTMLCanvasElement::recalcStyle):
  • html/HTMLCanvasElement.h:
  • html/canvas/CanvasRenderingContext2D.cpp: (WebCore::CanvasRenderingContext2D::updateFont):
  • html/canvas/CanvasRenderingContext2D.h:
Location:
trunk/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r62015 r62016  
     12010-06-28  Robin Cao  <robin.cao@torchmobile.com.cn>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        canvas fillText with @font-face crashes
     6        https://bugs.webkit.org/show_bug.cgi?id=35486
     7
     8        The font object in CanvasRenderingContext2D may become invalid at some point.
     9        Override recalcStyle() in HTMLCanvasElement, and update the font object from there if needed.
     10
     11        A test already exists: canvas/philip/tests/2d.text.draw.fontface.repeat.html
     12
     13        * html/HTMLCanvasElement.cpp:
     14        (WebCore::HTMLCanvasElement::recalcStyle):
     15        * html/HTMLCanvasElement.h:
     16        * html/canvas/CanvasRenderingContext2D.cpp:
     17        (WebCore::CanvasRenderingContext2D::updateFont):
     18        * html/canvas/CanvasRenderingContext2D.h:
     19
    1202010-06-28  Lucas De Marchi  <lucas.demarchi@profusion.mobi>
    221
  • trunk/WebCore/html/HTMLCanvasElement.cpp

    r61293 r62016  
    22 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
    33 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
     4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
    45 *
    56 * Redistribution and use in source and binary forms, with or without
     
    279280#endif
    280281
    281 }
     282void HTMLCanvasElement::recalcStyle(StyleChange change)
     283{
     284    HTMLElement::recalcStyle(change);
     285
     286    // Update font if needed.
     287    if (change == Force && m_context && m_context->is2d()) {
     288        CanvasRenderingContext2D* ctx = static_cast<CanvasRenderingContext2D*>(m_context.get());
     289        ctx->updateFont();
     290    }
     291}
     292
     293}
  • trunk/WebCore/html/HTMLCanvasElement.h

    r60342 r62016  
    22 * Copyright (C) 2004, 2006, 2009, 2010 Apple Inc. All rights reserved.
    33 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
     4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
    45 *
    56 * Redistribution and use in source and binary forms, with or without
     
    102103    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
    103104
     105    virtual void recalcStyle(StyleChange);
     106
    104107    void reset();
    105108
  • trunk/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r61970 r62016  
    55 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
    66 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org>
     7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
    78 *
    89 * Redistribution and use in source and binary forms, with or without
     
    15021503    state().m_realizedFont = true;
    15031504}
    1504        
     1505
     1506void CanvasRenderingContext2D::updateFont()
     1507{
     1508    if (!state().m_realizedFont)
     1509        return;
     1510
     1511    const Font& font = state().m_font;
     1512    font.update(font.fontSelector());
     1513}
     1514
    15051515String CanvasRenderingContext2D::textAlign() const
    15061516{
  • trunk/WebCore/html/canvas/CanvasRenderingContext2D.h

    r61877 r62016  
    194194        String font() const;
    195195        void setFont(const String&);
     196        void updateFont();
    196197       
    197198        String textAlign() const;
Note: See TracChangeset for help on using the changeset viewer.