Bug 401322 - "missing "Text Size" zoom feature, Full page zoom should be an option not replacement" [p=elmar.ludwig@uos.de (Elmar Ludwig) ui-r=beltzner r=gavin sr=bzbarsky a1.9=schrep]

This commit is contained in:
reed@reedloden.com 2008-02-13 03:00:45 -08:00
parent f5e38bca8c
commit ba0ce9ac14
8 changed files with 98 additions and 71 deletions

View File

@ -406,7 +406,7 @@ pref("mousewheel.withmetakey.action",0);
pref("mousewheel.withmetakey.sysnumlines",true);
pref("mousewheel.withmetakey.numlines",1);
#endif
pref("mousewheel.withcontrolkey.action",5);
pref("mousewheel.withcontrolkey.action",3);
pref("mousewheel.withcontrolkey.sysnumlines",false);
pref("mousewheel.withcontrolkey.numlines",1);
@ -674,6 +674,9 @@ pref("browser.ssl_override_behavior", 1);
// 2 - show full domain (e.g. bugzilla.mozilla.org)
pref("browser.identity.ssl_domain_display", 0);
// if true, use full page zoom instead of text zoom
pref("browser.zoom.full", true);
// replace newlines with spaces when pasting into <input type="text"> fields
pref("editor.singleLine.pasteNewlines", 2);

View File

@ -173,7 +173,7 @@
#endif
<menuitem label="&reloadCmd.label;" accesskey="&reloadCmd.accesskey;" command="Browser:Reload" key="key_reload"/>
<menuseparator/>
<menu id="viewFullZoomMenu" label="&fullZoom.label;" accesskey="&fullZoom.accesskey;">
<menu id="viewFullZoomMenu" label="&fullZoom.label;" accesskey="&fullZoom.accesskey;" onpopupshowing="FullZoom.updateMenu();">
<menupopup>
<menuitem key="key_fullZoomEnlarge" label="&fullZoomEnlargeCmd.label;" accesskey="&fullZoomEnlargeCmd.accesskey;"
command="cmd_fullZoomEnlarge"/>
@ -182,6 +182,9 @@
<menuseparator/>
<menuitem key="key_fullZoomReset" label="&fullZoomResetCmd.label;" accesskey="&fullZoomResetCmd.accesskey;"
command="cmd_fullZoomReset"/>
<menuseparator/>
<menuitem id="toggle_zoom" label="&fullZoomToggleCmd.label;" accesskey="&fullZoomToggleCmd.accesskey;"
type="checkbox" command="cmd_fullZoomToggle" checked="false"/>
</menupopup>
</menu>
<menu id="pageStyleMenu" label="&pageStyleMenu.label;" accesskey="&pageStyleMenu.accesskey;" observes="isImage">

View File

@ -104,6 +104,7 @@
<command id="cmd_fullZoomReduce" oncommand="FullZoom.reduce()"/>
<command id="cmd_fullZoomEnlarge" oncommand="FullZoom.enlarge()"/>
<command id="cmd_fullZoomReset" oncommand="FullZoom.reset()"/>
<command id="cmd_fullZoomToggle" oncommand="ZoomManager.toggleZoom();"/>
<command id="Browser:OpenLocation" oncommand="openLocation();"/>
<command id="Tools:Search" oncommand="BrowserSearch.webSearch();"/>

View File

@ -44,7 +44,7 @@ const MOUSE_SCROLL_IS_HORIZONTAL = 1 << 2;
// One of the possible values for the mousewheel.* preferences.
// From nsEventStateManager.cpp.
const MOUSE_SCROLL_FULLZOOM = 5;
const MOUSE_SCROLL_ZOOM = 3;
/**
* Controls the "full zoom" setting and its site-specific preferences.
@ -149,7 +149,7 @@ var FullZoom = {
// Don't do anything if this isn't a "zoom" scroll event.
var isZoomEvent = false;
try {
isZoomEvent = (gPrefService.getIntPref(pref) == MOUSE_SCROLL_FULLZOOM);
isZoomEvent = (gPrefService.getIntPref(pref) == MOUSE_SCROLL_ZOOM);
} catch (e) {}
if (!isZoomEvent)
return;
@ -202,6 +202,13 @@ var FullZoom = {
this._applyPrefToSetting(this._cps.getPref(aURI, this.name));
},
// update state of zoom type menu item
updateMenu: function FullZoom_updateMenu() {
var menuItem = document.getElementById("toggle_zoom");
menuItem.setAttribute("checked", !ZoomManager.useFullZoom);
},
//**************************************************************************//
// Setting & Pref Manipulation
@ -218,7 +225,7 @@ var FullZoom = {
reset: function FullZoom_reset() {
if (typeof this.globalValue != "undefined")
ZoomManager.fullZoom = this.globalValue;
ZoomManager.zoom = this.globalValue;
else
ZoomManager.reset();
@ -255,11 +262,11 @@ var FullZoom = {
try {
if (typeof aValue != "undefined")
ZoomManager.fullZoom = this._ensureValid(aValue);
ZoomManager.zoom = this._ensureValid(aValue);
else if (typeof this.globalValue != "undefined")
ZoomManager.fullZoom = this.globalValue;
ZoomManager.zoom = this.globalValue;
else
ZoomManager.fullZoom = 1;
ZoomManager.zoom = 1;
}
catch(ex) {}
},
@ -268,8 +275,8 @@ var FullZoom = {
if (gInPrintPreviewMode)
return;
var fullZoom = ZoomManager.fullZoom;
this._cps.setPref(gBrowser.currentURI, this.name, fullZoom);
var zoomLevel = ZoomManager.zoom;
this._cps.setPref(gBrowser.currentURI, this.name, zoomLevel);
},
_removePref: function FullZoom__removePref() {

View File

@ -215,9 +215,8 @@ enum {
MOUSE_SCROLL_N_LINES,
MOUSE_SCROLL_PAGE,
MOUSE_SCROLL_HISTORY,
MOUSE_SCROLL_TEXTSIZE,
MOUSE_SCROLL_PIXELS,
MOUSE_SCROLL_FULLZOOM
MOUSE_SCROLL_ZOOM,
MOUSE_SCROLL_PIXELS
};
// mask values for ui.key.chromeAccess and ui.key.contentAccess
@ -2025,8 +2024,8 @@ nsEventStateManager::ChangeFullZoom(PRInt32 change)
NS_ENSURE_SUCCESS(rv, rv);
float fullzoom;
float zoomMin = ((float)nsContentUtils::GetIntPref("fullZoom.minPercent", 50)) / 100;
float zoomMax = ((float)nsContentUtils::GetIntPref("fullZoom.maxPercent", 300)) / 100;
float zoomMin = ((float)nsContentUtils::GetIntPref("zoom.minPercent", 50)) / 100;
float zoomMax = ((float)nsContentUtils::GetIntPref("zoom.maxPercent", 300)) / 100;
mv->GetFullZoom(&fullzoom);
fullzoom += ((float)change) / 10;
if (fullzoom < zoomMin)
@ -2055,8 +2054,8 @@ nsEventStateManager::DoScrollHistory(PRInt32 direction)
}
void
nsEventStateManager::DoScrollTextsize(nsIFrame *aTargetFrame,
PRInt32 adjustment)
nsEventStateManager::DoScrollZoom(nsIFrame *aTargetFrame,
PRInt32 adjustment)
{
// Exclude form controls and XUL content.
nsIContent *content = aTargetFrame->GetContent();
@ -2064,23 +2063,13 @@ nsEventStateManager::DoScrollTextsize(nsIFrame *aTargetFrame,
!content->IsNodeOfType(nsINode::eHTML_FORM_CONTROL) &&
!content->IsNodeOfType(nsINode::eXUL))
{
// negative adjustment to increase text size, positive to decrease
ChangeTextSize((adjustment > 0) ? -1 : 1);
}
}
// positive adjustment to decrease zoom, negative to increase
PRInt32 change = (adjustment > 0) ? -1 : 1;
void
nsEventStateManager::DoScrollFullZoom(nsIFrame *aTargetFrame,
PRInt32 adjustment)
{
// Exclude form controls and XUL content.
nsIContent *content = aTargetFrame->GetContent();
if (content &&
!content->IsNodeOfType(nsINode::eHTML_FORM_CONTROL) &&
!content->IsNodeOfType(nsINode::eXUL))
{
// negative adjustment to increase zoom, positive to decrease
ChangeFullZoom((adjustment > 0) ? -1 : 1);
if (nsContentUtils::GetBoolPref("browser.zoom.full"))
ChangeFullZoom(change);
else
ChangeTextSize(change);
}
}
@ -2471,15 +2460,9 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
}
break;
case MOUSE_SCROLL_TEXTSIZE:
case MOUSE_SCROLL_ZOOM:
{
DoScrollTextsize(aTargetFrame, msEvent->delta);
}
break;
case MOUSE_SCROLL_FULLZOOM:
{
DoScrollFullZoom(aTargetFrame, msEvent->delta);
DoScrollZoom(aTargetFrame, msEvent->delta);
}
break;

View File

@ -304,8 +304,7 @@ protected:
ScrollQuantity aScrollQuantity);
void ForceViewUpdate(nsIView* aView);
void DoScrollHistory(PRInt32 direction);
void DoScrollTextsize(nsIFrame *aTargetFrame, PRInt32 adjustment);
void DoScrollFullZoom(nsIFrame *aTargetFrame, PRInt32 adjustment);
void DoScrollZoom(nsIFrame *aTargetFrame, PRInt32 adjustment);
nsresult GetMarkupDocumentViewer(nsIMarkupDocumentViewer** aMv);
nsresult ChangeTextSize(PRInt32 change);
nsresult ChangeFullZoom(PRInt32 change);

View File

@ -2371,6 +2371,7 @@ pref("signon.autofillForms", true);
pref("signon.debug", false); // logs to Error Console
// Zoom prefs
pref("fullZoom.minPercent", 50);
pref("fullZoom.maxPercent", 300);
pref("toolkit.zoomManager.fullZoomValues", ".5,.75,1,1.25,1.5,2,3");
pref("browser.zoom.full", false);
pref("zoom.minPercent", 50);
pref("zoom.maxPercent", 300);
pref("toolkit.zoomManager.zoomValues", ".5,.75,1,1.25,1.5,2,3");

View File

@ -47,64 +47,94 @@
var ZoomManager = {
get _prefBranch ZoomManager_get__prefBranch() {
return Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
delete this._prefBranch;
return this._prefBranch = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
},
get MIN ZoomManager_get_MIN() {
delete this.MIN;
return this.MIN = this._prefBranch.getIntPref("fullZoom.minPercent") / 100;
return this.MIN = this._prefBranch.getIntPref("zoom.minPercent") / 100;
},
get MAX ZoomManager_get_MAX() {
delete this.MAX;
return this.MAX = this._prefBranch.getIntPref("fullZoom.maxPercent") / 100;
return this.MAX = this._prefBranch.getIntPref("zoom.maxPercent") / 100;
},
get fullZoom ZoomManager_get_fullZoom() {
return getBrowser().markupDocumentViewer.fullZoom;
get useFullZoom ZoomManager_get_useFullZoom() {
return this._prefBranch.getBoolPref("browser.zoom.full");
},
set fullZoom ZoomManager_set_fullZoom(aVal) {
set useFullZoom ZoomManager_set_useFullZoom(aVal) {
this._prefBranch.setBoolPref("browser.zoom.full", aVal);
return aVal;
},
get zoom ZoomManager_get_zoom() {
var markupDocumentViewer = getBrowser().markupDocumentViewer;
return this.useFullZoom ? markupDocumentViewer.fullZoom
: markupDocumentViewer.textZoom;
},
set zoom ZoomManager_set_zoom(aVal) {
if (aVal < this.MIN || aVal > this.MAX)
throw Components.results.NS_ERROR_INVALID_ARG;
return (getBrowser().markupDocumentViewer.fullZoom = aVal);
var markupDocumentViewer = getBrowser().markupDocumentViewer;
if (this.useFullZoom) {
markupDocumentViewer.textZoom = 1;
markupDocumentViewer.fullZoom = aVal;
} else {
markupDocumentViewer.textZoom = aVal;
markupDocumentViewer.fullZoom = 1;
}
return aVal;
},
get fullZoomValues ZoomManager_get_fullZoomValues() {
var fullZoomValues = this._prefBranch.getCharPref("toolkit.zoomManager.fullZoomValues")
.split(",").map(parseFloat);
fullZoomValues.sort();
get zoomValues ZoomManager_get_zoomValues() {
var zoomValues = this._prefBranch.getCharPref("toolkit.zoomManager.zoomValues")
.split(",").map(parseFloat);
zoomValues.sort();
while (fullZoomValues[0] < this.MIN)
fullZoomValues.shift();
while (zoomValues[0] < this.MIN)
zoomValues.shift();
while (fullZoomValues[fullZoomValues.length - 1] > this.MAX)
fullZoomValues.pop();
while (zoomValues[zoomValues.length - 1] > this.MAX)
zoomValues.pop();
delete this.fullZoomValues;
return this.fullZoomValues = fullZoomValues;
delete this.zoomValues;
return this.zoomValues = zoomValues;
},
enlarge: function ZoomManager_enlarge() {
var i = this.fullZoomValues.indexOf(this.snap(this.fullZoom)) + 1;
if (i < this.fullZoomValues.length)
this.fullZoom = this.fullZoomValues[i];
var i = this.zoomValues.indexOf(this.snap(this.zoom)) + 1;
if (i < this.zoomValues.length)
this.zoom = this.zoomValues[i];
},
reduce: function ZoomManager_reduce() {
var i = this.fullZoomValues.indexOf(this.snap(this.fullZoom)) - 1;
var i = this.zoomValues.indexOf(this.snap(this.zoom)) - 1;
if (i >= 0)
this.fullZoom = this.fullZoomValues[i];
this.zoom = this.zoomValues[i];
},
reset: function ZoomManager_reset() {
this.fullZoom = 1;
this.zoom = 1;
},
toggleZoom: function ZoomManager_toggleZoom() {
var zoomLevel = this.zoom;
this.useFullZoom = !this.useFullZoom;
this.zoom = zoomLevel;
},
snap: function ZoomManager_snap(aVal) {
var values = this.fullZoomValues;
var values = this.zoomValues;
for (var i = 0; i < values.length; i++) {
if (values[i] >= aVal) {
if (i > 0 && aVal - values[i - 1] < values[i] - aVal)