Index: Source/web/WebViewImpl.cpp |
diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp |
index f1b2e0cc5c66d1e1bca37ee7cfc4abd946ad9659..1fb476b705954f5ffa05bc931facd304b49a0195 100644 |
--- a/Source/web/WebViewImpl.cpp |
+++ b/Source/web/WebViewImpl.cpp |
@@ -123,6 +123,7 @@ |
#include "public/web/WebPlugin.h" |
#include "public/web/WebPluginAction.h" |
#include "public/web/WebRange.h" |
+#include "public/web/WebSelection.h" |
#include "public/web/WebTextInputInfo.h" |
#include "public/web/WebViewClient.h" |
#include "public/web/WebWindowFeatures.h" |
@@ -1718,6 +1719,8 @@ void WebViewImpl::layout() |
for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
m_linkHighlights[i]->updateGeometry(); |
+ |
+ updateLayerTreeSelection(); |
abarth-chromium
2014/06/13 21:38:15
This shouldn't be a separate set in WebViewImpl::l
jdduke (slow)
2014/06/24 18:22:07
Done.
|
} |
void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect) |
@@ -4009,6 +4012,91 @@ void WebViewImpl::updateRootLayerTransform() |
} |
} |
+static bool computeCompositedLayerAndRect(Node* node, IntRect absoluteRect, int& layerId, WebRect& layerRect) |
+{ |
+ RenderLayer* renderLayer; |
+ GraphicsLayer* graphicsLayer; |
+ if (!RenderLayerCompositor::computeEnclosingCompositingLayer(node, renderLayer, graphicsLayer)) |
+ return false; |
+ |
+ ASSERT(renderLayer); |
+ ASSERT(graphicsLayer); |
+ |
+ absoluteRect.move(-graphicsLayer->offsetFromRenderer()); |
+ FloatQuad absoluteQuad(absoluteRect); |
+ FloatQuad layerQuad; |
+ RenderLayerCompositor::convertTargetSpaceQuadToCompositedLayer(absoluteQuad, node->renderer(), renderLayer->renderer(), layerQuad); |
+ |
+ layerRect = layerQuad.enclosingBoundingBox(); |
+ layerId = graphicsLayer->platformLayer()->id(); |
+ |
+ return true; |
+} |
abarth-chromium
2014/06/13 21:38:15
We won't need to do this work in the correct desig
jdduke (slow)
2014/06/24 18:22:07
How will we know this, and where is the correct tr
|
+ |
+void WebViewImpl::updateLayerTreeSelection() |
+{ |
+ if (!m_layerTreeView || !settings()->compositedSelectionUpdatesEnabled()) |
+ return; |
+ |
+ const LocalFrame* frame = toLocalFrame(focusedWebCoreFrame()); |
+ if (!frame || !frame->selection().isCaretOrRange()) |
+ return m_layerTreeView->clearSelection(); |
abarth-chromium
2014/06/13 21:38:15
Instead of polling blink_core to see whether !fram
jdduke (slow)
2014/06/24 18:22:07
Done.
|
+ |
+ FrameSelection& selection = frame->selection(); |
+ |
+ if (selection.isCaret()) { |
+ WebSelection webSelection; |
+ if (!computeCompositedLayerAndRect(selection.rootEditableElementOrDocumentElement(), |
+ selection.absoluteCaretBounds(), |
+ webSelection.anchorLayerId, |
+ webSelection.anchorRectInLayer)) { |
+ return m_layerTreeView->clearSelection(); |
+ } |
+ |
+ webSelection.type = WebSelection::TypeInsertion; |
+ m_layerTreeView->registerSelection(webSelection); |
+ return; |
+ } |
+ |
+ RefPtrWillBeRawPtr<Range> selectedRange = selection.toNormalizedRange(); |
+ if (!selectedRange) |
+ return m_layerTreeView->clearSelection(); |
+ |
+ WebSelection webSelection; |
+ |
+ RefPtrWillBeRawPtr<Range> range(Range::create(selectedRange->startContainer()->document(), |
+ selectedRange->startContainer(), |
+ selectedRange->startOffset(), |
+ selectedRange->startContainer(), |
+ selectedRange->startOffset())); |
+ IntRect anchor = frame->editor().firstRectForRange(range.get()); |
+ if (!computeCompositedLayerAndRect(selection.start().anchorNode(), |
+ anchor, |
+ webSelection.anchorLayerId, |
+ webSelection.anchorRectInLayer)) { |
+ return m_layerTreeView->clearSelection(); |
+ } |
+ |
+ range = Range::create(selectedRange->endContainer()->document(), |
+ selectedRange->endContainer(), |
+ selectedRange->endOffset(), |
+ selectedRange->endContainer(), |
+ selectedRange->endOffset()); |
+ IntRect focus = frame->editor().firstRectForRange(range.get()); |
+ if (!computeCompositedLayerAndRect(selection.end().anchorNode(), |
+ focus, |
+ webSelection.focusLayerId, |
+ webSelection.focusRectInLayer)) { |
+ return m_layerTreeView->clearSelection(); |
+ } |
+ |
+ webSelection.type = WebSelection::TypeSelection; |
+ webSelection.anchorDirection = selection.start().primaryDirection() == RTL ? WebTextDirectionRightToLeft : WebTextDirectionLeftToRight; |
+ webSelection.focusDirection = selection.end().primaryDirection() == RTL ? WebTextDirectionRightToLeft : WebTextDirectionLeftToRight; |
+ webSelection.anchorIsFirst = selection.selection().isBaseFirst(); |
+ m_layerTreeView->registerSelection(webSelection); |
+} |
+ |
bool WebViewImpl::detectContentOnTouch(const WebPoint& position) |
{ |
HitTestResult touchHit = hitTestResultForWindowPos(position); |