Changeset 85695 in webkit
- Timestamp:
- May 3, 2011 5:38:05 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r85693 r85695 1 2011-05-03 Ryosuke Niwa <rniwa@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 findNextLineBreak splits InlineIterator into 3 pieces 6 https://bugs.webkit.org/show_bug.cgi?id=60082 7 8 Avoid splitting InlineIterator into 3 variables with inter-dependencies. 9 10 * rendering/InlineIterator.h: 11 (WebCore::InlineIterator::fastIncrementInTextNode): Added. 12 (WebCore::InlineIterator::previousInSameNode): Added. 13 * rendering/RenderBlockLineLayout.cpp: 14 (WebCore::RenderBlock::findNextLineBreak): 15 1 16 2011-05-03 Dean Jackson <dino@apple.com> 2 17 -
trunk/Source/WebCore/rendering/InlineIterator.h
r84450 r85695 66 66 RenderObject* root() const { return m_root; } 67 67 68 void fastIncrementInTextNode(); 68 69 void increment(InlineBidiResolver* = 0); 69 70 bool atEnd() const; … … 81 82 82 83 UChar current() const; 84 UChar previousInSameNode() const; 83 85 ALWAYS_INLINE WTF::Unicode::Direction direction() const; 84 86 … … 237 239 } 238 240 241 inline void InlineIterator::fastIncrementInTextNode() 242 { 243 ASSERT(m_obj); 244 ASSERT(m_obj->isText()); 245 ASSERT(m_pos <= toRenderText(m_obj)->textLength()); 246 m_pos++; 247 } 248 239 249 inline void InlineIterator::increment(InlineBidiResolver* resolver) 240 250 { … … 242 252 return; 243 253 if (m_obj->isText()) { 244 m_pos++;254 fastIncrementInTextNode(); 245 255 if (m_pos < toRenderText(m_obj)->textLength()) 246 256 return; … … 265 275 266 276 return text->characters()[m_pos]; 277 } 278 279 inline UChar InlineIterator::previousInSameNode() const 280 { 281 if (!m_obj || !m_obj->isText() || !m_pos) 282 return 0; 283 284 RenderText* text = toRenderText(m_obj); 285 return text->characters()[m_pos - 1]; 267 286 } 268 287 -
trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp
r85685 r85695 1820 1820 // FIXME: It is error-prone to split the position object out like this. 1821 1821 // Teach this code to work with objects instead of this split tuple. 1822 RenderObject* o = resolver.position().m_obj; 1823 RenderObject* last = o; 1824 unsigned pos = resolver.position().m_pos; 1825 int nextBreakable = resolver.position().m_nextBreakablePosition; 1822 InlineIterator current = resolver.position(); 1823 RenderObject* last = current.m_obj; 1826 1824 bool atStart = true; 1827 1825 … … 1841 1839 EWhiteSpace currWS = style()->whiteSpace(); 1842 1840 EWhiteSpace lastWS = currWS; 1843 while ( o) {1844 RenderObject* next = bidiNext(this, o);1845 1846 currWS = o->isReplaced() ? o->parent()->style()->whiteSpace() : o->style()->whiteSpace();1841 while (current.m_obj) { 1842 RenderObject* next = bidiNext(this, current.m_obj); 1843 1844 currWS = current.m_obj->isReplaced() ? current.m_obj->parent()->style()->whiteSpace() : current.m_obj->style()->whiteSpace(); 1847 1845 lastWS = last->isReplaced() ? last->parent()->style()->whiteSpace() : last->style()->whiteSpace(); 1848 1846 … … 1851 1849 1852 1850 #if ENABLE(SVG) 1853 bool preserveNewline = o->isSVGInlineText() ? false : RenderStyle::preserveNewline(currWS);1851 bool preserveNewline = current.m_obj->isSVGInlineText() ? false : RenderStyle::preserveNewline(currWS); 1854 1852 #else 1855 1853 bool preserveNewline = RenderStyle::preserveNewline(currWS); … … 1858 1856 bool collapseWhiteSpace = RenderStyle::collapseWhiteSpace(currWS); 1859 1857 1860 if ( o->isBR()) {1858 if (current.m_obj->isBR()) { 1861 1859 if (width.fitsOnLine()) { 1862 lBreak.moveToStartOf( o);1860 lBreak.moveToStartOf(current.m_obj); 1863 1861 lBreak.increment(); 1864 1862 … … 1874 1872 1875 1873 if (!lineInfo.isEmpty() && clear) 1876 *clear = o->style()->clear();1874 *clear = current.m_obj->style()->clear(); 1877 1875 } 1878 1876 goto end; 1879 1877 } 1880 1878 1881 if ( o->isFloatingOrPositioned()) {1879 if (current.m_obj->isFloatingOrPositioned()) { 1882 1880 // add to special objects... 1883 if ( o->isFloating()) {1884 RenderBox* floatBox = toRenderBox( o);1881 if (current.m_obj->isFloating()) { 1882 RenderBox* floatBox = toRenderBox(current.m_obj); 1885 1883 FloatingObject* f = insertFloatingObject(floatBox); 1886 1884 // check if it fits in the current line. … … 1889 1887 if (floatsFitOnLine && width.fitsOnLine(logicalWidthForFloat(f))) { 1890 1888 positionNewFloatOnLine(f, lastFloatFromPreviousLine, width); 1891 if (lBreak.m_obj == o) {1889 if (lBreak.m_obj == current.m_obj) { 1892 1890 ASSERT(!lBreak.m_pos); 1893 1891 lBreak.increment(); … … 1895 1893 } else 1896 1894 floatsFitOnLine = false; 1897 } else if ( o->isPositioned()) {1895 } else if (current.m_obj->isPositioned()) { 1898 1896 // If our original display wasn't an inline type, then we can 1899 1897 // go ahead and determine our static inline position now. 1900 RenderBox* box = toRenderBox( o);1898 RenderBox* box = toRenderBox(current.m_obj); 1901 1899 bool isInlineType = box->style()->isOriginalDisplayInlineType(); 1902 1900 if (!isInlineType) … … 1910 1908 // If we're ignoring spaces, we have to stop and include this object and 1911 1909 // then start ignoring spaces again. 1912 if (isInlineType || o->container()->isRenderInline()) {1910 if (isInlineType || current.m_obj->container()->isRenderInline()) { 1913 1911 if (ignoringSpaces) { 1914 ignoreStart.m_obj = o;1912 ignoreStart.m_obj = current.m_obj; 1915 1913 ignoreStart.m_pos = 0; 1916 1914 addMidpoint(lineMidpointState, ignoreStart); // Stop ignoring spaces. … … 1921 1919 positionedBoxes.append(box); 1922 1920 } 1923 } else if ( o->isRenderInline()) {1921 } else if (current.m_obj->isRenderInline()) { 1924 1922 // Right now, we should only encounter empty inlines here. 1925 ASSERT(! o->firstChild());1926 1927 RenderInline* flowBox = toRenderInline( o);1923 ASSERT(!current.m_obj->firstChild()); 1924 1925 RenderInline* flowBox = toRenderInline(current.m_obj); 1928 1926 1929 1927 // Now that some inline flows have line boxes, if we are already ignoring spaces, we need … … 1935 1933 if (ignoringSpaces) { 1936 1934 trailingObjects.clear(); 1937 addMidpoint(lineMidpointState, InlineIterator(0, o, 0)); // Stop ignoring spaces.1938 addMidpoint(lineMidpointState, InlineIterator(0, o, 0)); // Start ignoring again.1939 } else if (style()->collapseWhiteSpace() && resolver.position().m_obj == o1940 && shouldSkipWhitespaceAfterStartObject(this, o, lineMidpointState)) {1935 addMidpoint(lineMidpointState, InlineIterator(0, current.m_obj, 0)); // Stop ignoring spaces. 1936 addMidpoint(lineMidpointState, InlineIterator(0, current.m_obj, 0)); // Start ignoring again. 1937 } else if (style()->collapseWhiteSpace() && resolver.position().m_obj == current.m_obj 1938 && shouldSkipWhitespaceAfterStartObject(this, current.m_obj, lineMidpointState)) { 1941 1939 // Like with list markers, we start ignoring spaces to make sure that any 1942 1940 // additional spaces we see will be discarded. … … 1948 1946 1949 1947 width.addUncommittedWidth(borderPaddingMarginStart(flowBox) + borderPaddingMarginEnd(flowBox)); 1950 } else if ( o->isReplaced()) {1951 RenderBox* replacedBox = toRenderBox( o);1948 } else if (current.m_obj->isReplaced()) { 1949 RenderBox* replacedBox = toRenderBox(current.m_obj); 1952 1950 1953 1951 // Break on replaced elements if either has normal white-space. 1954 if ((autoWrap || RenderStyle::autoWrap(lastWS)) && (! o->isImage() || allowImagesToBreak)) {1952 if ((autoWrap || RenderStyle::autoWrap(lastWS)) && (!current.m_obj->isImage() || allowImagesToBreak)) { 1955 1953 width.commit(); 1956 lBreak.moveToStartOf( o);1954 lBreak.moveToStartOf(current.m_obj); 1957 1955 } 1958 1956 1959 1957 if (ignoringSpaces) 1960 addMidpoint(lineMidpointState, InlineIterator(0, o, 0));1958 addMidpoint(lineMidpointState, InlineIterator(0, current.m_obj, 0)); 1961 1959 1962 1960 lineInfo.setEmpty(false); … … 1968 1966 // Optimize for a common case. If we can't find whitespace after the list 1969 1967 // item, then this is all moot. 1970 int replacedLogicalWidth = logicalWidthForChild(replacedBox) + marginStartForChild(replacedBox) + marginEndForChild(replacedBox) + inlineLogicalWidth( o);1971 if ( o->isListMarker()) {1972 if (style()->collapseWhiteSpace() && shouldSkipWhitespaceAfterStartObject(this, o, lineMidpointState)) {1968 int replacedLogicalWidth = logicalWidthForChild(replacedBox) + marginStartForChild(replacedBox) + marginEndForChild(replacedBox) + inlineLogicalWidth(current.m_obj); 1969 if (current.m_obj->isListMarker()) { 1970 if (style()->collapseWhiteSpace() && shouldSkipWhitespaceAfterStartObject(this, current.m_obj, lineMidpointState)) { 1973 1971 // Like with inline flows, we start ignoring spaces to make sure that any 1974 1972 // additional spaces we see will be discarded. … … 1977 1975 ignoringSpaces = true; 1978 1976 } 1979 if (toRenderListMarker( o)->isInside())1977 if (toRenderListMarker(current.m_obj)->isInside()) 1980 1978 width.addUncommittedWidth(replacedLogicalWidth); 1981 1979 } else 1982 1980 width.addUncommittedWidth(replacedLogicalWidth); 1983 if ( o->isRubyRun())1984 width.applyOverhang(toRenderRubyRun( o), last, next);1985 } else if ( o->isText()) {1986 if (! pos)1981 if (current.m_obj->isRubyRun()) 1982 width.applyOverhang(toRenderRubyRun(current.m_obj), last, next); 1983 } else if (current.m_obj->isText()) { 1984 if (!current.m_pos) 1987 1985 appliedStartWidth = false; 1988 1986 1989 RenderText* t = toRenderText( o);1987 RenderText* t = toRenderText(current.m_obj); 1990 1988 1991 1989 #if ENABLE(SVG) … … 1994 1992 1995 1993 RenderStyle* style = t->style(lineInfo.isFirstLine()); 1996 if (style->hasTextCombine() && o->isCombineText()) 1997 toRenderCombineText(o)->combineText(); 1998 1999 int strlen = t->textLength(); 2000 int len = strlen - pos; 2001 const UChar* str = t->characters(); 1994 if (style->hasTextCombine() && current.m_obj->isCombineText()) 1995 toRenderCombineText(current.m_obj)->combineText(); 2002 1996 2003 1997 const Font& f = style->font(); … … 2005 1999 bool canHyphenate = style->hyphens() == HyphensAuto && WebCore::canHyphenate(style->locale()); 2006 2000 2007 int lastSpace = pos;2008 float wordSpacing = o->style()->wordSpacing();2001 int lastSpace = current.m_pos; 2002 float wordSpacing = current.m_obj->style()->wordSpacing(); 2009 2003 float lastSpaceWordSpacing = 0; 2010 2004 … … 2013 2007 float wordTrailingSpaceWidth = f.typesettingFeatures() & Kerning ? f.width(TextRun(&space, 1)) + wordSpacing : 0; 2014 2008 2015 float wrapW = width.uncommittedWidth() + inlineLogicalWidth( o, !appliedStartWidth, true);2009 float wrapW = width.uncommittedWidth() + inlineLogicalWidth(current.m_obj, !appliedStartWidth, true); 2016 2010 float charWidth = 0; 2017 bool breakNBSP = autoWrap && o->style()->nbspMode() == SPACE;2011 bool breakNBSP = autoWrap && current.m_obj->style()->nbspMode() == SPACE; 2018 2012 // Auto-wrapping text should wrap in the middle of a word only if it could not wrap before the word, 2019 2013 // which is only possible if the word is the first thing on the line, that is, if |w| is zero. 2020 bool breakWords = o->style()->breakWords() && ((autoWrap && !width.committedWidth()) || currWS == PRE);2014 bool breakWords = current.m_obj->style()->breakWords() && ((autoWrap && !width.committedWidth()) || currWS == PRE); 2021 2015 bool midWordBreak = false; 2022 bool breakAll = o->style()->wordBreak() == BreakAllWordBreak && autoWrap;2016 bool breakAll = current.m_obj->style()->wordBreak() == BreakAllWordBreak && autoWrap; 2023 2017 float hyphenWidth = 0; 2024 2018 2025 2019 if (t->isWordBreak()) { 2026 2020 width.commit(); 2027 lBreak.moveToStartOf( o);2028 ASSERT( !len);2029 } 2030 2031 while (len) {2021 lBreak.moveToStartOf(current.m_obj); 2022 ASSERT(current.m_pos == t->textLength()); 2023 } 2024 2025 for (; current.m_pos < t->textLength(); current.fastIncrementInTextNode()) { 2032 2026 bool previousCharacterIsSpace = currentCharacterIsSpace; 2033 2027 bool previousCharacterIsWS = currentCharacterIsWS; 2034 UChar c = str[pos];2028 UChar c = current.current(); 2035 2029 currentCharacterIsSpace = c == ' ' || c == '\t' || (!preserveNewline && (c == '\n')); 2036 2030 … … 2050 2044 if ((breakAll || breakWords) && !midWordBreak) { 2051 2045 wrapW += charWidth; 2052 charWidth = textWidth(t, pos, 1, f, width.committedWidth() + wrapW, isFixedPitch, collapseWhiteSpace);2046 charWidth = textWidth(t, current.m_pos, 1, f, width.committedWidth() + wrapW, isFixedPitch, collapseWhiteSpace); 2053 2047 midWordBreak = width.committedWidth() + wrapW + charWidth > width.availableWidth(); 2054 2048 } … … 2056 2050 if (lineBreakIteratorInfo.first != t) { 2057 2051 lineBreakIteratorInfo.first = t; 2058 lineBreakIteratorInfo.second.reset( str, strlen);2052 lineBreakIteratorInfo.second.reset(t->characters(), t->textLength()); 2059 2053 } 2060 2054 2061 bool betweenWords = c == '\n' || (currWS != PRE && !atStart && isBreakable(lineBreakIteratorInfo.second, pos, nextBreakable, breakNBSP) && (style->hyphens() != HyphensNone || (pos && str[pos - 1] != softHyphen))); 2055 bool betweenWords = c == '\n' || (currWS != PRE && !atStart && isBreakable(lineBreakIteratorInfo.second, current.m_pos, current.m_nextBreakablePosition, breakNBSP) 2056 && (style->hyphens() != HyphensNone || (current.previousInSameNode() != softHyphen))); 2062 2057 2063 2058 if (betweenWords || midWordBreak) { … … 2069 2064 ignoringSpaces = false; 2070 2065 lastSpaceWordSpacing = 0; 2071 lastSpace = pos; // e.g., "Foo goo", don't add in any of the ignored spaces.2072 addMidpoint(lineMidpointState, InlineIterator(0, o,pos));2066 lastSpace = current.m_pos; // e.g., "Foo goo", don't add in any of the ignored spaces. 2067 addMidpoint(lineMidpointState, InlineIterator(0, current.m_obj, current.m_pos)); 2073 2068 stoppedIgnoringSpaces = true; 2074 2069 } else { 2075 2070 // Just keep ignoring these spaces. 2076 pos++;2077 len--;2078 2071 continue; 2079 2072 } … … 2082 2075 float additionalTmpW; 2083 2076 if (wordTrailingSpaceWidth && currentCharacterIsSpace) 2084 additionalTmpW = textWidth(t, lastSpace, pos + 1 - lastSpace, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace) - wordTrailingSpaceWidth + lastSpaceWordSpacing;2077 additionalTmpW = textWidth(t, lastSpace, current.m_pos + 1 - lastSpace, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace) - wordTrailingSpaceWidth + lastSpaceWordSpacing; 2085 2078 else 2086 additionalTmpW = textWidth(t, lastSpace, pos - lastSpace, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace) + lastSpaceWordSpacing;2079 additionalTmpW = textWidth(t, lastSpace, current.m_pos - lastSpace, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace) + lastSpaceWordSpacing; 2087 2080 width.addUncommittedWidth(additionalTmpW); 2088 2081 if (!appliedStartWidth) { 2089 width.addUncommittedWidth(inlineLogicalWidth( o, true, false));2082 width.addUncommittedWidth(inlineLogicalWidth(current.m_obj, true, false)); 2090 2083 appliedStartWidth = true; 2091 2084 } … … 2100 2093 // as candidate width for this line. 2101 2094 bool lineWasTooWide = false; 2102 if (width.fitsOnLine() && currentCharacterIsWS && o->style()->breakOnlyAfterWhiteSpace() && !midWordBreak) {2103 float charWidth = textWidth(t, pos, 1, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace) + (applyWordSpacing ? wordSpacing : 0);2095 if (width.fitsOnLine() && currentCharacterIsWS && current.m_obj->style()->breakOnlyAfterWhiteSpace() && !midWordBreak) { 2096 float charWidth = textWidth(t, current.m_pos, 1, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace) + (applyWordSpacing ? wordSpacing : 0); 2104 2097 // Check if line is too big even without the extra space 2105 2098 // at the end of the line. If it is not, do nothing. … … 2109 2102 if (!width.fitsOnLine(charWidth)) { 2110 2103 lineWasTooWide = true; 2111 lBreak.moveTo( o, pos, nextBreakable);2104 lBreak.moveTo(current.m_obj, current.m_pos, current.m_nextBreakablePosition); 2112 2105 skipTrailingWhitespace(lBreak, lineInfo); 2113 2106 } … … 2115 2108 if (lineWasTooWide || !width.fitsOnLine()) { 2116 2109 if (canHyphenate && !width.fitsOnLine()) { 2117 tryHyphenating(t, f, style->locale(), style->hyphenationLimitBefore(), style->hyphenationLimitAfter(), lastSpace, pos, width.currentWidth() - additionalTmpW, width.availableWidth(), isFixedPitch, collapseWhiteSpace, lastSpaceWordSpacing, lBreak, nextBreakable, hyphenated);2110 tryHyphenating(t, f, style->locale(), style->hyphenationLimitBefore(), style->hyphenationLimitAfter(), lastSpace, current.m_pos, width.currentWidth() - additionalTmpW, width.availableWidth(), isFixedPitch, collapseWhiteSpace, lastSpaceWordSpacing, lBreak, current.m_nextBreakablePosition, hyphenated); 2118 2111 if (hyphenated) 2119 2112 goto end; 2120 2113 } 2121 2114 if (lBreak.atTextParagraphSeparator()) { 2122 if (!stoppedIgnoringSpaces && pos > 0) {2115 if (!stoppedIgnoringSpaces && current.m_pos > 0) { 2123 2116 // We need to stop right before the newline and then start up again. 2124 addMidpoint(lineMidpointState, InlineIterator(0, o,pos - 1)); // Stop2125 addMidpoint(lineMidpointState, InlineIterator(0, o,pos)); // Start2117 addMidpoint(lineMidpointState, InlineIterator(0, current.m_obj, current.m_pos - 1)); // Stop 2118 addMidpoint(lineMidpointState, InlineIterator(0, current.m_obj, current.m_pos)); // Start 2126 2119 } 2127 2120 lBreak.increment(); … … 2143 2136 2144 2137 if (c == '\n' && preserveNewline) { 2145 if (!stoppedIgnoringSpaces && pos > 0) {2138 if (!stoppedIgnoringSpaces && current.m_pos > 0) { 2146 2139 // We need to stop right before the newline and then start up again. 2147 addMidpoint(lineMidpointState, InlineIterator(0, o,pos - 1)); // Stop2148 addMidpoint(lineMidpointState, InlineIterator(0, o,pos)); // Start2140 addMidpoint(lineMidpointState, InlineIterator(0, current.m_obj, current.m_pos - 1)); // Stop 2141 addMidpoint(lineMidpointState, InlineIterator(0, current.m_obj, current.m_pos)); // Start 2149 2142 } 2150 lBreak.moveTo( o, pos, nextBreakable);2143 lBreak.moveTo(current.m_obj, current.m_pos, current.m_nextBreakablePosition); 2151 2144 lBreak.increment(); 2152 2145 lineInfo.setPreviousLineBrokeCleanly(true); … … 2157 2150 width.commit(); 2158 2151 wrapW = 0; 2159 lBreak.moveTo( o, pos, nextBreakable);2152 lBreak.moveTo(current.m_obj, current.m_pos, current.m_nextBreakablePosition); 2160 2153 // Auto-wrapping text should not wrap in the middle of a word once it has had an 2161 2154 // opportunity to break after a word. … … 2166 2159 // Remember this as a breakable position in case 2167 2160 // adding the end width forces a break. 2168 lBreak.moveTo( o, pos, nextBreakable);2161 lBreak.moveTo(current.m_obj, current.m_pos, current.m_nextBreakablePosition); 2169 2162 midWordBreak &= (breakWords || breakAll); 2170 2163 } … … 2172 2165 if (betweenWords) { 2173 2166 lastSpaceWordSpacing = applyWordSpacing ? wordSpacing : 0; 2174 lastSpace = pos;2167 lastSpace = current.m_pos; 2175 2168 } 2176 2169 2177 if (!ignoringSpaces && o->style()->collapseWhiteSpace()) {2170 if (!ignoringSpaces && current.m_obj->style()->collapseWhiteSpace()) { 2178 2171 // If we encounter a newline, or if we encounter a 2179 2172 // second space, we need to go ahead and break up this … … 2193 2186 ignoringSpaces = false; 2194 2187 lastSpaceWordSpacing = applyWordSpacing ? wordSpacing : 0; 2195 lastSpace = pos; // e.g., "Foo goo", don't add in any of the ignored spaces.2196 addMidpoint(lineMidpointState, InlineIterator(0, o,pos));2188 lastSpace = current.m_pos; // e.g., "Foo goo", don't add in any of the ignored spaces. 2189 addMidpoint(lineMidpointState, InlineIterator(0, current.m_obj, current.m_pos)); 2197 2190 } 2198 2191 2199 2192 #if ENABLE(SVG) 2200 if (isSVGText && pos > 0) {2193 if (isSVGText && current.m_pos > 0) { 2201 2194 // Force creation of new InlineBoxes for each absolute positioned character (those that start new text chunks). 2202 if (static_cast<RenderSVGInlineText*>(t)->characterStartsNewTextChunk( pos)) {2203 addMidpoint(lineMidpointState, InlineIterator(0, o,pos - 1));2204 addMidpoint(lineMidpointState, InlineIterator(0, o,pos));2195 if (static_cast<RenderSVGInlineText*>(t)->characterStartsNewTextChunk(current.m_pos)) { 2196 addMidpoint(lineMidpointState, InlineIterator(0, current.m_obj, current.m_pos - 1)); 2197 addMidpoint(lineMidpointState, InlineIterator(0, current.m_obj, current.m_pos)); 2205 2198 } 2206 2199 } … … 2208 2201 2209 2202 if (currentCharacterIsSpace && !previousCharacterIsSpace) { 2210 ignoreStart.m_obj = o;2211 ignoreStart.m_pos = pos;2203 ignoreStart.m_obj = current.m_obj; 2204 ignoreStart.m_pos = current.m_pos; 2212 2205 } 2213 2206 2214 2207 if (!currentCharacterIsWS && previousCharacterIsWS) { 2215 if (autoWrap && o->style()->breakOnlyAfterWhiteSpace())2216 lBreak.moveTo( o, pos, nextBreakable);2208 if (autoWrap && current.m_obj->style()->breakOnlyAfterWhiteSpace()) 2209 lBreak.moveTo(current.m_obj, current.m_pos, current.m_nextBreakablePosition); 2217 2210 } 2218 2211 2219 2212 if (collapseWhiteSpace && currentCharacterIsSpace && !ignoringSpaces) 2220 trailingObjects.setTrailingWhitespace(static_cast<RenderText*>( o));2221 else if (! o->style()->collapseWhiteSpace() || !currentCharacterIsSpace)2213 trailingObjects.setTrailingWhitespace(static_cast<RenderText*>(current.m_obj)); 2214 else if (!current.m_obj->style()->collapseWhiteSpace() || !currentCharacterIsSpace) 2222 2215 trailingObjects.clear(); 2223 2216 2224 pos++;2225 len--;2226 2217 atStart = false; 2227 2218 } 2228 2219 2229 // IMPORTANT: pos is > length here!2230 float additionalTmpW = ignoringSpaces ? 0 : textWidth(t, lastSpace, pos - lastSpace, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace) + lastSpaceWordSpacing;2231 width.addUncommittedWidth(additionalTmpW + inlineLogicalWidth( o, !appliedStartWidth, true));2220 // IMPORTANT: current.m_pos is > length here! 2221 float additionalTmpW = ignoringSpaces ? 0 : textWidth(t, lastSpace, current.m_pos - lastSpace, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace) + lastSpaceWordSpacing; 2222 width.addUncommittedWidth(additionalTmpW + inlineLogicalWidth(current.m_obj, !appliedStartWidth, true)); 2232 2223 2233 2224 if (!width.fitsOnLine()) { 2234 2225 if (canHyphenate) 2235 tryHyphenating(t, f, style->locale(), style->hyphenationLimitBefore(), style->hyphenationLimitAfter(), lastSpace, pos, width.currentWidth() - additionalTmpW, width.availableWidth(), isFixedPitch, collapseWhiteSpace, lastSpaceWordSpacing, lBreak, nextBreakable, hyphenated);2226 tryHyphenating(t, f, style->locale(), style->hyphenationLimitBefore(), style->hyphenationLimitAfter(), lastSpace, current.m_pos, width.currentWidth() - additionalTmpW, width.availableWidth(), isFixedPitch, collapseWhiteSpace, lastSpaceWordSpacing, lBreak, current.m_nextBreakablePosition, hyphenated); 2236 2227 2237 2228 if (!hyphenated && lBreak.m_obj && lBreak.m_pos && lBreak.m_obj->isText() && toRenderText(lBreak.m_obj)->textLength() && toRenderText(lBreak.m_obj)->characters()[lBreak.m_pos - 1] == softHyphen && style->hyphens() != HyphensNone) … … 2247 2238 if (width.committedWidth() && !width.fitsOnLine() && lBreak.m_obj && currWS == NOWRAP) 2248 2239 checkForBreak = true; 2249 else if (next && o->isText() && next->isText() && !next->isBR()) {2240 else if (next && current.m_obj->isText() && next->isText() && !next->isBR()) { 2250 2241 if (autoWrap || (next->style()->autoWrap())) { 2251 2242 if (currentCharacterIsSpace) … … 2278 2269 if (checkForBreak && !width.fitsOnLine()) { 2279 2270 // if we have floats, try to get below them. 2280 if (currentCharacterIsSpace && !ignoringSpaces && o->style()->collapseWhiteSpace())2271 if (currentCharacterIsSpace && !ignoringSpaces && current.m_obj->style()->collapseWhiteSpace()) 2281 2272 trailingObjects.clear(); 2282 2273 … … 2293 2284 } 2294 2285 2295 if (! o->isFloatingOrPositioned()) {2296 last = o;2286 if (!current.m_obj->isFloatingOrPositioned()) { 2287 last = current.m_obj; 2297 2288 if (last->isReplaced() && autoWrap && (!last->isImage() || allowImagesToBreak) && (!last->isListMarker() || toRenderListMarker(last)->isInside())) { 2298 2289 width.commit(); … … 2300 2291 } 2301 2292 } 2302 2303 o = next;2304 nextBreakable = -1;2305 2293 2306 2294 // Clear out our character space bool, since inline <pre>s don't collapse whitespace … … 2309 2297 currentCharacterIsSpace = false; 2310 2298 2311 pos = 0;2299 current.moveToStartOf(next); 2312 2300 atStart = false; 2313 2301 } … … 2321 2309 if (style()->whiteSpace() == PRE) { 2322 2310 // FIXME: Don't really understand this case. 2323 if ( pos != 0) {2311 if (current.m_pos) { 2324 2312 // FIXME: This should call moveTo which would clear m_nextBreakablePosition 2325 2313 // this code as-is is likely wrong. 2326 lBreak.m_obj = o;2327 lBreak.m_pos = pos - 1;2314 lBreak.m_obj = current.m_obj; 2315 lBreak.m_pos = current.m_pos - 1; 2328 2316 } else 2329 2317 lBreak.moveTo(last, last->isText() ? last->length() : 0); … … 2332 2320 // There's no room at all. We just have to be on this line, 2333 2321 // even though we'll spill out. 2334 lBreak.moveTo( o,pos);2322 lBreak.moveTo(current.m_obj, current.m_pos); 2335 2323 } 2336 2324 }
Note: See TracChangeset
for help on using the changeset viewer.