| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 Handle<Node> outerBlock = (start.deprecatedNode() == nodeToSplitTo) ? start.
deprecatedNode() : splitTreeToNode(start.deprecatedNode(), nodeToSplitTo); | 65 Handle<Node> outerBlock = (start.deprecatedNode() == nodeToSplitTo) ? start.
deprecatedNode() : splitTreeToNode(start.deprecatedNode(), nodeToSplitTo); |
| 66 Handle<Node> nodeAfterInsertionPosition = outerBlock; | 66 Handle<Node> nodeAfterInsertionPosition = outerBlock; |
| 67 | 67 |
| 68 Handle<Range> range = Range::create(document(), start, endOfSelection); | 68 Handle<Range> range = Range::create(document(), start, endOfSelection); |
| 69 Handle<Element> refNode = enclosingBlockFlowElement(end); | 69 Handle<Element> refNode = enclosingBlockFlowElement(end); |
| 70 Handle<Element> root = editableRootForPosition(start); | 70 Handle<Element> root = editableRootForPosition(start); |
| 71 // Root is null for elements with contenteditable=false. | 71 // Root is null for elements with contenteditable=false. |
| 72 if (!root || !refNode) | 72 if (!root || !refNode) |
| 73 return; | 73 return; |
| 74 if (isElementForFormatBlock(refNode->tagQName()) && start == startOfBlock(st
art) | 74 if (isElementForFormatBlock(refNode->tagQName()) && start == startOfBlock(st
art) |
| 75 && (end == endOfBlock(end) || isNodeVisiblyContainedWithin(refNode.raw()
, range)) | 75 && (end == endOfBlock(end) || isNodeVisiblyContainedWithin(refNode, rang
e)) |
| 76 && refNode != root && !root->isDescendantOf(refNode.raw())) { | 76 && refNode != root && !root->isDescendantOf(refNode.raw())) { |
| 77 // Already in a block element that only contains the current paragraph | 77 // Already in a block element that only contains the current paragraph |
| 78 if (refNode->hasTagName(tagName())) | 78 if (refNode->hasTagName(tagName())) |
| 79 return; | 79 return; |
| 80 nodeAfterInsertionPosition = refNode; | 80 nodeAfterInsertionPosition = refNode; |
| 81 } | 81 } |
| 82 | 82 |
| 83 if (!blockNode) { | 83 if (!blockNode) { |
| 84 // Create a new blockquote and insert it as a child of the root editable
element. We accomplish | 84 // Create a new blockquote and insert it as a child of the root editable
element. We accomplish |
| 85 // this by splitting all parents of the current paragraph up to that poi
nt. | 85 // this by splitting all parents of the current paragraph up to that poi
nt. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 return blockTags.contains(tagName); | 147 return blockTags.contains(tagName); |
| 148 } | 148 } |
| 149 | 149 |
| 150 Result<Node> enclosingBlockToSplitTreeTo(const Handle<Node>& startNode) | 150 Result<Node> enclosingBlockToSplitTreeTo(const Handle<Node>& startNode) |
| 151 { | 151 { |
| 152 Handle<Node> lastBlock = startNode; | 152 Handle<Node> lastBlock = startNode; |
| 153 for (Handle<Node> n = startNode; n; n = n->parentNode()) { | 153 for (Handle<Node> n = startNode; n; n = n->parentNode()) { |
| 154 HandleScope scope; | 154 HandleScope scope; |
| 155 if (!n->rendererIsEditable()) | 155 if (!n->rendererIsEditable()) |
| 156 return lastBlock; | 156 return lastBlock; |
| 157 if (isTableCell(n.raw()) || n->hasTagName(bodyTag) || !n->parentNode() |
| !n->parentNode()->rendererIsEditable() || isElementForFormatBlock(n.raw())) | 157 if (isTableCell(n) || n->hasTagName(bodyTag) || !n->parentNode() || !n->
parentNode()->rendererIsEditable() || isElementForFormatBlock(n.raw())) |
| 158 return n; | 158 return n; |
| 159 if (isBlock(n.raw())) | 159 if (isBlock(n)) |
| 160 lastBlock = n; | 160 lastBlock = n; |
| 161 if (isListElement(n.raw())) { | 161 if (isListElement(n)) { |
| 162 if (n->parentNode()->rendererIsEditable()) | 162 if (n->parentNode()->rendererIsEditable()) |
| 163 return n->parentNode(); | 163 return n->parentNode(); |
| 164 else | 164 else |
| 165 return n; | 165 return n; |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 return lastBlock; | 168 return lastBlock; |
| 169 } | 169 } |
| 170 | 170 |
| 171 } | 171 } |
| OLD | NEW |