OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "core/editing/RenderedPosition.h" | 32 #include "core/editing/RenderedPosition.h" |
33 | 33 |
34 #include "core/editing/Position.h" | 34 #include "core/editing/TextAffinity.h" |
35 #include "core/editing/VisiblePosition.h" | 35 #include "core/editing/VisiblePosition.h" |
36 #include "core/layout/compositing/CompositedSelectionBound.h" | 36 #include "core/layout/compositing/CompositedSelectionBound.h" |
37 #include "core/paint/DeprecatedPaintLayer.h" | 37 #include "core/paint/DeprecatedPaintLayer.h" |
38 | 38 |
39 namespace blink { | 39 namespace blink { |
40 | 40 |
41 static inline LayoutObject* layoutObjectFromPosition(const Position& position) | 41 static inline LayoutObject* layoutObjectFromPosition(const Position& position) |
42 { | 42 { |
43 ASSERT(position.isNotNull()); | 43 ASSERT(position.isNotNull()); |
44 Node* layoutObjectNode = nullptr; | 44 Node* layoutObjectNode = nullptr; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 return; | 76 return; |
77 InlineBoxPosition boxPosition = computeInlineBoxPosition(position); | 77 InlineBoxPosition boxPosition = computeInlineBoxPosition(position); |
78 m_inlineBox = boxPosition.inlineBox; | 78 m_inlineBox = boxPosition.inlineBox; |
79 m_offset = boxPosition.offsetInBox; | 79 m_offset = boxPosition.offsetInBox; |
80 if (m_inlineBox) | 80 if (m_inlineBox) |
81 m_layoutObject = &m_inlineBox->layoutObject(); | 81 m_layoutObject = &m_inlineBox->layoutObject(); |
82 else | 82 else |
83 m_layoutObject = layoutObjectFromPosition(position.deepEquivalent()); | 83 m_layoutObject = layoutObjectFromPosition(position.deepEquivalent()); |
84 } | 84 } |
85 | 85 |
86 RenderedPosition::RenderedPosition(const Position& position, EAffinity affinity) | 86 RenderedPosition::RenderedPosition(const Position& position, TextAffinity affini
ty) |
87 : m_layoutObject(nullptr) | 87 : m_layoutObject(nullptr) |
88 , m_inlineBox(nullptr) | 88 , m_inlineBox(nullptr) |
89 , m_offset(0) | 89 , m_offset(0) |
90 , m_prevLeafChild(uncachedInlineBox()) | 90 , m_prevLeafChild(uncachedInlineBox()) |
91 , m_nextLeafChild(uncachedInlineBox()) | 91 , m_nextLeafChild(uncachedInlineBox()) |
92 { | 92 { |
93 if (position.isNull()) | 93 if (position.isNull()) |
94 return; | 94 return; |
95 InlineBoxPosition boxPosition = position.computeInlineBoxPosition(affinity); | 95 InlineBoxPosition boxPosition = position.computeInlineBoxPosition(affinity); |
96 m_inlineBox = boxPosition.inlineBox; | 96 m_inlineBox = boxPosition.inlineBox; |
97 m_offset = boxPosition.offsetInBox; | 97 m_offset = boxPosition.offsetInBox; |
98 if (m_inlineBox) | 98 if (m_inlineBox) |
99 m_layoutObject = &m_inlineBox->layoutObject(); | 99 m_layoutObject = &m_inlineBox->layoutObject(); |
100 else | 100 else |
101 m_layoutObject = layoutObjectFromPosition(position); | 101 m_layoutObject = layoutObjectFromPosition(position); |
102 } | 102 } |
103 | 103 |
104 RenderedPosition::RenderedPosition(const PositionInComposedTree& position, EAffi
nity affinity) | 104 RenderedPosition::RenderedPosition(const PositionInComposedTree& position, TextA
ffinity affinity) |
105 : RenderedPosition(toPositionInDOMTree(position), affinity) | 105 : RenderedPosition(toPositionInDOMTree(position), affinity) |
106 { | 106 { |
107 } | 107 } |
108 | 108 |
109 InlineBox* RenderedPosition::prevLeafChild() const | 109 InlineBox* RenderedPosition::prevLeafChild() const |
110 { | 110 { |
111 if (m_prevLeafChild == uncachedInlineBox()) | 111 if (m_prevLeafChild == uncachedInlineBox()) |
112 m_prevLeafChild = m_inlineBox->prevLeafChildIgnoringLineBreak(); | 112 m_prevLeafChild = m_inlineBox->prevLeafChildIgnoringLineBreak(); |
113 return m_prevLeafChild; | 113 return m_prevLeafChild; |
114 } | 114 } |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 bool layoutObjectContainsPosition(LayoutObject* target, const Position& position
) | 260 bool layoutObjectContainsPosition(LayoutObject* target, const Position& position
) |
261 { | 261 { |
262 for (LayoutObject* layoutObject = layoutObjectFromPosition(position); layout
Object && layoutObject->node(); layoutObject = layoutObject->parent()) { | 262 for (LayoutObject* layoutObject = layoutObjectFromPosition(position); layout
Object && layoutObject->node(); layoutObject = layoutObject->parent()) { |
263 if (layoutObject == target) | 263 if (layoutObject == target) |
264 return true; | 264 return true; |
265 } | 265 } |
266 return false; | 266 return false; |
267 } | 267 } |
268 | 268 |
269 }; | 269 }; |
OLD | NEW |