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 2041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2052 TextControlElement* textControl = enclosingTextControl(position); | 2052 TextControlElement* textControl = enclosingTextControl(position); |
2053 return isHTMLInputElement(textControl) && | 2053 return isHTMLInputElement(textControl) && |
2054 toHTMLInputElement(textControl)->type() == InputTypeNames::password; | 2054 toHTMLInputElement(textControl)->type() == InputTypeNames::password; |
2055 } | 2055 } |
2056 | 2056 |
2057 bool isTextSecurityNode(const Node* node) { | 2057 bool isTextSecurityNode(const Node* node) { |
2058 return node && node->layoutObject() && | 2058 return node && node->layoutObject() && |
2059 node->layoutObject()->style()->textSecurity() != TSNONE; | 2059 node->layoutObject()->style()->textSecurity() != TSNONE; |
2060 } | 2060 } |
2061 | 2061 |
| 2062 // If current position is at grapheme boundary, return 0; otherwise, return the |
| 2063 // distance to its nearest left grapheme boundary. |
| 2064 size_t computeDistanceToLeftGraphemeBoundary(const Position& position) { |
| 2065 const Position& adjustedPosition = previousPositionOf( |
| 2066 nextPositionOf(position, PositionMoveType::GraphemeCluster), |
| 2067 PositionMoveType::GraphemeCluster); |
| 2068 DCHECK_EQ(position.anchorNode(), adjustedPosition.anchorNode()); |
| 2069 DCHECK_GE(position.computeOffsetInContainerNode(), |
| 2070 adjustedPosition.computeOffsetInContainerNode()); |
| 2071 return static_cast<size_t>(position.computeOffsetInContainerNode() - |
| 2072 adjustedPosition.computeOffsetInContainerNode()); |
| 2073 } |
| 2074 |
| 2075 // If current position is at grapheme boundary, return 0; otherwise, return the |
| 2076 // distance to its nearest right grapheme boundary. |
| 2077 size_t computeDistanceToRightGraphemeBoundary(const Position& position) { |
| 2078 const Position& adjustedPosition = nextPositionOf( |
| 2079 previousPositionOf(position, PositionMoveType::GraphemeCluster), |
| 2080 PositionMoveType::GraphemeCluster); |
| 2081 DCHECK_EQ(position.anchorNode(), adjustedPosition.anchorNode()); |
| 2082 DCHECK_GE(adjustedPosition.computeOffsetInContainerNode(), |
| 2083 position.computeOffsetInContainerNode()); |
| 2084 return static_cast<size_t>(adjustedPosition.computeOffsetInContainerNode() - |
| 2085 position.computeOffsetInContainerNode()); |
| 2086 } |
| 2087 |
2062 const StaticRangeVector* targetRangesForInputEvent(const Node& node) { | 2088 const StaticRangeVector* targetRangesForInputEvent(const Node& node) { |
2063 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | 2089 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
2064 // needs to be audited. see http://crbug.com/590369 for more details. | 2090 // needs to be audited. see http://crbug.com/590369 for more details. |
2065 node.document().updateStyleAndLayoutIgnorePendingStylesheets(); | 2091 node.document().updateStyleAndLayoutIgnorePendingStylesheets(); |
2066 if (!hasRichlyEditableStyle(node)) | 2092 if (!hasRichlyEditableStyle(node)) |
2067 return nullptr; | 2093 return nullptr; |
2068 const EphemeralRange& range = | 2094 const EphemeralRange& range = |
2069 firstEphemeralRangeOf(node.document() | 2095 firstEphemeralRangeOf(node.document() |
2070 .frame() | 2096 .frame() |
2071 ->selection() | 2097 ->selection() |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2160 return InputType::DeleteSoftLineBackward; | 2186 return InputType::DeleteSoftLineBackward; |
2161 if (granularity == ParagraphBoundary) | 2187 if (granularity == ParagraphBoundary) |
2162 return InputType::DeleteHardLineBackward; | 2188 return InputType::DeleteHardLineBackward; |
2163 return InputType::DeleteContentBackward; | 2189 return InputType::DeleteContentBackward; |
2164 default: | 2190 default: |
2165 return InputType::None; | 2191 return InputType::None; |
2166 } | 2192 } |
2167 } | 2193 } |
2168 | 2194 |
2169 } // namespace blink | 2195 } // namespace blink |
OLD | NEW |