OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2004, 2005, 2006, 2007 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 } | 75 } |
76 | 76 |
77 #ifndef NDEBUG | 77 #ifndef NDEBUG |
78 const char* InlineBox::boxName() const | 78 const char* InlineBox::boxName() const |
79 { | 79 { |
80 return "InlineBox"; | 80 return "InlineBox"; |
81 } | 81 } |
82 | 82 |
83 void InlineBox::showTreeForThis() const | 83 void InlineBox::showTreeForThis() const |
84 { | 84 { |
85 renderer().showTreeForThis(); | 85 layoutObject().showTreeForThis(); |
86 } | 86 } |
87 | 87 |
88 void InlineBox::showLineTreeForThis() const | 88 void InlineBox::showLineTreeForThis() const |
89 { | 89 { |
90 renderer().containingBlock()->showLineTreeAndMark(this, "*"); | 90 layoutObject().containingBlock()->showLineTreeAndMark(this, "*"); |
91 } | 91 } |
92 | 92 |
93 void InlineBox::showLineTreeAndMark(const InlineBox* markedBox1, const char* mar
kedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const LayoutOb
ject* obj, int depth) const | 93 void InlineBox::showLineTreeAndMark(const InlineBox* markedBox1, const char* mar
kedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const LayoutOb
ject* obj, int depth) const |
94 { | 94 { |
95 int printedCharacters = 0; | 95 int printedCharacters = 0; |
96 if (this == markedBox1) | 96 if (this == markedBox1) |
97 printedCharacters += fprintf(stderr, "%s", markedLabel1); | 97 printedCharacters += fprintf(stderr, "%s", markedLabel1); |
98 if (this == markedBox2) | 98 if (this == markedBox2) |
99 printedCharacters += fprintf(stderr, "%s", markedLabel2); | 99 printedCharacters += fprintf(stderr, "%s", markedLabel2); |
100 if (&renderer() == obj) | 100 if (&layoutObject() == obj) |
101 printedCharacters += fprintf(stderr, "*"); | 101 printedCharacters += fprintf(stderr, "*"); |
102 for (; printedCharacters < depth * 2; printedCharacters++) | 102 for (; printedCharacters < depth * 2; printedCharacters++) |
103 fputc(' ', stderr); | 103 fputc(' ', stderr); |
104 | 104 |
105 showBox(printedCharacters); | 105 showBox(printedCharacters); |
106 } | 106 } |
107 | 107 |
108 void InlineBox::showBox(int printedCharacters) const | 108 void InlineBox::showBox(int printedCharacters) const |
109 { | 109 { |
110 printedCharacters += fprintf(stderr, "%s %p", boxName(), this); | 110 printedCharacters += fprintf(stderr, "%s %p", boxName(), this); |
111 for (; printedCharacters < showTreeCharacterOffset; printedCharacters++) | 111 for (; printedCharacters < showTreeCharacterOffset; printedCharacters++) |
112 fputc(' ', stderr); | 112 fputc(' ', stderr); |
113 fprintf(stderr, "\t%s %p {pos=%g,%g size=%g,%g} baseline=%i/%i\n", | 113 fprintf(stderr, "\t%s %p {pos=%g,%g size=%g,%g} baseline=%i/%i\n", |
114 renderer().decoratedName().ascii().data(), &renderer(), | 114 layoutObject().decoratedName().ascii().data(), &layoutObject(), |
115 x().toFloat(), y().toFloat(), width().toFloat(), height().toFloat(), | 115 x().toFloat(), y().toFloat(), width().toFloat(), height().toFloat(), |
116 baselinePosition(AlphabeticBaseline), baselinePosition(IdeographicBaseli
ne)); | 116 baselinePosition(AlphabeticBaseline), baselinePosition(IdeographicBaseli
ne)); |
117 } | 117 } |
118 #endif | 118 #endif |
119 | 119 |
120 FloatWillBeLayoutUnit InlineBox::logicalHeight() const | 120 FloatWillBeLayoutUnit InlineBox::logicalHeight() const |
121 { | 121 { |
122 if (hasVirtualLogicalHeight()) | 122 if (hasVirtualLogicalHeight()) |
123 return virtualLogicalHeight(); | 123 return virtualLogicalHeight(); |
124 | 124 |
125 if (renderer().isText()) | 125 if (layoutObject().isText()) |
126 return m_bitfields.isText() ? FloatWillBeLayoutUnit(renderer().style(isF
irstLineStyle())->fontMetrics().height()) : FloatWillBeLayoutUnit(); | 126 return m_bitfields.isText() ? FloatWillBeLayoutUnit(layoutObject().style
(isFirstLineStyle())->fontMetrics().height()) : FloatWillBeLayoutUnit(); |
127 if (renderer().isBox() && parent()) | 127 if (layoutObject().isBox() && parent()) |
128 return isHorizontal() ? toLayoutBox(renderer()).size().height() : toLayo
utBox(renderer()).size().width(); | 128 return isHorizontal() ? toLayoutBox(layoutObject()).size().height() : to
LayoutBox(layoutObject()).size().width(); |
129 | 129 |
130 ASSERT(isInlineFlowBox()); | 130 ASSERT(isInlineFlowBox()); |
131 LayoutBoxModelObject* flowObject = boxModelObject(); | 131 LayoutBoxModelObject* flowObject = boxModelObject(); |
132 const FontMetrics& fontMetrics = renderer().style(isFirstLineStyle())->fontM
etrics(); | 132 const FontMetrics& fontMetrics = layoutObject().style(isFirstLineStyle())->f
ontMetrics(); |
133 FloatWillBeLayoutUnit result = fontMetrics.height(); | 133 FloatWillBeLayoutUnit result = fontMetrics.height(); |
134 if (parent()) | 134 if (parent()) |
135 result += flowObject->borderAndPaddingLogicalHeight(); | 135 result += flowObject->borderAndPaddingLogicalHeight(); |
136 return result; | 136 return result; |
137 } | 137 } |
138 | 138 |
139 int InlineBox::baselinePosition(FontBaseline baselineType) const | 139 int InlineBox::baselinePosition(FontBaseline baselineType) const |
140 { | 140 { |
141 return boxModelObject()->baselinePosition(baselineType, m_bitfields.firstLin
e(), isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine); | 141 return boxModelObject()->baselinePosition(baselineType, m_bitfields.firstLin
e(), isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine); |
142 } | 142 } |
143 | 143 |
144 LayoutUnit InlineBox::lineHeight() const | 144 LayoutUnit InlineBox::lineHeight() const |
145 { | 145 { |
146 return boxModelObject()->lineHeight(m_bitfields.firstLine(), isHorizontal()
? HorizontalLine : VerticalLine, PositionOnContainingLine); | 146 return boxModelObject()->lineHeight(m_bitfields.firstLine(), isHorizontal()
? HorizontalLine : VerticalLine, PositionOnContainingLine); |
147 } | 147 } |
148 | 148 |
149 int InlineBox::caretMinOffset() const | 149 int InlineBox::caretMinOffset() const |
150 { | 150 { |
151 return renderer().caretMinOffset(); | 151 return layoutObject().caretMinOffset(); |
152 } | 152 } |
153 | 153 |
154 int InlineBox::caretMaxOffset() const | 154 int InlineBox::caretMaxOffset() const |
155 { | 155 { |
156 return renderer().caretMaxOffset(); | 156 return layoutObject().caretMaxOffset(); |
157 } | 157 } |
158 | 158 |
159 void InlineBox::dirtyLineBoxes() | 159 void InlineBox::dirtyLineBoxes() |
160 { | 160 { |
161 markDirty(); | 161 markDirty(); |
162 for (InlineFlowBox* curr = parent(); curr && !curr->isDirty(); curr = curr->
parent()) | 162 for (InlineFlowBox* curr = parent(); curr && !curr->isDirty(); curr = curr->
parent()) |
163 curr->markDirty(); | 163 curr->markDirty(); |
164 } | 164 } |
165 | 165 |
166 void InlineBox::deleteLine() | 166 void InlineBox::deleteLine() |
167 { | 167 { |
168 if (!m_bitfields.extracted() && renderer().isBox()) | 168 if (!m_bitfields.extracted() && layoutObject().isBox()) |
169 toLayoutBox(renderer()).setInlineBoxWrapper(0); | 169 toLayoutBox(layoutObject()).setInlineBoxWrapper(0); |
170 destroy(); | 170 destroy(); |
171 } | 171 } |
172 | 172 |
173 void InlineBox::extractLine() | 173 void InlineBox::extractLine() |
174 { | 174 { |
175 m_bitfields.setExtracted(true); | 175 m_bitfields.setExtracted(true); |
176 if (renderer().isBox()) | 176 if (layoutObject().isBox()) |
177 toLayoutBox(renderer()).setInlineBoxWrapper(0); | 177 toLayoutBox(layoutObject()).setInlineBoxWrapper(0); |
178 } | 178 } |
179 | 179 |
180 void InlineBox::attachLine() | 180 void InlineBox::attachLine() |
181 { | 181 { |
182 m_bitfields.setExtracted(false); | 182 m_bitfields.setExtracted(false); |
183 if (renderer().isBox()) | 183 if (layoutObject().isBox()) |
184 toLayoutBox(renderer()).setInlineBoxWrapper(this); | 184 toLayoutBox(layoutObject()).setInlineBoxWrapper(this); |
185 } | 185 } |
186 | 186 |
187 void InlineBox::adjustPosition(FloatWillBeLayoutUnit dx, FloatWillBeLayoutUnit d
y) | 187 void InlineBox::adjustPosition(FloatWillBeLayoutUnit dx, FloatWillBeLayoutUnit d
y) |
188 { | 188 { |
189 m_topLeft.move(dx, dy); | 189 m_topLeft.move(dx, dy); |
190 | 190 |
191 if (renderer().isReplaced()) | 191 if (layoutObject().isReplaced()) |
192 toLayoutBox(renderer()).move(dx, dy); | 192 toLayoutBox(layoutObject()).move(dx, dy); |
193 } | 193 } |
194 | 194 |
195 void InlineBox::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset
, LayoutUnit /* lineTop */, LayoutUnit /*lineBottom*/) | 195 void InlineBox::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset
, LayoutUnit /* lineTop */, LayoutUnit /*lineBottom*/) |
196 { | 196 { |
197 // Text clips are painted only for the direct inline children of the object
that has a text clip style on it, not block children. | 197 // Text clips are painted only for the direct inline children of the object
that has a text clip style on it, not block children. |
198 if (paintInfo.phase != PaintPhaseTextClip) | 198 if (paintInfo.phase != PaintPhaseTextClip) |
199 BlockPainter::paintInlineBox(*this, paintInfo, paintOffset); | 199 BlockPainter::paintInlineBox(*this, paintInfo, paintOffset); |
200 } | 200 } |
201 | 201 |
202 bool InlineBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result
, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffs
et, LayoutUnit /* lineTop */, LayoutUnit /*lineBottom*/) | 202 bool InlineBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result
, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffs
et, LayoutUnit /* lineTop */, LayoutUnit /*lineBottom*/) |
203 { | 203 { |
204 // Hit test all phases of replaced elements atomically, as though the replac
ed element established its | 204 // Hit test all phases of replaced elements atomically, as though the replac
ed element established its |
205 // own stacking context. (See Appendix E.2, section 6.4 on inline block/tab
le elements in the CSS2.1 | 205 // own stacking context. (See Appendix E.2, section 6.4 on inline block/tab
le elements in the CSS2.1 |
206 // specification.) | 206 // specification.) |
207 LayoutPoint childPoint = accumulatedOffset; | 207 LayoutPoint childPoint = accumulatedOffset; |
208 if (parent()->renderer().hasFlippedBlocksWritingMode()) // Faster than calli
ng containingBlock(). | 208 if (parent()->layoutObject().hasFlippedBlocksWritingMode()) // Faster than c
alling containingBlock(). |
209 childPoint = renderer().containingBlock()->flipForWritingModeForChild(&t
oLayoutBox(renderer()), childPoint); | 209 childPoint = layoutObject().containingBlock()->flipForWritingModeForChil
d(&toLayoutBox(layoutObject()), childPoint); |
210 | 210 |
211 return renderer().hitTest(request, result, locationInContainer, childPoint); | 211 return layoutObject().hitTest(request, result, locationInContainer, childPoi
nt); |
212 } | 212 } |
213 | 213 |
214 const RootInlineBox& InlineBox::root() const | 214 const RootInlineBox& InlineBox::root() const |
215 { | 215 { |
216 if (m_parent) | 216 if (m_parent) |
217 return m_parent->root(); | 217 return m_parent->root(); |
218 ASSERT(isRootInlineBox()); | 218 ASSERT(isRootInlineBox()); |
219 return static_cast<const RootInlineBox&>(*this); | 219 return static_cast<const RootInlineBox&>(*this); |
220 } | 220 } |
221 | 221 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 InlineBox* InlineBox::prevLeafChildIgnoringLineBreak() const | 273 InlineBox* InlineBox::prevLeafChildIgnoringLineBreak() const |
274 { | 274 { |
275 InlineBox* leaf = prevLeafChild(); | 275 InlineBox* leaf = prevLeafChild(); |
276 if (leaf && leaf->isLineBreak()) | 276 if (leaf && leaf->isLineBreak()) |
277 return 0; | 277 return 0; |
278 return leaf; | 278 return leaf; |
279 } | 279 } |
280 | 280 |
281 LayoutObject::SelectionState InlineBox::selectionState() const | 281 LayoutObject::SelectionState InlineBox::selectionState() const |
282 { | 282 { |
283 return renderer().selectionState(); | 283 return layoutObject().selectionState(); |
284 } | 284 } |
285 | 285 |
286 bool InlineBox::canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsisWidt
h) const | 286 bool InlineBox::canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsisWidt
h) const |
287 { | 287 { |
288 // Non-replaced elements can always accommodate an ellipsis. | 288 // Non-replaced elements can always accommodate an ellipsis. |
289 if (!renderer().isReplaced()) | 289 if (!layoutObject().isReplaced()) |
290 return true; | 290 return true; |
291 | 291 |
292 IntRect boxRect(left(), 0, m_logicalWidth, 10); | 292 IntRect boxRect(left(), 0, m_logicalWidth, 10); |
293 IntRect ellipsisRect(ltr ? blockEdge - ellipsisWidth : blockEdge, 0, ellipsi
sWidth, 10); | 293 IntRect ellipsisRect(ltr ? blockEdge - ellipsisWidth : blockEdge, 0, ellipsi
sWidth, 10); |
294 return !(boxRect.intersects(ellipsisRect)); | 294 return !(boxRect.intersects(ellipsisRect)); |
295 } | 295 } |
296 | 296 |
297 FloatWillBeLayoutUnit InlineBox::placeEllipsisBox(bool, FloatWillBeLayoutUnit, F
loatWillBeLayoutUnit, FloatWillBeLayoutUnit, FloatWillBeLayoutUnit& truncatedWid
th, bool&) | 297 FloatWillBeLayoutUnit InlineBox::placeEllipsisBox(bool, FloatWillBeLayoutUnit, F
loatWillBeLayoutUnit, FloatWillBeLayoutUnit, FloatWillBeLayoutUnit& truncatedWid
th, bool&) |
298 { | 298 { |
299 // Use -1 to mean "we didn't set the position." | 299 // Use -1 to mean "we didn't set the position." |
300 truncatedWidth += logicalWidth(); | 300 truncatedWidth += logicalWidth(); |
301 return -1; | 301 return -1; |
302 } | 302 } |
303 | 303 |
304 void InlineBox::clearKnownToHaveNoOverflow() | 304 void InlineBox::clearKnownToHaveNoOverflow() |
305 { | 305 { |
306 m_bitfields.setKnownToHaveNoOverflow(false); | 306 m_bitfields.setKnownToHaveNoOverflow(false); |
307 if (parent() && parent()->knownToHaveNoOverflow()) | 307 if (parent() && parent()->knownToHaveNoOverflow()) |
308 parent()->clearKnownToHaveNoOverflow(); | 308 parent()->clearKnownToHaveNoOverflow(); |
309 } | 309 } |
310 | 310 |
311 FloatPointWillBeLayoutPoint InlineBox::locationIncludingFlipping() | 311 FloatPointWillBeLayoutPoint InlineBox::locationIncludingFlipping() |
312 { | 312 { |
313 if (!UNLIKELY(renderer().hasFlippedBlocksWritingMode())) | 313 if (!UNLIKELY(layoutObject().hasFlippedBlocksWritingMode())) |
314 return FloatPointWillBeLayoutPoint(x(), y()); | 314 return FloatPointWillBeLayoutPoint(x(), y()); |
315 | 315 |
316 LayoutBlockFlow& block = root().block(); | 316 LayoutBlockFlow& block = root().block(); |
317 if (block.style()->isHorizontalWritingMode()) | 317 if (block.style()->isHorizontalWritingMode()) |
318 return FloatPointWillBeLayoutPoint(x(), block.size().height() - size().h
eight() - y()); | 318 return FloatPointWillBeLayoutPoint(x(), block.size().height() - size().h
eight() - y()); |
319 | 319 |
320 return FloatPointWillBeLayoutPoint(block.size().width() - size().width() - x
(), y()); | 320 return FloatPointWillBeLayoutPoint(block.size().width() - size().width() - x
(), y()); |
321 } | 321 } |
322 | 322 |
323 void InlineBox::flipForWritingMode(FloatRect& rect) | 323 void InlineBox::flipForWritingMode(FloatRect& rect) |
324 { | 324 { |
325 if (!UNLIKELY(renderer().hasFlippedBlocksWritingMode())) | 325 if (!UNLIKELY(layoutObject().hasFlippedBlocksWritingMode())) |
326 return; | 326 return; |
327 root().block().flipForWritingMode(rect); | 327 root().block().flipForWritingMode(rect); |
328 } | 328 } |
329 | 329 |
330 FloatPoint InlineBox::flipForWritingMode(const FloatPoint& point) | 330 FloatPoint InlineBox::flipForWritingMode(const FloatPoint& point) |
331 { | 331 { |
332 if (!UNLIKELY(renderer().hasFlippedBlocksWritingMode())) | 332 if (!UNLIKELY(layoutObject().hasFlippedBlocksWritingMode())) |
333 return point; | 333 return point; |
334 return root().block().flipForWritingMode(point); | 334 return root().block().flipForWritingMode(point); |
335 } | 335 } |
336 | 336 |
337 void InlineBox::flipForWritingMode(LayoutRect& rect) | 337 void InlineBox::flipForWritingMode(LayoutRect& rect) |
338 { | 338 { |
339 if (!UNLIKELY(renderer().hasFlippedBlocksWritingMode())) | 339 if (!UNLIKELY(layoutObject().hasFlippedBlocksWritingMode())) |
340 return; | 340 return; |
341 root().block().flipForWritingMode(rect); | 341 root().block().flipForWritingMode(rect); |
342 } | 342 } |
343 | 343 |
344 LayoutPoint InlineBox::flipForWritingMode(const LayoutPoint& point) | 344 LayoutPoint InlineBox::flipForWritingMode(const LayoutPoint& point) |
345 { | 345 { |
346 if (!UNLIKELY(renderer().hasFlippedBlocksWritingMode())) | 346 if (!UNLIKELY(layoutObject().hasFlippedBlocksWritingMode())) |
347 return point; | 347 return point; |
348 return root().block().flipForWritingMode(point); | 348 return root().block().flipForWritingMode(point); |
349 } | 349 } |
350 | 350 |
351 } // namespace blink | 351 } // namespace blink |
352 | 352 |
353 #ifndef NDEBUG | 353 #ifndef NDEBUG |
354 | 354 |
355 void showTree(const blink::InlineBox* b) | 355 void showTree(const blink::InlineBox* b) |
356 { | 356 { |
357 if (b) | 357 if (b) |
358 b->showTreeForThis(); | 358 b->showTreeForThis(); |
359 } | 359 } |
360 | 360 |
361 void showLineTree(const blink::InlineBox* b) | 361 void showLineTree(const blink::InlineBox* b) |
362 { | 362 { |
363 if (b) | 363 if (b) |
364 b->showLineTreeForThis(); | 364 b->showLineTreeForThis(); |
365 } | 365 } |
366 | 366 |
367 #endif | 367 #endif |
OLD | NEW |