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

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

Issue 224113002: Oilpan: move Range object to the oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: heap/Handle.h => platform/heap/Handle.h Created 6 years, 8 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, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2009 Igalia S.L. 4 * Copyright (C) 2009 Igalia S.L.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 fragment->appendChild(content, exceptionState); 206 fragment->appendChild(content, exceptionState);
207 if (exceptionState.hadException()) 207 if (exceptionState.hadException())
208 return false; 208 return false;
209 return executeInsertFragment(frame, fragment.release()); 209 return executeInsertFragment(frame, fragment.release());
210 } 210 }
211 211
212 static bool expandSelectionToGranularity(LocalFrame& frame, TextGranularity gran ularity) 212 static bool expandSelectionToGranularity(LocalFrame& frame, TextGranularity gran ularity)
213 { 213 {
214 VisibleSelection selection = frame.selection().selection(); 214 VisibleSelection selection = frame.selection().selection();
215 selection.expandUsingGranularity(granularity); 215 selection.expandUsingGranularity(granularity);
216 RefPtr<Range> newRange = selection.toNormalizedRange(); 216 RefPtrWillBeRawPtr<Range> newRange = selection.toNormalizedRange();
217 if (!newRange) 217 if (!newRange)
218 return false; 218 return false;
219 if (newRange->collapsed(IGNORE_EXCEPTION)) 219 if (newRange->collapsed(IGNORE_EXCEPTION))
220 return false; 220 return false;
221 RefPtr<Range> oldRange = frame.selection().selection().toNormalizedRange(); 221 RefPtrWillBeRawPtr<Range> ALLOW_UNUSED oldRange = frame.selection().selectio n().toNormalizedRange();
Yuta Kitamura 2014/04/04 02:37:25 This line can be removed, as well.
sof 2014/04/04 07:33:23 Done.
222 EAffinity affinity = frame.selection().affinity(); 222 EAffinity affinity = frame.selection().affinity();
223 frame.selection().setSelectedRange(newRange.get(), affinity, FrameSelection: :CloseTyping); 223 frame.selection().setSelectedRange(newRange.get(), affinity, FrameSelection: :CloseTyping);
224 return true; 224 return true;
225 } 225 }
226 226
227 static TriState stateStyle(LocalFrame& frame, CSSPropertyID propertyID, const ch ar* desiredValue) 227 static TriState stateStyle(LocalFrame& frame, CSSPropertyID propertyID, const ch ar* desiredValue)
228 { 228 {
229 if (frame.editor().behavior().shouldToggleStyleBasedOnStartOfSelection()) 229 if (frame.editor().behavior().shouldToggleStyleBasedOnStartOfSelection())
230 return frame.editor().selectionStartHasStyle(propertyID, desiredValue) ? TrueTriState : FalseTriState; 230 return frame.editor().selectionStartHasStyle(propertyID, desiredValue) ? TrueTriState : FalseTriState;
231 return frame.editor().selectionHasStyle(propertyID, desiredValue); 231 return frame.editor().selectionHasStyle(propertyID, desiredValue);
(...skipping 25 matching lines...) Expand all
257 return 0; 257 return 0;
258 RenderStyle* style = renderer->style(); 258 RenderStyle* style = renderer->style();
259 if (!style) 259 if (!style)
260 return 0; 260 return 0;
261 if (!(style->overflowY() == OSCROLL || style->overflowY() == OAUTO || focuse dElement->rendererIsEditable())) 261 if (!(style->overflowY() == OSCROLL || style->overflowY() == OAUTO || focuse dElement->rendererIsEditable()))
262 return 0; 262 return 0;
263 int height = std::min<int>(toRenderBox(renderer)->clientHeight(), frame.view ()->visibleHeight()); 263 int height = std::min<int>(toRenderBox(renderer)->clientHeight(), frame.view ()->visibleHeight());
264 return static_cast<unsigned>(max(max<int>(height * ScrollableArea::minFracti onToStepWhenPaging(), height - ScrollableArea::maxOverlapBetweenPages()), 1)); 264 return static_cast<unsigned>(max(max<int>(height * ScrollableArea::minFracti onToStepWhenPaging(), height - ScrollableArea::maxOverlapBetweenPages()), 1));
265 } 265 }
266 266
267 static RefPtr<Range> unionDOMRanges(Range* a, Range* b) 267 static PassRefPtrWillBeRawPtr<Range> unionDOMRanges(Range* a, Range* b)
268 { 268 {
269 Range* start = a->compareBoundaryPoints(Range::START_TO_START, b, ASSERT_NO_ EXCEPTION) <= 0 ? a : b; 269 Range* start = a->compareBoundaryPoints(Range::START_TO_START, b, ASSERT_NO_ EXCEPTION) <= 0 ? a : b;
270 Range* end = a->compareBoundaryPoints(Range::END_TO_END, b, ASSERT_NO_EXCEPT ION) <= 0 ? b : a; 270 Range* end = a->compareBoundaryPoints(Range::END_TO_END, b, ASSERT_NO_EXCEPT ION) <= 0 ? b : a;
271 271
272 return Range::create(a->ownerDocument(), start->startContainer(), start->sta rtOffset(), end->endContainer(), end->endOffset()); 272 return Range::create(a->ownerDocument(), start->startContainer(), start->sta rtOffset(), end->endContainer(), end->endOffset());
273 } 273 }
274 274
275 // Execute command functions 275 // Execute command functions
276 276
277 static bool executeBackColor(LocalFrame& frame, Event*, EditorCommandSource sour ce, const String& value) 277 static bool executeBackColor(LocalFrame& frame, Event*, EditorCommandSource sour ce, const String& value)
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 static bool executeDeleteToEndOfParagraph(LocalFrame& frame, Event*, EditorComma ndSource, const String&) 373 static bool executeDeleteToEndOfParagraph(LocalFrame& frame, Event*, EditorComma ndSource, const String&)
374 { 374 {
375 // Despite its name, this command should delete the newline at the end of 375 // Despite its name, this command should delete the newline at the end of
376 // a paragraph if you are at the end of a paragraph. 376 // a paragraph if you are at the end of a paragraph.
377 frame.editor().deleteWithDirection(DirectionForward, ParagraphBoundary, true , false); 377 frame.editor().deleteWithDirection(DirectionForward, ParagraphBoundary, true , false);
378 return true; 378 return true;
379 } 379 }
380 380
381 static bool executeDeleteToMark(LocalFrame& frame, Event*, EditorCommandSource, const String&) 381 static bool executeDeleteToMark(LocalFrame& frame, Event*, EditorCommandSource, const String&)
382 { 382 {
383 RefPtr<Range> mark = frame.editor().mark().toNormalizedRange(); 383 RefPtrWillBeRawPtr<Range> mark = frame.editor().mark().toNormalizedRange();
384 if (mark) { 384 if (mark) {
385 bool selected = frame.selection().setSelectedRange(unionDOMRanges(mark.g et(), frame.editor().selectedRange().get()).get(), DOWNSTREAM, FrameSelection::C loseTyping); 385 bool selected = frame.selection().setSelectedRange(unionDOMRanges(mark.g et(), frame.editor().selectedRange().get()).get(), DOWNSTREAM, FrameSelection::C loseTyping);
386 ASSERT(selected); 386 ASSERT(selected);
387 if (!selected) 387 if (!selected)
388 return false; 388 return false;
389 } 389 }
390 frame.editor().performDelete(); 390 frame.editor().performDelete();
391 frame.editor().setMark(frame.selection().selection()); 391 frame.editor().setMark(frame.selection().selection());
392 return true; 392 return true;
393 } 393 }
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 return expandSelectionToGranularity(frame, ParagraphGranularity); 1021 return expandSelectionToGranularity(frame, ParagraphGranularity);
1022 } 1022 }
1023 1023
1024 static bool executeSelectSentence(LocalFrame& frame, Event*, EditorCommandSource , const String&) 1024 static bool executeSelectSentence(LocalFrame& frame, Event*, EditorCommandSource , const String&)
1025 { 1025 {
1026 return expandSelectionToGranularity(frame, SentenceGranularity); 1026 return expandSelectionToGranularity(frame, SentenceGranularity);
1027 } 1027 }
1028 1028
1029 static bool executeSelectToMark(LocalFrame& frame, Event*, EditorCommandSource, const String&) 1029 static bool executeSelectToMark(LocalFrame& frame, Event*, EditorCommandSource, const String&)
1030 { 1030 {
1031 RefPtr<Range> mark = frame.editor().mark().toNormalizedRange(); 1031 RefPtrWillBeRawPtr<Range> mark = frame.editor().mark().toNormalizedRange();
1032 RefPtr<Range> selection = frame.editor().selectedRange(); 1032 RefPtrWillBeRawPtr<Range> selection = frame.editor().selectedRange();
1033 if (!mark || !selection) 1033 if (!mark || !selection)
1034 return false; 1034 return false;
1035 frame.selection().setSelectedRange(unionDOMRanges(mark.get(), selection.get( )).get(), DOWNSTREAM, FrameSelection::CloseTyping); 1035 frame.selection().setSelectedRange(unionDOMRanges(mark.get(), selection.get( )).get(), DOWNSTREAM, FrameSelection::CloseTyping);
1036 return true; 1036 return true;
1037 } 1037 }
1038 1038
1039 static bool executeSelectWord(LocalFrame& frame, Event*, EditorCommandSource, co nst String&) 1039 static bool executeSelectWord(LocalFrame& frame, Event*, EditorCommandSource, co nst String&)
1040 { 1040 {
1041 return expandSelectionToGranularity(frame, WordGranularity); 1041 return expandSelectionToGranularity(frame, WordGranularity);
1042 } 1042 }
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
1730 return m_command->state(*m_frame, triggeringEvent) == TrueTriState ? "tr ue" : "false"; 1730 return m_command->state(*m_frame, triggeringEvent) == TrueTriState ? "tr ue" : "false";
1731 return m_command->value(*m_frame, triggeringEvent); 1731 return m_command->value(*m_frame, triggeringEvent);
1732 } 1732 }
1733 1733
1734 bool Editor::Command::isTextInsertion() const 1734 bool Editor::Command::isTextInsertion() const
1735 { 1735 {
1736 return m_command && m_command->isTextInsertion; 1736 return m_command && m_command->isTextInsertion;
1737 } 1737 }
1738 1738
1739 } // namespace WebCore 1739 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698