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

Side by Side Diff: Source/core/frame/Frame.cpp

Issue 183713002: Add Frame and RemoteFrame classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removed unneeded method definition Created 6 years, 9 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 | « Source/core/frame/Frame.h ('k') | Source/core/frame/LocalFrame.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Simon Hausmann <hausmann@kde.org>
6 * 2000 Stefan Schimanski <1Stein@gmx.de>
7 * 2001 George Staikos <staikos@kde.org>
8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com>
10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
11 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
12 * Copyright (C) 2008 Google Inc.
13 *
14 * This library is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Library General Public
16 * License as published by the Free Software Foundation; either
17 * version 2 of the License, or (at your option) any later version.
18 *
19 * This library is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * Library General Public License for more details.
23 *
24 * You should have received a copy of the GNU Library General Public License
25 * along with this library; see the file COPYING.LIB. If not, write to
26 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
27 * Boston, MA 02110-1301, USA.
28 */
29
30 #include "config.h"
31 #include "core/frame/Frame.h"
32
33 #include "core/dom/DocumentType.h"
34 #include "core/events/Event.h"
35 #include "core/frame/DOMWindow.h"
36 #include "core/frame/FrameDestructionObserver.h"
37 #include "core/frame/FrameHost.h"
38 #include "core/frame/Settings.h"
39 #include "core/html/HTMLFrameElementBase.h"
40 #include "core/inspector/InspectorInstrumentation.h"
41 #include "core/loader/EmptyClients.h"
42 #include "core/loader/FrameLoaderClient.h"
43 #include "core/page/Chrome.h"
44 #include "core/page/ChromeClient.h"
45 #include "core/page/EventHandler.h"
46 #include "core/page/FocusController.h"
47 #include "core/page/Page.h"
48 #include "core/rendering/RenderView.h"
49 #include "public/platform/WebLayer.h"
50 #include "wtf/PassOwnPtr.h"
51 #include "wtf/RefCountedLeakCounter.h"
52
53 namespace WebCore {
54
55 using namespace HTMLNames;
56
57 namespace {
58
59 int64_t generateFrameID()
60 {
61 // Initialize to the current time to reduce the likelihood of generating
62 // identifiers that overlap with those from past/future browser sessions.
63 static int64_t next = static_cast<int64_t>(currentTime() * 1000000.0);
64 return ++next;
65 }
66
67 } // namespace
68
69 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, frameCounter, ("Frame"));
70
71 Frame::Frame(PassRefPtr<FrameInit> frameInit)
72 : m_frameInit(frameInit)
73 , m_host(m_frameInit->frameHost())
74 , m_frameID(generateFrameID())
75 , m_remotePlatformLayer(0)
76 {
77 ASSERT(page());
78
79 #ifndef NDEBUG
80 frameCounter.increment();
81 #endif
82 }
83
84 Frame::~Frame()
85 {
86 setDOMWindow(nullptr);
87
88 // FIXME: We should not be doing all this work inside the destructor
89
90 #ifndef NDEBUG
91 frameCounter.decrement();
92 #endif
93
94 HashSet<FrameDestructionObserver*>::iterator stop = m_destructionObservers.e nd();
95 for (HashSet<FrameDestructionObserver*>::iterator it = m_destructionObserver s.begin(); it != stop; ++it)
96 (*it)->frameDestroyed();
97 }
98
99 void Frame::addDestructionObserver(FrameDestructionObserver* observer)
100 {
101 m_destructionObservers.add(observer);
102 }
103
104 void Frame::removeDestructionObserver(FrameDestructionObserver* observer)
105 {
106 m_destructionObservers.remove(observer);
107 }
108
109 FrameHost* Frame::host() const
110 {
111 return m_host;
112 }
113
114 Page* Frame::page() const
115 {
116 if (m_host)
117 return &m_host->page();
118 return 0;
119 }
120
121 Settings* Frame::settings() const
122 {
123 if (m_host)
124 return &m_host->settings();
125 return 0;
126 }
127
128 void Frame::setDOMWindow(PassRefPtr<DOMWindow> domWindow)
129 {
130 if (m_domWindow)
131 m_domWindow->reset();
132 m_domWindow = domWindow;
133 }
134
135 static ChromeClient& emptyChromeClient()
136 {
137 DEFINE_STATIC_LOCAL(EmptyChromeClient, client, ());
138 return client;
139 }
140
141 ChromeClient& Frame::chromeClient() const
142 {
143 if (Page* page = this->page())
144 return page->chrome().client();
145 return emptyChromeClient();
146 }
147
148 Document* Frame::document() const
149 {
150 return m_domWindow ? m_domWindow->document() : 0;
151 }
152
153 RenderView* Frame::contentRenderer() const
154 {
155 return document() ? document()->renderView() : 0;
156 }
157
158 void Frame::willDetachFrameHost()
159 {
160 HashSet<FrameDestructionObserver*>::iterator stop = m_destructionObservers.e nd();
161 for (HashSet<FrameDestructionObserver*>::iterator it = m_destructionObserver s.begin(); it != stop; ++it)
162 (*it)->willDetachFrameHost();
163
164 // FIXME: Page should take care of updating focus/scrolling instead of Frame .
165 // FIXME: It's unclear as to why this is called more than once, but it is,
166 // so page() could be null.
167 if (page() && page()->focusController().focusedFrame() == this)
168 page()->focusController().setFocusedFrame(nullptr);
169 }
170
171 void Frame::detachFromFrameHost()
172 {
173 m_host = 0;
174 }
175
176 bool Frame::isMainFrame() const
177 {
178 Page* page = this->page();
179 return page && this == page->mainFrame();
180 }
181
182 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/frame/Frame.h ('k') | Source/core/frame/LocalFrame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698