Commit e94e43ff authored by darin's avatar darin

Reviewed by Dave.

	- fixed 96/72 dpi snafu; no need to do something different for AppKit,
          because it always uses pixel sizes, not font size

        * khtml/css/css_valueimpl.cpp:
        * khtml/css/css_valueimpl.h:
        * khtml/css/cssstyleselector.cpp:
        * kwq/KWQPaintDeviceMetrics.mm:
	Rolled out change from 2002-12-05

	- a cut at implementing heretofore unimplemented QTextStream classes

        * kwq/KWQTextStream.h:
        * kwq/KWQTextStream.mm:
	First cut implementation.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3277 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ad9ac7ba
2003-01-08 Darin Adler <darin@apple.com>
Reviewed by Dave.
- fixed 96/72 dpi snafu; no need to do something different for AppKit,
because it always uses pixel sizes, not font size
* khtml/css/css_valueimpl.cpp:
* khtml/css/css_valueimpl.h:
* khtml/css/cssstyleselector.cpp:
* kwq/KWQPaintDeviceMetrics.mm:
Rolled out change from 2002-12-05
- a cut at implementing heretofore unimplemented QTextStream classes
* kwq/KWQTextStream.h:
* kwq/KWQTextStream.mm:
First cut implementation.
=== Safari-49 ===
2003-01-05 Maciej Stachowiak <mjs@apple.com>
......
2003-01-08 Darin Adler <darin@apple.com>
Reviewed by Dave.
- fixed 96/72 dpi snafu; no need to do something different for AppKit,
because it always uses pixel sizes, not font size
* khtml/css/css_valueimpl.cpp:
* khtml/css/css_valueimpl.h:
* khtml/css/cssstyleselector.cpp:
* kwq/KWQPaintDeviceMetrics.mm:
Rolled out change from 2002-12-05
- a cut at implementing heretofore unimplemented QTextStream classes
* kwq/KWQTextStream.h:
* kwq/KWQTextStream.mm:
First cut implementation.
=== Safari-49 ===
2003-01-05 Maciej Stachowiak <mjs@apple.com>
......
......@@ -388,107 +388,57 @@ int CSSPrimitiveValueImpl::computeLength( khtml::RenderStyle *style, QPaintDevic
return ( int ) computeLengthFloat( style, devMetrics );
}
float CSSPrimitiveValueImpl::computeLengthFloat( khtml::RenderStyle *style, QPaintDeviceMetrics *devMetrics)
float CSSPrimitiveValueImpl::computeLengthFloat( khtml::RenderStyle *style, QPaintDeviceMetrics *devMetrics )
{
unsigned short type = primitiveType();
float dpiY = 72.; // fallback
if ( devMetrics )
dpiY = devMetrics->logicalDpiY();
if ( !khtml::printpainter && dpiY < 72 )
dpiY = 72.;
if ( !khtml::printpainter && dpiY < 96 )
dpiY = 96.;
float factor = 1.;
switch(type)
{
case CSSPrimitiveValue::CSS_EMS:
factor = style->font().pixelSize();
break;
case CSSPrimitiveValue::CSS_EXS:
{
QFontMetrics fm = style->fontMetrics();
case CSSPrimitiveValue::CSS_EMS:
factor = style->font().pixelSize();
break;
case CSSPrimitiveValue::CSS_EXS:
{
QFontMetrics fm = style->fontMetrics();
#if APPLE_CHANGES
factor = fm.xHeight();
factor = fm.xHeight();
#else
QRect b = fm.boundingRect('x');
factor = b.height();
QRect b = fm.boundingRect('x');
factor = b.height();
#endif
break;
}
case CSSPrimitiveValue::CSS_PX:
break;
case CSSPrimitiveValue::CSS_CM:
factor = dpiY/2.54; //72dpi/(2.54 cm/in)
break;
case CSSPrimitiveValue::CSS_MM:
factor = dpiY/25.4;
break;
case CSSPrimitiveValue::CSS_IN:
break;
}
case CSSPrimitiveValue::CSS_PX:
break;
case CSSPrimitiveValue::CSS_CM:
factor = dpiY/2.54; //72dpi/(2.54 cm/in)
break;
case CSSPrimitiveValue::CSS_MM:
factor = dpiY/25.4;
break;
case CSSPrimitiveValue::CSS_IN:
factor = dpiY;
break;
case CSSPrimitiveValue::CSS_PT:
break;
case CSSPrimitiveValue::CSS_PT:
factor = dpiY/72.;
break;
case CSSPrimitiveValue::CSS_PC:
break;
case CSSPrimitiveValue::CSS_PC:
// 1 pc == 12 pt
factor = dpiY*12./72.;
break;
default:
return -1;
break;
default:
return -1;
}
return getFloatValue(type)*factor;
}
#ifdef APPLE_CHANGES
// Compute point equivalent size for each unit type. OS X fonts are all specified in
// device independent point size, so don't apply DPI corrections.
float CSSPrimitiveValueImpl::computePointFloat( khtml::RenderStyle *style, QPaintDeviceMetrics *devMetrics)
{
unsigned short type = primitiveType();
float dpiY = 72.; // fallback
if ( devMetrics )
dpiY = devMetrics->logicalDpiY();
if ( !khtml::printpainter && dpiY < 72 )
dpiY = 72.;
float factor = 1.;
switch(type)
{
case CSSPrimitiveValue::CSS_EMS:
factor = style->font().pixelSize();
break;
case CSSPrimitiveValue::CSS_EXS:
{
QFontMetrics fm = style->fontMetrics();
factor = fm.xHeight();
break;
}
case CSSPrimitiveValue::CSS_PX:
factor = 72./dpiY;
break;
case CSSPrimitiveValue::CSS_CM:
factor = 72./2.54; //(2.54 cm/in)
break;
case CSSPrimitiveValue::CSS_MM:
factor = 72./25.4; //(25.4 cm/in)
break;
case CSSPrimitiveValue::CSS_IN:
factor = 72.;
break;
case CSSPrimitiveValue::CSS_PT:
break;
case CSSPrimitiveValue::CSS_PC:
// 1 pc == 12 pt
factor = 12.;
break;
default:
return -1;
}
return getFloatValue(type)*factor;
}
#endif
void CSSPrimitiveValueImpl::setFloatValue( unsigned short unitType, float floatValue, int &exceptioncode )
{
exceptioncode = 0;
......
......@@ -175,9 +175,7 @@ public:
int computeLength( khtml::RenderStyle *style, QPaintDeviceMetrics *devMetrics );
float computeLengthFloat( khtml::RenderStyle *style, QPaintDeviceMetrics *devMetrics );
#ifdef APPLE_CHANGES
float computePointFloat( khtml::RenderStyle *style, QPaintDeviceMetrics *devMetrics);
#endif
// use with care!!!
void setPrimitiveType(unsigned short type) { m_type = type; }
......
......@@ -2360,17 +2360,10 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
} else {
int type = primitiveValue->primitiveType();
if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) {
#if !APPLE_CHANGES
size = primitiveValue->computeLengthFloat(parentStyle, paintDeviceMetrics);
#else
// OS X will always provide device independent font size, so we don't want to adjust
// the device independent sizes.
size = primitiveValue->computePointFloat(parentStyle, paintDeviceMetrics);
#endif
if (!khtml::printpainter && element && element->getDocument()->view())
size *= element->getDocument()->view()->part()->zoomFactor() / 100.0;
}
else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
} else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
size = (primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE)
* parentStyle->font().pixelSize()) / 100;
else
......
......@@ -33,7 +33,7 @@ QPaintDeviceMetrics::QPaintDeviceMetrics(const QPaintDevice *)
int QPaintDeviceMetrics::logicalDpiY() const
{
return 72;
return 96;
}
int QPaintDeviceMetrics::depth() const
......
......@@ -26,6 +26,7 @@
#ifndef QTEXTSTREAM_H_
#define QTEXTSTREAM_H_
#include "KWQIODevice.h"
#include "KWQString.h"
class QTextStream;
......@@ -36,41 +37,41 @@ QTextStream &endl(QTextStream& stream);
class QTextStream {
public:
QTextStream();
QTextStream(QByteArray, int);
QTextStream(QString *, int);
virtual ~QTextStream();
QTextStream(const QByteArray &);
QTextStream(QString *, int mode = IO_WriteOnly);
QTextStream &operator<<(char);
QTextStream &operator<<(const char *);
QTextStream &operator<<(const QCString &);
QTextStream &operator<<(const QString &);
QTextStream &operator<<(const QTextStreamManipulator &);
QTextStream &operator<<(const void *);
QTextStream &operator<<(char);
QTextStream &operator<<(const char *);
QTextStream &operator<<(const QCString &);
QTextStream &operator<<(const QString &);
QTextStream &operator<<(const QTextStreamManipulator &);
QTextStream &operator<<(void *);
private:
QTextStream(const QTextStream &);
QTextStream &operator=(const QTextStream &);
bool _hasByteArray;
QByteArray _byteArray;
QString *_string;
};
class QTextIStream : public QTextStream {
class QTextOStream : public QTextStream {
public:
QTextIStream(QString *);
QString readLine();
QTextOStream(QString *s) : QTextStream(s) { }
QTextOStream(const QByteArray &ba) : QTextStream(ba) { }
};
class QTextOStream : public QTextStream {
class QTextIStream {
public:
QTextOStream(QString *);
QTextOStream(QByteArray);
QTextIStream(QString *s) : _string(s), _position(0) { }
QString readLine();
};
private:
QTextIStream(const QTextIStream &);
QTextIStream &operator=(const QTextIStream &);
QString *_string;
int _position;
};
#endif
......@@ -27,82 +27,83 @@
#import "KWQTextStream.h"
QTextStream::QTextStream()
QTextStream::QTextStream(const QByteArray &ba)
: _hasByteArray(true), _byteArray(ba), _string(0)
{
}
QTextStream::QTextStream(QByteArray, int)
{
ERROR("not yet implemented");
}
QTextStream::QTextStream(QString *, int)
{
ERROR("not yet implemented");
}
QTextStream::~QTextStream()
QTextStream::QTextStream(QString *s, int mode)
: _hasByteArray(false), _string(s)
{
ASSERT(mode == IO_WriteOnly);
}
QTextStream &QTextStream::operator<<(char)
QTextStream &QTextStream::operator<<(char c)
{
if (_hasByteArray) {
uint oldSize = _byteArray.size();
_byteArray.resize(oldSize + 1);
_byteArray[oldSize] = c;
}
if (_string) {
_string->append(QChar(c));
}
return *this;
}
QTextStream &QTextStream::operator<<(const char *)
QTextStream &QTextStream::operator<<(const char *s)
{
if (_hasByteArray) {
uint length = strlen(s);
uint oldSize = _byteArray.size();
_byteArray.resize(oldSize + length);
memcpy(_byteArray.data() + oldSize, s, length);
}
if (_string) {
_string->append(s);
}
return *this;
}
QTextStream &QTextStream::operator<<(const QCString &)
QTextStream &QTextStream::operator<<(const QCString &qcs)
{
return *this;
const char *s = qcs;
return *this << s;
}
QTextStream &QTextStream::operator<<(const QString &)
QTextStream &QTextStream::operator<<(const QString &s)
{
if (_hasByteArray) {
uint length = s.length();
uint oldSize = _byteArray.size();
_byteArray.resize(oldSize + length);
memcpy(_byteArray.data() + oldSize, s.latin1(), length);
}
if (_string) {
_string->append(s);
}
return *this;
}
QTextIStream::QTextIStream(QString *)
{
ERROR("not yet implemented");
}
QString QTextIStream::readLine()
QTextStream &QTextStream::operator<<(void *p)
{
ERROR("not yet implemented");
return QString();
char buffer[10];
sprintf(buffer, "%p", p);
return *this << buffer;
}
QTextOStream::QTextOStream(QString *)
QTextStream &QTextStream::operator<<(const QTextStreamManipulator &m)
{
ERROR("not yet implemented");
return m(*this);
}
QTextOStream::QTextOStream(QByteArray)
QTextStream &endl(QTextStream& stream)
{
ERROR("not yet implemented");
return stream << '\n';
}
QString QTextOStream::readLine()
QString QTextIStream::readLine()
{
ERROR("not yet implemented");
return QString();
}
QTextStream &QTextStream::operator<<(QTextStream &(*const &)(QTextStream &))
{
return *this;
}
QTextStream &QTextStream::operator<<(void const *)
{
return *this;
}
QTextStream &endl(QTextStream& stream)
{
return stream;
}
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