author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 31432 | jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIUtils.java@15d0fd22179a |
child 59169 | 7dae4286f1cc |
permissions | -rw-r--r-- |
12047 | 1 |
/* |
31432
15d0fd22179a
8008803: [macosx] JVM crash in apple.laf.JRSUIUtils.HitDetection.getHitForPoint
serb
parents:
25859
diff
changeset
|
2 |
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. |
12047 | 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 apple.laf; |
|
27 |
||
31432
15d0fd22179a
8008803: [macosx] JVM crash in apple.laf.JRSUIUtils.HitDetection.getHitForPoint
serb
parents:
25859
diff
changeset
|
28 |
import java.security.AccessController; |
12047 | 29 |
|
31432
15d0fd22179a
8008803: [macosx] JVM crash in apple.laf.JRSUIUtils.HitDetection.getHitForPoint
serb
parents:
25859
diff
changeset
|
30 |
import apple.laf.JRSUIConstants.Hit; |
15d0fd22179a
8008803: [macosx] JVM crash in apple.laf.JRSUIUtils.HitDetection.getHitForPoint
serb
parents:
25859
diff
changeset
|
31 |
import apple.laf.JRSUIConstants.ScrollBarPart; |
15d0fd22179a
8008803: [macosx] JVM crash in apple.laf.JRSUIUtils.HitDetection.getHitForPoint
serb
parents:
25859
diff
changeset
|
32 |
import com.apple.laf.AquaImageFactory.NineSliceMetrics; |
23267
381cfe2f7c85
7155984: Security problems in regression test java/awt/PrintJob/Security/SecurityDialogTest.java
pchelko
parents:
12047
diff
changeset
|
33 |
import sun.security.action.GetPropertyAction; |
381cfe2f7c85
7155984: Security problems in regression test java/awt/PrintJob/Security/SecurityDialogTest.java
pchelko
parents:
12047
diff
changeset
|
34 |
|
31432
15d0fd22179a
8008803: [macosx] JVM crash in apple.laf.JRSUIUtils.HitDetection.getHitForPoint
serb
parents:
25859
diff
changeset
|
35 |
public final class JRSUIUtils { |
12047 | 36 |
|
37 |
static boolean isLeopard = isMacOSXLeopard(); |
|
38 |
static boolean isSnowLeopardOrBelow = isMacOSXSnowLeopardOrBelow(); |
|
39 |
||
40 |
static boolean isMacOSXLeopard() { |
|
41 |
return isCurrentMacOSXVersion(5); |
|
42 |
} |
|
43 |
||
44 |
static boolean isMacOSXSnowLeopardOrBelow() { |
|
45 |
return currentMacOSXVersionMatchesGivenVersionRange(6, true, true, false); |
|
46 |
} |
|
47 |
||
48 |
static boolean isCurrentMacOSXVersion(final int version) { |
|
49 |
return currentMacOSXVersionMatchesGivenVersionRange(version, true, false, false); |
|
50 |
} |
|
51 |
||
31432
15d0fd22179a
8008803: [macosx] JVM crash in apple.laf.JRSUIUtils.HitDetection.getHitForPoint
serb
parents:
25859
diff
changeset
|
52 |
static boolean currentMacOSXVersionMatchesGivenVersionRange( |
15d0fd22179a
8008803: [macosx] JVM crash in apple.laf.JRSUIUtils.HitDetection.getHitForPoint
serb
parents:
25859
diff
changeset
|
53 |
final int version, final boolean inclusive, |
15d0fd22179a
8008803: [macosx] JVM crash in apple.laf.JRSUIUtils.HitDetection.getHitForPoint
serb
parents:
25859
diff
changeset
|
54 |
final boolean matchBelow, final boolean matchAbove) { |
12047 | 55 |
// split the "10.x.y" version number |
23267
381cfe2f7c85
7155984: Security problems in regression test java/awt/PrintJob/Security/SecurityDialogTest.java
pchelko
parents:
12047
diff
changeset
|
56 |
String osVersion = AccessController.doPrivileged(new GetPropertyAction("os.version")); |
12047 | 57 |
String[] fragments = osVersion.split("\\."); |
58 |
||
59 |
// sanity check the "10." part of the version |
|
60 |
if (!fragments[0].equals("10")) return false; |
|
61 |
if (fragments.length < 2) return false; |
|
62 |
||
63 |
// check if os.version matches the given version using the given match method |
|
64 |
try { |
|
65 |
int minorVers = Integer.parseInt(fragments[1]); |
|
66 |
||
67 |
if (inclusive && minorVers == version) return true; |
|
68 |
if (matchBelow && minorVers < version) return true; |
|
69 |
if (matchAbove && minorVers > version) return true; |
|
70 |
||
71 |
} catch (NumberFormatException e) { |
|
72 |
// was not an integer |
|
73 |
} |
|
74 |
return false; |
|
75 |
} |
|
76 |
||
77 |
public static class TabbedPane { |
|
78 |
public static boolean useLegacyTabs() { |
|
79 |
return isLeopard; |
|
80 |
} |
|
81 |
public static boolean shouldUseTabbedPaneContrastUI() { |
|
82 |
return !isSnowLeopardOrBelow; |
|
83 |
} |
|
84 |
} |
|
85 |
||
86 |
public static class InternalFrame { |
|
87 |
public static boolean shouldUseLegacyBorderMetrics() { |
|
88 |
return isSnowLeopardOrBelow; |
|
89 |
} |
|
90 |
} |
|
91 |
||
92 |
public static class Tree { |
|
93 |
public static boolean useLegacyTreeKnobs() { |
|
94 |
return isLeopard; |
|
95 |
} |
|
96 |
} |
|
97 |
||
98 |
public static class ScrollBar { |
|
99 |
private static native boolean shouldUseScrollToClick(); |
|
100 |
||
101 |
public static boolean useScrollToClick() { |
|
102 |
return shouldUseScrollToClick(); |
|
103 |
} |
|
104 |
||
31432
15d0fd22179a
8008803: [macosx] JVM crash in apple.laf.JRSUIUtils.HitDetection.getHitForPoint
serb
parents:
25859
diff
changeset
|
105 |
public static void getPartBounds(final double[] rect, |
15d0fd22179a
8008803: [macosx] JVM crash in apple.laf.JRSUIUtils.HitDetection.getHitForPoint
serb
parents:
25859
diff
changeset
|
106 |
final JRSUIControl control, |
15d0fd22179a
8008803: [macosx] JVM crash in apple.laf.JRSUIUtils.HitDetection.getHitForPoint
serb
parents:
25859
diff
changeset
|
107 |
final int x, final int y, final int w, |
15d0fd22179a
8008803: [macosx] JVM crash in apple.laf.JRSUIUtils.HitDetection.getHitForPoint
serb
parents:
25859
diff
changeset
|
108 |
final int h, |
15d0fd22179a
8008803: [macosx] JVM crash in apple.laf.JRSUIUtils.HitDetection.getHitForPoint
serb
parents:
25859
diff
changeset
|
109 |
final ScrollBarPart part) { |
12047 | 110 |
control.getPartBounds(rect, x, y, w, h, part.ordinal); |
111 |
} |
|
112 |
||
31432
15d0fd22179a
8008803: [macosx] JVM crash in apple.laf.JRSUIUtils.HitDetection.getHitForPoint
serb
parents:
25859
diff
changeset
|
113 |
public static double getNativeOffsetChange(final JRSUIControl control, |
15d0fd22179a
8008803: [macosx] JVM crash in apple.laf.JRSUIUtils.HitDetection.getHitForPoint
serb
parents:
25859
diff
changeset
|
114 |
final int x, final int y, |
15d0fd22179a
8008803: [macosx] JVM crash in apple.laf.JRSUIUtils.HitDetection.getHitForPoint
serb
parents:
25859
diff
changeset
|
115 |
final int w, final int h, |
15d0fd22179a
8008803: [macosx] JVM crash in apple.laf.JRSUIUtils.HitDetection.getHitForPoint
serb
parents:
25859
diff
changeset
|
116 |
final int offset, |
15d0fd22179a
8008803: [macosx] JVM crash in apple.laf.JRSUIUtils.HitDetection.getHitForPoint
serb
parents:
25859
diff
changeset
|
117 |
final int visibleAmount, |
15d0fd22179a
8008803: [macosx] JVM crash in apple.laf.JRSUIUtils.HitDetection.getHitForPoint
serb
parents:
25859
diff
changeset
|
118 |
final int extent) { |
15d0fd22179a
8008803: [macosx] JVM crash in apple.laf.JRSUIUtils.HitDetection.getHitForPoint
serb
parents:
25859
diff
changeset
|
119 |
return control.getScrollBarOffsetChange(x, y, w, h, offset, |
15d0fd22179a
8008803: [macosx] JVM crash in apple.laf.JRSUIUtils.HitDetection.getHitForPoint
serb
parents:
25859
diff
changeset
|
120 |
visibleAmount, extent); |
12047 | 121 |
} |
122 |
} |
|
123 |
||
124 |
public static class Images { |
|
125 |
public static boolean shouldUseLegacySecurityUIPath() { |
|
126 |
return isSnowLeopardOrBelow; |
|
127 |
} |
|
128 |
} |
|
129 |
||
130 |
public static class HitDetection { |
|
31432
15d0fd22179a
8008803: [macosx] JVM crash in apple.laf.JRSUIUtils.HitDetection.getHitForPoint
serb
parents:
25859
diff
changeset
|
131 |
public static Hit getHitForPoint(final JRSUIControl control, |
15d0fd22179a
8008803: [macosx] JVM crash in apple.laf.JRSUIUtils.HitDetection.getHitForPoint
serb
parents:
25859
diff
changeset
|
132 |
final int x, final int y, final int w, |
15d0fd22179a
8008803: [macosx] JVM crash in apple.laf.JRSUIUtils.HitDetection.getHitForPoint
serb
parents:
25859
diff
changeset
|
133 |
final int h, final int hitX, |
15d0fd22179a
8008803: [macosx] JVM crash in apple.laf.JRSUIUtils.HitDetection.getHitForPoint
serb
parents:
25859
diff
changeset
|
134 |
final int hitY) { |
12047 | 135 |
return control.getHitForPoint(x, y, w, h, hitX, hitY); |
136 |
} |
|
137 |
} |
|
138 |
||
139 |
public interface NineSliceMetricsProvider { |
|
140 |
public NineSliceMetrics getNineSliceMetricsForState(JRSUIState state); |
|
141 |
} |
|
142 |
} |