Changeset 93559 in webkit
- Timestamp:
- Aug 22, 2011 4:34:31 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r93558 r93559 1 2011-08-22 Eric Seidel <eric@webkit.org> 2 3 Attempt to clean up bidiNext usage 4 https://bugs.webkit.org/show_bug.cgi?id=66721 5 6 Reviewed by Ryosuke Niwa. 7 8 bidiNext and bidiFirst are horribly confusing. 9 Even worse is that bidiNext takes a bunch of mutually exclusive options. 10 It appears that there is a "return me every inline, even if its empty" 11 mode which is only used for simplified inline layout in RenderBlock.cpp. 12 To support that mode, there is a endOfInline pointer which keeps track 13 of if we just returned at the end of an inline to so we don't get stuck in 14 and empty inline (unable to distinguish the start from the finish). 15 16 The actual bidi/line-layout code uses bidiNext/bidiFirst in a "skip empty inlines" 17 mode. (Since empty inlines do not participate in the Unicode Bidi Algorithm.) 18 19 This change renames bidiNext to bidiNextShared (still a horrible name) and moves 20 all callers to explicitly calling bidiNextSkippingEmptyInlines or bidiNextIncludingEmptyInlines. 21 It becomes obvious which code uses which. 22 23 In reviewing this code be aware that the previous bidiNext default was to "skip empty inlines" (skipInlines = true). 24 Thus any caller who didn't pass true/false should now be calling bidiNextSkippingEmptyInlines instead. 25 26 No functional change, thus no tests. 27 28 * rendering/InlineIterator.h: 29 (WebCore::bidiNextShared): 30 (WebCore::bidiNextSkippingEmptyInlines): 31 (WebCore::bidiNextIncludingEmptyInlines): 32 (WebCore::bidiFirstSkippingEmptyInlines): 33 (WebCore::bidiFirstIncludingEmptyInlines): 34 (WebCore::InlineWalker::InlineWalker): 35 (WebCore::InlineWalker::advance): 36 (WebCore::InlineIterator::increment): 37 (WebCore::InlineBidiResolver::appendRun): 38 * rendering/RenderBlockLineLayout.cpp: 39 (WebCore::RenderBlock::determineStartPosition): 40 (WebCore::shouldSkipWhitespaceAfterStartObject): 41 (WebCore::RenderBlock::LineBreaker::nextLineBreak): 42 1 43 2011-08-22 David Levin <levin@chromium.org> 2 44 -
trunk/Source/WebCore/rendering/InlineIterator.h
r88122 r93559 140 140 } 141 141 142 // This enum is only used for bidiNextShared() 143 enum EmptyInlineBehavior { 144 SkipEmptyInlines, 145 IncludeEmptyInlines, 146 }; 147 142 148 // FIXME: This function is misleadingly named. It has little to do with bidi. 143 149 // This function will iterate over inlines within a block, optionally notifying 144 150 // a bidi resolver as it enters/exits inlines (so it can push/pop embedding levels). 145 static inline RenderObject* bidiNext (RenderObject* root, RenderObject* current, InlineBidiResolver* resolver = 0, bool skipInlines = true, bool* endOfInlinePtr = 0)151 static inline RenderObject* bidiNextShared(RenderObject* root, RenderObject* current, InlineBidiResolver* resolver = 0, EmptyInlineBehavior emptyInlineBehavior = SkipEmptyInlines, bool* endOfInlinePtr = 0) 146 152 { 147 153 RenderObject* next = 0; … … 160 166 if (!next) { 161 167 // If it is a renderer we care about, and we're doing our inline-walk, return it. 162 if ( !skipInlines && !oldEndOfInline && current->isRenderInline()) {168 if (emptyInlineBehavior == IncludeEmptyInlines && !oldEndOfInline && current->isRenderInline()) { 163 169 next = current; 164 170 endOfInline = true; … … 176 182 177 183 current = current->parent(); 178 if ( !skipInlines && current && current != root && current->isRenderInline()) {184 if (emptyInlineBehavior == IncludeEmptyInlines && current && current != root && current->isRenderInline()) { 179 185 next = current; 180 186 endOfInline = true; … … 188 194 189 195 if (isIteratorTarget(next) 190 || (( !skipInlines || !next->firstChild()) // Always return EMPTY inlines.196 || ((emptyInlineBehavior == IncludeEmptyInlines || !next->firstChild()) // Always return EMPTY inlines. 191 197 && next->isRenderInline())) 192 198 break; … … 200 206 } 201 207 202 static inline RenderObject* bidiFirstSkippingInlines(RenderObject* root, InlineBidiResolver* resolver) 208 static inline RenderObject* bidiNextSkippingEmptyInlines(RenderObject* root, RenderObject* current, InlineBidiResolver* observer = 0) 209 { 210 // The SkipEmptyInlines callers never care about endOfInlinePtr. 211 return bidiNextShared(root, current, observer, SkipEmptyInlines); 212 } 213 214 static inline RenderObject* bidiNextIncludingEmptyInlines(RenderObject* root, RenderObject* current, bool* endOfInlinePtr = 0) 215 { 216 InlineBidiResolver* observer = 0; // Callers who include empty inlines, never use an observer. 217 return bidiNextShared(root, current, observer, IncludeEmptyInlines, endOfInlinePtr); 218 } 219 220 static inline RenderObject* bidiFirstSkippingEmptyInlines(RenderObject* root, InlineBidiResolver* resolver) 203 221 { 204 222 ASSERT(resolver); … … 210 228 notifyResolverEnteredObject(resolver, o); 211 229 if (o->firstChild()) 212 o = bidiNext (root, o, resolver, true);230 o = bidiNextSkippingEmptyInlines(root, o, resolver); 213 231 else { 214 232 // Never skip empty inlines. … … 221 239 // FIXME: Unify this with the bidiNext call above. 222 240 if (o && !isIteratorTarget(o)) 223 o = bidiNext (root, o, resolver, true);241 o = bidiNextSkippingEmptyInlines(root, o, resolver); 224 242 225 243 resolver->commitExplicitEmbedding(); … … 228 246 229 247 // FIXME: This method needs to be renamed when bidiNext finds a good name. 230 static inline RenderObject* bidiFirst NotSkippingInlines(RenderObject* root)248 static inline RenderObject* bidiFirstIncludingEmptyInlines(RenderObject* root) 231 249 { 232 250 RenderObject* o = root->firstChild(); … … 236 254 return o; 237 255 238 return bidiNext (root, o, 0, false);256 return bidiNextIncludingEmptyInlines(root, o); 239 257 } 240 258 … … 247 265 } 248 266 267 // FIXME: This is used by RenderBlock for simplified layout, and has nothing to do with bidi 268 // it shouldn't use functions called bidiFirst and bidiNext. 249 269 class InlineWalker { 250 270 public: … … 254 274 , m_atEndOfInline(false) 255 275 { 256 // FIXME: This class should be taught how to do the skipInlines codepath as well.257 m_current = bidiFirst NotSkippingInlines(m_root);276 // FIXME: This class should be taught how to do the SkipEmptyInlines codepath as well. 277 m_current = bidiFirstIncludingEmptyInlines(m_root); 258 278 } 259 279 … … 266 286 RenderObject* advance() 267 287 { 268 // FIXME: Eventually skipInlines and observer will be a members. 269 bool skipInlines = false; 270 InlineBidiResolver* observer = 0; 271 m_current = bidiNext(m_root, m_current, observer, skipInlines, &m_atEndOfInline); 288 // FIXME: Support SkipEmptyInlines and observer parameters. 289 m_current = bidiNextIncludingEmptyInlines(m_root, m_current, &m_atEndOfInline); 272 290 return m_current; 273 291 } … … 275 293 RenderObject* m_root; 276 294 RenderObject* m_current; 277 bool m_skipInlines;278 295 bool m_atEndOfInline; 279 296 }; … … 289 306 } 290 307 // bidiNext can return 0, so use moveTo instead of moveToStartOf 291 moveTo(bidiNext (m_root, m_obj, resolver), 0);308 moveTo(bidiNextSkippingEmptyInlines(m_root, m_obj, resolver), 0); 292 309 } 293 310 … … 344 361 RenderBlock::appendRunsForObject(m_runs, start, obj->length(), obj, *this); 345 362 start = 0; 346 obj = bidiNext (m_sor.root(), obj);363 obj = bidiNextSkippingEmptyInlines(m_sor.root(), obj); 347 364 } 348 365 if (obj) { -
trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp
r93421 r93559 1428 1428 } else { 1429 1429 TextDirection direction = style()->direction(); 1430 if (style()->unicodeBidi() == Plaintext) 1431 determineParagraphDirection(direction, InlineIterator(this, bidiFirstNotSkippingInlines(this), 0)); 1430 if (style()->unicodeBidi() == Plaintext) { 1431 // FIXME: Why does "unicode-bidi: plaintext" bidiFirstIncludingEmptyInlines when all other line layout code uses bidiFirstSkippingEmptyInlines? 1432 determineParagraphDirection(direction, InlineIterator(this, bidiFirstIncludingEmptyInlines(this), 0)); 1433 } 1432 1434 resolver.setStatus(BidiStatus(direction, style()->unicodeBidi() == Override)); 1433 resolver.setPosition(InlineIterator(this, bidiFirstSkipping Inlines(this, &resolver), 0));1435 resolver.setPosition(InlineIterator(this, bidiFirstSkippingEmptyInlines(this, &resolver), 0)); 1434 1436 } 1435 1437 return curr; … … 1647 1649 static bool shouldSkipWhitespaceAfterStartObject(RenderBlock* block, RenderObject* o, LineMidpointState& lineMidpointState) 1648 1650 { 1649 RenderObject* next = bidiNext (block, o);1651 RenderObject* next = bidiNextSkippingEmptyInlines(block, o); 1650 1652 if (next && !next->isBR() && next->isText() && toRenderText(next)->textLength() > 0) { 1651 1653 RenderText* nextText = toRenderText(next); … … 1984 1986 EWhiteSpace lastWS = currWS; 1985 1987 while (current.m_obj) { 1986 RenderObject* next = bidiNext (m_block, current.m_obj);1988 RenderObject* next = bidiNextSkippingEmptyInlines(m_block, current.m_obj); 1987 1989 if (next && next->parent() && !next->parent()->isDescendantOf(current.m_obj->parent())) 1988 1990 includeEndWidth = true;
Note: See TracChangeset
for help on using the changeset viewer.