Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: Source/core/layout/LayoutBlockFlowLine.cpp

Issue 1043643002: Switch line layout to LayoutUnit. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: More TestExpectations tweaks Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/layout/LayoutBlockFlow.h ('k') | Source/core/layout/LayoutBox.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 if (endOfInline) { 1137 if (endOfInline) {
1138 return getBPMWidth(child.marginEnd(), childStyle.marginEnd()) + 1138 return getBPMWidth(child.marginEnd(), childStyle.marginEnd()) +
1139 getBPMWidth(child.paddingEnd(), childStyle.paddingEnd()) + 1139 getBPMWidth(child.paddingEnd(), childStyle.paddingEnd()) +
1140 child.borderEnd(); 1140 child.borderEnd();
1141 } 1141 }
1142 return getBPMWidth(child.marginStart(), childStyle.marginStart()) + 1142 return getBPMWidth(child.marginStart(), childStyle.marginStart()) +
1143 getBPMWidth(child.paddingStart(), childStyle.paddingStart()) + 1143 getBPMWidth(child.paddingStart(), childStyle.paddingStart()) +
1144 child.borderStart(); 1144 child.borderStart();
1145 } 1145 }
1146 1146
1147 static inline void stripTrailingSpace(FloatWillBeLayoutUnit& inlineMax, FloatWil lBeLayoutUnit& inlineMin, 1147 static inline void stripTrailingSpace(LayoutUnit& inlineMax, LayoutUnit& inlineM in,
1148 LayoutObject* trailingSpaceChild) 1148 LayoutObject* trailingSpaceChild)
1149 { 1149 {
1150 if (trailingSpaceChild && trailingSpaceChild->isText()) { 1150 if (trailingSpaceChild && trailingSpaceChild->isText()) {
1151 // Collapse away the trailing space at the end of a block by finding 1151 // Collapse away the trailing space at the end of a block by finding
1152 // the first white-space character and subtracting its width. Subsequent 1152 // the first white-space character and subtracting its width. Subsequent
1153 // white-space characters have been collapsed into the first one (which 1153 // white-space characters have been collapsed into the first one (which
1154 // can be either a space or a tab character). 1154 // can be either a space or a tab character).
1155 LayoutText* text = toLayoutText(trailingSpaceChild); 1155 LayoutText* text = toLayoutText(trailingSpaceChild);
1156 UChar trailingWhitespaceChar = ' '; 1156 UChar trailingWhitespaceChar = ' ';
1157 for (unsigned i = text->textLength(); i > 0; i--) { 1157 for (unsigned i = text->textLength(); i > 0; i--) {
(...skipping 23 matching lines...) Expand all
1181 // pure float accumulation. 1181 // pure float accumulation.
1182 static inline LayoutUnit adjustFloatForSubPixelLayout(float value) 1182 static inline LayoutUnit adjustFloatForSubPixelLayout(float value)
1183 { 1183 {
1184 return LayoutUnit::fromFloatCeil(value); 1184 return LayoutUnit::fromFloatCeil(value);
1185 } 1185 }
1186 1186
1187 // FIXME: This function should be broken into something less monolithic. 1187 // FIXME: This function should be broken into something less monolithic.
1188 // FIXME: The main loop here is very similar to LineBreaker::nextSegmentBreak. T hey can probably reuse code. 1188 // FIXME: The main loop here is very similar to LineBreaker::nextSegmentBreak. T hey can probably reuse code.
1189 void LayoutBlockFlow::computeInlinePreferredLogicalWidths(LayoutUnit& minLogical Width, LayoutUnit& maxLogicalWidth) 1189 void LayoutBlockFlow::computeInlinePreferredLogicalWidths(LayoutUnit& minLogical Width, LayoutUnit& maxLogicalWidth)
1190 { 1190 {
1191 FloatWillBeLayoutUnit inlineMax; 1191 LayoutUnit inlineMax;
1192 FloatWillBeLayoutUnit inlineMin; 1192 LayoutUnit inlineMin;
1193 1193
1194 const ComputedStyle& styleToUse = styleRef(); 1194 const ComputedStyle& styleToUse = styleRef();
1195 LayoutBlock* containingBlock = this->containingBlock(); 1195 LayoutBlock* containingBlock = this->containingBlock();
1196 LayoutUnit cw = containingBlock ? containingBlock->contentLogicalWidth() : L ayoutUnit(); 1196 LayoutUnit cw = containingBlock ? containingBlock->contentLogicalWidth() : L ayoutUnit();
1197 1197
1198 // If we are at the start of a line, we want to ignore all white-space. 1198 // If we are at the start of a line, we want to ignore all white-space.
1199 // Also strip spaces if we previously had text that ended in a trailing spac e. 1199 // Also strip spaces if we previously had text that ended in a trailing spac e.
1200 bool stripFrontSpaces = true; 1200 bool stripFrontSpaces = true;
1201 LayoutObject* trailingSpaceChild = 0; 1201 LayoutObject* trailingSpaceChild = 0;
1202 1202
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 // terminate our current line (unless we're already in a whitespace stripping 1253 // terminate our current line (unless we're already in a whitespace stripping
1254 // mode. 1254 // mode.
1255 // 1255 //
1256 // If the text string has a breakable character in the middle, but d idn't start 1256 // If the text string has a breakable character in the middle, but d idn't start
1257 // with whitespace, then we add the width of the first non-breakable run and 1257 // with whitespace, then we add the width of the first non-breakable run and
1258 // then end the current line. We then need to use the intermediate m in/max width 1258 // then end the current line. We then need to use the intermediate m in/max width
1259 // values (if any of them are larger than our current min/max). We t hen look at 1259 // values (if any of them are larger than our current min/max). We t hen look at
1260 // the width of the last non-breakable run and use that to start a n ew line 1260 // the width of the last non-breakable run and use that to start a n ew line
1261 // (unless we end in whitespace). 1261 // (unless we end in whitespace).
1262 const ComputedStyle& childStyle = child->styleRef(); 1262 const ComputedStyle& childStyle = child->styleRef();
1263 FloatWillBeLayoutUnit childMin; 1263 LayoutUnit childMin;
1264 FloatWillBeLayoutUnit childMax; 1264 LayoutUnit childMax;
1265 1265
1266 if (!child->isText()) { 1266 if (!child->isText()) {
1267 // Case (1) and (2). Inline replaced and inline flow elements. 1267 // Case (1) and (2). Inline replaced and inline flow elements.
1268 if (child->isLayoutInline()) { 1268 if (child->isLayoutInline()) {
1269 // Add in padding/border/margin from the appropriate side of 1269 // Add in padding/border/margin from the appropriate side of
1270 // the element. 1270 // the element.
1271 FloatWillBeLayoutUnit bpm = getBorderPaddingMargin(toLayoutI nline(*child), childIterator.endOfInline); 1271 LayoutUnit bpm = getBorderPaddingMargin(toLayoutInline(*chil d), childIterator.endOfInline);
1272 childMin += bpm; 1272 childMin += bpm;
1273 childMax += bpm; 1273 childMax += bpm;
1274 1274
1275 inlineMin += childMin; 1275 inlineMin += childMin;
1276 inlineMax += childMax; 1276 inlineMax += childMax;
1277 1277
1278 child->clearPreferredLogicalWidthsDirty(); 1278 child->clearPreferredLogicalWidthsDirty();
1279 } else { 1279 } else {
1280 // Inline replaced elts add in their margins to their min/ma x values. 1280 // Inline replaced elts add in their margins to their min/ma x values.
1281 LayoutUnit margins; 1281 LayoutUnit margins;
(...skipping 30 matching lines...) Expand all
1312 clearPreviousFloat = (prevFloat 1312 clearPreviousFloat = (prevFloat
1313 && ((prevFloat->styleRef().floating() == LeftFloat && (c hildStyle.clear() & CLEFT)) 1313 && ((prevFloat->styleRef().floating() == LeftFloat && (c hildStyle.clear() & CLEFT))
1314 || (prevFloat->styleRef().floating() == RightFloat & & (childStyle.clear() & CRIGHT)))); 1314 || (prevFloat->styleRef().floating() == RightFloat & & (childStyle.clear() & CRIGHT))));
1315 prevFloat = child; 1315 prevFloat = child;
1316 } else { 1316 } else {
1317 clearPreviousFloat = false; 1317 clearPreviousFloat = false;
1318 } 1318 }
1319 1319
1320 bool canBreakReplacedElement = !child->isImage() || allowImagesT oBreak; 1320 bool canBreakReplacedElement = !child->isImage() || allowImagesT oBreak;
1321 if ((canBreakReplacedElement && (autoWrap || oldAutoWrap) && (!i sPrevChildInlineFlow || shouldBreakLineAfterText)) || clearPreviousFloat) { 1321 if ((canBreakReplacedElement && (autoWrap || oldAutoWrap) && (!i sPrevChildInlineFlow || shouldBreakLineAfterText)) || clearPreviousFloat) {
1322 minLogicalWidth = std::max(minLogicalWidth, inlineMin.toLayo utUnit()); 1322 minLogicalWidth = std::max(minLogicalWidth, inlineMin);
1323 inlineMin = FloatWillBeLayoutUnit(); 1323 inlineMin = LayoutUnit();
1324 } 1324 }
1325 1325
1326 // If we're supposed to clear the previous float, then terminate maxwidth as well. 1326 // If we're supposed to clear the previous float, then terminate maxwidth as well.
1327 if (clearPreviousFloat) { 1327 if (clearPreviousFloat) {
1328 maxLogicalWidth = std::max(maxLogicalWidth, inlineMax.toLayo utUnit()); 1328 maxLogicalWidth = std::max(maxLogicalWidth, inlineMax);
1329 inlineMax = FloatWillBeLayoutUnit(); 1329 inlineMax = LayoutUnit();
1330 } 1330 }
1331 1331
1332 // Add in text-indent. This is added in only once. 1332 // Add in text-indent. This is added in only once.
1333 if (!addedTextIndent && !child->isFloating()) { 1333 if (!addedTextIndent && !child->isFloating()) {
1334 childMin += textIndent; 1334 childMin += textIndent;
1335 childMax += textIndent; 1335 childMax += textIndent;
1336 1336
1337 if (childMin < FloatWillBeLayoutUnit()) 1337 if (childMin < LayoutUnit())
1338 textIndent = childMin; 1338 textIndent = childMin;
1339 else 1339 else
1340 addedTextIndent = true; 1340 addedTextIndent = true;
1341 } 1341 }
1342 1342
1343 // Add our width to the max. 1343 // Add our width to the max.
1344 inlineMax += std::max(FloatWillBeLayoutUnit(), childMax); 1344 inlineMax += std::max(LayoutUnit(), childMax);
1345 1345
1346 if (!autoWrap || !canBreakReplacedElement || (isPrevChildInlineF low && !shouldBreakLineAfterText)) { 1346 if (!autoWrap || !canBreakReplacedElement || (isPrevChildInlineF low && !shouldBreakLineAfterText)) {
1347 if (child->isFloating()) 1347 if (child->isFloating())
1348 minLogicalWidth = std::max(minLogicalWidth, childMin.toL ayoutUnit()); 1348 minLogicalWidth = std::max(minLogicalWidth, childMin);
1349 else 1349 else
1350 inlineMin += childMin; 1350 inlineMin += childMin;
1351 } else { 1351 } else {
1352 // Now check our line. 1352 // Now check our line.
1353 minLogicalWidth = std::max(minLogicalWidth, childMin.toLayou tUnit()); 1353 minLogicalWidth = std::max(minLogicalWidth, childMin);
1354 1354
1355 // Now start a new line. 1355 // Now start a new line.
1356 inlineMin = FloatWillBeLayoutUnit(); 1356 inlineMin = LayoutUnit();
1357 } 1357 }
1358 1358
1359 if (autoWrap && canBreakReplacedElement && isPrevChildInlineFlow ) { 1359 if (autoWrap && canBreakReplacedElement && isPrevChildInlineFlow ) {
1360 minLogicalWidth = std::max(minLogicalWidth, inlineMin.toLayo utUnit()); 1360 minLogicalWidth = std::max(minLogicalWidth, inlineMin);
1361 inlineMin = FloatWillBeLayoutUnit(); 1361 inlineMin = LayoutUnit();
1362 } 1362 }
1363 1363
1364 // We are no longer stripping whitespace at the start of 1364 // We are no longer stripping whitespace at the start of
1365 // a line. 1365 // a line.
1366 if (!child->isFloating()) { 1366 if (!child->isFloating()) {
1367 stripFrontSpaces = false; 1367 stripFrontSpaces = false;
1368 trailingSpaceChild = 0; 1368 trailingSpaceChild = 0;
1369 } 1369 }
1370 } else if (child->isText()) { 1370 } else if (child->isText()) {
1371 // Case (3). Text. 1371 // Case (3). Text.
1372 LayoutText* t = toLayoutText(child); 1372 LayoutText* t = toLayoutText(child);
1373 1373
1374 if (t->isWordBreak()) { 1374 if (t->isWordBreak()) {
1375 minLogicalWidth = std::max(minLogicalWidth, inlineMin.toLayo utUnit()); 1375 minLogicalWidth = std::max(minLogicalWidth, inlineMin);
1376 inlineMin = FloatWillBeLayoutUnit(); 1376 inlineMin = LayoutUnit();
1377 continue; 1377 continue;
1378 } 1378 }
1379 1379
1380 // Determine if we have a breakable character. Pass in 1380 // Determine if we have a breakable character. Pass in
1381 // whether or not we should ignore any spaces at the front 1381 // whether or not we should ignore any spaces at the front
1382 // of the string. If those are going to be stripped out, 1382 // of the string. If those are going to be stripped out,
1383 // then they shouldn't be considered in the breakable char 1383 // then they shouldn't be considered in the breakable char
1384 // check. 1384 // check.
1385 bool hasBreakableChar, hasBreak; 1385 bool hasBreakableChar, hasBreak;
1386 FloatWillBeLayoutUnit firstLineMinWidth, lastLineMinWidth; 1386 LayoutUnit firstLineMinWidth, lastLineMinWidth;
1387 bool hasBreakableStart, hasBreakableEnd; 1387 bool hasBreakableStart, hasBreakableEnd;
1388 FloatWillBeLayoutUnit firstLineMaxWidth, lastLineMaxWidth; 1388 LayoutUnit firstLineMaxWidth, lastLineMaxWidth;
1389 t->trimmedPrefWidths(inlineMax, 1389 t->trimmedPrefWidths(inlineMax,
1390 firstLineMinWidth, hasBreakableStart, lastLineMinWidth, hasB reakableEnd, 1390 firstLineMinWidth, hasBreakableStart, lastLineMinWidth, hasB reakableEnd,
1391 hasBreakableChar, hasBreak, firstLineMaxWidth, lastLineMaxWi dth, 1391 hasBreakableChar, hasBreak, firstLineMaxWidth, lastLineMaxWi dth,
1392 childMin, childMax, stripFrontSpaces, styleToUse.direction() ); 1392 childMin, childMax, stripFrontSpaces, styleToUse.direction() );
1393 1393
1394 // This text object will not be layed out, but it may still prov ide a breaking opportunity. 1394 // This text object will not be layed out, but it may still prov ide a breaking opportunity.
1395 if (!hasBreak && !childMax) { 1395 if (!hasBreak && !childMax) {
1396 if (autoWrap && (hasBreakableStart || hasBreakableEnd)) { 1396 if (autoWrap && (hasBreakableStart || hasBreakableEnd)) {
1397 minLogicalWidth = std::max(minLogicalWidth, inlineMin.to LayoutUnit()); 1397 minLogicalWidth = std::max(minLogicalWidth, inlineMin);
1398 inlineMin = FloatWillBeLayoutUnit(); 1398 inlineMin = LayoutUnit();
1399 } 1399 }
1400 continue; 1400 continue;
1401 } 1401 }
1402 1402
1403 if (stripFrontSpaces) 1403 if (stripFrontSpaces)
1404 trailingSpaceChild = child; 1404 trailingSpaceChild = child;
1405 else 1405 else
1406 trailingSpaceChild = 0; 1406 trailingSpaceChild = 0;
1407 1407
1408 // Add in text-indent. This is added in only once. 1408 // Add in text-indent. This is added in only once.
1409 FloatWillBeLayoutUnit ti; 1409 LayoutUnit ti;
1410 if (!addedTextIndent || hasRemainingNegativeTextIndent) { 1410 if (!addedTextIndent || hasRemainingNegativeTextIndent) {
1411 ti = textIndent; 1411 ti = textIndent;
1412 childMin += ti; 1412 childMin += ti;
1413 firstLineMinWidth += ti; 1413 firstLineMinWidth += ti;
1414 1414
1415 // It the text indent negative and larger than the child min imum, we re-use the remainder 1415 // It the text indent negative and larger than the child min imum, we re-use the remainder
1416 // in future minimum calculations, but using the negative va lue again on the maximum 1416 // in future minimum calculations, but using the negative va lue again on the maximum
1417 // will lead to under-counting the max pref width. 1417 // will lead to under-counting the max pref width.
1418 if (!addedTextIndent) { 1418 if (!addedTextIndent) {
1419 childMax += ti; 1419 childMax += ti;
1420 firstLineMaxWidth += ti; 1420 firstLineMaxWidth += ti;
1421 addedTextIndent = true; 1421 addedTextIndent = true;
1422 } 1422 }
1423 1423
1424 if (childMin < FloatWillBeLayoutUnit()) { 1424 if (childMin < LayoutUnit()) {
1425 textIndent = childMin; 1425 textIndent = childMin;
1426 hasRemainingNegativeTextIndent = true; 1426 hasRemainingNegativeTextIndent = true;
1427 } 1427 }
1428 } 1428 }
1429 1429
1430 // If we have no breakable characters at all, 1430 // If we have no breakable characters at all,
1431 // then this is the easy case. We add ourselves to the current 1431 // then this is the easy case. We add ourselves to the current
1432 // min and max and continue. 1432 // min and max and continue.
1433 if (!hasBreakableChar) { 1433 if (!hasBreakableChar) {
1434 inlineMin += childMin; 1434 inlineMin += childMin;
1435 } else { 1435 } else {
1436 if (hasBreakableStart) { 1436 if (hasBreakableStart) {
1437 minLogicalWidth = std::max(minLogicalWidth, inlineMin.to LayoutUnit()); 1437 minLogicalWidth = std::max(minLogicalWidth, inlineMin);
1438 } else { 1438 } else {
1439 inlineMin += firstLineMinWidth; 1439 inlineMin += firstLineMinWidth;
1440 minLogicalWidth = std::max(minLogicalWidth, inlineMin.to LayoutUnit()); 1440 minLogicalWidth = std::max(minLogicalWidth, inlineMin);
1441 childMin -= ti; 1441 childMin -= ti;
1442 } 1442 }
1443 1443
1444 inlineMin = childMin; 1444 inlineMin = childMin;
1445 1445
1446 if (hasBreakableEnd) { 1446 if (hasBreakableEnd) {
1447 minLogicalWidth = std::max(minLogicalWidth, inlineMin.to LayoutUnit()); 1447 minLogicalWidth = std::max(minLogicalWidth, inlineMin);
1448 inlineMin = FloatWillBeLayoutUnit(); 1448 inlineMin = LayoutUnit();
1449 shouldBreakLineAfterText = false; 1449 shouldBreakLineAfterText = false;
1450 } else { 1450 } else {
1451 minLogicalWidth = std::max(minLogicalWidth, inlineMin.to LayoutUnit()); 1451 minLogicalWidth = std::max(minLogicalWidth, inlineMin);
1452 inlineMin = lastLineMinWidth; 1452 inlineMin = lastLineMinWidth;
1453 shouldBreakLineAfterText = true; 1453 shouldBreakLineAfterText = true;
1454 } 1454 }
1455 } 1455 }
1456 1456
1457 if (hasBreak) { 1457 if (hasBreak) {
1458 inlineMax += firstLineMaxWidth; 1458 inlineMax += firstLineMaxWidth;
1459 maxLogicalWidth = std::max(maxLogicalWidth, inlineMax.toLayo utUnit()); 1459 maxLogicalWidth = std::max(maxLogicalWidth, inlineMax);
1460 maxLogicalWidth = std::max(maxLogicalWidth, childMax.toLayou tUnit()); 1460 maxLogicalWidth = std::max(maxLogicalWidth, childMax);
1461 inlineMax = lastLineMaxWidth; 1461 inlineMax = lastLineMaxWidth;
1462 addedTextIndent = true; 1462 addedTextIndent = true;
1463 } else { 1463 } else {
1464 inlineMax += std::max<float>(0, childMax); 1464 inlineMax += std::max(LayoutUnit(), childMax);
1465 } 1465 }
1466 } 1466 }
1467 1467
1468 // Ignore spaces after a list marker. 1468 // Ignore spaces after a list marker.
1469 if (child->isListMarker()) 1469 if (child->isListMarker())
1470 stripFrontSpaces = true; 1470 stripFrontSpaces = true;
1471 } else { 1471 } else {
1472 minLogicalWidth = std::max(minLogicalWidth, inlineMin.toLayoutUnit() ); 1472 minLogicalWidth = std::max(minLogicalWidth, inlineMin);
1473 maxLogicalWidth = std::max(maxLogicalWidth, inlineMax.toLayoutUnit() ); 1473 maxLogicalWidth = std::max(maxLogicalWidth, inlineMax);
1474 inlineMin = inlineMax = FloatWillBeLayoutUnit(); 1474 inlineMin = inlineMax = LayoutUnit();
1475 stripFrontSpaces = true; 1475 stripFrontSpaces = true;
1476 trailingSpaceChild = 0; 1476 trailingSpaceChild = 0;
1477 addedTextIndent = true; 1477 addedTextIndent = true;
1478 } 1478 }
1479 1479
1480 if (!child->isText() && child->isLayoutInline()) 1480 if (!child->isText() && child->isLayoutInline())
1481 isPrevChildInlineFlow = true; 1481 isPrevChildInlineFlow = true;
1482 else 1482 else
1483 isPrevChildInlineFlow = false; 1483 isPrevChildInlineFlow = false;
1484 1484
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1896 void LayoutBlockFlow::deleteEllipsisLineBoxes() 1896 void LayoutBlockFlow::deleteEllipsisLineBoxes()
1897 { 1897 {
1898 ETextAlign textAlign = style()->textAlign(); 1898 ETextAlign textAlign = style()->textAlign();
1899 bool ltr = style()->isLeftToRightDirection(); 1899 bool ltr = style()->isLeftToRightDirection();
1900 bool firstLine = true; 1900 bool firstLine = true;
1901 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { 1901 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) {
1902 if (curr->hasEllipsisBox()) { 1902 if (curr->hasEllipsisBox()) {
1903 curr->clearTruncation(); 1903 curr->clearTruncation();
1904 1904
1905 // Shift the line back where it belongs if we cannot accomodate an e llipsis. 1905 // Shift the line back where it belongs if we cannot accomodate an e llipsis.
1906 float logicalLeft = logicalLeftOffsetForLine(curr->lineTop(), firstL ine).toFloat(); 1906 LayoutUnit logicalLeft = logicalLeftOffsetForLine(curr->lineTop(), f irstLine).toFloat();
1907 float availableLogicalWidth = logicalRightOffsetForLine(curr->lineTo p(), false) - logicalLeft; 1907 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(curr->l ineTop(), false) - logicalLeft;
1908 float totalLogicalWidth = curr->logicalWidth(); 1908 LayoutUnit totalLogicalWidth = curr->logicalWidth();
1909 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, tota lLogicalWidth, availableLogicalWidth, 0); 1909 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, tota lLogicalWidth, availableLogicalWidth, 0);
1910 1910
1911 if (ltr) 1911 if (ltr)
1912 curr->adjustLogicalPosition((logicalLeft - curr->logicalLeft()), 0); 1912 curr->adjustLogicalPosition((logicalLeft - curr->logicalLeft()), 0);
1913 else 1913 else
1914 curr->adjustLogicalPosition(-(curr->logicalLeft() - logicalLeft) , 0); 1914 curr->adjustLogicalPosition(-(curr->logicalLeft() - logicalLeft) , 0);
1915 } 1915 }
1916 firstLine = false; 1916 firstLine = false;
1917 } 1917 }
1918 } 1918 }
(...skipping 11 matching lines...) Expand all
1930 float ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : fon t.width(constructTextRun(this, font, &horizontalEllipsisCharacter, 1, styleRef() , ellipsisDirection)); 1930 float ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : fon t.width(constructTextRun(this, font, &horizontalEllipsisCharacter, 1, styleRef() , ellipsisDirection));
1931 1931
1932 // For LTR text truncation, we want to get the right edge of our padding box , and then we want to see 1932 // For LTR text truncation, we want to get the right edge of our padding box , and then we want to see
1933 // if the right edge of a line box exceeds that. For RTL, we use the left e dge of the padding box and 1933 // if the right edge of a line box exceeds that. For RTL, we use the left e dge of the padding box and
1934 // check the left edge of the line box to see if it is less 1934 // check the left edge of the line box to see if it is less
1935 // Include the scrollbar for overflow blocks, which means we want to use "co ntentWidth()" 1935 // Include the scrollbar for overflow blocks, which means we want to use "co ntentWidth()"
1936 bool ltr = style()->isLeftToRightDirection(); 1936 bool ltr = style()->isLeftToRightDirection();
1937 ETextAlign textAlign = style()->textAlign(); 1937 ETextAlign textAlign = style()->textAlign();
1938 bool firstLine = true; 1938 bool firstLine = true;
1939 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { 1939 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) {
1940 float currLogicalLeft = curr->logicalLeft(); 1940 LayoutUnit currLogicalLeft = curr->logicalLeft();
1941 LayoutUnit blockRightEdge = logicalRightOffsetForLine(curr->lineTop(), f irstLine); 1941 LayoutUnit blockRightEdge = logicalRightOffsetForLine(curr->lineTop(), f irstLine);
1942 LayoutUnit blockLeftEdge = logicalLeftOffsetForLine(curr->lineTop(), fir stLine); 1942 LayoutUnit blockLeftEdge = logicalLeftOffsetForLine(curr->lineTop(), fir stLine);
1943 LayoutUnit lineBoxEdge = ltr ? currLogicalLeft + curr->logicalWidth() : currLogicalLeft; 1943 LayoutUnit lineBoxEdge = ltr ? currLogicalLeft + curr->logicalWidth() : currLogicalLeft;
1944 if ((ltr && lineBoxEdge > blockRightEdge) || (!ltr && lineBoxEdge < bloc kLeftEdge)) { 1944 if ((ltr && lineBoxEdge > blockRightEdge) || (!ltr && lineBoxEdge < bloc kLeftEdge)) {
1945 // This line spills out of our box in the appropriate direction. No w we need to see if the line 1945 // This line spills out of our box in the appropriate direction. No w we need to see if the line
1946 // can be truncated. In order for truncation to be possible, the li ne must have sufficient space to 1946 // can be truncated. In order for truncation to be possible, the li ne must have sufficient space to
1947 // accommodate our truncation string, and no replaced elements (imag es, tables) can overlap the ellipsis 1947 // accommodate our truncation string, and no replaced elements (imag es, tables) can overlap the ellipsis
1948 // space. 1948 // space.
1949 1949
1950 LayoutUnit width = firstLine ? firstLineEllipsisWidth : ellipsisWidt h; 1950 LayoutUnit width = firstLine ? firstLineEllipsisWidth : ellipsisWidt h;
1951 LayoutUnit blockEdge = ltr ? blockRightEdge : blockLeftEdge; 1951 LayoutUnit blockEdge = ltr ? blockRightEdge : blockLeftEdge;
1952 if (curr->lineCanAccommodateEllipsis(ltr, blockEdge, lineBoxEdge, wi dth)) { 1952 if (curr->lineCanAccommodateEllipsis(ltr, blockEdge, lineBoxEdge, wi dth)) {
1953 float totalLogicalWidth = curr->placeEllipsis(ellipsisStr, ltr, blockLeftEdge.toFloat(), blockRightEdge.toFloat(), width.toFloat()); 1953 LayoutUnit totalLogicalWidth = curr->placeEllipsis(ellipsisStr, ltr, blockLeftEdge, blockRightEdge, width);
1954 1954
1955 float logicalLeft = 0; // We are only intersted in the delta fro m the base position. 1955 LayoutUnit logicalLeft; // We are only interested in the delta f rom the base position.
1956 float availableLogicalWidth = (blockRightEdge - blockLeftEdge).t oFloat(); 1956 LayoutUnit availableLogicalWidth = blockRightEdge - blockLeftEdg e;
1957 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, totalLogicalWidth, availableLogicalWidth, 0); 1957 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, totalLogicalWidth, availableLogicalWidth, 0);
1958 if (ltr) 1958 if (ltr)
1959 curr->adjustLogicalPosition(logicalLeft, 0); 1959 curr->adjustLogicalPosition(logicalLeft, 0);
1960 else 1960 else
1961 curr->adjustLogicalPosition(logicalLeft - (availableLogicalW idth - totalLogicalWidth), 0); 1961 curr->adjustLogicalPosition(logicalLeft - (availableLogicalW idth - totalLogicalWidth), 0);
1962 } 1962 }
1963 } 1963 }
1964 firstLine = false; 1964 firstLine = false;
1965 } 1965 }
1966 } 1966 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2017 } 2017 }
2018 2018
2019 LayoutUnit LayoutBlockFlow::startAlignedOffsetForLine(LayoutUnit position, bool firstLine) 2019 LayoutUnit LayoutBlockFlow::startAlignedOffsetForLine(LayoutUnit position, bool firstLine)
2020 { 2020 {
2021 ETextAlign textAlign = style()->textAlign(); 2021 ETextAlign textAlign = style()->textAlign();
2022 2022
2023 if (textAlign == TASTART) // FIXME: Handle TAEND here 2023 if (textAlign == TASTART) // FIXME: Handle TAEND here
2024 return startOffsetForLine(position, firstLine); 2024 return startOffsetForLine(position, firstLine);
2025 2025
2026 // updateLogicalWidthForAlignment() handles the direction of the block so no need to consider it here 2026 // updateLogicalWidthForAlignment() handles the direction of the block so no need to consider it here
2027 float totalLogicalWidth = 0; 2027 LayoutUnit totalLogicalWidth;
2028 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat (); 2028 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false);
2029 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal se) - logicalLeft; 2029 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight() , false) - logicalLeft;
2030 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); 2030 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0);
2031 2031
2032 if (!style()->isLeftToRightDirection()) 2032 if (!style()->isLeftToRightDirection())
2033 return logicalWidth() - logicalLeft; 2033 return logicalWidth() - logicalLeft;
2034 return logicalLeft; 2034 return logicalLeft;
2035 } 2035 }
2036 2036
2037 } 2037 }
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutBlockFlow.h ('k') | Source/core/layout/LayoutBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698