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 17 matching lines...) Expand all Loading... | |
28 #include "core/dom/RenderedDocumentMarker.h" | 28 #include "core/dom/RenderedDocumentMarker.h" |
29 #include "core/dom/Text.h" | 29 #include "core/dom/Text.h" |
30 #include "core/editing/Editor.h" | 30 #include "core/editing/Editor.h" |
31 #include "core/editing/InputMethodController.h" | 31 #include "core/editing/InputMethodController.h" |
32 #include "core/page/Frame.h" | 32 #include "core/page/Frame.h" |
33 #include "core/page/Page.h" | 33 #include "core/page/Page.h" |
34 #include "core/page/Settings.h" | 34 #include "core/page/Settings.h" |
35 #include "core/platform/graphics/DrawLooper.h" | 35 #include "core/platform/graphics/DrawLooper.h" |
36 #include "core/platform/graphics/FontCache.h" | 36 #include "core/platform/graphics/FontCache.h" |
37 #include "core/platform/graphics/GraphicsContextStateSaver.h" | 37 #include "core/platform/graphics/GraphicsContextStateSaver.h" |
38 #include "core/platform/graphics/WidthIterator.h" | |
38 #include "core/rendering/EllipsisBox.h" | 39 #include "core/rendering/EllipsisBox.h" |
39 #include "core/rendering/HitTestResult.h" | 40 #include "core/rendering/HitTestResult.h" |
40 #include "core/rendering/PaintInfo.h" | 41 #include "core/rendering/PaintInfo.h" |
41 #include "core/rendering/RenderBR.h" | 42 #include "core/rendering/RenderBR.h" |
42 #include "core/rendering/RenderBlock.h" | 43 #include "core/rendering/RenderBlock.h" |
43 #include "core/rendering/RenderCombineText.h" | 44 #include "core/rendering/RenderCombineText.h" |
44 #include "core/rendering/RenderRubyRun.h" | 45 #include "core/rendering/RenderRubyRun.h" |
45 #include "core/rendering/RenderRubyText.h" | 46 #include "core/rendering/RenderRubyText.h" |
46 #include "core/rendering/RenderTheme.h" | 47 #include "core/rendering/RenderTheme.h" |
47 #include "core/rendering/style/ShadowData.h" | 48 #include "core/rendering/style/ShadowData.h" |
(...skipping 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1478 return false; | 1479 return false; |
1479 | 1480 |
1480 // Offsets at the end are "out" for line breaks (they are on the next line). | 1481 // Offsets at the end are "out" for line breaks (they are on the next line). |
1481 if (isLineBreak()) | 1482 if (isLineBreak()) |
1482 return false; | 1483 return false; |
1483 | 1484 |
1484 // Offsets at the end are "in" for normal boxes (but the caller has to check affinity). | 1485 // Offsets at the end are "in" for normal boxes (but the caller has to check affinity). |
1485 return true; | 1486 return true; |
1486 } | 1487 } |
1487 | 1488 |
1489 void InlineTextBox::characterWidths(Vector<float>& widths) const | |
eseidel
2013/09/10 22:22:23
This function seems OK to me. I'm surprised it's
| |
1490 { | |
1491 FontCachePurgePreventer fontCachePurgePreventer; | |
1492 | |
1493 RenderText* textObj = textRenderer(); | |
1494 RenderStyle* styleToUse = textObj->style(isFirstLineStyle()); | |
1495 const Font& font = styleToUse->font(); | |
1496 | |
1497 StringBuilder charactersWithHyphen; | |
1498 TextRun textRun = constructTextRun(styleToUse, font, hasHyphen() ? &characte rsWithHyphen : 0); | |
1499 | |
1500 GlyphBuffer glyphBuffer; | |
1501 WidthIterator it(&font, textRun); | |
1502 float lastWidth = 0; | |
1503 widths.resize(m_len); | |
1504 for (unsigned i = 0; i < m_len; i++) { | |
1505 it.advance(i + 1, &glyphBuffer); | |
1506 widths[i] = it.m_runWidthSoFar - lastWidth; | |
1507 if (textRun.rtl()) | |
1508 widths[i] *= -1; | |
1509 lastWidth = it.m_runWidthSoFar; | |
1510 } | |
1511 } | |
1512 | |
1488 TextRun InlineTextBox::constructTextRun(RenderStyle* style, const Font& font, St ringBuilder* charactersWithHyphen) const | 1513 TextRun InlineTextBox::constructTextRun(RenderStyle* style, const Font& font, St ringBuilder* charactersWithHyphen) const |
1489 { | 1514 { |
1490 ASSERT(style); | 1515 ASSERT(style); |
1491 | 1516 |
1492 RenderText* textRenderer = this->textRenderer(); | 1517 RenderText* textRenderer = this->textRenderer(); |
1493 ASSERT(textRenderer); | 1518 ASSERT(textRenderer); |
1494 ASSERT(textRenderer->text()); | 1519 ASSERT(textRenderer->text()); |
1495 | 1520 |
1496 StringView string = textRenderer->text().createView(); | 1521 StringView string = textRenderer->text().createView(); |
1497 unsigned startPos = start(); | 1522 unsigned startPos = start(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1557 printedCharacters = fprintf(stderr, "\t%s %p", obj->renderName(), obj); | 1582 printedCharacters = fprintf(stderr, "\t%s %p", obj->renderName(), obj); |
1558 const int rendererCharacterOffset = 24; | 1583 const int rendererCharacterOffset = 24; |
1559 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) | 1584 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) |
1560 fputc(' ', stderr); | 1585 fputc(' ', stderr); |
1561 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata()); | 1586 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata()); |
1562 } | 1587 } |
1563 | 1588 |
1564 #endif | 1589 #endif |
1565 | 1590 |
1566 } // namespace WebCore | 1591 } // namespace WebCore |
OLD | NEW |