| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006, 2008 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // First sanity-check the unoverflowed width of the whole line to see if the
re is sufficient room. | 106 // First sanity-check the unoverflowed width of the whole line to see if the
re is sufficient room. |
| 107 int delta = ltr ? lineBoxEdge - blockEdge : blockEdge - lineBoxEdge; | 107 int delta = ltr ? lineBoxEdge - blockEdge : blockEdge - lineBoxEdge; |
| 108 if (logicalWidth() - delta < ellipsisWidth) | 108 if (logicalWidth() - delta < ellipsisWidth) |
| 109 return false; | 109 return false; |
| 110 | 110 |
| 111 // Next iterate over all the line boxes on the line. If we find a replaced
element that intersects | 111 // Next iterate over all the line boxes on the line. If we find a replaced
element that intersects |
| 112 // then we refuse to accommodate the ellipsis. Otherwise we're ok. | 112 // then we refuse to accommodate the ellipsis. Otherwise we're ok. |
| 113 return InlineFlowBox::canAccommodateEllipsis(ltr, blockEdge, ellipsisWidth); | 113 return InlineFlowBox::canAccommodateEllipsis(ltr, blockEdge, ellipsisWidth); |
| 114 } | 114 } |
| 115 | 115 |
| 116 float RootInlineBox::placeEllipsis(const AtomicString& ellipsisStr, bool ltr, f
loat blockLeftEdge, float blockRightEdge, float ellipsisWidth, | 116 FloatWillBeLayoutUnit RootInlineBox::placeEllipsis(const AtomicString& ellipsisS
tr, bool ltr, FloatWillBeLayoutUnit blockLeftEdge, FloatWillBeLayoutUnit blockR
ightEdge, FloatWillBeLayoutUnit ellipsisWidth, |
| 117 InlineBox* markupBox) | 117 InlineBox* markupBox) |
| 118 { | 118 { |
| 119 // Create an ellipsis box. | 119 // Create an ellipsis box. |
| 120 EllipsisBox* ellipsisBox = new EllipsisBox(renderer(), ellipsisStr, this, | 120 EllipsisBox* ellipsisBox = new EllipsisBox(renderer(), ellipsisStr, this, |
| 121 ellipsisWidth - (markupBox ? markupBox->logicalWidth() : 0), logicalHeig
ht(), | 121 ellipsisWidth - (markupBox ? markupBox->logicalWidth() : ZERO_LAYOUT_UNI
T), logicalHeight(), |
| 122 x(), y(), !prevRootBox(), isHorizontal(), markupBox); | 122 x(), y(), !prevRootBox(), isHorizontal(), markupBox); |
| 123 | 123 |
| 124 if (!gEllipsisBoxMap) | 124 if (!gEllipsisBoxMap) |
| 125 gEllipsisBoxMap = new EllipsisBoxMap(); | 125 gEllipsisBoxMap = new EllipsisBoxMap(); |
| 126 gEllipsisBoxMap->add(this, ellipsisBox); | 126 gEllipsisBoxMap->add(this, ellipsisBox); |
| 127 setHasEllipsisBox(true); | 127 setHasEllipsisBox(true); |
| 128 | 128 |
| 129 // FIXME: Do we need an RTL version of this? | 129 // FIXME: Do we need an RTL version of this? |
| 130 if (ltr && (logicalLeft() + logicalWidth() + ellipsisWidth) <= blockRightEdg
e) { | 130 if (ltr && (logicalLeft() + logicalWidth() + ellipsisWidth) <= blockRightEdg
e) { |
| 131 ellipsisBox->setLogicalLeft(logicalLeft() + logicalWidth()); | 131 ellipsisBox->setLogicalLeft(logicalLeft() + logicalWidth()); |
| 132 return logicalWidth() + ellipsisWidth; | 132 return logicalWidth() + ellipsisWidth; |
| 133 } | 133 } |
| 134 | 134 |
| 135 // Now attempt to find the nearest glyph horizontally and place just to the
right (or left in RTL) | 135 // Now attempt to find the nearest glyph horizontally and place just to the
right (or left in RTL) |
| 136 // of that glyph. Mark all of the objects that intersect the ellipsis box a
s not painting (as being | 136 // of that glyph. Mark all of the objects that intersect the ellipsis box a
s not painting (as being |
| 137 // truncated). | 137 // truncated). |
| 138 bool foundBox = false; | 138 bool foundBox = false; |
| 139 float truncatedWidth = 0; | 139 FloatWillBeLayoutUnit truncatedWidth = ZERO_LAYOUT_UNIT; |
| 140 float position = placeEllipsisBox(ltr, blockLeftEdge, blockRightEdge, ellips
isWidth, truncatedWidth, foundBox); | 140 FloatWillBeLayoutUnit position = placeEllipsisBox(ltr, blockLeftEdge, blockR
ightEdge, ellipsisWidth, truncatedWidth, foundBox); |
| 141 ellipsisBox->setLogicalLeft(position); | 141 ellipsisBox->setLogicalLeft(position); |
| 142 return truncatedWidth; | 142 return truncatedWidth; |
| 143 } | 143 } |
| 144 | 144 |
| 145 float RootInlineBox::placeEllipsisBox(bool ltr, float blockLeftEdge, float block
RightEdge, float ellipsisWidth, float &truncatedWidth, bool& foundBox) | 145 FloatWillBeLayoutUnit RootInlineBox::placeEllipsisBox(bool ltr, FloatWillBeLayou
tUnit blockLeftEdge, FloatWillBeLayoutUnit blockRightEdge, FloatWillBeLayoutUnit
ellipsisWidth, FloatWillBeLayoutUnit &truncatedWidth, bool& foundBox) |
| 146 { | 146 { |
| 147 float result = InlineFlowBox::placeEllipsisBox(ltr, blockLeftEdge, blockRigh
tEdge, ellipsisWidth, truncatedWidth, foundBox); | 147 FloatWillBeLayoutUnit result = InlineFlowBox::placeEllipsisBox(ltr, blockLef
tEdge, blockRightEdge, ellipsisWidth, truncatedWidth, foundBox); |
| 148 if (result == -1) { | 148 if (result == -1) { |
| 149 result = ltr ? blockRightEdge - ellipsisWidth : blockLeftEdge; | 149 result = ltr ? blockRightEdge - ellipsisWidth : blockLeftEdge; |
| 150 truncatedWidth = blockRightEdge - blockLeftEdge; | 150 truncatedWidth = blockRightEdge - blockLeftEdge; |
| 151 } | 151 } |
| 152 return result; | 152 return result; |
| 153 } | 153 } |
| 154 | 154 |
| 155 void RootInlineBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
LayoutUnit lineTop, LayoutUnit lineBottom) | 155 void RootInlineBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
LayoutUnit lineTop, LayoutUnit lineBottom) |
| 156 { | 156 { |
| 157 RootInlineBoxPainter(*this).paint(paintInfo, paintOffset, lineTop, lineBotto
m); | 157 RootInlineBoxPainter(*this).paint(paintInfo, paintOffset, lineTop, lineBotto
m); |
| 158 } | 158 } |
| 159 | 159 |
| 160 bool RootInlineBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
sult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulated
Offset, LayoutUnit lineTop, LayoutUnit lineBottom) | 160 bool RootInlineBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
sult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulated
Offset, LayoutUnit lineTop, LayoutUnit lineBottom) |
| 161 { | 161 { |
| 162 if (hasEllipsisBox() && visibleToHitTestRequest(request)) { | 162 if (hasEllipsisBox() && visibleToHitTestRequest(request)) { |
| 163 if (ellipsisBox()->nodeAtPoint(request, result, locationInContainer, acc
umulatedOffset, lineTop, lineBottom)) { | 163 if (ellipsisBox()->nodeAtPoint(request, result, locationInContainer, acc
umulatedOffset, lineTop, lineBottom)) { |
| 164 renderer().updateHitTestResult(result, locationInContainer.point() -
toLayoutSize(accumulatedOffset)); | 164 renderer().updateHitTestResult(result, locationInContainer.point() -
toLayoutSize(accumulatedOffset)); |
| 165 return true; | 165 return true; |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 return InlineFlowBox::nodeAtPoint(request, result, locationInContainer, accu
mulatedOffset, lineTop, lineBottom); | 168 return InlineFlowBox::nodeAtPoint(request, result, locationInContainer, accu
mulatedOffset, lineTop, lineBottom); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void RootInlineBox::adjustPosition(float dx, float dy) | 171 void RootInlineBox::adjustPosition(FloatWillBeLayoutUnit dx, FloatWillBeLayoutUn
it dy) |
| 172 { | 172 { |
| 173 InlineFlowBox::adjustPosition(dx, dy); | 173 InlineFlowBox::adjustPosition(dx, dy); |
| 174 LayoutUnit blockDirectionDelta = isHorizontal() ? dy : dx; // The block dire
ction delta is a LayoutUnit. | 174 LayoutUnit blockDirectionDelta = isHorizontal() ? dy : dx; // The block dire
ction delta is a LayoutUnit. |
| 175 m_lineTop += blockDirectionDelta; | 175 m_lineTop += blockDirectionDelta; |
| 176 m_lineBottom += blockDirectionDelta; | 176 m_lineBottom += blockDirectionDelta; |
| 177 m_lineTopWithLeading += blockDirectionDelta; | 177 m_lineTopWithLeading += blockDirectionDelta; |
| 178 m_lineBottomWithLeading += blockDirectionDelta; | 178 m_lineBottomWithLeading += blockDirectionDelta; |
| 179 m_selectionBottom += blockDirectionDelta; | 179 m_selectionBottom += blockDirectionDelta; |
| 180 if (hasEllipsisBox()) | 180 if (hasEllipsisBox()) |
| 181 ellipsisBox()->adjustPosition(dx, dy); | 181 ellipsisBox()->adjustPosition(dx, dy); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 if (annotationsAdjustment) { | 240 if (annotationsAdjustment) { |
| 241 // FIXME: Need to handle pagination here. We might have to move to the n
ext page/column as a result of the | 241 // FIXME: Need to handle pagination here. We might have to move to the n
ext page/column as a result of the |
| 242 // ruby expansion. | 242 // ruby expansion. |
| 243 adjustBlockDirectionPosition(annotationsAdjustment.toFloat()); | 243 adjustBlockDirectionPosition(annotationsAdjustment.toFloat()); |
| 244 heightOfBlock += annotationsAdjustment; | 244 heightOfBlock += annotationsAdjustment; |
| 245 } | 245 } |
| 246 | 246 |
| 247 return heightOfBlock + maxHeight; | 247 return heightOfBlock + maxHeight; |
| 248 } | 248 } |
| 249 | 249 |
| 250 float RootInlineBox::maxLogicalTop() const | 250 FloatWillBeLayoutUnit RootInlineBox::maxLogicalTop() const |
| 251 { | 251 { |
| 252 float maxLogicalTop = 0; | 252 FloatWillBeLayoutUnit maxLogicalTop = ZERO_LAYOUT_UNIT; |
| 253 computeMaxLogicalTop(maxLogicalTop); | 253 computeMaxLogicalTop(maxLogicalTop); |
| 254 return maxLogicalTop; | 254 return maxLogicalTop; |
| 255 } | 255 } |
| 256 | 256 |
| 257 LayoutUnit RootInlineBox::beforeAnnotationsAdjustment() const | 257 LayoutUnit RootInlineBox::beforeAnnotationsAdjustment() const |
| 258 { | 258 { |
| 259 LayoutUnit result = 0; | 259 LayoutUnit result = 0; |
| 260 | 260 |
| 261 if (!renderer().style()->isFlippedLinesWritingMode()) { | 261 if (!renderer().style()->isFlippedLinesWritingMode()) { |
| 262 // Annotations under the previous line may push us down. | 262 // Annotations under the previous line may push us down. |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 } | 858 } |
| 859 | 859 |
| 860 #ifndef NDEBUG | 860 #ifndef NDEBUG |
| 861 const char* RootInlineBox::boxName() const | 861 const char* RootInlineBox::boxName() const |
| 862 { | 862 { |
| 863 return "RootInlineBox"; | 863 return "RootInlineBox"; |
| 864 } | 864 } |
| 865 #endif | 865 #endif |
| 866 | 866 |
| 867 } // namespace blink | 867 } // namespace blink |
| OLD | NEW |