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

Side by Side Diff: sky/engine/core/rendering/RootInlineBox.cpp

Issue 688233002: Remove writing mode code from the linebox tree. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: merge to ToT Created 6 years, 1 month 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
« no previous file with comments | « sky/engine/core/rendering/RenderText.cpp ('k') | sky/engine/core/rendering/style/ShadowList.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, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2006, 2008 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 RootInlineBox::RootInlineBox(RenderBlockFlow& block) 49 RootInlineBox::RootInlineBox(RenderBlockFlow& block)
50 : InlineFlowBox(block) 50 : InlineFlowBox(block)
51 , m_lineBreakPos(0) 51 , m_lineBreakPos(0)
52 , m_lineBreakObj(0) 52 , m_lineBreakObj(0)
53 , m_lineTop(0) 53 , m_lineTop(0)
54 , m_lineBottom(0) 54 , m_lineBottom(0)
55 , m_lineTopWithLeading(0) 55 , m_lineTopWithLeading(0)
56 , m_lineBottomWithLeading(0) 56 , m_lineBottomWithLeading(0)
57 , m_selectionBottom(0) 57 , m_selectionBottom(0)
58 { 58 {
59 // FIXME(sky): Remove
60 setIsHorizontal(true);
61 } 59 }
62 60
63 61
64 void RootInlineBox::destroy() 62 void RootInlineBox::destroy()
65 { 63 {
66 detachEllipsisBox(); 64 detachEllipsisBox();
67 InlineFlowBox::destroy(); 65 InlineFlowBox::destroy();
68 } 66 }
69 67
70 void RootInlineBox::detachEllipsisBox() 68 void RootInlineBox::detachEllipsisBox()
(...skipping 14 matching lines...) Expand all
85 void RootInlineBox::clearTruncation() 83 void RootInlineBox::clearTruncation()
86 { 84 {
87 if (hasEllipsisBox()) { 85 if (hasEllipsisBox()) {
88 detachEllipsisBox(); 86 detachEllipsisBox();
89 InlineFlowBox::clearTruncation(); 87 InlineFlowBox::clearTruncation();
90 } 88 }
91 } 89 }
92 90
93 int RootInlineBox::baselinePosition(FontBaseline baselineType) const 91 int RootInlineBox::baselinePosition(FontBaseline baselineType) const
94 { 92 {
95 return boxModelObject()->baselinePosition(baselineType, isFirstLineStyle(), isHorizontal() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); 93 return boxModelObject()->baselinePosition(baselineType, isFirstLineStyle(), HorizontalLine, PositionOfInteriorLineBoxes);
96 } 94 }
97 95
98 LayoutUnit RootInlineBox::lineHeight() const 96 LayoutUnit RootInlineBox::lineHeight() const
99 { 97 {
100 return boxModelObject()->lineHeight(isFirstLineStyle(), isHorizontal() ? Hor izontalLine : VerticalLine, PositionOfInteriorLineBoxes); 98 return boxModelObject()->lineHeight(isFirstLineStyle(), HorizontalLine, Posi tionOfInteriorLineBoxes);
101 } 99 }
102 100
103 bool RootInlineBox::lineCanAccommodateEllipsis(bool ltr, int blockEdge, int line BoxEdge, int ellipsisWidth) 101 bool RootInlineBox::lineCanAccommodateEllipsis(bool ltr, int blockEdge, int line BoxEdge, int ellipsisWidth)
104 { 102 {
105 // First sanity-check the unoverflowed width of the whole line to see if the re is sufficient room. 103 // First sanity-check the unoverflowed width of the whole line to see if the re is sufficient room.
106 int delta = ltr ? lineBoxEdge - blockEdge : blockEdge - lineBoxEdge; 104 int delta = ltr ? lineBoxEdge - blockEdge : blockEdge - lineBoxEdge;
107 if (logicalWidth() - delta < ellipsisWidth) 105 if (logicalWidth() - delta < ellipsisWidth)
108 return false; 106 return false;
109 107
110 // Next iterate over all the line boxes on the line. If we find a replaced element that intersects 108 // Next iterate over all the line boxes on the line. If we find a replaced element that intersects
111 // then we refuse to accommodate the ellipsis. Otherwise we're ok. 109 // then we refuse to accommodate the ellipsis. Otherwise we're ok.
112 return InlineFlowBox::canAccommodateEllipsis(ltr, blockEdge, ellipsisWidth); 110 return InlineFlowBox::canAccommodateEllipsis(ltr, blockEdge, ellipsisWidth);
113 } 111 }
114 112
115 float RootInlineBox::placeEllipsis(const AtomicString& ellipsisStr, bool ltr, f loat blockLeftEdge, float blockRightEdge, float ellipsisWidth, 113 float RootInlineBox::placeEllipsis(const AtomicString& ellipsisStr, bool ltr, f loat blockLeftEdge, float blockRightEdge, float ellipsisWidth,
116 InlineBox* markupBox) 114 InlineBox* markupBox)
117 { 115 {
118 // Create an ellipsis box. 116 // Create an ellipsis box.
119 EllipsisBox* ellipsisBox = new EllipsisBox(renderer(), ellipsisStr, this, 117 EllipsisBox* ellipsisBox = new EllipsisBox(renderer(), ellipsisStr, this,
120 ellipsisWidth - (markupBox ? markupBox->logicalWidth() : 0), logicalHeig ht(), 118 ellipsisWidth - (markupBox ? markupBox->logicalWidth() : 0), logicalHeig ht(),
121 x(), y(), !prevRootBox(), isHorizontal(), markupBox); 119 x(), y(), !prevRootBox(), markupBox);
122 120
123 if (!gEllipsisBoxMap) 121 if (!gEllipsisBoxMap)
124 gEllipsisBoxMap = new EllipsisBoxMap(); 122 gEllipsisBoxMap = new EllipsisBoxMap();
125 gEllipsisBoxMap->add(this, ellipsisBox); 123 gEllipsisBoxMap->add(this, ellipsisBox);
126 setHasEllipsisBox(true); 124 setHasEllipsisBox(true);
127 125
128 // FIXME: Do we need an RTL version of this? 126 // FIXME: Do we need an RTL version of this?
129 if (ltr && (logicalLeft() + logicalWidth() + ellipsisWidth) <= blockRightEdg e) { 127 if (ltr && (logicalLeft() + logicalWidth() + ellipsisWidth) <= blockRightEdg e) {
130 ellipsisBox->setLogicalLeft(logicalLeft() + logicalWidth()); 128 ellipsisBox->setLogicalLeft(logicalLeft() + logicalWidth());
131 return logicalWidth() + ellipsisWidth; 129 return logicalWidth() + ellipsisWidth;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 renderer().updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset)); 168 renderer().updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset));
171 return true; 169 return true;
172 } 170 }
173 } 171 }
174 return InlineFlowBox::nodeAtPoint(request, result, locationInContainer, accu mulatedOffset, lineTop, lineBottom); 172 return InlineFlowBox::nodeAtPoint(request, result, locationInContainer, accu mulatedOffset, lineTop, lineBottom);
175 } 173 }
176 174
177 void RootInlineBox::adjustPosition(float dx, float dy) 175 void RootInlineBox::adjustPosition(float dx, float dy)
178 { 176 {
179 InlineFlowBox::adjustPosition(dx, dy); 177 InlineFlowBox::adjustPosition(dx, dy);
180 LayoutUnit blockDirectionDelta = isHorizontal() ? dy : dx; // The block dire ction delta is a LayoutUnit. 178 LayoutUnit blockDirectionDelta = dy; // The block direction delta is a Layou tUnit.
181 m_lineTop += blockDirectionDelta; 179 m_lineTop += blockDirectionDelta;
182 m_lineBottom += blockDirectionDelta; 180 m_lineBottom += blockDirectionDelta;
183 m_lineTopWithLeading += blockDirectionDelta; 181 m_lineTopWithLeading += blockDirectionDelta;
184 m_lineBottomWithLeading += blockDirectionDelta; 182 m_lineBottomWithLeading += blockDirectionDelta;
185 m_selectionBottom += blockDirectionDelta; 183 m_selectionBottom += blockDirectionDelta;
186 if (hasEllipsisBox()) 184 if (hasEllipsisBox())
187 ellipsisBox()->adjustPosition(dx, dy); 185 ellipsisBox()->adjustPosition(dx, dy);
188 } 186 }
189 187
190 void RootInlineBox::childRemoved(InlineBox* box) 188 void RootInlineBox::childRemoved(InlineBox* box)
(...skipping 13 matching lines...) Expand all
204 if (isSVGRootInlineBox()) 202 if (isSVGRootInlineBox())
205 return 0; 203 return 0;
206 204
207 LayoutUnit maxPositionTop = 0; 205 LayoutUnit maxPositionTop = 0;
208 LayoutUnit maxPositionBottom = 0; 206 LayoutUnit maxPositionBottom = 0;
209 int maxAscent = 0; 207 int maxAscent = 0;
210 int maxDescent = 0; 208 int maxDescent = 0;
211 bool setMaxAscent = false; 209 bool setMaxAscent = false;
212 bool setMaxDescent = false; 210 bool setMaxDescent = false;
213 211
214 m_baselineType = requiresIdeographicBaseline(textBoxDataMap) ? IdeographicBa seline : AlphabeticBaseline; 212 m_baselineType = AlphabeticBaseline;
215 213
216 computeLogicalBoxHeights(this, maxPositionTop, maxPositionBottom, maxAscent, maxDescent, setMaxAscent, setMaxDescent, true, 214 computeLogicalBoxHeights(this, maxPositionTop, maxPositionBottom, maxAscent, maxDescent, setMaxAscent, setMaxDescent, true,
217 textBoxDataMap, baselineType(), verticalPositionCac he); 215 textBoxDataMap, baselineType(), verticalPositionCac he);
218 216
219 if (maxAscent + maxDescent < std::max(maxPositionTop, maxPositionBottom)) 217 if (maxAscent + maxDescent < std::max(maxPositionTop, maxPositionBottom))
220 adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop, maxPosi tionBottom); 218 adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop, maxPosi tionBottom);
221 219
222 LayoutUnit maxHeight = maxAscent + maxDescent; 220 LayoutUnit maxHeight = maxAscent + maxDescent;
223 LayoutUnit lineTop = heightOfBlock; 221 LayoutUnit lineTop = heightOfBlock;
224 LayoutUnit lineBottom = heightOfBlock; 222 LayoutUnit lineBottom = heightOfBlock;
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 { 531 {
534 block().lineBoxes()->attachLineBox(this); 532 block().lineBoxes()->attachLineBox(this);
535 } 533 }
536 534
537 LayoutRect RootInlineBox::paddedLayoutOverflowRect(LayoutUnit endPadding) const 535 LayoutRect RootInlineBox::paddedLayoutOverflowRect(LayoutUnit endPadding) const
538 { 536 {
539 LayoutRect lineLayoutOverflow = layoutOverflowRect(lineTop(), lineBottom()); 537 LayoutRect lineLayoutOverflow = layoutOverflowRect(lineTop(), lineBottom());
540 if (!endPadding) 538 if (!endPadding)
541 return lineLayoutOverflow; 539 return lineLayoutOverflow;
542 540
543 if (isHorizontal()) { 541 if (isLeftToRightDirection())
544 if (isLeftToRightDirection()) 542 lineLayoutOverflow.shiftMaxXEdgeTo(std::max<LayoutUnit>(lineLayoutOverfl ow.maxX(), logicalRight() + endPadding));
545 lineLayoutOverflow.shiftMaxXEdgeTo(std::max<LayoutUnit>(lineLayoutOv erflow.maxX(), logicalRight() + endPadding)); 543 else
546 else 544 lineLayoutOverflow.shiftXEdgeTo(std::min<LayoutUnit>(lineLayoutOverflow. x(), logicalLeft() - endPadding));
547 lineLayoutOverflow.shiftXEdgeTo(std::min<LayoutUnit>(lineLayoutOverf low.x(), logicalLeft() - endPadding));
548 } else {
549 if (isLeftToRightDirection())
550 lineLayoutOverflow.shiftMaxYEdgeTo(std::max<LayoutUnit>(lineLayoutOv erflow.maxY(), logicalRight() + endPadding));
551 else
552 lineLayoutOverflow.shiftYEdgeTo(std::min<LayoutUnit>(lineLayoutOverf low.y(), logicalLeft() - endPadding));
553 }
554 545
555 return lineLayoutOverflow; 546 return lineLayoutOverflow;
556 } 547 }
557 548
558 static void setAscentAndDescent(int& ascent, int& descent, int newAscent, int ne wDescent, bool& ascentDescentSet) 549 static void setAscentAndDescent(int& ascent, int& descent, int newAscent, int ne wDescent, bool& ascentDescentSet)
559 { 550 {
560 if (!ascentDescentSet) { 551 if (!ascentDescentSet) {
561 ascentDescentSet = true; 552 ascentDescentSet = true;
562 ascent = newAscent; 553 ascent = newAscent;
563 descent = newDescent; 554 descent = newDescent;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 bool RootInlineBox::includeFontForBox(InlineBox* box) const 744 bool RootInlineBox::includeFontForBox(InlineBox* box) const
754 { 745 {
755 if (box->renderer().isReplaced() || (box->renderer().isText() && !box->isTex t())) 746 if (box->renderer().isReplaced() || (box->renderer().isText() && !box->isTex t()))
756 return false; 747 return false;
757 748
758 if (!box->isText() && box->isInlineFlowBox() && !toInlineFlowBox(box)->hasTe xtChildren()) 749 if (!box->isText() && box->isInlineFlowBox() && !toInlineFlowBox(box)->hasTe xtChildren())
759 return false; 750 return false;
760 751
761 // For now map "glyphs" to "font" in vertical text mode until the bounds ret urned by glyphs aren't garbage. 752 // For now map "glyphs" to "font" in vertical text mode until the bounds ret urned by glyphs aren't garbage.
762 LineBoxContain lineBoxContain = renderer().style()->lineBoxContain(); 753 LineBoxContain lineBoxContain = renderer().style()->lineBoxContain();
763 return (lineBoxContain & LineBoxContainFont) || (!isHorizontal() && (lineBox Contain & LineBoxContainGlyphs)); 754 return lineBoxContain & LineBoxContainFont;
764 } 755 }
765 756
766 bool RootInlineBox::includeGlyphsForBox(InlineBox* box) const 757 bool RootInlineBox::includeGlyphsForBox(InlineBox* box) const
767 { 758 {
768 if (box->renderer().isReplaced() || (box->renderer().isText() && !box->isTex t())) 759 if (box->renderer().isReplaced() || (box->renderer().isText() && !box->isTex t()))
769 return false; 760 return false;
770 761
771 if (!box->isText() && box->isInlineFlowBox() && !toInlineFlowBox(box)->hasTe xtChildren()) 762 if (!box->isText() && box->isInlineFlowBox() && !toInlineFlowBox(box)->hasTe xtChildren())
772 return false; 763 return false;
773 764
774 // FIXME: We can't fit to glyphs yet for vertical text, since the bounds ret urned are garbage. 765 // FIXME: We can't fit to glyphs yet for vertical text, since the bounds ret urned are garbage.
775 LineBoxContain lineBoxContain = renderer().style()->lineBoxContain(); 766 LineBoxContain lineBoxContain = renderer().style()->lineBoxContain();
776 return isHorizontal() && (lineBoxContain & LineBoxContainGlyphs); 767 return lineBoxContain & LineBoxContainGlyphs;
777 } 768 }
778 769
779 bool RootInlineBox::includeMarginForBox(InlineBox* box) const 770 bool RootInlineBox::includeMarginForBox(InlineBox* box) const
780 { 771 {
781 if (box->renderer().isReplaced() || (box->renderer().isText() && !box->isTex t())) 772 if (box->renderer().isReplaced() || (box->renderer().isText() && !box->isTex t()))
782 return false; 773 return false;
783 774
784 LineBoxContain lineBoxContain = renderer().style()->lineBoxContain(); 775 LineBoxContain lineBoxContain = renderer().style()->lineBoxContain();
785 return lineBoxContain & LineBoxContainInlineBox; 776 return lineBoxContain & LineBoxContainInlineBox;
786 } 777 }
787 778
788 779
789 bool RootInlineBox::fitsToGlyphs() const 780 bool RootInlineBox::fitsToGlyphs() const
790 { 781 {
791 // FIXME: We can't fit to glyphs yet for vertical text, since the bounds ret urned are garbage. 782 // FIXME: We can't fit to glyphs yet for vertical text, since the bounds ret urned are garbage.
792 LineBoxContain lineBoxContain = renderer().style()->lineBoxContain(); 783 LineBoxContain lineBoxContain = renderer().style()->lineBoxContain();
793 return isHorizontal() && (lineBoxContain & LineBoxContainGlyphs); 784 return lineBoxContain & LineBoxContainGlyphs;
794 } 785 }
795 786
796 bool RootInlineBox::includesRootLineBoxFontOrLeading() const 787 bool RootInlineBox::includesRootLineBoxFontOrLeading() const
797 { 788 {
798 LineBoxContain lineBoxContain = renderer().style()->lineBoxContain(); 789 LineBoxContain lineBoxContain = renderer().style()->lineBoxContain();
799 return (lineBoxContain & LineBoxContainBlock) || (lineBoxContain & LineBoxCo ntainInline) || (lineBoxContain & LineBoxContainFont); 790 return (lineBoxContain & LineBoxContainBlock) || (lineBoxContain & LineBoxCo ntainInline) || (lineBoxContain & LineBoxContainFont);
800 } 791 }
801 792
802 Node* RootInlineBox::getLogicalStartBoxWithNode(InlineBox*& startBox) const 793 Node* RootInlineBox::getLogicalStartBoxWithNode(InlineBox*& startBox) const
803 { 794 {
(...skipping 24 matching lines...) Expand all
828 } 819 }
829 820
830 #ifndef NDEBUG 821 #ifndef NDEBUG
831 const char* RootInlineBox::boxName() const 822 const char* RootInlineBox::boxName() const
832 { 823 {
833 return "RootInlineBox"; 824 return "RootInlineBox";
834 } 825 }
835 #endif 826 #endif
836 827
837 } // namespace blink 828 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/RenderText.cpp ('k') | sky/engine/core/rendering/style/ShadowList.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698