Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Side by Side Diff: Source/core/rendering/RenderText.cpp

Issue 111833006: Avoiding multiple text/string parsing while creating TextRun (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@FontOptPatch1
Patch Set: Fixing review comments for rebasing files Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 using namespace WTF; 49 using namespace WTF;
50 using namespace Unicode; 50 using namespace Unicode;
51 51
52 namespace WebCore { 52 namespace WebCore {
53 53
54 struct SameSizeAsRenderText : public RenderObject { 54 struct SameSizeAsRenderText : public RenderObject {
55 uint32_t bitfields : 16; 55 uint32_t bitfields : 16;
56 float widths[4]; 56 float widths[4];
57 String text; 57 String text;
58 void* pointers[2]; 58 void* pointers[2];
59 CodePath someCodePath;
eseidel 2013/12/27 04:36:45 nit: I would have called this "codePath".
59 }; 60 };
60 61
61 COMPILE_ASSERT(sizeof(RenderText) == sizeof(SameSizeAsRenderText), RenderText_sh ould_stay_small); 62 COMPILE_ASSERT(sizeof(RenderText) == sizeof(SameSizeAsRenderText), RenderText_sh ould_stay_small);
62 63
63 class SecureTextTimer; 64 class SecureTextTimer;
64 typedef HashMap<RenderText*, SecureTextTimer*> SecureTextTimerMap; 65 typedef HashMap<RenderText*, SecureTextTimer*> SecureTextTimerMap;
65 static SecureTextTimerMap* gSecureTextTimers = 0; 66 static SecureTextTimerMap* gSecureTextTimers = 0;
66 67
67 class SecureTextTimer : public TimerBase { 68 class SecureTextTimer : public TimerBase {
68 public: 69 public:
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 return w; 761 return w;
761 } 762 }
762 763
763 TextRun run = RenderBlockFlow::constructTextRun(const_cast<RenderText*>(this ), f, this, start, len, style()); 764 TextRun run = RenderBlockFlow::constructTextRun(const_cast<RenderText*>(this ), f, this, start, len, style());
764 run.setCharactersLength(textLength() - start); 765 run.setCharactersLength(textLength() - start);
765 ASSERT(run.charactersLength() >= run.length()); 766 ASSERT(run.charactersLength() >= run.length());
766 767
767 run.setCharacterScanForCodePath(!canUseSimpleFontCodePath()); 768 run.setCharacterScanForCodePath(!canUseSimpleFontCodePath());
768 run.setTabSize(!style()->collapseWhiteSpace(), style()->tabSize()); 769 run.setTabSize(!style()->collapseWhiteSpace(), style()->tabSize());
769 run.setXPos(xPos); 770 run.setXPos(xPos);
771
770 return f.width(run, fallbackFonts, glyphOverflow); 772 return f.width(run, fallbackFonts, glyphOverflow);
771 } 773 }
772 774
773 void RenderText::trimmedPrefWidths(float leadWidth, 775 void RenderText::trimmedPrefWidths(float leadWidth,
774 float& firstLineMinWidth, bool& hasBreakableStart, 776 float& firstLineMinWidth, bool& hasBreakableStart,
775 float& lastLineMinWidth, bool& hasBreakableEnd, 777 float& lastLineMinWidth, bool& hasBreakableEnd,
776 bool& hasBreakableChar, bool& hasBreak, 778 bool& hasBreakableChar, bool& hasBreak,
777 float& firstLineMaxWidth, float& lastLineMaxWidth, 779 float& firstLineMaxWidth, float& lastLineMaxWidth,
778 float& minWidth, float& maxWidth, bool& stripFrontSpaces) 780 float& minWidth, float& maxWidth, bool& stripFrontSpaces)
779 { 781 {
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after
1798 if (!iterator) 1800 if (!iterator)
1799 return current + 1; 1801 return current + 1;
1800 1802
1801 long result = iterator->following(current); 1803 long result = iterator->following(current);
1802 if (result == TextBreakDone) 1804 if (result == TextBreakDone)
1803 result = current + 1; 1805 result = current + 1;
1804 1806
1805 return result; 1807 return result;
1806 } 1808 }
1807 1809
1808 bool RenderText::computeCanUseSimpleFontCodePath() const 1810 bool RenderText::computeCanUseSimpleFontCodePath()
eseidel 2013/12/27 04:36:45 We could also just have made codepath mutable. Unc
1809 { 1811 {
eae 2013/12/30 19:29:14 This method didn't use to have a side effect and n
h.joshi 2013/12/31 06:07:43 This method is always called when RenderText is cr
1812 m_textCodePath = AutoPath;
1810 if (isAllASCII() || m_text.is8Bit()) 1813 if (isAllASCII() || m_text.is8Bit())
1811 return true; 1814 return true;
1812 return Font::characterRangeCodePath(characters16(), length()) == Font::Simpl e; 1815 m_textCodePath = Font::characterRangeCodePath(characters16(), length());
1816 return (m_textCodePath == SimplePath);
1813 } 1817 }
1814 1818
1815 #ifndef NDEBUG 1819 #ifndef NDEBUG
1816 1820
1817 void RenderText::checkConsistency() const 1821 void RenderText::checkConsistency() const
1818 { 1822 {
1819 #ifdef CHECK_CONSISTENCY 1823 #ifdef CHECK_CONSISTENCY
1820 const InlineTextBox* prev = 0; 1824 const InlineTextBox* prev = 0;
1821 for (const InlineTextBox* child = m_firstTextBox; child != 0; child = child- >nextTextBox()) { 1825 for (const InlineTextBox* child = m_firstTextBox; child != 0; child = child- >nextTextBox()) {
1822 ASSERT(child->renderer() == this); 1826 ASSERT(child->renderer() == this);
(...skipping 18 matching lines...) Expand all
1841 } 1845 }
1842 secureTextTimer->restartWithNewText(lastTypedCharacterOffset); 1846 secureTextTimer->restartWithNewText(lastTypedCharacterOffset);
1843 } 1847 }
1844 1848
1845 PassRefPtr<AbstractInlineTextBox> RenderText::firstAbstractInlineTextBox() 1849 PassRefPtr<AbstractInlineTextBox> RenderText::firstAbstractInlineTextBox()
1846 { 1850 {
1847 return AbstractInlineTextBox::getOrCreate(this, m_firstTextBox); 1851 return AbstractInlineTextBox::getOrCreate(this, m_firstTextBox);
1848 } 1852 }
1849 1853
1850 } // namespace WebCore 1854 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698