| 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 12 matching lines...) Expand all Loading... |
| 23 #include "core/layout/line/InlineTextBox.h" | 23 #include "core/layout/line/InlineTextBox.h" |
| 24 | 24 |
| 25 #include "core/layout/HitTestResult.h" | 25 #include "core/layout/HitTestResult.h" |
| 26 #include "core/layout/LayoutBR.h" | 26 #include "core/layout/LayoutBR.h" |
| 27 #include "core/layout/LayoutRubyText.h" | 27 #include "core/layout/LayoutRubyText.h" |
| 28 #include "core/layout/api/LineLayoutBox.h" | 28 #include "core/layout/api/LineLayoutBox.h" |
| 29 #include "core/layout/api/LineLayoutRubyRun.h" | 29 #include "core/layout/api/LineLayoutRubyRun.h" |
| 30 #include "core/layout/line/AbstractInlineTextBox.h" | 30 #include "core/layout/line/AbstractInlineTextBox.h" |
| 31 #include "core/layout/line/EllipsisBox.h" | 31 #include "core/layout/line/EllipsisBox.h" |
| 32 #include "core/paint/InlineTextBoxPainter.h" | 32 #include "core/paint/InlineTextBoxPainter.h" |
| 33 #include "platform/fonts/CharacterRange.h" | |
| 34 #include "platform/fonts/FontCache.h" | 33 #include "platform/fonts/FontCache.h" |
| 35 #include "platform/fonts/shaping/SimpleShaper.h" | 34 #include "platform/fonts/shaping/SimpleShaper.h" |
| 36 #include "wtf/Vector.h" | 35 #include "wtf/Vector.h" |
| 37 #include "wtf/text/StringBuilder.h" | 36 #include "wtf/text/StringBuilder.h" |
| 38 | 37 |
| 39 #include <algorithm> | 38 #include <algorithm> |
| 40 | 39 |
| 41 namespace blink { | 40 namespace blink { |
| 42 | 41 |
| 43 struct SameSizeAsInlineTextBox : public InlineBox { | 42 struct SameSizeAsInlineTextBox : public InlineBox { |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 { | 537 { |
| 539 if (!m_len) | 538 if (!m_len) |
| 540 return; | 539 return; |
| 541 | 540 |
| 542 FontCachePurgePreventer fontCachePurgePreventer; | 541 FontCachePurgePreventer fontCachePurgePreventer; |
| 543 ASSERT(getLineLayoutItem().text()); | 542 ASSERT(getLineLayoutItem().text()); |
| 544 | 543 |
| 545 const ComputedStyle& styleToUse = getLineLayoutItem().styleRef(isFirstLineSt
yle()); | 544 const ComputedStyle& styleToUse = getLineLayoutItem().styleRef(isFirstLineSt
yle()); |
| 546 const Font& font = styleToUse.font(); | 545 const Font& font = styleToUse.font(); |
| 547 | 546 |
| 548 TextRun textRun = constructTextRun(styleToUse, font); | 547 float lastWidth = 0; |
| 549 Vector<CharacterRange> ranges = font.individualCharacterRanges(textRun); | 548 widths.resize(m_len); |
| 550 DCHECK_EQ(ranges.size(), m_len); | 549 for (unsigned i = 0; i < m_len; i++) { |
| 551 | 550 StringView substringView = getLineLayoutItem().text().createView(); |
| 552 widths.resize(ranges.size()); | 551 substringView.narrow(start(), 1 + i); |
| 553 for (unsigned i = 0; i < ranges.size(); i++) | 552 TextRun textRun = constructTextRun(styleToUse, font, substringView, m_le
n); |
| 554 widths[i] = ranges[i].width(); | 553 widths[i] = font.width(textRun, nullptr, nullptr) - lastWidth; |
| 554 lastWidth = font.width(textRun, nullptr, nullptr); |
| 555 } |
| 555 } | 556 } |
| 556 | 557 |
| 557 TextRun InlineTextBox::constructTextRun(const ComputedStyle& style, const Font&
font, StringBuilder* charactersWithHyphen) const | 558 TextRun InlineTextBox::constructTextRun(const ComputedStyle& style, const Font&
font, StringBuilder* charactersWithHyphen) const |
| 558 { | 559 { |
| 559 ASSERT(getLineLayoutItem().text()); | 560 ASSERT(getLineLayoutItem().text()); |
| 560 | 561 |
| 561 StringView string = getLineLayoutItem().text().createView(); | 562 StringView string = getLineLayoutItem().text().createView(); |
| 562 unsigned startPos = start(); | 563 unsigned startPos = start(); |
| 563 unsigned length = len(); | 564 unsigned length = len(); |
| 564 | 565 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 printedCharacters = fprintf(stderr, "\t%s %p", obj.name(), obj.debugPointer(
)); | 626 printedCharacters = fprintf(stderr, "\t%s %p", obj.name(), obj.debugPointer(
)); |
| 626 const int layoutObjectCharacterOffset = 75; | 627 const int layoutObjectCharacterOffset = 75; |
| 627 for (; printedCharacters < layoutObjectCharacterOffset; printedCharacters++) | 628 for (; printedCharacters < layoutObjectCharacterOffset; printedCharacters++) |
| 628 fputc(' ', stderr); | 629 fputc(' ', stderr); |
| 629 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d
ata()); | 630 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d
ata()); |
| 630 } | 631 } |
| 631 | 632 |
| 632 #endif | 633 #endif |
| 633 | 634 |
| 634 } // namespace blink | 635 } // namespace blink |
| OLD | NEW |