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

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

Issue 2788473003: Use EphmeralRange insteadof Range in CompositeEditCommands::isNodeVisiblyContainedWithin()
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 1952 matching lines...) Expand 10 before | Expand all | Expand 10 after
1963 return; 1963 return;
1964 m_startingSelection = parent->m_endingSelection; 1964 m_startingSelection = parent->m_endingSelection;
1965 m_endingSelection = parent->m_endingSelection; 1965 m_endingSelection = parent->m_endingSelection;
1966 } 1966 }
1967 1967
1968 // Determines whether a node is inside a range or visibly starts and ends at the 1968 // Determines whether a node is inside a range or visibly starts and ends at the
1969 // boundaries of the range. Call this function to determine whether a node is 1969 // boundaries of the range. Call this function to determine whether a node is
1970 // visibly fit inside selectedRange 1970 // visibly fit inside selectedRange
1971 bool CompositeEditCommand::isNodeVisiblyContainedWithin( 1971 bool CompositeEditCommand::isNodeVisiblyContainedWithin(
1972 Node& node, 1972 Node& node,
1973 const Range& selectedRange) { 1973 const EphemeralRange& selectedRange) {
1974 DCHECK(!needsLayoutTreeUpdate(node)); 1974 DCHECK(!needsLayoutTreeUpdate(node));
1975 DocumentLifecycle::DisallowTransitionScope disallowTransition( 1975 DocumentLifecycle::DisallowTransitionScope disallowTransition(
1976 node.document().lifecycle()); 1976 node.document().lifecycle());
1977 1977
1978 if (isNodeFullyContained(EphemeralRange(&selectedRange), node)) 1978 if (isNodeFullyContained(selectedRange, node))
1979 return true; 1979 return true;
1980 1980
1981 bool startIsVisuallySame = 1981 bool startIsVisuallySame =
1982 visiblePositionBeforeNode(node).deepEquivalent() == 1982 visiblePositionBeforeNode(node).deepEquivalent() ==
1983 createVisiblePosition(selectedRange.startPosition()).deepEquivalent(); 1983 createVisiblePosition(selectedRange.startPosition()).deepEquivalent();
1984 if (startIsVisuallySame && comparePositions(Position::inParentAfterNode(node), 1984 if (startIsVisuallySame && comparePositions(Position::inParentAfterNode(node),
1985 selectedRange.endPosition()) < 0) 1985 selectedRange.endPosition()) < 0)
1986 return true; 1986 return true;
1987 1987
1988 bool endIsVisuallySame = 1988 bool endIsVisuallySame =
1989 visiblePositionAfterNode(node).deepEquivalent() == 1989 visiblePositionAfterNode(node).deepEquivalent() ==
1990 createVisiblePosition(selectedRange.endPosition()).deepEquivalent(); 1990 createVisiblePosition(selectedRange.endPosition()).deepEquivalent();
1991 if (endIsVisuallySame && 1991 if (endIsVisuallySame &&
1992 comparePositions(selectedRange.startPosition(), 1992 comparePositions(selectedRange.startPosition(),
1993 Position::inParentBeforeNode(node)) < 0) 1993 Position::inParentBeforeNode(node)) < 0)
1994 return true; 1994 return true;
1995 1995
1996 return startIsVisuallySame && endIsVisuallySame; 1996 return startIsVisuallySame && endIsVisuallySame;
1997 } 1997 }
1998 1998
1999 DEFINE_TRACE(CompositeEditCommand) { 1999 DEFINE_TRACE(CompositeEditCommand) {
2000 visitor->trace(m_commands); 2000 visitor->trace(m_commands);
2001 visitor->trace(m_startingSelection); 2001 visitor->trace(m_startingSelection);
2002 visitor->trace(m_endingSelection); 2002 visitor->trace(m_endingSelection);
2003 visitor->trace(m_undoStep); 2003 visitor->trace(m_undoStep);
2004 EditCommand::trace(visitor); 2004 EditCommand::trace(visitor);
2005 } 2005 }
2006 2006
2007 } // namespace blink 2007 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698