| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights |
| 3 * reserved. | 3 * reserved. |
| 4 * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved. | 4 * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 const PositionWithAffinityTemplate<Strategy> upstreamPosition( | 90 const PositionWithAffinityTemplate<Strategy> upstreamPosition( |
| 91 deepPosition, TextAffinity::Upstream); | 91 deepPosition, TextAffinity::Upstream); |
| 92 if (inSameLine(downstreamPosition, upstreamPosition)) | 92 if (inSameLine(downstreamPosition, upstreamPosition)) |
| 93 return VisiblePositionTemplate<Strategy>(downstreamPosition); | 93 return VisiblePositionTemplate<Strategy>(downstreamPosition); |
| 94 return VisiblePositionTemplate<Strategy>(upstreamPosition); | 94 return VisiblePositionTemplate<Strategy>(upstreamPosition); |
| 95 } | 95 } |
| 96 | 96 |
| 97 template <typename Strategy> | 97 template <typename Strategy> |
| 98 VisiblePositionTemplate<Strategy> VisiblePositionTemplate<Strategy>::afterNode( | 98 VisiblePositionTemplate<Strategy> VisiblePositionTemplate<Strategy>::afterNode( |
| 99 Node* node) { | 99 Node* node) { |
| 100 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | |
| 101 // needs to be audited. See http://crbug.com/590369 for more details. | |
| 102 if (node) | |
| 103 node->document().updateStyleAndLayoutIgnorePendingStylesheets(); | |
| 104 | |
| 105 return create(PositionWithAffinityTemplate<Strategy>( | 100 return create(PositionWithAffinityTemplate<Strategy>( |
| 106 PositionTemplate<Strategy>::afterNode(node))); | 101 PositionTemplate<Strategy>::afterNode(node))); |
| 107 } | 102 } |
| 108 | 103 |
| 109 template <typename Strategy> | 104 template <typename Strategy> |
| 110 VisiblePositionTemplate<Strategy> VisiblePositionTemplate<Strategy>::beforeNode( | 105 VisiblePositionTemplate<Strategy> VisiblePositionTemplate<Strategy>::beforeNode( |
| 111 Node* node) { | 106 Node* node) { |
| 112 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | |
| 113 // needs to be audited. See http://crbug.com/590369 for more details. | |
| 114 if (node) | |
| 115 node->document().updateStyleAndLayoutIgnorePendingStylesheets(); | |
| 116 | |
| 117 return create(PositionWithAffinityTemplate<Strategy>( | 107 return create(PositionWithAffinityTemplate<Strategy>( |
| 118 PositionTemplate<Strategy>::beforeNode(node))); | 108 PositionTemplate<Strategy>::beforeNode(node))); |
| 119 } | 109 } |
| 120 | 110 |
| 121 template <typename Strategy> | 111 template <typename Strategy> |
| 122 VisiblePositionTemplate<Strategy> | 112 VisiblePositionTemplate<Strategy> |
| 123 VisiblePositionTemplate<Strategy>::firstPositionInNode(Node* node) { | 113 VisiblePositionTemplate<Strategy>::firstPositionInNode(Node* node) { |
| 124 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | |
| 125 // needs to be audited. See http://crbug.com/590369 for more details. | |
| 126 if (node) | |
| 127 node->document().updateStyleAndLayoutIgnorePendingStylesheets(); | |
| 128 | |
| 129 return create(PositionWithAffinityTemplate<Strategy>( | 114 return create(PositionWithAffinityTemplate<Strategy>( |
| 130 PositionTemplate<Strategy>::firstPositionInNode(node))); | 115 PositionTemplate<Strategy>::firstPositionInNode(node))); |
| 131 } | 116 } |
| 132 | 117 |
| 133 template <typename Strategy> | 118 template <typename Strategy> |
| 134 VisiblePositionTemplate<Strategy> | 119 VisiblePositionTemplate<Strategy> |
| 135 VisiblePositionTemplate<Strategy>::inParentAfterNode(const Node& node) { | 120 VisiblePositionTemplate<Strategy>::inParentAfterNode(const Node& node) { |
| 136 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | |
| 137 // needs to be audited. See http://crbug.com/590369 for more details. | |
| 138 node.document().updateStyleAndLayoutIgnorePendingStylesheets(); | |
| 139 | |
| 140 return create(PositionWithAffinityTemplate<Strategy>( | 121 return create(PositionWithAffinityTemplate<Strategy>( |
| 141 PositionTemplate<Strategy>::inParentAfterNode(node))); | 122 PositionTemplate<Strategy>::inParentAfterNode(node))); |
| 142 } | 123 } |
| 143 | 124 |
| 144 template <typename Strategy> | 125 template <typename Strategy> |
| 145 VisiblePositionTemplate<Strategy> | 126 VisiblePositionTemplate<Strategy> |
| 146 VisiblePositionTemplate<Strategy>::inParentBeforeNode(const Node& node) { | 127 VisiblePositionTemplate<Strategy>::inParentBeforeNode(const Node& node) { |
| 147 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | |
| 148 // needs to be audited. See http://crbug.com/590369 for more details. | |
| 149 node.document().updateStyleAndLayoutIgnorePendingStylesheets(); | |
| 150 | |
| 151 return create(PositionWithAffinityTemplate<Strategy>( | 128 return create(PositionWithAffinityTemplate<Strategy>( |
| 152 PositionTemplate<Strategy>::inParentBeforeNode(node))); | 129 PositionTemplate<Strategy>::inParentBeforeNode(node))); |
| 153 } | 130 } |
| 154 | 131 |
| 155 template <typename Strategy> | 132 template <typename Strategy> |
| 156 VisiblePositionTemplate<Strategy> | 133 VisiblePositionTemplate<Strategy> |
| 157 VisiblePositionTemplate<Strategy>::lastPositionInNode(Node* node) { | 134 VisiblePositionTemplate<Strategy>::lastPositionInNode(Node* node) { |
| 158 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | |
| 159 // needs to be audited. See http://crbug.com/590369 for more details. | |
| 160 if (node) | |
| 161 node->document().updateStyleAndLayoutIgnorePendingStylesheets(); | |
| 162 | |
| 163 return create(PositionWithAffinityTemplate<Strategy>( | 135 return create(PositionWithAffinityTemplate<Strategy>( |
| 164 PositionTemplate<Strategy>::lastPositionInNode(node))); | 136 PositionTemplate<Strategy>::lastPositionInNode(node))); |
| 165 } | 137 } |
| 166 | 138 |
| 167 VisiblePosition createVisiblePositionDeprecated(const Position& position, | 139 VisiblePosition createVisiblePositionDeprecated(const Position& position, |
| 168 TextAffinity affinity) { | 140 TextAffinity affinity) { |
| 169 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | 141 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| 170 // needs to be audited. See http://crbug.com/590369 for more details. | 142 // needs to be audited. See http://crbug.com/590369 for more details. |
| 171 if (position.isNotNull()) | 143 if (position.isNotNull()) |
| 172 position.document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 144 position.document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 return; | 251 return; |
| 280 } | 252 } |
| 281 DVLOG(0) << "Cannot showTree for (nil) VisiblePosition."; | 253 DVLOG(0) << "Cannot showTree for (nil) VisiblePosition."; |
| 282 } | 254 } |
| 283 | 255 |
| 284 void showTree(const blink::VisiblePosition& vpos) { | 256 void showTree(const blink::VisiblePosition& vpos) { |
| 285 vpos.showTreeForThis(); | 257 vpos.showTreeForThis(); |
| 286 } | 258 } |
| 287 | 259 |
| 288 #endif | 260 #endif |
| OLD | NEW |