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

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

Issue 2414263002: Audit the use of updateStyleAndLayoutIgnorePendingStylesheets in toNormalizedEphemeralRange (Closed)
Patch Set: fix nit Created 4 years, 2 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 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 518
519 void DOMSelection::deleteFromDocument() { 519 void DOMSelection::deleteFromDocument() {
520 if (!isAvailable()) 520 if (!isAvailable())
521 return; 521 return;
522 522
523 FrameSelection& selection = frame()->selection(); 523 FrameSelection& selection = frame()->selection();
524 524
525 if (selection.isNone()) 525 if (selection.isNone())
526 return; 526 return;
527 527
528 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
529 // needs to be audited. See http://crbug.com/590369 for more details.
530 // |VisibleSelection::toNormalizedEphemeralRange| requires clean layout.
531 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets();
532
528 Range* selectedRange = 533 Range* selectedRange =
529 createRange(selection.selection().toNormalizedEphemeralRange()); 534 createRange(selection.selection().toNormalizedEphemeralRange());
530 if (!selectedRange) 535 if (!selectedRange)
531 return; 536 return;
532 537
533 selectedRange->deleteContents(ASSERT_NO_EXCEPTION); 538 selectedRange->deleteContents(ASSERT_NO_EXCEPTION);
534 539
535 setBaseAndExtent(selectedRange->startContainer(), 540 setBaseAndExtent(selectedRange->startContainer(),
536 selectedRange->startOffset(), 541 selectedRange->startOffset(),
537 selectedRange->startContainer(), 542 selectedRange->startContainer(),
538 selectedRange->startOffset(), ASSERT_NO_EXCEPTION); 543 selectedRange->startOffset(), ASSERT_NO_EXCEPTION);
539 } 544 }
540 545
541 bool DOMSelection::containsNode(const Node* n, bool allowPartial) const { 546 bool DOMSelection::containsNode(const Node* n, bool allowPartial) const {
542 DCHECK(n); 547 DCHECK(n);
543 548
544 if (!isAvailable()) 549 if (!isAvailable())
545 return false; 550 return false;
546 551
547 FrameSelection& selection = frame()->selection(); 552 FrameSelection& selection = frame()->selection();
548 553
549 if (frame()->document() != n->document() || selection.isNone()) 554 if (frame()->document() != n->document() || selection.isNone())
550 return false; 555 return false;
551 556
552 unsigned nodeIndex = n->nodeIndex(); 557 unsigned nodeIndex = n->nodeIndex();
558
559 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
560 // needs to be audited. See http://crbug.com/590369 for more details.
561 // |VisibleSelection::toNormalizedEphemeralRange| requires clean layout.
562 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets();
563
553 const EphemeralRange selectedRange = 564 const EphemeralRange selectedRange =
554 selection.selection().toNormalizedEphemeralRange(); 565 selection.selection().toNormalizedEphemeralRange();
555 566
556 ContainerNode* parentNode = n->parentNode(); 567 ContainerNode* parentNode = n->parentNode();
557 if (!parentNode) 568 if (!parentNode)
558 return false; 569 return false;
559 570
560 const Position startPosition = 571 const Position startPosition =
561 selectedRange.startPosition().toOffsetInAnchor(); 572 selectedRange.startPosition().toOffsetInAnchor();
562 const Position endPosition = selectedRange.endPosition().toOffsetInAnchor(); 573 const Position endPosition = selectedRange.endPosition().toOffsetInAnchor();
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 m_treeScope->document().addConsoleMessage( 670 m_treeScope->document().addConsoleMessage(
660 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); 671 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message));
661 } 672 }
662 673
663 DEFINE_TRACE(DOMSelection) { 674 DEFINE_TRACE(DOMSelection) {
664 visitor->trace(m_treeScope); 675 visitor->trace(m_treeScope);
665 DOMWindowProperty::trace(visitor); 676 DOMWindowProperty::trace(visitor);
666 } 677 }
667 678
668 } // namespace blink 679 } // 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