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

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

Issue 9567016: Merge 108009 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1025/
Patch Set: Created 8 years, 9 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
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // margin/padding, but not others. We should make the gap painting more con sistent and 73 // margin/padding, but not others. We should make the gap painting more con sistent and
74 // then use a left margin/padding rule here. 74 // then use a left margin/padding rule here.
75 if (visibleEnd != visibleStart && isStartOfParagraph(visibleEnd)) 75 if (visibleEnd != visibleStart && isStartOfParagraph(visibleEnd))
76 setEndingSelection(VisibleSelection(visibleStart, visibleEnd.previous(Ca nnotCrossEditingBoundary), endingSelection().isDirectional())); 76 setEndingSelection(VisibleSelection(visibleStart, visibleEnd.previous(Ca nnotCrossEditingBoundary), endingSelection().isDirectional()));
77 77
78 VisibleSelection selection = selectionForParagraphIteration(endingSelection( )); 78 VisibleSelection selection = selectionForParagraphIteration(endingSelection( ));
79 VisiblePosition startOfSelection = selection.visibleStart(); 79 VisiblePosition startOfSelection = selection.visibleStart();
80 VisiblePosition endOfSelection = selection.visibleEnd(); 80 VisiblePosition endOfSelection = selection.visibleEnd();
81 ASSERT(!startOfSelection.isNull()); 81 ASSERT(!startOfSelection.isNull());
82 ASSERT(!endOfSelection.isNull()); 82 ASSERT(!endOfSelection.isNull());
83 Element* startScope = 0; 83 RefPtr<Element> startScope;
84 int startIndex = indexForVisiblePosition(startOfSelection, &startScope); 84 int startIndex = indexForVisiblePosition(startOfSelection, startScope);
85 Element* endScope = 0; 85 RefPtr<Element> endScope;
86 int endIndex = indexForVisiblePosition(endOfSelection, &endScope); 86 int endIndex = indexForVisiblePosition(endOfSelection, endScope);
87 87
88 formatSelection(startOfSelection, endOfSelection); 88 formatSelection(startOfSelection, endOfSelection);
89 89
90 document()->updateLayoutIgnorePendingStylesheets(); 90 document()->updateLayoutIgnorePendingStylesheets();
91 91
92 ASSERT(startScope == endScope); 92 ASSERT(startScope == endScope);
93 ASSERT(startIndex >= 0); 93 ASSERT(startIndex >= 0);
94 ASSERT(startIndex <= endIndex); 94 ASSERT(startIndex <= endIndex);
95 if (startScope == endScope && startIndex >= 0 && startIndex <= endIndex) { 95 if (startScope == endScope && startIndex >= 0 && startIndex <= endIndex) {
96 VisiblePosition start(visiblePositionForIndex(startIndex, startScope)); 96 VisiblePosition start(visiblePositionForIndex(startIndex, startScope.get ()));
97 VisiblePosition end(visiblePositionForIndex(endIndex, endScope)); 97 VisiblePosition end(visiblePositionForIndex(endIndex, endScope.get()));
98 if (start.isNotNull() && end.isNotNull()) 98 if (start.isNotNull() && end.isNotNull())
99 setEndingSelection(VisibleSelection(start, end, endingSelection().is Directional())); 99 setEndingSelection(VisibleSelection(start, end, endingSelection().is Directional()));
100 } 100 }
101 } 101 }
102 102
103 void ApplyBlockElementCommand::formatSelection(const VisiblePosition& startOfSel ection, const VisiblePosition& endOfSelection) 103 void ApplyBlockElementCommand::formatSelection(const VisiblePosition& startOfSel ection, const VisiblePosition& endOfSelection)
104 { 104 {
105 // Special case empty unsplittable elements because there's nothing to split 105 // Special case empty unsplittable elements because there's nothing to split
106 // and there's nothing to move. 106 // and there's nothing to move.
107 Position start = startOfSelection.deepEquivalent().downstream(); 107 Position start = startOfSelection.deepEquivalent().downstream();
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 278
279 PassRefPtr<Element> ApplyBlockElementCommand::createBlockElement() const 279 PassRefPtr<Element> ApplyBlockElementCommand::createBlockElement() const
280 { 280 {
281 RefPtr<Element> element = createHTMLElement(document(), m_tagName); 281 RefPtr<Element> element = createHTMLElement(document(), m_tagName);
282 if (m_inlineStyle.length()) 282 if (m_inlineStyle.length())
283 element->setAttribute(styleAttr, m_inlineStyle); 283 element->setAttribute(styleAttr, m_inlineStyle);
284 return element.release(); 284 return element.release();
285 } 285 }
286 286
287 } 287 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698