| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 if (node->hasEditableStyle(editableType)) | 129 if (node->hasEditableStyle(editableType)) |
| 130 highestRoot = node; | 130 highestRoot = node; |
| 131 if (isHTMLBodyElement(*node)) | 131 if (isHTMLBodyElement(*node)) |
| 132 break; | 132 break; |
| 133 node = node->parentNode(); | 133 node = node->parentNode(); |
| 134 } | 134 } |
| 135 | 135 |
| 136 return highestRoot; | 136 return highestRoot; |
| 137 } | 137 } |
| 138 | 138 |
| 139 ContainerNode* highestEditableRoot(const PositionInComposedTree& position, Edita
bleType editableType) |
| 140 { |
| 141 return highestEditableRoot(toPositionInDOMTree(position), editableType); |
| 142 } |
| 143 |
| 139 Element* lowestEditableAncestor(Node* node) | 144 Element* lowestEditableAncestor(Node* node) |
| 140 { | 145 { |
| 141 while (node) { | 146 while (node) { |
| 142 if (node->hasEditableStyle()) | 147 if (node->hasEditableStyle()) |
| 143 return node->rootEditableElement(); | 148 return node->rootEditableElement(); |
| 144 if (isHTMLBodyElement(*node)) | 149 if (isHTMLBodyElement(*node)) |
| 145 break; | 150 break; |
| 146 node = node->parentNode(); | 151 node = node->parentNode(); |
| 147 } | 152 } |
| 148 | 153 |
| 149 return 0; | 154 return 0; |
| 150 } | 155 } |
| 151 | 156 |
| 152 bool isEditablePosition(const Position& p, EditableType editableType, EUpdateSty
le updateStyle) | 157 bool isEditablePosition(const Position& p, EditableType editableType, EUpdateSty
le updateStyle) |
| 153 { | 158 { |
| 154 Node* node = p.parentAnchoredEquivalent().anchorNode(); | 159 Node* node = p.parentAnchoredEquivalent().anchorNode(); |
| 155 if (!node) | 160 if (!node) |
| 156 return false; | 161 return false; |
| 157 if (updateStyle == UpdateStyle) | 162 if (updateStyle == UpdateStyle) |
| 158 node->document().updateLayoutIgnorePendingStylesheets(); | 163 node->document().updateLayoutIgnorePendingStylesheets(); |
| 159 else | 164 else |
| 160 ASSERT(updateStyle == DoNotUpdateStyle); | 165 ASSERT(updateStyle == DoNotUpdateStyle); |
| 161 | 166 |
| 162 if (isRenderedHTMLTableElement(node)) | 167 if (isRenderedHTMLTableElement(node)) |
| 163 node = node->parentNode(); | 168 node = node->parentNode(); |
| 164 | 169 |
| 165 return node->hasEditableStyle(editableType); | 170 return node->hasEditableStyle(editableType); |
| 166 } | 171 } |
| 167 | 172 |
| 173 bool isEditablePosition(const PositionInComposedTree& p, EditableType editableTy
pe, EUpdateStyle updateStyle) |
| 174 { |
| 175 return isEditablePosition(toPositionInDOMTree(p), editableType, updateStyle)
; |
| 176 } |
| 177 |
| 168 bool isAtUnsplittableElement(const Position& pos) | 178 bool isAtUnsplittableElement(const Position& pos) |
| 169 { | 179 { |
| 170 Node* node = pos.deprecatedNode(); | 180 Node* node = pos.deprecatedNode(); |
| 171 return (node == editableRootForPosition(pos) || node == enclosingNodeOfType(
pos, &isTableCell)); | 181 return (node == editableRootForPosition(pos) || node == enclosingNodeOfType(
pos, &isTableCell)); |
| 172 } | 182 } |
| 173 | 183 |
| 174 | 184 |
| 175 bool isRichlyEditablePosition(const Position& p, EditableType editableType) | 185 bool isRichlyEditablePosition(const Position& p, EditableType editableType) |
| 176 { | 186 { |
| 177 Node* node = p.deprecatedNode(); | 187 Node* node = p.deprecatedNode(); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 return p; | 294 return p; |
| 285 } | 295 } |
| 286 return PositionType(); | 296 return PositionType(); |
| 287 } | 297 } |
| 288 | 298 |
| 289 Position previousVisuallyDistinctCandidate(const Position& position) | 299 Position previousVisuallyDistinctCandidate(const Position& position) |
| 290 { | 300 { |
| 291 return previousVisuallyDistinctCandidateAlgorithm<Position>(position); | 301 return previousVisuallyDistinctCandidateAlgorithm<Position>(position); |
| 292 } | 302 } |
| 293 | 303 |
| 304 PositionInComposedTree previousVisuallyDistinctCandidate(const PositionInCompose
dTree& position) |
| 305 { |
| 306 return previousVisuallyDistinctCandidateAlgorithm<PositionInComposedTree>(po
sition); |
| 307 } |
| 308 |
| 294 VisiblePosition firstEditableVisiblePositionAfterPositionInRoot(const Position&
position, ContainerNode* highestRoot) | 309 VisiblePosition firstEditableVisiblePositionAfterPositionInRoot(const Position&
position, ContainerNode* highestRoot) |
| 295 { | 310 { |
| 296 // position falls before highestRoot. | 311 // position falls before highestRoot. |
| 297 if (comparePositions(position, firstPositionInNode(highestRoot)) == -1 && hi
ghestRoot->hasEditableStyle()) | 312 if (comparePositions(position, firstPositionInNode(highestRoot)) == -1 && hi
ghestRoot->hasEditableStyle()) |
| 298 return VisiblePosition(firstPositionInNode(highestRoot)); | 313 return VisiblePosition(firstPositionInNode(highestRoot)); |
| 299 | 314 |
| 300 Position editablePosition = position; | 315 Position editablePosition = position; |
| 301 | 316 |
| 302 if (position.deprecatedNode()->treeScope() != highestRoot->treeScope()) { | 317 if (position.deprecatedNode()->treeScope() != highestRoot->treeScope()) { |
| 303 Node* shadowAncestor = highestRoot->treeScope().ancestorInThisScope(edit
ablePosition.deprecatedNode()); | 318 Node* shadowAncestor = highestRoot->treeScope().ancestorInThisScope(edit
ablePosition.deprecatedNode()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 if (editablePosition.deprecatedNode() && editablePosition.deprecatedNode() !
= highestRoot && !editablePosition.deprecatedNode()->isDescendantOf(highestRoot)
) | 359 if (editablePosition.deprecatedNode() && editablePosition.deprecatedNode() !
= highestRoot && !editablePosition.deprecatedNode()->isDescendantOf(highestRoot)
) |
| 345 return PositionType(); | 360 return PositionType(); |
| 346 return editablePosition; | 361 return editablePosition; |
| 347 } | 362 } |
| 348 | 363 |
| 349 Position lastEditablePositionBeforePositionInRoot(const Position& position, Node
* highestRoot) | 364 Position lastEditablePositionBeforePositionInRoot(const Position& position, Node
* highestRoot) |
| 350 { | 365 { |
| 351 return lastEditablePositionBeforePositionInRootAlgorithm<Position>(position,
highestRoot); | 366 return lastEditablePositionBeforePositionInRootAlgorithm<Position>(position,
highestRoot); |
| 352 } | 367 } |
| 353 | 368 |
| 369 PositionInComposedTree lastEditablePositionBeforePositionInRoot(const PositionIn
ComposedTree& position, Node* highestRoot) |
| 370 { |
| 371 return lastEditablePositionBeforePositionInRootAlgorithm<PositionInComposedT
ree>(position, highestRoot); |
| 372 } |
| 373 |
| 354 // FIXME: The method name, comment, and code say three different things here! | 374 // FIXME: The method name, comment, and code say three different things here! |
| 355 // Whether or not content before and after this node will collapse onto the same
line as it. | 375 // Whether or not content before and after this node will collapse onto the same
line as it. |
| 356 bool isBlock(const Node* node) | 376 bool isBlock(const Node* node) |
| 357 { | 377 { |
| 358 return node && node->layoutObject() && !node->layoutObject()->isInline() &&
!node->layoutObject()->isRubyText(); | 378 return node && node->layoutObject() && !node->layoutObject()->isInline() &&
!node->layoutObject()->isRubyText(); |
| 359 } | 379 } |
| 360 | 380 |
| 361 bool isInline(const Node* node) | 381 bool isInline(const Node* node) |
| 362 { | 382 { |
| 363 return node && node->layoutObject() && node->layoutObject()->isInline(); | 383 return node && node->layoutObject() && node->layoutObject()->isInline(); |
| (...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1223 // if the selection starts just before a paragraph break, skip over it | 1243 // if the selection starts just before a paragraph break, skip over it |
| 1224 if (isEndOfParagraph(visiblePosition)) | 1244 if (isEndOfParagraph(visiblePosition)) |
| 1225 return visiblePosition.next().deepEquivalent().downstream(); | 1245 return visiblePosition.next().deepEquivalent().downstream(); |
| 1226 | 1246 |
| 1227 // otherwise, make sure to be at the start of the first selected node, | 1247 // otherwise, make sure to be at the start of the first selected node, |
| 1228 // instead of possibly at the end of the last node before the selection | 1248 // instead of possibly at the end of the last node before the selection |
| 1229 return visiblePosition.deepEquivalent().downstream(); | 1249 return visiblePosition.deepEquivalent().downstream(); |
| 1230 } | 1250 } |
| 1231 | 1251 |
| 1232 } // namespace blink | 1252 } // namespace blink |
| OLD | NEW |