| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010 Apple Inc. All right r
eserved. | 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010 Apple Inc. All right r
eserved. |
| 4 * Copyright (C) 2010 Google Inc. All rights reserved. | 4 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 // text children. InlineIterator will use bidiNext to find the next LayoutText | 36 // text children. InlineIterator will use bidiNext to find the next LayoutText |
| 37 // optionally notifying a BidiResolver every time it steps into/out of a LayoutI
nline. | 37 // optionally notifying a BidiResolver every time it steps into/out of a LayoutI
nline. |
| 38 class InlineIterator { | 38 class InlineIterator { |
| 39 public: | 39 public: |
| 40 enum IncrementRule { | 40 enum IncrementRule { |
| 41 FastIncrementInIsolatedLayout, | 41 FastIncrementInIsolatedLayout, |
| 42 FastIncrementInTextNode | 42 FastIncrementInTextNode |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 InlineIterator() | 45 InlineIterator() |
| 46 : m_root(0) | 46 : m_root(nullptr) |
| 47 , m_obj(0) | 47 , m_obj(nullptr) |
| 48 , m_nextBreakablePosition(-1) | 48 , m_nextBreakablePosition(-1) |
| 49 , m_pos(0) | 49 , m_pos(0) |
| 50 { | 50 { |
| 51 } | 51 } |
| 52 | 52 |
| 53 InlineIterator(LayoutObject* root, LayoutObject* o, unsigned p) | 53 InlineIterator(LayoutObject* root, LayoutObject* o, unsigned p) |
| 54 : m_root(root) | 54 : m_root(root) |
| 55 , m_obj(o) | 55 , m_obj(o) |
| 56 , m_nextBreakablePosition(-1) | 56 , m_nextBreakablePosition(-1) |
| 57 , m_pos(p) | 57 , m_pos(p) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 76 void setObject(LayoutObject* object) { m_obj = object; } | 76 void setObject(LayoutObject* object) { m_obj = object; } |
| 77 | 77 |
| 78 int nextBreakablePosition() const { return m_nextBreakablePosition; } | 78 int nextBreakablePosition() const { return m_nextBreakablePosition; } |
| 79 void setNextBreakablePosition(int position) { m_nextBreakablePosition = posi
tion; } | 79 void setNextBreakablePosition(int position) { m_nextBreakablePosition = posi
tion; } |
| 80 | 80 |
| 81 unsigned offset() const { return m_pos; } | 81 unsigned offset() const { return m_pos; } |
| 82 void setOffset(unsigned position) { m_pos = position; } | 82 void setOffset(unsigned position) { m_pos = position; } |
| 83 LayoutObject* root() const { return m_root; } | 83 LayoutObject* root() const { return m_root; } |
| 84 | 84 |
| 85 void fastIncrementInTextNode(); | 85 void fastIncrementInTextNode(); |
| 86 void increment(InlineBidiResolver* = 0, IncrementRule = FastIncrementInTextN
ode); | 86 void increment(InlineBidiResolver* = nullptr, IncrementRule = FastIncrementI
nTextNode); |
| 87 bool atEnd() const; | 87 bool atEnd() const; |
| 88 | 88 |
| 89 inline bool atTextParagraphSeparator() const | 89 inline bool atTextParagraphSeparator() const |
| 90 { | 90 { |
| 91 return m_obj && m_obj->preservesNewline() && m_obj->isText() && toLayout
Text(m_obj)->textLength() | 91 return m_obj && m_obj->preservesNewline() && m_obj->isText() && toLayout
Text(m_obj)->textLength() |
| 92 && !toLayoutText(m_obj)->isWordBreak() && toLayoutText(m_obj)->chara
cterAt(m_pos) == '\n'; | 92 && !toLayoutText(m_obj)->isWordBreak() && toLayoutText(m_obj)->chara
cterAt(m_pos) == '\n'; |
| 93 } | 93 } |
| 94 | 94 |
| 95 inline bool atParagraphSeparator() const | 95 inline bool atParagraphSeparator() const |
| 96 { | 96 { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 if (!isEmptyInline(curr)) | 200 if (!isEmptyInline(curr)) |
| 201 return false; | 201 return false; |
| 202 } | 202 } |
| 203 return true; | 203 return true; |
| 204 } | 204 } |
| 205 | 205 |
| 206 // FIXME: This function is misleadingly named. It has little to do with bidi. | 206 // FIXME: This function is misleadingly named. It has little to do with bidi. |
| 207 // This function will iterate over inlines within a block, optionally notifying | 207 // This function will iterate over inlines within a block, optionally notifying |
| 208 // a bidi resolver as it enters/exits inlines (so it can push/pop embedding leve
ls). | 208 // a bidi resolver as it enters/exits inlines (so it can push/pop embedding leve
ls). |
| 209 template <class Observer> | 209 template <class Observer> |
| 210 static inline LayoutObject* bidiNextShared(LayoutObject* root, LayoutObject* cur
rent, Observer* observer = 0, EmptyInlineBehavior emptyInlineBehavior = SkipEmpt
yInlines, bool* endOfInlinePtr = 0) | 210 static inline LayoutObject* bidiNextShared(LayoutObject* root, LayoutObject* cur
rent, Observer* observer = 0, EmptyInlineBehavior emptyInlineBehavior = SkipEmpt
yInlines, bool* endOfInlinePtr = nullptr) |
| 211 { | 211 { |
| 212 LayoutObject* next = 0; | 212 LayoutObject* next = nullptr; |
| 213 // oldEndOfInline denotes if when we last stopped iterating if we were at th
e end of an inline. | 213 // oldEndOfInline denotes if when we last stopped iterating if we were at th
e end of an inline. |
| 214 bool oldEndOfInline = endOfInlinePtr ? *endOfInlinePtr : false; | 214 bool oldEndOfInline = endOfInlinePtr ? *endOfInlinePtr : false; |
| 215 bool endOfInline = false; | 215 bool endOfInline = false; |
| 216 | 216 |
| 217 while (current) { | 217 while (current) { |
| 218 next = 0; | 218 next = 0; |
| 219 if (!oldEndOfInline && !isIteratorTarget(current)) { | 219 if (!oldEndOfInline && !isIteratorTarget(current)) { |
| 220 next = current->slowFirstChild(); | 220 next = current->slowFirstChild(); |
| 221 notifyObserverEnteredObject(observer, next); | 221 notifyObserverEnteredObject(observer, next); |
| 222 } | 222 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 template <class Observer> | 267 template <class Observer> |
| 268 static inline LayoutObject* bidiNextSkippingEmptyInlines(LayoutObject* root, Lay
outObject* current, Observer* observer) | 268 static inline LayoutObject* bidiNextSkippingEmptyInlines(LayoutObject* root, Lay
outObject* current, Observer* observer) |
| 269 { | 269 { |
| 270 // The SkipEmptyInlines callers never care about endOfInlinePtr. | 270 // The SkipEmptyInlines callers never care about endOfInlinePtr. |
| 271 return bidiNextShared(root, current, observer, SkipEmptyInlines); | 271 return bidiNextShared(root, current, observer, SkipEmptyInlines); |
| 272 } | 272 } |
| 273 | 273 |
| 274 // This makes callers cleaner as they don't have to specify a type for the obser
ver when not providing one. | 274 // This makes callers cleaner as they don't have to specify a type for the obser
ver when not providing one. |
| 275 static inline LayoutObject* bidiNextSkippingEmptyInlines(LayoutObject* root, Lay
outObject* current) | 275 static inline LayoutObject* bidiNextSkippingEmptyInlines(LayoutObject* root, Lay
outObject* current) |
| 276 { | 276 { |
| 277 InlineBidiResolver* observer = 0; | 277 InlineBidiResolver* observer = nullptr; |
| 278 return bidiNextSkippingEmptyInlines(root, current, observer); | 278 return bidiNextSkippingEmptyInlines(root, current, observer); |
| 279 } | 279 } |
| 280 | 280 |
| 281 static inline LayoutObject* bidiNextIncludingEmptyInlines(LayoutObject* root, La
youtObject* current, bool* endOfInlinePtr = 0) | 281 static inline LayoutObject* bidiNextIncludingEmptyInlines(LayoutObject* root, La
youtObject* current, bool* endOfInlinePtr = nullptr) |
| 282 { | 282 { |
| 283 InlineBidiResolver* observer = 0; // Callers who include empty inlines, neve
r use an observer. | 283 InlineBidiResolver* observer = nullptr; // Callers who include empty inlines
, never use an observer. |
| 284 return bidiNextShared(root, current, observer, IncludeEmptyInlines, endOfInl
inePtr); | 284 return bidiNextShared(root, current, observer, IncludeEmptyInlines, endOfInl
inePtr); |
| 285 } | 285 } |
| 286 | 286 |
| 287 static inline LayoutObject* bidiFirstSkippingEmptyInlines(LayoutBlockFlow* root,
BidiRunList<BidiRun>& runs, InlineBidiResolver* resolver = 0) | 287 static inline LayoutObject* bidiFirstSkippingEmptyInlines(LayoutBlockFlow* root,
BidiRunList<BidiRun>& runs, InlineBidiResolver* resolver = nullptr) |
| 288 { | 288 { |
| 289 LayoutObject* o = root->firstChild(); | 289 LayoutObject* o = root->firstChild(); |
| 290 if (!o) | 290 if (!o) |
| 291 return 0; | 291 return nullptr; |
| 292 | 292 |
| 293 if (o->isLayoutInline()) { | 293 if (o->isLayoutInline()) { |
| 294 notifyObserverEnteredObject(resolver, o); | 294 notifyObserverEnteredObject(resolver, o); |
| 295 if (!isEmptyInline(o)) { | 295 if (!isEmptyInline(o)) { |
| 296 o = bidiNextSkippingEmptyInlines(root, o, resolver); | 296 o = bidiNextSkippingEmptyInlines(root, o, resolver); |
| 297 } else { | 297 } else { |
| 298 // Never skip empty inlines. | 298 // Never skip empty inlines. |
| 299 if (resolver) | 299 if (resolver) |
| 300 resolver->commitExplicitEmbedding(runs); | 300 resolver->commitExplicitEmbedding(runs); |
| 301 return o; | 301 return o; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 331 if (m_pos < INT_MAX) | 331 if (m_pos < INT_MAX) |
| 332 m_pos++; | 332 m_pos++; |
| 333 } | 333 } |
| 334 | 334 |
| 335 // FIXME: This is used by LayoutBlockFlow for simplified layout, and has nothing
to do with bidi | 335 // FIXME: This is used by LayoutBlockFlow for simplified layout, and has nothing
to do with bidi |
| 336 // it shouldn't use functions called bidiFirst and bidiNext. | 336 // it shouldn't use functions called bidiFirst and bidiNext. |
| 337 class InlineWalker { | 337 class InlineWalker { |
| 338 public: | 338 public: |
| 339 InlineWalker(LayoutBlock* root) | 339 InlineWalker(LayoutBlock* root) |
| 340 : m_root(root) | 340 : m_root(root) |
| 341 , m_current(0) | 341 , m_current(nullptr) |
| 342 , m_atEndOfInline(false) | 342 , m_atEndOfInline(false) |
| 343 { | 343 { |
| 344 // FIXME: This class should be taught how to do the SkipEmptyInlines cod
epath as well. | 344 // FIXME: This class should be taught how to do the SkipEmptyInlines cod
epath as well. |
| 345 m_current = bidiFirstIncludingEmptyInlines(m_root); | 345 m_current = bidiFirstIncludingEmptyInlines(m_root); |
| 346 } | 346 } |
| 347 | 347 |
| 348 LayoutBlock* root() { return m_root; } | 348 LayoutBlock* root() { return m_root; } |
| 349 LayoutObject* current() { return m_current; } | 349 LayoutObject* current() { return m_current; } |
| 350 | 350 |
| 351 bool atEndOfInline() { return m_atEndOfInline; } | 351 bool atEndOfInline() { return m_atEndOfInline; } |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 m_sor = m_eor; | 737 m_sor = m_eor; |
| 738 } | 738 } |
| 739 | 739 |
| 740 m_direction = WTF::Unicode::OtherNeutral; | 740 m_direction = WTF::Unicode::OtherNeutral; |
| 741 m_status.eor = WTF::Unicode::OtherNeutral; | 741 m_status.eor = WTF::Unicode::OtherNeutral; |
| 742 } | 742 } |
| 743 | 743 |
| 744 } | 744 } |
| 745 | 745 |
| 746 #endif // InlineIterator_h | 746 #endif // InlineIterator_h |
| OLD | NEW |