| 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 FloatWillBeLayoutUnit RootInlineBox::placeEllipsis(const AtomicString& ellipsisS
tr, bool ltr, FloatWillBeLayoutUnit blockLeftEdge, FloatWillBeLayoutUnit blockR
ightEdge, FloatWillBeLayoutUnit ellipsisWidth) | 116 LayoutUnit RootInlineBox::placeEllipsis(const AtomicString& ellipsisStr, bool l
tr, LayoutUnit blockLeftEdge, LayoutUnit blockRightEdge, LayoutUnit ellipsisWidt
h) |
| 117 { | 117 { |
| 118 // Create an ellipsis box. | 118 // Create an ellipsis box. |
| 119 EllipsisBox* ellipsisBox = new EllipsisBox(layoutObject(), ellipsisStr, this
, | 119 EllipsisBox* ellipsisBox = new EllipsisBox(layoutObject(), ellipsisStr, this
, |
| 120 ellipsisWidth, logicalHeight().toFloat(), x(), y(), !prevRootBox(), isHo
rizontal()); | 120 ellipsisWidth, logicalHeight().toFloat(), x(), y(), !prevRootBox(), isHo
rizontal()); |
| 121 | 121 |
| 122 if (!gEllipsisBoxMap) | 122 if (!gEllipsisBoxMap) |
| 123 gEllipsisBoxMap = new EllipsisBoxMap(); | 123 gEllipsisBoxMap = new EllipsisBoxMap(); |
| 124 gEllipsisBoxMap->add(this, ellipsisBox); | 124 gEllipsisBoxMap->add(this, ellipsisBox); |
| 125 setHasEllipsisBox(true); | 125 setHasEllipsisBox(true); |
| 126 | 126 |
| 127 // FIXME: Do we need an RTL version of this? | 127 // FIXME: Do we need an RTL version of this? |
| 128 if (ltr && (logicalLeft() + logicalWidth() + ellipsisWidth) <= blockRightEdg
e) { | 128 if (ltr && (logicalLeft() + logicalWidth() + ellipsisWidth) <= blockRightEdg
e) { |
| 129 ellipsisBox->setLogicalLeft(logicalLeft() + logicalWidth()); | 129 ellipsisBox->setLogicalLeft(logicalLeft() + logicalWidth()); |
| 130 return logicalWidth() + ellipsisWidth; | 130 return logicalWidth() + ellipsisWidth; |
| 131 } | 131 } |
| 132 | 132 |
| 133 // Now attempt to find the nearest glyph horizontally and place just to the
right (or left in RTL) | 133 // Now attempt to find the nearest glyph horizontally and place just to the
right (or left in RTL) |
| 134 // of that glyph. Mark all of the objects that intersect the ellipsis box a
s not painting (as being | 134 // of that glyph. Mark all of the objects that intersect the ellipsis box a
s not painting (as being |
| 135 // truncated). | 135 // truncated). |
| 136 bool foundBox = false; | 136 bool foundBox = false; |
| 137 FloatWillBeLayoutUnit truncatedWidth = 0; | 137 LayoutUnit truncatedWidth = 0; |
| 138 FloatWillBeLayoutUnit position = placeEllipsisBox(ltr, blockLeftEdge, blockR
ightEdge, ellipsisWidth, truncatedWidth, foundBox); | 138 LayoutUnit position = placeEllipsisBox(ltr, blockLeftEdge, blockRightEdge, e
llipsisWidth, truncatedWidth, foundBox); |
| 139 ellipsisBox->setLogicalLeft(position); | 139 ellipsisBox->setLogicalLeft(position); |
| 140 return truncatedWidth; | 140 return truncatedWidth; |
| 141 } | 141 } |
| 142 | 142 |
| 143 FloatWillBeLayoutUnit RootInlineBox::placeEllipsisBox(bool ltr, FloatWillBeLayou
tUnit blockLeftEdge, FloatWillBeLayoutUnit blockRightEdge, FloatWillBeLayoutUnit
ellipsisWidth, FloatWillBeLayoutUnit &truncatedWidth, bool& foundBox) | 143 LayoutUnit RootInlineBox::placeEllipsisBox(bool ltr, LayoutUnit blockLeftEdge, L
ayoutUnit blockRightEdge, LayoutUnit ellipsisWidth, LayoutUnit &truncatedWidth,
bool& foundBox) |
| 144 { | 144 { |
| 145 FloatWillBeLayoutUnit result = InlineFlowBox::placeEllipsisBox(ltr, blockLef
tEdge, blockRightEdge, ellipsisWidth, truncatedWidth, foundBox); | 145 LayoutUnit result = InlineFlowBox::placeEllipsisBox(ltr, blockLeftEdge, bloc
kRightEdge, ellipsisWidth, truncatedWidth, foundBox); |
| 146 if (result == -1) { | 146 if (result == -1) { |
| 147 result = ltr ? blockRightEdge - ellipsisWidth : blockLeftEdge; | 147 result = ltr ? blockRightEdge - ellipsisWidth : blockLeftEdge; |
| 148 truncatedWidth = blockRightEdge - blockLeftEdge; | 148 truncatedWidth = blockRightEdge - blockLeftEdge; |
| 149 } | 149 } |
| 150 return result; | 150 return result; |
| 151 } | 151 } |
| 152 | 152 |
| 153 void RootInlineBox::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOf
fset, LayoutUnit lineTop, LayoutUnit lineBottom) | 153 void RootInlineBox::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOf
fset, LayoutUnit lineTop, LayoutUnit lineBottom) |
| 154 { | 154 { |
| 155 RootInlineBoxPainter(*this).paint(paintInfo, paintOffset, lineTop, lineBotto
m); | 155 RootInlineBoxPainter(*this).paint(paintInfo, paintOffset, lineTop, lineBotto
m); |
| 156 } | 156 } |
| 157 | 157 |
| 158 bool RootInlineBox::nodeAtPoint(HitTestResult& result, const HitTestLocation& lo
cationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, Lay
outUnit lineBottom) | 158 bool RootInlineBox::nodeAtPoint(HitTestResult& result, const HitTestLocation& lo
cationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, Lay
outUnit lineBottom) |
| 159 { | 159 { |
| 160 if (hasEllipsisBox() && visibleToHitTestRequest(result.hitTestRequest())) { | 160 if (hasEllipsisBox() && visibleToHitTestRequest(result.hitTestRequest())) { |
| 161 if (ellipsisBox()->nodeAtPoint(result, locationInContainer, accumulatedO
ffset, lineTop, lineBottom)) { | 161 if (ellipsisBox()->nodeAtPoint(result, locationInContainer, accumulatedO
ffset, lineTop, lineBottom)) { |
| 162 layoutObject().updateHitTestResult(result, locationInContainer.point
() - toLayoutSize(accumulatedOffset)); | 162 layoutObject().updateHitTestResult(result, locationInContainer.point
() - toLayoutSize(accumulatedOffset)); |
| 163 return true; | 163 return true; |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 return InlineFlowBox::nodeAtPoint(result, locationInContainer, accumulatedOf
fset, lineTop, lineBottom); | 166 return InlineFlowBox::nodeAtPoint(result, locationInContainer, accumulatedOf
fset, lineTop, lineBottom); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void RootInlineBox::adjustPosition(FloatWillBeLayoutUnit dx, FloatWillBeLayoutUn
it dy) | 169 void RootInlineBox::adjustPosition(LayoutUnit dx, LayoutUnit dy) |
| 170 { | 170 { |
| 171 InlineFlowBox::adjustPosition(dx, dy); | 171 InlineFlowBox::adjustPosition(dx, dy); |
| 172 LayoutUnit blockDirectionDelta = isHorizontal() ? dy : dx; // The block dire
ction delta is a LayoutUnit. | 172 LayoutUnit blockDirectionDelta = isHorizontal() ? dy : dx; // The block dire
ction delta is a LayoutUnit. |
| 173 m_lineTop += blockDirectionDelta; | 173 m_lineTop += blockDirectionDelta; |
| 174 m_lineBottom += blockDirectionDelta; | 174 m_lineBottom += blockDirectionDelta; |
| 175 m_lineTopWithLeading += blockDirectionDelta; | 175 m_lineTopWithLeading += blockDirectionDelta; |
| 176 m_lineBottomWithLeading += blockDirectionDelta; | 176 m_lineBottomWithLeading += blockDirectionDelta; |
| 177 m_selectionBottom += blockDirectionDelta; | 177 m_selectionBottom += blockDirectionDelta; |
| 178 if (hasEllipsisBox()) | 178 if (hasEllipsisBox()) |
| 179 ellipsisBox()->adjustPosition(dx, dy); | 179 ellipsisBox()->adjustPosition(dx, dy); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 if (annotationsAdjustment) { | 234 if (annotationsAdjustment) { |
| 235 // FIXME: Need to handle pagination here. We might have to move to the n
ext page/column as a result of the | 235 // FIXME: Need to handle pagination here. We might have to move to the n
ext page/column as a result of the |
| 236 // ruby expansion. | 236 // ruby expansion. |
| 237 adjustBlockDirectionPosition(annotationsAdjustment.toFloat()); | 237 adjustBlockDirectionPosition(annotationsAdjustment.toFloat()); |
| 238 heightOfBlock += annotationsAdjustment; | 238 heightOfBlock += annotationsAdjustment; |
| 239 } | 239 } |
| 240 | 240 |
| 241 return heightOfBlock + maxHeight; | 241 return heightOfBlock + maxHeight; |
| 242 } | 242 } |
| 243 | 243 |
| 244 FloatWillBeLayoutUnit RootInlineBox::maxLogicalTop() const | 244 LayoutUnit RootInlineBox::maxLogicalTop() const |
| 245 { | 245 { |
| 246 FloatWillBeLayoutUnit maxLogicalTop; | 246 LayoutUnit maxLogicalTop; |
| 247 computeMaxLogicalTop(maxLogicalTop); | 247 computeMaxLogicalTop(maxLogicalTop); |
| 248 return maxLogicalTop; | 248 return maxLogicalTop; |
| 249 } | 249 } |
| 250 | 250 |
| 251 LayoutUnit RootInlineBox::beforeAnnotationsAdjustment() const | 251 LayoutUnit RootInlineBox::beforeAnnotationsAdjustment() const |
| 252 { | 252 { |
| 253 LayoutUnit result = 0; | 253 LayoutUnit result = 0; |
| 254 | 254 |
| 255 if (!layoutObject().style()->isFlippedLinesWritingMode()) { | 255 if (!layoutObject().style()->isFlippedLinesWritingMode()) { |
| 256 // Annotations under the previous line may push us down. | 256 // Annotations under the previous line may push us down. |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 endBox = 0; | 847 endBox = 0; |
| 848 return 0; | 848 return 0; |
| 849 } | 849 } |
| 850 | 850 |
| 851 const char* RootInlineBox::boxName() const | 851 const char* RootInlineBox::boxName() const |
| 852 { | 852 { |
| 853 return "RootInlineBox"; | 853 return "RootInlineBox"; |
| 854 } | 854 } |
| 855 | 855 |
| 856 } // namespace blink | 856 } // namespace blink |
| OLD | NEW |