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

Unified Diff: Source/core/frame/FrameView.cpp

Issue 454643002: Route selection bounds updates through WebLayerTreeView (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: updated to use point based implementation Created 6 years, 3 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
Index: Source/core/frame/FrameView.cpp
diff --git a/Source/core/frame/FrameView.cpp b/Source/core/frame/FrameView.cpp
index 5d42bdac25b2d6c954d44fa2973ecd91db2e3f19..a171547c60e3cc9244c8b4d2f936d93bc17051d3 100644
--- a/Source/core/frame/FrameView.cpp
+++ b/Source/core/frame/FrameView.cpp
@@ -33,6 +33,7 @@
#include "core/css/resolver/StyleResolver.h"
#include "core/dom/DocumentMarkerController.h"
#include "core/editing/FrameSelection.h"
+#include "core/editing/RenderedPosition.h"
#include "core/events/OverflowEvent.h"
#include "core/fetch/ResourceFetcher.h"
#include "core/fetch/ResourceLoadPriorityOptimizer.h"
@@ -65,6 +66,7 @@
#include "core/rendering/RenderWidget.h"
#include "core/rendering/TextAutosizer.h"
#include "core/rendering/compositing/CompositedLayerMapping.h"
+#include "core/rendering/compositing/CompositedSelectionBound.h"
#include "core/rendering/compositing/RenderLayerCompositor.h"
#include "core/rendering/style/RenderStyle.h"
#include "core/rendering/svg/RenderSVGRoot.h"
@@ -1550,6 +1552,39 @@ void FrameView::updateFixedElementPaintInvalidationRectsAfterScroll()
}
}
+static bool computeCompositedSelectionBounds(LocalFrame& frame, CompositedSelectionBound& start, CompositedSelectionBound& end)
+{
+ const VisibleSelection &selection = frame.selection().selection();
+ if (!selection.isCaretOrRange())
+ return false;
+
+ VisiblePosition visibleStart(selection.visibleStart());
+ VisiblePosition visibleEnd(selection.visibleEnd());
+
+ RenderedPosition renderedStart(visibleStart);
+ RenderedPosition renderedEnd(visibleEnd);
+ FloatPoint edgeTop, edgeBottom;
+
+ renderedStart.layerPoints(start.layer, edgeTop, edgeBottom);
+ start.edgeTopInLayer = roundedIntPoint(edgeTop);
aelias_OOO_until_Jul13 2014/09/03 21:13:48 Please keep these as FloatPoint in CompositedSelec
+ start.edgeBottomInLayer = roundedIntPoint(edgeBottom);
+
+ renderedEnd.layerPoints(end.layer, edgeTop, edgeBottom);
+ end.edgeTopInLayer = roundedIntPoint(edgeTop);
+ end.edgeBottomInLayer = roundedIntPoint(edgeBottom);
+
+ if (selection.isCaret()) {
+ start.type = end.type = CompositedSelectionBound::Caret;
+ return true;
+ }
+
+ TextDirection startDir = visibleStart.deepEquivalent().primaryDirection();
+ TextDirection endDir = visibleEnd.deepEquivalent().primaryDirection();
+ start.type = startDir == RTL ? CompositedSelectionBound::SelectionRight : CompositedSelectionBound::SelectionLeft;
+ end.type = endDir == RTL ? CompositedSelectionBound::SelectionLeft : CompositedSelectionBound::SelectionRight;
+ return true;
+}
+
void FrameView::updateCompositedSelectionBoundsIfNeeded()
{
if (!RuntimeEnabledFeatures::compositedSelectionUpdatesEnabled())
@@ -1558,13 +1593,14 @@ void FrameView::updateCompositedSelectionBoundsIfNeeded()
Page* page = frame().page();
ASSERT(page);
+ CompositedSelectionBound start, end;
LocalFrame* frame = toLocalFrame(page->focusController().focusedOrMainFrame());
- if (!frame || !frame->selection().isCaretOrRange()) {
+ if (!frame || !computeCompositedSelectionBounds(*frame, start, end)) {
page->chrome().client().clearCompositedSelectionBounds();
return;
}
- // TODO(jdduke): Compute and route selection bounds through ChromeClient.
+ page->chrome().client().updateCompositedSelectionBounds(start, end);
}
bool FrameView::isRubberBandInProgress() const

Powered by Google App Engine
This is Rietveld 408576698