Change the default zoom mode in Google Chromium
As a WebKit based browser, Google Chrome use the text zoom mode as default zoom mode. It means, if you choose the Zoom -> Larger in the page context menu, or press the Ctrl + '+' accelerator, all the text font size in the page will be increased by 20%. On the other hand, if you do the same thing in FireFox, the whole page will be zoomed instead the text font size.
In my opinion, I feel the page zoom mode more comfortable, although I don't think any of those mode is better than the other. At least in my 24' LCD with 1080p, I need the page zoom width enough to fill the right space.
So, I just modified Chrome source code, add two alternative accelerators for page zoom mode; I also add a command line switch to set the default zoom mode when starting.
The changes are straight, because WebKit had provided the build-in support for page zoom mode, and Chrome also had an internal switch for zoom mode.
Following steps are the changes base on latest SVN revision.
- Add two new command definition in the \app\chrome_dll_resource.h file, which define the alternative zoom command itself.
#define IDC_ZOOM_VIEW_PLUS 38004
#define IDC_ZOOM_VIEW_MINUS 38005
And add new accelerator like Ctrl + Alt + '+'/'-' in the IDR_MAINFRAME table (app\chrom_dll.rc)
VK_ADD, IDC_ZOOM_VIEW_PLUS, VIRTKEY, CONTROL, ALT
VK_SUBTRACT, IDC_ZOOM_VIEW_MINUS, VIRTKEY, CONTROL, ALT - Handle the commands in the Browser::ExecuteCommand function (\browser\browser.cc), and add a parameter for ZoomIn/ZoomOut functions which is the zoom mode
// Zoom
case IDC_ZOOM_PLUS: ZoomIn(true); break;
case IDC_ZOOM_NORMAL: ZoomReset(); break;
case IDC_ZOOM_MINUS: ZoomOut(true); break;
case IDC_ZOOM_VIEW_PLUS: ZoomIn(false); break;
case IDC_ZOOM_VIEW_MINUS: ZoomOut(false); break; - Add two new zoom mode in PageZoom (\common\page_zoom.h), which will be used for page zoom; and refactor ZoomIn/ZoomOut functions (\browser\browser.cc) for new modes.
enum Function {
VIEW_SMALLER = -2,
SMALLER = -1,
STANDARD = 0,
LARGER = 1,
VIEW_LARGER = 2, };
void Browser::ZoomIn(bool isTextOnly) {
UserMetrics::RecordAction(L"ZoomPlus", profile_);
GetSelectedTabContents()->AsWebContents()->render_view_host()->Zoom( isTextOnly ? PageZoom::LARGER : PageZoom::VIEW_LARGER);}
void Browser::ZoomOut(bool isTextOnly) {
UserMetrics::RecordAction(L"ZoomMinus", profile_);
GetSelectedTabContents()->AsWebContents()->render_view_host()->Zoom( isTextOnly ? PageZoom::SMALLER : PageZoom::VIEW_SMALLER);}
Then, the RenderViewHost::Zoom function will wrap the zoom mode as a ViewMsg_Zoom message, and send it to the render process. - Modify the render handler, which redirect ViewMsg_Zoom message to OnZoom function (\renderer\render_view.cc)
IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom)
The OnZoom function has a hard code kZoomIsTextOnly constant. So, we just change its value base on the command line parameter; and set two kind of zoom mode base on its default setting.
void RenderView::OnZoom(int function) {
static const bool zoomIsTextOnly = CommandLine().HasSwitch(switches::kZoomIsTextOnly);
switch (function) {
case PageZoom::VIEW_SMALLER:
webview()->ZoomOut(!zoomIsTextOnly); break;
case PageZoom::SMALLER: webview()->ZoomOut(zoomIsTextOnly); break;
case PageZoom::STANDARD: webview()->ResetZoom(); break;
case PageZoom::LARGER: webview()->ZoomIn(zoomIsTextOnly); break;
case PageZoom::VIEW_LARGER: webview()->ZoomIn(!zoomIsTextOnly); break;
default: NOTREACHED(); }} - Besides the command workflow, there are some bookkeeping works.
We need update the command status base on the current stage in the Browser::UpdateCommandsForTabState function (browser\browser.cc)
controller_.UpdateCommandEnabled(IDC_ZOOM_VIEW_PLUS, is_web_contents);
controller_.UpdateCommandEnabled(IDC_ZOOM_VIEW_MINUS, is_web_contents); - To change the default zoom mode, I added a new switch for command line in \common\chrome_switches.h/.cc
// Turns on text only mode zoom supportconst wchar_t
kZoomIsTextOnly[] = L"zoom-is-text-only";
and add it into the switch_names array in RenderProcessHost::Init function (browser\render_process_host.cc). So, the browser process will propagate the switch to the child render process.
static const wchar_t* const switch_names[] = {
//...
switches::kZoomIsTextOnly, };
Besides, I found a similar feature request has been submited to the chrome issues tracking. So, I will add some comment as patch for this issue. Wish Google could merge it into next offical release :)
41 comments:
How do I access the \app\chrome_dll_resource.h file?
You could get the code from Google's SVN server
http://src.chromium.org/svn/trunk/src/chrome/app/chrome_dll_resource.h
Check their site for more detail
http://code.google.com/chromium/
你好~~今天搞pyV8的时候,遇到encoding的问题,想请教一下。http://code.google.com/p/pyv8/issues/detail?id=2
我又來看你囉~加油^^ 祝你天天順利開心..............................
秋去冬來~~大家要注意身體,別感冒囉! ..................................................
I do like ur article~!!!..................................................
請繼續發表好文!加油加油加油! ........................................
很喜歡你的blog哦...加油唷 ........................................
很精彩的部落格 期待你的繼續加油........................................
當一個人內心能容納兩樣相互衝突的東西,這個人便開始變得有價值了。 ..................................................
^^~~輕輕鬆鬆的逛部落格,多謝有您的分享哦~~~ ..................................................
知識可以傳授,智慧卻不行。每個人必須成為他自己。...............................................................
I like your blog................................
thanks a lot..........................................
go2av免費影片sex 0401 影音 live 秀視訊聊天交友 色美眉台中援交aa 片試看 a免費視訊聊天網 情人34C波霸美女 香蕉鮑魚俱樂部,免費av 免費線上 aa 片試看 g點無碼a片 性愛姿勢 辣妹sex story 視訊聊天室 sex888免費看影片波霸美女寫真 視訊美女pixnet 成人交友hibb 4u成人視訊 情人080視訊網 私密論壇sex888免費看影片論壇 Show-live視訊聊天室 辣妹貼圖a片天堂 a片免費看 情色視訊禁地論壇 日本 a 片,無碼影片,美女,sexy,a片天堂 小魔女免費影城 視訊美女sogo 色論壇 s38live秀 卡通aa片免費看自拍天堂 洪爺免費線上歐美A片段觀看 亞洲東洋影片 0941 影音視訊聊天室 18成人85cc影城0204movie 成人漫畫區月光論壇 a片-情色成人影片 免費視訊toolbox 707網愛聊天室 1111辣妹貼圖,寫真集辣妹 av無碼月光論壇辣妹視訊 視訊辣妹主播脫衣秀 aio性愛dvd辣妹影片直播 黑澀會美眉 mv 高雄視訊,qq 美女貼圖片區 5i176 免費視訊秀 168論壇視訊辣妹 a片天堂s383視訊 bt電影下載,aa 片 sexy girl video movie 080cc成人色網 後官0951主入口 視訊聊天評比 視訊交友聊天室 no8 sogo論壇視訊辣妹
喜歡你的部落格,留言請您繼續加油...............................................................
幸福不是一切,人還有責任。..................................................
人不能像動物一樣活著,而應該追求知識和美德..................................................
you always know the right thing to say!............................................................
go2av免費影片sex 0401 影音 live 秀視訊聊天交友 色美眉台中援交aa 片試看 a免費視訊聊天網 情人34C波霸美女 香蕉鮑魚俱樂部,免費av 免費線上 aa 片試看 g點無碼a片 性愛姿勢 辣妹sex story 視訊聊天室 sex888免費看影片波霸美女寫真 視訊美女pixnet 成人交友hibb 4u成人視訊 情人080視訊網 私密論壇sex888免費看影片論壇 Show-live視訊聊天室 辣妹貼圖a片天堂 a片免費看 情色視訊禁地論壇 日本 a 片,無碼影片,美女,sexy,a片天堂 小魔女免費影城 視訊美女sogo 色論壇 s38live秀 卡通aa片免費看自拍天堂 洪爺免費線上歐美A片段觀看 亞洲東洋影片 0941 影音視訊聊天室 18成人85cc影城0204movie 成人漫畫區月光論壇 a片-情色成人影片 免費視訊toolbox 707網愛聊天室 1111辣妹貼圖,寫真集辣妹 av無碼月光論壇辣妹視訊 視訊辣妹主播脫衣秀 aio性愛dvd辣妹影片直播 黑澀會美眉 mv 高雄視訊,qq 美女貼圖片區 5i176 免費視訊秀 168論壇視訊辣妹 a片天堂s383視訊 bt電影下載,aa 片 sexy girl video movie 080cc成人色網 後官0951主入口 視訊聊天評比 視訊交友聊天室 no8 sogo論壇視訊辣妹
Necessity is the mother of invention...................................................................
期待你每一篇文章......................................................................
知識可以傳授,智慧卻不行。每個人必須成為他自己。......................................................................
人不能像動物一樣活著,而應該追求知識和美德.................................................................
幸福不是一切,人還有責任。............................................................
It takes all kinds to make a world.............................................................
向著星球長驅直進的人,反比踟躕在峽路上的人,更容易達到目的。............................................................
看得見您的用心~~希望這裡愈來愈熱鬧哦~~............................................................
As a man sows, so he shall reap...................................................................
Nothing comes from nothing.............................................................
Prevention is better than cure...................................................
笑口常開~~天天開心..................................................................
thanks god for the chance to enjoy so many good artical.............................................................
當最困難的時候,也就是離成功不遠的時候。..................................................
Necessity is the mother of invention..................................................................
A friend in need is a friend indeed.............................................................
老天爺賦予了強者的能力,就是要他比弱者多擔待..................................................
Readiness is all.............................................................
來逛逛blog~~跟您打聲招呼............................................................
人不能像動物一樣活著,而應該追求知識和美德................. ................................................
一個人的價值,應該看他貢獻了什麼,而不是他取得了什麼............................................................
Post a Comment