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

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

Issue 2786573002: Use EphemeralRange instead of Range in Range::isNodeFullyContainded (Closed)
Patch Set: update Created 3 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 1955 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 // Determines whether a node is inside a range or visibly starts and ends at the 1966 // Determines whether a node is inside a range or visibly starts and ends at the
1967 // boundaries of the range. Call this function to determine whether a node is 1967 // boundaries of the range. Call this function to determine whether a node is
1968 // visibly fit inside selectedRange 1968 // visibly fit inside selectedRange
1969 bool CompositeEditCommand::isNodeVisiblyContainedWithin( 1969 bool CompositeEditCommand::isNodeVisiblyContainedWithin(
1970 Node& node, 1970 Node& node,
1971 const Range& selectedRange) { 1971 const Range& selectedRange) {
1972 DCHECK(!needsLayoutTreeUpdate(node)); 1972 DCHECK(!needsLayoutTreeUpdate(node));
1973 DocumentLifecycle::DisallowTransitionScope disallowTransition( 1973 DocumentLifecycle::DisallowTransitionScope disallowTransition(
1974 node.document().lifecycle()); 1974 node.document().lifecycle());
1975 1975
1976 if (selectedRange.isNodeFullyContained(node)) 1976 if (isNodeFullyContained(EphemeralRange(&selectedRange), node))
1977 return true; 1977 return true;
1978 1978
1979 bool startIsVisuallySame = 1979 bool startIsVisuallySame =
1980 visiblePositionBeforeNode(node).deepEquivalent() == 1980 visiblePositionBeforeNode(node).deepEquivalent() ==
1981 createVisiblePosition(selectedRange.startPosition()).deepEquivalent(); 1981 createVisiblePosition(selectedRange.startPosition()).deepEquivalent();
1982 if (startIsVisuallySame && comparePositions(Position::inParentAfterNode(node), 1982 if (startIsVisuallySame && comparePositions(Position::inParentAfterNode(node),
1983 selectedRange.endPosition()) < 0) 1983 selectedRange.endPosition()) < 0)
1984 return true; 1984 return true;
1985 1985
1986 bool endIsVisuallySame = 1986 bool endIsVisuallySame =
1987 visiblePositionAfterNode(node).deepEquivalent() == 1987 visiblePositionAfterNode(node).deepEquivalent() ==
1988 createVisiblePosition(selectedRange.endPosition()).deepEquivalent(); 1988 createVisiblePosition(selectedRange.endPosition()).deepEquivalent();
1989 if (endIsVisuallySame && 1989 if (endIsVisuallySame &&
1990 comparePositions(selectedRange.startPosition(), 1990 comparePositions(selectedRange.startPosition(),
1991 Position::inParentBeforeNode(node)) < 0) 1991 Position::inParentBeforeNode(node)) < 0)
1992 return true; 1992 return true;
1993 1993
1994 return startIsVisuallySame && endIsVisuallySame; 1994 return startIsVisuallySame && endIsVisuallySame;
1995 } 1995 }
1996 1996
1997 DEFINE_TRACE(CompositeEditCommand) { 1997 DEFINE_TRACE(CompositeEditCommand) {
1998 visitor->trace(m_commands); 1998 visitor->trace(m_commands);
1999 visitor->trace(m_startingSelection); 1999 visitor->trace(m_startingSelection);
2000 visitor->trace(m_endingSelection); 2000 visitor->trace(m_endingSelection);
2001 visitor->trace(m_undoStep); 2001 visitor->trace(m_undoStep);
2002 EditCommand::trace(visitor); 2002 EditCommand::trace(visitor);
2003 } 2003 }
2004 2004
2005 } // namespace blink 2005 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698