Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ight reserved. | 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ight reserved. |
| 4 * Copyright (C) 2010 Google Inc. All rights reserved. | 4 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 static bool parentIsConstructedOrHaveNext(InlineFlowBox* parentBox) | 75 static bool parentIsConstructedOrHaveNext(InlineFlowBox* parentBox) |
| 76 { | 76 { |
| 77 do { | 77 do { |
| 78 if (parentBox->isConstructed() || parentBox->nextOnLine()) | 78 if (parentBox->isConstructed() || parentBox->nextOnLine()) |
| 79 return true; | 79 return true; |
| 80 parentBox = parentBox->parent(); | 80 parentBox = parentBox->parent(); |
| 81 } while (parentBox); | 81 } while (parentBox); |
| 82 return false; | 82 return false; |
| 83 } | 83 } |
| 84 | 84 |
| 85 InlineFlowBox* RenderBlockFlow::createLineBoxes(RenderObject* obj, const LineInf o& lineInfo, InlineBox* childBox) | 85 InlineFlowBox* RenderParagraph::createLineBoxes(RenderObject* obj, const LineInf o& lineInfo, InlineBox* childBox) |
| 86 { | 86 { |
| 87 // See if we have an unconstructed line box for this object that is also | 87 // See if we have an unconstructed line box for this object that is also |
| 88 // the last item on the line. | 88 // the last item on the line. |
| 89 unsigned lineDepth = 1; | 89 unsigned lineDepth = 1; |
| 90 InlineFlowBox* parentBox = 0; | 90 InlineFlowBox* parentBox = 0; |
| 91 InlineFlowBox* result = 0; | 91 InlineFlowBox* result = 0; |
| 92 bool hasDefaultLineBoxContain = style()->lineBoxContain() == RenderStyle::in itialLineBoxContain(); | 92 bool hasDefaultLineBoxContain = style()->lineBoxContain() == RenderStyle::in itialLineBoxContain(); |
| 93 do { | 93 do { |
| 94 ASSERT_WITH_SECURITY_IMPLICATION(obj->isRenderInline() || obj == this); | 94 ASSERT_WITH_SECURITY_IMPLICATION(obj->isRenderInline() || obj == this); |
| 95 | 95 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 RenderText* renderText = toRenderText(r); | 166 RenderText* renderText = toRenderText(r); |
| 167 unsigned length = renderText->textLength(); | 167 unsigned length = renderText->textLength(); |
| 168 if (pos >= length) | 168 if (pos >= length) |
| 169 return true; | 169 return true; |
| 170 | 170 |
| 171 if (renderText->is8Bit()) | 171 if (renderText->is8Bit()) |
| 172 return endsWithASCIISpaces(renderText->characters8(), pos, length); | 172 return endsWithASCIISpaces(renderText->characters8(), pos, length); |
| 173 return endsWithASCIISpaces(renderText->characters16(), pos, length); | 173 return endsWithASCIISpaces(renderText->characters16(), pos, length); |
| 174 } | 174 } |
| 175 | 175 |
| 176 RootInlineBox* RenderBlockFlow::constructLine(BidiRunList<BidiRun>& bidiRuns, co nst LineInfo& lineInfo) | 176 RootInlineBox* RenderParagraph::constructLine(BidiRunList<BidiRun>& bidiRuns, co nst LineInfo& lineInfo) |
| 177 { | 177 { |
| 178 ASSERT(bidiRuns.firstRun()); | 178 ASSERT(bidiRuns.firstRun()); |
| 179 | 179 |
| 180 bool rootHasSelectedChildren = false; | 180 bool rootHasSelectedChildren = false; |
| 181 InlineFlowBox* parentBox = 0; | 181 InlineFlowBox* parentBox = 0; |
| 182 int runCount = bidiRuns.runCount() - lineInfo.runsFromLeadingWhitespace(); | 182 int runCount = bidiRuns.runCount() - lineInfo.runsFromLeadingWhitespace(); |
| 183 for (BidiRun* r = bidiRuns.firstRun(); r; r = r->next()) { | 183 for (BidiRun* r = bidiRuns.firstRun(); r; r = r->next()) { |
| 184 // Create a box for our object. | 184 // Create a box for our object. |
| 185 bool isOnlyRun = (runCount == 1); | 185 bool isOnlyRun = (runCount == 1); |
| 186 if (runCount == 2) | 186 if (runCount == 2) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 bool isLogicallyLastRunWrapped = bidiRuns.logicallyLastRun()->m_object && bi diRuns.logicallyLastRun()->m_object->isText() ? !reachedEndOfTextRenderer(bidiRu ns) : true; | 237 bool isLogicallyLastRunWrapped = bidiRuns.logicallyLastRun()->m_object && bi diRuns.logicallyLastRun()->m_object->isText() ? !reachedEndOfTextRenderer(bidiRu ns) : true; |
| 238 lastLineBox()->determineSpacingForFlowBoxes(lineInfo.isLastLine(), isLogical lyLastRunWrapped, bidiRuns.logicallyLastRun()->m_object); | 238 lastLineBox()->determineSpacingForFlowBoxes(lineInfo.isLastLine(), isLogical lyLastRunWrapped, bidiRuns.logicallyLastRun()->m_object); |
| 239 | 239 |
| 240 // Now mark the line boxes as being constructed. | 240 // Now mark the line boxes as being constructed. |
| 241 lastLineBox()->setConstructed(); | 241 lastLineBox()->setConstructed(); |
| 242 | 242 |
| 243 // Return the last line. | 243 // Return the last line. |
| 244 return lastRootBox(); | 244 return lastRootBox(); |
| 245 } | 245 } |
| 246 | 246 |
| 247 ETextAlign RenderBlockFlow::textAlignmentForLine(bool endsWithSoftBreak) const | 247 ETextAlign RenderParagraph::textAlignmentForLine(bool endsWithSoftBreak) const |
| 248 { | 248 { |
| 249 ETextAlign alignment = style()->textAlign(); | 249 ETextAlign alignment = style()->textAlign(); |
| 250 if (endsWithSoftBreak) | 250 if (endsWithSoftBreak) |
| 251 return alignment; | 251 return alignment; |
| 252 | 252 |
| 253 if (!RuntimeEnabledFeatures::css3TextEnabled()) | 253 if (!RuntimeEnabledFeatures::css3TextEnabled()) |
| 254 return (alignment == JUSTIFY) ? TASTART : alignment; | 254 return (alignment == JUSTIFY) ? TASTART : alignment; |
| 255 | 255 |
| 256 if (alignment != JUSTIFY) | 256 if (alignment != JUSTIFY) |
| 257 return alignment; | 257 return alignment; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 272 return JUSTIFY; | 272 return JUSTIFY; |
| 273 case TextAlignLastAuto: | 273 case TextAlignLastAuto: |
| 274 if (style()->textJustify() == TextJustifyDistribute) | 274 if (style()->textJustify() == TextJustifyDistribute) |
| 275 return JUSTIFY; | 275 return JUSTIFY; |
| 276 return TASTART; | 276 return TASTART; |
| 277 } | 277 } |
| 278 | 278 |
| 279 return alignment; | 279 return alignment; |
| 280 } | 280 } |
| 281 | 281 |
| 282 // Moved to RenderBlockFlow | |
| 282 static void updateLogicalWidthForLeftAlignedBlock(bool isLeftToRightDirection, B idiRun* trailingSpaceRun, float& logicalLeft, float& totalLogicalWidth, float av ailableLogicalWidth) | 283 static void updateLogicalWidthForLeftAlignedBlock(bool isLeftToRightDirection, B idiRun* trailingSpaceRun, float& logicalLeft, float& totalLogicalWidth, float av ailableLogicalWidth) |
| 283 { | 284 { |
| 284 // The direction of the block should determine what happens with wide lines. | 285 // The direction of the block should determine what happens with wide lines. |
| 285 // In particular with RTL blocks, wide lines should still spill out to the l eft. | 286 // In particular with RTL blocks, wide lines should still spill out to the l eft. |
| 286 if (isLeftToRightDirection) { | 287 if (isLeftToRightDirection) { |
| 287 if (totalLogicalWidth > availableLogicalWidth && trailingSpaceRun) | 288 if (totalLogicalWidth > availableLogicalWidth && trailingSpaceRun) |
| 288 trailingSpaceRun->m_box->setLogicalWidth(std::max<float>(0, trailing SpaceRun->m_box->logicalWidth() - totalLogicalWidth + availableLogicalWidth)); | 289 trailingSpaceRun->m_box->setLogicalWidth(std::max<float>(0, trailing SpaceRun->m_box->logicalWidth() - totalLogicalWidth + availableLogicalWidth)); |
| 289 return; | 290 return; |
| 290 } | 291 } |
| 291 | 292 |
| 292 if (trailingSpaceRun) | 293 if (trailingSpaceRun) |
| 293 trailingSpaceRun->m_box->setLogicalWidth(0); | 294 trailingSpaceRun->m_box->setLogicalWidth(0); |
| 294 else if (totalLogicalWidth > availableLogicalWidth) | 295 else if (totalLogicalWidth > availableLogicalWidth) |
| 295 logicalLeft -= (totalLogicalWidth - availableLogicalWidth); | 296 logicalLeft -= (totalLogicalWidth - availableLogicalWidth); |
| 296 } | 297 } |
| 297 | 298 |
| 299 // Moved to RenderBlockFlow | |
| 298 static void updateLogicalWidthForRightAlignedBlock(bool isLeftToRightDirection, BidiRun* trailingSpaceRun, float& logicalLeft, float& totalLogicalWidth, float a vailableLogicalWidth) | 300 static void updateLogicalWidthForRightAlignedBlock(bool isLeftToRightDirection, BidiRun* trailingSpaceRun, float& logicalLeft, float& totalLogicalWidth, float a vailableLogicalWidth) |
| 299 { | 301 { |
| 300 // Wide lines spill out of the block based off direction. | 302 // Wide lines spill out of the block based off direction. |
| 301 // So even if text-align is right, if direction is LTR, wide lines should ov erflow out of the right | 303 // So even if text-align is right, if direction is LTR, wide lines should ov erflow out of the right |
| 302 // side of the block. | 304 // side of the block. |
| 303 if (isLeftToRightDirection) { | 305 if (isLeftToRightDirection) { |
| 304 if (trailingSpaceRun) { | 306 if (trailingSpaceRun) { |
| 305 totalLogicalWidth -= trailingSpaceRun->m_box->logicalWidth(); | 307 totalLogicalWidth -= trailingSpaceRun->m_box->logicalWidth(); |
| 306 trailingSpaceRun->m_box->setLogicalWidth(0); | 308 trailingSpaceRun->m_box->setLogicalWidth(0); |
| 307 } | 309 } |
| 308 if (totalLogicalWidth < availableLogicalWidth) | 310 if (totalLogicalWidth < availableLogicalWidth) |
| 309 logicalLeft += availableLogicalWidth - totalLogicalWidth; | 311 logicalLeft += availableLogicalWidth - totalLogicalWidth; |
| 310 return; | 312 return; |
| 311 } | 313 } |
| 312 | 314 |
| 313 if (totalLogicalWidth > availableLogicalWidth && trailingSpaceRun) { | 315 if (totalLogicalWidth > availableLogicalWidth && trailingSpaceRun) { |
| 314 trailingSpaceRun->m_box->setLogicalWidth(std::max<float>(0, trailingSpac eRun->m_box->logicalWidth() - totalLogicalWidth + availableLogicalWidth)); | 316 trailingSpaceRun->m_box->setLogicalWidth(std::max<float>(0, trailingSpac eRun->m_box->logicalWidth() - totalLogicalWidth + availableLogicalWidth)); |
| 315 totalLogicalWidth -= trailingSpaceRun->m_box->logicalWidth(); | 317 totalLogicalWidth -= trailingSpaceRun->m_box->logicalWidth(); |
| 316 } else | 318 } else |
| 317 logicalLeft += availableLogicalWidth - totalLogicalWidth; | 319 logicalLeft += availableLogicalWidth - totalLogicalWidth; |
| 318 } | 320 } |
| 319 | 321 |
| 322 // Moved to RenderBlockFlow | |
| 320 static void updateLogicalWidthForCenterAlignedBlock(bool isLeftToRightDirection, BidiRun* trailingSpaceRun, float& logicalLeft, float& totalLogicalWidth, float availableLogicalWidth) | 323 static void updateLogicalWidthForCenterAlignedBlock(bool isLeftToRightDirection, BidiRun* trailingSpaceRun, float& logicalLeft, float& totalLogicalWidth, float availableLogicalWidth) |
| 321 { | 324 { |
| 322 float trailingSpaceWidth = 0; | 325 float trailingSpaceWidth = 0; |
| 323 if (trailingSpaceRun) { | 326 if (trailingSpaceRun) { |
| 324 totalLogicalWidth -= trailingSpaceRun->m_box->logicalWidth(); | 327 totalLogicalWidth -= trailingSpaceRun->m_box->logicalWidth(); |
| 325 trailingSpaceWidth = std::min(trailingSpaceRun->m_box->logicalWidth(), ( availableLogicalWidth - totalLogicalWidth + 1) / 2); | 328 trailingSpaceWidth = std::min(trailingSpaceRun->m_box->logicalWidth(), ( availableLogicalWidth - totalLogicalWidth + 1) / 2); |
| 326 trailingSpaceRun->m_box->setLogicalWidth(std::max<float>(0, trailingSpac eWidth)); | 329 trailingSpaceRun->m_box->setLogicalWidth(std::max<float>(0, trailingSpac eWidth)); |
| 327 } | 330 } |
| 328 if (isLeftToRightDirection) | 331 if (isLeftToRightDirection) |
| 329 logicalLeft += std::max<float>((availableLogicalWidth - totalLogicalWidt h) / 2, 0); | 332 logicalLeft += std::max<float>((availableLogicalWidth - totalLogicalWidt h) / 2, 0); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 437 textBox->setExpansion(expansion); | 440 textBox->setExpansion(expansion); |
| 438 totalLogicalWidth += expansion; | 441 totalLogicalWidth += expansion; |
| 439 } | 442 } |
| 440 expansionOpportunityCount -= opportunitiesInRun; | 443 expansionOpportunityCount -= opportunitiesInRun; |
| 441 if (!expansionOpportunityCount) | 444 if (!expansionOpportunityCount) |
| 442 break; | 445 break; |
| 443 } | 446 } |
| 444 } | 447 } |
| 445 } | 448 } |
| 446 | 449 |
| 450 // Moved to RenderBlockFlow | |
| 447 void RenderBlockFlow::updateLogicalWidthForAlignment(const ETextAlign& textAlign , const RootInlineBox* rootInlineBox, BidiRun* trailingSpaceRun, float& logicalL eft, float& totalLogicalWidth, float& availableLogicalWidth, unsigned expansionO pportunityCount) | 451 void RenderBlockFlow::updateLogicalWidthForAlignment(const ETextAlign& textAlign , const RootInlineBox* rootInlineBox, BidiRun* trailingSpaceRun, float& logicalL eft, float& totalLogicalWidth, float& availableLogicalWidth, unsigned expansionO pportunityCount) |
| 448 { | 452 { |
| 449 TextDirection direction; | 453 TextDirection direction; |
| 450 if (rootInlineBox && rootInlineBox->renderer().style()->unicodeBidi() == Pla intext) | 454 if (rootInlineBox && rootInlineBox->renderer().style()->unicodeBidi() == Pla intext) |
| 451 direction = rootInlineBox->direction(); | 455 direction = rootInlineBox->direction(); |
| 452 else | 456 else |
| 453 direction = style()->direction(); | 457 direction = style()->direction(); |
| 454 | 458 |
| 455 // Armed with the total width of the line (without justification), | 459 // Armed with the total width of the line (without justification), |
| 456 // we now examine our text-align property in order to determine where to pos ition the | 460 // we now examine our text-align property in order to determine where to pos ition the |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 484 break; | 488 break; |
| 485 case TAEND: | 489 case TAEND: |
| 486 if (direction == LTR) | 490 if (direction == LTR) |
| 487 updateLogicalWidthForRightAlignedBlock(style()->isLeftToRightDirecti on(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth); | 491 updateLogicalWidthForRightAlignedBlock(style()->isLeftToRightDirecti on(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth); |
| 488 else | 492 else |
| 489 updateLogicalWidthForLeftAlignedBlock(style()->isLeftToRightDirectio n(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth); | 493 updateLogicalWidthForLeftAlignedBlock(style()->isLeftToRightDirectio n(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth); |
| 490 break; | 494 break; |
| 491 } | 495 } |
| 492 } | 496 } |
| 493 | 497 |
| 494 static void updateLogicalInlinePositions(RenderBlockFlow* block, float& lineLogi calLeft, float& lineLogicalRight, float& availableLogicalWidth, IndentTextOrNot shouldIndentText) | 498 static void updateLogicalInlinePositions(RenderParagraph* block, float& lineLogi calLeft, float& lineLogicalRight, float& availableLogicalWidth, IndentTextOrNot shouldIndentText) |
| 495 { | 499 { |
| 496 lineLogicalLeft = block->logicalLeftOffsetForLine(shouldIndentText == Indent Text).toFloat(); | 500 lineLogicalLeft = block->logicalLeftOffsetForLine(shouldIndentText == Indent Text).toFloat(); |
| 497 lineLogicalRight = block->logicalRightOffsetForLine(shouldIndentText == Inde ntText).toFloat(); | 501 lineLogicalRight = block->logicalRightOffsetForLine(shouldIndentText == Inde ntText).toFloat(); |
| 498 availableLogicalWidth = lineLogicalRight - lineLogicalLeft; | 502 availableLogicalWidth = lineLogicalRight - lineLogicalLeft; |
| 499 } | 503 } |
| 500 | 504 |
| 501 void RenderBlockFlow::computeInlineDirectionPositionsForLine(RootInlineBox* line Box, const LineInfo& lineInfo, BidiRun* firstRun, BidiRun* trailingSpaceRun, boo l reachedEnd, | 505 void RenderParagraph::computeInlineDirectionPositionsForLine(RootInlineBox* line Box, const LineInfo& lineInfo, BidiRun* firstRun, BidiRun* trailingSpaceRun, boo l reachedEnd, |
| 502 GlyphOverflowAndFallbac kFontsMap& textBoxDataMap, VerticalPositionCache& verticalPositionCache, WordMea surements& wordMeasurements) | 506 GlyphOverflowAndFallbac kFontsMap& textBoxDataMap, VerticalPositionCache& verticalPositionCache, WordMea surements& wordMeasurements) |
| 503 { | 507 { |
| 504 ETextAlign textAlign = textAlignmentForLine(!reachedEnd && !lineBox->endsWit hBreak()); | 508 ETextAlign textAlign = textAlignmentForLine(!reachedEnd && !lineBox->endsWit hBreak()); |
| 505 | 509 |
| 506 // CSS 2.1: "'Text-indent' only affects a line if it is the first formatted line of an element. For example, the first line of an anonymous block | 510 // CSS 2.1: "'Text-indent' only affects a line if it is the first formatted line of an element. For example, the first line of an anonymous block |
| 507 // box is only affected if it is the first child of its parent element." | 511 // box is only affected if it is the first child of its parent element." |
| 508 // CSS3 "text-indent", "each-line" affects the first line of the block conta iner as well as each line after a forced line break, | 512 // CSS3 "text-indent", "each-line" affects the first line of the block conta iner as well as each line after a forced line break, |
| 509 // but does not affect lines after a soft wrap break. | 513 // but does not affect lines after a soft wrap break. |
| 510 bool isFirstLine = lineInfo.isFirstLine() && !(isAnonymousBlock() && parent( )->slowFirstChild() != this); | 514 bool isFirstLine = lineInfo.isFirstLine() && !(isAnonymousBlock() && parent( )->slowFirstChild() != this); |
| 511 bool isAfterHardLineBreak = lineBox->prevRootBox() && lineBox->prevRootBox() ->endsWithBreak(); | 515 bool isAfterHardLineBreak = lineBox->prevRootBox() && lineBox->prevRootBox() ->endsWithBreak(); |
| 512 IndentTextOrNot shouldIndentText = requiresIndent(isFirstLine, isAfterHardLi neBreak, style()); | 516 IndentTextOrNot shouldIndentText = requiresIndent(isFirstLine, isAfterHardLi neBreak, style()); |
| 513 float lineLogicalLeft; | 517 float lineLogicalLeft; |
| 514 float lineLogicalRight; | 518 float lineLogicalRight; |
| 515 float availableLogicalWidth; | 519 float availableLogicalWidth; |
| 516 updateLogicalInlinePositions(this, lineLogicalLeft, lineLogicalRight, availa bleLogicalWidth, shouldIndentText); | 520 updateLogicalInlinePositions(this, lineLogicalLeft, lineLogicalRight, availa bleLogicalWidth, shouldIndentText); |
| 517 bool needsWordSpacing; | 521 bool needsWordSpacing; |
| 518 | 522 |
| 519 if (firstRun && firstRun->m_object->isReplaced()) | 523 if (firstRun && firstRun->m_object->isReplaced()) |
| 520 updateLogicalInlinePositions(this, lineLogicalLeft, lineLogicalRight, av ailableLogicalWidth, shouldIndentText); | 524 updateLogicalInlinePositions(this, lineLogicalLeft, lineLogicalRight, av ailableLogicalWidth, shouldIndentText); |
| 521 | 525 |
| 522 computeInlineDirectionPositionsForSegment(lineBox, lineInfo, textAlign, line LogicalLeft, availableLogicalWidth, firstRun, trailingSpaceRun, textBoxDataMap, verticalPositionCache, wordMeasurements); | 526 computeInlineDirectionPositionsForSegment(lineBox, lineInfo, textAlign, line LogicalLeft, availableLogicalWidth, firstRun, trailingSpaceRun, textBoxDataMap, verticalPositionCache, wordMeasurements); |
| 523 // The widths of all runs are now known. We can now place every inline box ( and | 527 // The widths of all runs are now known. We can now place every inline box ( and |
| 524 // compute accurate widths for the inline flow boxes). | 528 // compute accurate widths for the inline flow boxes). |
| 525 needsWordSpacing = false; | 529 needsWordSpacing = false; |
| 526 lineBox->placeBoxesInInlineDirection(lineLogicalLeft, needsWordSpacing); | 530 lineBox->placeBoxesInInlineDirection(lineLogicalLeft, needsWordSpacing); |
| 527 } | 531 } |
| 528 | 532 |
| 529 BidiRun* RenderBlockFlow::computeInlineDirectionPositionsForSegment(RootInlineBo x* lineBox, const LineInfo& lineInfo, ETextAlign textAlign, float& logicalLeft, | 533 BidiRun* RenderParagraph::computeInlineDirectionPositionsForSegment(RootInlineBo x* lineBox, const LineInfo& lineInfo, ETextAlign textAlign, float& logicalLeft, |
| 530 float& availableLogicalWidth, BidiRun* firstRun, BidiRun* trailingSpaceRun, GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache& vertica lPositionCache, | 534 float& availableLogicalWidth, BidiRun* firstRun, BidiRun* trailingSpaceRun, GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache& vertica lPositionCache, |
| 531 WordMeasurements& wordMeasurements) | 535 WordMeasurements& wordMeasurements) |
| 532 { | 536 { |
| 533 bool needsWordSpacing = true; | 537 bool needsWordSpacing = true; |
| 534 float totalLogicalWidth = lineBox->getFlowSpacingLogicalWidth().toFloat(); | 538 float totalLogicalWidth = lineBox->getFlowSpacingLogicalWidth().toFloat(); |
| 535 unsigned expansionOpportunityCount = 0; | 539 unsigned expansionOpportunityCount = 0; |
| 536 bool isAfterExpansion = true; | 540 bool isAfterExpansion = true; |
| 537 Vector<unsigned, 16> expansionOpportunities; | 541 Vector<unsigned, 16> expansionOpportunities; |
| 538 RenderObject* previousObject = 0; | 542 RenderObject* previousObject = 0; |
| 539 TextJustify textJustify = style()->textJustify(); | 543 TextJustify textJustify = style()->textJustify(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 583 expansionOpportunityCount--; | 587 expansionOpportunityCount--; |
| 584 } | 588 } |
| 585 | 589 |
| 586 updateLogicalWidthForAlignment(textAlign, lineBox, trailingSpaceRun, logical Left, totalLogicalWidth, availableLogicalWidth, expansionOpportunityCount); | 590 updateLogicalWidthForAlignment(textAlign, lineBox, trailingSpaceRun, logical Left, totalLogicalWidth, availableLogicalWidth, expansionOpportunityCount); |
| 587 | 591 |
| 588 computeExpansionForJustifiedText(firstRun, trailingSpaceRun, expansionOpport unities, expansionOpportunityCount, totalLogicalWidth, availableLogicalWidth); | 592 computeExpansionForJustifiedText(firstRun, trailingSpaceRun, expansionOpport unities, expansionOpportunityCount, totalLogicalWidth, availableLogicalWidth); |
| 589 | 593 |
| 590 return r; | 594 return r; |
| 591 } | 595 } |
| 592 | 596 |
| 593 void RenderBlockFlow::computeBlockDirectionPositionsForLine(RootInlineBox* lineB ox, BidiRun* firstRun, GlyphOverflowAndFallbackFontsMap& textBoxDataMap, | 597 void RenderParagraph::computeBlockDirectionPositionsForLine(RootInlineBox* lineB ox, BidiRun* firstRun, GlyphOverflowAndFallbackFontsMap& textBoxDataMap, |
| 594 VerticalPositionCache& v erticalPositionCache) | 598 VerticalPositionCache& v erticalPositionCache) |
| 595 { | 599 { |
| 596 setLogicalHeight(lineBox->alignBoxesInBlockDirection(logicalHeight(), textBo xDataMap, verticalPositionCache)); | 600 setLogicalHeight(lineBox->alignBoxesInBlockDirection(logicalHeight(), textBo xDataMap, verticalPositionCache)); |
| 597 | 601 |
| 598 // Now make sure we place replaced render objects correctly. | 602 // Now make sure we place replaced render objects correctly. |
| 599 for (BidiRun* r = firstRun; r; r = r->next()) { | 603 for (BidiRun* r = firstRun; r; r = r->next()) { |
| 600 ASSERT(r->m_box); | 604 ASSERT(r->m_box); |
| 601 if (!r->m_box) | 605 if (!r->m_box) |
| 602 continue; // Skip runs with no line boxes. | 606 continue; // Skip runs with no line boxes. |
| 603 | 607 |
| 604 // Align positioned boxes with the top of the line box. This is | 608 // Align positioned boxes with the top of the line box. This is |
| 605 // a reasonable approximation of an appropriate y position. | 609 // a reasonable approximation of an appropriate y position. |
| 606 if (r->m_object->isOutOfFlowPositioned()) | 610 if (r->m_object->isOutOfFlowPositioned()) |
| 607 r->m_box->setLogicalTop(logicalHeight().toFloat()); | 611 r->m_box->setLogicalTop(logicalHeight().toFloat()); |
| 608 | 612 |
| 609 // Position is used to properly position both replaced elements and | 613 // Position is used to properly position both replaced elements and |
| 610 // to update the static normal flow x/y of positioned elements. | 614 // to update the static normal flow x/y of positioned elements. |
| 611 if (r->m_object->isText()) | 615 if (r->m_object->isText()) |
| 612 toRenderText(r->m_object)->positionLineBox(r->m_box); | 616 toRenderText(r->m_object)->positionLineBox(r->m_box); |
| 613 else if (r->m_object->isBox()) | 617 else if (r->m_object->isBox()) |
| 614 toRenderBox(r->m_object)->positionLineBox(r->m_box); | 618 toRenderBox(r->m_object)->positionLineBox(r->m_box); |
| 615 } | 619 } |
| 616 } | 620 } |
| 617 | 621 |
| 618 // This function constructs line boxes for all of the text runs in the resolver and computes their position. | 622 // This function constructs line boxes for all of the text runs in the resolver and computes their position. |
| 619 RootInlineBox* RenderBlockFlow::createLineBoxesFromBidiRuns(unsigned bidiLevel, BidiRunList<BidiRun>& bidiRuns, const InlineIterator& end, LineInfo& lineInfo, V erticalPositionCache& verticalPositionCache, BidiRun* trailingSpaceRun, WordMeas urements& wordMeasurements) | 623 RootInlineBox* RenderParagraph::createLineBoxesFromBidiRuns(unsigned bidiLevel, BidiRunList<BidiRun>& bidiRuns, const InlineIterator& end, LineInfo& lineInfo, V erticalPositionCache& verticalPositionCache, BidiRun* trailingSpaceRun, WordMeas urements& wordMeasurements) |
| 620 { | 624 { |
| 621 if (!bidiRuns.runCount()) | 625 if (!bidiRuns.runCount()) |
| 622 return 0; | 626 return 0; |
| 623 | 627 |
| 624 // FIXME: Why is this only done when we had runs? | 628 // FIXME: Why is this only done when we had runs? |
| 625 lineInfo.setLastLine(!end.object()); | 629 lineInfo.setLastLine(!end.object()); |
| 626 | 630 |
| 627 RootInlineBox* lineBox = constructLine(bidiRuns, lineInfo); | 631 RootInlineBox* lineBox = constructLine(bidiRuns, lineInfo); |
| 628 if (!lineBox) | 632 if (!lineBox) |
| 629 return 0; | 633 return 0; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 651 while (boxToDelete && boxToDelete != stopLine) { | 655 while (boxToDelete && boxToDelete != stopLine) { |
| 652 layoutState.updatePaintInvalidationRangeFromBox(boxToDelete); | 656 layoutState.updatePaintInvalidationRangeFromBox(boxToDelete); |
| 653 // Note: deleteLineRange(firstRootBox()) is not identical to deleteLineB oxTree(). | 657 // Note: deleteLineRange(firstRootBox()) is not identical to deleteLineB oxTree(). |
| 654 // deleteLineBoxTree uses nextLineBox() instead of nextRootBox() when tr aversing. | 658 // deleteLineBoxTree uses nextLineBox() instead of nextRootBox() when tr aversing. |
| 655 RootInlineBox* next = boxToDelete->nextRootBox(); | 659 RootInlineBox* next = boxToDelete->nextRootBox(); |
| 656 boxToDelete->deleteLine(); | 660 boxToDelete->deleteLine(); |
| 657 boxToDelete = next; | 661 boxToDelete = next; |
| 658 } | 662 } |
| 659 } | 663 } |
| 660 | 664 |
| 661 void RenderBlockFlow::layoutRunsAndFloats(LineLayoutState& layoutState) | 665 void RenderParagraph::layoutRunsAndFloats(LineLayoutState& layoutState) |
| 662 { | 666 { |
| 663 // We want to skip ahead to the first dirty line | 667 // We want to skip ahead to the first dirty line |
| 664 InlineBidiResolver resolver; | 668 InlineBidiResolver resolver; |
| 665 RootInlineBox* startLine = determineStartPosition(layoutState, resolver); | 669 RootInlineBox* startLine = determineStartPosition(layoutState, resolver); |
| 666 | 670 |
| 667 // We also find the first clean line and extract these lines. We will add t hem back | 671 // We also find the first clean line and extract these lines. We will add t hem back |
| 668 // if we determine that we're able to synchronize after handling all our dir ty lines. | 672 // if we determine that we're able to synchronize after handling all our dir ty lines. |
| 669 InlineIterator cleanLineStart; | 673 InlineIterator cleanLineStart; |
| 670 BidiStatus cleanLineBidiStatus; | 674 BidiStatus cleanLineBidiStatus; |
| 671 if (!layoutState.isFullLayout() && startLine) | 675 if (!layoutState.isFullLayout() && startLine) |
| 672 determineEndPosition(layoutState, startLine, cleanLineStart, cleanLineBi diStatus); | 676 determineEndPosition(layoutState, startLine, cleanLineStart, cleanLineBi diStatus); |
| 673 | 677 |
| 674 if (startLine) { | 678 if (startLine) { |
| 675 if (!layoutState.usesPaintInvalidationBounds()) | 679 if (!layoutState.usesPaintInvalidationBounds()) |
| 676 layoutState.setPaintInvalidationRange(logicalHeight()); | 680 layoutState.setPaintInvalidationRange(logicalHeight()); |
| 677 deleteLineRange(layoutState, startLine); | 681 deleteLineRange(layoutState, startLine); |
| 678 } | 682 } |
| 679 | 683 |
| 680 layoutRunsAndFloatsInRange(layoutState, resolver, cleanLineStart, cleanLineB idiStatus); | 684 layoutRunsAndFloatsInRange(layoutState, resolver, cleanLineStart, cleanLineB idiStatus); |
| 681 linkToEndLineIfNeeded(layoutState); | 685 linkToEndLineIfNeeded(layoutState); |
| 682 markDirtyFloatsForPaintInvalidation(layoutState.floats()); | 686 markDirtyFloatsForPaintInvalidation(layoutState.floats()); |
| 683 } | 687 } |
| 684 | 688 |
| 685 // Before restarting the layout loop with a new logicalHeight, remove all floats that were added and reset the resolver. | 689 void RenderParagraph::layoutRunsAndFloatsInRange(LineLayoutState& layoutState, |
| 686 inline const InlineIterator& RenderBlockFlow::restartLayoutRunsAndFloatsInRange( LayoutUnit oldLogicalHeight, LayoutUnit newLogicalHeight, FloatingObject* lastF loatFromPreviousLine, InlineBidiResolver& resolver, const InlineIterator& oldEn d) | |
|
rafaelw
2014/11/27 19:22:16
dead code
| |
| 687 { | |
| 688 setLogicalHeight(newLogicalHeight); | |
| 689 resolver.setPositionIgnoringNestedIsolates(oldEnd); | |
| 690 return oldEnd; | |
| 691 } | |
| 692 | |
| 693 void RenderBlockFlow::layoutRunsAndFloatsInRange(LineLayoutState& layoutState, | |
| 694 InlineBidiResolver& resolver, const InlineIterator& cleanLineStart, | 690 InlineBidiResolver& resolver, const InlineIterator& cleanLineStart, |
| 695 const BidiStatus& cleanLineBidiStatus) | 691 const BidiStatus& cleanLineBidiStatus) |
| 696 { | 692 { |
| 697 RenderStyle* styleToUse = style(); | 693 RenderStyle* styleToUse = style(); |
| 698 LineMidpointState& lineMidpointState = resolver.midpointState(); | 694 LineMidpointState& lineMidpointState = resolver.midpointState(); |
| 699 InlineIterator endOfLine = resolver.position(); | 695 InlineIterator endOfLine = resolver.position(); |
| 700 bool checkForEndLineMatch = layoutState.endLine(); | 696 bool checkForEndLineMatch = layoutState.endLine(); |
| 701 RenderTextInfo renderTextInfo; | 697 RenderTextInfo renderTextInfo; |
| 702 VerticalPositionCache verticalPositionCache; | 698 VerticalPositionCache verticalPositionCache; |
| 703 | 699 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 777 setStaticPositions(this, lineBreaker.positionedObjects()[i]); | 773 setStaticPositions(this, lineBreaker.positionedObjects()[i]); |
| 778 | 774 |
| 779 if (!layoutState.lineInfo().isEmpty()) | 775 if (!layoutState.lineInfo().isEmpty()) |
| 780 layoutState.lineInfo().setFirstLine(false); | 776 layoutState.lineInfo().setFirstLine(false); |
| 781 | 777 |
| 782 lineMidpointState.reset(); | 778 lineMidpointState.reset(); |
| 783 resolver.setPosition(endOfLine, numberOfIsolateAncestors(endOfLine)); | 779 resolver.setPosition(endOfLine, numberOfIsolateAncestors(endOfLine)); |
| 784 } | 780 } |
| 785 } | 781 } |
| 786 | 782 |
| 787 void RenderBlockFlow::linkToEndLineIfNeeded(LineLayoutState& layoutState) | 783 void RenderParagraph::linkToEndLineIfNeeded(LineLayoutState& layoutState) |
| 788 { | 784 { |
| 789 if (layoutState.endLine()) { | 785 if (layoutState.endLine()) { |
| 790 if (layoutState.endLineMatched()) { | 786 if (layoutState.endLineMatched()) { |
| 791 // Attach all the remaining lines, and then adjust their y-positions as needed. | 787 // Attach all the remaining lines, and then adjust their y-positions as needed. |
| 792 LayoutUnit delta = logicalHeight() - layoutState.endLineLogicalTop() ; | 788 LayoutUnit delta = logicalHeight() - layoutState.endLineLogicalTop() ; |
| 793 for (RootInlineBox* line = layoutState.endLine(); line; line = line- >nextRootBox()) { | 789 for (RootInlineBox* line = layoutState.endLine(); line; line = line- >nextRootBox()) { |
| 794 line->attachLine(); | 790 line->attachLine(); |
| 795 if (delta) { | 791 if (delta) { |
| 796 layoutState.updatePaintInvalidationRangeFromBox(line, delta) ; | 792 layoutState.updatePaintInvalidationRangeFromBox(line, delta) ; |
| 797 line->adjustBlockDirectionPosition(delta.toFloat()); | 793 line->adjustBlockDirectionPosition(delta.toFloat()); |
| 798 } | 794 } |
| 799 } | 795 } |
| 800 setLogicalHeight(lastRootBox()->lineBottomWithLeading()); | 796 setLogicalHeight(lastRootBox()->lineBottomWithLeading()); |
| 801 } else { | 797 } else { |
| 802 // Delete all the remaining lines. | 798 // Delete all the remaining lines. |
| 803 deleteLineRange(layoutState, layoutState.endLine()); | 799 deleteLineRange(layoutState, layoutState.endLine()); |
| 804 } | 800 } |
| 805 } | 801 } |
| 806 } | 802 } |
| 807 | 803 |
| 808 void RenderBlockFlow::markDirtyFloatsForPaintInvalidation(Vector<FloatWithRect>& floats) | 804 void RenderParagraph::markDirtyFloatsForPaintInvalidation(Vector<FloatWithRect>& floats) |
| 809 { | 805 { |
| 810 size_t floatCount = floats.size(); | 806 size_t floatCount = floats.size(); |
| 811 // Floats that did not have layout did not paint invalidations when we laid them out. They would have | 807 // Floats that did not have layout did not paint invalidations when we laid them out. They would have |
| 812 // painted by now if they had moved, but if they stayed at (0, 0), they stil l need to be | 808 // painted by now if they had moved, but if they stayed at (0, 0), they stil l need to be |
| 813 // painted. | 809 // painted. |
| 814 for (size_t i = 0; i < floatCount; ++i) { | 810 for (size_t i = 0; i < floatCount; ++i) { |
| 815 if (!floats[i].everHadLayout) { | 811 if (!floats[i].everHadLayout) { |
| 816 RenderBox* f = floats[i].object; | 812 RenderBox* f = floats[i].object; |
| 817 if (!f->x() && !f->y() && f->checkForPaintInvalidation()) { | 813 if (!f->x() && !f->y() && f->checkForPaintInvalidation()) { |
| 818 f->setShouldDoFullPaintInvalidation(true); | 814 f->setShouldDoFullPaintInvalidation(true); |
| 819 } | 815 } |
| 820 } | 816 } |
| 821 } | 817 } |
| 822 } | 818 } |
| 823 | 819 |
| 824 struct InlineMinMaxIterator { | 820 struct InlineMinMaxIterator { |
| 825 /* InlineMinMaxIterator is a class that will iterate over all render objects tha t contribute to | 821 /* InlineMinMaxIterator is a class that will iterate over all render objects tha t contribute to |
| 826 inline min/max width calculations. Note the following about the way it walks : | 822 inline min/max width calculations. Note the following about the way it walks : |
| 827 (1) Positioned content is skipped (since it does not contribute to min/max wi dth of a block) | 823 (1) Positioned content is skipped (since it does not contribute to min/max wi dth of a block) |
| 828 (2) We do not drill into the children of floats or replaced elements, since y ou can't break | 824 (2) We do not drill into the children of floats or replaced elements, since y ou can't break |
| 829 in the middle of such an element. | 825 in the middle of such an element. |
| 830 (3) Inline flows (e.g., <a>, <span>, <i>) are walked twice, since each side c an have | 826 (3) Inline flows (e.g., <a>, <span>, <i>) are walked twice, since each side c an have |
| 831 distinct borders/margin/padding that contribute to the min/max width. | 827 distinct borders/margin/padding that contribute to the min/max width. |
| 832 */ | 828 */ |
| 833 RenderObject* parent; | 829 RenderObject* parent; |
| 834 RenderObject* current; | 830 RenderObject* current; |
| 835 bool endOfInline; | 831 bool endOfInline; |
| 836 | 832 |
| 837 InlineMinMaxIterator(RenderObject* p, bool end = false) | 833 InlineMinMaxIterator(RenderObject* p) |
| 838 : parent(p), current(p), endOfInline(end) | 834 : parent(p), current(p), endOfInline(false) |
| 839 { | 835 { |
| 840 | 836 |
| 841 } | 837 } |
| 842 | 838 |
| 843 RenderObject* next(); | 839 RenderObject* next(); |
| 844 }; | 840 }; |
| 845 | 841 |
| 846 RenderObject* InlineMinMaxIterator::next() | 842 RenderObject* InlineMinMaxIterator::next() |
| 847 { | 843 { |
| 848 RenderObject* result = 0; | 844 RenderObject* result = 0; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 932 // with each conversion. When this occurs while accumulating our preferred width s, | 928 // with each conversion. When this occurs while accumulating our preferred width s, |
| 933 // we can wind up with a line width that's larger than our maxPreferredWidth due to | 929 // we can wind up with a line width that's larger than our maxPreferredWidth due to |
| 934 // pure float accumulation. | 930 // pure float accumulation. |
| 935 static inline LayoutUnit adjustFloatForSubPixelLayout(float value) | 931 static inline LayoutUnit adjustFloatForSubPixelLayout(float value) |
| 936 { | 932 { |
| 937 return LayoutUnit::fromFloatCeil(value); | 933 return LayoutUnit::fromFloatCeil(value); |
| 938 } | 934 } |
| 939 | 935 |
| 940 // FIXME: This function should be broken into something less monolithic. | 936 // FIXME: This function should be broken into something less monolithic. |
| 941 // FIXME: The main loop here is very similar to LineBreaker::nextSegmentBreak. T hey can probably reuse code. | 937 // FIXME: The main loop here is very similar to LineBreaker::nextSegmentBreak. T hey can probably reuse code. |
| 942 void RenderBlockFlow::computeInlinePreferredLogicalWidths(LayoutUnit& minLogical Width, LayoutUnit& maxLogicalWidth) | 938 void RenderParagraph::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const |
| 943 { | 939 { |
| 944 float inlineMax = 0; | 940 float inlineMax = 0; |
| 945 float inlineMin = 0; | 941 float inlineMin = 0; |
| 946 | 942 |
| 947 RenderStyle* styleToUse = style(); | 943 RenderStyle* styleToUse = style(); |
| 948 RenderBlock* containingBlock = this->containingBlock(); | 944 RenderBlock* containingBlock = this->containingBlock(); |
| 949 LayoutUnit cw = containingBlock ? containingBlock->contentLogicalWidth() : L ayoutUnit(); | 945 LayoutUnit cw = containingBlock ? containingBlock->contentLogicalWidth() : L ayoutUnit(); |
| 950 | 946 |
| 951 // If we are at the start of a line, we want to ignore all white-space. | 947 // If we are at the start of a line, we want to ignore all white-space. |
| 952 // Also strip spaces if we previously had text that ended in a trailing spac e. | 948 // Also strip spaces if we previously had text that ended in a trailing spac e. |
| 953 bool stripFrontSpaces = true; | 949 bool stripFrontSpaces = true; |
| 954 RenderObject* trailingSpaceChild = 0; | 950 RenderObject* trailingSpaceChild = 0; |
| 955 | 951 |
| 956 bool autoWrap, oldAutoWrap; | 952 bool autoWrap, oldAutoWrap; |
| 957 autoWrap = oldAutoWrap = styleToUse->autoWrap(); | 953 autoWrap = oldAutoWrap = styleToUse->autoWrap(); |
| 958 | 954 |
| 959 InlineMinMaxIterator childIterator(this); | 955 InlineMinMaxIterator childIterator(const_cast<RenderParagraph*>(this)); |
| 960 | 956 |
| 961 // Only gets added to the max preffered width once. | 957 // Only gets added to the max preffered width once. |
| 962 bool addedTextIndent = false; | 958 bool addedTextIndent = false; |
| 963 // Signals the text indent was more negative than the min preferred width | 959 // Signals the text indent was more negative than the min preferred width |
| 964 bool hasRemainingNegativeTextIndent = false; | 960 bool hasRemainingNegativeTextIndent = false; |
| 965 | 961 |
| 966 LayoutUnit textIndent = minimumValueForLength(styleToUse->textIndent(), cw); | 962 LayoutUnit textIndent = minimumValueForLength(styleToUse->textIndent(), cw); |
| 967 bool isPrevChildInlineFlow = false; | 963 bool isPrevChildInlineFlow = false; |
| 968 bool shouldBreakLineAfterText = false; | 964 bool shouldBreakLineAfterText = false; |
| 969 while (RenderObject* child = childIterator.next()) { | 965 while (RenderObject* child = childIterator.next()) { |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1183 isPrevChildInlineFlow = false; | 1179 isPrevChildInlineFlow = false; |
| 1184 | 1180 |
| 1185 oldAutoWrap = autoWrap; | 1181 oldAutoWrap = autoWrap; |
| 1186 } | 1182 } |
| 1187 | 1183 |
| 1188 if (styleToUse->collapseWhiteSpace()) | 1184 if (styleToUse->collapseWhiteSpace()) |
| 1189 stripTrailingSpace(inlineMax, inlineMin, trailingSpaceChild); | 1185 stripTrailingSpace(inlineMax, inlineMin, trailingSpaceChild); |
| 1190 | 1186 |
| 1191 updatePreferredWidth(minLogicalWidth, inlineMin); | 1187 updatePreferredWidth(minLogicalWidth, inlineMin); |
| 1192 updatePreferredWidth(maxLogicalWidth, inlineMax); | 1188 updatePreferredWidth(maxLogicalWidth, inlineMax); |
| 1189 | |
| 1190 maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth); | |
| 1193 } | 1191 } |
| 1194 | 1192 |
| 1195 void RenderBlockFlow::layoutInlineChildren(bool relayoutChildren, LayoutUnit& pa intInvalidationLogicalTop, LayoutUnit& paintInvalidationLogicalBottom, LayoutUni t afterEdge) | 1193 void RenderParagraph::layoutChildren(bool relayoutChildren, SubtreeLayoutScope& layoutScope, LayoutUnit& paintInvalidationLogicalTop, LayoutUnit& paintInvalidat ionLogicalBottom, LayoutUnit beforeEdge, LayoutUnit afterEdge) |
| 1196 { | 1194 { |
| 1197 // Figure out if we should clear out our line boxes. | 1195 // Figure out if we should clear out our line boxes. |
| 1198 // FIXME: Handle resize eventually! | 1196 // FIXME: Handle resize eventually! |
| 1199 bool isFullLayout = !firstLineBox() || selfNeedsLayout() || relayoutChildren ; | 1197 bool isFullLayout = !firstLineBox() || selfNeedsLayout() || relayoutChildren ; |
| 1200 LineLayoutState layoutState(isFullLayout, paintInvalidationLogicalTop, paint InvalidationLogicalBottom); | 1198 LineLayoutState layoutState(isFullLayout, paintInvalidationLogicalTop, paint InvalidationLogicalBottom); |
| 1201 | 1199 |
| 1202 if (isFullLayout) { | 1200 if (isFullLayout) { |
| 1203 // Ensure the old line boxes will be erased. | 1201 // Ensure the old line boxes will be erased. |
| 1204 if (firstLineBox()) | 1202 if (firstLineBox()) |
| 1205 setShouldDoFullPaintInvalidation(true); | 1203 setShouldDoFullPaintInvalidation(true); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1278 // See if we have any lines that spill out of our block. If we do, then we will possibly need to | 1276 // See if we have any lines that spill out of our block. If we do, then we will possibly need to |
| 1279 // truncate text. | 1277 // truncate text. |
| 1280 if (hasTextOverflow) | 1278 if (hasTextOverflow) |
| 1281 checkLinesForTextOverflow(); | 1279 checkLinesForTextOverflow(); |
| 1282 | 1280 |
| 1283 // Ensure the new line boxes will be painted. | 1281 // Ensure the new line boxes will be painted. |
| 1284 if (isFullLayout && firstLineBox()) | 1282 if (isFullLayout && firstLineBox()) |
| 1285 setShouldDoFullPaintInvalidation(true); | 1283 setShouldDoFullPaintInvalidation(true); |
| 1286 } | 1284 } |
| 1287 | 1285 |
| 1288 void RenderBlockFlow::checkFloatsInCleanLine(RootInlineBox* line, Vector<FloatWi thRect>& floats, size_t& floatIndex, bool& encounteredNewFloat, bool& dirtiedByF loat) | 1286 void RenderParagraph::checkFloatsInCleanLine(RootInlineBox* line, Vector<FloatWi thRect>& floats, size_t& floatIndex, bool& encounteredNewFloat, bool& dirtiedByF loat) |
| 1289 { | 1287 { |
| 1290 Vector<RenderBox*>* cleanLineFloats = line->floatsPtr(); | 1288 Vector<RenderBox*>* cleanLineFloats = line->floatsPtr(); |
| 1291 if (!cleanLineFloats) | 1289 if (!cleanLineFloats) |
| 1292 return; | 1290 return; |
| 1293 | 1291 |
| 1294 Vector<RenderBox*>::iterator end = cleanLineFloats->end(); | 1292 Vector<RenderBox*>::iterator end = cleanLineFloats->end(); |
| 1295 for (Vector<RenderBox*>::iterator it = cleanLineFloats->begin(); it != end; ++it) { | 1293 for (Vector<RenderBox*>::iterator it = cleanLineFloats->begin(); it != end; ++it) { |
| 1296 RenderBox* floatingBox = *it; | 1294 RenderBox* floatingBox = *it; |
| 1297 floatingBox->layoutIfNeeded(); | 1295 floatingBox->layoutIfNeeded(); |
| 1298 LayoutSize newSize(floatingBox->width() + floatingBox->marginWidth(), fl oatingBox->height() + floatingBox->marginHeight()); | 1296 LayoutSize newSize(floatingBox->width() + floatingBox->marginWidth(), fl oatingBox->height() + floatingBox->marginHeight()); |
| 1299 if (floats[floatIndex].object != floatingBox) { | 1297 if (floats[floatIndex].object != floatingBox) { |
| 1300 encounteredNewFloat = true; | 1298 encounteredNewFloat = true; |
| 1301 return; | 1299 return; |
| 1302 } | 1300 } |
| 1303 | 1301 |
| 1304 if (floats[floatIndex].rect.size() != newSize) { | 1302 if (floats[floatIndex].rect.size() != newSize) { |
| 1305 LayoutUnit floatTop = floats[floatIndex].rect.y(); | 1303 LayoutUnit floatTop = floats[floatIndex].rect.y(); |
| 1306 LayoutUnit floatHeight = std::max(floats[floatIndex].rect.height(), newSize.height()); | 1304 LayoutUnit floatHeight = std::max(floats[floatIndex].rect.height(), newSize.height()); |
| 1307 floatHeight = std::min(floatHeight, LayoutUnit::max() - floatTop); | 1305 floatHeight = std::min(floatHeight, LayoutUnit::max() - floatTop); |
| 1308 line->markDirty(); | 1306 line->markDirty(); |
| 1309 markLinesDirtyInBlockRange(line->lineBottomWithLeading(), floatTop + floatHeight, line); | 1307 markLinesDirtyInBlockRange(line->lineBottomWithLeading(), floatTop + floatHeight, line); |
| 1310 floats[floatIndex].rect.setSize(newSize); | 1308 floats[floatIndex].rect.setSize(newSize); |
| 1311 dirtiedByFloat = true; | 1309 dirtiedByFloat = true; |
| 1312 } | 1310 } |
| 1313 floatIndex++; | 1311 floatIndex++; |
| 1314 } | 1312 } |
| 1315 } | 1313 } |
| 1316 | 1314 |
| 1317 RootInlineBox* RenderBlockFlow::determineStartPosition(LineLayoutState& layoutSt ate, InlineBidiResolver& resolver) | 1315 RootInlineBox* RenderParagraph::determineStartPosition(LineLayoutState& layoutSt ate, InlineBidiResolver& resolver) |
| 1318 { | 1316 { |
| 1319 RootInlineBox* curr = 0; | 1317 RootInlineBox* curr = 0; |
| 1320 RootInlineBox* last = 0; | 1318 RootInlineBox* last = 0; |
| 1321 | 1319 |
| 1322 // FIXME: This entire float-checking block needs to be broken into a new fun ction. | 1320 // FIXME: This entire float-checking block needs to be broken into a new fun ction. |
| 1323 bool dirtiedByFloat = false; | 1321 bool dirtiedByFloat = false; |
| 1324 if (!layoutState.isFullLayout()) { | 1322 if (!layoutState.isFullLayout()) { |
| 1325 size_t floatIndex = 0; | 1323 size_t floatIndex = 0; |
| 1326 for (curr = firstRootBox(); curr && !curr->isDirty(); curr = curr->nextR ootBox()) { | 1324 for (curr = firstRootBox(); curr && !curr->isDirty(); curr = curr->nextR ootBox()) { |
| 1327 // If a new float has been inserted before this line or before its l ast known float, just do a full layout. | 1325 // If a new float has been inserted before this line or before its l ast known float, just do a full layout. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1388 TextDirection direction = style()->direction(); | 1386 TextDirection direction = style()->direction(); |
| 1389 if (style()->unicodeBidi() == Plaintext) | 1387 if (style()->unicodeBidi() == Plaintext) |
| 1390 direction = determinePlaintextDirectionality(this); | 1388 direction = determinePlaintextDirectionality(this); |
| 1391 resolver.setStatus(BidiStatus(direction, isOverride(style()->unicodeBidi ()))); | 1389 resolver.setStatus(BidiStatus(direction, isOverride(style()->unicodeBidi ()))); |
| 1392 InlineIterator iter = InlineIterator(this, bidiFirstSkippingEmptyInlines (this, resolver.runs(), &resolver), 0); | 1390 InlineIterator iter = InlineIterator(this, bidiFirstSkippingEmptyInlines (this, resolver.runs(), &resolver), 0); |
| 1393 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); | 1391 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); |
| 1394 } | 1392 } |
| 1395 return curr; | 1393 return curr; |
| 1396 } | 1394 } |
| 1397 | 1395 |
| 1398 void RenderBlockFlow::determineEndPosition(LineLayoutState& layoutState, RootInl ineBox* startLine, InlineIterator& cleanLineStart, BidiStatus& cleanLineBidiStat us) | 1396 void RenderParagraph::determineEndPosition(LineLayoutState& layoutState, RootInl ineBox* startLine, InlineIterator& cleanLineStart, BidiStatus& cleanLineBidiStat us) |
| 1399 { | 1397 { |
| 1400 ASSERT(!layoutState.endLine()); | 1398 ASSERT(!layoutState.endLine()); |
| 1401 size_t floatIndex = layoutState.floatIndex(); | 1399 size_t floatIndex = layoutState.floatIndex(); |
| 1402 RootInlineBox* last = 0; | 1400 RootInlineBox* last = 0; |
| 1403 for (RootInlineBox* curr = startLine->nextRootBox(); curr; curr = curr->next RootBox()) { | 1401 for (RootInlineBox* curr = startLine->nextRootBox(); curr; curr = curr->next RootBox()) { |
| 1404 if (!curr->isDirty()) { | 1402 if (!curr->isDirty()) { |
| 1405 bool encounteredNewFloat = false; | 1403 bool encounteredNewFloat = false; |
| 1406 bool dirtiedByFloat = false; | 1404 bool dirtiedByFloat = false; |
| 1407 checkFloatsInCleanLine(curr, layoutState.floats(), floatIndex, encou nteredNewFloat, dirtiedByFloat); | 1405 checkFloatsInCleanLine(curr, layoutState.floats(), floatIndex, encou nteredNewFloat, dirtiedByFloat); |
| 1408 if (encounteredNewFloat) | 1406 if (encounteredNewFloat) |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1425 cleanLineBidiStatus = prev->lineBreakBidiStatus(); | 1423 cleanLineBidiStatus = prev->lineBreakBidiStatus(); |
| 1426 layoutState.setEndLineLogicalTop(prev->lineBottomWithLeading()); | 1424 layoutState.setEndLineLogicalTop(prev->lineBottomWithLeading()); |
| 1427 | 1425 |
| 1428 for (RootInlineBox* line = last; line; line = line->nextRootBox()) | 1426 for (RootInlineBox* line = last; line; line = line->nextRootBox()) |
| 1429 line->extractLine(); // Disconnect all line boxes from their render obje cts while preserving | 1427 line->extractLine(); // Disconnect all line boxes from their render obje cts while preserving |
| 1430 // their connections to one another. | 1428 // their connections to one another. |
| 1431 | 1429 |
| 1432 layoutState.setEndLine(last); | 1430 layoutState.setEndLine(last); |
| 1433 } | 1431 } |
| 1434 | 1432 |
| 1435 bool RenderBlockFlow::checkPaginationAndFloatsAtEndLine(LineLayoutState& layoutS tate) | 1433 bool RenderParagraph::checkPaginationAndFloatsAtEndLine(LineLayoutState& layoutS tate) |
| 1436 { | 1434 { |
| 1437 // FIXME(sky): Remove this. | 1435 // FIXME(sky): Remove this. |
| 1438 return true; | 1436 return true; |
| 1439 } | 1437 } |
| 1440 | 1438 |
| 1441 bool RenderBlockFlow::matchedEndLine(LineLayoutState& layoutState, const InlineB idiResolver& resolver, const InlineIterator& endLineStart, const BidiStatus& end LineStatus) | 1439 bool RenderParagraph::matchedEndLine(LineLayoutState& layoutState, const InlineB idiResolver& resolver, const InlineIterator& endLineStart, const BidiStatus& end LineStatus) |
| 1442 { | 1440 { |
| 1443 if (resolver.position() == endLineStart) { | 1441 if (resolver.position() == endLineStart) { |
| 1444 if (resolver.status() != endLineStatus) | 1442 if (resolver.status() != endLineStatus) |
| 1445 return false; | 1443 return false; |
| 1446 return checkPaginationAndFloatsAtEndLine(layoutState); | 1444 return checkPaginationAndFloatsAtEndLine(layoutState); |
| 1447 } | 1445 } |
| 1448 | 1446 |
| 1449 // The first clean line doesn't match, but we can check a handful of followi ng lines to try | 1447 // The first clean line doesn't match, but we can check a handful of followi ng lines to try |
| 1450 // to match back up. | 1448 // to match back up. |
| 1451 static int numLines = 8; // The # of lines we're willing to match against. | 1449 static int numLines = 8; // The # of lines we're willing to match against. |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1467 | 1465 |
| 1468 // Now delete the lines that we failed to sync. | 1466 // Now delete the lines that we failed to sync. |
| 1469 deleteLineRange(layoutState, originalEndLine, result); | 1467 deleteLineRange(layoutState, originalEndLine, result); |
| 1470 return matched; | 1468 return matched; |
| 1471 } | 1469 } |
| 1472 } | 1470 } |
| 1473 | 1471 |
| 1474 return false; | 1472 return false; |
| 1475 } | 1473 } |
| 1476 | 1474 |
| 1477 bool RenderBlockFlow::generatesLineBoxesForInlineChild(RenderObject* inlineObj) | 1475 void RenderParagraph::deleteEllipsisLineBoxes() |
|
rafaelw
2014/11/27 19:22:16
dead code
| |
| 1478 | |
| 1479 { | |
| 1480 ASSERT(inlineObj->parent() == this); | |
| 1481 | |
| 1482 InlineIterator it(this, inlineObj, 0); | |
| 1483 // FIXME: We should pass correct value for WhitespacePosition. | |
| 1484 while (!it.atEnd() && !requiresLineBox(it)) | |
| 1485 it.increment(); | |
| 1486 | |
| 1487 return !it.atEnd(); | |
| 1488 } | |
| 1489 | |
| 1490 void RenderBlockFlow::deleteEllipsisLineBoxes() | |
| 1491 { | 1476 { |
| 1492 ETextAlign textAlign = style()->textAlign(); | 1477 ETextAlign textAlign = style()->textAlign(); |
| 1493 bool ltr = style()->isLeftToRightDirection(); | 1478 bool ltr = style()->isLeftToRightDirection(); |
| 1494 bool firstLine = true; | 1479 bool firstLine = true; |
| 1495 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { | 1480 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { |
| 1496 if (curr->hasEllipsisBox()) { | 1481 if (curr->hasEllipsisBox()) { |
| 1497 curr->clearTruncation(); | 1482 curr->clearTruncation(); |
| 1498 | 1483 |
| 1499 // Shift the line back where it belongs if we cannot accomodate an e llipsis. | 1484 // Shift the line back where it belongs if we cannot accomodate an e llipsis. |
| 1500 float logicalLeft = logicalLeftOffsetForLine(firstLine).toFloat(); | 1485 float logicalLeft = logicalLeftOffsetForLine(firstLine).toFloat(); |
| 1501 float availableLogicalWidth = logicalRightOffsetForLine(false) - log icalLeft; | 1486 float availableLogicalWidth = logicalRightOffsetForLine(false) - log icalLeft; |
| 1502 float totalLogicalWidth = curr->logicalWidth(); | 1487 float totalLogicalWidth = curr->logicalWidth(); |
| 1503 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, tota lLogicalWidth, availableLogicalWidth, 0); | 1488 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, tota lLogicalWidth, availableLogicalWidth, 0); |
| 1504 | 1489 |
| 1505 if (ltr) | 1490 if (ltr) |
| 1506 curr->adjustLogicalPosition((logicalLeft - curr->logicalLeft()), 0); | 1491 curr->adjustLogicalPosition((logicalLeft - curr->logicalLeft()), 0); |
| 1507 else | 1492 else |
| 1508 curr->adjustLogicalPosition(-(curr->logicalLeft() - logicalLeft) , 0); | 1493 curr->adjustLogicalPosition(-(curr->logicalLeft() - logicalLeft) , 0); |
| 1509 } | 1494 } |
| 1510 firstLine = false; | 1495 firstLine = false; |
| 1511 } | 1496 } |
| 1512 } | 1497 } |
| 1513 | 1498 |
| 1514 void RenderBlockFlow::checkLinesForTextOverflow() | 1499 void RenderParagraph::checkLinesForTextOverflow() |
| 1515 { | 1500 { |
| 1516 // Determine the width of the ellipsis using the current font. | 1501 // Determine the width of the ellipsis using the current font. |
| 1517 // FIXME: CSS3 says this is configurable, also need to use 0x002E (FULL STOP ) if horizontal ellipsis is "not renderable" | 1502 // FIXME: CSS3 says this is configurable, also need to use 0x002E (FULL STOP ) if horizontal ellipsis is "not renderable" |
| 1518 const Font& font = style()->font(); | 1503 const Font& font = style()->font(); |
| 1519 DEFINE_STATIC_LOCAL(AtomicString, ellipsisStr, (&horizontalEllipsis, 1)); | 1504 DEFINE_STATIC_LOCAL(AtomicString, ellipsisStr, (&horizontalEllipsis, 1)); |
| 1520 const Font& firstLineFont = firstLineStyle()->font(); | 1505 const Font& firstLineFont = firstLineStyle()->font(); |
| 1521 // FIXME: We should probably not hard-code the direction here. https://crbug .com/333004 | 1506 // FIXME: We should probably not hard-code the direction here. https://crbug .com/333004 |
| 1522 TextDirection ellipsisDirection = LTR; | 1507 TextDirection ellipsisDirection = LTR; |
| 1523 float firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, fi rstLineFont, &horizontalEllipsis, 1, firstLineStyle(), ellipsisDirection)); | 1508 float firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, fi rstLineFont, &horizontalEllipsis, 1, firstLineStyle(), ellipsisDirection)); |
| 1524 float ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : fon t.width(constructTextRun(this, font, &horizontalEllipsis, 1, style(), ellipsisDi rection)); | 1509 float ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : fon t.width(constructTextRun(this, font, &horizontalEllipsis, 1, style(), ellipsisDi rection)); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1571 float logicalLeft = logicalLeftOffsetForLine(false).toFloat(); | 1556 float logicalLeft = logicalLeftOffsetForLine(false).toFloat(); |
| 1572 float availableLogicalWidth = logicalRightOffsetForLine(false) - logicalLeft ; | 1557 float availableLogicalWidth = logicalRightOffsetForLine(false) - logicalLeft ; |
| 1573 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); | 1558 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); |
| 1574 | 1559 |
| 1575 if (!style()->isLeftToRightDirection()) | 1560 if (!style()->isLeftToRightDirection()) |
| 1576 return logicalWidth() - logicalLeft; | 1561 return logicalWidth() - logicalLeft; |
| 1577 return logicalLeft; | 1562 return logicalLeft; |
| 1578 } | 1563 } |
| 1579 | 1564 |
| 1580 } | 1565 } |
| OLD | NEW |