[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
hyatt
hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:24:36 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 35a85e5947befbb6c1c13befb127eb71ecf959ca
Author: hyatt <hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Feb 14 19:43:07 2003 +0000
Make the inline box model live. Borders/backgrounds and text
decorations have been rewritten.
Also fixed a bug with clip rects. They didn't include borders.
Reviewed by kocienda
* khtml/css/cssstyleselector.cpp:
* khtml/ecma/kjs_window.cpp:
(WindowFunc::tryCall):
* khtml/rendering/bidi.cpp:
* khtml/rendering/font.cpp:
* khtml/rendering/font.h:
* khtml/rendering/render_block.cpp:
* khtml/rendering/render_block.h:
* khtml/rendering/render_box.cpp:
(RenderBox::paintBackground):
(RenderBox::paintBackgroundExtended):
(RenderBox::getClipRect):
(RenderBox::position):
* khtml/rendering/render_box.h:
* khtml/rendering/render_flow.cpp:
(RenderFlow::createInlineBox):
(RenderFlow::paintLineBoxBackgroundBorder):
(RenderFlow::paintLineBoxDecorations):
(RenderFlow::repaint):
* khtml/rendering/render_flow.h:
* khtml/rendering/render_inline.cpp:
(RenderInline::paintObject):
(RenderInline::width):
(RenderInline::height):
(RenderInline::offsetLeft):
(RenderInline::offsetTop):
(RenderInline::nodeAtPoint):
* khtml/rendering/render_inline.h:
* khtml/rendering/render_line.cpp:
(InlineFlowBox::verticallyAlignBoxes):
(InlineFlowBox::computeLogicalBoxHeights):
(InlineFlowBox::placeBoxesVertically):
(InlineFlowBox::shrinkBoxesWithNoTextChildren):
(InlineFlowBox::paintBackgroundAndBorder):
(shouldDrawDecoration):
(InlineFlowBox::paintDecorations):
* khtml/rendering/render_line.h:
* khtml/rendering/render_object.cpp:
(RenderObject::setStyle):
(RenderObject::lineHeight):
(RenderObject::getTextDecorationColors):
* khtml/rendering/render_object.h:
* khtml/rendering/render_root.cpp:
(enclosingPositionedRect):
* khtml/rendering/render_style.cpp:
(StyleVisualData::StyleVisualData):
(StyleInheritedData::StyleInheritedData):
(StyleInheritedData::operator==):
(RenderStyle::diff):
* khtml/rendering/render_style.h:
* khtml/rendering/render_table.cpp:
(RenderTableCell::repaintRectangle):
* khtml/rendering/render_text.cpp:
(TextRun::paintDecoration):
(TextRun::checkSelectionPoint):
(RenderText::nodeAtPoint):
(RenderText::cursorPos):
(RenderText::absolutePosition):
(RenderText::paintObject):
(RenderText::paint):
(RenderText::position):
* khtml/rendering/render_text.h:
* kwq/KWQPainter.h:
* kwq/KWQPainter.mm:
(QPainter::drawLineForText):
* kwq/WebCoreTextRenderer.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3648 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 5fe2b69..bf52122 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,79 @@
+2003-02-14 David Hyatt <hyatt at apple.com>
+
+ Make the inline box model live. Borders/backgrounds and text
+ decorations have been rewritten.
+
+ Also fixed a bug with clip rects. They didn't include borders.
+
+ Reviewed by kocienda
+
+ * khtml/css/cssstyleselector.cpp:
+ * khtml/ecma/kjs_window.cpp:
+ (WindowFunc::tryCall):
+ * khtml/rendering/bidi.cpp:
+ * khtml/rendering/font.cpp:
+ * khtml/rendering/font.h:
+ * khtml/rendering/render_block.cpp:
+ * khtml/rendering/render_block.h:
+ * khtml/rendering/render_box.cpp:
+ (RenderBox::paintBackground):
+ (RenderBox::paintBackgroundExtended):
+ (RenderBox::getClipRect):
+ (RenderBox::position):
+ * khtml/rendering/render_box.h:
+ * khtml/rendering/render_flow.cpp:
+ (RenderFlow::createInlineBox):
+ (RenderFlow::paintLineBoxBackgroundBorder):
+ (RenderFlow::paintLineBoxDecorations):
+ (RenderFlow::repaint):
+ * khtml/rendering/render_flow.h:
+ * khtml/rendering/render_inline.cpp:
+ (RenderInline::paintObject):
+ (RenderInline::width):
+ (RenderInline::height):
+ (RenderInline::offsetLeft):
+ (RenderInline::offsetTop):
+ (RenderInline::nodeAtPoint):
+ * khtml/rendering/render_inline.h:
+ * khtml/rendering/render_line.cpp:
+ (InlineFlowBox::verticallyAlignBoxes):
+ (InlineFlowBox::computeLogicalBoxHeights):
+ (InlineFlowBox::placeBoxesVertically):
+ (InlineFlowBox::shrinkBoxesWithNoTextChildren):
+ (InlineFlowBox::paintBackgroundAndBorder):
+ (shouldDrawDecoration):
+ (InlineFlowBox::paintDecorations):
+ * khtml/rendering/render_line.h:
+ * khtml/rendering/render_object.cpp:
+ (RenderObject::setStyle):
+ (RenderObject::lineHeight):
+ (RenderObject::getTextDecorationColors):
+ * khtml/rendering/render_object.h:
+ * khtml/rendering/render_root.cpp:
+ (enclosingPositionedRect):
+ * khtml/rendering/render_style.cpp:
+ (StyleVisualData::StyleVisualData):
+ (StyleInheritedData::StyleInheritedData):
+ (StyleInheritedData::operator==):
+ (RenderStyle::diff):
+ * khtml/rendering/render_style.h:
+ * khtml/rendering/render_table.cpp:
+ (RenderTableCell::repaintRectangle):
+ * khtml/rendering/render_text.cpp:
+ (TextRun::paintDecoration):
+ (TextRun::checkSelectionPoint):
+ (RenderText::nodeAtPoint):
+ (RenderText::cursorPos):
+ (RenderText::absolutePosition):
+ (RenderText::paintObject):
+ (RenderText::paint):
+ (RenderText::position):
+ * khtml/rendering/render_text.h:
+ * kwq/KWQPainter.h:
+ * kwq/KWQPainter.mm:
+ (QPainter::drawLineForText):
+ * kwq/WebCoreTextRenderer.h:
+
2003-02-13 Trey Matteson <trey at apple.com>
First checkin for working forms autocomplete.
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 5fe2b69..bf52122 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,79 @@
+2003-02-14 David Hyatt <hyatt at apple.com>
+
+ Make the inline box model live. Borders/backgrounds and text
+ decorations have been rewritten.
+
+ Also fixed a bug with clip rects. They didn't include borders.
+
+ Reviewed by kocienda
+
+ * khtml/css/cssstyleselector.cpp:
+ * khtml/ecma/kjs_window.cpp:
+ (WindowFunc::tryCall):
+ * khtml/rendering/bidi.cpp:
+ * khtml/rendering/font.cpp:
+ * khtml/rendering/font.h:
+ * khtml/rendering/render_block.cpp:
+ * khtml/rendering/render_block.h:
+ * khtml/rendering/render_box.cpp:
+ (RenderBox::paintBackground):
+ (RenderBox::paintBackgroundExtended):
+ (RenderBox::getClipRect):
+ (RenderBox::position):
+ * khtml/rendering/render_box.h:
+ * khtml/rendering/render_flow.cpp:
+ (RenderFlow::createInlineBox):
+ (RenderFlow::paintLineBoxBackgroundBorder):
+ (RenderFlow::paintLineBoxDecorations):
+ (RenderFlow::repaint):
+ * khtml/rendering/render_flow.h:
+ * khtml/rendering/render_inline.cpp:
+ (RenderInline::paintObject):
+ (RenderInline::width):
+ (RenderInline::height):
+ (RenderInline::offsetLeft):
+ (RenderInline::offsetTop):
+ (RenderInline::nodeAtPoint):
+ * khtml/rendering/render_inline.h:
+ * khtml/rendering/render_line.cpp:
+ (InlineFlowBox::verticallyAlignBoxes):
+ (InlineFlowBox::computeLogicalBoxHeights):
+ (InlineFlowBox::placeBoxesVertically):
+ (InlineFlowBox::shrinkBoxesWithNoTextChildren):
+ (InlineFlowBox::paintBackgroundAndBorder):
+ (shouldDrawDecoration):
+ (InlineFlowBox::paintDecorations):
+ * khtml/rendering/render_line.h:
+ * khtml/rendering/render_object.cpp:
+ (RenderObject::setStyle):
+ (RenderObject::lineHeight):
+ (RenderObject::getTextDecorationColors):
+ * khtml/rendering/render_object.h:
+ * khtml/rendering/render_root.cpp:
+ (enclosingPositionedRect):
+ * khtml/rendering/render_style.cpp:
+ (StyleVisualData::StyleVisualData):
+ (StyleInheritedData::StyleInheritedData):
+ (StyleInheritedData::operator==):
+ (RenderStyle::diff):
+ * khtml/rendering/render_style.h:
+ * khtml/rendering/render_table.cpp:
+ (RenderTableCell::repaintRectangle):
+ * khtml/rendering/render_text.cpp:
+ (TextRun::paintDecoration):
+ (TextRun::checkSelectionPoint):
+ (RenderText::nodeAtPoint):
+ (RenderText::cursorPos):
+ (RenderText::absolutePosition):
+ (RenderText::paintObject):
+ (RenderText::paint):
+ (RenderText::position):
+ * khtml/rendering/render_text.h:
+ * kwq/KWQPainter.h:
+ * kwq/KWQPainter.mm:
+ (QPainter::drawLineForText):
+ * kwq/WebCoreTextRenderer.h:
+
2003-02-13 Trey Matteson <trey at apple.com>
First checkin for working forms autocomplete.
diff --git a/WebCore/khtml/css/cssstyleselector.cpp b/WebCore/khtml/css/cssstyleselector.cpp
index ad9e27b..6271882 100644
--- a/WebCore/khtml/css/cssstyleselector.cpp
+++ b/WebCore/khtml/css/cssstyleselector.cpp
@@ -1904,8 +1904,6 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
style->setBorderLeftColor(col); break;
case CSS_PROP_COLOR:
style->setColor(col); break;
- case CSS_PROP_TEXT_DECORATION_COLOR:
- style->setTextDecorationColor(col); break;
case CSS_PROP_OUTLINE_COLOR:
style->setOutlineColor(col); break;
case CSS_PROP_SCROLLBAR_FACE_COLOR:
@@ -2659,8 +2657,8 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
if(value->cssValueType() == CSSValue::CSS_INHERIT)
{
if(!parentNode) return;
- style->setTextDecoration(parentStyle->textDecoration());
- style->setTextDecorationColor(parentStyle->textDecorationColor());
+ style->addToTextDecorationsInEffect(parentStyle->textDecorationsInEffect());
+ style->setTextDecoration(parentStyle->textDecorationsInEffect());
return;
}
int t = TDNONE;
@@ -2692,9 +2690,10 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
}
}
}
- style->setTextDecoration(t);
- style->setTextDecorationColor(style->color());
- break;
+
+ style->addToTextDecorationsInEffect(t);
+ style->setTextDecoration(t);
+ break;
}
case CSS_PROP__KONQ_FLOW_MODE:
if(value->cssValueType() == CSSValue::CSS_INHERIT)
diff --git a/WebCore/khtml/ecma/kjs_window.cpp b/WebCore/khtml/ecma/kjs_window.cpp
index 382e492..c578e14 100644
--- a/WebCore/khtml/ecma/kjs_window.cpp
+++ b/WebCore/khtml/ecma/kjs_window.cpp
@@ -1444,12 +1444,7 @@ Value WindowFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
JSEventListener *listener = Window::retrieveActive(exec)->getJSEventListener(args[1]);
if (listener) {
DOM::Document doc = part->document();
- if (doc.isHTMLDocument()) {
- DOM::HTMLDocument htmlDoc = doc;
- htmlDoc.body().addEventListener(args[0].toString(exec).string(),listener,args[2].toBoolean(exec));
- }
- else
- doc.addEventListener(args[0].toString(exec).string(),listener,args[2].toBoolean(exec));
+ doc.addEventListener(args[0].toString(exec).string(),listener,args[2].toBoolean(exec));
}
return Undefined();
}
@@ -1459,12 +1454,7 @@ Value WindowFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
JSEventListener *listener = Window::retrieveActive(exec)->getJSEventListener(args[1]);
if (listener) {
DOM::Document doc = part->document();
- if (doc.isHTMLDocument()) {
- DOM::HTMLDocument htmlDoc = doc;
- htmlDoc.body().removeEventListener(args[0].toString(exec).string(),listener,args[2].toBoolean(exec));
- }
- else
- doc.removeEventListener(args[0].toString(exec).string(),listener,args[2].toBoolean(exec));
+ doc.removeEventListener(args[0].toString(exec).string(),listener,args[2].toBoolean(exec));
}
return Undefined();
}
diff --git a/WebCore/khtml/rendering/bidi.cpp b/WebCore/khtml/rendering/bidi.cpp
index 9b46605..da12568 100644
--- a/WebCore/khtml/rendering/bidi.cpp
+++ b/WebCore/khtml/rendering/bidi.cpp
@@ -666,10 +666,15 @@ void RenderBlock::computeVerticalPositionsForLine(InlineFlowBox* lineBox, QPtrLi
{
lineBox->verticallyAlignBoxes(m_height);
+ // See if the line spilled out. If so set overflow height accordingly.
+ int bottomOfLine = lineBox->bottomOverflow();
+ if (bottomOfLine > m_height && bottomOfLine > m_overflowHeight)
+ m_overflowHeight = bottomOfLine;
+
// Now make sure we place replaced render objects correctly.
BidiRun* r = runs.first();
while (r) {
- r->obj->position(r->box, r->box->yPos(), r->start, r->stop - r->start, r->level%2);
+ r->obj->position(r->box, r->start, r->stop - r->start, r->level%2);
r = runs.next();
}
}
@@ -1249,10 +1254,10 @@ void RenderBlock::layoutInlineChildren(bool relayoutChildren)
++end;
adjustEmbeddding = false;
}
-
+
+ m_firstLine = false;
newLine();
}
- m_firstLine = false;
deleteMidpoints(renderArena(), smidpoints);
}
startEmbed->deref();
@@ -1268,7 +1273,8 @@ void RenderBlock::layoutInlineChildren(bool relayoutChildren)
positionNewFloats();
// Always make sure this is at least our height.
- m_overflowHeight = m_height;
+ if (m_overflowHeight < m_height)
+ m_overflowHeight = m_height;
#if BIDI_DEBUG > 1
kdDebug(6041) << " ------- bidi end " << this << " -------" << endl;
diff --git a/WebCore/khtml/rendering/font.cpp b/WebCore/khtml/rendering/font.cpp
index 3f4c50c..6c21bbe 100644
--- a/WebCore/khtml/rendering/font.cpp
+++ b/WebCore/khtml/rendering/font.cpp
@@ -39,14 +39,6 @@
using namespace khtml;
-#if APPLE_CHANGES
-void Font::drawLineForText( QPainter *p, int x, int y, QChar *str, int slen, int pos, int len,
- int toAdd, int yOffset, QPainter::TextDirection d, int from, int to) const
-{
- p->drawLineForText(x, y, str + pos, std::min(slen - pos, len), from, to, toAdd, yOffset, d, letterSpacing, wordSpacing);
-}
-#endif
-
void Font::drawText( QPainter *p, int x, int y, QChar *str, int slen, int pos, int len,
int toAdd, QPainter::TextDirection d, int from, int to, QColor bg ) const
{
diff --git a/WebCore/khtml/rendering/font.h b/WebCore/khtml/rendering/font.h
index 7b2ca03..f432583 100644
--- a/WebCore/khtml/rendering/font.h
+++ b/WebCore/khtml/rendering/font.h
@@ -101,8 +101,6 @@ public:
QPainter::TextDirection d, int from=-1, int to=-1, QColor bg=QColor() ) const;
#if APPLE_CHANGES
- void drawLineForText( QPainter *p, int x, int y, QChar *str, int slen, int pos, int len, int toAdd, int yOffset,
- QPainter::TextDirection d, int from=-1, int to=-1) const;
float floatWidth( QChar *str, int slen, int pos, int len ) const;
void floatCharacterWidths( QChar *str, int slen, int pos, int len, int toAdd, float *buffer) const;
bool isFixedPitch() const;
diff --git a/WebCore/khtml/rendering/render_block.cpp b/WebCore/khtml/rendering/render_block.cpp
index 1205ef9..13e317d 100644
--- a/WebCore/khtml/rendering/render_block.cpp
+++ b/WebCore/khtml/rendering/render_block.cpp
@@ -1030,13 +1030,19 @@ void RenderBlock::paint(QPainter* p, int _x, int _y, int _w, int _h, int _tx, in
// check if we need to do anything at all...
if (!overhangingContents() && !isRelPositioned() && !isPositioned() )
{
- int h = m_height;
- if(m_specialObjects && floatBottom() > h) h = floatBottom();
- if((_ty > _y + _h) || (_ty + h < _y))
- {
- //kdDebug( 6040 ) << "cut!" << endl;
+ int h = m_overflowHeight;
+ int yPos = _ty;
+ if (m_specialObjects && floatBottom() > h)
+ h = floatBottom();
+
+ // Sanity check the first line
+ // to see if it extended a little above our box. Overflow out the bottom is already handled via
+ // overflowHeight(), so we don't need to check that.
+ if (m_firstLineBox && m_firstLineBox->topOverflow() < 0)
+ yPos += m_firstLineBox->topOverflow();
+
+ if( (yPos > _y + _h) || (_ty + h < _y))
return;
- }
}
paintObject(p, _x, _y, _w, _h, _tx, _ty, paintAction);
@@ -1059,6 +1065,7 @@ void RenderBlock::paintObject(QPainter *p, int _x, int _y,
paintBoxDecorations(p, _x, _y, _w, _h, _tx, _ty);
// 2. paint contents
+ paintLineBoxBackgroundBorder(p, _x, _y, _w, _h, _tx, _ty, paintAction);
RenderObject *child = firstChild();
while(child != 0)
{
@@ -1066,7 +1073,8 @@ void RenderBlock::paintObject(QPainter *p, int _x, int _y,
child->paint(p, _x, _y, _w, _h, _tx, _ty, paintAction);
child = child->nextSibling();
}
-
+ paintLineBoxDecorations(p, _x, _y, _w, _h, _tx, _ty, paintAction);
+
// 3. paint floats.
if (!inlineRunIn && (paintAction == PaintActionFloat || paintAction == PaintActionSelection))
paintFloats(p, _x, _y, _w, _h, _tx, _ty, paintAction == PaintActionSelection);
diff --git a/WebCore/khtml/rendering/render_block.h b/WebCore/khtml/rendering/render_block.h
index 64c1ecc..fd18d60 100644
--- a/WebCore/khtml/rendering/render_block.h
+++ b/WebCore/khtml/rendering/render_block.h
@@ -94,7 +94,7 @@ public:
void bidiReorderLine(const BidiIterator &start, const BidiIterator &end);
BidiIterator findNextLineBreak(BidiIterator &start, QPtrList<BidiIterator>& midpoints);
InlineFlowBox* constructLine(QPtrList<BidiRun>& runs, const BidiIterator& start,
- const BidiIterator& end);
+ const BidiIterator& end);
InlineFlowBox* createLineBoxes(RenderObject* obj);
void computeHorizontalPositionsForLine(InlineFlowBox* lineBox, QPtrList<BidiRun>& runs,
BidiContext* endEmbed);
diff --git a/WebCore/khtml/rendering/render_box.cpp b/WebCore/khtml/rendering/render_box.cpp
index e80dbfd..3d96d9a 100644
--- a/WebCore/khtml/rendering/render_box.cpp
+++ b/WebCore/khtml/rendering/render_box.cpp
@@ -198,6 +198,14 @@ void RenderBox::paintBoxDecorations(QPainter *p,int, int _y,
void RenderBox::paintBackground(QPainter *p, const QColor &c, CachedImage *bg, int clipy, int cliph, int _tx, int _ty, int w, int height)
{
+ paintBackgroundExtended(p, c, bg, clipy, cliph, _tx, _ty, w, height,
+ borderLeft(), borderRight());
+}
+
+void RenderBox::paintBackgroundExtended(QPainter *p, const QColor &c, CachedImage *bg, int clipy, int cliph,
+ int _tx, int _ty, int w, int h,
+ int bleft, int bright)
+{
if(c.isValid())
p->fillRect(_tx, clipy, w, cliph, c);
// no progressive loading of the background image
@@ -215,24 +223,15 @@ void RenderBox::paintBackground(QPainter *p, const QColor &c, CachedImage *bg, i
int sy = 0;
int cw,ch;
int cx,cy;
- int vpab = borderRight() + borderLeft();
+ int vpab = bleft + bright;
int hpab = borderTop() + borderBottom();
-
+
// CSS2 chapter 14.2.1
if (sptr->backgroundAttachment())
{
//scroll
- int pw = m_width - vpab;
- int h = isHtml() ? height : m_height;
- if (isTableCell()) {
- // Table cells' m_height variable is wrong. You have to take into
- // account this hack extra stuff to get the right height.
- // Otherwise using background-position: bottom won't work in
- // a table cell that has the extra height. -dwh
- RenderTableCell* tableCell = static_cast<RenderTableCell*>(this);
- h += tableCell->borderTopExtra() + tableCell->borderBottomExtra();
- }
+ int pw = w - vpab;
int ph = h - hpab;
int pixw = bg->pixmap_size().width();
@@ -262,7 +261,7 @@ void RenderBox::paintBackground(QPainter *p, const QColor &c, CachedImage *bg, i
}
}
- cx += borderLeft();
+ cx += bleft;
if( (bgr == NO_REPEAT || bgr == REPEAT_X) && h > pixh ) {
ch = pixh;
@@ -313,7 +312,7 @@ void RenderBox::paintBackground(QPainter *p, const QColor &c, CachedImage *bg, i
}
}
- if( (bgr == NO_REPEAT || bgr == REPEAT_X) && height > pixh ) {
+ if( (bgr == NO_REPEAT || bgr == REPEAT_X) && h > pixh ) {
ch = pixh;
cy = vr.y() + sptr->backgroundYPosition().minWidth(ph-pixh);
} else {
@@ -327,7 +326,7 @@ void RenderBox::paintBackground(QPainter *p, const QColor &c, CachedImage *bg, i
}
QRect fix(cx,cy,cw,ch);
- QRect ele(_tx+borderLeft(),_ty+borderTop(),w-vpab,height-hpab);
+ QRect ele(_tx+bleft,_ty+borderTop(),w-vpab,h-hpab);
QRect b = fix.intersect(ele);
sx+=b.x()-cx;
sy+=b.y()-cy;
@@ -364,35 +363,34 @@ QRect RenderBox::getOverflowClipRect(int tx, int ty)
QRect RenderBox::getClipRect(int tx, int ty)
{
- int bl=borderLeft(),bt=borderTop(),bb=borderBottom(),br=borderRight();
- int clipx = tx+bl;
- int clipy = ty+bt;
- int clipw = m_width-bl-br;
- int cliph = m_height-bt-bb;
+ int clipx = tx;
+ int clipy = ty;
+ int clipw = m_width;
+ int cliph = m_height;
if (!style()->clipLeft().isVariable())
{
- int c=style()->clipLeft().width(m_width-bl-br);
+ int c=style()->clipLeft().width(m_width);
clipx+=c;
clipw-=c;
}
if (!style()->clipRight().isVariable())
{
- int w = style()->clipRight().width(m_width-bl-br);
- clipw -= m_width - bl - br - w;
+ int w = style()->clipRight().width(m_width);
+ clipw -= m_width - w;
}
if (!style()->clipTop().isVariable())
{
- int c=style()->clipTop().width(m_height-bt-bb);
+ int c=style()->clipTop().width(m_height);
clipy+=c;
cliph-=c;
}
if (!style()->clipBottom().isVariable())
{
- int h = style()->clipBottom().width(m_height-bt-bb);
- cliph -= m_height - bt - bb - h;
+ int h = style()->clipBottom().width(m_height);
+ cliph -= m_height - h;
}
//kdDebug( 6040 ) << "setting clip("<<clipx<<","<<clipy<<","<<clipw<<","<<cliph<<")"<<endl;
@@ -437,10 +435,10 @@ bool RenderBox::absolutePosition(int &xPos, int &yPos, bool f)
}
}
-void RenderBox::position(InlineBox* box, int y, int from, int len, bool reverse)
+void RenderBox::position(InlineBox* box, int from, int len, bool reverse)
{
m_x = box->xPos();
- m_y = y + marginTop();
+ m_y = box->yPos();
}
void RenderBox::repaint(bool immediate)
diff --git a/WebCore/khtml/rendering/render_box.h b/WebCore/khtml/rendering/render_box.h
index fe965d5..aa996c4 100644
--- a/WebCore/khtml/rendering/render_box.h
+++ b/WebCore/khtml/rendering/render_box.h
@@ -83,7 +83,7 @@ public:
// shifted. -dwh
void calcHorizontalMargins(const Length& ml, const Length& mr, int cw);
- virtual void position(InlineBox* box, int y, int from, int len, bool reverse);
+ virtual void position(InlineBox* box, int from, int len, bool reverse);
virtual int lowestPosition() const;
virtual int rightmostPosition() const;
@@ -111,6 +111,10 @@ public:
void relativePositionOffset(int &tx, int &ty);
virtual RenderLayer* layer() const { return m_layer; }
+
+ virtual void paintBackgroundExtended(QPainter *p, const QColor &c, CachedImage *bg, int clipy, int cliph,
+ int _tx, int _ty, int w, int height,
+ int bleft, int bright);
protected:
virtual void paintBoxDecorations(QPainter *p,int _x, int _y,
diff --git a/WebCore/khtml/rendering/render_flow.cpp b/WebCore/khtml/rendering/render_flow.cpp
index 6dcf570..d7e62b5 100644
--- a/WebCore/khtml/rendering/render_flow.cpp
+++ b/WebCore/khtml/rendering/render_flow.cpp
@@ -153,7 +153,12 @@ void RenderFlow::detach(RenderArena* renderArena)
InlineBox* RenderFlow::createInlineBox()
{
- InlineFlowBox* flowBox = new (renderArena()) InlineFlowBox(this);
+ InlineFlowBox* flowBox = 0;
+ if (isInlineFlow())
+ flowBox = new (renderArena()) InlineFlowBox(this);
+ else
+ flowBox = new (renderArena()) RootInlineBox(this);
+
if (!m_firstLineBox)
m_firstLineBox = m_lastLineBox = flowBox;
else {
@@ -165,3 +170,92 @@ InlineBox* RenderFlow::createInlineBox()
return flowBox;
}
+void RenderFlow::paintLineBoxBackgroundBorder(QPainter *p, int _x, int _y,
+ int _w, int _h, int _tx, int _ty, PaintAction paintAction)
+{
+ if (!firstLineBox())
+ return;
+
+ if (style()->visibility() == VISIBLE && paintAction == PaintActionForeground) {
+ // We can check the first box and last box and avoid painting if we don't
+ // intersect.
+ int yPos = _ty + firstLineBox()->yPos();
+ int h = lastLineBox()->yPos() + lastLineBox()->height() - firstLineBox()->yPos();
+ if( (yPos > _y + _h) || (yPos + h < _y))
+ return;
+
+ // See if our boxes intersect with the dirty rect. If so, then we paint
+ // them. Note that boxes can easily overlap, so we can't make any assumptions
+ // based off positions of our first line box or our last line box.
+ int xOffsetWithinLineBoxes = 0;
+ for (InlineRunBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) {
+ yPos = _ty + curr->yPos();
+ h = curr->height();
+ if ((yPos <= _y + _h) && (yPos + h >= _y))
+ curr->paintBackgroundAndBorder(p, _x, _y, _w, _h, _tx, _ty, xOffsetWithinLineBoxes);
+ xOffsetWithinLineBoxes += curr->width();
+ }
+ }
+}
+
+void RenderFlow::paintLineBoxDecorations(QPainter *p, int _x, int _y,
+ int _w, int _h, int _tx, int _ty, PaintAction paintAction)
+{
+ if (!firstLineBox())
+ return;
+
+ if (style()->visibility() == VISIBLE && paintAction == PaintActionForeground) {
+ // We only paint line box decorations in strict or almost strict mode.
+ // Otherwise we let the TextRuns paint their own decorations.
+ RenderObject* curr = this;
+ while (curr && !curr->element())
+ curr = curr->container();
+ bool quirksMode = (curr && curr->element()->getDocument()->inQuirksMode());
+ if (quirksMode)
+ return;
+
+ // We can check the first box and last box and avoid painting if we don't
+ // intersect.
+ int yPos = _ty + firstLineBox()->yPos();;
+ int h = lastLineBox()->yPos() + lastLineBox()->height() - firstLineBox()->yPos();
+ if( (yPos > _y + _h) || (yPos + h < _y))
+ return;
+
+ // See if our boxes intersect with the dirty rect. If so, then we paint
+ // them. Note that boxes can easily overlap, so we can't make any assumptions
+ // based off positions of our first line box or our last line box.
+ for (InlineRunBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) {
+ yPos = _ty + curr->yPos();
+ h = curr->height();
+ if ((yPos <= _y + _h) && (yPos + h >= _y))
+ curr->paintDecorations(p, _x, _y, _w, _h, _tx, _ty);
+ }
+ }
+}
+
+void RenderFlow::repaint(bool immediate)
+{
+ if (isInlineFlow()) {
+ // Find our leftmost position.
+ int left = 0;
+ int top = firstLineBox() ? firstLineBox()->yPos() : 0;
+ for (InlineRunBox* curr = firstLineBox(); curr; curr = curr->nextLineBox())
+ if (curr == firstLineBox() || curr->xPos() < left)
+ left = curr->xPos();
+
+ // Now invalidate a rectangle.
+ int ow = style() ? style()->outlineWidth() : 0;
+ containingBlock()->repaintRectangle(-ow+left, -ow+top,
+ width()+ow*2, height()+ow*2, immediate);
+ }
+ else {
+ if (firstLineBox() && firstLineBox()->topOverflow() < 0) {
+ int ow = style() ? style()->outlineWidth() : 0;
+ repaintRectangle(-ow, -ow+firstLineBox()->topOverflow(),
+ overflowWidth()+ow*2, overflowHeight()+ow*2, immediate);
+ }
+ else
+ return RenderBox::repaint();
+ }
+}
+
diff --git a/WebCore/khtml/rendering/render_flow.h b/WebCore/khtml/rendering/render_flow.h
index f774a27..1995d9d 100644
--- a/WebCore/khtml/rendering/render_flow.h
+++ b/WebCore/khtml/rendering/render_flow.h
@@ -59,10 +59,17 @@ public:
void deleteLineBoxes(RenderArena* arena=0);
virtual void detach(RenderArena* arena);
- InlineFlowBox* firstLineBox() { return m_firstLineBox; }
- InlineFlowBox* lastLineBox() { return m_lastLineBox; }
+ InlineFlowBox* firstLineBox() const { return m_firstLineBox; }
+ InlineFlowBox* lastLineBox() const { return m_lastLineBox; }
virtual InlineBox* createInlineBox();
+
+ void paintLineBoxBackgroundBorder(QPainter *p, int _x, int _y,
+ int _w, int _h, int _tx, int _ty, PaintAction paintAction);
+ void paintLineBoxDecorations(QPainter *p, int _x, int _y,
+ int _w, int _h, int _tx, int _ty, PaintAction paintAction);
+
+ virtual void repaint(bool immediate = false);
protected:
// An inline can be split with blocks occurring in between the inline content.
diff --git a/WebCore/khtml/rendering/render_inline.cpp b/WebCore/khtml/rendering/render_inline.cpp
index f38b8ae..bd367a0 100644
--- a/WebCore/khtml/rendering/render_inline.cpp
+++ b/WebCore/khtml/rendering/render_inline.cpp
@@ -24,6 +24,7 @@
#include "render_arena.h"
#include "render_inline.h"
#include "render_block.h"
+#include "xml/dom_nodeimpl.h"
using namespace khtml;
@@ -243,13 +244,12 @@ void RenderInline::paint(QPainter *p, int _x, int _y, int _w, int _h,
void RenderInline::paintObject(QPainter *p, int _x, int _y,
int _w, int _h, int _tx, int _ty, PaintAction paintAction)
{
-
#ifdef DEBUG_LAYOUT
// kdDebug( 6040 ) << renderName() << "(RenderInline) " << this << " ::paintObject() w/h = (" << width() << "/" << height() << ")" << endl;
#endif
- // FIXME: This function will eventually get much more complicated. :) - dwh
- // paint contents
+ paintLineBoxBackgroundBorder(p, _x, _y, _w, _h, _tx, _ty, paintAction);
+
RenderObject *child = firstChild();
while(child != 0)
{
@@ -257,6 +257,8 @@ void RenderInline::paintObject(QPainter *p, int _x, int _y,
child->paint(p, _x, _y, _w, _h, _tx, _ty, paintAction);
child = child->nextSibling();
}
+
+ paintLineBoxDecorations(p, _x, _y, _w, _h, _tx, _ty, paintAction);
}
void RenderInline::calcMinMaxWidth()
@@ -274,43 +276,42 @@ void RenderInline::calcMinMaxWidth()
setMinMaxKnown();
}
-short RenderInline::offsetWidth() const
+short RenderInline::width() const
{
- short w = 0;
- RenderObject* object = firstChild();
- while (object) {
- w += object->offsetWidth();
- object = object->nextSibling();
+ // Return the width of the minimal left side and the maximal right side.
+ short leftSide = 0;
+ short rightSide = 0;
+ for (InlineRunBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) {
+ if (curr == firstLineBox() || curr->xPos() < leftSide)
+ leftSide = curr->xPos();
+ if (curr == firstLineBox() || curr->xPos() + curr->width() > rightSide)
+ rightSide = curr->xPos() + curr->width();
}
- return w;
+
+ return rightSide - leftSide;
}
-int RenderInline::offsetHeight() const
+int RenderInline::height() const
{
- if (firstChild())
- return firstChild()->offsetHeight();
- return height();
+ int h = 0;
+ if (firstLineBox())
+ h = lastLineBox()->yPos() + lastLineBox()->height() - firstLineBox()->yPos();
+ return h;
}
int RenderInline::offsetLeft() const
{
int x = RenderFlow::offsetLeft();
- RenderObject* textChild = (RenderObject*)this;
- while (textChild && textChild->isInline() && !textChild->isText())
- textChild = textChild->firstChild();
- if (textChild && textChild != this)
- x += textChild->xPos() - textChild->borderLeft() - textChild->paddingLeft();
+ if (firstLineBox())
+ x += firstLineBox()->xPos();
return x;
}
int RenderInline::offsetTop() const
{
- RenderObject* textChild = (RenderObject*)this;
- while (textChild && textChild->isInline() && !textChild->isText())
- textChild = textChild->firstChild();
int y = RenderFlow::offsetTop();
- if (textChild && textChild != this)
- y += textChild->yPos() - textChild->borderTop() - textChild->paddingTop();
+ if (firstLineBox())
+ y += firstLineBox()->yPos();
return y;
}
@@ -322,3 +323,67 @@ const char *RenderInline::renderName() const
return "RenderInline (anonymous)";
return "RenderInline";
}
+
+bool RenderInline::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty, bool inside)
+{
+ // Always check our kids.
+ for (RenderObject* child = lastChild(); child; child = child->previousSibling())
+ if (!child->layer() && child->nodeAtPoint(info, _x, _y, _tx, _ty))
+ inside = true;
+
+ // Check our line boxes if we're still not inside.
+ if (!inside && style()->visibility() != HIDDEN) {
+ // See if we're inside one of our line boxes.
+ for (InlineRunBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) {
+ if((_y >=_ty + curr->m_y) && (_y < _ty + curr->m_y + curr->m_height) &&
+ (_x >= _tx + curr->m_x) && (_x <_tx + curr->m_x + curr->m_width) ) {
+ inside = true;
+ break;
+ }
+ }
+ }
+
+ if (inside && element()) {
+ if (info.innerNode() && info.innerNode()->renderer() &&
+ !info.innerNode()->renderer()->isInline()) {
+ // Within the same layer, inlines are ALWAYS fully above blocks. Change inner node.
+ info.setInnerNode(element());
+
+ // Clear everything else.
+ info.setInnerNonSharedNode(0);
+ info.setURLElement(0);
+ }
+
+ if (!info.innerNode())
+ info.setInnerNode(element());
+
+ if(!info.innerNonSharedNode())
+ info.setInnerNonSharedNode(element());
+
+ if (!info.URLElement()) {
+ RenderObject* p = this;
+ while (p) {
+ if (p->element() && p->element()->hasAnchor()) {
+ info.setURLElement(p->element());
+ break;
+ }
+ if (!isSpecial()) break;
+ p = p->parent();
+ }
+ }
+
+ }
+
+ if (!info.readonly()) {
+ // lets see if we need a new style
+ bool oldinside = mouseInside();
+ setMouseInside(inside);
+
+ setHoverAndActive(info, oldinside, inside);
+ if (!isInline() && continuation())
+ continuation()->setHoverAndActive(info, oldinside, inside);
+ }
+
+ return inside;
+}
+
diff --git a/WebCore/khtml/rendering/render_inline.h b/WebCore/khtml/rendering/render_inline.h
index 9d8e604..cc02df2 100644
--- a/WebCore/khtml/rendering/render_inline.h
+++ b/WebCore/khtml/rendering/render_inline.h
@@ -53,15 +53,18 @@ public:
virtual void paintObject(QPainter *, int x, int y, int w, int h,
int tx, int ty, PaintAction paintAction);
+ virtual bool nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty, bool inside);
+
virtual void calcMinMaxWidth();
// overrides RenderObject
virtual bool requiresLayer() { return isRelPositioned(); }
+ virtual short width() const;
+ virtual int height() const;
+
// used to calculate offsetWidth/Height. Overridden by inlines (render_flow) to return
// the remaining width on a given line (and the height of a single line).
- virtual short offsetWidth() const;
- virtual int offsetHeight() const;
virtual int offsetLeft() const;
virtual int offsetTop() const;
};
diff --git a/WebCore/khtml/rendering/render_line.cpp b/WebCore/khtml/rendering/render_line.cpp
index 7f68d77..94e1068 100644
--- a/WebCore/khtml/rendering/render_line.cpp
+++ b/WebCore/khtml/rendering/render_line.cpp
@@ -272,7 +272,16 @@ void InlineFlowBox::verticallyAlignBoxes(int& heightOfBlock)
adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop, maxPositionBottom);
int maxHeight = maxAscent + maxDescent;
- placeBoxesVertically(heightOfBlock, maxHeight, maxAscent, strictMode);
+ int topPosition = heightOfBlock;
+ int bottomPosition = heightOfBlock;
+ placeBoxesVertically(heightOfBlock, maxHeight, maxAscent, strictMode, topPosition, bottomPosition);
+
+ setOverflowPositions(topPosition, bottomPosition);
+
+ // Shrink boxes with no text children in quirks and almost strict mode.
+ if (!strictMode)
+ shrinkBoxesWithNoTextChildren(topPosition, bottomPosition);
+
heightOfBlock += maxHeight;
}
@@ -304,7 +313,7 @@ void InlineFlowBox::adjustMaxAscentAndDescent(int& maxAscent, int& maxDescent,
void InlineFlowBox::computeLogicalBoxHeights(int& maxPositionTop, int& maxPositionBottom,
int& maxAscent, int& maxDescent, bool strictMode)
{
- if (!parent()) {
+ if (isRootInlineBox()) {
// Examine our root box.
setHeight(object()->lineHeight(m_firstLine));
bool isTableCell = object()->isTableCell();
@@ -350,29 +359,193 @@ void InlineFlowBox::computeLogicalBoxHeights(int& maxPositionTop, int& maxPositi
}
}
-void InlineFlowBox::placeBoxesVertically(int y, int maxHeight, int maxAscent, bool strictMode)
+void InlineFlowBox::placeBoxesVertically(int y, int maxHeight, int maxAscent, bool strictMode,
+ int& topPosition, int& bottomPosition)
{
- if (!parent()) {
- if (hasTextChildren() || strictMode)
- setYPos(y + maxAscent - baseline());// Place our root box.
- // FIXME: Use the tallest y/height out of our children.
- }
+ if (isRootInlineBox())
+ setYPos(y + maxAscent - baseline());// Place our root box.
for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
+ // Adjust boxes to use their real box y/height and not the logical height (as dictated by
+ // line-height).
+ if (curr->isInlineFlowBox())
+ static_cast<InlineFlowBox*>(curr)->placeBoxesVertically(y, maxHeight, maxAscent, strictMode,
+ topPosition, bottomPosition);
+
+ bool childAffectsTopBottomPos = true;
if (curr->yPos() == PositionTop)
curr->setYPos(y);
else if (curr->yPos() == PositionBottom)
curr->setYPos(y + maxHeight - curr->height());
- else if (curr->hasTextChildren() || strictMode)
- // FIXME: Use the tallest y/height out of our children.
+ else {
+ if (!curr->hasTextChildren() && !strictMode)
+ childAffectsTopBottomPos = false;
curr->setYPos(curr->yPos() + y + maxAscent - curr->baseline());
+ }
+
+ int newY = curr->yPos();
+ int newHeight = curr->height();
+ int newBaseline = curr->baseline();
+ if (curr->isTextRun() || curr->isInlineFlowBox()) {
+ const QFontMetrics &fm = curr->object()->fontMetrics( m_firstLine );
+ newBaseline = fm.ascent();
+ newY += curr->baseline() - newBaseline;
+ newHeight = newBaseline+fm.descent();
+ if (curr->isInlineFlowBox()) {
+ newHeight += curr->object()->borderTop() + curr->object()->paddingTop() +
+ curr->object()->borderBottom() + curr->object()->paddingBottom();
+ newY -= curr->object()->borderTop() + curr->object()->paddingTop();
+ newBaseline += curr->object()->borderTop() + curr->object()->paddingTop();
+ }
+ }
+ else {
+ newY += curr->object()->marginTop();
+ newHeight = curr->height() - (curr->object()->marginTop() + curr->object()->marginBottom());
+ }
+
+ curr->setYPos(newY);
+ curr->setHeight(newHeight);
+ curr->setBaseline(newBaseline);
+
+ if (childAffectsTopBottomPos) {
+ if (newY < topPosition)
+ topPosition = newY;
+ if (newY + newHeight > bottomPosition)
+ bottomPosition = newY + newHeight;
+ }
+ }
- // FIXME: Adjust the y position and heights of replaced elements for margins.
- // Adjust inline flows to use the font box height and not the logical height.
+ if (isRootInlineBox()) {
+ const QFontMetrics &fm = object()->fontMetrics( m_firstLine );
+ setHeight(fm.ascent()+fm.descent());
+ setYPos(yPos() + baseline() - fm.ascent());
+ setBaseline(fm.ascent());
+ if (hasTextChildren() || strictMode) {
+ if (yPos() < topPosition)
+ topPosition = yPos();
+ if (yPos() + height() > bottomPosition)
+ bottomPosition = yPos() + height();
+ }
+ }
+}
+
+void InlineFlowBox::shrinkBoxesWithNoTextChildren(int topPos, int bottomPos)
+{
+ // First shrink our kids.
+ for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
if (curr->isInlineFlowBox())
- static_cast<InlineFlowBox*>(curr)->placeBoxesVertically(y, maxHeight, maxAscent,
- strictMode);
+ static_cast<InlineFlowBox*>(curr)->shrinkBoxesWithNoTextChildren(topPos, bottomPos);
+ }
+
+ // See if we have text children. If not, then we need to shrink ourselves to fit on the line.
+ if (!hasTextChildren()) {
+ if (yPos() < topPos)
+ setYPos(topPos);
+ if (height() > bottomPos - topPos)
+ setHeight(bottomPos - topPos);
+ if (baseline() > height())
+ setBaseline(height());
}
}
+void InlineFlowBox::paintBackgroundAndBorder(QPainter *p, int _x, int _y,
+ int _w, int _h, int _tx, int _ty, int xOffsetOnLine)
+{
+ // Move x/y to our coordinates.
+ _tx += m_x;
+ _ty += m_y;
+
+ int w = width();
+ int h = height();
+
+ int my = QMAX(_ty,_y);
+ int mh;
+ if (_ty<_y)
+ mh= QMAX(0,h-(_y-_ty));
+ else
+ mh = QMIN(_h,h);
+
+ // You can use p::first-line to specify a background. If so, the root line boxes for
+ // a line may actually have to paint a background.
+ RenderStyle* styleToUse = object()->style(m_firstLine);
+ if (object()->hasFirstLine() || (parent() && object()->shouldPaintBackgroundOrBorder())) {
+ CachedImage* bg = styleToUse->backgroundImage();
+ bool hasBackgroundImage = bg && (bg->pixmap_size() == bg->valid_rect().size()) &&
+ !bg->isTransparent() && !bg->isErrorImage();
+ if (!hasBackgroundImage || (!prevLineBox() && !nextLineBox()) || !parent())
+ object()->paintBackgroundExtended(p, styleToUse->backgroundColor(),
+ bg, my, mh, _tx, _ty, w, h,
+ borderLeft(), borderRight());
+ else {
+ // We have a background image that spans multiple lines.
+ // We need to adjust _tx and _ty by the width of all previous lines.
+ // Think of background painting on inlines as though you had one long line, a single continuous
+ // strip. Even though that strip has been broken up across multiple lines, you still paint it
+ // as though you had one single line. This means each line has to pick up the background where
+ // the previous line left off.
+ int startX = _tx - xOffsetOnLine;
+ int totalWidth = xOffsetOnLine;
+ for (InlineRunBox* curr = this; curr; curr = curr->nextLineBox())
+ totalWidth += curr->width();
+ QRect clipRect(_tx, _ty, width(), height());
+ clipRect = p->xForm(clipRect);
+ p->save();
+ p->addClip(clipRect);
+ object()->paintBackgroundExtended(p, object()->style()->backgroundColor(),
+ object()->style()->backgroundImage(), my, mh, startX, _ty,
+ totalWidth, h,
+ borderLeft(), borderRight());
+ p->restore();
+ }
+ // :first-line cannot be used to put borders on a line. Always paint borders with our
+ // non-first-line style.
+ if (parent() && object()->style()->hasBorder())
+ object()->paintBorder(p, _tx, _ty, w, h, object()->style(), includeLeftEdge(), includeRightEdge());
+ }
+}
+
+static bool shouldDrawDecoration(RenderObject* obj)
+{
+ bool shouldDraw = false;
+ for (RenderObject* curr = obj->firstChild();
+ curr; curr = curr->nextSibling()) {
+ if (curr->isInlineFlow() || curr->isText()) {
+ shouldDraw = true;
+ break;
+ }
+ }
+ return shouldDraw;
+}
+
+void InlineFlowBox::paintDecorations(QPainter *p, int _x, int _y,
+ int _w, int _h, int _tx, int _ty)
+{
+ // Now paint our text decorations. We only do this if we aren't in quirks mode (i.e., in
+ // almost-strict mode or strict mode).
+ _tx += m_x;
+ _ty += m_y;
+ RenderStyle* styleToUse = object()->style(m_firstLine);
+ int deco = parent() ? styleToUse->textDecoration() : styleToUse->textDecorationsInEffect();
+ if (deco != TDNONE && shouldDrawDecoration(object())) {
+ // We must have child boxes and have decorations defined.
+ _tx += borderLeft() + paddingLeft();
+ int w = m_width - (borderLeft() + paddingLeft() + borderRight() + paddingRight());
+ QColor underline, overline, linethrough;
+ underline = overline = linethrough = styleToUse->color();
+ if (!parent())
+ object()->getTextDecorationColors(deco, underline, overline, linethrough);
+ if (deco & UNDERLINE) {
+ p->setPen(underline);
+ p->drawLineForText(_tx, _ty, m_baseline, w);
+ }
+ if (deco & OVERLINE) {
+ p->setPen(overline);
+ p->drawLineForText(_tx, _ty, 0, w);
+ }
+ if (deco & LINE_THROUGH) {
+ p->setPen(linethrough);
+ p->drawLineForText(_tx, _ty, 2*m_baseline/3, w);
+ }
+ }
+}
diff --git a/WebCore/khtml/rendering/render_line.h b/WebCore/khtml/rendering/render_line.h
index 12ba150..a2c3a14 100644
--- a/WebCore/khtml/rendering/render_line.h
+++ b/WebCore/khtml/rendering/render_line.h
@@ -59,6 +59,7 @@ public:
virtual bool isInlineFlowBox() { return false; }
virtual bool isContainer() { return false; }
virtual bool isTextRun() { return false; }
+ virtual bool isRootInlineBox() { return false; }
bool isConstructed() { return m_constructed; }
virtual void setConstructed() {
@@ -92,6 +93,9 @@ public:
int baseline() { return m_baseline; }
virtual bool hasTextChildren() { return true; }
+
+ virtual int topOverflow() { return yPos(); }
+ virtual int bottomOverflow() { return yPos()+height(); }
public: // FIXME: Would like to make this protected, but methods are accessing these
// members over in the part.
@@ -126,6 +130,11 @@ public:
InlineRunBox* nextLineBox() { return m_nextLine; }
void setNextLineBox(InlineRunBox* n) { m_nextLine = n; }
void setPreviousLineBox(InlineRunBox* p) { m_prevLine = p; }
+
+ virtual void paintBackgroundAndBorder(QPainter *p, int _x, int _y,
+ int _w, int _h, int _tx, int _ty, int xOffsetOnLine) {};
+ virtual void paintDecorations(QPainter *p, int _x, int _y,
+ int _w, int _h, int _tx, int _ty) {};
protected:
InlineRunBox* m_prevLine; // The previous box that also uses our RenderObject
@@ -168,6 +177,11 @@ public:
m_hasTextChildren = true;
}
+ virtual void paintBackgroundAndBorder(QPainter *p, int _x, int _y,
+ int _w, int _h, int _tx, int _ty, int xOffsetOnLine);
+ virtual void paintDecorations(QPainter *p, int _x, int _y,
+ int _w, int _h, int _tx, int _ty);
+
int marginBorderPaddingLeft();
int marginBorderPaddingRight();
int marginLeft();
@@ -184,7 +198,7 @@ public:
m_includeRightEdge = includeRight;
}
virtual bool hasTextChildren() { return m_hasTextChildren; }
-
+
// Helper functions used during line construction and placement.
void determineSpacingForFlowBoxes(bool lastLine, RenderObject* endObject);
int getFlowSpacingWidth();
@@ -197,7 +211,11 @@ public:
int& maxAscent, int& maxDescent, bool strictMode);
void adjustMaxAscentAndDescent(int& maxAscent, int& maxDescent,
int maxPositionTop, int maxPositionBottom);
- void placeBoxesVertically(int y, int maxHeight, int maxAscent, bool strictMode);
+ void placeBoxesVertically(int y, int maxHeight, int maxAscent, bool strictMode,
+ int& topPosition, int& bottomPosition);
+ void shrinkBoxesWithNoTextChildren(int topPosition, int bottomPosition);
+
+ virtual void setOverflowPositions(int top, int bottom) {}
protected:
InlineBox* m_firstChild;
@@ -207,6 +225,25 @@ protected:
bool m_hasTextChildren : 1;
};
+class RootInlineBox : public InlineFlowBox
+{
+public:
+ RootInlineBox(RenderObject* obj)
+ :InlineFlowBox(obj)
+ {
+ m_topOverflow = m_bottomOverflow = 0;
+ }
+
+ virtual bool isRootInlineBox() { return true; }
+ virtual int topOverflow() { return m_topOverflow; }
+ virtual int bottomOverflow() { return m_bottomOverflow; }
+ virtual void setOverflowPositions(int top, int bottom) { m_topOverflow = top; m_bottomOverflow = bottom; }
+
+protected:
+ int m_topOverflow;
+ int m_bottomOverflow;
+};
+
}; //namespace
#endif
diff --git a/WebCore/khtml/rendering/render_object.cpp b/WebCore/khtml/rendering/render_object.cpp
index a58b43d..c0ca3ce 100644
--- a/WebCore/khtml/rendering/render_object.cpp
+++ b/WebCore/khtml/rendering/render_object.cpp
@@ -878,7 +878,7 @@ void RenderObject::setStyle(RenderStyle *style)
//qDebug("triggering relayout");
setMinMaxKnown(false);
setLayouted(false);
- } else if ( m_parent ) {
+ } else if ( m_parent && !isText()) {
//qDebug("triggering repaint");
repaint();
}
@@ -1294,21 +1294,14 @@ short RenderObject::getVerticalPosition( bool firstLine ) const
short RenderObject::lineHeight( bool firstLine ) const
{
- Length lh;
- if( firstLine && hasFirstLine() ) {
- RenderStyle *pseudoStyle = style()->getPseudoStyle(RenderStyle::FIRST_LINE);
- if ( pseudoStyle )
- lh = pseudoStyle->lineHeight();
- }
- else
- lh = style()->lineHeight();
+ Length lh = style(firstLine)->lineHeight();
// its "unset", choose nice default
if ( lh.value < 0 )
- return style()->fontMetrics().lineSpacing();
+ return style(firstLine)->fontMetrics().lineSpacing();
if ( lh.isPercent() )
- return lh.minWidth( style()->font().pixelSize() );
+ return lh.minWidth( style(firstLine)->font().pixelSize() );
// its fixed
return lh.value;
@@ -1388,3 +1381,33 @@ InlineBox* RenderObject::createInlineBox()
return new (renderArena()) InlineBox(this);
}
+void RenderObject::getTextDecorationColors(int& decorations, QColor& underline, QColor& overline,
+ QColor& linethrough)
+{
+ int newDecorations = decorations;
+ RenderObject* curr = this;
+ do {
+ int currDecs = curr->style()->textDecoration();
+ if (currDecs) {
+ if (currDecs & UNDERLINE) {
+ newDecorations &= ~UNDERLINE;
+ underline = curr->style()->color();
+ }
+ if (currDecs & OVERLINE) {
+ newDecorations &= ~OVERLINE;
+ overline = curr->style()->color();
+ }
+ if (currDecs & LINE_THROUGH) {
+ newDecorations &= ~LINE_THROUGH;
+ linethrough = curr->style()->color();
+ }
+ }
+ curr = curr->parent();
+ if (curr && curr->isRenderBlock() && curr->continuation())
+ curr = curr->continuation();
+ } while (curr && newDecorations);
+
+ if (newDecorations)
+ // Null out everything that's left.
+ decorations &= ~newDecorations;
+}
diff --git a/WebCore/khtml/rendering/render_object.h b/WebCore/khtml/rendering/render_object.h
index 545c51e..5b4d3d1 100644
--- a/WebCore/khtml/rendering/render_object.h
+++ b/WebCore/khtml/rendering/render_object.h
@@ -276,6 +276,10 @@ public:
virtual void paintBoxDecorations(QPainter *p,int _x, int _y,
int _w, int _h, int _tx, int _ty) {};
+ virtual void paintBackgroundExtended(QPainter *p, const QColor &c, CachedImage *bg, int clipy, int cliph,
+ int _tx, int _ty, int w, int height,
+ int bleft, int bright) {};
+
/*
* This function calculates the minimum & maximum width that the object
* can be set to.
@@ -330,6 +334,7 @@ public:
{
friend class RenderImage;
friend class RenderText;
+ friend class RenderInline;
friend class RenderObject;
friend class RenderFrameSet;
friend class DOM::HTMLAreaElementImpl;
@@ -482,6 +487,9 @@ public:
return s;
}
+ void getTextDecorationColors(int& decorations, QColor& underline, QColor& overline,
+ QColor& linethrough);
+
enum BorderSide {
BSTop, BSBottom, BSLeft, BSRight
};
@@ -505,7 +513,7 @@ public:
virtual bool hasOverhangingFloats() { return false; }
// positioning of inline childs (bidi)
- virtual void position(InlineBox*, int, int, int, bool) {}
+ virtual void position(InlineBox*, int, int, bool) {}
enum SelectionState {
SelectionNone,
diff --git a/WebCore/khtml/rendering/render_root.cpp b/WebCore/khtml/rendering/render_root.cpp
index 9c15e6b..eae1b9c 100644
--- a/WebCore/khtml/rendering/render_root.cpp
+++ b/WebCore/khtml/rendering/render_root.cpp
@@ -291,15 +291,10 @@ void RenderRoot::close()
static QRect enclosingPositionedRect (RenderObject *n)
{
- RenderObject *enclosingParent = (RenderObject*)n;
- QRect rect;
-
- while (enclosingParent && (enclosingParent->isText() || (enclosingParent->width() == 0 && enclosingParent->height() == 0))){
- enclosingParent = enclosingParent->parent();
- }
- if (enclosingParent){
+ RenderObject *enclosingParent = n->containingBlock();
+ QRect rect(0,0,0,0);
+ if (enclosingParent) {
int ox, oy;
-
enclosingParent->absolutePosition(ox, oy);
rect.setX(ox);
rect.setY(oy);
diff --git a/WebCore/khtml/rendering/render_style.cpp b/WebCore/khtml/rendering/render_style.cpp
index f4dbfe0..486b3cd 100644
--- a/WebCore/khtml/rendering/render_style.cpp
+++ b/WebCore/khtml/rendering/render_style.cpp
@@ -85,7 +85,7 @@ bool StyleBoxData::operator==(const StyleBoxData& o) const
}
StyleVisualData::StyleVisualData()
- : hasClip(false), colspan( 1 ), counter_increment( 0 ), counter_reset( 0 ),
+ : hasClip(false), textDecoration(TDNONE), colspan( 1 ), counter_increment( 0 ), counter_reset( 0 ),
palette( QApplication::palette() )
{
}
@@ -95,7 +95,7 @@ StyleVisualData::~StyleVisualData() {
StyleVisualData::StyleVisualData(const StyleVisualData& o )
: Shared<StyleVisualData>(),
- clip( o.clip ), hasClip( o.hasClip ), colspan( o.colspan ),
+ clip( o.clip ), hasClip( o.hasClip ), textDecoration(o.textDecoration), colspan( o.colspan ),
counter_increment( o.counter_increment ), counter_reset( o.counter_reset ),
palette( o.palette )
{
@@ -130,7 +130,7 @@ bool StyleBackgroundData::operator==(const StyleBackgroundData& o) const
StyleInheritedData::StyleInheritedData()
: indent( Fixed ), line_height( -100, Percent ), style_image( 0 ),
- cursor_image( 0 ), font(), color( Qt::black ), decoration_color( Qt::black ), border_spacing( 0 )
+ cursor_image( 0 ), font(), color( Qt::black ), border_spacing( 0 )
{
}
@@ -142,7 +142,7 @@ StyleInheritedData::StyleInheritedData(const StyleInheritedData& o )
: Shared<StyleInheritedData>(),
indent( o.indent ), line_height( o.line_height ), style_image( o.style_image ),
cursor_image( o.cursor_image ), font( o.font ),
- color( o.color ), decoration_color( o.decoration_color ),
+ color( o.color ),
border_spacing( o.border_spacing )
{
}
@@ -156,8 +156,7 @@ bool StyleInheritedData::operator==(const StyleInheritedData& o) const
style_image == o.style_image &&
cursor_image == o.cursor_image &&
font == o.font &&
- color == o.color &&
- decoration_color == o.decoration_color;
+ color == o.color;
// doesn't work because structs are not packed
//return memcmp(this, &o, sizeof(*this))==0;
@@ -338,7 +337,6 @@ RenderStyle::Diff RenderStyle::diff( const RenderStyle *other ) const
// DataRef<StyleInheritedData> inherited;
if ( *box.get() != *other->box.get() ||
- *visual.get() != *other->visual.get() ||
*surround.get() != *other->surround.get() ||
!(inherited->indent == other->inherited->indent) ||
!(inherited->line_height == other->inherited->line_height) ||
@@ -349,7 +347,10 @@ RenderStyle::Diff RenderStyle::diff( const RenderStyle *other ) const
!(inherited_flags._visuallyOrdered == other->inherited_flags._visuallyOrdered) ||
!(inherited_flags._htmlHacks == other->inherited_flags._htmlHacks) ||
!(noninherited_flags._position == other->noninherited_flags._position) ||
- !(noninherited_flags._floating == other->noninherited_flags._floating) )
+ !(noninherited_flags._floating == other->noninherited_flags._floating) ||
+ visual->colspan != other->visual->colspan ||
+ visual->counter_increment != other->visual->counter_increment ||
+ visual->counter_reset != other->visual->counter_reset)
return CbLayout;
// changes causing Layout changes:
@@ -412,13 +413,16 @@ RenderStyle::Diff RenderStyle::diff( const RenderStyle *other ) const
// int _text_decoration : 4;
// DataRef<StyleBackgroundData> background;
if (inherited->color != other->inherited->color ||
- inherited->decoration_color != other->inherited->decoration_color ||
!(inherited_flags._visibility == other->inherited_flags._visibility) ||
!(noninherited_flags._overflow == other->noninherited_flags._overflow) ||
!(noninherited_flags._bg_repeat == other->noninherited_flags._bg_repeat) ||
!(noninherited_flags._bg_attachment == other->noninherited_flags._bg_attachment) ||
- !(inherited_flags._text_decoration == other->inherited_flags._text_decoration) ||
- *background.get() != *other->background.get()
+ !(inherited_flags._text_decorations == other->inherited_flags._text_decorations) ||
+ *background.get() != *other->background.get() ||
+ !(visual->clip == other->visual->clip) ||
+ visual->hasClip != other->visual->hasClip ||
+ visual->textDecoration != other->visual->textDecoration ||
+ !(visual->palette == other->visual->palette)
)
return Visible;
diff --git a/WebCore/khtml/rendering/render_style.h b/WebCore/khtml/rendering/render_style.h
index e82097d..6cda99b 100644
--- a/WebCore/khtml/rendering/render_style.h
+++ b/WebCore/khtml/rendering/render_style.h
@@ -323,11 +323,11 @@ public:
bool operator==( const StyleVisualData &o ) const {
return ( clip == o.clip &&
- hasClip == o.hasClip &&
+ hasClip == o.hasClip &&
colspan == o.colspan &&
counter_increment == o.counter_increment &&
counter_reset == o.counter_reset &&
- palette == o.palette );
+ palette == o.palette && textDecoration == o.textDecoration);
}
bool operator!=( const StyleVisualData &o ) const {
return !(*this == o);
@@ -335,6 +335,7 @@ public:
LengthBox clip;
bool hasClip : 1;
+ int textDecoration : 4; // Text decorations defined *only* by this element.
short colspan; // for html, not a css2 attribute
@@ -424,8 +425,7 @@ public:
khtml::Font font;
QColor color;
- QColor decoration_color;
-
+
short border_spacing;
};
@@ -519,7 +519,7 @@ protected:
EVisibility _visibility : 2;
ETextAlign _text_align : 3;
ETextTransform _text_transform : 2;
- int _text_decoration : 4;
+ int _text_decorations : 4;
ECursor _cursor_style : 4;
EDirection _direction : 1;
bool _border_collapse : 1 ;
@@ -588,7 +588,7 @@ protected:
inherited_flags._visibility = VISIBLE;
inherited_flags._text_align = TAAUTO;
inherited_flags._text_transform = TTNONE;
- inherited_flags._text_decoration = TDNONE;
+ inherited_flags._text_decorations = TDNONE;
inherited_flags._cursor_style = CURSOR_AUTO;
inherited_flags._direction = LTR;
inherited_flags._border_collapse = true;
@@ -717,8 +717,8 @@ public:
Length textIndent() const { return inherited->indent; }
ETextAlign textAlign() const { return inherited_flags._text_align; }
ETextTransform textTransform() const { return inherited_flags._text_transform; }
- int textDecoration() const { return inherited_flags._text_decoration; }
- const QColor &textDecorationColor() const { return inherited->decoration_color; }
+ int textDecorationsInEffect() const { return inherited_flags._text_decorations; }
+ int textDecoration() const { return visual->textDecoration; }
int wordSpacing() const { return inherited->font.wordSpacing; }
int letterSpacing() const { return inherited->font.letterSpacing; }
@@ -830,8 +830,8 @@ public:
void setTextIndent(Length v) { SET_VAR(inherited,indent,v) }
void setTextAlign(ETextAlign v) { inherited_flags._text_align = v; }
void setTextTransform(ETextTransform v) { inherited_flags._text_transform = v; }
- void setTextDecoration(int v) { inherited_flags._text_decoration = v; }
- void setTextDecorationColor(const QColor &v) { SET_VAR(inherited,decoration_color,v) }
+ void addToTextDecorationsInEffect(int v) { inherited_flags._text_decorations |= v; }
+ void setTextDecoration(int v) { SET_VAR(visual, textDecoration, v); }
void setDirection(EDirection v) { inherited_flags._direction = v; }
void setLineHeight(Length v) { SET_VAR(inherited,line_height,v) }
diff --git a/WebCore/khtml/rendering/render_table.cpp b/WebCore/khtml/rendering/render_table.cpp
index 995fb67..4e66243 100644
--- a/WebCore/khtml/rendering/render_table.cpp
+++ b/WebCore/khtml/rendering/render_table.cpp
@@ -1429,7 +1429,8 @@ void RenderTableCell::close()
void RenderTableCell::repaintRectangle(int x, int y, int w, int h, bool immediate, bool f)
{
- RenderBlock::repaintRectangle(x, y, w, h+_topExtra+_bottomExtra, immediate, f);
+ y += _topExtra;
+ RenderBlock::repaintRectangle(x, y, w, h, immediate, f);
}
bool RenderTableCell::absolutePosition(int &xPos, int &yPos, bool f)
diff --git a/WebCore/khtml/rendering/render_text.cpp b/WebCore/khtml/rendering/render_text.cpp
index 2aa5394..22c97a0 100644
--- a/WebCore/khtml/rendering/render_text.cpp
+++ b/WebCore/khtml/rendering/render_text.cpp
@@ -98,93 +98,60 @@ void TextRun::paintSelection(const Font *f, RenderText *text, QPainter *p, Rende
}
#ifdef APPLE_CHANGES
-void TextRun::paintDecoration( QPainter *pt, const Font *f, RenderText* p,
- int _tx, int _ty, int deco, bool begin, bool end, int from, int to)
+void TextRun::paintDecoration( QPainter *pt, int _tx, int _ty, int deco)
{
_tx += m_x;
_ty += m_y;
+
+ // Get the text decoration colors.
+ QColor underline, overline, linethrough;
+ object()->getTextDecorationColors(deco, underline, overline, linethrough);
// Use a special function for underlines to get the positioning exactly right.
if (deco & UNDERLINE) {
- f->drawLineForText(pt, _tx, _ty, p->str->s, p->str->l, m_start, m_len,
- m_toAdd, m_baseline, m_reversed ? QPainter::RTL : QPainter::LTR, from, to);
+ pt->setPen(underline);
+ pt->drawLineForText(_tx, _ty, m_baseline, m_width);
}
if (deco & OVERLINE) {
- f->drawLineForText(pt, _tx, _ty, p->str->s, p->str->l, m_start, m_len,
- m_toAdd, 0, m_reversed ? QPainter::RTL : QPainter::LTR, from, to);
+ pt->setPen(overline);
+ pt->drawLineForText(_tx, _ty, 0, m_width);
}
if (deco & LINE_THROUGH) {
- f->drawLineForText(pt, _tx, _ty, p->str->s, p->str->l, m_start, m_len,
- m_toAdd, 2*m_baseline/3, m_reversed ? QPainter::RTL : QPainter::LTR, from, to);
+ pt->setPen(linethrough);
+ pt->drawLineForText(_tx, _ty, 2*m_baseline/3, m_width);
}
}
#else
-void TextRun::paintDecoration( QPainter *pt, RenderText* p, int _tx, int _ty, int decoration, bool begin, bool end)
+void TextRun::paintDecoration( QPainter *pt, int _tx, int _ty, int decoration)
{
_tx += m_x;
_ty += m_y;
int width = m_width - 1;
- if( begin )
- width -= p->paddingLeft() + p->borderLeft();
-
- if ( end )
- width -= p->paddingRight() + p->borderRight();
-
+ QColor underline, overline, linethrough;
+ object()->getTextDecorationColors(decoration, underline, overline, linethrough);
+
int underlineOffset = ( pt->fontMetrics().height() + m_baseline ) / 2;
if(underlineOffset <= m_baseline) underlineOffset = m_baseline+1;
if(deco & UNDERLINE){
+ pt->setPen(underline);
pt->drawLine(_tx, _ty + underlineOffset, _tx + width, _ty + underlineOffset );
}
- if(deco & OVERLINE)
+ if (deco & OVERLINE) {
+ pt->setPen(overline);
pt->drawLine(_tx, _ty, _tx + width, _ty );
- if(deco & LINE_THROUGH)
+ }
+ if(deco & LINE_THROUGH) {
+ pt->setPen(linethrough);
pt->drawLine(_tx, _ty + 2*m_baseline/3, _tx + width, _ty + 2*m_baseline/3 );
+ }
// NO! Do NOT add BLINK! It is the most annouing feature of Netscape, and IE has a reason not to
// support it. Lars
}
#endif
-
-void TextRun::paintBoxDecorations(QPainter *pt, RenderStyle* style, RenderText *p, int _tx, int _ty, bool begin, bool end)
-{
- int topExtra = p->borderTop() + p->paddingTop();
- int bottomExtra = p->borderBottom() + p->paddingBottom();
- // ### firstline
- int halfleading = (p->m_lineHeight - style->font().pixelSize() ) / 2;
-
- _tx += m_x;
- _ty += m_y + halfleading - topExtra;
-
- int width = m_width + p->borderLeft() + p->borderRight() + p->paddingLeft() + p->paddingRight();
-
- // the height of the decorations is: topBorder + topPadding + CSS font-size + bottomPadding + bottomBorder
- int height = style->font().pixelSize() + topExtra + bottomExtra;
-
- if( begin )
- _tx -= p->paddingLeft() + p->borderLeft();
-
- QColor c = style->backgroundColor();
- CachedImage *i = style->backgroundImage();
- if(c.isValid() && (!i || i->tiled_pixmap(c).mask()))
- pt->fillRect(_tx, _ty, width, height, c);
-
- if(i) {
- // ### might need to add some correct offsets
- // ### use paddingX/Y
- pt->drawTiledPixmap(_tx, _ty, width, height, i->tiled_pixmap(c));
- }
-
-#ifdef DEBUG_VALIGN
- pt->fillRect(_tx, _ty, width, height, Qt::cyan );
-#endif
-
- if(style->hasBorder())
- p->paintBorder(pt, _tx, _ty, width, height, style, begin, end);
-}
-
#define LOCAL_WIDTH_BUF_SIZE 1024
FindSelectionResult TextRun::checkSelectionPoint(int _x, int _y, int _tx, int _ty, const Font *f, RenderText *text, int & offset, short lineHeight)
@@ -196,7 +163,7 @@ FindSelectionResult TextRun::checkSelectionPoint(int _x, int _y, int _tx, int _t
if ( _y < _ty + m_y )
return SelectionPointBefore; // above -> before
- if ( _y > _ty + m_y + lineHeight ) {
+ if ( _y > _ty + m_y + m_height ) {
// below -> after
// Set the offset to the max
offset = m_len;
@@ -450,12 +417,10 @@ bool RenderText::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty, b
{
assert(parent());
- int height = m_lineHeight;
-
TextRun *s = m_lines.count() ? m_lines[0] : 0;
int si = 0;
while(s) {
- if((_y >=_ty + s->m_y) && (_y < _ty + s->m_y + height) &&
+ if((_y >=_ty + s->m_y) && (_y < _ty + s->m_y + s->height()) &&
(_x >= _tx + s->m_x) && (_x <_tx + s->m_x + s->m_width) ) {
inside = true;
break;
@@ -543,9 +508,9 @@ void RenderText::cursorPos(int offset, int &_x, int &_y, int &height)
int pos;
TextRun * s = findTextRun( offset, pos );
_y = s->m_y;
- height = m_lineHeight; // ### firstLine!!! s->m_height;
+ height = s->m_height;
- const QFontMetrics &fm = metrics( false ); // #### wrong for first-line!
+ const QFontMetrics &fm = metrics( s->m_firstLine );
QString tekst(str->s + s->m_start, s->m_len);
_x = s->m_x + (fm.boundingRect(tekst, pos)).right();
if(pos)
@@ -569,14 +534,6 @@ void RenderText::cursorPos(int offset, int &_x, int &_y, int &height)
bool RenderText::absolutePosition(int &xPos, int &yPos, bool)
{
return RenderObject::absolutePosition(xPos, yPos, false);
-
- if(parent() && parent()->absolutePosition(xPos, yPos, false)) {
- xPos -= paddingLeft() + borderLeft();
- yPos -= borderTop() + paddingTop();
- return true;
- }
- xPos = yPos = 0;
- return false;
}
void RenderText::posOfChar(int chr, int &x, int &y)
@@ -616,7 +573,7 @@ void RenderText::paintObject(QPainter *p, int /*x*/, int y, int /*w*/, int h,
{
int ow = style()->outlineWidth();
RenderStyle* pseudoStyle = style()->getPseudoStyle(RenderStyle::FIRST_LINE);
- int d = style()->textDecoration();
+ int d = style()->textDecorationsInEffect();
TextRun f(0, y-ty);
int si = m_lines.findFirstMatching(&f);
// something matching found, find the first one to print
@@ -624,7 +581,7 @@ void RenderText::paintObject(QPainter *p, int /*x*/, int y, int /*w*/, int h,
if(si >= 0)
{
// Move up until out of area to be printed
- while(si > 0 && m_lines[si-1]->checkVerticalPoint(y, ty, h, m_lineHeight))
+ while(si > 0 && m_lines[si-1]->checkVerticalPoint(y, ty, h))
si--;
// Now calculate startPos and endPos, for printing selection.
@@ -668,7 +625,6 @@ void RenderText::paintObject(QPainter *p, int /*x*/, int y, int /*w*/, int h,
for (int pass = 0; pass < (haveSelection ? 2 : 1); pass++) {
si = startLine;
- bool drawDecorations = !haveSelection || pass == 0;
bool drawSelectionBackground = haveSelection && pass == 0 && paintAction != PaintActionSelection;
bool drawText = !haveSelection || pass == 1;
#endif
@@ -680,6 +636,7 @@ void RenderText::paintObject(QPainter *p, int /*x*/, int y, int /*w*/, int h,
if (isPrinting)
{
+ // FIXME: Need to understand what this section is doing.
int lh = lineHeight( false ) + paddingBottom() + borderBottom();
if (ty+s->m_y < y)
{
@@ -705,14 +662,6 @@ void RenderText::paintObject(QPainter *p, int /*x*/, int y, int /*w*/, int h,
}
#if APPLE_CHANGES
- if (drawDecorations)
-#endif
- if((shouldPaintBackgroundOrBorder() &&
- (parent()->isInline() || pseudoStyle)) &&
- (!pseudoStyle || s->m_firstLine))
- s->paintBoxDecorations(p, _style, this, tx, ty, si == 0, si == (int)m_lines.count()-1);
-
-#if APPLE_CHANGES
if (drawText) {
#endif
@@ -734,18 +683,15 @@ void RenderText::paintObject(QPainter *p, int /*x*/, int y, int /*w*/, int h,
}
}
- if(d != TDNONE)
+ if (d != TDNONE && paintAction == PaintActionForeground)
{
- p->setPen(_style->textDecorationColor());
- if (paintAction == PaintActionSelection) {
- int offset = s->m_start;
- int sPos = QMAX( startPos - offset, 0 );
- int ePos = QMIN( endPos - offset, s->m_len );
- if ( sPos < ePos ){
- s->paintDecoration(p, font, this, tx, ty, d, si == 0, si == ( int ) m_lines.count()-1, sPos, ePos);
- }
- } else {
- s->paintDecoration(p, font, this, tx, ty, d,si == 0, si == ( int ) m_lines.count()-1);
+ RenderObject* curr = this;
+ while (curr && !curr->element())
+ curr = curr->container();
+ bool quirksMode = (curr && curr->element()->getDocument()->inQuirksMode());
+ if (quirksMode) {
+ p->setPen(_style->color());
+ s->paintDecoration(p, tx, ty, d);
}
}
@@ -800,7 +746,7 @@ void RenderText::paintObject(QPainter *p, int /*x*/, int y, int /*w*/, int h,
}
#endif
- } while (++si < (int)m_lines.count() && m_lines[si]->checkVerticalPoint(y-ow, ty, h, m_lineHeight));
+ } while (++si < (int)m_lines.count() && m_lines[si]->checkVerticalPoint(y-ow, ty, h));
#if APPLE_CHANGES
} // end of for loop
@@ -819,19 +765,18 @@ void RenderText::paintObject(QPainter *p, int /*x*/, int y, int /*w*/, int h,
void RenderText::paint(QPainter *p, int x, int y, int w, int h,
int tx, int ty, PaintAction paintAction)
{
- if (paintAction != PaintActionForeground && paintAction != PaintActionSelection) {
+ if (paintAction != PaintActionForeground && paintAction != PaintActionSelection)
return;
- }
- if (style()->visibility() != VISIBLE) {
+
+ if (style()->visibility() != VISIBLE)
return;
- }
int s = m_lines.count() - 1;
- if ( s < 0 ) return;
+ if ( s < 0 )
+ return;
- // ### incorporate padding/border here!
- if ( ty + m_lines[0]->m_y > y + h + 64 ) return;
- if ( ty + m_lines[s]->m_y + m_lines[s]->m_baseline + m_lineHeight + 64 < y ) return;
+ if (ty + m_lines[0]->yPos() > y + h) return;
+ if (ty + m_lines[s]->yPos() + m_lines[s]->height() < y ) return;
paintObject(p, x, y, w, h, tx, ty, paintAction);
}
@@ -1193,7 +1138,7 @@ InlineBox* RenderText::createInlineBox()
return new (renderArena()) TextRun(this);
}
-void RenderText::position(InlineBox* box, int y, int from, int len, bool reverse)
+void RenderText::position(InlineBox* box, int from, int len, bool reverse)
{
// ### should not be needed!!!
if (len == 0 || (str->l && len == 1 && *(str->s+from) == '\n'))
@@ -1209,10 +1154,8 @@ void RenderText::position(InlineBox* box, int y, int from, int len, bool reverse
TextRun *s = static_cast<TextRun*>(box);
s->m_reversed = reverse;
- s->m_y = y;
s->m_start = from;
s->m_len = len;
- s->m_baseline = baselinePosition(s->m_firstLine);
if(m_lines.count() == m_lines.size())
m_lines.resize(m_lines.size()*2+1);
diff --git a/WebCore/khtml/rendering/render_text.h b/WebCore/khtml/rendering/render_text.h
index da2699e..12595ac 100644
--- a/WebCore/khtml/rendering/render_text.h
+++ b/WebCore/khtml/rendering/render_text.h
@@ -49,7 +49,6 @@ public:
{
m_start = 0;
m_len = 0;
- m_baseline = 0;
m_reversed = false;
m_toAdd = 0;
}
@@ -73,13 +72,7 @@ public:
virtual bool isTextRun() { return true; }
-#ifdef APPLE_CHANGES
- void paintDecoration( QPainter *pt, const Font *, RenderText* p,
- int _tx, int _ty, int decoration, bool begin, bool end, int from=-1, int to=-1);
-#else
- void paintDecoration( QPainter *pt, RenderText* p, int _tx, int _ty, int decoration, bool begin, bool end);
-#endif
- void paintBoxDecorations(QPainter *p, RenderStyle* style, RenderText *parent, int _tx, int _ty, bool begin, bool end);
+ void paintDecoration( QPainter *pt, int _tx, int _ty, int decoration);
void paintSelection(const Font *f, RenderText *text, QPainter *p, RenderStyle* style, int tx, int ty, int startPos, int endPos);
// Return before, after (offset set to max), or inside the text, at @p offset
@@ -90,12 +83,11 @@ public:
* of a view, would the @ref _y -coordinate be inside the vertical range
* of this object's representation?
*/
- bool checkVerticalPoint(int _y, int _ty, int _h, int height)
- { if((_ty + m_y > _y + _h) || (_ty + m_y + m_baseline + height < _y)) return false; return true; }
+ bool checkVerticalPoint(int _y, int _ty, int _h)
+ { if((_ty + m_y > _y + _h) || (_ty + m_y + m_baseline + height() < _y)) return false; return true; }
int m_start;
unsigned short m_len;
- unsigned short m_baseline;
bool m_reversed : 1;
int m_toAdd : 14; // for justified text
@@ -158,7 +150,7 @@ public:
unsigned int length() const { return str->l; }
QChar *text() const { return str->s; }
unsigned int stringLength() const { return str->l; } // non virtual implementation of length()
- virtual void position(InlineBox* box, int y, int from, int len, bool reverse);
+ virtual void position(InlineBox* box, int from, int len, bool reverse);
virtual unsigned int width(unsigned int from, unsigned int len, const Font *f) const;
virtual unsigned int width(unsigned int from, unsigned int len, bool firstLine = false) const;
diff --git a/WebCore/kwq/KWQPainter.h b/WebCore/kwq/KWQPainter.h
index fc01629..87cf32e 100644
--- a/WebCore/kwq/KWQPainter.h
+++ b/WebCore/kwq/KWQPainter.h
@@ -93,8 +93,7 @@ public:
void drawText(int x, int y, int, int, int alignmentFlags, const QString &);
void drawText(int x, int y, const QChar *, int length, int from, int to, int toAdd,
const QColor& backgroundColor, QPainter::TextDirection d, int letterSpacing, int wordSpacing);
- void drawLineForText(int x, int y, const QChar *, int length, int from, int to, int toAdd,
- int yOffset, QPainter::TextDirection d, int letterSpacing, int wordSpacing);
+ void drawLineForText(int x, int y, int yOffset, int width);
static QColor selectedTextBackgroundColor();
bool paintingDisabled() const;
diff --git a/WebCore/kwq/KWQPainter.mm b/WebCore/kwq/KWQPainter.mm
index ece5bec..df9d4d0 100644
--- a/WebCore/kwq/KWQPainter.mm
+++ b/WebCore/kwq/KWQPainter.mm
@@ -417,27 +417,16 @@ void QPainter::drawText(int x, int y, const QChar *str, int len, int from, int t
fontFamilies: families];
}
-void QPainter::drawLineForText(int x, int y, const QChar *str, int length, int from, int to, int toAdd, int yOffset, QPainter::TextDirection d, int letterSpacing, int wordSpacing)
+void QPainter::drawLineForText(int x, int y, int yOffset, int width)
{
if (data->state.paintingDisabled)
return;
- CREATE_FAMILY_ARRAY(data->state.font, families);
-
- _updateRenderer(families);
-
[data->lastTextRenderer
- drawLineForCharacters:(const UniChar *)str stringLength:length
- fromCharacterPosition:from
- toCharacterPosition:to
- atPoint:NSMakePoint(x, y)
+ drawLineForCharacters: NSMakePoint(x, y)
yOffset:(float)yOffset
- withPadding: toAdd
- withColor:data->state.pen.color().getNSColor()
- rightToLeft: d == RTL ? true : false
- letterSpacing: letterSpacing
- wordSpacing: wordSpacing
- fontFamilies: families];
+ withWidth: width
+ withColor:data->state.pen.color().getNSColor()];
}
QColor QPainter::selectedTextBackgroundColor()
diff --git a/WebCore/kwq/WebCoreTextRenderer.h b/WebCore/kwq/WebCoreTextRenderer.h
index a3989f8..2696f58 100644
--- a/WebCore/kwq/WebCoreTextRenderer.h
+++ b/WebCore/kwq/WebCoreTextRenderer.h
@@ -42,6 +42,6 @@
// drawing
- (void)drawCharacters:(const UniChar *)characters stringLength:(unsigned)length fromCharacterPosition:(int)from toCharacterPosition:(int)to atPoint:(NSPoint)point withPadding: (int)padding withTextColor:(NSColor *)textColor backgroundColor:(NSColor *)backgroundColor rightToLeft: (BOOL)rtl letterSpacing: (int)letterSpacing wordSpacing: (int)wordSpacing fontFamilies: (NSString **)families;
-- (void)drawLineForCharacters:(const UniChar *)characters stringLength:(unsigned)length fromCharacterPosition:(int)from toCharacterPosition:(int)to atPoint:(NSPoint)point yOffset:(float)yOffset withPadding: (int)padding withColor:(NSColor *)color rightToLeft: (BOOL)rtl letterSpacing: (int)letterSpacing wordSpacing: (int)wordSpacing fontFamilies: (NSString **)families;
+- (void)drawLineForCharacters:(NSPoint)point yOffset:(float)yOffset withWidth: (int)width withColor:(NSColor *)color;
@end
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list