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

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

Issue 2413633002: Prune createVisiblePositionDeprecated from EditingUtilities (Closed)
Patch Set: Address comments Created 4 years, 2 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/EditingUtilities.cpp
diff --git a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
index 7c79be31198935b5a08f7ff8fd732684d089c41f..113b1f17c14fe76c9acb0cc4b85ce7cdfd37cfd0 100644
--- a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
+++ b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
@@ -1032,15 +1032,16 @@ static bool isSpecialHTMLElement(const Node& n) {
}
static HTMLElement* firstInSpecialElement(const Position& pos) {
+ DCHECK(!needsLayoutTreeUpdate(pos));
Element* element = rootEditableElement(*pos.computeContainerNode());
for (Node& runner : NodeTraversal::inclusiveAncestorsOf(*pos.anchorNode())) {
if (rootEditableElement(runner) != element)
break;
if (isSpecialHTMLElement(runner)) {
HTMLElement* specialElement = toHTMLElement(&runner);
- VisiblePosition vPos = createVisiblePositionDeprecated(pos);
- VisiblePosition firstInElement = createVisiblePositionDeprecated(
- firstPositionInOrBeforeNode(specialElement));
+ VisiblePosition vPos = createVisiblePosition(pos);
+ VisiblePosition firstInElement =
+ createVisiblePosition(firstPositionInOrBeforeNode(specialElement));
if (isDisplayInsideTable(specialElement) &&
vPos.deepEquivalent() ==
nextPositionOf(firstInElement).deepEquivalent())
@@ -1053,15 +1054,16 @@ static HTMLElement* firstInSpecialElement(const Position& pos) {
}
static HTMLElement* lastInSpecialElement(const Position& pos) {
+ DCHECK(!needsLayoutTreeUpdate(pos));
Element* element = rootEditableElement(*pos.computeContainerNode());
for (Node& runner : NodeTraversal::inclusiveAncestorsOf(*pos.anchorNode())) {
if (rootEditableElement(runner) != element)
break;
if (isSpecialHTMLElement(runner)) {
HTMLElement* specialElement = toHTMLElement(&runner);
- VisiblePosition vPos = createVisiblePositionDeprecated(pos);
- VisiblePosition lastInElement = createVisiblePositionDeprecated(
- lastPositionInOrAfterNode(specialElement));
+ VisiblePosition vPos = createVisiblePosition(pos);
+ VisiblePosition lastInElement =
+ createVisiblePosition(lastPositionInOrAfterNode(specialElement));
if (isDisplayInsideTable(specialElement) &&
vPos.deepEquivalent() ==
previousPositionOf(lastInElement).deepEquivalent())
@@ -1076,6 +1078,7 @@ static HTMLElement* lastInSpecialElement(const Position& pos) {
Position positionBeforeContainingSpecialElement(
const Position& pos,
HTMLElement** containingSpecialElement) {
+ DCHECK(!needsLayoutTreeUpdate(pos));
HTMLElement* n = firstInSpecialElement(pos);
if (!n)
return pos;
@@ -1092,6 +1095,7 @@ Position positionBeforeContainingSpecialElement(
Position positionAfterContainingSpecialElement(
const Position& pos,
HTMLElement** containingSpecialElement) {
+ DCHECK(!needsLayoutTreeUpdate(pos));
HTMLElement* n = lastInSpecialElement(pos);
if (!n)
return pos;
@@ -1182,8 +1186,9 @@ Node* nextAtomicLeafNode(const Node& start) {
// Returns the visible position at the beginning of a node
VisiblePosition visiblePositionBeforeNode(Node& node) {
+ DCHECK(!needsLayoutTreeUpdate(node));
if (node.hasChildren())
- return createVisiblePositionDeprecated(firstPositionInOrBeforeNode(&node));
+ return createVisiblePosition(firstPositionInOrBeforeNode(&node));
DCHECK(node.parentNode()) << node;
DCHECK(!node.parentNode()->isShadowRoot()) << node.parentNode();
return VisiblePosition::inParentBeforeNode(node);
@@ -1191,8 +1196,9 @@ VisiblePosition visiblePositionBeforeNode(Node& node) {
// Returns the visible position at the ending of a node
VisiblePosition visiblePositionAfterNode(Node& node) {
+ DCHECK(!needsLayoutTreeUpdate(node));
if (node.hasChildren())
- return createVisiblePositionDeprecated(lastPositionInOrAfterNode(&node));
+ return createVisiblePosition(lastPositionInOrAfterNode(&node));
DCHECK(node.parentNode()) << node.parentNode();
DCHECK(!node.parentNode()->isShadowRoot()) << node.parentNode();
return VisiblePosition::inParentAfterNode(node);
@@ -1430,8 +1436,8 @@ HTMLElement* outermostEnclosingList(Node* node, HTMLElement* rootList) {
// Determines whether two positions are visibly next to each other (first then
// second) while ignoring whitespaces and unrendered nodes
static bool isVisiblyAdjacent(const Position& first, const Position& second) {
- return createVisiblePositionDeprecated(first).deepEquivalent() ==
- createVisiblePositionDeprecated(mostBackwardCaretPosition(second))
+ return createVisiblePosition(first).deepEquivalent() ==
+ createVisiblePosition(mostBackwardCaretPosition(second))
.deepEquivalent();
}
@@ -1440,6 +1446,8 @@ bool canMergeLists(Element* firstList, Element* secondList) {
!secondList->isHTMLElement())
return false;
+ DCHECK(!needsLayoutTreeUpdate(*firstList));
+ DCHECK(!needsLayoutTreeUpdate(*secondList));
return firstList->hasTagName(
secondList
->tagQName()) // make sure the list types match (ol vs. ul)
@@ -1575,14 +1583,14 @@ bool isNodeRendered(const Node& node) {
// "this"
static Position previousCharacterPosition(const Position& position,
TextAffinity affinity) {
+ DCHECK(!needsLayoutTreeUpdate(position));
if (position.isNull())
return Position();
Element* fromRootEditableElement =
rootEditableElement(*position.anchorNode());
- bool atStartOfLine =
- isStartOfLine(createVisiblePositionDeprecated(position, affinity));
+ bool atStartOfLine = isStartOfLine(createVisiblePosition(position, affinity));
bool rendered = isVisuallyEquivalentCandidate(position);
Position currentPos = position;
@@ -1611,6 +1619,7 @@ static Position previousCharacterPosition(const Position& position,
Position leadingWhitespacePosition(const Position& position,
TextAffinity affinity,
WhitespacePositionOption option) {
+ DCHECK(!needsLayoutTreeUpdate(position));
DCHECK(isEditablePosition(position)) << position;
if (position.isNull())
return Position();
@@ -1646,11 +1655,12 @@ Position leadingWhitespacePosition(const Position& position,
Position trailingWhitespacePosition(const Position& position,
TextAffinity,
WhitespacePositionOption option) {
+ DCHECK(!needsLayoutTreeUpdate(position));
DCHECK(isEditablePosition(position)) << position;
if (position.isNull())
return Position();
- VisiblePosition visiblePosition = createVisiblePositionDeprecated(position);
+ VisiblePosition visiblePosition = createVisiblePosition(position);
UChar characterAfterVisiblePosition = characterAfter(visiblePosition);
bool isSpace = option == ConsiderNonCollapsibleWhitespace
? (isSpaceOrNewline(characterAfterVisiblePosition) ||
@@ -1894,13 +1904,16 @@ VisiblePosition visiblePositionForIndex(int index, ContainerNode* scope) {
// boundaries of the range. Call this function to determine whether a node is
// visibly fit inside selectedRange
bool isNodeVisiblyContainedWithin(Node& node, const Range& selectedRange) {
+ DCHECK(!needsLayoutTreeUpdate(node));
+ DocumentLifecycle::DisallowTransitionScope disallowTransition(
+ node.document().lifecycle());
+
if (selectedRange.isNodeFullyContained(node))
return true;
bool startIsVisuallySame =
visiblePositionBeforeNode(node).deepEquivalent() ==
- createVisiblePositionDeprecated(selectedRange.startPosition())
- .deepEquivalent();
+ createVisiblePosition(selectedRange.startPosition()).deepEquivalent();
if (startIsVisuallySame &&
comparePositions(Position::inParentAfterNode(node),
selectedRange.endPosition()) < 0)
@@ -1908,8 +1921,7 @@ bool isNodeVisiblyContainedWithin(Node& node, const Range& selectedRange) {
bool endIsVisuallySame =
visiblePositionAfterNode(node).deepEquivalent() ==
- createVisiblePositionDeprecated(selectedRange.endPosition())
- .deepEquivalent();
+ createVisiblePosition(selectedRange.endPosition()).deepEquivalent();
if (endIsVisuallySame &&
comparePositions(selectedRange.startPosition(),
Position::inParentBeforeNode(node)) < 0)
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698