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

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

Issue 13532011: Stop inserting placeholders for TextArea and Input elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Levi's nit Created 7 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) 2005 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2005 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 18 matching lines...) Expand all
29 #include "Document.h" 29 #include "Document.h"
30 #include "DocumentFragment.h" 30 #include "DocumentFragment.h"
31 #include "DocumentMarkerController.h" 31 #include "DocumentMarkerController.h"
32 #include "EditingBoundary.h" 32 #include "EditingBoundary.h"
33 #include "Editor.h" 33 #include "Editor.h"
34 #include "EditorClient.h" 34 #include "EditorClient.h"
35 #include "Element.h" 35 #include "Element.h"
36 #include "Frame.h" 36 #include "Frame.h"
37 #include "htmlediting.h" 37 #include "htmlediting.h"
38 #include "HTMLInputElement.h" 38 #include "HTMLInputElement.h"
39 #include "HTMLTextAreaElement.h"
39 #include "HTMLNames.h" 40 #include "HTMLNames.h"
40 #include "NodeTraversal.h" 41 #include "NodeTraversal.h"
41 #include "RenderTableCell.h" 42 #include "RenderTableCell.h"
42 #include "Text.h" 43 #include "Text.h"
43 #include "VisibleUnits.h" 44 #include "VisibleUnits.h"
44 45
45 namespace WebCore { 46 namespace WebCore {
46 47
47 using namespace HTMLNames; 48 using namespace HTMLNames;
48 49
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 // If selection has not been set to a custom selection when the command was created, 784 // If selection has not been set to a custom selection when the command was created,
784 // use the current ending selection. 785 // use the current ending selection.
785 if (!m_hasSelectionToDelete) 786 if (!m_hasSelectionToDelete)
786 m_selectionToDelete = endingSelection(); 787 m_selectionToDelete = endingSelection();
787 788
788 if (!m_selectionToDelete.isNonOrphanedRange()) 789 if (!m_selectionToDelete.isNonOrphanedRange())
789 return; 790 return;
790 791
791 String originalString = originalStringForAutocorrectionAtBeginningOfSelectio n(); 792 String originalString = originalStringForAutocorrectionAtBeginningOfSelectio n();
792 793
794 Element* textControl = enclosingTextFormControl(m_selectionToDelete.start()) ;
793 // If the deletion is occurring in a text field, and we're not deleting to r eplace the selection, then let the frame call across the bridge to notify the fo rm delegate. 795 // If the deletion is occurring in a text field, and we're not deleting to r eplace the selection, then let the frame call across the bridge to notify the fo rm delegate.
794 if (!m_replace) { 796 if (!m_replace) {
795 Element* textControl = enclosingTextFormControl(m_selectionToDelete.star t());
796 if (textControl && textControl->focused()) 797 if (textControl && textControl->focused())
797 document()->frame()->editor()->textWillBeDeletedInTextField(textCont rol); 798 document()->frame()->editor()->textWillBeDeletedInTextField(textCont rol);
798 } 799 }
799 800
800 // save this to later make the selection with 801 // save this to later make the selection with
801 EAffinity affinity = m_selectionToDelete.affinity(); 802 EAffinity affinity = m_selectionToDelete.affinity();
802 803
803 Position downstreamEnd = m_selectionToDelete.end().downstream(); 804 Position downstreamEnd = m_selectionToDelete.end().downstream();
804 m_needPlaceholder = isStartOfParagraph(m_selectionToDelete.visibleStart(), C anCrossEditingBoundary) 805 m_needPlaceholder = isStartOfParagraph(m_selectionToDelete.visibleStart(), C anCrossEditingBoundary)
805 && isEndOfParagraph(m_selectionToDelete.visibleEnd(), CanCrossEditin gBoundary) 806 && isEndOfParagraph(m_selectionToDelete.visibleEnd(), CanCrossEditin gBoundary)
806 && !lineBreakExistsAtVisiblePosition(m_selectionToDelete.visibleEnd( )); 807 && !lineBreakExistsAtVisiblePosition(m_selectionToDelete.visibleEnd( ))
808 && !(textControl && (isHTMLTextAreaElement(textControl) || textContr ol->toInputElement())) ;
809
807 if (m_needPlaceholder) { 810 if (m_needPlaceholder) {
808 // Don't need a placeholder when deleting a selection that starts just b efore a table 811 // Don't need a placeholder when deleting a selection that starts just b efore a table
809 // and ends inside it (we do need placeholders to hold open empty cells, but that's 812 // and ends inside it (we do need placeholders to hold open empty cells, but that's
810 // handled elsewhere). 813 // handled elsewhere).
811 if (Node* table = isLastPositionBeforeTable(m_selectionToDelete.visibleS tart())) 814 if (Node* table = isLastPositionBeforeTable(m_selectionToDelete.visibleS tart()))
812 if (m_selectionToDelete.end().deprecatedNode()->isDescendantOf(table )) 815 if (m_selectionToDelete.end().deprecatedNode()->isDescendantOf(table ))
813 m_needPlaceholder = false; 816 m_needPlaceholder = false;
814 } 817 }
815 818
816 819
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 874
872 // Normally deletion doesn't preserve the typing style that was present before i t. For example, 875 // Normally deletion doesn't preserve the typing style that was present before i t. For example,
873 // type a character, Bold, then delete the character and start typing. The Bold typing style shouldn't 876 // type a character, Bold, then delete the character and start typing. The Bold typing style shouldn't
874 // stick around. Deletion should preserve a typing style that *it* sets, howeve r. 877 // stick around. Deletion should preserve a typing style that *it* sets, howeve r.
875 bool DeleteSelectionCommand::preservesTypingStyle() const 878 bool DeleteSelectionCommand::preservesTypingStyle() const
876 { 879 {
877 return m_typingStyle; 880 return m_typingStyle;
878 } 881 }
879 882
880 } // namespace WebCore 883 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698