Index: Source/core/frame/FrameView.cpp |
diff --git a/Source/core/frame/FrameView.cpp b/Source/core/frame/FrameView.cpp |
index b6b653971c1e33de06fed8cc9157629a90266c71..a97d4e045eaa534e8c652d34aa2dbad40e9df5f0 100644 |
--- a/Source/core/frame/FrameView.cpp |
+++ b/Source/core/frame/FrameView.cpp |
@@ -44,6 +44,7 @@ |
#include "core/frame/Settings.h" |
#include "core/html/HTMLFrameElement.h" |
#include "core/html/HTMLPlugInElement.h" |
+#include "core/html/HTMLTextFormControlElement.h" |
#include "core/html/parser/TextResourceDecoder.h" |
#include "core/inspector/InspectorInstrumentation.h" |
#include "core/inspector/InspectorTraceEvents.h" |
@@ -58,7 +59,7 @@ |
#include "core/layout/LayoutView.h" |
#include "core/layout/TextAutosizer.h" |
#include "core/layout/compositing/CompositedLayerMapping.h" |
-#include "core/layout/compositing/CompositedSelectionBound.h" |
+#include "core/layout/compositing/CompositedSelection.h" |
#include "core/layout/compositing/LayerCompositor.h" |
#include "core/layout/style/LayoutStyle.h" |
#include "core/layout/svg/LayoutSVGRoot.h" |
@@ -1651,39 +1652,40 @@ void FrameView::updateLayersAndCompositingAfterScrollIfNeeded() |
} |
} |
-bool FrameView::computeCompositedSelectionBounds(LocalFrame& frame, CompositedSelectionBound& start, CompositedSelectionBound& end) |
+bool FrameView::computeCompositedSelection(LocalFrame& frame, CompositedSelection& selection) |
{ |
- const VisibleSelection &selection = frame.selection().selection(); |
- if (!selection.isCaretOrRange()) |
+ const VisibleSelection& visibleSelection = frame.selection().selection(); |
+ if (!visibleSelection.isCaretOrRange()) |
return false; |
- VisiblePosition visibleStart(selection.visibleStart()); |
- VisiblePosition visibleEnd(selection.visibleEnd()); |
+ VisiblePosition visibleBase(visibleSelection.visibleBase()); |
+ VisiblePosition visibleExtent(visibleSelection.visibleExtent()); |
- RenderedPosition renderedStart(visibleStart); |
- RenderedPosition renderedEnd(visibleEnd); |
+ RenderedPosition renderedBase(visibleBase); |
+ RenderedPosition renderedExtent(visibleExtent); |
- renderedStart.positionInGraphicsLayerBacking(start); |
- if (!start.layer) |
+ renderedBase.positionInGraphicsLayerBacking(selection.base); |
+ if (!selection.base.layer) |
return false; |
- renderedEnd.positionInGraphicsLayerBacking(end); |
- if (!end.layer) |
+ renderedExtent.positionInGraphicsLayerBacking(selection.extent); |
+ if (!selection.extent.layer) |
return false; |
- if (selection.isCaret()) { |
- start.type = end.type = CompositedSelectionBound::Caret; |
- return true; |
+ selection.type = visibleSelection.selectionType(); |
+ selection.isBaseFirst = visibleSelection.isBaseFirst(); |
+ selection.isEditable = visibleSelection.isContentEditable(); |
+ if (selection.isEditable) { |
+ if (HTMLTextFormControlElement* enclosingTextFormControlElement = enclosingTextFormControl(visibleSelection.rootEditableElement())) |
+ selection.isEditableRegionEmpty = enclosingTextFormControlElement->value().isEmpty(); |
yoichio
2015/03/20 05:17:51
How about <div isContentEditable=true></div>? That
jdduke (slow)
2015/03/20 15:02:18
You're right.
I think it's OK if we make this "be
|
} |
+ selection.base.isTextDirectionRTL = visibleBase.deepEquivalent().primaryDirection() == RTL; |
+ selection.extent.isTextDirectionRTL = visibleExtent.deepEquivalent().primaryDirection() == RTL; |
- 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() |
+void FrameView::updateCompositedSelectionIfNeeded() |
{ |
if (!RuntimeEnabledFeatures::compositedSelectionUpdateEnabled()) |
return; |
@@ -1691,14 +1693,14 @@ void FrameView::updateCompositedSelectionBoundsIfNeeded() |
Page* page = frame().page(); |
ASSERT(page); |
- CompositedSelectionBound start, end; |
+ CompositedSelection selection; |
LocalFrame* frame = toLocalFrame(page->focusController().focusedOrMainFrame()); |
- if (!frame || !computeCompositedSelectionBounds(*frame, start, end)) { |
- page->chrome().client().clearCompositedSelectionBounds(); |
+ if (!frame || !computeCompositedSelection(*frame, selection)) { |
+ page->chrome().client().clearCompositedSelection(); |
return; |
} |
- page->chrome().client().updateCompositedSelectionBounds(start, end); |
+ page->chrome().client().updateCompositedSelection(selection); |
} |
HostWindow* FrameView::hostWindow() const |
@@ -2539,7 +2541,7 @@ void FrameView::updateLayoutAndStyleForPainting() |
if (view->compositor()->inCompositingMode() && m_frame->isLocalRoot()) |
scrollingCoordinator()->updateAfterCompositingChangeIfNeeded(); |
- updateCompositedSelectionBoundsIfNeeded(); |
+ updateCompositedSelectionIfNeeded(); |
scrollContentsIfNeededRecursive(); |