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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 // Use this function instead of create a regular range object (avoiding editing
offset). | 552 // Use this function instead of create a regular range object (avoiding editing
offset). |
553 PassRefPtrWillBeRawPtr<Range> createRange(Document& document, const VisiblePosit
ion& start, const VisiblePosition& end, ExceptionState& exceptionState) | 553 PassRefPtrWillBeRawPtr<Range> createRange(Document& document, const VisiblePosit
ion& start, const VisiblePosition& end, ExceptionState& exceptionState) |
554 { | 554 { |
555 RefPtrWillBeRawPtr<Range> selectedRange = Range::create(document); | 555 RefPtrWillBeRawPtr<Range> selectedRange = Range::create(document); |
556 selectedRange->setStart(start.deepEquivalent().containerNode(), start.deepEq
uivalent().computeOffsetInContainerNode(), exceptionState); | 556 selectedRange->setStart(start.deepEquivalent().containerNode(), start.deepEq
uivalent().computeOffsetInContainerNode(), exceptionState); |
557 if (!exceptionState.hadException()) | 557 if (!exceptionState.hadException()) |
558 selectedRange->setEnd(end.deepEquivalent().containerNode(), end.deepEqui
valent().computeOffsetInContainerNode(), exceptionState); | 558 selectedRange->setEnd(end.deepEquivalent().containerNode(), end.deepEqui
valent().computeOffsetInContainerNode(), exceptionState); |
559 return selectedRange.release(); | 559 return selectedRange.release(); |
560 } | 560 } |
561 | 561 |
562 bool isListElement(Node* n) | 562 bool isHTMLListElement(Node* n) |
563 { | 563 { |
564 return (n && (isHTMLUListElement(*n) || isHTMLOListElement(*n) || isHTMLDLis
tElement(*n))); | 564 return (n && (isHTMLUListElement(*n) || isHTMLOListElement(*n) || isHTMLDLis
tElement(*n))); |
565 } | 565 } |
566 | 566 |
567 bool isListItem(const Node* n) | 567 bool isListItem(const Node* n) |
568 { | 568 { |
569 return n && n->renderer() && n->renderer()->isListItem(); | 569 return n && n->renderer() && n->renderer()->isListItem(); |
570 } | 570 } |
571 | 571 |
572 Element* enclosingElementWithTag(const Position& p, const QualifiedName& tagName
) | 572 Element* enclosingElementWithTag(const Position& p, const QualifiedName& tagName
) |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 Node* enclosingListChild(Node *node) | 690 Node* enclosingListChild(Node *node) |
691 { | 691 { |
692 if (!node) | 692 if (!node) |
693 return 0; | 693 return 0; |
694 // Check for a list item element, or for a node whose parent is a list eleme
nt. Such a node | 694 // Check for a list item element, or for a node whose parent is a list eleme
nt. Such a node |
695 // will appear visually as a list item (but without a list marker) | 695 // will appear visually as a list item (but without a list marker) |
696 ContainerNode* root = highestEditableRoot(firstPositionInOrBeforeNode(node))
; | 696 ContainerNode* root = highestEditableRoot(firstPositionInOrBeforeNode(node))
; |
697 | 697 |
698 // FIXME: This function is inappropriately named if it starts with node inst
ead of node->parentNode() | 698 // FIXME: This function is inappropriately named if it starts with node inst
ead of node->parentNode() |
699 for (Node* n = node; n && n->parentNode(); n = n->parentNode()) { | 699 for (Node* n = node; n && n->parentNode(); n = n->parentNode()) { |
700 if (isHTMLLIElement(*n) || (isListElement(n->parentNode()) && n != root)
) | 700 if (isHTMLLIElement(*n) || (isHTMLListElement(n->parentNode()) && n != r
oot)) |
701 return n; | 701 return n; |
702 if (n == root || isTableCell(n)) | 702 if (n == root || isTableCell(n)) |
703 return 0; | 703 return 0; |
704 } | 704 } |
705 | 705 |
706 return 0; | 706 return 0; |
707 } | 707 } |
708 | 708 |
709 // FIXME: This method should not need to call isStartOfParagraph/isEndOfParagrap
h | 709 // FIXME: This method should not need to call isStartOfParagraph/isEndOfParagrap
h |
710 Node* enclosingEmptyListItem(const VisiblePosition& visiblePos) | 710 Node* enclosingEmptyListItem(const VisiblePosition& visiblePos) |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 PassRefPtrWillBeRawPtr<HTMLElement> createHTMLElement(Document& document, const
QualifiedName& name) | 840 PassRefPtrWillBeRawPtr<HTMLElement> createHTMLElement(Document& document, const
QualifiedName& name) |
841 { | 841 { |
842 return createHTMLElement(document, name.localName()); | 842 return createHTMLElement(document, name.localName()); |
843 } | 843 } |
844 | 844 |
845 PassRefPtrWillBeRawPtr<HTMLElement> createHTMLElement(Document& document, const
AtomicString& tagName) | 845 PassRefPtrWillBeRawPtr<HTMLElement> createHTMLElement(Document& document, const
AtomicString& tagName) |
846 { | 846 { |
847 return HTMLElementFactory::createHTMLElement(tagName, document, 0, false); | 847 return HTMLElementFactory::createHTMLElement(tagName, document, 0, false); |
848 } | 848 } |
849 | 849 |
850 bool isTabSpanElement(const Node* node) | 850 bool isTabHTMLSpanElement(const Node* node) |
851 { | 851 { |
852 if (!isHTMLSpanElement(node) || toHTMLSpanElement(node)->getAttribute(classA
ttr) != AppleTabSpanClass) | 852 if (!isHTMLSpanElement(node) || toHTMLSpanElement(node)->getAttribute(classA
ttr) != AppleTabSpanClass) |
853 return false; | 853 return false; |
854 UseCounter::count(node->document(), UseCounter::EditingAppleTabSpanClass); | 854 UseCounter::count(node->document(), UseCounter::EditingAppleTabSpanClass); |
855 return true; | 855 return true; |
856 } | 856 } |
857 | 857 |
858 bool isTabSpanTextNode(const Node* node) | 858 bool isTabHTMLSpanElementTextNode(const Node* node) |
859 { | 859 { |
860 return node && node->isTextNode() && node->parentNode() && isTabSpanElement(
node->parentNode()); | 860 return node && node->isTextNode() && node->parentNode() && isTabHTMLSpanElem
ent(node->parentNode()); |
861 } | 861 } |
862 | 862 |
863 HTMLSpanElement* tabSpanElement(const Node* node) | 863 HTMLSpanElement* tabSpanElement(const Node* node) |
864 { | 864 { |
865 return isTabSpanTextNode(node) ? toHTMLSpanElement(node->parentNode()) : 0; | 865 return isTabHTMLSpanElementTextNode(node) ? toHTMLSpanElement(node->parentNo
de()) : 0; |
866 } | 866 } |
867 | 867 |
868 PassRefPtrWillBeRawPtr<HTMLSpanElement> createTabSpanElement(Document& document,
PassRefPtrWillBeRawPtr<Text> prpTabTextNode) | 868 PassRefPtrWillBeRawPtr<HTMLSpanElement> createTabSpanElement(Document& document,
PassRefPtrWillBeRawPtr<Text> prpTabTextNode) |
869 { | 869 { |
870 RefPtrWillBeRawPtr<Text> tabTextNode = prpTabTextNode; | 870 RefPtrWillBeRawPtr<Text> tabTextNode = prpTabTextNode; |
871 | 871 |
872 // Make the span to hold the tab. | 872 // Make the span to hold the tab. |
873 RefPtrWillBeRawPtr<HTMLSpanElement> spanElement = toHTMLSpanElement(document
.createElement(spanTag, false).get()); | 873 RefPtrWillBeRawPtr<HTMLSpanElement> spanElement = toHTMLSpanElement(document
.createElement(spanTag, false).get()); |
874 spanElement->setAttribute(classAttr, AppleTabSpanClass); | 874 spanElement->setAttribute(classAttr, AppleTabSpanClass); |
875 spanElement->setAttribute(styleAttr, "white-space:pre"); | 875 spanElement->setAttribute(styleAttr, "white-space:pre"); |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1218 // if the selection starts just before a paragraph break, skip over it | 1218 // if the selection starts just before a paragraph break, skip over it |
1219 if (isEndOfParagraph(visiblePosition)) | 1219 if (isEndOfParagraph(visiblePosition)) |
1220 return visiblePosition.next().deepEquivalent().downstream(); | 1220 return visiblePosition.next().deepEquivalent().downstream(); |
1221 | 1221 |
1222 // otherwise, make sure to be at the start of the first selected node, | 1222 // 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 | 1223 // instead of possibly at the end of the last node before the selection |
1224 return visiblePosition.deepEquivalent().downstream(); | 1224 return visiblePosition.deepEquivalent().downstream(); |
1225 } | 1225 } |
1226 | 1226 |
1227 } // namespace blink | 1227 } // namespace blink |
OLD | NEW |