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 dispose(); | |
haraken
2014/09/08 07:25:58
It looks unsafe to call dispose() methods in Local
sof
2014/09/08 21:17:46
Why do you consider it unsafe? loader() (FrameLoad
| |
119 } | |
120 | |
121 void LocalFrame::trace(Visitor* visitor) | |
122 { | |
123 #if ENABLE(OILPAN) | |
124 visitor->trace(m_destructionObservers); | |
125 #endif | |
126 visitor->trace(m_loader); | |
127 visitor->trace(m_navigationScheduler); | |
128 visitor->trace(m_pagePopupOwner); | |
129 visitor->trace(m_editor); | |
130 visitor->trace(m_spellChecker); | |
131 visitor->trace(m_selection); | |
132 visitor->trace(m_eventHandler); | |
133 visitor->trace(m_console); | |
134 visitor->trace(m_inputMethodController); | |
135 Frame::trace(visitor); | |
136 WillBeHeapSupplementable<LocalFrame>::trace(visitor); | |
137 } | |
138 | |
139 void LocalFrame::dispose() | |
140 { | |
141 #if !ENABLE(OILPAN) | |
118 setView(nullptr); | 142 setView(nullptr); |
dcheng
2014/09/07 22:26:34
Similarly, is it safe to omit this call to setView
sof
2014/09/16 09:08:35
I now believe it is safe, except that it would be
| |
119 loader().clear(); | 143 loader().dispose(true); |
120 setDOMWindow(nullptr); | 144 #else |
145 loader().dispose(false); | |
dcheng
2014/09/07 22:26:34
Why do we pass different bool values, depending on
sof
2014/09/08 21:17:45
As dispose() is called from the dtor, we have to b
| |
146 #endif | |
121 | 147 |
122 // FIXME: What to do here... some of this is redundant with ~Frame. | 148 #if !ENABLE(OILPAN) |
123 HashSet<FrameDestructionObserver*>::iterator stop = m_destructionObservers.e nd(); | 149 HashSet<RawPtr<FrameDestructionObserver> >::iterator stop = m_destructionObs ervers.end(); |
124 for (HashSet<FrameDestructionObserver*>::iterator it = m_destructionObserver s.begin(); it != stop; ++it) | 150 for (HashSet<RawPtr<FrameDestructionObserver> >::iterator it = m_destruction Observers.begin(); it != stop; ++it) |
125 (*it)->frameDestroyed(); | 151 (*it)->frameDestroyed(); |
152 #endif | |
126 } | 153 } |
127 | 154 |
128 void LocalFrame::detach() | 155 void LocalFrame::detach() |
129 { | 156 { |
130 // A lot of the following steps can result in the current frame being | 157 // A lot of the following steps can result in the current frame being |
131 // detached, so protect a reference to it. | 158 // detached, so protect a reference to it. |
132 RefPtr<LocalFrame> protect(this); | 159 RefPtrWillBeRawPtr<LocalFrame> protect(this); |
133 m_loader.stopAllLoaders(); | 160 m_loader.stopAllLoaders(); |
134 m_loader.closeURL(); | 161 m_loader.closeURL(); |
135 detachChildren(); | 162 detachChildren(); |
136 // stopAllLoaders() needs to be called after detachChildren(), because detac hChildren() | 163 // 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 | 164 // 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. | 165 // handlers might start a new subresource load in this frame. |
139 m_loader.stopAllLoaders(); | 166 m_loader.stopAllLoaders(); |
140 m_loader.detachFromParent(); | 167 m_loader.detachFromParent(); |
141 } | 168 } |
142 | 169 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 | 219 |
193 document()->styleResolverChanged(); | 220 document()->styleResolverChanged(); |
194 if (shouldUsePrintingLayout()) { | 221 if (shouldUsePrintingLayout()) { |
195 view()->forceLayoutForPagination(pageSize, originalPageSize, maximumShri nkRatio); | 222 view()->forceLayoutForPagination(pageSize, originalPageSize, maximumShri nkRatio); |
196 } else { | 223 } else { |
197 view()->forceLayout(); | 224 view()->forceLayout(); |
198 view()->adjustViewSize(); | 225 view()->adjustViewSize(); |
199 } | 226 } |
200 | 227 |
201 // Subframes of the one we're printing don't lay out to the page size. | 228 // 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()) { | 229 for (RefPtrWillBeRawPtr<Frame> child = tree().firstChild(); child; child = c hild->tree().nextSibling()) { |
203 if (child->isLocalFrame()) | 230 if (child->isLocalFrame()) |
204 toLocalFrame(child.get())->setPrinting(printing, FloatSize(), FloatS ize(), 0); | 231 toLocalFrame(child.get())->setPrinting(printing, FloatSize(), FloatS ize(), 0); |
205 } | 232 } |
206 } | 233 } |
207 | 234 |
208 bool LocalFrame::shouldUsePrintingLayout() const | 235 bool LocalFrame::shouldUsePrintingLayout() const |
209 { | 236 { |
210 // Only top frame being printed should be fit to page size. | 237 // Only top frame being printed should be fit to page size. |
211 // Subframes should be constrained by parents only. | 238 // Subframes should be constrained by parents only. |
212 return document()->printing() && (!tree().parent() || !tree().parent()->isLo calFrame() || !toLocalFrame(tree().parent())->document()->printing()); | 239 return document()->printing() && (!tree().parent() || !tree().parent()->isLo calFrame() || !toLocalFrame(tree().parent())->document()->printing()); |
(...skipping 28 matching lines...) Expand all Loading... | |
241 if (domWindow) | 268 if (domWindow) |
242 script().clearWindowProxy(); | 269 script().clearWindowProxy(); |
243 Frame::setDOMWindow(domWindow); | 270 Frame::setDOMWindow(domWindow); |
244 } | 271 } |
245 | 272 |
246 void LocalFrame::didChangeVisibilityState() | 273 void LocalFrame::didChangeVisibilityState() |
247 { | 274 { |
248 if (document()) | 275 if (document()) |
249 document()->didChangeVisibilityState(); | 276 document()->didChangeVisibilityState(); |
250 | 277 |
251 Vector<RefPtr<LocalFrame> > childFrames; | 278 WillBeHeapVector<RefPtrWillBeMember<LocalFrame> > childFrames; |
252 for (Frame* child = tree().firstChild(); child; child = child->tree().nextSi bling()) { | 279 for (Frame* child = tree().firstChild(); child; child = child->tree().nextSi bling()) { |
253 if (child->isLocalFrame()) | 280 if (child->isLocalFrame()) |
254 childFrames.append(toLocalFrame(child)); | 281 childFrames.append(toLocalFrame(child)); |
255 } | 282 } |
256 | 283 |
257 for (size_t i = 0; i < childFrames.size(); ++i) | 284 for (size_t i = 0; i < childFrames.size(); ++i) |
258 childFrames[i]->didChangeVisibilityState(); | 285 childFrames[i]->didChangeVisibilityState(); |
259 } | 286 } |
260 | 287 |
261 void LocalFrame::addDestructionObserver(FrameDestructionObserver* observer) | 288 void LocalFrame::addDestructionObserver(FrameDestructionObserver* observer) |
262 { | 289 { |
263 m_destructionObservers.add(observer); | 290 m_destructionObservers.add(observer); |
264 } | 291 } |
265 | 292 |
266 void LocalFrame::removeDestructionObserver(FrameDestructionObserver* observer) | 293 void LocalFrame::removeDestructionObserver(FrameDestructionObserver* observer) |
267 { | 294 { |
268 m_destructionObservers.remove(observer); | 295 m_destructionObservers.remove(observer); |
269 } | 296 } |
270 | 297 |
271 void LocalFrame::willDetachFrameHost() | 298 void LocalFrame::willDetachFrameHost() |
272 { | 299 { |
273 // We should never be detatching the page during a Layout. | 300 // We should never be detatching the page during a Layout. |
274 RELEASE_ASSERT(!m_view || !m_view->isInPerformLayout()); | 301 RELEASE_ASSERT(!m_view || !m_view->isInPerformLayout()); |
275 | 302 |
276 Frame* parent = tree().parent(); | 303 Frame* parent = tree().parent(); |
277 if (parent && parent->isLocalFrame()) | 304 if (parent && parent->isLocalFrame()) |
278 toLocalFrame(parent)->loader().checkLoadComplete(); | 305 toLocalFrame(parent)->loader().checkLoadComplete(); |
279 | 306 |
280 HashSet<FrameDestructionObserver*>::iterator stop = m_destructionObservers.e nd(); | 307 WillBeHeapHashSet<RawPtrWillBeWeakMember<FrameDestructionObserver> >::iterat or stop = m_destructionObservers.end(); |
281 for (HashSet<FrameDestructionObserver*>::iterator it = m_destructionObserver s.begin(); it != stop; ++it) | 308 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<FrameDestructionObserver> >::i terator it = m_destructionObservers.begin(); it != stop; ++it) |
282 (*it)->willDetachFrameHost(); | 309 (*it)->willDetachFrameHost(); |
283 | 310 |
311 #if ENABLE(OILPAN) | |
312 m_destructionObservers.clear(); | |
haraken
2014/09/08 07:25:58
This is just for performance optimization and not
sof
2014/09/08 21:17:46
Yes, I just thought it appropriate to release the
| |
313 #endif | |
314 | |
284 // FIXME: Page should take care of updating focus/scrolling instead of Frame . | 315 // 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, | 316 // FIXME: It's unclear as to why this is called more than once, but it is, |
286 // so page() could be null. | 317 // so page() could be null. |
287 if (page() && page()->focusController().focusedFrame() == this) | 318 if (page() && page()->focusController().focusedFrame() == this) |
288 page()->focusController().setFocusedFrame(nullptr); | 319 page()->focusController().setFocusedFrame(nullptr); |
289 script().clearScriptObjects(); | 320 script().clearScriptObjects(); |
290 | 321 |
291 if (page() && page()->scrollingCoordinator() && m_view) | 322 if (page() && page()->scrollingCoordinator() && m_view) |
292 page()->scrollingCoordinator()->willDestroyScrollableArea(m_view.get()); | 323 page()->scrollingCoordinator()->willDestroyScrollableArea(m_view.get()); |
293 } | 324 } |
294 | 325 |
295 void LocalFrame::detachFromFrameHost() | 326 void LocalFrame::detachFromFrameHost() |
296 { | 327 { |
297 // We should never be detatching the page during a Layout. | 328 // We should never be detaching the page during a Layout. |
298 RELEASE_ASSERT(!m_view || !m_view->isInPerformLayout()); | 329 RELEASE_ASSERT(!m_view || !m_view->isInPerformLayout()); |
299 m_host = 0; | 330 m_host = 0; |
300 } | 331 } |
301 | 332 |
302 String LocalFrame::documentTypeString() const | 333 String LocalFrame::documentTypeString() const |
303 { | 334 { |
304 if (DocumentType* doctype = document()->doctype()) | 335 if (DocumentType* doctype = document()->doctype()) |
305 return createMarkup(doctype); | 336 return createMarkup(doctype); |
306 | 337 |
307 return String(); | 338 return String(); |
(...skipping 198 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. | 537 // 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(); | 538 LayoutPoint scrollPosition = view->scrollPosition(); |
508 float percentDifference = (pageZoomFactor / m_pageZoomFactor); | 539 float percentDifference = (pageZoomFactor / m_pageZoomFactor); |
509 view->setScrollPosition(IntPoint(scrollPosition.x() * percentDiffere nce, scrollPosition.y() * percentDifference)); | 540 view->setScrollPosition(IntPoint(scrollPosition.x() * percentDiffere nce, scrollPosition.y() * percentDifference)); |
510 } | 541 } |
511 } | 542 } |
512 | 543 |
513 m_pageZoomFactor = pageZoomFactor; | 544 m_pageZoomFactor = pageZoomFactor; |
514 m_textZoomFactor = textZoomFactor; | 545 m_textZoomFactor = textZoomFactor; |
515 | 546 |
516 for (RefPtr<Frame> child = tree().firstChild(); child; child = child->tree() .nextSibling()) { | 547 for (RefPtrWillBeRawPtr<Frame> child = tree().firstChild(); child; child = c hild->tree().nextSibling()) { |
517 if (child->isLocalFrame()) | 548 if (child->isLocalFrame()) |
518 toLocalFrame(child.get())->setPageAndTextZoomFactors(m_pageZoomFacto r, m_textZoomFactor); | 549 toLocalFrame(child.get())->setPageAndTextZoomFactors(m_pageZoomFacto r, m_textZoomFactor); |
519 } | 550 } |
520 | 551 |
521 document->setNeedsStyleRecalc(SubtreeStyleChange); | 552 document->setNeedsStyleRecalc(SubtreeStyleChange); |
522 document->updateLayoutIgnorePendingStylesheets(); | 553 document->updateLayoutIgnorePendingStylesheets(); |
523 } | 554 } |
524 | 555 |
525 void LocalFrame::deviceOrPageScaleFactorChanged() | 556 void LocalFrame::deviceOrPageScaleFactorChanged() |
526 { | 557 { |
527 document()->mediaQueryAffectingValueChanged(); | 558 document()->mediaQueryAffectingValueChanged(); |
528 for (RefPtr<Frame> child = tree().firstChild(); child; child = child->tree() .nextSibling()) { | 559 for (RefPtrWillBeRawPtr<Frame> child = tree().firstChild(); child; child = c hild->tree().nextSibling()) { |
529 if (child->isLocalFrame()) | 560 if (child->isLocalFrame()) |
530 toLocalFrame(child.get())->deviceOrPageScaleFactorChanged(); | 561 toLocalFrame(child.get())->deviceOrPageScaleFactorChanged(); |
531 } | 562 } |
532 } | 563 } |
533 | 564 |
534 bool LocalFrame::isURLAllowed(const KURL& url) const | 565 bool LocalFrame::isURLAllowed(const KURL& url) const |
535 { | 566 { |
536 // We allow one level of self-reference because some sites depend on that, | 567 // We allow one level of self-reference because some sites depend on that, |
537 // but we don't allow more than one. | 568 // but we don't allow more than one. |
538 if (page()->subframeCount() >= Page::maxNumberOfFrames) | 569 if (page()->subframeCount() >= Page::maxNumberOfFrames) |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
679 | 710 |
680 return curFrame; | 711 return curFrame; |
681 } | 712 } |
682 | 713 |
683 void LocalFrame::setPagePopupOwner(Element& owner) | 714 void LocalFrame::setPagePopupOwner(Element& owner) |
684 { | 715 { |
685 m_pagePopupOwner = &owner; | 716 m_pagePopupOwner = &owner; |
686 } | 717 } |
687 | 718 |
688 } // namespace blink | 719 } // namespace blink |
OLD | NEW |