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

Side by Side Diff: third_party/WebKit/Source/core/page/Page.cpp

Issue 2873503002: NOT YET READY: Improve granularity of window namespaces in Blink.
Patch Set: Rebasing... 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All
3 * Rights Reserved. 3 * Rights Reserved.
4 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. 4 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved.
5 * (http://www.torchmobile.com/) 5 * (http://www.torchmobile.com/)
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 static Page::PageSet& AllPages() { 71 static Page::PageSet& AllPages() {
72 DEFINE_STATIC_LOCAL(Page::PageSet, pages, ()); 72 DEFINE_STATIC_LOCAL(Page::PageSet, pages, ());
73 return pages; 73 return pages;
74 } 74 }
75 75
76 Page::PageSet& Page::OrdinaryPages() { 76 Page::PageSet& Page::OrdinaryPages() {
77 DEFINE_STATIC_LOCAL(Page::PageSet, pages, ()); 77 DEFINE_STATIC_LOCAL(Page::PageSet, pages, ());
78 return pages; 78 return pages;
79 } 79 }
80 80
81 HeapVector<Member<Page>> Page::RelatedPages() {
82 HeapVector<Member<Page>> result;
83 Page* ptr = this->next_related_page_;
84 while (ptr != this) {
85 result.push_back(ptr);
86 ptr = ptr->next_related_page_;
87 }
88 return result;
89 }
90
81 float DeviceScaleFactorDeprecated(LocalFrame* frame) { 91 float DeviceScaleFactorDeprecated(LocalFrame* frame) {
82 if (!frame) 92 if (!frame)
83 return 1; 93 return 1;
84 Page* page = frame->GetPage(); 94 Page* page = frame->GetPage();
85 if (!page) 95 if (!page)
86 return 1; 96 return 1;
87 return page->DeviceScaleFactorDeprecated(); 97 return page->DeviceScaleFactorDeprecated();
88 } 98 }
89 99
90 Page* Page::CreateOrdinary(PageClients& page_clients) { 100 Page* Page::CreateOrdinary(PageClients& page_clients, Page* opener) {
91 Page* page = Create(page_clients); 101 Page* page = Create(page_clients);
102
103 if (opener) {
104 // Before: ... -> opener -> next -> ...
105 // After: ... -> opener -> page -> next -> ...
106 Page* next = opener->next_related_page_;
107 opener->next_related_page_ = page;
108 page->prev_related_page_ = opener;
109 page->next_related_page_ = next;
110 next->prev_related_page_ = page;
111 }
112
92 OrdinaryPages().insert(page); 113 OrdinaryPages().insert(page);
93 if (ScopedPageSuspender::IsActive()) 114 if (ScopedPageSuspender::IsActive())
94 page->SetSuspended(true); 115 page->SetSuspended(true);
95 return page; 116 return page;
96 } 117 }
97 118
98 Page::Page(PageClients& page_clients) 119 Page::Page(PageClients& page_clients)
99 : SettingsDelegate(Settings::Create()), 120 : SettingsDelegate(Settings::Create()),
100 animator_(PageAnimator::Create(*this)), 121 animator_(PageAnimator::Create(*this)),
101 autoscroll_controller_(AutoscrollController::Create(*this)), 122 autoscroll_controller_(AutoscrollController::Create(*this)),
(...skipping 21 matching lines...) Expand all
123 use_counter_(page_clients.chrome_client && 144 use_counter_(page_clients.chrome_client &&
124 page_clients.chrome_client->IsSVGImageChromeClient() 145 page_clients.chrome_client->IsSVGImageChromeClient()
125 ? UseCounter::kSVGImageContext 146 ? UseCounter::kSVGImageContext
126 : UseCounter::kDefaultContext), 147 : UseCounter::kDefaultContext),
127 opened_by_dom_(false), 148 opened_by_dom_(false),
128 tab_key_cycles_through_elements_(true), 149 tab_key_cycles_through_elements_(true),
129 suspended_(false), 150 suspended_(false),
130 device_scale_factor_(1), 151 device_scale_factor_(1),
131 visibility_state_(kPageVisibilityStateVisible), 152 visibility_state_(kPageVisibilityStateVisible),
132 is_cursor_visible_(true), 153 is_cursor_visible_(true),
133 subframe_count_(0) { 154 subframe_count_(0),
155 next_related_page_(this),
156 prev_related_page_(this) {
134 DCHECK(editor_client_); 157 DCHECK(editor_client_);
135 158
136 DCHECK(!AllPages().Contains(this)); 159 DCHECK(!AllPages().Contains(this));
137 AllPages().insert(this); 160 AllPages().insert(this);
138 } 161 }
139 162
140 Page::~Page() { 163 Page::~Page() {
141 // willBeDestroyed() must be called before Page destruction. 164 // willBeDestroyed() must be called before Page destruction.
142 DCHECK(!main_frame_); 165 DCHECK(!main_frame_);
143 } 166 }
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 visitor->Trace(browser_controls_); 655 visitor->Trace(browser_controls_);
633 visitor->Trace(console_message_storage_); 656 visitor->Trace(console_message_storage_);
634 visitor->Trace(event_handler_registry_); 657 visitor->Trace(event_handler_registry_);
635 visitor->Trace(global_root_scroller_controller_); 658 visitor->Trace(global_root_scroller_controller_);
636 visitor->Trace(visual_viewport_); 659 visitor->Trace(visual_viewport_);
637 visitor->Trace(overscroll_controller_); 660 visitor->Trace(overscroll_controller_);
638 visitor->Trace(main_frame_); 661 visitor->Trace(main_frame_);
639 visitor->Trace(plugin_data_); 662 visitor->Trace(plugin_data_);
640 visitor->Trace(validation_message_client_); 663 visitor->Trace(validation_message_client_);
641 visitor->Trace(use_counter_); 664 visitor->Trace(use_counter_);
665 visitor->Trace(next_related_page_);
666 visitor->Trace(prev_related_page_);
642 Supplementable<Page>::Trace(visitor); 667 Supplementable<Page>::Trace(visitor);
643 PageVisibilityNotifier::Trace(visitor); 668 PageVisibilityNotifier::Trace(visitor);
644 } 669 }
645 670
646 void Page::LayerTreeViewInitialized(WebLayerTreeView& layer_tree_view, 671 void Page::LayerTreeViewInitialized(WebLayerTreeView& layer_tree_view,
647 LocalFrameView* view) { 672 LocalFrameView* view) {
648 if (GetScrollingCoordinator()) 673 if (GetScrollingCoordinator())
649 GetScrollingCoordinator()->LayerTreeViewInitialized(layer_tree_view, view); 674 GetScrollingCoordinator()->LayerTreeViewInitialized(layer_tree_view, view);
650 } 675 }
651 676
652 void Page::WillCloseLayerTreeView(WebLayerTreeView& layer_tree_view, 677 void Page::WillCloseLayerTreeView(WebLayerTreeView& layer_tree_view,
653 LocalFrameView* view) { 678 LocalFrameView* view) {
654 if (scrolling_coordinator_) 679 if (scrolling_coordinator_)
655 scrolling_coordinator_->WillCloseLayerTreeView(layer_tree_view, view); 680 scrolling_coordinator_->WillCloseLayerTreeView(layer_tree_view, view);
656 } 681 }
657 682
658 void Page::WillBeDestroyed() { 683 void Page::WillBeDestroyed() {
659 Frame* main_frame = main_frame_; 684 Frame* main_frame = main_frame_;
660 685
661 // TODO(sashab): Remove this check, the call to detach() here should always 686 // TODO(sashab): Remove this check, the call to detach() here should always
662 // work. 687 // work.
663 if (main_frame->IsAttached()) 688 if (main_frame->IsAttached())
664 main_frame->Detach(FrameDetachType::kRemove); 689 main_frame->Detach(FrameDetachType::kRemove);
665 690
666 DCHECK(AllPages().Contains(this)); 691 DCHECK(AllPages().Contains(this));
667 AllPages().erase(this); 692 AllPages().erase(this);
668 OrdinaryPages().erase(this); 693 OrdinaryPages().erase(this);
669 694
695 {
696 // Before: ... -> prev -> this -> next -> ...
697 // After: ... -> prev -> next -> ...
698 // (this is ok even if |this| is the only element on the list).
699 Page* prev = this->prev_related_page_;
700 Page* next = this->next_related_page_;
701 next->prev_related_page_ = prev;
702 prev->next_related_page_ = next;
703 this->prev_related_page_ = nullptr;
704 this->next_related_page_ = nullptr;
705 }
706
670 if (scrolling_coordinator_) 707 if (scrolling_coordinator_)
671 scrolling_coordinator_->WillBeDestroyed(); 708 scrolling_coordinator_->WillBeDestroyed();
672 709
673 GetChromeClient().ChromeDestroyed(); 710 GetChromeClient().ChromeDestroyed();
674 if (validation_message_client_) 711 if (validation_message_client_)
675 validation_message_client_->WillBeDestroyed(); 712 validation_message_client_->WillBeDestroyed();
676 main_frame_ = nullptr; 713 main_frame_ = nullptr;
677 714
678 PageVisibilityNotifier::NotifyContextDestroyed(); 715 PageVisibilityNotifier::NotifyContextDestroyed();
679 } 716 }
680 717
681 Page::PageClients::PageClients() 718 Page::PageClients::PageClients()
682 : chrome_client(nullptr), 719 : chrome_client(nullptr),
683 context_menu_client(nullptr), 720 context_menu_client(nullptr),
684 editor_client(nullptr), 721 editor_client(nullptr),
685 spell_checker_client(nullptr) {} 722 spell_checker_client(nullptr) {}
686 723
687 Page::PageClients::~PageClients() {} 724 Page::PageClients::~PageClients() {}
688 725
689 template class CORE_TEMPLATE_EXPORT Supplement<Page>; 726 template class CORE_TEMPLATE_EXPORT Supplement<Page>;
690 727
691 } // namespace blink 728 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/page/Page.h ('k') | third_party/WebKit/Source/web/LocalFrameClientImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698