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