| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 x().toFloat(), y().toFloat(), width().toFloat(), height().toFloat(), | 136 x().toFloat(), y().toFloat(), width().toFloat(), height().toFloat(), |
| 137 baselinePosition(AlphabeticBaseline), baselinePosition(IdeographicBaseli
ne)); | 137 baselinePosition(AlphabeticBaseline), baselinePosition(IdeographicBaseli
ne)); |
| 138 } | 138 } |
| 139 #endif | 139 #endif |
| 140 | 140 |
| 141 LayoutUnit InlineBox::logicalHeight() const | 141 LayoutUnit InlineBox::logicalHeight() const |
| 142 { | 142 { |
| 143 if (hasVirtualLogicalHeight()) | 143 if (hasVirtualLogicalHeight()) |
| 144 return virtualLogicalHeight(); | 144 return virtualLogicalHeight(); |
| 145 | 145 |
| 146 if (lineLayoutItem().isText()) | 146 if (getLineLayoutItem().isText()) |
| 147 return m_bitfields.isText() ? LayoutUnit(lineLayoutItem().style(isFirstL
ineStyle())->fontMetrics().height()) : LayoutUnit(); | 147 return m_bitfields.isText() ? LayoutUnit(getLineLayoutItem().style(isFir
stLineStyle())->fontMetrics().height()) : LayoutUnit(); |
| 148 if (lineLayoutItem().isBox() && parent()) | 148 if (getLineLayoutItem().isBox() && parent()) |
| 149 return isHorizontal() ? toLayoutBox(layoutObject()).size().height() : to
LayoutBox(layoutObject()).size().width(); | 149 return isHorizontal() ? toLayoutBox(layoutObject()).size().height() : to
LayoutBox(layoutObject()).size().width(); |
| 150 | 150 |
| 151 ASSERT(isInlineFlowBox()); | 151 ASSERT(isInlineFlowBox()); |
| 152 LineLayoutBoxModel flowObject = boxModelObject(); | 152 LineLayoutBoxModel flowObject = boxModelObject(); |
| 153 const FontMetrics& fontMetrics = lineLayoutItem().style(isFirstLineStyle())-
>fontMetrics(); | 153 const FontMetrics& fontMetrics = getLineLayoutItem().style(isFirstLineStyle(
))->fontMetrics(); |
| 154 LayoutUnit result(fontMetrics.height()); | 154 LayoutUnit result(fontMetrics.height()); |
| 155 if (parent()) | 155 if (parent()) |
| 156 result += flowObject.borderAndPaddingLogicalHeight(); | 156 result += flowObject.borderAndPaddingLogicalHeight(); |
| 157 return result; | 157 return result; |
| 158 } | 158 } |
| 159 | 159 |
| 160 int InlineBox::baselinePosition(FontBaseline baselineType) const | 160 int InlineBox::baselinePosition(FontBaseline baselineType) const |
| 161 { | 161 { |
| 162 return boxModelObject().baselinePosition(baselineType, m_bitfields.firstLine
(), isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine); | 162 return boxModelObject().baselinePosition(baselineType, m_bitfields.firstLine
(), isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine); |
| 163 } | 163 } |
| 164 | 164 |
| 165 LayoutUnit InlineBox::lineHeight() const | 165 LayoutUnit InlineBox::lineHeight() const |
| 166 { | 166 { |
| 167 return boxModelObject().lineHeight(m_bitfields.firstLine(), isHorizontal() ?
HorizontalLine : VerticalLine, PositionOnContainingLine); | 167 return boxModelObject().lineHeight(m_bitfields.firstLine(), isHorizontal() ?
HorizontalLine : VerticalLine, PositionOnContainingLine); |
| 168 } | 168 } |
| 169 | 169 |
| 170 int InlineBox::caretMinOffset() const | 170 int InlineBox::caretMinOffset() const |
| 171 { | 171 { |
| 172 return lineLayoutItem().caretMinOffset(); | 172 return getLineLayoutItem().caretMinOffset(); |
| 173 } | 173 } |
| 174 | 174 |
| 175 int InlineBox::caretMaxOffset() const | 175 int InlineBox::caretMaxOffset() const |
| 176 { | 176 { |
| 177 return lineLayoutItem().caretMaxOffset(); | 177 return getLineLayoutItem().caretMaxOffset(); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void InlineBox::dirtyLineBoxes() | 180 void InlineBox::dirtyLineBoxes() |
| 181 { | 181 { |
| 182 markDirty(); | 182 markDirty(); |
| 183 for (InlineFlowBox* curr = parent(); curr && !curr->isDirty(); curr = curr->
parent()) | 183 for (InlineFlowBox* curr = parent(); curr && !curr->isDirty(); curr = curr->
parent()) |
| 184 curr->markDirty(); | 184 curr->markDirty(); |
| 185 } | 185 } |
| 186 | 186 |
| 187 void InlineBox::deleteLine() | 187 void InlineBox::deleteLine() |
| 188 { | 188 { |
| 189 if (!m_bitfields.extracted() && lineLayoutItem().isBox()) | 189 if (!m_bitfields.extracted() && getLineLayoutItem().isBox()) |
| 190 toLayoutBox(layoutObject()).setInlineBoxWrapper(nullptr); | 190 toLayoutBox(layoutObject()).setInlineBoxWrapper(nullptr); |
| 191 destroy(); | 191 destroy(); |
| 192 } | 192 } |
| 193 | 193 |
| 194 void InlineBox::extractLine() | 194 void InlineBox::extractLine() |
| 195 { | 195 { |
| 196 m_bitfields.setExtracted(true); | 196 m_bitfields.setExtracted(true); |
| 197 if (lineLayoutItem().isBox()) | 197 if (getLineLayoutItem().isBox()) |
| 198 toLayoutBox(layoutObject()).setInlineBoxWrapper(nullptr); | 198 toLayoutBox(layoutObject()).setInlineBoxWrapper(nullptr); |
| 199 } | 199 } |
| 200 | 200 |
| 201 void InlineBox::attachLine() | 201 void InlineBox::attachLine() |
| 202 { | 202 { |
| 203 m_bitfields.setExtracted(false); | 203 m_bitfields.setExtracted(false); |
| 204 if (lineLayoutItem().isBox()) | 204 if (getLineLayoutItem().isBox()) |
| 205 toLayoutBox(layoutObject()).setInlineBoxWrapper(this); | 205 toLayoutBox(layoutObject()).setInlineBoxWrapper(this); |
| 206 } | 206 } |
| 207 | 207 |
| 208 void InlineBox::move(const LayoutSize& delta) | 208 void InlineBox::move(const LayoutSize& delta) |
| 209 { | 209 { |
| 210 m_topLeft.move(delta); | 210 m_topLeft.move(delta); |
| 211 | 211 |
| 212 if (lineLayoutItem().isAtomicInlineLevel()) | 212 if (getLineLayoutItem().isAtomicInlineLevel()) |
| 213 toLayoutBox(layoutObject()).move(delta.width(), delta.height()); | 213 toLayoutBox(layoutObject()).move(delta.width(), delta.height()); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void InlineBox::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset
, LayoutUnit /* lineTop */, LayoutUnit /* lineBottom */) const | 216 void InlineBox::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset
, LayoutUnit /* lineTop */, LayoutUnit /* lineBottom */) const |
| 217 { | 217 { |
| 218 BlockPainter::paintInlineBox(*this, paintInfo, paintOffset); | 218 BlockPainter::paintInlineBox(*this, paintInfo, paintOffset); |
| 219 } | 219 } |
| 220 | 220 |
| 221 bool InlineBox::nodeAtPoint(HitTestResult& result, const HitTestLocation& locati
onInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit /* lineTop */, L
ayoutUnit /* lineBottom */) | 221 bool InlineBox::nodeAtPoint(HitTestResult& result, const HitTestLocation& locati
onInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit /* lineTop */, L
ayoutUnit /* lineBottom */) |
| 222 { | 222 { |
| 223 // Hit test all phases of replaced elements atomically, as though the replac
ed element established its | 223 // Hit test all phases of replaced elements atomically, as though the replac
ed element established its |
| 224 // own stacking context. (See Appendix E.2, section 6.4 on inline block/tab
le elements in the CSS2.1 | 224 // own stacking context. (See Appendix E.2, section 6.4 on inline block/tab
le elements in the CSS2.1 |
| 225 // specification.) | 225 // specification.) |
| 226 LayoutPoint childPoint = accumulatedOffset; | 226 LayoutPoint childPoint = accumulatedOffset; |
| 227 if (parent()->lineLayoutItem().hasFlippedBlocksWritingMode()) // Faster than
calling containingBlock(). | 227 if (parent()->getLineLayoutItem().hasFlippedBlocksWritingMode()) // Faster t
han calling containingBlock(). |
| 228 childPoint = layoutObject().containingBlock()->flipForWritingModeForChil
d(&toLayoutBox(layoutObject()), childPoint); | 228 childPoint = layoutObject().containingBlock()->flipForWritingModeForChil
d(&toLayoutBox(layoutObject()), childPoint); |
| 229 | 229 |
| 230 if (lineLayoutItem().style()->hasBorderRadius()) { | 230 if (getLineLayoutItem().style()->hasBorderRadius()) { |
| 231 LayoutRect borderRect = logicalFrameRect(); | 231 LayoutRect borderRect = logicalFrameRect(); |
| 232 borderRect.moveBy(accumulatedOffset); | 232 borderRect.moveBy(accumulatedOffset); |
| 233 FloatRoundedRect border = lineLayoutItem().style()->getRoundedBorderFor(
borderRect); | 233 FloatRoundedRect border = getLineLayoutItem().style()->getRoundedBorderF
or(borderRect); |
| 234 if (!locationInContainer.intersects(border)) | 234 if (!locationInContainer.intersects(border)) |
| 235 return false; | 235 return false; |
| 236 } | 236 } |
| 237 | 237 |
| 238 return lineLayoutItem().hitTest(result, locationInContainer, childPoint); | 238 return getLineLayoutItem().hitTest(result, locationInContainer, childPoint); |
| 239 } | 239 } |
| 240 | 240 |
| 241 const RootInlineBox& InlineBox::root() const | 241 const RootInlineBox& InlineBox::root() const |
| 242 { | 242 { |
| 243 if (m_parent) | 243 if (m_parent) |
| 244 return m_parent->root(); | 244 return m_parent->root(); |
| 245 ASSERT(isRootInlineBox()); | 245 ASSERT(isRootInlineBox()); |
| 246 return static_cast<const RootInlineBox&>(*this); | 246 return static_cast<const RootInlineBox&>(*this); |
| 247 } | 247 } |
| 248 | 248 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 InlineBox* leaf = nextLeafChild(); | 294 InlineBox* leaf = nextLeafChild(); |
| 295 return (leaf && leaf->isLineBreak()) ? nullptr : leaf; | 295 return (leaf && leaf->isLineBreak()) ? nullptr : leaf; |
| 296 } | 296 } |
| 297 | 297 |
| 298 InlineBox* InlineBox::prevLeafChildIgnoringLineBreak() const | 298 InlineBox* InlineBox::prevLeafChildIgnoringLineBreak() const |
| 299 { | 299 { |
| 300 InlineBox* leaf = prevLeafChild(); | 300 InlineBox* leaf = prevLeafChild(); |
| 301 return (leaf && leaf->isLineBreak()) ? nullptr : leaf; | 301 return (leaf && leaf->isLineBreak()) ? nullptr : leaf; |
| 302 } | 302 } |
| 303 | 303 |
| 304 SelectionState InlineBox::selectionState() const | 304 SelectionState InlineBox::getSelectionState() const |
| 305 { | 305 { |
| 306 return layoutObject().selectionState(); | 306 return layoutObject().getSelectionState(); |
| 307 } | 307 } |
| 308 | 308 |
| 309 bool InlineBox::canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsisWidt
h) const | 309 bool InlineBox::canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsisWidt
h) const |
| 310 { | 310 { |
| 311 // Non-atomic inline-level elements can always accommodate an ellipsis. | 311 // Non-atomic inline-level elements can always accommodate an ellipsis. |
| 312 if (!lineLayoutItem().isAtomicInlineLevel()) | 312 if (!getLineLayoutItem().isAtomicInlineLevel()) |
| 313 return true; | 313 return true; |
| 314 | 314 |
| 315 IntRect boxRect(left(), 0, m_logicalWidth, 10); | 315 IntRect boxRect(left(), 0, m_logicalWidth, 10); |
| 316 IntRect ellipsisRect(ltr ? blockEdge - ellipsisWidth : blockEdge, 0, ellipsi
sWidth, 10); | 316 IntRect ellipsisRect(ltr ? blockEdge - ellipsisWidth : blockEdge, 0, ellipsi
sWidth, 10); |
| 317 return !(boxRect.intersects(ellipsisRect)); | 317 return !(boxRect.intersects(ellipsisRect)); |
| 318 } | 318 } |
| 319 | 319 |
| 320 LayoutUnit InlineBox::placeEllipsisBox(bool, LayoutUnit, LayoutUnit, LayoutUnit,
LayoutUnit& truncatedWidth, bool&) | 320 LayoutUnit InlineBox::placeEllipsisBox(bool, LayoutUnit, LayoutUnit, LayoutUnit,
LayoutUnit& truncatedWidth, bool&) |
| 321 { | 321 { |
| 322 // Use -1 to mean "we didn't set the position." | 322 // Use -1 to mean "we didn't set the position." |
| 323 truncatedWidth += logicalWidth(); | 323 truncatedWidth += logicalWidth(); |
| 324 return LayoutUnit(-1); | 324 return LayoutUnit(-1); |
| 325 } | 325 } |
| 326 | 326 |
| 327 void InlineBox::clearKnownToHaveNoOverflow() | 327 void InlineBox::clearKnownToHaveNoOverflow() |
| 328 { | 328 { |
| 329 m_bitfields.setKnownToHaveNoOverflow(false); | 329 m_bitfields.setKnownToHaveNoOverflow(false); |
| 330 if (parent() && parent()->knownToHaveNoOverflow()) | 330 if (parent() && parent()->knownToHaveNoOverflow()) |
| 331 parent()->clearKnownToHaveNoOverflow(); | 331 parent()->clearKnownToHaveNoOverflow(); |
| 332 } | 332 } |
| 333 | 333 |
| 334 LayoutPoint InlineBox::locationIncludingFlipping() const | 334 LayoutPoint InlineBox::locationIncludingFlipping() const |
| 335 { | 335 { |
| 336 return logicalPositionToPhysicalPoint(m_topLeft, size()); | 336 return logicalPositionToPhysicalPoint(m_topLeft, size()); |
| 337 } | 337 } |
| 338 | 338 |
| 339 LayoutPoint InlineBox::logicalPositionToPhysicalPoint(const LayoutPoint& point,
const LayoutSize& size) const | 339 LayoutPoint InlineBox::logicalPositionToPhysicalPoint(const LayoutPoint& point,
const LayoutSize& size) const |
| 340 { | 340 { |
| 341 if (!UNLIKELY(lineLayoutItem().hasFlippedBlocksWritingMode())) | 341 if (!UNLIKELY(getLineLayoutItem().hasFlippedBlocksWritingMode())) |
| 342 return LayoutPoint(point.x(), point.y()); | 342 return LayoutPoint(point.x(), point.y()); |
| 343 | 343 |
| 344 LineLayoutBlockFlow block = root().block(); | 344 LineLayoutBlockFlow block = root().block(); |
| 345 if (block.style()->isHorizontalWritingMode()) | 345 if (block.style()->isHorizontalWritingMode()) |
| 346 return LayoutPoint(point.x(), block.size().height() - size.height() - po
int.y()); | 346 return LayoutPoint(point.x(), block.size().height() - size.height() - po
int.y()); |
| 347 | 347 |
| 348 return LayoutPoint(block.size().width() - size.width() - point.x(), point.y(
)); | 348 return LayoutPoint(block.size().width() - size.width() - point.x(), point.y(
)); |
| 349 } | 349 } |
| 350 | 350 |
| 351 void InlineBox::logicalRectToPhysicalRect(LayoutRect& current) const | 351 void InlineBox::logicalRectToPhysicalRect(LayoutRect& current) const |
| 352 { | 352 { |
| 353 if (isHorizontal() && !lineLayoutItem().hasFlippedBlocksWritingMode()) | 353 if (isHorizontal() && !getLineLayoutItem().hasFlippedBlocksWritingMode()) |
| 354 return; | 354 return; |
| 355 | 355 |
| 356 if (!isHorizontal()) { | 356 if (!isHorizontal()) { |
| 357 current = current.transposedRect(); | 357 current = current.transposedRect(); |
| 358 } | 358 } |
| 359 current.setLocation(logicalPositionToPhysicalPoint(current.location(), curre
nt.size())); | 359 current.setLocation(logicalPositionToPhysicalPoint(current.location(), curre
nt.size())); |
| 360 return; | 360 return; |
| 361 } | 361 } |
| 362 | 362 |
| 363 void InlineBox::flipForWritingMode(FloatRect& rect) const | 363 void InlineBox::flipForWritingMode(FloatRect& rect) const |
| 364 { | 364 { |
| 365 if (!UNLIKELY(lineLayoutItem().hasFlippedBlocksWritingMode())) | 365 if (!UNLIKELY(getLineLayoutItem().hasFlippedBlocksWritingMode())) |
| 366 return; | 366 return; |
| 367 root().block().flipForWritingMode(rect); | 367 root().block().flipForWritingMode(rect); |
| 368 } | 368 } |
| 369 | 369 |
| 370 FloatPoint InlineBox::flipForWritingMode(const FloatPoint& point) const | 370 FloatPoint InlineBox::flipForWritingMode(const FloatPoint& point) const |
| 371 { | 371 { |
| 372 if (!UNLIKELY(lineLayoutItem().hasFlippedBlocksWritingMode())) | 372 if (!UNLIKELY(getLineLayoutItem().hasFlippedBlocksWritingMode())) |
| 373 return point; | 373 return point; |
| 374 return root().block().flipForWritingMode(point); | 374 return root().block().flipForWritingMode(point); |
| 375 } | 375 } |
| 376 | 376 |
| 377 void InlineBox::flipForWritingMode(LayoutRect& rect) const | 377 void InlineBox::flipForWritingMode(LayoutRect& rect) const |
| 378 { | 378 { |
| 379 if (!UNLIKELY(lineLayoutItem().hasFlippedBlocksWritingMode())) | 379 if (!UNLIKELY(getLineLayoutItem().hasFlippedBlocksWritingMode())) |
| 380 return; | 380 return; |
| 381 root().block().flipForWritingMode(rect); | 381 root().block().flipForWritingMode(rect); |
| 382 } | 382 } |
| 383 | 383 |
| 384 LayoutPoint InlineBox::flipForWritingMode(const LayoutPoint& point) const | 384 LayoutPoint InlineBox::flipForWritingMode(const LayoutPoint& point) const |
| 385 { | 385 { |
| 386 if (!UNLIKELY(lineLayoutItem().hasFlippedBlocksWritingMode())) | 386 if (!UNLIKELY(getLineLayoutItem().hasFlippedBlocksWritingMode())) |
| 387 return point; | 387 return point; |
| 388 return root().block().flipForWritingMode(point); | 388 return root().block().flipForWritingMode(point); |
| 389 } | 389 } |
| 390 | 390 |
| 391 void InlineBox::invalidateDisplayItemClientsRecursively() | 391 void InlineBox::invalidateDisplayItemClientsRecursively() |
| 392 { | 392 { |
| 393 layoutObject().invalidateDisplayItemClient(*this); | 393 layoutObject().invalidateDisplayItemClient(*this); |
| 394 if (!isInlineFlowBox()) | 394 if (!isInlineFlowBox()) |
| 395 return; | 395 return; |
| 396 for (InlineBox* child = toInlineFlowBox(this)->firstChild(); child; child =
child->nextOnLine()) | 396 for (InlineBox* child = toInlineFlowBox(this)->firstChild(); child; child =
child->nextOnLine()) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 411 | 411 |
| 412 void showLineTree(const blink::InlineBox* b) | 412 void showLineTree(const blink::InlineBox* b) |
| 413 { | 413 { |
| 414 if (b) | 414 if (b) |
| 415 b->showLineTreeForThis(); | 415 b->showLineTreeForThis(); |
| 416 else | 416 else |
| 417 fprintf(stderr, "Cannot showLineTree for (nil) InlineBox.\n"); | 417 fprintf(stderr, "Cannot showLineTree for (nil) InlineBox.\n"); |
| 418 } | 418 } |
| 419 | 419 |
| 420 #endif | 420 #endif |
| OLD | NEW |