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

Side by Side Diff: third_party/WebKit/Source/core/editing/Editor.cpp

Issue 2740823003: [PasswordGeneration] Makes generated passwords copyable (Closed)
Patch Set: Changes in the test addressed to reviewer comments Created 3 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/EditorTest.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, 2007, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2011 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 * 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 12 matching lines...) Expand all
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #include "core/editing/Editor.h" 27 #include "core/editing/Editor.h"
28 28
29 #include "bindings/core/v8/ExceptionState.h" 29 #include "bindings/core/v8/ExceptionState.h"
30 #include "core/CSSPropertyNames.h" 30 #include "core/CSSPropertyNames.h"
31 #include "core/EventNames.h" 31 #include "core/EventNames.h"
32 #include "core/HTMLNames.h" 32 #include "core/HTMLNames.h"
33 #include "core/InputTypeNames.h"
33 #include "core/clipboard/DataObject.h" 34 #include "core/clipboard/DataObject.h"
34 #include "core/clipboard/DataTransfer.h" 35 #include "core/clipboard/DataTransfer.h"
35 #include "core/clipboard/Pasteboard.h" 36 #include "core/clipboard/Pasteboard.h"
36 #include "core/css/CSSComputedStyleDeclaration.h" 37 #include "core/css/CSSComputedStyleDeclaration.h"
37 #include "core/css/StylePropertySet.h" 38 #include "core/css/StylePropertySet.h"
38 #include "core/dom/AXObjectCache.h" 39 #include "core/dom/AXObjectCache.h"
39 #include "core/dom/DocumentFragment.h" 40 #include "core/dom/DocumentFragment.h"
40 #include "core/dom/ElementTraversal.h" 41 #include "core/dom/ElementTraversal.h"
41 #include "core/dom/NodeTraversal.h" 42 #include "core/dom/NodeTraversal.h"
42 #include "core/dom/ParserContentPolicy.h" 43 #include "core/dom/ParserContentPolicy.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 129
129 InputEvent::EventIsComposing isComposingFromCommand( 130 InputEvent::EventIsComposing isComposingFromCommand(
130 const CompositeEditCommand* command) { 131 const CompositeEditCommand* command) {
131 if (command->isTypingCommand() && 132 if (command->isTypingCommand() &&
132 toTypingCommand(command)->compositionType() != 133 toTypingCommand(command)->compositionType() !=
133 TypingCommand::TextCompositionNone) 134 TypingCommand::TextCompositionNone)
134 return InputEvent::EventIsComposing::IsComposing; 135 return InputEvent::EventIsComposing::IsComposing;
135 return InputEvent::EventIsComposing::NotComposing; 136 return InputEvent::EventIsComposing::NotComposing;
136 } 137 }
137 138
139 bool isInPasswordFieldWithUnrevealedPassword(const Position& position) {
140 TextControlElement* textControl = enclosingTextControl(position);
141 if (!isHTMLInputElement(textControl))
142 return false;
143 HTMLInputElement* input = toHTMLInputElement(textControl);
144 return (input->type() == InputTypeNames::password) &&
145 !input->shouldRevealPassword();
146 }
147
138 } // anonymous namespace 148 } // anonymous namespace
139 149
140 Editor::RevealSelectionScope::RevealSelectionScope(Editor* editor) 150 Editor::RevealSelectionScope::RevealSelectionScope(Editor* editor)
141 : m_editor(editor) { 151 : m_editor(editor) {
142 ++m_editor->m_preventRevealSelection; 152 ++m_editor->m_preventRevealSelection;
143 } 153 }
144 154
145 Editor::RevealSelectionScope::~RevealSelectionScope() { 155 Editor::RevealSelectionScope::~RevealSelectionScope() {
146 DCHECK(m_editor->m_preventRevealSelection); 156 DCHECK(m_editor->m_preventRevealSelection);
147 --m_editor->m_preventRevealSelection; 157 --m_editor->m_preventRevealSelection;
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 if (!isHTMLImageElement(node)) 328 if (!isHTMLImageElement(node))
319 return 0; 329 return 0;
320 return toHTMLImageElement(node); 330 return toHTMLImageElement(node);
321 } 331 }
322 332
323 bool Editor::canCopy() const { 333 bool Editor::canCopy() const {
324 if (imageElementFromImageDocument(frame().document())) 334 if (imageElementFromImageDocument(frame().document()))
325 return true; 335 return true;
326 FrameSelection& selection = frame().selection(); 336 FrameSelection& selection = frame().selection();
327 return selection.computeVisibleSelectionInDOMTreeDeprecated().isRange() && 337 return selection.computeVisibleSelectionInDOMTreeDeprecated().isRange() &&
328 !isInPasswordField( 338 !isInPasswordFieldWithUnrevealedPassword(
329 frame().selection().computeVisibleSelectionInDOMTree().start()); 339 frame().selection().computeVisibleSelectionInDOMTree().start());
330 } 340 }
331 341
332 bool Editor::canPaste() const { 342 bool Editor::canPaste() const {
333 return canEdit(); 343 return canEdit();
334 } 344 }
335 345
336 bool Editor::canDelete() const { 346 bool Editor::canDelete() const {
337 FrameSelection& selection = frame().selection(); 347 FrameSelection& selection = frame().selection();
338 return selection.computeVisibleSelectionInDOMTreeDeprecated().isRange() && 348 return selection.computeVisibleSelectionInDOMTreeDeprecated().isRange() &&
(...skipping 1437 matching lines...) Expand 10 before | Expand all | Expand 10 after
1776 1786
1777 DEFINE_TRACE(Editor) { 1787 DEFINE_TRACE(Editor) {
1778 visitor->trace(m_frame); 1788 visitor->trace(m_frame);
1779 visitor->trace(m_lastEditCommand); 1789 visitor->trace(m_lastEditCommand);
1780 visitor->trace(m_undoStack); 1790 visitor->trace(m_undoStack);
1781 visitor->trace(m_mark); 1791 visitor->trace(m_mark);
1782 visitor->trace(m_typingStyle); 1792 visitor->trace(m_typingStyle);
1783 } 1793 }
1784 1794
1785 } // namespace blink 1795 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/EditorTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698