Commit bdd26c11 authored by darin's avatar darin
Browse files

Reviewed by Trey.

	- moved KWQFontFamily and KWQPageState to new homes

        * kwq/KWQFontFamily.h: Added.
        * kwq/KWQFontFamily.mm: Added.
        * kwq/KWQPageState.h: Added.
        * kwq/KWQPageState.mm: Added.
        * WebCore.pbproj/project.pbxproj: Added new source files.

        * kwq/KWQFont.h: Removed KWQFontFamily.
        * kwq/KWQFont.mm:  Removed KWQFontFamily.
        * kwq/WebCoreBridge.mm: Removed KWQPageState.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3038 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c2eaba9e
2002-12-13 Darin Adler <darin@apple.com>
Reviewed by Trey.
- moved KWQFontFamily and KWQPageState to new homes
* kwq/KWQFontFamily.h: Added.
* kwq/KWQFontFamily.mm: Added.
* kwq/KWQPageState.h: Added.
* kwq/KWQPageState.mm: Added.
* WebCore.pbproj/project.pbxproj: Added new source files.
* kwq/KWQFont.h: Removed KWQFontFamily.
* kwq/KWQFont.mm: Removed KWQFontFamily.
* kwq/WebCoreBridge.mm: Removed KWQPageState.
2002-12-13 Maciej Stachowiak <mjs@apple.com>
Reviewed by Ken.
......
2002-12-13 Darin Adler <darin@apple.com>
Reviewed by Trey.
- moved KWQFontFamily and KWQPageState to new homes
* kwq/KWQFontFamily.h: Added.
* kwq/KWQFontFamily.mm: Added.
* kwq/KWQPageState.h: Added.
* kwq/KWQPageState.mm: Added.
* WebCore.pbproj/project.pbxproj: Added new source files.
* kwq/KWQFont.h: Removed KWQFontFamily.
* kwq/KWQFont.mm: Removed KWQFontFamily.
* kwq/WebCoreBridge.mm: Removed KWQPageState.
2002-12-13 Maciej Stachowiak <mjs@apple.com>
Reviewed by Ken.
......
......@@ -470,6 +470,8 @@
931C8A180380288B008635CE,
BC7294FA03804B3C00A80166,
BC7294FE03804B5600A80166,
9394E0A603AA5BBE008635CE,
9394E0AB03AA60FB008635CE,
);
isa = PBXHeadersBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
......@@ -704,6 +706,8 @@
931C8A190380288B008635CE,
BC7294F903804B3C00A80166,
BC7294FD03804B5600A80166,
9394E0A703AA5BBE008635CE,
9394E0AC03AA60FB008635CE,
);
isa = PBXSourcesBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
......@@ -974,6 +978,54 @@
settings = {
};
};
9394E0A403AA5BBE008635CE = {
fileEncoding = 4;
isa = PBXFileReference;
path = KWQPageState.h;
refType = 4;
};
9394E0A503AA5BBE008635CE = {
fileEncoding = 4;
isa = PBXFileReference;
path = KWQPageState.mm;
refType = 4;
};
9394E0A603AA5BBE008635CE = {
fileRef = 9394E0A403AA5BBE008635CE;
isa = PBXBuildFile;
settings = {
};
};
9394E0A703AA5BBE008635CE = {
fileRef = 9394E0A503AA5BBE008635CE;
isa = PBXBuildFile;
settings = {
};
};
9394E0A903AA60FB008635CE = {
fileEncoding = 4;
isa = PBXFileReference;
path = KWQFontFamily.h;
refType = 4;
};
9394E0AA03AA60FB008635CE = {
fileEncoding = 4;
isa = PBXFileReference;
path = KWQFontFamily.mm;
refType = 4;
};
9394E0AB03AA60FB008635CE = {
fileRef = 9394E0A903AA60FB008635CE;
isa = PBXBuildFile;
settings = {
};
};
9394E0AC03AA60FB008635CE = {
fileRef = 9394E0AA03AA60FB008635CE;
isa = PBXBuildFile;
settings = {
};
};
93CCF7D4033BD43C008635CE = {
fileEncoding = 30;
isa = PBXFileReference;
......@@ -1137,6 +1189,8 @@
931C8A170380288B008635CE,
93CCF7D4033BD43C008635CE,
93CCF7D5033BD43C008635CE,
9394E0A903AA60FB008635CE,
9394E0AA03AA60FB008635CE,
F58784EE02DE375901EA4122,
F58784EF02DE375901EA4122,
F58784FA02DE375901EA4122,
......@@ -1147,6 +1201,8 @@
F587850302DE375901EA4122,
93861DDF032C2E52008635CE,
93861DE0032C2E52008635CE,
9394E0A403AA5BBE008635CE,
9394E0A503AA5BBE008635CE,
93386B90037045B3008635CE,
93386B91037045B3008635CE,
F587851B02DE375901EA4122,
......
/*
* Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
* Copyright (C) 2001, 2002 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
......@@ -26,55 +26,14 @@
#ifndef QFONT_H_
#define QFONT_H_
#include "KWQString.h"
#include "KWQFontFamily.h"
#ifdef __OBJC__
@class NSFont;
@class NSString;
#else
class NSFont;
class NSString;
#endif
class KWQFontFamily {
public:
KWQFontFamily();
~KWQFontFamily() { if (_next) _next->deref(); }
KWQFontFamily(const KWQFontFamily &);
KWQFontFamily &operator=(const KWQFontFamily &);
void setFamily(const QString &);
QString family() const { return _family; }
bool familyIsEmpty() const { return _family.isEmpty(); }
NSString *getNSFamily() const;
KWQFontFamily *next() { return _next; }
const KWQFontFamily *next() const { return _next; }
void appendFamily(KWQFontFamily *family)
{
if (family)
family->ref();
if (_next)
_next->deref();
_next = family;
}
bool operator==(const KWQFontFamily &) const;
bool operator!=(const KWQFontFamily &x) const { return !(*this == x); }
void ref() { _refCnt++; }
void deref() { _refCnt--; if (_refCnt == 0) delete this; }
private:
QString _family;
KWQFontFamily *_next;
int _refCnt;
mutable NSString *_NSFamily;
};
class QFont {
public:
enum Weight { Normal = 50, Bold = 63 };
......@@ -115,32 +74,4 @@ private:
mutable NSFont *_nsfont;
};
// Macro to create a stack array containing non-retained NSString names
// of CSS font families. This can be used to avoid allocations in
// performance critical code. Create a NSSString ** name families
// and populates with a NSString * for each family name. Null terminates
// the array.
#define CREATE_FAMILY_ARRAY(font,families)\
int __numFamilies = 0;\
{\
const KWQFontFamily *__ff = (font).firstFamily();\
while (__ff)\
{\
__numFamilies++;\
__ff = __ff->next();\
}\
}\
NSString *families[__numFamilies+1];\
{\
int __i = 0;\
const KWQFontFamily *__ff = (font).firstFamily();\
while (__ff)\
{\
families[__i++] = __ff->getNSFamily();\
__ff = __ff->next();\
}\
families[__i] = 0;\
}
#endif
/*
* Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
* Copyright (C) 2001, 2002 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
......@@ -28,72 +28,6 @@
#import "KWQString.h"
#import "WebCoreTextRendererFactory.h"
KWQFontFamily::KWQFontFamily()
: _next(0)
, _refCnt(0)
, _NSFamily(0)
{
}
KWQFontFamily::KWQFontFamily(const KWQFontFamily& other)
: _family(other._family)
, _next(other._next)
, _refCnt(0)
, _NSFamily(other._NSFamily)
{
if (_next)
_next->ref();
}
KWQFontFamily& KWQFontFamily::operator=(const KWQFontFamily& other)
{
if (other._next)
other._next->ref();
if (_next)
_next->deref();
_family = other._family;
_next = other._next;
_NSFamily = other._NSFamily;
return *this;
}
NSString *KWQFontFamily::getNSFamily() const
{
if (!_NSFamily) {
// Use an immutable copy of the name, but keep a set of
// all family names so we don't end up with too many objects.
static CFMutableDictionaryRef families;
if (families == NULL) {
families = CFDictionaryCreateMutable(NULL, 0, &CFDictionaryQStringKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
}
_NSFamily = (NSString *)CFDictionaryGetValue(families, &_family);
if (!_NSFamily) {
_NSFamily = _family.getNSString();
CFDictionarySetValue(families, &_family, _NSFamily);
}
}
return _NSFamily;
}
void KWQFontFamily::setFamily(const QString &family)
{
if (family == _family) {
return;
}
_family = family;
_NSFamily = nil;
}
bool KWQFontFamily::operator==(const KWQFontFamily &compareFontFamily) const
{
if ((!_next && compareFontFamily._next) ||
(_next && !compareFontFamily._next) ||
((_next && compareFontFamily._next) && (*_next != *(compareFontFamily._next))))
return false;
return getNSFamily() == compareFontFamily.getNSFamily();
}
QFont::QFont()
: _trait(0)
, _size(12.0)
......
/*
* Copyright (C) 2002 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.
*/
#include "KWQString.h"
#ifdef __OBJC__
@class NSString;
#else
class NSString;
#endif
class KWQFontFamily {
public:
KWQFontFamily();
~KWQFontFamily() { if (_next) _next->deref(); }
KWQFontFamily(const KWQFontFamily &);
KWQFontFamily &operator=(const KWQFontFamily &);
void setFamily(const QString &);
QString family() const { return _family; }
bool familyIsEmpty() const { return _family.isEmpty(); }
NSString *getNSFamily() const;
KWQFontFamily *next() { return _next; }
const KWQFontFamily *next() const { return _next; }
void appendFamily(KWQFontFamily *family)
{
if (family)
family->ref();
if (_next)
_next->deref();
_next = family;
}
bool operator==(const KWQFontFamily &) const;
bool operator!=(const KWQFontFamily &x) const { return !(*this == x); }
void ref() { _refCnt++; }
void deref() { _refCnt--; if (_refCnt == 0) delete this; }
private:
QString _family;
KWQFontFamily *_next;
int _refCnt;
mutable NSString *_NSFamily;
};
// Macro to create a stack array containing non-retained NSString names
// of CSS font families. This can be used to avoid allocations in
// performance critical code. Create a NSSString ** name families
// and populates with a NSString * for each family name. Null terminates
// the array.
#define CREATE_FAMILY_ARRAY(font,families)\
int __numFamilies = 0;\
{\
const KWQFontFamily *__ff = (font).firstFamily();\
while (__ff)\
{\
__numFamilies++;\
__ff = __ff->next();\
}\
}\
NSString *families[__numFamilies+1];\
{\
int __i = 0;\
const KWQFontFamily *__ff = (font).firstFamily();\
while (__ff)\
{\
families[__i++] = __ff->getNSFamily();\
__ff = __ff->next();\
}\
families[__i] = 0;\
}
/*
* Copyright (C) 2001, 2002 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.
*/
#include "KWQFontFamily.h"
KWQFontFamily::KWQFontFamily()
: _next(0)
, _refCnt(0)
, _NSFamily(0)
{
}
KWQFontFamily::KWQFontFamily(const KWQFontFamily& other)
: _family(other._family)
, _next(other._next)
, _refCnt(0)
, _NSFamily(other._NSFamily)
{
if (_next)
_next->ref();
}
KWQFontFamily& KWQFontFamily::operator=(const KWQFontFamily& other)
{
if (other._next)
other._next->ref();
if (_next)
_next->deref();
_family = other._family;
_next = other._next;
_NSFamily = other._NSFamily;
return *this;
}
NSString *KWQFontFamily::getNSFamily() const
{
if (!_NSFamily) {
// Use an immutable copy of the name, but keep a set of
// all family names so we don't end up with too many objects.
static CFMutableDictionaryRef families;
if (families == NULL) {
families = CFDictionaryCreateMutable(NULL, 0, &CFDictionaryQStringKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
}
_NSFamily = (NSString *)CFDictionaryGetValue(families, &_family);
if (!_NSFamily) {
_NSFamily = _family.getNSString();
CFDictionarySetValue(families, &_family, _NSFamily);
}
}
return _NSFamily;
}
void KWQFontFamily::setFamily(const QString &family)
{
if (family == _family) {
return;
}
_family = family;
_NSFamily = nil;
}
bool KWQFontFamily::operator==(const KWQFontFamily &compareFontFamily) const
{
if ((!_next && compareFontFamily._next) ||
(_next && !compareFontFamily._next) ||
((_next && compareFontFamily._next) && (*_next != *(compareFontFamily._next))))
return false;
return getNSFamily() == compareFontFamily.getNSFamily();
}
/*
* Copyright (C) 2002 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 <Foundation/Foundation.h>
class KURL;
namespace DOM {
class DocumentImpl;
}
namespace khtml {
class RenderObject;
}
namespace KJS {
class SavedProperties;
}
@interface KWQPageState : NSObject
{
DOM::DocumentImpl *document;
KURL *URL;
KJS::SavedProperties *windowProperties;
KJS::SavedProperties *locationProperties;
khtml::RenderObject *docRenderer;
}
- initWithDocument:(DOM::DocumentImpl *)doc URL:(const KURL &)u windowProperties:(KJS::SavedProperties *)wp locationProperties:(KJS::SavedProperties *)lp;
- (DOM::DocumentImpl *)document;
- (KURL *)URL;
- (KJS::SavedProperties *)windowProperties;
- (KJS::SavedProperties *)locationProperties;
- (khtml::RenderObject *)renderer;
- (void)invalidate;
@end
/*
* Copyright (C) 2002 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 "KWQPageState.h"
#import <JavaScriptCore/property_map.h>
#import "dom_docimpl.h"
#import "khtmlview.h"
#import "KWQAssertions.h"
#import "KWQKHTMLPart.h"
using DOM::DocumentImpl;
using KJS::SavedProperties;
@implementation KWQPageState
- initWithDocument:(DocumentImpl *)doc URL:(const KURL &)u windowProperties:(SavedProperties *)wp locationProperties:(SavedProperties *)lp
{
[super init];
doc->ref();
document = doc;
docRenderer = doc->renderer();
document->setInPageCache(YES);
URL = new KURL(u);
windowProperties = wp;
locationProperties = lp;
return self;
}
// Called when the KWQPageState is restored. It should relinquish ownership
// of objects to core.
- (void)invalidate
{
// Should only ever invalidate once.
ASSERT(document);