| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2004 Apple Computer, 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 const TextAffinity SelDefaultAffinity = TextAffinity::Downstream; | 44 const TextAffinity SelDefaultAffinity = TextAffinity::Downstream; |
| 45 enum SelectionDirection { DirectionForward, DirectionBackward, DirectionRight, D
irectionLeft }; | 45 enum SelectionDirection { DirectionForward, DirectionBackward, DirectionRight, D
irectionLeft }; |
| 46 | 46 |
| 47 template <typename Strategy> | 47 template <typename Strategy> |
| 48 class CORE_TEMPLATE_CLASS_EXPORT VisibleSelectionTemplate { | 48 class CORE_TEMPLATE_CLASS_EXPORT VisibleSelectionTemplate { |
| 49 DISALLOW_NEW(); | 49 DISALLOW_NEW(); |
| 50 public: | 50 public: |
| 51 VisibleSelectionTemplate(); | 51 VisibleSelectionTemplate(); |
| 52 VisibleSelectionTemplate(const PositionTemplate<Strategy>&, TextAffinity, bo
ol isDirectional = false); | 52 VisibleSelectionTemplate(const PositionTemplate<Strategy>&, TextAffinity, bo
ol isDirectional = false); |
| 53 VisibleSelectionTemplate(const PositionTemplate<Strategy>& base, const Posit
ionTemplate<Strategy>& extent, TextAffinity = SelDefaultAffinity, bool isDirecti
onal = false); | 53 VisibleSelectionTemplate(const PositionTemplate<Strategy>& base, const Posit
ionTemplate<Strategy>& extent, TextAffinity = SelDefaultAffinity, bool isDirecti
onal = false, bool isHandleVisible = false); |
| 54 explicit VisibleSelectionTemplate(const EphemeralRangeTemplate<Strategy>&, T
extAffinity = SelDefaultAffinity, bool isDirectional = false); | 54 explicit VisibleSelectionTemplate(const EphemeralRangeTemplate<Strategy>&, T
extAffinity = SelDefaultAffinity, bool isDirectional = false); |
| 55 | 55 |
| 56 explicit VisibleSelectionTemplate(const VisiblePositionTemplate<Strategy>&,
bool isDirectional = false); | 56 explicit VisibleSelectionTemplate(const VisiblePositionTemplate<Strategy>&,
bool isDirectional = false); |
| 57 VisibleSelectionTemplate(const VisiblePositionTemplate<Strategy>&, const Vis
iblePositionTemplate<Strategy>&, bool isDirectional = false); | 57 VisibleSelectionTemplate(const VisiblePositionTemplate<Strategy>&, const Vis
iblePositionTemplate<Strategy>&, bool isDirectional = false, bool isHandleVisibl
e = false); |
| 58 | 58 |
| 59 explicit VisibleSelectionTemplate(const PositionWithAffinityTemplate<Strateg
y>&, bool isDirectional = false); | 59 explicit VisibleSelectionTemplate(const PositionWithAffinityTemplate<Strateg
y>&, bool isDirectional = false); |
| 60 | 60 |
| 61 VisibleSelectionTemplate(const VisibleSelectionTemplate&); | 61 VisibleSelectionTemplate(const VisibleSelectionTemplate&); |
| 62 VisibleSelectionTemplate& operator=(const VisibleSelectionTemplate&); | 62 VisibleSelectionTemplate& operator=(const VisibleSelectionTemplate&); |
| 63 | 63 |
| 64 static VisibleSelectionTemplate selectionFromContentsOfNode(Node*); | 64 static VisibleSelectionTemplate selectionFromContentsOfNode(Node*); |
| 65 | 65 |
| 66 SelectionType getSelectionType() const { return m_selectionType; } | 66 SelectionType getSelectionType() const { return m_selectionType; } |
| 67 | 67 |
| 68 void setIsHandleVisible(bool isHandleVisible) { m_isHandleVisible = isHandle
Visible; } |
| 69 bool isHandleVisible() const { return m_isHandleVisible; } |
| 70 |
| 68 void setAffinity(TextAffinity affinity) { m_affinity = affinity; } | 71 void setAffinity(TextAffinity affinity) { m_affinity = affinity; } |
| 69 TextAffinity affinity() const { return m_affinity; } | 72 TextAffinity affinity() const { return m_affinity; } |
| 70 | 73 |
| 71 void setBase(const PositionTemplate<Strategy>&); | 74 void setBase(const PositionTemplate<Strategy>&); |
| 72 void setBase(const VisiblePositionTemplate<Strategy>&); | 75 void setBase(const VisiblePositionTemplate<Strategy>&); |
| 73 void setExtent(const PositionTemplate<Strategy>&); | 76 void setExtent(const PositionTemplate<Strategy>&); |
| 74 void setExtent(const VisiblePositionTemplate<Strategy>&); | 77 void setExtent(const VisiblePositionTemplate<Strategy>&); |
| 75 | 78 |
| 76 PositionTemplate<Strategy> base() const { return m_base; } | 79 PositionTemplate<Strategy> base() const { return m_base; } |
| 77 PositionTemplate<Strategy> extent() const { return m_extent; } | 80 PositionTemplate<Strategy> extent() const { return m_extent; } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 SelectionType m_selectionType; // None, Caret, Range | 168 SelectionType m_selectionType; // None, Caret, Range |
| 166 bool m_baseIsFirst : 1; // True if base is before the extent | 169 bool m_baseIsFirst : 1; // True if base is before the extent |
| 167 bool m_isDirectional : 1; // Non-directional ignores m_baseIsFirst and selec
tion always extends on shift + arrow key. | 170 bool m_isDirectional : 1; // Non-directional ignores m_baseIsFirst and selec
tion always extends on shift + arrow key. |
| 168 | 171 |
| 169 TextGranularity m_granularity; | 172 TextGranularity m_granularity; |
| 170 // |updateIfNeeded()| uses |m_hasTrailingWhitespace| for word granularity. | 173 // |updateIfNeeded()| uses |m_hasTrailingWhitespace| for word granularity. |
| 171 // |m_hasTrailingWhitespace| is set by |appendTrailingWhitespace()|. | 174 // |m_hasTrailingWhitespace| is set by |appendTrailingWhitespace()|. |
| 172 // TODO(yosin): Once we unify start/end and base/extent, we should get rid | 175 // TODO(yosin): Once we unify start/end and base/extent, we should get rid |
| 173 // of |m_hasTrailingWhitespace|. | 176 // of |m_hasTrailingWhitespace|. |
| 174 bool m_hasTrailingWhitespace : 1; | 177 bool m_hasTrailingWhitespace : 1; |
| 178 bool m_isHandleVisible : 1; |
| 175 }; | 179 }; |
| 176 | 180 |
| 177 extern template class CORE_EXTERN_TEMPLATE_EXPORT VisibleSelectionTemplate<Editi
ngStrategy>; | 181 extern template class CORE_EXTERN_TEMPLATE_EXPORT VisibleSelectionTemplate<Editi
ngStrategy>; |
| 178 extern template class CORE_EXTERN_TEMPLATE_EXPORT VisibleSelectionTemplate<Editi
ngInFlatTreeStrategy>; | 182 extern template class CORE_EXTERN_TEMPLATE_EXPORT VisibleSelectionTemplate<Editi
ngInFlatTreeStrategy>; |
| 179 | 183 |
| 180 using VisibleSelection = VisibleSelectionTemplate<EditingStrategy>; | 184 using VisibleSelection = VisibleSelectionTemplate<EditingStrategy>; |
| 181 using VisibleSelectionInFlatTree = VisibleSelectionTemplate<EditingInFlatTreeStr
ategy>; | 185 using VisibleSelectionInFlatTree = VisibleSelectionTemplate<EditingInFlatTreeStr
ategy>; |
| 182 | 186 |
| 183 // We don't yet support multi-range selections, so we only ever have one range | 187 // We don't yet support multi-range selections, so we only ever have one range |
| 184 // to return. | 188 // to return. |
| 185 CORE_EXPORT EphemeralRange firstEphemeralRangeOf(const VisibleSelection&); | 189 CORE_EXPORT EphemeralRange firstEphemeralRangeOf(const VisibleSelection&); |
| 186 | 190 |
| 187 // TODO(sof): move more firstRangeOf() uses to be over EphemeralRange instead. | 191 // TODO(sof): move more firstRangeOf() uses to be over EphemeralRange instead. |
| 188 CORE_EXPORT Range* firstRangeOf(const VisibleSelection&); | 192 CORE_EXPORT Range* firstRangeOf(const VisibleSelection&); |
| 189 | 193 |
| 190 CORE_EXPORT std::ostream& operator<<(std::ostream&, const VisibleSelection&); | 194 CORE_EXPORT std::ostream& operator<<(std::ostream&, const VisibleSelection&); |
| 191 CORE_EXPORT std::ostream& operator<<(std::ostream&, const VisibleSelectionInFlat
Tree&); | 195 CORE_EXPORT std::ostream& operator<<(std::ostream&, const VisibleSelectionInFlat
Tree&); |
| 192 | 196 |
| 193 } // namespace blink | 197 } // namespace blink |
| 194 | 198 |
| 195 #ifndef NDEBUG | 199 #ifndef NDEBUG |
| 196 // Outside the WebCore namespace for ease of invocation from gdb. | 200 // Outside the WebCore namespace for ease of invocation from gdb. |
| 197 void showTree(const blink::VisibleSelection&); | 201 void showTree(const blink::VisibleSelection&); |
| 198 void showTree(const blink::VisibleSelection*); | 202 void showTree(const blink::VisibleSelection*); |
| 199 void showTree(const blink::VisibleSelectionInFlatTree&); | 203 void showTree(const blink::VisibleSelectionInFlatTree&); |
| 200 void showTree(const blink::VisibleSelectionInFlatTree*); | 204 void showTree(const blink::VisibleSelectionInFlatTree*); |
| 201 #endif | 205 #endif |
| 202 | 206 |
| 203 #endif // VisibleSelection_h | 207 #endif // VisibleSelection_h |
| OLD | NEW |