OLD | NEW |
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // Next iterate over all the line boxes on the line. If we find a replaced | 104 // Next iterate over all the line boxes on the line. If we find a replaced |
105 // element that intersects then we refuse to accommodate the ellipsis. | 105 // element that intersects then we refuse to accommodate the ellipsis. |
106 // Otherwise we're ok. | 106 // Otherwise we're ok. |
107 return InlineFlowBox::canAccommodateEllipsis(ltr, blockEdge, ellipsisWidth); | 107 return InlineFlowBox::canAccommodateEllipsis(ltr, blockEdge, ellipsisWidth); |
108 } | 108 } |
109 | 109 |
110 LayoutUnit RootInlineBox::placeEllipsis(const AtomicString& ellipsisStr, | 110 LayoutUnit RootInlineBox::placeEllipsis(const AtomicString& ellipsisStr, |
111 bool ltr, | 111 bool ltr, |
112 LayoutUnit blockLeftEdge, | 112 LayoutUnit blockLeftEdge, |
113 LayoutUnit blockRightEdge, | 113 LayoutUnit blockRightEdge, |
114 LayoutUnit ellipsisWidth) { | 114 LayoutUnit ellipsisWidth, |
115 // Create an ellipsis box. | 115 LayoutUnit logicalLeftOffset, |
116 EllipsisBox* ellipsisBox = new EllipsisBox( | 116 bool foundBox) { |
117 getLineLayoutItem(), ellipsisStr, this, ellipsisWidth, logicalHeight(), | 117 // Create an ellipsis box if we don't already have one. If we already have one |
118 location(), !prevRootBox(), isHorizontal()); | 118 // we're just |
| 119 // here to blank out (truncate) the text boxes. |
| 120 if (!foundBox) { |
| 121 EllipsisBox* ellipsisBox = new EllipsisBox( |
| 122 getLineLayoutItem(), ellipsisStr, this, ellipsisWidth, logicalHeight(), |
| 123 location(), !prevRootBox(), isHorizontal()); |
119 | 124 |
120 if (!gEllipsisBoxMap) | 125 if (!gEllipsisBoxMap) |
121 gEllipsisBoxMap = new EllipsisBoxMap(); | 126 gEllipsisBoxMap = new EllipsisBoxMap(); |
122 gEllipsisBoxMap->insert(this, ellipsisBox); | 127 gEllipsisBoxMap->insert(this, ellipsisBox); |
123 setHasEllipsisBox(true); | 128 setHasEllipsisBox(true); |
| 129 } |
124 | 130 |
125 // FIXME: Do we need an RTL version of this? | 131 // FIXME: Do we need an RTL version of this? |
| 132 LayoutUnit adjustedLogicalLeft = logicalLeftOffset + logicalLeft(); |
126 if (ltr && | 133 if (ltr && |
127 (logicalLeft() + logicalWidth() + ellipsisWidth) <= blockRightEdge) { | 134 (adjustedLogicalLeft + logicalWidth() + ellipsisWidth) <= |
128 ellipsisBox->setLogicalLeft(logicalLeft() + logicalWidth()); | 135 blockRightEdge) { |
| 136 if (hasEllipsisBox()) |
| 137 ellipsisBox()->setLogicalLeft(logicalLeft() + logicalWidth()); |
129 return logicalWidth() + ellipsisWidth; | 138 return logicalWidth() + ellipsisWidth; |
130 } | 139 } |
131 | 140 |
132 // Now attempt to find the nearest glyph horizontally and place just to the | 141 // Now attempt to find the nearest glyph horizontally and place just to the |
133 // right (or left in RTL) of that glyph. Mark all of the objects that | 142 // right (or left in RTL) of that glyph. Mark all of the objects that |
134 // intersect the ellipsis box as not painting (as being truncated). | 143 // intersect the ellipsis box as not painting (as being truncated). |
135 bool foundBox = false; | |
136 LayoutUnit truncatedWidth; | 144 LayoutUnit truncatedWidth; |
137 LayoutUnit position = | 145 LayoutUnit position = |
138 placeEllipsisBox(ltr, blockLeftEdge, blockRightEdge, ellipsisWidth, | 146 placeEllipsisBox(ltr, blockLeftEdge, blockRightEdge, ellipsisWidth, |
139 truncatedWidth, foundBox); | 147 truncatedWidth, foundBox, logicalLeftOffset); |
140 ellipsisBox->setLogicalLeft(position); | 148 if (hasEllipsisBox()) |
| 149 ellipsisBox()->setLogicalLeft(position); |
141 return truncatedWidth; | 150 return truncatedWidth; |
142 } | 151 } |
143 | 152 |
144 LayoutUnit RootInlineBox::placeEllipsisBox(bool ltr, | 153 LayoutUnit RootInlineBox::placeEllipsisBox(bool ltr, |
145 LayoutUnit blockLeftEdge, | 154 LayoutUnit blockLeftEdge, |
146 LayoutUnit blockRightEdge, | 155 LayoutUnit blockRightEdge, |
147 LayoutUnit ellipsisWidth, | 156 LayoutUnit ellipsisWidth, |
148 LayoutUnit& truncatedWidth, | 157 LayoutUnit& truncatedWidth, |
149 bool& foundBox) { | 158 bool& foundBox, |
150 LayoutUnit result = | 159 LayoutUnit logicalLeftOffset) { |
151 InlineFlowBox::placeEllipsisBox(ltr, blockLeftEdge, blockRightEdge, | 160 LayoutUnit result = InlineFlowBox::placeEllipsisBox( |
152 ellipsisWidth, truncatedWidth, foundBox); | 161 ltr, blockLeftEdge, blockRightEdge, ellipsisWidth, truncatedWidth, |
| 162 foundBox, logicalLeftOffset); |
153 if (result == -1) { | 163 if (result == -1) { |
154 result = ltr ? blockRightEdge - ellipsisWidth : blockLeftEdge; | 164 result = ltr ? std::max<LayoutUnit>( |
155 truncatedWidth = blockRightEdge - blockLeftEdge; | 165 LayoutUnit(), |
| 166 blockRightEdge - ellipsisWidth - logicalLeftOffset) |
| 167 : blockLeftEdge - logicalLeftOffset; |
| 168 truncatedWidth = blockRightEdge - blockLeftEdge - logicalLeftOffset; |
156 } | 169 } |
157 return result; | 170 return result; |
158 } | 171 } |
159 | 172 |
160 void RootInlineBox::paint(const PaintInfo& paintInfo, | 173 void RootInlineBox::paint(const PaintInfo& paintInfo, |
161 const LayoutPoint& paintOffset, | 174 const LayoutPoint& paintOffset, |
162 LayoutUnit lineTop, | 175 LayoutUnit lineTop, |
163 LayoutUnit lineBottom) const { | 176 LayoutUnit lineBottom) const { |
164 RootInlineBoxPainter(*this).paint(paintInfo, paintOffset, lineTop, | 177 RootInlineBoxPainter(*this).paint(paintInfo, paintOffset, lineTop, |
165 lineBottom); | 178 lineBottom); |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 } | 788 } |
776 endBox = nullptr; | 789 endBox = nullptr; |
777 return nullptr; | 790 return nullptr; |
778 } | 791 } |
779 | 792 |
780 const char* RootInlineBox::boxName() const { | 793 const char* RootInlineBox::boxName() const { |
781 return "RootInlineBox"; | 794 return "RootInlineBox"; |
782 } | 795 } |
783 | 796 |
784 } // namespace blink | 797 } // namespace blink |
OLD | NEW |