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 1652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1663 setWebCoreFrame(LocalFrame::create(&m_frameLoaderClientImpl, &page->frameHos
t(), 0)); | 1663 setWebCoreFrame(LocalFrame::create(&m_frameLoaderClientImpl, &page->frameHos
t(), 0)); |
1664 | 1664 |
1665 // We must call init() after m_frame is assigned because it is referenced | 1665 // We must call init() after m_frame is assigned because it is referenced |
1666 // during init(). | 1666 // during init(). |
1667 m_frame->init(); | 1667 m_frame->init(); |
1668 } | 1668 } |
1669 | 1669 |
1670 PassRefPtr<LocalFrame> WebLocalFrameImpl::createChildFrame(const FrameLoadReques
t& request, HTMLFrameOwnerElement* ownerElement) | 1670 PassRefPtr<LocalFrame> WebLocalFrameImpl::createChildFrame(const FrameLoadReques
t& request, HTMLFrameOwnerElement* ownerElement) |
1671 { | 1671 { |
1672 ASSERT(m_client); | 1672 ASSERT(m_client); |
1673 // Protect a reference to the new child frame, in case it gets detached. | 1673 WebLocalFrameImpl* webframeChild = toWebLocalFrameImpl(m_client->createChild
Frame(this, request.frameName())); |
1674 RefPtr<WebLocalFrameImpl> child = toWebLocalFrameImpl(m_client->createChildF
rame(this, request.frameName())); | 1674 if (!webframeChild) |
1675 if (!child) | |
1676 return nullptr; | 1675 return nullptr; |
1677 | 1676 |
1678 // FIXME: Using subResourceAttributeName as fallback is not a perfect | 1677 // FIXME: Using subResourceAttributeName as fallback is not a perfect |
1679 // solution. subResourceAttributeName returns just one attribute name. The | 1678 // solution. subResourceAttributeName returns just one attribute name. The |
1680 // element might not have the attribute, and there might be other attributes | 1679 // element might not have the attribute, and there might be other attributes |
1681 // which can identify the element. | 1680 // which can identify the element. |
1682 child->initializeAsChildFrame(frame()->host(), ownerElement, request.frameNa
me(), ownerElement->getAttribute(ownerElement->subResourceAttributeName())); | 1681 RefPtr<LocalFrame> child = webframeChild->initializeAsChildFrame(frame()->ho
st(), ownerElement, request.frameName(), ownerElement->getAttribute(ownerElement
->subResourceAttributeName())); |
1683 // Initializing the WebCore frame may cause the new child to be detached, si
nce it may dispatch a load event in the parent. | 1682 // Initializing the WebCore frame may cause the new child to be detached, si
nce it may dispatch a load event in the parent. |
1684 if (!child->frame()) | 1683 if (!child->tree().parent()) |
1685 return nullptr; | 1684 return nullptr; |
1686 | 1685 |
1687 // If we're moving in the back/forward list, we might want to replace the co
ntent | 1686 // If we're moving in the back/forward list, we might want to replace the co
ntent |
1688 // of this child frame with whatever was there at that point. | 1687 // of this child frame with whatever was there at that point. |
1689 RefPtr<HistoryItem> childItem; | 1688 RefPtr<HistoryItem> childItem; |
1690 if (isBackForwardLoadType(frame()->loader().loadType()) && !frame()->documen
t()->loadEventFinished()) | 1689 if (isBackForwardLoadType(frame()->loader().loadType()) && !frame()->documen
t()->loadEventFinished()) |
1691 childItem = PassRefPtr<HistoryItem>(child->client()->historyItemForNewCh
ildFrame(child.get())); | 1690 childItem = PassRefPtr<HistoryItem>(webframeChild->client()->historyItem
ForNewChildFrame(webframeChild)); |
1692 | 1691 |
1693 if (childItem) | 1692 if (childItem) |
1694 child->frame()->loader().loadHistoryItem(childItem.get()); | 1693 child->loader().loadHistoryItem(childItem.get()); |
1695 else | 1694 else |
1696 child->frame()->loader().load(FrameLoadRequest(0, request.resourceReques
t(), "_self")); | 1695 child->loader().load(FrameLoadRequest(0, request.resourceRequest(), "_se
lf")); |
1697 | 1696 |
1698 // Note a synchronous navigation (about:blank) would have already processed | 1697 // Note a synchronous navigation (about:blank) would have already processed |
1699 // onload, so it is possible for the child frame to have already been destro
yed by | 1698 // onload, so it is possible for the child frame to have already been |
1700 // script in the page. | 1699 // detached by script in the page. |
1701 return child->frame(); | 1700 if (!child->tree().parent()) |
| 1701 return nullptr; |
| 1702 return child; |
1702 } | 1703 } |
1703 | 1704 |
1704 void WebLocalFrameImpl::didChangeContentsSize(const IntSize& size) | 1705 void WebLocalFrameImpl::didChangeContentsSize(const IntSize& size) |
1705 { | 1706 { |
1706 // This is only possible on the main frame. | 1707 // This is only possible on the main frame. |
1707 if (m_textFinder && m_textFinder->totalMatchCount() > 0) { | 1708 if (m_textFinder && m_textFinder->totalMatchCount() > 0) { |
1708 ASSERT(!parent()); | 1709 ASSERT(!parent()); |
1709 m_textFinder->increaseMarkerVersion(); | 1710 m_textFinder->increaseMarkerVersion(); |
1710 } | 1711 } |
1711 } | 1712 } |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1937 } | 1938 } |
1938 | 1939 |
1939 void WebLocalFrameImpl::invalidateAll() const | 1940 void WebLocalFrameImpl::invalidateAll() const |
1940 { | 1941 { |
1941 ASSERT(frame() && frame()->view()); | 1942 ASSERT(frame() && frame()->view()); |
1942 FrameView* view = frame()->view(); | 1943 FrameView* view = frame()->view(); |
1943 view->invalidateRect(view->frameRect()); | 1944 view->invalidateRect(view->frameRect()); |
1944 invalidateScrollbar(); | 1945 invalidateScrollbar(); |
1945 } | 1946 } |
1946 | 1947 |
1947 void WebLocalFrameImpl::initializeAsChildFrame(FrameHost* host, FrameOwner* owne
r, const AtomicString& name, const AtomicString& fallbackName) | 1948 PassRefPtr<LocalFrame> WebLocalFrameImpl::initializeAsChildFrame(FrameHost* host
, FrameOwner* owner, const AtomicString& name, const AtomicString& fallbackName) |
1948 { | 1949 { |
1949 setWebCoreFrame(LocalFrame::create(&m_frameLoaderClientImpl, host, owner)); | 1950 RefPtr<LocalFrame> frame = LocalFrame::create(&m_frameLoaderClientImpl, host
, owner); |
1950 frame()->tree().setName(name, fallbackName); | 1951 setWebCoreFrame(frame); |
1951 // May dispatch JS events; frame() may be null after this. | 1952 frame->tree().setName(name, fallbackName); |
1952 frame()->init(); | 1953 // May dispatch JS events; frame may be detached after this. |
| 1954 frame->init(); |
| 1955 return frame; |
1953 } | 1956 } |
1954 | 1957 |
1955 } // namespace blink | 1958 } // namespace blink |
OLD | NEW |