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