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

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

Issue 424493003: Use tighter typing in editing: CompositeEditCommand (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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
« no previous file with comments | « no previous file | Source/core/editing/ApplyStyleCommand.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 16 matching lines...) Expand all
27 #include "config.h" 27 #include "config.h"
28 #include "core/editing/ApplyBlockElementCommand.h" 28 #include "core/editing/ApplyBlockElementCommand.h"
29 29
30 #include "bindings/core/v8/ExceptionState.h" 30 #include "bindings/core/v8/ExceptionState.h"
31 #include "core/HTMLNames.h" 31 #include "core/HTMLNames.h"
32 #include "core/dom/NodeRenderStyle.h" 32 #include "core/dom/NodeRenderStyle.h"
33 #include "core/dom/Text.h" 33 #include "core/dom/Text.h"
34 #include "core/editing/VisiblePosition.h" 34 #include "core/editing/VisiblePosition.h"
35 #include "core/editing/VisibleUnits.h" 35 #include "core/editing/VisibleUnits.h"
36 #include "core/editing/htmlediting.h" 36 #include "core/editing/htmlediting.h"
37 #include "core/html/HTMLBRElement.h"
37 #include "core/html/HTMLElement.h" 38 #include "core/html/HTMLElement.h"
38 #include "core/rendering/RenderObject.h" 39 #include "core/rendering/RenderObject.h"
39 #include "core/rendering/style/RenderStyle.h" 40 #include "core/rendering/style/RenderStyle.h"
40 41
41 namespace blink { 42 namespace blink {
42 43
43 using namespace HTMLNames; 44 using namespace HTMLNames;
44 45
45 ApplyBlockElementCommand::ApplyBlockElementCommand(Document& document, const Qua lifiedName& tagName, const AtomicString& inlineStyle) 46 ApplyBlockElementCommand::ApplyBlockElementCommand(Document& document, const Qua lifiedName& tagName, const AtomicString& inlineStyle)
46 : CompositeEditCommand(document) 47 : CompositeEditCommand(document)
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 107 }
107 108
108 void ApplyBlockElementCommand::formatSelection(const VisiblePosition& startOfSel ection, const VisiblePosition& endOfSelection) 109 void ApplyBlockElementCommand::formatSelection(const VisiblePosition& startOfSel ection, const VisiblePosition& endOfSelection)
109 { 110 {
110 // Special case empty unsplittable elements because there's nothing to split 111 // Special case empty unsplittable elements because there's nothing to split
111 // and there's nothing to move. 112 // and there's nothing to move.
112 Position start = startOfSelection.deepEquivalent().downstream(); 113 Position start = startOfSelection.deepEquivalent().downstream();
113 if (isAtUnsplittableElement(start)) { 114 if (isAtUnsplittableElement(start)) {
114 RefPtrWillBeRawPtr<HTMLElement> blockquote = createBlockElement(); 115 RefPtrWillBeRawPtr<HTMLElement> blockquote = createBlockElement();
115 insertNodeAt(blockquote, start); 116 insertNodeAt(blockquote, start);
116 RefPtrWillBeRawPtr<Element> placeholder = createBreakElement(document()) ; 117 RefPtrWillBeRawPtr<HTMLBRElement> placeholder = createBreakElement(docum ent());
117 appendNode(placeholder, blockquote); 118 appendNode(placeholder, blockquote);
118 setEndingSelection(VisibleSelection(positionBeforeNode(placeholder.get() ), DOWNSTREAM, endingSelection().isDirectional())); 119 setEndingSelection(VisibleSelection(positionBeforeNode(placeholder.get() ), DOWNSTREAM, endingSelection().isDirectional()));
119 return; 120 return;
120 } 121 }
121 122
122 RefPtrWillBeRawPtr<HTMLElement> blockquoteForNextIndent = nullptr; 123 RefPtrWillBeRawPtr<HTMLElement> blockquoteForNextIndent = nullptr;
123 VisiblePosition endOfCurrentParagraph = endOfParagraph(startOfSelection); 124 VisiblePosition endOfCurrentParagraph = endOfParagraph(startOfSelection);
124 VisiblePosition endOfLastParagraph = endOfParagraph(endOfSelection); 125 VisiblePosition endOfLastParagraph = endOfParagraph(endOfSelection);
125 VisiblePosition endAfterSelection = endOfParagraph(endOfLastParagraph.next() ); 126 VisiblePosition endAfterSelection = endOfParagraph(endOfLastParagraph.next() );
126 m_endOfLastParagraph = endOfLastParagraph.deepEquivalent(); 127 m_endOfLastParagraph = endOfLastParagraph.deepEquivalent();
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 return element.release(); 289 return element.release();
289 } 290 }
290 291
291 void ApplyBlockElementCommand::trace(Visitor* visitor) 292 void ApplyBlockElementCommand::trace(Visitor* visitor)
292 { 293 {
293 visitor->trace(m_endOfLastParagraph); 294 visitor->trace(m_endOfLastParagraph);
294 CompositeEditCommand::trace(visitor); 295 CompositeEditCommand::trace(visitor);
295 } 296 }
296 297
297 } 298 }
OLDNEW
« no previous file with comments | « no previous file | Source/core/editing/ApplyStyleCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698