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

Unified Diff: Source/core/rendering/RenderView.cpp

Issue 696703005: Remove RenderSelectionInfo (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated after Kouhei's comment. Created 6 years, 1 month 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 | « Source/core/rendering/RenderText.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderView.cpp
diff --git a/Source/core/rendering/RenderView.cpp b/Source/core/rendering/RenderView.cpp
index bd48ce87bc32b407df4babd9726baf82be914613..c50e55f56ac8e56054ca9a1bccb71a2513fd6fef 100644
--- a/Source/core/rendering/RenderView.cpp
+++ b/Source/core/rendering/RenderView.cpp
@@ -37,7 +37,6 @@
#include "core/rendering/RenderLayer.h"
#include "core/rendering/RenderPart.h"
#include "core/rendering/RenderQuote.h"
-#include "core/rendering/RenderSelectionInfo.h"
#include "core/rendering/compositing/CompositedLayerMapping.h"
#include "core/rendering/compositing/RenderLayerCompositor.h"
#include "core/svg/SVGDocumentExtensions.h"
@@ -438,23 +437,37 @@ static RenderObject* rendererAfterPosition(RenderObject* object, unsigned offset
return child ? child : object->nextInPreOrderAfterChildren();
}
+static LayoutRect selectionRectForRenderer(const RenderObject* object)
+{
+ if (!object->isRooted())
+ return LayoutRect();
+
+ if (!object->canUpdateSelectionOnRootLineBoxes())
+ return LayoutRect();
+
+ return object->selectionRectForPaintInvalidation(object->containerForPaintInvalidation());
+}
+
IntRect RenderView::selectionBounds() const
{
- typedef WillBeHeapHashMap<RawPtrWillBeMember<RenderObject>, OwnPtrWillBeMember<RenderSelectionInfo> > SelectionMap;
- SelectionMap selectedObjects;
+ // Now create a single bounding box rect that encloses the whole selection.
+ LayoutRect selRect;
+
+ typedef WillBeHeapHashSet<RawPtrWillBeMember<const RenderBlock> > VisitedContainingBlockSet;
+ VisitedContainingBlockSet visitedContainingBlocks;
RenderObject* os = m_selectionStart;
RenderObject* stop = rendererAfterPosition(m_selectionEnd, m_selectionEndPos);
while (os && os != stop) {
if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selectionEnd) && os->selectionState() != SelectionNone) {
// Blocks are responsible for painting line gaps and margin gaps. They must be examined as well.
- selectedObjects.set(os, adoptPtrWillBeNoop(new RenderSelectionInfo(os)));
- RenderBlock* cb = os->containingBlock();
+ selRect.unite(selectionRectForRenderer(os));
+ const RenderBlock* cb = os->containingBlock();
while (cb && !cb->isRenderView()) {
- OwnPtrWillBeMember<RenderSelectionInfo>& blockInfo = selectedObjects.add(cb, nullptr).storedValue->value;
- if (blockInfo)
+ selRect.unite(selectionRectForRenderer(cb));
+ VisitedContainingBlockSet::AddResult addResult = visitedContainingBlocks.add(cb);
+ if (!addResult.isNewEntry)
break;
- blockInfo = adoptPtrWillBeNoop(new RenderSelectionInfo(cb));
cb = cb->containingBlock();
}
}
@@ -462,12 +475,6 @@ IntRect RenderView::selectionBounds() const
os = os->nextInPreOrder();
}
- // Now create a single bounding box rect that encloses the whole selection.
- LayoutRect selRect;
- SelectionMap::iterator end = selectedObjects.end();
- for (SelectionMap::iterator i = selectedObjects.begin(); i != end; ++i)
- selRect.unite(i->value->absoluteSelectionRect());
-
return pixelSnappedIntRect(selRect);
}
« no previous file with comments | « Source/core/rendering/RenderText.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698