summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/browser_commands.cc12
-rw-r--r--chrome/browser/render_view_host.cc4
-rw-r--r--chrome/browser/render_view_host.h9
-rw-r--r--chrome/browser/tab_contents.h1
-rw-r--r--chrome/common/common.vcproj8
-rw-r--r--chrome/common/page_zoom.h23
-rw-r--r--chrome/common/render_messages_internal.h6
-rw-r--r--chrome/common/text_zoom.h18
-rw-r--r--chrome/renderer/render_view.cc21
-rw-r--r--chrome/renderer/render_view.h11
-rw-r--r--webkit/glue/webview.h16
-rw-r--r--webkit/glue/webview_impl.cc28
-rw-r--r--webkit/glue/webview_impl.h24
-rw-r--r--webkit/tools/test_shell/event_sending_controller.cc4
14 files changed, 100 insertions, 85 deletions
diff --git a/chrome/browser/browser_commands.cc b/chrome/browser/browser_commands.cc
index 12d70ce..cca8754 100644
--- a/chrome/browser/browser_commands.cc
+++ b/chrome/browser/browser_commands.cc
@@ -512,8 +512,8 @@ void Browser::ExecuteCommand(int id) {
UserMetrics::RecordAction(L"ZoomPlus", profile_);
TabContents* current_tab = GetSelectedTabContents();
if (current_tab->AsWebContents()) {
- current_tab->AsWebContents()->render_view_host()->AlterTextSize(
- text_zoom::TEXT_LARGER);
+ current_tab->AsWebContents()->render_view_host()->Zoom(
+ PageZoom::LARGER);
}
break;
}
@@ -522,8 +522,8 @@ void Browser::ExecuteCommand(int id) {
UserMetrics::RecordAction(L"ZoomMinus", profile_);
TabContents* current_tab = GetSelectedTabContents();
if (current_tab->AsWebContents()) {
- current_tab->AsWebContents()->render_view_host()->AlterTextSize(
- text_zoom::TEXT_SMALLER);
+ current_tab->AsWebContents()->render_view_host()->Zoom(
+ PageZoom::SMALLER);
}
break;
}
@@ -532,8 +532,8 @@ void Browser::ExecuteCommand(int id) {
UserMetrics::RecordAction(L"ZoomNormal", profile_);
TabContents* current_tab = GetSelectedTabContents();
if (current_tab->AsWebContents()) {
- current_tab->AsWebContents()->render_view_host()->AlterTextSize(
- text_zoom::TEXT_STANDARD);
+ current_tab->AsWebContents()->render_view_host()->Zoom(
+ PageZoom::STANDARD);
}
break;
}
diff --git a/chrome/browser/render_view_host.cc b/chrome/browser/render_view_host.cc
index d269017..990e4c0 100644
--- a/chrome/browser/render_view_host.cc
+++ b/chrome/browser/render_view_host.cc
@@ -326,8 +326,8 @@ void RenderViewHost::StopFinding(bool clear_selection) {
Send(new ViewMsg_StopFinding(routing_id_, clear_selection));
}
-void RenderViewHost::AlterTextSize(text_zoom::TextSize size) {
- Send(new ViewMsg_AlterTextSize(routing_id_, size));
+void RenderViewHost::Zoom(PageZoom::Function function) {
+ Send(new ViewMsg_Zoom(routing_id_, function));
}
void RenderViewHost::SetPageEncoding(const std::wstring& encoding_name) {
diff --git a/chrome/browser/render_view_host.h b/chrome/browser/render_view_host.h
index 13b40ac..c0ebefe 100644
--- a/chrome/browser/render_view_host.h
+++ b/chrome/browser/render_view_host.h
@@ -11,6 +11,7 @@
#include "base/scoped_handle.h"
#include "chrome/browser/render_view_host_delegate.h"
#include "chrome/browser/render_widget_host.h"
+#include "chrome/common/page_zoom.h"
#ifdef CHROME_PERSONALIZATION
#include "chrome/personalization/personalization.h"
#endif
@@ -39,10 +40,6 @@ namespace net {
enum LoadState;
}
-namespace text_zoom {
-enum TextSize;
-}
-
namespace webkit_glue {
struct WebApplicationInfo;
}
@@ -188,8 +185,8 @@ class RenderViewHost : public RenderWidgetHost {
// clear the selection on the focused frame.
void StopFinding(bool clear_selection);
- // Change the text size of the page.
- void AlterTextSize(text_zoom::TextSize size);
+ // Change the zoom level of a page.
+ void Zoom(PageZoom::Function function);
// Change the encoding of the page.
void SetPageEncoding(const std::wstring& encoding_name);
diff --git a/chrome/browser/tab_contents.h b/chrome/browser/tab_contents.h
index 583358f..fc6fa04 100644
--- a/chrome/browser/tab_contents.h
+++ b/chrome/browser/tab_contents.h
@@ -14,7 +14,6 @@
#include "chrome/browser/page_navigator.h"
#include "chrome/browser/tab_contents_type.h"
#include "chrome/common/navigation_types.h"
-#include "chrome/common/text_zoom.h"
namespace gfx {
class Rect;
diff --git a/chrome/common/common.vcproj b/chrome/common/common.vcproj
index 771ff8c..8bcb3ff 100644
--- a/chrome/common/common.vcproj
+++ b/chrome/common/common.vcproj
@@ -542,6 +542,10 @@
>
</File>
<File
+ RelativePath=".\page_zoom.h"
+ >
+ </File>
+ <File
RelativePath="..\tools\build\win\precompiled.cc"
>
<FileConfiguration
@@ -658,10 +662,6 @@
>
</File>
<File
- RelativePath=".\text_zoom.h"
- >
- </File>
- <File
RelativePath=".\throb_animation.cc"
>
</File>
diff --git a/chrome/common/page_zoom.h b/chrome/common/page_zoom.h
new file mode 100644
index 0000000..17743b7
--- /dev/null
+++ b/chrome/common/page_zoom.h
@@ -0,0 +1,23 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_COMMON_PAGE_ZOOM_H_
+#define CHROME_COMMON_PAGE_ZOOM_H_
+
+// This enum is the parameter to various text/page zoom commands so we know
+// what the specific zoom command is.
+class PageZoom {
+ public:
+ enum Function {
+ SMALLER = -1,
+ STANDARD = 0,
+ LARGER = 1,
+ };
+
+ private:
+ PageZoom() {} // For scoping only.
+};
+
+#endif // CHROME_COMMON_PAGE_ZOOM_H_
+
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 9480f06..b7966ac 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -229,9 +229,9 @@ IPC_BEGIN_MESSAGES(View, 1)
IPC_MESSAGE_ROUTED1(ViewMsg_DebugCommand,
std::wstring /* cmd */)
- // Change the text size in the renderer.
- IPC_MESSAGE_ROUTED1(ViewMsg_AlterTextSize,
- int /* enum text_zoom::TextSize from text_zoom.h */)
+ // Change the zoom level in the renderer.
+ IPC_MESSAGE_ROUTED1(ViewMsg_Zoom,
+ int /* One of PageZoom::Function */)
// Change encoding of page in the renderer.
IPC_MESSAGE_ROUTED1(ViewMsg_SetPageEncoding,
diff --git a/chrome/common/text_zoom.h b/chrome/common/text_zoom.h
deleted file mode 100644
index 1d8b127..0000000
--- a/chrome/common/text_zoom.h
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_COMMON_TEXT_ZOOM_H__
-#define CHROME_COMMON_TEXT_ZOOM_H__
-
-// Used in AlterTextSize IPC call.
-namespace text_zoom {
- enum TextSize {
- TEXT_SMALLER = -1,
- TEXT_STANDARD = 0,
- TEXT_LARGER = 1,
- };
-}
-
-#endif
-
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 722e67f..748e612 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -24,8 +24,8 @@
#include "chrome/common/gfx/color_utils.h"
#include "chrome/common/jstemplate_builder.h"
#include "chrome/common/l10n_util.h"
+#include "chrome/common/page_zoom.h"
#include "chrome/common/resource_bundle.h"
-#include "chrome/common/text_zoom.h"
#include "chrome/common/thumbnail_score.h"
#include "chrome/common/chrome_plugin_lib.h"
#include "chrome/renderer/about_handler.h"
@@ -289,7 +289,7 @@ void RenderView::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll)
IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt)
IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind)
- IPC_MESSAGE_HANDLER(ViewMsg_AlterTextSize, OnAlterTextSize)
+ IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom)
IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding)
IPC_MESSAGE_HANDLER(ViewMsg_InspectElement, OnInspectElement)
IPC_MESSAGE_HANDLER(ViewMsg_ShowJavaScriptConsole, OnShowJavaScriptConsole)
@@ -2159,16 +2159,17 @@ void RenderView::DnsPrefetch(const std::vector<std::string>& host_names) {
Send(new ViewHostMsg_DnsPrefetch(host_names));
}
-void RenderView::OnAlterTextSize(int size) {
- switch (size) {
- case text_zoom::TEXT_SMALLER:
- webview()->MakeTextSmaller();
+void RenderView::OnZoom(int function) {
+ static const bool kZoomIsTextOnly = false;
+ switch (function) {
+ case PageZoom::SMALLER:
+ webview()->ZoomOut(kZoomIsTextOnly);
break;
- case text_zoom::TEXT_STANDARD:
- webview()->MakeTextStandardSize();
+ case PageZoom::STANDARD:
+ webview()->ResetZoom();
break;
- case text_zoom::TEXT_LARGER:
- webview()->MakeTextLarger();
+ case PageZoom::LARGER:
+ webview()->ZoomIn(kZoomIsTextOnly);
break;
default:
NOTREACHED();
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 71faf63..51b9d93 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_RENDERER_RENDER_VIEW_H__
-#define CHROME_RENDERER_RENDER_VIEW_H__
+#ifndef CHROME_RENDERER_RENDER_VIEW_H_
+#define CHROME_RENDERER_RENDER_VIEW_H_
#include <string>
#include <vector>
@@ -14,6 +14,7 @@
#include "base/gfx/rect.h"
#include "base/timer.h"
#include "base/values.h"
+#include "chrome/common/page_zoom.h"
#include "chrome/common/resource_dispatcher.h"
#ifdef CHROME_PERSONALIZATION
#include "chrome/personalization/personalization.h"
@@ -372,7 +373,7 @@ class RenderView : public RenderWidget, public WebViewDelegate,
void OnShowJavaScriptConsole();
void OnCancelDownload(int32 download_id);
void OnFind(const FindInPageRequest& request);
- void OnAlterTextSize(int size);
+ void OnZoom(int function);
void OnSetPageEncoding(const std::wstring& encoding_name);
void OnGetAllSavableResourceLinksForCurrentPage(const GURL& page_url);
void OnGetSerializedHtmlDataForCurrentPageWithLocalLinks(
@@ -620,7 +621,7 @@ class RenderView : public RenderWidget, public WebViewDelegate,
// maintains the cache and other features of the accessibility tree.
scoped_ptr<GlueAccessibility> glue_accessibility_;
- DISALLOW_EVIL_CONSTRUCTORS(RenderView);
+ DISALLOW_COPY_AND_ASSIGN(RenderView);
};
-#endif // CHROME_RENDERER_RENDER_VIEW_H__
+#endif // CHROME_RENDERER_RENDER_VIEW_H_
diff --git a/webkit/glue/webview.h b/webkit/glue/webview.h
index bd13a701..e47ad0e 100644
--- a/webkit/glue/webview.h
+++ b/webkit/glue/webview.h
@@ -149,10 +149,18 @@ class WebView : public WebWidget {
// Return the canonical encoding name of current main webframe in webview.
virtual std::wstring GetMainFrameEncodingName() = 0;
- // Change the text zoom level. Text size is made 20% larger or smaller.
- virtual void MakeTextLarger() = 0;
- virtual void MakeTextSmaller() = 0;
- virtual void MakeTextStandardSize() = 0;
+ // Change the text zoom level. It will make the zoom level 20% larger or
+ // smaller. If text_only is set, the text size will be changed. When unset,
+ // the entire page's zoom factor will be changed.
+ //
+ // You can only have either text zoom or full page zoom at one time. Changing
+ // the mode will change things in weird ways. Generally the app should only
+ // support text zoom or full page zoom, and not both.
+ //
+ // ResetZoom will reset both full page and text zoom.
+ virtual void ZoomIn(bool text_only) = 0;
+ virtual void ZoomOut(bool text_only) = 0;
+ virtual void ResetZoom() = 0;
// Copy to the clipboard the image located at a particular point in the
// WebView (if there is such an image)
diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc
index da53eb6..8bbe9c7 100644
--- a/webkit/glue/webview_impl.cc
+++ b/webkit/glue/webview_impl.cc
@@ -140,7 +140,7 @@ WebViewImpl::WebViewImpl()
#ifndef NDEBUG
new_navigation_loader_(NULL),
#endif
- text_zoom_level_(0),
+ zoom_level_(0),
context_menu_allowed_(false),
doing_drag_and_drop_(false),
suppress_next_keypress_event_(false),
@@ -1158,33 +1158,37 @@ std::wstring WebViewImpl::GetMainFrameEncodingName() {
return webkit_glue::StringToStdWString(encoding_name);
}
-void WebViewImpl::MakeTextLarger() {
+void WebViewImpl::ZoomIn(bool text_only) {
Frame* frame = main_frame()->frame();
double multiplier = std::min(std::pow(kTextSizeMultiplierRatio,
- text_zoom_level_ + 1),
+ zoom_level_ + 1),
kMaxTextSizeMultiplier);
float zoom_factor = static_cast<float>(multiplier);
if (zoom_factor != frame->zoomFactor()) {
- ++text_zoom_level_;
- frame->setZoomFactor(zoom_factor, false);
+ ++zoom_level_;
+ frame->setZoomFactor(zoom_factor, text_only);
}
}
-void WebViewImpl::MakeTextSmaller() {
+void WebViewImpl::ZoomOut(bool text_only) {
Frame* frame = main_frame()->frame();
double multiplier = std::max(std::pow(kTextSizeMultiplierRatio,
- text_zoom_level_ - 1),
+ zoom_level_ - 1),
kMinTextSizeMultiplier);
float zoom_factor = static_cast<float>(multiplier);
if (zoom_factor != frame->zoomFactor()) {
- --text_zoom_level_;
- frame->setZoomFactor(zoom_factor, false);
+ --zoom_level_;
+ frame->setZoomFactor(zoom_factor, text_only);
}
}
-void WebViewImpl::MakeTextStandardSize() {
- text_zoom_level_ = 0;
- main_frame()->frame()->setZoomFactor(1.0f, false);
+void WebViewImpl::ResetZoom() {
+ // We don't change the zoom mode (text only vs. full page) here. We just want
+ // to reset whatever is already set.
+ zoom_level_ = 0;
+ main_frame()->frame()->setZoomFactor(
+ 1.0f,
+ main_frame()->frame()->isZoomFactorTextOnly());
}
void WebViewImpl::CopyImageAt(int x, int y) {
diff --git a/webkit/glue/webview_impl.h b/webkit/glue/webview_impl.h
index ebe9e14..ad8f662 100644
--- a/webkit/glue/webview_impl.h
+++ b/webkit/glue/webview_impl.h
@@ -23,13 +23,13 @@ MSVC_PUSH_WARNING_LEVEL(0);
MSVC_POP_WARNING();
namespace WebCore {
- class Frame;
- class HistoryItem;
- class KeyboardEvent;
- class Page;
- class PlatformKeyboardEvent;
- class Range;
- class Widget;
+class Frame;
+class HistoryItem;
+class KeyboardEvent;
+class Page;
+class PlatformKeyboardEvent;
+class Range;
+class Widget;
}
class ImageResourceFetcher;
@@ -81,9 +81,9 @@ class WebViewImpl : public WebView,
virtual const WebPreferences& GetPreferences();
virtual void SetPageEncoding(const std::wstring& encoding_name);
virtual std::wstring GetMainFrameEncodingName();
- virtual void MakeTextLarger();
- virtual void MakeTextSmaller();
- virtual void MakeTextStandardSize();
+ virtual void ZoomIn(bool text_only);
+ virtual void ZoomOut(bool text_only);
+ virtual void ResetZoom();
virtual void CopyImageAt(int x, int y);
virtual void InspectElement(int x, int y);
virtual void ShowJavaScriptConsole();
@@ -275,8 +275,8 @@ class WebViewImpl : public WebView,
gfx::Point last_mouse_down_point_;
// Keeps track of the current text zoom level. 0 means no zoom, positive
- // values mean larger text, negative numbers mean smaller text.
- int text_zoom_level_;
+ // values mean larger text, negative numbers mean smaller.
+ int zoom_level_;
bool context_menu_allowed_;
diff --git a/webkit/tools/test_shell/event_sending_controller.cc b/webkit/tools/test_shell/event_sending_controller.cc
index 53bde83..7164e7f 100644
--- a/webkit/tools/test_shell/event_sending_controller.cc
+++ b/webkit/tools/test_shell/event_sending_controller.cc
@@ -496,13 +496,13 @@ int EventSendingController::GetButtonNumberFromSingleArg(
// WebKit/WebView/WebView.mm)
void EventSendingController::textZoomIn(
const CppArgumentList& args, CppVariant* result) {
- webview()->MakeTextLarger();
+ webview()->ZoomIn(true);
result->SetNull();
}
void EventSendingController::textZoomOut(
const CppArgumentList& args, CppVariant* result) {
- webview()->MakeTextSmaller();
+ webview()->ZoomOut(true);
result->SetNull();
}