| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2006 Apple Computer, 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 if (!commonAncestor) | 108 if (!commonAncestor) |
| 109 return 0; | 109 return 0; |
| 110 | 110 |
| 111 Element* rootEditableElement = range->startContainer()->rootEditableElement(
); | 111 Element* rootEditableElement = range->startContainer()->rootEditableElement(
); |
| 112 if (!rootEditableElement || commonAncestor->contains(rootEditableElement)) | 112 if (!rootEditableElement || commonAncestor->contains(rootEditableElement)) |
| 113 return 0; | 113 return 0; |
| 114 | 114 |
| 115 return commonAncestor->isElementNode() ? toElement(commonAncestor) : 0; | 115 return commonAncestor->isElementNode() ? toElement(commonAncestor) : 0; |
| 116 } | 116 } |
| 117 | 117 |
| 118 // FIXME: This function doesn't work properly for XHTML documents that use a non
-standard prefix. |
| 118 bool isElementForFormatBlock(const QualifiedName& tagName) | 119 bool isElementForFormatBlock(const QualifiedName& tagName) |
| 119 { | 120 { |
| 120 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, blockTags, ()); | 121 DEFINE_STATIC_LOCAL(QualifiedNameLiteralSet, blockTags, ()); |
| 121 if (blockTags.isEmpty()) { | 122 if (!blockTags.isInitialized()) { |
| 122 blockTags.add(addressTag); | 123 static const QualifiedName* blockTagData[] = { |
| 123 blockTags.add(articleTag); | 124 &addressTag, |
| 124 blockTags.add(asideTag); | 125 &articleTag, |
| 125 blockTags.add(blockquoteTag); | 126 &asideTag, |
| 126 blockTags.add(ddTag); | 127 &blockquoteTag, |
| 127 blockTags.add(divTag); | 128 &ddTag, |
| 128 blockTags.add(dlTag); | 129 &divTag, |
| 129 blockTags.add(dtTag); | 130 &dlTag, |
| 130 blockTags.add(footerTag); | 131 &dtTag, |
| 131 blockTags.add(h1Tag); | 132 &footerTag, |
| 132 blockTags.add(h2Tag); | 133 &h1Tag, |
| 133 blockTags.add(h3Tag); | 134 &h2Tag, |
| 134 blockTags.add(h4Tag); | 135 &h3Tag, |
| 135 blockTags.add(h5Tag); | 136 &h4Tag, |
| 136 blockTags.add(h6Tag); | 137 &h5Tag, |
| 137 blockTags.add(headerTag); | 138 &h6Tag, |
| 138 blockTags.add(hgroupTag); | 139 &headerTag, |
| 139 blockTags.add(mainTag); | 140 &hgroupTag, |
| 140 blockTags.add(navTag); | 141 &mainTag, |
| 141 blockTags.add(pTag); | 142 &navTag, |
| 142 blockTags.add(preTag); | 143 &pTag, |
| 143 blockTags.add(sectionTag); | 144 &preTag, |
| 145 §ionTag, |
| 146 }; |
| 147 blockTags.init(blockTagData, WTF_ARRAY_LENGTH(blockTagData)); |
| 144 } | 148 } |
| 145 return blockTags.contains(tagName); | 149 return blockTags.contains(&tagName); |
| 146 } | 150 } |
| 147 | 151 |
| 148 Node* enclosingBlockToSplitTreeTo(Node* startNode) | 152 Node* enclosingBlockToSplitTreeTo(Node* startNode) |
| 149 { | 153 { |
| 150 Node* lastBlock = startNode; | 154 Node* lastBlock = startNode; |
| 151 for (Node* n = startNode; n; n = n->parentNode()) { | 155 for (Node* n = startNode; n; n = n->parentNode()) { |
| 152 if (!n->rendererIsEditable()) | 156 if (!n->rendererIsEditable()) |
| 153 return lastBlock; | 157 return lastBlock; |
| 154 if (isTableCell(n) || n->hasTagName(bodyTag) || !n->parentNode() || !n->
parentNode()->rendererIsEditable() || isElementForFormatBlock(n)) | 158 if (isTableCell(n) || n->hasTagName(bodyTag) || !n->parentNode() || !n->
parentNode()->rendererIsEditable() || isElementForFormatBlock(n)) |
| 155 return n; | 159 return n; |
| 156 if (isBlock(n)) | 160 if (isBlock(n)) |
| 157 lastBlock = n; | 161 lastBlock = n; |
| 158 if (isListElement(n)) | 162 if (isListElement(n)) |
| 159 return n->parentNode()->rendererIsEditable() ? n->parentNode() : n; | 163 return n->parentNode()->rendererIsEditable() ? n->parentNode() : n; |
| 160 } | 164 } |
| 161 return lastBlock; | 165 return lastBlock; |
| 162 } | 166 } |
| 163 | 167 |
| 164 } | 168 } |
| OLD | NEW |