Null-check frame (which is needed when bounds width/height is zero) and clamp negative values to zero. b=570884 r=josh

This commit is contained in:
Mats Palmgren 2010-06-09 21:07:41 +02:00
Родитель 42880f8258
Коммит 7a656c7ffc
3 изменённых файлов: 15 добавлений и 3 удалений

Просмотреть файл

@ -0,0 +1,8 @@
<body>
<embed type="application/x-test" width="20"></embed>
<embed type="application/x-test" width="10"></embed>
<embed type="application/x-test" width="0"></embed>
<embed type="application/x-test" width="20" height="20"></embed>
<embed type="application/x-test" width="10" height="10"></embed>
<embed type="application/x-test" width="0" height="0"></embed>
</body>

Просмотреть файл

@ -4,3 +4,4 @@ load 48856-1.html
load 110650-1.html
skip-if(MOZ_WIDGET_TOOLKIT=="cocoa") script 539897-1.html
script 540114-1.html
load 570884.html

Просмотреть файл

@ -189,7 +189,8 @@ pluginDraw(InstanceData* instanceData, NPCocoaEvent* event)
// Initialize a rectangular path.
CGMutablePathRef path = CGPathCreateMutable();
CGRect bounds = CGRectMake(10.0, 10.0, windowWidth - 20.0, windowHeight - 20.0);
CGRect bounds = CGRectMake(10.0, 10.0, PR_MAX(0.0, windowWidth - 20.0),
PR_MAX(0.0, windowHeight - 20.0));
CGPathAddRect(path, NULL, bounds);
// Initialize an attributed string.
@ -210,8 +211,10 @@ pluginDraw(InstanceData* instanceData, NPCocoaEvent* event)
// Create the frame and draw it into the graphics context
CTFrameRef frame = CTFramesetterCreateFrame(framesetter, CFRangeMake(0, 0), path, NULL);
CFRelease(framesetter);
CTFrameDraw(frame, cgContext);
CFRelease(frame);
if (frame) {
CTFrameDraw(frame, cgContext);
CFRelease(frame);
}
// restore the cgcontext gstate
CGContextRestoreGState(cgContext);