OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/tab_contents/tab_contents.h" | 5 #include "content/browser/tab_contents/tab_contents.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 is_being_destroyed_(false), | 190 is_being_destroyed_(false), |
191 notify_disconnection_(false), | 191 notify_disconnection_(false), |
192 dialog_creator_(NULL), | 192 dialog_creator_(NULL), |
193 #if defined(OS_WIN) | 193 #if defined(OS_WIN) |
194 message_box_active_(CreateEvent(NULL, TRUE, FALSE, NULL)), | 194 message_box_active_(CreateEvent(NULL, TRUE, FALSE, NULL)), |
195 #endif | 195 #endif |
196 is_showing_before_unload_dialog_(false), | 196 is_showing_before_unload_dialog_(false), |
197 opener_web_ui_type_(WebUI::kNoWebUI), | 197 opener_web_ui_type_(WebUI::kNoWebUI), |
198 closed_by_user_gesture_(false), | 198 closed_by_user_gesture_(false), |
199 minimum_zoom_percent_( | 199 minimum_zoom_percent_( |
200 static_cast<int>(WebKit::WebView::minTextSizeMultiplier * 100)), | 200 static_cast<int>(content::kMinimumZoomFactor * 100)), |
201 maximum_zoom_percent_( | 201 maximum_zoom_percent_( |
202 static_cast<int>(WebKit::WebView::maxTextSizeMultiplier * 100)), | 202 static_cast<int>(content::kMaximumZoomFactor * 100)), |
203 temporary_zoom_settings_(false), | 203 temporary_zoom_settings_(false), |
204 content_restrictions_(0), | 204 content_restrictions_(0), |
205 view_type_(content::VIEW_TYPE_TAB_CONTENTS) { | 205 view_type_(content::VIEW_TYPE_TAB_CONTENTS) { |
206 | 206 |
207 render_manager_.Init(browser_context, site_instance, routing_id); | 207 render_manager_.Init(browser_context, site_instance, routing_id); |
208 | 208 |
209 // We have the initial size of the view be based on the size of the passed in | 209 // We have the initial size of the view be based on the size of the passed in |
210 // tab contents (normally a tab from the same window). | 210 // tab contents (normally a tab from the same window). |
211 view_->CreateView(base_tab_contents ? | 211 view_->CreateView(base_tab_contents ? |
212 base_tab_contents->view()->GetContainerSize() : gfx::Size()); | 212 base_tab_contents->view()->GetContainerSize() : gfx::Size()); |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
856 url = active_entry ? active_entry->url() : GURL::EmptyGURL(); | 856 url = active_entry ? active_entry->url() : GURL::EmptyGURL(); |
857 zoom_level = zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL(url)); | 857 zoom_level = zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL(url)); |
858 } | 858 } |
859 return zoom_level; | 859 return zoom_level; |
860 } | 860 } |
861 | 861 |
862 int TabContents::GetZoomPercent(bool* enable_increment, | 862 int TabContents::GetZoomPercent(bool* enable_increment, |
863 bool* enable_decrement) { | 863 bool* enable_decrement) { |
864 *enable_decrement = *enable_increment = false; | 864 *enable_decrement = *enable_increment = false; |
865 int percent = static_cast<int>( | 865 int percent = static_cast<int>( |
866 WebKit::WebView::zoomLevelToZoomFactor(GetZoomLevel()) * 100); | 866 WebKit::WebView::zoomLevelToZoomFactor(GetZoomLevel()) * 100 + 0.5); |
James Hawkins
2011/11/14 18:09:05
What's the 0.5 about?
csilv
2011/11/14 23:10:29
Rouding a fractional value to the nearest integer.
| |
867 *enable_decrement = percent > minimum_zoom_percent_; | 867 *enable_decrement = percent > minimum_zoom_percent_; |
868 *enable_increment = percent < maximum_zoom_percent_; | 868 *enable_increment = percent < maximum_zoom_percent_; |
869 return percent; | 869 return percent; |
870 } | 870 } |
871 | 871 |
872 void TabContents::ViewSource() { | 872 void TabContents::ViewSource() { |
873 if (!delegate_) | 873 if (!delegate_) |
874 return; | 874 return; |
875 | 875 |
876 NavigationEntry* active_entry = controller().GetActiveEntry(); | 876 NavigationEntry* active_entry = controller().GetActiveEntry(); |
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2015 | 2015 |
2016 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2016 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
2017 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 2017 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
2018 rwh_view->SetSize(view()->GetContainerSize()); | 2018 rwh_view->SetSize(view()->GetContainerSize()); |
2019 } | 2019 } |
2020 | 2020 |
2021 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { | 2021 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { |
2022 return render_view_host() ? | 2022 return render_view_host() ? |
2023 render_view_host()->GotResponseToLockMouseRequest(allowed) : false; | 2023 render_view_host()->GotResponseToLockMouseRequest(allowed) : false; |
2024 } | 2024 } |
OLD | NEW |