| 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, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 bool InlineTextBox::isSelected(int startPos, int endPos) const | 122 bool InlineTextBox::isSelected(int startPos, int endPos) const |
| 123 { | 123 { |
| 124 int sPos = std::max(startPos - m_start, 0); | 124 int sPos = std::max(startPos - m_start, 0); |
| 125 // The position after a hard line break is considered to be past its end. | 125 // The position after a hard line break is considered to be past its end. |
| 126 // See the corresponding code in InlineTextBox::selectionState. | 126 // See the corresponding code in InlineTextBox::selectionState. |
| 127 int ePos = std::min(endPos - m_start, int(m_len) + (isLineBreak() ? 0 : 1)); | 127 int ePos = std::min(endPos - m_start, int(m_len) + (isLineBreak() ? 0 : 1)); |
| 128 return (sPos < ePos); | 128 return (sPos < ePos); |
| 129 } | 129 } |
| 130 | 130 |
| 131 RenderObject::SelectionState InlineTextBox::selectionState() const | 131 LayoutObject::SelectionState InlineTextBox::selectionState() const |
| 132 { | 132 { |
| 133 RenderObject::SelectionState state = renderer().selectionState(); | 133 LayoutObject::SelectionState state = renderer().selectionState(); |
| 134 if (state == RenderObject::SelectionStart || state == RenderObject::Selectio
nEnd || state == RenderObject::SelectionBoth) { | 134 if (state == LayoutObject::SelectionStart || state == LayoutObject::Selectio
nEnd || state == LayoutObject::SelectionBoth) { |
| 135 int startPos, endPos; | 135 int startPos, endPos; |
| 136 renderer().selectionStartEnd(startPos, endPos); | 136 renderer().selectionStartEnd(startPos, endPos); |
| 137 // The position after a hard line break is considered to be past its end
. | 137 // The position after a hard line break is considered to be past its end
. |
| 138 // See the corresponding code in InlineTextBox::isSelected. | 138 // See the corresponding code in InlineTextBox::isSelected. |
| 139 int lastSelectable = start() + len() - (isLineBreak() ? 1 : 0); | 139 int lastSelectable = start() + len() - (isLineBreak() ? 1 : 0); |
| 140 | 140 |
| 141 // FIXME: Remove -webkit-line-break: LineBreakAfterWhiteSpace. | 141 // FIXME: Remove -webkit-line-break: LineBreakAfterWhiteSpace. |
| 142 int endOfLineAdjustmentForCSSLineBreak = renderer().style()->lineBreak()
== LineBreakAfterWhiteSpace ? -1 : 0; | 142 int endOfLineAdjustmentForCSSLineBreak = renderer().style()->lineBreak()
== LineBreakAfterWhiteSpace ? -1 : 0; |
| 143 bool start = (state != RenderObject::SelectionEnd && startPos >= m_start
&& startPos <= m_start + m_len + endOfLineAdjustmentForCSSLineBreak); | 143 bool start = (state != LayoutObject::SelectionEnd && startPos >= m_start
&& startPos <= m_start + m_len + endOfLineAdjustmentForCSSLineBreak); |
| 144 bool end = (state != RenderObject::SelectionStart && endPos > m_start &&
endPos <= lastSelectable); | 144 bool end = (state != LayoutObject::SelectionStart && endPos > m_start &&
endPos <= lastSelectable); |
| 145 if (start && end) | 145 if (start && end) |
| 146 state = RenderObject::SelectionBoth; | 146 state = LayoutObject::SelectionBoth; |
| 147 else if (start) | 147 else if (start) |
| 148 state = RenderObject::SelectionStart; | 148 state = LayoutObject::SelectionStart; |
| 149 else if (end) | 149 else if (end) |
| 150 state = RenderObject::SelectionEnd; | 150 state = LayoutObject::SelectionEnd; |
| 151 else if ((state == RenderObject::SelectionEnd || startPos < m_start) | 151 else if ((state == LayoutObject::SelectionEnd || startPos < m_start) |
| 152 && (state == RenderObject::SelectionStart || endPos > lastSelectable
)) | 152 && (state == LayoutObject::SelectionStart || endPos > lastSelectable
)) |
| 153 state = RenderObject::SelectionInside; | 153 state = LayoutObject::SelectionInside; |
| 154 else if (state == RenderObject::SelectionBoth) | 154 else if (state == LayoutObject::SelectionBoth) |
| 155 state = RenderObject::SelectionNone; | 155 state = LayoutObject::SelectionNone; |
| 156 } | 156 } |
| 157 | 157 |
| 158 // If there are ellipsis following, make sure their selection is updated. | 158 // If there are ellipsis following, make sure their selection is updated. |
| 159 if (m_truncation != cNoTruncation && root().ellipsisBox()) { | 159 if (m_truncation != cNoTruncation && root().ellipsisBox()) { |
| 160 EllipsisBox* ellipsis = root().ellipsisBox(); | 160 EllipsisBox* ellipsis = root().ellipsisBox(); |
| 161 if (state != RenderObject::SelectionNone) { | 161 if (state != LayoutObject::SelectionNone) { |
| 162 int start, end; | 162 int start, end; |
| 163 selectionStartEnd(start, end); | 163 selectionStartEnd(start, end); |
| 164 // The ellipsis should be considered to be selected if the end of | 164 // The ellipsis should be considered to be selected if the end of |
| 165 // the selection is past the beginning of the truncation and the | 165 // the selection is past the beginning of the truncation and the |
| 166 // beginning of the selection is before or at the beginning of the | 166 // beginning of the selection is before or at the beginning of the |
| 167 // truncation. | 167 // truncation. |
| 168 ellipsis->setSelectionState(end >= m_truncation && start <= m_trunca
tion ? | 168 ellipsis->setSelectionState(end >= m_truncation && start <= m_trunca
tion ? |
| 169 RenderObject::SelectionInside : RenderObject::SelectionNone); | 169 LayoutObject::SelectionInside : LayoutObject::SelectionNone); |
| 170 } else { | 170 } else { |
| 171 ellipsis->setSelectionState(RenderObject::SelectionNone); | 171 ellipsis->setSelectionState(LayoutObject::SelectionNone); |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 | 174 |
| 175 return state; | 175 return state; |
| 176 } | 176 } |
| 177 | 177 |
| 178 LayoutRect InlineTextBox::localSelectionRect(int startPos, int endPos) | 178 LayoutRect InlineTextBox::localSelectionRect(int startPos, int endPos) |
| 179 { | 179 { |
| 180 int sPos = std::max(startPos - m_start, 0); | 180 int sPos = std::max(startPos - m_start, 0); |
| 181 int ePos = std::min(endPos - m_start, (int)m_len); | 181 int ePos = std::min(endPos - m_start, (int)m_len); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 } | 353 } |
| 354 | 354 |
| 355 void InlineTextBox::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOf
fset, LayoutUnit /*lineTop*/, LayoutUnit /*lineBottom*/) | 355 void InlineTextBox::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOf
fset, LayoutUnit /*lineTop*/, LayoutUnit /*lineBottom*/) |
| 356 { | 356 { |
| 357 InlineTextBoxPainter(*this).paint(paintInfo, paintOffset); | 357 InlineTextBoxPainter(*this).paint(paintInfo, paintOffset); |
| 358 } | 358 } |
| 359 | 359 |
| 360 void InlineTextBox::selectionStartEnd(int& sPos, int& ePos) const | 360 void InlineTextBox::selectionStartEnd(int& sPos, int& ePos) const |
| 361 { | 361 { |
| 362 int startPos, endPos; | 362 int startPos, endPos; |
| 363 if (renderer().selectionState() == RenderObject::SelectionInside) { | 363 if (renderer().selectionState() == LayoutObject::SelectionInside) { |
| 364 startPos = 0; | 364 startPos = 0; |
| 365 endPos = renderer().textLength(); | 365 endPos = renderer().textLength(); |
| 366 } else { | 366 } else { |
| 367 renderer().selectionStartEnd(startPos, endPos); | 367 renderer().selectionStartEnd(startPos, endPos); |
| 368 if (renderer().selectionState() == RenderObject::SelectionStart) | 368 if (renderer().selectionState() == LayoutObject::SelectionStart) |
| 369 endPos = renderer().textLength(); | 369 endPos = renderer().textLength(); |
| 370 else if (renderer().selectionState() == RenderObject::SelectionEnd) | 370 else if (renderer().selectionState() == LayoutObject::SelectionEnd) |
| 371 startPos = 0; | 371 startPos = 0; |
| 372 } | 372 } |
| 373 | 373 |
| 374 sPos = std::max(startPos - m_start, 0); | 374 sPos = std::max(startPos - m_start, 0); |
| 375 ePos = std::min(endPos - m_start, (int)m_len); | 375 ePos = std::min(endPos - m_start, (int)m_len); |
| 376 } | 376 } |
| 377 | 377 |
| 378 void InlineTextBox::paintDocumentMarker(GraphicsContext* pt, const FloatPointWil
lBeLayoutPoint& boxOrigin, DocumentMarker* marker, const RenderStyle& style, con
st Font& font, bool grammar) | 378 void InlineTextBox::paintDocumentMarker(GraphicsContext* pt, const FloatPointWil
lBeLayoutPoint& boxOrigin, DocumentMarker* marker, const RenderStyle& style, con
st Font& font, bool grammar) |
| 379 { | 379 { |
| 380 InlineTextBoxPainter(*this).paintDocumentMarker(pt, boxOrigin.toFloatPoint()
, marker, style, font, grammar); | 380 InlineTextBoxPainter(*this).paintDocumentMarker(pt, boxOrigin.toFloatPoint()
, marker, style, font, grammar); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 printedCharacters = fprintf(stderr, "\t%s %p", obj.renderName(), &obj); | 543 printedCharacters = fprintf(stderr, "\t%s %p", obj.renderName(), &obj); |
| 544 const int rendererCharacterOffset = 75; | 544 const int rendererCharacterOffset = 75; |
| 545 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) | 545 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) |
| 546 fputc(' ', stderr); | 546 fputc(' ', stderr); |
| 547 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d
ata()); | 547 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d
ata()); |
| 548 } | 548 } |
| 549 | 549 |
| 550 #endif | 550 #endif |
| 551 | 551 |
| 552 } // namespace blink | 552 } // namespace blink |
| OLD | NEW |