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 18 matching lines...) Expand all Loading... |
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 { | 38 enum IncrementRule { |
39 FastIncrementInlineRenderer, | 39 FastIncrementInIsolatedRenderer, |
40 FastIncrementInTextNode | 40 FastIncrementInTextNode |
41 }; | 41 }; |
42 | 42 |
43 InlineIterator() | 43 InlineIterator() |
44 : m_root(0) | 44 : m_root(0) |
45 , m_obj(0) | 45 , m_obj(0) |
46 , m_pos(0) | 46 , m_pos(0) |
47 , m_nextBreakablePosition(-1) | 47 , m_nextBreakablePosition(-1) |
48 { | 48 { |
49 } | 49 } |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 private: | 354 private: |
355 RenderObject* m_root; | 355 RenderObject* m_root; |
356 RenderObject* m_current; | 356 RenderObject* m_current; |
357 bool m_atEndOfInline; | 357 bool m_atEndOfInline; |
358 }; | 358 }; |
359 | 359 |
360 inline void InlineIterator::increment(InlineBidiResolver* resolver, IncrementRul
e rule) | 360 inline void InlineIterator::increment(InlineBidiResolver* resolver, IncrementRul
e rule) |
361 { | 361 { |
362 if (!m_obj) | 362 if (!m_obj) |
363 return; | 363 return; |
364 if (m_obj->isText() && rule == FastIncrementInTextNode) { | 364 |
| 365 if (resolver && resolver->inIsolate() && rule == FastIncrementInIsolatedRend
erer) { |
| 366 moveTo(bidiNextSkippingEmptyInlines(m_root, m_obj, resolver), 0); |
| 367 return; |
| 368 } |
| 369 |
| 370 if (m_obj->isText()) { |
365 fastIncrementInTextNode(); | 371 fastIncrementInTextNode(); |
366 if (m_pos < toRenderText(m_obj)->textLength()) | 372 if (m_pos < toRenderText(m_obj)->textLength()) |
367 return; | 373 return; |
368 } | 374 } |
369 // bidiNext can return 0, so use moveTo instead of moveToStartOf | 375 // bidiNext can return 0, so use moveTo instead of moveToStartOf |
370 moveTo(bidiNextSkippingEmptyInlines(m_root, m_obj, resolver), 0); | 376 moveTo(bidiNextSkippingEmptyInlines(m_root, m_obj, resolver), 0); |
371 } | 377 } |
372 | 378 |
373 inline bool InlineIterator::atEnd() const | 379 inline bool InlineIterator::atEnd() const |
374 { | 380 { |
(...skipping 28 matching lines...) Expand all Loading... |
403 | 409 |
404 if (m_obj && m_obj->isListMarker()) | 410 if (m_obj && m_obj->isListMarker()) |
405 return m_obj->style()->isLeftToRightDirection() ? WTF::Unicode::LeftToRi
ght : WTF::Unicode::RightToLeft; | 411 return m_obj->style()->isLeftToRightDirection() ? WTF::Unicode::LeftToRi
ght : WTF::Unicode::RightToLeft; |
406 | 412 |
407 return WTF::Unicode::OtherNeutral; | 413 return WTF::Unicode::OtherNeutral; |
408 } | 414 } |
409 | 415 |
410 template<> | 416 template<> |
411 inline void InlineBidiResolver::increment() | 417 inline void InlineBidiResolver::increment() |
412 { | 418 { |
413 m_current.increment(this); | 419 m_current.increment(this, InlineIterator::FastIncrementInIsolatedRenderer); |
| 420 } |
| 421 |
| 422 template <> |
| 423 inline bool InlineBidiResolver::isEndOfParagraph(const InlineIterator& end) |
| 424 { |
| 425 bool inEndOfParagraph = m_current == end || m_current.atEnd() || (inIsolate(
) && m_current.m_obj == end.m_obj); |
| 426 if (inIsolate() && inEndOfParagraph) { |
| 427 m_current.moveTo(m_current.m_obj, end.m_pos, m_current.m_nextBreakablePo
sition); |
| 428 m_last = m_current; |
| 429 updateStatusLastFromCurrentDirection(WTF::Unicode::OtherNeutral); |
| 430 } |
| 431 return inEndOfParagraph; |
414 } | 432 } |
415 | 433 |
416 static inline bool isIsolatedInline(RenderObject* object) | 434 static inline bool isIsolatedInline(RenderObject* object) |
417 { | 435 { |
418 ASSERT(object); | 436 ASSERT(object); |
419 return object->isRenderInline() && isIsolated(object->style()->unicodeBidi()
); | 437 return object->isRenderInline() && isIsolated(object->style()->unicodeBidi()
); |
420 } | 438 } |
421 | 439 |
422 static inline RenderObject* highestContainingIsolateWithinRoot(RenderObject* obj
ect, RenderObject* root) | 440 static inline RenderObject* highestContainingIsolateWithinRoot(RenderObject* obj
ect, RenderObject* root) |
423 { | 441 { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 m_sor = m_eor; | 562 m_sor = m_eor; |
545 } | 563 } |
546 | 564 |
547 m_direction = WTF::Unicode::OtherNeutral; | 565 m_direction = WTF::Unicode::OtherNeutral; |
548 m_status.eor = WTF::Unicode::OtherNeutral; | 566 m_status.eor = WTF::Unicode::OtherNeutral; |
549 } | 567 } |
550 | 568 |
551 } | 569 } |
552 | 570 |
553 #endif // InlineIterator_h | 571 #endif // InlineIterator_h |
OLD | NEW |