| OLD | NEW |
| 1 /** | 1 /** |
| 2 * Copyright (C) 2003, 2006 Apple Computer, Inc. | 2 * Copyright (C) 2003, 2006 Apple Computer, Inc. |
| 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 20 matching lines...) Expand all Loading... |
| 31 #include "platform/fonts/Font.h" | 31 #include "platform/fonts/Font.h" |
| 32 #include "platform/text/TextRun.h" | 32 #include "platform/text/TextRun.h" |
| 33 | 33 |
| 34 namespace blink { | 34 namespace blink { |
| 35 | 35 |
| 36 void EllipsisBox::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffs
et, LayoutUnit lineTop, LayoutUnit lineBottom) | 36 void EllipsisBox::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffs
et, LayoutUnit lineTop, LayoutUnit lineBottom) |
| 37 { | 37 { |
| 38 EllipsisBoxPainter(*this).paint(paintInfo, paintOffset, lineTop, lineBottom)
; | 38 EllipsisBoxPainter(*this).paint(paintInfo, paintOffset, lineTop, lineBottom)
; |
| 39 } | 39 } |
| 40 | 40 |
| 41 InlineBox* EllipsisBox::markupBox() const | |
| 42 { | |
| 43 if (!m_shouldPaintMarkupBox || !layoutObject().isLayoutBlock()) | |
| 44 return 0; | |
| 45 | |
| 46 LayoutBlock& block = toLayoutBlock(layoutObject()); | |
| 47 RootInlineBox* lastLine = block.lineAtIndex(block.lineCount() - 1); | |
| 48 if (!lastLine) | |
| 49 return 0; | |
| 50 | |
| 51 // If the last line-box on the last line of a block is a link, -webkit-line-
clamp paints that box after the ellipsis. | |
| 52 // It does not actually move the link. | |
| 53 InlineBox* anchorBox = lastLine->lastChild(); | |
| 54 if (!anchorBox || !anchorBox->layoutObject().style()->isLink()) | |
| 55 return 0; | |
| 56 | |
| 57 return anchorBox; | |
| 58 } | |
| 59 | |
| 60 IntRect EllipsisBox::selectionRect() | 41 IntRect EllipsisBox::selectionRect() |
| 61 { | 42 { |
| 62 const ComputedStyle& style = layoutObject().styleRef(isFirstLineStyle()); | 43 const ComputedStyle& style = layoutObject().styleRef(isFirstLineStyle()); |
| 63 const Font& font = style.font(); | 44 const Font& font = style.font(); |
| 64 return enclosingIntRect(font.selectionRectForText(constructTextRun(&layoutOb
ject(), font, m_str, style, TextRun::AllowTrailingExpansion), IntPoint(logicalLe
ft(), logicalTop() + root().selectionTopAdjustedForPrecedingBlock()), root().sel
ectionHeightAdjustedForPrecedingBlock())); | 45 return enclosingIntRect(font.selectionRectForText(constructTextRun(&layoutOb
ject(), font, m_str, style, TextRun::AllowTrailingExpansion), IntPoint(logicalLe
ft(), logicalTop() + root().selectionTopAdjustedForPrecedingBlock()), root().sel
ectionHeightAdjustedForPrecedingBlock())); |
| 65 } | 46 } |
| 66 | 47 |
| 67 bool EllipsisBox::nodeAtPoint(HitTestResult& result, const HitTestLocation& loca
tionInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, Layou
tUnit lineBottom) | 48 bool EllipsisBox::nodeAtPoint(HitTestResult& result, const HitTestLocation& loca
tionInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, Layou
tUnit lineBottom) |
| 68 { | 49 { |
| 69 // FIXME: the call to roundedLayoutPoint() below is temporary and should be
removed once | 50 // FIXME: the call to roundedLayoutPoint() below is temporary and should be
removed once |
| 70 // the transition to LayoutUnit-based types is complete (crbug.com/321237) | 51 // the transition to LayoutUnit-based types is complete (crbug.com/321237) |
| 71 LayoutPoint adjustedLocation = accumulatedOffset + topLeft().roundedLayoutPo
int(); | 52 LayoutPoint adjustedLocation = accumulatedOffset + topLeft().roundedLayoutPo
int(); |
| 72 | 53 |
| 73 // Hit test the markup box. | |
| 74 if (InlineBox* markupBox = this->markupBox()) { | |
| 75 const ComputedStyle& style = layoutObject().styleRef(isFirstLineStyle())
; | |
| 76 LayoutUnit mtx = adjustedLocation.x() + m_logicalWidth - markupBox->x(); | |
| 77 LayoutUnit mty = adjustedLocation.y() + style.fontMetrics().ascent() - (
markupBox->y() + markupBox->layoutObject().style(isFirstLineStyle())->fontMetric
s().ascent()); | |
| 78 if (markupBox->nodeAtPoint(result, locationInContainer, LayoutPoint(mtx,
mty), lineTop, lineBottom)) { | |
| 79 layoutObject().updateHitTestResult(result, locationInContainer.point
() - LayoutSize(mtx, mty)); | |
| 80 return true; | |
| 81 } | |
| 82 } | |
| 83 | |
| 84 FloatPointWillBeLayoutPoint boxOrigin = locationIncludingFlipping(); | 54 FloatPointWillBeLayoutPoint boxOrigin = locationIncludingFlipping(); |
| 85 boxOrigin.moveBy(accumulatedOffset); | 55 boxOrigin.moveBy(accumulatedOffset); |
| 86 FloatRectWillBeLayoutRect boundsRect(boxOrigin, size()); | 56 FloatRectWillBeLayoutRect boundsRect(boxOrigin, size()); |
| 87 if (visibleToHitTestRequest(result.hitTestRequest()) && boundsRect.intersect
s(FloatRectWillBeLayoutRect(HitTestLocation::rectForPoint(locationInContainer.po
int(), 0, 0, 0, 0)))) { | 57 if (visibleToHitTestRequest(result.hitTestRequest()) && boundsRect.intersect
s(FloatRectWillBeLayoutRect(HitTestLocation::rectForPoint(locationInContainer.po
int(), 0, 0, 0, 0)))) { |
| 88 layoutObject().updateHitTestResult(result, locationInContainer.point() -
toLayoutSize(adjustedLocation)); | 58 layoutObject().updateHitTestResult(result, locationInContainer.point() -
toLayoutSize(adjustedLocation)); |
| 89 // FIXME: the call to rawValue() below is temporary and should be remove
d once the transition | 59 // FIXME: the call to rawValue() below is temporary and should be remove
d once the transition |
| 90 // to LayoutUnit-based types is complete (crbug.com/321237) | 60 // to LayoutUnit-based types is complete (crbug.com/321237) |
| 91 if (!result.addNodeToListBasedTestResult(layoutObject().node(), location
InContainer, boundsRect.rawValue())) | 61 if (!result.addNodeToListBasedTestResult(layoutObject().node(), location
InContainer, boundsRect.rawValue())) |
| 92 return true; | 62 return true; |
| 93 } | 63 } |
| 94 | 64 |
| 95 return false; | 65 return false; |
| 96 } | 66 } |
| 97 | 67 |
| 98 const char* EllipsisBox::boxName() const | 68 const char* EllipsisBox::boxName() const |
| 99 { | 69 { |
| 100 return "EllipsisBox"; | 70 return "EllipsisBox"; |
| 101 } | 71 } |
| 102 | 72 |
| 103 } // namespace blink | 73 } // namespace blink |
| OLD | NEW |