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 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 maxWidth -= spaceWidth; | 816 maxWidth -= spaceWidth; |
817 } else { | 817 } else { |
818 maxWidth += font.wordSpacing(); | 818 maxWidth += font.wordSpacing(); |
819 } | 819 } |
820 } | 820 } |
821 | 821 |
822 stripFrontSpaces = collapseWhiteSpace && m_hasBreakableEnd; | 822 stripFrontSpaces = collapseWhiteSpace && m_hasEndWhiteSpace; |
823 | 823 |
824 if (!style()->autoWrap() || minWidth > maxWidth) | 824 if (!style()->autoWrap() || minWidth > maxWidth) |
825 minWidth = maxWidth; | 825 minWidth = maxWidth; |
826 | 826 |
827 // Compute our max widths by scanning the string for newlines. | 827 // Compute our max widths by scanning the string for newlines. |
828 if (hasBreak) { | 828 if (hasBreak) { |
829 const Font& f = style()->font(); // FIXME: This ignores first-line. | 829 const Font& f = style()->font(); // FIXME: This ignores first-line. |
830 bool firstLine = true; | 830 bool firstLine = true; |
831 firstLineMaxWidth = maxWidth; | 831 firstLineMaxWidth = maxWidth; |
832 lastLineMaxWidth = maxWidth; | 832 lastLineMaxWidth = maxWidth; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
941 if (isBR()) | 941 if (isBR()) |
942 return; | 942 return; |
943 | 943 |
944 float currMinWidth = 0; | 944 float currMinWidth = 0; |
945 float currMaxWidth = 0; | 945 float currMaxWidth = 0; |
946 m_hasBreakableChar = false; | 946 m_hasBreakableChar = false; |
947 m_hasBreak = false; | 947 m_hasBreak = false; |
948 m_hasTab = false; | 948 m_hasTab = false; |
949 m_hasBreakableStart = false; | 949 m_hasBreakableStart = false; |
950 m_hasBreakableEnd = false; | 950 m_hasBreakableEnd = false; |
| 951 m_hasEndWhiteSpace = false; |
951 | 952 |
952 RenderStyle* styleToUse = style(); | 953 RenderStyle* styleToUse = style(); |
953 const Font& f = styleToUse->font(); // FIXME: This ignores first-line. | 954 const Font& f = styleToUse->font(); // FIXME: This ignores first-line. |
954 float wordSpacing = styleToUse->wordSpacing(); | 955 float wordSpacing = styleToUse->wordSpacing(); |
955 int len = textLength(); | 956 int len = textLength(); |
956 LazyLineBreakIterator breakIterator(m_text, styleToUse->locale()); | 957 LazyLineBreakIterator breakIterator(m_text, styleToUse->locale()); |
957 bool needsWordSpacing = false; | 958 bool needsWordSpacing = false; |
958 bool ignoringSpaces = false; | 959 bool ignoringSpaces = false; |
959 bool isSpace = false; | 960 bool isSpace = false; |
960 bool firstWord = true; | 961 bool firstWord = true; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 isSpace = true; | 1004 isSpace = true; |
1004 } else if (c == '\t') { | 1005 } else if (c == '\t') { |
1005 if (!styleToUse->collapseWhiteSpace()) { | 1006 if (!styleToUse->collapseWhiteSpace()) { |
1006 m_hasTab = true; | 1007 m_hasTab = true; |
1007 isSpace = false; | 1008 isSpace = false; |
1008 } else | 1009 } else |
1009 isSpace = true; | 1010 isSpace = true; |
1010 } else | 1011 } else |
1011 isSpace = c == ' '; | 1012 isSpace = c == ' '; |
1012 | 1013 |
1013 if ((isSpace || isNewline) && !i) | 1014 bool isBreakableLocation = isNewline || (isSpace && styleToUse->autoWrap
()); |
1014 m_hasBreakableStart = true; | 1015 if (!i) |
1015 if ((isSpace || isNewline) && i == len - 1) | 1016 m_hasBreakableStart = isBreakableLocation; |
1016 m_hasBreakableEnd = true; | 1017 if (i == len - 1) { |
| 1018 m_hasBreakableEnd = isBreakableLocation; |
| 1019 m_hasEndWhiteSpace = isNewline || isSpace; |
| 1020 } |
1017 | 1021 |
1018 if (!ignoringSpaces && styleToUse->collapseWhiteSpace() && previousChara
cterIsSpace && isSpace) | 1022 if (!ignoringSpaces && styleToUse->collapseWhiteSpace() && previousChara
cterIsSpace && isSpace) |
1019 ignoringSpaces = true; | 1023 ignoringSpaces = true; |
1020 | 1024 |
1021 if (ignoringSpaces && !isSpace) | 1025 if (ignoringSpaces && !isSpace) |
1022 ignoringSpaces = false; | 1026 ignoringSpaces = false; |
1023 | 1027 |
1024 // Ignore spaces and soft hyphens | 1028 // Ignore spaces and soft hyphens |
1025 if (ignoringSpaces) { | 1029 if (ignoringSpaces) { |
1026 ASSERT(lastWordBoundary == i); | 1030 ASSERT(lastWordBoundary == i); |
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1929 void RenderText::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const | 1933 void RenderText::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const |
1930 { | 1934 { |
1931 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Rendering)
; | 1935 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Rendering)
; |
1932 RenderObject::reportMemoryUsage(memoryObjectInfo); | 1936 RenderObject::reportMemoryUsage(memoryObjectInfo); |
1933 info.addMember(m_text, "text"); | 1937 info.addMember(m_text, "text"); |
1934 info.addMember(m_firstTextBox, "firstTextBox"); | 1938 info.addMember(m_firstTextBox, "firstTextBox"); |
1935 info.addMember(m_lastTextBox, "lastTextBox"); | 1939 info.addMember(m_lastTextBox, "lastTextBox"); |
1936 } | 1940 } |
1937 | 1941 |
1938 } // namespace WebCore | 1942 } // namespace WebCore |
OLD | NEW |