OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2009 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 |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 #include "Position.h" | 27 #include "Position.h" |
28 | 28 |
29 #include "CSSComputedStyleDeclaration.h" | 29 #include "CSSComputedStyleDeclaration.h" |
| 30 #include "ContextFeatures.h" |
30 #include "HTMLNames.h" | 31 #include "HTMLNames.h" |
31 #include "InlineTextBox.h" | 32 #include "InlineTextBox.h" |
32 #include "Logging.h" | 33 #include "Logging.h" |
33 #include "PositionIterator.h" | 34 #include "PositionIterator.h" |
34 #include "RenderBlock.h" | 35 #include "RenderBlock.h" |
35 #include "RenderText.h" | 36 #include "RenderText.h" |
36 #include "RuntimeEnabledFeatures.h" | |
37 #include "Text.h" | 37 #include "Text.h" |
38 #include "TextIterator.h" | 38 #include "TextIterator.h" |
39 #include "VisiblePosition.h" | 39 #include "VisiblePosition.h" |
40 #include "htmlediting.h" | 40 #include "htmlediting.h" |
41 #include "visible_units.h" | 41 #include "visible_units.h" |
42 #include <stdio.h> | 42 #include <stdio.h> |
43 #include <wtf/text/CString.h> | 43 #include <wtf/text/CString.h> |
44 #include <wtf/unicode/CharacterNames.h> | 44 #include <wtf/unicode/CharacterNames.h> |
45 | 45 |
46 namespace WebCore { | 46 namespace WebCore { |
(...skipping 28 matching lines...) Expand all Loading... |
75 return 0; | 75 return 0; |
76 } | 76 } |
77 | 77 |
78 Position::Position(PassRefPtr<Node> anchorNode, LegacyEditingOffset offset) | 78 Position::Position(PassRefPtr<Node> anchorNode, LegacyEditingOffset offset) |
79 : m_anchorNode(anchorNode) | 79 : m_anchorNode(anchorNode) |
80 , m_offset(offset.value()) | 80 , m_offset(offset.value()) |
81 , m_anchorType(anchorTypeForLegacyEditingPosition(m_anchorNode.get(), m_offs
et)) | 81 , m_anchorType(anchorTypeForLegacyEditingPosition(m_anchorNode.get(), m_offs
et)) |
82 , m_isLegacyEditingPosition(true) | 82 , m_isLegacyEditingPosition(true) |
83 { | 83 { |
84 #if ENABLE(SHADOW_DOM) | 84 #if ENABLE(SHADOW_DOM) |
85 ASSERT((m_anchorNode && RuntimeEnabledFeatures::shadowDOMEnabled()) | 85 ASSERT((m_anchorNode && ContextFeatures::shadowDOMEnabled(m_anchorNode->docu
ment())) |
86 || !m_anchorNode || !m_anchorNode->isShadowRoot()); | 86 || !m_anchorNode || !m_anchorNode->isShadowRoot()); |
87 #else | 87 #else |
88 ASSERT(!m_anchorNode || !m_anchorNode->isShadowRoot()); | 88 ASSERT(!m_anchorNode || !m_anchorNode->isShadowRoot()); |
89 #endif | 89 #endif |
90 } | 90 } |
91 | 91 |
92 Position::Position(PassRefPtr<Node> anchorNode, AnchorType anchorType) | 92 Position::Position(PassRefPtr<Node> anchorNode, AnchorType anchorType) |
93 : m_anchorNode(anchorNode) | 93 : m_anchorNode(anchorNode) |
94 , m_offset(0) | 94 , m_offset(0) |
95 , m_anchorType(anchorType) | 95 , m_anchorType(anchorType) |
96 , m_isLegacyEditingPosition(false) | 96 , m_isLegacyEditingPosition(false) |
97 { | 97 { |
98 #if ENABLE(SHADOW_DOM) | 98 #if ENABLE(SHADOW_DOM) |
99 ASSERT((m_anchorNode && RuntimeEnabledFeatures::shadowDOMEnabled()) | 99 ASSERT((m_anchorNode && ContextFeatures::shadowDOMEnabled(m_anchorNode->docu
ment())) |
100 || !m_anchorNode || !m_anchorNode->isShadowRoot()); | 100 || !m_anchorNode || !m_anchorNode->isShadowRoot()); |
101 #else | 101 #else |
102 ASSERT(!m_anchorNode || !m_anchorNode->isShadowRoot()); | 102 ASSERT(!m_anchorNode || !m_anchorNode->isShadowRoot()); |
103 #endif | 103 #endif |
104 | 104 |
105 ASSERT(anchorType != PositionIsOffsetInAnchor); | 105 ASSERT(anchorType != PositionIsOffsetInAnchor); |
106 ASSERT(!((anchorType == PositionIsBeforeChildren || anchorType == PositionIs
AfterChildren) | 106 ASSERT(!((anchorType == PositionIsBeforeChildren || anchorType == PositionIs
AfterChildren) |
107 && (m_anchorNode->isTextNode() || editingIgnoresContent(m_anchorNode.get
())))); | 107 && (m_anchorNode->isTextNode() || editingIgnoresContent(m_anchorNode.get
())))); |
108 } | 108 } |
109 | 109 |
110 Position::Position(PassRefPtr<Node> anchorNode, int offset, AnchorType anchorTyp
e) | 110 Position::Position(PassRefPtr<Node> anchorNode, int offset, AnchorType anchorTyp
e) |
111 : m_anchorNode(anchorNode) | 111 : m_anchorNode(anchorNode) |
112 , m_offset(offset) | 112 , m_offset(offset) |
113 , m_anchorType(anchorType) | 113 , m_anchorType(anchorType) |
114 , m_isLegacyEditingPosition(false) | 114 , m_isLegacyEditingPosition(false) |
115 { | 115 { |
116 #if ENABLE(SHADOW_DOM) | 116 #if ENABLE(SHADOW_DOM) |
117 ASSERT((m_anchorNode && RuntimeEnabledFeatures::shadowDOMEnabled()) | 117 ASSERT((m_anchorNode && ContextFeatures::shadowDOMEnabled(m_anchorNode->docu
ment())) |
118 || !m_anchorNode || !editingIgnoresContent(m_anchorNode.get()) || !m_
anchorNode->isShadowRoot()); | 118 || !m_anchorNode || !editingIgnoresContent(m_anchorNode.get()) || !m_
anchorNode->isShadowRoot()); |
119 #else | 119 #else |
120 ASSERT(!m_anchorNode || !editingIgnoresContent(m_anchorNode.get()) || !m_anc
horNode->isShadowRoot()); | 120 ASSERT(!m_anchorNode || !editingIgnoresContent(m_anchorNode.get()) || !m_anc
horNode->isShadowRoot()); |
121 #endif | 121 #endif |
122 | 122 |
123 ASSERT(anchorType == PositionIsOffsetInAnchor); | 123 ASSERT(anchorType == PositionIsOffsetInAnchor); |
124 } | 124 } |
125 | 125 |
126 Position::Position(PassRefPtr<Text> textNode, unsigned offset) | 126 Position::Position(PassRefPtr<Text> textNode, unsigned offset) |
127 : m_anchorNode(textNode) | 127 : m_anchorNode(textNode) |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 bool Position::nodeIsUserSelectNone(Node* node) | 851 bool Position::nodeIsUserSelectNone(Node* node) |
852 { | 852 { |
853 return node && node->renderer() && node->renderer()->style()->userSelect() =
= SELECT_NONE; | 853 return node && node->renderer() && node->renderer()->style()->userSelect() =
= SELECT_NONE; |
854 } | 854 } |
855 | 855 |
856 ContainerNode* Position::findParent(const Node* node) | 856 ContainerNode* Position::findParent(const Node* node) |
857 { | 857 { |
858 // FIXME: See http://web.ug/82697 | 858 // FIXME: See http://web.ug/82697 |
859 | 859 |
860 #if ENABLE(SHADOW_DOM) | 860 #if ENABLE(SHADOW_DOM) |
861 if (RuntimeEnabledFeatures::shadowDOMEnabled()) | 861 if (ContextFeatures::shadowDOMEnabled(node->document())) |
862 return node->parentNode(); | 862 return node->parentNode(); |
863 #endif | 863 #endif |
864 | 864 |
865 return node->nonShadowBoundaryParentNode(); | 865 return node->nonShadowBoundaryParentNode(); |
866 } | 866 } |
867 | 867 |
868 bool Position::isCandidate() const | 868 bool Position::isCandidate() const |
869 { | 869 { |
870 if (isNull()) | 870 if (isNull()) |
871 return false; | 871 return false; |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1376 pos.showTreeForThis(); | 1376 pos.showTreeForThis(); |
1377 } | 1377 } |
1378 | 1378 |
1379 void showTree(const WebCore::Position* pos) | 1379 void showTree(const WebCore::Position* pos) |
1380 { | 1380 { |
1381 if (pos) | 1381 if (pos) |
1382 pos->showTreeForThis(); | 1382 pos->showTreeForThis(); |
1383 } | 1383 } |
1384 | 1384 |
1385 #endif | 1385 #endif |
OLD | NEW |