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

Side by Side Diff: Source/web/WebFrameImpl.cpp

Issue 170603003: Use nullptr_t for RefPtr, PassRefPtr and RawPtr. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Final rebase Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « Source/web/WebFontImpl.cpp ('k') | Source/web/WebIDBKey.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 } 749 }
750 750
751 WebFrame* WebFrameImpl::findChildByExpression(const WebString& xpath) const 751 WebFrame* WebFrameImpl::findChildByExpression(const WebString& xpath) const
752 { 752 {
753 if (xpath.isEmpty()) 753 if (xpath.isEmpty())
754 return 0; 754 return 0;
755 755
756 Document* document = frame()->document(); 756 Document* document = frame()->document();
757 ASSERT(document); 757 ASSERT(document);
758 758
759 RefPtrWillBeRawPtr<XPathResult> xpathResult = DocumentXPathEvaluator::evalua te(*document, xpath, document, 0, XPathResult::ORDERED_NODE_ITERATOR_TYPE, 0, IG NORE_EXCEPTION); 759 RefPtrWillBeRawPtr<XPathResult> xpathResult = DocumentXPathEvaluator::evalua te(*document, xpath, document, nullptr, XPathResult::ORDERED_NODE_ITERATOR_TYPE, 0, IGNORE_EXCEPTION);
760 if (!xpathResult) 760 if (!xpathResult)
761 return 0; 761 return 0;
762 762
763 Node* node = xpathResult->iterateNext(IGNORE_EXCEPTION); 763 Node* node = xpathResult->iterateNext(IGNORE_EXCEPTION);
764 if (!node || !node->isFrameOwnerElement()) 764 if (!node || !node->isFrameOwnerElement())
765 return 0; 765 return 0;
766 return fromFrame(toHTMLFrameOwnerElement(node)->contentFrame()); 766 return fromFrame(toHTMLFrameOwnerElement(node)->contentFrame());
767 } 767 }
768 768
769 WebDocument WebFrameImpl::document() const 769 WebDocument WebFrameImpl::document() const
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
1494 return false; 1494 return false;
1495 1495
1496 WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl(); 1496 WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl();
1497 1497
1498 if (!options.findNext) 1498 if (!options.findNext)
1499 frame()->page()->unmarkAllTextMatches(); 1499 frame()->page()->unmarkAllTextMatches();
1500 else 1500 else
1501 setMarkerActive(m_activeMatch.get(), false); 1501 setMarkerActive(m_activeMatch.get(), false);
1502 1502
1503 if (m_activeMatch && &m_activeMatch->ownerDocument() != frame()->document()) 1503 if (m_activeMatch && &m_activeMatch->ownerDocument() != frame()->document())
1504 m_activeMatch = 0; 1504 m_activeMatch = nullptr;
1505 1505
1506 // If the user has selected something since the last Find operation we want 1506 // If the user has selected something since the last Find operation we want
1507 // to start from there. Otherwise, we start searching from where the last Fi nd 1507 // to start from there. Otherwise, we start searching from where the last Fi nd
1508 // operation left off (either a Find or a FindNext operation). 1508 // operation left off (either a Find or a FindNext operation).
1509 VisibleSelection selection(frame()->selection().selection()); 1509 VisibleSelection selection(frame()->selection().selection());
1510 bool activeSelection = !selection.isNone(); 1510 bool activeSelection = !selection.isNone();
1511 if (activeSelection) { 1511 if (activeSelection) {
1512 m_activeMatch = selection.firstRange().get(); 1512 m_activeMatch = selection.firstRange().get();
1513 frame()->selection().clear(); 1513 frame()->selection().clear();
1514 } 1514 }
(...skipping 18 matching lines...) Expand all
1533 1533
1534 #if OS(ANDROID) 1534 #if OS(ANDROID)
1535 viewImpl()->zoomToFindInPageRect(frameView()->contentsToWindow(enclosingIntR ect(RenderObject::absoluteBoundingBoxRectForRange(m_activeMatch.get())))); 1535 viewImpl()->zoomToFindInPageRect(frameView()->contentsToWindow(enclosingIntR ect(RenderObject::absoluteBoundingBoxRectForRange(m_activeMatch.get()))));
1536 #endif 1536 #endif
1537 1537
1538 setMarkerActive(m_activeMatch.get(), true); 1538 setMarkerActive(m_activeMatch.get(), true);
1539 WebFrameImpl* oldActiveFrame = mainFrameImpl->m_currentActiveMatchFrame; 1539 WebFrameImpl* oldActiveFrame = mainFrameImpl->m_currentActiveMatchFrame;
1540 mainFrameImpl->m_currentActiveMatchFrame = this; 1540 mainFrameImpl->m_currentActiveMatchFrame = this;
1541 1541
1542 // Make sure no node is focused. See http://crbug.com/38700. 1542 // Make sure no node is focused. See http://crbug.com/38700.
1543 frame()->document()->setFocusedElement(0); 1543 frame()->document()->setFocusedElement(nullptr);
1544 1544
1545 if (!options.findNext || activeSelection) { 1545 if (!options.findNext || activeSelection) {
1546 // This is either a Find operation or a Find-next from a new start point 1546 // This is either a Find operation or a Find-next from a new start point
1547 // due to a selection, so we set the flag to ask the scoping effort 1547 // due to a selection, so we set the flag to ask the scoping effort
1548 // to find the active rect for us and report it back to the UI. 1548 // to find the active rect for us and report it back to the UI.
1549 m_locatingActiveRect = true; 1549 m_locatingActiveRect = true;
1550 } else { 1550 } else {
1551 if (oldActiveFrame != this) { 1551 if (oldActiveFrame != this) {
1552 if (options.forward) 1552 if (options.forward)
1553 m_activeMatchIndexInCurrentFrame = 0; 1553 m_activeMatchIndexInCurrentFrame = 0;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 if (frame() && frame()->page() && frame()->editor().markedTextMatchesAre Highlighted()) 1603 if (frame() && frame()->page() && frame()->editor().markedTextMatchesAre Highlighted())
1604 frame()->page()->unmarkAllTextMatches(); 1604 frame()->page()->unmarkAllTextMatches();
1605 1605
1606 // Clear the tickmarks and results cache. 1606 // Clear the tickmarks and results cache.
1607 clearFindMatchesCache(); 1607 clearFindMatchesCache();
1608 1608
1609 // Clear the counters from last operation. 1609 // Clear the counters from last operation.
1610 m_lastMatchCount = 0; 1610 m_lastMatchCount = 0;
1611 m_nextInvalidateAfter = 0; 1611 m_nextInvalidateAfter = 0;
1612 1612
1613 m_resumeScopingFromRange = 0; 1613 m_resumeScopingFromRange = nullptr;
1614 1614
1615 // The view might be null on detached frames. 1615 // The view might be null on detached frames.
1616 if (frame() && frame()->page()) 1616 if (frame() && frame()->page())
1617 viewImpl()->mainFrameImpl()->m_framesScopingCount++; 1617 viewImpl()->mainFrameImpl()->m_framesScopingCount++;
1618 1618
1619 // Now, defer scoping until later to allow find operation to finish quic kly. 1619 // Now, defer scoping until later to allow find operation to finish quic kly.
1620 scopeStringMatchesSoon(identifier, searchText, options, false); // false means just reset, so don't do it again. 1620 scopeStringMatchesSoon(identifier, searchText, options, false); // false means just reset, so don't do it again.
1621 return; 1621 return;
1622 } 1622 }
1623 1623
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1832 1832
1833 void WebFrameImpl::sendOrientationChangeEvent(int orientation) 1833 void WebFrameImpl::sendOrientationChangeEvent(int orientation)
1834 { 1834 {
1835 if (frame()) 1835 if (frame())
1836 frame()->sendOrientationChangeEvent(orientation); 1836 frame()->sendOrientationChangeEvent(orientation);
1837 } 1837 }
1838 1838
1839 void WebFrameImpl::dispatchMessageEventWithOriginCheck(const WebSecurityOrigin& intendedTargetOrigin, const WebDOMEvent& event) 1839 void WebFrameImpl::dispatchMessageEventWithOriginCheck(const WebSecurityOrigin& intendedTargetOrigin, const WebDOMEvent& event)
1840 { 1840 {
1841 ASSERT(!event.isNull()); 1841 ASSERT(!event.isNull());
1842 frame()->domWindow()->dispatchMessageEventWithOriginCheck(intendedTargetOrig in.get(), event, 0); 1842 frame()->domWindow()->dispatchMessageEventWithOriginCheck(intendedTargetOrig in.get(), event, nullptr);
1843 } 1843 }
1844 1844
1845 int WebFrameImpl::findMatchMarkersVersion() const 1845 int WebFrameImpl::findMatchMarkersVersion() const
1846 { 1846 {
1847 ASSERT(!parent()); 1847 ASSERT(!parent());
1848 return m_findMatchMarkersVersion; 1848 return m_findMatchMarkersVersion;
1849 } 1849 }
1850 1850
1851 void WebFrameImpl::clearFindMatchesCache() 1851 void WebFrameImpl::clearFindMatchesCache()
1852 { 1852 {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1998 viewImpl()->mainFrameImpl()->m_currentActiveMatchFrame = this; 1998 viewImpl()->mainFrameImpl()->m_currentActiveMatchFrame = this;
1999 viewImpl()->setFocusedFrame(this); 1999 viewImpl()->setFocusedFrame(this);
2000 2000
2001 m_activeMatch = range.release(); 2001 m_activeMatch = range.release();
2002 setMarkerActive(m_activeMatch.get(), true); 2002 setMarkerActive(m_activeMatch.get(), true);
2003 2003
2004 // Clear any user selection, to make sure Find Next continues on from th e match we just activated. 2004 // Clear any user selection, to make sure Find Next continues on from th e match we just activated.
2005 frame()->selection().clear(); 2005 frame()->selection().clear();
2006 2006
2007 // Make sure no node is focused. See http://crbug.com/38700. 2007 // Make sure no node is focused. See http://crbug.com/38700.
2008 frame()->document()->setFocusedElement(0); 2008 frame()->document()->setFocusedElement(nullptr);
2009 } 2009 }
2010 2010
2011 IntRect activeMatchRect; 2011 IntRect activeMatchRect;
2012 IntRect activeMatchBoundingBox = enclosingIntRect(RenderObject::absoluteBoun dingBoxRectForRange(m_activeMatch.get())); 2012 IntRect activeMatchBoundingBox = enclosingIntRect(RenderObject::absoluteBoun dingBoxRectForRange(m_activeMatch.get()));
2013 2013
2014 if (!activeMatchBoundingBox.isEmpty()) { 2014 if (!activeMatchBoundingBox.isEmpty()) {
2015 if (m_activeMatch->firstNode() && m_activeMatch->firstNode()->renderer() ) 2015 if (m_activeMatch->firstNode() && m_activeMatch->firstNode()->renderer() )
2016 m_activeMatch->firstNode()->renderer()->scrollRectToVisible(activeMa tchBoundingBox, 2016 m_activeMatch->firstNode()->renderer()->scrollRectToVisible(activeMa tchBoundingBox,
2017 ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::align CenterIfNeeded); 2017 ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::align CenterIfNeeded);
2018 2018
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
2125 , m_parent(0) 2125 , m_parent(0)
2126 , m_previousSibling(0) 2126 , m_previousSibling(0)
2127 , m_nextSibling(0) 2127 , m_nextSibling(0)
2128 , m_firstChild(0) 2128 , m_firstChild(0)
2129 , m_lastChild(0) 2129 , m_lastChild(0)
2130 , m_client(client) 2130 , m_client(client)
2131 , m_permissionClient(0) 2131 , m_permissionClient(0)
2132 , m_currentActiveMatchFrame(0) 2132 , m_currentActiveMatchFrame(0)
2133 , m_activeMatchIndexInCurrentFrame(-1) 2133 , m_activeMatchIndexInCurrentFrame(-1)
2134 , m_locatingActiveRect(false) 2134 , m_locatingActiveRect(false)
2135 , m_resumeScopingFromRange(0) 2135 , m_resumeScopingFromRange(nullptr)
2136 , m_lastMatchCount(-1) 2136 , m_lastMatchCount(-1)
2137 , m_totalMatchCount(-1) 2137 , m_totalMatchCount(-1)
2138 , m_framesScopingCount(-1) 2138 , m_framesScopingCount(-1)
2139 , m_findRequestIdentifier(-1) 2139 , m_findRequestIdentifier(-1)
2140 , m_scopingInProgress(false) 2140 , m_scopingInProgress(false)
2141 , m_lastFindRequestCompletedWithNoMatches(false) 2141 , m_lastFindRequestCompletedWithNoMatches(false)
2142 , m_nextInvalidateAfter(0) 2142 , m_nextInvalidateAfter(0)
2143 , m_findMatchMarkersVersion(0) 2143 , m_findMatchMarkersVersion(0)
2144 , m_findMatchRectsAreValid(false) 2144 , m_findMatchRectsAreValid(false)
2145 , m_inputEventsScaleFactorForEmulation(1) 2145 , m_inputEventsScaleFactorForEmulation(1)
(...skipping 23 matching lines...) Expand all
2169 // We must call init() after m_frame is assigned because it is referenced 2169 // We must call init() after m_frame is assigned because it is referenced
2170 // during init(). 2170 // during init().
2171 m_frame->init(); 2171 m_frame->init();
2172 } 2172 }
2173 2173
2174 PassRefPtr<Frame> WebFrameImpl::createChildFrame(const FrameLoadRequest& request , HTMLFrameOwnerElement* ownerElement) 2174 PassRefPtr<Frame> WebFrameImpl::createChildFrame(const FrameLoadRequest& request , HTMLFrameOwnerElement* ownerElement)
2175 { 2175 {
2176 ASSERT(m_client); 2176 ASSERT(m_client);
2177 WebFrameImpl* webframe = toWebFrameImpl(m_client->createChildFrame(this, req uest.frameName())); 2177 WebFrameImpl* webframe = toWebFrameImpl(m_client->createChildFrame(this, req uest.frameName()));
2178 if (!webframe) 2178 if (!webframe)
2179 return 0; 2179 return nullptr;
2180 2180
2181 webframe->m_frameInit->setFrameHost(frame()->host()); 2181 webframe->m_frameInit->setFrameHost(frame()->host());
2182 webframe->m_frameInit->setOwnerElement(ownerElement); 2182 webframe->m_frameInit->setOwnerElement(ownerElement);
2183 RefPtr<Frame> childFrame = Frame::create(webframe->m_frameInit); 2183 RefPtr<Frame> childFrame = Frame::create(webframe->m_frameInit);
2184 webframe->setWebCoreFrame(childFrame); 2184 webframe->setWebCoreFrame(childFrame);
2185 2185
2186 childFrame->tree().setName(request.frameName()); 2186 childFrame->tree().setName(request.frameName());
2187 2187
2188 // FIXME: This comment is not quite accurate anymore. 2188 // FIXME: This comment is not quite accurate anymore.
2189 // Frame::init() can trigger onload event in the parent frame, 2189 // Frame::init() can trigger onload event in the parent frame,
2190 // which may detach this frame and trigger a null-pointer access 2190 // which may detach this frame and trigger a null-pointer access
2191 // in FrameTree::removeChild. Move init() after appendChild call 2191 // in FrameTree::removeChild. Move init() after appendChild call
2192 // so that webframe->mFrame is in the tree before triggering 2192 // so that webframe->mFrame is in the tree before triggering
2193 // onload event handler. 2193 // onload event handler.
2194 // Because the event handler may set webframe->mFrame to null, 2194 // Because the event handler may set webframe->mFrame to null,
2195 // it is necessary to check the value after calling init() and 2195 // it is necessary to check the value after calling init() and
2196 // return without loading URL. 2196 // return without loading URL.
2197 // NOTE: m_client will be null if this frame has been detached. 2197 // NOTE: m_client will be null if this frame has been detached.
2198 // (b:791612) 2198 // (b:791612)
2199 childFrame->init(); // create an empty document 2199 childFrame->init(); // create an empty document
2200 if (!childFrame->tree().parent()) 2200 if (!childFrame->tree().parent())
2201 return 0; 2201 return nullptr;
2202 2202
2203 // If we're moving in the back/forward list, we might want to replace the co ntent 2203 // If we're moving in the back/forward list, we might want to replace the co ntent
2204 // of this child frame with whatever was there at that point. 2204 // of this child frame with whatever was there at that point.
2205 HistoryItem* childItem = 0; 2205 HistoryItem* childItem = 0;
2206 if (isBackForwardLoadType(frame()->loader().loadType()) && !frame()->documen t()->loadEventFinished()) 2206 if (isBackForwardLoadType(frame()->loader().loadType()) && !frame()->documen t()->loadEventFinished())
2207 childItem = frame()->page()->historyController().itemForNewChildFrame(ch ildFrame.get()); 2207 childItem = frame()->page()->historyController().itemForNewChildFrame(ch ildFrame.get());
2208 2208
2209 if (childItem) 2209 if (childItem)
2210 childFrame->loader().loadHistoryItem(childItem); 2210 childFrame->loader().loadHistoryItem(childItem);
2211 else 2211 else
2212 childFrame->loader().load(FrameLoadRequest(0, request.resourceRequest(), "_self")); 2212 childFrame->loader().load(FrameLoadRequest(0, request.resourceRequest(), "_self"));
2213 2213
2214 // A synchronous navigation (about:blank) would have already processed 2214 // A synchronous navigation (about:blank) would have already processed
2215 // onload, so it is possible for the frame to have already been destroyed by 2215 // onload, so it is possible for the frame to have already been destroyed by
2216 // script in the page. 2216 // script in the page.
2217 // NOTE: m_client will be null if this frame has been detached. 2217 // NOTE: m_client will be null if this frame has been detached.
2218 if (!childFrame->tree().parent()) 2218 if (!childFrame->tree().parent())
2219 return 0; 2219 return nullptr;
2220 2220
2221 return childFrame.release(); 2221 return childFrame.release();
2222 } 2222 }
2223 2223
2224 void WebFrameImpl::didChangeContentsSize(const IntSize& size) 2224 void WebFrameImpl::didChangeContentsSize(const IntSize& size)
2225 { 2225 {
2226 // This is only possible on the main frame. 2226 // This is only possible on the main frame.
2227 if (m_totalMatchCount > 0) { 2227 if (m_totalMatchCount > 0) {
2228 ASSERT(!parent()); 2228 ASSERT(!parent());
2229 ++m_findMatchMarkersVersion; 2229 ++m_findMatchMarkersVersion;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
2328 return; 2328 return;
2329 } 2329 }
2330 } 2330 }
2331 2331
2332 // No node related to the active match was focusable, so set the 2332 // No node related to the active match was focusable, so set the
2333 // active match as the selection (so that when you end the Find session, 2333 // active match as the selection (so that when you end the Find session,
2334 // you'll have the last thing you found highlighted) and make sure that 2334 // you'll have the last thing you found highlighted) and make sure that
2335 // we have nothing focused (otherwise you might have text selected but 2335 // we have nothing focused (otherwise you might have text selected but
2336 // a link focused, which is weird). 2336 // a link focused, which is weird).
2337 frame()->selection().setSelection(m_activeMatch.get()); 2337 frame()->selection().setSelection(m_activeMatch.get());
2338 frame()->document()->setFocusedElement(0); 2338 frame()->document()->setFocusedElement(nullptr);
2339 2339
2340 // Finally clear the active match, for two reasons: 2340 // Finally clear the active match, for two reasons:
2341 // We just finished the find 'session' and we don't want future (potenti ally 2341 // We just finished the find 'session' and we don't want future (potenti ally
2342 // unrelated) find 'sessions' operations to start at the same place. 2342 // unrelated) find 'sessions' operations to start at the same place.
2343 // The WebFrameImpl could get reused and the m_activeMatch could end up pointing 2343 // The WebFrameImpl could get reused and the m_activeMatch could end up pointing
2344 // to a document that is no longer valid. Keeping an invalid reference a round 2344 // to a document that is no longer valid. Keeping an invalid reference a round
2345 // is just asking for trouble. 2345 // is just asking for trouble.
2346 m_activeMatch = 0; 2346 m_activeMatch = nullptr;
2347 } 2347 }
2348 } 2348 }
2349 2349
2350 void WebFrameImpl::didFail(const ResourceError& error, bool wasProvisional) 2350 void WebFrameImpl::didFail(const ResourceError& error, bool wasProvisional)
2351 { 2351 {
2352 if (!client()) 2352 if (!client())
2353 return; 2353 return;
2354 WebURLError webError = error; 2354 WebURLError webError = error;
2355 if (wasProvisional) 2355 if (wasProvisional)
2356 client()->didFailProvisionalLoad(this, webError); 2356 client()->didFailProvisionalLoad(this, webError);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2519 2519
2520 // There is a possibility that the frame being detached was the only 2520 // There is a possibility that the frame being detached was the only
2521 // pending one. We need to make sure final replies can be sent. 2521 // pending one. We need to make sure final replies can be sent.
2522 flushCurrentScopingEffort(m_findRequestIdentifier); 2522 flushCurrentScopingEffort(m_findRequestIdentifier);
2523 2523
2524 cancelPendingScopingEffort(); 2524 cancelPendingScopingEffort();
2525 } 2525 }
2526 } 2526 }
2527 2527
2528 } // namespace blink 2528 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebFontImpl.cpp ('k') | Source/web/WebIDBKey.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698