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

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

Issue 2707993004: Selection API: Fix a null pointer dereference in addRange(). (Closed)
Patch Set: 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 | « third_party/WebKit/LayoutTests/editing/selection/addrange-crash.html ('k') | no next file » | 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 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 // parameter that does not require clean layout, so that modifying selection 610 // parameter that does not require clean layout, so that modifying selection
611 // no longer performs synchronous layout by itself. 611 // no longer performs synchronous layout by itself.
612 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 612 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets();
613 613
614 if (rangeCount() == 0) { 614 if (rangeCount() == 0) {
615 selection.setSelectedRange(EphemeralRange(newRange), VP_DEFAULT_AFFINITY); 615 selection.setSelectedRange(EphemeralRange(newRange), VP_DEFAULT_AFFINITY);
616 cacheRangeIfSelectionOfDocument(newRange); 616 cacheRangeIfSelectionOfDocument(newRange);
617 return; 617 return;
618 } 618 }
619 619
620 Range* originalRange = selection.firstRange(); 620 Range* originalRange = primaryRangeOrNull();
621 DCHECK(originalRange);
621 622
622 if (originalRange->startContainer()->treeScope() != 623 if (originalRange->startContainer()->treeScope() !=
623 newRange->startContainer()->treeScope()) { 624 newRange->startContainer()->treeScope()) {
624 return; 625 return;
625 } 626 }
626 627
627 if (originalRange->compareBoundaryPoints(Range::kStartToEnd, newRange, 628 if (originalRange->compareBoundaryPoints(Range::kStartToEnd, newRange,
628 ASSERT_NO_EXCEPTION) < 0 || 629 ASSERT_NO_EXCEPTION) < 0 ||
629 newRange->compareBoundaryPoints(Range::kStartToEnd, originalRange, 630 newRange->compareBoundaryPoints(Range::kStartToEnd, originalRange,
630 ASSERT_NO_EXCEPTION) < 0) { 631 ASSERT_NO_EXCEPTION) < 0) {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 m_treeScope->document().addConsoleMessage( 814 m_treeScope->document().addConsoleMessage(
814 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); 815 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message));
815 } 816 }
816 817
817 DEFINE_TRACE(DOMSelection) { 818 DEFINE_TRACE(DOMSelection) {
818 visitor->trace(m_treeScope); 819 visitor->trace(m_treeScope);
819 ContextClient::trace(visitor); 820 ContextClient::trace(visitor);
820 } 821 }
821 822
822 } // namespace blink 823 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/editing/selection/addrange-crash.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698