Commit 9e07e880 authored by hyatt's avatar hyatt

Merge WebCoreTextRenderer into WebTextRenderer. Merge WebCoreTextRendererFactory

        into WebTextRendererFactory.  Change all callers to refer to the concrete classes
        now.  Change WebCoreTextRenderer.h to be the public API that WebKit uses when
        it calls in to WebCore.  Clean up the exports to remove things WebKit no longer
        needs.

        Reviewed by darin

        * WebCore.exp:
        * WebCore.xcodeproj/project.pbxproj:
        * bridge/mac/WebCoreStringTruncator.mm:
        (stringWidth):
        (truncateString):
        (+[WebCoreStringTruncator widthOfString:font:]):
        * kwq/KWQComboBox.mm:
        (QComboBox::sizeHint):
        * kwq/KWQLineEdit.mm:
        (QLineEdit::sizeForCharacterWidth):
        * kwq/KWQListBox.mm:
        (itemTextRenderer):
        (groupLabelTextRenderer):
        (QListBox::sizeForNumberOfLines):
        (-[KWQTableView drawRow:clipRect:]):
        * platform/Font.h:
        * platform/FontDataSet.h:
        * platform/mac/FontMac.mm:
        (WebCore::FontDataSet::getWebCoreFont):
        (WebCore::FontDataSet::getRenderer):
        (WebCore::FontDataSet::determinePitch):
        * platform/mac/WebCoreTextRenderer.h:
        * platform/mac/WebCoreTextRendererFactory.mm:
        (-[WebCoreTextRendererFactory init]):
        * platform/mac/WebTextRenderer.h:
        * platform/mac/WebTextRenderer.mm:
        * platform/mac/WebTextRendererFactory.h:
        * platform/mac/WebTextRendererFactory.mm:
        (WebCoreInitializeFont):
        (WebCoreInitializeTextRun):
        (WebCoreInitializeEmptyTextStyle):
        (WebCoreInitializeEmptyTextGeometry):
        (-[WebTextRendererFactory clearCaches]):
        (+[WebTextRendererFactory createSharedFactory]):
        (+[WebTextRendererFactory sharedFactory]):
        (-[WebTextRendererFactory init]):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@14115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6cc39b92
2006-04-28 David Hyatt <hyatt@apple.com>
Merge WebCoreTextRenderer into WebTextRenderer. Merge WebCoreTextRendererFactory
into WebTextRendererFactory. Change all callers to refer to the concrete classes
now. Change WebCoreTextRenderer.h to be the public API that WebKit uses when
it calls in to WebCore. Clean up the exports to remove things WebKit no longer
needs.
Reviewed by darin
* WebCore.exp:
* WebCore.xcodeproj/project.pbxproj:
* bridge/mac/WebCoreStringTruncator.mm:
(stringWidth):
(truncateString):
(+[WebCoreStringTruncator widthOfString:font:]):
* kwq/KWQComboBox.mm:
(QComboBox::sizeHint):
* kwq/KWQLineEdit.mm:
(QLineEdit::sizeForCharacterWidth):
* kwq/KWQListBox.mm:
(itemTextRenderer):
(groupLabelTextRenderer):
(QListBox::sizeForNumberOfLines):
(-[KWQTableView drawRow:clipRect:]):
* platform/Font.h:
* platform/FontDataSet.h:
* platform/mac/FontMac.mm:
(WebCore::FontDataSet::getWebCoreFont):
(WebCore::FontDataSet::getRenderer):
(WebCore::FontDataSet::determinePitch):
* platform/mac/WebCoreTextRenderer.h:
* platform/mac/WebCoreTextRendererFactory.mm:
(-[WebCoreTextRendererFactory init]):
* platform/mac/WebTextRenderer.h:
* platform/mac/WebTextRenderer.mm:
* platform/mac/WebTextRendererFactory.h:
* platform/mac/WebTextRendererFactory.mm:
(WebCoreInitializeFont):
(WebCoreInitializeTextRun):
(WebCoreInitializeEmptyTextStyle):
(WebCoreInitializeEmptyTextGeometry):
(-[WebTextRendererFactory clearCaches]):
(+[WebTextRendererFactory createSharedFactory]):
(+[WebTextRendererFactory sharedFactory]):
(-[WebTextRendererFactory init]):
2006-04-28 David Hyatt <hyatt@apple.com>
Fix for 8586, move WebTextRenderer into WebCore.
......@@ -116,13 +116,8 @@
.objc_class_name_WebCoreStringTruncator
.objc_class_name_WebCoreSettings
.objc_class_name_WebCoreTextDecoder
.objc_class_name_WebCoreTextRendererFactory
.objc_class_name_WebCoreViewFactory
.objc_class_name_WebDashboardRegion
_WebCoreInitializeEmptyTextGeometry
_WebCoreInitializeEmptyTextStyle
_WebCoreInitializeFont
_WebCoreInitializeTextRun
_WebCorePageCacheStateKey
_WebCoreDrawTextAtPoint
_WebCoreTextFloatWidth
......
......@@ -993,8 +993,6 @@
BC066F3909FEAF5300C589A7 /* WebTextRendererFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = BC066F3509FEAF5300C589A7 /* WebTextRendererFactory.h */; };
BC066F3A09FEAF5300C589A7 /* WebTextRendererFactory.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC066F3609FEAF5300C589A7 /* WebTextRendererFactory.mm */; };
BC066F6F09FEB2FA00C589A7 /* WebCoreTextRenderer.h in Headers */ = {isa = PBXBuildFile; fileRef = BC066F6C09FEB2FA00C589A7 /* WebCoreTextRenderer.h */; settings = {ATTRIBUTES = (Private, ); }; };
BC066F7009FEB2FA00C589A7 /* WebCoreTextRendererFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = BC066F6D09FEB2FA00C589A7 /* WebCoreTextRendererFactory.h */; };
BC066F7109FEB2FA00C589A7 /* WebCoreTextRendererFactory.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC066F6E09FEB2FA00C589A7 /* WebCoreTextRendererFactory.mm */; };
BC1A37AD097C715F0019F3D8 /* DOM.h in Headers */ = {isa = PBXBuildFile; fileRef = BC1A3797097C715F0019F3D8 /* DOM.h */; settings = {ATTRIBUTES = (Private, ); }; };
BC1A37AE097C715F0019F3D8 /* DOM.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC1A3798097C715F0019F3D8 /* DOM.mm */; };
BC1A37AF097C715F0019F3D8 /* DOMCore.h in Headers */ = {isa = PBXBuildFile; fileRef = BC1A3799097C715F0019F3D8 /* DOMCore.h */; settings = {ATTRIBUTES = (Private, ); }; };
......@@ -2275,8 +2273,6 @@
BC066F3509FEAF5300C589A7 /* WebTextRendererFactory.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebTextRendererFactory.h; sourceTree = "<group>"; };
BC066F3609FEAF5300C589A7 /* WebTextRendererFactory.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebTextRendererFactory.mm; sourceTree = "<group>"; };
BC066F6C09FEB2FA00C589A7 /* WebCoreTextRenderer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCoreTextRenderer.h; sourceTree = "<group>"; };
BC066F6D09FEB2FA00C589A7 /* WebCoreTextRendererFactory.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCoreTextRendererFactory.h; sourceTree = "<group>"; };
BC066F6E09FEB2FA00C589A7 /* WebCoreTextRendererFactory.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreTextRendererFactory.mm; sourceTree = "<group>"; };
BC06F24906D18A7E004A6FA3 /* XSLStyleSheet.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XSLStyleSheet.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
BC06F24A06D18A7E004A6FA3 /* XSLStyleSheet.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = XSLStyleSheet.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
BC06F24B06D18A7E004A6FA3 /* XSLTProcessor.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XSLTProcessor.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
......@@ -2843,8 +2839,6 @@
9352071C09BD3BBB00F2038D /* WebCoreWidgetHolder.h */,
BCFE8E310A02A1D30009E61D /* WebCoreTextRenderer.mm */,
BC066F6C09FEB2FA00C589A7 /* WebCoreTextRenderer.h */,
BC066F6D09FEB2FA00C589A7 /* WebCoreTextRendererFactory.h */,
BC066F6E09FEB2FA00C589A7 /* WebCoreTextRendererFactory.mm */,
BC066F3309FEAF5300C589A7 /* WebTextRenderer.h */,
BC066F3409FEAF5300C589A7 /* WebTextRenderer.mm */,
BC066F3509FEAF5300C589A7 /* WebTextRendererFactory.h */,
......@@ -4848,7 +4842,6 @@
BC066F3709FEAF5300C589A7 /* WebTextRenderer.h in Headers */,
BC066F3909FEAF5300C589A7 /* WebTextRendererFactory.h in Headers */,
BC066F6F09FEB2FA00C589A7 /* WebCoreTextRenderer.h in Headers */,
BC066F7009FEB2FA00C589A7 /* WebCoreTextRendererFactory.h in Headers */,
14DC0D3809FED073007B0235 /* JSNode.h in Headers */,
14D0C82509FF0EF5006B36D9 /* kjs_domnode.h in Headers */,
142011B70A003133008303F9 /* JSCSSStyleDeclaration.h in Headers */,
......@@ -5566,7 +5559,6 @@
65901A4509FC6039005BD752 /* WebCoreStringTruncator.mm in Sources */,
BC066F3809FEAF5300C589A7 /* WebTextRenderer.mm in Sources */,
BC066F3A09FEAF5300C589A7 /* WebTextRendererFactory.mm in Sources */,
BC066F7109FEB2FA00C589A7 /* WebCoreTextRendererFactory.mm in Sources */,
BCFE8E320A02A1D30009E61D /* WebCoreTextRenderer.mm in Sources */,
14DC0D3709FED073007B0235 /* JSNode.cpp in Sources */,
142011B60A003133008303F9 /* JSCSSStyleDeclaration.cpp in Sources */,
......
......@@ -39,7 +39,7 @@
#define ELLIPSIS_CHARACTER 0x2026
static NSFont *currentFont;
static id<WebCoreTextRenderer> currentRenderer;
static WebTextRenderer* currentRenderer;
static float currentEllipsisWidth;
typedef unsigned TruncationFunction(NSString *string, unsigned length, unsigned keepCount, unichar *buffer);
......@@ -79,7 +79,7 @@ static unsigned rightTruncateToBuffer(NSString *string, unsigned length, unsigne
return keepRange.length + 1;
}
static float stringWidth(id<WebCoreTextRenderer> renderer, const unichar *characters, unsigned length)
static float stringWidth(WebTextRenderer* renderer, const unichar *characters, unsigned length)
{
WebCoreTextRun run;
WebCoreInitializeTextRun (&run, characters, length, 0, length);
......@@ -116,7 +116,7 @@ static NSString *truncateString(NSString *string, float maxWidth, NSFont *font,
WebCoreFont f;
WebCoreInitializeFont(&f);
f.font = font;
currentRenderer = [[[WebCoreTextRendererFactory sharedFactory] rendererWithFont:f] retain];
currentRenderer = [[[WebTextRendererFactory sharedFactory] rendererWithFont:f] retain];
ellipsis = ELLIPSIS_CHARACTER;
currentEllipsisWidth = stringWidth(currentRenderer, &ellipsis, 1);
}
......@@ -225,7 +225,7 @@ static NSFont *defaultMenuFont(void)
WebCoreFont f;
WebCoreInitializeFont(&f);
f.font = font;
float width = stringWidth([[WebCoreTextRendererFactory sharedFactory] rendererWithFont:f], s, length);
float width = stringWidth([[WebTextRendererFactory sharedFactory] rendererWithFont:f], s, length);
free(s);
return width;
}
......
......@@ -30,7 +30,8 @@
#import "FoundationExtras.h"
#import "FrameMac.h"
#import "WebCoreFrameBridge.h"
#import "WebCoreTextRenderer.h"
#import "WebTextRenderer.h"
#import "WebTextRendererFactory.h"
#import "WebCoreWidgetHolder.h"
#import "render_form.h"
......@@ -167,8 +168,8 @@ IntSize QComboBox::sizeHint() const
WebCoreInitializeFont(&itemFont);
itemFont.font = [button font];
itemFont.forPrinter = ![NSGraphicsContext currentContextDrawingToScreen];
id <WebCoreTextRenderer> itemRenderer = [[WebCoreTextRendererFactory sharedFactory] rendererWithFont:itemFont];
id <WebCoreTextRenderer> labelRenderer = nil;
WebTextRenderer* itemRenderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:itemFont];
WebTextRenderer* labelRenderer = nil;
WebCoreTextStyle style;
WebCoreInitializeEmptyTextStyle(&style);
style.applyRunRounding = NO;
......@@ -182,14 +183,14 @@ IntSize QComboBox::sizeHint() const
int length = s.length();
WebCoreInitializeTextRun(&run, reinterpret_cast<const UniChar *>(s.unicode()), length, 0, length);
id <WebCoreTextRenderer> renderer;
WebTextRenderer* renderer;
if (isGroupLabel) {
if (labelRenderer == nil) {
WebCoreFont labelFont;
WebCoreInitializeFont(&labelFont);
labelFont.font = this->labelFont();
labelFont.forPrinter = ![NSGraphicsContext currentContextDrawingToScreen];
labelRenderer = [[WebCoreTextRendererFactory sharedFactory] rendererWithFont:labelFont];
labelRenderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:labelFont];
}
renderer = labelRenderer;
} else {
......
......@@ -33,8 +33,8 @@
#import "Logging.h"
#import "WebCoreTextField.h"
#import "WebCoreFrameBridge.h"
#import "WebCoreTextRenderer.h"
#import "WebCoreTextRendererFactory.h"
#import "WebTextRenderer.h"
#import "WebTextRendererFactory.h"
#import "WebCoreViewFactory.h"
#import "WidgetClient.h"
......@@ -265,7 +265,7 @@ IntSize QLineEdit::sizeForCharacterWidth(int numCharacters) const
WebCoreInitializeFont(&font);
font.font = [textField font];
font.forPrinter = ![NSGraphicsContext currentContextDrawingToScreen];
id <WebCoreTextRenderer> renderer = [[WebCoreTextRendererFactory sharedFactory] rendererWithFont:font];
WebTextRenderer* renderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:font];
NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
size.height += [layoutManager defaultLineHeightForFont:font.font];
......
......@@ -29,8 +29,8 @@
#import "BlockExceptions.h"
#import "FrameMac.h"
#import "WebCoreFrameBridge.h"
#import "WebCoreTextRenderer.h"
#import "WebCoreTextRendererFactory.h"
#import "WebTextRenderer.h"
#import "WebTextRendererFactory.h"
#import "WebCoreWidgetHolder.h"
#import <kxmlcore/Assertions.h>
......@@ -66,10 +66,10 @@ const float rightMargin = 2;
- (void)fontChanged;
@end
static id <WebCoreTextRenderer> itemScreenRenderer;
static id <WebCoreTextRenderer> itemPrinterRenderer;
static id <WebCoreTextRenderer> groupLabelScreenRenderer;
static id <WebCoreTextRenderer> groupLabelPrinterRenderer;
static WebTextRenderer* itemScreenRenderer;
static WebTextRenderer* itemPrinterRenderer;
static WebTextRenderer* groupLabelScreenRenderer;
static WebTextRenderer* groupLabelPrinterRenderer;
static NSFont *itemFont()
{
......@@ -77,14 +77,14 @@ static NSFont *itemFont()
return font;
}
static id <WebCoreTextRenderer> itemTextRenderer()
static WebTextRenderer* itemTextRenderer()
{
if ([NSGraphicsContext currentContextDrawingToScreen]) {
if (itemScreenRenderer == nil) {
WebCoreFont font;
WebCoreInitializeFont(&font);
font.font = itemFont();
itemScreenRenderer = [[[WebCoreTextRendererFactory sharedFactory] rendererWithFont:font] retain];
itemScreenRenderer = [[[WebTextRendererFactory sharedFactory] rendererWithFont:font] retain];
}
return itemScreenRenderer;
} else {
......@@ -93,20 +93,20 @@ static id <WebCoreTextRenderer> itemTextRenderer()
WebCoreInitializeFont(&font);
font.font = itemFont();
font.forPrinter = YES;
itemPrinterRenderer = [[[WebCoreTextRendererFactory sharedFactory] rendererWithFont:font] retain];
itemPrinterRenderer = [[[WebTextRendererFactory sharedFactory] rendererWithFont:font] retain];
}
return itemPrinterRenderer;
}
}
static id <WebCoreTextRenderer> groupLabelTextRenderer()
static WebTextRenderer* groupLabelTextRenderer()
{
if ([NSGraphicsContext currentContextDrawingToScreen]) {
if (groupLabelScreenRenderer == nil) {
WebCoreFont font;
WebCoreInitializeFont(&font);
font.font = [NSFont boldSystemFontOfSize:[NSFont smallSystemFontSize]];
groupLabelScreenRenderer = [[[WebCoreTextRendererFactory sharedFactory] rendererWithFont:font] retain];
groupLabelScreenRenderer = [[[WebTextRendererFactory sharedFactory] rendererWithFont:font] retain];
}
return groupLabelScreenRenderer;
} else {
......@@ -115,7 +115,7 @@ static id <WebCoreTextRenderer> groupLabelTextRenderer()
WebCoreInitializeFont(&font);
font.font = [NSFont boldSystemFontOfSize:[NSFont smallSystemFontSize]];
font.forPrinter = YES;
groupLabelPrinterRenderer = [[[WebCoreTextRendererFactory sharedFactory] rendererWithFont:font] retain];
groupLabelPrinterRenderer = [[[WebTextRendererFactory sharedFactory] rendererWithFont:font] retain];
}
return groupLabelPrinterRenderer;
}
......@@ -279,19 +279,19 @@ IntSize QListBox::sizeForNumberOfLines(int lines) const
style.applyRunRounding = NO;
style.applyWordRounding = NO;
id <WebCoreTextRenderer> renderer;
id <WebCoreTextRenderer> groupLabelRenderer;
WebTextRenderer* renderer;
WebTextRenderer* groupLabelRenderer;
if (tableView->isSystemFont) {
renderer = itemTextRenderer();
groupLabelRenderer = groupLabelTextRenderer();
} else {
renderer = [[WebCoreTextRendererFactory sharedFactory] rendererWithFont:font().getWebCoreFont()];
renderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:font().getWebCoreFont()];
FontDescription boldDesc = font().fontDescription();
boldDesc.setWeight(cBoldWeight);
Font b = Font(boldDesc, font().letterSpacing(), font().wordSpacing());
b.update();
groupLabelRenderer = [[WebCoreTextRendererFactory sharedFactory] rendererWithFont:b.getWebCoreFont()];
groupLabelRenderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:b.getWebCoreFont()];
}
do {
......@@ -687,7 +687,7 @@ static Boolean KWQTableViewTypeSelectCallback(UInt32 index, void *listDataPtr, v
bool rtl = _direction == NSWritingDirectionRightToLeft;
id <WebCoreTextRenderer> renderer;
WebTextRenderer* renderer;
if (isSystemFont) {
renderer = (item.type == KWQListBoxGroupLabel) ? groupLabelTextRenderer() : itemTextRenderer();
} else {
......@@ -696,10 +696,10 @@ static Boolean KWQTableViewTypeSelectCallback(UInt32 index, void *listDataPtr, v
boldDesc.setWeight(cBoldWeight);
Font b = Font(boldDesc, _box->font().letterSpacing(), _box->font().wordSpacing());
b.update();
renderer = [[WebCoreTextRendererFactory sharedFactory] rendererWithFont:b.getWebCoreFont()];
renderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:b.getWebCoreFont()];
}
else
renderer = [[WebCoreTextRendererFactory sharedFactory] rendererWithFont:_box->font().getWebCoreFont()];
renderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:_box->font().getWebCoreFont()];
}
WebCoreTextStyle style;
......
......@@ -31,7 +31,20 @@
#include "TextDirection.h"
#if __APPLE__
#include "WebCoreTextRendererFactory.h"
#ifdef __OBJC__
@class NSFont;
#else
class NSFont;
#endif
struct WebCoreFont {
NSFont *font;
bool syntheticBold;
bool syntheticOblique;
bool forPrinter;
};
#endif
namespace WebCore {
......
......@@ -26,6 +26,14 @@
#include <kxmlcore/Vector.h>
#ifdef __APPLE__
#ifdef __OBJC__
@class WebTextRenderer;
#else
class WebTextRenderer;
#endif
#endif
namespace WebCore {
class Font;
......@@ -47,12 +55,8 @@ public:
private:
mutable Pitch m_pitch;
#if __APPLE__
#if __OBJC__
id <WebCoreTextRenderer> m_renderer;
id <WebCoreTextRenderer> getRenderer(const FontDescription&);
#else
void* m_renderer;
#endif
WebTextRenderer* m_renderer;
WebTextRenderer* getRenderer(const FontDescription&);
mutable WebCoreFont m_webCoreFont;
const WebCoreFont& getWebCoreFont(const FontDescription&) const;
#else
......
......@@ -34,7 +34,9 @@
#import "GraphicsContext.h"
#import "KWQKHTMLSettings.h"
#import "WebCoreTextRenderer.h"
#import "WebTextRenderer.h"
#import "WebTextRendererFactory.h"
#import "IntRect.h"
namespace WebCore {
......@@ -61,7 +63,7 @@ const WebCoreFont& FontDataSet::getWebCoreFont(const FontDescription& fontDescri
traits |= NSItalicFontMask;
if (fontDescription.weight() >= WebCore::cBoldWeight)
traits |= NSBoldFontMask;
m_webCoreFont = [[WebCoreTextRendererFactory sharedFactory]
m_webCoreFont = [[WebTextRendererFactory sharedFactory]
fontWithFamilies:families traits:traits size:fontDescription.computedPixelSize()];
KWQRetain(m_webCoreFont.font);
m_webCoreFont.forPrinter = fontDescription.usePrinterFont();
......@@ -70,16 +72,16 @@ const WebCoreFont& FontDataSet::getWebCoreFont(const FontDescription& fontDescri
return m_webCoreFont;
}
id <WebCoreTextRenderer> FontDataSet::getRenderer(const FontDescription& fontDescription)
WebTextRenderer* FontDataSet::getRenderer(const FontDescription& fontDescription)
{
if (!m_renderer)
m_renderer = KWQRetain([[WebCoreTextRendererFactory sharedFactory] rendererWithFont:getWebCoreFont(fontDescription)]);
m_renderer = KWQRetain([[WebTextRendererFactory sharedFactory] rendererWithFont:getWebCoreFont(fontDescription)]);
return m_renderer;
}
void FontDataSet::determinePitch(const FontDescription& fontDescription) const {
BEGIN_BLOCK_OBJC_EXCEPTIONS;
if ([[WebCoreTextRendererFactory sharedFactory] isFontFixedPitch:getWebCoreFont(fontDescription)])
if ([[WebTextRendererFactory sharedFactory] isFontFixedPitch:getWebCoreFont(fontDescription)])
m_pitch = FixedPitch;
else
m_pitch = VariablePitch;
......
/*
* Copyright (C) 2004 Apple Computer, Inc. All rights reserved.
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -25,88 +25,17 @@
#import <Cocoa/Cocoa.h>
struct WebCoreTextStyle
{
NSColor *textColor;
NSColor *backgroundColor;
int letterSpacing;
int wordSpacing;
int padding;
int tabWidth;
int xpos;
NSString **families;
bool smallCaps;
bool rtl;
bool directionalOverride;
bool applyRunRounding;
bool applyWordRounding;
bool attemptFontSubstitution;
};
struct WebCoreTextRun
{
const UniChar *characters;
unsigned int length;
int from;
int to;
};
struct WebCoreTextGeometry
{
NSPoint point;
float selectionY;
float selectionHeight;
bool useFontMetricsForSelectionYAndHeight;
};
#ifdef __cplusplus
extern "C" {
#endif
typedef struct WebCoreTextRun WebCoreTextRun;
typedef struct WebCoreTextStyle WebCoreTextStyle;
typedef struct WebCoreTextGeometry WebCoreTextGeometry;
extern void WebCoreInitializeTextRun(WebCoreTextRun *run, const UniChar *characters, unsigned int length, int from, int to);
extern void WebCoreInitializeEmptyTextStyle(WebCoreTextStyle *style);
extern void WebCoreInitializeEmptyTextGeometry(WebCoreTextGeometry *geometry);
extern void WebCoreDrawTextAtPoint(const UniChar*, unsigned length, NSPoint, NSFont*, NSColor*);
extern float WebCoreTextFloatWidth(const UniChar*, unsigned length, NSFont*);
extern void WebCoreSetShouldUseFontSmoothing(bool);
extern bool WebCoreShouldUseFontSmoothing();
extern void WebCoreSetAlwaysUseATSU(bool);
extern NSFont* WebCoreFindFont(NSString* familyName, NSFontTraitMask, int size);
#ifdef __cplusplus
}
#endif
@protocol WebCoreTextRenderer <NSObject>
// WebCoreTextRenderer must guarantee that no calls to any of these
// methods will raise any ObjC exceptions. It's too expensive to do
// blocking for all of them at the WebCore level, and some
// implementations may be able to guarantee no exceptions without the
// use of NS_DURING.
// vertical metrics
- (int)ascent;
- (int)descent;
- (int)lineSpacing;
- (float)xHeight;
// horizontal metrics
- (float)floatWidthForRun:(const WebCoreTextRun *)run style:(const WebCoreTextStyle *)style;
// drawing
- (void)drawRun:(const WebCoreTextRun *)run style:(const WebCoreTextStyle *)style geometry:(const WebCoreTextGeometry *)geometry;
- (NSRect)selectionRectForRun:(const WebCoreTextRun *)run style:(const WebCoreTextStyle *)style geometry:(const WebCoreTextGeometry *)geometry;
- (void)drawHighlightForRun:(const WebCoreTextRun *)run style:(const WebCoreTextStyle *)style geometry:(const WebCoreTextGeometry *)geometry;
- (void)drawLineForCharacters:(NSPoint)point yOffset:(float)yOffset width: (int)width color:(NSColor *)color thickness:(float)thickness;
- (void)drawLineForMisspelling:(NSPoint)point withWidth:(int)width;
- (int)misspellingLineThickness;
// selection point check
- (int)pointToOffset:(const WebCoreTextRun *)run style:(const WebCoreTextStyle *)style position:(int)x includePartialGlyphs:(BOOL)includePartialGlyphs;
@end
/*
* Copyright (C) 2004 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
@protocol WebCoreTextRenderer;
#else
class NSFont;
#endif
typedef struct WebCoreFont {
NSFont *font;
bool syntheticBold;
bool syntheticOblique;
bool forPrinter;
} WebCoreFont;
#ifdef __cplusplus
extern "C" {
#endif
extern void WebCoreInitializeFont(WebCoreFont *font);
#ifdef __cplusplus
}
#endif
#ifdef __OBJC__
@interface WebCoreTextRendererFactory : NSObject
+ (WebCoreTextRendererFactory *)sharedFactory;
- (WebCoreFont)fontWithFamilies:(NSString **)families traits:(NSFontTraitMask)traits size:(float)size;
- (BOOL)isFontFixedPitch:(WebCoreFont)font;
- (id <WebCoreTextRenderer>)rendererWithFont:(WebCoreFont)font;
- (void)clearCaches;
@end
#endif
/*
* Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "config.h"
#import "WebTextRendererFactory.h"
#import "KWQListBox.h"
#import "Page.h"
#import "WebCoreFrameBridge.h"
#import "WebCoreTextRenderer.h"
#import <kxmlcore/Assertions.h>
using namespace WebCore;
void WebCoreInitializeFont(WebCoreFont *font)
{
font->font = nil;
font->syntheticBold = NO;
font->syntheticOblique = NO;
font->forPrinter = NO;
}
void WebCoreInitializeTextRun(WebCoreTextRun *run, const UniChar *characters, unsigned int length, int from, int to)
{
run->characters = characters;
run->length = length;
run->from = from;
run->to = to;
}
void WebCoreInitializeEmptyTextStyle(WebCoreTextStyle *style)
{
style->textColor = nil;
style->backgroundColor = nil;
style->letterSpacing = 0;
style->wordSpacing = 0;
style->padding = 0;