Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.
/ jfx23u Public archive

Commit 840eb5b

Browse files
committedJul 24, 2024
Merge
2 parents eec590a + 6135202 commit 840eb5b

File tree

4 files changed

+187
-3
lines changed

4 files changed

+187
-3
lines changed
 

‎modules/javafx.web/src/main/native/Source/WebCore/layout/formattingContexts/inline/InlineLevelBox.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,15 @@ inline InlineLayoutUnit InlineLevelBox::preferredLineHeight() const
191191
{
192192
if (isPreferredLineHeightFontMetricsBased())
193193
return primarymetricsOfPrimaryFont().floatLineSpacing();
194-
194+
#if !PLATFORM(JAVA)
195195
if (m_style.lineHeight.isPercentOrCalculated())
196196
return minimumValueForLength(m_style.lineHeight, fontSize());
197197
return m_style.lineHeight.value();
198+
#else // required to round a floating-point number down to the nearest integer value otherwise it will introduce 1px extra height
199+
if (m_style.lineHeight.isPercentOrCalculated())
200+
return floorf(minimumValueForLength(m_style.lineHeight, fontSize()));
201+
return floorf(m_style.lineHeight.value());
202+
#endif
198203
}
199204

200205
inline bool InlineLevelBox::hasLineBoxRelativeAlignment() const

‎modules/javafx.web/src/test/java/test/javafx/scene/web/MiscellaneousTest.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,15 @@ public void call(long createdTime, long interval, int index) {
217217
}
218218
}
219219

220-
@Ignore("JDK-8335548")
221-
@Test public void testCookieEnabled() {
220+
221+
@Test public void testCookieEnabled() throws Exception {
222222
final WebEngine webEngine = createWebEngine();
223+
String location = new File("src/test/resources/test/html/cookie.html")
224+
.toURI().toASCIIString().replaceAll("^file:/", "file:///");
225+
Platform.runLater(() -> {
226+
webEngine.load(location);
227+
});
228+
Thread.sleep(1000);
223229
submit(() -> {
224230
final JSObject window = (JSObject) webEngine.executeScript("window");
225231
assertNotNull(window);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<body>
4+
test cookie
5+
</body>
6+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
/*
2+
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
26+
package test.javafx.scene.web;
27+
28+
import javafx.application.Application;
29+
import javafx.application.Platform;
30+
import javafx.concurrent.Worker;
31+
import javafx.scene.Scene;
32+
import javafx.scene.web.WebView;
33+
import javafx.stage.Stage;
34+
import org.junit.jupiter.api.AfterAll;
35+
import org.junit.jupiter.api.BeforeAll;
36+
import org.junit.jupiter.api.BeforeEach;
37+
import org.junit.jupiter.api.Test;
38+
import test.util.Util;
39+
40+
import java.util.concurrent.CountDownLatch;
41+
42+
import static org.junit.jupiter.api.Assertions.assertEquals;
43+
import static org.junit.jupiter.api.Assertions.assertNotNull;
44+
import static org.junit.jupiter.api.Assertions.assertTrue;
45+
46+
public class CSSRoundingTest {
47+
48+
private static final CountDownLatch launchLatch = new CountDownLatch(1);
49+
50+
// Maintain one application instance
51+
static CSSRoundingTestApp cssRoundingTestApp;
52+
public static Stage primaryStage;
53+
public static WebView webView;
54+
55+
public static class CSSRoundingTestApp extends Application {
56+
57+
@Override
58+
public void init() {
59+
CSSRoundingTest.cssRoundingTestApp = this;
60+
}
61+
62+
@Override
63+
public void start(Stage primaryStage) throws Exception {
64+
CSSRoundingTest.primaryStage = primaryStage;
65+
webView = new WebView();
66+
Scene scene = new Scene(webView, 150, 100);
67+
primaryStage.setScene(scene);
68+
primaryStage.show();
69+
launchLatch.countDown();
70+
}
71+
}
72+
73+
@BeforeAll
74+
public static void setupOnce() {
75+
Util.launch(launchLatch, CSSRoundingTestApp.class);
76+
}
77+
78+
@AfterAll
79+
public static void tearDownOnce() {
80+
Util.shutdown();
81+
}
82+
83+
@Test
84+
public void testCSSroundingForLinearLayout() {
85+
86+
final CountDownLatch webViewStateLatch = new CountDownLatch(1);
87+
88+
Util.runAndWait(() -> {
89+
assertNotNull(webView);
90+
91+
webView.getEngine().getLoadWorker().stateProperty().addListener((observable, oldValue, newValue) -> {
92+
if (newValue == Worker.State.SUCCEEDED) {
93+
webView.requestFocus();
94+
}
95+
});
96+
97+
webView.focusedProperty().addListener((observable, oldValue, newValue) -> {
98+
if (newValue) {
99+
webViewStateLatch.countDown();
100+
}
101+
});
102+
103+
String content = """
104+
<html>
105+
<head>
106+
<style type="text/css">
107+
body, div {
108+
margin: 0;
109+
padding: 0;
110+
border: 0;
111+
}
112+
#top, #bottom {
113+
line-height: 1.5;
114+
font-size: 70%;
115+
background:green;
116+
color:white;
117+
width:100%;
118+
}
119+
#top {
120+
padding:.6em 0 .7em;
121+
}
122+
#bottom {
123+
position:absolute;
124+
top:2.8em;
125+
}
126+
</style>
127+
</head>
128+
<body>
129+
<div id="top">no gap below</div>
130+
<div id="bottom">no gap above</div>
131+
<div id="description"></div>
132+
<div id="console"></div>
133+
<script>
134+
description("This test checks that floating point rounding doesn't cause misalignment. There should be no gap between the divs.");
135+
var divtop = document.getElementById("top").getBoundingClientRect();
136+
var divbottom = document.getElementById("bottom").getBoundingClientRect();
137+
console.log("divtop.bottom: " + divtop.bottom);
138+
console.log("divbottom.top: " + divbottom.top);
139+
window.testResults = { topBottom: Math.round(divtop.bottom), bottomTop: Math.round(divbottom.top) };
140+
</script>
141+
</body>
142+
</html>
143+
""";
144+
webView.getEngine().loadContent(content);
145+
});
146+
147+
assertTrue(Util.await(webViewStateLatch), "Timeout when waiting for focus change");
148+
// Introduce sleep to ensure web contents are loaded
149+
Util.sleep(1000);
150+
151+
Util.runAndWait(() -> {
152+
webView.getEngine().executeScript("""
153+
var divtop = document.getElementById("top").getBoundingClientRect();
154+
var divbottom = document.getElementById("bottom").getBoundingClientRect();
155+
var topBottom = Math.round(divtop.bottom);
156+
var bottomTop = Math.round(divbottom.top);
157+
window.testResults = { topBottom: topBottom, bottomTop: bottomTop };
158+
""");
159+
160+
int topBottom = ((Number) webView.getEngine().executeScript("window.testResults.topBottom")).intValue();
161+
int bottomTop = ((Number) webView.getEngine().executeScript("window.testResults.bottomTop")).intValue();
162+
163+
assertEquals(31, topBottom);
164+
assertEquals(31, bottomTop);
165+
});
166+
}
167+
}

0 commit comments

Comments
 (0)
This repository has been archived.