Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: Source/core/editing/FormatBlockCommand.cpp

Issue 23467007: Have Range constructor take a Document reference in argument (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
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()); 63 Node* nodeToSplitTo = enclosingBlockToSplitTreeTo(start.deprecatedNode());
64 RefPtr<Node> outerBlock = (start.deprecatedNode() == nodeToSplitTo) ? start. deprecatedNode() : splitTreeToNode(start.deprecatedNode(), nodeToSplitTo); 64 RefPtr<Node> outerBlock = (start.deprecatedNode() == nodeToSplitTo) ? start. deprecatedNode() : splitTreeToNode(start.deprecatedNode(), nodeToSplitTo);
65 RefPtr<Node> nodeAfterInsertionPosition = outerBlock; 65 RefPtr<Node> nodeAfterInsertionPosition = outerBlock;
66 66
67 RefPtr<Range> range = Range::create(&document(), start, endOfSelection); 67 RefPtr<Range> range = Range::create(document(), start, endOfSelection);
68 Element* refNode = enclosingBlockFlowElement(end); 68 Element* refNode = enclosingBlockFlowElement(end);
69 Element* root = editableRootForPosition(start); 69 Element* root = editableRootForPosition(start);
70 // Root is null for elements with contenteditable=false. 70 // Root is null for elements with contenteditable=false.
71 if (!root || !refNode) 71 if (!root || !refNode)
72 return; 72 return;
73 if (isElementForFormatBlock(refNode->tagQName()) && start == startOfBlock(st art) 73 if (isElementForFormatBlock(refNode->tagQName()) && start == startOfBlock(st art)
74 && (end == endOfBlock(end) || isNodeVisiblyContainedWithin(refNode, rang e.get())) 74 && (end == endOfBlock(end) || isNodeVisiblyContainedWithin(refNode, rang e.get()))
75 && refNode != root && !root->isDescendantOf(refNode)) { 75 && refNode != root && !root->isDescendantOf(refNode)) {
76 // Already in a block element that only contains the current paragraph 76 // Already in a block element that only contains the current paragraph
77 if (refNode->hasTagName(tagName())) 77 if (refNode->hasTagName(tagName()))
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 return n; 154 return n;
155 if (isBlock(n)) 155 if (isBlock(n))
156 lastBlock = n; 156 lastBlock = n;
157 if (isListElement(n)) 157 if (isListElement(n))
158 return n->parentNode()->rendererIsEditable() ? n->parentNode() : n; 158 return n->parentNode()->rendererIsEditable() ? n->parentNode() : n;
159 } 159 }
160 return lastBlock; 160 return lastBlock;
161 } 161 }
162 162
163 } 163 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698