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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 void FormatBlockCommand::formatSelection(const VisiblePosition& startOfSelection
, const VisiblePosition& endOfSelection) | 53 void FormatBlockCommand::formatSelection(const VisiblePosition& startOfSelection
, const VisiblePosition& endOfSelection) |
54 { | 54 { |
55 if (!isElementForFormatBlock(tagName())) | 55 if (!isElementForFormatBlock(tagName())) |
56 return; | 56 return; |
57 ApplyBlockElementCommand::formatSelection(startOfSelection, endOfSelection); | 57 ApplyBlockElementCommand::formatSelection(startOfSelection, endOfSelection); |
58 m_didApply = true; | 58 m_didApply = true; |
59 } | 59 } |
60 | 60 |
61 void FormatBlockCommand::formatRange(const Position& start, const Position& end,
const Position& endOfSelection, RefPtr<Element>& blockNode) | 61 void FormatBlockCommand::formatRange(const Position& start, const Position& end,
const Position& endOfSelection, RefPtr<Element>& blockNode) |
62 { | 62 { |
63 Node* nodeToSplitTo = enclosingBlockToSplitTreeTo(start.deprecatedNode()); | |
64 RefPtr<Node> outerBlock = (start.deprecatedNode() == nodeToSplitTo) ? start.
deprecatedNode() : splitTreeToNode(start.deprecatedNode(), nodeToSplitTo); | |
65 RefPtr<Node> nodeAfterInsertionPosition = outerBlock; | |
66 | |
67 RefPtr<Range> range = Range::create(document(), start, endOfSelection); | |
68 Element* refNode = enclosingBlockFlowElement(end); | 63 Element* refNode = enclosingBlockFlowElement(end); |
69 Element* root = editableRootForPosition(start); | 64 Element* root = editableRootForPosition(start); |
70 // Root is null for elements with contenteditable=false. | 65 // Root is null for elements with contenteditable=false. |
71 if (!root || !refNode) | 66 if (!root || !refNode) |
72 return; | 67 return; |
| 68 |
| 69 Node* nodeToSplitTo = enclosingBlockToSplitTreeTo(start.deprecatedNode()); |
| 70 RefPtr<Node> outerBlock = (start.deprecatedNode() == nodeToSplitTo) ? start.
deprecatedNode() : splitTreeToNode(start.deprecatedNode(), nodeToSplitTo); |
| 71 RefPtr<Node> nodeAfterInsertionPosition = outerBlock; |
| 72 RefPtr<Range> range = Range::create(document(), start, endOfSelection); |
| 73 |
73 if (isElementForFormatBlock(refNode->tagQName()) && start == startOfBlock(st
art) | 74 if (isElementForFormatBlock(refNode->tagQName()) && start == startOfBlock(st
art) |
74 && (end == endOfBlock(end) || isNodeVisiblyContainedWithin(refNode, rang
e.get())) | 75 && (end == endOfBlock(end) || isNodeVisiblyContainedWithin(refNode, rang
e.get())) |
75 && refNode != root && !root->isDescendantOf(refNode)) { | 76 && refNode != root && !root->isDescendantOf(refNode)) { |
76 // Already in a block element that only contains the current paragraph | 77 // Already in a block element that only contains the current paragraph |
77 if (refNode->hasTagName(tagName())) | 78 if (refNode->hasTagName(tagName())) |
78 return; | 79 return; |
79 nodeAfterInsertionPosition = refNode; | 80 nodeAfterInsertionPosition = refNode; |
80 } | 81 } |
81 | 82 |
82 if (!blockNode) { | 83 if (!blockNode) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 return n; | 155 return n; |
155 if (isBlock(n)) | 156 if (isBlock(n)) |
156 lastBlock = n; | 157 lastBlock = n; |
157 if (isListElement(n)) | 158 if (isListElement(n)) |
158 return n->parentNode()->rendererIsEditable() ? n->parentNode() : n; | 159 return n->parentNode()->rendererIsEditable() ? n->parentNode() : n; |
159 } | 160 } |
160 return lastBlock; | 161 return lastBlock; |
161 } | 162 } |
162 | 163 |
163 } | 164 } |
OLD | NEW |