| 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 16 matching lines...) Expand all Loading... |
| 27 #define VisibleSelection_h | 27 #define VisibleSelection_h |
| 28 | 28 |
| 29 #include "core/CoreExport.h" | 29 #include "core/CoreExport.h" |
| 30 #include "core/editing/EditingStrategy.h" | 30 #include "core/editing/EditingStrategy.h" |
| 31 #include "core/editing/EphemeralRange.h" | 31 #include "core/editing/EphemeralRange.h" |
| 32 #include "core/editing/SelectionType.h" | 32 #include "core/editing/SelectionType.h" |
| 33 #include "core/editing/TextAffinity.h" | 33 #include "core/editing/TextAffinity.h" |
| 34 #include "core/editing/TextGranularity.h" | 34 #include "core/editing/TextGranularity.h" |
| 35 #include "core/editing/VisiblePosition.h" | 35 #include "core/editing/VisiblePosition.h" |
| 36 #include "core/editing/VisibleUnits.h" | 36 #include "core/editing/VisibleUnits.h" |
| 37 #include "wtf/Allocator.h" |
| 37 | 38 |
| 38 namespace blink { | 39 namespace blink { |
| 39 | 40 |
| 40 class LayoutPoint; | 41 class LayoutPoint; |
| 41 | 42 |
| 42 // TODO(yosin) We should use capitalized name instead of |SEL_DEFAULT_AFFINITY|. | 43 // TODO(yosin) We should use capitalized name instead of |SEL_DEFAULT_AFFINITY|. |
| 43 const TextAffinity SEL_DEFAULT_AFFINITY = TextAffinity::Downstream; // NOLINT | 44 const TextAffinity SEL_DEFAULT_AFFINITY = TextAffinity::Downstream; // NOLINT |
| 44 enum SelectionDirection { DirectionForward, DirectionBackward, DirectionRight, D
irectionLeft }; | 45 enum SelectionDirection { DirectionForward, DirectionBackward, DirectionRight, D
irectionLeft }; |
| 45 | 46 |
| 46 class CORE_EXPORT VisibleSelection { | 47 class CORE_EXPORT VisibleSelection { |
| 47 DISALLOW_ALLOCATION(); | 48 DISALLOW_ALLOCATION(); |
| 48 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(VisibleSelection); | 49 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(VisibleSelection); |
| 49 public: | 50 public: |
| 50 class InDOMTree { | 51 class InDOMTree { |
| 52 STATIC_ONLY(InDOMTree); |
| 51 public: | 53 public: |
| 52 using PositionType = Position; | 54 using PositionType = Position; |
| 53 using Strategy = EditingStrategy; | 55 using Strategy = EditingStrategy; |
| 54 | 56 |
| 55 static EphemeralRange asRange(const VisibleSelection&); | 57 static EphemeralRange asRange(const VisibleSelection&); |
| 56 static bool equalSelections(const VisibleSelection&, const VisibleSelect
ion&); | 58 static bool equalSelections(const VisibleSelection&, const VisibleSelect
ion&); |
| 57 static PositionType selectionBase(const VisibleSelection& selection) { r
eturn selection.base(); } | 59 static PositionType selectionBase(const VisibleSelection& selection) { r
eturn selection.base(); } |
| 58 static PositionType selectionExtent(const VisibleSelection& selection) {
return selection.extent(); } | 60 static PositionType selectionExtent(const VisibleSelection& selection) {
return selection.extent(); } |
| 59 static PositionType selectionStart(const VisibleSelection& selection) {
return selection.start(); } | 61 static PositionType selectionStart(const VisibleSelection& selection) {
return selection.start(); } |
| 60 static PositionType selectionEnd(const VisibleSelection& selection) { re
turn selection.end(); } | 62 static PositionType selectionEnd(const VisibleSelection& selection) { re
turn selection.end(); } |
| 61 static SelectionType selectionType(const VisibleSelection& selection) {
return selection.selectionType(); } | 63 static SelectionType selectionType(const VisibleSelection& selection) {
return selection.selectionType(); } |
| 62 static VisiblePosition selectionVisibleStart(const VisibleSelection& sel
ection) { return selection.visibleStart(); } | 64 static VisiblePosition selectionVisibleStart(const VisibleSelection& sel
ection) { return selection.visibleStart(); } |
| 63 static VisiblePosition selectionVisibleEnd(const VisibleSelection& selec
tion) { return selection.visibleEnd(); } | 65 static VisiblePosition selectionVisibleEnd(const VisibleSelection& selec
tion) { return selection.visibleEnd(); } |
| 64 static PositionType toPositionType(const Position& position) { return po
sition; } | 66 static PositionType toPositionType(const Position& position) { return po
sition; } |
| 65 }; | 67 }; |
| 66 | 68 |
| 67 class InComposedTree { | 69 class InComposedTree { |
| 70 STATIC_ONLY(InComposedTree); |
| 68 public: | 71 public: |
| 69 using PositionType = PositionInComposedTree; | 72 using PositionType = PositionInComposedTree; |
| 70 using Strategy = EditingInComposedTreeStrategy; | 73 using Strategy = EditingInComposedTreeStrategy; |
| 71 | 74 |
| 72 static EphemeralRangeInComposedTree asRange(const VisibleSelection&); | 75 static EphemeralRangeInComposedTree asRange(const VisibleSelection&); |
| 73 static bool equalSelections(const VisibleSelection&, const VisibleSelect
ion&); | 76 static bool equalSelections(const VisibleSelection&, const VisibleSelect
ion&); |
| 74 static bool isRange(const VisibleSelection& selection) { return selectio
nType(selection) == RangeSelection; } | 77 static bool isRange(const VisibleSelection& selection) { return selectio
nType(selection) == RangeSelection; } |
| 75 static PositionType selectionBase(const VisibleSelection& selection) { r
eturn selection.baseInComposedTree(); } | 78 static PositionType selectionBase(const VisibleSelection& selection) { r
eturn selection.baseInComposedTree(); } |
| 76 static PositionType selectionExtent(const VisibleSelection& selection) {
return selection.extentInComposedTree(); } | 79 static PositionType selectionExtent(const VisibleSelection& selection) {
return selection.extentInComposedTree(); } |
| 77 static PositionType selectionStart(const VisibleSelection& selection) {
return selection.startInComposedTree(); } | 80 static PositionType selectionStart(const VisibleSelection& selection) {
return selection.startInComposedTree(); } |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 | 260 |
| 258 } // namespace blink | 261 } // namespace blink |
| 259 | 262 |
| 260 #ifndef NDEBUG | 263 #ifndef NDEBUG |
| 261 // Outside the WebCore namespace for ease of invocation from gdb. | 264 // Outside the WebCore namespace for ease of invocation from gdb. |
| 262 void showTree(const blink::VisibleSelection&); | 265 void showTree(const blink::VisibleSelection&); |
| 263 void showTree(const blink::VisibleSelection*); | 266 void showTree(const blink::VisibleSelection*); |
| 264 #endif | 267 #endif |
| 265 | 268 |
| 266 #endif // VisibleSelection_h | 269 #endif // VisibleSelection_h |
| OLD | NEW |