| 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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 // block that contains the table and not the table, and this function should be
the only one responsible for | 329 // block that contains the table and not the table, and this function should be
the only one responsible for |
| 330 // knowing about these kinds of special cases. | 330 // knowing about these kinds of special cases. |
| 331 Element* enclosingBlock(Node* node, EditingBoundaryCrossingRule rule) | 331 Element* enclosingBlock(Node* node, EditingBoundaryCrossingRule rule) |
| 332 { | 332 { |
| 333 Node* enclosingNode = enclosingNodeOfType(firstPositionInOrBeforeNode(node),
isBlock, rule); | 333 Node* enclosingNode = enclosingNodeOfType(firstPositionInOrBeforeNode(node),
isBlock, rule); |
| 334 return enclosingNode && enclosingNode->isElementNode() ? toElement(enclosing
Node) : 0; | 334 return enclosingNode && enclosingNode->isElementNode() ? toElement(enclosing
Node) : 0; |
| 335 } | 335 } |
| 336 | 336 |
| 337 Element* enclosingBlockFlowElement(Node& node) | 337 Element* enclosingBlockFlowElement(Node& node) |
| 338 { | 338 { |
| 339 if (node.isBlockFlowElement()) | 339 if (isBlockFlowElement(node)) |
| 340 return &toElement(node); | 340 return &toElement(node); |
| 341 | 341 |
| 342 for (Node* n = node.parentNode(); n; n = n->parentNode()) { | 342 for (Node* n = node.parentNode(); n; n = n->parentNode()) { |
| 343 if (n->isBlockFlowElement() || isHTMLBodyElement(*n)) | 343 if (isBlockFlowElement(*n) || isHTMLBodyElement(*n)) |
| 344 return toElement(n); | 344 return toElement(n); |
| 345 } | 345 } |
| 346 return 0; | 346 return 0; |
| 347 } | 347 } |
| 348 | 348 |
| 349 bool inSameContainingBlockFlowElement(Node* a, Node* b) | 349 bool inSameContainingBlockFlowElement(Node* a, Node* b) |
| 350 { | 350 { |
| 351 return a && b && enclosingBlockFlowElement(*a) == enclosingBlockFlowElement(
*b); | 351 return a && b && enclosingBlockFlowElement(*a) == enclosingBlockFlowElement(
*b); |
| 352 } | 352 } |
| 353 | 353 |
| (...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 || element.hasTagName(tableTag) | 1192 || element.hasTagName(tableTag) |
| 1193 || element.hasTagName(ulTag) | 1193 || element.hasTagName(ulTag) |
| 1194 || element.hasTagName(xmpTag) | 1194 || element.hasTagName(xmpTag) |
| 1195 || element.hasTagName(h1Tag) | 1195 || element.hasTagName(h1Tag) |
| 1196 || element.hasTagName(h2Tag) | 1196 || element.hasTagName(h2Tag) |
| 1197 || element.hasTagName(h3Tag) | 1197 || element.hasTagName(h3Tag) |
| 1198 || element.hasTagName(h4Tag) | 1198 || element.hasTagName(h4Tag) |
| 1199 || element.hasTagName(h5Tag); | 1199 || element.hasTagName(h5Tag); |
| 1200 } | 1200 } |
| 1201 | 1201 |
| 1202 bool isBlockFlowElement(const Node& node) |
| 1203 { |
| 1204 RenderObject* renderer = node.renderer(); |
| 1205 return node.isElementNode() && renderer && renderer->isRenderBlockFlow(); |
| 1206 } |
| 1207 |
| 1202 Position adjustedSelectionStartForStyleComputation(const VisibleSelection& selec
tion) | 1208 Position adjustedSelectionStartForStyleComputation(const VisibleSelection& selec
tion) |
| 1203 { | 1209 { |
| 1204 // This function is used by range style computations to avoid bugs like: | 1210 // This function is used by range style computations to avoid bugs like: |
| 1205 // <rdar://problem/4017641> REGRESSION (Mail): you can only bold/unbold a se
lection starting from end of line once | 1211 // <rdar://problem/4017641> REGRESSION (Mail): you can only bold/unbold a se
lection starting from end of line once |
| 1206 // It is important to skip certain irrelevant content at the start of the se
lection, so we do not wind up | 1212 // It is important to skip certain irrelevant content at the start of the se
lection, so we do not wind up |
| 1207 // with a spurious "mixed" style. | 1213 // with a spurious "mixed" style. |
| 1208 | 1214 |
| 1209 VisiblePosition visiblePosition(selection.start()); | 1215 VisiblePosition visiblePosition(selection.start()); |
| 1210 if (visiblePosition.isNull()) | 1216 if (visiblePosition.isNull()) |
| 1211 return Position(); | 1217 return Position(); |
| 1212 | 1218 |
| 1213 // if the selection is a caret, just return the position, since the style | 1219 // if the selection is a caret, just return the position, since the style |
| 1214 // behind us is relevant | 1220 // behind us is relevant |
| 1215 if (selection.isCaret()) | 1221 if (selection.isCaret()) |
| 1216 return visiblePosition.deepEquivalent(); | 1222 return visiblePosition.deepEquivalent(); |
| 1217 | 1223 |
| 1218 // if the selection starts just before a paragraph break, skip over it | 1224 // if the selection starts just before a paragraph break, skip over it |
| 1219 if (isEndOfParagraph(visiblePosition)) | 1225 if (isEndOfParagraph(visiblePosition)) |
| 1220 return visiblePosition.next().deepEquivalent().downstream(); | 1226 return visiblePosition.next().deepEquivalent().downstream(); |
| 1221 | 1227 |
| 1222 // otherwise, make sure to be at the start of the first selected node, | 1228 // otherwise, make sure to be at the start of the first selected node, |
| 1223 // instead of possibly at the end of the last node before the selection | 1229 // instead of possibly at the end of the last node before the selection |
| 1224 return visiblePosition.deepEquivalent().downstream(); | 1230 return visiblePosition.deepEquivalent().downstream(); |
| 1225 } | 1231 } |
| 1226 | 1232 |
| 1227 } // namespace blink | 1233 } // namespace blink |
| OLD | NEW |