Changeset 51560 in webkit


Ignore:
Timestamp:
Dec 1, 2009 3:34:28 PM (14 years ago)
Author:
pkasting@chromium.org
Message:

[Chromium] Simplify zoom-related APIs and add a zoom level getter,
part one: Add new APIs. (Old APIs will be removed in a second pass.)
https://bugs.webkit.org/show_bug.cgi?id=31893

Reviewed by Darin Fisher.

  • public/WebView.h:
  • src/WebViewImpl.cpp:

(WebKit::WebViewImpl::zoomLevel):
(WebKit::WebViewImpl::setZoomLevel):

  • src/WebViewImpl.h:
Location:
trunk/WebKit/chromium
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/chromium/ChangeLog

    r51548 r51560  
     12009-12-01  Peter Kasting  <pkasting@google.com>
     2
     3        Reviewed by Darin Fisher.
     4
     5        [Chromium] Simplify zoom-related APIs and add a zoom level getter,
     6        part one: Add new APIs.  (Old APIs will be removed in a second pass.)
     7        https://bugs.webkit.org/show_bug.cgi?id=31893
     8
     9        * public/WebView.h:
     10        * src/WebViewImpl.cpp:
     11        (WebKit::WebViewImpl::zoomLevel):
     12        (WebKit::WebViewImpl::setZoomLevel):
     13        * src/WebViewImpl.h:
     14
    1152009-12-01  Xiyuan Xia  <xiyuan@chromium.org>
    216
  • trunk/WebKit/chromium/public/WebView.h

    r51440 r51560  
    136136    // Zoom ----------------------------------------------------------------
    137137
    138     // Change the text zoom level.  It will make the zoom level 20% larger
    139     // or smaller.  If textOnly is set, the text size will be changed.
    140     // When unset, the entire page's zoom factor will be changed.
    141     //
    142     // You can only have either text zoom or full page zoom at one time.
    143     // Changing the mode will change things in weird ways.  Generally the
    144     // app should only support text zoom or full page zoom, and not both.
    145     //
    146     // zoomDefault will reset both full page and text zoom.
     138    // DEPRECATED: Will be removed very soon!
    147139    virtual void zoomIn(bool textOnly) = 0;
    148140    virtual void zoomOut(bool textOnly) = 0;
    149141    virtual void zoomDefault() = 0;
     142
     143    // Returns the current zoom level.  0 is "original size", and each increment
     144    // above or below represents zooming 20% larger or smaller to limits of 300%
     145    // and 50% of original size, respectively.
     146    virtual int zoomLevel() = 0;
     147
     148    // Changes the zoom level to the specified level, clamping at the limits
     149    // noted above, and returns the current zoom level after applying the
     150    // change.
     151    //
     152    // If |textOnly| is set, only the text will be zoomed; otherwise the entire
     153    // page will be zoomed. You can only have either text zoom or full page zoom
     154    // at one time.  Changing the mode while the page is zoomed will have odd
     155    // effects.
     156    virtual int setZoomLevel(bool textOnly, int zoomLevel) = 0;
    150157
    151158
  • trunk/WebKit/chromium/src/WebViewImpl.cpp

    r51440 r51560  
    12471247}
    12481248
     1249// DEPRECATED
    12491250void WebViewImpl::zoomIn(bool textOnly)
    12501251{
     
    12591260}
    12601261
     1262// DEPRECATED
    12611263void WebViewImpl::zoomOut(bool textOnly)
    12621264{
     
    12711273}
    12721274
     1275// DEPRECATED
    12731276void WebViewImpl::zoomDefault()
    12741277{
     
    12781281    mainFrameImpl()->frame()->setZoomFactor(
    12791282        1.0f, mainFrameImpl()->frame()->isZoomFactorTextOnly());
     1283}
     1284
     1285int WebViewImpl::zoomLevel()
     1286{
     1287    return m_zoomLevel;
     1288}
     1289
     1290int WebViewImpl::setZoomLevel(bool textOnly, int zoomLevel)
     1291{
     1292    float zoomFactor = static_cast<float>(
     1293        std::max(std::min(std::pow(textSizeMultiplierRatio, zoomLevel),
     1294                          maxTextSizeMultiplier),
     1295                 minTextSizeMultiplier));
     1296    Frame* frame = mainFrameImpl()->frame();
     1297    if (zoomFactor != frame->zoomFactor()) {
     1298        m_zoomLevel = zoomLevel;
     1299        frame->setZoomFactor(zoomFactor, textOnly);
     1300    }
     1301    return m_zoomLevel;
    12801302}
    12811303
  • trunk/WebKit/chromium/src/WebViewImpl.h

    r51440 r51560  
    117117    virtual void setInitialFocus(bool reverse);
    118118    virtual void clearFocusedNode();
    119     virtual void zoomIn(bool textOnly);
    120     virtual void zoomOut(bool textOnly);
    121     virtual void zoomDefault();
     119    virtual void zoomIn(bool textOnly);   // DEPRECATED
     120    virtual void zoomOut(bool textOnly);  // DEPRECATED
     121    virtual void zoomDefault();           // DEPRECATED
     122    virtual int zoomLevel();
     123    virtual int setZoomLevel(bool textOnly, int zoomLevel);
    122124    virtual void performMediaPlayerAction(
    123125        const WebMediaPlayerAction& action,
     
    338340    WebPoint m_lastMouseDownPoint;
    339341
    340     // Keeps track of the current text zoom level.  0 means no zoom, positive
    341     // values mean larger text, negative numbers mean smaller.
     342    // Keeps track of the current zoom level.  0 means no zoom, positive numbers
     343    // mean zoom in, negative numbers mean zoom out.
    342344    int m_zoomLevel;
    343345
Note: See TracChangeset for help on using the changeset viewer.