| 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 |
| 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) |
| 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 14 matching lines...) Expand all Loading... |
| 227 ASSERT(fabs(originalSize.height()) > std::numeric_limits<float>::epsilon
()); | 254 ASSERT(fabs(originalSize.height()) > std::numeric_limits<float>::epsilon
()); |
| 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 { |
| 264 // FIXME: Oilpan: the objects that keep the LocalDOMWindow references |
| 265 // that's cleared here non-Oilpan will have to clear out and reset |
| 266 // themselves. Or deemed to die at the same time as this frame, hence |
| 267 // the clearing isn't required. |
| 237 if (m_domWindow) { | 268 if (m_domWindow) { |
| 238 console().messageStorage()->frameWindowDiscarded(m_domWindow.get()); | 269 console().messageStorage()->frameWindowDiscarded(m_domWindow.get()); |
| 239 InspectorInstrumentation::frameWindowDiscarded(this, m_domWindow.get()); | 270 InspectorInstrumentation::frameWindowDiscarded(this, m_domWindow.get()); |
| 240 } | 271 } |
| 241 if (domWindow) | 272 if (domWindow) |
| 242 script().clearWindowProxy(); | 273 script().clearWindowProxy(); |
| 243 Frame::setDOMWindow(domWindow); | 274 Frame::setDOMWindow(domWindow); |
| 244 } | 275 } |
| 245 | 276 |
| 246 void LocalFrame::didChangeVisibilityState() | 277 void LocalFrame::didChangeVisibilityState() |
| 247 { | 278 { |
| 248 if (document()) | 279 if (document()) |
| 249 document()->didChangeVisibilityState(); | 280 document()->didChangeVisibilityState(); |
| 250 | 281 |
| 251 Vector<RefPtr<LocalFrame> > childFrames; | 282 WillBeHeapVector<RefPtrWillBeMember<LocalFrame> > childFrames; |
| 252 for (Frame* child = tree().firstChild(); child; child = child->tree().nextSi
bling()) { | 283 for (Frame* child = tree().firstChild(); child; child = child->tree().nextSi
bling()) { |
| 253 if (child->isLocalFrame()) | 284 if (child->isLocalFrame()) |
| 254 childFrames.append(toLocalFrame(child)); | 285 childFrames.append(toLocalFrame(child)); |
| 255 } | 286 } |
| 256 | 287 |
| 257 for (size_t i = 0; i < childFrames.size(); ++i) | 288 for (size_t i = 0; i < childFrames.size(); ++i) |
| 258 childFrames[i]->didChangeVisibilityState(); | 289 childFrames[i]->didChangeVisibilityState(); |
| 259 } | 290 } |
| 260 | 291 |
| 261 void LocalFrame::addDestructionObserver(FrameDestructionObserver* observer) | 292 void LocalFrame::addDestructionObserver(FrameDestructionObserver* observer) |
| 262 { | 293 { |
| 263 m_destructionObservers.add(observer); | 294 m_destructionObservers.add(observer); |
| 264 } | 295 } |
| 265 | 296 |
| 266 void LocalFrame::removeDestructionObserver(FrameDestructionObserver* observer) | 297 void LocalFrame::removeDestructionObserver(FrameDestructionObserver* observer) |
| 267 { | 298 { |
| 268 m_destructionObservers.remove(observer); | 299 m_destructionObservers.remove(observer); |
| 269 } | 300 } |
| 270 | 301 |
| 271 void LocalFrame::willDetachFrameHost() | 302 void LocalFrame::willDetachFrameHost() |
| 272 { | 303 { |
| 273 // We should never be detatching the page during a Layout. | 304 // We should never be detatching the page during a Layout. |
| 274 RELEASE_ASSERT(!m_view || !m_view->isInPerformLayout()); | 305 RELEASE_ASSERT(!m_view || !m_view->isInPerformLayout()); |
| 275 | 306 |
| 276 Frame* parent = tree().parent(); | 307 Frame* parent = tree().parent(); |
| 277 if (parent && parent->isLocalFrame()) | 308 if (parent && parent->isLocalFrame()) |
| 278 toLocalFrame(parent)->loader().checkLoadComplete(); | 309 toLocalFrame(parent)->loader().checkLoadComplete(); |
| 279 | 310 |
| 280 HashSet<FrameDestructionObserver*>::iterator stop = m_destructionObservers.e
nd(); | 311 WillBeHeapHashSet<RawPtrWillBeWeakMember<FrameDestructionObserver> >::iterat
or stop = m_destructionObservers.end(); |
| 281 for (HashSet<FrameDestructionObserver*>::iterator it = m_destructionObserver
s.begin(); it != stop; ++it) | 312 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<FrameDestructionObserver> >::i
terator it = m_destructionObservers.begin(); it != stop; ++it) |
| 282 (*it)->willDetachFrameHost(); | 313 (*it)->willDetachFrameHost(); |
| 283 | 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 = nullptr; |
| 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(); |
| 308 } | 339 } |
| 309 | 340 |
| (...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. | 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 |