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

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

Issue 2698793003: Get rid of redundant layout tree update related to selection (Closed)
Patch Set: 2017-02-17T16:13:56 selectionTypeWithLegacyGranularity() 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/Editor.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) 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 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 selectedRange->startContainer(), 659 selectedRange->startContainer(),
660 selectedRange->startOffset(), ASSERT_NO_EXCEPTION); 660 selectedRange->startOffset(), ASSERT_NO_EXCEPTION);
661 } 661 }
662 662
663 bool DOMSelection::containsNode(const Node* n, bool allowPartial) const { 663 bool DOMSelection::containsNode(const Node* n, bool allowPartial) const {
664 DCHECK(n); 664 DCHECK(n);
665 665
666 if (!isAvailable()) 666 if (!isAvailable())
667 return false; 667 return false;
668 668
669 FrameSelection& selection = frame()->selection(); 669 if (frame()->document() != n->document())
670
671 if (frame()->document() != n->document() || selection.isNone())
672 return false; 670 return false;
673 671
674 unsigned nodeIndex = n->nodeIndex(); 672 unsigned nodeIndex = n->nodeIndex();
675 673
676 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets 674 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
677 // needs to be audited. See http://crbug.com/590369 for more details. 675 // needs to be audited. See http://crbug.com/590369 for more details.
678 // |VisibleSelection::toNormalizedEphemeralRange| requires clean layout. 676 // |VisibleSelection::toNormalizedEphemeralRange| requires clean layout.
679 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 677 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets();
680 678
679 FrameSelection& selection = frame()->selection();
681 const EphemeralRange selectedRange = 680 const EphemeralRange selectedRange =
682 selection.selection().toNormalizedEphemeralRange(); 681 selection.selection().toNormalizedEphemeralRange();
682 if (selectedRange.isNull())
683 return false;
683 684
684 ContainerNode* parentNode = n->parentNode(); 685 ContainerNode* parentNode = n->parentNode();
685 if (!parentNode) 686 if (!parentNode)
686 return false; 687 return false;
687 688
688 const Position startPosition = 689 const Position startPosition =
689 selectedRange.startPosition().toOffsetInAnchor(); 690 selectedRange.startPosition().toOffsetInAnchor();
690 const Position endPosition = selectedRange.endPosition().toOffsetInAnchor(); 691 const Position endPosition = selectedRange.endPosition().toOffsetInAnchor();
691 DummyExceptionStateForTesting exceptionState; 692 DummyExceptionStateForTesting exceptionState;
692 bool nodeFullySelected = 693 bool nodeFullySelected =
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 m_treeScope->document().addConsoleMessage( 790 m_treeScope->document().addConsoleMessage(
790 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); 791 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message));
791 } 792 }
792 793
793 DEFINE_TRACE(DOMSelection) { 794 DEFINE_TRACE(DOMSelection) {
794 visitor->trace(m_treeScope); 795 visitor->trace(m_treeScope);
795 ContextClient::trace(visitor); 796 ContextClient::trace(visitor);
796 } 797 }
797 798
798 } // namespace blink 799 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/Editor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698