OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights |
4 * reserved. | 4 * reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 } | 179 } |
180 } | 180 } |
181 } | 181 } |
182 | 182 |
183 runner = GetNextOrPrevLayoutObjectBasedOnDirection( | 183 runner = GetNextOrPrevLayoutObjectBasedOnDirection( |
184 runner, stop, continue_exploring, exploring_backwards); | 184 runner, stop, continue_exploring, exploring_backwards); |
185 } | 185 } |
186 return selected_map; | 186 return selected_map; |
187 } | 187 } |
188 | 188 |
189 static void MarkSetSelectionState(LayoutObject* start, | |
yosin_UTC9
2017/05/15 08:30:05
nit: s/MarkSetSelectionState/MarkSelectionState/
yoichio
2017/05/15 09:12:22
Done.
| |
190 LayoutObject* end, | |
191 int end_pos) { | |
192 // Update the selection status of all objects between m_selectionStart and | |
yosin_UTC9
2017/05/15 08:30:04
nit: s/status/state/
nit: s/m_selectionStart/|star
yoichio
2017/05/15 09:12:21
Done.
| |
193 // m_selectionEnd | |
yosin_UTC9
2017/05/15 08:30:05
nit: s/m_selecitonEnd/|end|/
This function doesn'
yoichio
2017/05/15 09:12:22
Done.
| |
194 if (start && start == end) { | |
195 start->SetSelectionStateIfNeeded(SelectionBoth); | |
196 } else { | |
yosin_UTC9
2017/05/15 08:30:05
nit: better to use else-if to shallow indentation
yoichio
2017/05/15 09:12:22
Done.
| |
197 if (start) | |
198 start->SetSelectionStateIfNeeded(SelectionStart); | |
199 if (end) | |
200 end->SetSelectionStateIfNeeded(SelectionEnd); | |
201 } | |
202 | |
203 LayoutObject* o = start; | |
yosin_UTC9
2017/05/15 08:30:05
nit: s/o/runner/ or something
Please avoid to use
yoichio
2017/05/15 09:12:21
Done.
| |
204 LayoutObject* const stop = LayoutObjectAfterPosition(end, end_pos); | |
205 | |
206 while (o && o != stop) { | |
yosin_UTC9
2017/05/15 08:30:04
nit: It is better to use for:
for (LayoutObject*
yoichio
2017/05/15 09:12:22
Done.
| |
207 if (o != start && o != end && o->CanBeSelectionLeaf()) | |
208 o->SetSelectionStateIfNeeded(SelectionInside); | |
209 o = o->NextInPreOrder(); | |
210 } | |
211 } | |
212 | |
189 void LayoutSelection::SetSelection( | 213 void LayoutSelection::SetSelection( |
190 LayoutObject* start, | 214 LayoutObject* start, |
191 int start_pos, | 215 int start_pos, |
192 LayoutObject* end, | 216 LayoutObject* end, |
193 int end_pos, | 217 int end_pos, |
194 SelectionPaintInvalidationMode block_paint_invalidation_mode) { | 218 SelectionPaintInvalidationMode block_paint_invalidation_mode) { |
195 // This code makes no assumptions as to if the layout tree is up to date or | 219 // This code makes no assumptions as to if the layout tree is up to date or |
196 // not and will not try to update it. Currently clearSelection calls this | 220 // not and will not try to update it. Currently clearSelection calls this |
197 // (intentionally) without updating the layout tree as it doesn't care. | 221 // (intentionally) without updating the layout tree as it doesn't care. |
198 // Other callers may want to force recalc style before calling this. | 222 // Other callers may want to force recalc style before calling this. |
(...skipping 26 matching lines...) Expand all Loading... | |
225 for (SelectedObjectMap::iterator i = old_selected_map.object_map.begin(); | 249 for (SelectedObjectMap::iterator i = old_selected_map.object_map.begin(); |
226 i != old_objects_end; ++i) | 250 i != old_objects_end; ++i) |
227 i->key->SetSelectionStateIfNeeded(SelectionNone); | 251 i->key->SetSelectionStateIfNeeded(SelectionNone); |
228 | 252 |
229 // set selection start and end | 253 // set selection start and end |
230 selection_start_ = start; | 254 selection_start_ = start; |
231 selection_start_pos_ = start_pos; | 255 selection_start_pos_ = start_pos; |
232 selection_end_ = end; | 256 selection_end_ = end; |
233 selection_end_pos_ = end_pos; | 257 selection_end_pos_ = end_pos; |
234 | 258 |
235 // Update the selection status of all objects between m_selectionStart and | 259 MarkSetSelectionState(start, end, end_pos); |
236 // m_selectionEnd | |
237 if (start && start == end) { | |
238 start->SetSelectionStateIfNeeded(SelectionBoth); | |
239 } else { | |
240 if (start) | |
241 start->SetSelectionStateIfNeeded(SelectionStart); | |
242 if (end) | |
243 end->SetSelectionStateIfNeeded(SelectionEnd); | |
244 } | |
245 | |
246 LayoutObject* o = start; | |
247 LayoutObject* const stop = LayoutObjectAfterPosition(end, end_pos); | |
248 | |
249 while (o && o != stop) { | |
250 if (o != start && o != end && o->CanBeSelectionLeaf()) | |
251 o->SetSelectionStateIfNeeded(SelectionInside); | |
252 o = o->NextInPreOrder(); | |
253 } | |
254 | 260 |
255 // Now that the selection state has been updated for the new objects, walk | 261 // Now that the selection state has been updated for the new objects, walk |
256 // them again and put them in the new objects list. | 262 // them again and put them in the new objects list. |
257 // TODO(editing-dev): |new_selected_map| doesn't really need to store the | 263 // TODO(editing-dev): |new_selected_map| doesn't really need to store the |
258 // SelectionState, it's just more convenient to have it use the same data | 264 // SelectionState, it's just more convenient to have it use the same data |
259 // structure as |old_selected_map|. | 265 // structure as |old_selected_map|. |
260 SelectedMap new_selected_map = | 266 SelectedMap new_selected_map = |
261 CollectSelectedMap(start, end, end_pos, kPaintInvalidationNewXOROld); | 267 CollectSelectedMap(start, end, end_pos, kPaintInvalidationNewXOROld); |
262 | 268 |
263 // Have any of the old selected objects changed compared to the new selection? | 269 // Have any of the old selected objects changed compared to the new selection? |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
434 | 440 |
435 o->SetShouldInvalidateSelection(); | 441 o->SetShouldInvalidateSelection(); |
436 } | 442 } |
437 } | 443 } |
438 | 444 |
439 DEFINE_TRACE(LayoutSelection) { | 445 DEFINE_TRACE(LayoutSelection) { |
440 visitor->Trace(frame_selection_); | 446 visitor->Trace(frame_selection_); |
441 } | 447 } |
442 | 448 |
443 } // namespace blink | 449 } // namespace blink |
OLD | NEW |