Changeset 19876 in webkit


Ignore:
Timestamp:
Feb 26, 2007, 9:23:22 PM (18 years ago)
Author:
oliver
Message:

2007-02-26 Oliver Hunt <oliver@apple.com>

Reviewed by Maciej.

Fix for <rdar://problem/4827378>: Canvas with large height
uses lots of memory, computer almost stops responding


Put cap on maximum area of canvas, size is similar too the
maximum size allowed by firefox (firefox seems to to cut off
at area == 32767 * 9358).

Also protect renderer against the possibility of a null context
(this was triggering a CG warning)

  • html/HTMLCanvasElement.cpp: (WebCore::HTMLCanvasElement::createDrawingContext):

Apply maximum canvas area

(WebCore::HTMLCanvasElement::createPlatformImage):

Protect against null CG Context

Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r19875 r19876  
     12007-02-26  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Maciej.
     4
     5        Fix for <rdar://problem/4827378>: Canvas with large height
     6        uses lots of memory, computer almost stops responding
     7         
     8        Put cap on maximum area of canvas, size is similar too the
     9        maximum size allowed by firefox (firefox seems to to cut off
     10        at area == 32767 * 9358).
     11
     12        Also protect renderer against the possibility of a null context
     13        (this was triggering a CG warning)
     14
     15        * html/HTMLCanvasElement.cpp:
     16        (WebCore::HTMLCanvasElement::createDrawingContext):
     17           Apply maximum canvas area
     18        (WebCore::HTMLCanvasElement::createPlatformImage):
     19           Protect against null CG Context
     20
    1212007-02-26  Mitz Pettel  <mitz@webkit.org>
    222
  • trunk/WebCore/html/HTMLCanvasElement.cpp

    r18417 r19876  
    5050const int defaultHeight = 150;
    5151
     52// Firefox limits width/height to 32767 pixels, but slows down dramatically before it
     53// reaches that limit we limit by area instead, giving us larger max dimensions, in exchange
     54// for reduce maximum canvas size.
     55const float maxCanvasArea = 32768 * 8192; // Maximum canvas area in CSS pixels
     56
    5257HTMLCanvasElement::HTMLCanvasElement(Document* doc)
    5358    : HTMLElement(canvasTag, doc)
     
    179184    float hf = ceilf(unscaledHeight * pageScaleFactor);
    180185   
    181     if (!(wf > 0 && wf < UINT_MAX && hf > 0 && hf < UINT_MAX))
     186    if (!(wf >= 1 && hf >= 1 && wf * hf <= maxCanvasArea))
    182187        return;
    183188       
     
    215220    if (!context)
    216221        return 0;
    217     CGContextFlush(context->platformContext());
    218     return CGBitmapContextCreateImage(context->platformContext());
     222   
     223    CGContextRef contextRef = context->platformContext();
     224    if (!contextRef)
     225        return 0;
     226   
     227    CGContextFlush(contextRef);
     228   
     229    return CGBitmapContextCreateImage(contextRef);
    219230}
    220231
Note: See TracChangeset for help on using the changeset viewer.