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

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

Issue 23671002: Refactoring: Add toWebFrameImpl() interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Corrected as per review commments. Created 7 years, 3 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
« no previous file with comments | « Source/web/WebFrameImpl.h ('k') | Source/web/WebPageSerializer.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 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 629
630 WebFrame* WebFrameImpl::opener() const 630 WebFrame* WebFrameImpl::opener() const
631 { 631 {
632 if (!frame()) 632 if (!frame())
633 return 0; 633 return 0;
634 return fromFrame(frame()->loader()->opener()); 634 return fromFrame(frame()->loader()->opener());
635 } 635 }
636 636
637 void WebFrameImpl::setOpener(const WebFrame* webFrame) 637 void WebFrameImpl::setOpener(const WebFrame* webFrame)
638 { 638 {
639 frame()->loader()->setOpener(webFrame ? static_cast<const WebFrameImpl*>(web Frame)->frame() : 0); 639 frame()->loader()->setOpener(webFrame ? toWebFrameImpl(webFrame)->frame() : 0);
640 } 640 }
641 641
642 WebFrame* WebFrameImpl::parent() const 642 WebFrame* WebFrameImpl::parent() const
643 { 643 {
644 if (!frame()) 644 if (!frame())
645 return 0; 645 return 0;
646 return fromFrame(frame()->tree()->parent()); 646 return fromFrame(frame()->tree()->parent());
647 } 647 }
648 648
649 WebFrame* WebFrameImpl::top() const 649 WebFrame* WebFrameImpl::top() const
(...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1878 for (Vector<FindMatch>::const_iterator it = m_findMatchesCache.begin(); it != m_findMatchesCache.end(); ++it) 1878 for (Vector<FindMatch>::const_iterator it = m_findMatchesCache.begin(); it != m_findMatchesCache.end(); ++it)
1879 if (!it->m_rect.isEmpty()) 1879 if (!it->m_rect.isEmpty())
1880 filteredMatches.append(*it); 1880 filteredMatches.append(*it);
1881 1881
1882 m_findMatchesCache.swap(filteredMatches); 1882 m_findMatchesCache.swap(filteredMatches);
1883 } 1883 }
1884 1884
1885 // Invalidate the rects in child frames. Will be updated later during traver sal. 1885 // Invalidate the rects in child frames. Will be updated later during traver sal.
1886 if (!m_findMatchRectsAreValid) 1886 if (!m_findMatchRectsAreValid)
1887 for (WebFrame* child = firstChild(); child; child = child->nextSibling() ) 1887 for (WebFrame* child = firstChild(); child; child = child->nextSibling() )
1888 static_cast<WebFrameImpl*>(child)->m_findMatchRectsAreValid = false; 1888 toWebFrameImpl(child)->m_findMatchRectsAreValid = false;
1889 1889
1890 m_findMatchRectsAreValid = true; 1890 m_findMatchRectsAreValid = true;
1891 } 1891 }
1892 1892
1893 WebFloatRect WebFrameImpl::activeFindMatchRect() 1893 WebFloatRect WebFrameImpl::activeFindMatchRect()
1894 { 1894 {
1895 ASSERT(!parent()); 1895 ASSERT(!parent());
1896 1896
1897 if (!isActiveMatchFrameValid()) 1897 if (!isActiveMatchFrameValid())
1898 return WebFloatRect(); 1898 return WebFloatRect();
1899 1899
1900 return WebFloatRect(findInPageRectFromRange(m_currentActiveMatchFrame->m_act iveMatch.get())); 1900 return WebFloatRect(findInPageRectFromRange(m_currentActiveMatchFrame->m_act iveMatch.get()));
1901 } 1901 }
1902 1902
1903 void WebFrameImpl::findMatchRects(WebVector<WebFloatRect>& outputRects) 1903 void WebFrameImpl::findMatchRects(WebVector<WebFloatRect>& outputRects)
1904 { 1904 {
1905 ASSERT(!parent()); 1905 ASSERT(!parent());
1906 1906
1907 Vector<WebFloatRect> matchRects; 1907 Vector<WebFloatRect> matchRects;
1908 for (WebFrameImpl* frame = this; frame; frame = static_cast<WebFrameImpl*>(f rame->traverseNext(false))) 1908 for (WebFrameImpl* frame = this; frame; frame = toWebFrameImpl(frame->traver seNext(false)))
1909 frame->appendFindMatchRects(matchRects); 1909 frame->appendFindMatchRects(matchRects);
1910 1910
1911 outputRects = matchRects; 1911 outputRects = matchRects;
1912 } 1912 }
1913 1913
1914 void WebFrameImpl::appendFindMatchRects(Vector<WebFloatRect>& frameRects) 1914 void WebFrameImpl::appendFindMatchRects(Vector<WebFloatRect>& frameRects)
1915 { 1915 {
1916 updateFindMatchRects(); 1916 updateFindMatchRects();
1917 frameRects.reserveCapacity(frameRects.size() + m_findMatchesCache.size()); 1917 frameRects.reserveCapacity(frameRects.size() + m_findMatchesCache.size());
1918 for (Vector<FindMatch>::const_iterator it = m_findMatchesCache.begin(); it ! = m_findMatchesCache.end(); ++it) { 1918 for (Vector<FindMatch>::const_iterator it = m_findMatchesCache.begin(); it ! = m_findMatchesCache.end(); ++it) {
1919 ASSERT(!it->m_rect.isEmpty()); 1919 ASSERT(!it->m_rect.isEmpty());
1920 frameRects.append(it->m_rect); 1920 frameRects.append(it->m_rect);
1921 } 1921 }
1922 } 1922 }
1923 1923
1924 int WebFrameImpl::selectNearestFindMatch(const WebFloatPoint& point, WebRect* se lectionRect) 1924 int WebFrameImpl::selectNearestFindMatch(const WebFloatPoint& point, WebRect* se lectionRect)
1925 { 1925 {
1926 ASSERT(!parent()); 1926 ASSERT(!parent());
1927 1927
1928 WebFrameImpl* bestFrame = 0; 1928 WebFrameImpl* bestFrame = 0;
1929 int indexInBestFrame = -1; 1929 int indexInBestFrame = -1;
1930 float distanceInBestFrame = FLT_MAX; 1930 float distanceInBestFrame = FLT_MAX;
1931 1931
1932 for (WebFrameImpl* frame = this; frame; frame = static_cast<WebFrameImpl*>(f rame->traverseNext(false))) { 1932 for (WebFrameImpl* frame = this; frame; frame = toWebFrameImpl(frame->traver seNext(false))) {
1933 float distanceInFrame; 1933 float distanceInFrame;
1934 int indexInFrame = frame->nearestFindMatch(point, distanceInFrame); 1934 int indexInFrame = frame->nearestFindMatch(point, distanceInFrame);
1935 if (distanceInFrame < distanceInBestFrame) { 1935 if (distanceInFrame < distanceInBestFrame) {
1936 bestFrame = frame; 1936 bestFrame = frame;
1937 indexInBestFrame = indexInFrame; 1937 indexInBestFrame = indexInFrame;
1938 distanceInBestFrame = distanceInFrame; 1938 distanceInBestFrame = distanceInFrame;
1939 } 1939 }
1940 } 1940 }
1941 1941
1942 if (indexInBestFrame != -1) 1942 if (indexInBestFrame != -1)
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
2369 return; 2369 return;
2370 frame()->document()->markers()->setMarkersActive(range, active); 2370 frame()->document()->markers()->setMarkersActive(range, active);
2371 } 2371 }
2372 2372
2373 int WebFrameImpl::ordinalOfFirstMatchForFrame(WebFrameImpl* frame) const 2373 int WebFrameImpl::ordinalOfFirstMatchForFrame(WebFrameImpl* frame) const
2374 { 2374 {
2375 int ordinal = 0; 2375 int ordinal = 0;
2376 WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl(); 2376 WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl();
2377 // Iterate from the main frame up to (but not including) |frame| and 2377 // Iterate from the main frame up to (but not including) |frame| and
2378 // add up the number of matches found so far. 2378 // add up the number of matches found so far.
2379 for (WebFrameImpl* it = mainFrameImpl; it != frame; it = static_cast<WebFram eImpl*>(it->traverseNext(true))) { 2379 for (WebFrameImpl* it = mainFrameImpl; it != frame; it = toWebFrameImpl(it-> traverseNext(true))) {
2380 if (it->m_lastMatchCount > 0) 2380 if (it->m_lastMatchCount > 0)
2381 ordinal += it->m_lastMatchCount; 2381 ordinal += it->m_lastMatchCount;
2382 } 2382 }
2383 return ordinal; 2383 return ordinal;
2384 } 2384 }
2385 2385
2386 bool WebFrameImpl::shouldScopeMatches(const String& searchText) 2386 bool WebFrameImpl::shouldScopeMatches(const String& searchText)
2387 { 2387 {
2388 // Don't scope if we can't find a frame or a view. 2388 // Don't scope if we can't find a frame or a view.
2389 // The user may have closed the tab/application, so abort. 2389 // The user may have closed the tab/application, so abort.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
2483 2483
2484 // There is a possibility that the frame being detached was the only 2484 // There is a possibility that the frame being detached was the only
2485 // pending one. We need to make sure final replies can be sent. 2485 // pending one. We need to make sure final replies can be sent.
2486 flushCurrentScopingEffort(m_findRequestIdentifier); 2486 flushCurrentScopingEffort(m_findRequestIdentifier);
2487 2487
2488 cancelPendingScopingEffort(); 2488 cancelPendingScopingEffort();
2489 } 2489 }
2490 } 2490 }
2491 2491
2492 } // namespace WebKit 2492 } // namespace WebKit
OLDNEW
« no previous file with comments | « Source/web/WebFrameImpl.h ('k') | Source/web/WebPageSerializer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698