| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 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 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 #include "core/dom/Node.h" | 29 #include "core/dom/Node.h" |
| 30 #include "core/dom/NodeTraversal.h" | 30 #include "core/dom/NodeTraversal.h" |
| 31 #include "core/editing/Position.h" | 31 #include "core/editing/Position.h" |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 class RangeBoundaryPoint { | 35 class RangeBoundaryPoint { |
| 36 DISALLOW_NEW(); | 36 DISALLOW_NEW(); |
| 37 public: | 37 public: |
| 38 explicit RangeBoundaryPoint(PassRefPtrWillBeRawPtr<Node> container); | 38 explicit RangeBoundaryPoint(RawPtr<Node> container); |
| 39 | 39 |
| 40 explicit RangeBoundaryPoint(const RangeBoundaryPoint&); | 40 explicit RangeBoundaryPoint(const RangeBoundaryPoint&); |
| 41 | 41 |
| 42 bool inDocument() const; | 42 bool inDocument() const; |
| 43 const Position toPosition() const; | 43 const Position toPosition() const; |
| 44 | 44 |
| 45 Node* container() const; | 45 Node* container() const; |
| 46 int offset() const; | 46 int offset() const; |
| 47 Node* childBefore() const; | 47 Node* childBefore() const; |
| 48 | 48 |
| 49 void clear(); | 49 void clear(); |
| 50 | 50 |
| 51 void set(PassRefPtrWillBeRawPtr<Node> container, int offset, Node* childBefo
re); | 51 void set(RawPtr<Node> container, int offset, Node* childBefore); |
| 52 void setOffset(int); | 52 void setOffset(int); |
| 53 | 53 |
| 54 void setToBeforeChild(Node&); | 54 void setToBeforeChild(Node&); |
| 55 void setToStartOfNode(Node&); | 55 void setToStartOfNode(Node&); |
| 56 void setToEndOfNode(Node&); | 56 void setToEndOfNode(Node&); |
| 57 | 57 |
| 58 void childBeforeWillBeRemoved(); | 58 void childBeforeWillBeRemoved(); |
| 59 void invalidateOffset() const; | 59 void invalidateOffset() const; |
| 60 void ensureOffsetIsValid() const; | 60 void ensureOffsetIsValid() const; |
| 61 | 61 |
| 62 DEFINE_INLINE_TRACE() | 62 DEFINE_INLINE_TRACE() |
| 63 { | 63 { |
| 64 visitor->trace(m_containerNode); | 64 visitor->trace(m_containerNode); |
| 65 visitor->trace(m_childBeforeBoundary); | 65 visitor->trace(m_childBeforeBoundary); |
| 66 } | 66 } |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 static const int invalidOffset = -1; | 69 static const int invalidOffset = -1; |
| 70 | 70 |
| 71 RefPtrWillBeMember<Node> m_containerNode; | 71 Member<Node> m_containerNode; |
| 72 mutable int m_offsetInContainer; | 72 mutable int m_offsetInContainer; |
| 73 RefPtrWillBeMember<Node> m_childBeforeBoundary; | 73 Member<Node> m_childBeforeBoundary; |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 inline RangeBoundaryPoint::RangeBoundaryPoint(PassRefPtrWillBeRawPtr<Node> conta
iner) | 76 inline RangeBoundaryPoint::RangeBoundaryPoint(RawPtr<Node> container) |
| 77 : m_containerNode(container) | 77 : m_containerNode(container) |
| 78 , m_offsetInContainer(0) | 78 , m_offsetInContainer(0) |
| 79 , m_childBeforeBoundary(nullptr) | 79 , m_childBeforeBoundary(nullptr) |
| 80 { | 80 { |
| 81 ASSERT(m_containerNode); | 81 ASSERT(m_containerNode); |
| 82 } | 82 } |
| 83 | 83 |
| 84 inline RangeBoundaryPoint::RangeBoundaryPoint(const RangeBoundaryPoint& other) | 84 inline RangeBoundaryPoint::RangeBoundaryPoint(const RangeBoundaryPoint& other) |
| 85 : m_containerNode(other.container()) | 85 : m_containerNode(other.container()) |
| 86 , m_offsetInContainer(other.offset()) | 86 , m_offsetInContainer(other.offset()) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 return m_offsetInContainer; | 124 return m_offsetInContainer; |
| 125 } | 125 } |
| 126 | 126 |
| 127 inline void RangeBoundaryPoint::clear() | 127 inline void RangeBoundaryPoint::clear() |
| 128 { | 128 { |
| 129 m_containerNode.clear(); | 129 m_containerNode.clear(); |
| 130 m_offsetInContainer = 0; | 130 m_offsetInContainer = 0; |
| 131 m_childBeforeBoundary = nullptr; | 131 m_childBeforeBoundary = nullptr; |
| 132 } | 132 } |
| 133 | 133 |
| 134 inline void RangeBoundaryPoint::set(PassRefPtrWillBeRawPtr<Node> container, int
offset, Node* childBefore) | 134 inline void RangeBoundaryPoint::set(RawPtr<Node> container, int offset, Node* ch
ildBefore) |
| 135 { | 135 { |
| 136 ASSERT(container); | 136 ASSERT(container); |
| 137 ASSERT(offset >= 0); | 137 ASSERT(offset >= 0); |
| 138 ASSERT(childBefore == (offset ? NodeTraversal::childAt(*container, offset -
1) : 0)); | 138 ASSERT(childBefore == (offset ? NodeTraversal::childAt(*container, offset -
1) : 0)); |
| 139 m_containerNode = container; | 139 m_containerNode = container; |
| 140 m_offsetInContainer = offset; | 140 m_offsetInContainer = offset; |
| 141 m_childBeforeBoundary = childBefore; | 141 m_childBeforeBoundary = childBefore; |
| 142 } | 142 } |
| 143 | 143 |
| 144 inline void RangeBoundaryPoint::setOffset(int offset) | 144 inline void RangeBoundaryPoint::setOffset(int offset) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 } else { | 202 } else { |
| 203 if (a.offset() != b.offset()) | 203 if (a.offset() != b.offset()) |
| 204 return false; | 204 return false; |
| 205 } | 205 } |
| 206 return true; | 206 return true; |
| 207 } | 207 } |
| 208 | 208 |
| 209 } // namespace blink | 209 } // namespace blink |
| 210 | 210 |
| 211 #endif | 211 #endif |
| OLD | NEW |