| 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. | 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. |
| 4 * All right reserved. | 4 * All right reserved. |
| 5 * Copyright (C) 2010 Google Inc. All rights reserved. | 5 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 } | 356 } |
| 357 | 357 |
| 358 ETextAlign LayoutBlockFlow::textAlignmentForLine(bool endsWithSoftBreak) const { | 358 ETextAlign LayoutBlockFlow::textAlignmentForLine(bool endsWithSoftBreak) const { |
| 359 ETextAlign alignment = style()->textAlign(); | 359 ETextAlign alignment = style()->textAlign(); |
| 360 if (endsWithSoftBreak) | 360 if (endsWithSoftBreak) |
| 361 return alignment; | 361 return alignment; |
| 362 | 362 |
| 363 TextAlignLast alignmentLast = style()->getTextAlignLast(); | 363 TextAlignLast alignmentLast = style()->getTextAlignLast(); |
| 364 switch (alignmentLast) { | 364 switch (alignmentLast) { |
| 365 case TextAlignLastStart: | 365 case TextAlignLastStart: |
| 366 return TASTART; | 366 return ETextAlign::Start; |
| 367 case TextAlignLastEnd: | 367 case TextAlignLastEnd: |
| 368 return TAEND; | 368 return ETextAlign::End; |
| 369 case TextAlignLastLeft: | 369 case TextAlignLastLeft: |
| 370 return LEFT; | 370 return ETextAlign::Left; |
| 371 case TextAlignLastRight: | 371 case TextAlignLastRight: |
| 372 return RIGHT; | 372 return ETextAlign::Right; |
| 373 case TextAlignLastCenter: | 373 case TextAlignLastCenter: |
| 374 return CENTER; | 374 return ETextAlign::Center; |
| 375 case TextAlignLastJustify: | 375 case TextAlignLastJustify: |
| 376 return JUSTIFY; | 376 return ETextAlign::Justify; |
| 377 case TextAlignLastAuto: | 377 case TextAlignLastAuto: |
| 378 if (alignment == JUSTIFY) | 378 if (alignment == ETextAlign::Justify) |
| 379 return TASTART; | 379 return ETextAlign::Start; |
| 380 return alignment; | 380 return alignment; |
| 381 } | 381 } |
| 382 | 382 |
| 383 return alignment; | 383 return alignment; |
| 384 } | 384 } |
| 385 | 385 |
| 386 static void updateLogicalWidthForLeftAlignedBlock( | 386 static void updateLogicalWidthForLeftAlignedBlock( |
| 387 bool isLeftToRightDirection, | 387 bool isLeftToRightDirection, |
| 388 BidiRun* trailingSpaceRun, | 388 BidiRun* trailingSpaceRun, |
| 389 LayoutUnit& logicalLeft, | 389 LayoutUnit& logicalLeft, |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 rootInlineBox->getLineLayoutItem().style()->unicodeBidi() == Plaintext) | 663 rootInlineBox->getLineLayoutItem().style()->unicodeBidi() == Plaintext) |
| 664 direction = rootInlineBox->direction(); | 664 direction = rootInlineBox->direction(); |
| 665 else | 665 else |
| 666 direction = style()->direction(); | 666 direction = style()->direction(); |
| 667 | 667 |
| 668 // Armed with the total width of the line (without justification), | 668 // Armed with the total width of the line (without justification), |
| 669 // we now examine our text-align property in order to determine where to | 669 // we now examine our text-align property in order to determine where to |
| 670 // position the objects horizontally. The total width of the line can be | 670 // position the objects horizontally. The total width of the line can be |
| 671 // increased if we end up justifying text. | 671 // increased if we end up justifying text. |
| 672 switch (textAlign) { | 672 switch (textAlign) { |
| 673 case LEFT: | 673 case ETextAlign::Left: |
| 674 case WEBKIT_LEFT: | 674 case ETextAlign::WebkitLeft: |
| 675 updateLogicalWidthForLeftAlignedBlock( | 675 updateLogicalWidthForLeftAlignedBlock( |
| 676 style()->isLeftToRightDirection(), trailingSpaceRun, logicalLeft, | 676 style()->isLeftToRightDirection(), trailingSpaceRun, logicalLeft, |
| 677 totalLogicalWidth, availableLogicalWidth); | 677 totalLogicalWidth, availableLogicalWidth); |
| 678 break; | 678 break; |
| 679 case RIGHT: | 679 case ETextAlign::Right: |
| 680 case WEBKIT_RIGHT: | 680 case ETextAlign::WebkitRight: |
| 681 updateLogicalWidthForRightAlignedBlock( | 681 updateLogicalWidthForRightAlignedBlock( |
| 682 style()->isLeftToRightDirection(), trailingSpaceRun, logicalLeft, | 682 style()->isLeftToRightDirection(), trailingSpaceRun, logicalLeft, |
| 683 totalLogicalWidth, availableLogicalWidth); | 683 totalLogicalWidth, availableLogicalWidth); |
| 684 break; | 684 break; |
| 685 case CENTER: | 685 case ETextAlign::Center: |
| 686 case WEBKIT_CENTER: | 686 case ETextAlign::WebkitCenter: |
| 687 updateLogicalWidthForCenterAlignedBlock( | 687 updateLogicalWidthForCenterAlignedBlock( |
| 688 style()->isLeftToRightDirection(), trailingSpaceRun, logicalLeft, | 688 style()->isLeftToRightDirection(), trailingSpaceRun, logicalLeft, |
| 689 totalLogicalWidth, availableLogicalWidth); | 689 totalLogicalWidth, availableLogicalWidth); |
| 690 break; | 690 break; |
| 691 case JUSTIFY: | 691 case ETextAlign::Justify: |
| 692 adjustInlineDirectionLineBounds(expansionOpportunityCount, logicalLeft, | 692 adjustInlineDirectionLineBounds(expansionOpportunityCount, logicalLeft, |
| 693 availableLogicalWidth); | 693 availableLogicalWidth); |
| 694 if (expansionOpportunityCount) { | 694 if (expansionOpportunityCount) { |
| 695 if (trailingSpaceRun) { | 695 if (trailingSpaceRun) { |
| 696 totalLogicalWidth -= trailingSpaceRun->m_box->logicalWidth(); | 696 totalLogicalWidth -= trailingSpaceRun->m_box->logicalWidth(); |
| 697 trailingSpaceRun->m_box->setLogicalWidth(LayoutUnit()); | 697 trailingSpaceRun->m_box->setLogicalWidth(LayoutUnit()); |
| 698 } | 698 } |
| 699 break; | 699 break; |
| 700 } | 700 } |
| 701 // Fall through | 701 // Fall through |
| 702 case TASTART: | 702 case ETextAlign::Start: |
| 703 if (direction == LTR) | 703 if (direction == LTR) |
| 704 updateLogicalWidthForLeftAlignedBlock( | 704 updateLogicalWidthForLeftAlignedBlock( |
| 705 style()->isLeftToRightDirection(), trailingSpaceRun, logicalLeft, | 705 style()->isLeftToRightDirection(), trailingSpaceRun, logicalLeft, |
| 706 totalLogicalWidth, availableLogicalWidth); | 706 totalLogicalWidth, availableLogicalWidth); |
| 707 else | 707 else |
| 708 updateLogicalWidthForRightAlignedBlock( | 708 updateLogicalWidthForRightAlignedBlock( |
| 709 style()->isLeftToRightDirection(), trailingSpaceRun, logicalLeft, | 709 style()->isLeftToRightDirection(), trailingSpaceRun, logicalLeft, |
| 710 totalLogicalWidth, availableLogicalWidth); | 710 totalLogicalWidth, availableLogicalWidth); |
| 711 break; | 711 break; |
| 712 case TAEND: | 712 case ETextAlign::End: |
| 713 if (direction == LTR) | 713 if (direction == LTR) |
| 714 updateLogicalWidthForRightAlignedBlock( | 714 updateLogicalWidthForRightAlignedBlock( |
| 715 style()->isLeftToRightDirection(), trailingSpaceRun, logicalLeft, | 715 style()->isLeftToRightDirection(), trailingSpaceRun, logicalLeft, |
| 716 totalLogicalWidth, availableLogicalWidth); | 716 totalLogicalWidth, availableLogicalWidth); |
| 717 else | 717 else |
| 718 updateLogicalWidthForLeftAlignedBlock( | 718 updateLogicalWidthForLeftAlignedBlock( |
| 719 style()->isLeftToRightDirection(), trailingSpaceRun, logicalLeft, | 719 style()->isLeftToRightDirection(), trailingSpaceRun, logicalLeft, |
| 720 totalLogicalWidth, availableLogicalWidth); | 720 totalLogicalWidth, availableLogicalWidth); |
| 721 break; | 721 break; |
| 722 } | 722 } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 for (; r; r = r->next()) { | 813 for (; r; r = r->next()) { |
| 814 if (!r->m_box || r->m_lineLayoutItem.isOutOfFlowPositioned() || | 814 if (!r->m_box || r->m_lineLayoutItem.isOutOfFlowPositioned() || |
| 815 r->m_box->isLineBreak()) { | 815 r->m_box->isLineBreak()) { |
| 816 continue; // Positioned objects are only participating to figure out | 816 continue; // Positioned objects are only participating to figure out |
| 817 // their correct static x position. They have no effect on the | 817 // their correct static x position. They have no effect on the |
| 818 // width. Similarly, line break boxes have no effect on the | 818 // width. Similarly, line break boxes have no effect on the |
| 819 // width. | 819 // width. |
| 820 } | 820 } |
| 821 if (r->m_lineLayoutItem.isText()) { | 821 if (r->m_lineLayoutItem.isText()) { |
| 822 LineLayoutText rt(r->m_lineLayoutItem); | 822 LineLayoutText rt(r->m_lineLayoutItem); |
| 823 if (textAlign == JUSTIFY && r != trailingSpaceRun && | 823 if (textAlign == ETextAlign::Justify && r != trailingSpaceRun && |
| 824 textJustify != TextJustifyNone) { | 824 textJustify != TextJustifyNone) { |
| 825 if (!isAfterExpansion) | 825 if (!isAfterExpansion) |
| 826 toInlineTextBox(r->m_box)->setCanHaveLeadingExpansion(true); | 826 toInlineTextBox(r->m_box)->setCanHaveLeadingExpansion(true); |
| 827 expansions.addRunWithExpansions(*r, isAfterExpansion, textJustify); | 827 expansions.addRunWithExpansions(*r, isAfterExpansion, textJustify); |
| 828 } | 828 } |
| 829 | 829 |
| 830 if (rt.textLength()) { | 830 if (rt.textLength()) { |
| 831 if (!r->m_start && needsWordSpacing && | 831 if (!r->m_start && needsWordSpacing && |
| 832 isSpaceOrNewline(rt.characterAt(r->m_start))) | 832 isSpaceOrNewline(rt.characterAt(r->m_start))) |
| 833 totalLogicalWidth += rt.style(lineInfo.isFirstLine()) | 833 totalLogicalWidth += rt.style(lineInfo.isFirstLine()) |
| (...skipping 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2463 } | 2463 } |
| 2464 } | 2464 } |
| 2465 | 2465 |
| 2466 LayoutUnit LayoutBlockFlow::startAlignedOffsetForLine( | 2466 LayoutUnit LayoutBlockFlow::startAlignedOffsetForLine( |
| 2467 LayoutUnit position, | 2467 LayoutUnit position, |
| 2468 IndentTextOrNot indentText) { | 2468 IndentTextOrNot indentText) { |
| 2469 ETextAlign textAlign = style()->textAlign(); | 2469 ETextAlign textAlign = style()->textAlign(); |
| 2470 | 2470 |
| 2471 bool applyIndentText; | 2471 bool applyIndentText; |
| 2472 switch (textAlign) { // FIXME: Handle TAEND here | 2472 switch (textAlign) { // FIXME: Handle TAEND here |
| 2473 case LEFT: | 2473 case ETextAlign::Left: |
| 2474 case WEBKIT_LEFT: | 2474 case ETextAlign::WebkitLeft: |
| 2475 applyIndentText = style()->isLeftToRightDirection(); | 2475 applyIndentText = style()->isLeftToRightDirection(); |
| 2476 break; | 2476 break; |
| 2477 case RIGHT: | 2477 case ETextAlign::Right: |
| 2478 case WEBKIT_RIGHT: | 2478 case ETextAlign::WebkitRight: |
| 2479 applyIndentText = !style()->isLeftToRightDirection(); | 2479 applyIndentText = !style()->isLeftToRightDirection(); |
| 2480 break; | 2480 break; |
| 2481 case TASTART: | 2481 case ETextAlign::Start: |
| 2482 applyIndentText = true; | 2482 applyIndentText = true; |
| 2483 break; | 2483 break; |
| 2484 default: | 2484 default: |
| 2485 applyIndentText = false; | 2485 applyIndentText = false; |
| 2486 } | 2486 } |
| 2487 | 2487 |
| 2488 if (applyIndentText) | 2488 if (applyIndentText) |
| 2489 return startOffsetForLine(position, indentText); | 2489 return startOffsetForLine(position, indentText); |
| 2490 | 2490 |
| 2491 // updateLogicalWidthForAlignment() handles the direction of the block so no | 2491 // updateLogicalWidthForAlignment() handles the direction of the block so no |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2511 | 2511 |
| 2512 bool LayoutBlockFlow::paintedOutputOfObjectHasNoEffectRegardlessOfSize() const { | 2512 bool LayoutBlockFlow::paintedOutputOfObjectHasNoEffectRegardlessOfSize() const { |
| 2513 // LayoutBlockFlow is in charge of paint invalidation of the first line. | 2513 // LayoutBlockFlow is in charge of paint invalidation of the first line. |
| 2514 if (firstLineBox()) | 2514 if (firstLineBox()) |
| 2515 return false; | 2515 return false; |
| 2516 | 2516 |
| 2517 return LayoutBlock::paintedOutputOfObjectHasNoEffectRegardlessOfSize(); | 2517 return LayoutBlock::paintedOutputOfObjectHasNoEffectRegardlessOfSize(); |
| 2518 } | 2518 } |
| 2519 | 2519 |
| 2520 } // namespace blink | 2520 } // namespace blink |
| OLD | NEW |