| 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 * Copyright (C) 2013 Adobe Systems Incorporated. | 5 * Copyright (C) 2013 Adobe Systems Incorporated. |
| 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 18 matching lines...) Expand all Loading... |
| 29 #include "core/rendering/RenderCombineText.h" | 29 #include "core/rendering/RenderCombineText.h" |
| 30 #include "core/rendering/RenderInline.h" | 30 #include "core/rendering/RenderInline.h" |
| 31 #include "core/rendering/RenderLayer.h" | 31 #include "core/rendering/RenderLayer.h" |
| 32 #include "core/rendering/RenderListMarker.h" | 32 #include "core/rendering/RenderListMarker.h" |
| 33 #include "core/rendering/RenderRubyRun.h" | 33 #include "core/rendering/RenderRubyRun.h" |
| 34 #include "core/rendering/break_lines.h" | 34 #include "core/rendering/break_lines.h" |
| 35 #include "core/rendering/line/LineBreaker.h" | 35 #include "core/rendering/line/LineBreaker.h" |
| 36 #include "core/rendering/line/LineInfo.h" | 36 #include "core/rendering/line/LineInfo.h" |
| 37 #include "core/rendering/line/LineWidth.h" | 37 #include "core/rendering/line/LineWidth.h" |
| 38 #include "core/rendering/line/TrailingObjects.h" | 38 #include "core/rendering/line/TrailingObjects.h" |
| 39 #include "core/rendering/shapes/ShapeInsideInfo.h" | |
| 40 #include "core/rendering/svg/RenderSVGInlineText.h" | 39 #include "core/rendering/svg/RenderSVGInlineText.h" |
| 41 | 40 |
| 42 namespace WebCore { | 41 namespace WebCore { |
| 43 | 42 |
| 44 // We don't let our line box tree for a single line get any deeper than this. | 43 // We don't let our line box tree for a single line get any deeper than this. |
| 45 const unsigned cMaxLineDepth = 200; | 44 const unsigned cMaxLineDepth = 200; |
| 46 | 45 |
| 47 class WordMeasurement { | 46 class WordMeasurement { |
| 48 public: | 47 public: |
| 49 WordMeasurement() | 48 WordMeasurement() |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 | 499 |
| 501 inline float firstPositiveWidth(const WordMeasurements& wordMeasurements) | 500 inline float firstPositiveWidth(const WordMeasurements& wordMeasurements) |
| 502 { | 501 { |
| 503 for (size_t i = 0; i < wordMeasurements.size(); ++i) { | 502 for (size_t i = 0; i < wordMeasurements.size(); ++i) { |
| 504 if (wordMeasurements[i].width > 0) | 503 if (wordMeasurements[i].width > 0) |
| 505 return wordMeasurements[i].width; | 504 return wordMeasurements[i].width; |
| 506 } | 505 } |
| 507 return 0; | 506 return 0; |
| 508 } | 507 } |
| 509 | 508 |
| 510 inline void updateSegmentsForShapes(RenderBlockFlow* block, const FloatingObject
* lastFloatFromPreviousLine, const WordMeasurements& wordMeasurements, LineWidth
& width, bool isFirstLine) | |
| 511 { | |
| 512 ASSERT(lastFloatFromPreviousLine); | |
| 513 | |
| 514 ShapeInsideInfo* shapeInsideInfo = block->layoutShapeInsideInfo(); | |
| 515 if (!lastFloatFromPreviousLine->isPlaced() || !shapeInsideInfo) | |
| 516 return; | |
| 517 | |
| 518 bool isHorizontalWritingMode = block->isHorizontalWritingMode(); | |
| 519 LayoutUnit logicalOffsetFromShapeContainer = block->logicalOffsetFromShapeAn
cestorContainer(&shapeInsideInfo->owner()).height(); | |
| 520 | |
| 521 LayoutUnit lineLogicalTop = block->logicalHeight() + logicalOffsetFromShapeC
ontainer; | |
| 522 LayoutUnit lineLogicalHeight = block->lineHeight(isFirstLine, isHorizontalWr
itingMode ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); | |
| 523 LayoutUnit lineLogicalBottom = lineLogicalTop + lineLogicalHeight; | |
| 524 | |
| 525 LayoutUnit floatLogicalTop = block->logicalTopForFloat(lastFloatFromPrevious
Line); | |
| 526 LayoutUnit floatLogicalBottom = block->logicalBottomForFloat(lastFloatFromPr
eviousLine); | |
| 527 | |
| 528 bool lineOverlapsWithFloat = (floatLogicalTop < lineLogicalBottom) && (lineL
ogicalTop < floatLogicalBottom); | |
| 529 if (!lineOverlapsWithFloat) | |
| 530 return; | |
| 531 | |
| 532 // FIXME: We need to remove this once we support multiple-segment polygons | |
| 533 if (shapeInsideInfo->segments().size() > 1) | |
| 534 return; | |
| 535 | |
| 536 float minSegmentWidth = firstPositiveWidth(wordMeasurements); | |
| 537 | |
| 538 LayoutUnit floatLogicalWidth = block->logicalWidthForFloat(lastFloatFromPrev
iousLine); | |
| 539 LayoutUnit availableLogicalWidth = block->logicalWidth() - block->logicalRig
htForFloat(lastFloatFromPreviousLine); | |
| 540 if (availableLogicalWidth < minSegmentWidth) | |
| 541 block->setLogicalHeight(floatLogicalBottom); | |
| 542 | |
| 543 if (block->logicalHeight() < floatLogicalTop) { | |
| 544 shapeInsideInfo->adjustLogicalLineTop(minSegmentWidth + floatLogicalWidt
h); | |
| 545 block->setLogicalHeight(shapeInsideInfo->logicalLineTop() - logicalOffse
tFromShapeContainer); | |
| 546 } | |
| 547 | |
| 548 lineLogicalTop = block->logicalHeight() + logicalOffsetFromShapeContainer; | |
| 549 | |
| 550 shapeInsideInfo->updateSegmentsForLine(lineLogicalTop, lineLogicalHeight); | |
| 551 width.updateCurrentShapeSegment(); | |
| 552 width.updateAvailableWidth(); | |
| 553 } | |
| 554 | |
| 555 inline float measureHyphenWidth(RenderText* renderer, const Font& font, TextDire
ction textDirection) | 509 inline float measureHyphenWidth(RenderText* renderer, const Font& font, TextDire
ction textDirection) |
| 556 { | 510 { |
| 557 RenderStyle* style = renderer->style(); | 511 RenderStyle* style = renderer->style(); |
| 558 return font.width(RenderBlockFlow::constructTextRun(renderer, font, | 512 return font.width(RenderBlockFlow::constructTextRun(renderer, font, |
| 559 style->hyphenString().string(), style, style->direction())); | 513 style->hyphenString().string(), style, style->direction())); |
| 560 } | 514 } |
| 561 | 515 |
| 562 ALWAYS_INLINE TextDirection textDirectionFromUnicode(WTF::Unicode::Direction dir
ection) | 516 ALWAYS_INLINE TextDirection textDirectionFromUnicode(WTF::Unicode::Direction dir
ection) |
| 563 { | 517 { |
| 564 return direction == WTF::Unicode::RightToLeft | 518 return direction == WTF::Unicode::RightToLeft |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 additionalTmpW = textWidth(renderText, lastSpace, m_current.offs
et() - lastSpace, font, m_width.currentWidth(), isFixedPitch, m_collapseWhiteSpa
ce, &wordMeasurement.fallbackFonts); | 666 additionalTmpW = textWidth(renderText, lastSpace, m_current.offs
et() - lastSpace, font, m_width.currentWidth(), isFixedPitch, m_collapseWhiteSpa
ce, &wordMeasurement.fallbackFonts); |
| 713 | 667 |
| 714 wordMeasurement.width = additionalTmpW + wordSpacingForWordMeasureme
nt; | 668 wordMeasurement.width = additionalTmpW + wordSpacingForWordMeasureme
nt; |
| 715 additionalTmpW += lastSpaceWordSpacing; | 669 additionalTmpW += lastSpaceWordSpacing; |
| 716 m_width.addUncommittedWidth(additionalTmpW); | 670 m_width.addUncommittedWidth(additionalTmpW); |
| 717 if (!m_appliedStartWidth) { | 671 if (!m_appliedStartWidth) { |
| 718 m_width.addUncommittedWidth(inlineLogicalWidth(m_current.object(
), true, false).toFloat()); | 672 m_width.addUncommittedWidth(inlineLogicalWidth(m_current.object(
), true, false).toFloat()); |
| 719 m_appliedStartWidth = true; | 673 m_appliedStartWidth = true; |
| 720 } | 674 } |
| 721 | 675 |
| 722 if (m_lastFloatFromPreviousLine) | |
| 723 updateSegmentsForShapes(m_block, m_lastFloatFromPreviousLine, wo
rdMeasurements, m_width, m_lineInfo.isFirstLine()); | |
| 724 | |
| 725 applyWordSpacing = wordSpacing && m_currentCharacterIsSpace; | 676 applyWordSpacing = wordSpacing && m_currentCharacterIsSpace; |
| 726 | 677 |
| 727 if (!m_width.committedWidth() && m_autoWrap && !m_width.fitsOnLine()
) | 678 if (!m_width.committedWidth() && m_autoWrap && !m_width.fitsOnLine()
) |
| 728 m_width.fitBelowFloats(m_lineInfo.isFirstLine()); | 679 m_width.fitBelowFloats(m_lineInfo.isFirstLine()); |
| 729 | 680 |
| 730 if (m_autoWrap || breakWords) { | 681 if (m_autoWrap || breakWords) { |
| 731 // If we break only after white-space, consider the current char
acter | 682 // If we break only after white-space, consider the current char
acter |
| 732 // as candidate width for this line. | 683 // as candidate width for this line. |
| 733 bool lineWasTooWide = false; | 684 bool lineWasTooWide = false; |
| 734 if (m_width.fitsOnLine() && m_currentCharacterIsSpace && m_curre
ntStyle->breakOnlyAfterWhiteSpace() && !midWordBreak) { | 685 if (m_width.fitsOnLine() && m_currentCharacterIsSpace && m_curre
ntStyle->breakOnlyAfterWhiteSpace() && !midWordBreak) { |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 return IndentText; | 902 return IndentText; |
| 952 if (isAfterHardLineBreak && style->textIndentLine() == TextIndentEachLine) | 903 if (isAfterHardLineBreak && style->textIndentLine() == TextIndentEachLine) |
| 953 return IndentText; | 904 return IndentText; |
| 954 | 905 |
| 955 return DoNotIndentText; | 906 return DoNotIndentText; |
| 956 } | 907 } |
| 957 | 908 |
| 958 } | 909 } |
| 959 | 910 |
| 960 #endif // BreakingContextInlineHeaders_h | 911 #endif // BreakingContextInlineHeaders_h |
| OLD | NEW |