| 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 2030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2041 element.hasTagName(h3Tag) || element.hasTagName(h4Tag) || | 2041 element.hasTagName(h3Tag) || element.hasTagName(h4Tag) || |
| 2042 element.hasTagName(h5Tag); | 2042 element.hasTagName(h5Tag); |
| 2043 } | 2043 } |
| 2044 | 2044 |
| 2045 bool isBlockFlowElement(const Node& node) { | 2045 bool isBlockFlowElement(const Node& node) { |
| 2046 LayoutObject* layoutObject = node.layoutObject(); | 2046 LayoutObject* layoutObject = node.layoutObject(); |
| 2047 return node.isElementNode() && layoutObject && | 2047 return node.isElementNode() && layoutObject && |
| 2048 layoutObject->isLayoutBlockFlow(); | 2048 layoutObject->isLayoutBlockFlow(); |
| 2049 } | 2049 } |
| 2050 | 2050 |
| 2051 Position adjustedSelectionStartForStyleComputation( | 2051 Position adjustedSelectionStartForStyleComputation(const Position& position) { |
| 2052 const VisibleSelection& selection) { | |
| 2053 // This function is used by range style computations to avoid bugs like: | 2052 // This function is used by range style computations to avoid bugs like: |
| 2054 // <rdar://problem/4017641> REGRESSION (Mail): you can only bold/unbold a | 2053 // <rdar://problem/4017641> REGRESSION (Mail): you can only bold/unbold a |
| 2055 // selection starting from end of line once | 2054 // selection starting from end of line once |
| 2056 // It is important to skip certain irrelevant content at the start of the | 2055 // It is important to skip certain irrelevant content at the start of the |
| 2057 // selection, so we do not wind up with a spurious "mixed" style. | 2056 // selection, so we do not wind up with a spurious "mixed" style. |
| 2058 | 2057 |
| 2059 VisiblePosition visiblePosition = createVisiblePosition(selection.start()); | 2058 VisiblePosition visiblePosition = createVisiblePosition(position); |
| 2060 if (visiblePosition.isNull()) | 2059 if (visiblePosition.isNull()) |
| 2061 return Position(); | 2060 return Position(); |
| 2062 | 2061 |
| 2063 // if the selection is a caret, just return the position, since the style | |
| 2064 // behind us is relevant | |
| 2065 if (selection.isCaret()) | |
| 2066 return visiblePosition.deepEquivalent(); | |
| 2067 | |
| 2068 // if the selection starts just before a paragraph break, skip over it | 2062 // if the selection starts just before a paragraph break, skip over it |
| 2069 if (isEndOfParagraph(visiblePosition)) | 2063 if (isEndOfParagraph(visiblePosition)) |
| 2070 return mostForwardCaretPosition( | 2064 return mostForwardCaretPosition( |
| 2071 nextPositionOf(visiblePosition).deepEquivalent()); | 2065 nextPositionOf(visiblePosition).deepEquivalent()); |
| 2072 | 2066 |
| 2073 // otherwise, make sure to be at the start of the first selected node, | 2067 // otherwise, make sure to be at the start of the first selected node, |
| 2074 // instead of possibly at the end of the last node before the selection | 2068 // instead of possibly at the end of the last node before the selection |
| 2075 return mostForwardCaretPosition(visiblePosition.deepEquivalent()); | 2069 return mostForwardCaretPosition(visiblePosition.deepEquivalent()); |
| 2076 } | 2070 } |
| 2077 | 2071 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2179 return InputType::DeleteWordBackward; | 2173 return InputType::DeleteWordBackward; |
| 2180 if (granularity == LineBoundary) | 2174 if (granularity == LineBoundary) |
| 2181 return InputType::DeleteLineBackward; | 2175 return InputType::DeleteLineBackward; |
| 2182 return InputType::DeleteContentBackward; | 2176 return InputType::DeleteContentBackward; |
| 2183 default: | 2177 default: |
| 2184 return InputType::None; | 2178 return InputType::None; |
| 2185 } | 2179 } |
| 2186 } | 2180 } |
| 2187 | 2181 |
| 2188 } // namespace blink | 2182 } // namespace blink |
| OLD | NEW |