| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 DISALLOW_NEW(); | 54 DISALLOW_NEW(); |
| 55 | 55 |
| 56 public: | 56 public: |
| 57 VisibleSelectionTemplate(); | 57 VisibleSelectionTemplate(); |
| 58 VisibleSelectionTemplate(const VisibleSelectionTemplate&); | 58 VisibleSelectionTemplate(const VisibleSelectionTemplate&); |
| 59 VisibleSelectionTemplate& operator=(const VisibleSelectionTemplate&); | 59 VisibleSelectionTemplate& operator=(const VisibleSelectionTemplate&); |
| 60 | 60 |
| 61 // Note: |create()| should be used only by |createVisibleSelection|. | 61 // Note: |create()| should be used only by |createVisibleSelection|. |
| 62 static VisibleSelectionTemplate Create(const SelectionTemplate<Strategy>&); | 62 static VisibleSelectionTemplate Create(const SelectionTemplate<Strategy>&); |
| 63 | 63 |
| 64 // Note: |CreateWithGranularity()| should be used only by |
| 65 // |CreateVisibleSelectionWithGranularity()|. |
| 66 static VisibleSelectionTemplate CreateWithGranularity( |
| 67 const SelectionTemplate<Strategy>&, |
| 68 TextGranularity); |
| 69 |
| 64 SelectionType GetSelectionType() const { return selection_type_; } | 70 SelectionType GetSelectionType() const { return selection_type_; } |
| 65 | 71 |
| 66 TextAffinity Affinity() const { return affinity_; } | 72 TextAffinity Affinity() const { return affinity_; } |
| 67 | 73 |
| 68 SelectionTemplate<Strategy> AsSelection() const; | 74 SelectionTemplate<Strategy> AsSelection() const; |
| 69 PositionTemplate<Strategy> Base() const { return base_; } | 75 PositionTemplate<Strategy> Base() const { return base_; } |
| 70 PositionTemplate<Strategy> Extent() const { return extent_; } | 76 PositionTemplate<Strategy> Extent() const { return extent_; } |
| 71 PositionTemplate<Strategy> Start() const { return start_; } | 77 PositionTemplate<Strategy> Start() const { return start_; } |
| 72 PositionTemplate<Strategy> End() const { return end_; } | 78 PositionTemplate<Strategy> End() const { return end_; } |
| 73 | 79 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 DECLARE_TRACE(); | 143 DECLARE_TRACE(); |
| 138 | 144 |
| 139 #ifndef NDEBUG | 145 #ifndef NDEBUG |
| 140 void ShowTreeForThis() const; | 146 void ShowTreeForThis() const; |
| 141 #endif | 147 #endif |
| 142 static void PrintTo(const VisibleSelectionTemplate&, std::ostream*); | 148 static void PrintTo(const VisibleSelectionTemplate&, std::ostream*); |
| 143 | 149 |
| 144 private: | 150 private: |
| 145 friend class SelectionAdjuster; | 151 friend class SelectionAdjuster; |
| 146 | 152 |
| 147 VisibleSelectionTemplate(const SelectionTemplate<Strategy>&); | 153 VisibleSelectionTemplate(const SelectionTemplate<Strategy>&, TextGranularity); |
| 148 | 154 |
| 149 void Validate(TextGranularity = kCharacterGranularity); | 155 void Validate(TextGranularity = kCharacterGranularity); |
| 150 | 156 |
| 151 // Support methods for validate() | 157 // Support methods for validate() |
| 152 void SetBaseAndExtentToDeepEquivalents(); | 158 void SetBaseAndExtentToDeepEquivalents(); |
| 153 void AdjustSelectionToAvoidCrossingShadowBoundaries(); | 159 void AdjustSelectionToAvoidCrossingShadowBoundaries(); |
| 154 void AdjustSelectionToAvoidCrossingEditingBoundaries(); | 160 void AdjustSelectionToAvoidCrossingEditingBoundaries(); |
| 155 void UpdateSelectionType(); | 161 void UpdateSelectionType(); |
| 156 | 162 |
| 157 // We need to store these as Positions because VisibleSelection is | 163 // We need to store these as Positions because VisibleSelection is |
| (...skipping 28 matching lines...) Expand all Loading... |
| 186 VisibleSelectionTemplate<EditingInFlatTreeStrategy>; | 192 VisibleSelectionTemplate<EditingInFlatTreeStrategy>; |
| 187 | 193 |
| 188 using VisibleSelection = VisibleSelectionTemplate<EditingStrategy>; | 194 using VisibleSelection = VisibleSelectionTemplate<EditingStrategy>; |
| 189 using VisibleSelectionInFlatTree = | 195 using VisibleSelectionInFlatTree = |
| 190 VisibleSelectionTemplate<EditingInFlatTreeStrategy>; | 196 VisibleSelectionTemplate<EditingInFlatTreeStrategy>; |
| 191 | 197 |
| 192 CORE_EXPORT VisibleSelection CreateVisibleSelection(const SelectionInDOMTree&); | 198 CORE_EXPORT VisibleSelection CreateVisibleSelection(const SelectionInDOMTree&); |
| 193 CORE_EXPORT VisibleSelectionInFlatTree | 199 CORE_EXPORT VisibleSelectionInFlatTree |
| 194 CreateVisibleSelection(const SelectionInFlatTree&); | 200 CreateVisibleSelection(const SelectionInFlatTree&); |
| 195 | 201 |
| 202 CORE_EXPORT VisibleSelection |
| 203 CreateVisibleSelectionWithGranularity(const SelectionInDOMTree&, |
| 204 TextGranularity); |
| 205 |
| 206 CORE_EXPORT VisibleSelectionInFlatTree |
| 207 CreateVisibleSelectionWithGranularity(const SelectionInFlatTree&, |
| 208 TextGranularity); |
| 209 |
| 196 // We don't yet support multi-range selections, so we only ever have one range | 210 // We don't yet support multi-range selections, so we only ever have one range |
| 197 // to return. | 211 // to return. |
| 198 CORE_EXPORT EphemeralRange FirstEphemeralRangeOf(const VisibleSelection&); | 212 CORE_EXPORT EphemeralRange FirstEphemeralRangeOf(const VisibleSelection&); |
| 199 | 213 |
| 200 CORE_EXPORT std::ostream& operator<<(std::ostream&, const VisibleSelection&); | 214 CORE_EXPORT std::ostream& operator<<(std::ostream&, const VisibleSelection&); |
| 201 CORE_EXPORT std::ostream& operator<<(std::ostream&, | 215 CORE_EXPORT std::ostream& operator<<(std::ostream&, |
| 202 const VisibleSelectionInFlatTree&); | 216 const VisibleSelectionInFlatTree&); |
| 203 | 217 |
| 204 PositionInFlatTree ComputeStartRespectingGranularity( | 218 PositionInFlatTree ComputeStartRespectingGranularity( |
| 205 const PositionInFlatTreeWithAffinity&, | 219 const PositionInFlatTreeWithAffinity&, |
| 206 TextGranularity); | 220 TextGranularity); |
| 207 | 221 |
| 208 PositionInFlatTree ComputeEndRespectingGranularity( | 222 PositionInFlatTree ComputeEndRespectingGranularity( |
| 209 const PositionInFlatTree&, | 223 const PositionInFlatTree&, |
| 210 const PositionInFlatTreeWithAffinity&, | 224 const PositionInFlatTreeWithAffinity&, |
| 211 TextGranularity); | 225 TextGranularity); |
| 212 | 226 |
| 213 } // namespace blink | 227 } // namespace blink |
| 214 | 228 |
| 215 #ifndef NDEBUG | 229 #ifndef NDEBUG |
| 216 // Outside the WebCore namespace for ease of invocation from gdb. | 230 // Outside the WebCore namespace for ease of invocation from gdb. |
| 217 void showTree(const blink::VisibleSelection&); | 231 void showTree(const blink::VisibleSelection&); |
| 218 void showTree(const blink::VisibleSelection*); | 232 void showTree(const blink::VisibleSelection*); |
| 219 void showTree(const blink::VisibleSelectionInFlatTree&); | 233 void showTree(const blink::VisibleSelectionInFlatTree&); |
| 220 void showTree(const blink::VisibleSelectionInFlatTree*); | 234 void showTree(const blink::VisibleSelectionInFlatTree*); |
| 221 #endif | 235 #endif |
| 222 | 236 |
| 223 #endif // VisibleSelection_h | 237 #endif // VisibleSelection_h |
| OLD | NEW |