2 * Copyright (C) 2003, 2006 Apple Computer, Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
21 #include "core/layout/line/EllipsisBox.h"
23 #include "core/layout/HitTestResult.h"
24 #include "core/layout/TextRunConstructor.h"
25 #include "core/layout/line/InlineTextBox.h"
26 #include "core/layout/line/RootInlineBox.h"
27 #include "core/paint/EllipsisBoxPainter.h"
28 #include "core/style/ShadowList.h"
29 #include "platform/fonts/Font.h"
30 #include "platform/text/TextRun.h"
34 void EllipsisBox::paint(const PaintInfo
& paintInfo
, const LayoutPoint
& paintOffset
, LayoutUnit lineTop
, LayoutUnit lineBottom
)
36 EllipsisBoxPainter(*this).paint(paintInfo
, paintOffset
, lineTop
, lineBottom
);
39 IntRect
EllipsisBox::selectionRect()
41 const ComputedStyle
& style
= lineLayoutItem().styleRef(isFirstLineStyle());
42 const Font
& font
= style
.font();
43 return enclosingIntRect(font
.selectionRectForText(constructTextRun(font
, m_str
, style
, TextRun::AllowTrailingExpansion
), IntPoint(logicalLeft(), logicalTop() + root().selectionTopAdjustedForPrecedingBlock()), root().selectionHeightAdjustedForPrecedingBlock()));
46 bool EllipsisBox::nodeAtPoint(HitTestResult
& result
, const HitTestLocation
& locationInContainer
, const LayoutPoint
& accumulatedOffset
, LayoutUnit lineTop
, LayoutUnit lineBottom
)
48 // FIXME: the call to roundedLayoutPoint() below is temporary and should be removed once
49 // the transition to LayoutUnit-based types is complete (crbug.com/321237)
50 LayoutPoint adjustedLocation
= accumulatedOffset
+ topLeft();
52 LayoutPoint boxOrigin
= locationIncludingFlipping();
53 boxOrigin
.moveBy(accumulatedOffset
);
54 LayoutRect
boundsRect(boxOrigin
, size());
55 if (visibleToHitTestRequest(result
.hitTestRequest()) && boundsRect
.intersects(LayoutRect(HitTestLocation::rectForPoint(locationInContainer
.point(), 0, 0, 0, 0)))) {
56 lineLayoutItem().updateHitTestResult(result
, locationInContainer
.point() - toLayoutSize(adjustedLocation
));
57 // FIXME: the call to rawValue() below is temporary and should be removed once the transition
58 // to LayoutUnit-based types is complete (crbug.com/321237)
59 if (!result
.addNodeToListBasedTestResult(lineLayoutItem().node(), locationInContainer
, boundsRect
))
66 const char* EllipsisBox::boxName() const