| OLD | NEW |
| 1 /* | 1 /* |
| 2 * (C) 1999 Lars Knoll (knoll@kde.org) | 2 * (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2000 Dirk Mueller (mueller@kde.org) | 3 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
| 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) | 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) |
| 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) | 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 | 314 |
| 315 void RenderText::absoluteQuads(Vector<FloatQuad>& quads, ClippingOption option)
const | 315 void RenderText::absoluteQuads(Vector<FloatQuad>& quads, ClippingOption option)
const |
| 316 { | 316 { |
| 317 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) { | 317 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) { |
| 318 FloatRect boundaries = box->calculateBoundaries(); | 318 FloatRect boundaries = box->calculateBoundaries(); |
| 319 | 319 |
| 320 // Shorten the width of this text box if it ends in an ellipsis. | 320 // Shorten the width of this text box if it ends in an ellipsis. |
| 321 // FIXME: ellipsisRectForBox should switch to return FloatRect soon with
the subpixellayout branch. | 321 // FIXME: ellipsisRectForBox should switch to return FloatRect soon with
the subpixellayout branch. |
| 322 IntRect ellipsisRect = (option == ClipToEllipsis) ? ellipsisRectForBox(b
ox, 0, textLength()) : IntRect(); | 322 IntRect ellipsisRect = (option == ClipToEllipsis) ? ellipsisRectForBox(b
ox, 0, textLength()) : IntRect(); |
| 323 if (!ellipsisRect.isEmpty()) { | 323 if (!ellipsisRect.isEmpty()) { |
| 324 if (style()->isHorizontalWritingMode()) | 324 boundaries.setWidth(ellipsisRect.maxX() - boundaries.x()); |
| 325 boundaries.setWidth(ellipsisRect.maxX() - boundaries.x()); | |
| 326 else | |
| 327 boundaries.setHeight(ellipsisRect.maxY() - boundaries.y()); | |
| 328 } | 325 } |
| 329 quads.append(localToAbsoluteQuad(boundaries, 0)); | 326 quads.append(localToAbsoluteQuad(boundaries, 0)); |
| 330 } | 327 } |
| 331 } | 328 } |
| 332 | 329 |
| 333 void RenderText::absoluteQuads(Vector<FloatQuad>& quads) const | 330 void RenderText::absoluteQuads(Vector<FloatQuad>& quads) const |
| 334 { | 331 { |
| 335 absoluteQuads(quads, NoClipping); | 332 absoluteQuads(quads, NoClipping); |
| 336 } | 333 } |
| 337 | 334 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 return createPositionWithAffinityForBox(box, box->caretLeftmostOffset(), sho
uldAffinityBeDownstream); | 495 return createPositionWithAffinityForBox(box, box->caretLeftmostOffset(), sho
uldAffinityBeDownstream); |
| 499 } | 496 } |
| 500 | 497 |
| 501 PositionWithAffinity RenderText::positionForPoint(const LayoutPoint& point) | 498 PositionWithAffinity RenderText::positionForPoint(const LayoutPoint& point) |
| 502 { | 499 { |
| 503 if (!firstTextBox() || textLength() == 0) | 500 if (!firstTextBox() || textLength() == 0) |
| 504 return createPositionWithAffinity(0, DOWNSTREAM); | 501 return createPositionWithAffinity(0, DOWNSTREAM); |
| 505 | 502 |
| 506 LayoutUnit pointLineDirection = firstTextBox()->isHorizontal() ? point.x() :
point.y(); | 503 LayoutUnit pointLineDirection = firstTextBox()->isHorizontal() ? point.x() :
point.y(); |
| 507 LayoutUnit pointBlockDirection = firstTextBox()->isHorizontal() ? point.y()
: point.x(); | 504 LayoutUnit pointBlockDirection = firstTextBox()->isHorizontal() ? point.y()
: point.x(); |
| 508 bool blocksAreFlipped = style()->isFlippedBlocksWritingMode(); | |
| 509 | 505 |
| 510 InlineTextBox* lastBox = 0; | 506 InlineTextBox* lastBox = 0; |
| 511 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) { | 507 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) { |
| 512 if (box->isLineBreak() && !box->prevLeafChild() && box->nextLeafChild()
&& !box->nextLeafChild()->isLineBreak()) | 508 if (box->isLineBreak() && !box->prevLeafChild() && box->nextLeafChild()
&& !box->nextLeafChild()->isLineBreak()) |
| 513 box = box->nextTextBox(); | 509 box = box->nextTextBox(); |
| 514 | 510 |
| 515 RootInlineBox& rootBox = box->root(); | 511 RootInlineBox& rootBox = box->root(); |
| 516 LayoutUnit top = std::min(rootBox.selectionTop(), rootBox.lineTop()); | 512 LayoutUnit top = std::min(rootBox.selectionTop(), rootBox.lineTop()); |
| 517 if (pointBlockDirection > top || (!blocksAreFlipped && pointBlockDirecti
on == top)) { | 513 if (pointBlockDirection > top || pointBlockDirection == top) { |
| 518 LayoutUnit bottom = rootBox.selectionBottom(); | 514 LayoutUnit bottom = rootBox.selectionBottom(); |
| 519 if (rootBox.nextRootBox()) | 515 if (rootBox.nextRootBox()) |
| 520 bottom = std::min(bottom, rootBox.nextRootBox()->lineTop()); | 516 bottom = std::min(bottom, rootBox.nextRootBox()->lineTop()); |
| 521 | 517 |
| 522 if (pointBlockDirection < bottom || (blocksAreFlipped && pointBlockD
irection == bottom)) { | 518 if (pointBlockDirection < bottom) { |
| 523 ShouldAffinityBeDownstream shouldAffinityBeDownstream; | 519 ShouldAffinityBeDownstream shouldAffinityBeDownstream; |
| 524 if (lineDirectionPointFitsInBox(pointLineDirection, box, shouldA
ffinityBeDownstream)) | 520 if (lineDirectionPointFitsInBox(pointLineDirection, box, shouldA
ffinityBeDownstream)) |
| 525 return createPositionWithAffinityForBoxAfterAdjustingOffsetF
orBiDi(box, box->offsetForPosition(pointLineDirection.toFloat()), shouldAffinity
BeDownstream); | 521 return createPositionWithAffinityForBoxAfterAdjustingOffsetF
orBiDi(box, box->offsetForPosition(pointLineDirection.toFloat()), shouldAffinity
BeDownstream); |
| 526 } | 522 } |
| 527 } | 523 } |
| 528 lastBox = box; | 524 lastBox = box; |
| 529 } | 525 } |
| 530 | 526 |
| 531 if (lastBox) { | 527 if (lastBox) { |
| 532 ShouldAffinityBeDownstream shouldAffinityBeDownstream; | 528 ShouldAffinityBeDownstream shouldAffinityBeDownstream; |
| (...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1359 // Return the width of the minimal left side and the maximal right side. | 1355 // Return the width of the minimal left side and the maximal right side. |
| 1360 float logicalLeftSide = 0; | 1356 float logicalLeftSide = 0; |
| 1361 float logicalRightSide = 0; | 1357 float logicalRightSide = 0; |
| 1362 for (InlineTextBox* curr = firstTextBox(); curr; curr = curr->nextTextBo
x()) { | 1358 for (InlineTextBox* curr = firstTextBox(); curr; curr = curr->nextTextBo
x()) { |
| 1363 if (curr == firstTextBox() || curr->logicalLeft() < logicalLeftSide) | 1359 if (curr == firstTextBox() || curr->logicalLeft() < logicalLeftSide) |
| 1364 logicalLeftSide = curr->logicalLeft(); | 1360 logicalLeftSide = curr->logicalLeft(); |
| 1365 if (curr == firstTextBox() || curr->logicalRight() > logicalRightSid
e) | 1361 if (curr == firstTextBox() || curr->logicalRight() > logicalRightSid
e) |
| 1366 logicalRightSide = curr->logicalRight(); | 1362 logicalRightSide = curr->logicalRight(); |
| 1367 } | 1363 } |
| 1368 | 1364 |
| 1369 bool isHorizontal = style()->isHorizontalWritingMode(); | 1365 float x = logicalLeftSide; |
| 1370 | 1366 float y = firstTextBox()->y(); |
| 1371 float x = isHorizontal ? logicalLeftSide : firstTextBox()->x(); | 1367 float width = logicalRightSide - logicalLeftSide; |
| 1372 float y = isHorizontal ? firstTextBox()->y() : logicalLeftSide; | 1368 float height = lastTextBox()->logicalBottom() - y; |
| 1373 float width = isHorizontal ? logicalRightSide - logicalLeftSide : lastTe
xtBox()->logicalBottom() - x; | |
| 1374 float height = isHorizontal ? lastTextBox()->logicalBottom() - y : logic
alRightSide - logicalLeftSide; | |
| 1375 result = enclosingIntRect(FloatRect(x, y, width, height)); | 1369 result = enclosingIntRect(FloatRect(x, y, width, height)); |
| 1376 } | 1370 } |
| 1377 | 1371 |
| 1378 return result; | 1372 return result; |
| 1379 } | 1373 } |
| 1380 | 1374 |
| 1381 LayoutRect RenderText::linesVisualOverflowBoundingBox() const | 1375 LayoutRect RenderText::linesVisualOverflowBoundingBox() const |
| 1382 { | 1376 { |
| 1383 if (!firstTextBox()) | 1377 if (!firstTextBox()) |
| 1384 return LayoutRect(); | 1378 return LayoutRect(); |
| 1385 | 1379 |
| 1386 // Return the width of the minimal left side and the maximal right side. | 1380 // Return the width of the minimal left side and the maximal right side. |
| 1387 LayoutUnit logicalLeftSide = LayoutUnit::max(); | 1381 LayoutUnit logicalLeftSide = LayoutUnit::max(); |
| 1388 LayoutUnit logicalRightSide = LayoutUnit::min(); | 1382 LayoutUnit logicalRightSide = LayoutUnit::min(); |
| 1389 for (InlineTextBox* curr = firstTextBox(); curr; curr = curr->nextTextBox())
{ | 1383 for (InlineTextBox* curr = firstTextBox(); curr; curr = curr->nextTextBox())
{ |
| 1390 LayoutRect logicalVisualOverflow = curr->logicalOverflowRect(); | 1384 LayoutRect logicalVisualOverflow = curr->logicalOverflowRect(); |
| 1391 logicalLeftSide = std::min(logicalLeftSide, logicalVisualOverflow.x()); | 1385 logicalLeftSide = std::min(logicalLeftSide, logicalVisualOverflow.x()); |
| 1392 logicalRightSide = std::max(logicalRightSide, logicalVisualOverflow.maxX
()); | 1386 logicalRightSide = std::max(logicalRightSide, logicalVisualOverflow.maxX
()); |
| 1393 } | 1387 } |
| 1394 | 1388 |
| 1395 LayoutUnit logicalTop = firstTextBox()->logicalTopVisualOverflow(); | 1389 LayoutUnit logicalTop = firstTextBox()->logicalTopVisualOverflow(); |
| 1396 LayoutUnit logicalWidth = logicalRightSide - logicalLeftSide; | 1390 LayoutUnit logicalWidth = logicalRightSide - logicalLeftSide; |
| 1397 LayoutUnit logicalHeight = lastTextBox()->logicalBottomVisualOverflow() - lo
gicalTop; | 1391 LayoutUnit logicalHeight = lastTextBox()->logicalBottomVisualOverflow() - lo
gicalTop; |
| 1398 | 1392 |
| 1399 LayoutRect rect(logicalLeftSide, logicalTop, logicalWidth, logicalHeight); | 1393 LayoutRect rect(logicalLeftSide, logicalTop, logicalWidth, logicalHeight); |
| 1400 if (!style()->isHorizontalWritingMode()) | |
| 1401 rect = rect.transposedRect(); | |
| 1402 return rect; | 1394 return rect; |
| 1403 } | 1395 } |
| 1404 | 1396 |
| 1405 LayoutRect RenderText::clippedOverflowRectForPaintInvalidation(const RenderLayer
ModelObject* paintInvalidationContainer, const PaintInvalidationState* paintInva
lidationState) const | 1397 LayoutRect RenderText::clippedOverflowRectForPaintInvalidation(const RenderLayer
ModelObject* paintInvalidationContainer, const PaintInvalidationState* paintInva
lidationState) const |
| 1406 { | 1398 { |
| 1407 RenderObject* rendererToIssuePaintInvalidations = containingBlock(); | 1399 RenderObject* rendererToIssuePaintInvalidations = containingBlock(); |
| 1408 | 1400 |
| 1409 // Do not cross self-painting layer boundaries. | 1401 // Do not cross self-painting layer boundaries. |
| 1410 RenderObject* enclosingLayerRenderer = enclosingLayer()->renderer(); | 1402 RenderObject* enclosingLayerRenderer = enclosingLayer()->renderer(); |
| 1411 if (enclosingLayerRenderer != rendererToIssuePaintInvalidations && !renderer
ToIssuePaintInvalidations->isDescendantOf(enclosingLayerRenderer)) | 1403 if (enclosingLayerRenderer != rendererToIssuePaintInvalidations && !renderer
ToIssuePaintInvalidations->isDescendantOf(enclosingLayerRenderer)) |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1680 ASSERT(child->prevTextBox() == prev); | 1672 ASSERT(child->prevTextBox() == prev); |
| 1681 prev = child; | 1673 prev = child; |
| 1682 } | 1674 } |
| 1683 ASSERT(prev == m_lastTextBox); | 1675 ASSERT(prev == m_lastTextBox); |
| 1684 #endif | 1676 #endif |
| 1685 } | 1677 } |
| 1686 | 1678 |
| 1687 #endif | 1679 #endif |
| 1688 | 1680 |
| 1689 } // namespace blink | 1681 } // namespace blink |
| OLD | NEW |