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

Side by Side Diff: Source/core/layout/line/InlineFlowBox.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/line/InlineFlowBox.h ('k') | Source/core/layout/line/InlineTextBox.h » ('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) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { 67 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
68 if (curr->isInlineFlowBox()) 68 if (curr->isInlineFlowBox())
69 totWidth += toInlineFlowBox(curr)->getFlowSpacingLogicalWidth(); 69 totWidth += toInlineFlowBox(curr)->getFlowSpacingLogicalWidth();
70 } 70 }
71 return totWidth; 71 return totWidth;
72 } 72 }
73 73
74 IntRect InlineFlowBox::roundedFrameRect() const 74 IntRect InlineFlowBox::roundedFrameRect() const
75 { 75 {
76 // Begin by snapping the x and y coordinates to the nearest pixel. 76 // Begin by snapping the x and y coordinates to the nearest pixel.
77 int snappedX = lroundf(x()); 77 int snappedX = x().round();
78 int snappedY = lroundf(y()); 78 int snappedY = y().round();
79 79
80 int snappedMaxX = lroundf(x() + width()); 80 int snappedMaxX = (x() + width()).round();
81 int snappedMaxY = lroundf(y() + height()); 81 int snappedMaxY = (y() + height()).round();
82 82
83 return IntRect(snappedX, snappedY, snappedMaxX - snappedX, snappedMaxY - sna ppedY); 83 return IntRect(snappedX, snappedY, snappedMaxX - snappedX, snappedMaxY - sna ppedY);
84 } 84 }
85 85
86 static void setHasTextDescendantsOnAncestors(InlineFlowBox* box) 86 static void setHasTextDescendantsOnAncestors(InlineFlowBox* box)
87 { 87 {
88 while (box && !box->hasTextDescendants()) { 88 while (box && !box->hasTextDescendants()) {
89 box->setHasTextDescendants(); 89 box->setHasTextDescendants();
90 box = box->parent(); 90 box = box->parent();
91 } 91 }
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 attachLineBoxToLayoutObject(); 247 attachLineBoxToLayoutObject();
248 for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) 248 for (InlineBox* child = firstChild(); child; child = child->nextOnLine())
249 child->attachLine(); 249 child->attachLine();
250 } 250 }
251 251
252 void InlineFlowBox::attachLineBoxToLayoutObject() 252 void InlineFlowBox::attachLineBoxToLayoutObject()
253 { 253 {
254 lineBoxes()->attachLineBox(this); 254 lineBoxes()->attachLineBox(this);
255 } 255 }
256 256
257 void InlineFlowBox::adjustPosition(FloatWillBeLayoutUnit dx, FloatWillBeLayoutUn it dy) 257 void InlineFlowBox::adjustPosition(LayoutUnit dx, LayoutUnit dy)
258 { 258 {
259 InlineBox::adjustPosition(dx, dy); 259 InlineBox::adjustPosition(dx, dy);
260 for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) { 260 for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
261 if (child->layoutObject().isOutOfFlowPositioned()) 261 if (child->layoutObject().isOutOfFlowPositioned())
262 continue; 262 continue;
263 child->adjustPosition(dx, dy); 263 child->adjustPosition(dx, dy);
264 } 264 }
265 if (m_overflow) 265 if (m_overflow)
266 m_overflow->move(dx, dy); // FIXME: Rounding error here since overflow w as pixel snapped, but nobody other than list markers passes non-integral values here. 266 m_overflow->move(dx, dy); // FIXME: Rounding error here since overflow w as pixel snapped, but nobody other than list markers passes non-integral values here.
267 } 267 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 355
356 // Recur into our children. 356 // Recur into our children.
357 for (InlineBox* currChild = firstChild(); currChild; currChild = currChild-> nextOnLine()) { 357 for (InlineBox* currChild = firstChild(); currChild; currChild = currChild-> nextOnLine()) {
358 if (currChild->isInlineFlowBox()) { 358 if (currChild->isInlineFlowBox()) {
359 InlineFlowBox* currFlow = toInlineFlowBox(currChild); 359 InlineFlowBox* currFlow = toInlineFlowBox(currChild);
360 currFlow->determineSpacingForFlowBoxes(lastLine, isLogicallyLastRunW rapped, logicallyLastRunLayoutObject); 360 currFlow->determineSpacingForFlowBoxes(lastLine, isLogicallyLastRunW rapped, logicallyLastRunLayoutObject);
361 } 361 }
362 } 362 }
363 } 363 }
364 364
365 FloatWillBeLayoutUnit InlineFlowBox::placeBoxesInInlineDirection(FloatWillBeLayo utUnit logicalLeft, bool& needsWordSpacing) 365 LayoutUnit InlineFlowBox::placeBoxesInInlineDirection(LayoutUnit logicalLeft, bo ol& needsWordSpacing)
366 { 366 {
367 // Set our x position. 367 // Set our x position.
368 beginPlacingBoxRangesInInlineDirection(logicalLeft); 368 beginPlacingBoxRangesInInlineDirection(logicalLeft);
369 369
370 FloatWillBeLayoutUnit startLogicalLeft = logicalLeft; 370 LayoutUnit startLogicalLeft = logicalLeft;
371 logicalLeft += borderLogicalLeft() + paddingLogicalLeft(); 371 logicalLeft += borderLogicalLeft() + paddingLogicalLeft();
372 372
373 FloatWillBeLayoutUnit minLogicalLeft = startLogicalLeft; 373 LayoutUnit minLogicalLeft = startLogicalLeft;
374 FloatWillBeLayoutUnit maxLogicalRight = logicalLeft; 374 LayoutUnit maxLogicalRight = logicalLeft;
375 375
376 placeBoxRangeInInlineDirection(firstChild(), 0, logicalLeft, minLogicalLeft, maxLogicalRight, needsWordSpacing); 376 placeBoxRangeInInlineDirection(firstChild(), 0, logicalLeft, minLogicalLeft, maxLogicalRight, needsWordSpacing);
377 377
378 logicalLeft += borderLogicalRight() + paddingLogicalRight(); 378 logicalLeft += borderLogicalRight() + paddingLogicalRight();
379 endPlacingBoxRangesInInlineDirection(startLogicalLeft, logicalLeft, minLogic alLeft, maxLogicalRight); 379 endPlacingBoxRangesInInlineDirection(startLogicalLeft, logicalLeft, minLogic alLeft, maxLogicalRight);
380 return logicalLeft; 380 return logicalLeft;
381 } 381 }
382 382
383 FloatWillBeLayoutUnit InlineFlowBox::placeBoxRangeInInlineDirection(InlineBox* f irstChild, InlineBox* lastChild, 383 LayoutUnit InlineFlowBox::placeBoxRangeInInlineDirection(InlineBox* firstChild, InlineBox* lastChild,
384 FloatWillBeLayoutUnit& logicalLeft, FloatWillBeLayoutUnit& minLogicalLeft, F loatWillBeLayoutUnit& maxLogicalRight, bool& needsWordSpacing) 384 LayoutUnit& logicalLeft, LayoutUnit& minLogicalLeft, LayoutUnit& maxLogicalR ight, bool& needsWordSpacing)
385 { 385 {
386 for (InlineBox* curr = firstChild; curr && curr != lastChild; curr = curr->n extOnLine()) { 386 for (InlineBox* curr = firstChild; curr && curr != lastChild; curr = curr->n extOnLine()) {
387 if (curr->layoutObject().isText()) { 387 if (curr->layoutObject().isText()) {
388 InlineTextBox* text = toInlineTextBox(curr); 388 InlineTextBox* text = toInlineTextBox(curr);
389 LayoutText& rt = text->layoutObject(); 389 LayoutText& rt = text->layoutObject();
390 FloatWillBeLayoutUnit space; 390 LayoutUnit space;
391 if (rt.textLength()) { 391 if (rt.textLength()) {
392 if (needsWordSpacing && isSpaceOrNewline(rt.characterAt(text->st art()))) 392 if (needsWordSpacing && isSpaceOrNewline(rt.characterAt(text->st art())))
393 space = rt.style(isFirstLineStyle())->font().fontDescription ().wordSpacing(); 393 space = rt.style(isFirstLineStyle())->font().fontDescription ().wordSpacing();
394 needsWordSpacing = !isSpaceOrNewline(rt.characterAt(text->end()) ); 394 needsWordSpacing = !isSpaceOrNewline(rt.characterAt(text->end()) );
395 } 395 }
396 if (isLeftToRightDirection()) { 396 if (isLeftToRightDirection()) {
397 logicalLeft += space; 397 logicalLeft += space;
398 text->setLogicalLeft(logicalLeft); 398 text->setLogicalLeft(logicalLeft);
399 } else { 399 } else {
400 text->setLogicalLeft(logicalLeft); 400 text->setLogicalLeft(logicalLeft);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 } else if (curr->verticalAlign() == BOTTOM) { 549 } else if (curr->verticalAlign() == BOTTOM) {
550 if (maxPositionBottom < boxHeight) 550 if (maxPositionBottom < boxHeight)
551 maxPositionBottom = boxHeight; 551 maxPositionBottom = boxHeight;
552 } else if (!inlineFlowBox || strictMode || inlineFlowBox->hasTextChildre n() || (inlineFlowBox->descendantsHaveSameLineHeightAndBaseline() && inlineFlowB ox->hasTextDescendants()) || inlineFlowBox->boxModelObject()->hasInlineDirection BordersOrPadding()) { 552 } else if (!inlineFlowBox || strictMode || inlineFlowBox->hasTextChildre n() || (inlineFlowBox->descendantsHaveSameLineHeightAndBaseline() && inlineFlowB ox->hasTextDescendants()) || inlineFlowBox->boxModelObject()->hasInlineDirection BordersOrPadding()) {
553 // Note that these values can be negative. Even though we only affe ct the maxAscent and maxDescent values 553 // Note that these values can be negative. Even though we only affe ct the maxAscent and maxDescent values
554 // if our box (excluding line-height) was above (for ascent) or belo w (for descent) the root baseline, once you factor in line-height 554 // if our box (excluding line-height) was above (for ascent) or belo w (for descent) the root baseline, once you factor in line-height
555 // the final box can end up being fully above or fully below the roo t box's baseline! This is ok, but what it 555 // the final box can end up being fully above or fully below the roo t box's baseline! This is ok, but what it
556 // means is that ascent and descent (including leading), can end up being negative. The setMaxAscent and 556 // means is that ascent and descent (including leading), can end up being negative. The setMaxAscent and
557 // setMaxDescent booleans are used to ensure that we're willing to i nitially set maxAscent/Descent to negative 557 // setMaxDescent booleans are used to ensure that we're willing to i nitially set maxAscent/Descent to negative
558 // values. 558 // values.
559 ascent -= curr->logicalTop(); 559 ascent -= curr->logicalTop().round();
560 descent += curr->logicalTop(); 560 descent += curr->logicalTop().round();
561 if (affectsAscent && (maxAscent < ascent || !setMaxAscent)) { 561 if (affectsAscent && (maxAscent < ascent || !setMaxAscent)) {
562 maxAscent = ascent; 562 maxAscent = ascent;
563 setMaxAscent = true; 563 setMaxAscent = true;
564 } 564 }
565 565
566 if (affectsDescent && (maxDescent < descent || !setMaxDescent)) { 566 if (affectsDescent && (maxDescent < descent || !setMaxDescent)) {
567 maxDescent = descent; 567 maxDescent = descent;
568 setMaxDescent = true; 568 setMaxDescent = true;
569 } 569 }
570 } 570 }
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 selectionBottom = std::max<LayoutUnit>(selectionBottom, pixelSnapped LogicalBottom()); 701 selectionBottom = std::max<LayoutUnit>(selectionBottom, pixelSnapped LogicalBottom());
702 lineBottom = std::max<LayoutUnit>(lineBottom, pixelSnappedLogicalBot tom()); 702 lineBottom = std::max<LayoutUnit>(lineBottom, pixelSnappedLogicalBot tom());
703 lineBottomIncludingMargins = std::max(lineBottom, lineBottomIncludin gMargins); 703 lineBottomIncludingMargins = std::max(lineBottom, lineBottomIncludin gMargins);
704 } 704 }
705 705
706 if (layoutObject().style()->isFlippedLinesWritingMode()) 706 if (layoutObject().style()->isFlippedLinesWritingMode())
707 flipLinesInBlockDirection(lineTopIncludingMargins, lineBottomIncludi ngMargins); 707 flipLinesInBlockDirection(lineTopIncludingMargins, lineBottomIncludi ngMargins);
708 } 708 }
709 } 709 }
710 710
711 void InlineFlowBox::computeMaxLogicalTop(FloatWillBeLayoutUnit& maxLogicalTop) c onst 711 void InlineFlowBox::computeMaxLogicalTop(LayoutUnit& maxLogicalTop) const
712 { 712 {
713 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { 713 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
714 if (curr->layoutObject().isOutOfFlowPositioned()) 714 if (curr->layoutObject().isOutOfFlowPositioned())
715 continue; // Positioned placeholders don't affect calculations. 715 continue; // Positioned placeholders don't affect calculations.
716 716
717 if (descendantsHaveSameLineHeightAndBaseline()) 717 if (descendantsHaveSameLineHeightAndBaseline())
718 continue; 718 continue;
719 719
720 maxLogicalTop = std::max<FloatWillBeLayoutUnit>(maxLogicalTop, curr->y() ); 720 maxLogicalTop = std::max<LayoutUnit>(maxLogicalTop, curr->y());
721 FloatWillBeLayoutUnit localMaxLogicalTop; 721 LayoutUnit localMaxLogicalTop;
722 if (curr->isInlineFlowBox()) 722 if (curr->isInlineFlowBox())
723 toInlineFlowBox(curr)->computeMaxLogicalTop(localMaxLogicalTop); 723 toInlineFlowBox(curr)->computeMaxLogicalTop(localMaxLogicalTop);
724 maxLogicalTop = std::max<FloatWillBeLayoutUnit>(maxLogicalTop, localMaxL ogicalTop); 724 maxLogicalTop = std::max<LayoutUnit>(maxLogicalTop, localMaxLogicalTop);
725 } 725 }
726 } 726 }
727 727
728 void InlineFlowBox::flipLinesInBlockDirection(LayoutUnit lineTop, LayoutUnit lin eBottom) 728 void InlineFlowBox::flipLinesInBlockDirection(LayoutUnit lineTop, LayoutUnit lin eBottom)
729 { 729 {
730 // Flip the box on the line such that the top is now relative to the lineBot tom instead of the lineTop. 730 // Flip the box on the line such that the top is now relative to the lineBot tom instead of the lineTop.
731 setLogicalTop(lineBottom - (logicalTop() - lineTop) - logicalHeight()); 731 setLogicalTop(lineBottom - (logicalTop() - lineTop) - logicalHeight());
732 732
733 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { 733 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
734 if (curr->layoutObject().isOutOfFlowPositioned()) 734 if (curr->layoutObject().isOutOfFlowPositioned())
(...skipping 16 matching lines...) Expand all
751 WritingMode writingMode = style.writingMode(); 751 WritingMode writingMode = style.writingMode();
752 ShadowList* boxShadow = style.boxShadow(); 752 ShadowList* boxShadow = style.boxShadow();
753 if (!boxShadow) 753 if (!boxShadow)
754 return; 754 return;
755 755
756 LayoutRectOutsets outsets(boxShadow->rectOutsetsIncludingOriginal()); 756 LayoutRectOutsets outsets(boxShadow->rectOutsetsIncludingOriginal());
757 // Similar to how glyph overflow works, if our lines are flipped, then it's actually the opposite shadow that applies, since 757 // Similar to how glyph overflow works, if our lines are flipped, then it's actually the opposite shadow that applies, since
758 // the line is "upside down" in terms of block coordinates. 758 // the line is "upside down" in terms of block coordinates.
759 LayoutRectOutsets logicalOutsets(outsets.logicalOutsetsWithFlippedLines(writ ingMode)); 759 LayoutRectOutsets logicalOutsets(outsets.logicalOutsetsWithFlippedLines(writ ingMode));
760 760
761 LayoutRect shadowBounds(logicalFrameRect().toLayoutRect()); 761 LayoutRect shadowBounds(logicalFrameRect());
762 shadowBounds.expand(logicalOutsets); 762 shadowBounds.expand(logicalOutsets);
763 logicalVisualOverflow.unite(shadowBounds); 763 logicalVisualOverflow.unite(shadowBounds);
764 } 764 }
765 765
766 inline void InlineFlowBox::addBorderOutsetVisualOverflow(LayoutRect& logicalVisu alOverflow) 766 inline void InlineFlowBox::addBorderOutsetVisualOverflow(LayoutRect& logicalVisu alOverflow)
767 { 767 {
768 // border-image-outset on root line boxes is applying to the block and not t o the lines. 768 // border-image-outset on root line boxes is applying to the block and not t o the lines.
769 if (!parent()) 769 if (!parent())
770 return; 770 return;
771 771
772 const ComputedStyle& style = layoutObject().styleRef(isFirstLineStyle()); 772 const ComputedStyle& style = layoutObject().styleRef(isFirstLineStyle());
773 if (!style.hasBorderImageOutsets()) 773 if (!style.hasBorderImageOutsets())
774 return; 774 return;
775 775
776 // Similar to how glyph overflow works, if our lines are flipped, then it's actually the opposite border that applies, since 776 // Similar to how glyph overflow works, if our lines are flipped, then it's actually the opposite border that applies, since
777 // the line is "upside down" in terms of block coordinates. vertical-rl and horizontal-bt are the flipped line modes. 777 // the line is "upside down" in terms of block coordinates. vertical-rl and horizontal-bt are the flipped line modes.
778 LayoutRectOutsets logicalOutsets = style.borderImageOutsets().logicalOutsets WithFlippedLines(style.writingMode()); 778 LayoutRectOutsets logicalOutsets = style.borderImageOutsets().logicalOutsets WithFlippedLines(style.writingMode());
779 779
780 if (!includeLogicalLeftEdge()) 780 if (!includeLogicalLeftEdge())
781 logicalOutsets.setLeft(LayoutUnit()); 781 logicalOutsets.setLeft(LayoutUnit());
782 if (!includeLogicalRightEdge()) 782 if (!includeLogicalRightEdge())
783 logicalOutsets.setRight(LayoutUnit()); 783 logicalOutsets.setRight(LayoutUnit());
784 784
785 LayoutRect borderOutsetBounds(logicalFrameRect().toLayoutRect()); 785 LayoutRect borderOutsetBounds(logicalFrameRect());
786 borderOutsetBounds.expand(logicalOutsets); 786 borderOutsetBounds.expand(logicalOutsets);
787 logicalVisualOverflow.unite(borderOutsetBounds); 787 logicalVisualOverflow.unite(borderOutsetBounds);
788 } 788 }
789 789
790 inline void InlineFlowBox::addOutlineVisualOverflow(LayoutRect& logicalVisualOve rflow) 790 inline void InlineFlowBox::addOutlineVisualOverflow(LayoutRect& logicalVisualOve rflow)
791 { 791 {
792 // Outline on root line boxes is applied to the block and not to the lines. 792 // Outline on root line boxes is applied to the block and not to the lines.
793 if (!parent()) 793 if (!parent())
794 return; 794 return;
795 795
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 } 891 }
892 892
893 if (m_overflow) 893 if (m_overflow)
894 m_overflow.clear(); 894 m_overflow.clear();
895 895
896 // Visual overflow just includes overflow for stuff we need to issues paint invalidations for ourselves. Self-painting layers are ignored. 896 // Visual overflow just includes overflow for stuff we need to issues paint invalidations for ourselves. Self-painting layers are ignored.
897 // Layout overflow is used to determine scrolling extent, so it still includ es child layers and also factors in 897 // Layout overflow is used to determine scrolling extent, so it still includ es child layers and also factors in
898 // transforms, relative positioning, etc. 898 // transforms, relative positioning, etc.
899 // FIXME: the call to enclosingLayoutRect() below is temporary and should be removed once 899 // FIXME: the call to enclosingLayoutRect() below is temporary and should be removed once
900 // the transition to LayoutUnit-based types is complete (crbug.com/321237) 900 // the transition to LayoutUnit-based types is complete (crbug.com/321237)
901 LayoutRect logicalLayoutOverflow(logicalFrameRectIncludingLineHeight(lineTop , lineBottom).enclosingLayoutRect()); 901 LayoutRect logicalLayoutOverflow(enclosingLayoutRect(logicalFrameRectIncludi ngLineHeight(lineTop, lineBottom)));
902 LayoutRect logicalVisualOverflow(logicalLayoutOverflow); 902 LayoutRect logicalVisualOverflow(logicalLayoutOverflow);
903 903
904 addBoxShadowVisualOverflow(logicalVisualOverflow); 904 addBoxShadowVisualOverflow(logicalVisualOverflow);
905 addBorderOutsetVisualOverflow(logicalVisualOverflow); 905 addBorderOutsetVisualOverflow(logicalVisualOverflow);
906 addOutlineVisualOverflow(logicalVisualOverflow); 906 addOutlineVisualOverflow(logicalVisualOverflow);
907 907
908 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { 908 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
909 if (curr->layoutObject().isOutOfFlowPositioned()) 909 if (curr->layoutObject().isOutOfFlowPositioned())
910 continue; // Positioned placeholders don't affect calculations. 910 continue; // Positioned placeholders don't affect calculations.
911 911
912 if (curr->layoutObject().isText()) { 912 if (curr->layoutObject().isText()) {
913 InlineTextBox* text = toInlineTextBox(curr); 913 InlineTextBox* text = toInlineTextBox(curr);
914 LayoutText& rt = text->layoutObject(); 914 LayoutText& rt = text->layoutObject();
915 if (rt.isBR()) 915 if (rt.isBR())
916 continue; 916 continue;
917 // FIXME: the call to enclosingLayoutRect() below is temporary and s hould be removed once 917 // FIXME: the call to enclosingLayoutRect() below is temporary and s hould be removed once
918 // the transition to LayoutUnit-based types is complete (crbug.com/3 21237) 918 // the transition to LayoutUnit-based types is complete (crbug.com/3 21237)
919 LayoutRect textBoxOverflow(text->logicalFrameRect().enclosingLayoutR ect()); 919 LayoutRect textBoxOverflow(enclosingLayoutRect(text->logicalFrameRec t()));
920 addTextBoxVisualOverflow(text, textBoxDataMap, textBoxOverflow); 920 addTextBoxVisualOverflow(text, textBoxDataMap, textBoxOverflow);
921 logicalVisualOverflow.unite(textBoxOverflow); 921 logicalVisualOverflow.unite(textBoxOverflow);
922 } else if (curr->layoutObject().isLayoutInline()) { 922 } else if (curr->layoutObject().isLayoutInline()) {
923 InlineFlowBox* flow = toInlineFlowBox(curr); 923 InlineFlowBox* flow = toInlineFlowBox(curr);
924 flow->computeOverflow(lineTop, lineBottom, textBoxDataMap); 924 flow->computeOverflow(lineTop, lineBottom, textBoxDataMap);
925 if (!flow->boxModelObject()->hasSelfPaintingLayer()) 925 if (!flow->boxModelObject()->hasSelfPaintingLayer())
926 logicalVisualOverflow.unite(flow->logicalVisualOverflowRect(line Top, lineBottom)); 926 logicalVisualOverflow.unite(flow->logicalVisualOverflowRect(line Top, lineBottom));
927 LayoutRect childLayoutOverflow = flow->logicalLayoutOverflowRect(lin eTop, lineBottom); 927 LayoutRect childLayoutOverflow = flow->logicalLayoutOverflowRect(lin eTop, lineBottom);
928 childLayoutOverflow.move(flow->boxModelObject()->relativePositionLog icalOffset()); 928 childLayoutOverflow.move(flow->boxModelObject()->relativePositionLog icalOffset());
929 logicalLayoutOverflow.unite(childLayoutOverflow); 929 logicalLayoutOverflow.unite(childLayoutOverflow);
(...skipping 24 matching lines...) Expand all
954 if (!m_overflow) 954 if (!m_overflow)
955 m_overflow = adoptPtr(new OverflowModel(frameBox, frameBox)); 955 m_overflow = adoptPtr(new OverflowModel(frameBox, frameBox));
956 956
957 m_overflow->setVisualOverflow(rect); 957 m_overflow->setVisualOverflow(rect);
958 } 958 }
959 959
960 void InlineFlowBox::setOverflowFromLogicalRects(const LayoutRect& logicalLayoutO verflow, const LayoutRect& logicalVisualOverflow, LayoutUnit lineTop, LayoutUnit lineBottom) 960 void InlineFlowBox::setOverflowFromLogicalRects(const LayoutRect& logicalLayoutO verflow, const LayoutRect& logicalVisualOverflow, LayoutUnit lineTop, LayoutUnit lineBottom)
961 { 961 {
962 // FIXME: the call to enclosingLayoutRect() below is temporary and should be removed once 962 // FIXME: the call to enclosingLayoutRect() below is temporary and should be removed once
963 // the transition to LayoutUnit-based types is complete (crbug.com/321237) 963 // the transition to LayoutUnit-based types is complete (crbug.com/321237)
964 LayoutRect frameBox = frameRectIncludingLineHeight(lineTop, lineBottom).encl osingLayoutRect(); 964 LayoutRect frameBox = enclosingLayoutRect(frameRectIncludingLineHeight(lineT op, lineBottom));
965 965
966 LayoutRect layoutOverflow(isHorizontal() ? logicalLayoutOverflow : logicalLa youtOverflow.transposedRect()); 966 LayoutRect layoutOverflow(isHorizontal() ? logicalLayoutOverflow : logicalLa youtOverflow.transposedRect());
967 setLayoutOverflow(layoutOverflow, frameBox); 967 setLayoutOverflow(layoutOverflow, frameBox);
968 968
969 LayoutRect visualOverflow(isHorizontal() ? logicalVisualOverflow : logicalVi sualOverflow.transposedRect()); 969 LayoutRect visualOverflow(isHorizontal() ? logicalVisualOverflow : logicalVi sualOverflow.transposedRect());
970 setVisualOverflow(visualOverflow, frameBox); 970 setVisualOverflow(visualOverflow, frameBox);
971 } 971 }
972 972
973 bool InlineFlowBox::nodeAtPoint(HitTestResult& result, const HitTestLocation& lo cationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, Lay outUnit lineBottom) 973 bool InlineFlowBox::nodeAtPoint(HitTestResult& result, const HitTestLocation& lo cationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, Lay outUnit lineBottom)
974 { 974 {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 1092
1093 bool InlineFlowBox::canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsis Width) const 1093 bool InlineFlowBox::canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsis Width) const
1094 { 1094 {
1095 for (InlineBox* box = firstChild(); box; box = box->nextOnLine()) { 1095 for (InlineBox* box = firstChild(); box; box = box->nextOnLine()) {
1096 if (!box->canAccommodateEllipsis(ltr, blockEdge, ellipsisWidth)) 1096 if (!box->canAccommodateEllipsis(ltr, blockEdge, ellipsisWidth))
1097 return false; 1097 return false;
1098 } 1098 }
1099 return true; 1099 return true;
1100 } 1100 }
1101 1101
1102 FloatWillBeLayoutUnit InlineFlowBox::placeEllipsisBox(bool ltr, FloatWillBeLayou tUnit blockLeftEdge, FloatWillBeLayoutUnit blockRightEdge, FloatWillBeLayoutUnit ellipsisWidth, FloatWillBeLayoutUnit &truncatedWidth, bool& foundBox) 1102 LayoutUnit InlineFlowBox::placeEllipsisBox(bool ltr, LayoutUnit blockLeftEdge, L ayoutUnit blockRightEdge, LayoutUnit ellipsisWidth, LayoutUnit &truncatedWidth, bool& foundBox)
1103 { 1103 {
1104 FloatWillBeLayoutUnit result = -1; 1104 LayoutUnit result = -1;
1105 // We iterate over all children, the foundBox variable tells us when we've f ound the 1105 // We iterate over all children, the foundBox variable tells us when we've f ound the
1106 // box containing the ellipsis. All boxes after that one in the flow are hi dden. 1106 // box containing the ellipsis. All boxes after that one in the flow are hi dden.
1107 // If our flow is ltr then iterate over the boxes from left to right, otherw ise iterate 1107 // If our flow is ltr then iterate over the boxes from left to right, otherw ise iterate
1108 // from right to left. Varying the order allows us to correctly hide the box es following the ellipsis. 1108 // from right to left. Varying the order allows us to correctly hide the box es following the ellipsis.
1109 InlineBox* box = ltr ? firstChild() : lastChild(); 1109 InlineBox* box = ltr ? firstChild() : lastChild();
1110 1110
1111 // NOTE: these will cross after foundBox = true. 1111 // NOTE: these will cross after foundBox = true.
1112 int visibleLeftEdge = blockLeftEdge; 1112 int visibleLeftEdge = blockLeftEdge;
1113 int visibleRightEdge = blockRightEdge; 1113 int visibleRightEdge = blockRightEdge;
1114 1114
1115 while (box) { 1115 while (box) {
1116 int currResult = box->placeEllipsisBox(ltr, visibleLeftEdge, visibleRigh tEdge, ellipsisWidth, truncatedWidth, foundBox); 1116 int currResult = box->placeEllipsisBox(ltr, visibleLeftEdge, visibleRigh tEdge, ellipsisWidth, truncatedWidth, foundBox);
1117 if (currResult != -1 && result == -1) 1117 if (currResult != -1 && result == -1)
1118 result = currResult; 1118 result = currResult;
1119 1119
1120 if (ltr) { 1120 if (ltr) {
1121 visibleLeftEdge += box->logicalWidth(); 1121 visibleLeftEdge += box->logicalWidth().round();
1122 box = box->nextOnLine(); 1122 box = box->nextOnLine();
1123 } else { 1123 } else {
1124 visibleRightEdge -= box->logicalWidth(); 1124 visibleRightEdge -= box->logicalWidth().round();
1125 box = box->prevOnLine(); 1125 box = box->prevOnLine();
1126 } 1126 }
1127 } 1127 }
1128 return result; 1128 return result;
1129 } 1129 }
1130 1130
1131 void InlineFlowBox::clearTruncation() 1131 void InlineFlowBox::clearTruncation()
1132 { 1132 {
1133 for (InlineBox* box = firstChild(); box; box = box->nextOnLine()) 1133 for (InlineBox* box = firstChild(); box; box = box->nextOnLine())
1134 box->clearTruncation(); 1134 box->clearTruncation();
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 ASSERT(child->prevOnLine() == prev); 1310 ASSERT(child->prevOnLine() == prev);
1311 prev = child; 1311 prev = child;
1312 } 1312 }
1313 ASSERT(prev == m_lastChild); 1313 ASSERT(prev == m_lastChild);
1314 #endif 1314 #endif
1315 } 1315 }
1316 1316
1317 #endif 1317 #endif
1318 1318
1319 } // namespace blink 1319 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/line/InlineFlowBox.h ('k') | Source/core/layout/line/InlineTextBox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698