Chromium Code Reviews| 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(); | |
| 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); |
| 119 loader().clear(); | 143 loader().dispose(FrameLoader::DoDisposeFrameContents); |
| 120 setDOMWindow(nullptr); | 144 #else |
|
haraken
2014/09/11 14:47:25
Why did you remove this from non-oilpan builds?
sof
2014/09/12 12:26:07
Added back.
| |
| 145 loader().dispose(FrameLoader::DoNotDisposeFrameContents); | |
| 146 #endif | |
| 121 | 147 |
| 122 // FIXME: What to do here... some of this is redundant with ~Frame. | 148 #if !ENABLE(OILPAN) |
|
haraken
2014/09/11 14:47:25
Merge this #if with the #if above.
sof
2014/09/12 12:26:07
Done as part of inlining dispose() into the dtor.
| |
| 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 15 matching lines...) Expand all Loading... | |
| 228 float ratio = originalSize.width() / originalSize.height(); | 255 float ratio = originalSize.width() / originalSize.height(); |
| 229 resultSize.setHeight(floorf(expectedSize.height())); | 256 resultSize.setHeight(floorf(expectedSize.height())); |
| 230 resultSize.setWidth(floorf(resultSize.height() * ratio)); | 257 resultSize.setWidth(floorf(resultSize.height() * ratio)); |
| 231 } | 258 } |
| 232 return resultSize; | 259 return resultSize; |
| 233 } | 260 } |
| 234 | 261 |
| 235 void LocalFrame::setDOMWindow(PassRefPtrWillBeRawPtr<LocalDOMWindow> domWindow) | 262 void LocalFrame::setDOMWindow(PassRefPtrWillBeRawPtr<LocalDOMWindow> domWindow) |
| 236 { | 263 { |
| 237 if (m_domWindow) { | 264 if (m_domWindow) { |
| 265 // Oilpan: the assumption is that FrameDestructionObserver::willDetachFr ameHost() | |
| 266 // on LocalWindow will have signalled these frameWindowDiscarded() notif ications. | |
| 267 // | |
| 268 // It is not invoked when finalizing the LocalFrame, as setDOMWindow() i sn't invoked | |
| 269 // then, as accessing the m_domWindow heap object isn't safe. | |
| 238 console().messageStorage()->frameWindowDiscarded(m_domWindow.get()); | 270 console().messageStorage()->frameWindowDiscarded(m_domWindow.get()); |
| 239 InspectorInstrumentation::frameWindowDiscarded(this, m_domWindow.get()); | 271 InspectorInstrumentation::frameWindowDiscarded(this, m_domWindow.get()); |
| 240 } | 272 } |
| 241 if (domWindow) | 273 if (domWindow) |
| 242 script().clearWindowProxy(); | 274 script().clearWindowProxy(); |
| 243 Frame::setDOMWindow(domWindow); | 275 Frame::setDOMWindow(domWindow); |
| 244 } | 276 } |
| 245 | 277 |
| 246 void LocalFrame::didChangeVisibilityState() | 278 void LocalFrame::didChangeVisibilityState() |
| 247 { | 279 { |
| 248 if (document()) | 280 if (document()) |
| 249 document()->didChangeVisibilityState(); | 281 document()->didChangeVisibilityState(); |
| 250 | 282 |
| 251 Vector<RefPtr<LocalFrame> > childFrames; | 283 WillBeHeapVector<RefPtrWillBeMember<LocalFrame> > childFrames; |
| 252 for (Frame* child = tree().firstChild(); child; child = child->tree().nextSi bling()) { | 284 for (Frame* child = tree().firstChild(); child; child = child->tree().nextSi bling()) { |
| 253 if (child->isLocalFrame()) | 285 if (child->isLocalFrame()) |
| 254 childFrames.append(toLocalFrame(child)); | 286 childFrames.append(toLocalFrame(child)); |
| 255 } | 287 } |
| 256 | 288 |
| 257 for (size_t i = 0; i < childFrames.size(); ++i) | 289 for (size_t i = 0; i < childFrames.size(); ++i) |
| 258 childFrames[i]->didChangeVisibilityState(); | 290 childFrames[i]->didChangeVisibilityState(); |
| 259 } | 291 } |
| 260 | 292 |
| 261 void LocalFrame::addDestructionObserver(FrameDestructionObserver* observer) | 293 void LocalFrame::addDestructionObserver(FrameDestructionObserver* observer) |
| 262 { | 294 { |
| 263 m_destructionObservers.add(observer); | 295 m_destructionObservers.add(observer); |
| 264 } | 296 } |
| 265 | 297 |
| 266 void LocalFrame::removeDestructionObserver(FrameDestructionObserver* observer) | 298 void LocalFrame::removeDestructionObserver(FrameDestructionObserver* observer) |
| 267 { | 299 { |
| 268 m_destructionObservers.remove(observer); | 300 m_destructionObservers.remove(observer); |
| 269 } | 301 } |
| 270 | 302 |
| 271 void LocalFrame::willDetachFrameHost() | 303 void LocalFrame::willDetachFrameHost() |
| 272 { | 304 { |
| 273 // We should never be detatching the page during a Layout. | 305 // We should never be detatching the page during a Layout. |
| 274 RELEASE_ASSERT(!m_view || !m_view->isInPerformLayout()); | 306 RELEASE_ASSERT(!m_view || !m_view->isInPerformLayout()); |
| 275 | 307 |
| 276 Frame* parent = tree().parent(); | 308 Frame* parent = tree().parent(); |
| 277 if (parent && parent->isLocalFrame()) | 309 if (parent && parent->isLocalFrame()) |
| 278 toLocalFrame(parent)->loader().checkLoadComplete(); | 310 toLocalFrame(parent)->loader().checkLoadComplete(); |
| 279 | 311 |
| 280 HashSet<FrameDestructionObserver*>::iterator stop = m_destructionObservers.e nd(); | 312 WillBeHeapHashSet<RawPtrWillBeWeakMember<FrameDestructionObserver> >::iterat or stop = m_destructionObservers.end(); |
| 281 for (HashSet<FrameDestructionObserver*>::iterator it = m_destructionObserver s.begin(); it != stop; ++it) | 313 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<FrameDestructionObserver> >::i terator it = m_destructionObservers.begin(); it != stop; ++it) |
| 282 (*it)->willDetachFrameHost(); | 314 (*it)->willDetachFrameHost(); |
| 283 | 315 |
| 284 // FIXME: Page should take care of updating focus/scrolling instead of Frame . | 316 // 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, | 317 // FIXME: It's unclear as to why this is called more than once, but it is, |
| 286 // so page() could be null. | 318 // so page() could be null. |
| 287 if (page() && page()->focusController().focusedFrame() == this) | 319 if (page() && page()->focusController().focusedFrame() == this) |
| 288 page()->focusController().setFocusedFrame(nullptr); | 320 page()->focusController().setFocusedFrame(nullptr); |
| 289 script().clearScriptObjects(); | 321 script().clearScriptObjects(); |
| 290 | 322 |
| 291 if (page() && page()->scrollingCoordinator() && m_view) | 323 if (page() && page()->scrollingCoordinator() && m_view) |
| 292 page()->scrollingCoordinator()->willDestroyScrollableArea(m_view.get()); | 324 page()->scrollingCoordinator()->willDestroyScrollableArea(m_view.get()); |
| 293 } | 325 } |
| 294 | 326 |
| 295 void LocalFrame::detachFromFrameHost() | 327 void LocalFrame::detachFromFrameHost() |
| 296 { | 328 { |
| 297 // We should never be detatching the page during a Layout. | 329 // We should never be detaching the page during a Layout. |
| 298 RELEASE_ASSERT(!m_view || !m_view->isInPerformLayout()); | 330 RELEASE_ASSERT(!m_view || !m_view->isInPerformLayout()); |
| 299 m_host = 0; | 331 m_host = nullptr; |
| 300 } | 332 } |
| 301 | 333 |
| 302 String LocalFrame::documentTypeString() const | 334 String LocalFrame::documentTypeString() const |
| 303 { | 335 { |
| 304 if (DocumentType* doctype = document()->doctype()) | 336 if (DocumentType* doctype = document()->doctype()) |
| 305 return createMarkup(doctype); | 337 return createMarkup(doctype); |
| 306 | 338 |
| 307 return String(); | 339 return String(); |
| 308 } | 340 } |
| 309 | 341 |
| (...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. | 538 // 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(); | 539 LayoutPoint scrollPosition = view->scrollPosition(); |
| 508 float percentDifference = (pageZoomFactor / m_pageZoomFactor); | 540 float percentDifference = (pageZoomFactor / m_pageZoomFactor); |
| 509 view->setScrollPosition(IntPoint(scrollPosition.x() * percentDiffere nce, scrollPosition.y() * percentDifference)); | 541 view->setScrollPosition(IntPoint(scrollPosition.x() * percentDiffere nce, scrollPosition.y() * percentDifference)); |
| 510 } | 542 } |
| 511 } | 543 } |
| 512 | 544 |
| 513 m_pageZoomFactor = pageZoomFactor; | 545 m_pageZoomFactor = pageZoomFactor; |
| 514 m_textZoomFactor = textZoomFactor; | 546 m_textZoomFactor = textZoomFactor; |
| 515 | 547 |
| 516 for (RefPtr<Frame> child = tree().firstChild(); child; child = child->tree() .nextSibling()) { | 548 for (RefPtrWillBeRawPtr<Frame> child = tree().firstChild(); child; child = c hild->tree().nextSibling()) { |
| 517 if (child->isLocalFrame()) | 549 if (child->isLocalFrame()) |
| 518 toLocalFrame(child.get())->setPageAndTextZoomFactors(m_pageZoomFacto r, m_textZoomFactor); | 550 toLocalFrame(child.get())->setPageAndTextZoomFactors(m_pageZoomFacto r, m_textZoomFactor); |
| 519 } | 551 } |
| 520 | 552 |
| 521 document->setNeedsStyleRecalc(SubtreeStyleChange); | 553 document->setNeedsStyleRecalc(SubtreeStyleChange); |
| 522 document->updateLayoutIgnorePendingStylesheets(); | 554 document->updateLayoutIgnorePendingStylesheets(); |
| 523 } | 555 } |
| 524 | 556 |
| 525 void LocalFrame::deviceOrPageScaleFactorChanged() | 557 void LocalFrame::deviceOrPageScaleFactorChanged() |
| 526 { | 558 { |
| 527 document()->mediaQueryAffectingValueChanged(); | 559 document()->mediaQueryAffectingValueChanged(); |
| 528 for (RefPtr<Frame> child = tree().firstChild(); child; child = child->tree() .nextSibling()) { | 560 for (RefPtrWillBeRawPtr<Frame> child = tree().firstChild(); child; child = c hild->tree().nextSibling()) { |
| 529 if (child->isLocalFrame()) | 561 if (child->isLocalFrame()) |
| 530 toLocalFrame(child.get())->deviceOrPageScaleFactorChanged(); | 562 toLocalFrame(child.get())->deviceOrPageScaleFactorChanged(); |
| 531 } | 563 } |
| 532 } | 564 } |
| 533 | 565 |
| 534 bool LocalFrame::isURLAllowed(const KURL& url) const | 566 bool LocalFrame::isURLAllowed(const KURL& url) const |
| 535 { | 567 { |
| 536 // We allow one level of self-reference because some sites depend on that, | 568 // We allow one level of self-reference because some sites depend on that, |
| 537 // but we don't allow more than one. | 569 // but we don't allow more than one. |
| 538 if (page()->subframeCount() >= Page::maxNumberOfFrames) | 570 if (page()->subframeCount() >= Page::maxNumberOfFrames) |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 679 | 711 |
| 680 return curFrame; | 712 return curFrame; |
| 681 } | 713 } |
| 682 | 714 |
| 683 void LocalFrame::setPagePopupOwner(Element& owner) | 715 void LocalFrame::setPagePopupOwner(Element& owner) |
| 684 { | 716 { |
| 685 m_pagePopupOwner = &owner; | 717 m_pagePopupOwner = &owner; |
| 686 } | 718 } |
| 687 | 719 |
| 688 } // namespace blink | 720 } // namespace blink |
| OLD | NEW |