| 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 const ComputedStyle& styleToUse = getLineLayoutItem().styleRef(isFirstLineSt
yle()); | 229 const ComputedStyle& styleToUse = getLineLayoutItem().styleRef(isFirstLineSt
yle()); |
| 230 const Font& font = styleToUse.font(); | 230 const Font& font = styleToUse.font(); |
| 231 | 231 |
| 232 StringBuilder charactersWithHyphen; | 232 StringBuilder charactersWithHyphen; |
| 233 bool respectHyphen = ePos == m_len && hasHyphen(); | 233 bool respectHyphen = ePos == m_len && hasHyphen(); |
| 234 TextRun textRun = constructTextRun(styleToUse, respectHyphen ? &charactersWi
thHyphen : 0); | 234 TextRun textRun = constructTextRun(styleToUse, respectHyphen ? &charactersWi
thHyphen : 0); |
| 235 | 235 |
| 236 LayoutPoint startingPoint = LayoutPoint(logicalLeft(), selTop); | 236 LayoutPoint startingPoint = LayoutPoint(logicalLeft(), selTop); |
| 237 LayoutRect r; | 237 LayoutRect r; |
| 238 if (sPos || ePos != static_cast<int>(m_len)) { | 238 if (sPos || ePos != static_cast<int>(m_len)) { |
| 239 r = LayoutRect(enclosingIntRect(font.selectionRectForText(textRun, Float
Point(startingPoint), selHeight, sPos, ePos))); | 239 r = LayoutRect(enclosingIntRect(font.selectionRectForText(textRun, Float
Point(startingPoint), selHeight.toInt(), sPos, ePos))); |
| 240 } else { // Avoid computing the font width when the entire line box is selec
ted as an optimization. | 240 } else { // Avoid computing the font width when the entire line box is selec
ted as an optimization. |
| 241 r = LayoutRect(enclosingIntRect(LayoutRect(startingPoint, LayoutSize(m_l
ogicalWidth, selHeight)))); | 241 r = LayoutRect(enclosingIntRect(LayoutRect(startingPoint, LayoutSize(m_l
ogicalWidth, selHeight)))); |
| 242 } | 242 } |
| 243 | 243 |
| 244 LayoutUnit logicalWidth = r.width(); | 244 LayoutUnit logicalWidth = r.width(); |
| 245 if (r.x() > logicalRight()) | 245 if (r.x() > logicalRight()) |
| 246 logicalWidth = LayoutUnit(); | 246 logicalWidth = LayoutUnit(); |
| 247 else if (r.maxX() > logicalRight()) | 247 else if (r.maxX() > logicalRight()) |
| 248 logicalWidth = logicalRight() - r.x(); | 248 logicalWidth = logicalRight() - r.x(); |
| 249 | 249 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 bool rtlEllipsisWithinBox = !flowIsLTR && (ellipsisX > logicalLeft()); | 334 bool rtlEllipsisWithinBox = !flowIsLTR && (ellipsisX > logicalLeft()); |
| 335 if (ltrEllipsisWithinBox || rtlEllipsisWithinBox) { | 335 if (ltrEllipsisWithinBox || rtlEllipsisWithinBox) { |
| 336 foundBox = true; | 336 foundBox = true; |
| 337 | 337 |
| 338 // The inline box may have different directionality than it's parent. S
ince truncation | 338 // The inline box may have different directionality than it's parent. S
ince truncation |
| 339 // behavior depends both on both the parent and the inline block's direc
tionality, we | 339 // behavior depends both on both the parent and the inline block's direc
tionality, we |
| 340 // must keep track of these separately. | 340 // must keep track of these separately. |
| 341 bool ltr = isLeftToRightDirection(); | 341 bool ltr = isLeftToRightDirection(); |
| 342 if (ltr != flowIsLTR) { | 342 if (ltr != flowIsLTR) { |
| 343 // Width in pixels of the visible portion of the box, excluding the
ellipsis. | 343 // Width in pixels of the visible portion of the box, excluding the
ellipsis. |
| 344 int visibleBoxWidth = visibleRightEdge - visibleLeftEdge - ellipsisW
idth; | 344 int visibleBoxWidth = (visibleRightEdge - visibleLeftEdge - ellipsis
Width).toInt(); |
| 345 ellipsisX = flowIsLTR ? logicalLeft() + visibleBoxWidth : logicalRig
ht() - visibleBoxWidth; | 345 ellipsisX = flowIsLTR ? logicalLeft() + visibleBoxWidth : logicalRig
ht() - visibleBoxWidth; |
| 346 } | 346 } |
| 347 | 347 |
| 348 int offset = offsetForPosition(ellipsisX, false); | 348 int offset = offsetForPosition(ellipsisX, false); |
| 349 if (offset == 0) { | 349 if (offset == 0) { |
| 350 // No characters should be laid out. Set ourselves to full truncati
on and place the ellipsis at the min of our start | 350 // No characters should be laid out. Set ourselves to full truncati
on and place the ellipsis at the min of our start |
| 351 // and the ellipsis edge. | 351 // and the ellipsis edge. |
| 352 setTruncation(cFullTruncation); | 352 setTruncation(cFullTruncation); |
| 353 truncatedWidth += ellipsisWidth; | 353 truncatedWidth += ellipsisWidth; |
| 354 return std::min(ellipsisX, logicalLeft()); | 354 return std::min(ellipsisX, logicalLeft()); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 | 500 |
| 501 if (isLineBreak()) | 501 if (isLineBreak()) |
| 502 return logicalLeft(); | 502 return logicalLeft(); |
| 503 | 503 |
| 504 LineLayoutText text = getLineLayoutItem(); | 504 LineLayoutText text = getLineLayoutItem(); |
| 505 const ComputedStyle& styleToUse = text.styleRef(isFirstLineStyle()); | 505 const ComputedStyle& styleToUse = text.styleRef(isFirstLineStyle()); |
| 506 const Font& font = styleToUse.font(); | 506 const Font& font = styleToUse.font(); |
| 507 int from = !isLeftToRightDirection() ? offset - m_start : 0; | 507 int from = !isLeftToRightDirection() ? offset - m_start : 0; |
| 508 int to = !isLeftToRightDirection() ? m_len : offset - m_start; | 508 int to = !isLeftToRightDirection() ? m_len : offset - m_start; |
| 509 // FIXME: Do we need to add rightBearing here? | 509 // FIXME: Do we need to add rightBearing here? |
| 510 return LayoutUnit(font.selectionRectForText(constructTextRun(styleToUse), In
tPoint(logicalLeft(), 0), 0, from, to).maxX()); | 510 return LayoutUnit(font.selectionRectForText(constructTextRun(styleToUse), In
tPoint(logicalLeft().toInt(), 0), 0, from, to).maxX()); |
| 511 } | 511 } |
| 512 | 512 |
| 513 bool InlineTextBox::containsCaretOffset(int offset) const | 513 bool InlineTextBox::containsCaretOffset(int offset) const |
| 514 { | 514 { |
| 515 // Offsets before the box are never "in". | 515 // Offsets before the box are never "in". |
| 516 if (offset < m_start) | 516 if (offset < m_start) |
| 517 return false; | 517 return false; |
| 518 | 518 |
| 519 int pastEnd = m_start + m_len; | 519 int pastEnd = m_start + m_len; |
| 520 | 520 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 printedCharacters = fprintf(stderr, "\t%s %p", obj.name(), obj.debugPointer(
)); | 621 printedCharacters = fprintf(stderr, "\t%s %p", obj.name(), obj.debugPointer(
)); |
| 622 const int layoutObjectCharacterOffset = 75; | 622 const int layoutObjectCharacterOffset = 75; |
| 623 for (; printedCharacters < layoutObjectCharacterOffset; printedCharacters++) | 623 for (; printedCharacters < layoutObjectCharacterOffset; printedCharacters++) |
| 624 fputc(' ', stderr); | 624 fputc(' ', stderr); |
| 625 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d
ata()); | 625 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d
ata()); |
| 626 } | 626 } |
| 627 | 627 |
| 628 #endif | 628 #endif |
| 629 | 629 |
| 630 } // namespace blink | 630 } // namespace blink |
| OLD | NEW |