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

Side by Side Diff: third_party/WebKit/Source/core/editing/PendingSelection.cpp

Issue 2341273002: Prune some unnecessary calls to createVisiblePositionDeprecated (Closed)
Patch Set: Include LocalFrame::rangeForPoint Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/PlainTextRange.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 return true; 55 return true;
56 } 56 }
57 57
58 VisibleSelectionInFlatTree PendingSelection::calcVisibleSelection(const VisibleS electionInFlatTree& originalSelection) const 58 VisibleSelectionInFlatTree PendingSelection::calcVisibleSelection(const VisibleS electionInFlatTree& originalSelection) const
59 { 59 {
60 const PositionInFlatTree& start = originalSelection.start(); 60 const PositionInFlatTree& start = originalSelection.start();
61 const PositionInFlatTree& end = originalSelection.end(); 61 const PositionInFlatTree& end = originalSelection.end();
62 SelectionType selectionType = originalSelection.getSelectionType(); 62 SelectionType selectionType = originalSelection.getSelectionType();
63 const TextAffinity affinity = originalSelection.affinity(); 63 const TextAffinity affinity = originalSelection.affinity();
64 64
65 bool paintBlockCursor = m_frameSelection->shouldShowBlockCursor() && selecti onType == SelectionType::CaretSelection && !isLogicalEndOfLine(createVisiblePosi tionDeprecated(end, affinity)); 65 bool paintBlockCursor = m_frameSelection->shouldShowBlockCursor() && selecti onType == SelectionType::CaretSelection && !isLogicalEndOfLine(createVisiblePosi tion(end, affinity));
66 VisibleSelectionInFlatTree selection; 66 VisibleSelectionInFlatTree selection;
67 if (enclosingTextFormControl(start.computeContainerNode())) { 67 if (enclosingTextFormControl(start.computeContainerNode())) {
68 // TODO(yosin) We should use |PositionMoveType::CodePoint| to avoid 68 // TODO(yosin) We should use |PositionMoveType::CodePoint| to avoid
69 // ending paint at middle of character. 69 // ending paint at middle of character.
70 PositionInFlatTree endPosition = paintBlockCursor ? nextPositionOf(origi nalSelection.extent(), PositionMoveType::CodeUnit) : end; 70 PositionInFlatTree endPosition = paintBlockCursor ? nextPositionOf(origi nalSelection.extent(), PositionMoveType::CodeUnit) : end;
71 selection.setWithoutValidation(start, endPosition); 71 selection.setWithoutValidation(start, endPosition);
72 return selection; 72 return selection;
73 } 73 }
74 74
75 const VisiblePositionInFlatTree& visibleStart = createVisiblePositionDepreca ted(start, selectionType == SelectionType::RangeSelection ? TextAffinity::Downst ream : affinity); 75 const VisiblePositionInFlatTree& visibleStart = createVisiblePosition(start, selectionType == SelectionType::RangeSelection ? TextAffinity::Downstream : aff inity);
76 if (paintBlockCursor) { 76 if (paintBlockCursor) {
77 VisiblePositionInFlatTree visibleExtent = createVisiblePositionDeprecate d(end, affinity); 77 VisiblePositionInFlatTree visibleExtent = createVisiblePosition(end, aff inity);
78 visibleExtent = nextPositionOf(visibleExtent, CanSkipOverEditingBoundary ); 78 visibleExtent = nextPositionOf(visibleExtent, CanSkipOverEditingBoundary );
79 return VisibleSelectionInFlatTree(visibleStart, visibleExtent); 79 return VisibleSelectionInFlatTree(visibleStart, visibleExtent);
80 } 80 }
81 const VisiblePositionInFlatTree visibleEnd = createVisiblePositionDeprecated (end, selectionType == SelectionType::RangeSelection ? TextAffinity::Upstream : affinity); 81 const VisiblePositionInFlatTree visibleEnd = createVisiblePosition(end, sele ctionType == SelectionType::RangeSelection ? TextAffinity::Upstream : affinity);
82 return VisibleSelectionInFlatTree(visibleStart, visibleEnd); 82 return VisibleSelectionInFlatTree(visibleStart, visibleEnd);
83 } 83 }
84 84
85 void PendingSelection::commit(LayoutView& layoutView) 85 void PendingSelection::commit(LayoutView& layoutView)
86 { 86 {
87 if (!hasPendingSelection()) 87 if (!hasPendingSelection())
88 return; 88 return;
89 DCHECK(!layoutView.needsLayout()); 89 DCHECK(!layoutView.needsLayout());
90 m_hasPendingSelection = false; 90 m_hasPendingSelection = false;
91 91
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 DCHECK(layoutView == endLayoutObject->view()); 134 DCHECK(layoutView == endLayoutObject->view());
135 layoutView.setSelection(startLayoutObject, startPos.computeEditingOffset(), endLayoutObject, endPos.computeEditingOffset()); 135 layoutView.setSelection(startLayoutObject, startPos.computeEditingOffset(), endLayoutObject, endPos.computeEditingOffset());
136 } 136 }
137 137
138 DEFINE_TRACE(PendingSelection) 138 DEFINE_TRACE(PendingSelection)
139 { 139 {
140 visitor->trace(m_frameSelection); 140 visitor->trace(m_frameSelection);
141 } 141 }
142 142
143 } // namespace blink 143 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/PlainTextRange.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698