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

Side by Side Diff: Source/core/page/DOMSelection.cpp

Issue 255453003: Let Selection.deleteFromDocument not delete a character when the selection is a caret. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: use shouldBeEqualToString instead of shouldBe 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
« no previous file with comments | « LayoutTests/editing/selection/deleteFromDocument-undo-crash-expected.txt ('k') | no next file » | 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) 2007, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2012 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 * 8 *
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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 void DOMSelection::deleteFromDocument() 440 void DOMSelection::deleteFromDocument()
441 { 441 {
442 if (!m_frame) 442 if (!m_frame)
443 return; 443 return;
444 444
445 FrameSelection& selection = m_frame->selection(); 445 FrameSelection& selection = m_frame->selection();
446 446
447 if (selection.isNone()) 447 if (selection.isNone())
448 return; 448 return;
449 449
450 if (isCollapsed())
451 selection.modify(FrameSelection::AlterationExtend, DirectionBackward, Ch aracterGranularity);
452
453 RefPtrWillBeRawPtr<Range> selectedRange = selection.selection().toNormalized Range(); 450 RefPtrWillBeRawPtr<Range> selectedRange = selection.selection().toNormalized Range();
454 if (!selectedRange) 451 if (!selectedRange)
455 return; 452 return;
456 453
457 selectedRange->deleteContents(ASSERT_NO_EXCEPTION); 454 selectedRange->deleteContents(ASSERT_NO_EXCEPTION);
458 455
459 setBaseAndExtent(selectedRange->startContainer(ASSERT_NO_EXCEPTION), selecte dRange->startOffset(), selectedRange->startContainer(), selectedRange->startOffs et(), ASSERT_NO_EXCEPTION); 456 setBaseAndExtent(selectedRange->startContainer(ASSERT_NO_EXCEPTION), selecte dRange->startOffset(), selectedRange->startContainer(), selectedRange->startOffs et(), ASSERT_NO_EXCEPTION);
460 } 457 }
461 458
462 bool DOMSelection::containsNode(const Node* n, bool allowPartial) const 459 bool DOMSelection::containsNode(const Node* n, bool allowPartial) const
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 return node->document() == m_frame->document(); 550 return node->document() == m_frame->document();
554 } 551 }
555 552
556 void DOMSelection::addConsoleError(const String& message) 553 void DOMSelection::addConsoleError(const String& message)
557 { 554 {
558 if (m_treeScope) 555 if (m_treeScope)
559 m_treeScope->document().addConsoleMessage(JSMessageSource, ErrorMessageL evel, message); 556 m_treeScope->document().addConsoleMessage(JSMessageSource, ErrorMessageL evel, message);
560 } 557 }
561 558
562 } // namespace WebCore 559 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/editing/selection/deleteFromDocument-undo-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698