OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> | 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> |
3 * 1999 Lars Knoll <knoll@kde.org> | 3 * 1999 Lars Knoll <knoll@kde.org> |
4 * 1999 Antti Koivisto <koivisto@kde.org> | 4 * 1999 Antti Koivisto <koivisto@kde.org> |
5 * 2000 Simon Hausmann <hausmann@kde.org> | 5 * 2000 Simon Hausmann <hausmann@kde.org> |
6 * 2000 Stefan Schimanski <1Stein@gmx.de> | 6 * 2000 Stefan Schimanski <1Stein@gmx.de> |
7 * 2001 George Staikos <staikos@kde.org> | 7 * 2001 George Staikos <staikos@kde.org> |
8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. | 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> | 9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> |
10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 , m_selection(FrameSelection::create(this)) | 99 , m_selection(FrameSelection::create(this)) |
100 , m_eventHandler(adoptPtrWillBeNoop(new EventHandler(this))) | 100 , m_eventHandler(adoptPtrWillBeNoop(new EventHandler(this))) |
101 , m_console(FrameConsole::create(*this)) | 101 , m_console(FrameConsole::create(*this)) |
102 , m_inputMethodController(InputMethodController::create(*this)) | 102 , m_inputMethodController(InputMethodController::create(*this)) |
103 , m_pageZoomFactor(parentPageZoomFactor(this)) | 103 , m_pageZoomFactor(parentPageZoomFactor(this)) |
104 , m_textZoomFactor(parentTextZoomFactor(this)) | 104 , m_textZoomFactor(parentTextZoomFactor(this)) |
105 , m_inViewSourceMode(false) | 105 , m_inViewSourceMode(false) |
106 { | 106 { |
107 } | 107 } |
108 | 108 |
109 PassRefPtr<LocalFrame> LocalFrame::create(FrameLoaderClient* client, FrameHost* host, FrameOwner* owner) | 109 PassRefPtrWillBeRawPtr<LocalFrame> LocalFrame::create(FrameLoaderClient* client, FrameHost* host, FrameOwner* owner) |
110 { | 110 { |
111 RefPtr<LocalFrame> frame = adoptRef(new LocalFrame(client, host, owner)); | 111 RefPtrWillBeRawPtr<LocalFrame> frame = adoptRefWillBeNoop(new LocalFrame(cli ent, host, owner)); |
112 InspectorInstrumentation::frameAttachedToParent(frame.get()); | 112 InspectorInstrumentation::frameAttachedToParent(frame.get()); |
113 return frame.release(); | 113 return frame.release(); |
114 } | 114 } |
115 | 115 |
116 LocalFrame::~LocalFrame() | 116 LocalFrame::~LocalFrame() |
117 { | 117 { |
118 #if ENABLE(OILPAN) | |
119 // With Oilpan, the FrameView is detached. A more complete | |
120 // setView(nullptr) will touch other on-heap objects, which | |
121 // is not allowed. | |
122 detachView(); | |
123 m_view = nullptr; | |
124 loader().dispose(FrameLoader::DoNotDisposeFrameContents); | |
125 // Oilpan: see setDOMWindow() comment why it is acceptable | |
126 // not to mirror the non-Oilpan call below. | |
127 // | |
128 // Also, FrameDestructionObservers that live longer than this | |
129 // frame object keep weak references to the frame; those will | |
130 // be automatically cleared by the garbage collector. Hence, | |
131 // no need to trigger frameDestroyed() notifications. | |
132 #else | |
118 setView(nullptr); | 133 setView(nullptr); |
119 loader().clear(); | 134 loader().dispose(FrameLoader::DoDisposeFrameContents); |
120 setDOMWindow(nullptr); | 135 setDOMWindow(nullptr); |
121 | 136 |
122 // FIXME: What to do here... some of this is redundant with ~Frame. | 137 HashSet<RawPtr<FrameDestructionObserver> >::iterator stop = m_destructionObs ervers.end(); |
123 HashSet<FrameDestructionObserver*>::iterator stop = m_destructionObservers.e nd(); | 138 for (HashSet<RawPtr<FrameDestructionObserver> >::iterator it = m_destruction Observers.begin(); it != stop; ++it) |
124 for (HashSet<FrameDestructionObserver*>::iterator it = m_destructionObserver s.begin(); it != stop; ++it) | |
125 (*it)->frameDestroyed(); | 139 (*it)->frameDestroyed(); |
140 #endif | |
141 } | |
142 | |
143 void LocalFrame::trace(Visitor* visitor) | |
144 { | |
145 #if ENABLE(OILPAN) | |
146 visitor->trace(m_destructionObservers); | |
147 #endif | |
148 visitor->trace(m_loader); | |
149 visitor->trace(m_navigationScheduler); | |
150 visitor->trace(m_pagePopupOwner); | |
151 visitor->trace(m_editor); | |
152 visitor->trace(m_spellChecker); | |
153 visitor->trace(m_selection); | |
154 visitor->trace(m_eventHandler); | |
155 visitor->trace(m_console); | |
156 visitor->trace(m_inputMethodController); | |
157 Frame::trace(visitor); | |
158 WillBeHeapSupplementable<LocalFrame>::trace(visitor); | |
126 } | 159 } |
127 | 160 |
128 void LocalFrame::detach() | 161 void LocalFrame::detach() |
129 { | 162 { |
130 // A lot of the following steps can result in the current frame being | 163 // A lot of the following steps can result in the current frame being |
131 // detached, so protect a reference to it. | 164 // detached, so protect a reference to it. |
132 RefPtr<LocalFrame> protect(this); | 165 RefPtrWillBeRawPtr<LocalFrame> protect(this); |
133 m_loader.stopAllLoaders(); | 166 m_loader.stopAllLoaders(); |
134 m_loader.closeURL(); | 167 m_loader.closeURL(); |
135 detachChildren(); | 168 detachChildren(); |
136 // stopAllLoaders() needs to be called after detachChildren(), because detac hChildren() | 169 // stopAllLoaders() needs to be called after detachChildren(), because detac hChildren() |
137 // will trigger the unload event handlers of any child frames, and those eve nt | 170 // will trigger the unload event handlers of any child frames, and those eve nt |
138 // handlers might start a new subresource load in this frame. | 171 // handlers might start a new subresource load in this frame. |
139 m_loader.stopAllLoaders(); | 172 m_loader.stopAllLoaders(); |
140 m_loader.detachFromParent(); | 173 m_loader.detachFromParent(); |
141 } | 174 } |
142 | 175 |
143 bool LocalFrame::inScope(TreeScope* scope) const | 176 bool LocalFrame::inScope(TreeScope* scope) const |
144 { | 177 { |
145 ASSERT(scope); | 178 ASSERT(scope); |
146 Document* doc = document(); | 179 Document* doc = document(); |
147 if (!doc) | 180 if (!doc) |
148 return false; | 181 return false; |
149 // FIXME: This check is broken in for OOPI. | 182 // FIXME: This check is broken in for OOPI. |
150 HTMLFrameOwnerElement* owner = doc->ownerElement(); | 183 HTMLFrameOwnerElement* owner = doc->ownerElement(); |
151 if (!owner) | 184 if (!owner) |
152 return false; | 185 return false; |
153 return owner->treeScope() == scope; | 186 return owner->treeScope() == scope; |
154 } | 187 } |
155 | 188 |
189 void LocalFrame::detachView() | |
190 { | |
191 // We detach the FrameView's custom scroll bars as early as | |
192 // possible to prevent m_doc->detach() from messing with the view | |
193 // such that its scroll bars won't be torn down. | |
194 // | |
195 // FIXME: We should revisit this. | |
196 if (m_view) | |
197 m_view->prepareForDetach(); | |
198 } | |
199 | |
156 void LocalFrame::setView(PassRefPtr<FrameView> view) | 200 void LocalFrame::setView(PassRefPtr<FrameView> view) |
157 { | 201 { |
158 // We the custom scroll bars as early as possible to prevent m_doc->detach() | 202 if (!view) |
Mads Ager (chromium)
2014/09/16 12:17:45
Why this extra check compared to before?
sof
2014/09/17 09:42:58
It is not needed really, just pointlessly optimizi
| |
159 // from messing with the view such that its scroll bars won't be torn down. | 203 detachView(); |
160 // FIXME: We should revisit this. | |
161 if (m_view) | |
162 m_view->prepareForDetach(); | |
163 | 204 |
164 // Prepare for destruction now, so any unload event handlers get run and the LocalDOMWindow is | 205 // Prepare for destruction now, so any unload event handlers get run and the LocalDOMWindow is |
165 // notified. If we wait until the view is destroyed, then things won't be ho oked up enough for | 206 // notified. If we wait until the view is destroyed, then things won't be ho oked up enough for |
166 // these calls to work. | 207 // these calls to work. |
167 if (!view && document() && document()->isActive()) { | 208 if (!view && document() && document()->isActive()) { |
168 // FIXME: We don't call willRemove here. Why is that OK? | 209 // FIXME: We don't call willRemove here. Why is that OK? |
169 document()->prepareForDestruction(); | 210 document()->prepareForDestruction(); |
Mads Ager (chromium)
2014/09/16 12:17:45
Are we losing this with Oilpan on destruction beca
sof
2014/09/17 09:42:58
The issue of signalling document destruction is de
| |
170 } | 211 } |
171 | 212 |
172 eventHandler().clear(); | 213 eventHandler().clear(); |
173 | 214 |
174 m_view = view; | 215 m_view = view; |
175 | 216 |
176 if (m_view && isMainFrame()) { | 217 if (m_view && isMainFrame()) { |
177 if (settings()->pinchVirtualViewportEnabled()) | 218 if (settings()->pinchVirtualViewportEnabled()) |
178 m_host->pinchViewport().mainFrameDidChangeSize(); | 219 m_host->pinchViewport().mainFrameDidChangeSize(); |
179 else | 220 else |
(...skipping 12 matching lines...) Expand all Loading... | |
192 | 233 |
193 document()->styleResolverChanged(); | 234 document()->styleResolverChanged(); |
194 if (shouldUsePrintingLayout()) { | 235 if (shouldUsePrintingLayout()) { |
195 view()->forceLayoutForPagination(pageSize, originalPageSize, maximumShri nkRatio); | 236 view()->forceLayoutForPagination(pageSize, originalPageSize, maximumShri nkRatio); |
196 } else { | 237 } else { |
197 view()->forceLayout(); | 238 view()->forceLayout(); |
198 view()->adjustViewSize(); | 239 view()->adjustViewSize(); |
199 } | 240 } |
200 | 241 |
201 // Subframes of the one we're printing don't lay out to the page size. | 242 // Subframes of the one we're printing don't lay out to the page size. |
202 for (RefPtr<Frame> child = tree().firstChild(); child; child = child->tree() .nextSibling()) { | 243 for (RefPtrWillBeRawPtr<Frame> child = tree().firstChild(); child; child = c hild->tree().nextSibling()) { |
203 if (child->isLocalFrame()) | 244 if (child->isLocalFrame()) |
204 toLocalFrame(child.get())->setPrinting(printing, FloatSize(), FloatS ize(), 0); | 245 toLocalFrame(child.get())->setPrinting(printing, FloatSize(), FloatS ize(), 0); |
205 } | 246 } |
206 } | 247 } |
207 | 248 |
208 bool LocalFrame::shouldUsePrintingLayout() const | 249 bool LocalFrame::shouldUsePrintingLayout() const |
209 { | 250 { |
210 // Only top frame being printed should be fit to page size. | 251 // Only top frame being printed should be fit to page size. |
211 // Subframes should be constrained by parents only. | 252 // Subframes should be constrained by parents only. |
212 return document()->printing() && (!tree().parent() || !tree().parent()->isLo calFrame() || !toLocalFrame(tree().parent())->document()->printing()); | 253 return document()->printing() && (!tree().parent() || !tree().parent()->isLo calFrame() || !toLocalFrame(tree().parent())->document()->printing()); |
(...skipping 15 matching lines...) Expand all Loading... | |
228 float ratio = originalSize.width() / originalSize.height(); | 269 float ratio = originalSize.width() / originalSize.height(); |
229 resultSize.setHeight(floorf(expectedSize.height())); | 270 resultSize.setHeight(floorf(expectedSize.height())); |
230 resultSize.setWidth(floorf(resultSize.height() * ratio)); | 271 resultSize.setWidth(floorf(resultSize.height() * ratio)); |
231 } | 272 } |
232 return resultSize; | 273 return resultSize; |
233 } | 274 } |
234 | 275 |
235 void LocalFrame::setDOMWindow(PassRefPtrWillBeRawPtr<LocalDOMWindow> domWindow) | 276 void LocalFrame::setDOMWindow(PassRefPtrWillBeRawPtr<LocalDOMWindow> domWindow) |
236 { | 277 { |
237 if (m_domWindow) { | 278 if (m_domWindow) { |
279 // Oilpan: the assumption is that FrameDestructionObserver::willDetachFr ameHost() | |
280 // on LocalWindow will have signalled these frameWindowDiscarded() notif ications. | |
281 // | |
282 // It is not invoked when finalizing the LocalFrame, as setDOMWindow() i sn't | |
283 // performed (accessing the m_domWindow heap object is unsafe then.) | |
238 console().messageStorage()->frameWindowDiscarded(m_domWindow.get()); | 284 console().messageStorage()->frameWindowDiscarded(m_domWindow.get()); |
239 InspectorInstrumentation::frameWindowDiscarded(this, m_domWindow.get()); | 285 InspectorInstrumentation::frameWindowDiscarded(this, m_domWindow.get()); |
240 } | 286 } |
241 if (domWindow) | 287 if (domWindow) |
242 script().clearWindowProxy(); | 288 script().clearWindowProxy(); |
243 Frame::setDOMWindow(domWindow); | 289 Frame::setDOMWindow(domWindow); |
244 } | 290 } |
245 | 291 |
246 void LocalFrame::didChangeVisibilityState() | 292 void LocalFrame::didChangeVisibilityState() |
247 { | 293 { |
248 if (document()) | 294 if (document()) |
249 document()->didChangeVisibilityState(); | 295 document()->didChangeVisibilityState(); |
250 | 296 |
251 Vector<RefPtr<LocalFrame> > childFrames; | 297 WillBeHeapVector<RefPtrWillBeMember<LocalFrame> > childFrames; |
252 for (Frame* child = tree().firstChild(); child; child = child->tree().nextSi bling()) { | 298 for (Frame* child = tree().firstChild(); child; child = child->tree().nextSi bling()) { |
253 if (child->isLocalFrame()) | 299 if (child->isLocalFrame()) |
254 childFrames.append(toLocalFrame(child)); | 300 childFrames.append(toLocalFrame(child)); |
255 } | 301 } |
256 | 302 |
257 for (size_t i = 0; i < childFrames.size(); ++i) | 303 for (size_t i = 0; i < childFrames.size(); ++i) |
258 childFrames[i]->didChangeVisibilityState(); | 304 childFrames[i]->didChangeVisibilityState(); |
259 } | 305 } |
260 | 306 |
261 void LocalFrame::addDestructionObserver(FrameDestructionObserver* observer) | 307 void LocalFrame::addDestructionObserver(FrameDestructionObserver* observer) |
262 { | 308 { |
263 m_destructionObservers.add(observer); | 309 m_destructionObservers.add(observer); |
264 } | 310 } |
265 | 311 |
266 void LocalFrame::removeDestructionObserver(FrameDestructionObserver* observer) | 312 void LocalFrame::removeDestructionObserver(FrameDestructionObserver* observer) |
267 { | 313 { |
268 m_destructionObservers.remove(observer); | 314 m_destructionObservers.remove(observer); |
269 } | 315 } |
270 | 316 |
271 void LocalFrame::willDetachFrameHost() | 317 void LocalFrame::willDetachFrameHost() |
272 { | 318 { |
273 // We should never be detatching the page during a Layout. | 319 // We should never be detatching the page during a Layout. |
274 RELEASE_ASSERT(!m_view || !m_view->isInPerformLayout()); | 320 RELEASE_ASSERT(!m_view || !m_view->isInPerformLayout()); |
275 | 321 |
276 Frame* parent = tree().parent(); | 322 Frame* parent = tree().parent(); |
277 if (parent && parent->isLocalFrame()) | 323 if (parent && parent->isLocalFrame()) |
278 toLocalFrame(parent)->loader().checkLoadComplete(); | 324 toLocalFrame(parent)->loader().checkLoadComplete(); |
279 | 325 |
280 HashSet<FrameDestructionObserver*>::iterator stop = m_destructionObservers.e nd(); | 326 WillBeHeapHashSet<RawPtrWillBeWeakMember<FrameDestructionObserver> >::iterat or stop = m_destructionObservers.end(); |
281 for (HashSet<FrameDestructionObserver*>::iterator it = m_destructionObserver s.begin(); it != stop; ++it) | 327 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<FrameDestructionObserver> >::i terator it = m_destructionObservers.begin(); it != stop; ++it) |
282 (*it)->willDetachFrameHost(); | 328 (*it)->willDetachFrameHost(); |
283 | 329 |
284 // FIXME: Page should take care of updating focus/scrolling instead of Frame . | 330 // FIXME: Page should take care of updating focus/scrolling instead of Frame . |
285 // FIXME: It's unclear as to why this is called more than once, but it is, | 331 // FIXME: It's unclear as to why this is called more than once, but it is, |
286 // so page() could be null. | 332 // so page() could be null. |
287 if (page() && page()->focusController().focusedFrame() == this) | 333 if (page() && page()->focusController().focusedFrame() == this) |
288 page()->focusController().setFocusedFrame(nullptr); | 334 page()->focusController().setFocusedFrame(nullptr); |
289 script().clearScriptObjects(); | 335 script().clearScriptObjects(); |
290 | 336 |
291 if (page() && page()->scrollingCoordinator() && m_view) | 337 if (page() && page()->scrollingCoordinator() && m_view) |
292 page()->scrollingCoordinator()->willDestroyScrollableArea(m_view.get()); | 338 page()->scrollingCoordinator()->willDestroyScrollableArea(m_view.get()); |
293 } | 339 } |
294 | 340 |
295 void LocalFrame::detachFromFrameHost() | 341 void LocalFrame::detachFromFrameHost() |
296 { | 342 { |
297 // We should never be detatching the page during a Layout. | 343 // We should never be detaching the page during a Layout. |
298 RELEASE_ASSERT(!m_view || !m_view->isInPerformLayout()); | 344 RELEASE_ASSERT(!m_view || !m_view->isInPerformLayout()); |
299 m_host = 0; | 345 m_host = nullptr; |
300 } | 346 } |
301 | 347 |
302 String LocalFrame::documentTypeString() const | 348 String LocalFrame::documentTypeString() const |
303 { | 349 { |
304 if (DocumentType* doctype = document()->doctype()) | 350 if (DocumentType* doctype = document()->doctype()) |
305 return createMarkup(doctype); | 351 return createMarkup(doctype); |
306 | 352 |
307 return String(); | 353 return String(); |
308 } | 354 } |
309 | 355 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
506 // Update the scroll position when doing a full page zoom, so the co ntent stays in relatively the same position. | 552 // Update the scroll position when doing a full page zoom, so the co ntent stays in relatively the same position. |
507 LayoutPoint scrollPosition = view->scrollPosition(); | 553 LayoutPoint scrollPosition = view->scrollPosition(); |
508 float percentDifference = (pageZoomFactor / m_pageZoomFactor); | 554 float percentDifference = (pageZoomFactor / m_pageZoomFactor); |
509 view->setScrollPosition(IntPoint(scrollPosition.x() * percentDiffere nce, scrollPosition.y() * percentDifference)); | 555 view->setScrollPosition(IntPoint(scrollPosition.x() * percentDiffere nce, scrollPosition.y() * percentDifference)); |
510 } | 556 } |
511 } | 557 } |
512 | 558 |
513 m_pageZoomFactor = pageZoomFactor; | 559 m_pageZoomFactor = pageZoomFactor; |
514 m_textZoomFactor = textZoomFactor; | 560 m_textZoomFactor = textZoomFactor; |
515 | 561 |
516 for (RefPtr<Frame> child = tree().firstChild(); child; child = child->tree() .nextSibling()) { | 562 for (RefPtrWillBeRawPtr<Frame> child = tree().firstChild(); child; child = c hild->tree().nextSibling()) { |
517 if (child->isLocalFrame()) | 563 if (child->isLocalFrame()) |
518 toLocalFrame(child.get())->setPageAndTextZoomFactors(m_pageZoomFacto r, m_textZoomFactor); | 564 toLocalFrame(child.get())->setPageAndTextZoomFactors(m_pageZoomFacto r, m_textZoomFactor); |
519 } | 565 } |
520 | 566 |
521 document->setNeedsStyleRecalc(SubtreeStyleChange); | 567 document->setNeedsStyleRecalc(SubtreeStyleChange); |
522 document->updateLayoutIgnorePendingStylesheets(); | 568 document->updateLayoutIgnorePendingStylesheets(); |
523 } | 569 } |
524 | 570 |
525 void LocalFrame::deviceOrPageScaleFactorChanged() | 571 void LocalFrame::deviceOrPageScaleFactorChanged() |
526 { | 572 { |
527 document()->mediaQueryAffectingValueChanged(); | 573 document()->mediaQueryAffectingValueChanged(); |
528 for (RefPtr<Frame> child = tree().firstChild(); child; child = child->tree() .nextSibling()) { | 574 for (RefPtrWillBeRawPtr<Frame> child = tree().firstChild(); child; child = c hild->tree().nextSibling()) { |
529 if (child->isLocalFrame()) | 575 if (child->isLocalFrame()) |
530 toLocalFrame(child.get())->deviceOrPageScaleFactorChanged(); | 576 toLocalFrame(child.get())->deviceOrPageScaleFactorChanged(); |
531 } | 577 } |
532 } | 578 } |
533 | 579 |
534 bool LocalFrame::isURLAllowed(const KURL& url) const | 580 bool LocalFrame::isURLAllowed(const KURL& url) const |
535 { | 581 { |
536 // We allow one level of self-reference because some sites depend on that, | 582 // We allow one level of self-reference because some sites depend on that, |
537 // but we don't allow more than one. | 583 // but we don't allow more than one. |
538 if (page()->subframeCount() >= Page::maxNumberOfFrames) | 584 if (page()->subframeCount() >= Page::maxNumberOfFrames) |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
679 | 725 |
680 return curFrame; | 726 return curFrame; |
681 } | 727 } |
682 | 728 |
683 void LocalFrame::setPagePopupOwner(Element& owner) | 729 void LocalFrame::setPagePopupOwner(Element& owner) |
684 { | 730 { |
685 m_pagePopupOwner = &owner; | 731 m_pagePopupOwner = &owner; |
686 } | 732 } |
687 | 733 |
688 } // namespace blink | 734 } // namespace blink |
OLD | NEW |