Skip to content

Commit 1386486

Browse files
committed
cleanup
1 parent 562ff92 commit 1386486

9 files changed

Lines changed: 18 additions & 29 deletions

File tree

src/main/java/org/htmlunit/html/HtmlElement.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import java.util.Locale;
2727
import java.util.Map;
2828

29-
import org.apache.commons.lang3.StringUtils;
3029
import org.htmlunit.BrowserVersion;
3130
import org.htmlunit.ElementNotFoundException;
3231
import org.htmlunit.Page;
@@ -45,6 +44,7 @@
4544
import org.htmlunit.javascript.host.event.KeyboardEvent;
4645
import org.htmlunit.javascript.host.html.HTMLDocument;
4746
import org.htmlunit.javascript.host.html.HTMLElement;
47+
import org.htmlunit.util.StringUtils;
4848
import org.w3c.dom.Attr;
4949
import org.w3c.dom.CDATASection;
5050
import org.w3c.dom.Comment;
@@ -1313,9 +1313,6 @@ public DisplayStyle getDefaultStyleDisplay() {
13131313
* or an empty string if that attribute isn't defined.
13141314
*/
13151315
protected final String getSrcAttributeNormalized() {
1316-
// at the moment StringUtils.replaceChars returns the org string
1317-
// if nothing to replace was found but the doc implies, that we
1318-
// can't trust on this in the future
13191316
final String attrib = getAttributeDirect(SRC_ATTRIBUTE);
13201317
if (ATTRIBUTE_NOT_DEFINED == attrib) {
13211318
return attrib;

src/main/java/org/htmlunit/html/HtmlTableCell.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
import java.util.Map;
1818

19-
import org.apache.commons.lang3.StringUtils;
2019
import org.htmlunit.SgmlPage;
20+
import org.htmlunit.util.StringUtils;
2121

2222
/**
2323
* An abstract cell that provides the implementation for HtmlTableDataCell and HtmlTableHeaderCell.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ public Object execute(final HtmlPage page, final Scriptable scope, final Script
782782
final HtmlUnitContextAction action = new HtmlUnitContextAction(page) {
783783
@Override
784784
public Object doRun(final Context cx) {
785-
return script.exec(cx, scope);
785+
return script.exec(cx, scope, scope);
786786
}
787787

788788
@Override

src/main/java/org/htmlunit/javascript/host/WindowOrWorkerGlobalScopeMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import java.util.Arrays;
1919
import java.util.Base64;
2020

21-
import org.apache.commons.lang3.StringUtils;
2221
import org.htmlunit.Page;
2322
import org.htmlunit.WebWindow;
2423
import org.htmlunit.corejs.javascript.Context;
@@ -29,6 +28,7 @@
2928
import org.htmlunit.javascript.JavaScriptEngine;
3029
import org.htmlunit.javascript.background.BackgroundJavaScriptFactory;
3130
import org.htmlunit.javascript.background.JavaScriptJob;
31+
import org.htmlunit.util.StringUtils;
3232

3333
/**
3434
* The implementation of {@code WindowOrWorkerGlobalScope}

src/main/java/org/htmlunit/javascript/polyfill/Polyfill.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void apply(final Context context, final Scriptable scriptable) {
7272
}
7373

7474
if (script_ != null) {
75-
script_.exec(context, scriptable);
75+
script_.exec(context, scriptable, scriptable);
7676
}
7777
}
7878
}

src/main/java/org/htmlunit/javascript/preprocessor/HtmxTwoZeroSevenScriptPreProcessor.java

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
*/
1515
package org.htmlunit.javascript.preprocessor;
1616

17-
import org.apache.commons.lang3.StringUtils;
1817
import org.htmlunit.ScriptPreProcessor;
1918
import org.htmlunit.html.HtmlElement;
2019
import org.htmlunit.html.HtmlPage;
@@ -78,41 +77,34 @@ public String preProcess(final HtmlPage htmlPage, final String sourceCode, final
7877
String patchedSourceCode = sourceCode;
7978

8079
if (sourceName.contains("/htmx.js") && !sourceName.contains("/htmx.js#")) {
81-
patchedSourceCode = StringUtils.replace(
82-
sourceCode,
80+
patchedSourceCode = sourceCode.replace(
8381
"result.push(...toArray(rootNode.querySelectorAll(standardSelector)))",
8482
"result.push.apply(result, toArray(rootNode.querySelectorAll(standardSelector)))");
8583

86-
patchedSourceCode = StringUtils.replace(
87-
patchedSourceCode,
84+
patchedSourceCode = patchedSourceCode.replace(
8885
"result.push(...findAttributeTargets(eltToInheritFrom, attrName))",
8986
"result.push.apply(result, findAttributeTargets(eltToInheritFrom, attrName))");
9087

91-
patchedSourceCode = StringUtils.replace(
92-
patchedSourceCode,
88+
patchedSourceCode = patchedSourceCode.replace(
9389
"for (const preservedElt of [...pantry.children]) {",
9490
"for (const preservedElt of Array.from(pantry.children)) {");
9591
}
9692
else if (sourceName.contains("/htmx.min.js") && !sourceName.contains("/htmx.min.js#")) {
9793
// 2.0.4
98-
patchedSourceCode = StringUtils.replace(
99-
sourceCode,
94+
patchedSourceCode = sourceCode.replace(
10095
"i.push(...M(c.querySelectorAll(e)))",
10196
"i.push.apply(i,M(c.querySelectorAll(e)))");
10297

10398
// 2.0.7
104-
patchedSourceCode = StringUtils.replace(
105-
patchedSourceCode,
99+
patchedSourceCode = patchedSourceCode.replace(
106100
"i.push(...F(c.querySelectorAll(e)))",
107101
"i.push.apply(i,F(c.querySelectorAll(e)))");
108102

109-
patchedSourceCode = StringUtils.replace(
110-
patchedSourceCode,
103+
patchedSourceCode = patchedSourceCode.replace(
111104
"r.push(...we(i,n))",
112105
"r.push.apply(r,we(i,n))");
113106

114-
patchedSourceCode = StringUtils.replace(
115-
patchedSourceCode,
107+
patchedSourceCode = patchedSourceCode.replace(
116108
"for(const t of[...e.children]){",
117109
"for(const t of Array.from(e.children)){");
118110
}

src/main/java/org/htmlunit/platform/font/AwtFontUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ public int countLines(final String content, final int pixelWidth, final String f
4848
do {
4949
lineBreakMeasurer.nextLayout(pixelWidth);
5050
lineCount++;
51-
} while (lineBreakMeasurer.getPosition() < line.length() && lineCount < 1000);
51+
}
52+
while (lineBreakMeasurer.getPosition() < line.length() && lineCount < 1000);
5253
}
5354
}
5455
return lineCount;

src/main/java/org/htmlunit/svg/SvgScript.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616

1717
import java.util.Map;
1818

19-
import org.apache.commons.lang3.StringUtils;
2019
import org.htmlunit.SgmlPage;
2120
import org.htmlunit.html.DomAttr;
2221
import org.htmlunit.html.ScriptElement;
2322
import org.htmlunit.html.ScriptElementSupport;
23+
import org.htmlunit.util.StringUtils;
2424

2525
/**
2626
* Wrapper for the SVG element {@code script}.
@@ -90,9 +90,6 @@ public final String getScriptSource() {
9090
* or an empty string if that attribute isn't defined.
9191
*/
9292
protected final String getSrcAttributeNormalized() {
93-
// at the moment StringUtils.replaceChars returns the org string
94-
// if nothing to replace was found but the doc implies, that we
95-
// can't trust on this in the future
9693
final String attrib = getAttributeDirect(SRC_ATTRIBUTE);
9794
if (ATTRIBUTE_NOT_DEFINED == attrib) {
9895
return attrib;

src/main/java/org/htmlunit/util/EncodingSniffer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,9 @@ public static Charset extractEncodingFromContentType(final String s) {
415415
if (i == bytes.length) {
416416
return null;
417417
}
418-
} while (bytes[i] == 0x09 || bytes[i] == 0x0A || bytes[i] == 0x0C || bytes[i] == 0x0D || bytes[i] == 0x20);
418+
}
419+
while (bytes[i] == 0x09 || bytes[i] == 0x0A || bytes[i] == 0x0C || bytes[i] == 0x0D || bytes[i] == 0x20);
420+
419421
if (bytes[i] == '"') {
420422
if (bytes.length <= i + 1) {
421423
return null;

0 commit comments

Comments
 (0)