| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2008 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 // abc^def where "^" represent |Position| | 63 // abc^def where "^" represent |Position| |
| 64 // When above text line wrapped after "abc" | 64 // When above text line wrapped after "abc" |
| 65 // abc| UPSTREAM |VisiblePosition| | 65 // abc| UPSTREAM |VisiblePosition| |
| 66 // |def DOWNSTREAM |VisiblePosition| | 66 // |def DOWNSTREAM |VisiblePosition| |
| 67 // | 67 // |
| 68 // NOTE: UPSTREAM affinity will be used only if pos is at end of a wrapped line, | 68 // NOTE: UPSTREAM affinity will be used only if pos is at end of a wrapped line, |
| 69 // otherwise it will be converted to DOWNSTREAM. | 69 // otherwise it will be converted to DOWNSTREAM. |
| 70 class CORE_EXPORT VisiblePosition final { | 70 class CORE_EXPORT VisiblePosition final { |
| 71 DISALLOW_ALLOCATION(); | 71 DISALLOW_ALLOCATION(); |
| 72 public: | 72 public: |
| 73 VisiblePosition() : m_affinity(VP_DEFAULT_AFFINITY) { } | 73 VisiblePosition(); |
| 74 | 74 |
| 75 // Node: Other than |createVisiblePosition()|, we should not use | 75 // Node: Other than |createVisiblePosition()|, we should not use |
| 76 // |createWithoutCanonicalization()|. | 76 // |createWithoutCanonicalization()|. |
| 77 static VisiblePosition createWithoutCanonicalization(const PositionWithAffin
ity& canonicalized); | 77 static VisiblePosition createWithoutCanonicalization(const PositionWithAffin
ity& canonicalized); |
| 78 | 78 |
| 79 // Intentionally delete |operator==()| and |operator!=()| for reducing | 79 // Intentionally delete |operator==()| and |operator!=()| for reducing |
| 80 // compilation error message. | 80 // compilation error message. |
| 81 // TODO(yosin) We'll have |equals()| when we have use cases of checking | 81 // TODO(yosin) We'll have |equals()| when we have use cases of checking |
| 82 // equality of both position and affinity. | 82 // equality of both position and affinity. |
| 83 bool operator==(const VisiblePosition&) const = delete; | 83 bool operator==(const VisiblePosition&) const = delete; |
| 84 bool operator!=(const VisiblePosition&) const = delete; | 84 bool operator!=(const VisiblePosition&) const = delete; |
| 85 | 85 |
| 86 bool isNull() const { return m_deepPosition.isNull(); } | 86 bool isNull() const { return m_positionWithAffinity.isNull(); } |
| 87 bool isNotNull() const { return m_deepPosition.isNotNull(); } | 87 bool isNotNull() const { return m_positionWithAffinity.isNotNull(); } |
| 88 bool isOrphan() const { return m_deepPosition.isOrphan(); } | 88 bool isOrphan() const { return deepEquivalent().isOrphan(); } |
| 89 | 89 |
| 90 Position deepEquivalent() const { return m_deepPosition; } | 90 Position deepEquivalent() const { return m_positionWithAffinity.position();
} |
| 91 Position toParentAnchoredPosition() const { return deepEquivalent().parentAn
choredEquivalent(); } | 91 Position toParentAnchoredPosition() const { return deepEquivalent().parentAn
choredEquivalent(); } |
| 92 PositionWithAffinity toPositionWithAffinity() const { return PositionWithAff
inity(m_deepPosition, m_affinity); } | 92 PositionWithAffinity toPositionWithAffinity() const { return m_positionWithA
ffinity; } |
| 93 TextAffinity affinity() const { return m_affinity; } | 93 TextAffinity affinity() const { return m_positionWithAffinity.affinity(); } |
| 94 | 94 |
| 95 DECLARE_TRACE(); | 95 DECLARE_TRACE(); |
| 96 | 96 |
| 97 #ifndef NDEBUG | 97 #ifndef NDEBUG |
| 98 void debugPosition(const char* msg = "") const; | 98 void debugPosition(const char* msg = "") const; |
| 99 void formatForDebugger(char* buffer, unsigned length) const; | 99 void formatForDebugger(char* buffer, unsigned length) const; |
| 100 void showTreeForThis() const; | 100 void showTreeForThis() const; |
| 101 #endif | 101 #endif |
| 102 | 102 |
| 103 private: | 103 private: |
| 104 explicit VisiblePosition(const Position&, TextAffinity); | 104 explicit VisiblePosition(const PositionWithAffinity&); |
| 105 | 105 |
| 106 // TODO(yosin) We should use |PositionWithAffinity| to make | 106 PositionWithAffinity m_positionWithAffinity; |
| 107 // |toPositionWithAffinity()| simpler. | |
| 108 Position m_deepPosition; | |
| 109 TextAffinity m_affinity; | |
| 110 }; | 107 }; |
| 111 | 108 |
| 112 // TODO(yosin) We should move |honorEditingBoundaryAtOr{Before,After} to | 109 // TODO(yosin) We should move |honorEditingBoundaryAtOr{Before,After} to |
| 113 // "VisibleUnits.cpp" as static function. | 110 // "VisibleUnits.cpp" as static function. |
| 114 // next() and previous() will increment/decrement by a character cluster. | 111 // next() and previous() will increment/decrement by a character cluster. |
| 115 VisiblePosition honorEditingBoundaryAtOrBefore(const VisiblePosition&, const Pos
ition& anchor); | 112 VisiblePosition honorEditingBoundaryAtOrBefore(const VisiblePosition&, const Pos
ition& anchor); |
| 116 PositionWithAffinity honorEditingBoundaryAtOrBeforeOf(const PositionWithAffinity
&, const Position& anchor); | 113 PositionWithAffinity honorEditingBoundaryAtOrBeforeOf(const PositionWithAffinity
&, const Position& anchor); |
| 117 PositionInComposedTreeWithAffinity honorEditingBoundaryAtOrBeforeOf(const Positi
onInComposedTreeWithAffinity&, const PositionInComposedTree& anchor); | 114 PositionInComposedTreeWithAffinity honorEditingBoundaryAtOrBeforeOf(const Positi
onInComposedTreeWithAffinity&, const PositionInComposedTree& anchor); |
| 118 VisiblePosition honorEditingBoundaryAtOrAfter(const VisiblePosition&, const Posi
tion& anchor); | 115 VisiblePosition honorEditingBoundaryAtOrAfter(const VisiblePosition&, const Posi
tion& anchor); |
| 119 | 116 |
| 120 CORE_EXPORT VisiblePosition createVisiblePosition(const Position&, TextAffinity
= VP_DEFAULT_AFFINITY); | 117 CORE_EXPORT VisiblePosition createVisiblePosition(const Position&, TextAffinity
= VP_DEFAULT_AFFINITY); |
| 121 CORE_EXPORT VisiblePosition createVisiblePosition(const PositionWithAffinity&); | 118 CORE_EXPORT VisiblePosition createVisiblePosition(const PositionWithAffinity&); |
| 122 CORE_EXPORT VisiblePosition createVisiblePosition(const PositionInComposedTree&,
TextAffinity = VP_DEFAULT_AFFINITY); | 119 CORE_EXPORT VisiblePosition createVisiblePosition(const PositionInComposedTree&,
TextAffinity = VP_DEFAULT_AFFINITY); |
| 123 | 120 |
| 124 } // namespace blink | 121 } // namespace blink |
| 125 | 122 |
| 126 #ifndef NDEBUG | 123 #ifndef NDEBUG |
| 127 // Outside the WebCore namespace for ease of invocation from gdb. | 124 // Outside the WebCore namespace for ease of invocation from gdb. |
| 128 void showTree(const blink::VisiblePosition*); | 125 void showTree(const blink::VisiblePosition*); |
| 129 void showTree(const blink::VisiblePosition&); | 126 void showTree(const blink::VisiblePosition&); |
| 130 #endif | 127 #endif |
| 131 | 128 |
| 132 #endif // VisiblePosition_h | 129 #endif // VisiblePosition_h |
| OLD | NEW |