| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 m_firstChild = child; | 102 m_firstChild = child; |
| 103 m_lastChild = child; | 103 m_lastChild = child; |
| 104 } else { | 104 } else { |
| 105 m_lastChild->setNextOnLine(child); | 105 m_lastChild->setNextOnLine(child); |
| 106 child->setPrevOnLine(m_lastChild); | 106 child->setPrevOnLine(m_lastChild); |
| 107 m_lastChild = child; | 107 m_lastChild = child; |
| 108 } | 108 } |
| 109 child->setFirstLineStyleBit(isFirstLineStyle()); | 109 child->setFirstLineStyleBit(isFirstLineStyle()); |
| 110 child->setIsHorizontal(isHorizontal()); | 110 child->setIsHorizontal(isHorizontal()); |
| 111 if (child->isText()) { | 111 if (child->isText()) { |
| 112 if (child->renderer()->parent() == renderer()) | 112 if (child->renderer().parent() == renderer()) |
| 113 m_hasTextChildren = true; | 113 m_hasTextChildren = true; |
| 114 setHasTextDescendantsOnAncestors(this); | 114 setHasTextDescendantsOnAncestors(this); |
| 115 } else if (child->isInlineFlowBox()) { | 115 } else if (child->isInlineFlowBox()) { |
| 116 if (toInlineFlowBox(child)->hasTextDescendants()) | 116 if (toInlineFlowBox(child)->hasTextDescendants()) |
| 117 setHasTextDescendantsOnAncestors(this); | 117 setHasTextDescendantsOnAncestors(this); |
| 118 } | 118 } |
| 119 | 119 |
| 120 if (descendantsHaveSameLineHeightAndBaseline() && !child->renderer()->isOutO
fFlowPositioned()) { | 120 if (descendantsHaveSameLineHeightAndBaseline() && !child->renderer().isOutOf
FlowPositioned()) { |
| 121 RenderStyle* parentStyle = renderer()->style(isFirstLineStyle()); | 121 RenderStyle* parentStyle = renderer().style(isFirstLineStyle()); |
| 122 RenderStyle* childStyle = child->renderer()->style(isFirstLineStyle()); | 122 RenderStyle* childStyle = child->renderer().style(isFirstLineStyle()); |
| 123 bool shouldClearDescendantsHaveSameLineHeightAndBaseline = false; | 123 bool shouldClearDescendantsHaveSameLineHeightAndBaseline = false; |
| 124 if (child->renderer()->isReplaced()) | 124 if (child->renderer().isReplaced()) |
| 125 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; | 125 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; |
| 126 else if (child->isText()) { | 126 else if (child->isText()) { |
| 127 if (child->renderer()->isBR() || child->renderer()->parent() != rend
erer()) { | 127 if (child->renderer().isBR() || child->renderer().parent() != render
er()) { |
| 128 if (!parentStyle->font().fontMetrics().hasIdenticalAscentDescent
AndLineGap(childStyle->font().fontMetrics()) | 128 if (!parentStyle->font().fontMetrics().hasIdenticalAscentDescent
AndLineGap(childStyle->font().fontMetrics()) |
| 129 || parentStyle->lineHeight() != childStyle->lineHeight() | 129 || parentStyle->lineHeight() != childStyle->lineHeight() |
| 130 || (parentStyle->verticalAlign() != BASELINE && !isRootInlin
eBox()) || childStyle->verticalAlign() != BASELINE) | 130 || (parentStyle->verticalAlign() != BASELINE && !isRootInlin
eBox()) || childStyle->verticalAlign() != BASELINE) |
| 131 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; | 131 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; |
| 132 } | 132 } |
| 133 if (childStyle->hasTextCombine() || childStyle->textEmphasisMark() !
= TextEmphasisMarkNone) | 133 if (childStyle->hasTextCombine() || childStyle->textEmphasisMark() !
= TextEmphasisMarkNone) |
| 134 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; | 134 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; |
| 135 } else { | 135 } else { |
| 136 if (child->renderer()->isBR()) { | 136 if (child->renderer().isBR()) { |
| 137 // FIXME: This is dumb. We only turn off because current layout
test results expect the <br> to be 0-height on the baseline. | 137 // FIXME: This is dumb. We only turn off because current layout
test results expect the <br> to be 0-height on the baseline. |
| 138 // Other than making a zillion tests have to regenerate results,
there's no reason to ditch the optimization here. | 138 // Other than making a zillion tests have to regenerate results,
there's no reason to ditch the optimization here. |
| 139 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; | 139 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; |
| 140 } else { | 140 } else { |
| 141 ASSERT(isInlineFlowBox()); | 141 ASSERT(isInlineFlowBox()); |
| 142 InlineFlowBox* childFlowBox = toInlineFlowBox(child); | 142 InlineFlowBox* childFlowBox = toInlineFlowBox(child); |
| 143 // Check the child's bit, and then also check for differences in
font, line-height, vertical-align | 143 // Check the child's bit, and then also check for differences in
font, line-height, vertical-align |
| 144 if (!childFlowBox->descendantsHaveSameLineHeightAndBaseline() | 144 if (!childFlowBox->descendantsHaveSameLineHeightAndBaseline() |
| 145 || !parentStyle->font().fontMetrics().hasIdenticalAscentDesc
entAndLineGap(childStyle->font().fontMetrics()) | 145 || !parentStyle->font().fontMetrics().hasIdenticalAscentDesc
entAndLineGap(childStyle->font().fontMetrics()) |
| 146 || parentStyle->lineHeight() != childStyle->lineHeight() | 146 || parentStyle->lineHeight() != childStyle->lineHeight() |
| 147 || (parentStyle->verticalAlign() != BASELINE && !isRootInlin
eBox()) || childStyle->verticalAlign() != BASELINE | 147 || (parentStyle->verticalAlign() != BASELINE && !isRootInlin
eBox()) || childStyle->verticalAlign() != BASELINE |
| 148 || childStyle->hasBorder() || childStyle->hasPadding() || ch
ildStyle->hasTextCombine()) | 148 || childStyle->hasBorder() || childStyle->hasPadding() || ch
ildStyle->hasTextCombine()) |
| 149 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; | 149 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; |
| 150 } | 150 } |
| 151 } | 151 } |
| 152 | 152 |
| 153 if (shouldClearDescendantsHaveSameLineHeightAndBaseline) | 153 if (shouldClearDescendantsHaveSameLineHeightAndBaseline) |
| 154 clearDescendantsHaveSameLineHeightAndBaseline(); | 154 clearDescendantsHaveSameLineHeightAndBaseline(); |
| 155 } | 155 } |
| 156 | 156 |
| 157 if (!child->renderer()->isOutOfFlowPositioned()) { | 157 if (!child->renderer().isOutOfFlowPositioned()) { |
| 158 if (child->isText()) { | 158 if (child->isText()) { |
| 159 RenderStyle* childStyle = child->renderer()->style(isFirstLineStyle(
)); | 159 RenderStyle* childStyle = child->renderer().style(isFirstLineStyle()
); |
| 160 if (childStyle->letterSpacing() < 0 || childStyle->textShadow() || c
hildStyle->textEmphasisMark() != TextEmphasisMarkNone || childStyle->textStrokeW
idth()) | 160 if (childStyle->letterSpacing() < 0 || childStyle->textShadow() || c
hildStyle->textEmphasisMark() != TextEmphasisMarkNone || childStyle->textStrokeW
idth()) |
| 161 child->clearKnownToHaveNoOverflow(); | 161 child->clearKnownToHaveNoOverflow(); |
| 162 } else if (child->renderer()->isReplaced()) { | 162 } else if (child->renderer().isReplaced()) { |
| 163 RenderBox* box = toRenderBox(child->renderer()); | 163 RenderBox& box = toRenderBox(child->renderer()); |
| 164 if (box->hasRenderOverflow() || box->hasSelfPaintingLayer()) | 164 if (box.hasRenderOverflow() || box.hasSelfPaintingLayer()) |
| 165 child->clearKnownToHaveNoOverflow(); | 165 child->clearKnownToHaveNoOverflow(); |
| 166 } else if (!child->renderer()->isBR() && (child->renderer()->style(isFir
stLineStyle())->boxShadow() || child->boxModelObject()->hasSelfPaintingLayer() | 166 } else if (!child->renderer().isBR() && (child->renderer().style(isFirst
LineStyle())->boxShadow() || child->boxModelObject()->hasSelfPaintingLayer() |
| 167 || (child->renderer()->isListMarker() && !toRenderListMarker(
child->renderer())->isInside()) | 167 || (child->renderer().isListMarker() && !toRenderListMarker(child->r
enderer()).isInside()) |
| 168 || child->renderer()->style(isFirstLineStyle())->hasBorderIma
geOutsets())) | 168 || child->renderer().style(isFirstLineStyle())->hasBorderImageOutset
s())) { |
| 169 |
| 169 child->clearKnownToHaveNoOverflow(); | 170 child->clearKnownToHaveNoOverflow(); |
| 171 } |
| 170 | 172 |
| 171 if (knownToHaveNoOverflow() && child->isInlineFlowBox() && !toInlineFlow
Box(child)->knownToHaveNoOverflow()) | 173 if (knownToHaveNoOverflow() && child->isInlineFlowBox() && !toInlineFlow
Box(child)->knownToHaveNoOverflow()) |
| 172 clearKnownToHaveNoOverflow(); | 174 clearKnownToHaveNoOverflow(); |
| 173 } | 175 } |
| 174 | 176 |
| 175 checkConsistency(); | 177 checkConsistency(); |
| 176 } | 178 } |
| 177 | 179 |
| 178 void InlineFlowBox::removeChild(InlineBox* child) | 180 void InlineFlowBox::removeChild(InlineBox* child) |
| 179 { | 181 { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 m_firstChild = 0; | 217 m_firstChild = 0; |
| 216 m_lastChild = 0; | 218 m_lastChild = 0; |
| 217 #endif | 219 #endif |
| 218 | 220 |
| 219 removeLineBoxFromRenderObject(); | 221 removeLineBoxFromRenderObject(); |
| 220 destroy(); | 222 destroy(); |
| 221 } | 223 } |
| 222 | 224 |
| 223 void InlineFlowBox::removeLineBoxFromRenderObject() | 225 void InlineFlowBox::removeLineBoxFromRenderObject() |
| 224 { | 226 { |
| 225 toRenderInline(renderer())->lineBoxes()->removeLineBox(this); | 227 rendererLineBoxes()->removeLineBox(this); |
| 226 } | 228 } |
| 227 | 229 |
| 228 void InlineFlowBox::extractLine() | 230 void InlineFlowBox::extractLine() |
| 229 { | 231 { |
| 230 if (!extracted()) | 232 if (!extracted()) |
| 231 extractLineBoxFromRenderObject(); | 233 extractLineBoxFromRenderObject(); |
| 232 for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) | 234 for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) |
| 233 child->extractLine(); | 235 child->extractLine(); |
| 234 } | 236 } |
| 235 | 237 |
| 236 void InlineFlowBox::extractLineBoxFromRenderObject() | 238 void InlineFlowBox::extractLineBoxFromRenderObject() |
| 237 { | 239 { |
| 238 toRenderInline(renderer())->lineBoxes()->extractLineBox(this); | 240 rendererLineBoxes()->extractLineBox(this); |
| 239 } | 241 } |
| 240 | 242 |
| 241 void InlineFlowBox::attachLine() | 243 void InlineFlowBox::attachLine() |
| 242 { | 244 { |
| 243 if (extracted()) | 245 if (extracted()) |
| 244 attachLineBoxToRenderObject(); | 246 attachLineBoxToRenderObject(); |
| 245 for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) | 247 for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) |
| 246 child->attachLine(); | 248 child->attachLine(); |
| 247 } | 249 } |
| 248 | 250 |
| 249 void InlineFlowBox::attachLineBoxToRenderObject() | 251 void InlineFlowBox::attachLineBoxToRenderObject() |
| 250 { | 252 { |
| 251 toRenderInline(renderer())->lineBoxes()->attachLineBox(this); | 253 rendererLineBoxes()->attachLineBox(this); |
| 252 } | 254 } |
| 253 | 255 |
| 254 void InlineFlowBox::adjustPosition(float dx, float dy) | 256 void InlineFlowBox::adjustPosition(float dx, float dy) |
| 255 { | 257 { |
| 256 InlineBox::adjustPosition(dx, dy); | 258 InlineBox::adjustPosition(dx, dy); |
| 257 for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) | 259 for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) |
| 258 child->adjustPosition(dx, dy); | 260 child->adjustPosition(dx, dy); |
| 259 if (m_overflow) | 261 if (m_overflow) |
| 260 m_overflow->move(dx, dy); // FIXME: Rounding error here since overflow w
as pixel snapped, but nobody other than list markers passes non-integral values
here. | 262 m_overflow->move(dx, dy); // FIXME: Rounding error here since overflow w
as pixel snapped, but nobody other than list markers passes non-integral values
here. |
| 261 } | 263 } |
| 262 | 264 |
| 263 RenderLineBoxList* InlineFlowBox::rendererLineBoxes() const | 265 RenderLineBoxList* InlineFlowBox::rendererLineBoxes() const |
| 264 { | 266 { |
| 265 return toRenderInline(renderer())->lineBoxes(); | 267 return toRenderInline(renderer()).lineBoxes(); |
| 266 } | 268 } |
| 267 | 269 |
| 268 static inline bool isLastChildForRenderer(RenderObject* ancestor, RenderObject*
child) | 270 static inline bool isLastChildForRenderer(RenderObject* ancestor, RenderObject*
child) |
| 269 { | 271 { |
| 270 if (!child) | 272 if (!child) |
| 271 return false; | 273 return false; |
| 272 | 274 |
| 273 if (child == ancestor) | 275 if (child == ancestor) |
| 274 return true; | 276 return true; |
| 275 | 277 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 301 | 303 |
| 302 void InlineFlowBox::determineSpacingForFlowBoxes(bool lastLine, bool isLogically
LastRunWrapped, RenderObject* logicallyLastRunRenderer) | 304 void InlineFlowBox::determineSpacingForFlowBoxes(bool lastLine, bool isLogically
LastRunWrapped, RenderObject* logicallyLastRunRenderer) |
| 303 { | 305 { |
| 304 // All boxes start off open. They will not apply any margins/border/padding
on | 306 // All boxes start off open. They will not apply any margins/border/padding
on |
| 305 // any side. | 307 // any side. |
| 306 bool includeLeftEdge = false; | 308 bool includeLeftEdge = false; |
| 307 bool includeRightEdge = false; | 309 bool includeRightEdge = false; |
| 308 | 310 |
| 309 // The root inline box never has borders/margins/padding. | 311 // The root inline box never has borders/margins/padding. |
| 310 if (parent()) { | 312 if (parent()) { |
| 311 bool ltr = renderer()->style()->isLeftToRightDirection(); | 313 bool ltr = renderer().style()->isLeftToRightDirection(); |
| 312 | 314 |
| 313 // Check to see if all initial lines are unconstructed. If so, then | 315 // Check to see if all initial lines are unconstructed. If so, then |
| 314 // we know the inline began on this line (unless we are a continuation). | 316 // we know the inline began on this line (unless we are a continuation). |
| 315 RenderLineBoxList* lineBoxList = rendererLineBoxes(); | 317 RenderLineBoxList* lineBoxList = rendererLineBoxes(); |
| 316 if (!lineBoxList->firstLineBox()->isConstructed() && !renderer()->isInli
neElementContinuation()) { | 318 if (!lineBoxList->firstLineBox()->isConstructed() && !renderer().isInlin
eElementContinuation()) { |
| 317 if (renderer()->style()->boxDecorationBreak() == DCLONE) | 319 if (renderer().style()->boxDecorationBreak() == DCLONE) |
| 318 includeLeftEdge = includeRightEdge = true; | 320 includeLeftEdge = includeRightEdge = true; |
| 319 else if (ltr && lineBoxList->firstLineBox() == this) | 321 else if (ltr && lineBoxList->firstLineBox() == this) |
| 320 includeLeftEdge = true; | 322 includeLeftEdge = true; |
| 321 else if (!ltr && lineBoxList->lastLineBox() == this) | 323 else if (!ltr && lineBoxList->lastLineBox() == this) |
| 322 includeRightEdge = true; | 324 includeRightEdge = true; |
| 323 } | 325 } |
| 324 | 326 |
| 325 if (!lineBoxList->lastLineBox()->isConstructed()) { | 327 if (!lineBoxList->lastLineBox()->isConstructed()) { |
| 326 RenderInline* inlineFlow = toRenderInline(renderer()); | 328 RenderInline& inlineFlow = toRenderInline(renderer()); |
| 327 bool isLastObjectOnLine = !isAnsectorAndWithinBlock(renderer(), logi
callyLastRunRenderer) || (isLastChildForRenderer(renderer(), logicallyLastRunRen
derer) && !isLogicallyLastRunWrapped); | 329 bool isLastObjectOnLine = !isAnsectorAndWithinBlock(&renderer(), log
icallyLastRunRenderer) || (isLastChildForRenderer(&renderer(), logicallyLastRunR
enderer) && !isLogicallyLastRunWrapped); |
| 328 | 330 |
| 329 // We include the border under these conditions: | 331 // We include the border under these conditions: |
| 330 // (1) The next line was not created, or it is constructed. We check
the previous line for rtl. | 332 // (1) The next line was not created, or it is constructed. We check
the previous line for rtl. |
| 331 // (2) The logicallyLastRun is not a descendant of this renderer. | 333 // (2) The logicallyLastRun is not a descendant of this renderer. |
| 332 // (3) The logicallyLastRun is a descendant of this renderer, but it
is the last child of this renderer and it does not wrap to the next line. | 334 // (3) The logicallyLastRun is a descendant of this renderer, but it
is the last child of this renderer and it does not wrap to the next line. |
| 333 // (4) The decoration break is set to clone therefore there will be
borders on every sides. | 335 // (4) The decoration break is set to clone therefore there will be
borders on every sides. |
| 334 if (renderer()->style()->boxDecorationBreak() == DCLONE) | 336 if (renderer().style()->boxDecorationBreak() == DCLONE) |
| 335 includeLeftEdge = includeRightEdge = true; | 337 includeLeftEdge = includeRightEdge = true; |
| 336 else if (ltr) { | 338 else if (ltr) { |
| 337 if (!nextLineBox() | 339 if (!nextLineBox() |
| 338 && ((lastLine || isLastObjectOnLine) && !inlineFlow->continu
ation())) | 340 && ((lastLine || isLastObjectOnLine) && !inlineFlow.continua
tion())) |
| 339 includeRightEdge = true; | 341 includeRightEdge = true; |
| 340 } else { | 342 } else { |
| 341 if ((!prevLineBox() || prevLineBox()->isConstructed()) | 343 if ((!prevLineBox() || prevLineBox()->isConstructed()) |
| 342 && ((lastLine || isLastObjectOnLine) && !inlineFlow->continu
ation())) | 344 && ((lastLine || isLastObjectOnLine) && !inlineFlow.continua
tion())) |
| 343 includeLeftEdge = true; | 345 includeLeftEdge = true; |
| 344 } | 346 } |
| 345 } | 347 } |
| 346 } | 348 } |
| 347 | 349 |
| 348 setEdges(includeLeftEdge, includeRightEdge); | 350 setEdges(includeLeftEdge, includeRightEdge); |
| 349 | 351 |
| 350 // Recur into our children. | 352 // Recur into our children. |
| 351 for (InlineBox* currChild = firstChild(); currChild; currChild = currChild->
nextOnLine()) { | 353 for (InlineBox* currChild = firstChild(); currChild; currChild = currChild->
nextOnLine()) { |
| 352 if (currChild->isInlineFlowBox()) { | 354 if (currChild->isInlineFlowBox()) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 370 placeBoxRangeInInlineDirection(firstChild(), 0, logicalLeft, minLogicalLeft,
maxLogicalRight, needsWordSpacing, textBoxDataMap); | 372 placeBoxRangeInInlineDirection(firstChild(), 0, logicalLeft, minLogicalLeft,
maxLogicalRight, needsWordSpacing, textBoxDataMap); |
| 371 | 373 |
| 372 logicalLeft += borderLogicalRight() + paddingLogicalRight(); | 374 logicalLeft += borderLogicalRight() + paddingLogicalRight(); |
| 373 endPlacingBoxRangesInInlineDirection(startLogicalLeft, logicalLeft, minLogic
alLeft, maxLogicalRight); | 375 endPlacingBoxRangesInInlineDirection(startLogicalLeft, logicalLeft, minLogic
alLeft, maxLogicalRight); |
| 374 return logicalLeft; | 376 return logicalLeft; |
| 375 } | 377 } |
| 376 | 378 |
| 377 float InlineFlowBox::placeBoxRangeInInlineDirection(InlineBox* firstChild, Inlin
eBox* lastChild, float& logicalLeft, float& minLogicalLeft, float& maxLogicalRig
ht, bool& needsWordSpacing, GlyphOverflowAndFallbackFontsMap& textBoxDataMap) | 379 float InlineFlowBox::placeBoxRangeInInlineDirection(InlineBox* firstChild, Inlin
eBox* lastChild, float& logicalLeft, float& minLogicalLeft, float& maxLogicalRig
ht, bool& needsWordSpacing, GlyphOverflowAndFallbackFontsMap& textBoxDataMap) |
| 378 { | 380 { |
| 379 for (InlineBox* curr = firstChild; curr && curr != lastChild; curr = curr->n
extOnLine()) { | 381 for (InlineBox* curr = firstChild; curr && curr != lastChild; curr = curr->n
extOnLine()) { |
| 380 if (curr->renderer()->isText()) { | 382 if (curr->renderer().isText()) { |
| 381 InlineTextBox* text = toInlineTextBox(curr); | 383 InlineTextBox* text = toInlineTextBox(curr); |
| 382 RenderText* rt = toRenderText(text->renderer()); | 384 RenderText& rt = toRenderText(text->renderer()); |
| 383 if (rt->textLength()) { | 385 if (rt.textLength()) { |
| 384 if (needsWordSpacing && isSpaceOrNewline(rt->characterAt(text->s
tart()))) | 386 if (needsWordSpacing && isSpaceOrNewline(rt.characterAt(text->st
art()))) |
| 385 logicalLeft += rt->style(isFirstLineStyle())->font().fontDes
cription().wordSpacing(); | 387 logicalLeft += rt.style(isFirstLineStyle())->font().fontDesc
ription().wordSpacing(); |
| 386 needsWordSpacing = !isSpaceOrNewline(rt->characterAt(text->end()
)); | 388 needsWordSpacing = !isSpaceOrNewline(rt.characterAt(text->end())
); |
| 387 } | 389 } |
| 388 text->setLogicalLeft(logicalLeft); | 390 text->setLogicalLeft(logicalLeft); |
| 389 if (knownToHaveNoOverflow()) | 391 if (knownToHaveNoOverflow()) |
| 390 minLogicalLeft = min(logicalLeft, minLogicalLeft); | 392 minLogicalLeft = min(logicalLeft, minLogicalLeft); |
| 391 logicalLeft += text->logicalWidth(); | 393 logicalLeft += text->logicalWidth(); |
| 392 if (knownToHaveNoOverflow()) | 394 if (knownToHaveNoOverflow()) |
| 393 maxLogicalRight = max(logicalLeft, maxLogicalRight); | 395 maxLogicalRight = max(logicalLeft, maxLogicalRight); |
| 394 } else { | 396 } else { |
| 395 if (curr->renderer()->isOutOfFlowPositioned()) { | 397 if (curr->renderer().isOutOfFlowPositioned()) { |
| 396 if (curr->renderer()->parent()->style()->isLeftToRightDirection(
)) | 398 if (curr->renderer().parent()->style()->isLeftToRightDirection()
) { |
| 397 curr->setLogicalLeft(logicalLeft); | 399 curr->setLogicalLeft(logicalLeft); |
| 398 else | 400 } else { |
| 399 // Our offset that we cache needs to be from the edge of the
right border box and | 401 // Our offset that we cache needs to be from the edge of the
right border box and |
| 400 // not the left border box. We have to subtract |x| from th
e width of the block | 402 // not the left border box. We have to subtract |x| from th
e width of the block |
| 401 // (which can be obtained from the root line box). | 403 // (which can be obtained from the root line box). |
| 402 curr->setLogicalLeft(root()->block()->logicalWidth() - logic
alLeft); | 404 curr->setLogicalLeft(root()->block().logicalWidth() - logica
lLeft); |
| 405 } |
| 403 continue; // The positioned object has no effect on the width. | 406 continue; // The positioned object has no effect on the width. |
| 404 } | 407 } |
| 405 if (curr->renderer()->isRenderInline()) { | 408 if (curr->renderer().isRenderInline()) { |
| 406 InlineFlowBox* flow = toInlineFlowBox(curr); | 409 InlineFlowBox* flow = toInlineFlowBox(curr); |
| 407 logicalLeft += flow->marginLogicalLeft(); | 410 logicalLeft += flow->marginLogicalLeft(); |
| 408 if (knownToHaveNoOverflow()) | 411 if (knownToHaveNoOverflow()) |
| 409 minLogicalLeft = min(logicalLeft, minLogicalLeft); | 412 minLogicalLeft = min(logicalLeft, minLogicalLeft); |
| 410 logicalLeft = flow->placeBoxesInInlineDirection(logicalLeft, nee
dsWordSpacing, textBoxDataMap); | 413 logicalLeft = flow->placeBoxesInInlineDirection(logicalLeft, nee
dsWordSpacing, textBoxDataMap); |
| 411 if (knownToHaveNoOverflow()) | 414 if (knownToHaveNoOverflow()) |
| 412 maxLogicalRight = max(logicalLeft, maxLogicalRight); | 415 maxLogicalRight = max(logicalLeft, maxLogicalRight); |
| 413 logicalLeft += flow->marginLogicalRight(); | 416 logicalLeft += flow->marginLogicalRight(); |
| 414 } else if (!curr->renderer()->isListMarker() || toRenderListMarker(c
urr->renderer())->isInside()) { | 417 } else if (!curr->renderer().isListMarker() || toRenderListMarker(cu
rr->renderer()).isInside()) { |
| 415 // The box can have a different writing-mode than the overall li
ne, so this is a bit complicated. | 418 // The box can have a different writing-mode than the overall li
ne, so this is a bit complicated. |
| 416 // Just get all the physical margin and overflow values by hand
based off |isVertical|. | 419 // Just get all the physical margin and overflow values by hand
based off |isVertical|. |
| 417 LayoutUnit logicalLeftMargin = isHorizontal() ? curr->boxModelOb
ject()->marginLeft() : curr->boxModelObject()->marginTop(); | 420 LayoutUnit logicalLeftMargin = isHorizontal() ? curr->boxModelOb
ject()->marginLeft() : curr->boxModelObject()->marginTop(); |
| 418 LayoutUnit logicalRightMargin = isHorizontal() ? curr->boxModelO
bject()->marginRight() : curr->boxModelObject()->marginBottom(); | 421 LayoutUnit logicalRightMargin = isHorizontal() ? curr->boxModelO
bject()->marginRight() : curr->boxModelObject()->marginBottom(); |
| 419 | 422 |
| 420 logicalLeft += logicalLeftMargin; | 423 logicalLeft += logicalLeftMargin; |
| 421 curr->setLogicalLeft(logicalLeft); | 424 curr->setLogicalLeft(logicalLeft); |
| 422 if (knownToHaveNoOverflow()) | 425 if (knownToHaveNoOverflow()) |
| 423 minLogicalLeft = min(logicalLeft, minLogicalLeft); | 426 minLogicalLeft = min(logicalLeft, minLogicalLeft); |
| 424 logicalLeft += curr->logicalWidth(); | 427 logicalLeft += curr->logicalWidth(); |
| 425 if (knownToHaveNoOverflow()) | 428 if (knownToHaveNoOverflow()) |
| 426 maxLogicalRight = max(logicalLeft, maxLogicalRight); | 429 maxLogicalRight = max(logicalLeft, maxLogicalRight); |
| 427 logicalLeft += logicalRightMargin; | 430 logicalLeft += logicalRightMargin; |
| 428 // If we encounter any space after this inline block then ensure
it is treated as the space between two words. | 431 // If we encounter any space after this inline block then ensure
it is treated as the space between two words. |
| 429 needsWordSpacing = true; | 432 needsWordSpacing = true; |
| 430 } | 433 } |
| 431 } | 434 } |
| 432 } | 435 } |
| 433 return logicalLeft; | 436 return logicalLeft; |
| 434 } | 437 } |
| 435 | 438 |
| 436 bool InlineFlowBox::requiresIdeographicBaseline(const GlyphOverflowAndFallbackFo
ntsMap& textBoxDataMap) const | 439 bool InlineFlowBox::requiresIdeographicBaseline(const GlyphOverflowAndFallbackFo
ntsMap& textBoxDataMap) const |
| 437 { | 440 { |
| 438 if (isHorizontal()) | 441 if (isHorizontal()) |
| 439 return false; | 442 return false; |
| 440 | 443 |
| 441 if (renderer()->style(isFirstLineStyle())->fontDescription().nonCJKGlyphOrie
ntation() == NonCJKGlyphOrientationUpright | 444 if (renderer().style(isFirstLineStyle())->fontDescription().nonCJKGlyphOrien
tation() == NonCJKGlyphOrientationUpright |
| 442 || renderer()->style(isFirstLineStyle())->font().primaryFont()->hasVerti
calGlyphs()) | 445 || renderer().style(isFirstLineStyle())->font().primaryFont()->hasVertic
alGlyphs()) |
| 443 return true; | 446 return true; |
| 444 | 447 |
| 445 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { | 448 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { |
| 446 if (curr->renderer()->isOutOfFlowPositioned()) | 449 if (curr->renderer().isOutOfFlowPositioned()) |
| 447 continue; // Positioned placeholders don't affect calculations. | 450 continue; // Positioned placeholders don't affect calculations. |
| 448 | 451 |
| 449 if (curr->isInlineFlowBox()) { | 452 if (curr->isInlineFlowBox()) { |
| 450 if (toInlineFlowBox(curr)->requiresIdeographicBaseline(textBoxDataMa
p)) | 453 if (toInlineFlowBox(curr)->requiresIdeographicBaseline(textBoxDataMa
p)) |
| 451 return true; | 454 return true; |
| 452 } else { | 455 } else { |
| 453 if (curr->renderer()->style(isFirstLineStyle())->font().primaryFont(
)->hasVerticalGlyphs()) | 456 if (curr->renderer().style(isFirstLineStyle())->font().primaryFont()
->hasVerticalGlyphs()) |
| 454 return true; | 457 return true; |
| 455 | 458 |
| 456 const Vector<const SimpleFontData*>* usedFonts = 0; | 459 const Vector<const SimpleFontData*>* usedFonts = 0; |
| 457 if (curr->isInlineTextBox()) { | 460 if (curr->isInlineTextBox()) { |
| 458 GlyphOverflowAndFallbackFontsMap::const_iterator it = textBoxDat
aMap.find(toInlineTextBox(curr)); | 461 GlyphOverflowAndFallbackFontsMap::const_iterator it = textBoxDat
aMap.find(toInlineTextBox(curr)); |
| 459 usedFonts = it == textBoxDataMap.end() ? 0 : &it->value.first; | 462 usedFonts = it == textBoxDataMap.end() ? 0 : &it->value.first; |
| 460 } | 463 } |
| 461 | 464 |
| 462 if (usedFonts) { | 465 if (usedFonts) { |
| 463 for (size_t i = 0; i < usedFonts->size(); ++i) { | 466 for (size_t i = 0; i < usedFonts->size(); ++i) { |
| 464 if (usedFonts->at(i)->hasVerticalGlyphs()) | 467 if (usedFonts->at(i)->hasVerticalGlyphs()) |
| 465 return true; | 468 return true; |
| 466 } | 469 } |
| 467 } | 470 } |
| 468 } | 471 } |
| 469 } | 472 } |
| 470 | 473 |
| 471 return false; | 474 return false; |
| 472 } | 475 } |
| 473 | 476 |
| 474 void InlineFlowBox::adjustMaxAscentAndDescent(int& maxAscent, int& maxDescent, i
nt maxPositionTop, int maxPositionBottom) | 477 void InlineFlowBox::adjustMaxAscentAndDescent(int& maxAscent, int& maxDescent, i
nt maxPositionTop, int maxPositionBottom) |
| 475 { | 478 { |
| 476 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { | 479 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { |
| 477 // The computed lineheight needs to be extended for the | 480 // The computed lineheight needs to be extended for the |
| 478 // positioned elements | 481 // positioned elements |
| 479 if (curr->renderer()->isOutOfFlowPositioned()) | 482 if (curr->renderer().isOutOfFlowPositioned()) |
| 480 continue; // Positioned placeholders don't affect calculations. | 483 continue; // Positioned placeholders don't affect calculations. |
| 481 if (curr->verticalAlign() == TOP || curr->verticalAlign() == BOTTOM) { | 484 if (curr->verticalAlign() == TOP || curr->verticalAlign() == BOTTOM) { |
| 482 int lineHeight = curr->lineHeight(); | 485 int lineHeight = curr->lineHeight(); |
| 483 if (curr->verticalAlign() == TOP) { | 486 if (curr->verticalAlign() == TOP) { |
| 484 if (maxAscent + maxDescent < lineHeight) | 487 if (maxAscent + maxDescent < lineHeight) |
| 485 maxDescent = lineHeight - maxAscent; | 488 maxDescent = lineHeight - maxAscent; |
| 486 } | 489 } |
| 487 else { | 490 else { |
| 488 if (maxAscent + maxDescent < lineHeight) | 491 if (maxAscent + maxDescent < lineHeight) |
| 489 maxAscent = lineHeight - maxDescent; | 492 maxAscent = lineHeight - maxDescent; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 maxDescent = descent; | 539 maxDescent = descent; |
| 537 setMaxDescent = true; | 540 setMaxDescent = true; |
| 538 } | 541 } |
| 539 } | 542 } |
| 540 } | 543 } |
| 541 | 544 |
| 542 if (!checkChildren) | 545 if (!checkChildren) |
| 543 return; | 546 return; |
| 544 | 547 |
| 545 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { | 548 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { |
| 546 if (curr->renderer()->isOutOfFlowPositioned()) | 549 if (curr->renderer().isOutOfFlowPositioned()) |
| 547 continue; // Positioned placeholders don't affect calculations. | 550 continue; // Positioned placeholders don't affect calculations. |
| 548 | 551 |
| 549 InlineFlowBox* inlineFlowBox = curr->isInlineFlowBox() ? toInlineFlowBox
(curr) : 0; | 552 InlineFlowBox* inlineFlowBox = curr->isInlineFlowBox() ? toInlineFlowBox
(curr) : 0; |
| 550 | 553 |
| 551 bool affectsAscent = false; | 554 bool affectsAscent = false; |
| 552 bool affectsDescent = false; | 555 bool affectsDescent = false; |
| 553 | 556 |
| 554 // The verticalPositionForBox function returns the distance between the
child box's baseline | 557 // The verticalPositionForBox function returns the distance between the
child box's baseline |
| 555 // and the root box's baseline. The value is negative if the child box'
s baseline is above the | 558 // and the root box's baseline. The value is negative if the child box'
s baseline is above the |
| 556 // root box's baseline, and it is positive if the child box's baseline i
s below the root box's baseline. | 559 // root box's baseline, and it is positive if the child box's baseline i
s below the root box's baseline. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 setMaxAscent, setMaxDescent,
strictMode, textBoxDataMap, | 596 setMaxAscent, setMaxDescent,
strictMode, textBoxDataMap, |
| 594 baselineType, verticalPositi
onCache); | 597 baselineType, verticalPositi
onCache); |
| 595 } | 598 } |
| 596 } | 599 } |
| 597 | 600 |
| 598 void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei
ght, int maxAscent, bool strictMode, LayoutUnit& lineTop, LayoutUnit& lineBottom
, bool& setLineTop, | 601 void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei
ght, int maxAscent, bool strictMode, LayoutUnit& lineTop, LayoutUnit& lineBottom
, bool& setLineTop, |
| 599 LayoutUnit& lineTopIncludingMargi
ns, LayoutUnit& lineBottomIncludingMargins, bool& hasAnnotationsBefore, bool& ha
sAnnotationsAfter, FontBaseline baselineType) | 602 LayoutUnit& lineTopIncludingMargi
ns, LayoutUnit& lineBottomIncludingMargins, bool& hasAnnotationsBefore, bool& ha
sAnnotationsAfter, FontBaseline baselineType) |
| 600 { | 603 { |
| 601 bool isRootBox = isRootInlineBox(); | 604 bool isRootBox = isRootInlineBox(); |
| 602 if (isRootBox) { | 605 if (isRootBox) { |
| 603 const FontMetrics& fontMetrics = renderer()->style(isFirstLineStyle())->
fontMetrics(); | 606 const FontMetrics& fontMetrics = renderer().style(isFirstLineStyle())->f
ontMetrics(); |
| 604 // RootInlineBoxes are always placed on at pixel boundaries in their log
ical y direction. Not doing | 607 // RootInlineBoxes are always placed on at pixel boundaries in their log
ical y direction. Not doing |
| 605 // so results in incorrect rendering of text decorations, most notably u
nderlines. | 608 // so results in incorrect rendering of text decorations, most notably u
nderlines. |
| 606 setLogicalTop(roundToInt(top + maxAscent - fontMetrics.ascent(baselineTy
pe))); | 609 setLogicalTop(roundToInt(top + maxAscent - fontMetrics.ascent(baselineTy
pe))); |
| 607 } | 610 } |
| 608 | 611 |
| 609 LayoutUnit adjustmentForChildrenWithSameLineHeightAndBaseline = 0; | 612 LayoutUnit adjustmentForChildrenWithSameLineHeightAndBaseline = 0; |
| 610 if (descendantsHaveSameLineHeightAndBaseline()) { | 613 if (descendantsHaveSameLineHeightAndBaseline()) { |
| 611 adjustmentForChildrenWithSameLineHeightAndBaseline = logicalTop(); | 614 adjustmentForChildrenWithSameLineHeightAndBaseline = logicalTop(); |
| 612 if (parent()) | 615 if (parent()) |
| 613 adjustmentForChildrenWithSameLineHeightAndBaseline += (boxModelObjec
t()->borderBefore() + boxModelObject()->paddingBefore()); | 616 adjustmentForChildrenWithSameLineHeightAndBaseline += (boxModelObjec
t()->borderBefore() + boxModelObject()->paddingBefore()); |
| 614 } | 617 } |
| 615 | 618 |
| 616 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { | 619 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { |
| 617 if (curr->renderer()->isOutOfFlowPositioned()) | 620 if (curr->renderer().isOutOfFlowPositioned()) |
| 618 continue; // Positioned placeholders don't affect calculations. | 621 continue; // Positioned placeholders don't affect calculations. |
| 619 | 622 |
| 620 if (descendantsHaveSameLineHeightAndBaseline()) { | 623 if (descendantsHaveSameLineHeightAndBaseline()) { |
| 621 curr->adjustBlockDirectionPosition(adjustmentForChildrenWithSameLine
HeightAndBaseline); | 624 curr->adjustBlockDirectionPosition(adjustmentForChildrenWithSameLine
HeightAndBaseline); |
| 622 continue; | 625 continue; |
| 623 } | 626 } |
| 624 | 627 |
| 625 InlineFlowBox* inlineFlowBox = curr->isInlineFlowBox() ? toInlineFlowBox
(curr) : 0; | 628 InlineFlowBox* inlineFlowBox = curr->isInlineFlowBox() ? toInlineFlowBox
(curr) : 0; |
| 626 bool childAffectsTopBottomPos = true; | 629 bool childAffectsTopBottomPos = true; |
| 627 if (curr->verticalAlign() == TOP) | 630 if (curr->verticalAlign() == TOP) |
| 628 curr->setLogicalTop(top); | 631 curr->setLogicalTop(top); |
| 629 else if (curr->verticalAlign() == BOTTOM) | 632 else if (curr->verticalAlign() == BOTTOM) |
| 630 curr->setLogicalTop(top + maxHeight - curr->lineHeight()); | 633 curr->setLogicalTop(top + maxHeight - curr->lineHeight()); |
| 631 else { | 634 else { |
| 632 if (!strictMode && inlineFlowBox && !inlineFlowBox->hasTextChildren(
) && !curr->boxModelObject()->hasInlineDirectionBordersOrPadding() | 635 if (!strictMode && inlineFlowBox && !inlineFlowBox->hasTextChildren(
) && !curr->boxModelObject()->hasInlineDirectionBordersOrPadding() |
| 633 && !(inlineFlowBox->descendantsHaveSameLineHeightAndBaseline() &
& inlineFlowBox->hasTextDescendants())) | 636 && !(inlineFlowBox->descendantsHaveSameLineHeightAndBaseline() &
& inlineFlowBox->hasTextDescendants())) |
| 634 childAffectsTopBottomPos = false; | 637 childAffectsTopBottomPos = false; |
| 635 LayoutUnit posAdjust = maxAscent - curr->baselinePosition(baselineTy
pe); | 638 LayoutUnit posAdjust = maxAscent - curr->baselinePosition(baselineTy
pe); |
| 636 curr->setLogicalTop(curr->logicalTop() + top + posAdjust); | 639 curr->setLogicalTop(curr->logicalTop() + top + posAdjust); |
| 637 } | 640 } |
| 638 | 641 |
| 639 LayoutUnit newLogicalTop = curr->logicalTop(); | 642 LayoutUnit newLogicalTop = curr->logicalTop(); |
| 640 LayoutUnit newLogicalTopIncludingMargins = newLogicalTop; | 643 LayoutUnit newLogicalTopIncludingMargins = newLogicalTop; |
| 641 LayoutUnit boxHeight = curr->logicalHeight(); | 644 LayoutUnit boxHeight = curr->logicalHeight(); |
| 642 LayoutUnit boxHeightIncludingMargins = boxHeight; | 645 LayoutUnit boxHeightIncludingMargins = boxHeight; |
| 643 | 646 |
| 644 if (curr->isText() || curr->isInlineFlowBox()) { | 647 if (curr->isText() || curr->isInlineFlowBox()) { |
| 645 const FontMetrics& fontMetrics = curr->renderer()->style(isFirstLine
Style())->fontMetrics(); | 648 const FontMetrics& fontMetrics = curr->renderer().style(isFirstLineS
tyle())->fontMetrics(); |
| 646 newLogicalTop += curr->baselinePosition(baselineType) - fontMetrics.
ascent(baselineType); | 649 newLogicalTop += curr->baselinePosition(baselineType) - fontMetrics.
ascent(baselineType); |
| 647 if (curr->isInlineFlowBox()) { | 650 if (curr->isInlineFlowBox()) { |
| 648 RenderBoxModelObject* boxObject = toRenderBoxModelObject(curr->r
enderer()); | 651 RenderBoxModelObject& boxObject = toRenderBoxModelObject(curr->r
enderer()); |
| 649 newLogicalTop -= boxObject->style(isFirstLineStyle())->isHorizon
talWritingMode() ? boxObject->borderTop() + boxObject->paddingTop() : | 652 newLogicalTop -= boxObject.style(isFirstLineStyle())->isHorizont
alWritingMode() ? boxObject.borderTop() + boxObject.paddingTop() : |
| 650 boxObject->borderRight() + boxObject->paddingRi
ght(); | 653 boxObject.borderRight() + boxObject.paddingRight(); |
| 651 } | 654 } |
| 652 newLogicalTopIncludingMargins = newLogicalTop; | 655 newLogicalTopIncludingMargins = newLogicalTop; |
| 653 } else if (!curr->renderer()->isBR()) { | 656 } else if (!curr->renderer().isBR()) { |
| 654 RenderBox* box = toRenderBox(curr->renderer()); | 657 RenderBox& box = toRenderBox(curr->renderer()); |
| 655 newLogicalTopIncludingMargins = newLogicalTop; | 658 newLogicalTopIncludingMargins = newLogicalTop; |
| 656 LayoutUnit overSideMargin = curr->isHorizontal() ? box->marginTop()
: box->marginRight(); | 659 LayoutUnit overSideMargin = curr->isHorizontal() ? box.marginTop() :
box.marginRight(); |
| 657 LayoutUnit underSideMargin = curr->isHorizontal() ? box->marginBotto
m() : box->marginLeft(); | 660 LayoutUnit underSideMargin = curr->isHorizontal() ? box.marginBottom
() : box.marginLeft(); |
| 658 newLogicalTop += overSideMargin; | 661 newLogicalTop += overSideMargin; |
| 659 boxHeightIncludingMargins += overSideMargin + underSideMargin; | 662 boxHeightIncludingMargins += overSideMargin + underSideMargin; |
| 660 } | 663 } |
| 661 | 664 |
| 662 curr->setLogicalTop(newLogicalTop); | 665 curr->setLogicalTop(newLogicalTop); |
| 663 | 666 |
| 664 if (childAffectsTopBottomPos) { | 667 if (childAffectsTopBottomPos) { |
| 665 if (curr->renderer()->isRubyRun()) { | 668 if (curr->renderer().isRubyRun()) { |
| 666 // Treat the leading on the first and last lines of ruby runs as
not being part of the overall lineTop/lineBottom. | 669 // Treat the leading on the first and last lines of ruby runs as
not being part of the overall lineTop/lineBottom. |
| 667 // Really this is a workaround hack for the fact that ruby shoul
d have been done as line layout and not done using | 670 // Really this is a workaround hack for the fact that ruby shoul
d have been done as line layout and not done using |
| 668 // inline-block. | 671 // inline-block. |
| 669 if (renderer()->style()->isFlippedLinesWritingMode() == (curr->r
enderer()->style()->rubyPosition() == RubyPositionAfter)) | 672 if (renderer().style()->isFlippedLinesWritingMode() == (curr->re
nderer().style()->rubyPosition() == RubyPositionAfter)) |
| 670 hasAnnotationsBefore = true; | 673 hasAnnotationsBefore = true; |
| 671 else | 674 else |
| 672 hasAnnotationsAfter = true; | 675 hasAnnotationsAfter = true; |
| 673 | 676 |
| 674 RenderRubyRun* rubyRun = toRenderRubyRun(curr->renderer()); | 677 RenderRubyRun& rubyRun = toRenderRubyRun(curr->renderer()); |
| 675 if (RenderRubyBase* rubyBase = rubyRun->rubyBase()) { | 678 if (RenderRubyBase* rubyBase = rubyRun.rubyBase()) { |
| 676 LayoutUnit bottomRubyBaseLeading = (curr->logicalHeight() -
rubyBase->logicalBottom()) + rubyBase->logicalHeight() - (rubyBase->lastRootBox(
) ? rubyBase->lastRootBox()->lineBottom() : LayoutUnit()); | 679 LayoutUnit bottomRubyBaseLeading = (curr->logicalHeight() -
rubyBase->logicalBottom()) + rubyBase->logicalHeight() - (rubyBase->lastRootBox(
) ? rubyBase->lastRootBox()->lineBottom() : LayoutUnit()); |
| 677 LayoutUnit topRubyBaseLeading = rubyBase->logicalTop() + (ru
byBase->firstRootBox() ? rubyBase->firstRootBox()->lineTop() : LayoutUnit()); | 680 LayoutUnit topRubyBaseLeading = rubyBase->logicalTop() + (ru
byBase->firstRootBox() ? rubyBase->firstRootBox()->lineTop() : LayoutUnit()); |
| 678 newLogicalTop += !renderer()->style()->isFlippedLinesWriting
Mode() ? topRubyBaseLeading : bottomRubyBaseLeading; | 681 newLogicalTop += !renderer().style()->isFlippedLinesWritingM
ode() ? topRubyBaseLeading : bottomRubyBaseLeading; |
| 679 boxHeight -= (topRubyBaseLeading + bottomRubyBaseLeading); | 682 boxHeight -= (topRubyBaseLeading + bottomRubyBaseLeading); |
| 680 } | 683 } |
| 681 } | 684 } |
| 682 if (curr->isInlineTextBox()) { | 685 if (curr->isInlineTextBox()) { |
| 683 TextEmphasisPosition emphasisMarkPosition; | 686 TextEmphasisPosition emphasisMarkPosition; |
| 684 if (toInlineTextBox(curr)->getEmphasisMarkPosition(curr->rendere
r()->style(isFirstLineStyle()), emphasisMarkPosition)) { | 687 if (toInlineTextBox(curr)->getEmphasisMarkPosition(curr->rendere
r().style(isFirstLineStyle()), emphasisMarkPosition)) { |
| 685 bool emphasisMarkIsOver = emphasisMarkPosition == TextEmphas
isPositionOver; | 688 bool emphasisMarkIsOver = emphasisMarkPosition == TextEmphas
isPositionOver; |
| 686 if (emphasisMarkIsOver != curr->renderer()->style(isFirstLin
eStyle())->isFlippedLinesWritingMode()) | 689 if (emphasisMarkIsOver != curr->renderer().style(isFirstLine
Style())->isFlippedLinesWritingMode()) |
| 687 hasAnnotationsBefore = true; | 690 hasAnnotationsBefore = true; |
| 688 else | 691 else |
| 689 hasAnnotationsAfter = true; | 692 hasAnnotationsAfter = true; |
| 690 } | 693 } |
| 691 } | 694 } |
| 692 | 695 |
| 693 if (!setLineTop) { | 696 if (!setLineTop) { |
| 694 setLineTop = true; | 697 setLineTop = true; |
| 695 lineTop = newLogicalTop; | 698 lineTop = newLogicalTop; |
| 696 lineTopIncludingMargins = min(lineTop, newLogicalTopIncludingMar
gins); | 699 lineTopIncludingMargins = min(lineTop, newLogicalTopIncludingMar
gins); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 716 lineTop = pixelSnappedLogicalTop(); | 719 lineTop = pixelSnappedLogicalTop(); |
| 717 lineTopIncludingMargins = lineTop; | 720 lineTopIncludingMargins = lineTop; |
| 718 } else { | 721 } else { |
| 719 lineTop = min<LayoutUnit>(lineTop, pixelSnappedLogicalTop()); | 722 lineTop = min<LayoutUnit>(lineTop, pixelSnappedLogicalTop()); |
| 720 lineTopIncludingMargins = min(lineTop, lineTopIncludingMargins); | 723 lineTopIncludingMargins = min(lineTop, lineTopIncludingMargins); |
| 721 } | 724 } |
| 722 lineBottom = max<LayoutUnit>(lineBottom, pixelSnappedLogicalBottom()
); | 725 lineBottom = max<LayoutUnit>(lineBottom, pixelSnappedLogicalBottom()
); |
| 723 lineBottomIncludingMargins = max(lineBottom, lineBottomIncludingMarg
ins); | 726 lineBottomIncludingMargins = max(lineBottom, lineBottomIncludingMarg
ins); |
| 724 } | 727 } |
| 725 | 728 |
| 726 if (renderer()->style()->isFlippedLinesWritingMode()) | 729 if (renderer().style()->isFlippedLinesWritingMode()) |
| 727 flipLinesInBlockDirection(lineTopIncludingMargins, lineBottomIncludi
ngMargins); | 730 flipLinesInBlockDirection(lineTopIncludingMargins, lineBottomIncludi
ngMargins); |
| 728 } | 731 } |
| 729 } | 732 } |
| 730 | 733 |
| 731 void InlineFlowBox::computeMaxLogicalTop(float& maxLogicalTop) const | 734 void InlineFlowBox::computeMaxLogicalTop(float& maxLogicalTop) const |
| 732 { | 735 { |
| 733 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { | 736 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { |
| 734 if (curr->renderer()->isOutOfFlowPositioned()) | 737 if (curr->renderer().isOutOfFlowPositioned()) |
| 735 continue; // Positioned placeholders don't affect calculations. | 738 continue; // Positioned placeholders don't affect calculations. |
| 736 | 739 |
| 737 if (descendantsHaveSameLineHeightAndBaseline()) | 740 if (descendantsHaveSameLineHeightAndBaseline()) |
| 738 continue; | 741 continue; |
| 739 | 742 |
| 740 maxLogicalTop = max<float>(maxLogicalTop, curr->y()); | 743 maxLogicalTop = max<float>(maxLogicalTop, curr->y()); |
| 741 float localMaxLogicalTop = 0; | 744 float localMaxLogicalTop = 0; |
| 742 if (curr->isInlineFlowBox()) | 745 if (curr->isInlineFlowBox()) |
| 743 toInlineFlowBox(curr)->computeMaxLogicalTop(localMaxLogicalTop); | 746 toInlineFlowBox(curr)->computeMaxLogicalTop(localMaxLogicalTop); |
| 744 maxLogicalTop = max<float>(maxLogicalTop, localMaxLogicalTop); | 747 maxLogicalTop = max<float>(maxLogicalTop, localMaxLogicalTop); |
| 745 } | 748 } |
| 746 } | 749 } |
| 747 | 750 |
| 748 void InlineFlowBox::flipLinesInBlockDirection(LayoutUnit lineTop, LayoutUnit lin
eBottom) | 751 void InlineFlowBox::flipLinesInBlockDirection(LayoutUnit lineTop, LayoutUnit lin
eBottom) |
| 749 { | 752 { |
| 750 // Flip the box on the line such that the top is now relative to the lineBot
tom instead of the lineTop. | 753 // Flip the box on the line such that the top is now relative to the lineBot
tom instead of the lineTop. |
| 751 setLogicalTop(lineBottom - (logicalTop() - lineTop) - logicalHeight()); | 754 setLogicalTop(lineBottom - (logicalTop() - lineTop) - logicalHeight()); |
| 752 | 755 |
| 753 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { | 756 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { |
| 754 if (curr->renderer()->isOutOfFlowPositioned()) | 757 if (curr->renderer().isOutOfFlowPositioned()) |
| 755 continue; // Positioned placeholders aren't affected here. | 758 continue; // Positioned placeholders aren't affected here. |
| 756 | 759 |
| 757 if (curr->isInlineFlowBox()) | 760 if (curr->isInlineFlowBox()) |
| 758 toInlineFlowBox(curr)->flipLinesInBlockDirection(lineTop, lineBottom
); | 761 toInlineFlowBox(curr)->flipLinesInBlockDirection(lineTop, lineBottom
); |
| 759 else | 762 else |
| 760 curr->setLogicalTop(lineBottom - (curr->logicalTop() - lineTop) - cu
rr->logicalHeight()); | 763 curr->setLogicalTop(lineBottom - (curr->logicalTop() - lineTop) - cu
rr->logicalHeight()); |
| 761 } | 764 } |
| 762 } | 765 } |
| 763 | 766 |
| 764 inline void InlineFlowBox::addBoxShadowVisualOverflow(LayoutRect& logicalVisualO
verflow) | 767 inline void InlineFlowBox::addBoxShadowVisualOverflow(LayoutRect& logicalVisualO
verflow) |
| 765 { | 768 { |
| 766 // box-shadow on root line boxes is applying to the block and not to the lin
es. | 769 // box-shadow on root line boxes is applying to the block and not to the lin
es. |
| 767 if (!parent()) | 770 if (!parent()) |
| 768 return; | 771 return; |
| 769 | 772 |
| 770 RenderStyle* style = renderer()->style(isFirstLineStyle()); | 773 RenderStyle* style = renderer().style(isFirstLineStyle()); |
| 771 if (!style->boxShadow()) | 774 if (!style->boxShadow()) |
| 772 return; | 775 return; |
| 773 | 776 |
| 774 LayoutUnit boxShadowLogicalTop; | 777 LayoutUnit boxShadowLogicalTop; |
| 775 LayoutUnit boxShadowLogicalBottom; | 778 LayoutUnit boxShadowLogicalBottom; |
| 776 style->getBoxShadowBlockDirectionExtent(boxShadowLogicalTop, boxShadowLogica
lBottom); | 779 style->getBoxShadowBlockDirectionExtent(boxShadowLogicalTop, boxShadowLogica
lBottom); |
| 777 | 780 |
| 778 // Similar to how glyph overflow works, if our lines are flipped, then it's
actually the opposite shadow that applies, since | 781 // Similar to how glyph overflow works, if our lines are flipped, then it's
actually the opposite shadow that applies, since |
| 779 // the line is "upside down" in terms of block coordinates. | 782 // the line is "upside down" in terms of block coordinates. |
| 780 LayoutUnit shadowLogicalTop = style->isFlippedLinesWritingMode() ? -boxShado
wLogicalBottom : boxShadowLogicalTop; | 783 LayoutUnit shadowLogicalTop = style->isFlippedLinesWritingMode() ? -boxShado
wLogicalBottom : boxShadowLogicalTop; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 793 logicalVisualOverflow = LayoutRect(logicalLeftVisualOverflow, logicalTopVisu
alOverflow, | 796 logicalVisualOverflow = LayoutRect(logicalLeftVisualOverflow, logicalTopVisu
alOverflow, |
| 794 logicalRightVisualOverflow - logicalLeftV
isualOverflow, logicalBottomVisualOverflow - logicalTopVisualOverflow); | 797 logicalRightVisualOverflow - logicalLeftV
isualOverflow, logicalBottomVisualOverflow - logicalTopVisualOverflow); |
| 795 } | 798 } |
| 796 | 799 |
| 797 inline void InlineFlowBox::addBorderOutsetVisualOverflow(LayoutRect& logicalVisu
alOverflow) | 800 inline void InlineFlowBox::addBorderOutsetVisualOverflow(LayoutRect& logicalVisu
alOverflow) |
| 798 { | 801 { |
| 799 // border-image-outset on root line boxes is applying to the block and not t
o the lines. | 802 // border-image-outset on root line boxes is applying to the block and not t
o the lines. |
| 800 if (!parent()) | 803 if (!parent()) |
| 801 return; | 804 return; |
| 802 | 805 |
| 803 RenderStyle* style = renderer()->style(isFirstLineStyle()); | 806 RenderStyle* style = renderer().style(isFirstLineStyle()); |
| 804 if (!style->hasBorderImageOutsets()) | 807 if (!style->hasBorderImageOutsets()) |
| 805 return; | 808 return; |
| 806 | 809 |
| 807 LayoutBoxExtent borderOutsets = style->borderImageOutsets(); | 810 LayoutBoxExtent borderOutsets = style->borderImageOutsets(); |
| 808 | 811 |
| 809 LayoutUnit borderOutsetLogicalTop = borderOutsets.logicalTop(style->writingM
ode()); | 812 LayoutUnit borderOutsetLogicalTop = borderOutsets.logicalTop(style->writingM
ode()); |
| 810 LayoutUnit borderOutsetLogicalBottom = borderOutsets.logicalBottom(style->wr
itingMode()); | 813 LayoutUnit borderOutsetLogicalBottom = borderOutsets.logicalBottom(style->wr
itingMode()); |
| 811 LayoutUnit borderOutsetLogicalLeft = borderOutsets.logicalLeft(style->writin
gMode()); | 814 LayoutUnit borderOutsetLogicalLeft = borderOutsets.logicalLeft(style->writin
gMode()); |
| 812 LayoutUnit borderOutsetLogicalRight = borderOutsets.logicalRight(style->writ
ingMode()); | 815 LayoutUnit borderOutsetLogicalRight = borderOutsets.logicalRight(style->writ
ingMode()); |
| 813 | 816 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 827 | 830 |
| 828 logicalVisualOverflow = LayoutRect(logicalLeftVisualOverflow, logicalTopVisu
alOverflow, | 831 logicalVisualOverflow = LayoutRect(logicalLeftVisualOverflow, logicalTopVisu
alOverflow, |
| 829 logicalRightVisualOverflow - logicalLeftV
isualOverflow, logicalBottomVisualOverflow - logicalTopVisualOverflow); | 832 logicalRightVisualOverflow - logicalLeftV
isualOverflow, logicalBottomVisualOverflow - logicalTopVisualOverflow); |
| 830 } | 833 } |
| 831 | 834 |
| 832 inline void InlineFlowBox::addTextBoxVisualOverflow(InlineTextBox* textBox, Glyp
hOverflowAndFallbackFontsMap& textBoxDataMap, LayoutRect& logicalVisualOverflow) | 835 inline void InlineFlowBox::addTextBoxVisualOverflow(InlineTextBox* textBox, Glyp
hOverflowAndFallbackFontsMap& textBoxDataMap, LayoutRect& logicalVisualOverflow) |
| 833 { | 836 { |
| 834 if (textBox->knownToHaveNoOverflow()) | 837 if (textBox->knownToHaveNoOverflow()) |
| 835 return; | 838 return; |
| 836 | 839 |
| 837 RenderStyle* style = textBox->renderer()->style(isFirstLineStyle()); | 840 RenderStyle* style = textBox->renderer().style(isFirstLineStyle()); |
| 838 | 841 |
| 839 GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(textBox)
; | 842 GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(textBox)
; |
| 840 GlyphOverflow* glyphOverflow = it == textBoxDataMap.end() ? 0 : &it->value.s
econd; | 843 GlyphOverflow* glyphOverflow = it == textBoxDataMap.end() ? 0 : &it->value.s
econd; |
| 841 bool isFlippedLine = style->isFlippedLinesWritingMode(); | 844 bool isFlippedLine = style->isFlippedLinesWritingMode(); |
| 842 | 845 |
| 843 int topGlyphEdge = glyphOverflow ? (isFlippedLine ? glyphOverflow->bottom :
glyphOverflow->top) : 0; | 846 int topGlyphEdge = glyphOverflow ? (isFlippedLine ? glyphOverflow->bottom :
glyphOverflow->top) : 0; |
| 844 int bottomGlyphEdge = glyphOverflow ? (isFlippedLine ? glyphOverflow->top :
glyphOverflow->bottom) : 0; | 847 int bottomGlyphEdge = glyphOverflow ? (isFlippedLine ? glyphOverflow->top :
glyphOverflow->bottom) : 0; |
| 845 int leftGlyphEdge = glyphOverflow ? glyphOverflow->left : 0; | 848 int leftGlyphEdge = glyphOverflow ? glyphOverflow->left : 0; |
| 846 int rightGlyphEdge = glyphOverflow ? glyphOverflow->right : 0; | 849 int rightGlyphEdge = glyphOverflow ? glyphOverflow->right : 0; |
| 847 | 850 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 LayoutUnit logicalRightVisualOverflow = max(textBox->pixelSnappedLogicalRigh
t() + childOverflowLogicalRight, logicalVisualOverflow.maxX()); | 887 LayoutUnit logicalRightVisualOverflow = max(textBox->pixelSnappedLogicalRigh
t() + childOverflowLogicalRight, logicalVisualOverflow.maxX()); |
| 885 | 888 |
| 886 logicalVisualOverflow = LayoutRect(logicalLeftVisualOverflow, logicalTopVisu
alOverflow, | 889 logicalVisualOverflow = LayoutRect(logicalLeftVisualOverflow, logicalTopVisu
alOverflow, |
| 887 logicalRightVisualOverflow - logicalLeftV
isualOverflow, logicalBottomVisualOverflow - logicalTopVisualOverflow); | 890 logicalRightVisualOverflow - logicalLeftV
isualOverflow, logicalBottomVisualOverflow - logicalTopVisualOverflow); |
| 888 | 891 |
| 889 textBox->setLogicalOverflowRect(logicalVisualOverflow); | 892 textBox->setLogicalOverflowRect(logicalVisualOverflow); |
| 890 } | 893 } |
| 891 | 894 |
| 892 inline void InlineFlowBox::addReplacedChildOverflow(const InlineBox* inlineBox,
LayoutRect& logicalLayoutOverflow, LayoutRect& logicalVisualOverflow) | 895 inline void InlineFlowBox::addReplacedChildOverflow(const InlineBox* inlineBox,
LayoutRect& logicalLayoutOverflow, LayoutRect& logicalVisualOverflow) |
| 893 { | 896 { |
| 894 RenderBox* box = toRenderBox(inlineBox->renderer()); | 897 RenderBox& box = toRenderBox(inlineBox->renderer()); |
| 895 | 898 |
| 896 // Visual overflow only propagates if the box doesn't have a self-painting l
ayer. This rectangle does not include | 899 // Visual overflow only propagates if the box doesn't have a self-painting l
ayer. This rectangle does not include |
| 897 // transforms or relative positioning (since those objects always have self-
painting layers), but it does need to be adjusted | 900 // transforms or relative positioning (since those objects always have self-
painting layers), but it does need to be adjusted |
| 898 // for writing-mode differences. | 901 // for writing-mode differences. |
| 899 if (!box->hasSelfPaintingLayer()) { | 902 if (!box.hasSelfPaintingLayer()) { |
| 900 LayoutRect childLogicalVisualOverflow = box->logicalVisualOverflowRectFo
rPropagation(renderer()->style()); | 903 LayoutRect childLogicalVisualOverflow = box.logicalVisualOverflowRectFor
Propagation(renderer().style()); |
| 901 childLogicalVisualOverflow.move(inlineBox->logicalLeft(), inlineBox->log
icalTop()); | 904 childLogicalVisualOverflow.move(inlineBox->logicalLeft(), inlineBox->log
icalTop()); |
| 902 logicalVisualOverflow.unite(childLogicalVisualOverflow); | 905 logicalVisualOverflow.unite(childLogicalVisualOverflow); |
| 903 } | 906 } |
| 904 | 907 |
| 905 // Layout overflow internal to the child box only propagates if the child bo
x doesn't have overflow clip set. | 908 // Layout overflow internal to the child box only propagates if the child bo
x doesn't have overflow clip set. |
| 906 // Otherwise the child border box propagates as layout overflow. This recta
ngle must include transforms and relative positioning | 909 // Otherwise the child border box propagates as layout overflow. This recta
ngle must include transforms and relative positioning |
| 907 // and be adjusted for writing-mode differences. | 910 // and be adjusted for writing-mode differences. |
| 908 LayoutRect childLogicalLayoutOverflow = box->logicalLayoutOverflowRectForPro
pagation(renderer()->style()); | 911 LayoutRect childLogicalLayoutOverflow = box.logicalLayoutOverflowRectForProp
agation(renderer().style()); |
| 909 childLogicalLayoutOverflow.move(inlineBox->logicalLeft(), inlineBox->logical
Top()); | 912 childLogicalLayoutOverflow.move(inlineBox->logicalLeft(), inlineBox->logical
Top()); |
| 910 logicalLayoutOverflow.unite(childLogicalLayoutOverflow); | 913 logicalLayoutOverflow.unite(childLogicalLayoutOverflow); |
| 911 } | 914 } |
| 912 | 915 |
| 913 void InlineFlowBox::computeOverflow(LayoutUnit lineTop, LayoutUnit lineBottom, G
lyphOverflowAndFallbackFontsMap& textBoxDataMap) | 916 void InlineFlowBox::computeOverflow(LayoutUnit lineTop, LayoutUnit lineBottom, G
lyphOverflowAndFallbackFontsMap& textBoxDataMap) |
| 914 { | 917 { |
| 915 // If we know we have no overflow, we can just bail. | 918 // If we know we have no overflow, we can just bail. |
| 916 if (knownToHaveNoOverflow()) | 919 if (knownToHaveNoOverflow()) |
| 917 return; | 920 return; |
| 918 | 921 |
| 919 // Visual overflow just includes overflow for stuff we need to repaint ourse
lves. Self-painting layers are ignored. | 922 // Visual overflow just includes overflow for stuff we need to repaint ourse
lves. Self-painting layers are ignored. |
| 920 // Layout overflow is used to determine scrolling extent, so it still includ
es child layers and also factors in | 923 // Layout overflow is used to determine scrolling extent, so it still includ
es child layers and also factors in |
| 921 // transforms, relative positioning, etc. | 924 // transforms, relative positioning, etc. |
| 922 LayoutRect logicalLayoutOverflow(enclosingLayoutRect(logicalFrameRectIncludi
ngLineHeight(lineTop, lineBottom))); | 925 LayoutRect logicalLayoutOverflow(enclosingLayoutRect(logicalFrameRectIncludi
ngLineHeight(lineTop, lineBottom))); |
| 923 LayoutRect logicalVisualOverflow(logicalLayoutOverflow); | 926 LayoutRect logicalVisualOverflow(logicalLayoutOverflow); |
| 924 | 927 |
| 925 addBoxShadowVisualOverflow(logicalVisualOverflow); | 928 addBoxShadowVisualOverflow(logicalVisualOverflow); |
| 926 addBorderOutsetVisualOverflow(logicalVisualOverflow); | 929 addBorderOutsetVisualOverflow(logicalVisualOverflow); |
| 927 | 930 |
| 928 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { | 931 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { |
| 929 if (curr->renderer()->isOutOfFlowPositioned()) | 932 if (curr->renderer().isOutOfFlowPositioned()) |
| 930 continue; // Positioned placeholders don't affect calculations. | 933 continue; // Positioned placeholders don't affect calculations. |
| 931 | 934 |
| 932 if (curr->renderer()->isText()) { | 935 if (curr->renderer().isText()) { |
| 933 InlineTextBox* text = toInlineTextBox(curr); | 936 InlineTextBox* text = toInlineTextBox(curr); |
| 934 RenderText* rt = toRenderText(text->renderer()); | 937 RenderText& rt = toRenderText(text->renderer()); |
| 935 if (rt->isBR()) | 938 if (rt.isBR()) |
| 936 continue; | 939 continue; |
| 937 LayoutRect textBoxOverflow(enclosingLayoutRect(text->logicalFrameRec
t())); | 940 LayoutRect textBoxOverflow(enclosingLayoutRect(text->logicalFrameRec
t())); |
| 938 addTextBoxVisualOverflow(text, textBoxDataMap, textBoxOverflow); | 941 addTextBoxVisualOverflow(text, textBoxDataMap, textBoxOverflow); |
| 939 logicalVisualOverflow.unite(textBoxOverflow); | 942 logicalVisualOverflow.unite(textBoxOverflow); |
| 940 } else if (curr->renderer()->isRenderInline()) { | 943 } else if (curr->renderer().isRenderInline()) { |
| 941 InlineFlowBox* flow = toInlineFlowBox(curr); | 944 InlineFlowBox* flow = toInlineFlowBox(curr); |
| 942 flow->computeOverflow(lineTop, lineBottom, textBoxDataMap); | 945 flow->computeOverflow(lineTop, lineBottom, textBoxDataMap); |
| 943 if (!flow->boxModelObject()->hasSelfPaintingLayer()) | 946 if (!flow->boxModelObject()->hasSelfPaintingLayer()) |
| 944 logicalVisualOverflow.unite(flow->logicalVisualOverflowRect(line
Top, lineBottom)); | 947 logicalVisualOverflow.unite(flow->logicalVisualOverflowRect(line
Top, lineBottom)); |
| 945 LayoutRect childLayoutOverflow = flow->logicalLayoutOverflowRect(lin
eTop, lineBottom); | 948 LayoutRect childLayoutOverflow = flow->logicalLayoutOverflowRect(lin
eTop, lineBottom); |
| 946 childLayoutOverflow.move(flow->boxModelObject()->relativePositionLog
icalOffset()); | 949 childLayoutOverflow.move(flow->boxModelObject()->relativePositionLog
icalOffset()); |
| 947 logicalLayoutOverflow.unite(childLayoutOverflow); | 950 logicalLayoutOverflow.unite(childLayoutOverflow); |
| 948 } else | 951 } else { |
| 949 addReplacedChildOverflow(curr, logicalLayoutOverflow, logicalVisualO
verflow); | 952 addReplacedChildOverflow(curr, logicalLayoutOverflow, logicalVisualO
verflow); |
| 953 } |
| 950 } | 954 } |
| 951 | 955 |
| 952 setOverflowFromLogicalRects(logicalLayoutOverflow, logicalVisualOverflow, li
neTop, lineBottom); | 956 setOverflowFromLogicalRects(logicalLayoutOverflow, logicalVisualOverflow, li
neTop, lineBottom); |
| 953 } | 957 } |
| 954 | 958 |
| 955 void InlineFlowBox::setLayoutOverflow(const LayoutRect& rect, LayoutUnit lineTop
, LayoutUnit lineBottom) | 959 void InlineFlowBox::setLayoutOverflow(const LayoutRect& rect, LayoutUnit lineTop
, LayoutUnit lineBottom) |
| 956 { | 960 { |
| 957 LayoutRect frameBox = enclosingLayoutRect(frameRectIncludingLineHeight(lineT
op, lineBottom)); | 961 LayoutRect frameBox = enclosingLayoutRect(frameRectIncludingLineHeight(lineT
op, lineBottom)); |
| 958 if (frameBox.contains(rect) || rect.isEmpty()) | 962 if (frameBox.contains(rect) || rect.isEmpty()) |
| 959 return; | 963 return; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 990 LayoutRect overflowRect(visualOverflowRect(lineTop, lineBottom)); | 994 LayoutRect overflowRect(visualOverflowRect(lineTop, lineBottom)); |
| 991 flipForWritingMode(overflowRect); | 995 flipForWritingMode(overflowRect); |
| 992 overflowRect.moveBy(accumulatedOffset); | 996 overflowRect.moveBy(accumulatedOffset); |
| 993 if (!locationInContainer.intersects(overflowRect)) | 997 if (!locationInContainer.intersects(overflowRect)) |
| 994 return false; | 998 return false; |
| 995 | 999 |
| 996 // Check children first. | 1000 // Check children first. |
| 997 // We need to account for culled inline parents of the hit-tested nodes, so
that they may also get included in area-based hit-tests. | 1001 // We need to account for culled inline parents of the hit-tested nodes, so
that they may also get included in area-based hit-tests. |
| 998 RenderObject* culledParent = 0; | 1002 RenderObject* culledParent = 0; |
| 999 for (InlineBox* curr = lastChild(); curr; curr = curr->prevOnLine()) { | 1003 for (InlineBox* curr = lastChild(); curr; curr = curr->prevOnLine()) { |
| 1000 if (curr->renderer()->isText() || !curr->boxModelObject()->hasSelfPainti
ngLayer()) { | 1004 if (curr->renderer().isText() || !curr->boxModelObject()->hasSelfPaintin
gLayer()) { |
| 1001 RenderObject* newParent = 0; | 1005 RenderObject* newParent = 0; |
| 1002 // Culled parents are only relevant for area-based hit-tests, so ign
ore it in point-based ones. | 1006 // Culled parents are only relevant for area-based hit-tests, so ign
ore it in point-based ones. |
| 1003 if (locationInContainer.isRectBasedTest()) { | 1007 if (locationInContainer.isRectBasedTest()) { |
| 1004 newParent = curr->renderer()->parent(); | 1008 newParent = curr->renderer().parent(); |
| 1005 if (newParent == renderer()) | 1009 if (newParent == renderer()) |
| 1006 newParent = 0; | 1010 newParent = 0; |
| 1007 } | 1011 } |
| 1008 // Check the culled parent after all its children have been checked,
to do this we wait until | 1012 // Check the culled parent after all its children have been checked,
to do this we wait until |
| 1009 // we are about to test an element with a different parent. | 1013 // we are about to test an element with a different parent. |
| 1010 if (newParent != culledParent) { | 1014 if (newParent != culledParent) { |
| 1011 if (!newParent || !newParent->isDescendantOf(culledParent)) { | 1015 if (!newParent || !newParent->isDescendantOf(culledParent)) { |
| 1012 while (culledParent && culledParent != renderer() && culledP
arent != newParent) { | 1016 while (culledParent && culledParent != renderer() && culledP
arent != newParent) { |
| 1013 if (culledParent->isRenderInline() && toRenderInline(cul
ledParent)->hitTestCulledInline(request, result, locationInContainer, accumulate
dOffset)) | 1017 if (culledParent->isRenderInline() && toRenderInline(cul
ledParent)->hitTestCulledInline(request, result, locationInContainer, accumulate
dOffset)) |
| 1014 return true; | 1018 return true; |
| 1015 culledParent = culledParent->parent(); | 1019 culledParent = culledParent->parent(); |
| 1016 } | 1020 } |
| 1017 } | 1021 } |
| 1018 culledParent = newParent; | 1022 culledParent = newParent; |
| 1019 } | 1023 } |
| 1020 if (curr->nodeAtPoint(request, result, locationInContainer, accumula
tedOffset, lineTop, lineBottom)) { | 1024 if (curr->nodeAtPoint(request, result, locationInContainer, accumula
tedOffset, lineTop, lineBottom)) { |
| 1021 renderer()->updateHitTestResult(result, locationInContainer.poin
t() - toLayoutSize(accumulatedOffset)); | 1025 renderer().updateHitTestResult(result, locationInContainer.point
() - toLayoutSize(accumulatedOffset)); |
| 1022 return true; | 1026 return true; |
| 1023 } | 1027 } |
| 1024 } | 1028 } |
| 1025 } | 1029 } |
| 1026 // Check any culled ancestor of the final children tested. | 1030 // Check any culled ancestor of the final children tested. |
| 1027 while (culledParent && culledParent != renderer()) { | 1031 while (culledParent && culledParent != renderer()) { |
| 1028 if (culledParent->isRenderInline() && toRenderInline(culledParent)->hitT
estCulledInline(request, result, locationInContainer, accumulatedOffset)) | 1032 if (culledParent->isRenderInline() && toRenderInline(culledParent)->hitT
estCulledInline(request, result, locationInContainer, accumulatedOffset)) |
| 1029 return true; | 1033 return true; |
| 1030 culledParent = culledParent->parent(); | 1034 culledParent = culledParent->parent(); |
| 1031 } | 1035 } |
| 1032 | 1036 |
| 1033 // Now check ourselves. Pixel snap hit testing. | 1037 // Now check ourselves. Pixel snap hit testing. |
| 1034 LayoutRect frameRect = roundedFrameRect(); | 1038 LayoutRect frameRect = roundedFrameRect(); |
| 1035 LayoutUnit minX = frameRect.x(); | 1039 LayoutUnit minX = frameRect.x(); |
| 1036 LayoutUnit minY = frameRect.y(); | 1040 LayoutUnit minY = frameRect.y(); |
| 1037 LayoutUnit width = frameRect.width(); | 1041 LayoutUnit width = frameRect.width(); |
| 1038 LayoutUnit height = frameRect.height(); | 1042 LayoutUnit height = frameRect.height(); |
| 1039 | 1043 |
| 1040 // Constrain our hit testing to the line top and bottom if necessary. | 1044 // Constrain our hit testing to the line top and bottom if necessary. |
| 1041 bool noQuirksMode = renderer()->document().inNoQuirksMode(); | 1045 bool noQuirksMode = renderer().document().inNoQuirksMode(); |
| 1042 if (!noQuirksMode && !hasTextChildren() && !(descendantsHaveSameLineHeightAn
dBaseline() && hasTextDescendants())) { | 1046 if (!noQuirksMode && !hasTextChildren() && !(descendantsHaveSameLineHeightAn
dBaseline() && hasTextDescendants())) { |
| 1043 RootInlineBox* rootBox = root(); | 1047 RootInlineBox* rootBox = root(); |
| 1044 LayoutUnit& top = isHorizontal() ? minY : minX; | 1048 LayoutUnit& top = isHorizontal() ? minY : minX; |
| 1045 LayoutUnit& logicalHeight = isHorizontal() ? height : width; | 1049 LayoutUnit& logicalHeight = isHorizontal() ? height : width; |
| 1046 LayoutUnit bottom = min(rootBox->lineBottom(), top + logicalHeight); | 1050 LayoutUnit bottom = min(rootBox->lineBottom(), top + logicalHeight); |
| 1047 top = max(rootBox->lineTop(), top); | 1051 top = max(rootBox->lineTop(), top); |
| 1048 logicalHeight = bottom - top; | 1052 logicalHeight = bottom - top; |
| 1049 } | 1053 } |
| 1050 | 1054 |
| 1051 // Move x/y to our coordinates. | 1055 // Move x/y to our coordinates. |
| 1052 LayoutRect rect(minX, minY, width, height); | 1056 LayoutRect rect(minX, minY, width, height); |
| 1053 flipForWritingMode(rect); | 1057 flipForWritingMode(rect); |
| 1054 rect.moveBy(accumulatedOffset); | 1058 rect.moveBy(accumulatedOffset); |
| 1055 | 1059 |
| 1056 if (visibleToHitTestRequest(request) && locationInContainer.intersects(rect)
) { | 1060 if (visibleToHitTestRequest(request) && locationInContainer.intersects(rect)
) { |
| 1057 renderer()->updateHitTestResult(result, flipForWritingMode(locationInCon
tainer.point() - toLayoutSize(accumulatedOffset))); // Don't add in m_x or m_y h
ere, we want coords in the containing block's space. | 1061 renderer().updateHitTestResult(result, flipForWritingMode(locationInCont
ainer.point() - toLayoutSize(accumulatedOffset))); // Don't add in m_x or m_y he
re, we want coords in the containing block's space. |
| 1058 if (!result.addNodeToRectBasedTestResult(renderer()->node(), request, lo
cationInContainer, rect)) | 1062 if (!result.addNodeToRectBasedTestResult(renderer().node(), request, loc
ationInContainer, rect)) |
| 1059 return true; | 1063 return true; |
| 1060 } | 1064 } |
| 1061 | 1065 |
| 1062 return false; | 1066 return false; |
| 1063 } | 1067 } |
| 1064 | 1068 |
| 1065 void InlineFlowBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
LayoutUnit lineTop, LayoutUnit lineBottom) | 1069 void InlineFlowBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
LayoutUnit lineTop, LayoutUnit lineBottom) |
| 1066 { | 1070 { |
| 1067 LayoutRect overflowRect(visualOverflowRect(lineTop, lineBottom)); | 1071 LayoutRect overflowRect(visualOverflowRect(lineTop, lineBottom)); |
| 1068 overflowRect.inflate(renderer()->maximalOutlineSize(paintInfo.phase)); | 1072 overflowRect.inflate(renderer().maximalOutlineSize(paintInfo.phase)); |
| 1069 flipForWritingMode(overflowRect); | 1073 flipForWritingMode(overflowRect); |
| 1070 overflowRect.moveBy(paintOffset); | 1074 overflowRect.moveBy(paintOffset); |
| 1071 | 1075 |
| 1072 if (!paintInfo.rect.intersects(pixelSnappedIntRect(overflowRect))) | 1076 if (!paintInfo.rect.intersects(pixelSnappedIntRect(overflowRect))) |
| 1073 return; | 1077 return; |
| 1074 | 1078 |
| 1075 if (paintInfo.phase != PaintPhaseChildOutlines) { | 1079 if (paintInfo.phase != PaintPhaseChildOutlines) { |
| 1076 if (paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhas
eSelfOutline) { | 1080 if (paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhas
eSelfOutline) { |
| 1077 // Add ourselves to the paint info struct's list of inlines that nee
d to paint their | 1081 // Add ourselves to the paint info struct's list of inlines that nee
d to paint their |
| 1078 // outlines. | 1082 // outlines. |
| 1079 if (renderer()->style()->visibility() == VISIBLE && renderer()->hasO
utline() && !isRootInlineBox()) { | 1083 if (renderer().style()->visibility() == VISIBLE && renderer().hasOut
line() && !isRootInlineBox()) { |
| 1080 RenderInline* inlineFlow = toRenderInline(renderer()); | 1084 RenderInline& inlineFlow = toRenderInline(renderer()); |
| 1081 | 1085 |
| 1082 RenderBlock* cb = 0; | 1086 RenderBlock* cb = 0; |
| 1083 bool containingBlockPaintsContinuationOutline = inlineFlow->cont
inuation() || inlineFlow->isInlineElementContinuation(); | 1087 bool containingBlockPaintsContinuationOutline = inlineFlow.conti
nuation() || inlineFlow.isInlineElementContinuation(); |
| 1084 if (containingBlockPaintsContinuationOutline) { | 1088 if (containingBlockPaintsContinuationOutline) { |
| 1085 // FIXME: See https://bugs.webkit.org/show_bug.cgi?id=54690.
We currently don't reconnect inline continuations | 1089 // FIXME: See https://bugs.webkit.org/show_bug.cgi?id=54690.
We currently don't reconnect inline continuations |
| 1086 // after a child removal. As a result, those merged inlines
do not get seperated and hence not get enclosed by | 1090 // after a child removal. As a result, those merged inlines
do not get seperated and hence not get enclosed by |
| 1087 // anonymous blocks. In this case, it is better to bail out
and paint it ourself. | 1091 // anonymous blocks. In this case, it is better to bail out
and paint it ourself. |
| 1088 RenderBlock* enclosingAnonymousBlock = renderer()->containin
gBlock(); | 1092 RenderBlock* enclosingAnonymousBlock = renderer().containing
Block(); |
| 1089 if (!enclosingAnonymousBlock->isAnonymousBlock()) | 1093 if (!enclosingAnonymousBlock->isAnonymousBlock()) |
| 1090 containingBlockPaintsContinuationOutline = false; | 1094 containingBlockPaintsContinuationOutline = false; |
| 1091 else { | 1095 else { |
| 1092 cb = enclosingAnonymousBlock->containingBlock(); | 1096 cb = enclosingAnonymousBlock->containingBlock(); |
| 1093 for (RenderBoxModelObject* box = boxModelObject(); box !
= cb; box = box->parent()->enclosingBoxModelObject()) { | 1097 for (RenderBoxModelObject* box = boxModelObject(); box !
= cb; box = box->parent()->enclosingBoxModelObject()) { |
| 1094 if (box->hasSelfPaintingLayer()) { | 1098 if (box->hasSelfPaintingLayer()) { |
| 1095 containingBlockPaintsContinuationOutline = false
; | 1099 containingBlockPaintsContinuationOutline = false
; |
| 1096 break; | 1100 break; |
| 1097 } | 1101 } |
| 1098 } | 1102 } |
| 1099 } | 1103 } |
| 1100 } | 1104 } |
| 1101 | 1105 |
| 1102 if (containingBlockPaintsContinuationOutline) { | 1106 if (containingBlockPaintsContinuationOutline) { |
| 1103 // Add ourselves to the containing block of the entire conti
nuation so that it can | 1107 // Add ourselves to the containing block of the entire conti
nuation so that it can |
| 1104 // paint us atomically. | 1108 // paint us atomically. |
| 1105 cb->addContinuationWithOutline(toRenderInline(renderer()->no
de()->renderer())); | 1109 cb->addContinuationWithOutline(toRenderInline(renderer().nod
e()->renderer())); |
| 1106 } else if (!inlineFlow->isInlineElementContinuation()) { | 1110 } else if (!inlineFlow.isInlineElementContinuation()) { |
| 1107 paintInfo.outlineObjects()->add(inlineFlow); | 1111 paintInfo.outlineObjects()->add(&inlineFlow); |
| 1108 } | 1112 } |
| 1109 } | 1113 } |
| 1110 } else if (paintInfo.phase == PaintPhaseMask) { | 1114 } else if (paintInfo.phase == PaintPhaseMask) { |
| 1111 paintMask(paintInfo, paintOffset); | 1115 paintMask(paintInfo, paintOffset); |
| 1112 return; | 1116 return; |
| 1113 } else { | 1117 } else { |
| 1114 // Paint our background, border and box-shadow. | 1118 // Paint our background, border and box-shadow. |
| 1115 paintBoxDecorations(paintInfo, paintOffset); | 1119 paintBoxDecorations(paintInfo, paintOffset); |
| 1116 } | 1120 } |
| 1117 } | 1121 } |
| 1118 | 1122 |
| 1119 if (paintInfo.phase == PaintPhaseMask) | 1123 if (paintInfo.phase == PaintPhaseMask) |
| 1120 return; | 1124 return; |
| 1121 | 1125 |
| 1122 PaintPhase paintPhase = paintInfo.phase == PaintPhaseChildOutlines ? PaintPh
aseOutline : paintInfo.phase; | 1126 PaintPhase paintPhase = paintInfo.phase == PaintPhaseChildOutlines ? PaintPh
aseOutline : paintInfo.phase; |
| 1123 PaintInfo childInfo(paintInfo); | 1127 PaintInfo childInfo(paintInfo); |
| 1124 childInfo.phase = paintPhase; | 1128 childInfo.phase = paintPhase; |
| 1125 childInfo.updatePaintingRootForChildren(renderer()); | 1129 childInfo.updatePaintingRootForChildren(&renderer()); |
| 1126 | 1130 |
| 1127 // Paint our children. | 1131 // Paint our children. |
| 1128 if (paintPhase != PaintPhaseSelfOutline) { | 1132 if (paintPhase != PaintPhaseSelfOutline) { |
| 1129 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { | 1133 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { |
| 1130 if (curr->renderer()->isText() || !curr->boxModelObject()->hasSelfPa
intingLayer()) | 1134 if (curr->renderer().isText() || !curr->boxModelObject()->hasSelfPai
ntingLayer()) |
| 1131 curr->paint(childInfo, paintOffset, lineTop, lineBottom); | 1135 curr->paint(childInfo, paintOffset, lineTop, lineBottom); |
| 1132 } | 1136 } |
| 1133 } | 1137 } |
| 1134 } | 1138 } |
| 1135 | 1139 |
| 1136 void InlineFlowBox::paintFillLayers(const PaintInfo& paintInfo, const Color& c,
const FillLayer* fillLayer, const LayoutRect& rect, CompositeOperator op) | 1140 void InlineFlowBox::paintFillLayers(const PaintInfo& paintInfo, const Color& c,
const FillLayer* fillLayer, const LayoutRect& rect, CompositeOperator op) |
| 1137 { | 1141 { |
| 1138 if (!fillLayer) | 1142 if (!fillLayer) |
| 1139 return; | 1143 return; |
| 1140 paintFillLayers(paintInfo, c, fillLayer->next(), rect, op); | 1144 paintFillLayers(paintInfo, c, fillLayer->next(), rect, op); |
| 1141 paintFillLayer(paintInfo, c, fillLayer, rect, op); | 1145 paintFillLayer(paintInfo, c, fillLayer, rect, op); |
| 1142 } | 1146 } |
| 1143 | 1147 |
| 1144 bool InlineFlowBox::boxShadowCanBeAppliedToBackground(const FillLayer& lastBackg
roundLayer) const | 1148 bool InlineFlowBox::boxShadowCanBeAppliedToBackground(const FillLayer& lastBackg
roundLayer) const |
| 1145 { | 1149 { |
| 1146 // The checks here match how paintFillLayer() decides whether to clip (if it
does, the shadow | 1150 // The checks here match how paintFillLayer() decides whether to clip (if it
does, the shadow |
| 1147 // would be clipped out, so it has to be drawn separately). | 1151 // would be clipped out, so it has to be drawn separately). |
| 1148 StyleImage* image = lastBackgroundLayer.image(); | 1152 StyleImage* image = lastBackgroundLayer.image(); |
| 1149 bool hasFillImage = image && image->canRender(renderer(), renderer()->style(
)->effectiveZoom()); | 1153 bool hasFillImage = image && image->canRender(&renderer(), renderer().style(
)->effectiveZoom()); |
| 1150 return (!hasFillImage && !renderer()->style()->hasBorderRadius()) || (!prevL
ineBox() && !nextLineBox()) || !parent(); | 1154 return (!hasFillImage && !renderer().style()->hasBorderRadius()) || (!prevLi
neBox() && !nextLineBox()) || !parent(); |
| 1151 } | 1155 } |
| 1152 | 1156 |
| 1153 void InlineFlowBox::paintFillLayer(const PaintInfo& paintInfo, const Color& c, c
onst FillLayer* fillLayer, const LayoutRect& rect, CompositeOperator op) | 1157 void InlineFlowBox::paintFillLayer(const PaintInfo& paintInfo, const Color& c, c
onst FillLayer* fillLayer, const LayoutRect& rect, CompositeOperator op) |
| 1154 { | 1158 { |
| 1155 StyleImage* img = fillLayer->image(); | 1159 StyleImage* img = fillLayer->image(); |
| 1156 bool hasFillImage = img && img->canRender(renderer(), renderer()->style()->e
ffectiveZoom()); | 1160 bool hasFillImage = img && img->canRender(&renderer(), renderer().style()->e
ffectiveZoom()); |
| 1157 if ((!hasFillImage && !renderer()->style()->hasBorderRadius()) || (!prevLine
Box() && !nextLineBox()) || !parent()) | 1161 if ((!hasFillImage && !renderer().style()->hasBorderRadius()) || (!prevLineB
ox() && !nextLineBox()) || !parent()) { |
| 1158 boxModelObject()->paintFillLayerExtended(paintInfo, c, fillLayer, rect,
BackgroundBleedNone, this, rect.size(), op); | 1162 boxModelObject()->paintFillLayerExtended(paintInfo, c, fillLayer, rect,
BackgroundBleedNone, this, rect.size(), op); |
| 1159 else if (renderer()->style()->boxDecorationBreak() == DCLONE) { | 1163 } else if (renderer().style()->boxDecorationBreak() == DCLONE) { |
| 1160 GraphicsContextStateSaver stateSaver(*paintInfo.context); | 1164 GraphicsContextStateSaver stateSaver(*paintInfo.context); |
| 1161 paintInfo.context->clip(LayoutRect(rect.x(), rect.y(), width(), height()
)); | 1165 paintInfo.context->clip(LayoutRect(rect.x(), rect.y(), width(), height()
)); |
| 1162 boxModelObject()->paintFillLayerExtended(paintInfo, c, fillLayer, rect,
BackgroundBleedNone, this, rect.size(), op); | 1166 boxModelObject()->paintFillLayerExtended(paintInfo, c, fillLayer, rect,
BackgroundBleedNone, this, rect.size(), op); |
| 1163 } else { | 1167 } else { |
| 1164 // We have a fill image that spans multiple lines. | 1168 // We have a fill image that spans multiple lines. |
| 1165 // We need to adjust tx and ty by the width of all previous lines. | 1169 // We need to adjust tx and ty by the width of all previous lines. |
| 1166 // Think of background painting on inlines as though you had one long li
ne, a single continuous | 1170 // Think of background painting on inlines as though you had one long li
ne, a single continuous |
| 1167 // strip. Even though that strip has been broken up across multiple lin
es, you still paint it | 1171 // strip. Even though that strip has been broken up across multiple lin
es, you still paint it |
| 1168 // as though you had one single line. This means each line has to pick
up the background where | 1172 // as though you had one single line. This means each line has to pick
up the background where |
| 1169 // the previous line left off. | 1173 // the previous line left off. |
| 1170 LayoutUnit logicalOffsetOnLine = 0; | 1174 LayoutUnit logicalOffsetOnLine = 0; |
| 1171 LayoutUnit totalLogicalWidth; | 1175 LayoutUnit totalLogicalWidth; |
| 1172 if (renderer()->style()->direction() == LTR) { | 1176 if (renderer().style()->direction() == LTR) { |
| 1173 for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->prevLin
eBox()) | 1177 for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->prevLin
eBox()) |
| 1174 logicalOffsetOnLine += curr->logicalWidth(); | 1178 logicalOffsetOnLine += curr->logicalWidth(); |
| 1175 totalLogicalWidth = logicalOffsetOnLine; | 1179 totalLogicalWidth = logicalOffsetOnLine; |
| 1176 for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox()) | 1180 for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox()) |
| 1177 totalLogicalWidth += curr->logicalWidth(); | 1181 totalLogicalWidth += curr->logicalWidth(); |
| 1178 } else { | 1182 } else { |
| 1179 for (InlineFlowBox* curr = nextLineBox(); curr; curr = curr->nextLin
eBox()) | 1183 for (InlineFlowBox* curr = nextLineBox(); curr; curr = curr->nextLin
eBox()) |
| 1180 logicalOffsetOnLine += curr->logicalWidth(); | 1184 logicalOffsetOnLine += curr->logicalWidth(); |
| 1181 totalLogicalWidth = logicalOffsetOnLine; | 1185 totalLogicalWidth = logicalOffsetOnLine; |
| 1182 for (InlineFlowBox* curr = this; curr; curr = curr->prevLineBox()) | 1186 for (InlineFlowBox* curr = this; curr; curr = curr->prevLineBox()) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1199 boxModelObject()->paintBoxShadow(info, paintRect, s, shadowStyle); | 1203 boxModelObject()->paintBoxShadow(info, paintRect, s, shadowStyle); |
| 1200 else { | 1204 else { |
| 1201 // FIXME: We can do better here in the multi-line case. We want to push
a clip so that the shadow doesn't | 1205 // FIXME: We can do better here in the multi-line case. We want to push
a clip so that the shadow doesn't |
| 1202 // protrude incorrectly at the edges, and we want to possibly include sh
adows cast from the previous/following lines | 1206 // protrude incorrectly at the edges, and we want to possibly include sh
adows cast from the previous/following lines |
| 1203 boxModelObject()->paintBoxShadow(info, paintRect, s, shadowStyle, includ
eLogicalLeftEdge(), includeLogicalRightEdge()); | 1207 boxModelObject()->paintBoxShadow(info, paintRect, s, shadowStyle, includ
eLogicalLeftEdge(), includeLogicalRightEdge()); |
| 1204 } | 1208 } |
| 1205 } | 1209 } |
| 1206 | 1210 |
| 1207 void InlineFlowBox::constrainToLineTopAndBottomIfNeeded(LayoutRect& rect) const | 1211 void InlineFlowBox::constrainToLineTopAndBottomIfNeeded(LayoutRect& rect) const |
| 1208 { | 1212 { |
| 1209 bool noQuirksMode = renderer()->document().inNoQuirksMode(); | 1213 bool noQuirksMode = renderer().document().inNoQuirksMode(); |
| 1210 if (!noQuirksMode && !hasTextChildren() && !(descendantsHaveSameLineHeightAn
dBaseline() && hasTextDescendants())) { | 1214 if (!noQuirksMode && !hasTextChildren() && !(descendantsHaveSameLineHeightAn
dBaseline() && hasTextDescendants())) { |
| 1211 const RootInlineBox* rootBox = root(); | 1215 const RootInlineBox* rootBox = root(); |
| 1212 LayoutUnit logicalTop = isHorizontal() ? rect.y() : rect.x(); | 1216 LayoutUnit logicalTop = isHorizontal() ? rect.y() : rect.x(); |
| 1213 LayoutUnit logicalHeight = isHorizontal() ? rect.height() : rect.width()
; | 1217 LayoutUnit logicalHeight = isHorizontal() ? rect.height() : rect.width()
; |
| 1214 LayoutUnit bottom = min(rootBox->lineBottom(), logicalTop + logicalHeigh
t); | 1218 LayoutUnit bottom = min(rootBox->lineBottom(), logicalTop + logicalHeigh
t); |
| 1215 logicalTop = max(rootBox->lineTop(), logicalTop); | 1219 logicalTop = max(rootBox->lineTop(), logicalTop); |
| 1216 logicalHeight = bottom - logicalTop; | 1220 logicalHeight = bottom - logicalTop; |
| 1217 if (isHorizontal()) { | 1221 if (isHorizontal()) { |
| 1218 rect.setY(logicalTop); | 1222 rect.setY(logicalTop); |
| 1219 rect.setHeight(logicalHeight); | 1223 rect.setHeight(logicalHeight); |
| 1220 } else { | 1224 } else { |
| 1221 rect.setX(logicalTop); | 1225 rect.setX(logicalTop); |
| 1222 rect.setWidth(logicalHeight); | 1226 rect.setWidth(logicalHeight); |
| 1223 } | 1227 } |
| 1224 } | 1228 } |
| 1225 } | 1229 } |
| 1226 | 1230 |
| 1227 static LayoutRect clipRectForNinePieceImageStrip(InlineFlowBox* box, const NineP
ieceImage& image, const LayoutRect& paintRect) | 1231 static LayoutRect clipRectForNinePieceImageStrip(InlineFlowBox* box, const NineP
ieceImage& image, const LayoutRect& paintRect) |
| 1228 { | 1232 { |
| 1229 LayoutRect clipRect(paintRect); | 1233 LayoutRect clipRect(paintRect); |
| 1230 RenderStyle* style = box->renderer()->style(); | 1234 RenderStyle* style = box->renderer().style(); |
| 1231 LayoutBoxExtent outsets = style->imageOutsets(image); | 1235 LayoutBoxExtent outsets = style->imageOutsets(image); |
| 1232 if (box->isHorizontal()) { | 1236 if (box->isHorizontal()) { |
| 1233 clipRect.setY(paintRect.y() - outsets.top()); | 1237 clipRect.setY(paintRect.y() - outsets.top()); |
| 1234 clipRect.setHeight(paintRect.height() + outsets.top() + outsets.bottom()
); | 1238 clipRect.setHeight(paintRect.height() + outsets.top() + outsets.bottom()
); |
| 1235 if (box->includeLogicalLeftEdge()) { | 1239 if (box->includeLogicalLeftEdge()) { |
| 1236 clipRect.setX(paintRect.x() - outsets.left()); | 1240 clipRect.setX(paintRect.x() - outsets.left()); |
| 1237 clipRect.setWidth(paintRect.width() + outsets.left()); | 1241 clipRect.setWidth(paintRect.width() + outsets.left()); |
| 1238 } | 1242 } |
| 1239 if (box->includeLogicalRightEdge()) | 1243 if (box->includeLogicalRightEdge()) |
| 1240 clipRect.setWidth(clipRect.width() + outsets.right()); | 1244 clipRect.setWidth(clipRect.width() + outsets.right()); |
| 1241 } else { | 1245 } else { |
| 1242 clipRect.setX(paintRect.x() - outsets.left()); | 1246 clipRect.setX(paintRect.x() - outsets.left()); |
| 1243 clipRect.setWidth(paintRect.width() + outsets.left() + outsets.right()); | 1247 clipRect.setWidth(paintRect.width() + outsets.left() + outsets.right()); |
| 1244 if (box->includeLogicalLeftEdge()) { | 1248 if (box->includeLogicalLeftEdge()) { |
| 1245 clipRect.setY(paintRect.y() - outsets.top()); | 1249 clipRect.setY(paintRect.y() - outsets.top()); |
| 1246 clipRect.setHeight(paintRect.height() + outsets.top()); | 1250 clipRect.setHeight(paintRect.height() + outsets.top()); |
| 1247 } | 1251 } |
| 1248 if (box->includeLogicalRightEdge()) | 1252 if (box->includeLogicalRightEdge()) |
| 1249 clipRect.setHeight(clipRect.height() + outsets.bottom()); | 1253 clipRect.setHeight(clipRect.height() + outsets.bottom()); |
| 1250 } | 1254 } |
| 1251 return clipRect; | 1255 return clipRect; |
| 1252 } | 1256 } |
| 1253 | 1257 |
| 1254 void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint&
paintOffset) | 1258 void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint&
paintOffset) |
| 1255 { | 1259 { |
| 1256 if (!paintInfo.shouldPaintWithinRoot(renderer()) || renderer()->style()->vis
ibility() != VISIBLE || paintInfo.phase != PaintPhaseForeground) | 1260 if (!paintInfo.shouldPaintWithinRoot(&renderer()) || renderer().style()->vis
ibility() != VISIBLE || paintInfo.phase != PaintPhaseForeground) |
| 1257 return; | 1261 return; |
| 1258 | 1262 |
| 1259 // Pixel snap background/border painting. | 1263 // Pixel snap background/border painting. |
| 1260 LayoutRect frameRect = roundedFrameRect(); | 1264 LayoutRect frameRect = roundedFrameRect(); |
| 1261 | 1265 |
| 1262 constrainToLineTopAndBottomIfNeeded(frameRect); | 1266 constrainToLineTopAndBottomIfNeeded(frameRect); |
| 1263 | 1267 |
| 1264 // Move x/y to our coordinates. | 1268 // Move x/y to our coordinates. |
| 1265 LayoutRect localRect(frameRect); | 1269 LayoutRect localRect(frameRect); |
| 1266 flipForWritingMode(localRect); | 1270 flipForWritingMode(localRect); |
| 1267 LayoutPoint adjustedPaintoffset = paintOffset + localRect.location(); | 1271 LayoutPoint adjustedPaintoffset = paintOffset + localRect.location(); |
| 1268 | 1272 |
| 1269 GraphicsContext* context = paintInfo.context; | 1273 GraphicsContext* context = paintInfo.context; |
| 1270 | 1274 |
| 1271 // You can use p::first-line to specify a background. If so, the root line b
oxes for | 1275 // You can use p::first-line to specify a background. If so, the root line b
oxes for |
| 1272 // a line may actually have to paint a background. | 1276 // a line may actually have to paint a background. |
| 1273 RenderStyle* styleToUse = renderer()->style(isFirstLineStyle()); | 1277 RenderStyle* styleToUse = renderer().style(isFirstLineStyle()); |
| 1274 if ((!parent() && isFirstLineStyle() && styleToUse != renderer()->style()) |
| (parent() && renderer()->hasBoxDecorations())) { | 1278 if ((!parent() && isFirstLineStyle() && styleToUse != renderer().style()) ||
(parent() && renderer().hasBoxDecorations())) { |
| 1275 LayoutRect paintRect = LayoutRect(adjustedPaintoffset, frameRect.size())
; | 1279 LayoutRect paintRect = LayoutRect(adjustedPaintoffset, frameRect.size())
; |
| 1276 // Shadow comes first and is behind the background and border. | 1280 // Shadow comes first and is behind the background and border. |
| 1277 if (!boxModelObject()->boxShadowShouldBeAppliedToBackground(BackgroundBl
eedNone, this)) | 1281 if (!boxModelObject()->boxShadowShouldBeAppliedToBackground(BackgroundBl
eedNone, this)) |
| 1278 paintBoxShadow(paintInfo, styleToUse, Normal, paintRect); | 1282 paintBoxShadow(paintInfo, styleToUse, Normal, paintRect); |
| 1279 | 1283 |
| 1280 Color c = renderer()->resolveColor(styleToUse, CSSPropertyBackgroundColo
r); | 1284 Color c = renderer().resolveColor(styleToUse, CSSPropertyBackgroundColor
); |
| 1281 paintFillLayers(paintInfo, c, styleToUse->backgroundLayers(), paintRect)
; | 1285 paintFillLayers(paintInfo, c, styleToUse->backgroundLayers(), paintRect)
; |
| 1282 paintBoxShadow(paintInfo, styleToUse, Inset, paintRect); | 1286 paintBoxShadow(paintInfo, styleToUse, Inset, paintRect); |
| 1283 | 1287 |
| 1284 // :first-line cannot be used to put borders on a line. Always paint bor
ders with our | 1288 // :first-line cannot be used to put borders on a line. Always paint bor
ders with our |
| 1285 // non-first-line style. | 1289 // non-first-line style. |
| 1286 if (parent() && renderer()->style()->hasBorder()) { | 1290 if (parent() && renderer().style()->hasBorder()) { |
| 1287 const NinePieceImage& borderImage = renderer()->style()->borderImage
(); | 1291 const NinePieceImage& borderImage = renderer().style()->borderImage(
); |
| 1288 StyleImage* borderImageSource = borderImage.image(); | 1292 StyleImage* borderImageSource = borderImage.image(); |
| 1289 bool hasBorderImage = borderImageSource && borderImageSource->canRen
der(renderer(), styleToUse->effectiveZoom()); | 1293 bool hasBorderImage = borderImageSource && borderImageSource->canRen
der(&renderer(), styleToUse->effectiveZoom()); |
| 1290 if (hasBorderImage && !borderImageSource->isLoaded()) | 1294 if (hasBorderImage && !borderImageSource->isLoaded()) |
| 1291 return; // Don't paint anything while we wait for the image to l
oad. | 1295 return; // Don't paint anything while we wait for the image to l
oad. |
| 1292 | 1296 |
| 1293 // The simple case is where we either have no border image or we are
the only box for this object. In those | 1297 // The simple case is where we either have no border image or we are
the only box for this object. In those |
| 1294 // cases only a single call to draw is required. | 1298 // cases only a single call to draw is required. |
| 1295 if (!hasBorderImage || (!prevLineBox() && !nextLineBox())) | 1299 if (!hasBorderImage || (!prevLineBox() && !nextLineBox())) |
| 1296 boxModelObject()->paintBorder(paintInfo, paintRect, renderer()->
style(isFirstLineStyle()), BackgroundBleedNone, includeLogicalLeftEdge(), includ
eLogicalRightEdge()); | 1300 boxModelObject()->paintBorder(paintInfo, paintRect, renderer().s
tyle(isFirstLineStyle()), BackgroundBleedNone, includeLogicalLeftEdge(), include
LogicalRightEdge()); |
| 1297 else { | 1301 else { |
| 1298 // We have a border image that spans multiple lines. | 1302 // We have a border image that spans multiple lines. |
| 1299 // We need to adjust tx and ty by the width of all previous line
s. | 1303 // We need to adjust tx and ty by the width of all previous line
s. |
| 1300 // Think of border image painting on inlines as though you had o
ne long line, a single continuous | 1304 // Think of border image painting on inlines as though you had o
ne long line, a single continuous |
| 1301 // strip. Even though that strip has been broken up across mult
iple lines, you still paint it | 1305 // strip. Even though that strip has been broken up across mult
iple lines, you still paint it |
| 1302 // as though you had one single line. This means each line has
to pick up the image where | 1306 // as though you had one single line. This means each line has
to pick up the image where |
| 1303 // the previous line left off. | 1307 // the previous line left off. |
| 1304 // FIXME: What the heck do we do with RTL here? The math we're u
sing is obviously not right, | 1308 // FIXME: What the heck do we do with RTL here? The math we're u
sing is obviously not right, |
| 1305 // but it isn't even clear how this should work at all. | 1309 // but it isn't even clear how this should work at all. |
| 1306 LayoutUnit logicalOffsetOnLine = 0; | 1310 LayoutUnit logicalOffsetOnLine = 0; |
| 1307 for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->pre
vLineBox()) | 1311 for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->pre
vLineBox()) |
| 1308 logicalOffsetOnLine += curr->logicalWidth(); | 1312 logicalOffsetOnLine += curr->logicalWidth(); |
| 1309 LayoutUnit totalLogicalWidth = logicalOffsetOnLine; | 1313 LayoutUnit totalLogicalWidth = logicalOffsetOnLine; |
| 1310 for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox(
)) | 1314 for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox(
)) |
| 1311 totalLogicalWidth += curr->logicalWidth(); | 1315 totalLogicalWidth += curr->logicalWidth(); |
| 1312 LayoutUnit stripX = adjustedPaintoffset.x() - (isHorizontal() ?
logicalOffsetOnLine : LayoutUnit()); | 1316 LayoutUnit stripX = adjustedPaintoffset.x() - (isHorizontal() ?
logicalOffsetOnLine : LayoutUnit()); |
| 1313 LayoutUnit stripY = adjustedPaintoffset.y() - (isHorizontal() ?
LayoutUnit() : logicalOffsetOnLine); | 1317 LayoutUnit stripY = adjustedPaintoffset.y() - (isHorizontal() ?
LayoutUnit() : logicalOffsetOnLine); |
| 1314 LayoutUnit stripWidth = isHorizontal() ? totalLogicalWidth : fra
meRect.width(); | 1318 LayoutUnit stripWidth = isHorizontal() ? totalLogicalWidth : fra
meRect.width(); |
| 1315 LayoutUnit stripHeight = isHorizontal() ? frameRect.height() : t
otalLogicalWidth; | 1319 LayoutUnit stripHeight = isHorizontal() ? frameRect.height() : t
otalLogicalWidth; |
| 1316 | 1320 |
| 1317 LayoutRect clipRect = clipRectForNinePieceImageStrip(this, borde
rImage, paintRect); | 1321 LayoutRect clipRect = clipRectForNinePieceImageStrip(this, borde
rImage, paintRect); |
| 1318 GraphicsContextStateSaver stateSaver(*context); | 1322 GraphicsContextStateSaver stateSaver(*context); |
| 1319 context->clip(clipRect); | 1323 context->clip(clipRect); |
| 1320 boxModelObject()->paintBorder(paintInfo, LayoutRect(stripX, stri
pY, stripWidth, stripHeight), renderer()->style(isFirstLineStyle())); | 1324 boxModelObject()->paintBorder(paintInfo, LayoutRect(stripX, stri
pY, stripWidth, stripHeight), renderer().style(isFirstLineStyle())); |
| 1321 } | 1325 } |
| 1322 } | 1326 } |
| 1323 } | 1327 } |
| 1324 } | 1328 } |
| 1325 | 1329 |
| 1326 void InlineFlowBox::paintMask(PaintInfo& paintInfo, const LayoutPoint& paintOffs
et) | 1330 void InlineFlowBox::paintMask(PaintInfo& paintInfo, const LayoutPoint& paintOffs
et) |
| 1327 { | 1331 { |
| 1328 if (!paintInfo.shouldPaintWithinRoot(renderer()) || renderer()->style()->vis
ibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) | 1332 if (!paintInfo.shouldPaintWithinRoot(&renderer()) || renderer().style()->vis
ibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) |
| 1329 return; | 1333 return; |
| 1330 | 1334 |
| 1331 // Pixel snap mask painting. | 1335 // Pixel snap mask painting. |
| 1332 LayoutRect frameRect = roundedFrameRect(); | 1336 LayoutRect frameRect = roundedFrameRect(); |
| 1333 | 1337 |
| 1334 constrainToLineTopAndBottomIfNeeded(frameRect); | 1338 constrainToLineTopAndBottomIfNeeded(frameRect); |
| 1335 | 1339 |
| 1336 // Move x/y to our coordinates. | 1340 // Move x/y to our coordinates. |
| 1337 LayoutRect localRect(frameRect); | 1341 LayoutRect localRect(frameRect); |
| 1338 flipForWritingMode(localRect); | 1342 flipForWritingMode(localRect); |
| 1339 LayoutPoint adjustedPaintOffset = paintOffset + localRect.location(); | 1343 LayoutPoint adjustedPaintOffset = paintOffset + localRect.location(); |
| 1340 | 1344 |
| 1341 const NinePieceImage& maskNinePieceImage = renderer()->style()->maskBoxImage
(); | 1345 const NinePieceImage& maskNinePieceImage = renderer().style()->maskBoxImage(
); |
| 1342 StyleImage* maskBoxImage = renderer()->style()->maskBoxImage().image(); | 1346 StyleImage* maskBoxImage = renderer().style()->maskBoxImage().image(); |
| 1343 | 1347 |
| 1344 // Figure out if we need to push a transparency layer to render our mask. | 1348 // Figure out if we need to push a transparency layer to render our mask. |
| 1345 bool pushTransparencyLayer = false; | 1349 bool pushTransparencyLayer = false; |
| 1346 bool compositedMask = renderer()->hasLayer() && boxModelObject()->layer()->h
asCompositedMask(); | 1350 bool compositedMask = renderer().hasLayer() && boxModelObject()->layer()->ha
sCompositedMask(); |
| 1347 bool flattenCompositingLayers = renderer()->view()->frameView() && renderer(
)->view()->frameView()->paintBehavior() & PaintBehaviorFlattenCompositingLayers; | 1351 bool flattenCompositingLayers = renderer().view()->frameView() && renderer()
.view()->frameView()->paintBehavior() & PaintBehaviorFlattenCompositingLayers; |
| 1348 CompositeOperator compositeOp = CompositeSourceOver; | 1352 CompositeOperator compositeOp = CompositeSourceOver; |
| 1349 if (!compositedMask || flattenCompositingLayers) { | 1353 if (!compositedMask || flattenCompositingLayers) { |
| 1350 if ((maskBoxImage && renderer()->style()->maskLayers()->hasImage()) || r
enderer()->style()->maskLayers()->next()) | 1354 if ((maskBoxImage && renderer().style()->maskLayers()->hasImage()) || re
nderer().style()->maskLayers()->next()) |
| 1351 pushTransparencyLayer = true; | 1355 pushTransparencyLayer = true; |
| 1352 | 1356 |
| 1353 compositeOp = CompositeDestinationIn; | 1357 compositeOp = CompositeDestinationIn; |
| 1354 if (pushTransparencyLayer) { | 1358 if (pushTransparencyLayer) { |
| 1355 paintInfo.context->setCompositeOperation(CompositeDestinationIn); | 1359 paintInfo.context->setCompositeOperation(CompositeDestinationIn); |
| 1356 paintInfo.context->beginTransparencyLayer(1.0f); | 1360 paintInfo.context->beginTransparencyLayer(1.0f); |
| 1357 compositeOp = CompositeSourceOver; | 1361 compositeOp = CompositeSourceOver; |
| 1358 } | 1362 } |
| 1359 } | 1363 } |
| 1360 | 1364 |
| 1361 LayoutRect paintRect = LayoutRect(adjustedPaintOffset, frameRect.size()); | 1365 LayoutRect paintRect = LayoutRect(adjustedPaintOffset, frameRect.size()); |
| 1362 paintFillLayers(paintInfo, Color::transparent, renderer()->style()->maskLaye
rs(), paintRect, compositeOp); | 1366 paintFillLayers(paintInfo, Color::transparent, renderer().style()->maskLayer
s(), paintRect, compositeOp); |
| 1363 | 1367 |
| 1364 bool hasBoxImage = maskBoxImage && maskBoxImage->canRender(renderer(), rende
rer()->style()->effectiveZoom()); | 1368 bool hasBoxImage = maskBoxImage && maskBoxImage->canRender(&renderer(), rend
erer().style()->effectiveZoom()); |
| 1365 if (!hasBoxImage || !maskBoxImage->isLoaded()) { | 1369 if (!hasBoxImage || !maskBoxImage->isLoaded()) { |
| 1366 if (pushTransparencyLayer) | 1370 if (pushTransparencyLayer) |
| 1367 paintInfo.context->endLayer(); | 1371 paintInfo.context->endLayer(); |
| 1368 return; // Don't paint anything while we wait for the image to load. | 1372 return; // Don't paint anything while we wait for the image to load. |
| 1369 } | 1373 } |
| 1370 | 1374 |
| 1371 // The simple case is where we are the only box for this object. In those | 1375 // The simple case is where we are the only box for this object. In those |
| 1372 // cases only a single call to draw is required. | 1376 // cases only a single call to draw is required. |
| 1373 if (!prevLineBox() && !nextLineBox()) { | 1377 if (!prevLineBox() && !nextLineBox()) { |
| 1374 boxModelObject()->paintNinePieceImage(paintInfo.context, LayoutRect(adju
stedPaintOffset, frameRect.size()), renderer()->style(), maskNinePieceImage, com
positeOp); | 1378 boxModelObject()->paintNinePieceImage(paintInfo.context, LayoutRect(adju
stedPaintOffset, frameRect.size()), renderer().style(), maskNinePieceImage, comp
ositeOp); |
| 1375 } else { | 1379 } else { |
| 1376 // We have a mask image that spans multiple lines. | 1380 // We have a mask image that spans multiple lines. |
| 1377 // We need to adjust _tx and _ty by the width of all previous lines. | 1381 // We need to adjust _tx and _ty by the width of all previous lines. |
| 1378 LayoutUnit logicalOffsetOnLine = 0; | 1382 LayoutUnit logicalOffsetOnLine = 0; |
| 1379 for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->prevLineBox
()) | 1383 for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->prevLineBox
()) |
| 1380 logicalOffsetOnLine += curr->logicalWidth(); | 1384 logicalOffsetOnLine += curr->logicalWidth(); |
| 1381 LayoutUnit totalLogicalWidth = logicalOffsetOnLine; | 1385 LayoutUnit totalLogicalWidth = logicalOffsetOnLine; |
| 1382 for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox()) | 1386 for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox()) |
| 1383 totalLogicalWidth += curr->logicalWidth(); | 1387 totalLogicalWidth += curr->logicalWidth(); |
| 1384 LayoutUnit stripX = adjustedPaintOffset.x() - (isHorizontal() ? logicalO
ffsetOnLine : LayoutUnit()); | 1388 LayoutUnit stripX = adjustedPaintOffset.x() - (isHorizontal() ? logicalO
ffsetOnLine : LayoutUnit()); |
| 1385 LayoutUnit stripY = adjustedPaintOffset.y() - (isHorizontal() ? LayoutUn
it() : logicalOffsetOnLine); | 1389 LayoutUnit stripY = adjustedPaintOffset.y() - (isHorizontal() ? LayoutUn
it() : logicalOffsetOnLine); |
| 1386 LayoutUnit stripWidth = isHorizontal() ? totalLogicalWidth : frameRect.w
idth(); | 1390 LayoutUnit stripWidth = isHorizontal() ? totalLogicalWidth : frameRect.w
idth(); |
| 1387 LayoutUnit stripHeight = isHorizontal() ? frameRect.height() : totalLogi
calWidth; | 1391 LayoutUnit stripHeight = isHorizontal() ? frameRect.height() : totalLogi
calWidth; |
| 1388 | 1392 |
| 1389 LayoutRect clipRect = clipRectForNinePieceImageStrip(this, maskNinePiece
Image, paintRect); | 1393 LayoutRect clipRect = clipRectForNinePieceImageStrip(this, maskNinePiece
Image, paintRect); |
| 1390 GraphicsContextStateSaver stateSaver(*paintInfo.context); | 1394 GraphicsContextStateSaver stateSaver(*paintInfo.context); |
| 1391 paintInfo.context->clip(clipRect); | 1395 paintInfo.context->clip(clipRect); |
| 1392 boxModelObject()->paintNinePieceImage(paintInfo.context, LayoutRect(stri
pX, stripY, stripWidth, stripHeight), renderer()->style(), maskNinePieceImage, c
ompositeOp); | 1396 boxModelObject()->paintNinePieceImage(paintInfo.context, LayoutRect(stri
pX, stripY, stripWidth, stripHeight), renderer().style(), maskNinePieceImage, co
mpositeOp); |
| 1393 } | 1397 } |
| 1394 | 1398 |
| 1395 if (pushTransparencyLayer) | 1399 if (pushTransparencyLayer) |
| 1396 paintInfo.context->endLayer(); | 1400 paintInfo.context->endLayer(); |
| 1397 } | 1401 } |
| 1398 | 1402 |
| 1399 InlineBox* InlineFlowBox::firstLeafChild() const | 1403 InlineBox* InlineFlowBox::firstLeafChild() const |
| 1400 { | 1404 { |
| 1401 InlineBox* leaf = 0; | 1405 InlineBox* leaf = 0; |
| 1402 for (InlineBox* child = firstChild(); child && !leaf; child = child->nextOnL
ine()) | 1406 for (InlineBox* child = firstChild(); child && !leaf; child = child->nextOnL
ine()) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1459 void InlineFlowBox::clearTruncation() | 1463 void InlineFlowBox::clearTruncation() |
| 1460 { | 1464 { |
| 1461 for (InlineBox *box = firstChild(); box; box = box->nextOnLine()) | 1465 for (InlineBox *box = firstChild(); box; box = box->nextOnLine()) |
| 1462 box->clearTruncation(); | 1466 box->clearTruncation(); |
| 1463 } | 1467 } |
| 1464 | 1468 |
| 1465 LayoutUnit InlineFlowBox::computeOverAnnotationAdjustment(LayoutUnit allowedPosi
tion) const | 1469 LayoutUnit InlineFlowBox::computeOverAnnotationAdjustment(LayoutUnit allowedPosi
tion) const |
| 1466 { | 1470 { |
| 1467 LayoutUnit result = 0; | 1471 LayoutUnit result = 0; |
| 1468 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { | 1472 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { |
| 1469 if (curr->renderer()->isOutOfFlowPositioned()) | 1473 if (curr->renderer().isOutOfFlowPositioned()) |
| 1470 continue; // Positioned placeholders don't affect calculations. | 1474 continue; // Positioned placeholders don't affect calculations. |
| 1471 | 1475 |
| 1472 if (curr->isInlineFlowBox()) | 1476 if (curr->isInlineFlowBox()) |
| 1473 result = max(result, toInlineFlowBox(curr)->computeOverAnnotationAdj
ustment(allowedPosition)); | 1477 result = max(result, toInlineFlowBox(curr)->computeOverAnnotationAdj
ustment(allowedPosition)); |
| 1474 | 1478 |
| 1475 if (curr->renderer()->isReplaced() && curr->renderer()->isRubyRun() && c
urr->renderer()->style()->rubyPosition() == RubyPositionBefore) { | 1479 if (curr->renderer().isReplaced() && curr->renderer().isRubyRun() && cur
r->renderer().style()->rubyPosition() == RubyPositionBefore) { |
| 1476 RenderRubyRun* rubyRun = toRenderRubyRun(curr->renderer()); | 1480 RenderRubyRun& rubyRun = toRenderRubyRun(curr->renderer()); |
| 1477 RenderRubyText* rubyText = rubyRun->rubyText(); | 1481 RenderRubyText* rubyText = rubyRun.rubyText(); |
| 1478 if (!rubyText) | 1482 if (!rubyText) |
| 1479 continue; | 1483 continue; |
| 1480 | 1484 |
| 1481 if (!rubyRun->style()->isFlippedLinesWritingMode()) { | 1485 if (!rubyRun.style()->isFlippedLinesWritingMode()) { |
| 1482 LayoutUnit topOfFirstRubyTextLine = rubyText->logicalTop() + (ru
byText->firstRootBox() ? rubyText->firstRootBox()->lineTop() : LayoutUnit()); | 1486 LayoutUnit topOfFirstRubyTextLine = rubyText->logicalTop() + (ru
byText->firstRootBox() ? rubyText->firstRootBox()->lineTop() : LayoutUnit()); |
| 1483 if (topOfFirstRubyTextLine >= 0) | 1487 if (topOfFirstRubyTextLine >= 0) |
| 1484 continue; | 1488 continue; |
| 1485 topOfFirstRubyTextLine += curr->logicalTop(); | 1489 topOfFirstRubyTextLine += curr->logicalTop(); |
| 1486 result = max(result, allowedPosition - topOfFirstRubyTextLine); | 1490 result = max(result, allowedPosition - topOfFirstRubyTextLine); |
| 1487 } else { | 1491 } else { |
| 1488 LayoutUnit bottomOfLastRubyTextLine = rubyText->logicalTop() + (
rubyText->lastRootBox() ? rubyText->lastRootBox()->lineBottom() : rubyText->logi
calHeight()); | 1492 LayoutUnit bottomOfLastRubyTextLine = rubyText->logicalTop() + (
rubyText->lastRootBox() ? rubyText->lastRootBox()->lineBottom() : rubyText->logi
calHeight()); |
| 1489 if (bottomOfLastRubyTextLine <= curr->logicalHeight()) | 1493 if (bottomOfLastRubyTextLine <= curr->logicalHeight()) |
| 1490 continue; | 1494 continue; |
| 1491 bottomOfLastRubyTextLine += curr->logicalTop(); | 1495 bottomOfLastRubyTextLine += curr->logicalTop(); |
| 1492 result = max(result, bottomOfLastRubyTextLine - allowedPosition)
; | 1496 result = max(result, bottomOfLastRubyTextLine - allowedPosition)
; |
| 1493 } | 1497 } |
| 1494 } | 1498 } |
| 1495 | 1499 |
| 1496 if (curr->isInlineTextBox()) { | 1500 if (curr->isInlineTextBox()) { |
| 1497 RenderStyle* style = curr->renderer()->style(isFirstLineStyle()); | 1501 RenderStyle* style = curr->renderer().style(isFirstLineStyle()); |
| 1498 TextEmphasisPosition emphasisMarkPosition; | 1502 TextEmphasisPosition emphasisMarkPosition; |
| 1499 if (style->textEmphasisMark() != TextEmphasisMarkNone && toInlineTex
tBox(curr)->getEmphasisMarkPosition(style, emphasisMarkPosition) && emphasisMark
Position == TextEmphasisPositionOver) { | 1503 if (style->textEmphasisMark() != TextEmphasisMarkNone && toInlineTex
tBox(curr)->getEmphasisMarkPosition(style, emphasisMarkPosition) && emphasisMark
Position == TextEmphasisPositionOver) { |
| 1500 if (!style->isFlippedLinesWritingMode()) { | 1504 if (!style->isFlippedLinesWritingMode()) { |
| 1501 int topOfEmphasisMark = curr->logicalTop() - style->font().e
mphasisMarkHeight(style->textEmphasisMarkString()); | 1505 int topOfEmphasisMark = curr->logicalTop() - style->font().e
mphasisMarkHeight(style->textEmphasisMarkString()); |
| 1502 result = max(result, allowedPosition - topOfEmphasisMark); | 1506 result = max(result, allowedPosition - topOfEmphasisMark); |
| 1503 } else { | 1507 } else { |
| 1504 int bottomOfEmphasisMark = curr->logicalBottom() + style->fo
nt().emphasisMarkHeight(style->textEmphasisMarkString()); | 1508 int bottomOfEmphasisMark = curr->logicalBottom() + style->fo
nt().emphasisMarkHeight(style->textEmphasisMarkString()); |
| 1505 result = max(result, bottomOfEmphasisMark - allowedPosition)
; | 1509 result = max(result, bottomOfEmphasisMark - allowedPosition)
; |
| 1506 } | 1510 } |
| 1507 } | 1511 } |
| 1508 } | 1512 } |
| 1509 } | 1513 } |
| 1510 return result; | 1514 return result; |
| 1511 } | 1515 } |
| 1512 | 1516 |
| 1513 LayoutUnit InlineFlowBox::computeUnderAnnotationAdjustment(LayoutUnit allowedPos
ition) const | 1517 LayoutUnit InlineFlowBox::computeUnderAnnotationAdjustment(LayoutUnit allowedPos
ition) const |
| 1514 { | 1518 { |
| 1515 LayoutUnit result = 0; | 1519 LayoutUnit result = 0; |
| 1516 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { | 1520 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { |
| 1517 if (curr->renderer()->isOutOfFlowPositioned()) | 1521 if (curr->renderer().isOutOfFlowPositioned()) |
| 1518 continue; // Positioned placeholders don't affect calculations. | 1522 continue; // Positioned placeholders don't affect calculations. |
| 1519 | 1523 |
| 1520 if (curr->isInlineFlowBox()) | 1524 if (curr->isInlineFlowBox()) |
| 1521 result = max(result, toInlineFlowBox(curr)->computeUnderAnnotationAd
justment(allowedPosition)); | 1525 result = max(result, toInlineFlowBox(curr)->computeUnderAnnotationAd
justment(allowedPosition)); |
| 1522 | 1526 |
| 1523 if (curr->renderer()->isReplaced() && curr->renderer()->isRubyRun() && c
urr->renderer()->style()->rubyPosition() == RubyPositionAfter) { | 1527 if (curr->renderer().isReplaced() && curr->renderer().isRubyRun() && cur
r->renderer().style()->rubyPosition() == RubyPositionAfter) { |
| 1524 RenderRubyRun* rubyRun = toRenderRubyRun(curr->renderer()); | 1528 RenderRubyRun& rubyRun = toRenderRubyRun(curr->renderer()); |
| 1525 RenderRubyText* rubyText = rubyRun->rubyText(); | 1529 RenderRubyText* rubyText = rubyRun.rubyText(); |
| 1526 if (!rubyText) | 1530 if (!rubyText) |
| 1527 continue; | 1531 continue; |
| 1528 | 1532 |
| 1529 if (rubyRun->style()->isFlippedLinesWritingMode()) { | 1533 if (rubyRun.style()->isFlippedLinesWritingMode()) { |
| 1530 LayoutUnit topOfFirstRubyTextLine = rubyText->logicalTop() + (ru
byText->firstRootBox() ? rubyText->firstRootBox()->lineTop() : LayoutUnit()); | 1534 LayoutUnit topOfFirstRubyTextLine = rubyText->logicalTop() + (ru
byText->firstRootBox() ? rubyText->firstRootBox()->lineTop() : LayoutUnit()); |
| 1531 if (topOfFirstRubyTextLine >= 0) | 1535 if (topOfFirstRubyTextLine >= 0) |
| 1532 continue; | 1536 continue; |
| 1533 topOfFirstRubyTextLine += curr->logicalTop(); | 1537 topOfFirstRubyTextLine += curr->logicalTop(); |
| 1534 result = max(result, allowedPosition - topOfFirstRubyTextLine); | 1538 result = max(result, allowedPosition - topOfFirstRubyTextLine); |
| 1535 } else { | 1539 } else { |
| 1536 LayoutUnit bottomOfLastRubyTextLine = rubyText->logicalTop() + (
rubyText->lastRootBox() ? rubyText->lastRootBox()->lineBottom() : rubyText->logi
calHeight()); | 1540 LayoutUnit bottomOfLastRubyTextLine = rubyText->logicalTop() + (
rubyText->lastRootBox() ? rubyText->lastRootBox()->lineBottom() : rubyText->logi
calHeight()); |
| 1537 if (bottomOfLastRubyTextLine <= curr->logicalHeight()) | 1541 if (bottomOfLastRubyTextLine <= curr->logicalHeight()) |
| 1538 continue; | 1542 continue; |
| 1539 bottomOfLastRubyTextLine += curr->logicalTop(); | 1543 bottomOfLastRubyTextLine += curr->logicalTop(); |
| 1540 result = max(result, bottomOfLastRubyTextLine - allowedPosition)
; | 1544 result = max(result, bottomOfLastRubyTextLine - allowedPosition)
; |
| 1541 } | 1545 } |
| 1542 } | 1546 } |
| 1543 | 1547 |
| 1544 if (curr->isInlineTextBox()) { | 1548 if (curr->isInlineTextBox()) { |
| 1545 RenderStyle* style = curr->renderer()->style(isFirstLineStyle()); | 1549 RenderStyle* style = curr->renderer().style(isFirstLineStyle()); |
| 1546 if (style->textEmphasisMark() != TextEmphasisMarkNone && style->text
EmphasisPosition() == TextEmphasisPositionUnder) { | 1550 if (style->textEmphasisMark() != TextEmphasisMarkNone && style->text
EmphasisPosition() == TextEmphasisPositionUnder) { |
| 1547 if (!style->isFlippedLinesWritingMode()) { | 1551 if (!style->isFlippedLinesWritingMode()) { |
| 1548 LayoutUnit bottomOfEmphasisMark = curr->logicalBottom() + st
yle->font().emphasisMarkHeight(style->textEmphasisMarkString()); | 1552 LayoutUnit bottomOfEmphasisMark = curr->logicalBottom() + st
yle->font().emphasisMarkHeight(style->textEmphasisMarkString()); |
| 1549 result = max(result, bottomOfEmphasisMark - allowedPosition)
; | 1553 result = max(result, bottomOfEmphasisMark - allowedPosition)
; |
| 1550 } else { | 1554 } else { |
| 1551 LayoutUnit topOfEmphasisMark = curr->logicalTop() - style->f
ont().emphasisMarkHeight(style->textEmphasisMarkString()); | 1555 LayoutUnit topOfEmphasisMark = curr->logicalTop() - style->f
ont().emphasisMarkHeight(style->textEmphasisMarkString()); |
| 1552 result = max(result, allowedPosition - topOfEmphasisMark); | 1556 result = max(result, allowedPosition - topOfEmphasisMark); |
| 1553 } | 1557 } |
| 1554 } | 1558 } |
| 1555 } | 1559 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1566 unsigned char minLevel = 128; | 1570 unsigned char minLevel = 128; |
| 1567 unsigned char maxLevel = 0; | 1571 unsigned char maxLevel = 0; |
| 1568 | 1572 |
| 1569 // First find highest and lowest levels, and initialize leafBoxesInLogicalOr
der with the leaf boxes in visual order. | 1573 // First find highest and lowest levels, and initialize leafBoxesInLogicalOr
der with the leaf boxes in visual order. |
| 1570 for (; leaf; leaf = leaf->nextLeafChild()) { | 1574 for (; leaf; leaf = leaf->nextLeafChild()) { |
| 1571 minLevel = min(minLevel, leaf->bidiLevel()); | 1575 minLevel = min(minLevel, leaf->bidiLevel()); |
| 1572 maxLevel = max(maxLevel, leaf->bidiLevel()); | 1576 maxLevel = max(maxLevel, leaf->bidiLevel()); |
| 1573 leafBoxesInLogicalOrder.append(leaf); | 1577 leafBoxesInLogicalOrder.append(leaf); |
| 1574 } | 1578 } |
| 1575 | 1579 |
| 1576 if (renderer()->style()->rtlOrdering() == VisualOrder) | 1580 if (renderer().style()->rtlOrdering() == VisualOrder) |
| 1577 return; | 1581 return; |
| 1578 | 1582 |
| 1579 // Reverse of reordering of the line (L2 according to Bidi spec): | 1583 // Reverse of reordering of the line (L2 according to Bidi spec): |
| 1580 // L2. From the highest level found in the text to the lowest odd level on e
ach line, | 1584 // L2. From the highest level found in the text to the lowest odd level on e
ach line, |
| 1581 // reverse any contiguous sequence of characters that are at that level or h
igher. | 1585 // reverse any contiguous sequence of characters that are at that level or h
igher. |
| 1582 | 1586 |
| 1583 // Reversing the reordering of the line is only done up to the lowest odd le
vel. | 1587 // Reversing the reordering of the line is only done up to the lowest odd le
vel. |
| 1584 if (!(minLevel % 2)) | 1588 if (!(minLevel % 2)) |
| 1585 ++minLevel; | 1589 ++minLevel; |
| 1586 | 1590 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1634 ASSERT(child->prevOnLine() == prev); | 1638 ASSERT(child->prevOnLine() == prev); |
| 1635 prev = child; | 1639 prev = child; |
| 1636 } | 1640 } |
| 1637 ASSERT(prev == m_lastChild); | 1641 ASSERT(prev == m_lastChild); |
| 1638 #endif | 1642 #endif |
| 1639 } | 1643 } |
| 1640 | 1644 |
| 1641 #endif | 1645 #endif |
| 1642 | 1646 |
| 1643 } // namespace WebCore | 1647 } // namespace WebCore |
| OLD | NEW |