| 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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 int InlineTextBox::offsetForPosition(FloatWillBeLayoutUnit lineOffset, bool incl
udePartialGlyphs) const | 407 int InlineTextBox::offsetForPosition(FloatWillBeLayoutUnit lineOffset, bool incl
udePartialGlyphs) const |
| 408 { | 408 { |
| 409 if (isLineBreak()) | 409 if (isLineBreak()) |
| 410 return 0; | 410 return 0; |
| 411 | 411 |
| 412 if (lineOffset - logicalLeft() > logicalWidth()) | 412 if (lineOffset - logicalLeft() > logicalWidth()) |
| 413 return isLeftToRightDirection() ? len() : 0; | 413 return isLeftToRightDirection() ? len() : 0; |
| 414 if (lineOffset - logicalLeft() < 0) | 414 if (lineOffset - logicalLeft() < 0) |
| 415 return isLeftToRightDirection() ? 0 : len(); | 415 return isLeftToRightDirection() ? 0 : len(); |
| 416 | 416 |
| 417 RenderText& text = renderer(); | 417 LayoutText& text = renderer(); |
| 418 const LayoutStyle& style = text.styleRef(isFirstLineStyle()); | 418 const LayoutStyle& style = text.styleRef(isFirstLineStyle()); |
| 419 const Font& font = style.font(); | 419 const Font& font = style.font(); |
| 420 return font.offsetForPosition(constructTextRun(style, font), lineOffset - lo
gicalLeft(), includePartialGlyphs); | 420 return font.offsetForPosition(constructTextRun(style, font), lineOffset - lo
gicalLeft(), includePartialGlyphs); |
| 421 } | 421 } |
| 422 | 422 |
| 423 FloatWillBeLayoutUnit InlineTextBox::positionForOffset(int offset) const | 423 FloatWillBeLayoutUnit InlineTextBox::positionForOffset(int offset) const |
| 424 { | 424 { |
| 425 ASSERT(offset >= m_start); | 425 ASSERT(offset >= m_start); |
| 426 ASSERT(offset <= m_start + m_len); | 426 ASSERT(offset <= m_start + m_len); |
| 427 | 427 |
| 428 if (isLineBreak()) | 428 if (isLineBreak()) |
| 429 return logicalLeft(); | 429 return logicalLeft(); |
| 430 | 430 |
| 431 RenderText& text = renderer(); | 431 LayoutText& text = renderer(); |
| 432 const LayoutStyle& styleToUse = text.styleRef(isFirstLineStyle()); | 432 const LayoutStyle& styleToUse = text.styleRef(isFirstLineStyle()); |
| 433 const Font& font = styleToUse.font(); | 433 const Font& font = styleToUse.font(); |
| 434 int from = !isLeftToRightDirection() ? offset - m_start : 0; | 434 int from = !isLeftToRightDirection() ? offset - m_start : 0; |
| 435 int to = !isLeftToRightDirection() ? m_len : offset - m_start; | 435 int to = !isLeftToRightDirection() ? m_len : offset - m_start; |
| 436 // FIXME: Do we need to add rightBearing here? | 436 // FIXME: Do we need to add rightBearing here? |
| 437 return font.selectionRectForText(constructTextRun(styleToUse, font), IntPoin
t(logicalLeft(), 0), 0, from, to).maxX(); | 437 return font.selectionRectForText(constructTextRun(styleToUse, font), IntPoin
t(logicalLeft(), 0), 0, from, to).maxX(); |
| 438 } | 438 } |
| 439 | 439 |
| 440 bool InlineTextBox::containsCaretOffset(int offset) const | 440 bool InlineTextBox::containsCaretOffset(int offset) const |
| 441 { | 441 { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 | 525 |
| 526 #ifndef NDEBUG | 526 #ifndef NDEBUG |
| 527 | 527 |
| 528 const char* InlineTextBox::boxName() const | 528 const char* InlineTextBox::boxName() const |
| 529 { | 529 { |
| 530 return "InlineTextBox"; | 530 return "InlineTextBox"; |
| 531 } | 531 } |
| 532 | 532 |
| 533 void InlineTextBox::showBox(int printedCharacters) const | 533 void InlineTextBox::showBox(int printedCharacters) const |
| 534 { | 534 { |
| 535 const RenderText& obj = renderer(); | 535 const LayoutText& obj = renderer(); |
| 536 String value = obj.text(); | 536 String value = obj.text(); |
| 537 value = value.substring(start(), len()); | 537 value = value.substring(start(), len()); |
| 538 value.replaceWithLiteral('\\', "\\\\"); | 538 value.replaceWithLiteral('\\', "\\\\"); |
| 539 value.replaceWithLiteral('\n', "\\n"); | 539 value.replaceWithLiteral('\n', "\\n"); |
| 540 printedCharacters += fprintf(stderr, "%s %p", boxName(), this); | 540 printedCharacters += fprintf(stderr, "%s %p", boxName(), this); |
| 541 for (; printedCharacters < showTreeCharacterOffset; printedCharacters++) | 541 for (; printedCharacters < showTreeCharacterOffset; printedCharacters++) |
| 542 fputc(' ', stderr); | 542 fputc(' ', stderr); |
| 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 |