Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: third_party/WebKit/Source/web/WebLocalFrameImpl.cpp

Issue 2714943004: Move unique name generation and tracking into //content. (Closed)
Patch Set: Rebase again. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 WebLocalFrame::close(); 538 WebLocalFrame::close();
539 539
540 m_client = nullptr; 540 m_client = nullptr;
541 541
542 if (m_devToolsAgent) 542 if (m_devToolsAgent)
543 m_devToolsAgent.clear(); 543 m_devToolsAgent.clear();
544 544
545 m_selfKeepAlive.clear(); 545 m_selfKeepAlive.clear();
546 } 546 }
547 547
548 WebString WebLocalFrameImpl::uniqueName() const {
549 return frame()->tree().uniqueName();
550 }
551
552 WebString WebLocalFrameImpl::assignedName() const { 548 WebString WebLocalFrameImpl::assignedName() const {
553 return frame()->tree().name(); 549 return frame()->tree().name();
554 } 550 }
555 551
556 void WebLocalFrameImpl::setName(const WebString& name) { 552 void WebLocalFrameImpl::setName(const WebString& name) {
557 frame()->tree().setName(name); 553 frame()->tree().setName(name);
558 } 554 }
559 555
560 WebVector<WebIconURL> WebLocalFrameImpl::iconURLs(int iconTypesMask) const { 556 WebVector<WebIconURL> WebLocalFrameImpl::iconURLs(int iconTypesMask) const {
561 // The URL to the icon may be in the header. As such, only 557 // The URL to the icon may be in the header. As such, only
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 // Note: this *always* temporarily sets a frame owner, even for main frames! 1521 // Note: this *always* temporarily sets a frame owner, even for main frames!
1526 // When a core Frame is created with no owner, it attempts to set itself as 1522 // When a core Frame is created with no owner, it attempts to set itself as
1527 // the main frame of the Page. However, this is a provisional frame, and may 1523 // the main frame of the Page. However, this is a provisional frame, and may
1528 // disappear, so Page::m_mainFrame can't be updated just yet. 1524 // disappear, so Page::m_mainFrame can't be updated just yet.
1529 FrameOwner* tempOwner = DummyFrameOwner::create(); 1525 FrameOwner* tempOwner = DummyFrameOwner::create();
1530 // TODO(dcheng): This block is very similar to initializeCoreFrame. Try to 1526 // TODO(dcheng): This block is very similar to initializeCoreFrame. Try to
1531 // reuse it here. 1527 // reuse it here.
1532 LocalFrame* frame = LocalFrame::create(webFrame->m_localFrameClientImpl.get(), 1528 LocalFrame* frame = LocalFrame::create(webFrame->m_localFrameClientImpl.get(),
1533 oldFrame->page(), tempOwner, 1529 oldFrame->page(), tempOwner,
1534 interfaceProvider, interfaceRegistry); 1530 interfaceProvider, interfaceRegistry);
1535 // Set the name and unique name directly, bypassing any of the normal logic 1531 frame->tree().setName(
1536 // to calculate unique name. 1532 toWebRemoteFrameImpl(oldWebFrame)->frame()->tree().name());
1537 frame->tree().setPrecalculatedName(
1538 toWebRemoteFrameImpl(oldWebFrame)->frame()->tree().name(),
1539 toWebRemoteFrameImpl(oldWebFrame)->frame()->tree().uniqueName());
1540 webFrame->setCoreFrame(frame); 1533 webFrame->setCoreFrame(frame);
1541 1534
1542 frame->setOwner(oldFrame->owner()); 1535 frame->setOwner(oldFrame->owner());
1543 1536
1544 if (frame->owner() && frame->owner()->isRemote()) 1537 if (frame->owner() && frame->owner()->isRemote())
1545 toRemoteFrameOwner(frame->owner()) 1538 toRemoteFrameOwner(frame->owner())
1546 ->setSandboxFlags(static_cast<SandboxFlags>(flags)); 1539 ->setSandboxFlags(static_cast<SandboxFlags>(flags));
1547 1540
1548 // We must call init() after m_frame is assigned because it is referenced 1541 // We must call init() after m_frame is assigned because it is referenced
1549 // during init(). Note that this may dispatch JS events; the frame may be 1542 // during init(). Note that this may dispatch JS events; the frame may be
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1601 WebFrame::traceFrames(visitor, this); 1594 WebFrame::traceFrames(visitor, this);
1602 WebFrameImplBase::trace(visitor); 1595 WebFrameImplBase::trace(visitor);
1603 } 1596 }
1604 1597
1605 void WebLocalFrameImpl::setCoreFrame(LocalFrame* frame) { 1598 void WebLocalFrameImpl::setCoreFrame(LocalFrame* frame) {
1606 m_frame = frame; 1599 m_frame = frame;
1607 } 1600 }
1608 1601
1609 void WebLocalFrameImpl::initializeCoreFrame(FrameHost* host, 1602 void WebLocalFrameImpl::initializeCoreFrame(FrameHost* host,
1610 FrameOwner* owner, 1603 FrameOwner* owner,
1611 const AtomicString& name, 1604 const AtomicString& name) {
1612 const AtomicString& uniqueName) {
1613 setCoreFrame(LocalFrame::create(m_localFrameClientImpl.get(), 1605 setCoreFrame(LocalFrame::create(m_localFrameClientImpl.get(),
1614 host ? &host->page() : nullptr, owner, 1606 host ? &host->page() : nullptr, owner,
1615 m_interfaceProvider, m_interfaceRegistry)); 1607 m_interfaceProvider, m_interfaceRegistry));
1616 frame()->tree().setPrecalculatedName(name, uniqueName); 1608 frame()->tree().setName(name);
1617 // We must call init() after m_frame is assigned because it is referenced 1609 // We must call init() after m_frame is assigned because it is referenced
1618 // during init(). Note that this may dispatch JS events; the frame may be 1610 // during init(). Note that this may dispatch JS events; the frame may be
1619 // detached after init() returns. 1611 // detached after init() returns.
1620 frame()->init(); 1612 frame()->init();
1621 if (frame()) { 1613 if (frame()) {
1622 if (frame()->loader().stateMachine()->isDisplayingInitialEmptyDocument() && 1614 if (frame()->loader().stateMachine()->isDisplayingInitialEmptyDocument() &&
1623 !parent() && !opener() && 1615 !parent() && !opener() &&
1624 frame()->settings()->getShouldReuseGlobalForUnownedMainFrame()) { 1616 frame()->settings()->getShouldReuseGlobalForUnownedMainFrame()) {
1625 frame()->document()->getSecurityOrigin()->grantUniversalAccess(); 1617 frame()->document()->getSecurityOrigin()->grantUniversalAccess();
1626 } 1618 }
(...skipping 27 matching lines...) Expand all
1654 WebFrameOwnerProperties ownerProperties( 1646 WebFrameOwnerProperties ownerProperties(
1655 ownerElement->browsingContextContainerName(), 1647 ownerElement->browsingContextContainerName(),
1656 ownerElement->scrollingMode(), ownerElement->marginWidth(), 1648 ownerElement->scrollingMode(), ownerElement->marginWidth(),
1657 ownerElement->marginHeight(), ownerElement->allowFullscreen(), 1649 ownerElement->marginHeight(), ownerElement->allowFullscreen(),
1658 ownerElement->allowPaymentRequest(), ownerElement->csp(), 1650 ownerElement->allowPaymentRequest(), ownerElement->csp(),
1659 ownerElement->allowedFeatures()); 1651 ownerElement->allowedFeatures());
1660 // FIXME: Using subResourceAttributeName as fallback is not a perfect 1652 // FIXME: Using subResourceAttributeName as fallback is not a perfect
1661 // solution. subResourceAttributeName returns just one attribute name. The 1653 // solution. subResourceAttributeName returns just one attribute name. The
1662 // element might not have the attribute, and there might be other attributes 1654 // element might not have the attribute, and there might be other attributes
1663 // which can identify the element. 1655 // which can identify the element.
1664 AtomicString uniqueName = frame()->tree().calculateUniqueNameForNewChildFrame(
1665 name,
1666 ownerElement->getAttribute(ownerElement->subResourceAttributeName()));
1667 WebLocalFrameImpl* webframeChild = 1656 WebLocalFrameImpl* webframeChild =
1668 toWebLocalFrameImpl(m_client->createChildFrame( 1657 toWebLocalFrameImpl(m_client->createChildFrame(
1669 this, scope, name, uniqueName, 1658 this, scope, name,
1659 ownerElement->getAttribute(ownerElement->subResourceAttributeName()),
1670 static_cast<WebSandboxFlags>(ownerElement->getSandboxFlags()), 1660 static_cast<WebSandboxFlags>(ownerElement->getSandboxFlags()),
1671 ownerProperties)); 1661 ownerProperties));
1672 if (!webframeChild) 1662 if (!webframeChild)
1673 return nullptr; 1663 return nullptr;
1674 1664
1675 webframeChild->initializeCoreFrame(frame()->host(), ownerElement, name, 1665 webframeChild->initializeCoreFrame(frame()->host(), ownerElement, name);
1676 uniqueName);
1677 // Initializing the core frame may cause the new child to be detached, since 1666 // Initializing the core frame may cause the new child to be detached, since
1678 // it may dispatch a load event in the parent. 1667 // it may dispatch a load event in the parent.
1679 if (!webframeChild->parent()) 1668 if (!webframeChild->parent())
1680 return nullptr; 1669 return nullptr;
1681 1670
1682 // If we're moving in the back/forward list, we might want to replace the 1671 // If we're moving in the back/forward list, we might want to replace the
1683 // content of this child frame with whatever was there at that point. 1672 // content of this child frame with whatever was there at that point.
1684 HistoryItem* childItem = nullptr; 1673 HistoryItem* childItem = nullptr;
1685 if (isBackForwardLoadType(frame()->loader().documentLoader()->loadType()) && 1674 if (isBackForwardLoadType(frame()->loader().documentLoader()->loadType()) &&
1686 !frame()->document()->loadEventFinished()) 1675 !frame()->document()->loadEventFinished())
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
2516 createMarkup(startPosition, endPosition, AnnotateForInterchange, 2505 createMarkup(startPosition, endPosition, AnnotateForInterchange,
2517 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs); 2506 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs);
2518 } else { 2507 } else {
2519 clipHtml = 2508 clipHtml =
2520 createMarkup(endPosition, startPosition, AnnotateForInterchange, 2509 createMarkup(endPosition, startPosition, AnnotateForInterchange,
2521 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs); 2510 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs);
2522 } 2511 }
2523 } 2512 }
2524 2513
2525 } // namespace blink 2514 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebLocalFrameImpl.h ('k') | third_party/WebKit/Source/web/WebRemoteFrameImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698