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