summaryrefslogtreecommitdiffstats
path: root/WebCore/rendering/InlineFlowBox.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-04-27 16:31:00 +0100
committerSteve Block <steveblock@google.com>2010-05-11 14:42:12 +0100
commitdcc8cf2e65d1aa555cce12431a16547e66b469ee (patch)
tree92a8d65cd5383bca9749f5327fb5e440563926e6 /WebCore/rendering/InlineFlowBox.cpp
parentccac38a6b48843126402088a309597e682f40fe6 (diff)
downloadexternal_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.zip
external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.tar.gz
external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.tar.bz2
Merge webkit.org at r58033 : Initial merge by git
Change-Id: If006c38561af287c50cd578d251629b51e4d8cd1
Diffstat (limited to 'WebCore/rendering/InlineFlowBox.cpp')
-rw-r--r--WebCore/rendering/InlineFlowBox.cpp93
1 files changed, 49 insertions, 44 deletions
diff --git a/WebCore/rendering/InlineFlowBox.cpp b/WebCore/rendering/InlineFlowBox.cpp
index 34eec30..6ee610d 100644
--- a/WebCore/rendering/InlineFlowBox.cpp
+++ b/WebCore/rendering/InlineFlowBox.cpp
@@ -21,6 +21,7 @@
#include "InlineFlowBox.h"
#include "CachedImage.h"
+#include "CSSPropertyNames.h"
#include "Document.h"
#include "EllipsisBox.h"
#include "GraphicsContext.h"
@@ -165,7 +166,7 @@ void InlineFlowBox::attachLineBoxToRenderObject()
void InlineFlowBox::adjustPosition(int dx, int dy)
{
- InlineRunBox::adjustPosition(dx, dy);
+ InlineBox::adjustPosition(dx, dy);
for (InlineBox* child = firstChild(); child; child = child->nextOnLine())
child->adjustPosition(dx, dy);
if (m_overflow)
@@ -288,14 +289,16 @@ int InlineFlowBox::placeBoxesHorizontally(int xPos, bool& needsWordSpacing)
int letterSpacing = min(0, (int)rt->style(m_firstLine)->font().letterSpacing());
rightLayoutOverflow = max(xPos + text->width() - letterSpacing, rightLayoutOverflow);
- int leftGlyphOverflow = -strokeOverflow;
- int rightGlyphOverflow = strokeOverflow - letterSpacing;
+ GlyphOverflow* glyphOverflow = static_cast<InlineTextBox*>(curr)->glyphOverflow();
+
+ int leftGlyphOverflow = -strokeOverflow - (glyphOverflow ? glyphOverflow->left : 0);
+ int rightGlyphOverflow = strokeOverflow - letterSpacing + (glyphOverflow ? glyphOverflow->right : 0);
int childOverflowLeft = leftGlyphOverflow;
int childOverflowRight = rightGlyphOverflow;
- for (ShadowData* shadow = rt->style()->textShadow(); shadow; shadow = shadow->next) {
- childOverflowLeft = min(childOverflowLeft, shadow->x - shadow->blur + leftGlyphOverflow);
- childOverflowRight = max(childOverflowRight, shadow->x + shadow->blur + rightGlyphOverflow);
+ for (const ShadowData* shadow = rt->style()->textShadow(); shadow; shadow = shadow->next()) {
+ childOverflowLeft = min(childOverflowLeft, shadow->x() - shadow->blur() + leftGlyphOverflow);
+ childOverflowRight = max(childOverflowRight, shadow->x() + shadow->blur() + rightGlyphOverflow);
}
leftVisualOverflow = min(xPos + childOverflowLeft, leftVisualOverflow);
@@ -412,35 +415,35 @@ void InlineFlowBox::computeLogicalBoxHeights(int& maxPositionTop, int& maxPositi
int lineHeight;
int baseline;
- Vector<const SimpleFontData*> usedFonts;
+ Vector<const SimpleFontData*>* usedFonts = 0;
if (curr->isInlineTextBox())
- static_cast<InlineTextBox*>(curr)->takeFallbackFonts(usedFonts);
+ usedFonts = static_cast<InlineTextBox*>(curr)->fallbackFonts();
- if (!usedFonts.isEmpty()) {
- usedFonts.append(curr->renderer()->style(m_firstLine)->font().primaryFont());
+ if (usedFonts) {
+ usedFonts->append(curr->renderer()->style(m_firstLine)->font().primaryFont());
Length parentLineHeight = curr->renderer()->parent()->style()->lineHeight();
if (parentLineHeight.isNegative()) {
int baselineToBottom = 0;
baseline = 0;
- for (size_t i = 0; i < usedFonts.size(); ++i) {
- int halfLeading = (usedFonts[i]->lineSpacing() - usedFonts[i]->ascent() - usedFonts[i]->descent()) / 2;
- baseline = max(baseline, halfLeading + usedFonts[i]->ascent());
- baselineToBottom = max(baselineToBottom, usedFonts[i]->lineSpacing() - usedFonts[i]->ascent() - usedFonts[i]->descent() - halfLeading);
+ for (size_t i = 0; i < usedFonts->size(); ++i) {
+ int halfLeading = (usedFonts->at(i)->lineSpacing() - usedFonts->at(i)->ascent() - usedFonts->at(i)->descent()) / 2;
+ baseline = max(baseline, halfLeading + usedFonts->at(i)->ascent());
+ baselineToBottom = max(baselineToBottom, usedFonts->at(i)->lineSpacing() - usedFonts->at(i)->ascent() - usedFonts->at(i)->descent() - halfLeading);
}
lineHeight = baseline + baselineToBottom;
} else if (parentLineHeight.isPercent()) {
lineHeight = parentLineHeight.calcMinValue(curr->renderer()->style()->fontSize());
baseline = 0;
- for (size_t i = 0; i < usedFonts.size(); ++i) {
- int halfLeading = (lineHeight - usedFonts[i]->ascent() - usedFonts[i]->descent()) / 2;
- baseline = max(baseline, halfLeading + usedFonts[i]->ascent());
+ for (size_t i = 0; i < usedFonts->size(); ++i) {
+ int halfLeading = (lineHeight - usedFonts->at(i)->ascent() - usedFonts->at(i)->descent()) / 2;
+ baseline = max(baseline, halfLeading + usedFonts->at(i)->ascent());
}
} else {
lineHeight = parentLineHeight.value();
baseline = 0;
- for (size_t i = 0; i < usedFonts.size(); ++i) {
- int halfLeading = (lineHeight - usedFonts[i]->ascent() - usedFonts[i]->descent()) / 2;
- baseline = max(baseline, halfLeading + usedFonts[i]->ascent());
+ for (size_t i = 0; i < usedFonts->size(); ++i) {
+ int halfLeading = (lineHeight - usedFonts->at(i)->ascent() - usedFonts->at(i)->descent()) / 2;
+ baseline = max(baseline, halfLeading + usedFonts->at(i)->ascent());
}
}
} else {
@@ -562,15 +565,17 @@ void InlineFlowBox::computeVerticalOverflow(int lineTop, int lineBottom, bool st
continue;
int strokeOverflow = static_cast<int>(ceilf(rt->style()->textStrokeWidth() / 2.0f));
-
- int topGlyphOverflow = -strokeOverflow;
- int bottomGlyphOverflow = strokeOverflow;
-
+
+ GlyphOverflow* glyphOverflow = static_cast<InlineTextBox*>(curr)->glyphOverflow();
+
+ int topGlyphOverflow = -strokeOverflow - (glyphOverflow ? glyphOverflow->top : 0);
+ int bottomGlyphOverflow = strokeOverflow + (glyphOverflow ? glyphOverflow->bottom : 0);
+
int childOverflowTop = topGlyphOverflow;
int childOverflowBottom = bottomGlyphOverflow;
- for (ShadowData* shadow = rt->style()->textShadow(); shadow; shadow = shadow->next) {
- childOverflowTop = min(childOverflowTop, shadow->y - shadow->blur + topGlyphOverflow);
- childOverflowBottom = max(childOverflowBottom, shadow->y + shadow->blur + bottomGlyphOverflow);
+ for (const ShadowData* shadow = rt->style()->textShadow(); shadow; shadow = shadow->next()) {
+ childOverflowTop = min(childOverflowTop, shadow->y() - shadow->blur() + topGlyphOverflow);
+ childOverflowBottom = max(childOverflowBottom, shadow->y() + shadow->blur() + bottomGlyphOverflow);
}
topVisualOverflow = min(curr->y() + childOverflowTop, topVisualOverflow);
@@ -703,11 +708,11 @@ void InlineFlowBox::paintFillLayer(const RenderObject::PaintInfo& paintInfo, con
// FIXME: What the heck do we do with RTL here? The math we're using is obviously not right,
// but it isn't even clear how this should work at all.
int xOffsetOnLine = 0;
- for (InlineRunBox* curr = prevLineBox(); curr; curr = curr->prevLineBox())
+ for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->prevLineBox())
xOffsetOnLine += curr->width();
int startX = tx - xOffsetOnLine;
int totalWidth = xOffsetOnLine;
- for (InlineRunBox* curr = this; curr; curr = curr->nextLineBox())
+ for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox())
totalWidth += curr->width();
paintInfo.context->save();
paintInfo.context->clip(IntRect(tx, ty, width(), height()));
@@ -760,7 +765,7 @@ void InlineFlowBox::paintBoxDecorations(RenderObject::PaintInfo& paintInfo, int
if (styleToUse->boxShadow())
paintBoxShadow(context, styleToUse, Normal, tx, ty, w, h);
- Color c = styleToUse->backgroundColor();
+ Color c = styleToUse->visitedDependentColor(CSSPropertyBackgroundColor);
paintFillLayers(paintInfo, c, styleToUse->backgroundLayers(), tx, ty, w, h);
if (styleToUse->boxShadow())
@@ -788,11 +793,11 @@ void InlineFlowBox::paintBoxDecorations(RenderObject::PaintInfo& paintInfo, int
// FIXME: What the heck do we do with RTL here? The math we're using is obviously not right,
// but it isn't even clear how this should work at all.
int xOffsetOnLine = 0;
- for (InlineRunBox* curr = prevLineBox(); curr; curr = curr->prevLineBox())
+ for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->prevLineBox())
xOffsetOnLine += curr->width();
int startX = tx - xOffsetOnLine;
int totalWidth = xOffsetOnLine;
- for (InlineRunBox* curr = this; curr; curr = curr->nextLineBox())
+ for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox())
totalWidth += curr->width();
context->save();
context->clip(IntRect(tx, ty, w, h));
@@ -859,11 +864,11 @@ void InlineFlowBox::paintMask(RenderObject::PaintInfo& paintInfo, int tx, int ty
// We have a mask image that spans multiple lines.
// We need to adjust _tx and _ty by the width of all previous lines.
int xOffsetOnLine = 0;
- for (InlineRunBox* curr = prevLineBox(); curr; curr = curr->prevLineBox())
+ for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->prevLineBox())
xOffsetOnLine += curr->width();
int startX = tx - xOffsetOnLine;
int totalWidth = xOffsetOnLine;
- for (InlineRunBox* curr = this; curr; curr = curr->nextLineBox())
+ for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox())
totalWidth += curr->width();
paintInfo.context->save();
paintInfo.context->clip(IntRect(tx, ty, w, h));
@@ -957,7 +962,7 @@ void InlineFlowBox::paintTextDecorations(RenderObject::PaintInfo& paintInfo, int
tx += borderLeft() + paddingLeft();
Color underline, overline, linethrough;
- underline = overline = linethrough = styleToUse->color();
+ underline = overline = linethrough = styleToUse->visitedDependentColor(CSSPropertyColor);
if (!parent())
renderer()->getTextDecorationColors(deco, underline, overline, linethrough);
@@ -976,15 +981,15 @@ void InlineFlowBox::paintTextDecorations(RenderObject::PaintInfo& paintInfo, int
bool setClip = false;
int extraOffset = 0;
- ShadowData* shadow = styleToUse->textShadow();
- if (!linesAreOpaque && shadow && shadow->next) {
+ const ShadowData* shadow = styleToUse->textShadow();
+ if (!linesAreOpaque && shadow && shadow->next()) {
IntRect clipRect(tx, ty, w, baselinePos + 2);
- for (ShadowData* s = shadow; s; s = s->next) {
+ for (const ShadowData* s = shadow; s; s = s->next()) {
IntRect shadowRect(tx, ty, w, baselinePos + 2);
- shadowRect.inflate(s->blur);
- shadowRect.move(s->x, s->y);
+ shadowRect.inflate(s->blur());
+ shadowRect.move(s->x(), s->y());
clipRect.unite(shadowRect);
- extraOffset = max(extraOffset, max(0, s->y) + s->blur);
+ extraOffset = max(extraOffset, max(0, s->y()) + s->blur());
}
context->save();
context->clip(clipRect);
@@ -997,14 +1002,14 @@ void InlineFlowBox::paintTextDecorations(RenderObject::PaintInfo& paintInfo, int
bool setShadow = false;
do {
if (shadow) {
- if (!shadow->next) {
+ if (!shadow->next()) {
// The last set of lines paints normally inside the clip.
ty -= extraOffset;
extraOffset = 0;
}
- context->setShadow(IntSize(shadow->x, shadow->y - extraOffset), shadow->blur, shadow->color, colorSpace);
+ context->setShadow(IntSize(shadow->x(), shadow->y() - extraOffset), shadow->blur(), shadow->color(), colorSpace);
setShadow = true;
- shadow = shadow->next;
+ shadow = shadow->next();
}
if (paintUnderline) {