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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 return JUSTIFY; | 288 return JUSTIFY; |
| 289 case TextAlignLastAuto: | 289 case TextAlignLastAuto: |
| 290 if (alignment == JUSTIFY) | 290 if (alignment == JUSTIFY) |
| 291 return TASTART; | 291 return TASTART; |
| 292 return alignment; | 292 return alignment; |
| 293 } | 293 } |
| 294 | 294 |
| 295 return alignment; | 295 return alignment; |
| 296 } | 296 } |
| 297 | 297 |
| 298 static void updateLogicalWidthForLeftAlignedBlock(bool isLeftToRightDirection, B idiRun* trailingSpaceRun, float& logicalLeft, float& totalLogicalWidth, float av ailableLogicalWidth) | 298 static void updateLogicalWidthForLeftAlignedBlock(bool isLeftToRightDirection, B idiRun* trailingSpaceRun, LayoutUnit& logicalLeft, LayoutUnit totalLogicalWidth, LayoutUnit availableLogicalWidth) |
| 299 { | 299 { |
| 300 // The direction of the block should determine what happens with wide lines. | 300 // The direction of the block should determine what happens with wide lines. |
| 301 // In particular with RTL blocks, wide lines should still spill out to the l eft. | 301 // In particular with RTL blocks, wide lines should still spill out to the l eft. |
| 302 if (isLeftToRightDirection) { | 302 if (isLeftToRightDirection) { |
| 303 if (totalLogicalWidth > availableLogicalWidth && trailingSpaceRun) | 303 if (totalLogicalWidth > availableLogicalWidth && trailingSpaceRun) |
| 304 trailingSpaceRun->m_box->setLogicalWidth(std::max<float>(0, trailing SpaceRun->m_box->logicalWidth() - totalLogicalWidth + availableLogicalWidth)); | 304 trailingSpaceRun->m_box->setLogicalWidth(std::max(LayoutUnit(), trai lingSpaceRun->m_box->logicalWidth() - totalLogicalWidth + availableLogicalWidth) ); |
| 305 return; | 305 return; |
| 306 } | 306 } |
| 307 | 307 |
| 308 if (trailingSpaceRun) | 308 if (trailingSpaceRun) |
| 309 trailingSpaceRun->m_box->setLogicalWidth(0); | 309 trailingSpaceRun->m_box->setLogicalWidth(0); |
| 310 else if (totalLogicalWidth > availableLogicalWidth) | 310 else if (totalLogicalWidth > availableLogicalWidth) |
| 311 logicalLeft -= (totalLogicalWidth - availableLogicalWidth); | 311 logicalLeft -= (totalLogicalWidth - availableLogicalWidth); |
| 312 } | 312 } |
| 313 | 313 |
| 314 static void updateLogicalWidthForRightAlignedBlock(bool isLeftToRightDirection, BidiRun* trailingSpaceRun, float& logicalLeft, float& totalLogicalWidth, float a vailableLogicalWidth) | 314 static void updateLogicalWidthForRightAlignedBlock(bool isLeftToRightDirection, BidiRun* trailingSpaceRun, LayoutUnit& logicalLeft, LayoutUnit& totalLogicalWidt h, LayoutUnit availableLogicalWidth) |
| 315 { | 315 { |
| 316 // Wide lines spill out of the block based off direction. | 316 // Wide lines spill out of the block based off direction. |
| 317 // So even if text-align is right, if direction is LTR, wide lines should ov erflow out of the right | 317 // So even if text-align is right, if direction is LTR, wide lines should ov erflow out of the right |
| 318 // side of the block. | 318 // side of the block. |
| 319 if (isLeftToRightDirection) { | 319 if (isLeftToRightDirection) { |
| 320 if (trailingSpaceRun) { | 320 if (trailingSpaceRun) { |
| 321 totalLogicalWidth -= trailingSpaceRun->m_box->logicalWidth(); | 321 totalLogicalWidth -= trailingSpaceRun->m_box->logicalWidth(); |
| 322 trailingSpaceRun->m_box->setLogicalWidth(0); | 322 trailingSpaceRun->m_box->setLogicalWidth(0); |
| 323 } | 323 } |
| 324 if (totalLogicalWidth < availableLogicalWidth) | 324 if (totalLogicalWidth < availableLogicalWidth) |
| 325 logicalLeft += availableLogicalWidth - totalLogicalWidth; | 325 logicalLeft += availableLogicalWidth - totalLogicalWidth; |
| 326 return; | 326 return; |
| 327 } | 327 } |
| 328 | 328 |
| 329 if (totalLogicalWidth > availableLogicalWidth && trailingSpaceRun) { | 329 if (totalLogicalWidth > availableLogicalWidth && trailingSpaceRun) { |
| 330 trailingSpaceRun->m_box->setLogicalWidth(std::max<float>(0, trailingSpac eRun->m_box->logicalWidth() - totalLogicalWidth + availableLogicalWidth)); | 330 trailingSpaceRun->m_box->setLogicalWidth(std::max(LayoutUnit(), trailing SpaceRun->m_box->logicalWidth() - totalLogicalWidth + availableLogicalWidth)); |
| 331 totalLogicalWidth -= trailingSpaceRun->m_box->logicalWidth(); | 331 totalLogicalWidth -= trailingSpaceRun->m_box->logicalWidth(); |
| 332 } else { | 332 } else { |
| 333 logicalLeft += availableLogicalWidth - totalLogicalWidth; | 333 logicalLeft += availableLogicalWidth - totalLogicalWidth; |
| 334 } | 334 } |
| 335 } | 335 } |
| 336 | 336 |
| 337 static void updateLogicalWidthForCenterAlignedBlock(bool isLeftToRightDirection, BidiRun* trailingSpaceRun, float& logicalLeft, float& totalLogicalWidth, float availableLogicalWidth) | 337 static void updateLogicalWidthForCenterAlignedBlock(bool isLeftToRightDirection, BidiRun* trailingSpaceRun, LayoutUnit& logicalLeft, LayoutUnit& totalLogicalWid th, LayoutUnit availableLogicalWidth) |
| 338 { | 338 { |
| 339 float trailingSpaceWidth = 0; | 339 LayoutUnit trailingSpaceWidth; |
| 340 if (trailingSpaceRun) { | 340 if (trailingSpaceRun) { |
| 341 totalLogicalWidth -= trailingSpaceRun->m_box->logicalWidth(); | 341 totalLogicalWidth -= trailingSpaceRun->m_box->logicalWidth(); |
| 342 trailingSpaceWidth = std::min(trailingSpaceRun->m_box->logicalWidth().to Float(), (availableLogicalWidth - totalLogicalWidth + 1) / 2); | 342 trailingSpaceWidth = std::min(trailingSpaceRun->m_box->logicalWidth(), ( availableLogicalWidth - totalLogicalWidth + 1) / 2); |
| 343 trailingSpaceRun->m_box->setLogicalWidth(std::max<float>(0, trailingSpac eWidth)); | 343 trailingSpaceRun->m_box->setLogicalWidth(std::max(LayoutUnit(), trailing SpaceWidth)); |
| 344 } | 344 } |
| 345 if (isLeftToRightDirection) | 345 if (isLeftToRightDirection) |
| 346 logicalLeft += std::max<float>((availableLogicalWidth - totalLogicalWidt h) / 2, 0); | 346 logicalLeft += std::max((availableLogicalWidth - totalLogicalWidth) / 2, LayoutUnit()); |
| 347 else | 347 else |
| 348 logicalLeft += totalLogicalWidth > availableLogicalWidth ? (availableLog icalWidth - totalLogicalWidth) : (availableLogicalWidth - totalLogicalWidth) / 2 - trailingSpaceWidth; | 348 logicalLeft += totalLogicalWidth > availableLogicalWidth ? (availableLog icalWidth - totalLogicalWidth) : (availableLogicalWidth - totalLogicalWidth) / 2 - trailingSpaceWidth; |
| 349 } | 349 } |
| 350 | 350 |
| 351 void LayoutBlockFlow::setMarginsForRubyRun(BidiRun* run, LayoutRubyRun* layoutRu byRun, LayoutObject* previousObject, const LineInfo& lineInfo) | 351 void LayoutBlockFlow::setMarginsForRubyRun(BidiRun* run, LayoutRubyRun* layoutRu byRun, LayoutObject* previousObject, const LineInfo& lineInfo) |
| 352 { | 352 { |
| 353 int startOverhang; | 353 int startOverhang; |
| 354 int endOverhang; | 354 int endOverhang; |
| 355 LayoutObject* nextObject = 0; | 355 LayoutObject* nextObject = 0; |
| 356 for (BidiRun* runWithNextObject = run->next(); runWithNextObject; runWithNex tObject = runWithNextObject->next()) { | 356 for (BidiRun* runWithNextObject = run->next(); runWithNextObject; runWithNex tObject = runWithNextObject->next()) { |
| 357 if (!runWithNextObject->m_object->isOutOfFlowPositioned() && !runWithNex tObject->m_box->isLineBreak()) { | 357 if (!runWithNextObject->m_object->isOutOfFlowPositioned() && !runWithNex tObject->m_box->isLineBreak()) { |
| 358 nextObject = runWithNextObject->m_object; | 358 nextObject = runWithNextObject->m_object; |
| 359 break; | 359 break; |
| 360 } | 360 } |
| 361 } | 361 } |
| 362 layoutRubyRun->getOverhang(lineInfo.isFirstLine(), layoutRubyRun->style()->i sLeftToRightDirection() ? previousObject : nextObject, layoutRubyRun->style()->i sLeftToRightDirection() ? nextObject : previousObject, startOverhang, endOverhan g); | 362 layoutRubyRun->getOverhang(lineInfo.isFirstLine(), layoutRubyRun->style()->i sLeftToRightDirection() ? previousObject : nextObject, layoutRubyRun->style()->i sLeftToRightDirection() ? nextObject : previousObject, startOverhang, endOverhan g); |
| 363 setMarginStartForChild(*layoutRubyRun, -startOverhang); | 363 setMarginStartForChild(*layoutRubyRun, -startOverhang); |
| 364 setMarginEndForChild(*layoutRubyRun, -endOverhang); | 364 setMarginEndForChild(*layoutRubyRun, -endOverhang); |
| 365 } | 365 } |
| 366 | 366 |
| 367 static inline void setLogicalWidthForTextRun(RootInlineBox* lineBox, BidiRun* ru n, LayoutText* layoutText, float xPos, const LineInfo& lineInfo, | 367 static inline void setLogicalWidthForTextRun(RootInlineBox* lineBox, BidiRun* ru n, LayoutText* layoutText, LayoutUnit xPos, const LineInfo& lineInfo, |
| 368 GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache& ver ticalPositionCache, WordMeasurements& wordMeasurements) | 368 GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache& ver ticalPositionCache, WordMeasurements& wordMeasurements) |
| 369 { | 369 { |
| 370 HashSet<const SimpleFontData*> fallbackFonts; | 370 HashSet<const SimpleFontData*> fallbackFonts; |
| 371 GlyphOverflow glyphOverflow; | 371 GlyphOverflow glyphOverflow; |
| 372 | 372 |
| 373 const Font& font = layoutText->style(lineInfo.isFirstLine())->font(); | 373 const Font& font = layoutText->style(lineInfo.isFirstLine())->font(); |
| 374 // Always compute glyph overflow if the block's line-box-contain value is "g lyphs". | 374 // Always compute glyph overflow if the block's line-box-contain value is "g lyphs". |
| 375 if (lineBox->fitsToGlyphs()) { | 375 if (lineBox->fitsToGlyphs()) { |
| 376 // If we don't stick out of the root line's font box, then don't bother computing our glyph overflow. This optimization | 376 // If we don't stick out of the root line's font box, then don't bother computing our glyph overflow. This optimization |
| 377 // will keep us from computing glyph bounds in nearly all cases. | 377 // will keep us from computing glyph bounds in nearly all cases. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 452 run->m_box->parent()->clearDescendantsHaveSameLineHeightAndBaseline(); | 452 run->m_box->parent()->clearDescendantsHaveSameLineHeightAndBaseline(); |
| 453 } | 453 } |
| 454 if (!glyphOverflow.isZero()) { | 454 if (!glyphOverflow.isZero()) { |
| 455 ASSERT(run->m_box->isText()); | 455 ASSERT(run->m_box->isText()); |
| 456 GlyphOverflowAndFallbackFontsMap::ValueType* it = textBoxDataMap.add(toI nlineTextBox(run->m_box), std::make_pair(Vector<const SimpleFontData*>(), GlyphO verflow())).storedValue; | 456 GlyphOverflowAndFallbackFontsMap::ValueType* it = textBoxDataMap.add(toI nlineTextBox(run->m_box), std::make_pair(Vector<const SimpleFontData*>(), GlyphO verflow())).storedValue; |
| 457 it->value.second = glyphOverflow; | 457 it->value.second = glyphOverflow; |
| 458 run->m_box->clearKnownToHaveNoOverflow(); | 458 run->m_box->clearKnownToHaveNoOverflow(); |
| 459 } | 459 } |
| 460 } | 460 } |
| 461 | 461 |
| 462 static inline void computeExpansionForJustifiedText(BidiRun* firstRun, BidiRun* trailingSpaceRun, Vector<unsigned, 16>& expansionOpportunities, unsigned expansi onOpportunityCount, float& totalLogicalWidth, float availableLogicalWidth) | 462 static inline void computeExpansionForJustifiedText(BidiRun* firstRun, BidiRun* trailingSpaceRun, Vector<unsigned, 16>& expansionOpportunities, unsigned expansi onOpportunityCount, LayoutUnit& totalLogicalWidth, LayoutUnit availableLogicalWi dth) |
| 463 { | 463 { |
| 464 if (!expansionOpportunityCount || availableLogicalWidth <= totalLogicalWidth ) | 464 if (!expansionOpportunityCount || availableLogicalWidth <= totalLogicalWidth ) |
| 465 return; | 465 return; |
| 466 | 466 |
| 467 size_t i = 0; | 467 size_t i = 0; |
| 468 for (BidiRun* r = firstRun; r; r = r->next()) { | 468 for (BidiRun* r = firstRun; r; r = r->next()) { |
| 469 if (!r->m_box || r == trailingSpaceRun) | 469 if (!r->m_box || r == trailingSpaceRun) |
| 470 continue; | 470 continue; |
| 471 | 471 |
| 472 if (r->m_object->isText()) { | 472 if (r->m_object->isText()) { |
| 473 unsigned opportunitiesInRun = expansionOpportunities[i++]; | 473 unsigned opportunitiesInRun = expansionOpportunities[i++]; |
| 474 | 474 |
| 475 ASSERT(opportunitiesInRun <= expansionOpportunityCount); | 475 ASSERT(opportunitiesInRun <= expansionOpportunityCount); |
| 476 | 476 |
| 477 // Don't justify for white-space: pre. | 477 // Don't justify for white-space: pre. |
| 478 if (r->m_object->style()->whiteSpace() != PRE) { | 478 if (r->m_object->style()->whiteSpace() != PRE) { |
| 479 InlineTextBox* textBox = toInlineTextBox(r->m_box); | 479 InlineTextBox* textBox = toInlineTextBox(r->m_box); |
| 480 int expansion = (availableLogicalWidth - totalLogicalWidth) * op portunitiesInRun / expansionOpportunityCount; | 480 int expansion = (availableLogicalWidth - totalLogicalWidth) * op portunitiesInRun / expansionOpportunityCount; |
| 481 textBox->setExpansion(expansion); | 481 textBox->setExpansion(expansion); |
| 482 totalLogicalWidth += expansion; | 482 totalLogicalWidth += expansion; |
| 483 } | 483 } |
| 484 expansionOpportunityCount -= opportunitiesInRun; | 484 expansionOpportunityCount -= opportunitiesInRun; |
| 485 if (!expansionOpportunityCount) | 485 if (!expansionOpportunityCount) |
| 486 break; | 486 break; |
| 487 } | 487 } |
| 488 } | 488 } |
| 489 } | 489 } |
| 490 | 490 |
| 491 void LayoutBlockFlow::updateLogicalWidthForAlignment(const ETextAlign& textAlign , const RootInlineBox* rootInlineBox, BidiRun* trailingSpaceRun, float& logicalL eft, float& totalLogicalWidth, float& availableLogicalWidth, unsigned expansionO pportunityCount) | 491 void LayoutBlockFlow::updateLogicalWidthForAlignment(const ETextAlign& textAlign , const RootInlineBox* rootInlineBox, BidiRun* trailingSpaceRun, LayoutUnit& log icalLeft, LayoutUnit& totalLogicalWidth, LayoutUnit& availableLogicalWidth, unsi gned expansionOpportunityCount) |
| 492 { | 492 { |
| 493 TextDirection direction; | 493 TextDirection direction; |
| 494 if (rootInlineBox && rootInlineBox->layoutObject().style()->unicodeBidi() == Plaintext) | 494 if (rootInlineBox && rootInlineBox->layoutObject().style()->unicodeBidi() == Plaintext) |
| 495 direction = rootInlineBox->direction(); | 495 direction = rootInlineBox->direction(); |
| 496 else | 496 else |
| 497 direction = style()->direction(); | 497 direction = style()->direction(); |
| 498 | 498 |
| 499 // Armed with the total width of the line (without justification), | 499 // Armed with the total width of the line (without justification), |
| 500 // we now examine our text-align property in order to determine where to pos ition the | 500 // we now examine our text-align property in order to determine where to pos ition the |
| 501 // objects horizontally. The total width of the line can be increased if we end up | 501 // objects horizontally. The total width of the line can be increased if we end up |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 533 if (direction == LTR) | 533 if (direction == LTR) |
| 534 updateLogicalWidthForRightAlignedBlock(style()->isLeftToRightDirecti on(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth); | 534 updateLogicalWidthForRightAlignedBlock(style()->isLeftToRightDirecti on(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth); |
| 535 else | 535 else |
| 536 updateLogicalWidthForLeftAlignedBlock(style()->isLeftToRightDirectio n(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth); | 536 updateLogicalWidthForLeftAlignedBlock(style()->isLeftToRightDirectio n(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth); |
| 537 break; | 537 break; |
| 538 } | 538 } |
| 539 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) | 539 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
| 540 logicalLeft += verticalScrollbarWidth(); | 540 logicalLeft += verticalScrollbarWidth(); |
| 541 } | 541 } |
| 542 | 542 |
| 543 static void updateLogicalInlinePositions(LayoutBlockFlow* block, float& lineLogi calLeft, float& lineLogicalRight, float& availableLogicalWidth, bool firstLine, IndentTextOrNot shouldIndentText, LayoutUnit boxLogicalHeight) | 543 static void updateLogicalInlinePositions(LayoutBlockFlow* block, LayoutUnit& lin eLogicalLeft, LayoutUnit& lineLogicalRight, LayoutUnit& availableLogicalWidth, b ool firstLine, IndentTextOrNot shouldIndentText, LayoutUnit boxLogicalHeight) |
| 544 { | 544 { |
| 545 LayoutUnit lineLogicalHeight = block->minLineHeightForReplacedObject(firstLi ne, boxLogicalHeight); | 545 LayoutUnit lineLogicalHeight = block->minLineHeightForReplacedObject(firstLi ne, boxLogicalHeight); |
| 546 lineLogicalLeft = block->logicalLeftOffsetForLine(block->logicalHeight(), sh ouldIndentText == IndentText, lineLogicalHeight).toFloat(); | 546 lineLogicalLeft = block->logicalLeftOffsetForLine(block->logicalHeight(), sh ouldIndentText == IndentText, lineLogicalHeight); |
| 547 lineLogicalRight = block->logicalRightOffsetForLine(block->logicalHeight(), shouldIndentText == IndentText, lineLogicalHeight).toFloat(); | 547 lineLogicalRight = block->logicalRightOffsetForLine(block->logicalHeight(), shouldIndentText == IndentText, lineLogicalHeight); |
| 548 availableLogicalWidth = lineLogicalRight - lineLogicalLeft; | 548 availableLogicalWidth = lineLogicalRight - lineLogicalLeft; |
| 549 } | 549 } |
| 550 | 550 |
| 551 void LayoutBlockFlow::computeInlineDirectionPositionsForLine(RootInlineBox* line Box, const LineInfo& lineInfo, BidiRun* firstRun, BidiRun* trailingSpaceRun, boo l reachedEnd, | 551 void LayoutBlockFlow::computeInlineDirectionPositionsForLine(RootInlineBox* line Box, const LineInfo& lineInfo, BidiRun* firstRun, BidiRun* trailingSpaceRun, boo l reachedEnd, |
| 552 GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache& ver ticalPositionCache, WordMeasurements& wordMeasurements) | 552 GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache& ver ticalPositionCache, WordMeasurements& wordMeasurements) |
| 553 { | 553 { |
| 554 ETextAlign textAlign = textAlignmentForLine(!reachedEnd && !lineBox->endsWit hBreak()); | 554 ETextAlign textAlign = textAlignmentForLine(!reachedEnd && !lineBox->endsWit hBreak()); |
| 555 | 555 |
| 556 // 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 | 556 // 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 |
| 557 // box is only affected if it is the first child of its parent element." | 557 // box is only affected if it is the first child of its parent element." |
| 558 // CSS3 "text-indent", "each-line" affects the first line of the block conta iner as well as each line after a forced line break, | 558 // CSS3 "text-indent", "each-line" affects the first line of the block conta iner as well as each line after a forced line break, |
| 559 // but does not affect lines after a soft wrap break. | 559 // but does not affect lines after a soft wrap break. |
| 560 bool isFirstLine = lineInfo.isFirstLine() && !(isAnonymousBlock() && parent( )->slowFirstChild() != this); | 560 bool isFirstLine = lineInfo.isFirstLine() && !(isAnonymousBlock() && parent( )->slowFirstChild() != this); |
| 561 bool isAfterHardLineBreak = lineBox->prevRootBox() && lineBox->prevRootBox() ->endsWithBreak(); | 561 bool isAfterHardLineBreak = lineBox->prevRootBox() && lineBox->prevRootBox() ->endsWithBreak(); |
| 562 IndentTextOrNot shouldIndentText = requiresIndent(isFirstLine, isAfterHardLi neBreak, styleRef()); | 562 IndentTextOrNot shouldIndentText = requiresIndent(isFirstLine, isAfterHardLi neBreak, styleRef()); |
| 563 float lineLogicalLeft; | 563 LayoutUnit lineLogicalLeft; |
| 564 float lineLogicalRight; | 564 LayoutUnit lineLogicalRight; |
| 565 float availableLogicalWidth; | 565 LayoutUnit availableLogicalWidth; |
| 566 updateLogicalInlinePositions(this, lineLogicalLeft, lineLogicalRight, availa bleLogicalWidth, isFirstLine, shouldIndentText, 0); | 566 updateLogicalInlinePositions(this, lineLogicalLeft, lineLogicalRight, availa bleLogicalWidth, isFirstLine, shouldIndentText, 0); |
| 567 bool needsWordSpacing; | 567 bool needsWordSpacing; |
| 568 | 568 |
| 569 if (firstRun && firstRun->m_object->isReplaced()) { | 569 if (firstRun && firstRun->m_object->isReplaced()) { |
| 570 LayoutBox* layoutBox = toLayoutBox(firstRun->m_object); | 570 LayoutBox* layoutBox = toLayoutBox(firstRun->m_object); |
| 571 updateLogicalInlinePositions(this, lineLogicalLeft, lineLogicalRight, av ailableLogicalWidth, isFirstLine, shouldIndentText, layoutBox->logicalHeight()); | 571 updateLogicalInlinePositions(this, lineLogicalLeft, lineLogicalRight, av ailableLogicalWidth, isFirstLine, shouldIndentText, layoutBox->logicalHeight()); |
| 572 } | 572 } |
| 573 | 573 |
| 574 computeInlineDirectionPositionsForSegment(lineBox, lineInfo, textAlign, line LogicalLeft, availableLogicalWidth, firstRun, trailingSpaceRun, textBoxDataMap, verticalPositionCache, wordMeasurements); | 574 computeInlineDirectionPositionsForSegment(lineBox, lineInfo, textAlign, line LogicalLeft, availableLogicalWidth, firstRun, trailingSpaceRun, textBoxDataMap, verticalPositionCache, wordMeasurements); |
| 575 // The widths of all runs are now known. We can now place every inline box ( and | 575 // The widths of all runs are now known. We can now place every inline box ( and |
| 576 // compute accurate widths for the inline flow boxes). | 576 // compute accurate widths for the inline flow boxes). |
| 577 needsWordSpacing = lineBox->isLeftToRightDirection() ? false: true; | 577 needsWordSpacing = lineBox->isLeftToRightDirection() ? false: true; |
| 578 lineBox->placeBoxesInInlineDirection(lineLogicalLeft, needsWordSpacing); | 578 lineBox->placeBoxesInInlineDirection(lineLogicalLeft, needsWordSpacing); |
| 579 } | 579 } |
| 580 | 580 |
| 581 BidiRun* LayoutBlockFlow::computeInlineDirectionPositionsForSegment(RootInlineBo x* lineBox, const LineInfo& lineInfo, ETextAlign textAlign, float& logicalLeft, | 581 BidiRun* LayoutBlockFlow::computeInlineDirectionPositionsForSegment(RootInlineBo x* lineBox, const LineInfo& lineInfo, ETextAlign textAlign, LayoutUnit& logicalL eft, |
| 582 float& availableLogicalWidth, BidiRun* firstRun, BidiRun* trailingSpaceRun, GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache& vertica lPositionCache, | 582 LayoutUnit& availableLogicalWidth, BidiRun* firstRun, BidiRun* trailingSpace Run, GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache& ve rticalPositionCache, |
| 583 WordMeasurements& wordMeasurements) | 583 WordMeasurements& wordMeasurements) |
| 584 { | 584 { |
| 585 bool needsWordSpacing = true; | 585 bool needsWordSpacing = true; |
| 586 float totalLogicalWidth = lineBox->getFlowSpacingLogicalWidth().toFloat(); | 586 LayoutUnit totalLogicalWidth = lineBox->getFlowSpacingLogicalWidth(); |
| 587 unsigned expansionOpportunityCount = 0; | 587 unsigned expansionOpportunityCount = 0; |
| 588 bool isAfterExpansion = true; | 588 bool isAfterExpansion = true; |
| 589 Vector<unsigned, 16> expansionOpportunities; | 589 Vector<unsigned, 16> expansionOpportunities; |
| 590 LayoutObject* previousObject = 0; | 590 LayoutObject* previousObject = 0; |
| 591 TextJustify textJustify = style()->textJustify(); | 591 TextJustify textJustify = style()->textJustify(); |
| 592 | 592 |
| 593 BidiRun* r = firstRun; | 593 BidiRun* r = firstRun; |
| 594 for (; r; r = r->next()) { | 594 for (; r; r = r->next()) { |
| 595 if (!r->m_box || r->m_object->isOutOfFlowPositioned() || r->m_box->isLin eBreak()) { | 595 if (!r->m_box || r->m_object->isOutOfFlowPositioned() || r->m_box->isLin eBreak()) { |
| 596 continue; // Positioned objects are only participating to figure out their | 596 continue; // Positioned objects are only participating to figure out their |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1144 if (endOfInline) { | 1144 if (endOfInline) { |
| 1145 return getBPMWidth(child.marginEnd(), childStyle.marginEnd()) + | 1145 return getBPMWidth(child.marginEnd(), childStyle.marginEnd()) + |
| 1146 getBPMWidth(child.paddingEnd(), childStyle.paddingEnd()) + | 1146 getBPMWidth(child.paddingEnd(), childStyle.paddingEnd()) + |
| 1147 child.borderEnd(); | 1147 child.borderEnd(); |
| 1148 } | 1148 } |
| 1149 return getBPMWidth(child.marginStart(), childStyle.marginStart()) + | 1149 return getBPMWidth(child.marginStart(), childStyle.marginStart()) + |
| 1150 getBPMWidth(child.paddingStart(), childStyle.paddingStart()) + | 1150 getBPMWidth(child.paddingStart(), childStyle.paddingStart()) + |
| 1151 child.borderStart(); | 1151 child.borderStart(); |
| 1152 } | 1152 } |
| 1153 | 1153 |
| 1154 static inline void stripTrailingSpace(FloatWillBeLayoutUnit& inlineMax, FloatWil lBeLayoutUnit& inlineMin, | 1154 static inline void stripTrailingSpace(LayoutUnit& inlineMax, LayoutUnit& inlineM in, |
| 1155 LayoutObject* trailingSpaceChild) | 1155 LayoutObject* trailingSpaceChild) |
| 1156 { | 1156 { |
| 1157 if (trailingSpaceChild && trailingSpaceChild->isText()) { | 1157 if (trailingSpaceChild && trailingSpaceChild->isText()) { |
| 1158 // Collapse away the trailing space at the end of a block by finding | 1158 // Collapse away the trailing space at the end of a block by finding |
| 1159 // the first white-space character and subtracting its width. Subsequent | 1159 // the first white-space character and subtracting its width. Subsequent |
| 1160 // white-space characters have been collapsed into the first one (which | 1160 // white-space characters have been collapsed into the first one (which |
| 1161 // can be either a space or a tab character). | 1161 // can be either a space or a tab character). |
| 1162 LayoutText* text = toLayoutText(trailingSpaceChild); | 1162 LayoutText* text = toLayoutText(trailingSpaceChild); |
| 1163 UChar trailingWhitespaceChar = ' '; | 1163 UChar trailingWhitespaceChar = ' '; |
| 1164 for (unsigned i = text->textLength(); i > 0; i--) { | 1164 for (unsigned i = text->textLength(); i > 0; i--) { |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 1188 // pure float accumulation. | 1188 // pure float accumulation. |
| 1189 static inline LayoutUnit adjustFloatForSubPixelLayout(float value) | 1189 static inline LayoutUnit adjustFloatForSubPixelLayout(float value) |
| 1190 { | 1190 { |
| 1191 return LayoutUnit::fromFloatCeil(value); | 1191 return LayoutUnit::fromFloatCeil(value); |
| 1192 } | 1192 } |
| 1193 | 1193 |
| 1194 // FIXME: This function should be broken into something less monolithic. | 1194 // FIXME: This function should be broken into something less monolithic. |
| 1195 // FIXME: The main loop here is very similar to LineBreaker::nextSegmentBreak. T hey can probably reuse code. | 1195 // FIXME: The main loop here is very similar to LineBreaker::nextSegmentBreak. T hey can probably reuse code. |
| 1196 void LayoutBlockFlow::computeInlinePreferredLogicalWidths(LayoutUnit& minLogical Width, LayoutUnit& maxLogicalWidth) | 1196 void LayoutBlockFlow::computeInlinePreferredLogicalWidths(LayoutUnit& minLogical Width, LayoutUnit& maxLogicalWidth) |
| 1197 { | 1197 { |
| 1198 FloatWillBeLayoutUnit inlineMax; | 1198 LayoutUnit inlineMax; |
| 1199 FloatWillBeLayoutUnit inlineMin; | 1199 LayoutUnit inlineMin; |
| 1200 | 1200 |
| 1201 const ComputedStyle& styleToUse = styleRef(); | 1201 const ComputedStyle& styleToUse = styleRef(); |
| 1202 LayoutBlock* containingBlock = this->containingBlock(); | 1202 LayoutBlock* containingBlock = this->containingBlock(); |
| 1203 LayoutUnit cw = containingBlock ? containingBlock->contentLogicalWidth() : L ayoutUnit(); | 1203 LayoutUnit cw = containingBlock ? containingBlock->contentLogicalWidth() : L ayoutUnit(); |
| 1204 | 1204 |
| 1205 // If we are at the start of a line, we want to ignore all white-space. | 1205 // If we are at the start of a line, we want to ignore all white-space. |
| 1206 // Also strip spaces if we previously had text that ended in a trailing spac e. | 1206 // Also strip spaces if we previously had text that ended in a trailing spac e. |
| 1207 bool stripFrontSpaces = true; | 1207 bool stripFrontSpaces = true; |
| 1208 LayoutObject* trailingSpaceChild = 0; | 1208 LayoutObject* trailingSpaceChild = 0; |
| 1209 | 1209 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1260 // terminate our current line (unless we're already in a whitespace stripping | 1260 // terminate our current line (unless we're already in a whitespace stripping |
| 1261 // mode. | 1261 // mode. |
| 1262 // | 1262 // |
| 1263 // If the text string has a breakable character in the middle, but d idn't start | 1263 // If the text string has a breakable character in the middle, but d idn't start |
| 1264 // with whitespace, then we add the width of the first non-breakable run and | 1264 // with whitespace, then we add the width of the first non-breakable run and |
| 1265 // then end the current line. We then need to use the intermediate m in/max width | 1265 // then end the current line. We then need to use the intermediate m in/max width |
| 1266 // values (if any of them are larger than our current min/max). We t hen look at | 1266 // values (if any of them are larger than our current min/max). We t hen look at |
| 1267 // the width of the last non-breakable run and use that to start a n ew line | 1267 // the width of the last non-breakable run and use that to start a n ew line |
| 1268 // (unless we end in whitespace). | 1268 // (unless we end in whitespace). |
| 1269 const ComputedStyle& childStyle = child->styleRef(); | 1269 const ComputedStyle& childStyle = child->styleRef(); |
| 1270 FloatWillBeLayoutUnit childMin; | 1270 LayoutUnit childMin; |
| 1271 FloatWillBeLayoutUnit childMax; | 1271 LayoutUnit childMax; |
| 1272 | 1272 |
| 1273 if (!child->isText()) { | 1273 if (!child->isText()) { |
| 1274 // Case (1) and (2). Inline replaced and inline flow elements. | 1274 // Case (1) and (2). Inline replaced and inline flow elements. |
| 1275 if (child->isLayoutInline()) { | 1275 if (child->isLayoutInline()) { |
| 1276 // Add in padding/border/margin from the appropriate side of | 1276 // Add in padding/border/margin from the appropriate side of |
| 1277 // the element. | 1277 // the element. |
| 1278 FloatWillBeLayoutUnit bpm = getBorderPaddingMargin(toLayoutI nline(*child), childIterator.endOfInline); | 1278 LayoutUnit bpm = getBorderPaddingMargin(toLayoutInline(*chil d), childIterator.endOfInline); |
| 1279 childMin += bpm; | 1279 childMin += bpm; |
| 1280 childMax += bpm; | 1280 childMax += bpm; |
| 1281 | 1281 |
| 1282 inlineMin += childMin; | 1282 inlineMin += childMin; |
| 1283 inlineMax += childMax; | 1283 inlineMax += childMax; |
| 1284 | 1284 |
| 1285 child->clearPreferredLogicalWidthsDirty(); | 1285 child->clearPreferredLogicalWidthsDirty(); |
| 1286 } else { | 1286 } else { |
| 1287 // Inline replaced elts add in their margins to their min/ma x values. | 1287 // Inline replaced elts add in their margins to their min/ma x values. |
| 1288 LayoutUnit margins; | 1288 LayoutUnit margins; |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 1319 clearPreviousFloat = (prevFloat | 1319 clearPreviousFloat = (prevFloat |
| 1320 && ((prevFloat->styleRef().floating() == LeftFloat && (c hildStyle.clear() & CLEFT)) | 1320 && ((prevFloat->styleRef().floating() == LeftFloat && (c hildStyle.clear() & CLEFT)) |
| 1321 || (prevFloat->styleRef().floating() == RightFloat & & (childStyle.clear() & CRIGHT)))); | 1321 || (prevFloat->styleRef().floating() == RightFloat & & (childStyle.clear() & CRIGHT)))); |
| 1322 prevFloat = child; | 1322 prevFloat = child; |
| 1323 } else { | 1323 } else { |
| 1324 clearPreviousFloat = false; | 1324 clearPreviousFloat = false; |
| 1325 } | 1325 } |
| 1326 | 1326 |
| 1327 bool canBreakReplacedElement = !child->isImage() || allowImagesT oBreak; | 1327 bool canBreakReplacedElement = !child->isImage() || allowImagesT oBreak; |
| 1328 if ((canBreakReplacedElement && (autoWrap || oldAutoWrap) && (!i sPrevChildInlineFlow || shouldBreakLineAfterText)) || clearPreviousFloat) { | 1328 if ((canBreakReplacedElement && (autoWrap || oldAutoWrap) && (!i sPrevChildInlineFlow || shouldBreakLineAfterText)) || clearPreviousFloat) { |
| 1329 minLogicalWidth = std::max(minLogicalWidth, inlineMin.toLayo utUnit()); | 1329 minLogicalWidth = std::max(minLogicalWidth, inlineMin); |
| 1330 inlineMin = FloatWillBeLayoutUnit(); | 1330 inlineMin = LayoutUnit(); |
| 1331 } | 1331 } |
| 1332 | 1332 |
| 1333 // If we're supposed to clear the previous float, then terminate maxwidth as well. | 1333 // If we're supposed to clear the previous float, then terminate maxwidth as well. |
| 1334 if (clearPreviousFloat) { | 1334 if (clearPreviousFloat) { |
| 1335 maxLogicalWidth = std::max(maxLogicalWidth, inlineMax.toLayo utUnit()); | 1335 maxLogicalWidth = std::max(maxLogicalWidth, inlineMax); |
| 1336 inlineMax = FloatWillBeLayoutUnit(); | 1336 inlineMax = LayoutUnit(); |
| 1337 } | 1337 } |
| 1338 | 1338 |
| 1339 // Add in text-indent. This is added in only once. | 1339 // Add in text-indent. This is added in only once. |
| 1340 if (!addedTextIndent && !child->isFloating()) { | 1340 if (!addedTextIndent && !child->isFloating()) { |
| 1341 childMin += textIndent; | 1341 childMin += textIndent; |
| 1342 childMax += textIndent; | 1342 childMax += textIndent; |
| 1343 | 1343 |
| 1344 if (childMin < FloatWillBeLayoutUnit()) | 1344 if (childMin < LayoutUnit()) |
| 1345 textIndent = childMin; | 1345 textIndent = childMin; |
| 1346 else | 1346 else |
| 1347 addedTextIndent = true; | 1347 addedTextIndent = true; |
| 1348 } | 1348 } |
| 1349 | 1349 |
| 1350 // Add our width to the max. | 1350 // Add our width to the max. |
| 1351 inlineMax += std::max(FloatWillBeLayoutUnit(), childMax); | 1351 inlineMax += std::max(LayoutUnit(), childMax); |
| 1352 | 1352 |
| 1353 if (!autoWrap || !canBreakReplacedElement || (isPrevChildInlineF low && !shouldBreakLineAfterText)) { | 1353 if (!autoWrap || !canBreakReplacedElement || (isPrevChildInlineF low && !shouldBreakLineAfterText)) { |
| 1354 if (child->isFloating()) | 1354 if (child->isFloating()) |
| 1355 minLogicalWidth = std::max(minLogicalWidth, childMin.toL ayoutUnit()); | 1355 minLogicalWidth = std::max(minLogicalWidth, childMin); |
| 1356 else | 1356 else |
| 1357 inlineMin += childMin; | 1357 inlineMin += childMin; |
| 1358 } else { | 1358 } else { |
| 1359 // Now check our line. | 1359 // Now check our line. |
| 1360 minLogicalWidth = std::max(minLogicalWidth, childMin.toLayou tUnit()); | 1360 minLogicalWidth = std::max(minLogicalWidth, childMin); |
| 1361 | 1361 |
| 1362 // Now start a new line. | 1362 // Now start a new line. |
| 1363 inlineMin = FloatWillBeLayoutUnit(); | 1363 inlineMin = LayoutUnit(); |
| 1364 } | 1364 } |
| 1365 | 1365 |
| 1366 if (autoWrap && canBreakReplacedElement && isPrevChildInlineFlow ) { | 1366 if (autoWrap && canBreakReplacedElement && isPrevChildInlineFlow ) { |
| 1367 minLogicalWidth = std::max(minLogicalWidth, inlineMin.toLayo utUnit()); | 1367 minLogicalWidth = std::max(minLogicalWidth, inlineMin); |
| 1368 inlineMin = FloatWillBeLayoutUnit(); | 1368 inlineMin = LayoutUnit(); |
| 1369 } | 1369 } |
| 1370 | 1370 |
| 1371 // We are no longer stripping whitespace at the start of | 1371 // We are no longer stripping whitespace at the start of |
| 1372 // a line. | 1372 // a line. |
| 1373 if (!child->isFloating()) { | 1373 if (!child->isFloating()) { |
| 1374 stripFrontSpaces = false; | 1374 stripFrontSpaces = false; |
| 1375 trailingSpaceChild = 0; | 1375 trailingSpaceChild = 0; |
| 1376 } | 1376 } |
| 1377 } else if (child->isText()) { | 1377 } else if (child->isText()) { |
| 1378 // Case (3). Text. | 1378 // Case (3). Text. |
| 1379 LayoutText* t = toLayoutText(child); | 1379 LayoutText* t = toLayoutText(child); |
| 1380 | 1380 |
| 1381 if (t->isWordBreak()) { | 1381 if (t->isWordBreak()) { |
| 1382 minLogicalWidth = std::max(minLogicalWidth, inlineMin.toLayo utUnit()); | 1382 minLogicalWidth = std::max(minLogicalWidth, inlineMin); |
| 1383 inlineMin = FloatWillBeLayoutUnit(); | 1383 inlineMin = LayoutUnit(); |
| 1384 continue; | 1384 continue; |
| 1385 } | 1385 } |
| 1386 | 1386 |
| 1387 // Determine if we have a breakable character. Pass in | 1387 // Determine if we have a breakable character. Pass in |
| 1388 // whether or not we should ignore any spaces at the front | 1388 // whether or not we should ignore any spaces at the front |
| 1389 // of the string. If those are going to be stripped out, | 1389 // of the string. If those are going to be stripped out, |
| 1390 // then they shouldn't be considered in the breakable char | 1390 // then they shouldn't be considered in the breakable char |
| 1391 // check. | 1391 // check. |
| 1392 bool hasBreakableChar, hasBreak; | 1392 bool hasBreakableChar, hasBreak; |
| 1393 FloatWillBeLayoutUnit firstLineMinWidth, lastLineMinWidth; | 1393 LayoutUnit firstLineMinWidth, lastLineMinWidth; |
| 1394 bool hasBreakableStart, hasBreakableEnd; | 1394 bool hasBreakableStart, hasBreakableEnd; |
| 1395 FloatWillBeLayoutUnit firstLineMaxWidth, lastLineMaxWidth; | 1395 LayoutUnit firstLineMaxWidth, lastLineMaxWidth; |
| 1396 t->trimmedPrefWidths(inlineMax, | 1396 t->trimmedPrefWidths(inlineMax, |
| 1397 firstLineMinWidth, hasBreakableStart, lastLineMinWidth, hasB reakableEnd, | 1397 firstLineMinWidth, hasBreakableStart, lastLineMinWidth, hasB reakableEnd, |
| 1398 hasBreakableChar, hasBreak, firstLineMaxWidth, lastLineMaxWi dth, | 1398 hasBreakableChar, hasBreak, firstLineMaxWidth, lastLineMaxWi dth, |
| 1399 childMin, childMax, stripFrontSpaces, styleToUse.direction() ); | 1399 childMin, childMax, stripFrontSpaces, styleToUse.direction() ); |
| 1400 | 1400 |
| 1401 // This text object will not be layed out, but it may still prov ide a breaking opportunity. | 1401 // This text object will not be layed out, but it may still prov ide a breaking opportunity. |
| 1402 if (!hasBreak && !childMax) { | 1402 if (!hasBreak && !childMax) { |
| 1403 if (autoWrap && (hasBreakableStart || hasBreakableEnd)) { | 1403 if (autoWrap && (hasBreakableStart || hasBreakableEnd)) { |
| 1404 minLogicalWidth = std::max(minLogicalWidth, inlineMin.to LayoutUnit()); | 1404 minLogicalWidth = std::max(minLogicalWidth, inlineMin); |
| 1405 inlineMin = FloatWillBeLayoutUnit(); | 1405 inlineMin = LayoutUnit(); |
| 1406 } | 1406 } |
| 1407 continue; | 1407 continue; |
| 1408 } | 1408 } |
| 1409 | 1409 |
| 1410 if (stripFrontSpaces) | 1410 if (stripFrontSpaces) |
| 1411 trailingSpaceChild = child; | 1411 trailingSpaceChild = child; |
| 1412 else | 1412 else |
| 1413 trailingSpaceChild = 0; | 1413 trailingSpaceChild = 0; |
| 1414 | 1414 |
| 1415 // Add in text-indent. This is added in only once. | 1415 // Add in text-indent. This is added in only once. |
| 1416 FloatWillBeLayoutUnit ti; | 1416 LayoutUnit ti; |
| 1417 if (!addedTextIndent || hasRemainingNegativeTextIndent) { | 1417 if (!addedTextIndent || hasRemainingNegativeTextIndent) { |
| 1418 ti = textIndent; | 1418 ti = textIndent; |
| 1419 childMin += ti; | 1419 childMin += ti; |
| 1420 firstLineMinWidth += ti; | 1420 firstLineMinWidth += ti; |
| 1421 | 1421 |
| 1422 // It the text indent negative and larger than the child min imum, we re-use the remainder | 1422 // It the text indent negative and larger than the child min imum, we re-use the remainder |
| 1423 // in future minimum calculations, but using the negative va lue again on the maximum | 1423 // in future minimum calculations, but using the negative va lue again on the maximum |
| 1424 // will lead to under-counting the max pref width. | 1424 // will lead to under-counting the max pref width. |
| 1425 if (!addedTextIndent) { | 1425 if (!addedTextIndent) { |
| 1426 childMax += ti; | 1426 childMax += ti; |
| 1427 firstLineMaxWidth += ti; | 1427 firstLineMaxWidth += ti; |
| 1428 addedTextIndent = true; | 1428 addedTextIndent = true; |
| 1429 } | 1429 } |
| 1430 | 1430 |
| 1431 if (childMin < FloatWillBeLayoutUnit()) { | 1431 if (childMin < LayoutUnit()) { |
| 1432 textIndent = childMin; | 1432 textIndent = childMin; |
| 1433 hasRemainingNegativeTextIndent = true; | 1433 hasRemainingNegativeTextIndent = true; |
| 1434 } | 1434 } |
| 1435 } | 1435 } |
| 1436 | 1436 |
| 1437 // If we have no breakable characters at all, | 1437 // If we have no breakable characters at all, |
| 1438 // then this is the easy case. We add ourselves to the current | 1438 // then this is the easy case. We add ourselves to the current |
| 1439 // min and max and continue. | 1439 // min and max and continue. |
| 1440 if (!hasBreakableChar) { | 1440 if (!hasBreakableChar) { |
| 1441 inlineMin += childMin; | 1441 inlineMin += childMin; |
| 1442 } else { | 1442 } else { |
| 1443 if (hasBreakableStart) { | 1443 if (hasBreakableStart) { |
| 1444 minLogicalWidth = std::max(minLogicalWidth, inlineMin.to LayoutUnit()); | 1444 minLogicalWidth = std::max(minLogicalWidth, inlineMin); |
| 1445 } else { | 1445 } else { |
| 1446 inlineMin += firstLineMinWidth; | 1446 inlineMin += firstLineMinWidth; |
| 1447 minLogicalWidth = std::max(minLogicalWidth, inlineMin.to LayoutUnit()); | 1447 minLogicalWidth = std::max(minLogicalWidth, inlineMin); |
| 1448 childMin -= ti; | 1448 childMin -= ti; |
| 1449 } | 1449 } |
| 1450 | 1450 |
| 1451 inlineMin = childMin; | 1451 inlineMin = childMin; |
| 1452 | 1452 |
| 1453 if (hasBreakableEnd) { | 1453 if (hasBreakableEnd) { |
| 1454 minLogicalWidth = std::max(minLogicalWidth, inlineMin.to LayoutUnit()); | 1454 minLogicalWidth = std::max(minLogicalWidth, inlineMin); |
| 1455 inlineMin = FloatWillBeLayoutUnit(); | 1455 inlineMin = LayoutUnit(); |
| 1456 shouldBreakLineAfterText = false; | 1456 shouldBreakLineAfterText = false; |
| 1457 } else { | 1457 } else { |
| 1458 minLogicalWidth = std::max(minLogicalWidth, inlineMin.to LayoutUnit()); | 1458 minLogicalWidth = std::max(minLogicalWidth, inlineMin); |
| 1459 inlineMin = lastLineMinWidth; | 1459 inlineMin = lastLineMinWidth; |
| 1460 shouldBreakLineAfterText = true; | 1460 shouldBreakLineAfterText = true; |
| 1461 } | 1461 } |
| 1462 } | 1462 } |
| 1463 | 1463 |
| 1464 if (hasBreak) { | 1464 if (hasBreak) { |
| 1465 inlineMax += firstLineMaxWidth; | 1465 inlineMax += firstLineMaxWidth; |
| 1466 maxLogicalWidth = std::max(maxLogicalWidth, inlineMax.toLayo utUnit()); | 1466 maxLogicalWidth = std::max(maxLogicalWidth, inlineMax); |
| 1467 maxLogicalWidth = std::max(maxLogicalWidth, childMax.toLayou tUnit()); | 1467 maxLogicalWidth = std::max(maxLogicalWidth, childMax); |
| 1468 inlineMax = lastLineMaxWidth; | 1468 inlineMax = lastLineMaxWidth; |
| 1469 addedTextIndent = true; | 1469 addedTextIndent = true; |
| 1470 } else { | 1470 } else { |
| 1471 inlineMax += std::max<float>(0, childMax); | 1471 inlineMax += std::max(LayoutUnit(), childMax); |
| 1472 } | 1472 } |
| 1473 } | 1473 } |
| 1474 | 1474 |
| 1475 // Ignore spaces after a list marker. | 1475 // Ignore spaces after a list marker. |
| 1476 if (child->isListMarker()) | 1476 if (child->isListMarker()) |
| 1477 stripFrontSpaces = true; | 1477 stripFrontSpaces = true; |
| 1478 } else { | 1478 } else { |
| 1479 minLogicalWidth = std::max(minLogicalWidth, inlineMin.toLayoutUnit() ); | 1479 minLogicalWidth = std::max(minLogicalWidth, inlineMin); |
| 1480 maxLogicalWidth = std::max(maxLogicalWidth, inlineMax.toLayoutUnit() ); | 1480 maxLogicalWidth = std::max(maxLogicalWidth, inlineMax); |
| 1481 inlineMin = inlineMax = FloatWillBeLayoutUnit(); | 1481 inlineMin = inlineMax = LayoutUnit(); |
| 1482 stripFrontSpaces = true; | 1482 stripFrontSpaces = true; |
| 1483 trailingSpaceChild = 0; | 1483 trailingSpaceChild = 0; |
| 1484 addedTextIndent = true; | 1484 addedTextIndent = true; |
| 1485 } | 1485 } |
| 1486 | 1486 |
| 1487 if (!child->isText() && child->isLayoutInline()) | 1487 if (!child->isText() && child->isLayoutInline()) |
| 1488 isPrevChildInlineFlow = true; | 1488 isPrevChildInlineFlow = true; |
| 1489 else | 1489 else |
| 1490 isPrevChildInlineFlow = false; | 1490 isPrevChildInlineFlow = false; |
| 1491 | 1491 |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1901 void LayoutBlockFlow::deleteEllipsisLineBoxes() | 1901 void LayoutBlockFlow::deleteEllipsisLineBoxes() |
| 1902 { | 1902 { |
| 1903 ETextAlign textAlign = style()->textAlign(); | 1903 ETextAlign textAlign = style()->textAlign(); |
| 1904 bool ltr = style()->isLeftToRightDirection(); | 1904 bool ltr = style()->isLeftToRightDirection(); |
| 1905 bool firstLine = true; | 1905 bool firstLine = true; |
| 1906 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { | 1906 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { |
| 1907 if (curr->hasEllipsisBox()) { | 1907 if (curr->hasEllipsisBox()) { |
| 1908 curr->clearTruncation(); | 1908 curr->clearTruncation(); |
| 1909 | 1909 |
| 1910 // Shift the line back where it belongs if we cannot accomodate an e llipsis. | 1910 // Shift the line back where it belongs if we cannot accomodate an e llipsis. |
| 1911 float logicalLeft = logicalLeftOffsetForLine(curr->lineTop(), firstL ine).toFloat(); | 1911 LayoutUnit logicalLeft = logicalLeftOffsetForLine(curr->lineTop(), f irstLine).toFloat(); |
| 1912 float availableLogicalWidth = logicalRightOffsetForLine(curr->lineTo p(), false) - logicalLeft; | 1912 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(curr->l ineTop(), false) - logicalLeft; |
| 1913 float totalLogicalWidth = curr->logicalWidth(); | 1913 LayoutUnit totalLogicalWidth = curr->logicalWidth(); |
| 1914 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, tota lLogicalWidth, availableLogicalWidth, 0); | 1914 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, tota lLogicalWidth, availableLogicalWidth, 0); |
| 1915 | 1915 |
| 1916 if (ltr) | 1916 if (ltr) |
| 1917 curr->adjustLogicalPosition((logicalLeft - curr->logicalLeft()), 0); | 1917 curr->adjustLogicalPosition((logicalLeft - curr->logicalLeft()), 0); |
| 1918 else | 1918 else |
| 1919 curr->adjustLogicalPosition(-(curr->logicalLeft() - logicalLeft) , 0); | 1919 curr->adjustLogicalPosition(-(curr->logicalLeft() - logicalLeft) , 0); |
| 1920 } | 1920 } |
| 1921 firstLine = false; | 1921 firstLine = false; |
| 1922 } | 1922 } |
| 1923 } | 1923 } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 1935 float ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : fon t.width(constructTextRun(this, font, &horizontalEllipsisCharacter, 1, styleRef() , ellipsisDirection)); | 1935 float ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : fon t.width(constructTextRun(this, font, &horizontalEllipsisCharacter, 1, styleRef() , ellipsisDirection)); |
| 1936 | 1936 |
| 1937 // For LTR text truncation, we want to get the right edge of our padding box , and then we want to see | 1937 // For LTR text truncation, we want to get the right edge of our padding box , and then we want to see |
| 1938 // if the right edge of a line box exceeds that. For RTL, we use the left e dge of the padding box and | 1938 // if the right edge of a line box exceeds that. For RTL, we use the left e dge of the padding box and |
| 1939 // check the left edge of the line box to see if it is less | 1939 // check the left edge of the line box to see if it is less |
| 1940 // Include the scrollbar for overflow blocks, which means we want to use "co ntentWidth()" | 1940 // Include the scrollbar for overflow blocks, which means we want to use "co ntentWidth()" |
| 1941 bool ltr = style()->isLeftToRightDirection(); | 1941 bool ltr = style()->isLeftToRightDirection(); |
| 1942 ETextAlign textAlign = style()->textAlign(); | 1942 ETextAlign textAlign = style()->textAlign(); |
| 1943 bool firstLine = true; | 1943 bool firstLine = true; |
| 1944 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { | 1944 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { |
| 1945 float currLogicalLeft = curr->logicalLeft(); | 1945 LayoutUnit currLogicalLeft = curr->logicalLeft(); |
| 1946 LayoutUnit blockRightEdge = logicalRightOffsetForLine(curr->lineTop(), f irstLine); | 1946 LayoutUnit blockRightEdge = logicalRightOffsetForLine(curr->lineTop(), f irstLine); |
| 1947 LayoutUnit blockLeftEdge = logicalLeftOffsetForLine(curr->lineTop(), fir stLine); | 1947 LayoutUnit blockLeftEdge = logicalLeftOffsetForLine(curr->lineTop(), fir stLine); |
| 1948 LayoutUnit lineBoxEdge = ltr ? currLogicalLeft + curr->logicalWidth() : currLogicalLeft; | 1948 LayoutUnit lineBoxEdge = ltr ? currLogicalLeft + curr->logicalWidth() : currLogicalLeft; |
| 1949 if ((ltr && lineBoxEdge > blockRightEdge) || (!ltr && lineBoxEdge < bloc kLeftEdge)) { | 1949 if ((ltr && lineBoxEdge > blockRightEdge) || (!ltr && lineBoxEdge < bloc kLeftEdge)) { |
| 1950 // This line spills out of our box in the appropriate direction. No w we need to see if the line | 1950 // This line spills out of our box in the appropriate direction. No w we need to see if the line |
| 1951 // can be truncated. In order for truncation to be possible, the li ne must have sufficient space to | 1951 // can be truncated. In order for truncation to be possible, the li ne must have sufficient space to |
| 1952 // accommodate our truncation string, and no replaced elements (imag es, tables) can overlap the ellipsis | 1952 // accommodate our truncation string, and no replaced elements (imag es, tables) can overlap the ellipsis |
| 1953 // space. | 1953 // space. |
| 1954 | 1954 |
| 1955 LayoutUnit width = firstLine ? firstLineEllipsisWidth : ellipsisWidt h; | 1955 LayoutUnit width = firstLine ? firstLineEllipsisWidth : ellipsisWidt h; |
| 1956 LayoutUnit blockEdge = ltr ? blockRightEdge : blockLeftEdge; | 1956 LayoutUnit blockEdge = ltr ? blockRightEdge : blockLeftEdge; |
| 1957 if (curr->lineCanAccommodateEllipsis(ltr, blockEdge, lineBoxEdge, wi dth)) { | 1957 if (curr->lineCanAccommodateEllipsis(ltr, blockEdge, lineBoxEdge, wi dth)) { |
| 1958 float totalLogicalWidth = curr->placeEllipsis(ellipsisStr, ltr, blockLeftEdge.toFloat(), blockRightEdge.toFloat(), width.toFloat()); | 1958 LayoutUnit totalLogicalWidth = curr->placeEllipsis(ellipsisStr, ltr, blockLeftEdge, blockRightEdge, width); |
| 1959 | 1959 |
| 1960 float logicalLeft = 0; // We are only intersted in the delta fro m the base position. | 1960 LayoutUnit logicalLeft; // We are only intersted in the delta fr om the base position. |
|
dsinclair
2015/05/26 18:59:22
nit: s/intersted/interested
szager1
2015/05/27 05:59:42
Done.
| |
| 1961 float availableLogicalWidth = (blockRightEdge - blockLeftEdge).t oFloat(); | 1961 LayoutUnit availableLogicalWidth = blockRightEdge - blockLeftEdg e; |
| 1962 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, totalLogicalWidth, availableLogicalWidth, 0); | 1962 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, totalLogicalWidth, availableLogicalWidth, 0); |
| 1963 if (ltr) | 1963 if (ltr) |
| 1964 curr->adjustLogicalPosition(logicalLeft, 0); | 1964 curr->adjustLogicalPosition(logicalLeft, 0); |
| 1965 else | 1965 else |
| 1966 curr->adjustLogicalPosition(logicalLeft - (availableLogicalW idth - totalLogicalWidth), 0); | 1966 curr->adjustLogicalPosition(logicalLeft - (availableLogicalW idth - totalLogicalWidth), 0); |
| 1967 } | 1967 } |
| 1968 } | 1968 } |
| 1969 firstLine = false; | 1969 firstLine = false; |
| 1970 } | 1970 } |
| 1971 } | 1971 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2022 } | 2022 } |
| 2023 | 2023 |
| 2024 LayoutUnit LayoutBlockFlow::startAlignedOffsetForLine(LayoutUnit position, bool firstLine) | 2024 LayoutUnit LayoutBlockFlow::startAlignedOffsetForLine(LayoutUnit position, bool firstLine) |
| 2025 { | 2025 { |
| 2026 ETextAlign textAlign = style()->textAlign(); | 2026 ETextAlign textAlign = style()->textAlign(); |
| 2027 | 2027 |
| 2028 if (textAlign == TASTART) // FIXME: Handle TAEND here | 2028 if (textAlign == TASTART) // FIXME: Handle TAEND here |
| 2029 return startOffsetForLine(position, firstLine); | 2029 return startOffsetForLine(position, firstLine); |
| 2030 | 2030 |
| 2031 // updateLogicalWidthForAlignment() handles the direction of the block so no need to consider it here | 2031 // updateLogicalWidthForAlignment() handles the direction of the block so no need to consider it here |
| 2032 float totalLogicalWidth = 0; | 2032 LayoutUnit totalLogicalWidth; |
| 2033 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat (); | 2033 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); |
| 2034 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal se) - logicalLeft; | 2034 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight() , false) - logicalLeft; |
| 2035 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); | 2035 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); |
| 2036 | 2036 |
| 2037 if (!style()->isLeftToRightDirection()) | 2037 if (!style()->isLeftToRightDirection()) |
| 2038 return logicalWidth() - logicalLeft; | 2038 return logicalWidth() - logicalLeft; |
| 2039 return logicalLeft; | 2039 return logicalLeft; |
| 2040 } | 2040 } |
| 2041 | 2041 |
| 2042 } | 2042 } |
| OLD | NEW |