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

Unified Diff: third_party/WebKit/Source/core/editing/SelectionAdjuster.cpp

Issue 2706003002: Get rid of unused functions SelectionAdjuster::adjustSelectionIn{DOM,Flat}Tree (Closed)
Patch Set: 2017-02-20T18:17:58 Created 3 years, 10 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: third_party/WebKit/Source/core/editing/SelectionAdjuster.cpp
diff --git a/third_party/WebKit/Source/core/editing/SelectionAdjuster.cpp b/third_party/WebKit/Source/core/editing/SelectionAdjuster.cpp
index 450fe189491bacae676770847718c5d3d8302383..4d77b449cacd339be95c2410fa4a0a6cd2836a65 100644
--- a/third_party/WebKit/Source/core/editing/SelectionAdjuster.cpp
+++ b/third_party/WebKit/Source/core/editing/SelectionAdjuster.cpp
@@ -153,100 +153,6 @@ Position adjustPositionForStart(const Position& currentPosition,
} // namespace
-// Updates |selectionInFlatTree| to match with |selection|.
-void SelectionAdjuster::adjustSelectionInFlatTree(
- VisibleSelectionInFlatTree* selectionInFlatTree,
- const VisibleSelection& selection) {
- if (selection.isNone()) {
- *selectionInFlatTree = VisibleSelectionInFlatTree();
- return;
- }
-
- const PositionInFlatTree& base = toPositionInFlatTree(selection.base());
- const PositionInFlatTree& extent = toPositionInFlatTree(selection.extent());
- const PositionInFlatTree& position1 = toPositionInFlatTree(selection.start());
- const PositionInFlatTree& position2 = toPositionInFlatTree(selection.end());
- position1.anchorNode()->updateDistribution();
- position2.anchorNode()->updateDistribution();
- selectionInFlatTree->m_base = base;
- selectionInFlatTree->m_extent = extent;
- selectionInFlatTree->m_affinity = selection.m_affinity;
- selectionInFlatTree->m_isDirectional = selection.m_isDirectional;
- selectionInFlatTree->m_granularity = selection.m_granularity;
- selectionInFlatTree->m_hasTrailingWhitespace =
- selection.m_hasTrailingWhitespace;
- selectionInFlatTree->m_baseIsFirst =
- base.isNull() || base.compareTo(extent) <= 0;
- if (position1.compareTo(position2) <= 0) {
- selectionInFlatTree->m_start = position1;
- selectionInFlatTree->m_end = position2;
- } else {
- selectionInFlatTree->m_start = position2;
- selectionInFlatTree->m_end = position1;
- }
- selectionInFlatTree->updateSelectionType();
-}
-
-static bool isCrossingShadowBoundaries(
- const VisibleSelectionInFlatTree& selection) {
- if (!selection.isRange())
- return false;
- TreeScope& treeScope = selection.base().anchorNode()->treeScope();
- return selection.extent().anchorNode()->treeScope() != treeScope ||
- selection.start().anchorNode()->treeScope() != treeScope ||
- selection.end().anchorNode()->treeScope() != treeScope;
-}
-
-// TODO(yosin): We should make |adjustSelectionInDOMTree()| to return
-// |VisibleSelection| once |VisibleSelection| constructor doesn't call
-// |validate()|.
-void SelectionAdjuster::adjustSelectionInDOMTree(
- VisibleSelection* selection,
- const VisibleSelectionInFlatTree& selectionInFlatTree) {
- if (selectionInFlatTree.isNone()) {
- *selection = VisibleSelection();
- return;
- }
-
- const Position& base = toPositionInDOMTree(selectionInFlatTree.base());
- const Position& extent = toPositionInDOMTree(selectionInFlatTree.extent());
-
- if (isCrossingShadowBoundaries(selectionInFlatTree)) {
- DCHECK(base.document());
-
- // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
- // needs to be audited. See http://crbug.com/590369 for more details.
- // This layout update call cannot be hoisted out of the |if|, otherwise it's
- // going to cause performance regression (http://crbug.com/652301).
- // TODO(yosin): Implement and apply lazy visible selection validation so
- // that we don't need to update layout here.
- base.document()->updateStyleAndLayoutIgnorePendingStylesheets();
-
- *selection = createVisibleSelection(
- SelectionInDOMTree::Builder().setBaseAndExtent(base, extent).build());
- return;
- }
-
- const Position& position1 = toPositionInDOMTree(selectionInFlatTree.start());
- const Position& position2 = toPositionInDOMTree(selectionInFlatTree.end());
- selection->m_base = base;
- selection->m_extent = extent;
- selection->m_affinity = selectionInFlatTree.m_affinity;
- selection->m_isDirectional = selectionInFlatTree.m_isDirectional;
- selection->m_granularity = selectionInFlatTree.m_granularity;
- selection->m_hasTrailingWhitespace =
- selectionInFlatTree.m_hasTrailingWhitespace;
- selection->m_baseIsFirst = base.isNull() || base.compareTo(extent) <= 0;
- if (position1.compareTo(position2) <= 0) {
- selection->m_start = position1;
- selection->m_end = position2;
- } else {
- selection->m_start = position2;
- selection->m_end = position1;
- }
- selection->updateSelectionType();
-}
-
void SelectionAdjuster::adjustSelectionToAvoidCrossingShadowBoundaries(
VisibleSelection* selection) {
// Note: |m_selectionType| isn't computed yet.

Powered by Google App Engine
This is Rietveld 408576698