Commit 3aaa7d9f authored by darin's avatar darin
Browse files

Reviewed by Dave.

	- fixed ==/= typo in QFontMetrics that caused a part of my recent speedup to not take effect
	- fixed 3128582 -- REGRESSION: Crash on planetquake.com

        * kwq/KWQFontMetrics.mm:
	(QFontMetricsPrivate::setFont): Fix a horrifying "== instead of =" mistake.
        (QFontMetrics::ascent): Give an ERROR message, don't crash, when this is called on a
	font metrics object that hasn't been updated to work for a particular font.
        (QFontMetrics::descent): Ditto.
        (QFontMetrics::lineSpacing): Ditto.
        (QFontMetrics::xHeight): Ditto.
        (QFontMetrics::width): Ditto.
        (QFontMetrics::floatWidth): Ditto.
        (QFontMetrics::floatCharacterWidths): Ditto.

        * khtml/html/html_inlineimpl.cpp: (HTMLBRElementImpl::attach):
	Eliminated what was causing us to hit the above. BR elements need to respect display() == NONE.

	- fixed the fix for operator==; needs to work even if the pseudo type was
	  extracted already for one of the two, and not the other

        * khtml/css/cssparser.cpp:
        (CSSSelector::extractPseudoType): Only do work when the selector is Pseudo.
        (CSSSelector::operator==): Call pseudoType() instead of going right at _pseudoType.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3063 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5767599b
2002-12-15 Darin Adler <darin@apple.com>
Reviewed by Dave.
- fixed ==/= typo in QFontMetrics that caused a part of my recent speedup to not take effect
- fixed 3128582 -- REGRESSION: Crash on planetquake.com
* kwq/KWQFontMetrics.mm:
(QFontMetricsPrivate::setFont): Fix a horrifying "== instead of =" mistake.
(QFontMetrics::ascent): Give an ERROR message, don't crash, when this is called on a
font metrics object that hasn't been updated to work for a particular font.
(QFontMetrics::descent): Ditto.
(QFontMetrics::lineSpacing): Ditto.
(QFontMetrics::xHeight): Ditto.
(QFontMetrics::width): Ditto.
(QFontMetrics::floatWidth): Ditto.
(QFontMetrics::floatCharacterWidths): Ditto.
* khtml/html/html_inlineimpl.cpp: (HTMLBRElementImpl::attach):
Eliminated what was causing us to hit the above. BR elements need to respect display() == NONE.
- fixed the fix for operator==; needs to work even if the pseudo type was
extracted already for one of the two, and not the other
* khtml/css/cssparser.cpp:
(CSSSelector::extractPseudoType): Only do work when the selector is Pseudo.
(CSSSelector::operator==): Call pseudoType() instead of going right at _pseudoType.
2002-12-15 David Hyatt <hyatt@apple.com>
Fix for 3128402, missing content on voodooextreme. Don't allow
......
2002-12-15 Darin Adler <darin@apple.com>
Reviewed by Dave.
- fixed ==/= typo in QFontMetrics that caused a part of my recent speedup to not take effect
- fixed 3128582 -- REGRESSION: Crash on planetquake.com
* kwq/KWQFontMetrics.mm:
(QFontMetricsPrivate::setFont): Fix a horrifying "== instead of =" mistake.
(QFontMetrics::ascent): Give an ERROR message, don't crash, when this is called on a
font metrics object that hasn't been updated to work for a particular font.
(QFontMetrics::descent): Ditto.
(QFontMetrics::lineSpacing): Ditto.
(QFontMetrics::xHeight): Ditto.
(QFontMetrics::width): Ditto.
(QFontMetrics::floatWidth): Ditto.
(QFontMetrics::floatCharacterWidths): Ditto.
* khtml/html/html_inlineimpl.cpp: (HTMLBRElementImpl::attach):
Eliminated what was causing us to hit the above. BR elements need to respect display() == NONE.
- fixed the fix for operator==; needs to work even if the pseudo type was
extracted already for one of the two, and not the other
* khtml/css/cssparser.cpp:
(CSSSelector::extractPseudoType): Only do work when the selector is Pseudo.
(CSSSelector::operator==): Call pseudoType() instead of going right at _pseudoType.
2002-12-15 David Hyatt <hyatt@apple.com>
Fix for 3128402, missing content on voodooextreme. Don't allow
......
......@@ -3072,6 +3072,8 @@ unsigned int CSSSelector::specificity()
void CSSSelector::extractPseudoType() const
{
if (match != Pseudo)
return;
_pseudoType = PseudoOther;
if (!value.isEmpty()) {
switch (value[0]) {
......@@ -3127,7 +3129,8 @@ bool CSSSelector::operator == ( const CSSSelector &other )
if ( sel1->tag != sel2->tag || sel1->attr != sel2->attr ||
sel1->relation != sel2->relation || sel1->match != sel2->match ||
sel1->nonCSSHint != sel2->nonCSSHint ||
sel1->value != sel2->value || sel1->_pseudoType != sel2->_pseudoType)
sel1->value != sel2->value ||
sel1->pseudoType() != sel2->pseudoType())
return false;
sel1 = sel1->tagHistory;
sel2 = sel2->tagHistory;
......
......@@ -219,11 +219,16 @@ void HTMLBRElementImpl::attach()
assert(!m_render);
assert(parentNode());
if (parentNode()->renderer()) {
m_render = new (getDocument()->renderArena()) RenderBR(this);
m_render->setStyle(getDocument()->styleSelector()->styleForElement(this));
parentNode()->renderer()->addChild(m_render, nextRenderer());
RenderObject *parentRenderer = parentNode()->renderer();
if (parentRenderer) {
RenderStyle *style = getDocument()->styleSelector()->styleForElement(this);
if (style->display() != NONE) {
m_render = new (getDocument()->renderArena()) RenderBR(this);
m_render->setStyle(style);
parentRenderer->addChild(m_render, nextRenderer());
}
}
NodeImpl::attach();
}
......
......@@ -28,10 +28,11 @@
#import <Cocoa/Cocoa.h>
#import "KWQFont.h"
#import "WebCoreTextRendererFactory.h"
#import "WebCoreTextRenderer.h"
#import "KWQLogging.h"
#import "WebCoreTextRenderer.h"
#import "WebCoreTextRendererFactory.h"
struct QFontMetricsPrivate
{
QFontMetricsPrivate(const QFont &font)
......@@ -56,7 +57,7 @@ struct QFontMetricsPrivate
if (_font == font) {
return;
}
_font == font;
_font = font;
[_renderer release];
_renderer = nil;
}
......@@ -106,11 +107,21 @@ void QFontMetrics::setFont(const QFont &font)
int QFontMetrics::ascent() const
{
if (data.isNull()) {
ERROR("called ascent on an empty QFontMetrics");
return 0;
}
return [data->getRenderer() ascent];
}
int QFontMetrics::descent() const
{
if (data.isNull()) {
ERROR("called descent on an empty QFontMetrics");
return 0;
}
return [data->getRenderer() descent];
}
......@@ -123,16 +134,29 @@ int QFontMetrics::height() const
int QFontMetrics::lineSpacing() const
{
if (data.isNull()) {
ERROR("called lineSpacing on an empty QFontMetrics");
return 0;
}
return [data->getRenderer() lineSpacing];
}
float QFontMetrics::xHeight() const
{
if (data.isNull()) {
ERROR("called xHeight on an empty QFontMetrics");
return 0;
}
return [data->getRenderer() xHeight];
}
int QFontMetrics::width(QChar qc) const
{
if (data.isNull()) {
ERROR("called width on an empty QFontMetrics");
return 0;
}
UniChar c = qc.unicode();
CREATE_FAMILY_ARRAY(data->font(), families);
......@@ -147,6 +171,11 @@ int QFontMetrics::charWidth(const QString &s, int pos) const
int QFontMetrics::width(char c) const
{
if (data.isNull()) {
ERROR("called width on an empty QFontMetrics");
return 0;
}
UniChar ch = (uchar) c;
CREATE_FAMILY_ARRAY(data->font(), families);
......@@ -156,6 +185,11 @@ int QFontMetrics::width(char c) const
int QFontMetrics::width(const QString &qstring, int len) const
{
if (data.isNull()) {
ERROR("called width on an empty QFontMetrics");
return 0;
}
CREATE_FAMILY_ARRAY(data->font(), families);
return ROUND_TO_INT([data->getRenderer() floatWidthForCharacters:(const UniChar *)qstring.unicode() stringLength:len fromCharacterPosition:0 numberOfCharacters:len withPadding: 0 applyRounding:YES attemptFontSubstitution: YES widths: 0 letterSpacing:0 wordSpacing:0 fontFamilies: families]);
......@@ -163,6 +197,11 @@ int QFontMetrics::width(const QString &qstring, int len) const
int QFontMetrics::width(const QChar *uchars, int len) const
{
if (data.isNull()) {
ERROR("called width on an empty QFontMetrics");
return 0;
}
CREATE_FAMILY_ARRAY(data->font(), families);
return ROUND_TO_INT([data->getRenderer() floatWidthForCharacters:(const UniChar *)uchars stringLength:len fromCharacterPosition:0 numberOfCharacters:len withPadding: 0 applyRounding:YES attemptFontSubstitution: YES widths: 0 letterSpacing:0 wordSpacing:0 fontFamilies: families]);
......@@ -170,6 +209,11 @@ int QFontMetrics::width(const QChar *uchars, int len) const
float QFontMetrics::floatWidth(const QChar *uchars, int slen, int pos, int len, int letterSpacing, int wordSpacing) const
{
if (data.isNull()) {
ERROR("called floatWidth on an empty QFontMetrics");
return 0;
}
CREATE_FAMILY_ARRAY(data->font(), families);
return [data->getRenderer() floatWidthForCharacters:(const UniChar *)uchars stringLength:slen fromCharacterPosition:pos numberOfCharacters:len withPadding: 0 applyRounding: YES attemptFontSubstitution: YES widths: 0 letterSpacing:letterSpacing wordSpacing:wordSpacing fontFamilies: families];
......@@ -177,6 +221,11 @@ float QFontMetrics::floatWidth(const QChar *uchars, int slen, int pos, int len,
float QFontMetrics::floatCharacterWidths(const QChar *uchars, int slen, int pos, int len, int toAdd, float *buffer, int letterSpacing, int wordSpacing) const
{
if (data.isNull()) {
ERROR("called floatCharacterWidths on an empty QFontMetrics");
return 0;
}
CREATE_FAMILY_ARRAY(data->font(), families);
return [data->getRenderer() floatWidthForCharacters:(const UniChar *)uchars stringLength:slen fromCharacterPosition:pos numberOfCharacters:len withPadding: toAdd applyRounding: YES attemptFontSubstitution: YES widths: (float *)buffer letterSpacing:letterSpacing wordSpacing: wordSpacing fontFamilies: families];
......
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