| 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 1918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1929 VisiblePosition::firstPositionInNode(parentElement); | 1929 VisiblePosition::firstPositionInNode(parentElement); |
| 1930 VisiblePosition positionInNode = | 1930 VisiblePosition positionInNode = |
| 1931 createVisiblePosition(firstPositionInOrBeforeNode(node)); | 1931 createVisiblePosition(firstPositionInOrBeforeNode(node)); |
| 1932 if (positionInParent.deepEquivalent() != positionInNode.deepEquivalent()) | 1932 if (positionInParent.deepEquivalent() != positionInNode.deepEquivalent()) |
| 1933 splitElement(parentElement, node); | 1933 splitElement(parentElement, node); |
| 1934 } | 1934 } |
| 1935 | 1935 |
| 1936 return node; | 1936 return node; |
| 1937 } | 1937 } |
| 1938 | 1938 |
| 1939 void CompositeEditCommand::setStartingSelection( |
| 1940 const VisibleSelection& selection) { |
| 1941 for (CompositeEditCommand* command = this;; command = command->parent()) { |
| 1942 if (UndoStep* undoStep = command->undoStep()) { |
| 1943 DCHECK(command->isTopLevelCommand()); |
| 1944 undoStep->setStartingSelection(selection); |
| 1945 } |
| 1946 command->m_startingSelection = selection; |
| 1947 if (!command->parent() || command->parent()->isFirstCommand(command)) |
| 1948 break; |
| 1949 } |
| 1950 } |
| 1951 |
| 1952 // TODO(yosin): We will make |SelectionInDOMTree| version of |
| 1953 // |setEndingSelection()| as primary function instead of wrapper, once |
| 1954 // |EditCommand| holds other than |VisibleSelection|. |
| 1955 void CompositeEditCommand::setEndingSelection( |
| 1956 const SelectionInDOMTree& selection) { |
| 1957 // TODO(editing-dev): The use of |
| 1958 // updateStyleAndLayoutIgnorePendingStylesheets |
| 1959 // needs to be audited. See http://crbug.com/590369 for more details. |
| 1960 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 1961 setEndingVisibleSelection(createVisibleSelection(selection)); |
| 1962 } |
| 1963 |
| 1964 // TODO(yosin): We will make |SelectionInDOMTree| version of |
| 1965 // |setEndingSelection()| as primary function instead of wrapper. |
| 1966 void CompositeEditCommand::setEndingVisibleSelection( |
| 1967 const VisibleSelection& selection) { |
| 1968 for (CompositeEditCommand* command = this; command; |
| 1969 command = command->parent()) { |
| 1970 if (UndoStep* undoStep = command->undoStep()) { |
| 1971 DCHECK(command->isTopLevelCommand()); |
| 1972 undoStep->setEndingSelection(selection); |
| 1973 } |
| 1974 command->m_endingSelection = selection; |
| 1975 } |
| 1976 } |
| 1977 |
| 1978 void CompositeEditCommand::setParent(CompositeEditCommand* parent) { |
| 1979 EditCommand::setParent(parent); |
| 1980 if (!parent) |
| 1981 return; |
| 1982 m_startingSelection = parent->m_endingSelection; |
| 1983 m_endingSelection = parent->m_endingSelection; |
| 1984 } |
| 1985 |
| 1939 DEFINE_TRACE(CompositeEditCommand) { | 1986 DEFINE_TRACE(CompositeEditCommand) { |
| 1940 visitor->trace(m_commands); | 1987 visitor->trace(m_commands); |
| 1941 visitor->trace(m_startingSelection); | 1988 visitor->trace(m_startingSelection); |
| 1942 visitor->trace(m_endingSelection); | 1989 visitor->trace(m_endingSelection); |
| 1943 visitor->trace(m_undoStep); | 1990 visitor->trace(m_undoStep); |
| 1944 EditCommand::trace(visitor); | 1991 EditCommand::trace(visitor); |
| 1945 } | 1992 } |
| 1946 | 1993 |
| 1947 } // namespace blink | 1994 } // namespace blink |
| OLD | NEW |