| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 , m_parent(0) | 44 , m_parent(0) |
| 45 , m_renderer(obj) | 45 , m_renderer(obj) |
| 46 , m_logicalWidth(0) | 46 , m_logicalWidth(0) |
| 47 #if ENABLE(ASSERT) | 47 #if ENABLE(ASSERT) |
| 48 , m_hasBadParent(false) | 48 , m_hasBadParent(false) |
| 49 #endif | 49 #endif |
| 50 { | 50 { |
| 51 } | 51 } |
| 52 | 52 |
| 53 InlineBox(RenderObject& obj, FloatPoint topLeft, float logicalWidth, bool fi
rstLine, bool constructed, | 53 InlineBox(RenderObject& obj, FloatPoint topLeft, float logicalWidth, bool fi
rstLine, bool constructed, |
| 54 bool dirty, bool extracted, bool isHorizontal, InlineBox* next, In
lineBox* prev, InlineFlowBox* parent) | 54 bool dirty, bool extracted, InlineBox* next, InlineBox* prev, Inli
neFlowBox* parent) |
| 55 : m_next(next) | 55 : m_next(next) |
| 56 , m_prev(prev) | 56 , m_prev(prev) |
| 57 , m_parent(parent) | 57 , m_parent(parent) |
| 58 , m_renderer(obj) | 58 , m_renderer(obj) |
| 59 , m_topLeft(topLeft) | 59 , m_topLeft(topLeft) |
| 60 , m_logicalWidth(logicalWidth) | 60 , m_logicalWidth(logicalWidth) |
| 61 , m_bitfields(firstLine, constructed, dirty, extracted, isHorizontal) | 61 , m_bitfields(firstLine, constructed, dirty, extracted) |
| 62 #if ENABLE(ASSERT) | 62 #if ENABLE(ASSERT) |
| 63 , m_hasBadParent(false) | 63 , m_hasBadParent(false) |
| 64 #endif | 64 #endif |
| 65 { | 65 { |
| 66 } | 66 } |
| 67 | 67 |
| 68 virtual ~InlineBox(); | 68 virtual ~InlineBox(); |
| 69 | 69 |
| 70 virtual void destroy() { delete this; } | 70 virtual void destroy() { delete this; } |
| 71 | 71 |
| 72 virtual void deleteLine(); | 72 virtual void deleteLine(); |
| 73 virtual void extractLine(); | 73 virtual void extractLine(); |
| 74 virtual void attachLine(); | 74 virtual void attachLine(); |
| 75 | 75 |
| 76 virtual bool isLineBreak() const { return false; } | 76 virtual bool isLineBreak() const { return false; } |
| 77 | 77 |
| 78 virtual void adjustPosition(float dx, float dy); | 78 virtual void adjustPosition(float dx, float dy); |
| 79 void adjustLogicalPosition(float deltaLogicalLeft, float deltaLogicalTop) | 79 void adjustLogicalPosition(float deltaLogicalLeft, float deltaLogicalTop) |
| 80 { | 80 { |
| 81 if (isHorizontal()) | 81 // FIXME(sky): Remove |
| 82 adjustPosition(deltaLogicalLeft, deltaLogicalTop); | 82 adjustPosition(deltaLogicalLeft, deltaLogicalTop); |
| 83 else | |
| 84 adjustPosition(deltaLogicalTop, deltaLogicalLeft); | |
| 85 } | 83 } |
| 86 void adjustLineDirectionPosition(float delta) | 84 void adjustLineDirectionPosition(float delta) |
| 87 { | 85 { |
| 88 if (isHorizontal()) | 86 adjustPosition(delta, 0); |
| 89 adjustPosition(delta, 0); | |
| 90 else | |
| 91 adjustPosition(0, delta); | |
| 92 } | 87 } |
| 93 void adjustBlockDirectionPosition(float delta) | 88 void adjustBlockDirectionPosition(float delta) |
| 94 { | 89 { |
| 95 if (isHorizontal()) | 90 adjustPosition(0, delta); |
| 96 adjustPosition(0, delta); | |
| 97 else | |
| 98 adjustPosition(delta, 0); | |
| 99 } | 91 } |
| 100 | 92 |
| 101 virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, Layou
tUnit lineBottom); | 93 virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, Layou
tUnit lineBottom); |
| 102 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTes
tLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit
lineTop, LayoutUnit lineBottom); | 94 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTes
tLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit
lineTop, LayoutUnit lineBottom); |
| 103 | 95 |
| 104 // InlineBoxes are allocated out of the rendering partition. | 96 // InlineBoxes are allocated out of the rendering partition. |
| 105 void* operator new(size_t); | 97 void* operator new(size_t); |
| 106 void operator delete(void*); | 98 void operator delete(void*); |
| 107 | 99 |
| 108 #ifndef NDEBUG | 100 #ifndef NDEBUG |
| (...skipping 17 matching lines...) Expand all Loading... |
| 126 virtual bool isSVGRootInlineBox() const { return false; } | 118 virtual bool isSVGRootInlineBox() const { return false; } |
| 127 | 119 |
| 128 bool hasVirtualLogicalHeight() const { return m_bitfields.hasVirtualLogicalH
eight(); } | 120 bool hasVirtualLogicalHeight() const { return m_bitfields.hasVirtualLogicalH
eight(); } |
| 129 void setHasVirtualLogicalHeight() { m_bitfields.setHasVirtualLogicalHeight(t
rue); } | 121 void setHasVirtualLogicalHeight() { m_bitfields.setHasVirtualLogicalHeight(t
rue); } |
| 130 virtual float virtualLogicalHeight() const | 122 virtual float virtualLogicalHeight() const |
| 131 { | 123 { |
| 132 ASSERT_NOT_REACHED(); | 124 ASSERT_NOT_REACHED(); |
| 133 return 0; | 125 return 0; |
| 134 } | 126 } |
| 135 | 127 |
| 136 bool isHorizontal() const { return m_bitfields.isHorizontal(); } | |
| 137 void setIsHorizontal(bool isHorizontal) { m_bitfields.setIsHorizontal(isHori
zontal); } | |
| 138 | |
| 139 virtual FloatRect calculateBoundaries() const | 128 virtual FloatRect calculateBoundaries() const |
| 140 { | 129 { |
| 141 ASSERT_NOT_REACHED(); | 130 ASSERT_NOT_REACHED(); |
| 142 return FloatRect(); | 131 return FloatRect(); |
| 143 } | 132 } |
| 144 | 133 |
| 145 bool isConstructed() { return m_bitfields.constructed(); } | 134 bool isConstructed() { return m_bitfields.constructed(); } |
| 146 virtual void setConstructed() { m_bitfields.setConstructed(true); } | 135 virtual void setConstructed() { m_bitfields.setConstructed(true); } |
| 147 | 136 |
| 148 void setExtracted(bool extracted = true) { m_bitfields.setExtracted(extracte
d); } | 137 void setExtracted(bool extracted = true) { m_bitfields.setExtracted(extracte
d); } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 float x() const { return m_topLeft.x(); } | 183 float x() const { return m_topLeft.x(); } |
| 195 float left() const { return m_topLeft.x(); } | 184 float left() const { return m_topLeft.x(); } |
| 196 | 185 |
| 197 // y() is the top side of the box in the containing block's coordinate syste
m. | 186 // y() is the top side of the box in the containing block's coordinate syste
m. |
| 198 void setY(float y) { m_topLeft.setY(y); } | 187 void setY(float y) { m_topLeft.setY(y); } |
| 199 float y() const { return m_topLeft.y(); } | 188 float y() const { return m_topLeft.y(); } |
| 200 float top() const { return m_topLeft.y(); } | 189 float top() const { return m_topLeft.y(); } |
| 201 | 190 |
| 202 const FloatPoint& topLeft() const { return m_topLeft; } | 191 const FloatPoint& topLeft() const { return m_topLeft; } |
| 203 | 192 |
| 204 float width() const { return isHorizontal() ? logicalWidth() : hasVirtualLog
icalHeight() ? virtualLogicalHeight() : logicalHeight(); } | 193 float width() const { return logicalWidth(); } |
| 205 float height() const { return isHorizontal() ? hasVirtualLogicalHeight() ? v
irtualLogicalHeight() : logicalHeight() : logicalWidth(); } | 194 float height() const { return hasVirtualLogicalHeight() ? virtualLogicalHeig
ht() : logicalHeight(); } |
| 206 FloatSize size() const { return FloatSize(width(), height()); } | 195 FloatSize size() const { return FloatSize(width(), height()); } |
| 207 float right() const { return left() + width(); } | 196 float right() const { return left() + width(); } |
| 208 float bottom() const { return top() + height(); } | 197 float bottom() const { return top() + height(); } |
| 209 | 198 |
| 210 // The logicalLeft position is the left edge of the line box in a horizontal
line and the top edge in a vertical line. | 199 // The logicalLeft position is the left edge of the line box in a horizontal
line and the top edge in a vertical line. |
| 211 float logicalLeft() const { return isHorizontal() ? m_topLeft.x() : m_topLef
t.y(); } | 200 float logicalLeft() const { return m_topLeft.x(); } |
| 212 float logicalRight() const { return logicalLeft() + logicalWidth(); } | 201 float logicalRight() const { return logicalLeft() + logicalWidth(); } |
| 213 void setLogicalLeft(float left) | 202 void setLogicalLeft(float left) |
| 214 { | 203 { |
| 215 if (isHorizontal()) | 204 // FIXME(sky): Remove |
| 216 setX(left); | 205 setX(left); |
| 217 else | |
| 218 setY(left); | |
| 219 } | 206 } |
| 220 int pixelSnappedLogicalLeft() const { return logicalLeft(); } | 207 int pixelSnappedLogicalLeft() const { return logicalLeft(); } |
| 221 int pixelSnappedLogicalRight() const { return ceilf(logicalRight()); } | 208 int pixelSnappedLogicalRight() const { return ceilf(logicalRight()); } |
| 222 int pixelSnappedLogicalTop() const { return logicalTop(); } | 209 int pixelSnappedLogicalTop() const { return logicalTop(); } |
| 223 int pixelSnappedLogicalBottom() const { return ceilf(logicalBottom()); } | 210 int pixelSnappedLogicalBottom() const { return ceilf(logicalBottom()); } |
| 224 | 211 |
| 225 // The logicalTop[ position is the top edge of the line box in a horizontal
line and the left edge in a vertical line. | 212 // The logicalTop[ position is the top edge of the line box in a horizontal
line and the left edge in a vertical line. |
| 226 float logicalTop() const { return isHorizontal() ? m_topLeft.y() : m_topLeft
.x(); } | 213 float logicalTop() const { return m_topLeft.y(); } |
| 227 float logicalBottom() const { return logicalTop() + logicalHeight(); } | 214 float logicalBottom() const { return logicalTop() + logicalHeight(); } |
| 228 void setLogicalTop(float top) | 215 void setLogicalTop(float top) |
| 229 { | 216 { |
| 230 if (isHorizontal()) | 217 setY(top); |
| 231 setY(top); | |
| 232 else | |
| 233 setX(top); | |
| 234 } | 218 } |
| 235 | 219 |
| 236 // The logical width is our extent in the line's overall inline direction, i
.e., width for horizontal text and height for vertical text. | 220 // The logical width is our extent in the line's overall inline direction, i
.e., width for horizontal text and height for vertical text. |
| 237 void setLogicalWidth(float w) { m_logicalWidth = w; } | 221 void setLogicalWidth(float w) { m_logicalWidth = w; } |
| 238 float logicalWidth() const { return m_logicalWidth; } | 222 float logicalWidth() const { return m_logicalWidth; } |
| 239 | 223 |
| 240 // The logical height is our extent in the block flow direction, i.e., heigh
t for horizontal text and width for vertical text. | 224 // The logical height is our extent in the block flow direction, i.e., heigh
t for horizontal text and width for vertical text. |
| 241 float logicalHeight() const; | 225 float logicalHeight() const; |
| 242 | 226 |
| 243 FloatRect logicalFrameRect() const { return isHorizontal() ? FloatRect(m_top
Left.x(), m_topLeft.y(), m_logicalWidth, logicalHeight()) : FloatRect(m_topLeft.
y(), m_topLeft.x(), m_logicalWidth, logicalHeight()); } | 227 FloatRect logicalFrameRect() const { return FloatRect(m_topLeft.x(), m_topLe
ft.y(), m_logicalWidth, logicalHeight()); } |
| 244 | 228 |
| 245 virtual int baselinePosition(FontBaseline baselineType) const; | 229 virtual int baselinePosition(FontBaseline baselineType) const; |
| 246 virtual LayoutUnit lineHeight() const; | 230 virtual LayoutUnit lineHeight() const; |
| 247 | 231 |
| 248 virtual int caretMinOffset() const; | 232 virtual int caretMinOffset() const; |
| 249 virtual int caretMaxOffset() const; | 233 virtual int caretMaxOffset() const; |
| 250 | 234 |
| 251 unsigned char bidiLevel() const { return m_bitfields.bidiEmbeddingLevel(); } | 235 unsigned char bidiLevel() const { return m_bitfields.bidiEmbeddingLevel(); } |
| 252 void setBidiLevel(unsigned char level) { m_bitfields.setBidiEmbeddingLevel(l
evel); } | 236 void setBidiLevel(unsigned char level) { m_bitfields.setBidiEmbeddingLevel(l
evel); } |
| 253 TextDirection direction() const { return bidiLevel() % 2 ? RTL : LTR; } | 237 TextDirection direction() const { return bidiLevel() % 2 ? RTL : LTR; } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 | 280 |
| 297 #define ADD_BOOLEAN_BITFIELD(name, Name) \ | 281 #define ADD_BOOLEAN_BITFIELD(name, Name) \ |
| 298 private:\ | 282 private:\ |
| 299 unsigned m_##name : 1;\ | 283 unsigned m_##name : 1;\ |
| 300 public:\ | 284 public:\ |
| 301 bool name() const { return m_##name; }\ | 285 bool name() const { return m_##name; }\ |
| 302 void set##Name(bool name) { m_##name = name; }\ | 286 void set##Name(bool name) { m_##name = name; }\ |
| 303 | 287 |
| 304 class InlineBoxBitfields { | 288 class InlineBoxBitfields { |
| 305 public: | 289 public: |
| 306 InlineBoxBitfields(bool firstLine = false, bool constructed = false, boo
l dirty = false, bool extracted = false, bool isHorizontal = true) | 290 InlineBoxBitfields(bool firstLine = false, bool constructed = false, boo
l dirty = false, bool extracted = false) |
| 307 : m_firstLine(firstLine) | 291 : m_firstLine(firstLine) |
| 308 , m_constructed(constructed) | 292 , m_constructed(constructed) |
| 309 , m_bidiEmbeddingLevel(0) | 293 , m_bidiEmbeddingLevel(0) |
| 310 , m_dirty(dirty) | 294 , m_dirty(dirty) |
| 311 , m_extracted(extracted) | 295 , m_extracted(extracted) |
| 312 , m_hasVirtualLogicalHeight(false) | 296 , m_hasVirtualLogicalHeight(false) |
| 313 , m_isHorizontal(isHorizontal) | |
| 314 , m_endsWithBreak(false) | 297 , m_endsWithBreak(false) |
| 315 , m_hasSelectedChildrenOrCanHaveLeadingExpansion(false) | 298 , m_hasSelectedChildrenOrCanHaveLeadingExpansion(false) |
| 316 , m_knownToHaveNoOverflow(true) | 299 , m_knownToHaveNoOverflow(true) |
| 317 , m_hasEllipsisBoxOrHyphen(false) | 300 , m_hasEllipsisBoxOrHyphen(false) |
| 318 , m_dirOverride(false) | 301 , m_dirOverride(false) |
| 319 , m_isText(false) | 302 , m_isText(false) |
| 320 , m_determinedIfNextOnLineExists(false) | 303 , m_determinedIfNextOnLineExists(false) |
| 321 , m_nextOnLineExists(false) | 304 , m_nextOnLineExists(false) |
| 322 , m_expansion(0) | 305 , m_expansion(0) |
| 323 { | 306 { |
| 324 } | 307 } |
| 325 | 308 |
| 326 // Some of these bits are actually for subclasses and moved here to comp
act the structures. | 309 // Some of these bits are actually for subclasses and moved here to comp
act the structures. |
| 327 // for this class | 310 // for this class |
| 328 ADD_BOOLEAN_BITFIELD(firstLine, FirstLine); | 311 ADD_BOOLEAN_BITFIELD(firstLine, FirstLine); |
| 329 ADD_BOOLEAN_BITFIELD(constructed, Constructed); | 312 ADD_BOOLEAN_BITFIELD(constructed, Constructed); |
| 330 | 313 |
| 331 private: | 314 private: |
| 332 unsigned m_bidiEmbeddingLevel : 6; // The maximium bidi level is 62: htt
p://unicode.org/reports/tr9/#Explicit_Levels_and_Directions | 315 unsigned m_bidiEmbeddingLevel : 6; // The maximium bidi level is 62: htt
p://unicode.org/reports/tr9/#Explicit_Levels_and_Directions |
| 333 | 316 |
| 334 public: | 317 public: |
| 335 unsigned char bidiEmbeddingLevel() const { return m_bidiEmbeddingLevel;
} | 318 unsigned char bidiEmbeddingLevel() const { return m_bidiEmbeddingLevel;
} |
| 336 void setBidiEmbeddingLevel(unsigned char bidiEmbeddingLevel) { m_bidiEmb
eddingLevel = bidiEmbeddingLevel; } | 319 void setBidiEmbeddingLevel(unsigned char bidiEmbeddingLevel) { m_bidiEmb
eddingLevel = bidiEmbeddingLevel; } |
| 337 | 320 |
| 338 ADD_BOOLEAN_BITFIELD(dirty, Dirty); | 321 ADD_BOOLEAN_BITFIELD(dirty, Dirty); |
| 339 ADD_BOOLEAN_BITFIELD(extracted, Extracted); | 322 ADD_BOOLEAN_BITFIELD(extracted, Extracted); |
| 340 ADD_BOOLEAN_BITFIELD(hasVirtualLogicalHeight, HasVirtualLogicalHeight); | 323 ADD_BOOLEAN_BITFIELD(hasVirtualLogicalHeight, HasVirtualLogicalHeight); |
| 341 ADD_BOOLEAN_BITFIELD(isHorizontal, IsHorizontal); | |
| 342 // for RootInlineBox | 324 // for RootInlineBox |
| 343 ADD_BOOLEAN_BITFIELD(endsWithBreak, EndsWithBreak); // Whether the line
ends with a <br>. | 325 ADD_BOOLEAN_BITFIELD(endsWithBreak, EndsWithBreak); // Whether the line
ends with a <br>. |
| 344 // shared between RootInlineBox and InlineTextBox | 326 // shared between RootInlineBox and InlineTextBox |
| 345 ADD_BOOLEAN_BITFIELD(hasSelectedChildrenOrCanHaveLeadingExpansion, HasSe
lectedChildrenOrCanHaveLeadingExpansion); | 327 ADD_BOOLEAN_BITFIELD(hasSelectedChildrenOrCanHaveLeadingExpansion, HasSe
lectedChildrenOrCanHaveLeadingExpansion); |
| 346 ADD_BOOLEAN_BITFIELD(knownToHaveNoOverflow, KnownToHaveNoOverflow); | 328 ADD_BOOLEAN_BITFIELD(knownToHaveNoOverflow, KnownToHaveNoOverflow); |
| 347 ADD_BOOLEAN_BITFIELD(hasEllipsisBoxOrHyphen, HasEllipsisBoxOrHyphen); | 329 ADD_BOOLEAN_BITFIELD(hasEllipsisBoxOrHyphen, HasEllipsisBoxOrHyphen); |
| 348 // for InlineTextBox | 330 // for InlineTextBox |
| 349 ADD_BOOLEAN_BITFIELD(dirOverride, DirOverride); | 331 ADD_BOOLEAN_BITFIELD(dirOverride, DirOverride); |
| 350 ADD_BOOLEAN_BITFIELD(isText, IsText); // Whether or not this object repr
esents text with a non-zero height. Includes non-image list markers, text boxes. | 332 ADD_BOOLEAN_BITFIELD(isText, IsText); // Whether or not this object repr
esents text with a non-zero height. Includes non-image list markers, text boxes. |
| 351 | 333 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 | 413 |
| 432 } // namespace blink | 414 } // namespace blink |
| 433 | 415 |
| 434 #ifndef NDEBUG | 416 #ifndef NDEBUG |
| 435 // Outside the WebCore namespace for ease of invocation from gdb. | 417 // Outside the WebCore namespace for ease of invocation from gdb. |
| 436 void showTree(const blink::InlineBox*); | 418 void showTree(const blink::InlineBox*); |
| 437 void showLineTree(const blink::InlineBox*); | 419 void showLineTree(const blink::InlineBox*); |
| 438 #endif | 420 #endif |
| 439 | 421 |
| 440 #endif // InlineBox_h | 422 #endif // InlineBox_h |
| OLD | NEW |