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

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

Issue 2734793002: Expand FrameSelection::isInPasswordFiled() into call sites (Closed)
Patch Set: 2017-03-07T11:24:31 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/FrameSelection.h » ('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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 .isContentRichlyEditable(); 276 .isContentRichlyEditable();
277 } 277 }
278 278
279 // WinIE uses onbeforecut and onbeforepaste to enables the cut and paste menu 279 // WinIE uses onbeforecut and onbeforepaste to enables the cut and paste menu
280 // items. They also send onbeforecopy, apparently for symmetry, but it doesn't 280 // items. They also send onbeforecopy, apparently for symmetry, but it doesn't
281 // affect the menu items. We need to use onbeforecopy as a real menu enabler 281 // affect the menu items. We need to use onbeforecopy as a real menu enabler
282 // because we allow elements that are not normally selectable to implement 282 // because we allow elements that are not normally selectable to implement
283 // copy/paste (like divs, or a document body). 283 // copy/paste (like divs, or a document body).
284 284
285 bool Editor::canDHTMLCut() { 285 bool Editor::canDHTMLCut() {
286 return !frame().selection().isInPasswordField() && 286 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets
287 // needs to be audited. See http://crbug.com/590369 for more details.
288 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets();
289 return !isInPasswordField(
290 frame().selection().computeVisibleSelectionInDOMTree().start()) &&
287 !dispatchCPPEvent(EventTypeNames::beforecut, DataTransferNumb); 291 !dispatchCPPEvent(EventTypeNames::beforecut, DataTransferNumb);
288 } 292 }
289 293
290 bool Editor::canDHTMLCopy() { 294 bool Editor::canDHTMLCopy() {
291 return !frame().selection().isInPasswordField() && 295 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets
296 // needs to be audited. See http://crbug.com/590369 for more details.
297 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets();
298 return !isInPasswordField(
299 frame().selection().computeVisibleSelectionInDOMTree().start()) &&
292 !dispatchCPPEvent(EventTypeNames::beforecopy, DataTransferNumb); 300 !dispatchCPPEvent(EventTypeNames::beforecopy, DataTransferNumb);
293 } 301 }
294 302
295 bool Editor::canCut() const { 303 bool Editor::canCut() const {
296 return canCopy() && canDelete(); 304 return canCopy() && canDelete();
297 } 305 }
298 306
299 static HTMLImageElement* imageElementFromImageDocument(Document* document) { 307 static HTMLImageElement* imageElementFromImageDocument(Document* document) {
300 if (!document) 308 if (!document)
301 return 0; 309 return 0;
302 if (!document->isImageDocument()) 310 if (!document->isImageDocument())
303 return 0; 311 return 0;
304 312
305 HTMLElement* body = document->body(); 313 HTMLElement* body = document->body();
306 if (!body) 314 if (!body)
307 return 0; 315 return 0;
308 316
309 Node* node = body->firstChild(); 317 Node* node = body->firstChild();
310 if (!isHTMLImageElement(node)) 318 if (!isHTMLImageElement(node))
311 return 0; 319 return 0;
312 return toHTMLImageElement(node); 320 return toHTMLImageElement(node);
313 } 321 }
314 322
315 bool Editor::canCopy() const { 323 bool Editor::canCopy() const {
316 if (imageElementFromImageDocument(frame().document())) 324 if (imageElementFromImageDocument(frame().document()))
317 return true; 325 return true;
318 FrameSelection& selection = frame().selection(); 326 FrameSelection& selection = frame().selection();
319 return selection.computeVisibleSelectionInDOMTreeDeprecated().isRange() && 327 return selection.computeVisibleSelectionInDOMTreeDeprecated().isRange() &&
320 !selection.isInPasswordField(); 328 !isInPasswordField(
329 frame().selection().computeVisibleSelectionInDOMTree().start());
321 } 330 }
322 331
323 bool Editor::canPaste() const { 332 bool Editor::canPaste() const {
324 return canEdit(); 333 return canEdit();
325 } 334 }
326 335
327 bool Editor::canDelete() const { 336 bool Editor::canDelete() const {
328 FrameSelection& selection = frame().selection(); 337 FrameSelection& selection = frame().selection();
329 return selection.computeVisibleSelectionInDOMTreeDeprecated().isRange() && 338 return selection.computeVisibleSelectionInDOMTreeDeprecated().isRange() &&
330 selection.computeVisibleSelectionInDOMTree().rootEditableElement(); 339 selection.computeVisibleSelectionInDOMTree().rootEditableElement();
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 bool smartReplace, 444 bool smartReplace,
436 bool matchStyle) { 445 bool matchStyle) {
437 Element* target = findEventTargetFromSelection(); 446 Element* target = findEventTargetFromSelection();
438 if (!target) 447 if (!target)
439 return; 448 return;
440 target->dispatchEvent(TextEvent::createForFragmentPaste( 449 target->dispatchEvent(TextEvent::createForFragmentPaste(
441 frame().domWindow(), pastingFragment, smartReplace, matchStyle)); 450 frame().domWindow(), pastingFragment, smartReplace, matchStyle));
442 } 451 }
443 452
444 bool Editor::tryDHTMLCopy() { 453 bool Editor::tryDHTMLCopy() {
445 if (frame().selection().isInPasswordField()) 454 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets
455 // needs to be audited. See http://crbug.com/590369 for more details.
456 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets();
457 if (isInPasswordField(
458 frame().selection().computeVisibleSelectionInDOMTree().start()))
446 return false; 459 return false;
447 460
448 return !dispatchCPPEvent(EventTypeNames::copy, DataTransferWritable); 461 return !dispatchCPPEvent(EventTypeNames::copy, DataTransferWritable);
449 } 462 }
450 463
451 bool Editor::tryDHTMLCut() { 464 bool Editor::tryDHTMLCut() {
452 if (frame().selection().isInPasswordField()) 465 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets
466 // needs to be audited. See http://crbug.com/590369 for more details.
467 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets();
468 if (isInPasswordField(
469 frame().selection().computeVisibleSelectionInDOMTree().start()))
453 return false; 470 return false;
454 471
455 return !dispatchCPPEvent(EventTypeNames::cut, DataTransferWritable); 472 return !dispatchCPPEvent(EventTypeNames::cut, DataTransferWritable);
456 } 473 }
457 474
458 bool Editor::tryDHTMLPaste(PasteMode pasteMode) { 475 bool Editor::tryDHTMLPaste(PasteMode pasteMode) {
459 return !dispatchCPPEvent(EventTypeNames::paste, DataTransferReadable, 476 return !dispatchCPPEvent(EventTypeNames::paste, DataTransferReadable,
460 pasteMode); 477 pasteMode);
461 } 478 }
462 479
(...skipping 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after
1759 1776
1760 DEFINE_TRACE(Editor) { 1777 DEFINE_TRACE(Editor) {
1761 visitor->trace(m_frame); 1778 visitor->trace(m_frame);
1762 visitor->trace(m_lastEditCommand); 1779 visitor->trace(m_lastEditCommand);
1763 visitor->trace(m_undoStack); 1780 visitor->trace(m_undoStack);
1764 visitor->trace(m_mark); 1781 visitor->trace(m_mark);
1765 visitor->trace(m_typingStyle); 1782 visitor->trace(m_typingStyle);
1766 } 1783 }
1767 1784
1768 } // namespace blink 1785 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/FrameSelection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698