Changeset 28714 in webkit


Ignore:
Timestamp:
Dec 14, 2007, 11:37:12 AM (17 years ago)
Author:
mitz@apple.com
Message:

Reviewed by Darin Adler.

  • platform/graphics/cg/GraphicsContextCG.cpp: (WebCore::GraphicsContext::setShadow): Slightly increase the magnitude of the offsets passed to CGContextSetShadow* to ensure that the end result after truncation is the desired integer offsets.
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r28711 r28714  
     12007-12-14  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        - fix <rdar://problem/5643663> text-shadow and box-shadow offsets 1px smaller than specified
     6          which is the root cause of:
     7          http://bugs.webkit.org/show_bug.cgi?id=12943
     8          box-shadow: small values don't affect shadow position
     9          http://bugs.webkit.org/show_bug.cgi?id=14736
     10          Safari implementation of text-shadow off by 1px
     11
     12        * platform/graphics/cg/GraphicsContextCG.cpp:
     13        (WebCore::GraphicsContext::setShadow): Slightly increase the magnitude
     14        of the offsets passed to CGContextSetShadow* to ensure that the end
     15        result after truncation is the desired integer offsets.
     16
    1172007-12-13  Alp Toker  <alp@atoker.com>
    218
  • trunk/WebCore/platform/graphics/cg/GraphicsContextCG.cpp

    r28588 r28714  
    3131
    3232#include "AffineTransform.h"
     33#include "FloatConversion.h"
    3334#include "GraphicsContextPlatformPrivate.h"
    3435#include "KURL.h"
     
    510511    if (paintingDisabled())
    511512        return;
     513    CGContextRef context = platformContext();
     514
     515    CGFloat width = size.width();
     516    CGFloat height = size.height();
     517
     518#if PLATFORM(MAC)
     519    // Work around <rdar://problem/5539388> by ensuring that the offsets will get truncated
     520    // to the desired integer.
     521    // FIXME: This is not needed post-Leopard.
     522    static const CGFloat extraShadowOffset = narrowPrecisionToCGFloat(1.0 / 128);
     523    if (width > 0)
     524        width += extraShadowOffset;
     525    else if (width < 0)
     526        width -= extraShadowOffset;
     527
     528    if (height > 0)
     529        height += extraShadowOffset;
     530    else if (height < 0)
     531        height -= extraShadowOffset;
     532#endif
     533
    512534    // Check for an invalid color, as this means that the color was not set for the shadow
    513535    // and we should therefore just use the default shadow color.
    514     CGContextRef context = platformContext();
    515536    if (!color.isValid())
    516         CGContextSetShadow(context, CGSizeMake(size.width(), -size.height()), blur); // y is flipped.
     537        CGContextSetShadow(context, CGSizeMake(width, -height), blur); // y is flipped.
    517538    else {
    518539        CGColorRef colorCG = cgColor(color);
    519540        CGContextSetShadowWithColor(context,
    520                                     CGSizeMake(size.width(), -size.height()), // y is flipped.
     541                                    CGSizeMake(width, -height), // y is flipped.
    521542                                    blur,
    522543                                    colorCG);
Note: See TracChangeset for help on using the changeset viewer.