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 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 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
811 if (text[0] == ' ' || (text[0] == '\n' && !style()->preserveNewline()) || te xt[0] == '\t') { | 811 if (text[0] == ' ' || (text[0] == '\n' && !style()->preserveNewline()) || te xt[0] == '\t') { |
812 const Font& font = style()->font(); // FIXME: This ignores first-line. | 812 const Font& font = style()->font(); // FIXME: This ignores first-line. |
813 if (stripFrontSpaces) { | 813 if (stripFrontSpaces) { |
814 const UChar space = ' '; | 814 const UChar space = ' '; |
815 float spaceWidth = font.width(RenderBlock::constructTextRun(this, fo nt, &space, 1, style())); | 815 float spaceWidth = font.width(RenderBlock::constructTextRun(this, fo nt, &space, 1, style())); |
816 maxW -= spaceWidth; | 816 maxW -= spaceWidth; |
817 } else | 817 } else |
818 maxW += font.wordSpacing(); | 818 maxW += font.wordSpacing(); |
819 } | 819 } |
820 | 820 |
821 stripFrontSpaces = collapseWhiteSpace && m_hasEndWS; | 821 stripFrontSpaces = collapseWhiteSpace && m_hasEndWhiteSpace; |
822 | 822 |
823 if (!style()->autoWrap() || minW > maxW) | 823 if (!style()->autoWrap() || minW > maxW) |
824 minW = maxW; | 824 minW = maxW; |
825 | 825 |
826 // Compute our max widths by scanning the string for newlines. | 826 // Compute our max widths by scanning the string for newlines. |
827 if (hasBreak) { | 827 if (hasBreak) { |
828 const Font& f = style()->font(); // FIXME: This ignores first-line. | 828 const Font& f = style()->font(); // FIXME: This ignores first-line. |
829 bool firstLine = true; | 829 bool firstLine = true; |
830 beginMaxW = maxW; | 830 beginMaxW = maxW; |
831 endMaxW = maxW; | 831 endMaxW = maxW; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
939 if (isBR()) | 939 if (isBR()) |
940 return; | 940 return; |
941 | 941 |
942 float currMinWidth = 0; | 942 float currMinWidth = 0; |
943 float currMaxWidth = 0; | 943 float currMaxWidth = 0; |
944 m_hasBreakableChar = false; | 944 m_hasBreakableChar = false; |
945 m_hasBreak = false; | 945 m_hasBreak = false; |
946 m_hasTab = false; | 946 m_hasTab = false; |
947 m_hasBeginWS = false; | 947 m_hasBeginWS = false; |
948 m_hasEndWS = false; | 948 m_hasEndWS = false; |
949 m_hasEndWhiteSpace = false; | |
949 | 950 |
950 RenderStyle* styleToUse = style(); | 951 RenderStyle* styleToUse = style(); |
951 const Font& f = styleToUse->font(); // FIXME: This ignores first-line. | 952 const Font& f = styleToUse->font(); // FIXME: This ignores first-line. |
952 float wordSpacing = styleToUse->wordSpacing(); | 953 float wordSpacing = styleToUse->wordSpacing(); |
953 int len = textLength(); | 954 int len = textLength(); |
954 LazyLineBreakIterator breakIterator(m_text, styleToUse->locale()); | 955 LazyLineBreakIterator breakIterator(m_text, styleToUse->locale()); |
955 bool needsWordSpacing = false; | 956 bool needsWordSpacing = false; |
956 bool ignoringSpaces = false; | 957 bool ignoringSpaces = false; |
957 bool isSpace = false; | 958 bool isSpace = false; |
958 bool firstWord = true; | 959 bool firstWord = true; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1001 isSpace = true; | 1002 isSpace = true; |
1002 } else if (c == '\t') { | 1003 } else if (c == '\t') { |
1003 if (!styleToUse->collapseWhiteSpace()) { | 1004 if (!styleToUse->collapseWhiteSpace()) { |
1004 m_hasTab = true; | 1005 m_hasTab = true; |
1005 isSpace = false; | 1006 isSpace = false; |
1006 } else | 1007 } else |
1007 isSpace = true; | 1008 isSpace = true; |
1008 } else | 1009 } else |
1009 isSpace = c == ' '; | 1010 isSpace = c == ' '; |
1010 | 1011 |
1011 if ((isSpace || isNewline) && !i) | 1012 bool isBreakableLocation = isNewline || (isSpace && styleToUse->autoWrap ()); |
1012 m_hasBeginWS = true; | 1013 if (!i) |
1013 if ((isSpace || isNewline) && i == len - 1) | 1014 m_hasBeginWS = isBreakableLocation; |
1014 m_hasEndWS = true; | 1015 if (i == len - 1) { |
1016 m_hasEndWS = isBreakableLocation; | |
1017 m_hasEndWhiteSpace = isNewline || isSpace; | |
esprehn
2013/06/18 02:10:03
I'd prefer you do the rename before landing this.
ojan
2013/06/18 03:33:46
Fair enough. I'll do that tomorrow.
| |
1018 } | |
1015 | 1019 |
1016 if (!ignoringSpaces && styleToUse->collapseWhiteSpace() && previousChara cterIsSpace && isSpace) | 1020 if (!ignoringSpaces && styleToUse->collapseWhiteSpace() && previousChara cterIsSpace && isSpace) |
1017 ignoringSpaces = true; | 1021 ignoringSpaces = true; |
1018 | 1022 |
1019 if (ignoringSpaces && !isSpace) | 1023 if (ignoringSpaces && !isSpace) |
1020 ignoringSpaces = false; | 1024 ignoringSpaces = false; |
1021 | 1025 |
1022 // Ignore spaces and soft hyphens | 1026 // Ignore spaces and soft hyphens |
1023 if (ignoringSpaces) { | 1027 if (ignoringSpaces) { |
1024 ASSERT(lastWordBoundary == i); | 1028 ASSERT(lastWordBoundary == i); |
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1927 void RenderText::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const | 1931 void RenderText::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const |
1928 { | 1932 { |
1929 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Rendering) ; | 1933 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Rendering) ; |
1930 RenderObject::reportMemoryUsage(memoryObjectInfo); | 1934 RenderObject::reportMemoryUsage(memoryObjectInfo); |
1931 info.addMember(m_text, "text"); | 1935 info.addMember(m_text, "text"); |
1932 info.addMember(m_firstTextBox, "firstTextBox"); | 1936 info.addMember(m_firstTextBox, "firstTextBox"); |
1933 info.addMember(m_lastTextBox, "lastTextBox"); | 1937 info.addMember(m_lastTextBox, "lastTextBox"); |
1934 } | 1938 } |
1935 | 1939 |
1936 } // namespace WebCore | 1940 } // namespace WebCore |
OLD | NEW |