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/frame/Frame.h" | 32 #include "core/frame/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" |
| 39 #include "core/rendering/AbstractInlineTextBox.h" |
38 #include "core/rendering/EllipsisBox.h" | 40 #include "core/rendering/EllipsisBox.h" |
39 #include "core/rendering/HitTestResult.h" | 41 #include "core/rendering/HitTestResult.h" |
40 #include "core/rendering/PaintInfo.h" | 42 #include "core/rendering/PaintInfo.h" |
41 #include "core/rendering/RenderBR.h" | 43 #include "core/rendering/RenderBR.h" |
42 #include "core/rendering/RenderBlock.h" | 44 #include "core/rendering/RenderBlock.h" |
43 #include "core/rendering/RenderCombineText.h" | 45 #include "core/rendering/RenderCombineText.h" |
44 #include "core/rendering/RenderRubyRun.h" | 46 #include "core/rendering/RenderRubyRun.h" |
45 #include "core/rendering/RenderRubyText.h" | 47 #include "core/rendering/RenderRubyText.h" |
46 #include "core/rendering/RenderTheme.h" | 48 #include "core/rendering/RenderTheme.h" |
47 #include "core/rendering/style/ShadowData.h" | 49 #include "core/rendering/style/ShadowData.h" |
(...skipping 14 matching lines...) Expand all Loading... |
62 | 64 |
63 COMPILE_ASSERT(sizeof(InlineTextBox) == sizeof(SameSizeAsInlineTextBox), InlineT
extBox_should_stay_small); | 65 COMPILE_ASSERT(sizeof(InlineTextBox) == sizeof(SameSizeAsInlineTextBox), InlineT
extBox_should_stay_small); |
64 | 66 |
65 typedef WTF::HashMap<const InlineTextBox*, LayoutRect> InlineTextBoxOverflowMap; | 67 typedef WTF::HashMap<const InlineTextBox*, LayoutRect> InlineTextBoxOverflowMap; |
66 static InlineTextBoxOverflowMap* gTextBoxesWithOverflow; | 68 static InlineTextBoxOverflowMap* gTextBoxesWithOverflow; |
67 | 69 |
68 static const int misspellingLineThickness = 3; | 70 static const int misspellingLineThickness = 3; |
69 | 71 |
70 void InlineTextBox::destroy() | 72 void InlineTextBox::destroy() |
71 { | 73 { |
| 74 AbstractInlineTextBox::willDestroy(this); |
| 75 |
72 if (!knownToHaveNoOverflow() && gTextBoxesWithOverflow) | 76 if (!knownToHaveNoOverflow() && gTextBoxesWithOverflow) |
73 gTextBoxesWithOverflow->remove(this); | 77 gTextBoxesWithOverflow->remove(this); |
74 InlineBox::destroy(); | 78 InlineBox::destroy(); |
75 } | 79 } |
76 | 80 |
77 void InlineTextBox::markDirty(bool dirty) | 81 void InlineTextBox::markDirty(bool dirty) |
78 { | 82 { |
79 if (dirty) { | 83 if (dirty) { |
80 m_len = 0; | 84 m_len = 0; |
81 m_start = 0; | 85 m_start = 0; |
(...skipping 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1467 return false; | 1471 return false; |
1468 | 1472 |
1469 // Offsets at the end are "out" for line breaks (they are on the next line). | 1473 // Offsets at the end are "out" for line breaks (they are on the next line). |
1470 if (isLineBreak()) | 1474 if (isLineBreak()) |
1471 return false; | 1475 return false; |
1472 | 1476 |
1473 // Offsets at the end are "in" for normal boxes (but the caller has to check
affinity). | 1477 // Offsets at the end are "in" for normal boxes (but the caller has to check
affinity). |
1474 return true; | 1478 return true; |
1475 } | 1479 } |
1476 | 1480 |
| 1481 void InlineTextBox::characterWidths(Vector<float>& widths) const |
| 1482 { |
| 1483 FontCachePurgePreventer fontCachePurgePreventer; |
| 1484 |
| 1485 RenderText* textObj = textRenderer(); |
| 1486 RenderStyle* styleToUse = textObj->style(isFirstLineStyle()); |
| 1487 const Font& font = styleToUse->font(); |
| 1488 |
| 1489 TextRun textRun = constructTextRun(styleToUse, font); |
| 1490 |
| 1491 GlyphBuffer glyphBuffer; |
| 1492 WidthIterator it(&font, textRun); |
| 1493 float lastWidth = 0; |
| 1494 widths.resize(m_len); |
| 1495 for (unsigned i = 0; i < m_len; i++) { |
| 1496 it.advance(i + 1, &glyphBuffer); |
| 1497 widths[i] = it.m_runWidthSoFar - lastWidth; |
| 1498 lastWidth = it.m_runWidthSoFar; |
| 1499 } |
| 1500 } |
| 1501 |
1477 TextRun InlineTextBox::constructTextRun(RenderStyle* style, const Font& font, St
ringBuilder* charactersWithHyphen) const | 1502 TextRun InlineTextBox::constructTextRun(RenderStyle* style, const Font& font, St
ringBuilder* charactersWithHyphen) const |
1478 { | 1503 { |
1479 ASSERT(style); | 1504 ASSERT(style); |
1480 | 1505 |
1481 RenderText* textRenderer = this->textRenderer(); | 1506 RenderText* textRenderer = this->textRenderer(); |
1482 ASSERT(textRenderer); | 1507 ASSERT(textRenderer); |
1483 ASSERT(textRenderer->text()); | 1508 ASSERT(textRenderer->text()); |
1484 | 1509 |
1485 StringView string = textRenderer->text().createView(); | 1510 StringView string = textRenderer->text().createView(); |
1486 unsigned startPos = start(); | 1511 unsigned startPos = start(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1546 printedCharacters = fprintf(stderr, "\t%s %p", obj->renderName(), obj); | 1571 printedCharacters = fprintf(stderr, "\t%s %p", obj->renderName(), obj); |
1547 const int rendererCharacterOffset = 24; | 1572 const int rendererCharacterOffset = 24; |
1548 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) | 1573 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) |
1549 fputc(' ', stderr); | 1574 fputc(' ', stderr); |
1550 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d
ata()); | 1575 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d
ata()); |
1551 } | 1576 } |
1552 | 1577 |
1553 #endif | 1578 #endif |
1554 | 1579 |
1555 } // namespace WebCore | 1580 } // namespace WebCore |
OLD | NEW |