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

Side by Side Diff: sky/engine/core/page/Page.cpp

Issue 746713002: Move InspectorBackendMojo out of the blink namespace (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 R ights Reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All R ights Reserved.
3 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 3 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "core/rendering/RenderView.h" 42 #include "core/rendering/RenderView.h"
43 #include "wtf/HashMap.h" 43 #include "wtf/HashMap.h"
44 #include "wtf/RefCountedLeakCounter.h" 44 #include "wtf/RefCountedLeakCounter.h"
45 #include "wtf/StdLibExtras.h" 45 #include "wtf/StdLibExtras.h"
46 #include "wtf/text/Base64.h" 46 #include "wtf/text/Base64.h"
47 47
48 namespace blink { 48 namespace blink {
49 49
50 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, pageCounter, ("Page")); 50 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, pageCounter, ("Page"));
51 51
52 // static
53 HashSet<Page*>& Page::allPages()
54 {
55 DEFINE_STATIC_LOCAL(HashSet<Page*>, allPages, ());
56 return allPages;
57 }
58
59 // static
60 HashSet<Page*>& Page::ordinaryPages()
61 {
62 DEFINE_STATIC_LOCAL(HashSet<Page*>, ordinaryPages, ());
63 return ordinaryPages;
64 }
65
66
67 void Page::networkStateChanged(bool online)
68 {
69 Vector<RefPtr<LocalFrame> > frames;
70
71 // Get all the frames of all the pages in all the page groups
72 HashSet<Page*>::iterator end = allPages().end();
73 for (HashSet<Page*>::iterator it = allPages().begin(); it != end; ++it) {
74 LocalFrame* frame = (*it)->mainFrame();
75 frames.append(frame);
76 }
77
78 AtomicString eventName = online ? EventTypeNames::online : EventTypeNames::o ffline;
79 for (unsigned i = 0; i < frames.size(); i++)
80 frames[i]->domWindow()->dispatchEvent(Event::create(eventName));
81 }
82
83 float deviceScaleFactor(LocalFrame* frame) 52 float deviceScaleFactor(LocalFrame* frame)
84 { 53 {
85 if (!frame) 54 if (!frame)
86 return 1; 55 return 1;
87 Page* page = frame->page(); 56 Page* page = frame->page();
88 if (!page) 57 if (!page)
89 return 1; 58 return 1;
90 return page->deviceScaleFactor(); 59 return page->deviceScaleFactor();
91 } 60 }
92 61
(...skipping 10 matching lines...) Expand all
103 , m_spellCheckerClient(pageClients.spellCheckerClient) 72 , m_spellCheckerClient(pageClients.spellCheckerClient)
104 , m_tabKeyCyclesThroughElements(true) 73 , m_tabKeyCyclesThroughElements(true)
105 , m_deviceScaleFactor(1) 74 , m_deviceScaleFactor(1)
106 , m_timerAlignmentInterval(DOMTimer::visiblePageAlignmentInterval()) 75 , m_timerAlignmentInterval(DOMTimer::visiblePageAlignmentInterval())
107 , m_visibilityState(PageVisibilityStateVisible) 76 , m_visibilityState(PageVisibilityStateVisible)
108 , m_isCursorVisible(true) 77 , m_isCursorVisible(true)
109 #if ENABLE(ASSERT) 78 #if ENABLE(ASSERT)
110 , m_isPainting(false) 79 , m_isPainting(false)
111 #endif 80 #endif
112 , m_frameHost(FrameHost::create(*this, services)) 81 , m_frameHost(FrameHost::create(*this, services))
82 , m_inspectorHost(0)
113 { 83 {
114 ASSERT(m_editorClient); 84 ASSERT(m_editorClient);
115 85
116 ASSERT(!allPages().contains(this));
117 allPages().add(this);
118
119 #ifndef NDEBUG 86 #ifndef NDEBUG
120 pageCounter.increment(); 87 pageCounter.increment();
121 #endif 88 #endif
122 } 89 }
123 90
124 Page::~Page() 91 Page::~Page()
125 { 92 {
126 // willBeDestroyed() must be called before Page destruction. 93 // willBeDestroyed() must be called before Page destruction.
127 ASSERT(!m_mainFrame); 94 ASSERT(!m_mainFrame);
128 } 95 }
129 96
130 void Page::makeOrdinary()
131 {
132 ASSERT(!ordinaryPages().contains(this));
133 ordinaryPages().add(this);
134 }
135
136 void Page::setMainFrame(LocalFrame* mainFrame) 97 void Page::setMainFrame(LocalFrame* mainFrame)
137 { 98 {
138 // Should only be called during initialization or swaps between local and 99 // Should only be called during initialization or swaps between local and
139 // remote frames. 100 // remote frames.
140 // FIXME: Unfortunately we can't assert on this at the moment, because this 101 // FIXME: Unfortunately we can't assert on this at the moment, because this
141 // is called in the base constructor for both LocalFrame and RemoteFrame, 102 // is called in the base constructor for both LocalFrame and RemoteFrame,
142 // when the vtables for the derived classes have not yet been setup. 103 // when the vtables for the derived classes have not yet been setup.
143 m_mainFrame = mainFrame; 104 m_mainFrame = mainFrame;
144 } 105 }
145 106
146 void Page::documentDetached(Document* document) 107 void Page::documentDetached(Document* document)
147 { 108 {
148 m_multisamplingChangedObservers.clear(); 109 m_multisamplingChangedObservers.clear();
149 } 110 }
150 111
151 bool Page::openedByDOM() const 112 bool Page::openedByDOM() const
152 { 113 {
153 return m_openedByDOM; 114 return m_openedByDOM;
154 } 115 }
155 116
156 void Page::setOpenedByDOM() 117 void Page::setOpenedByDOM()
157 { 118 {
158 m_openedByDOM = true; 119 m_openedByDOM = true;
159 } 120 }
160 121
161 void Page::scheduleForcedStyleRecalcForAllPages()
162 {
163 HashSet<Page*>::iterator end = allPages().end();
164 for (HashSet<Page*>::iterator it = allPages().begin(); it != end; ++it) {
165 LocalFrame* frame = (*it)->mainFrame();
166 frame->document()->setNeedsStyleRecalc(SubtreeStyleChange);
167 }
168 }
169
170 void Page::setNeedsRecalcStyleInAllFrames() 122 void Page::setNeedsRecalcStyleInAllFrames()
171 { 123 {
172 LocalFrame* frame = mainFrame(); 124 LocalFrame* frame = mainFrame();
173 if (frame && frame->document()) 125 if (frame && frame->document())
174 frame->document()->styleResolverChanged(); 126 frame->document()->styleResolverChanged();
175 } 127 }
176 128
177 void Page::setNeedsLayoutInAllFrames() 129 void Page::setNeedsLayoutInAllFrames()
178 { 130 {
179 LocalFrame* frame = mainFrame(); 131 LocalFrame* frame = mainFrame();
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 return PageLifecycleNotifier::create(this); 279 return PageLifecycleNotifier::create(this);
328 } 280 }
329 281
330 void Page::willBeDestroyed() 282 void Page::willBeDestroyed()
331 { 283 {
332 RefPtr<LocalFrame> mainFrame = m_mainFrame; 284 RefPtr<LocalFrame> mainFrame = m_mainFrame;
333 285
334 mainFrame->detach(); 286 mainFrame->detach();
335 mainFrame->setView(nullptr); 287 mainFrame->setView(nullptr);
336 288
337 allPages().remove(this);
338 if (ordinaryPages().contains(this))
339 ordinaryPages().remove(this);
340
341 #ifndef NDEBUG 289 #ifndef NDEBUG
342 pageCounter.decrement(); 290 pageCounter.decrement();
343 #endif 291 #endif
344 292
345 m_chrome->willBeDestroyed(); 293 m_chrome->willBeDestroyed();
346 m_mainFrame = 0; 294 m_mainFrame = 0;
347 } 295 }
348 296
349 Page::PageClients::PageClients() 297 Page::PageClients::PageClients()
350 : chromeClient(0) 298 : chromeClient(0)
351 , editorClient(0) 299 , editorClient(0)
352 , spellCheckerClient(0) 300 , spellCheckerClient(0)
353 { 301 {
354 } 302 }
355 303
356 Page::PageClients::~PageClients() 304 Page::PageClients::~PageClients()
357 { 305 {
358 } 306 }
359 307
360 } // namespace blink 308 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698