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

Side by Side Diff: third_party/WebKit/Source/web/WebFrameWidgetImpl.cpp

Issue 2920853005: Fix a crash related to detaching a frame embedding pepper plugin with selection (Closed)
Patch Set: nits Created 3 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
« no previous file with comments | « no previous file | 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) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 } 589 }
590 590
591 // TODO(ekaramad):This method is almost duplicated in WebViewImpl as well. This 591 // TODO(ekaramad):This method is almost duplicated in WebViewImpl as well. This
592 // code needs to be refactored (http://crbug.com/629721). 592 // code needs to be refactored (http://crbug.com/629721).
593 bool WebFrameWidgetImpl::SelectionBounds(WebRect& anchor, 593 bool WebFrameWidgetImpl::SelectionBounds(WebRect& anchor,
594 WebRect& focus) const { 594 WebRect& focus) const {
595 const LocalFrame* local_frame = FocusedLocalFrameInWidget(); 595 const LocalFrame* local_frame = FocusedLocalFrameInWidget();
596 if (!local_frame) 596 if (!local_frame)
597 return false; 597 return false;
598 598
599 FrameSelection& selection = local_frame->Selection();
600 if (!selection.IsAvailable() || selection.GetSelectionInDOMTree().IsNone())
601 return false;
602
599 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets 603 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets
600 // needs to be audited. See http://crbug.com/590369 for more details. 604 // needs to be audited. See http://crbug.com/590369 for more details.
601 local_frame->GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets(); 605 local_frame->GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets();
602 606
603 DocumentLifecycle::DisallowTransitionScope disallow_transition( 607 DocumentLifecycle::DisallowTransitionScope disallow_transition(
604 local_frame->GetDocument()->Lifecycle()); 608 local_frame->GetDocument()->Lifecycle());
605 609
606 FrameSelection& selection = local_frame->Selection();
607 if (selection.ComputeVisibleSelectionInDOMTree().IsNone()) 610 if (selection.ComputeVisibleSelectionInDOMTree().IsNone())
608 return false; 611 return false;
609 612
610 if (selection.ComputeVisibleSelectionInDOMTree().IsCaret()) { 613 if (selection.ComputeVisibleSelectionInDOMTree().IsCaret()) {
611 anchor = focus = selection.AbsoluteCaretBounds(); 614 anchor = focus = selection.AbsoluteCaretBounds();
612 } else { 615 } else {
613 const EphemeralRange selected_range = 616 const EphemeralRange selected_range =
614 selection.ComputeVisibleSelectionInDOMTree() 617 selection.ComputeVisibleSelectionInDOMTree()
615 .ToNormalizedEphemeralRange(); 618 .ToNormalizedEphemeralRange();
616 if (selected_range.IsNull()) 619 if (selected_range.IsNull())
(...skipping 18 matching lines...) Expand all
635 } 638 }
636 639
637 // TODO(ekaramad):This method is almost duplicated in WebViewImpl as well. This 640 // TODO(ekaramad):This method is almost duplicated in WebViewImpl as well. This
638 // code needs to be refactored (http://crbug.com/629721). 641 // code needs to be refactored (http://crbug.com/629721).
639 bool WebFrameWidgetImpl::SelectionTextDirection(WebTextDirection& start, 642 bool WebFrameWidgetImpl::SelectionTextDirection(WebTextDirection& start,
640 WebTextDirection& end) const { 643 WebTextDirection& end) const {
641 const LocalFrame* frame = FocusedLocalFrameInWidget(); 644 const LocalFrame* frame = FocusedLocalFrameInWidget();
642 if (!frame) 645 if (!frame)
643 return false; 646 return false;
644 647
648 FrameSelection& selection = frame->Selection();
649 if (!selection.IsAvailable())
650 return false;
651
645 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets 652 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets
646 // needs to be audited. See http://crbug.com/590369 for more details. 653 // needs to be audited. See http://crbug.com/590369 for more details.
647 frame->GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets(); 654 frame->GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets();
648 655
649 FrameSelection& selection = frame->Selection();
650 if (selection.ComputeVisibleSelectionInDOMTree() 656 if (selection.ComputeVisibleSelectionInDOMTree()
651 .ToNormalizedEphemeralRange() 657 .ToNormalizedEphemeralRange()
652 .IsNull()) 658 .IsNull())
653 return false; 659 return false;
654 start = ToWebTextDirection(PrimaryDirectionOf( 660 start = ToWebTextDirection(PrimaryDirectionOf(
655 *selection.ComputeVisibleSelectionInDOMTree().Start().AnchorNode())); 661 *selection.ComputeVisibleSelectionInDOMTree().Start().AnchorNode()));
656 end = ToWebTextDirection(PrimaryDirectionOf( 662 end = ToWebTextDirection(PrimaryDirectionOf(
657 *selection.ComputeVisibleSelectionInDOMTree().end().AnchorNode())); 663 *selection.ComputeVisibleSelectionInDOMTree().end().AnchorNode()));
658 return true; 664 return true;
659 } 665 }
660 666
661 // TODO(ekaramad):This method is almost duplicated in WebViewImpl as well. This 667 // TODO(ekaramad):This method is almost duplicated in WebViewImpl as well. This
662 // code needs to be refactored (http://crbug.com/629721). 668 // code needs to be refactored (http://crbug.com/629721).
663 bool WebFrameWidgetImpl::IsSelectionAnchorFirst() const { 669 bool WebFrameWidgetImpl::IsSelectionAnchorFirst() const {
664 if (const LocalFrame* frame = FocusedLocalFrameInWidget()) { 670 if (const LocalFrame* frame = FocusedLocalFrameInWidget()) {
665 return frame->Selection() 671 FrameSelection& selection = frame->Selection();
666 .ComputeVisibleSelectionInDOMTreeDeprecated() 672 return selection.IsAvailable() &&
667 .IsBaseFirst(); 673 selection.ComputeVisibleSelectionInDOMTreeDeprecated().IsBaseFirst();
668 } 674 }
669 return false; 675 return false;
670 } 676 }
671 677
672 // TODO(ekaramad):This method is almost duplicated in WebViewImpl as well. This 678 // TODO(ekaramad):This method is almost duplicated in WebViewImpl as well. This
673 // code needs to be refactored (http://crbug.com/629721). 679 // code needs to be refactored (http://crbug.com/629721).
674 WebRange WebFrameWidgetImpl::CaretOrSelectionRange() { 680 WebRange WebFrameWidgetImpl::CaretOrSelectionRange() {
675 LocalFrame* focused = FocusedLocalFrameInWidget(); 681 LocalFrame* focused = FocusedLocalFrameInWidget();
676 if (!focused) 682 if (!focused)
677 return WebRange(); 683 return WebRange();
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 : nullptr; 1201 : nullptr;
1196 } 1202 }
1197 1203
1198 LocalFrame* WebFrameWidgetImpl::FocusedLocalFrameAvailableForIme() const { 1204 LocalFrame* WebFrameWidgetImpl::FocusedLocalFrameAvailableForIme() const {
1199 if (!ime_accept_events_) 1205 if (!ime_accept_events_)
1200 return nullptr; 1206 return nullptr;
1201 return FocusedLocalFrameInWidget(); 1207 return FocusedLocalFrameInWidget();
1202 } 1208 }
1203 1209
1204 } // namespace blink 1210 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698