| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 unsigned variables[1]; | 65 unsigned variables[1]; |
| 66 unsigned short variables2[2]; | 66 unsigned short variables2[2]; |
| 67 void* pointers[2]; | 67 void* pointers[2]; |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 COMPILE_ASSERT(sizeof(InlineTextBox) == sizeof(SameSizeAsInlineTextBox), InlineT
extBox_should_stay_small); | 70 COMPILE_ASSERT(sizeof(InlineTextBox) == sizeof(SameSizeAsInlineTextBox), InlineT
extBox_should_stay_small); |
| 71 | 71 |
| 72 typedef WTF::HashMap<const InlineTextBox*, LayoutRect> InlineTextBoxOverflowMap; | 72 typedef WTF::HashMap<const InlineTextBox*, LayoutRect> InlineTextBoxOverflowMap; |
| 73 static InlineTextBoxOverflowMap* gTextBoxesWithOverflow; | 73 static InlineTextBoxOverflowMap* gTextBoxesWithOverflow; |
| 74 | 74 |
| 75 typedef WTF::HashMap<const InlineTextBox*, TextBlobPtr> InlineTextBoxBlobCacheMa
p; |
| 76 static InlineTextBoxBlobCacheMap* gTextBlobCache; |
| 77 |
| 75 static const int misspellingLineThickness = 3; | 78 static const int misspellingLineThickness = 3; |
| 76 | 79 |
| 77 void InlineTextBox::destroy() | 80 void InlineTextBox::destroy() |
| 78 { | 81 { |
| 79 AbstractInlineTextBox::willDestroy(this); | 82 AbstractInlineTextBox::willDestroy(this); |
| 80 | 83 |
| 81 if (!knownToHaveNoOverflow() && gTextBoxesWithOverflow) | 84 if (!knownToHaveNoOverflow() && gTextBoxesWithOverflow) |
| 82 gTextBoxesWithOverflow->remove(this); | 85 gTextBoxesWithOverflow->remove(this); |
| 86 if (gTextBlobCache) |
| 87 gTextBlobCache->remove(this); |
| 83 InlineBox::destroy(); | 88 InlineBox::destroy(); |
| 84 } | 89 } |
| 85 | 90 |
| 86 void InlineTextBox::markDirty() | 91 void InlineTextBox::markDirty() |
| 87 { | 92 { |
| 93 // FIXME: Is it actually possible to try and paint a dirty InlineTextBox? |
| 94 if (gTextBlobCache) |
| 95 gTextBlobCache->remove(this); |
| 96 |
| 88 m_len = 0; | 97 m_len = 0; |
| 89 m_start = 0; | 98 m_start = 0; |
| 90 InlineBox::markDirty(); | 99 InlineBox::markDirty(); |
| 91 } | 100 } |
| 92 | 101 |
| 93 LayoutRect InlineTextBox::logicalOverflowRect() const | 102 LayoutRect InlineTextBox::logicalOverflowRect() const |
| 94 { | 103 { |
| 95 if (knownToHaveNoOverflow() || !gTextBoxesWithOverflow) | 104 if (knownToHaveNoOverflow() || !gTextBoxesWithOverflow) |
| 96 return enclosingIntRect(logicalFrameRect()); | 105 return enclosingIntRect(logicalFrameRect()); |
| 97 return gTextBoxesWithOverflow->get(this); | 106 return gTextBoxesWithOverflow->get(this); |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 textPainter.setCombinedText(combinedText); | 591 textPainter.setCombinedText(combinedText); |
| 583 | 592 |
| 584 if (!paintSelectedTextOnly) { | 593 if (!paintSelectedTextOnly) { |
| 585 // FIXME: Truncate right-to-left text correctly. | 594 // FIXME: Truncate right-to-left text correctly. |
| 586 int startOffset = 0; | 595 int startOffset = 0; |
| 587 int endOffset = length; | 596 int endOffset = length; |
| 588 if (paintSelectedTextSeparately && selectionStart < selectionEnd) { | 597 if (paintSelectedTextSeparately && selectionStart < selectionEnd) { |
| 589 startOffset = selectionEnd; | 598 startOffset = selectionEnd; |
| 590 endOffset = selectionStart; | 599 endOffset = selectionStart; |
| 591 } | 600 } |
| 592 textPainter.paint(startOffset, endOffset, length, textStyle); | 601 |
| 602 // FIXME: This cache should probably ultimately be held somewhere else. |
| 603 // A hashmap is convenient to avoid a memory hit when the |
| 604 // RuntimeEnabledFeature is off. |
| 605 bool textBlobIsCacheable = RuntimeEnabledFeatures::textBlobEnabled() &&
startOffset == 0 && endOffset == length; |
| 606 TextBlobPtr* cachedTextBlob = 0; |
| 607 if (textBlobIsCacheable) { |
| 608 if (!gTextBlobCache) |
| 609 gTextBlobCache = new InlineTextBoxBlobCacheMap; |
| 610 cachedTextBlob = &gTextBlobCache->add(this, nullptr).storedValue->va
lue; |
| 611 } |
| 612 textPainter.paint(startOffset, endOffset, length, textStyle, cachedTextB
lob); |
| 593 } | 613 } |
| 594 | 614 |
| 595 if ((paintSelectedTextOnly || paintSelectedTextSeparately) && selectionStart
< selectionEnd) { | 615 if ((paintSelectedTextOnly || paintSelectedTextSeparately) && selectionStart
< selectionEnd) { |
| 596 // paint only the text that is selected | 616 // paint only the text that is selected |
| 597 textPainter.paint(selectionStart, selectionEnd, length, selectionStyle); | 617 textPainter.paint(selectionStart, selectionEnd, length, selectionStyle); |
| 598 } | 618 } |
| 599 | 619 |
| 600 // Paint decorations | 620 // Paint decorations |
| 601 TextDecoration textDecorations = styleToUse->textDecorationsInEffect(); | 621 TextDecoration textDecorations = styleToUse->textDecorationsInEffect(); |
| 602 if (textDecorations != TextDecorationNone && !paintSelectedTextOnly) { | 622 if (textDecorations != TextDecorationNone && !paintSelectedTextOnly) { |
| (...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1370 printedCharacters = fprintf(stderr, "\t%s %p", obj.renderName(), &obj); | 1390 printedCharacters = fprintf(stderr, "\t%s %p", obj.renderName(), &obj); |
| 1371 const int rendererCharacterOffset = 24; | 1391 const int rendererCharacterOffset = 24; |
| 1372 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) | 1392 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) |
| 1373 fputc(' ', stderr); | 1393 fputc(' ', stderr); |
| 1374 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d
ata()); | 1394 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d
ata()); |
| 1375 } | 1395 } |
| 1376 | 1396 |
| 1377 #endif | 1397 #endif |
| 1378 | 1398 |
| 1379 } // namespace blink | 1399 } // namespace blink |
| OLD | NEW |