Chromium Code Reviews| 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 17 matching lines...) Expand all Loading... | |
| 28 #include "core/editing/VisibleUnits.h" | 28 #include "core/editing/VisibleUnits.h" |
| 29 #include "core/html/TextControlElement.h" | 29 #include "core/html/TextControlElement.h" |
| 30 #include "core/layout/LayoutView.h" | 30 #include "core/layout/LayoutView.h" |
| 31 #include "core/paint/PaintLayer.h" | 31 #include "core/paint/PaintLayer.h" |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 LayoutSelection::LayoutSelection(FrameSelection& frame_selection) | 35 LayoutSelection::LayoutSelection(FrameSelection& frame_selection) |
| 36 : frame_selection_(&frame_selection), | 36 : frame_selection_(&frame_selection), |
| 37 has_pending_selection_(false), | 37 has_pending_selection_(false), |
| 38 selection_start_(nullptr), | 38 paint_range_(SelectionPaintRange()) {} |
| 39 selection_end_(nullptr), | |
| 40 selection_start_pos_(-1), | |
| 41 selection_end_pos_(-1) {} | |
| 42 | 39 |
| 43 SelectionInFlatTree LayoutSelection::CalcVisibleSelection( | 40 SelectionInFlatTree LayoutSelection::CalcVisibleSelection( |
| 44 const VisibleSelectionInFlatTree& original_selection) const { | 41 const VisibleSelectionInFlatTree& original_selection) const { |
| 45 const PositionInFlatTree& start = original_selection.Start(); | 42 const PositionInFlatTree& start = original_selection.Start(); |
| 46 const PositionInFlatTree& end = original_selection.end(); | 43 const PositionInFlatTree& end = original_selection.end(); |
| 47 SelectionType selection_type = original_selection.GetSelectionType(); | 44 SelectionType selection_type = original_selection.GetSelectionType(); |
| 48 const TextAffinity affinity = original_selection.Affinity(); | 45 const TextAffinity affinity = original_selection.Affinity(); |
| 49 | 46 |
| 50 bool paint_block_cursor = | 47 bool paint_block_cursor = |
| 51 frame_selection_->ShouldShowBlockCursor() && | 48 frame_selection_->ShouldShowBlockCursor() && |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 SelectedMap(SelectedMap&& other) { | 114 SelectedMap(SelectedMap&& other) { |
| 118 object_map = std::move(other.object_map); | 115 object_map = std::move(other.object_map); |
| 119 block_map = std::move(other.block_map); | 116 block_map = std::move(other.block_map); |
| 120 } | 117 } |
| 121 | 118 |
| 122 private: | 119 private: |
| 123 DISALLOW_COPY_AND_ASSIGN(SelectedMap); | 120 DISALLOW_COPY_AND_ASSIGN(SelectedMap); |
| 124 }; | 121 }; |
| 125 | 122 |
| 126 static SelectedMap CollectSelectedMap( | 123 static SelectedMap CollectSelectedMap( |
| 127 LayoutObject* selection_start, | 124 const SelectionPaintRange& range, |
| 128 LayoutObject* selection_end, | |
| 129 int selection_end_pos, | |
| 130 LayoutSelection::SelectionPaintInvalidationMode | 125 LayoutSelection::SelectionPaintInvalidationMode |
| 131 block_paint_invalidation_mode) { | 126 block_paint_invalidation_mode) { |
| 132 SelectedMap selected_map; | 127 SelectedMap selected_map; |
| 133 | 128 |
| 134 LayoutObject* const stop = | 129 LayoutObject* const stop = |
| 135 LayoutObjectAfterPosition(selection_end, selection_end_pos); | 130 LayoutObjectAfterPosition(range.end_layout_object_, range.end_offset_); |
| 136 for (LayoutObject* runner = selection_start; runner && (runner != stop); | 131 for (LayoutObject* runner = range.start_layout_object_; |
| 137 runner = runner->NextInPreOrder()) { | 132 runner && (runner != stop); runner = runner->NextInPreOrder()) { |
| 138 if (!runner->CanBeSelectionLeaf() && runner != selection_start && | 133 if (!runner->CanBeSelectionLeaf() && runner != range.start_layout_object_ && |
| 139 runner != selection_end) | 134 runner != range.end_layout_object_) |
| 140 continue; | 135 continue; |
| 141 if (runner->GetSelectionState() == SelectionNone) | 136 if (runner->GetSelectionState() == SelectionNone) |
| 142 continue; | 137 continue; |
| 143 | 138 |
| 144 // Blocks are responsible for painting line gaps and margin gaps. They | 139 // Blocks are responsible for painting line gaps and margin gaps. They |
| 145 // must be examined as well. | 140 // must be examined as well. |
| 146 selected_map.object_map.Set(runner, runner->GetSelectionState()); | 141 selected_map.object_map.Set(runner, runner->GetSelectionState()); |
| 147 if (block_paint_invalidation_mode == | 142 if (block_paint_invalidation_mode == |
| 148 LayoutSelection::kPaintInvalidationNewXOROld) { | 143 LayoutSelection::kPaintInvalidationNewXOROld) { |
| 149 LayoutBlock* containing_block = runner->ContainingBlock(); | 144 LayoutBlock* containing_block = runner->ContainingBlock(); |
| 150 while (containing_block && !containing_block->IsLayoutView()) { | 145 while (containing_block && !containing_block->IsLayoutView()) { |
| 151 SelectedBlockMap::AddResult result = selected_map.block_map.insert( | 146 SelectedBlockMap::AddResult result = selected_map.block_map.insert( |
| 152 containing_block, containing_block->GetSelectionState()); | 147 containing_block, containing_block->GetSelectionState()); |
| 153 if (!result.is_new_entry) | 148 if (!result.is_new_entry) |
| 154 break; | 149 break; |
| 155 containing_block = containing_block->ContainingBlock(); | 150 containing_block = containing_block->ContainingBlock(); |
| 156 } | 151 } |
| 157 } | 152 } |
| 158 } | 153 } |
| 159 return selected_map; | 154 return selected_map; |
| 160 } | 155 } |
| 161 | 156 |
| 162 // Update the selection status of all LayoutObjects between |start| and |end|. | 157 // Update the selection status of all LayoutObjects between |start| and |end|. |
| 163 static void SetSelectionState(LayoutObject* start, | 158 static void SetSelectionState(const SelectionPaintRange& range) { |
| 164 LayoutObject* end, | 159 DCHECK(range.start_layout_object_); |
| 165 int end_pos) { | 160 DCHECK(range.end_layout_object_); |
| 166 if (start && start == end) { | 161 if (range.start_layout_object_ == range.end_layout_object_) { |
| 167 start->SetSelectionStateIfNeeded(SelectionBoth); | 162 range.start_layout_object_->SetSelectionStateIfNeeded(SelectionBoth); |
| 168 } else { | 163 } else { |
| 169 if (start) | 164 range.start_layout_object_->SetSelectionStateIfNeeded(SelectionStart); |
| 170 start->SetSelectionStateIfNeeded(SelectionStart); | 165 range.end_layout_object_->SetSelectionStateIfNeeded(SelectionEnd); |
| 171 if (end) | |
| 172 end->SetSelectionStateIfNeeded(SelectionEnd); | |
| 173 } | 166 } |
| 174 | 167 |
| 175 LayoutObject* const stop = LayoutObjectAfterPosition(end, end_pos); | 168 LayoutObject* const stop = |
| 176 for (LayoutObject* runner = start; runner && runner != stop; | 169 LayoutObjectAfterPosition(range.end_layout_object_, range.end_offset_); |
| 177 runner = runner->NextInPreOrder()) { | 170 for (LayoutObject* runner = range.start_layout_object_; |
| 178 if (runner != start && runner != end && runner->CanBeSelectionLeaf()) | 171 runner && runner != stop; runner = runner->NextInPreOrder()) { |
| 172 if (runner != range.start_layout_object_ && | |
| 173 runner != range.end_layout_object_ && runner->CanBeSelectionLeaf()) | |
| 179 runner->SetSelectionStateIfNeeded(SelectionInside); | 174 runner->SetSelectionStateIfNeeded(SelectionInside); |
| 180 } | 175 } |
| 181 } | 176 } |
| 182 | 177 |
| 183 void LayoutSelection::SetSelection( | 178 void LayoutSelection::SetSelection( |
| 184 LayoutObject* start, | 179 const SelectionPaintRange& new_range, |
| 185 int start_pos, | |
| 186 LayoutObject* end, | |
| 187 int end_pos, | |
| 188 SelectionPaintInvalidationMode block_paint_invalidation_mode) { | 180 SelectionPaintInvalidationMode block_paint_invalidation_mode) { |
| 189 DCHECK(start); | 181 DCHECK(new_range.start_layout_object_); |
|
yosin_UTC9
2017/05/24 08:38:46
Once ctor has DCHECK's for members, we don't need
yoichio
2017/05/24 09:09:29
How about null SelectionPaintRange?
yosin_UTC9
2017/05/24 09:31:18
We need to check null SelectionPaintRange.
Is it b
| |
| 190 DCHECK(end); | 182 DCHECK(new_range.end_layout_object_); |
| 191 | 183 |
| 192 // Just return if the selection hasn't changed. | 184 // Just return if the selection hasn't changed. |
| 193 if (selection_start_ == start && selection_start_pos_ == start_pos && | 185 if (paint_range_ == new_range) |
| 194 selection_end_ == end && selection_end_pos_ == end_pos) | |
| 195 return; | 186 return; |
| 196 | 187 |
| 197 DCHECK(frame_selection_->GetDocument().GetLayoutView()->GetFrameView()); | 188 DCHECK(frame_selection_->GetDocument().GetLayoutView()->GetFrameView()); |
| 198 DCHECK(!frame_selection_->GetDocument().NeedsLayoutTreeUpdate()); | 189 DCHECK(!frame_selection_->GetDocument().NeedsLayoutTreeUpdate()); |
| 199 | 190 |
| 200 SelectedMap old_selected_map = | 191 SelectedMap old_selected_map = |
| 201 CollectSelectedMap(selection_start_, selection_end_, selection_end_pos_, | 192 CollectSelectedMap(paint_range_, block_paint_invalidation_mode); |
| 202 block_paint_invalidation_mode); | |
| 203 | 193 |
| 204 // Now clear the selection. | 194 // Now clear the selection. |
| 205 for (auto layout_object : old_selected_map.object_map.Keys()) | 195 for (auto layout_object : old_selected_map.object_map.Keys()) |
| 206 layout_object->SetSelectionStateIfNeeded(SelectionNone); | 196 layout_object->SetSelectionStateIfNeeded(SelectionNone); |
| 207 | 197 |
| 208 SetSelectionState(start, end, end_pos); | 198 SetSelectionState(new_range); |
| 209 | 199 |
| 210 // Now that the selection state has been updated for the new objects, walk | 200 // Now that the selection state has been updated for the new objects, walk |
| 211 // them again and put them in the new objects list. | 201 // them again and put them in the new objects list. |
| 212 // TODO(editing-dev): |new_selected_map| doesn't really need to store the | 202 // TODO(editing-dev): |new_selected_map| doesn't really need to store the |
| 213 // SelectionState, it's just more convenient to have it use the same data | 203 // SelectionState, it's just more convenient to have it use the same data |
| 214 // structure as |old_selected_map|. | 204 // structure as |old_selected_map|. |
| 215 SelectedMap new_selected_map = | 205 SelectedMap new_selected_map = |
| 216 CollectSelectedMap(start, end, end_pos, kPaintInvalidationNewXOROld); | 206 CollectSelectedMap(new_range, kPaintInvalidationNewXOROld); |
| 217 | 207 |
| 218 // Have any of the old selected objects changed compared to the new selection? | 208 // Have any of the old selected objects changed compared to the new selection? |
| 219 for (const auto& pair : old_selected_map.object_map) { | 209 for (const auto& pair : old_selected_map.object_map) { |
| 220 LayoutObject* obj = pair.key; | 210 LayoutObject* obj = pair.key; |
| 221 SelectionState new_selection_state = obj->GetSelectionState(); | 211 SelectionState new_selection_state = obj->GetSelectionState(); |
| 222 SelectionState old_selection_state = pair.value; | 212 SelectionState old_selection_state = pair.value; |
| 223 if (new_selection_state != old_selection_state || | 213 if (new_selection_state != old_selection_state || |
| 224 (start == obj && start_pos != selection_start_pos_) || | 214 (new_range.start_layout_object_ == obj && |
|
yosin_UTC9
2017/05/24 08:38:46
Can we use SelectionPaintRange::operator!=()?
e.g.
yoichio
2017/05/24 09:09:29
This is not SelectionPaintRange compare.
| |
| 225 (end == obj && end_pos != selection_end_pos_)) { | 215 new_range.start_offset_ != paint_range_.start_offset_) || |
| 216 (new_range.end_layout_object_ == obj && | |
| 217 new_range.end_offset_ != paint_range_.end_offset_)) { | |
| 226 obj->SetShouldInvalidateSelection(); | 218 obj->SetShouldInvalidateSelection(); |
| 227 new_selected_map.object_map.erase(obj); | 219 new_selected_map.object_map.erase(obj); |
| 228 } | 220 } |
| 229 } | 221 } |
| 230 | 222 |
| 231 // Any new objects that remain were not found in the old objects dict, and so | 223 // Any new objects that remain were not found in the old objects dict, and so |
| 232 // they need to be updated. | 224 // they need to be updated. |
| 233 for (auto layout_object : new_selected_map.object_map.Keys()) | 225 for (auto layout_object : new_selected_map.object_map.Keys()) |
| 234 layout_object->SetShouldInvalidateSelection(); | 226 layout_object->SetShouldInvalidateSelection(); |
| 235 | 227 |
| 236 // Have any of the old blocks changed? | 228 // Have any of the old blocks changed? |
| 237 for (const auto& pair : old_selected_map.block_map) { | 229 for (const auto& pair : old_selected_map.block_map) { |
| 238 LayoutBlock* block = pair.key; | 230 LayoutBlock* block = pair.key; |
| 239 SelectionState new_selection_state = block->GetSelectionState(); | 231 SelectionState new_selection_state = block->GetSelectionState(); |
| 240 SelectionState old_selection_state = pair.value; | 232 SelectionState old_selection_state = pair.value; |
| 241 if (new_selection_state != old_selection_state) { | 233 if (new_selection_state != old_selection_state) { |
| 242 block->SetShouldInvalidateSelection(); | 234 block->SetShouldInvalidateSelection(); |
| 243 new_selected_map.block_map.erase(block); | 235 new_selected_map.block_map.erase(block); |
| 244 } | 236 } |
| 245 } | 237 } |
| 246 | 238 |
| 247 // Any new blocks that remain were not found in the old blocks dict, and so | 239 // Any new blocks that remain were not found in the old blocks dict, and so |
| 248 // they need to be updated. | 240 // they need to be updated. |
| 249 for (auto layout_object : new_selected_map.block_map.Keys()) | 241 for (auto layout_object : new_selected_map.block_map.Keys()) |
| 250 layout_object->SetShouldInvalidateSelection(); | 242 layout_object->SetShouldInvalidateSelection(); |
| 251 | 243 |
| 252 // set selection start and end | 244 paint_range_ = new_range; |
| 253 selection_start_ = start; | |
| 254 selection_start_pos_ = start_pos; | |
| 255 selection_end_ = end; | |
| 256 selection_end_pos_ = end_pos; | |
| 257 } | 245 } |
| 258 | 246 |
| 259 std::pair<int, int> LayoutSelection::SelectionStartEnd() { | 247 std::pair<int, int> LayoutSelection::SelectionStartEnd() { |
| 260 Commit(); | 248 Commit(); |
| 261 return std::make_pair(selection_start_pos_, selection_end_pos_); | 249 return std::make_pair(paint_range_.start_offset_, paint_range_.end_offset_); |
| 262 } | 250 } |
| 263 | 251 |
| 264 void LayoutSelection::ClearSelection() { | 252 void LayoutSelection::ClearSelection() { |
| 265 // For querying Layer::compositingState() | 253 // For querying Layer::compositingState() |
| 266 // This is correct, since destroying layout objects needs to cause eager paint | 254 // This is correct, since destroying layout objects needs to cause eager paint |
| 267 // invalidations. | 255 // invalidations. |
| 268 DisableCompositingQueryAsserts disabler; | 256 DisableCompositingQueryAsserts disabler; |
| 269 | 257 |
| 270 // Just return if the selection hasn't changed. | 258 // Just return if the selection is already empty. |
| 271 if (!selection_start_) { | 259 if (paint_range_ == SelectionPaintRange()) |
| 272 DCHECK_EQ(selection_end_, nullptr); | |
| 273 DCHECK_EQ(selection_start_pos_, -1); | |
| 274 DCHECK_EQ(selection_end_pos_, -1); | |
| 275 return; | 260 return; |
| 276 } | |
| 277 | 261 |
| 278 const SelectedMap& old_selected_map = | 262 const SelectedMap& old_selected_map = |
| 279 CollectSelectedMap(selection_start_, selection_end_, selection_end_pos_, | 263 CollectSelectedMap(paint_range_, kPaintInvalidationNewMinusOld); |
| 280 kPaintInvalidationNewMinusOld); | |
| 281 // Clear SelectionState and invalidation. | 264 // Clear SelectionState and invalidation. |
| 282 for (auto layout_object : old_selected_map.object_map.Keys()) { | 265 for (auto layout_object : old_selected_map.object_map.Keys()) { |
| 283 const SelectionState old_state = layout_object->GetSelectionState(); | 266 const SelectionState old_state = layout_object->GetSelectionState(); |
| 284 layout_object->SetSelectionStateIfNeeded(SelectionNone); | 267 layout_object->SetSelectionStateIfNeeded(SelectionNone); |
| 285 if (layout_object->GetSelectionState() == old_state) | 268 if (layout_object->GetSelectionState() == old_state) |
| 286 continue; | 269 continue; |
| 287 layout_object->SetShouldInvalidateSelection(); | 270 layout_object->SetShouldInvalidateSelection(); |
| 288 } | 271 } |
| 289 | 272 |
| 290 // Reset selection start and end. | 273 // Reset selection start and end. |
| 291 selection_start_ = nullptr; | 274 paint_range_ = SelectionPaintRange(); |
| 292 selection_start_pos_ = -1; | |
| 293 selection_end_ = nullptr; | |
| 294 selection_end_pos_ = -1; | |
| 295 } | 275 } |
| 296 | 276 |
| 297 void LayoutSelection::Commit() { | 277 void LayoutSelection::Commit() { |
| 298 if (!HasPendingSelection()) | 278 if (!HasPendingSelection()) |
| 299 return; | 279 return; |
| 300 has_pending_selection_ = false; | 280 has_pending_selection_ = false; |
| 301 | 281 |
| 302 const VisibleSelectionInFlatTree& original_selection = | 282 const VisibleSelectionInFlatTree& original_selection = |
| 303 frame_selection_->ComputeVisibleSelectionInFlatTree(); | 283 frame_selection_->ComputeVisibleSelectionInFlatTree(); |
| 304 | 284 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 335 if (start_pos.IsNull() || end_pos.IsNull() || | 315 if (start_pos.IsNull() || end_pos.IsNull() || |
| 336 selection.VisibleStart().DeepEquivalent() == | 316 selection.VisibleStart().DeepEquivalent() == |
| 337 selection.VisibleEnd().DeepEquivalent()) | 317 selection.VisibleEnd().DeepEquivalent()) |
| 338 return; | 318 return; |
| 339 DCHECK_LE(start_pos, end_pos); | 319 DCHECK_LE(start_pos, end_pos); |
| 340 LayoutObject* start_layout_object = start_pos.AnchorNode()->GetLayoutObject(); | 320 LayoutObject* start_layout_object = start_pos.AnchorNode()->GetLayoutObject(); |
| 341 LayoutObject* end_layout_object = end_pos.AnchorNode()->GetLayoutObject(); | 321 LayoutObject* end_layout_object = end_pos.AnchorNode()->GetLayoutObject(); |
| 342 if (!start_layout_object || !end_layout_object) | 322 if (!start_layout_object || !end_layout_object) |
| 343 return; | 323 return; |
| 344 DCHECK(start_layout_object->View() == end_layout_object->View()); | 324 DCHECK(start_layout_object->View() == end_layout_object->View()); |
| 345 SetSelection(start_layout_object, start_pos.ComputeEditingOffset(), | 325 SetSelection( |
| 346 end_layout_object, end_pos.ComputeEditingOffset()); | 326 SelectionPaintRange(start_layout_object, start_pos.ComputeEditingOffset(), |
| 327 end_layout_object, end_pos.ComputeEditingOffset())); | |
| 347 } | 328 } |
| 348 | 329 |
| 349 void LayoutSelection::OnDocumentShutdown() { | 330 void LayoutSelection::OnDocumentShutdown() { |
| 350 has_pending_selection_ = false; | 331 has_pending_selection_ = false; |
| 351 selection_start_ = nullptr; | 332 paint_range_ = SelectionPaintRange(); |
| 352 selection_end_ = nullptr; | |
| 353 selection_start_pos_ = -1; | |
| 354 selection_end_pos_ = -1; | |
| 355 } | 333 } |
| 356 | 334 |
| 357 static LayoutRect SelectionRectForLayoutObject(const LayoutObject* object) { | 335 static LayoutRect SelectionRectForLayoutObject(const LayoutObject* object) { |
| 358 if (!object->IsRooted()) | 336 if (!object->IsRooted()) |
| 359 return LayoutRect(); | 337 return LayoutRect(); |
| 360 | 338 |
| 361 if (!object->CanUpdateSelectionOnRootLineBoxes()) | 339 if (!object->CanUpdateSelectionOnRootLineBoxes()) |
| 362 return LayoutRect(); | 340 return LayoutRect(); |
| 363 | 341 |
| 364 return object->SelectionRectInViewCoordinates(); | 342 return object->SelectionRectInViewCoordinates(); |
| 365 } | 343 } |
| 366 | 344 |
| 367 IntRect LayoutSelection::SelectionBounds() { | 345 IntRect LayoutSelection::SelectionBounds() { |
| 368 // Now create a single bounding box rect that encloses the whole selection. | 346 // Now create a single bounding box rect that encloses the whole selection. |
| 369 LayoutRect sel_rect; | 347 LayoutRect sel_rect; |
| 370 | 348 |
| 371 typedef HashSet<const LayoutBlock*> VisitedContainingBlockSet; | 349 typedef HashSet<const LayoutBlock*> VisitedContainingBlockSet; |
| 372 VisitedContainingBlockSet visited_containing_blocks; | 350 VisitedContainingBlockSet visited_containing_blocks; |
| 373 | 351 |
| 374 Commit(); | 352 Commit(); |
| 375 LayoutObject* os = selection_start_; | 353 LayoutObject* os = paint_range_.start_layout_object_; |
| 376 LayoutObject* stop = | 354 LayoutObject* stop = LayoutObjectAfterPosition( |
| 377 LayoutObjectAfterPosition(selection_end_, selection_end_pos_); | 355 paint_range_.end_layout_object_, paint_range_.end_offset_); |
| 378 while (os && os != stop) { | 356 while (os && os != stop) { |
| 379 if ((os->CanBeSelectionLeaf() || os == selection_start_ || | 357 if ((os->CanBeSelectionLeaf() || os == paint_range_.start_layout_object_ || |
| 380 os == selection_end_) && | 358 os == paint_range_.end_layout_object_) && |
| 381 os->GetSelectionState() != SelectionNone) { | 359 os->GetSelectionState() != SelectionNone) { |
| 382 // Blocks are responsible for painting line gaps and margin gaps. They | 360 // Blocks are responsible for painting line gaps and margin gaps. They |
| 383 // must be examined as well. | 361 // must be examined as well. |
| 384 sel_rect.Unite(SelectionRectForLayoutObject(os)); | 362 sel_rect.Unite(SelectionRectForLayoutObject(os)); |
| 385 const LayoutBlock* cb = os->ContainingBlock(); | 363 const LayoutBlock* cb = os->ContainingBlock(); |
| 386 while (cb && !cb->IsLayoutView()) { | 364 while (cb && !cb->IsLayoutView()) { |
| 387 sel_rect.Unite(SelectionRectForLayoutObject(cb)); | 365 sel_rect.Unite(SelectionRectForLayoutObject(cb)); |
| 388 VisitedContainingBlockSet::AddResult add_result = | 366 VisitedContainingBlockSet::AddResult add_result = |
| 389 visited_containing_blocks.insert(cb); | 367 visited_containing_blocks.insert(cb); |
| 390 if (!add_result.is_new_entry) | 368 if (!add_result.is_new_entry) |
| 391 break; | 369 break; |
| 392 cb = cb->ContainingBlock(); | 370 cb = cb->ContainingBlock(); |
| 393 } | 371 } |
| 394 } | 372 } |
| 395 | 373 |
| 396 os = os->NextInPreOrder(); | 374 os = os->NextInPreOrder(); |
| 397 } | 375 } |
| 398 | 376 |
| 399 return PixelSnappedIntRect(sel_rect); | 377 return PixelSnappedIntRect(sel_rect); |
| 400 } | 378 } |
| 401 | 379 |
| 402 void LayoutSelection::InvalidatePaintForSelection() { | 380 void LayoutSelection::InvalidatePaintForSelection() { |
| 403 LayoutObject* end = | 381 LayoutObject* end = LayoutObjectAfterPosition(paint_range_.end_layout_object_, |
| 404 LayoutObjectAfterPosition(selection_end_, selection_end_pos_); | 382 paint_range_.end_offset_); |
| 405 for (LayoutObject* o = selection_start_; o && o != end; | 383 for (LayoutObject* o = paint_range_.start_layout_object_; o && o != end; |
| 406 o = o->NextInPreOrder()) { | 384 o = o->NextInPreOrder()) { |
| 407 if (!o->CanBeSelectionLeaf() && o != selection_start_ && | 385 if (!o->CanBeSelectionLeaf() && o != paint_range_.start_layout_object_ && |
| 408 o != selection_end_) | 386 o != paint_range_.end_layout_object_) |
| 409 continue; | 387 continue; |
| 410 if (o->GetSelectionState() == SelectionNone) | 388 if (o->GetSelectionState() == SelectionNone) |
| 411 continue; | 389 continue; |
| 412 | 390 |
| 413 o->SetShouldInvalidateSelection(); | 391 o->SetShouldInvalidateSelection(); |
| 414 } | 392 } |
| 415 } | 393 } |
| 416 | 394 |
| 417 DEFINE_TRACE(LayoutSelection) { | 395 DEFINE_TRACE(LayoutSelection) { |
| 418 visitor->Trace(frame_selection_); | 396 visitor->Trace(frame_selection_); |
| 419 } | 397 } |
| 420 | 398 |
| 421 } // namespace blink | 399 } // namespace blink |
| OLD | NEW |