| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/views/tab_contents/tab_contents_view_win.h" | 5 #include "chrome/browser/views/tab_contents/tab_contents_view_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "app/gfx/canvas_paint.h" | 9 #include "app/gfx/canvas_paint.h" |
| 10 #include "app/os_exchange_data.h" | 10 #include "app/os_exchange_data.h" |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 // A message is reflected here from view(). | 476 // A message is reflected here from view(). |
| 477 // Return non-zero to indicate that it is handled here. | 477 // Return non-zero to indicate that it is handled here. |
| 478 // Return 0 to allow view() to further process it. | 478 // Return 0 to allow view() to further process it. |
| 479 LRESULT TabContentsViewWin::OnReflectedMessage(UINT msg, WPARAM w_param, | 479 LRESULT TabContentsViewWin::OnReflectedMessage(UINT msg, WPARAM w_param, |
| 480 LPARAM l_param) { | 480 LPARAM l_param) { |
| 481 MSG* message = reinterpret_cast<MSG*>(l_param); | 481 MSG* message = reinterpret_cast<MSG*>(l_param); |
| 482 switch (message->message) { | 482 switch (message->message) { |
| 483 case WM_MOUSEWHEEL: | 483 case WM_MOUSEWHEEL: |
| 484 // This message is reflected from the view() to this window. | 484 // This message is reflected from the view() to this window. |
| 485 if (GET_KEYSTATE_WPARAM(message->wParam) & MK_CONTROL) { | 485 if (GET_KEYSTATE_WPARAM(message->wParam) & MK_CONTROL) { |
| 486 WheelZoom(GET_WHEEL_DELTA_WPARAM(message->wParam)); | 486 PageZoom::Function zoom_type; |
| 487 const bool zoom_in = GET_WHEEL_DELTA_WPARAM(message->wParam) > 0; |
| 488 |
| 489 if (GET_KEYSTATE_WPARAM(message->wParam) & MK_SHIFT) { |
| 490 zoom_type = zoom_in ? PageZoom::TEXT_ONLY_LARGER : |
| 491 PageZoom::TEXT_ONLY_SMALLER; |
| 492 } else { |
| 493 zoom_type = zoom_in ? PageZoom::LARGER : PageZoom::SMALLER; |
| 494 } |
| 495 |
| 496 WheelZoom(zoom_type); |
| 487 return 1; | 497 return 1; |
| 488 } | 498 } |
| 489 break; | 499 break; |
| 490 case WM_HSCROLL: | 500 case WM_HSCROLL: |
| 491 case WM_VSCROLL: | 501 case WM_VSCROLL: |
| 492 if (ScrollZoom(LOWORD(message->wParam))) | 502 if (ScrollZoom(LOWORD(message->wParam))) |
| 493 return 1; | 503 return 1; |
| 494 default: | 504 default: |
| 495 break; | 505 break; |
| 496 } | 506 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 bool TabContentsViewWin::ScrollZoom(int scroll_type) { | 595 bool TabContentsViewWin::ScrollZoom(int scroll_type) { |
| 586 // If ctrl is held, zoom the UI. There are three issues with this: | 596 // If ctrl is held, zoom the UI. There are three issues with this: |
| 587 // 1) Should the event be eaten or forwarded to content? We eat the event, | 597 // 1) Should the event be eaten or forwarded to content? We eat the event, |
| 588 // which is like Firefox and unlike IE. | 598 // which is like Firefox and unlike IE. |
| 589 // 2) Should wheel up zoom in or out? We zoom in (increase font size), which | 599 // 2) Should wheel up zoom in or out? We zoom in (increase font size), which |
| 590 // is like IE and Google maps, but unlike Firefox. | 600 // is like IE and Google maps, but unlike Firefox. |
| 591 // 3) Should the mouse have to be over the content area? We zoom as long as | 601 // 3) Should the mouse have to be over the content area? We zoom as long as |
| 592 // content has focus, although FF and IE require that the mouse is over | 602 // content has focus, although FF and IE require that the mouse is over |
| 593 // content. This is because all events get forwarded when content has | 603 // content. This is because all events get forwarded when content has |
| 594 // focus. | 604 // focus. |
| 605 const int zoom_text_only = GetAsyncKeyState(VK_SHIFT) & 0x8000; |
| 606 |
| 595 if (GetAsyncKeyState(VK_CONTROL) & 0x8000) { | 607 if (GetAsyncKeyState(VK_CONTROL) & 0x8000) { |
| 596 int distance = 0; | 608 PageZoom::Function zoom_type; |
| 597 switch (scroll_type) { | 609 switch (scroll_type) { |
| 598 case SB_LINEUP: | 610 case SB_LINEUP: |
| 599 distance = WHEEL_DELTA; | 611 zoom_type = zoom_text_only ? PageZoom::TEXT_ONLY_LARGER : |
| 612 PageZoom::LARGER; |
| 600 break; | 613 break; |
| 601 case SB_LINEDOWN: | 614 case SB_LINEDOWN: |
| 602 distance = -WHEEL_DELTA; | 615 zoom_type = zoom_text_only ? PageZoom::TEXT_ONLY_SMALLER : |
| 616 PageZoom::SMALLER; |
| 603 break; | 617 break; |
| 604 // TODO(joshia): Handle SB_PAGEUP, SB_PAGEDOWN, SB_THUMBPOSITION, | 618 // TODO(joshia): Handle SB_PAGEUP, SB_PAGEDOWN, SB_THUMBPOSITION, |
| 605 // and SB_THUMBTRACK for completeness | 619 // and SB_THUMBTRACK for completeness |
| 606 default: | 620 default: |
| 607 break; | 621 return false; |
| 608 } | 622 } |
| 609 | 623 |
| 610 WheelZoom(distance); | 624 WheelZoom(zoom_type); |
| 611 return true; | 625 return true; |
| 612 } | 626 } |
| 613 return false; | 627 return false; |
| 614 } | 628 } |
| 615 | 629 |
| 616 void TabContentsViewWin::WheelZoom(int distance) { | 630 void TabContentsViewWin::WheelZoom(PageZoom::Function zoom_type) { |
| 617 if (tab_contents()->delegate()) { | 631 if (tab_contents()->delegate()) |
| 618 bool zoom_in = distance > 0; | 632 tab_contents()->delegate()->ContentsZoomChange(zoom_type); |
| 619 tab_contents()->delegate()->ContentsZoomChange(zoom_in); | |
| 620 } | |
| 621 } | 633 } |
| OLD | NEW |