Don't use insane (negative) layout values if layout engine does not allocate sufficient space for a text string

This resolves Bug 1950
Make most debugging statements work again
Add new debugging statements
Fix several annoying build warnings
(cherry picked from commit cc5fd88be3)
v3.5.13-sru
Timothy Pearson 10 years ago committed by Slávek Banko
parent e25c6429ea
commit f3635faf14

@ -539,12 +539,12 @@ TQRegion HTMLAreaElementImpl::getRegion(int width_, int height_) const
m_coords[(i<<1)+1].minWidth(height_)); m_coords[(i<<1)+1].minWidth(height_));
region = TQRegion(points); region = TQRegion(points);
} }
else if (shape==Circle && m_coordsLen>=3 || shape==Unknown && m_coordsLen == 3) { else if ((shape==Circle && m_coordsLen>=3) || (shape==Unknown && m_coordsLen == 3)) {
int r = kMin(m_coords[2].minWidth(width_), m_coords[2].minWidth(height_)); int r = kMin(m_coords[2].minWidth(width_), m_coords[2].minWidth(height_));
region = TQRegion(m_coords[0].minWidth(width_)-r, region = TQRegion(m_coords[0].minWidth(width_)-r,
m_coords[1].minWidth(height_)-r, 2*r, 2*r,TQRegion::Ellipse); m_coords[1].minWidth(height_)-r, 2*r, 2*r,TQRegion::Ellipse);
} }
else if (shape==Rect && m_coordsLen>=4 || shape==Unknown && m_coordsLen == 4) { else if ((shape==Rect && m_coordsLen>=4) || (shape==Unknown && m_coordsLen == 4)) {
int x0 = m_coords[0].minWidth(width_); int x0 = m_coords[0].minWidth(width_);
int y0 = m_coords[1].minWidth(height_); int y0 = m_coords[1].minWidth(height_);
int x1 = m_coords[2].minWidth(width_); int x1 = m_coords[2].minWidth(width_);

@ -1385,11 +1385,11 @@ void HTMLTokenizer::write( const TokenizerString &str, bool appendData )
else if ( startTag ) else if ( startTag )
{ {
startTag = false; startTag = false;
bool endTag = false; // bool endTag = false;
switch(cc) { switch(cc) {
case '/': case '/':
endTag = true; // endTag = true;
break; break;
case '!': case '!':
{ {
@ -1440,11 +1440,14 @@ void HTMLTokenizer::write( const TokenizerString &str, bool appendData )
// immediately before an endtag should be ignored. // immediately before an endtag should be ignored.
// ### Gecko and MSIE though only ignores LF immediately after // ### Gecko and MSIE though only ignores LF immediately after
// starttags and only for PRE elements -- asj (28/06-2005) // starttags and only for PRE elements -- asj (28/06-2005)
if ( pending ) if ( pending ) {
if (!select) if (!select) {
addPending(); addPending();
else }
else {
pending = NonePending; pending = NonePending;
}
}
// Cancel unused discards // Cancel unused discards
discard = NoneDiscard; discard = NoneDiscard;

@ -35,8 +35,9 @@
#include "tqfontmetrics.h" #include "tqfontmetrics.h"
#define BIDI_DEBUG 0 #define BIDI_DEBUG 0
//#define DEBUG_LINEBREAKS // #define DEBUG_LINEBREAKS
//#define PAGE_DEBUG // #define DEBUG_LAYOUT
// #define PAGE_DEBUG
namespace khtml { namespace khtml {
@ -701,8 +702,12 @@ void RenderBlock::computeHorizontalPositionsForLine(InlineFlowBox* lineBox, Bidi
if (r->obj->isPositioned()) if (r->obj->isPositioned())
continue; // Positioned objects are only participating to figure out their continue; // Positioned objects are only participating to figure out their
// correct static x position. They have no effect on the width. // correct static x position. They have no effect on the width.
if (r->obj->isText()) if (r->obj->isText()) {
r->box->setWidth(static_cast<RenderText *>(r->obj)->width(r->start, r->stop-r->start, m_firstLine)); r->box->setWidth(static_cast<RenderText *>(r->obj)->width(r->start, r->stop-r->start, m_firstLine));
#ifdef DEBUG_LAYOUT
kdDebug( 6040 ) << renderName() << " computeHorizontalPositionsForLine() set text box width: " << r->box->width() << endl;
#endif
}
else if (!r->obj->isInlineFlow()) { else if (!r->obj->isInlineFlow()) {
r->obj->calcWidth(); r->obj->calcWidth();
r->box->setWidth(r->obj->width()); r->box->setWidth(r->obj->width());
@ -776,6 +781,10 @@ void RenderBlock::computeHorizontalPositionsForLine(InlineFlowBox* lineBox, Bidi
m_overflowWidth = rightPos; // FIXME: Work for rtl overflow also. m_overflowWidth = rightPos; // FIXME: Work for rtl overflow also.
if (x < 0) if (x < 0)
m_overflowLeft = kMin(m_overflowLeft, x); m_overflowLeft = kMin(m_overflowLeft, x);
#ifdef DEBUG_LAYOUT
kdDebug( 6040 ) << renderName() << " computeHorizontalPositionsForLine() m_overflowWidth: " << m_overflowWidth << " m_overflowLeft: " << m_overflowLeft << endl;
#endif
} }
void RenderBlock::computeVerticalPositionsForLine(InlineFlowBox* lineBox) void RenderBlock::computeVerticalPositionsForLine(InlineFlowBox* lineBox)
@ -865,6 +874,9 @@ bool RenderBlock::clearLineOfPageBreaks(InlineFlowBox* lineBox)
} }
if (doPageBreak) { if (doPageBreak) {
int pTop = pageTopAfter(lineBox->yPos()); int pTop = pageTopAfter(lineBox->yPos());
#ifdef PAGE_DEBUG
int oldYPos = lineBox->yPos();
#endif
m_height = pTop; m_height = pTop;
lineBox->setAfterPageBreak(true); lineBox->setAfterPageBreak(true);
@ -1254,8 +1266,8 @@ void RenderBlock::bidiReorderLine(const BidiIterator &start, const BidiIterator
} }
#if BIDI_DEBUG > 0 #if BIDI_DEBUG > 0
kdDebug(6041) << "reached end of line current=" << current.obj << "/" << current.pos kdDebug(6041) << "reached end of line current=" << bidi.current.obj << "/" << bidi.current.pos
<< ", eor=" << eor.obj << "/" << eor.pos << endl; << ", eor=" << bidi.eor.obj << "/" << bidi.eor.pos << endl;
#endif #endif
if ( !emptyRun && bidi.sor != bidi.current ) { if ( !emptyRun && bidi.sor != bidi.current ) {
bidi.eor = bidi.last; bidi.eor = bidi.last;
@ -1286,9 +1298,7 @@ void RenderBlock::bidiReorderLine(const BidiIterator &start, const BidiIterator
#if BIDI_DEBUG > 0 #if BIDI_DEBUG > 0
kdDebug(6041) << "lineLow = " << (uint)levelLow << ", lineHigh = " << (uint)levelHigh << endl; kdDebug(6041) << "lineLow = " << (uint)levelLow << ", lineHigh = " << (uint)levelHigh << endl;
kdDebug(6041) << "logical order is:" << endl; kdDebug(6041) << "logical order is:" << endl;
TQPtrListIterator<BidiRun> it2(runs); for (BidiRun* r2 = sFirstBidiRun; r2; r2 = r2->nextRun)
BidiRun *r2;
for ( ; (r2 = it2.current()); ++it2 )
kdDebug(6041) << " " << r2 << " start=" << r2->start << " stop=" << r2->stop << " level=" << (uint)r2->level << endl; kdDebug(6041) << " " << r2 << " start=" << r2->start << " stop=" << r2->stop << " level=" << (uint)r2->level << endl;
#endif #endif
@ -1318,7 +1328,7 @@ void RenderBlock::bidiReorderLine(const BidiIterator &start, const BidiIterator
#if BIDI_DEBUG > 0 #if BIDI_DEBUG > 0
kdDebug(6041) << "visual order is:" << endl; kdDebug(6041) << "visual order is:" << endl;
for (BidiRun* curr = sFirstRun; curr; curr = curr->nextRun) for (BidiRun* curr = sFirstBidiRun; curr; curr = curr->nextRun)
kdDebug(6041) << " " << curr << endl; kdDebug(6041) << " " << curr << endl;
#endif #endif
} }

@ -230,11 +230,9 @@ void RenderBlock::updateFirstLetter()
while ( length < oldText->l && (oldText->s+length)->isSpace() ) while ( length < oldText->l && (oldText->s+length)->isSpace() )
length++; length++;
begin = length; begin = length;
while ( length < oldText->l && while ( (length < oldText->l && ( (oldText->s+length)->isPunct())) || (oldText->s+length)->isSpace() )
( (oldText->s+length)->isPunct()) || (oldText->s+length)->isSpace() )
length++; length++;
if ( length < oldText->l && if ( length < oldText->l && !( (oldText->s+length)->isSpace() || (oldText->s+length)->isPunct() ))
!( (oldText->s+length)->isSpace() || (oldText->s+length)->isPunct() ))
length++; length++;
while ( length < oldText->l && (oldText->s+length)->isMark() ) while ( length < oldText->l && (oldText->s+length)->isMark() )
length++; length++;
@ -1466,6 +1464,10 @@ void RenderBlock::layoutBlockChildren( bool relayoutChildren )
m_overflowHeight = kMax(effY + child->effectiveHeight(), m_overflowHeight); m_overflowHeight = kMax(effY + child->effectiveHeight(), m_overflowHeight);
m_overflowTop = kMin(effY, m_overflowTop); m_overflowTop = kMin(effY, m_overflowTop);
#ifdef PAGE_DEBUG
kdDebug(6040) << renderName() << "(RenderBlock)::layoutBlockChildren(" << relayoutChildren << ") effX: " << effX << " effY: " << effY << " child: " << child << " child->effectiveWidth(): " << child->effectiveWidth() << " child->effectiveHeight(): " << child->effectiveHeight() << endl;
#endif
// Insert our compact into the block margin if we have one. // Insert our compact into the block margin if we have one.
insertCompactIfNeeded(child, compactInfo); insertCompactIfNeeded(child, compactInfo);
@ -2168,6 +2170,9 @@ int RenderBlock::rightmostPosition(bool includeOverflowInterior, bool includeSel
} }
} }
#ifdef PAGE_DEBUG
kdDebug(6040) << renderName() << "(RenderBlock)::rightmostPosition(" << includeOverflowInterior << "," << includeSelf << ") Rightmost position: " << right << " overflow width: " << m_overflowWidth << endl;
#endif
return right; return right;
} }
@ -2184,6 +2189,9 @@ int RenderBlock::rightmostAbsolutePosition() const
int rp = r->xPos() + r->rightmostPosition(false); int rp = r->xPos() + r->rightmostPosition(false);
right = kMax(right, rp); right = kMax(right, rp);
} }
#ifdef PAGE_DEBUG
kdDebug(6040) << renderName() << " Rightmost absolute position: " << right << endl;
#endif
return right; return right;
} }

@ -319,7 +319,7 @@ void RenderCanvas::paint(PaintInfo& paintInfo, int _tx, int _ty)
_ty += m_view->contentsY(); _ty += m_view->contentsY();
} }
outlineBox(p, _tx, _ty); outlineBox(paintInfo.p, _tx, _ty);
#endif #endif
} }

@ -358,6 +358,9 @@ int RenderFlow::rightmostPosition(bool includeOverflowInterior, bool includeSelf
relativePositionOffset(right, y); relativePositionOffset(right, y);
} }
#ifdef DEBUG_LAYOUT
kdDebug(6040) << renderName() << "(RenderFlow)::rightmostPosition(" << includeOverflowInterior << "," << includeSelf << ") Rightmost position: " << right << endl;
#endif
return right; return right;
} }

@ -84,7 +84,15 @@ public:
RootInlineBox* root(); RootInlineBox* root();
void setWidth(short w) { m_width = w; } void setWidth(short w) {
if (w < 0) {
m_width = SHRT_MAX;
kdDebug( 6040 ) << " InlineBox::setWidth() invalid negative width " << w << " specified!" << endl;
}
else {
m_width = w;
}
}
short width() const { return m_width; } short width() const { return m_width; }
void setXPos(short x) { m_x = x; } void setXPos(short x) { m_x = x; }

@ -334,10 +334,8 @@ public:
m_minMaxKnown = b; m_minMaxKnown = b;
if ( !b ) { if ( !b ) {
RenderObject *o = this; RenderObject *o = this;
RenderObject *root = this;
while( o ) { // ### && !o->m_recalcMinMax ) { while( o ) { // ### && !o->m_recalcMinMax ) {
o->m_recalcMinMax = true; o->m_recalcMinMax = true;
root = o;
o = o->m_parent; o = o->m_parent;
} }
} }

@ -23,8 +23,8 @@
* *
*/ */
//#define DEBUG_LAYOUT // #define DEBUG_LAYOUT
//#define BIDI_DEBUG // #define BIDI_DEBUG
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>
@ -295,7 +295,7 @@ void InlineTextBox::paintDecoration( TQPainter *pt, const Font *f, int _tx, int
pt->setPen(linethrough); pt->setPen(linethrough);
f->drawDecoration(pt, _tx, _ty, baseline(), width, height(), Font::LINE_THROUGH); f->drawDecoration(pt, _tx, _ty, baseline(), width, height(), Font::LINE_THROUGH);
} }
// NO! Do NOT add BLINK! It is the most annouing feature of Netscape, and IE has a reason not to // NO! Do NOT add BLINK! It is the most annoying feature of Netscape, and IE has a reason not to
// support it. Lars // support it. Lars
} }
@ -1305,7 +1305,9 @@ unsigned int RenderText::width(unsigned int from, unsigned int len, const Font *
int w = f->width(str->s, str->l, from, len ); int w = f->width(str->s, str->l, from, len );
//kdDebug( 6040 ) << "RenderText::width(" << from << ", " << len << ") = " << w << endl; #ifdef DEBUG_LAYOUT
kdDebug( 6040 ) << "RenderText::width(" << from << ", " << len << ") = " << w << endl;
#endif
return w; return w;
} }
@ -1315,16 +1317,19 @@ short RenderText::width() const
int minx = 100000000; int minx = 100000000;
int maxx = 0; int maxx = 0;
// slooow // slooow
for(unsigned int si = 0; si < m_lines.count(); si++) { for (unsigned int si = 0; si < m_lines.count(); si++) {
InlineTextBox* s = m_lines[si]; InlineTextBox* s = m_lines[si];
if(s->m_x < minx) if (s->m_x < minx)
minx = s->m_x; minx = s->m_x;
if(s->m_x + s->m_width > maxx) if (s->m_x + s->m_width > maxx)
maxx = s->m_x + s->m_width; maxx = s->m_x + s->m_width;
} }
w = kMax(0, maxx-minx); w = kMax(0, maxx-minx);
#ifdef DEBUG_LAYOUT
kdDebug( 6040 ) << "RenderText::width() = " << w << endl;
#endif
return w; return w;
} }
@ -1486,7 +1491,7 @@ static TQString quoteAndEscapeNonPrintables(const TQString &s)
static void writeTextRun(TQTextStream &ts, const RenderText &o, const InlineTextBox &run) static void writeTextRun(TQTextStream &ts, const RenderText &o, const InlineTextBox &run)
{ {
ts << "text run at (" << run.m_x << "," << run.m_y << ") width " << run.m_width << ": " ts << "text run at (" << run.m_x << "," << run.m_y << ") width " << run.width() << ": "
<< quoteAndEscapeNonPrintables(o.data().string().mid(run.m_start, run.m_len)); << quoteAndEscapeNonPrintables(o.data().string().mid(run.m_start, run.m_len));
} }

@ -74,7 +74,15 @@ private:
void* operator new(size_t sz) throw(); void* operator new(size_t sz) throw();
public: public:
void setSpaceAdd(int add) { m_width -= m_toAdd; m_toAdd = add; m_width += m_toAdd; } void setSpaceAdd(int add) {
if (add < 0) {
m_toAdd = 0;
kdDebug( 6040 ) << " InlineTextBox::setSpaceAdd() invalid negative value " << add << " specified!" << endl;
}
else {
m_width -= m_toAdd; m_toAdd = add; m_width += m_toAdd;
}
}
int spaceAdd() { return m_toAdd; } int spaceAdd() { return m_toAdd; }
virtual bool isInlineTextBox() const { return true; } virtual bool isInlineTextBox() const { return true; }

@ -2345,7 +2345,7 @@ bool DocumentImpl::isURLAllowed(const TQString& url) const
return false; return false;
// Prohibit non-file URLs if we are asked to. // Prohibit non-file URLs if we are asked to.
if (!thisPart || thisPart->onlyLocalReferences() && newURL.protocol() != "file" && newURL.protocol() != "data") if (!thisPart || (thisPart->onlyLocalReferences() && (newURL.protocol() != "file") && (newURL.protocol() != "data")))
return false; return false;
// do we allow this suburl ? // do we allow this suburl ?

@ -27,6 +27,8 @@
#ifndef _DOM_DocumentImpl_h_ #ifndef _DOM_DocumentImpl_h_
#define _DOM_DocumentImpl_h_ #define _DOM_DocumentImpl_h_
#include <stdint.h>
#include "xml/dom_elementimpl.h" #include "xml/dom_elementimpl.h"
#include "xml/dom_textimpl.h" #include "xml/dom_textimpl.h"
#include "xml/dom2_traversalimpl.h" #include "xml/dom2_traversalimpl.h"
@ -617,7 +619,7 @@ protected:
TQString name = cs ? n.string() : n.string().upper(); TQString name = cs ? n.string() : n.string().upper();
TQString qn("aliases: " + (cs ? px.string() : px.string().upper()) + ":" + name); TQString qn("aliases: " + (cs ? px.string() : px.string().upper()) + ":" + name);
if (!ids.find( qn )) { if (!ids.find( qn )) {
ids.insert( qn, (void*)id ); ids.insert( qn, (void*)(intptr_t)id );
} }
} }
expandIfNeeded(); expandIfNeeded();

Loading…
Cancel
Save