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

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

Issue 2714943004: Move unique name generation and tracking into //content. (Closed)
Patch Set: . 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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 WebLocalFrame::close(); 535 WebLocalFrame::close();
536 536
537 m_client = nullptr; 537 m_client = nullptr;
538 538
539 if (m_devToolsAgent) 539 if (m_devToolsAgent)
540 m_devToolsAgent.clear(); 540 m_devToolsAgent.clear();
541 541
542 m_selfKeepAlive.clear(); 542 m_selfKeepAlive.clear();
543 } 543 }
544 544
545 WebString WebLocalFrameImpl::uniqueName() const {
546 return frame()->tree().uniqueName();
547 }
548
549 WebString WebLocalFrameImpl::assignedName() const { 545 WebString WebLocalFrameImpl::assignedName() const {
550 return frame()->tree().name(); 546 return frame()->tree().name();
551 } 547 }
552 548
553 void WebLocalFrameImpl::setName(const WebString& name) { 549 void WebLocalFrameImpl::setName(const WebString& name) {
554 frame()->tree().setName(name); 550 frame()->tree().setName(name);
555 } 551 }
556 552
557 WebVector<WebIconURL> WebLocalFrameImpl::iconURLs(int iconTypesMask) const { 553 WebVector<WebIconURL> WebLocalFrameImpl::iconURLs(int iconTypesMask) const {
558 // The URL to the icon may be in the header. As such, only 554 // The URL to the icon may be in the header. As such, only
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 // Note: this *always* temporarily sets a frame owner, even for main frames! 1501 // Note: this *always* temporarily sets a frame owner, even for main frames!
1506 // When a core Frame is created with no owner, it attempts to set itself as 1502 // When a core Frame is created with no owner, it attempts to set itself as
1507 // the main frame of the Page. However, this is a provisional frame, and may 1503 // the main frame of the Page. However, this is a provisional frame, and may
1508 // disappear, so Page::m_mainFrame can't be updated just yet. 1504 // disappear, so Page::m_mainFrame can't be updated just yet.
1509 FrameOwner* tempOwner = DummyFrameOwner::create(); 1505 FrameOwner* tempOwner = DummyFrameOwner::create();
1510 // TODO(dcheng): This block is very similar to initializeCoreFrame. Try to 1506 // TODO(dcheng): This block is very similar to initializeCoreFrame. Try to
1511 // reuse it here. 1507 // reuse it here.
1512 LocalFrame* frame = LocalFrame::create(webFrame->m_localFrameClientImpl.get(), 1508 LocalFrame* frame = LocalFrame::create(webFrame->m_localFrameClientImpl.get(),
1513 oldFrame->host(), tempOwner, 1509 oldFrame->host(), tempOwner,
1514 interfaceProvider, interfaceRegistry); 1510 interfaceProvider, interfaceRegistry);
1515 // Set the name and unique name directly, bypassing any of the normal logic 1511 frame->tree().setName(
1516 // to calculate unique name. 1512 toWebRemoteFrameImpl(oldWebFrame)->frame()->tree().name());
1517 frame->tree().setPrecalculatedName(
1518 toWebRemoteFrameImpl(oldWebFrame)->frame()->tree().name(),
1519 toWebRemoteFrameImpl(oldWebFrame)->frame()->tree().uniqueName());
1520 webFrame->setCoreFrame(frame); 1513 webFrame->setCoreFrame(frame);
1521 1514
1522 frame->setOwner(oldFrame->owner()); 1515 frame->setOwner(oldFrame->owner());
1523 1516
1524 if (frame->owner() && frame->owner()->isRemote()) 1517 if (frame->owner() && frame->owner()->isRemote())
1525 toRemoteFrameOwner(frame->owner()) 1518 toRemoteFrameOwner(frame->owner())
1526 ->setSandboxFlags(static_cast<SandboxFlags>(flags)); 1519 ->setSandboxFlags(static_cast<SandboxFlags>(flags));
1527 1520
1528 // We must call init() after m_frame is assigned because it is referenced 1521 // We must call init() after m_frame is assigned because it is referenced
1529 // during init(). Note that this may dispatch JS events; the frame may be 1522 // 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
1581 WebFrame::traceFrames(visitor, this); 1574 WebFrame::traceFrames(visitor, this);
1582 WebFrameImplBase::trace(visitor); 1575 WebFrameImplBase::trace(visitor);
1583 } 1576 }
1584 1577
1585 void WebLocalFrameImpl::setCoreFrame(LocalFrame* frame) { 1578 void WebLocalFrameImpl::setCoreFrame(LocalFrame* frame) {
1586 m_frame = frame; 1579 m_frame = frame;
1587 } 1580 }
1588 1581
1589 void WebLocalFrameImpl::initializeCoreFrame(FrameHost* host, 1582 void WebLocalFrameImpl::initializeCoreFrame(FrameHost* host,
1590 FrameOwner* owner, 1583 FrameOwner* owner,
1591 const AtomicString& name, 1584 const AtomicString& name) {
1592 const AtomicString& uniqueName) {
1593 setCoreFrame(LocalFrame::create(m_localFrameClientImpl.get(), host, owner, 1585 setCoreFrame(LocalFrame::create(m_localFrameClientImpl.get(), host, owner,
1594 m_interfaceProvider, m_interfaceRegistry)); 1586 m_interfaceProvider, m_interfaceRegistry));
1595 frame()->tree().setPrecalculatedName(name, uniqueName); 1587 frame()->tree().setName(name);
1596 // We must call init() after m_frame is assigned because it is referenced 1588 // We must call init() after m_frame is assigned because it is referenced
1597 // during init(). Note that this may dispatch JS events; the frame may be 1589 // during init(). Note that this may dispatch JS events; the frame may be
1598 // detached after init() returns. 1590 // detached after init() returns.
1599 frame()->init(); 1591 frame()->init();
1600 if (frame()) { 1592 if (frame()) {
1601 if (frame()->loader().stateMachine()->isDisplayingInitialEmptyDocument() && 1593 if (frame()->loader().stateMachine()->isDisplayingInitialEmptyDocument() &&
1602 !parent() && !opener() && 1594 !parent() && !opener() &&
1603 frame()->settings()->getShouldReuseGlobalForUnownedMainFrame()) { 1595 frame()->settings()->getShouldReuseGlobalForUnownedMainFrame()) {
1604 frame()->document()->getSecurityOrigin()->grantUniversalAccess(); 1596 frame()->document()->getSecurityOrigin()->grantUniversalAccess();
1605 } 1597 }
(...skipping 21 matching lines...) Expand all
1627 WebFrameOwnerProperties ownerProperties( 1619 WebFrameOwnerProperties ownerProperties(
1628 ownerElement->browsingContextContainerName(), 1620 ownerElement->browsingContextContainerName(),
1629 ownerElement->scrollingMode(), ownerElement->marginWidth(), 1621 ownerElement->scrollingMode(), ownerElement->marginWidth(),
1630 ownerElement->marginHeight(), ownerElement->allowFullscreen(), 1622 ownerElement->marginHeight(), ownerElement->allowFullscreen(),
1631 ownerElement->allowPaymentRequest(), ownerElement->csp(), 1623 ownerElement->allowPaymentRequest(), ownerElement->csp(),
1632 ownerElement->delegatedPermissions(), ownerElement->allowedFeatures()); 1624 ownerElement->delegatedPermissions(), ownerElement->allowedFeatures());
1633 // FIXME: Using subResourceAttributeName as fallback is not a perfect 1625 // FIXME: Using subResourceAttributeName as fallback is not a perfect
1634 // solution. subResourceAttributeName returns just one attribute name. The 1626 // solution. subResourceAttributeName returns just one attribute name. The
1635 // element might not have the attribute, and there might be other attributes 1627 // element might not have the attribute, and there might be other attributes
1636 // which can identify the element. 1628 // which can identify the element.
1637 AtomicString uniqueName = frame()->tree().calculateUniqueNameForNewChildFrame(
1638 name,
1639 ownerElement->getAttribute(ownerElement->subResourceAttributeName()));
1640 WebLocalFrameImpl* webframeChild = 1629 WebLocalFrameImpl* webframeChild =
1641 toWebLocalFrameImpl(m_client->createChildFrame( 1630 toWebLocalFrameImpl(m_client->createChildFrame(
1642 this, scope, name, uniqueName, 1631 this, scope, name,
1632 ownerElement->getAttribute(ownerElement->subResourceAttributeName()),
1643 static_cast<WebSandboxFlags>(ownerElement->getSandboxFlags()), 1633 static_cast<WebSandboxFlags>(ownerElement->getSandboxFlags()),
1644 ownerProperties)); 1634 ownerProperties));
1645 if (!webframeChild) 1635 if (!webframeChild)
1646 return nullptr; 1636 return nullptr;
1647 1637
1648 webframeChild->initializeCoreFrame(frame()->host(), ownerElement, name, 1638 webframeChild->initializeCoreFrame(frame()->host(), ownerElement, name);
1649 uniqueName);
1650 // Initializing the core frame may cause the new child to be detached, since 1639 // Initializing the core frame may cause the new child to be detached, since
1651 // it may dispatch a load event in the parent. 1640 // it may dispatch a load event in the parent.
1652 if (!webframeChild->parent()) 1641 if (!webframeChild->parent())
1653 return nullptr; 1642 return nullptr;
1654 1643
1655 // If we're moving in the back/forward list, we might want to replace the 1644 // If we're moving in the back/forward list, we might want to replace the
1656 // content of this child frame with whatever was there at that point. 1645 // content of this child frame with whatever was there at that point.
1657 HistoryItem* childItem = nullptr; 1646 HistoryItem* childItem = nullptr;
1658 if (isBackForwardLoadType(frame()->loader().documentLoader()->loadType()) && 1647 if (isBackForwardLoadType(frame()->loader().documentLoader()->loadType()) &&
1659 !frame()->document()->loadEventFinished()) 1648 !frame()->document()->loadEventFinished())
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
2454 createMarkup(startPosition, endPosition, AnnotateForInterchange, 2443 createMarkup(startPosition, endPosition, AnnotateForInterchange,
2455 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs); 2444 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs);
2456 } else { 2445 } else {
2457 clipHtml = 2446 clipHtml =
2458 createMarkup(endPosition, startPosition, AnnotateForInterchange, 2447 createMarkup(endPosition, startPosition, AnnotateForInterchange,
2459 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs); 2448 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs);
2460 } 2449 }
2461 } 2450 }
2462 2451
2463 } // namespace blink 2452 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698