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

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-16T17:15:58 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 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 selectedRange->startContainer(), 600 selectedRange->startContainer(),
601 selectedRange->startOffset(), ASSERT_NO_EXCEPTION); 601 selectedRange->startOffset(), ASSERT_NO_EXCEPTION);
602 } 602 }
603 603
604 bool DOMSelection::containsNode(const Node* n, bool allowPartial) const { 604 bool DOMSelection::containsNode(const Node* n, bool allowPartial) const {
605 DCHECK(n); 605 DCHECK(n);
606 606
607 if (!isAvailable()) 607 if (!isAvailable())
608 return false; 608 return false;
609 609
610 FrameSelection& selection = frame()->selection(); 610 if (frame()->document() != n->document())
611
612 if (frame()->document() != n->document() || selection.isNone())
yosin_UTC9 2017/02/16 09:50:26 FrameSeleciton::isNone() requires clean layout tre
613 return false; 611 return false;
614 612
615 unsigned nodeIndex = n->nodeIndex(); 613 unsigned nodeIndex = n->nodeIndex();
616 614
617 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets 615 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
618 // needs to be audited. See http://crbug.com/590369 for more details. 616 // needs to be audited. See http://crbug.com/590369 for more details.
619 // |VisibleSelection::toNormalizedEphemeralRange| requires clean layout. 617 // |VisibleSelection::toNormalizedEphemeralRange| requires clean layout.
620 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 618 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets();
621 619
620 FrameSelection& selection = frame()->selection();
622 const EphemeralRange selectedRange = 621 const EphemeralRange selectedRange =
623 selection.selection().toNormalizedEphemeralRange(); 622 selection.selection().toNormalizedEphemeralRange();
623 if (selectedRange.isNull())
624 return false;
624 625
625 ContainerNode* parentNode = n->parentNode(); 626 ContainerNode* parentNode = n->parentNode();
626 if (!parentNode) 627 if (!parentNode)
627 return false; 628 return false;
628 629
629 const Position startPosition = 630 const Position startPosition =
630 selectedRange.startPosition().toOffsetInAnchor(); 631 selectedRange.startPosition().toOffsetInAnchor();
631 const Position endPosition = selectedRange.endPosition().toOffsetInAnchor(); 632 const Position endPosition = selectedRange.endPosition().toOffsetInAnchor();
632 DummyExceptionStateForTesting exceptionState; 633 DummyExceptionStateForTesting exceptionState;
633 bool nodeFullySelected = 634 bool nodeFullySelected =
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 m_treeScope->document().addConsoleMessage( 731 m_treeScope->document().addConsoleMessage(
731 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); 732 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message));
732 } 733 }
733 734
734 DEFINE_TRACE(DOMSelection) { 735 DEFINE_TRACE(DOMSelection) {
735 visitor->trace(m_treeScope); 736 visitor->trace(m_treeScope);
736 ContextClient::trace(visitor); 737 ContextClient::trace(visitor);
737 } 738 }
738 739
739 } // namespace blink 740 } // 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