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

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

Issue 2001083002: Explicit management of FrameSelection availability (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-06-08T18:08:39 Created 4 years, 6 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) 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 { 74 {
75 } 75 }
76 76
77 void DOMSelection::clearTreeScope() 77 void DOMSelection::clearTreeScope()
78 { 78 {
79 m_treeScope = nullptr; 79 m_treeScope = nullptr;
80 } 80 }
81 81
82 bool DOMSelection::isAvailable() const 82 bool DOMSelection::isAvailable() const
83 { 83 {
84 return m_frame; 84 return m_frame && m_frame->selection().isAvailable();
85 } 85 }
86 86
87 const VisibleSelection& DOMSelection::visibleSelection() const 87 const VisibleSelection& DOMSelection::visibleSelection() const
88 { 88 {
89 DCHECK(m_frame); 89 DCHECK(m_frame);
90 return m_frame->selection().selection(); 90 return m_frame->selection().selection();
91 } 91 }
92 92
93 static Position anchorPosition(const VisibleSelection& selection) 93 static Position anchorPosition(const VisibleSelection& selection)
94 { 94 {
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 if (newRange->ownerDocument() != m_frame->document()) 417 if (newRange->ownerDocument() != m_frame->document())
418 return; 418 return;
419 419
420 if (!newRange->inShadowIncludingDocument()) { 420 if (!newRange->inShadowIncludingDocument()) {
421 addConsoleError("The given range isn't in document."); 421 addConsoleError("The given range isn't in document.");
422 return; 422 return;
423 } 423 }
424 424
425 FrameSelection& selection = m_frame->selection(); 425 FrameSelection& selection = m_frame->selection();
426 426
427 if (newRange->ownerDocument() != selection.document()) {
428 // "editing/selection/selection-in-iframe-removed-crash.html" goes here.
429 return;
430 }
431
427 if (selection.isNone()) { 432 if (selection.isNone()) {
428 selection.setSelectedRange(newRange, VP_DEFAULT_AFFINITY); 433 selection.setSelectedRange(newRange, VP_DEFAULT_AFFINITY);
429 return; 434 return;
430 } 435 }
431 436
432 Range* originalRange = selection.firstRange(); 437 Range* originalRange = selection.firstRange();
433 438
434 if (originalRange->startContainer()->document() != newRange->startContainer( )->document()) { 439 if (originalRange->startContainer()->document() != newRange->startContainer( )->document()) {
435 addConsoleError("The given range does not belong to the current selectio n's document."); 440 addConsoleError("The given range does not belong to the current selectio n's document.");
436 return; 441 return;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 m_treeScope->document().addConsoleMessage(ConsoleMessage::create(JSMessa geSource, ErrorMessageLevel, message)); 586 m_treeScope->document().addConsoleMessage(ConsoleMessage::create(JSMessa geSource, ErrorMessageLevel, message));
582 } 587 }
583 588
584 DEFINE_TRACE(DOMSelection) 589 DEFINE_TRACE(DOMSelection)
585 { 590 {
586 visitor->trace(m_treeScope); 591 visitor->trace(m_treeScope);
587 DOMWindowProperty::trace(visitor); 592 DOMWindowProperty::trace(visitor);
588 } 593 }
589 594
590 } // namespace blink 595 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | third_party/WebKit/Source/core/editing/FrameCaret.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698