OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1480 return; | 1480 return; |
1481 | 1481 |
1482 // Don't send state updates for kSwappedOutURL. | 1482 // Don't send state updates for kSwappedOutURL. |
1483 if (entry->root().urlString() == WebString::fromUTF8(kSwappedOutURL)) | 1483 if (entry->root().urlString() == WebString::fromUTF8(kSwappedOutURL)) |
1484 return; | 1484 return; |
1485 | 1485 |
1486 Send(new ViewHostMsg_UpdateState( | 1486 Send(new ViewHostMsg_UpdateState( |
1487 routing_id_, page_id_, HistoryEntryToPageState(entry))); | 1487 routing_id_, page_id_, HistoryEntryToPageState(entry))); |
1488 } | 1488 } |
1489 | 1489 |
| 1490 void RenderViewImpl::SendFrameStateUpdates() { |
| 1491 // We only use this path in OOPIF-enabled modes. |
| 1492 DCHECK(SiteIsolationPolicy::UseSubframeNavigationEntries()); |
| 1493 |
| 1494 // Tell each frame with pending state to send its UpdateState message. |
| 1495 for (int render_frame_routing_id : frames_with_pending_state_) { |
| 1496 RenderFrameImpl* frame = |
| 1497 RenderFrameImpl::FromRoutingID(render_frame_routing_id); |
| 1498 if (frame) |
| 1499 frame->SendUpdateState(); |
| 1500 } |
| 1501 frames_with_pending_state_.clear(); |
| 1502 } |
| 1503 |
1490 void RenderViewImpl::ApplyWebPreferencesInternal( | 1504 void RenderViewImpl::ApplyWebPreferencesInternal( |
1491 const WebPreferences& prefs, | 1505 const WebPreferences& prefs, |
1492 blink::WebView* web_view, | 1506 blink::WebView* web_view, |
1493 CompositorDependencies* compositor_deps) { | 1507 CompositorDependencies* compositor_deps) { |
1494 ApplyWebPreferences(prefs, web_view); | 1508 ApplyWebPreferences(prefs, web_view); |
1495 #if defined(OS_MACOSX) && !defined(OS_IOS) | 1509 #if defined(OS_MACOSX) && !defined(OS_IOS) |
1496 DCHECK(compositor_deps); | 1510 DCHECK(compositor_deps); |
1497 bool is_elastic_overscroll_enabled = | 1511 bool is_elastic_overscroll_enabled = |
1498 compositor_deps->IsElasticOverscrollEnabled(); | 1512 compositor_deps->IsElasticOverscrollEnabled(); |
1499 web_view->settings()->setReportWheelOverscroll(is_elastic_overscroll_enabled); | 1513 web_view->settings()->setReportWheelOverscroll(is_elastic_overscroll_enabled); |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1844 } | 1858 } |
1845 } | 1859 } |
1846 | 1860 |
1847 gfx::RectF RenderViewImpl::ClientRectToPhysicalWindowRect( | 1861 gfx::RectF RenderViewImpl::ClientRectToPhysicalWindowRect( |
1848 const gfx::RectF& rect) const { | 1862 const gfx::RectF& rect) const { |
1849 gfx::RectF window_rect = rect; | 1863 gfx::RectF window_rect = rect; |
1850 window_rect.Scale(device_scale_factor_ * webview()->pageScaleFactor()); | 1864 window_rect.Scale(device_scale_factor_ * webview()->pageScaleFactor()); |
1851 return window_rect; | 1865 return window_rect; |
1852 } | 1866 } |
1853 | 1867 |
1854 void RenderViewImpl::StartNavStateSyncTimerIfNecessary() { | 1868 void RenderViewImpl::StartNavStateSyncTimerIfNecessary(RenderFrameImpl* frame) { |
1855 // TODO(creis): Move this to RenderFrameHost. In the meantime, we'll ignore | 1869 // In OOPIF modes, keep track of which frames have pending updates. |
1856 // state changes between navigation events in OOPIF-enabled modes. | |
1857 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | 1870 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) |
1858 return; | 1871 frames_with_pending_state_.insert(frame->GetRoutingID()); |
1859 | 1872 |
1860 int delay; | 1873 int delay; |
1861 if (send_content_state_immediately_) | 1874 if (send_content_state_immediately_) |
1862 delay = 0; | 1875 delay = 0; |
1863 else if (is_hidden()) | 1876 else if (is_hidden()) |
1864 delay = kDelaySecondsForContentStateSyncHidden; | 1877 delay = kDelaySecondsForContentStateSyncHidden; |
1865 else | 1878 else |
1866 delay = kDelaySecondsForContentStateSync; | 1879 delay = kDelaySecondsForContentStateSync; |
1867 | 1880 |
1868 if (nav_state_sync_timer_.IsRunning()) { | 1881 if (nav_state_sync_timer_.IsRunning()) { |
1869 // The timer is already running. If the delay of the timer maches the amount | 1882 // The timer is already running. If the delay of the timer maches the amount |
1870 // we want to delay by, then return. Otherwise stop the timer so that it | 1883 // we want to delay by, then return. Otherwise stop the timer so that it |
1871 // gets started with the right delay. | 1884 // gets started with the right delay. |
1872 if (nav_state_sync_timer_.GetCurrentDelay().InSeconds() == delay) | 1885 if (nav_state_sync_timer_.GetCurrentDelay().InSeconds() == delay) |
1873 return; | 1886 return; |
1874 nav_state_sync_timer_.Stop(); | 1887 nav_state_sync_timer_.Stop(); |
1875 } | 1888 } |
1876 | 1889 |
1877 nav_state_sync_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(delay), this, | 1890 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
1878 &RenderViewImpl::SendUpdateState); | 1891 // In OOPIF modes, tell each frame with pending state to inform the browser. |
| 1892 nav_state_sync_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(delay), this, |
| 1893 &RenderViewImpl::SendFrameStateUpdates); |
| 1894 } else { |
| 1895 // By default, send an UpdateState for the current history item. |
| 1896 nav_state_sync_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(delay), this, |
| 1897 &RenderViewImpl::SendUpdateState); |
| 1898 } |
1879 } | 1899 } |
1880 | 1900 |
1881 void RenderViewImpl::setMouseOverURL(const WebURL& url) { | 1901 void RenderViewImpl::setMouseOverURL(const WebURL& url) { |
1882 mouse_over_url_ = GURL(url); | 1902 mouse_over_url_ = GURL(url); |
1883 UpdateTargetURL(mouse_over_url_, focus_url_); | 1903 UpdateTargetURL(mouse_over_url_, focus_url_); |
1884 } | 1904 } |
1885 | 1905 |
1886 void RenderViewImpl::setKeyboardFocusURL(const WebURL& url) { | 1906 void RenderViewImpl::setKeyboardFocusURL(const WebURL& url) { |
1887 focus_url_ = GURL(url); | 1907 focus_url_ = GURL(url); |
1888 UpdateTargetURL(focus_url_, mouse_over_url_); | 1908 UpdateTargetURL(focus_url_, mouse_over_url_); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2129 std::vector<FaviconURL> urls; | 2149 std::vector<FaviconURL> urls; |
2130 for (size_t i = 0; i < icon_urls.size(); i++) { | 2150 for (size_t i = 0; i < icon_urls.size(); i++) { |
2131 std::vector<gfx::Size> sizes; | 2151 std::vector<gfx::Size> sizes; |
2132 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 2152 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
2133 urls.push_back(FaviconURL( | 2153 urls.push_back(FaviconURL( |
2134 icon_urls[i].iconURL(), ToFaviconType(icon_urls[i].iconType()), sizes)); | 2154 icon_urls[i].iconURL(), ToFaviconType(icon_urls[i].iconType()), sizes)); |
2135 } | 2155 } |
2136 SendUpdateFaviconURL(urls); | 2156 SendUpdateFaviconURL(urls); |
2137 } | 2157 } |
2138 | 2158 |
2139 void RenderViewImpl::didUpdateCurrentHistoryItem(WebLocalFrame* frame) { | |
2140 StartNavStateSyncTimerIfNecessary(); | |
2141 } | |
2142 | |
2143 void RenderViewImpl::CheckPreferredSize() { | 2159 void RenderViewImpl::CheckPreferredSize() { |
2144 // We don't always want to send the change messages over IPC, only if we've | 2160 // We don't always want to send the change messages over IPC, only if we've |
2145 // been put in that mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| | 2161 // been put in that mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| |
2146 // message. | 2162 // message. |
2147 if (!send_preferred_size_changes_ || !webview()) | 2163 if (!send_preferred_size_changes_ || !webview()) |
2148 return; | 2164 return; |
2149 | 2165 |
2150 gfx::Size size = webview()->contentsPreferredMinimumSize(); | 2166 gfx::Size size = webview()->contentsPreferredMinimumSize(); |
2151 if (size == preferred_size_) | 2167 if (size == preferred_size_) |
2152 return; | 2168 return; |
2153 | 2169 |
2154 preferred_size_ = size; | 2170 preferred_size_ = size; |
2155 Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_, | 2171 Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_, |
2156 preferred_size_)); | 2172 preferred_size_)); |
2157 } | 2173 } |
2158 | 2174 |
2159 void RenderViewImpl::didChangeScrollOffset(WebLocalFrame* frame) { | |
2160 StartNavStateSyncTimerIfNecessary(); | |
2161 } | |
2162 | |
2163 void RenderViewImpl::SendFindReply(int request_id, | 2175 void RenderViewImpl::SendFindReply(int request_id, |
2164 int match_count, | 2176 int match_count, |
2165 int ordinal, | 2177 int ordinal, |
2166 const WebRect& selection_rect, | 2178 const WebRect& selection_rect, |
2167 bool final_status_update) { | 2179 bool final_status_update) { |
2168 Send(new ViewHostMsg_Find_Reply(routing_id_, | 2180 Send(new ViewHostMsg_Find_Reply(routing_id_, |
2169 request_id, | 2181 request_id, |
2170 match_count, | 2182 match_count, |
2171 selection_rect, | 2183 selection_rect, |
2172 ordinal, | 2184 ordinal, |
(...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3713 if (IsUseZoomForDSFEnabled()) { | 3725 if (IsUseZoomForDSFEnabled()) { |
3714 compositor_->SetPaintedDeviceScaleFactor(device_scale_factor_); | 3726 compositor_->SetPaintedDeviceScaleFactor(device_scale_factor_); |
3715 webview()->setZoomFactorForDeviceScaleFactor( | 3727 webview()->setZoomFactorForDeviceScaleFactor( |
3716 device_scale_factor_); | 3728 device_scale_factor_); |
3717 } else { | 3729 } else { |
3718 webview()->setDeviceScaleFactor(device_scale_factor_); | 3730 webview()->setDeviceScaleFactor(device_scale_factor_); |
3719 } | 3731 } |
3720 } | 3732 } |
3721 | 3733 |
3722 } // namespace content | 3734 } // namespace content |
OLD | NEW |