Commit 63bcd63c authored by adachan@apple.com's avatar adachan@apple.com
Browse files

Support text shadow in WebDrawText().

        Remove DrawTextAtPoint() since it is only called by WebDrawText().

        Reviewed by Adam.

        * WebKit.vcproj/WebKit.def:
        * WebKit.vcproj/WebKit_debug.def:
        * WebKitGraphics.cpp:
        (WebDrawText):
        * WebKitGraphics.h:
        


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@32717 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7b3b129e
2008-04-29 Ada Chan <adachan@apple.com>
Support text shadow in WebDrawText().
Remove DrawTextAtPoint() since it is only called by WebDrawText().
Reviewed by Adam.
* WebKit.vcproj/WebKit.def:
* WebKit.vcproj/WebKit_debug.def:
* WebKitGraphics.cpp:
(WebDrawText):
* WebKitGraphics.h:
2008-04-29 Adam Roben <aroben@apple.com>
 
Restore the beloved COMPtr::operator&
......
......@@ -92,7 +92,6 @@ EXPORTS
progIDForClass
WebLocalizedStringUTF8
WebLocalizedLPCTSTRUTF8
DrawTextAtPoint
WebDrawText
FontMetrics
TextFloatWidth
......
......@@ -92,7 +92,6 @@ EXPORTS
progIDForClass
WebLocalizedStringUTF8
WebLocalizedLPCTSTRUTF8
DrawTextAtPoint
WebDrawText
FontMetrics
TextFloatWidth
......
......@@ -70,19 +70,25 @@ static Font makeFont(const WebFontDescription& description)
return font;
}
void DrawTextAtPoint(CGContextRef cgContext, LPCTSTR text, int length, POINT point, const WebFontDescription& description, CGColorRef color, int underlinedIndex, bool drawAsPassword)
// Text shadow is added post 3.1.1. In order for nightlies to not break Safari 3.1.1, we should still allow
// the old WebTextRenderInfo that has a smaller structSize than the current one with the new text shadow data members.
struct WebTextRenderInfoWithoutShadow
{
GraphicsContext context(cgContext);
String drawString(text, length);
if (drawAsPassword)
drawString = drawString.impl()->secure(WebCore::bullet);
WebCoreDrawTextAtPoint(context, drawString, point, makeFont(description), color, underlinedIndex);
}
DWORD structSize;
CGContextRef cgContext;
LPCTSTR text;
int length;
POINT pt;
const WebFontDescription* description;
CGColorRef color;
int underlinedIndex;
bool drawAsPassword;
int overrideSmoothingLevel; // pass in -1 if caller does not want to override smoothing level
};
void WebDrawText(WebTextRenderInfo* info)
{
if (!info || info->structSize != sizeof(WebTextRenderInfo) || !info->cgContext || !info->description)
if (!info || info->structSize < sizeof(WebTextRenderInfoWithoutShadow) || !info->cgContext || !info->description)
return;
int oldFontSmoothingLevel = -1;
......@@ -91,7 +97,22 @@ void WebDrawText(WebTextRenderInfo* info)
wkSetFontSmoothingLevel(info->overrideSmoothingLevel);
}
DrawTextAtPoint(info->cgContext, info->text, info->length, info->pt, *(info->description), info->color, info->underlinedIndex, info->drawAsPassword);
{
GraphicsContext context(info->cgContext);
String drawString(info->text, info->length);
if (info->drawAsPassword)
drawString = drawString.impl()->secure(WebCore::bullet);
context.save();
// Set shadow setting
if (info->structSize == sizeof(WebTextRenderInfo) &&
(info->shadowOffset.cx || info->shadowOffset.cy || info->shadowBlur || info->shadowColor))
context.setShadow(info->shadowOffset, info->shadowBlur, info->shadowColor);
WebCoreDrawTextAtPoint(context, drawString, info->pt, makeFont(*(info->description)), info->color, info->underlinedIndex);
context.restore();
}
if (info->overrideSmoothingLevel >= 0)
wkSetFontSmoothingLevel(oldFontSmoothingLevel);
......
......@@ -56,9 +56,11 @@ struct WebTextRenderInfo
int underlinedIndex;
bool drawAsPassword;
int overrideSmoothingLevel; // pass in -1 if caller does not want to override smoothing level
SIZE shadowOffset;
int shadowBlur;
CGColorRef shadowColor;
};
void DrawTextAtPoint(CGContextRef, LPCTSTR text, int length, POINT, const WebFontDescription&, CGColorRef, int underlinedIndex = -1, bool drawAsPassword = false);
void WebDrawText(WebTextRenderInfo*);
float TextFloatWidth(LPCTSTR text, int length, const WebFontDescription&);
void FontMetrics(const WebFontDescription&, int* ascent, int* descent, int* lineSpacing);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment