| 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 | 308 |
| 309 if (editablePosition.deprecatedNode() && editablePosition.deprecatedNode() !
= highestRoot && !editablePosition.deprecatedNode()->isDescendantOf(highestRoot)
) | 309 if (editablePosition.deprecatedNode() && editablePosition.deprecatedNode() !
= highestRoot && !editablePosition.deprecatedNode()->isDescendantOf(highestRoot)
) |
| 310 return Position(); | 310 return Position(); |
| 311 return editablePosition; | 311 return editablePosition; |
| 312 } | 312 } |
| 313 | 313 |
| 314 // FIXME: The method name, comment, and code say three different things here! | 314 // FIXME: The method name, comment, and code say three different things here! |
| 315 // Whether or not content before and after this node will collapse onto the same
line as it. | 315 // Whether or not content before and after this node will collapse onto the same
line as it. |
| 316 bool isBlock(const Node* node) | 316 bool isBlock(const Node* node) |
| 317 { | 317 { |
| 318 return node && node->renderer() && !node->renderer()->isInline() && !node->r
enderer()->isRubyText(); | 318 return node && node->layoutObject() && !node->layoutObject()->isInline() &&
!node->layoutObject()->isRubyText(); |
| 319 } | 319 } |
| 320 | 320 |
| 321 bool isInline(const Node* node) | 321 bool isInline(const Node* node) |
| 322 { | 322 { |
| 323 return node && node->renderer() && node->renderer()->isInline(); | 323 return node && node->layoutObject() && node->layoutObject()->isInline(); |
| 324 } | 324 } |
| 325 | 325 |
| 326 // FIXME: Deploy this in all of the places where enclosingBlockFlow/enclosingBlo
ckFlowOrTableElement are used. | 326 // FIXME: Deploy this in all of the places where enclosingBlockFlow/enclosingBlo
ckFlowOrTableElement are used. |
| 327 // FIXME: Pass a position to this function. The enclosing block of [table, x] fo
r example, should be the | 327 // FIXME: Pass a position to this function. The enclosing block of [table, x] fo
r example, should be the |
| 328 // block that contains the table and not the table, and this function should be
the only one responsible for | 328 // block that contains the table and not the table, and this function should be
the only one responsible for |
| 329 // knowing about these kinds of special cases. | 329 // knowing about these kinds of special cases. |
| 330 Element* enclosingBlock(Node* node, EditingBoundaryCrossingRule rule) | 330 Element* enclosingBlock(Node* node, EditingBoundaryCrossingRule rule) |
| 331 { | 331 { |
| 332 Node* enclosingNode = enclosingNodeOfType(firstPositionInOrBeforeNode(node),
isBlock, rule); | 332 Node* enclosingNode = enclosingNodeOfType(firstPositionInOrBeforeNode(node),
isBlock, rule); |
| 333 return enclosingNode && enclosingNode->isElementNode() ? toElement(enclosing
Node) : 0; | 333 return enclosingNode && enclosingNode->isElementNode() ? toElement(enclosing
Node) : 0; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 348 bool inSameContainingBlockFlowElement(Node* a, Node* b) | 348 bool inSameContainingBlockFlowElement(Node* a, Node* b) |
| 349 { | 349 { |
| 350 return a && b && enclosingBlockFlowElement(*a) == enclosingBlockFlowElement(
*b); | 350 return a && b && enclosingBlockFlowElement(*a) == enclosingBlockFlowElement(
*b); |
| 351 } | 351 } |
| 352 | 352 |
| 353 TextDirection directionOfEnclosingBlock(const Position& position) | 353 TextDirection directionOfEnclosingBlock(const Position& position) |
| 354 { | 354 { |
| 355 Element* enclosingBlockElement = enclosingBlock(position.containerNode()); | 355 Element* enclosingBlockElement = enclosingBlock(position.containerNode()); |
| 356 if (!enclosingBlockElement) | 356 if (!enclosingBlockElement) |
| 357 return LTR; | 357 return LTR; |
| 358 LayoutObject* renderer = enclosingBlockElement->renderer(); | 358 LayoutObject* renderer = enclosingBlockElement->layoutObject(); |
| 359 return renderer ? renderer->style()->direction() : LTR; | 359 return renderer ? renderer->style()->direction() : LTR; |
| 360 } | 360 } |
| 361 | 361 |
| 362 // This method is used to create positions in the DOM. It returns the maximum va
lid offset | 362 // This method is used to create positions in the DOM. It returns the maximum va
lid offset |
| 363 // in a node. It returns 1 for some elements even though they do not have childr
en, which | 363 // in a node. It returns 1 for some elements even though they do not have childr
en, which |
| 364 // creates technically invalid DOM Positions. Be sure to call parentAnchoredEqui
valent | 364 // creates technically invalid DOM Positions. Be sure to call parentAnchoredEqui
valent |
| 365 // on a Position before using it to create a DOM Range, or an exception will be
thrown. | 365 // on a Position before using it to create a DOM Range, or an exception will be
thrown. |
| 366 int lastOffsetForEditing(const Node* node) | 366 int lastOffsetForEditing(const Node* node) |
| 367 { | 367 { |
| 368 ASSERT(node); | 368 ASSERT(node); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 } | 406 } |
| 407 } | 407 } |
| 408 | 408 |
| 409 ASSERT(rebalancedString.length() == length); | 409 ASSERT(rebalancedString.length() == length); |
| 410 | 410 |
| 411 return rebalancedString.toString(); | 411 return rebalancedString.toString(); |
| 412 } | 412 } |
| 413 | 413 |
| 414 bool isTableStructureNode(const Node *node) | 414 bool isTableStructureNode(const Node *node) |
| 415 { | 415 { |
| 416 LayoutObject* renderer = node->renderer(); | 416 LayoutObject* renderer = node->layoutObject(); |
| 417 return (renderer && (renderer->isTableCell() || renderer->isTableRow() || re
nderer->isTableSection() || renderer->isLayoutTableCol())); | 417 return (renderer && (renderer->isTableCell() || renderer->isTableRow() || re
nderer->isTableSection() || renderer->isLayoutTableCol())); |
| 418 } | 418 } |
| 419 | 419 |
| 420 const String& nonBreakingSpaceString() | 420 const String& nonBreakingSpaceString() |
| 421 { | 421 { |
| 422 DEFINE_STATIC_LOCAL(String, nonBreakingSpaceString, (&noBreakSpace, 1)); | 422 DEFINE_STATIC_LOCAL(String, nonBreakingSpaceString, (&noBreakSpace, 1)); |
| 423 return nonBreakingSpaceString; | 423 return nonBreakingSpaceString; |
| 424 } | 424 } |
| 425 | 425 |
| 426 // FIXME: need to dump this | 426 // FIXME: need to dump this |
| 427 static bool isSpecialHTMLElement(const Node& n) | 427 static bool isSpecialHTMLElement(const Node& n) |
| 428 { | 428 { |
| 429 if (!n.isHTMLElement()) | 429 if (!n.isHTMLElement()) |
| 430 return false; | 430 return false; |
| 431 | 431 |
| 432 if (n.isLink()) | 432 if (n.isLink()) |
| 433 return true; | 433 return true; |
| 434 | 434 |
| 435 LayoutObject* renderer = n.renderer(); | 435 LayoutObject* renderer = n.layoutObject(); |
| 436 if (!renderer) | 436 if (!renderer) |
| 437 return false; | 437 return false; |
| 438 | 438 |
| 439 if (renderer->style()->display() == TABLE || renderer->style()->display() ==
INLINE_TABLE) | 439 if (renderer->style()->display() == TABLE || renderer->style()->display() ==
INLINE_TABLE) |
| 440 return true; | 440 return true; |
| 441 | 441 |
| 442 if (renderer->style()->isFloating()) | 442 if (renderer->style()->isFloating()) |
| 443 return true; | 443 return true; |
| 444 | 444 |
| 445 return false; | 445 return false; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 return VisiblePosition(positionInParentAfterNode(node)); | 543 return VisiblePosition(positionInParentAfterNode(node)); |
| 544 } | 544 } |
| 545 | 545 |
| 546 bool isHTMLListElement(Node* n) | 546 bool isHTMLListElement(Node* n) |
| 547 { | 547 { |
| 548 return (n && (isHTMLUListElement(*n) || isHTMLOListElement(*n) || isHTMLDLis
tElement(*n))); | 548 return (n && (isHTMLUListElement(*n) || isHTMLOListElement(*n) || isHTMLDLis
tElement(*n))); |
| 549 } | 549 } |
| 550 | 550 |
| 551 bool isListItem(const Node* n) | 551 bool isListItem(const Node* n) |
| 552 { | 552 { |
| 553 return n && n->renderer() && n->renderer()->isListItem(); | 553 return n && n->layoutObject() && n->layoutObject()->isListItem(); |
| 554 } | 554 } |
| 555 | 555 |
| 556 Element* enclosingElementWithTag(const Position& p, const QualifiedName& tagName
) | 556 Element* enclosingElementWithTag(const Position& p, const QualifiedName& tagName
) |
| 557 { | 557 { |
| 558 if (p.isNull()) | 558 if (p.isNull()) |
| 559 return 0; | 559 return 0; |
| 560 | 560 |
| 561 ContainerNode* root = highestEditableRoot(p); | 561 ContainerNode* root = highestEditableRoot(p); |
| 562 Element* ancestor = p.deprecatedNode()->isElementNode() ? toElement(p.deprec
atedNode()) : p.deprecatedNode()->parentElement(); | 562 Element* ancestor = p.deprecatedNode()->isElementNode() ? toElement(p.deprec
atedNode()) : p.deprecatedNode()->parentElement(); |
| 563 for (; ancestor; ancestor = ancestor->parentElement()) { | 563 for (; ancestor; ancestor = ancestor->parentElement()) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 return highest; | 610 return highest; |
| 611 } | 611 } |
| 612 | 612 |
| 613 static bool hasARenderedDescendant(Node* node, Node* excludedNode) | 613 static bool hasARenderedDescendant(Node* node, Node* excludedNode) |
| 614 { | 614 { |
| 615 for (Node* n = node->firstChild(); n;) { | 615 for (Node* n = node->firstChild(); n;) { |
| 616 if (n == excludedNode) { | 616 if (n == excludedNode) { |
| 617 n = NodeTraversal::nextSkippingChildren(*n, node); | 617 n = NodeTraversal::nextSkippingChildren(*n, node); |
| 618 continue; | 618 continue; |
| 619 } | 619 } |
| 620 if (n->renderer()) | 620 if (n->layoutObject()) |
| 621 return true; | 621 return true; |
| 622 n = NodeTraversal::next(*n, node); | 622 n = NodeTraversal::next(*n, node); |
| 623 } | 623 } |
| 624 return false; | 624 return false; |
| 625 } | 625 } |
| 626 | 626 |
| 627 Node* highestNodeToRemoveInPruning(Node* node, Node* excludeNode) | 627 Node* highestNodeToRemoveInPruning(Node* node, Node* excludeNode) |
| 628 { | 628 { |
| 629 Node* previousNode = nullptr; | 629 Node* previousNode = nullptr; |
| 630 Element* rootEditableElement = node ? node->rootEditableElement() : nullptr; | 630 Element* rootEditableElement = node ? node->rootEditableElement() : nullptr; |
| 631 for (; node; node = node->parentNode()) { | 631 for (; node; node = node->parentNode()) { |
| 632 if (LayoutObject* renderer = node->renderer()) { | 632 if (LayoutObject* renderer = node->layoutObject()) { |
| 633 if (!renderer->canHaveChildren() || hasARenderedDescendant(node, pre
viousNode) || rootEditableElement == node || excludeNode == node) | 633 if (!renderer->canHaveChildren() || hasARenderedDescendant(node, pre
viousNode) || rootEditableElement == node || excludeNode == node) |
| 634 return previousNode; | 634 return previousNode; |
| 635 } | 635 } |
| 636 previousNode = node; | 636 previousNode = node; |
| 637 } | 637 } |
| 638 return 0; | 638 return 0; |
| 639 } | 639 } |
| 640 | 640 |
| 641 Element* enclosingTableCell(const Position& p) | 641 Element* enclosingTableCell(const Position& p) |
| 642 { | 642 { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 | 737 |
| 738 return firstList->hasTagName(secondList->tagQName()) // make sure the list t
ypes match (ol vs. ul) | 738 return firstList->hasTagName(secondList->tagQName()) // make sure the list t
ypes match (ol vs. ul) |
| 739 && firstList->hasEditableStyle() && secondList->hasEditableStyle() // both l
ists are editable | 739 && firstList->hasEditableStyle() && secondList->hasEditableStyle() // both l
ists are editable |
| 740 && firstList->rootEditableElement() == secondList->rootEditableElement() //
don't cross editing boundaries | 740 && firstList->rootEditableElement() == secondList->rootEditableElement() //
don't cross editing boundaries |
| 741 && isVisiblyAdjacent(positionInParentAfterNode(*firstList), positionInParent
BeforeNode(*secondList)); | 741 && isVisiblyAdjacent(positionInParentAfterNode(*firstList), positionInParent
BeforeNode(*secondList)); |
| 742 // Make sure there is no visible content between this li and the previous li
st | 742 // Make sure there is no visible content between this li and the previous li
st |
| 743 } | 743 } |
| 744 | 744 |
| 745 bool isRenderedHTMLTableElement(const Node* node) | 745 bool isRenderedHTMLTableElement(const Node* node) |
| 746 { | 746 { |
| 747 return isHTMLTableElement(*node) && node->renderer(); | 747 return isHTMLTableElement(*node) && node->layoutObject(); |
| 748 } | 748 } |
| 749 | 749 |
| 750 bool isRenderedTableElement(const Node* node) | 750 bool isRenderedTableElement(const Node* node) |
| 751 { | 751 { |
| 752 if (!node || !node->isElementNode()) | 752 if (!node || !node->isElementNode()) |
| 753 return false; | 753 return false; |
| 754 | 754 |
| 755 LayoutObject* renderer = node->renderer(); | 755 LayoutObject* renderer = node->layoutObject(); |
| 756 return (renderer && renderer->isTable()); | 756 return (renderer && renderer->isTable()); |
| 757 } | 757 } |
| 758 | 758 |
| 759 bool isTableCell(const Node* node) | 759 bool isTableCell(const Node* node) |
| 760 { | 760 { |
| 761 ASSERT(node); | 761 ASSERT(node); |
| 762 LayoutObject* r = node->renderer(); | 762 LayoutObject* r = node->layoutObject(); |
| 763 return r ? r->isTableCell() : isHTMLTableCellElement(*node); | 763 return r ? r->isTableCell() : isHTMLTableCellElement(*node); |
| 764 } | 764 } |
| 765 | 765 |
| 766 bool isEmptyTableCell(const Node* node) | 766 bool isEmptyTableCell(const Node* node) |
| 767 { | 767 { |
| 768 // Returns true IFF the passed in node is one of: | 768 // Returns true IFF the passed in node is one of: |
| 769 // .) a table cell with no children, | 769 // .) a table cell with no children, |
| 770 // .) a table cell with a single BR child, and which has no other child re
nderers, including :before and :after renderers | 770 // .) a table cell with a single BR child, and which has no other child re
nderers, including :before and :after renderers |
| 771 // .) the BR child of such a table cell | 771 // .) the BR child of such a table cell |
| 772 | 772 |
| 773 // Find rendered node | 773 // Find rendered node |
| 774 while (node && !node->renderer()) | 774 while (node && !node->layoutObject()) |
| 775 node = node->parentNode(); | 775 node = node->parentNode(); |
| 776 if (!node) | 776 if (!node) |
| 777 return false; | 777 return false; |
| 778 | 778 |
| 779 // Make sure the rendered node is a table cell or <br>. | 779 // Make sure the rendered node is a table cell or <br>. |
| 780 // If it's a <br>, then the parent node has to be a table cell. | 780 // If it's a <br>, then the parent node has to be a table cell. |
| 781 LayoutObject* renderer = node->renderer(); | 781 LayoutObject* renderer = node->layoutObject(); |
| 782 if (renderer->isBR()) { | 782 if (renderer->isBR()) { |
| 783 renderer = renderer->parent(); | 783 renderer = renderer->parent(); |
| 784 if (!renderer) | 784 if (!renderer) |
| 785 return false; | 785 return false; |
| 786 } | 786 } |
| 787 if (!renderer->isTableCell()) | 787 if (!renderer->isTableCell()) |
| 788 return false; | 788 return false; |
| 789 | 789 |
| 790 // Check that the table cell contains no child renderers except for perhaps
a single <br>. | 790 // Check that the table cell contains no child renderers except for perhaps
a single <br>. |
| 791 LayoutObject* childRenderer = toLayoutTableCell(renderer)->firstChild(); | 791 LayoutObject* childRenderer = toLayoutTableCell(renderer)->firstChild(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 return createTabSpanElement(document, PassRefPtrWillBeRawPtr<Text>(nullptr))
; | 875 return createTabSpanElement(document, PassRefPtrWillBeRawPtr<Text>(nullptr))
; |
| 876 } | 876 } |
| 877 | 877 |
| 878 PassRefPtrWillBeRawPtr<HTMLBRElement> createBlockPlaceholderElement(Document& do
cument) | 878 PassRefPtrWillBeRawPtr<HTMLBRElement> createBlockPlaceholderElement(Document& do
cument) |
| 879 { | 879 { |
| 880 return toHTMLBRElement(document.createElement(brTag, false).get()); | 880 return toHTMLBRElement(document.createElement(brTag, false).get()); |
| 881 } | 881 } |
| 882 | 882 |
| 883 bool isNodeRendered(const Node& node) | 883 bool isNodeRendered(const Node& node) |
| 884 { | 884 { |
| 885 LayoutObject* renderer = node.renderer(); | 885 LayoutObject* renderer = node.layoutObject(); |
| 886 if (!renderer) | 886 if (!renderer) |
| 887 return false; | 887 return false; |
| 888 | 888 |
| 889 return renderer->style()->visibility() == VISIBLE; | 889 return renderer->style()->visibility() == VISIBLE; |
| 890 } | 890 } |
| 891 | 891 |
| 892 // return first preceding DOM position rendered at a different location, or "thi
s" | 892 // return first preceding DOM position rendered at a different location, or "thi
s" |
| 893 static Position previousCharacterPosition(const Position& position, EAffinity af
finity) | 893 static Position previousCharacterPosition(const Position& position, EAffinity af
finity) |
| 894 { | 894 { |
| 895 if (position.isNull()) | 895 if (position.isNull()) |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1000 { | 1000 { |
| 1001 if (!node || !node->isHTMLElement()) | 1001 if (!node || !node->isHTMLElement()) |
| 1002 return false; | 1002 return false; |
| 1003 | 1003 |
| 1004 const HTMLElement& element = toHTMLElement(*node); | 1004 const HTMLElement& element = toHTMLElement(*node); |
| 1005 return element.hasTagName(blockquoteTag) && element.getAttribute("type") ==
"cite"; | 1005 return element.hasTagName(blockquoteTag) && element.getAttribute("type") ==
"cite"; |
| 1006 } | 1006 } |
| 1007 | 1007 |
| 1008 int caretMinOffset(const Node* n) | 1008 int caretMinOffset(const Node* n) |
| 1009 { | 1009 { |
| 1010 LayoutObject* r = n->renderer(); | 1010 LayoutObject* r = n->layoutObject(); |
| 1011 ASSERT(!n->isCharacterDataNode() || !r || r->isText()); // FIXME: This was a
runtime check that seemingly couldn't fail; changed it to an assertion for now. | 1011 ASSERT(!n->isCharacterDataNode() || !r || r->isText()); // FIXME: This was a
runtime check that seemingly couldn't fail; changed it to an assertion for now. |
| 1012 return r ? r->caretMinOffset() : 0; | 1012 return r ? r->caretMinOffset() : 0; |
| 1013 } | 1013 } |
| 1014 | 1014 |
| 1015 // If a node can contain candidates for VisiblePositions, return the offset of t
he last candidate, otherwise | 1015 // If a node can contain candidates for VisiblePositions, return the offset of t
he last candidate, otherwise |
| 1016 // return the number of children for container nodes and the length for unrender
ed text nodes. | 1016 // return the number of children for container nodes and the length for unrender
ed text nodes. |
| 1017 int caretMaxOffset(const Node* n) | 1017 int caretMaxOffset(const Node* n) |
| 1018 { | 1018 { |
| 1019 // For rendered text nodes, return the last position that a caret could occu
py. | 1019 // For rendered text nodes, return the last position that a caret could occu
py. |
| 1020 if (n->isTextNode() && n->renderer()) | 1020 if (n->isTextNode() && n->layoutObject()) |
| 1021 return n->renderer()->caretMaxOffset(); | 1021 return n->layoutObject()->caretMaxOffset(); |
| 1022 // For containers return the number of children. For others do the same as a
bove. | 1022 // For containers return the number of children. For others do the same as a
bove. |
| 1023 return lastOffsetForEditing(n); | 1023 return lastOffsetForEditing(n); |
| 1024 } | 1024 } |
| 1025 | 1025 |
| 1026 bool lineBreakExistsAtVisiblePosition(const VisiblePosition& visiblePosition) | 1026 bool lineBreakExistsAtVisiblePosition(const VisiblePosition& visiblePosition) |
| 1027 { | 1027 { |
| 1028 return lineBreakExistsAtPosition(visiblePosition.deepEquivalent().downstream
()); | 1028 return lineBreakExistsAtPosition(visiblePosition.deepEquivalent().downstream
()); |
| 1029 } | 1029 } |
| 1030 | 1030 |
| 1031 bool lineBreakExistsAtPosition(const Position& position) | 1031 bool lineBreakExistsAtPosition(const Position& position) |
| 1032 { | 1032 { |
| 1033 if (position.isNull()) | 1033 if (position.isNull()) |
| 1034 return false; | 1034 return false; |
| 1035 | 1035 |
| 1036 if (isHTMLBRElement(*position.anchorNode()) && position.atFirstEditingPositi
onForNode()) | 1036 if (isHTMLBRElement(*position.anchorNode()) && position.atFirstEditingPositi
onForNode()) |
| 1037 return true; | 1037 return true; |
| 1038 | 1038 |
| 1039 if (!position.anchorNode()->renderer()) | 1039 if (!position.anchorNode()->layoutObject()) |
| 1040 return false; | 1040 return false; |
| 1041 | 1041 |
| 1042 if (!position.anchorNode()->isTextNode() || !position.anchorNode()->renderer
()->style()->preserveNewline()) | 1042 if (!position.anchorNode()->isTextNode() || !position.anchorNode()->layoutOb
ject()->style()->preserveNewline()) |
| 1043 return false; | 1043 return false; |
| 1044 | 1044 |
| 1045 Text* textNode = toText(position.anchorNode()); | 1045 Text* textNode = toText(position.anchorNode()); |
| 1046 unsigned offset = position.offsetInContainerNode(); | 1046 unsigned offset = position.offsetInContainerNode(); |
| 1047 return offset < textNode->length() && textNode->data()[offset] == '\n'; | 1047 return offset < textNode->length() && textNode->data()[offset] == '\n'; |
| 1048 } | 1048 } |
| 1049 | 1049 |
| 1050 // Modifies selections that have an end point at the edge of a table | 1050 // Modifies selections that have an end point at the edge of a table |
| 1051 // that contains the other endpoint so that they don't confuse | 1051 // that contains the other endpoint so that they don't confuse |
| 1052 // code that iterates over selected paragraphs. | 1052 // code that iterates over selected paragraphs. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1128 if (endIsVisuallySame && comparePositions(selectedRange.startPosition(), pos
itionInParentBeforeNode(node)) < 0) | 1128 if (endIsVisuallySame && comparePositions(selectedRange.startPosition(), pos
itionInParentBeforeNode(node)) < 0) |
| 1129 return true; | 1129 return true; |
| 1130 | 1130 |
| 1131 return startIsVisuallySame && endIsVisuallySame; | 1131 return startIsVisuallySame && endIsVisuallySame; |
| 1132 } | 1132 } |
| 1133 | 1133 |
| 1134 bool isRenderedAsNonInlineTableImageOrHR(const Node* node) | 1134 bool isRenderedAsNonInlineTableImageOrHR(const Node* node) |
| 1135 { | 1135 { |
| 1136 if (!node) | 1136 if (!node) |
| 1137 return false; | 1137 return false; |
| 1138 LayoutObject* renderer = node->renderer(); | 1138 LayoutObject* renderer = node->layoutObject(); |
| 1139 return renderer && ((renderer->isTable() && !renderer->isInline()) || (rende
rer->isImage() && !renderer->isInline()) || renderer->isHR()); | 1139 return renderer && ((renderer->isTable() && !renderer->isInline()) || (rende
rer->isImage() && !renderer->isInline()) || renderer->isHR()); |
| 1140 } | 1140 } |
| 1141 | 1141 |
| 1142 bool areIdenticalElements(const Node* first, const Node* second) | 1142 bool areIdenticalElements(const Node* first, const Node* second) |
| 1143 { | 1143 { |
| 1144 if (!first->isElementNode() || !second->isElementNode()) | 1144 if (!first->isElementNode() || !second->isElementNode()) |
| 1145 return false; | 1145 return false; |
| 1146 | 1146 |
| 1147 const Element* firstElement = toElement(first); | 1147 const Element* firstElement = toElement(first); |
| 1148 const Element* secondElement = toElement(second); | 1148 const Element* secondElement = toElement(second); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1166 || element.hasTagName(xmpTag) | 1166 || element.hasTagName(xmpTag) |
| 1167 || element.hasTagName(h1Tag) | 1167 || element.hasTagName(h1Tag) |
| 1168 || element.hasTagName(h2Tag) | 1168 || element.hasTagName(h2Tag) |
| 1169 || element.hasTagName(h3Tag) | 1169 || element.hasTagName(h3Tag) |
| 1170 || element.hasTagName(h4Tag) | 1170 || element.hasTagName(h4Tag) |
| 1171 || element.hasTagName(h5Tag); | 1171 || element.hasTagName(h5Tag); |
| 1172 } | 1172 } |
| 1173 | 1173 |
| 1174 bool isBlockFlowElement(const Node& node) | 1174 bool isBlockFlowElement(const Node& node) |
| 1175 { | 1175 { |
| 1176 LayoutObject* renderer = node.renderer(); | 1176 LayoutObject* renderer = node.layoutObject(); |
| 1177 return node.isElementNode() && renderer && renderer->isLayoutBlockFlow(); | 1177 return node.isElementNode() && renderer && renderer->isLayoutBlockFlow(); |
| 1178 } | 1178 } |
| 1179 | 1179 |
| 1180 Position adjustedSelectionStartForStyleComputation(const VisibleSelection& selec
tion) | 1180 Position adjustedSelectionStartForStyleComputation(const VisibleSelection& selec
tion) |
| 1181 { | 1181 { |
| 1182 // This function is used by range style computations to avoid bugs like: | 1182 // This function is used by range style computations to avoid bugs like: |
| 1183 // <rdar://problem/4017641> REGRESSION (Mail): you can only bold/unbold a se
lection starting from end of line once | 1183 // <rdar://problem/4017641> REGRESSION (Mail): you can only bold/unbold a se
lection starting from end of line once |
| 1184 // It is important to skip certain irrelevant content at the start of the se
lection, so we do not wind up | 1184 // It is important to skip certain irrelevant content at the start of the se
lection, so we do not wind up |
| 1185 // with a spurious "mixed" style. | 1185 // with a spurious "mixed" style. |
| 1186 | 1186 |
| 1187 VisiblePosition visiblePosition(selection.start()); | 1187 VisiblePosition visiblePosition(selection.start()); |
| 1188 if (visiblePosition.isNull()) | 1188 if (visiblePosition.isNull()) |
| 1189 return Position(); | 1189 return Position(); |
| 1190 | 1190 |
| 1191 // if the selection is a caret, just return the position, since the style | 1191 // if the selection is a caret, just return the position, since the style |
| 1192 // behind us is relevant | 1192 // behind us is relevant |
| 1193 if (selection.isCaret()) | 1193 if (selection.isCaret()) |
| 1194 return visiblePosition.deepEquivalent(); | 1194 return visiblePosition.deepEquivalent(); |
| 1195 | 1195 |
| 1196 // if the selection starts just before a paragraph break, skip over it | 1196 // if the selection starts just before a paragraph break, skip over it |
| 1197 if (isEndOfParagraph(visiblePosition)) | 1197 if (isEndOfParagraph(visiblePosition)) |
| 1198 return visiblePosition.next().deepEquivalent().downstream(); | 1198 return visiblePosition.next().deepEquivalent().downstream(); |
| 1199 | 1199 |
| 1200 // otherwise, make sure to be at the start of the first selected node, | 1200 // otherwise, make sure to be at the start of the first selected node, |
| 1201 // instead of possibly at the end of the last node before the selection | 1201 // instead of possibly at the end of the last node before the selection |
| 1202 return visiblePosition.deepEquivalent().downstream(); | 1202 return visiblePosition.deepEquivalent().downstream(); |
| 1203 } | 1203 } |
| 1204 | 1204 |
| 1205 } // namespace blink | 1205 } // namespace blink |
| OLD | NEW |