| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 case InputType::DeleteContentBackward: | 97 case InputType::DeleteContentBackward: |
| 98 case InputType::DeleteContentForward: | 98 case InputType::DeleteContentForward: |
| 99 return InputEvent::EventCancelable::NotCancelable; | 99 return InputEvent::EventCancelable::NotCancelable; |
| 100 default: | 100 default: |
| 101 return InputEvent::EventCancelable::IsCancelable; | 101 return InputEvent::EventCancelable::IsCancelable; |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 | 104 |
| 105 } // namespace | 105 } // namespace |
| 106 | 106 |
| 107 static bool needsLayoutTreeUpdate(const Node& node) { | 107 bool needsLayoutTreeUpdate(const Node& node) { |
| 108 const Document& document = node.document(); | 108 const Document& document = node.document(); |
| 109 if (document.needsLayoutTreeUpdate()) | 109 if (document.needsLayoutTreeUpdate()) |
| 110 return true; | 110 return true; |
| 111 // TODO(yosin): We should make |document::needsLayoutTreeUpdate()| to | 111 // TODO(yosin): We should make |document::needsLayoutTreeUpdate()| to |
| 112 // check |LayoutView::needsLayout()|. | 112 // check |LayoutView::needsLayout()|. |
| 113 return document.view() && document.view()->needsLayout(); | 113 return document.view() && document.view()->needsLayout(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 template <typename PositionType> | 116 template <typename PositionType> |
| 117 static bool needsLayoutTreeUpdateAlgorithm(const PositionType& position) { | 117 static bool needsLayoutTreeUpdateAlgorithm(const PositionType& position) { |
| (...skipping 1845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1963 | 1963 |
| 1964 EphemeralRange range = PlainTextRange(index).createRangeForSelection(*scope); | 1964 EphemeralRange range = PlainTextRange(index).createRangeForSelection(*scope); |
| 1965 // Check for an invalid index. Certain editing operations invalidate indices | 1965 // Check for an invalid index. Certain editing operations invalidate indices |
| 1966 // because of problems with | 1966 // because of problems with |
| 1967 // TextIteratorEmitsCharactersBetweenAllVisiblePositions. | 1967 // TextIteratorEmitsCharactersBetweenAllVisiblePositions. |
| 1968 if (range.isNull()) | 1968 if (range.isNull()) |
| 1969 return VisiblePosition(); | 1969 return VisiblePosition(); |
| 1970 return createVisiblePosition(range.startPosition()); | 1970 return createVisiblePosition(range.startPosition()); |
| 1971 } | 1971 } |
| 1972 | 1972 |
| 1973 // Determines whether a node is inside a range or visibly starts and ends at the | |
| 1974 // boundaries of the range. Call this function to determine whether a node is | |
| 1975 // visibly fit inside selectedRange | |
| 1976 bool isNodeVisiblyContainedWithin(Node& node, const Range& selectedRange) { | |
| 1977 DCHECK(!needsLayoutTreeUpdate(node)); | |
| 1978 DocumentLifecycle::DisallowTransitionScope disallowTransition( | |
| 1979 node.document().lifecycle()); | |
| 1980 | |
| 1981 if (selectedRange.isNodeFullyContained(node)) | |
| 1982 return true; | |
| 1983 | |
| 1984 bool startIsVisuallySame = | |
| 1985 visiblePositionBeforeNode(node).deepEquivalent() == | |
| 1986 createVisiblePosition(selectedRange.startPosition()).deepEquivalent(); | |
| 1987 if (startIsVisuallySame && | |
| 1988 comparePositions(Position::inParentAfterNode(node), | |
| 1989 selectedRange.endPosition()) < 0) | |
| 1990 return true; | |
| 1991 | |
| 1992 bool endIsVisuallySame = | |
| 1993 visiblePositionAfterNode(node).deepEquivalent() == | |
| 1994 createVisiblePosition(selectedRange.endPosition()).deepEquivalent(); | |
| 1995 if (endIsVisuallySame && | |
| 1996 comparePositions(selectedRange.startPosition(), | |
| 1997 Position::inParentBeforeNode(node)) < 0) | |
| 1998 return true; | |
| 1999 | |
| 2000 return startIsVisuallySame && endIsVisuallySame; | |
| 2001 } | |
| 2002 | |
| 2003 bool isRenderedAsNonInlineTableImageOrHR(const Node* node) { | 1973 bool isRenderedAsNonInlineTableImageOrHR(const Node* node) { |
| 2004 if (!node) | 1974 if (!node) |
| 2005 return false; | 1975 return false; |
| 2006 LayoutObject* layoutObject = node->layoutObject(); | 1976 LayoutObject* layoutObject = node->layoutObject(); |
| 2007 return layoutObject && | 1977 return layoutObject && |
| 2008 ((layoutObject->isTable() && !layoutObject->isInline()) || | 1978 ((layoutObject->isTable() && !layoutObject->isInline()) || |
| 2009 (layoutObject->isImage() && !layoutObject->isInline()) || | 1979 (layoutObject->isImage() && !layoutObject->isInline()) || |
| 2010 layoutObject->isHR()); | 1980 layoutObject->isHR()); |
| 2011 } | 1981 } |
| 2012 | 1982 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2173 return InputType::DeleteWordBackward; | 2143 return InputType::DeleteWordBackward; |
| 2174 if (granularity == LineBoundary) | 2144 if (granularity == LineBoundary) |
| 2175 return InputType::DeleteLineBackward; | 2145 return InputType::DeleteLineBackward; |
| 2176 return InputType::DeleteContentBackward; | 2146 return InputType::DeleteContentBackward; |
| 2177 default: | 2147 default: |
| 2178 return InputType::None; | 2148 return InputType::None; |
| 2179 } | 2149 } |
| 2180 } | 2150 } |
| 2181 | 2151 |
| 2182 } // namespace blink | 2152 } // namespace blink |
| OLD | NEW |