[haiku-webkit-commits] r381 - in webkit/trunk/WebKit/haiku: API WebPositive

  • From: webkit@xxxxxxxxxxxxxxx
  • To: haiku-webkit-commits@xxxxxxxxxxxxx
  • Date: Sat, 03 Apr 2010 19:32:47 +0000

Author: stippi
Date: Sat Apr  3 19:32:47 2010
New Revision: 381
URL: http://mmlr.dyndns.org/changeset/381

Log:
Added option and infrastructure to zoom the whole page instead of the text only.
(Currently not remembered, but the default (off) is often better than zooming
images.)

Modified:
   webkit/trunk/WebKit/haiku/API/WebFrame.cpp
   webkit/trunk/WebKit/haiku/API/WebFrame.h
   webkit/trunk/WebKit/haiku/API/WebPage.cpp
   webkit/trunk/WebKit/haiku/API/WebPage.h
   webkit/trunk/WebKit/haiku/API/WebView.cpp
   webkit/trunk/WebKit/haiku/API/WebView.h
   webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp
   webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h

Modified: webkit/trunk/WebKit/haiku/API/WebFrame.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebFrame.cpp  Sat Apr  3 16:46:54 2010        
(r380)
+++ webkit/trunk/WebKit/haiku/API/WebFrame.cpp  Sat Apr  3 19:32:47 2010        
(r381)
@@ -23,7 +23,7 @@
  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #include "config.h"
@@ -50,14 +50,14 @@
 #include <Entry.h>
 #include <String.h>
 
-static const float kMinimumTextSizeMultiplier = 0.5;
-static const float kMaximumTextSizeMultiplier = 3;
-static const float kTextSizeMultiplierRatio = 1.1;
+static const float kMinimumZoomFactorMultiplier = 0.5;
+static const float kMaximumZoomFactorMultiplier = 3;
+static const float kZoomFactorMultiplierRatio = 1.1;
 
 using namespace WebCore;
 
 BWebFrame::BWebFrame(BWebPage* webPage, BWebFrame* parentFrame, 
WebFramePrivate* data)
-    : fTextMagnifier(1.0)
+    : fZoomFactor(1.0)
     , fIsEditable(false)
     , fTitle(0)
     , fData(data)
@@ -306,48 +306,48 @@
     return false;
 }
 
-bool BWebFrame::CanIncreaseTextSize() const
+bool BWebFrame::CanIncreaseZoomFactor() const
 {
     if (fData->frame)
-        if (fTextMagnifier * kTextSizeMultiplierRatio <= 
kMaximumTextSizeMultiplier)
+        if (fZoomFactor * kZoomFactorMultiplierRatio <= 
kMaximumZoomFactorMultiplier)
             return true;
 
     return false;
 }
 
-bool BWebFrame::CanDecreaseTextSize() const
+bool BWebFrame::CanDecreaseZoomFactor() const
 {
     if (fData->frame)
-        return fTextMagnifier / kTextSizeMultiplierRatio >= 
kMinimumTextSizeMultiplier;
+        return fZoomFactor / kZoomFactorMultiplierRatio >= 
kMinimumZoomFactorMultiplier;
 
     return false;
 }
 
-void BWebFrame::IncreaseTextSize()
+void BWebFrame::IncreaseZoomFactor(bool textOnly)
 {
-    if (CanIncreaseTextSize()) {
-        fTextMagnifier = fTextMagnifier * kTextSizeMultiplierRatio;
-        fData->frame->setZoomFactor(fTextMagnifier, true);
+    if (CanIncreaseZoomFactor()) {
+        fZoomFactor = fZoomFactor * kZoomFactorMultiplierRatio;
+        fData->frame->setZoomFactor(fZoomFactor, textOnly);
     }
 }
 
-void BWebFrame::DecreaseTextSize()
+void BWebFrame::DecreaseZoomFactor(bool textOnly)
 {
-    if (CanDecreaseTextSize()) {
-        fTextMagnifier = fTextMagnifier / kTextSizeMultiplierRatio;
-        fData->frame->setZoomFactor(fTextMagnifier, true);
+    if (CanDecreaseZoomFactor()) {
+        fZoomFactor = fZoomFactor / kZoomFactorMultiplierRatio;
+        fData->frame->setZoomFactor(fZoomFactor, textOnly);
     }
 }
 
-void BWebFrame::ResetTextSize()
+void BWebFrame::ResetZoomFactor()
 {
-    if (fTextMagnifier == 1)
+    if (fZoomFactor == 1)
         return;
 
-    fTextMagnifier = 1;
+    fZoomFactor = 1;
 
     if (fData->frame)
-        fData->frame->setZoomFactor(fTextMagnifier, true);
+        fData->frame->setZoomFactor(fZoomFactor, true);
 }
 
 void BWebFrame::SetEditable(bool editable)

Modified: webkit/trunk/WebKit/haiku/API/WebFrame.h
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebFrame.h    Sat Apr  3 16:46:54 2010        
(r380)
+++ webkit/trunk/WebKit/haiku/API/WebFrame.h    Sat Apr  3 19:32:47 2010        
(r381)
@@ -89,13 +89,13 @@
                                                                        bool 
wrapSelection = true,
                                                                        bool 
startInSelection = true);
 
-                       bool                            CanIncreaseTextSize() 
const;
-                       bool                            CanDecreaseTextSize() 
const;
+                       bool                            CanIncreaseZoomFactor() 
const;
+                       bool                            CanDecreaseZoomFactor() 
const;
 
-                       void                            IncreaseTextSize();
-                       void                            DecreaseTextSize();
+                       void                            IncreaseZoomFactor(bool 
textOnly);
+                       void                            DecreaseZoomFactor(bool 
textOnly);
 
-                       void                            ResetTextSize();
+                       void                            ResetZoomFactor();
 
                        void                            SetEditable(bool 
editable);
                        bool                            IsEditable() const;
@@ -120,7 +120,7 @@
                        WebCore::Frame*         Frame() const;
 
 private:
-                       float                           fTextMagnifier;
+                       float                           fZoomFactor;
                        bool                            fIsEditable;
                        BString                         fTitle;
 

Modified: webkit/trunk/WebKit/haiku/API/WebPage.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebPage.cpp   Sat Apr  3 16:46:54 2010        
(r380)
+++ webkit/trunk/WebKit/haiku/API/WebPage.cpp   Sat Apr  3 19:32:47 2010        
(r381)
@@ -111,7 +111,7 @@
     HANDLE_DRAW = 'draw',
     HANDLE_FRAME_RESIZED = 'rszd',
 
-    HANDLE_CHANGE_TEXT_SIZE = 'txts',
+    HANDLE_CHANGE_ZOOM_FACTOR = 'zmfr',
     HANDLE_FIND_STRING = 'find',
 
     HANDLE_SET_STATUS_MESSAGE = 'stsm',
@@ -293,10 +293,11 @@
     Looper()->PostMessage(&message, this);
 }
 
-void BWebPage::ChangeTextSize(float increment)
+void BWebPage::ChangeZoomFactor(float increment, bool textOnly)
 {
-       BMessage message(HANDLE_CHANGE_TEXT_SIZE);
+       BMessage message(HANDLE_CHANGE_ZOOM_FACTOR);
        message.AddFloat("increment", increment);
+       message.AddBool("text only", textOnly);
     Looper()->PostMessage(&message, this);
 }
 
@@ -904,8 +905,8 @@
         handleKeyEvent(message);
         break;
 
-       case HANDLE_CHANGE_TEXT_SIZE:
-               handleChangeTextSize(message);
+       case HANDLE_CHANGE_ZOOM_FACTOR:
+               handleChangeZoomFactor(message);
                break;
     case HANDLE_FIND_STRING:
         handleFindString(message);
@@ -1161,16 +1162,22 @@
        }
 }
 
-void BWebPage::handleChangeTextSize(BMessage* message)
+void BWebPage::handleChangeZoomFactor(BMessage* message)
 {
-    float increment = 0;
-    message->FindFloat("increment", &increment);
+    float increment;
+    if (message->FindFloat("increment", &increment) != B_OK)
+       increment = 0;
+
+    bool textOnly;
+    if (message->FindBool("text only", &textOnly) != B_OK)
+       textOnly = true;
+
     if (increment > 0)
-       fMainFrame->IncreaseTextSize();
+       fMainFrame->IncreaseZoomFactor(textOnly);
     else if (increment < 0)
-       fMainFrame->DecreaseTextSize();
+       fMainFrame->DecreaseZoomFactor(textOnly);
     else
-       fMainFrame->ResetTextSize();
+       fMainFrame->ResetZoomFactor();
 }
 
 void BWebPage::handleFindString(BMessage* message)

Modified: webkit/trunk/WebKit/haiku/API/WebPage.h
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebPage.h     Sat Apr  3 16:46:54 2010        
(r380)
+++ webkit/trunk/WebKit/haiku/API/WebPage.h     Sat Apr  3 19:32:47 2010        
(r381)
@@ -100,7 +100,8 @@
                        BString                         MainFrameRequestedURL() 
const;
                        BString                         MainFrameURL() const;
 
-                       void                            ChangeTextSize(float 
increment);
+                       void                            ChangeZoomFactor(float 
increment,
+                                                                       bool 
textOnly);
                        void                            FindString(const char* 
string,
                                                                        bool 
forward = true,
                                                                        bool 
caseSensitive = false,
@@ -206,7 +207,7 @@
        void handleMouseEvent(const BMessage* message);
        void handleMouseWheelChanged(BMessage* message);
        void handleKeyEvent(BMessage* message);
-       void handleChangeTextSize(BMessage* message);
+       void handleChangeZoomFactor(BMessage* message);
        void handleFindString(BMessage* message);
        void handleResendNotifications(BMessage* message);
 

Modified: webkit/trunk/WebKit/haiku/API/WebView.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebView.cpp   Sat Apr  3 16:46:54 2010        
(r380)
+++ webkit/trunk/WebKit/haiku/API/WebView.cpp   Sat Apr  3 19:32:47 2010        
(r381)
@@ -267,19 +267,19 @@
     fWebPage->StopLoading();
 }
 
-void BWebView::IncreaseTextSize()
+void BWebView::IncreaseZoomFactor(bool textOnly)
 {
-       fWebPage->ChangeTextSize(1);
+       fWebPage->ChangeZoomFactor(1, textOnly);
 }
 
-void BWebView::DecreaseTextSize()
+void BWebView::DecreaseZoomFactor(bool textOnly)
 {
-       fWebPage->ChangeTextSize(-1);
+       fWebPage->ChangeZoomFactor(-1, textOnly);
 }
 
-void BWebView::ResetTextSize()
+void BWebView::ResetZoomFactor()
 {
-       fWebPage->ChangeTextSize(0);
+       fWebPage->ChangeZoomFactor(0, false);
 }
 
 void BWebView::FindString(const char* string, bool forward ,

Modified: webkit/trunk/WebKit/haiku/API/WebView.h
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebView.h     Sat Apr  3 16:46:54 2010        
(r380)
+++ webkit/trunk/WebKit/haiku/API/WebView.h     Sat Apr  3 19:32:47 2010        
(r381)
@@ -80,9 +80,9 @@
                        void                            GoForward();
                        void                            StopLoading();
 
-                       void                            IncreaseTextSize();
-                       void                            DecreaseTextSize();
-                       void                            ResetTextSize();
+                       void                            IncreaseZoomFactor(bool 
textOnly);
+                       void                            DecreaseZoomFactor(bool 
textOnly);
+                       void                            ResetZoomFactor();
 
                        void                            FindString(const char* 
string,
                                                                        bool 
forward = true,

Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp     Sat Apr  3 
16:46:54 2010        (r380)
+++ webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp     Sat Apr  3 
19:32:47 2010        (r381)
@@ -82,9 +82,10 @@
        CREATE_BOOKMARK = 'crbm',
        SHOW_BOOKMARKS = 'shbm',
 
-       TEXT_SIZE_INCREASE = 'tsin',
-       TEXT_SIZE_DECREASE = 'tsdc',
-       TEXT_SIZE_RESET = 'tsrs',
+       ZOOM_FACTOR_INCREASE = 'zfin',
+       ZOOM_FACTOR_DECREASE = 'zfdc',
+       ZOOM_FACTOR_RESET = 'zfrs',
+       ZOOM_TEXT_ONLY = 'zfto',
 
        TEXT_SHOW_FIND_GROUP = 'sfnd',
        TEXT_HIDE_FIND_GROUP = 'hfnd',
@@ -243,7 +244,8 @@
        :
        BWebWindow(frame, kApplicationName,
                B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
-               B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS)
+               B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS),
+       fZoomTextOnly(true)
 {
        BMessage* newTabMessage = new BMessage(NEW_TAB);
        newTabMessage->AddString("url", "");
@@ -282,9 +284,13 @@
        menu = new BMenu("Text");
        menu->AddItem(new BMenuItem("Find", new BMessage(TEXT_SHOW_FIND_GROUP), 
'F'));
        menu->AddSeparatorItem();
-       menu->AddItem(new BMenuItem("Increase size", new 
BMessage(TEXT_SIZE_INCREASE), '+'));
-       menu->AddItem(new BMenuItem("Decrease size", new 
BMessage(TEXT_SIZE_DECREASE), '-'));
-       menu->AddItem(new BMenuItem("Reset size", new 
BMessage(TEXT_SIZE_RESET), '0'));
+       menu->AddItem(new BMenuItem("Increase size", new 
BMessage(ZOOM_FACTOR_INCREASE), '+'));
+       menu->AddItem(new BMenuItem("Decrease size", new 
BMessage(ZOOM_FACTOR_DECREASE), '-'));
+       menu->AddItem(new BMenuItem("Reset size", new 
BMessage(ZOOM_FACTOR_RESET), '0'));
+       fZoomTextOnlyMenuItem = new BMenuItem("Zoom text only",
+               new BMessage(ZOOM_TEXT_ONLY));
+       fZoomTextOnlyMenuItem->SetMarked(fZoomTextOnly);
+       menu->AddItem(fZoomTextOnlyMenuItem);
        mainMenu->AddItem(menu);
 
        fGoMenu = new BMenu("Go");
@@ -593,14 +599,20 @@
                break;
        }
 
-       case TEXT_SIZE_INCREASE:
-               CurrentWebView()->IncreaseTextSize();
+       case ZOOM_FACTOR_INCREASE:
+               CurrentWebView()->IncreaseZoomFactor(fZoomTextOnly);
                break;
-       case TEXT_SIZE_DECREASE:
-               CurrentWebView()->DecreaseTextSize();
+       case ZOOM_FACTOR_DECREASE:
+               CurrentWebView()->DecreaseZoomFactor(fZoomTextOnly);
                break;
-       case TEXT_SIZE_RESET:
-               CurrentWebView()->ResetTextSize();
+       case ZOOM_FACTOR_RESET:
+               CurrentWebView()->ResetZoomFactor();
+               break;
+       case ZOOM_TEXT_ONLY:
+               fZoomTextOnly = !fZoomTextOnly;
+               fZoomTextOnlyMenuItem->SetMarked(fZoomTextOnly);
+               // TODO: Would be nice to have an instant update if the page is 
already
+               // zoomed.
                break;
 
        case TEXT_FIND_NEXT:

Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h       Sat Apr  3 
16:46:54 2010        (r380)
+++ webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h       Sat Apr  3 
19:32:47 2010        (r381)
@@ -40,6 +40,7 @@
 class BFile;
 class BLayoutItem;
 class BMenu;
+class BMenuItem;
 class BPath;
 class BStatusBar;
 class BStringView;
@@ -142,6 +143,8 @@
 
 private:
                        BMenu*                          fGoMenu;
+                       BMenuItem*                      fZoomTextOnlyMenuItem;
+                       bool                            fZoomTextOnly;
                        IconButton*                     fBackButton;
                        IconButton*                     fForwardButton;
                        IconButton*                     fStopButton;

Other related posts:

  • » [haiku-webkit-commits] r381 - in webkit/trunk/WebKit/haiku: API WebPositive - webkit