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