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

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

Issue 2710883002: Expand FrameSeleciton::isNone() to increase chances of hoisting update layout (Closed)
Patch Set: 2017-02-23T16:27:43 rebase to resolve conflict with DOMSelection in r452402 Created 3 years, 10 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, 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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 if (killRing) 403 if (killRing)
404 setStartNewKillRingSequence(false); 404 setStartNewKillRingSequence(false);
405 405
406 return true; 406 return true;
407 } 407 }
408 408
409 void Editor::deleteSelectionWithSmartDelete( 409 void Editor::deleteSelectionWithSmartDelete(
410 DeleteMode deleteMode, 410 DeleteMode deleteMode,
411 InputEvent::InputType inputType, 411 InputEvent::InputType inputType,
412 const Position& referenceMovePosition) { 412 const Position& referenceMovePosition) {
413 if (frame().selection().isNone()) 413 if (frame().selection().computeVisibleSelectionInDOMTreeDeprecated().isNone())
414 return; 414 return;
415 415
416 const bool kMergeBlocksAfterDelete = true; 416 const bool kMergeBlocksAfterDelete = true;
417 const bool kExpandForSpecialElements = false; 417 const bool kExpandForSpecialElements = false;
418 const bool kSanitizeMarkup = true; 418 const bool kSanitizeMarkup = true;
419 DCHECK(frame().document()); 419 DCHECK(frame().document());
420 DeleteSelectionCommand::create( 420 DeleteSelectionCommand::create(
421 *frame().document(), deleteMode == DeleteMode::Smart, 421 *frame().document(), deleteMode == DeleteMode::Smart,
422 kMergeBlocksAfterDelete, kExpandForSpecialElements, kSanitizeMarkup, 422 kMergeBlocksAfterDelete, kExpandForSpecialElements, kSanitizeMarkup,
423 inputType, referenceMovePosition) 423 inputType, referenceMovePosition)
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 bool Editor::canSmartReplaceWithPasteboard(Pasteboard* pasteboard) { 598 bool Editor::canSmartReplaceWithPasteboard(Pasteboard* pasteboard) {
599 return smartInsertDeleteEnabled() && pasteboard->canSmartReplace(); 599 return smartInsertDeleteEnabled() && pasteboard->canSmartReplace();
600 } 600 }
601 601
602 void Editor::replaceSelectionWithFragment(DocumentFragment* fragment, 602 void Editor::replaceSelectionWithFragment(DocumentFragment* fragment,
603 bool selectReplacement, 603 bool selectReplacement,
604 bool smartReplace, 604 bool smartReplace,
605 bool matchStyle, 605 bool matchStyle,
606 InputEvent::InputType inputType) { 606 InputEvent::InputType inputType) {
607 DCHECK(!frame().document()->needsLayoutTreeUpdate()); 607 DCHECK(!frame().document()->needsLayoutTreeUpdate());
608 if (frame().selection().isNone() || 608 if (frame()
609 .selection()
610 .computeVisibleSelectionInDOMTreeDeprecated()
611 .isNone() ||
609 !frame() 612 !frame()
610 .selection() 613 .selection()
611 .computeVisibleSelectionInDOMTreeDeprecated() 614 .computeVisibleSelectionInDOMTreeDeprecated()
612 .isContentEditable() || 615 .isContentEditable() ||
613 !fragment) 616 !fragment)
614 return; 617 return;
615 618
616 ReplaceSelectionCommand::CommandOptions options = 619 ReplaceSelectionCommand::CommandOptions options =
617 ReplaceSelectionCommand::PreventNesting | 620 ReplaceSelectionCommand::PreventNesting |
618 ReplaceSelectionCommand::SanitizeFragment; 621 ReplaceSelectionCommand::SanitizeFragment;
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 ApplyStyleCommand::create(*frame().document(), 792 ApplyStyleCommand::create(*frame().document(),
790 EditingStyle::create(style), inputType) 793 EditingStyle::create(style), inputType)
791 ->apply(); 794 ->apply();
792 } 795 }
793 break; 796 break;
794 } 797 }
795 } 798 }
796 799
797 void Editor::applyParagraphStyle(StylePropertySet* style, 800 void Editor::applyParagraphStyle(StylePropertySet* style,
798 InputEvent::InputType inputType) { 801 InputEvent::InputType inputType) {
799 if (frame().selection().isNone() || !style) 802 if (frame()
803 .selection()
804 .computeVisibleSelectionInDOMTreeDeprecated()
805 .isNone() ||
806 !style)
800 return; 807 return;
801 DCHECK(frame().document()); 808 DCHECK(frame().document());
802 ApplyStyleCommand::create(*frame().document(), EditingStyle::create(style), 809 ApplyStyleCommand::create(*frame().document(), EditingStyle::create(style),
803 inputType, ApplyStyleCommand::ForceBlockProperties) 810 inputType, ApplyStyleCommand::ForceBlockProperties)
804 ->apply(); 811 ->apply();
805 } 812 }
806 813
807 void Editor::applyStyleToSelection(StylePropertySet* style, 814 void Editor::applyStyleToSelection(StylePropertySet* style,
808 InputEvent::InputType inputType) { 815 InputEvent::InputType inputType) {
809 if (!style || style->isEmpty() || !canEditRichly()) 816 if (!style || style->isEmpty() || !canEditRichly())
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
1759 1766
1760 DEFINE_TRACE(Editor) { 1767 DEFINE_TRACE(Editor) {
1761 visitor->trace(m_frame); 1768 visitor->trace(m_frame);
1762 visitor->trace(m_lastEditCommand); 1769 visitor->trace(m_lastEditCommand);
1763 visitor->trace(m_undoStack); 1770 visitor->trace(m_undoStack);
1764 visitor->trace(m_mark); 1771 visitor->trace(m_mark);
1765 visitor->trace(m_typingStyle); 1772 visitor->trace(m_typingStyle);
1766 } 1773 }
1767 1774
1768 } // namespace blink 1775 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/DOMSelection.cpp ('k') | third_party/WebKit/Source/core/editing/FrameSelection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698