Skip to content

Commit 94f6720

Browse files
committed
scope handling (wip)
1 parent 7f90a4f commit 94f6720

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

src/main/java/org/htmlunit/javascript/JavaScriptEngine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ public Object execute(final HtmlPage page, final Scriptable scope, final Script
792792
final HtmlUnitContextAction action = new HtmlUnitContextAction(page) {
793793
@Override
794794
public Object doRun(final Context cx) {
795-
return script.exec(cx, scope, ((TopLevel) scope).getGlobalThis());
795+
return script.exec(cx, scope, ScriptableObject.getTopLevelScope(scope).getGlobalThis());
796796
}
797797

798798
@Override

src/main/java/org/htmlunit/javascript/host/svg/SVGMatrix.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
*/
1515
package org.htmlunit.javascript.host.svg;
1616

17+
import org.htmlunit.corejs.javascript.TopLevel;
1718
import org.htmlunit.javascript.HtmlUnitScriptable;
1819
import org.htmlunit.javascript.JavaScriptEngine;
1920
import org.htmlunit.javascript.configuration.JsxClass;
2021
import org.htmlunit.javascript.configuration.JsxConstructor;
2122
import org.htmlunit.javascript.configuration.JsxFunction;
2223
import org.htmlunit.javascript.configuration.JsxGetter;
2324
import org.htmlunit.javascript.configuration.JsxSetter;
24-
import org.htmlunit.javascript.host.Window;
2525
import org.htmlunit.javascript.host.dom.DOMException;
2626

2727
/**
@@ -66,7 +66,7 @@ public void jsConstructor() {
6666
* Instantiates and configure scope and prototype.
6767
* @param scope the parent scope
6868
*/
69-
public SVGMatrix(final Window scope) {
69+
public SVGMatrix(final TopLevel scope) {
7070
this();
7171
setParentScope(scope);
7272
setPrototype(getPrototype(getClass()));
@@ -186,7 +186,7 @@ public void setF(final double newValue) {
186186
*/
187187
@JsxFunction
188188
public SVGMatrix flipX() {
189-
final SVGMatrix result = new SVGMatrix(getWindow());
189+
final SVGMatrix result = new SVGMatrix(getWindow().getWebWindow().getTopLevelScope());
190190
result.shearX_ = shearX_;
191191
result.shearY_ = -shearY_;
192192
result.scaleX_ = -scaleX_;
@@ -203,7 +203,7 @@ public SVGMatrix flipX() {
203203
*/
204204
@JsxFunction
205205
public SVGMatrix flipY() {
206-
final SVGMatrix result = new SVGMatrix(getWindow());
206+
final SVGMatrix result = new SVGMatrix(getWindow().getWebWindow().getTopLevelScope());
207207
result.shearX_ = -shearX_;
208208
result.shearY_ = shearY_;
209209
result.scaleX_ = scaleX_;
@@ -229,7 +229,7 @@ public SVGMatrix inverse() {
229229
DOMException.INVALID_STATE_ERR);
230230
}
231231

232-
final SVGMatrix result = new SVGMatrix(getWindow());
232+
final SVGMatrix result = new SVGMatrix(getWindow().getWebWindow().getTopLevelScope());
233233
result.shearX_ = -shearX_ / determinant;
234234
result.shearY_ = -shearY_ / determinant;
235235
result.scaleX_ = scaleY_ / determinant;
@@ -247,7 +247,7 @@ public SVGMatrix inverse() {
247247
*/
248248
@JsxFunction
249249
public SVGMatrix multiply(final SVGMatrix by) {
250-
final SVGMatrix result = new SVGMatrix(getWindow());
250+
final SVGMatrix result = new SVGMatrix(getWindow().getWebWindow().getTopLevelScope());
251251

252252
result.shearX_ = by.shearX_ * scaleX_ + by.scaleY_ * shearX_;
253253
result.shearY_ = by.scaleX_ * shearY_ + by.shearY_ * scaleY_;
@@ -270,7 +270,7 @@ public SVGMatrix rotate(final double angle) {
270270
final double sin = Math.sin(theta);
271271
final double cos = Math.cos(theta);
272272

273-
final SVGMatrix result = new SVGMatrix(getWindow());
273+
final SVGMatrix result = new SVGMatrix(getWindow().getWebWindow().getTopLevelScope());
274274

275275
result.shearX_ = -sin * scaleX_ + cos * shearX_;
276276
result.shearY_ = cos * shearY_ + sin * scaleY_;
@@ -301,7 +301,7 @@ public SVGMatrix rotateFromVector(final double x, final double y) {
301301
final double sin = Math.sin(theta);
302302
final double cos = Math.cos(theta);
303303

304-
final SVGMatrix result = new SVGMatrix(getWindow());
304+
final SVGMatrix result = new SVGMatrix(getWindow().getWebWindow().getTopLevelScope());
305305

306306
result.shearX_ = -sin * scaleX_ + cos * shearX_;
307307
result.shearY_ = cos * shearY_ + sin * scaleY_;
@@ -331,7 +331,7 @@ public SVGMatrix scale(final double factor) {
331331
*/
332332
@JsxFunction
333333
public SVGMatrix scaleNonUniform(final double factorX, final double factorY) {
334-
final SVGMatrix result = new SVGMatrix(getWindow());
334+
final SVGMatrix result = new SVGMatrix(getWindow().getWebWindow().getTopLevelScope());
335335

336336
result.shearX_ = factorY * shearX_;
337337
result.shearY_ = factorX * shearY_;
@@ -352,7 +352,7 @@ public SVGMatrix scaleNonUniform(final double factorX, final double factorY) {
352352
public SVGMatrix skewX(final double angle) {
353353
final double shear = Math.tan(Math.toRadians(angle));
354354

355-
final SVGMatrix result = new SVGMatrix(getWindow());
355+
final SVGMatrix result = new SVGMatrix(getWindow().getWebWindow().getTopLevelScope());
356356

357357
result.shearX_ = shear * scaleX_ + shearX_;
358358
result.shearY_ = shearY_;
@@ -373,7 +373,7 @@ public SVGMatrix skewX(final double angle) {
373373
public SVGMatrix skewY(final double angle) {
374374
final double shear = Math.tan(Math.toRadians(angle));
375375

376-
final SVGMatrix result = new SVGMatrix(getWindow());
376+
final SVGMatrix result = new SVGMatrix(getWindow().getWebWindow().getTopLevelScope());
377377

378378
result.shearX_ = shearX_;
379379
result.shearY_ = shearY_ + shear * scaleY_;
@@ -393,7 +393,7 @@ public SVGMatrix skewY(final double angle) {
393393
*/
394394
@JsxFunction
395395
public SVGMatrix translate(final double x, final double y) {
396-
final SVGMatrix result = new SVGMatrix(getWindow());
396+
final SVGMatrix result = new SVGMatrix(getWindow().getWebWindow().getTopLevelScope());
397397

398398
result.shearX_ = shearX_;
399399
result.shearY_ = shearY_;

src/main/java/org/htmlunit/javascript/host/svg/SVGSVGElement.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void jsConstructor() {
5454
*/
5555
@JsxFunction
5656
public SVGMatrix createSVGMatrix() {
57-
return new SVGMatrix(getWindow());
57+
return new SVGMatrix(getWindow().getWebWindow().getTopLevelScope());
5858
}
5959

6060
/**
@@ -63,7 +63,7 @@ public SVGMatrix createSVGMatrix() {
6363
*/
6464
@JsxFunction
6565
public SVGMatrix getScreenCTM() {
66-
return new SVGMatrix(getWindow());
66+
return new SVGMatrix(getWindow().getWebWindow().getTopLevelScope());
6767
}
6868

6969
/**

0 commit comments

Comments
 (0)