Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Unified Diff: third_party/WebKit/Source/core/editing/LayoutSelection.cpp

Issue 2938133002: Refactor LayoutSelection::SelectionBounds() with CollectSelectedMap(). (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/LayoutSelection.cpp
diff --git a/third_party/WebKit/Source/core/editing/LayoutSelection.cpp b/third_party/WebKit/Source/core/editing/LayoutSelection.cpp
index 39c940b8c118bd147f519ad317dee8c11e496837..d94c6482ea6e6c022c2e2be0955179e909e4b311 100644
--- a/third_party/WebKit/Source/core/editing/LayoutSelection.cpp
+++ b/third_party/WebKit/Source/core/editing/LayoutSelection.cpp
@@ -406,36 +406,19 @@ static LayoutRect SelectionRectForLayoutObject(const LayoutObject* object) {
}
IntRect LayoutSelection::SelectionBounds() {
- // Now create a single bounding box rect that encloses the whole selection.
- LayoutRect sel_rect;
-
- typedef HashSet<const LayoutBlock*> VisitedContainingBlockSet;
- VisitedContainingBlockSet visited_containing_blocks;
-
Commit();
if (paint_range_.IsNull())
return IntRect();
- // TODO(yoichio): Use CollectSelectedMap.
- for (LayoutObject* runner : paint_range_) {
- if (runner->GetSelectionState() == SelectionState::kNone)
- continue;
-
- // Blocks are responsible for painting line gaps and margin gaps. They
- // must be examined as well.
- sel_rect.Unite(SelectionRectForLayoutObject(runner));
- const LayoutBlock* cb = runner->ContainingBlock();
- while (cb && !cb->IsLayoutView()) {
- sel_rect.Unite(SelectionRectForLayoutObject(cb));
- VisitedContainingBlockSet::AddResult add_result =
- visited_containing_blocks.insert(cb);
- if (!add_result.is_new_entry)
- break;
- cb = cb->ContainingBlock();
- }
- }
+ // Create a single bounding box rect that encloses the whole selection.
+ LayoutRect selected_rect;
+ const SelectedMap& current_map = CollectSelectedMap(paint_range_);
+ for (auto layout_object : current_map.object_map.Keys())
+ selected_rect.Unite(SelectionRectForLayoutObject(layout_object));
+ for (auto layout_block : current_map.block_map.Keys())
+ selected_rect.Unite(SelectionRectForLayoutObject(layout_block));
- return PixelSnappedIntRect(sel_rect);
+ return PixelSnappedIntRect(selected_rect);
}
void LayoutSelection::InvalidatePaintForSelection() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698