| 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 |
| 9 * rights reserved. |
| 9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> | 10 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> |
| 10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 11 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 11 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 12 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
| 12 * Copyright (C) 2008 Google Inc. | 13 * Copyright (C) 2008 Google Inc. |
| 13 * | 14 * |
| 14 * This library is free software; you can redistribute it and/or | 15 * This library is free software; you can redistribute it and/or |
| 15 * modify it under the terms of the GNU Library General Public | 16 * modify it under the terms of the GNU Library General Public |
| 16 * License as published by the Free Software Foundation; either | 17 * License as published by the Free Software Foundation; either |
| 17 * version 2 of the License, or (at your option) any later version. | 18 * version 2 of the License, or (at your option) any later version. |
| 18 * | 19 * |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 #include "wtf/PtrUtil.h" | 92 #include "wtf/PtrUtil.h" |
| 92 #include "wtf/StdLibExtras.h" | 93 #include "wtf/StdLibExtras.h" |
| 93 #include <memory> | 94 #include <memory> |
| 94 | 95 |
| 95 namespace blink { | 96 namespace blink { |
| 96 | 97 |
| 97 using namespace HTMLNames; | 98 using namespace HTMLNames; |
| 98 | 99 |
| 99 namespace { | 100 namespace { |
| 100 | 101 |
| 101 // Convenience class for initializing a GraphicsContext to build a DragImage fro
m a specific | 102 // Convenience class for initializing a GraphicsContext to build a DragImage |
| 102 // region specified by |bounds|. After painting the using context(), the DragIma
ge returned from | 103 // from a specific region specified by |bounds|. After painting the using |
| 103 // createImage() will only contain the content in |bounds| with the appropriate
device scale | 104 // context(), the DragImage returned from createImage() will only contain the |
| 104 // factor included. | 105 // content in |bounds| with the appropriate device scale factor included. |
| 105 class DragImageBuilder { | 106 class DragImageBuilder { |
| 106 STACK_ALLOCATED(); | 107 STACK_ALLOCATED(); |
| 107 | 108 |
| 108 public: | 109 public: |
| 109 DragImageBuilder(const LocalFrame& localFrame, const FloatRect& bounds) | 110 DragImageBuilder(const LocalFrame& localFrame, const FloatRect& bounds) |
| 110 : m_localFrame(&localFrame), m_bounds(bounds) { | 111 : m_localFrame(&localFrame), m_bounds(bounds) { |
| 111 // TODO(oshima): Remove this when all platforms are migrated to use-zoom-for
-dsf. | 112 // TODO(oshima): Remove this when all platforms are migrated to |
| 113 // use-zoom-for-dsf. |
| 112 float deviceScaleFactor = | 114 float deviceScaleFactor = |
| 113 m_localFrame->host()->deviceScaleFactorDeprecated(); | 115 m_localFrame->host()->deviceScaleFactorDeprecated(); |
| 114 float pageScaleFactor = m_localFrame->host()->visualViewport().scale(); | 116 float pageScaleFactor = m_localFrame->host()->visualViewport().scale(); |
| 115 m_bounds.setWidth(m_bounds.width() * deviceScaleFactor * pageScaleFactor); | 117 m_bounds.setWidth(m_bounds.width() * deviceScaleFactor * pageScaleFactor); |
| 116 m_bounds.setHeight(m_bounds.height() * deviceScaleFactor * pageScaleFactor); | 118 m_bounds.setHeight(m_bounds.height() * deviceScaleFactor * pageScaleFactor); |
| 117 m_pictureBuilder = wrapUnique(new SkPictureBuilder( | 119 m_pictureBuilder = wrapUnique(new SkPictureBuilder( |
| 118 SkRect::MakeIWH(m_bounds.width(), m_bounds.height()))); | 120 SkRect::MakeIWH(m_bounds.width(), m_bounds.height()))); |
| 119 | 121 |
| 120 AffineTransform transform; | 122 AffineTransform transform; |
| 121 transform.scale(deviceScaleFactor * pageScaleFactor, | 123 transform.scale(deviceScaleFactor * pageScaleFactor, |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 void LocalFrame::detach(FrameDetachType type) { | 381 void LocalFrame::detach(FrameDetachType type) { |
| 380 PluginScriptForbiddenScope forbidPluginDestructorScripting; | 382 PluginScriptForbiddenScope forbidPluginDestructorScripting; |
| 381 m_loader.stopAllLoaders(); | 383 m_loader.stopAllLoaders(); |
| 382 // Don't allow any new child frames to load in this frame: attaching a new | 384 // Don't allow any new child frames to load in this frame: attaching a new |
| 383 // child frame during or after detaching children results in an attached | 385 // child frame during or after detaching children results in an attached |
| 384 // frame on a detached DOM tree, which is bad. | 386 // frame on a detached DOM tree, which is bad. |
| 385 SubframeLoadingDisabler disabler(*document()); | 387 SubframeLoadingDisabler disabler(*document()); |
| 386 m_loader.dispatchUnloadEvent(); | 388 m_loader.dispatchUnloadEvent(); |
| 387 detachChildren(); | 389 detachChildren(); |
| 388 | 390 |
| 389 // All done if detaching the subframes brought about a detach of this frame al
so. | 391 // All done if detaching the subframes brought about a detach of this frame |
| 392 // also. |
| 390 if (!client()) | 393 if (!client()) |
| 391 return; | 394 return; |
| 392 | 395 |
| 393 // stopAllLoaders() needs to be called after detachChildren(), because detachC
hildren() | 396 // stopAllLoaders() needs to be called after detachChildren(), because |
| 394 // will trigger the unload event handlers of any child frames, and those event | 397 // detachChildren() will trigger the unload event handlers of any child |
| 395 // handlers might start a new subresource load in this frame. | 398 // frames, and those event handlers might start a new subresource load in this |
| 399 // frame. |
| 396 m_loader.stopAllLoaders(); | 400 m_loader.stopAllLoaders(); |
| 397 m_loader.detach(); | 401 m_loader.detach(); |
| 398 document()->shutdown(); | 402 document()->shutdown(); |
| 399 // This is the earliest that scripting can be disabled: | 403 // This is the earliest that scripting can be disabled: |
| 400 // - FrameLoader::detach() can fire XHR abort events | 404 // - FrameLoader::detach() can fire XHR abort events |
| 401 // - Document::shutdown()'s deferred widget updates can run script. | 405 // - Document::shutdown()'s deferred widget updates can run script. |
| 402 ScriptForbiddenScope forbidScript; | 406 ScriptForbiddenScope forbidScript; |
| 403 m_loader.clear(); | 407 m_loader.clear(); |
| 404 if (!client()) | 408 if (!client()) |
| 405 return; | 409 return; |
| 406 | 410 |
| 407 client()->willBeDetached(); | 411 client()->willBeDetached(); |
| 408 // Notify ScriptController that the frame is closing, since its cleanup ends u
p calling | 412 // Notify ScriptController that the frame is closing, since its cleanup ends |
| 409 // back to FrameLoaderClient via WindowProxy. | 413 // up calling back to FrameLoaderClient via WindowProxy. |
| 410 script().clearForClose(); | 414 script().clearForClose(); |
| 411 setView(nullptr); | 415 setView(nullptr); |
| 412 | 416 |
| 413 m_host->eventHandlerRegistry().didRemoveAllEventHandlers(*localDOMWindow()); | 417 m_host->eventHandlerRegistry().didRemoveAllEventHandlers(*localDOMWindow()); |
| 414 | 418 |
| 415 localDOMWindow()->frameDestroyed(); | 419 localDOMWindow()->frameDestroyed(); |
| 416 | 420 |
| 417 // TODO: Page should take care of updating focus/scrolling instead of Frame. | 421 // TODO: Page should take care of updating focus/scrolling instead of Frame. |
| 418 // TODO: It's unclear as to why this is called more than once, but it is, | 422 // TODO: It's unclear as to why this is called more than once, but it is, |
| 419 // so page() could be null. | 423 // so page() could be null. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 // is acceptable as its actions are either not needed or handled | 485 // is acceptable as its actions are either not needed or handled |
| 482 // by other means -- | 486 // by other means -- |
| 483 // | 487 // |
| 484 // - LocalFrameLifecycleObserver::willDetachFrameHost() will have | 488 // - LocalFrameLifecycleObserver::willDetachFrameHost() will have |
| 485 // signalled the Inspector frameWindowDiscarded() notifications. | 489 // signalled the Inspector frameWindowDiscarded() notifications. |
| 486 // We assume that all LocalFrames are detached, where that notification | 490 // We assume that all LocalFrames are detached, where that notification |
| 487 // will have been done. | 491 // will have been done. |
| 488 // | 492 // |
| 489 // - Calling LocalDOMWindow::reset() is not needed (called from | 493 // - Calling LocalDOMWindow::reset() is not needed (called from |
| 490 // Frame::setDOMWindow().) The Member references it clears will now | 494 // Frame::setDOMWindow().) The Member references it clears will now |
| 491 // die with the window. And the registered DOMWindowProperty instances that
don't, | 495 // die with the window. And the registered DOMWindowProperty instances that |
| 492 // only keep a weak reference to this frame, so there's no need to be | 496 // don't, only keep a weak reference to this frame, so there's no need to |
| 493 // explicitly notified that this frame is going away. | 497 // be explicitly notified that this frame is going away. |
| 494 if (domWindow) | 498 if (domWindow) |
| 495 script().clearWindowProxy(); | 499 script().clearWindowProxy(); |
| 496 | 500 |
| 497 if (m_domWindow) | 501 if (m_domWindow) |
| 498 m_domWindow->reset(); | 502 m_domWindow->reset(); |
| 499 m_domWindow = domWindow; | 503 m_domWindow = domWindow; |
| 500 } | 504 } |
| 501 | 505 |
| 502 Document* LocalFrame::document() const { | 506 Document* LocalFrame::document() const { |
| 503 return m_domWindow ? m_domWindow->document() : nullptr; | 507 return m_domWindow ? m_domWindow->document() : nullptr; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 Frame* top = tree().top(); | 540 Frame* top = tree().top(); |
| 537 return top && | 541 return top && |
| 538 !securityOrigin->canAccess( | 542 !securityOrigin->canAccess( |
| 539 top->securityContext()->getSecurityOrigin()); | 543 top->securityContext()->getSecurityOrigin()); |
| 540 } | 544 } |
| 541 | 545 |
| 542 void LocalFrame::setPrinting(bool printing, | 546 void LocalFrame::setPrinting(bool printing, |
| 543 const FloatSize& pageSize, | 547 const FloatSize& pageSize, |
| 544 const FloatSize& originalPageSize, | 548 const FloatSize& originalPageSize, |
| 545 float maximumShrinkRatio) { | 549 float maximumShrinkRatio) { |
| 546 // In setting printing, we should not validate resources already cached for th
e document. | 550 // In setting printing, we should not validate resources already cached for |
| 547 // See https://bugs.webkit.org/show_bug.cgi?id=43704 | 551 // the document. See https://bugs.webkit.org/show_bug.cgi?id=43704 |
| 548 ResourceCacheValidationSuppressor validationSuppressor(document()->fetcher()); | 552 ResourceCacheValidationSuppressor validationSuppressor(document()->fetcher()); |
| 549 | 553 |
| 550 document()->setPrinting(printing); | 554 document()->setPrinting(printing); |
| 551 view()->adjustMediaTypeForPrinting(printing); | 555 view()->adjustMediaTypeForPrinting(printing); |
| 552 | 556 |
| 553 if (shouldUsePrintingLayout()) { | 557 if (shouldUsePrintingLayout()) { |
| 554 view()->forceLayoutForPagination(pageSize, originalPageSize, | 558 view()->forceLayoutForPagination(pageSize, originalPageSize, |
| 555 maximumShrinkRatio); | 559 maximumShrinkRatio); |
| 556 } else { | 560 } else { |
| 557 if (LayoutView* layoutView = view()->layoutView()) { | 561 if (LayoutView* layoutView = view()->layoutView()) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 | 619 |
| 616 Page* page = this->page(); | 620 Page* page = this->page(); |
| 617 if (!page) | 621 if (!page) |
| 618 return; | 622 return; |
| 619 | 623 |
| 620 Document* document = this->document(); | 624 Document* document = this->document(); |
| 621 if (!document) | 625 if (!document) |
| 622 return; | 626 return; |
| 623 | 627 |
| 624 // Respect SVGs zoomAndPan="disabled" property in standalone SVG documents. | 628 // Respect SVGs zoomAndPan="disabled" property in standalone SVG documents. |
| 625 // FIXME: How to handle compound documents + zoomAndPan="disabled"? Needs SVG
WG clarification. | 629 // FIXME: How to handle compound documents + zoomAndPan="disabled"? Needs SVG |
| 630 // WG clarification. |
| 626 if (document->isSVGDocument()) { | 631 if (document->isSVGDocument()) { |
| 627 if (!document->accessSVGExtensions().zoomAndPanEnabled()) | 632 if (!document->accessSVGExtensions().zoomAndPanEnabled()) |
| 628 return; | 633 return; |
| 629 } | 634 } |
| 630 | 635 |
| 631 if (m_pageZoomFactor != pageZoomFactor) { | 636 if (m_pageZoomFactor != pageZoomFactor) { |
| 632 if (FrameView* view = this->view()) { | 637 if (FrameView* view = this->view()) { |
| 633 // Update the scroll position when doing a full page zoom, so the content
stays in relatively the same position. | 638 // Update the scroll position when doing a full page zoom, so the content |
| 639 // stays in relatively the same position. |
| 634 LayoutPoint scrollPosition = view->scrollPosition(); | 640 LayoutPoint scrollPosition = view->scrollPosition(); |
| 635 float percentDifference = (pageZoomFactor / m_pageZoomFactor); | 641 float percentDifference = (pageZoomFactor / m_pageZoomFactor); |
| 636 view->setScrollPosition( | 642 view->setScrollPosition( |
| 637 DoublePoint(scrollPosition.x() * percentDifference, | 643 DoublePoint(scrollPosition.x() * percentDifference, |
| 638 scrollPosition.y() * percentDifference), | 644 scrollPosition.y() * percentDifference), |
| 639 ProgrammaticScroll); | 645 ProgrammaticScroll); |
| 640 } | 646 } |
| 641 } | 647 } |
| 642 | 648 |
| 643 m_pageZoomFactor = pageZoomFactor; | 649 m_pageZoomFactor = pageZoomFactor; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext()) | 898 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext()) |
| 893 m_frame->client()->frameBlameContext()->Enter(); | 899 m_frame->client()->frameBlameContext()->Enter(); |
| 894 } | 900 } |
| 895 | 901 |
| 896 ScopedFrameBlamer::~ScopedFrameBlamer() { | 902 ScopedFrameBlamer::~ScopedFrameBlamer() { |
| 897 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext()) | 903 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext()) |
| 898 m_frame->client()->frameBlameContext()->Leave(); | 904 m_frame->client()->frameBlameContext()->Leave(); |
| 899 } | 905 } |
| 900 | 906 |
| 901 } // namespace blink | 907 } // namespace blink |
| OLD | NEW |