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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 if (!object->IsRooted()) | 399 if (!object->IsRooted()) |
400 return LayoutRect(); | 400 return LayoutRect(); |
401 | 401 |
402 if (!object->CanUpdateSelectionOnRootLineBoxes()) | 402 if (!object->CanUpdateSelectionOnRootLineBoxes()) |
403 return LayoutRect(); | 403 return LayoutRect(); |
404 | 404 |
405 return object->SelectionRectInViewCoordinates(); | 405 return object->SelectionRectInViewCoordinates(); |
406 } | 406 } |
407 | 407 |
408 IntRect LayoutSelection::SelectionBounds() { | 408 IntRect LayoutSelection::SelectionBounds() { |
409 // Now create a single bounding box rect that encloses the whole selection. | |
410 LayoutRect sel_rect; | |
411 | |
412 typedef HashSet<const LayoutBlock*> VisitedContainingBlockSet; | |
413 VisitedContainingBlockSet visited_containing_blocks; | |
414 | |
415 Commit(); | 409 Commit(); |
416 if (paint_range_.IsNull()) | 410 if (paint_range_.IsNull()) |
417 return IntRect(); | 411 return IntRect(); |
418 | 412 |
419 // TODO(yoichio): Use CollectSelectedMap. | 413 // Create a single bounding box rect that encloses the whole selection. |
420 for (LayoutObject* runner : paint_range_) { | 414 LayoutRect selected_rect; |
421 if (runner->GetSelectionState() == SelectionState::kNone) | 415 const SelectedMap& current_map = CollectSelectedMap(paint_range_); |
422 continue; | 416 for (auto layout_object : current_map.object_map.Keys()) |
| 417 selected_rect.Unite(SelectionRectForLayoutObject(layout_object)); |
| 418 for (auto layout_block : current_map.block_map.Keys()) |
| 419 selected_rect.Unite(SelectionRectForLayoutObject(layout_block)); |
423 | 420 |
424 // Blocks are responsible for painting line gaps and margin gaps. They | 421 return PixelSnappedIntRect(selected_rect); |
425 // must be examined as well. | |
426 sel_rect.Unite(SelectionRectForLayoutObject(runner)); | |
427 const LayoutBlock* cb = runner->ContainingBlock(); | |
428 while (cb && !cb->IsLayoutView()) { | |
429 sel_rect.Unite(SelectionRectForLayoutObject(cb)); | |
430 VisitedContainingBlockSet::AddResult add_result = | |
431 visited_containing_blocks.insert(cb); | |
432 if (!add_result.is_new_entry) | |
433 break; | |
434 cb = cb->ContainingBlock(); | |
435 } | |
436 } | |
437 | |
438 return PixelSnappedIntRect(sel_rect); | |
439 } | 422 } |
440 | 423 |
441 void LayoutSelection::InvalidatePaintForSelection() { | 424 void LayoutSelection::InvalidatePaintForSelection() { |
442 if (paint_range_.IsNull()) | 425 if (paint_range_.IsNull()) |
443 return; | 426 return; |
444 | 427 |
445 for (LayoutObject* runner : paint_range_) { | 428 for (LayoutObject* runner : paint_range_) { |
446 if (runner->GetSelectionState() == SelectionState::kNone) | 429 if (runner->GetSelectionState() == SelectionState::kNone) |
447 continue; | 430 continue; |
448 | 431 |
449 runner->SetShouldInvalidateSelection(); | 432 runner->SetShouldInvalidateSelection(); |
450 } | 433 } |
451 } | 434 } |
452 | 435 |
453 DEFINE_TRACE(LayoutSelection) { | 436 DEFINE_TRACE(LayoutSelection) { |
454 visitor->Trace(frame_selection_); | 437 visitor->Trace(frame_selection_); |
455 } | 438 } |
456 | 439 |
457 } // namespace blink | 440 } // namespace blink |
OLD | NEW |