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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 , m_offset(0) | 82 , m_offset(0) |
83 , m_prevLeafChild(uncachedInlineBox()) | 83 , m_prevLeafChild(uncachedInlineBox()) |
84 , m_nextLeafChild(uncachedInlineBox()) | 84 , m_nextLeafChild(uncachedInlineBox()) |
85 { | 85 { |
86 if (position.isNull()) | 86 if (position.isNull()) |
87 return; | 87 return; |
88 InlineBoxPosition boxPosition = computeInlineBoxPosition(position, affinity)
; | 88 InlineBoxPosition boxPosition = computeInlineBoxPosition(position, affinity)
; |
89 m_inlineBox = boxPosition.inlineBox; | 89 m_inlineBox = boxPosition.inlineBox; |
90 m_offset = boxPosition.offsetInBox; | 90 m_offset = boxPosition.offsetInBox; |
91 if (m_inlineBox) | 91 if (m_inlineBox) |
92 m_layoutObject = LineLayoutAPIShim::layoutObjectFrom(m_inlineBox->lineLa
youtItem()); | 92 m_layoutObject = LineLayoutAPIShim::layoutObjectFrom(m_inlineBox->getLin
eLayoutItem()); |
93 else | 93 else |
94 m_layoutObject = layoutObjectFromPosition(position); | 94 m_layoutObject = layoutObjectFromPosition(position); |
95 } | 95 } |
96 | 96 |
97 RenderedPosition::RenderedPosition(const PositionInFlatTree& position, TextAffin
ity affinity) | 97 RenderedPosition::RenderedPosition(const PositionInFlatTree& position, TextAffin
ity affinity) |
98 : RenderedPosition(toPositionInDOMTree(position), affinity) | 98 : RenderedPosition(toPositionInDOMTree(position), affinity) |
99 { | 99 { |
100 } | 100 } |
101 | 101 |
102 InlineBox* RenderedPosition::prevLeafChild() const | 102 InlineBox* RenderedPosition::prevLeafChild() const |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 134 |
135 RenderedPosition RenderedPosition::leftBoundaryOfBidiRun(unsigned char bidiLevel
OfRun) | 135 RenderedPosition RenderedPosition::leftBoundaryOfBidiRun(unsigned char bidiLevel
OfRun) |
136 { | 136 { |
137 if (!m_inlineBox || bidiLevelOfRun > m_inlineBox->bidiLevel()) | 137 if (!m_inlineBox || bidiLevelOfRun > m_inlineBox->bidiLevel()) |
138 return RenderedPosition(); | 138 return RenderedPosition(); |
139 | 139 |
140 InlineBox* box = m_inlineBox; | 140 InlineBox* box = m_inlineBox; |
141 do { | 141 do { |
142 InlineBox* prev = box->prevLeafChildIgnoringLineBreak(); | 142 InlineBox* prev = box->prevLeafChildIgnoringLineBreak(); |
143 if (!prev || prev->bidiLevel() < bidiLevelOfRun) | 143 if (!prev || prev->bidiLevel() < bidiLevelOfRun) |
144 return RenderedPosition(LineLayoutAPIShim::layoutObjectFrom(box->lin
eLayoutItem()), box, box->caretLeftmostOffset()); | 144 return RenderedPosition(LineLayoutAPIShim::layoutObjectFrom(box->get
LineLayoutItem()), box, box->caretLeftmostOffset()); |
145 box = prev; | 145 box = prev; |
146 } while (box); | 146 } while (box); |
147 | 147 |
148 ASSERT_NOT_REACHED(); | 148 ASSERT_NOT_REACHED(); |
149 return RenderedPosition(); | 149 return RenderedPosition(); |
150 } | 150 } |
151 | 151 |
152 RenderedPosition RenderedPosition::rightBoundaryOfBidiRun(unsigned char bidiLeve
lOfRun) | 152 RenderedPosition RenderedPosition::rightBoundaryOfBidiRun(unsigned char bidiLeve
lOfRun) |
153 { | 153 { |
154 if (!m_inlineBox || bidiLevelOfRun > m_inlineBox->bidiLevel()) | 154 if (!m_inlineBox || bidiLevelOfRun > m_inlineBox->bidiLevel()) |
155 return RenderedPosition(); | 155 return RenderedPosition(); |
156 | 156 |
157 InlineBox* box = m_inlineBox; | 157 InlineBox* box = m_inlineBox; |
158 do { | 158 do { |
159 InlineBox* next = box->nextLeafChildIgnoringLineBreak(); | 159 InlineBox* next = box->nextLeafChildIgnoringLineBreak(); |
160 if (!next || next->bidiLevel() < bidiLevelOfRun) | 160 if (!next || next->bidiLevel() < bidiLevelOfRun) |
161 return RenderedPosition(LineLayoutAPIShim::layoutObjectFrom(box->lin
eLayoutItem()), box, box->caretRightmostOffset()); | 161 return RenderedPosition(LineLayoutAPIShim::layoutObjectFrom(box->get
LineLayoutItem()), box, box->caretRightmostOffset()); |
162 box = next; | 162 box = next; |
163 } while (box); | 163 } while (box); |
164 | 164 |
165 ASSERT_NOT_REACHED(); | 165 ASSERT_NOT_REACHED(); |
166 return RenderedPosition(); | 166 return RenderedPosition(); |
167 } | 167 } |
168 | 168 |
169 bool RenderedPosition::atLeftBoundaryOfBidiRun(ShouldMatchBidiLevel shouldMatchB
idiLevel, unsigned char bidiLevelOfRun) const | 169 bool RenderedPosition::atLeftBoundaryOfBidiRun(ShouldMatchBidiLevel shouldMatchB
idiLevel, unsigned char bidiLevelOfRun) const |
170 { | 170 { |
171 if (!m_inlineBox) | 171 if (!m_inlineBox) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 return false; | 206 return false; |
207 } | 207 } |
208 | 208 |
209 Position RenderedPosition::positionAtLeftBoundaryOfBiDiRun() const | 209 Position RenderedPosition::positionAtLeftBoundaryOfBiDiRun() const |
210 { | 210 { |
211 ASSERT(atLeftBoundaryOfBidiRun()); | 211 ASSERT(atLeftBoundaryOfBidiRun()); |
212 | 212 |
213 if (atLeftmostOffsetInBox()) | 213 if (atLeftmostOffsetInBox()) |
214 return Position::editingPositionOf(m_layoutObject->node(), m_offset); | 214 return Position::editingPositionOf(m_layoutObject->node(), m_offset); |
215 | 215 |
216 return Position::editingPositionOf(nextLeafChild()->lineLayoutItem().node(),
nextLeafChild()->caretLeftmostOffset()); | 216 return Position::editingPositionOf(nextLeafChild()->getLineLayoutItem().node
(), nextLeafChild()->caretLeftmostOffset()); |
217 } | 217 } |
218 | 218 |
219 Position RenderedPosition::positionAtRightBoundaryOfBiDiRun() const | 219 Position RenderedPosition::positionAtRightBoundaryOfBiDiRun() const |
220 { | 220 { |
221 ASSERT(atRightBoundaryOfBidiRun()); | 221 ASSERT(atRightBoundaryOfBidiRun()); |
222 | 222 |
223 if (atRightmostOffsetInBox()) | 223 if (atRightmostOffsetInBox()) |
224 return Position::editingPositionOf(m_layoutObject->node(), m_offset); | 224 return Position::editingPositionOf(m_layoutObject->node(), m_offset); |
225 | 225 |
226 return Position::editingPositionOf(prevLeafChild()->lineLayoutItem().node(),
prevLeafChild()->caretRightmostOffset()); | 226 return Position::editingPositionOf(prevLeafChild()->getLineLayoutItem().node
(), prevLeafChild()->caretRightmostOffset()); |
227 } | 227 } |
228 | 228 |
229 IntRect RenderedPosition::absoluteRect(LayoutUnit* extraWidthToEndOfLine) const | 229 IntRect RenderedPosition::absoluteRect(LayoutUnit* extraWidthToEndOfLine) const |
230 { | 230 { |
231 if (isNull()) | 231 if (isNull()) |
232 return IntRect(); | 232 return IntRect(); |
233 | 233 |
234 IntRect localRect = pixelSnappedIntRect(m_layoutObject->localCaretRect(m_inl
ineBox, m_offset, extraWidthToEndOfLine)); | 234 IntRect localRect = pixelSnappedIntRect(m_layoutObject->localCaretRect(m_inl
ineBox, m_offset, extraWidthToEndOfLine)); |
235 return localRect == IntRect() ? IntRect() : m_layoutObject->localToAbsoluteQ
uad(FloatRect(localRect)).enclosingBoundingBox(); | 235 return localRect == IntRect() ? IntRect() : m_layoutObject->localToAbsoluteQ
uad(FloatRect(localRect)).enclosingBoundingBox(); |
236 } | 236 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 bool layoutObjectContainsPosition(LayoutObject* target, const Position& position
) | 271 bool layoutObjectContainsPosition(LayoutObject* target, const Position& position
) |
272 { | 272 { |
273 for (LayoutObject* layoutObject = layoutObjectFromPosition(position); layout
Object && layoutObject->node(); layoutObject = layoutObject->parent()) { | 273 for (LayoutObject* layoutObject = layoutObjectFromPosition(position); layout
Object && layoutObject->node(); layoutObject = layoutObject->parent()) { |
274 if (layoutObject == target) | 274 if (layoutObject == target) |
275 return true; | 275 return true; |
276 } | 276 } |
277 return false; | 277 return false; |
278 } | 278 } |
279 | 279 |
280 } // namespace blink | 280 } // namespace blink |
OLD | NEW |