Chromium Code Reviews| 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 17 matching lines...) Expand all Loading... | |
| 28 #include "core/rendering/RenderText.h" | 28 #include "core/rendering/RenderText.h" |
| 29 #include "wtf/StdLibExtras.h" | 29 #include "wtf/StdLibExtras.h" |
| 30 | 30 |
| 31 namespace WebCore { | 31 namespace WebCore { |
| 32 | 32 |
| 33 // This class is used to RenderInline subtrees, stepping by character within the | 33 // This class is used to RenderInline subtrees, stepping by character within the |
| 34 // text children. InlineIterator will use bidiNext to find the next RenderText | 34 // text children. InlineIterator will use bidiNext to find the next RenderText |
| 35 // optionally notifying a BidiResolver every time it steps into/out of a RenderI nline. | 35 // optionally notifying a BidiResolver every time it steps into/out of a RenderI nline. |
| 36 class InlineIterator { | 36 class InlineIterator { |
| 37 public: | 37 public: |
| 38 enum IncrementRule { | |
| 39 FastIncrementInlineRenderer, | |
| 40 FastIncrementInTextNode | |
| 41 }; | |
| 42 | |
| 38 InlineIterator() | 43 InlineIterator() |
| 39 : m_root(0) | 44 : m_root(0) |
| 40 , m_obj(0) | 45 , m_obj(0) |
| 41 , m_pos(0) | 46 , m_pos(0) |
| 42 , m_nextBreakablePosition(-1) | 47 , m_nextBreakablePosition(-1) |
| 43 { | 48 { |
| 44 } | 49 } |
| 45 | 50 |
| 46 InlineIterator(RenderObject* root, RenderObject* o, unsigned p) | 51 InlineIterator(RenderObject* root, RenderObject* o, unsigned p) |
| 47 : m_root(root) | 52 : m_root(root) |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 63 m_obj = object; | 68 m_obj = object; |
| 64 m_pos = offset; | 69 m_pos = offset; |
| 65 m_nextBreakablePosition = nextBreak; | 70 m_nextBreakablePosition = nextBreak; |
| 66 } | 71 } |
| 67 | 72 |
| 68 RenderObject* object() const { return m_obj; } | 73 RenderObject* object() const { return m_obj; } |
| 69 unsigned offset() const { return m_pos; } | 74 unsigned offset() const { return m_pos; } |
| 70 RenderObject* root() const { return m_root; } | 75 RenderObject* root() const { return m_root; } |
| 71 | 76 |
| 72 void fastIncrementInTextNode(); | 77 void fastIncrementInTextNode(); |
| 73 void increment(InlineBidiResolver* = 0); | 78 void fastIncrementInline(); |
|
eseidel
2013/09/03 23:28:40
I don't see this used anywhere?
| |
| 79 void increment(InlineBidiResolver* = 0, IncrementRule = FastIncrementInTextN ode); | |
| 74 bool atEnd() const; | 80 bool atEnd() const; |
| 75 | 81 |
| 76 inline bool atTextParagraphSeparator() | 82 inline bool atTextParagraphSeparator() |
| 77 { | 83 { |
| 78 return m_obj && m_obj->preservesNewline() && m_obj->isText() && toRender Text(m_obj)->textLength() | 84 return m_obj && m_obj->preservesNewline() && m_obj->isText() && toRender Text(m_obj)->textLength() |
| 79 && !toRenderText(m_obj)->isWordBreak() && toRenderText(m_obj)->chara cterAt(m_pos) == '\n'; | 85 && !toRenderText(m_obj)->isWordBreak() && toRenderText(m_obj)->chara cterAt(m_pos) == '\n'; |
| 80 } | 86 } |
| 81 | 87 |
| 82 inline bool atParagraphSeparator() | 88 inline bool atParagraphSeparator() |
| 83 { | 89 { |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 345 // FIXME: Support SkipEmptyInlines and observer parameters. | 351 // FIXME: Support SkipEmptyInlines and observer parameters. |
| 346 m_current = bidiNextIncludingEmptyInlines(m_root, m_current, &m_atEndOfI nline); | 352 m_current = bidiNextIncludingEmptyInlines(m_root, m_current, &m_atEndOfI nline); |
| 347 return m_current; | 353 return m_current; |
| 348 } | 354 } |
| 349 private: | 355 private: |
| 350 RenderObject* m_root; | 356 RenderObject* m_root; |
| 351 RenderObject* m_current; | 357 RenderObject* m_current; |
| 352 bool m_atEndOfInline; | 358 bool m_atEndOfInline; |
| 353 }; | 359 }; |
| 354 | 360 |
| 355 inline void InlineIterator::increment(InlineBidiResolver* resolver) | 361 inline void InlineIterator::increment(InlineBidiResolver* resolver, IncrementRul e rule) |
| 356 { | 362 { |
| 357 if (!m_obj) | 363 if (!m_obj) |
| 358 return; | 364 return; |
| 359 if (m_obj->isText()) { | 365 if (m_obj->isText() && rule == FastIncrementInTextNode) { |
| 360 fastIncrementInTextNode(); | 366 fastIncrementInTextNode(); |
| 361 if (m_pos < toRenderText(m_obj)->textLength()) | 367 if (m_pos < toRenderText(m_obj)->textLength()) |
| 362 return; | 368 return; |
| 363 } | 369 } |
| 364 // bidiNext can return 0, so use moveTo instead of moveToStartOf | 370 // bidiNext can return 0, so use moveTo instead of moveToStartOf |
| 365 moveTo(bidiNextSkippingEmptyInlines(m_root, m_obj, resolver), 0); | 371 moveTo(bidiNextSkippingEmptyInlines(m_root, m_obj, resolver), 0); |
| 366 } | 372 } |
| 367 | 373 |
| 368 inline bool InlineIterator::atEnd() const | 374 inline bool InlineIterator::atEnd() const |
| 369 { | 375 { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 542 m_sor = m_eor; | 548 m_sor = m_eor; |
| 543 } | 549 } |
| 544 | 550 |
| 545 m_direction = WTF::Unicode::OtherNeutral; | 551 m_direction = WTF::Unicode::OtherNeutral; |
| 546 m_status.eor = WTF::Unicode::OtherNeutral; | 552 m_status.eor = WTF::Unicode::OtherNeutral; |
| 547 } | 553 } |
| 548 | 554 |
| 549 } | 555 } |
| 550 | 556 |
| 551 #endif // InlineIterator_h | 557 #endif // InlineIterator_h |
| OLD | NEW |