OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All r
ights 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 16 matching lines...) Expand all Loading... |
27 namespace WebCore { | 27 namespace WebCore { |
28 | 28 |
29 class HitTestRequest; | 29 class HitTestRequest; |
30 class HitTestResult; | 30 class HitTestResult; |
31 class RootInlineBox; | 31 class RootInlineBox; |
32 | 32 |
33 // InlineBox represents a rectangle that occurs on a line. It corresponds to | 33 // InlineBox represents a rectangle that occurs on a line. It corresponds to |
34 // some RenderObject (i.e., it represents a portion of that RenderObject). | 34 // some RenderObject (i.e., it represents a portion of that RenderObject). |
35 class InlineBox { | 35 class InlineBox { |
36 public: | 36 public: |
37 InlineBox(RenderObject* obj) | 37 InlineBox(RenderObject& obj) |
38 : m_next(0) | 38 : m_next(0) |
39 , m_prev(0) | 39 , m_prev(0) |
40 , m_parent(0) | 40 , m_parent(0) |
41 , m_renderer(obj) | 41 , m_renderer(obj) |
42 , m_logicalWidth(0) | 42 , m_logicalWidth(0) |
43 #ifndef NDEBUG | 43 #ifndef NDEBUG |
44 , m_hasBadParent(false) | 44 , m_hasBadParent(false) |
45 #endif | 45 #endif |
46 { | 46 { |
47 } | 47 } |
48 | 48 |
49 InlineBox(RenderObject* obj, FloatPoint topLeft, float logicalWidth, bool fi
rstLine, bool constructed, | 49 InlineBox(RenderObject& obj, FloatPoint topLeft, float logicalWidth, bool fi
rstLine, bool constructed, |
50 bool dirty, bool extracted, bool isHorizontal, InlineBox* next, In
lineBox* prev, InlineFlowBox* parent) | 50 bool dirty, bool extracted, bool isHorizontal, InlineBox* next, In
lineBox* prev, InlineFlowBox* parent) |
51 : m_next(next) | 51 : m_next(next) |
52 , m_prev(prev) | 52 , m_prev(prev) |
53 , m_parent(parent) | 53 , m_parent(parent) |
54 , m_renderer(obj) | 54 , m_renderer(obj) |
55 , m_topLeft(topLeft) | 55 , m_topLeft(topLeft) |
56 , m_logicalWidth(logicalWidth) | 56 , m_logicalWidth(logicalWidth) |
57 , m_bitfields(firstLine, constructed, dirty, extracted, isHorizontal) | 57 , m_bitfields(firstLine, constructed, dirty, extracted, isHorizontal) |
58 #ifndef NDEBUG | 58 #ifndef NDEBUG |
59 , m_hasBadParent(false) | 59 , m_hasBadParent(false) |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 166 |
167 InlineBox* nextLeafChild() const; | 167 InlineBox* nextLeafChild() const; |
168 InlineBox* prevLeafChild() const; | 168 InlineBox* prevLeafChild() const; |
169 | 169 |
170 // Helper functions for editing and hit-testing code. | 170 // Helper functions for editing and hit-testing code. |
171 // FIXME: These two functions should be moved to RenderedPosition once the c
ode to convert between | 171 // FIXME: These two functions should be moved to RenderedPosition once the c
ode to convert between |
172 // Position and inline box, offset pair is moved to RenderedPosition. | 172 // Position and inline box, offset pair is moved to RenderedPosition. |
173 InlineBox* nextLeafChildIgnoringLineBreak() const; | 173 InlineBox* nextLeafChildIgnoringLineBreak() const; |
174 InlineBox* prevLeafChildIgnoringLineBreak() const; | 174 InlineBox* prevLeafChildIgnoringLineBreak() const; |
175 | 175 |
176 RenderObject* renderer() const { return m_renderer; } | 176 RenderObject& renderer() const { return m_renderer; } |
177 | 177 |
178 InlineFlowBox* parent() const | 178 InlineFlowBox* parent() const |
179 { | 179 { |
180 ASSERT(!m_hasBadParent); | 180 ASSERT(!m_hasBadParent); |
181 return m_parent; | 181 return m_parent; |
182 } | 182 } |
183 void setParent(InlineFlowBox* par) { m_parent = par; } | 183 void setParent(InlineFlowBox* par) { m_parent = par; } |
184 | 184 |
185 const RootInlineBox* root() const; | 185 const RootInlineBox* root() const; |
186 RootInlineBox* root(); | 186 RootInlineBox* root(); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 virtual bool canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsisWid
th) const; | 263 virtual bool canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsisWid
th) const; |
264 // visibleLeftEdge, visibleRightEdge are in the parent's coordinate system. | 264 // visibleLeftEdge, visibleRightEdge are in the parent's coordinate system. |
265 virtual float placeEllipsisBox(bool ltr, float visibleLeftEdge, float visibl
eRightEdge, float ellipsisWidth, float &truncatedWidth, bool&); | 265 virtual float placeEllipsisBox(bool ltr, float visibleLeftEdge, float visibl
eRightEdge, float ellipsisWidth, float &truncatedWidth, bool&); |
266 | 266 |
267 #ifndef NDEBUG | 267 #ifndef NDEBUG |
268 void setHasBadParent(); | 268 void setHasBadParent(); |
269 #endif | 269 #endif |
270 | 270 |
271 int expansion() const { return m_bitfields.expansion(); } | 271 int expansion() const { return m_bitfields.expansion(); } |
272 | 272 |
273 bool visibleToHitTestRequest(const HitTestRequest& request) const { return r
enderer()->visibleToHitTestRequest(request); } | 273 bool visibleToHitTestRequest(const HitTestRequest& request) const { return r
enderer().visibleToHitTestRequest(request); } |
274 | 274 |
275 EVerticalAlign verticalAlign() const { return renderer()->style(m_bitfields.
firstLine())->verticalAlign(); } | 275 EVerticalAlign verticalAlign() const { return renderer().style(m_bitfields.f
irstLine())->verticalAlign(); } |
276 | 276 |
277 // Use with caution! The type is not checked! | 277 // Use with caution! The type is not checked! |
278 RenderBoxModelObject* boxModelObject() const | 278 RenderBoxModelObject* boxModelObject() const |
279 { | 279 { |
280 if (!m_renderer->isText()) | 280 if (!renderer().isText()) |
281 return toRenderBoxModelObject(m_renderer); | 281 return toRenderBoxModelObject(&renderer()); |
282 return 0; | 282 return 0; |
283 } | 283 } |
284 | 284 |
285 FloatPoint locationIncludingFlipping(); | 285 FloatPoint locationIncludingFlipping(); |
286 void flipForWritingMode(FloatRect&); | 286 void flipForWritingMode(FloatRect&); |
287 FloatPoint flipForWritingMode(const FloatPoint&); | 287 FloatPoint flipForWritingMode(const FloatPoint&); |
288 void flipForWritingMode(LayoutRect&); | 288 void flipForWritingMode(LayoutRect&); |
289 LayoutPoint flipForWritingMode(const LayoutPoint&); | 289 LayoutPoint flipForWritingMode(const LayoutPoint&); |
290 | 290 |
291 bool knownToHaveNoOverflow() const { return m_bitfields.knownToHaveNoOverflo
w(); } | 291 bool knownToHaveNoOverflow() const { return m_bitfields.knownToHaveNoOverflo
w(); } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 signed expansion() const { return m_expansion; } | 370 signed expansion() const { return m_expansion; } |
371 void setExpansion(signed expansion) { m_expansion = expansion; } | 371 void setExpansion(signed expansion) { m_expansion = expansion; } |
372 }; | 372 }; |
373 #undef ADD_BOOLEAN_BITFIELD | 373 #undef ADD_BOOLEAN_BITFIELD |
374 | 374 |
375 private: | 375 private: |
376 InlineBox* m_next; // The next element on the same line as us. | 376 InlineBox* m_next; // The next element on the same line as us. |
377 InlineBox* m_prev; // The previous element on the same line as us. | 377 InlineBox* m_prev; // The previous element on the same line as us. |
378 | 378 |
379 InlineFlowBox* m_parent; // The box that contains us. | 379 InlineFlowBox* m_parent; // The box that contains us. |
| 380 RenderObject& m_renderer; |
380 | 381 |
381 protected: | 382 protected: |
382 // For RootInlineBox | 383 // For RootInlineBox |
383 bool endsWithBreak() const { return m_bitfields.endsWithBreak(); } | 384 bool endsWithBreak() const { return m_bitfields.endsWithBreak(); } |
384 void setEndsWithBreak(bool endsWithBreak) { m_bitfields.setEndsWithBreak(end
sWithBreak); } | 385 void setEndsWithBreak(bool endsWithBreak) { m_bitfields.setEndsWithBreak(end
sWithBreak); } |
385 bool hasEllipsisBox() const { return m_bitfields.hasEllipsisBoxOrHyphen(); } | 386 bool hasEllipsisBox() const { return m_bitfields.hasEllipsisBoxOrHyphen(); } |
386 bool hasSelectedChildren() const { return m_bitfields.hasSelectedChildrenOrC
anHaveLeadingExpansion(); } | 387 bool hasSelectedChildren() const { return m_bitfields.hasSelectedChildrenOrC
anHaveLeadingExpansion(); } |
387 void setHasSelectedChildren(bool hasSelectedChildren) { m_bitfields.setHasSe
lectedChildrenOrCanHaveLeadingExpansion(hasSelectedChildren); } | 388 void setHasSelectedChildren(bool hasSelectedChildren) { m_bitfields.setHasSe
lectedChildrenOrCanHaveLeadingExpansion(hasSelectedChildren); } |
388 void setHasEllipsisBox(bool hasEllipsisBox) { m_bitfields.setHasEllipsisBoxO
rHyphen(hasEllipsisBox); } | 389 void setHasEllipsisBox(bool hasEllipsisBox) { m_bitfields.setHasEllipsisBoxO
rHyphen(hasEllipsisBox); } |
389 | 390 |
390 // For InlineTextBox | 391 // For InlineTextBox |
391 bool hasHyphen() const { return m_bitfields.hasEllipsisBoxOrHyphen(); } | 392 bool hasHyphen() const { return m_bitfields.hasEllipsisBoxOrHyphen(); } |
392 void setHasHyphen(bool hasHyphen) { m_bitfields.setHasEllipsisBoxOrHyphen(ha
sHyphen); } | 393 void setHasHyphen(bool hasHyphen) { m_bitfields.setHasEllipsisBoxOrHyphen(ha
sHyphen); } |
393 bool canHaveLeadingExpansion() const { return m_bitfields.hasSelectedChildre
nOrCanHaveLeadingExpansion(); } | 394 bool canHaveLeadingExpansion() const { return m_bitfields.hasSelectedChildre
nOrCanHaveLeadingExpansion(); } |
394 void setCanHaveLeadingExpansion(bool canHaveLeadingExpansion) { m_bitfields.
setHasSelectedChildrenOrCanHaveLeadingExpansion(canHaveLeadingExpansion); } | 395 void setCanHaveLeadingExpansion(bool canHaveLeadingExpansion) { m_bitfields.
setHasSelectedChildrenOrCanHaveLeadingExpansion(canHaveLeadingExpansion); } |
395 signed expansion() { return m_bitfields.expansion(); } | 396 signed expansion() { return m_bitfields.expansion(); } |
396 void setExpansion(signed expansion) { m_bitfields.setExpansion(expansion); } | 397 void setExpansion(signed expansion) { m_bitfields.setExpansion(expansion); } |
397 | 398 |
398 // For InlineFlowBox and InlineTextBox | 399 // For InlineFlowBox and InlineTextBox |
399 bool extracted() const { return m_bitfields.extracted(); } | 400 bool extracted() const { return m_bitfields.extracted(); } |
400 | 401 |
401 RenderObject* m_renderer; | |
402 | |
403 FloatPoint m_topLeft; | 402 FloatPoint m_topLeft; |
404 float m_logicalWidth; | 403 float m_logicalWidth; |
405 | 404 |
406 private: | 405 private: |
407 InlineBoxBitfields m_bitfields; | 406 InlineBoxBitfields m_bitfields; |
408 | 407 |
409 #ifndef NDEBUG | 408 #ifndef NDEBUG |
410 bool m_hasBadParent; | 409 bool m_hasBadParent; |
411 #endif | 410 #endif |
412 }; | 411 }; |
(...skipping 16 matching lines...) Expand all Loading... |
429 | 428 |
430 } // namespace WebCore | 429 } // namespace WebCore |
431 | 430 |
432 #ifndef NDEBUG | 431 #ifndef NDEBUG |
433 // Outside the WebCore namespace for ease of invocation from gdb. | 432 // Outside the WebCore namespace for ease of invocation from gdb. |
434 void showTree(const WebCore::InlineBox*); | 433 void showTree(const WebCore::InlineBox*); |
435 void showLineTree(const WebCore::InlineBox*); | 434 void showLineTree(const WebCore::InlineBox*); |
436 #endif | 435 #endif |
437 | 436 |
438 #endif // InlineBox_h | 437 #endif // InlineBox_h |
OLD | NEW |