Skip to content

Commit 67f7717

Browse files
committed
nw2: Fix Win.zoomLevel
Ref nwjs#5875
1 parent 4197d43 commit 67f7717

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

src/api/nw_current_window_internal.idl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ namespace nw.currentWindowInternal {
3636
static bool isKioskInternal();
3737
static void capturePageInternal(optional CapturePageOptions options, optional CapturePageCallback callback);
3838
static void clearMenu(optional long win);
39-
static MenuPatch[] setMenu(long id, optional long wid);
39+
static MenuPatch[] setMenu(long id, optional long winId);
4040
static void reloadIgnoringCache();
41-
static double getZoom();
42-
static void setZoom(double level);
41+
static double getZoom(optional long winId);
42+
static void setZoom(double level, optional long winId);
4343
static void setShowInTaskbar(boolean show);
4444
static DOMString getTitleInternal(optional long winId);
4545
static void setTitleInternal(DOMString title, optional long winId);

src/api/nw_window_api.cc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,16 @@ NwCurrentWindowInternalReloadIgnoringCacheFunction::Run() {
721721

722722
bool NwCurrentWindowInternalGetZoomFunction::RunNWSync(base::ListValue* response, std::string* error) {
723723
content::WebContents* web_contents = GetSenderWebContents();
724+
if (args_->GetSize() > 0) {
725+
int id = 0;
726+
args_->GetInteger(0, &id);
727+
Browser* browser = getBrowser(this, id);
728+
if (!browser) {
729+
*error = "no browser window found";
730+
return false;
731+
}
732+
web_contents = browser->tab_strip_model()->GetActiveWebContents();
733+
}
724734
if (!web_contents)
725735
return false;
726736
double zoom_level =
@@ -734,6 +744,16 @@ bool NwCurrentWindowInternalSetZoomFunction::RunNWSync(base::ListValue* response
734744

735745
EXTENSION_FUNCTION_VALIDATE(args_->GetDouble(0, &zoom_level));
736746
content::WebContents* web_contents = GetSenderWebContents();
747+
if (args_->GetSize() > 1) {
748+
int id = 0;
749+
args_->GetInteger(1, &id);
750+
Browser* browser = getBrowser(this, id);
751+
if (!browser) {
752+
*error = "no browser window found";
753+
return false;
754+
}
755+
web_contents = browser->tab_strip_model()->GetActiveWebContents();
756+
}
737757
if (!web_contents)
738758
return false;
739759
ZoomController* zoom_controller =

src/resources/api_nw_newwin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,10 +579,10 @@ Object.defineProperty(NWWindow.prototype, 'title', {
579579
});
580580
Object.defineProperty(NWWindow.prototype, 'zoomLevel', {
581581
get: function() {
582-
return currentNWWindowInternal.getZoom();
582+
return currentNWWindowInternal.getZoom(this.cWindow.id);
583583
},
584584
set: function(val) {
585-
currentNWWindowInternal.setZoom(val);
585+
currentNWWindowInternal.setZoom(val, this.cWindow.id);
586586
}
587587
});
588588
Object.defineProperty(NWWindow.prototype, 'isTransparent', {

0 commit comments

Comments
 (0)