Chromium Code Reviews| 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 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 830 bool isTabSpanTextNode(const Node* node) | 830 bool isTabSpanTextNode(const Node* node) |
| 831 { | 831 { |
| 832 return node && node->isTextNode() && node->parentNode() && isTabSpanNode(nod e->parentNode()); | 832 return node && node->isTextNode() && node->parentNode() && isTabSpanNode(nod e->parentNode()); |
| 833 } | 833 } |
| 834 | 834 |
| 835 Node* tabSpanNode(const Node* node) | 835 Node* tabSpanNode(const Node* node) |
| 836 { | 836 { |
| 837 return isTabSpanTextNode(node) ? node->parentNode() : 0; | 837 return isTabSpanTextNode(node) ? node->parentNode() : 0; |
| 838 } | 838 } |
| 839 | 839 |
| 840 PassRefPtrWillBeRawPtr<Element> createTabSpanElement(Document& document, PassRef Ptr<Node> prpTabTextNode) | 840 PassRefPtrWillBeRawPtr<Element> createTabSpanElement(Document& document, PassRef PtrWillBeRawPtr<Node> prpTabTextNode) |
| 841 { | 841 { |
| 842 RefPtr<Node> tabTextNode = prpTabTextNode; | 842 RefPtrWillBeRawPtr<Node> tabTextNode = prpTabTextNode; |
| 843 | 843 |
| 844 // Make the span to hold the tab. | 844 // Make the span to hold the tab. |
| 845 RefPtrWillBeRawPtr<Element> spanElement = document.createElement(spanTag, fa lse); | 845 RefPtrWillBeRawPtr<Element> spanElement = document.createElement(spanTag, fa lse); |
| 846 spanElement->setAttribute(classAttr, AppleTabSpanClass); | 846 spanElement->setAttribute(classAttr, AppleTabSpanClass); |
| 847 spanElement->setAttribute(styleAttr, "white-space:pre"); | 847 spanElement->setAttribute(styleAttr, "white-space:pre"); |
| 848 | 848 |
| 849 // Add tab text to that span. | 849 // Add tab text to that span. |
| 850 if (!tabTextNode) | 850 if (!tabTextNode) |
| 851 tabTextNode = document.createEditingTextNode("\t"); | 851 tabTextNode = document.createEditingTextNode("\t"); |
| 852 | 852 |
| 853 spanElement->appendChild(tabTextNode.release()); | 853 spanElement->appendChild(tabTextNode.release()); |
| 854 | 854 |
| 855 return spanElement.release(); | 855 return spanElement.release(); |
| 856 } | 856 } |
| 857 | 857 |
| 858 PassRefPtrWillBeRawPtr<Element> createTabSpanElement(Document& document, const S tring& tabText) | 858 PassRefPtrWillBeRawPtr<Element> createTabSpanElement(Document& document, const S tring& tabText) |
| 859 { | 859 { |
| 860 return createTabSpanElement(document, document.createTextNode(tabText)); | 860 return createTabSpanElement(document, document.createTextNode(tabText)); |
| 861 } | 861 } |
| 862 | 862 |
| 863 PassRefPtrWillBeRawPtr<Element> createTabSpanElement(Document& document) | 863 PassRefPtrWillBeRawPtr<Element> createTabSpanElement(Document& document) |
| 864 { | 864 { |
| 865 return createTabSpanElement(document, PassRefPtr<Node>()); | 865 return createTabSpanElement(document, PassRefPtrWillBeRawPtr<Node>(nullptr)) ; |
|
haraken
2014/05/25 18:08:46
Doesn't just 'nullptr' work?
sof
2014/05/25 18:11:23
That's ambiguous -- there's also createTabSpanElem
| |
| 866 } | 866 } |
| 867 | 867 |
| 868 bool isNodeRendered(const Node *node) | 868 bool isNodeRendered(const Node *node) |
| 869 { | 869 { |
| 870 if (!node) | 870 if (!node) |
| 871 return false; | 871 return false; |
| 872 | 872 |
| 873 RenderObject* renderer = node->renderer(); | 873 RenderObject* renderer = node->renderer(); |
| 874 if (!renderer) | 874 if (!renderer) |
| 875 return false; | 875 return false; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 994 | 994 |
| 995 return newSelection; | 995 return newSelection; |
| 996 } | 996 } |
| 997 | 997 |
| 998 // FIXME: indexForVisiblePosition and visiblePositionForIndex use TextIterators to convert between | 998 // FIXME: indexForVisiblePosition and visiblePositionForIndex use TextIterators to convert between |
| 999 // VisiblePositions and indices. But TextIterator iteration using TextIteratorEm itsCharactersBetweenAllVisiblePositions | 999 // VisiblePositions and indices. But TextIterator iteration using TextIteratorEm itsCharactersBetweenAllVisiblePositions |
| 1000 // does not exactly match VisiblePosition iteration, so using them to preserve a selection during an editing | 1000 // does not exactly match VisiblePosition iteration, so using them to preserve a selection during an editing |
| 1001 // opertion is unreliable. TextIterator's TextIteratorEmitsCharactersBetweenAllV isiblePositions mode needs to be fixed, | 1001 // opertion is unreliable. TextIterator's TextIteratorEmitsCharactersBetweenAllV isiblePositions mode needs to be fixed, |
| 1002 // or these functions need to be changed to iterate using actual VisiblePosition s. | 1002 // or these functions need to be changed to iterate using actual VisiblePosition s. |
| 1003 // FIXME: Deploy these functions everywhere that TextIterators are used to conve rt between VisiblePositions and indices. | 1003 // FIXME: Deploy these functions everywhere that TextIterators are used to conve rt between VisiblePositions and indices. |
| 1004 int indexForVisiblePosition(const VisiblePosition& visiblePosition, RefPtr<Conta inerNode>& scope) | 1004 int indexForVisiblePosition(const VisiblePosition& visiblePosition, RefPtrWillBe RawPtr<ContainerNode>& scope) |
| 1005 { | 1005 { |
| 1006 if (visiblePosition.isNull()) | 1006 if (visiblePosition.isNull()) |
| 1007 return 0; | 1007 return 0; |
| 1008 | 1008 |
| 1009 Position p(visiblePosition.deepEquivalent()); | 1009 Position p(visiblePosition.deepEquivalent()); |
| 1010 Document& document = *p.document(); | 1010 Document& document = *p.document(); |
| 1011 ShadowRoot* shadowRoot = p.anchorNode()->containingShadowRoot(); | 1011 ShadowRoot* shadowRoot = p.anchorNode()->containingShadowRoot(); |
| 1012 | 1012 |
| 1013 if (shadowRoot) | 1013 if (shadowRoot) |
| 1014 scope = shadowRoot; | 1014 scope = shadowRoot; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1113 // if the selection starts just before a paragraph break, skip over it | 1113 // if the selection starts just before a paragraph break, skip over it |
| 1114 if (isEndOfParagraph(visiblePosition)) | 1114 if (isEndOfParagraph(visiblePosition)) |
| 1115 return visiblePosition.next().deepEquivalent().downstream(); | 1115 return visiblePosition.next().deepEquivalent().downstream(); |
| 1116 | 1116 |
| 1117 // otherwise, make sure to be at the start of the first selected node, | 1117 // otherwise, make sure to be at the start of the first selected node, |
| 1118 // instead of possibly at the end of the last node before the selection | 1118 // instead of possibly at the end of the last node before the selection |
| 1119 return visiblePosition.deepEquivalent().downstream(); | 1119 return visiblePosition.deepEquivalent().downstream(); |
| 1120 } | 1120 } |
| 1121 | 1121 |
| 1122 } // namespace WebCore | 1122 } // namespace WebCore |
| OLD | NEW |