OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 // FrameLoader | 44 // FrameLoader |
45 // | 45 // |
46 // FrameLoader and LocalFrame are formerly one object that was split apart becau se | 46 // FrameLoader and LocalFrame are formerly one object that was split apart becau se |
47 // it got too big. They basically have the same lifetime, hence the double line. | 47 // it got too big. They basically have the same lifetime, hence the double line. |
48 // | 48 // |
49 // From the perspective of the embedder, WebFrame is simply an object that it | 49 // From the perspective of the embedder, WebFrame is simply an object that it |
50 // allocates by calling WebFrame::create() and must be freed by calling close(). | 50 // allocates by calling WebFrame::create() and must be freed by calling close(). |
51 // Internally, WebFrame is actually refcounted and it holds a reference to its | 51 // Internally, WebFrame is actually refcounted and it holds a reference to its |
52 // corresponding LocalFrame in WebCore. | 52 // corresponding LocalFrame in WebCore. |
53 // | 53 // |
54 // How frames are destroyed | 54 // How frames are destroyed |
dcheng
2014/09/07 22:26:34
Frame detach is really complicated. Does this comm
| |
55 // ------------------------ | 55 // ------------------------ |
56 // | 56 // |
57 // The main frame is never destroyed and is re-used. The FrameLoader is re-used | 57 // The main frame is never destroyed and is re-used. The FrameLoader is re-used |
58 // and a reference to the main frame is kept by the Page. | 58 // and a reference to the main frame is kept by the Page. |
59 // | 59 // |
60 // When frame content is replaced, all subframes are destroyed. This happens | 60 // When frame content is replaced, all subframes are destroyed. This happens |
61 // in FrameLoader::detachFromParent for each subframe in a pre-order depth-first | 61 // in FrameLoader::detachFromParent for each subframe in a pre-order depth-first |
62 // traversal. Note that child node order may not match DOM node order! | 62 // traversal. Note that child node order may not match DOM node order! |
63 // detachFromParent() calls FrameLoaderClient::detachedFromParent(), which calls | 63 // detachFromParent() calls FrameLoaderClient::detachedFromParent(), which calls |
64 // WebFrame::frameDetached(). This triggers WebFrame to clear its reference to | 64 // WebFrame::frameDetached(). This triggers WebFrame to clear its reference to |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
489 WebRemoteFrame* WebLocalFrameImpl::toWebRemoteFrame() | 489 WebRemoteFrame* WebLocalFrameImpl::toWebRemoteFrame() |
490 { | 490 { |
491 ASSERT_NOT_REACHED(); | 491 ASSERT_NOT_REACHED(); |
492 return 0; | 492 return 0; |
493 } | 493 } |
494 | 494 |
495 void WebLocalFrameImpl::close() | 495 void WebLocalFrameImpl::close() |
496 { | 496 { |
497 m_client = 0; | 497 m_client = 0; |
498 | 498 |
499 #if ENABLE(OILPAN) | |
500 if (m_frame) | |
501 m_frame->setHasBeenClosed(); | |
502 #else | |
499 deref(); // Balances ref() acquired in WebFrame::create | 503 deref(); // Balances ref() acquired in WebFrame::create |
504 #endif | |
500 } | 505 } |
501 | 506 |
502 WebString WebLocalFrameImpl::uniqueName() const | 507 WebString WebLocalFrameImpl::uniqueName() const |
503 { | 508 { |
504 return frame()->tree().uniqueName(); | 509 return frame()->tree().uniqueName(); |
505 } | 510 } |
506 | 511 |
507 WebString WebLocalFrameImpl::assignedName() const | 512 WebString WebLocalFrameImpl::assignedName() const |
508 { | 513 { |
509 return frame()->tree().name(); | 514 return frame()->tree().name(); |
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1507 | 1512 |
1508 // WebLocalFrameImpl public ---------------------------------------------------- ----- | 1513 // WebLocalFrameImpl public ---------------------------------------------------- ----- |
1509 | 1514 |
1510 WebLocalFrame* WebLocalFrame::create(WebFrameClient* client) | 1515 WebLocalFrame* WebLocalFrame::create(WebFrameClient* client) |
1511 { | 1516 { |
1512 return WebLocalFrameImpl::create(client); | 1517 return WebLocalFrameImpl::create(client); |
1513 } | 1518 } |
1514 | 1519 |
1515 WebLocalFrameImpl* WebLocalFrameImpl::create(WebFrameClient* client) | 1520 WebLocalFrameImpl* WebLocalFrameImpl::create(WebFrameClient* client) |
1516 { | 1521 { |
1517 return adoptRef(new WebLocalFrameImpl(client)).leakRef(); | 1522 WebLocalFrameImpl* frame = new WebLocalFrameImpl(client); |
1523 #if ENABLE(OILPAN) | |
1524 return frame; | |
1525 #else | |
1526 return adoptRef(frame).leakRef(); | |
haraken
2014/09/08 07:25:59
Just help me understand: In oilpan builds, who kee
sof
2014/09/08 21:17:46
If it needs to be kept alive, WebViewImpl::setMain
| |
1527 #endif | |
1518 } | 1528 } |
1519 | 1529 |
1520 WebLocalFrameImpl::WebLocalFrameImpl(WebFrameClient* client) | 1530 WebLocalFrameImpl::WebLocalFrameImpl(WebFrameClient* client) |
1521 : m_frameLoaderClientImpl(this) | 1531 : m_frameLoaderClientImpl(this) |
1522 , m_client(client) | 1532 , m_client(client) |
1523 , m_permissionClient(0) | 1533 , m_permissionClient(0) |
1524 , m_inputEventsScaleFactorForEmulation(1) | 1534 , m_inputEventsScaleFactorForEmulation(1) |
1525 , m_userMediaClientImpl(this) | 1535 , m_userMediaClientImpl(this) |
1526 , m_geolocationClientProxy(GeolocationClientProxy::create(client ? client->g eolocationClient() : 0)) | 1536 , m_geolocationClientProxy(GeolocationClientProxy::create(client ? client->g eolocationClient() : 0)) |
1527 { | 1537 { |
1528 Platform::current()->incrementStatsCounter(webFrameActiveCount); | 1538 Platform::current()->incrementStatsCounter(webFrameActiveCount); |
1529 frameCount++; | 1539 frameCount++; |
1530 } | 1540 } |
1531 | 1541 |
1532 WebLocalFrameImpl::~WebLocalFrameImpl() | 1542 WebLocalFrameImpl::~WebLocalFrameImpl() |
1533 { | 1543 { |
1534 Platform::current()->decrementStatsCounter(webFrameActiveCount); | 1544 Platform::current()->decrementStatsCounter(webFrameActiveCount); |
1535 frameCount--; | 1545 frameCount--; |
1536 | 1546 |
1537 cancelPendingScopingEffort(); | 1547 cancelPendingScopingEffort(); |
1538 } | 1548 } |
1539 | 1549 |
1540 void WebLocalFrameImpl::setCoreFrame(PassRefPtr<LocalFrame> frame) | 1550 void WebLocalFrameImpl::trace(Visitor* visitor) |
1551 { | |
1552 visitor->trace(m_frame); | |
1553 visitor->trace(m_printContext); | |
1554 visitor->trace(m_geolocationClientProxy); | |
1555 | |
1556 WebFrame::trace(visitor, this); | |
1557 } | |
1558 | |
1559 void WebLocalFrameImpl::setCoreFrame(PassRefPtrWillBeRawPtr<LocalFrame> frame) | |
1541 { | 1560 { |
1542 m_frame = frame; | 1561 m_frame = frame; |
1543 | 1562 |
1544 // FIXME: we shouldn't add overhead to every frame by registering these obje cts when they're not used. | 1563 // FIXME: we shouldn't add overhead to every frame by registering these obje cts when they're not used. |
1545 if (m_frame) { | 1564 if (m_frame) { |
1546 OwnPtr<NotificationPresenterImpl> notificationPresenter = adoptPtr(new N otificationPresenterImpl()); | 1565 OwnPtr<NotificationPresenterImpl> notificationPresenter = adoptPtr(new N otificationPresenterImpl()); |
1547 if (m_client) | 1566 if (m_client) |
1548 notificationPresenter->initialize(m_client->notificationPresenter()) ; | 1567 notificationPresenter->initialize(m_client->notificationPresenter()) ; |
1549 | 1568 |
1550 provideNotification(*m_frame, notificationPresenter.release()); | 1569 provideNotification(*m_frame, notificationPresenter.release()); |
1551 provideNotificationPermissionClientTo(*m_frame, NotificationPermissionCl ientImpl::create()); | 1570 provideNotificationPermissionClientTo(*m_frame, NotificationPermissionCl ientImpl::create()); |
1552 provideUserMediaTo(*m_frame, &m_userMediaClientImpl); | 1571 provideUserMediaTo(*m_frame, &m_userMediaClientImpl); |
1553 provideGeolocationTo(*m_frame, m_geolocationClientProxy.get()); | 1572 provideGeolocationTo(*m_frame, m_geolocationClientProxy.get()); |
1554 m_geolocationClientProxy->setController(GeolocationController::from(m_fr ame.get())); | 1573 m_geolocationClientProxy->setController(GeolocationController::from(m_fr ame.get())); |
1555 provideMIDITo(*m_frame, MIDIClientProxy::create(m_client ? m_client->web MIDIClient() : 0)); | 1574 provideMIDITo(*m_frame, MIDIClientProxy::create(m_client ? m_client->web MIDIClient() : 0)); |
1556 provideLocalFileSystemTo(*m_frame, LocalFileSystemClient::create()); | 1575 provideLocalFileSystemTo(*m_frame, LocalFileSystemClient::create()); |
1557 | 1576 |
1558 if (RuntimeEnabledFeatures::screenOrientationEnabled()) | 1577 if (RuntimeEnabledFeatures::screenOrientationEnabled()) |
1559 ScreenOrientationController::provideTo(*m_frame, m_client ? m_client ->webScreenOrientationClient() : 0); | 1578 ScreenOrientationController::provideTo(*m_frame, m_client ? m_client ->webScreenOrientationClient() : 0); |
1560 } | 1579 } |
1561 } | 1580 } |
1562 | 1581 |
1563 PassRefPtr<LocalFrame> WebLocalFrameImpl::initializeCoreFrame(FrameHost* host, F rameOwner* owner, const AtomicString& name, const AtomicString& fallbackName) | 1582 PassRefPtrWillBeRawPtr<LocalFrame> WebLocalFrameImpl::initializeCoreFrame(FrameH ost* host, FrameOwner* owner, const AtomicString& name, const AtomicString& fall backName) |
1564 { | 1583 { |
1565 RefPtr<LocalFrame> frame = LocalFrame::create(&m_frameLoaderClientImpl, host , owner); | 1584 RefPtrWillBeRawPtr<LocalFrame> frame = LocalFrame::create(&m_frameLoaderClie ntImpl, host, owner); |
1566 setCoreFrame(frame); | 1585 setCoreFrame(frame); |
1567 frame->tree().setName(name, fallbackName); | 1586 frame->tree().setName(name, fallbackName); |
1568 // We must call init() after m_frame is assigned because it is referenced | 1587 // We must call init() after m_frame is assigned because it is referenced |
1569 // during init(). Note that this may dispatch JS events; the frame may be | 1588 // during init(). Note that this may dispatch JS events; the frame may be |
1570 // detached after init() returns. | 1589 // detached after init() returns. |
1571 frame->init(); | 1590 frame->init(); |
1572 return frame; | 1591 return frame; |
1573 } | 1592 } |
1574 | 1593 |
1575 PassRefPtr<LocalFrame> WebLocalFrameImpl::createChildFrame(const FrameLoadReques t& request, HTMLFrameOwnerElement* ownerElement) | 1594 PassRefPtrWillBeRawPtr<LocalFrame> WebLocalFrameImpl::createChildFrame(const Fra meLoadRequest& request, HTMLFrameOwnerElement* ownerElement) |
1576 { | 1595 { |
1577 ASSERT(m_client); | 1596 ASSERT(m_client); |
1578 WebLocalFrameImpl* webframeChild = toWebLocalFrameImpl(m_client->createChild Frame(this, request.frameName())); | 1597 WebLocalFrameImpl* webframeChild = toWebLocalFrameImpl(m_client->createChild Frame(this, request.frameName())); |
1579 if (!webframeChild) | 1598 if (!webframeChild) |
1580 return nullptr; | 1599 return nullptr; |
1581 | 1600 |
1582 // FIXME: Using subResourceAttributeName as fallback is not a perfect | 1601 // FIXME: Using subResourceAttributeName as fallback is not a perfect |
1583 // solution. subResourceAttributeName returns just one attribute name. The | 1602 // solution. subResourceAttributeName returns just one attribute name. The |
1584 // element might not have the attribute, and there might be other attributes | 1603 // element might not have the attribute, and there might be other attributes |
1585 // which can identify the element. | 1604 // which can identify the element. |
1586 RefPtr<LocalFrame> child = webframeChild->initializeCoreFrame(frame()->host( ), ownerElement, request.frameName(), ownerElement->getAttribute(ownerElement->s ubResourceAttributeName())); | 1605 RefPtrWillBeRawPtr<LocalFrame> child = webframeChild->initializeCoreFrame(fr ame()->host(), ownerElement, request.frameName(), ownerElement->getAttribute(own erElement->subResourceAttributeName())); |
1587 // Initializing the core frame may cause the new child to be detached, since | 1606 // Initializing the core frame may cause the new child to be detached, since |
1588 // it may dispatch a load event in the parent. | 1607 // it may dispatch a load event in the parent. |
1589 if (!child->tree().parent()) | 1608 if (!child->tree().parent()) |
1590 return nullptr; | 1609 return nullptr; |
1591 | 1610 |
1592 // If we're moving in the back/forward list, we might want to replace the co ntent | 1611 // If we're moving in the back/forward list, we might want to replace the co ntent |
1593 // of this child frame with whatever was there at that point. | 1612 // of this child frame with whatever was there at that point. |
1594 RefPtr<HistoryItem> childItem; | 1613 RefPtr<HistoryItem> childItem; |
1595 if (isBackForwardLoadType(frame()->loader().loadType()) && !frame()->documen t()->loadEventFinished()) | 1614 if (isBackForwardLoadType(frame()->loader().loadType()) && !frame()->documen t()->loadEventFinished()) |
1596 childItem = PassRefPtr<HistoryItem>(webframeChild->client()->historyItem ForNewChildFrame(webframeChild)); | 1615 childItem = PassRefPtr<HistoryItem>(webframeChild->client()->historyItem ForNewChildFrame(webframeChild)); |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1864 | 1883 |
1865 void WebLocalFrameImpl::invalidateAll() const | 1884 void WebLocalFrameImpl::invalidateAll() const |
1866 { | 1885 { |
1867 ASSERT(frame() && frame()->view()); | 1886 ASSERT(frame() && frame()->view()); |
1868 FrameView* view = frame()->view(); | 1887 FrameView* view = frame()->view(); |
1869 view->invalidateRect(view->frameRect()); | 1888 view->invalidateRect(view->frameRect()); |
1870 invalidateScrollbar(); | 1889 invalidateScrollbar(); |
1871 } | 1890 } |
1872 | 1891 |
1873 } // namespace blink | 1892 } // namespace blink |
OLD | NEW |