Chromium Code Reviews| Index: Source/core/frame/FrameView.cpp |
| diff --git a/Source/core/frame/FrameView.cpp b/Source/core/frame/FrameView.cpp |
| index ff2036c34979491b8991335b97a1060b8067ffb6..9a436fe35bda3d82bde794d60b8b1638edcf25cb 100644 |
| --- a/Source/core/frame/FrameView.cpp |
| +++ b/Source/core/frame/FrameView.cpp |
| @@ -34,6 +34,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" |
| @@ -66,6 +67,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" |
| @@ -1507,6 +1509,34 @@ void FrameView::updateLayersAndCompositingAfterScrollIfNeeded() |
| } |
| } |
| +bool FrameView::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, start.edgeTopInLayer, start.edgeBottomInLayer); |
|
chrishtr
2014/09/18 23:30:55
Just pass a CompositedSelectionBound& to layerPoin
trchen
2014/09/19 00:10:02
Acknowledged.
|
| + renderedEnd.layerPoints(end.layer, end.edgeTopInLayer, end.edgeBottomInLayer); |
| + |
| + 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()) |
| @@ -1515,13 +1545,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 |