Compare commits

..

1 Commits
1407 ... 1379

Author SHA1 Message Date
Vitaly Provodin
5b6652871d updated JTreg exclude list 2021-03-17 12:05:08 +07:00
265 changed files with 2306 additions and 1375 deletions

View File

@@ -1,7 +1,9 @@
<component name="CopyrightManager">
<copyright>
<option name="allowReplaceRegexp" value="JetBrains" />
<option name="notice" value="Copyright 2000-&amp;#36;today.year JetBrains s.r.o.&#10;DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.&#10; &#10;This code is free software; you can redistribute it and/or modify it&#10;under the terms of the GNU General Public License version 2 only, as&#10;published by the Free Software Foundation.&#10;&#10;This code is distributed in the hope that it will be useful, but WITHOUT&#10;ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or&#10;FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License&#10;version 2 for more details (a copy is included in the LICENSE file that&#10;accompanied this code).&#10;&#10;You should have received a copy of the GNU General Public License version&#10;2 along with this work; if not, write to the Free Software Foundation,&#10;Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.&#10;&#10;Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA&#10;or visit www.oracle.com if you need additional information or have any&#10;questions." />
<option name="notice" value="Copyright 2000-&amp;#36;today.year JetBrains s.r.o.&#10;&#10;Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);&#10;you may not use this file except in compliance with the License.&#10;You may obtain a copy of the License at&#10;&#10;http://www.apache.org/licenses/LICENSE-2.0&#10;&#10;Unless required by applicable law or agreed to in writing, software&#10;distributed under the License is distributed on an &quot;AS IS&quot; BASIS,&#10;WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&#10;See the License for the specific language governing permissions and&#10;limitations under the License." />
<option name="keyword" value="Copyright" />
<option name="allowReplaceKeyword" value="JetBrains" />
<option name="myName" value="JetBrains" />
<option name="myLocal" value="true" />
</copyright>
</component>

View File

@@ -1,5 +1,12 @@
[![official JetBrains project](http://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
# Downloads
|Windows-x64 |macOS |Linux-x64 |
|-------------|-------------|-------------|
|[ ![Download](https://api.bintray.com/packages/jetbrains/intellij-jdk/openjdk11-windows-x64/images/download.svg) ](https://bintray.com/jetbrains/intellij-jdk/openjdk11-windows-x64/_latestVersion)|[ ![Download](https://api.bintray.com/packages/jetbrains/intellij-jdk/openjdk11-osx-x64/images/download.svg) ](https://bintray.com/jetbrains/intellij-jdk/openjdk11-osx-x64/_latestVersion)|[ ![Download](https://api.bintray.com/packages/jetbrains/intellij-jdk/openjdk11-linux-x64/images/download.svg) ](https://bintray.com/jetbrains/intellij-jdk/openjdk11-linux-x64/_latestVersion)|
# How JetBrains Runtime is organised
## Workspaces

View File

@@ -4,9 +4,9 @@ RUN yum -y install centos-release-scl
RUN yum -y install devtoolset-8
RUN yum -y install zip bzip2 unzip tar wget make autoconf automake libtool alsa-devel cups-devel xorg-x11-devel libjpeg62-devel giflib-devel freetype-devel file which libXtst-devel libXt-devel libXrender-devel alsa-lib-devel fontconfig-devel libXrandr-devel libXi-devel git
# Install Java 11
RUN wget https://cdn.azul.com/zulu/bin/zulu11.45.27-ca-jdk11.0.10-linux_x64.tar.gz \
RUN wget https://bintray.com/jetbrains/intellij-jbr/download_file?file_path=jbrsdk-11_0_3-linux-x64-b360.2.tar.gz \
-O - | tar xz -C /
ENV JAVA_HOME /zulu11.45.27-ca-jdk11.0.10-linux_x64
ENV JAVA_HOME /jbrsdk
ENV PATH $JAVA_HOME/bin:/opt/rh/devtoolset-8/root/usr/bin:$PATH
RUN git config --global user.email "teamcity@buildserver.intellij.net"
RUN git config --global user.name "builduser"

View File

@@ -572,43 +572,105 @@ endif
###########################################################################
ifeq ($(USE_EXTERNAL_HARFBUZZ), true)
LIBFONTMANAGER_EXTRA_SRC =
BUILD_LIBFONTMANAGER_FONTLIB += $(LIBHARFBUZZ_LIBS)
LIBHARFBUZZ_LIBS := $(HARFBUZZ_LIBS)
else
LIBFONTMANAGER_EXTRA_SRC = libharfbuzz
HARFBUZZ_CFLAGS := -DHAVE_OT -DHAVE_FALLBACK -DHAVE_UCDN -DHAVE_ROUND
ifneq ($(OPENJDK_TARGET_OS), windows)
HARFBUZZ_CFLAGS += -DGETPAGESIZE -DHAVE_MPROTECT -DHAVE_PTHREAD \
-DHAVE_SYSCONF -DHAVE_SYS_MMAN_H -DHAVE_UNISTD_H \
-DHB_NO_PRAGMA_GCC_DIAGNOSTIC
endif
ifneq (, $(findstring $(OPENJDK_TARGET_OS), linux macosx))
HARFBUZZ_CFLAGS += -DHAVE_INTEL_ATOMIC_PRIMITIVES
endif
HARFBUZZ_CFLAGS := -DHAVE_OT -DHAVE_FALLBACK -DHAVE_UCDN -DHAVE_ROUND
# This is better than adding EXPORT_ALL_SYMBOLS
ifneq ($(filter $(TOOLCHAIN_TYPE), gcc clang solstudio), )
HARFBUZZ_CFLAGS += -DHB_EXTERN=__attribute__\(\(visibility\(\"default\"\)\)\)
else ifeq ($(TOOLCHAIN_TYPE), microsoft)
HARFBUZZ_CFLAGS += -DHB_EXTERN=__declspec\(dllexport\)
endif
# hb-ft.cc is not presently needed, and requires freetype 2.4.2 or later.
LIBFONTMANAGER_EXCLUDE_FILES += libharfbuzz/hb-ft.cc \
libharfbuzz/hb-coretext.cc
LIBHARFBUZZ_LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN)
ifeq ($(TOOLCHAIN_TYPE), gcc)
ifeq ($(CC_VERSION_NUMBER), 4.4.7)
LIBHARFBUZZ_LDFLAGS := $(subst -Xlinker -z -Xlinker defs,, \
$(subst -Wl$(COMMA)-z$(COMMA)defs,,$(LDFLAGS_JDKLIB))) \
$(call SET_SHARED_LIBRARY_ORIGIN)
endif
endif
HARFBUZZ_EXTRA_HEADER_DIRS := \
libharfbuzz/hb-ucdn
ifneq ($(OPENJDK_TARGET_OS), windows)
HARFBUZZ_CFLAGS += -DGETPAGESIZE -DHAVE_MPROTECT -DHAVE_PTHREAD \
-DHAVE_SYSCONF -DHAVE_SYS_MMAN_H -DHAVE_UNISTD_H \
-DHB_NO_PRAGMA_GCC_DIAGNOSTIC
endif
ifneq (, $(findstring $(OPENJDK_TARGET_OS), linux macosx))
HARFBUZZ_CFLAGS += -DHAVE_INTEL_ATOMIC_PRIMITIVES
endif
ifeq ($(OPENJDK_TARGET_OS), solaris)
HARFBUZZ_CFLAGS += -DHAVE_SOLARIS_ATOMIC_OPS
endif
HARFBUZZ_DISABLED_WARNINGS_gcc := type-limits missing-field-initializers strict-aliasing
HARFBUZZ_DISABLED_WARNINGS_CXX_gcc := reorder delete-non-virtual-dtor strict-overflow \
maybe-uninitialized class-memaccess
HARFBUZZ_DISABLED_WARNINGS_clang := unused-value incompatible-pointer-types \
tautological-constant-out-of-range-compare int-to-pointer-cast \
undef missing-field-initializers range-loop-analysis
HARFBUZZ_DISABLED_WARNINGS_microsoft := 4267 4244 4090 4146 4334 4819 4101 4068 4805 4138
LIBHARFBUZZ_EXCLUDE_FILES += harfbuzz/hb-coretext.cc
LIBFONTMANAGER_CFLAGS += $(HARFBUZZ_CFLAGS)
# hb-ft.cc is not presently needed, and requires freetype 2.4.2 or later.
LIBHARFBUZZ_EXCLUDE_FILES += harfbuzz/hb-ft.cc
LIBHARFBUZZ_CFLAGS += $(HARFBUZZ_CFLAGS)
# For use by libfontmanager:
ifeq ($(OPENJDK_TARGET_OS), windows)
LIBHARFBUZZ_LIBS := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjharfbuzz/jharfbuzz.lib
else ifeq ($(OPENJDK_TARGET_OS), macosx)
LIBHARFBUZZ_LIBS := -ljharfbuzz
endif
LIBHARFBUZZ_EXTRA_HEADER_DIRS := \
libjharfbuzz/hb-ucdn \
#
LIBHARFBUZZ_OPTIMIZATION := HIGH
LIBHARFBUZZ_CFLAGS += $(X_CFLAGS) -DLE_STANDALONE -DHEADLESS
$(eval $(call SetupJdkLibrary, BUILD_LIBHARFBUZZ, \
NAME := jharfbuzz, \
EXCLUDE_FILES := $(LIBHARFBUZZ_EXCLUDE_FILES), \
TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
CFLAGS := $(CFLAGS_JDKLIB) $(LIBHARFBUZZ_CFLAGS), \
CXXFLAGS := $(CXXFLAGS_JDKLIB) $(LIBHARFBUZZ_CFLAGS), \
OPTIMIZATION := $(LIBHARFBUZZ_OPTIMIZATION), \
CFLAGS_windows = -DCC_NOEX, \
EXTRA_HEADER_DIRS := $(LIBHARFBUZZ_EXTRA_HEADER_DIRS), \
WARNINGS_AS_ERRORS_xlc := false, \
DISABLED_WARNINGS_gcc := type-limits missing-field-initializers strict-aliasing, \
DISABLED_WARNINGS_CXX_gcc := reorder delete-non-virtual-dtor strict-overflow \
maybe-uninitialized class-memaccess, \
DISABLED_WARNINGS_clang := unused-value incompatible-pointer-types \
tautological-constant-out-of-range-compare int-to-pointer-cast \
undef missing-field-initializers, \
DISABLED_WARNINGS_C_solstudio := \
E_INTEGER_OVERFLOW_DETECTED \
E_ARG_INCOMPATIBLE_WITH_ARG_L \
E_ENUM_VAL_OVERFLOWS_INT_MAX, \
DISABLED_WARNINGS_CXX_solstudio := \
truncwarn wvarhidenmem wvarhidemem wbadlkginit identexpected \
hidevf w_novirtualdescr arrowrtn2 unknownpragma, \
DISABLED_WARNINGS_microsoft := 4267 4244 4090 4146 4334 4819 4101 4068 4805 4138, \
LDFLAGS := $(LIBHARFBUZZ_LDFLAGS), \
LDFLAGS_unix := -L$(INSTALL_LIBRARIES_HERE), \
LDFLAGS_aix := -Wl$(COMMA)-berok, \
LIBS := $(BUILD_LIBHARFBUZZ), \
LIBS_unix := $(LIBM) $(LIBCXX), \
LIBS_macosx := -framework CoreText -framework CoreFoundation -framework CoreGraphics, \
LIBS_windows := user32.lib, \
))
ifeq ($(FREETYPE_TO_USE), bundled)
$(BUILD_LIBHARFBUZZ): $(BUILD_LIBFREETYPE)
endif
TARGETS += $(BUILD_LIBHARFBUZZ)
endif
###########################################################################
LIBFONTMANAGER_EXTRA_HEADER_DIRS := \
libharfbuzz \
libjharfbuzz \
common/awt \
common/font \
libawt/java2d \
@@ -616,10 +678,10 @@ LIBFONTMANAGER_EXTRA_HEADER_DIRS := \
libawt/java2d/loops \
#
LIBFONTMANAGER_CFLAGS += $(LIBFREETYPE_CFLAGS)
BUILD_LIBFONTMANAGER_FONTLIB += $(LIBFREETYPE_LIBS)
LIBFONTMANAGER_CFLAGS += $(LIBFREETYPE_CFLAGS) $(HARFBUZZ_FLAGS)
BUILD_LIBFONTMANAGER_FONTLIB += $(LIBHARFBUZZ_LIBS) $(LIBFREETYPE_LIBS)
LIBFONTMANAGER_OPTIMIZATION := HIGHEST
LIBFONTMANAGER_OPTIMIZATION := HIGH
ifeq ($(OPENJDK_TARGET_OS), windows)
LIBFONTMANAGER_EXCLUDE_FILES += X11FontScaler.c \
@@ -658,13 +720,18 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBFONTMANAGER, \
CXXFLAGS := $(CXXFLAGS_JDKLIB) $(LIBFONTMANAGER_CFLAGS), \
OPTIMIZATION := $(LIBFONTMANAGER_OPTIMIZATION), \
CFLAGS_windows = -DCC_NOEX, \
EXTRA_HEADER_DIRS := $(LIBFONTMANAGER_EXTRA_HEADER_DIRS) $(HARFBUZZ_EXTRA_HEADER_DIRS), \
EXTRA_SRC := $(LIBFONTMANAGER_EXTRA_SRC), \
EXTRA_HEADER_DIRS := $(LIBFONTMANAGER_EXTRA_HEADER_DIRS), \
WARNINGS_AS_ERRORS_xlc := false, \
DISABLED_WARNINGS_gcc := $(HARFBUZZ_DISABLED_WARNINGS_gcc), \
DISABLED_WARNINGS_CXX_gcc := $(HARFBUZZ_DISABLED_WARNINGS_CXX_gcc), \
DISABLED_WARNINGS_clang := $(HARFBUZZ_DISABLED_WARNINGS_clang), \
DISABLED_WARNINGS_microsoft := $(HARFBUZZ_DISABLED_WARNINGS_microsoft), \
DISABLED_WARNINGS_gcc := sign-compare unused-function int-to-pointer-cast, \
DISABLED_WARNINGS_clang := sign-compare, \
DISABLED_WARNINGS_C_solstudio := \
E_INTEGER_OVERFLOW_DETECTED \
E_ARG_INCOMPATIBLE_WITH_ARG_L \
E_ENUM_VAL_OVERFLOWS_INT_MAX, \
DISABLED_WARNINGS_CXX_solstudio := \
truncwarn wvarhidenmem wvarhidemem wbadlkginit identexpected \
hidevf w_novirtualdescr arrowrtn2 unknownpragma, \
DISABLED_WARNINGS_microsoft := 4018 4146 4244 4996 4996 4146 4334 4819 4101 4068 4805 4138, \
LDFLAGS := $(subst -Xlinker -z -Xlinker defs,, \
$(subst -Wl$(COMMA)-z$(COMMA)defs,,$(LDFLAGS_JDKLIB))) $(LDFLAGS_CXX_JDK) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
@@ -672,13 +739,17 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBFONTMANAGER, \
LDFLAGS_aix := -Wl$(COMMA)-berok, \
LIBS := $(BUILD_LIBFONTMANAGER_FONTLIB), \
LIBS_unix := -lawt -ljava -ljvm $(LIBM) $(LIBCXX), \
LIBS_macosx := -lawt_lwawt -framework CoreText -framework CoreFoundation -framework CoreGraphics, \
LIBS_macosx := -lawt_lwawt, \
LIBS_windows := $(WIN_JAVA_LIB) advapi32.lib user32.lib gdi32.lib \
$(WIN_AWT_LIB), \
))
$(BUILD_LIBFONTMANAGER): $(BUILD_LIBAWT)
ifeq ($(USE_EXTERNAL_HARFBUZZ), false)
$(BUILD_LIBFONTMANAGER): $(BUILD_LIBHARFBUZZ)
endif
ifeq ($(OPENJDK_TARGET_OS), macosx)
$(BUILD_LIBFONTMANAGER): $(call FindLib, $(MODULE), awt_lwawt)
endif

View File

@@ -0,0 +1,51 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.apple.eawt;
import com.apple.eawt.AppEvent.AppForegroundEvent;
/**
* Implementors are notified when the app becomes the foreground app and when it resigns being the foreground app.
* This notification is useful for hiding and showing transient UI like palette windows which should be hidden when the app is in the background.
*
* @see Application#addAppEventListener(AppEventListener)
*
* @since Java for Mac OS X 10.6 Update 3
* @since Java for Mac OS X 10.5 Update 8
*/
public interface AppForegroundListener extends AppEventListener {
/**
* Called when the app becomes the foreground app.
* @param e the app became foreground notification.
*/
public void appRaisedToForeground(final AppForegroundEvent e);
/**
* Called when the app resigns to the background and another app becomes the foreground app.
* @param e the app resigned foreground notification.
*/
public void appMovedToBackground(final AppForegroundEvent e);
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.apple.eawt;
import com.apple.eawt.AppEvent.AppHiddenEvent;
/**
* Implementors are notified when the app is hidden or shown by the user.
* This notification is helpful for discontinuing a costly animation if it's not visible to the user.
*
* @see Application#addAppEventListener(AppEventListener)
*
* @since Java for Mac OS X 10.6 Update 3
* @since Java for Mac OS X 10.5 Update 8
*/
public interface AppHiddenListener extends AppEventListener {
/**
* Called the app is hidden.
* @param e
*/
public void appHidden(final AppHiddenEvent e);
/**
* Called when the hidden app is shown again (but not necessarily brought to the foreground).
* @param e
*/
public void appUnhidden(final AppHiddenEvent e);
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.apple.eawt;
import com.apple.eawt.AppEvent.AppReOpenedEvent;
/**
* Implementors receive notification when the app has been asked to open again.
* Re-open events occur when the user clicks on the running app's Dock icon.
* Re-open events also occur when the app is double-clicked in the Finder and the app is already running.
*
* This notification is useful for showing a new document when your app has no open windows.
*
* @see Application#addAppEventListener(AppEventListener)
*
* @since Java for Mac OS X 10.6 Update 3
* @since Java for Mac OS X 10.5 Update 8
*/
public interface AppReOpenedListener extends AppEventListener {
/**
* Called when the app has been re-opened (it's Dock icon was clicked on, or was double-clicked in the Finder)
* @param e the request to re-open the app
*/
public void appReOpened(final AppReOpenedEvent e);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,38 +25,20 @@
package com.apple.eawt;
import java.awt.Image;
import java.awt.PopupMenu;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.desktop.AboutHandler;
import java.awt.desktop.AppForegroundListener;
import java.awt.desktop.AppHiddenListener;
import java.awt.desktop.AppReopenedListener;
import java.awt.desktop.OpenFilesEvent;
import java.awt.desktop.OpenFilesHandler;
import java.awt.desktop.OpenURIEvent;
import java.awt.desktop.OpenURIHandler;
import java.awt.desktop.PreferencesHandler;
import java.awt.desktop.PrintFilesEvent;
import java.awt.desktop.PrintFilesHandler;
import java.awt.desktop.QuitHandler;
import java.awt.desktop.QuitResponse;
import java.awt.desktop.QuitStrategy;
import java.awt.desktop.ScreenSleepListener;
import java.awt.desktop.SystemEventListener;
import java.awt.desktop.SystemSleepListener;
import java.awt.desktop.UserSessionListener;
import java.awt.*;
import java.awt.peer.*;
import java.beans.Beans;
import java.util.function.Consumer;
import javax.swing.JMenuBar;
import sun.lwawt.*;
import sun.lwawt.macosx.*;
import sun.awt.AWTAccessor;
import sun.lwawt.LWWindowPeer;
import sun.lwawt.macosx.CPlatformWindow;
import sun.util.logging.PlatformLogger;
/**
* The {@code Application} class allows you to integrate your Java application with the native Mac OS X environment.
* The <code>Application</code> class allows you to integrate your Java application with the native Mac OS X environment.
* You can provide your Mac OS X users a greatly enhanced experience by implementing a few basic handlers for standard system events.
*
* For example:
@@ -74,13 +56,22 @@ import sun.lwawt.macosx.CPlatformWindow;
* @since 1.4
*/
public class Application {
private static final PlatformLogger focusRequestLog = PlatformLogger.getLogger("jb.focus.requests");
private static native void nativeInitializeApplicationDelegate();
static Application sApplication = null;
static {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("awt");
return null;
}
});
checkSecurity();
Toolkit.getDefaultToolkit(); // Start AppKit
if (!Beans.isDesignTime()) {
nativeInitializeApplicationDelegate();
}
@@ -121,11 +112,11 @@ public class Application {
}
/**
* Adds sub-types of {@link SystemEventListener} to listen for notifications from the native Mac OS X system.
* Adds sub-types of {@link AppEventListener} to listen for notifications from the native Mac OS X system.
*
* @see AppForegroundListener
* @see AppHiddenListener
* @see AppReopenedListener
* @see AppReOpenedListener
* @see ScreenSleepListener
* @see SystemSleepListener
* @see UserSessionListener
@@ -134,16 +125,16 @@ public class Application {
* @since Java for Mac OS X 10.6 Update 3
* @since Java for Mac OS X 10.5 Update 8
*/
public void addAppEventListener(final SystemEventListener listener) {
public void addAppEventListener(final AppEventListener listener) {
eventHandler.addListener(listener);
}
/**
* Removes sub-types of {@link SystemEventListener} from listening for notifications from the native Mac OS X system.
* Removes sub-types of {@link AppEventListener} from listening for notifications from the native Mac OS X system.
*
* @see AppForegroundListener
* @see AppHiddenListener
* @see AppReopenedListener
* @see AppReOpenedListener
* @see ScreenSleepListener
* @see SystemSleepListener
* @see UserSessionListener
@@ -152,16 +143,16 @@ public class Application {
* @since Java for Mac OS X 10.6 Update 3
* @since Java for Mac OS X 10.5 Update 8
*/
public void removeAppEventListener(final SystemEventListener listener) {
public void removeAppEventListener(final AppEventListener listener) {
eventHandler.removeListener(listener);
}
/**
* Installs a handler to show a custom About window for your application.
*
* Setting the {@link AboutHandler} to {@code null} reverts it to the default Cocoa About window.
* Setting the {@link AboutHandler} to <code>null</code> reverts it to the default Cocoa About window.
*
* @param aboutHandler the handler to respond to the {@link AboutHandler#handleAbout} message
* @param aboutHandler the handler to respond to the {@link AboutHandler#handleAbout()} message
* @since Java for Mac OS X 10.6 Update 3
* @since Java for Mac OS X 10.5 Update 8
*/
@@ -172,7 +163,7 @@ public class Application {
/**
* Installs a handler to create the Preferences menu item in your application's app menu.
*
* Setting the {@link PreferencesHandler} to {@code null} will remove the Preferences item from the app menu.
* Setting the {@link PreferencesHandler} to <code>null</code> will remove the Preferences item from the app menu.
*
* @param preferencesHandler
* @since Java for Mac OS X 10.6 Update 3
@@ -184,8 +175,8 @@ public class Application {
/**
* Installs the handler which is notified when the application is asked to open a list of files.
* The {@link OpenFilesHandler#openFiles(OpenFilesEvent)} notifications are only sent if the Java app is a bundled application, with a {@code CFBundleDocumentTypes} array present in it's Info.plist.
* See the <a href="http://developer.apple.com/mac/library/documentation/General/Reference/InfoPlistKeyReference">Info.plist Key Reference</a> for more information about adding a {@code CFBundleDocumentTypes} key to your app's Info.plist.
* The {@link OpenFilesHandler#openFiles(AppEvent.OpenFilesEvent)} notifications are only sent if the Java app is a bundled application, with a <code>CFBundleDocumentTypes</code> array present in it's Info.plist.
* See the <a href="http://developer.apple.com/mac/library/documentation/General/Reference/InfoPlistKeyReference">Info.plist Key Reference</a> for more information about adding a <code>CFBundleDocumentTypes</code> key to your app's Info.plist.
*
* @param openFileHandler
* @since Java for Mac OS X 10.6 Update 3
@@ -197,8 +188,8 @@ public class Application {
/**
* Installs the handler which is notified when the application is asked to print a list of files.
* The {@link PrintFilesHandler#printFiles(PrintFilesEvent)} notifications are only sent if the Java app is a bundled application, with a {@code CFBundleDocumentTypes} array present in it's Info.plist.
* See the <a href="http://developer.apple.com/mac/library/documentation/General/Reference/InfoPlistKeyReference">Info.plist Key Reference</a> for more information about adding a {@code CFBundleDocumentTypes} key to your app's Info.plist.
* The {@link PrintFilesHandler#printFiles(AppEvent.PrintFilesEvent)} notifications are only sent if the Java app is a bundled application, with a <code>CFBundleDocumentTypes</code> array present in it's Info.plist.
* See the <a href="http://developer.apple.com/mac/library/documentation/General/Reference/InfoPlistKeyReference">Info.plist Key Reference</a> for more information about adding a <code>CFBundleDocumentTypes</code> key to your app's Info.plist.
*
* @param printFileHandler
* @since Java for Mac OS X 10.6 Update 3
@@ -210,10 +201,10 @@ public class Application {
/**
* Installs the handler which is notified when the application is asked to open a URL.
* The {@link OpenURIHandler#openURI(OpenURIEvent)} notifications are only sent if the Java app is a bundled application, with a {@code CFBundleURLTypes} array present in it's Info.plist.
* See the <a href="http://developer.apple.com/mac/library/documentation/General/Reference/InfoPlistKeyReference">Info.plist Key Reference</a> for more information about adding a {@code CFBundleURLTypes} key to your app's Info.plist.
* The {@link OpenURIHandler#openURI(AppEvent.OpenURIEvent)} notifications are only sent if the Java app is a bundled application, with a <code>CFBundleURLTypes</code> array present in it's Info.plist.
* See the <a href="http://developer.apple.com/mac/library/documentation/General/Reference/InfoPlistKeyReference">Info.plist Key Reference</a> for more information about adding a <code>CFBundleURLTypes</code> key to your app's Info.plist.
*
* Setting the handler to {@code null} causes all {@link OpenURIHandler#openURI(OpenURIEvent)} requests to be enqueued until another handler is set.
* Setting the handler to <code>null</code> causes all {@link OpenURIHandler#openURI(AppEvent.OpenURIEvent)} requests to be enqueued until another handler is set.
*
* @param openURIHandler
* @since Java for Mac OS X 10.6 Update 3
@@ -226,7 +217,7 @@ public class Application {
/**
* Installs the handler which determines if the application should quit.
* The handler is passed a one-shot {@link QuitResponse} which can cancel or proceed with the quit.
* Setting the handler to {@code null} causes all quit requests to directly perform the default {@link QuitStrategy}.
* Setting the handler to <code>null</code> causes all quit requests to directly perform the default {@link QuitStrategy}.
*
* @param quitHandler the handler that is called when the application is asked to quit
* @since Java for Mac OS X 10.6 Update 3
@@ -296,6 +287,9 @@ public class Application {
* @since Java for Mac OS X 10.5 Update 6 - 1.6, 1.5
*/
public void requestForeground(final boolean allWindows) {
if (focusRequestLog.isLoggable(PlatformLogger.Level.FINE)) {
focusRequestLog.fine("requestForeground(" + (allWindows ? "allWindows" : "") + ")", new Throwable());
}
_AppMiscHandlers.requestActivation(allWindows);
}
@@ -384,16 +378,6 @@ public class Application {
iconHandler.setDockIconBadge(badge);
}
/**
* Displays a progress bar to this application's Dock icon.
* Acceptable values are from 0 to 100, any other disables progress indication.
*
* @param value progress value
*/
public void setDockIconProgress(final int value) {
iconHandler.setDockIconProgress(value);
}
/**
* Sets the default menu bar to use when there are no active frames.
* Only used when the system property "apple.laf.useScreenMenuBar" is "true", and
@@ -416,12 +400,189 @@ public class Application {
*
* @since Java for Mac OS X 10.7 Update 1
*/
@SuppressWarnings("deprecation")
public void requestToggleFullScreen(final Window window) {
invokeOnPlatformWindow(window, pw -> pw.toggleFullScreen());
}
public void requestEnterFullScreen(final Window window) {
invokeOnPlatformWindow(window, pw -> pw.enterFullScreen());
}
public void requestLeaveFullScreen(final Window window) {
invokeOnPlatformWindow(window, pw -> pw.leaveFullScreen());
}
private void invokeOnPlatformWindow (final Window window, Consumer<CPlatformWindow> consumer) {
final Object peer = AWTAccessor.getComponentAccessor().getPeer(window);
if (!(peer instanceof LWWindowPeer)) return;
Object platformWindow = ((LWWindowPeer) peer).getPlatformWindow();
if (!(platformWindow instanceof CPlatformWindow)) return;
((CPlatformWindow)platformWindow).toggleFullScreen();
consumer.accept((CPlatformWindow)platformWindow);
}
// -- DEPRECATED API --
/**
* Adds the specified ApplicationListener as a receiver of callbacks from this class.
* This method throws a RuntimeException if the newer About, Preferences, Quit, etc handlers are installed.
*
* @param listener an implementation of ApplicationListener that handles ApplicationEvents
*
* @deprecated register individual handlers for each task (About, Preferences, Open, Print, Quit, etc)
* @since 1.4
*/
@SuppressWarnings("deprecation")
@Deprecated
public void addApplicationListener(final ApplicationListener listener) {
eventHandler.legacyHandler.addLegacyAppListener(listener);
}
/**
* Removes the specified ApplicationListener from being a receiver of callbacks from this class.
* This method throws a RuntimeException if the newer About, Preferences, Quit, etc handlers are installed.
*
* @param listener an implementation of ApplicationListener that had previously been registered to handle ApplicationEvents
*
* @deprecated unregister individual handlers for each task (About, Preferences, Open, Print, Quit, etc)
* @since 1.4
*/
@SuppressWarnings("deprecation")
@Deprecated
public void removeApplicationListener(final ApplicationListener listener) {
eventHandler.legacyHandler.removeLegacyAppListener(listener);
}
/**
* Enables the Preferences item in the application menu. The ApplicationListener receives a callback for
* selection of the Preferences item in the application menu only if this is set to <code>true</code>.
*
* If a Preferences item isn't present, this method adds and enables it.
*
* @param enable specifies whether the Preferences item in the application menu should be enabled (<code>true</code>) or not (<code>false</code>)
*
* @deprecated no replacement
* @since 1.4
*/
@Deprecated
public void setEnabledPreferencesMenu(final boolean enable) {
menuBarHandler.setPreferencesMenuItemVisible(true);
menuBarHandler.setPreferencesMenuItemEnabled(enable);
}
/**
* Enables the About item in the application menu. The ApplicationListener receives a callback for
* selection of the About item in the application menu only if this is set to <code>true</code>. Because AWT supplies
* a standard About window when an application may not, by default this is set to <code>true</code>.
*
* If the About item isn't present, this method adds and enables it.
*
* @param enable specifies whether the About item in the application menu should be enabled (<code>true</code>) or not (<code>false</code>)
*
* @deprecated no replacement
* @since 1.4
*/
@Deprecated
public void setEnabledAboutMenu(final boolean enable) {
menuBarHandler.setAboutMenuItemEnabled(enable);
}
/**
* Determines if the Preferences item of the application menu is enabled.
*
* @deprecated no replacement
* @since 1.4
*/
@Deprecated
public boolean getEnabledPreferencesMenu() {
return menuBarHandler.isPreferencesMenuItemEnabled();
}
/**
* Determines if the About item of the application menu is enabled.
*
* @deprecated no replacement
* @since 1.4
*/
@Deprecated
public boolean getEnabledAboutMenu() {
return menuBarHandler.isAboutMenuItemEnabled();
}
/**
* Determines if the About item of the application menu is present.
*
* @deprecated no replacement
* @since 1.4
*/
@Deprecated
public boolean isAboutMenuItemPresent() {
return menuBarHandler.isAboutMenuItemVisible();
}
/**
* Adds the About item to the application menu if the item is not already present.
*
* @deprecated use {@link #setAboutHandler(AboutHandler)} with a non-null {@link AboutHandler} parameter
* @since 1.4
*/
@Deprecated
public void addAboutMenuItem() {
menuBarHandler.setAboutMenuItemVisible(true);
}
/**
* Removes the About item from the application menu if the item is present.
*
* @deprecated use {@link #setAboutHandler(AboutHandler)} with a null parameter
* @since 1.4
*/
@Deprecated
public void removeAboutMenuItem() {
menuBarHandler.setAboutMenuItemVisible(false);
}
/**
* Determines if the About Preferences of the application menu is present. By default there is no Preferences menu item.
*
* @deprecated no replacement
* @since 1.4
*/
@Deprecated
public boolean isPreferencesMenuItemPresent() {
return menuBarHandler.isPreferencesMenuItemVisible();
}
/**
* Adds the Preferences item to the application menu if the item is not already present.
*
* @deprecated use {@link #setPreferencesHandler(PreferencesHandler)} with a non-null {@link PreferencesHandler} parameter
* @since 1.4
*/
@Deprecated
public void addPreferencesMenuItem() {
menuBarHandler.setPreferencesMenuItemVisible(true);
}
/**
* Removes the Preferences item from the application menu if that item is present.
*
* @deprecated use {@link #setPreferencesHandler(PreferencesHandler)} with a null parameter
* @since 1.4
*/
@Deprecated
public void removePreferencesMenuItem() {
menuBarHandler.setPreferencesMenuItemVisible(false);
}
/**
* @deprecated Use <code>java.awt.MouseInfo.getPointerInfo().getLocation()</code>.
*
* @since 1.4
*/
@Deprecated
public static Point getMouseLocationOnScreen() {
return java.awt.MouseInfo.getPointerInfo().getLocation();
}
}

View File

@@ -0,0 +1,75 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.apple.eawt;
/**
* An abstract adapter class for receiving <code>ApplicationEvents</code>.
*
* ApplicationEvents are deprecated. Use individual app event listeners or handlers instead.
*
* @see Application#addAppEventListener(AppEventListener)
*
* @see AboutHandler
* @see PreferencesHandler
* @see OpenURIHandler
* @see OpenFilesHandler
* @see PrintFilesHandler
* @see QuitHandler
*
* @see AppReOpenedListener
* @see AppForegroundListener
* @see AppHiddenListener
* @see UserSessionListener
* @see ScreenSleepListener
* @see SystemSleepListener
*
* @deprecated replaced by {@link AboutHandler}, {@link PreferencesHandler}, {@link AppReOpenedListener}, {@link OpenFilesHandler}, {@link PrintFilesHandler}, {@link QuitHandler}, {@link QuitResponse}.
* @since 1.4
*/
@SuppressWarnings("deprecation")
@Deprecated
public class ApplicationAdapter implements ApplicationListener {
@Deprecated
public void handleAbout(final ApplicationEvent event) { }
@Deprecated
public void handleOpenApplication(final ApplicationEvent event) { }
@Deprecated
public void handleOpenFile(final ApplicationEvent event) { }
@Deprecated
public void handlePreferences(final ApplicationEvent event) { }
@Deprecated
public void handlePrintFile(final ApplicationEvent event) { }
@Deprecated
public void handleQuit(final ApplicationEvent event) { }
@Deprecated
public void handleReOpenApplication(final ApplicationEvent event) { }
}

View File

@@ -0,0 +1,95 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.apple.eawt;
import java.util.EventObject;
/**
* The class of events sent to the deprecated ApplicationListener callbacks.
*
* @deprecated replaced by {@link AboutHandler}, {@link PreferencesHandler}, {@link AppReOpenedListener}, {@link OpenFilesHandler}, {@link PrintFilesHandler}, {@link QuitHandler}, {@link QuitResponse}
* @since 1.4
*/
@Deprecated
public class ApplicationEvent extends EventObject {
private String fFilename = null;
private boolean fHandled = false;
ApplicationEvent(final Object source) {
super(source);
}
ApplicationEvent(final Object source, final String filename) {
super(source);
fFilename = filename;
}
/**
* Determines whether an ApplicationListener has acted on a particular event.
* An event is marked as having been handled with <code>setHandled(true)</code>.
*
* @return <code>true</code> if the event has been handled, otherwise <code>false</code>
*
* @since 1.4
* @deprecated
*/
@Deprecated
public boolean isHandled() {
return fHandled;
}
/**
* Marks the event as handled.
* After this method handles an ApplicationEvent, it may be useful to specify that it has been handled.
* This is usually used in conjunction with <code>getHandled()</code>.
* Set to <code>true</code> to designate that this event has been handled. By default it is <code>false</code>.
*
* @param state <code>true</code> if the event has been handled, otherwise <code>false</code>.
*
* @since 1.4
* @deprecated
*/
@Deprecated
public void setHandled(final boolean state) {
fHandled = state;
}
/**
* Provides the filename associated with a particular AppleEvent.
* When the ApplicationEvent corresponds to an AppleEvent that needs to act on a particular file, the ApplicationEvent carries the name of the specific file with it.
* For example, the Print and Open events refer to specific files.
* For these cases, this returns the appropriate file name.
*
* @return the full path to the file associated with the event, if applicable, otherwise <code>null</code>
*
* @since 1.4
* @deprecated use {@link OpenFilesHandler} or {@link PrintFilesHandler} instead
*/
@Deprecated
public String getFilename() {
return fFilename;
}
}

View File

@@ -0,0 +1,153 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.apple.eawt;
import java.util.EventListener;
/**
* ApplicationEvents are deprecated. Use individual AppEvent listeners or handlers instead.
*
* @see Application#addAppEventListener(AppEventListener)
*
* @see AboutHandler
* @see PreferencesHandler
* @see OpenURIHandler
* @see OpenFilesHandler
* @see PrintFilesHandler
* @see QuitHandler
*
* @see AppReOpenedListener
* @see AppForegroundListener
* @see AppHiddenListener
* @see UserSessionListener
* @see ScreenSleepListener
* @see SystemSleepListener
*
* @since 1.4
* @deprecated replaced by {@link AboutHandler}, {@link PreferencesHandler}, {@link AppReOpenedListener}, {@link OpenFilesHandler}, {@link PrintFilesHandler}, {@link QuitHandler}, {@link QuitResponse}
*/
@SuppressWarnings("deprecation")
@Deprecated
public interface ApplicationListener extends EventListener {
/**
* Called when the user selects the About item in the application menu. If <code>event</code> is not handled by
* setting <code>isHandled(true)</code>, a default About window consisting of the application's name and icon is
* displayed. To display a custom About window, designate the <code>event</code> as being handled and display the
* appropriate About window.
*
* @param event an ApplicationEvent initiated by the user choosing About in the application menu
* @deprecated use {@link AboutHandler}
*/
@Deprecated
public void handleAbout(ApplicationEvent event);
/**
* Called when the application receives an Open Application event from the Finder or another application. Usually
* this will come from the Finder when a user double-clicks your application icon. If there is any special code
* that you want to run when you user launches your application from the Finder or by sending an Open Application
* event from another application, include that code as part of this handler. The Open Application event is sent
* after AWT has been loaded.
*
* @param event the Open Application event
* @deprecated no replacement
*/
@Deprecated
public void handleOpenApplication(ApplicationEvent event);
/**
* Called when the application receives an Open Document event from the Finder or another application. This event
* is generated when a user double-clicks a document in the Finder. If the document is registered as belonging
* to your application, this event is sent to your application. Documents are bound to a particular application based
* primarily on their suffix. In the Finder, a user selects a document and then from the File Menu chooses Get Info.
* The Info window allows users to bind a document to a particular application.
*
* These events are sent only if the bound application has file types listed in the Info.plist entries Document Types
* or CFBundleDocumentTypes.
*
* The ApplicationEvent sent to this handler holds a reference to the file being opened.
*
* @param event an Open Document event with reference to the file to be opened
* @deprecated use {@link OpenFilesHandler}
*/
@Deprecated
public void handleOpenFile(ApplicationEvent event);
/**
* Called when the Preference item in the application menu is selected. Native Mac OS X applications make their
* Preferences window available through the application menu. Java applications are automatically given an application
* menu in Mac OS X. By default, the Preferences item is disabled in that menu. If you are deploying an application
* on Mac OS X, you should enable the preferences item with <code>setEnabledPreferencesMenu(true)</code> in the
* Application object and then display your Preferences window in this handler.
*
* @param event triggered when the user selects Preferences from the application menu
* @deprecated use {@link PreferencesHandler}
*/
@Deprecated
public void handlePreferences(ApplicationEvent event);
/**
* Called when the application is sent a request to print a particular file or files. You can allow other applications to
* print files with your application by implementing this handler. If another application sends a Print Event along
* with the name of a file that your application knows how to process, you can use this handler to determine what to
* do with that request. You might open your entire application, or just invoke your printing classes.
*
* These events are sent only if the bound application has file types listed in the Info.plist entries Document Types
* or CFBundleDocumentTypes.
*
* The ApplicationEvent sent to this handler holds a reference to the file being opened.
*
* @param event a Print Document event with a reference to the file(s) to be printed
* @deprecated use {@link PrintFilesHandler}
*/
@Deprecated
public void handlePrintFile(ApplicationEvent event);
/**
* Called when the application is sent the Quit event. This event is generated when the user selects Quit from the
* application menu, when the user types Command-Q, or when the user control clicks on your application icon in the
* Dock and chooses Quit. You can either accept or reject the request to quit. You might want to reject the request
* to quit if the user has unsaved work. Reject the request, move into your code to save changes, then quit your
* application. To accept the request to quit, and terminate the application, set <code>isHandled(true)</code> for the
* <code>event</code>. To reject the quit, set <code>isHandled(false)</code>.
*
* @param event a Quit Application event
* @deprecated use {@link QuitHandler} and {@link QuitResponse}
*/
@Deprecated
public void handleQuit(ApplicationEvent event);
/**
* Called when the application receives a Reopen Application event from the Finder or another application. Usually
* this will come when a user clicks on your application icon in the Dock. If there is any special code
* that needs to run when your user clicks on your application icon in the Dock or when a Reopen Application
* event is sent from another application, include that code as part of this handler.
*
* @param event the Reopen Application event
* @deprecated use {@link AppReOpenedListener}
*/
@Deprecated
public void handleReOpenApplication(ApplicationEvent event);
}

View File

@@ -25,7 +25,7 @@
package com.apple.eawt;
import com.apple.eawt.event.FullScreenEvent;
import com.apple.eawt.AppEvent.FullScreenEvent;
/**
* Abstract adapter class for receiving fullscreen events. This class is provided

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,13 +25,13 @@
package com.apple.eawt;
import com.apple.eawt.event.FullScreenEvent;
import java.awt.*;
import java.util.*;
import java.util.List;
import javax.swing.RootPaneContainer;
import com.apple.eawt.AppEvent.FullScreenEvent;
import sun.awt.SunToolkit;
import java.lang.annotation.Native;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,9 +25,9 @@
package com.apple.eawt;
import com.apple.eawt.event.FullScreenEvent;
import java.util.EventListener;
import com.apple.eawt.AppEvent.FullScreenEvent;
/**
*
@@ -37,25 +37,25 @@ import java.util.EventListener;
public interface FullScreenListener extends EventListener {
/**
* Invoked when a window has started to enter full screen.
* @param e containing the specific window entering full screen.
* @param event containing the specific window entering full screen.
*/
public void windowEnteringFullScreen(final FullScreenEvent e);
/**
* Invoked when a window has fully entered full screen.
* @param e containing the specific window which has entered full screen.
* @param event containing the specific window which has entered full screen.
*/
public void windowEnteredFullScreen(final FullScreenEvent e);
/**
* Invoked when a window has started to exit full screen.
* @param e containing the specific window exiting full screen.
* @param event containing the specific window exiting full screen.
*/
public void windowExitingFullScreen(final FullScreenEvent e);
/**
* Invoked when a window has fully exited full screen.
* @param e containing the specific window which has exited full screen.
* @param event containing the specific window which has exited full screen.
*/
public void windowExitedFullScreen(final FullScreenEvent e);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,25 +25,27 @@
package com.apple.eawt;
import java.awt.Component;
import java.awt.Window;
import java.awt.*;
import javax.swing.RootPaneContainer;
import sun.lwawt.macosx.*;
import com.apple.eawt.event.GestureUtilities;
import sun.lwawt.macosx.CPlatformWindow;
/**
* Utility class perform animated full screen actions to top-level {@link Window}s.
*
* This class manages the relationship between {@link Window}s and the {@link FullScreenListener}s
* attached to them. It adds additional functionality to AWT Windows, without adding new API to the
* This class manages the relationship between {@link Windows}s and the {@link FullScreenListener}s
* attached to them. It's design is similar to the Java SE 6u10 {@link com.sun.awt.AWTUtilities}
* class which adds additional functionality to AWT Windows, without adding new API to the
* {@link java.awt.Window} class.
*
* Full screen operations can only be performed on top-level {@link Window}s that are also {@link RootPaneContainer}s.
*
* @see FullScreenAdapter
* @see GestureUtilities
* @see com.sun.awt.AWTUtilities
*
* @since Java for Mac OS X 10.7 Update 1
*/

View File

@@ -53,7 +53,7 @@ public class MacQuitResponse implements QuitResponse {
*/
@Override
public void performQuit() {
if (appEventHandler.currentQuitResponse != this) return;
//if (appEventHandler.currentQuitResponse != this) return;
appEventHandler.performQuit();
}
@@ -63,7 +63,7 @@ public class MacQuitResponse implements QuitResponse {
*/
@Override
public void cancelQuit() {
if (appEventHandler.currentQuitResponse != this) return;
//if (appEventHandler.currentQuitResponse != this) return;
appEventHandler.cancelQuit();
}
}

View File

@@ -47,6 +47,8 @@ public class QuitResponse {
* Notifies the external quit requester that the quit will proceed, and performs the default {@link QuitStrategy}.
*/
public void performQuit() {
if (appEventHandler.currentQuitResponse != this) return;
appEventHandler.performQuit();
}
/**
@@ -54,5 +56,7 @@ public class QuitResponse {
* <b>Note: this will cancel a pending log-out, restart, or shutdown.</b>
*/
public void cancelQuit() {
if (appEventHandler.currentQuitResponse != this) return;
appEventHandler.cancelQuit();
}
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.apple.eawt;
import com.apple.eawt.AppEvent.ScreenSleepEvent;
/**
* Implementors receive notification when the displays attached to the system have entered power save sleep.
*
* This notification is useful for discontinuing a costly animation, or indicating that the user is no longer present on a network service.
*
* This message is not sent on Mac OS X versions prior to 10.6.
*
* @see Application#addAppEventListener(AppEventListener)
*
* @since Java for Mac OS X 10.6 Update 3
* @since Java for Mac OS X 10.5 Update 8
*/
public interface ScreenSleepListener extends AppEventListener {
/**
* Called when the system displays have entered power save sleep.
* @param e the screen sleep event
*/
public void screenAboutToSleep(final ScreenSleepEvent e);
/**
* Called when the system displays have awoke from power save sleep.
* @param e the screen sleep event
*/
public void screenAwoke(final ScreenSleepEvent e);
}

View File

@@ -0,0 +1,53 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.apple.eawt;
import com.apple.eawt.AppEvent.SystemSleepEvent;
/**
* Implementors receive notification as the system is entering sleep, and after the system wakes.
*
* This notification is useful for disconnecting from network services prior to sleep, or re-establishing a connection if the network configuration has changed during sleep.
*
* @see Application#addAppEventListener(AppEventListener)
*
* @since Java for Mac OS X 10.6 Update 3
* @since Java for Mac OS X 10.5 Update 8
*/
public interface SystemSleepListener extends AppEventListener {
/**
* Called when the system is about to sleep.
* Note: This message may not be delivered prior to the actual system sleep, and may be processed after the corresponding wake has occurred.
* @param e the system sleep event
*/
public void systemAboutToSleep(final SystemSleepEvent e);
/**
* Called after the system has awoke from sleeping.
* @param e the system sleep event
*/
public void systemAwoke(final SystemSleepEvent e);
}

View File

@@ -0,0 +1,52 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.apple.eawt;
import com.apple.eawt.AppEvent.UserSessionEvent;
/**
* Implementors receive notification when Fast User Switching changes the user session.
*
* This notification is useful for discontinuing a costly animation, or indicating that the user is no longer present on a network service.
*
* @see Application#addAppEventListener(AppEventListener)
*
* @since Java for Mac OS X 10.6 Update 3
* @since Java for Mac OS X 10.5 Update 8
*/
public interface UserSessionListener extends AppEventListener {
/**
* Called when the user session has been switched away.
* @param e the user session switch event
*/
public void userSessionDeactivated(final UserSessionEvent e);
/**
* Called when the user session has been switched to.
* @param e the user session switch event
*/
public void userSessionActivated(final UserSessionEvent e);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,14 +28,13 @@ package com.apple.eawt;
import java.awt.*;
import java.lang.reflect.*;
import sun.awt.AWTAccessor;
import sun.lwawt.macosx.*;
import sun.lwawt.macosx.CImage.Creator;
import sun.awt.AWTAccessor;
class _AppDockIconHandler {
private static native void nativeSetDockMenu(final long cmenu);
private static native void nativeSetDockIconImage(final long image);
private static native void nativeSetDockIconProgress(final int value);
private static native long nativeGetDockIconImage();
private static native void nativeSetDockIconBadge(final String badge);
@@ -43,6 +42,7 @@ class _AppDockIconHandler {
_AppDockIconHandler() { }
@SuppressWarnings("deprecation")
public void setDockMenu(final PopupMenu menu) {
fDockMenu = menu;
@@ -72,8 +72,9 @@ class _AppDockIconHandler {
public void setDockIconImage(final Image image) {
try {
final CImage cImage = CImage.createFromImage(image);
cImage.execute(_AppDockIconHandler::nativeSetDockIconImage);
final CImage cImage = getCImageCreator().createFromImage(image);
final long nsImagePtr = getNSImagePtrFrom(cImage);
nativeSetDockIconImage(nsImagePtr);
} catch (final Throwable e) {
throw new RuntimeException(e);
}
@@ -83,11 +84,7 @@ class _AppDockIconHandler {
try {
final long dockNSImage = nativeGetDockIconImage();
if (dockNSImage == 0) return null;
final Method getCreatorMethod = CImage.class.getDeclaredMethod(
"getCreator", new Class<?>[]{});
getCreatorMethod.setAccessible(true);
Creator imageCreator = (Creator) getCreatorMethod.invoke(null, new Object[]{});
return imageCreator.createImageUsingNativeSize(dockNSImage);
return getCImageCreator().createImageUsingNativeSize(dockNSImage);
} catch (final Throwable e) {
throw new RuntimeException(e);
}
@@ -97,7 +94,26 @@ class _AppDockIconHandler {
nativeSetDockIconBadge(badge);
}
void setDockIconProgress(int value) {
nativeSetDockIconProgress(value);
@SuppressWarnings("rawtypes")
static Creator getCImageCreator() {
try {
final Method getCreatorMethod = CImage.class.getDeclaredMethod("getCreator", new Class[] {});
getCreatorMethod.setAccessible(true);
return (Creator)getCreatorMethod.invoke(null, new Object[] {});
} catch (final Throwable e) {
throw new RuntimeException(e);
}
}
static long getNSImagePtrFrom(final CImage cImage) {
if (cImage == null) return 0;
try {
final Field cImagePtrField = CFRetainedResource.class.getDeclaredField("ptr");
cImagePtrField.setAccessible(true);
return cImagePtrField.getLong(cImage);
} catch (final Throwable e) {
throw new RuntimeException(e);
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,47 +25,17 @@
package com.apple.eawt;
import java.awt.EventQueue;
import java.awt.Frame;
import java.awt.desktop.AboutEvent;
import java.awt.desktop.AboutHandler;
import java.awt.desktop.AppForegroundEvent;
import java.awt.desktop.AppForegroundListener;
import java.awt.desktop.AppHiddenEvent;
import java.awt.desktop.AppHiddenListener;
import java.awt.desktop.AppReopenedEvent;
import java.awt.desktop.AppReopenedListener;
import java.awt.desktop.OpenFilesEvent;
import java.awt.desktop.OpenFilesHandler;
import java.awt.desktop.OpenURIEvent;
import java.awt.desktop.OpenURIHandler;
import java.awt.desktop.PreferencesEvent;
import java.awt.desktop.PreferencesHandler;
import java.awt.desktop.PrintFilesEvent;
import java.awt.desktop.PrintFilesHandler;
import java.awt.desktop.QuitEvent;
import java.awt.desktop.QuitHandler;
import java.awt.desktop.QuitStrategy;
import java.awt.desktop.ScreenSleepEvent;
import java.awt.desktop.ScreenSleepListener;
import java.awt.desktop.SystemEventListener;
import java.awt.desktop.SystemSleepEvent;
import java.awt.desktop.SystemSleepListener;
import java.awt.desktop.UserSessionEvent;
import java.awt.desktop.UserSessionEvent.Reason;
import java.awt.desktop.UserSessionListener;
import java.awt.*;
import java.awt.event.WindowEvent;
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.IdentityHashMap;
import java.util.LinkedList;
import java.net.*;
import java.util.*;
import java.util.List;
import java.util.Map;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
import com.apple.eawt.AppEvent.*;
class _AppEventHandler {
private static final int NOTIFY_ABOUT = 1;
private static final int NOTIFY_PREFS = 2;
@@ -92,7 +62,7 @@ class _AppEventHandler {
private static native void nativeReplyToAppShouldTerminate(final boolean shouldTerminate);
private static native void nativeRegisterForNotification(final int notification);
static final _AppEventHandler instance = new _AppEventHandler();
final static _AppEventHandler instance = new _AppEventHandler();
static _AppEventHandler getInstance() {
return instance;
}
@@ -114,7 +84,9 @@ class _AppEventHandler {
final _ScreenSleepDispatcher screenSleepDispatcher = new _ScreenSleepDispatcher();
final _SystemSleepDispatcher systemSleepDispatcher = new _SystemSleepDispatcher();
QuitStrategy defaultQuitAction = QuitStrategy.NORMAL_EXIT;
final _AppEventLegacyHandler legacyHandler = new _AppEventLegacyHandler(this);
QuitStrategy defaultQuitAction = QuitStrategy.SYSTEM_EXIT_0;
_AppEventHandler() {
final String strategyProp = System.getProperty("apple.eawt.quitStrategy");
@@ -122,16 +94,15 @@ class _AppEventHandler {
if ("CLOSE_ALL_WINDOWS".equals(strategyProp)) {
setDefaultQuitStrategy(QuitStrategy.CLOSE_ALL_WINDOWS);
} else if ("SYSTEM_EXIT_O".equals(strategyProp)
|| "NORMAL_EXIT".equals(strategyProp)) {
setDefaultQuitStrategy(QuitStrategy.NORMAL_EXIT);
} else if ("SYSTEM_EXIT_O".equals(strategyProp)) {
setDefaultQuitStrategy(QuitStrategy.SYSTEM_EXIT_0);
} else {
System.err.println("unrecognized apple.eawt.quitStrategy: " + strategyProp);
}
}
void addListener(final SystemEventListener listener) {
if (listener instanceof AppReopenedListener) reOpenAppDispatcher.addListener((AppReopenedListener)listener);
void addListener(final AppEventListener listener) {
if (listener instanceof AppReOpenedListener) reOpenAppDispatcher.addListener((AppReOpenedListener)listener);
if (listener instanceof AppForegroundListener) foregroundAppDispatcher.addListener((AppForegroundListener)listener);
if (listener instanceof AppHiddenListener) hiddenAppDispatcher.addListener((AppHiddenListener)listener);
if (listener instanceof UserSessionListener) userSessionDispatcher.addListener((UserSessionListener)listener);
@@ -139,8 +110,8 @@ class _AppEventHandler {
if (listener instanceof SystemSleepListener) systemSleepDispatcher.addListener((SystemSleepListener)listener);
}
void removeListener(final SystemEventListener listener) {
if (listener instanceof AppReopenedListener) reOpenAppDispatcher.removeListener((AppReopenedListener)listener);
void removeListener(final AppEventListener listener) {
if (listener instanceof AppReOpenedListener) reOpenAppDispatcher.removeListener((AppReOpenedListener)listener);
if (listener instanceof AppForegroundListener) foregroundAppDispatcher.removeListener((AppForegroundListener)listener);
if (listener instanceof AppHiddenListener) hiddenAppDispatcher.removeListener((AppHiddenListener)listener);
if (listener instanceof UserSessionListener) userSessionDispatcher.removeListener((UserSessionListener)listener);
@@ -156,10 +127,10 @@ class _AppEventHandler {
this.defaultQuitAction = defaultQuitAction;
}
MacQuitResponse currentQuitResponse;
synchronized MacQuitResponse obtainQuitResponse() {
QuitResponse currentQuitResponse;
synchronized QuitResponse obtainQuitResponse() {
if (currentQuitResponse != null) return currentQuitResponse;
return currentQuitResponse = new MacQuitResponse(this);
return currentQuitResponse = new QuitResponse(this);
}
synchronized void cancelQuit() {
@@ -171,8 +142,7 @@ class _AppEventHandler {
currentQuitResponse = null;
try {
if (defaultQuitAction == QuitStrategy.NORMAL_EXIT
|| _AppMiscHandlers.isSuddenTerminationEnbaled()) System.exit(0);
if (defaultQuitAction == QuitStrategy.SYSTEM_EXIT_0) System.exit(0);
if (defaultQuitAction != QuitStrategy.CLOSE_ALL_WINDOWS) {
throw new RuntimeException("Unknown quit action");
@@ -300,10 +270,10 @@ class _AppEventHandler {
}
}
class _AppReOpenedDispatcher extends _AppEventMultiplexor<AppReopenedListener> {
void performOnListener(AppReopenedListener listener, final _NativeEvent event) {
final AppReopenedEvent e = new AppReopenedEvent();
listener.appReopened(e);
class _AppReOpenedDispatcher extends _AppEventMultiplexor<AppReOpenedListener> {
void performOnListener(AppReOpenedListener listener, final _NativeEvent event) {
final AppReOpenedEvent e = new AppReOpenedEvent();
listener.appReOpened(e);
}
}
@@ -332,9 +302,7 @@ class _AppEventHandler {
}
class _UserSessionDispatcher extends _BooleanAppEventMultiplexor<UserSessionListener, UserSessionEvent> {
UserSessionEvent createEvent(final boolean isTrue) {
return new UserSessionEvent(Reason.UNSPECIFIED);
}
UserSessionEvent createEvent(final boolean isTrue) { return new UserSessionEvent(); }
void performFalseEventOn(final UserSessionListener listener, final UserSessionEvent e) {
listener.userSessionDeactivated(e);
@@ -423,11 +391,7 @@ class _AppEventHandler {
}
void performUsing(final QuitHandler handler, final _NativeEvent event) {
if (_AppMiscHandlers.isSuddenTerminationEnbaled()) {
performDefaultAction(event);
return;
}
final MacQuitResponse response = obtainQuitResponse(); // obtains the "current" quit response
final QuitResponse response = obtainQuitResponse(); // obtains the "current" quit response
handler.handleQuitRequestWith(new QuitEvent(), response);
}
}
@@ -560,6 +524,9 @@ class _AppEventHandler {
setHandlerContext(AppContext.getAppContext());
// if a new handler is installed, block addition of legacy ApplicationListeners
if (handler == legacyHandler) return;
legacyHandler.blockLegacyAPI();
}
void performDefaultAction(final _NativeEvent event) { } // by default, do nothing
@@ -607,6 +574,10 @@ class _AppEventHandler {
}
}
}
// if a new handler is installed, block addition of legacy ApplicationListeners
if (handler == legacyHandler) return;
legacyHandler.blockLegacyAPI();
}
}
}

View File

@@ -0,0 +1,188 @@
/*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.apple.eawt;
import java.awt.Toolkit;
import java.io.File;
import java.util.*;
import com.apple.eawt.AppEvent.*;
@SuppressWarnings("deprecation")
class _AppEventLegacyHandler implements AboutHandler, PreferencesHandler, _OpenAppHandler, AppReOpenedListener, OpenFilesHandler, PrintFilesHandler, QuitHandler {
final _AppEventHandler parent;
final Vector<ApplicationListener> legacyAppListeners = new Vector<ApplicationListener>();
boolean blockLegacyAPI;
boolean initializedParentDispatchers;
_AppEventLegacyHandler(final _AppEventHandler parent) {
this.parent = parent;
}
void blockLegacyAPI() {
blockLegacyAPI = true;
}
void checkIfLegacyAPIBlocked() {
if (!blockLegacyAPI) return;
throw new IllegalStateException("Cannot add com.apple.eawt.ApplicationListener after installing an app event handler");
}
void addLegacyAppListener(final ApplicationListener listener) {
checkIfLegacyAPIBlocked();
if (!initializedParentDispatchers) {
final _AppMenuBarHandler menuBarHandler = Application.getApplication().menuBarHandler;
final boolean prefsMenuAlreadyExplicitlySet = menuBarHandler.prefsMenuItemExplicitlySet;
parent.aboutDispatcher.setHandler(this);
parent.preferencesDispatcher.setHandler(this);
if (!prefsMenuAlreadyExplicitlySet) {
menuBarHandler.setPreferencesMenuItemVisible(false); // default behavior is not to have a preferences item
}
parent.openAppDispatcher.setHandler(this);
parent.reOpenAppDispatcher.addListener(this);
parent.openFilesDispatcher.setHandler(this);
parent.printFilesDispatcher.setHandler(this);
parent.quitDispatcher.setHandler(this);
initializedParentDispatchers = true;
}
synchronized (legacyAppListeners) {
legacyAppListeners.addElement(listener);
}
}
public void removeLegacyAppListener(final ApplicationListener listener) {
checkIfLegacyAPIBlocked();
synchronized (legacyAppListeners) {
legacyAppListeners.removeElement(listener);
}
}
@Override
public void handleAbout(final AboutEvent e) {
final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit());
sendEventToEachListenerUntilHandled(ae, new EventDispatcher() {
public void dispatchEvent(final ApplicationListener listener) {
listener.handleAbout(ae);
}
});
if (ae.isHandled()) return;
parent.openCocoaAboutWindow();
}
@Override
public void handlePreferences(final PreferencesEvent e) {
final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit());
sendEventToEachListenerUntilHandled(ae, new EventDispatcher() {
public void dispatchEvent(final ApplicationListener listener) {
listener.handlePreferences(ae);
}
});
}
@Override
public void handleOpenApp() {
final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit());
sendEventToEachListenerUntilHandled(ae, new EventDispatcher() {
public void dispatchEvent(final ApplicationListener listener) {
listener.handleOpenApplication(ae);
}
});
}
@Override
public void appReOpened(final AppReOpenedEvent e) {
final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit());
sendEventToEachListenerUntilHandled(ae, new EventDispatcher() {
public void dispatchEvent(final ApplicationListener listener) {
listener.handleReOpenApplication(ae);
}
});
}
@Override
public void openFiles(final OpenFilesEvent e) {
final List<File> files = e.getFiles();
for (final File file : files) { // legacy ApplicationListeners only understood one file at a time
final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit(), file.getAbsolutePath());
sendEventToEachListenerUntilHandled(ae, new EventDispatcher() {
public void dispatchEvent(final ApplicationListener listener) {
listener.handleOpenFile(ae);
}
});
}
}
@Override
public void printFiles(PrintFilesEvent e) {
final List<File> files = e.getFiles();
for (final File file : files) { // legacy ApplicationListeners only understood one file at a time
final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit(), file.getAbsolutePath());
sendEventToEachListenerUntilHandled(ae, new EventDispatcher() {
public void dispatchEvent(final ApplicationListener listener) {
listener.handlePrintFile(ae);
}
});
}
}
@Override
public void handleQuitRequestWith(final QuitEvent e, final QuitResponse response) {
final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit());
sendEventToEachListenerUntilHandled(ae, new EventDispatcher() {
public void dispatchEvent(final ApplicationListener listener) {
listener.handleQuit(ae);
}
});
if (ae.isHandled()) {
parent.performQuit();
} else {
parent.cancelQuit();
}
}
interface EventDispatcher {
void dispatchEvent(final ApplicationListener listener);
}
// helper that cycles through the loop and aborts if the event is handled, or there are no listeners
void sendEventToEachListenerUntilHandled(final ApplicationEvent event, final EventDispatcher dispatcher) {
synchronized (legacyAppListeners) {
if (legacyAppListeners.size() == 0) return;
final Enumeration<ApplicationListener> e = legacyAppListeners.elements();
while (e.hasMoreElements() && !event.isHandled()) {
dispatcher.dispatchEvent(e.nextElement());
}
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,20 +25,17 @@
package com.apple.eawt;
import java.awt.Container;
import java.awt.Frame;
import java.awt.peer.MenuComponentPeer;
import javax.swing.JFrame;
import javax.swing.JLayeredPane;
import javax.swing.JMenuBar;
import javax.swing.*;
import javax.swing.plaf.MenuBarUI;
import com.apple.laf.ScreenMenuBar;
import sun.awt.AWTAccessor;
import sun.lwawt.macosx.CMenuBar;
import com.apple.laf.AquaMenuBarUI;
import sun.awt.AWTAccessor;
class _AppMenuBarHandler {
private static final int MENU_ABOUT = 1;
@@ -46,20 +43,14 @@ class _AppMenuBarHandler {
private static native void nativeSetMenuState(final int menu, final boolean visible, final boolean enabled);
private static native void nativeSetDefaultMenuBar(final long menuBarPeer);
private static native void nativeActivateDefaultMenuBar(final long menuBarPeer);
static final _AppMenuBarHandler instance = new _AppMenuBarHandler();
static _AppMenuBarHandler getInstance() {
return instance;
}
private static ScreenMenuBar defaultMenuBar;
// callback from the native delegate -init function
private static void initMenuStates(final boolean aboutMenuItemVisible,
final boolean aboutMenuItemEnabled,
final boolean prefsMenuItemVisible,
final boolean prefsMenuItemEnabled) {
private static void initMenuStates(final boolean aboutMenuItemVisible, final boolean aboutMenuItemEnabled, final boolean prefsMenuItemVisible, final boolean prefsMenuItemEnabled) {
synchronized (instance) {
instance.aboutMenuItemVisible = aboutMenuItemVisible;
instance.aboutMenuItemEnabled = aboutMenuItemEnabled;
@@ -79,45 +70,41 @@ class _AppMenuBarHandler {
void setDefaultMenuBar(final JMenuBar menuBar) {
installDefaultMenuBar(menuBar);
}
static boolean isMenuBarActivationNeeded() {
// scan the current frames, and see if any are foreground
final Frame[] frames = Frame.getFrames();
for (final Frame frame : frames) {
if (frame.isVisible() && !isFrameMinimized(frame)) {
return false;
return;
}
}
return true;
// if we have no foreground frames, then we have to "kick" the menubar
final JFrame pingFrame = new JFrame();
pingFrame.getRootPane().putClientProperty("Window.alpha", Float.valueOf(0.0f));
pingFrame.setUndecorated(true);
pingFrame.setVisible(true);
pingFrame.toFront();
pingFrame.setVisible(false);
pingFrame.dispose();
}
static boolean isFrameMinimized(final Frame frame) {
return (frame.getExtendedState() & Frame.ICONIFIED) != 0;
}
@SuppressWarnings("deprecation")
static void installDefaultMenuBar(final JMenuBar menuBar) {
if (menuBar == null) {
// intentionally clearing the default menu
if (defaultMenuBar != null) {
defaultMenuBar.removeNotify();
defaultMenuBar = null;
}
nativeSetDefaultMenuBar(0);
return;
}
Container parent = menuBar.getParent();
if (parent instanceof JLayeredPane) {
((JLayeredPane) parent).remove(menuBar);
}
MenuBarUI ui = menuBar.getUI();
final MenuBarUI ui = menuBar.getUI();
if (!(ui instanceof AquaMenuBarUI)) {
ui = new AquaMenuBarUI();
menuBar.setUI(ui);
// Aqua was not installed
throw new IllegalStateException("Application.setDefaultMenuBar() only works with the Aqua Look and Feel");
}
final AquaMenuBarUI aquaUI = (AquaMenuBarUI)ui;
@@ -127,14 +114,7 @@ class _AppMenuBarHandler {
throw new IllegalStateException("Application.setDefaultMenuBar() only works if apple.laf.useScreenMenuBar=true");
}
if (screenMenuBar != defaultMenuBar) {
if (defaultMenuBar != null) {
defaultMenuBar.removeNotify();
}
defaultMenuBar = screenMenuBar;
screenMenuBar.addNotify();
}
screenMenuBar.addNotify();
final Object peer = AWTAccessor.getMenuComponentAccessor().getPeer(screenMenuBar);
if (!(peer instanceof CMenuBar)) {
// such a thing should not be possible
@@ -143,11 +123,6 @@ class _AppMenuBarHandler {
// grab the pointer to the CMenuBar, and retain it in native
((CMenuBar) peer).execute(_AppMenuBarHandler::nativeSetDefaultMenuBar);
// if there is no currently active frame, install the default menu bar in the application main menu
if (isMenuBarActivationNeeded()) {
((CMenuBar) peer).execute(_AppMenuBarHandler::nativeActivateDefaultMenuBar);
}
}
void setAboutMenuItemVisible(final boolean present) {

View File

@@ -26,8 +26,6 @@
package com.apple.eawt;
class _AppMiscHandlers {
private static boolean isSuddenTerminationEnabled;
private static native void nativeOpenHelpViewer();
private static native void nativeRequestActivation(final boolean allWindows);
@@ -49,16 +47,10 @@ class _AppMiscHandlers {
}
static void enableSuddenTermination() {
isSuddenTerminationEnabled = true;
nativeEnableSuddenTermination();
}
static void disableSuddenTermination() {
isSuddenTerminationEnabled = false;
nativeDisableSuddenTermination();
}
public static boolean isSuddenTerminationEnbaled() {
return isSuddenTerminationEnabled;
}
}

View File

@@ -27,4 +27,4 @@ package com.apple.eawt;
interface _OpenAppHandler {
void handleOpenApp();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,7 @@ package com.apple.eawt.event;
* Abstract adapter class for receiving gesture events. This class is provided
* as a convenience for creating listeners.
*
* Subclasses registered with {@link GestureUtilities#addGestureListenerTo}
* Subclasses registered with {@link GestureUtilities#addGestureListenerTo()}
* will receive all phase, magnification, rotation, and swipe events.
*
* @see GestureUtilities

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
package com.apple.eawt.event;
import java.awt.*;
import java.awt.event.InputEvent;
/**
* Abstract event all gestures inherit from.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -39,13 +39,13 @@ package com.apple.eawt.event;
public interface GesturePhaseListener extends GestureListener {
/**
* Invoked when the user has started a continuous gesture.
* @param e representing the start of a continuous gesture.
* @param event representing the start of a continuous gesture.
*/
public void gestureBegan(final GesturePhaseEvent e);
/**
* Invoked when the user has stopped a continuous gesture.
* @param e representing the end of a continuous gesture.
* @param event representing the end of a continuous gesture.
*/
public void gestureEnded(final GesturePhaseEvent e);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,15 +25,14 @@
package com.apple.eawt.event;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JRootPane;
import javax.swing.*;
/**
* Registration utility class to add {@link GestureListener}s to Swing components.
*
* This class manages the relationship between {@link JComponent}s and the {@link GestureListener}s
* attached to them. It adds additional functionality to AWT Windows, without adding new API to the
* attached to them. It's design is similar to the Java SE 6u10 {@link com.sun.awt.AWTUtilities}
* class which adds additional functionality to AWT Windows, without adding new API to the
* {@link java.awt.Window} class.
*
* To add a {@link GestureListener} to a top-level Swing window, use the {@link JRootPane} of the
@@ -41,6 +40,7 @@ import javax.swing.JRootPane;
*
* @see GestureAdapter
* @see JFrame#getRootPane()
* @see com.sun.awt.AWTUtilities
*
* @since Java for Mac OS X 10.5 Update 7, Java for Mac OS X 10.6 Update 2
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,7 @@ package com.apple.eawt.event;
public interface MagnificationListener extends GestureListener {
/**
* Invoked when a magnification gesture is performed by the user.
* @param e containing the scale of the magnification.
* @param event containing the scale of the magnification.
*/
public void magnify(final MagnificationEvent e);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,7 @@ package com.apple.eawt.event;
public interface RotationListener extends GestureListener {
/**
* Invoked when a rotation gesture is performed by the user.
* @param e containing an abstract measure of rotation.
* @param event containing an abstract measure of rotation.
*/
public void rotate(final RotationEvent e);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -38,25 +38,25 @@ package com.apple.eawt.event;
public interface SwipeListener extends GestureListener {
/**
* Invoked when an upwards swipe gesture is performed by the user.
* @param e representing the occurrence of a swipe.
* @param event representing the occurrence of a swipe.
*/
public void swipedUp(final SwipeEvent e);
/**
* Invoked when a downward swipe gesture is performed by the user.
* @param e representing the occurrence of a swipe.
* @param event representing the occurrence of a swipe.
*/
public void swipedDown(final SwipeEvent e);
/**
* Invoked when a leftward swipe gesture is performed by the user.
* @param e representing the occurrence of a swipe.
* @param event representing the occurrence of a swipe.
*/
public void swipedLeft(final SwipeEvent e);
/**
* Invoked when a rightward swipe gesture is performed by the user.
* @param e representing the occurrence of a swipe.
* @param event representing the occurrence of a swipe.
*/
public void swipedRight(final SwipeEvent e);
}

View File

@@ -0,0 +1,13 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body bgcolor="white">
Classes for receiving gesture events.
Provides a mechanism to receive various gesture events on JComponents. Gesture notifications are relayed up the component hierarchy from the deepest component under the cursor to the top-level container. Events may be consumed by deeper components to prevent them from propagating to higher components.
Gesture listeners are added to components using the GestureUtilities helper class.
</body>
</html>

View File

@@ -0,0 +1,10 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body bgcolor="white">
Provides classes for integrating Java applications with the native application environment.
These classes provide a simple way to implement native features to fine tune Java applications on Mac OS X. These listeners and handlers can help make Java applications behaviors and user interface indistinguishable from native applications. For further information on the Mac OS X user interface, consult the <a target=_blank href="http://developer.apple.com/mac/library/documentation/UserExperience/Conceptual/AppleHIGuidelines"> Aqua Human Interface Guidelines</a>.</body>
</html>

View File

@@ -40,9 +40,7 @@ public final class CStrike extends PhysicalStrike {
double[] glyphTx,
double[] invDevTxMatrix,
int aaHint,
int fmHint,
int subpixelResolutionX,
int subpixelResolutionY);
int fmHint);
// Disposes the native strike
private static native void disposeNativeStrikePtr(long nativeStrikePtr);
@@ -129,9 +127,7 @@ public final class CStrike extends PhysicalStrike {
}
nativeStrikePtr =
createNativeStrikePtr(nativeFont.getNativeFontPtr(),
glyphTx, invDevTxMatrix, aaHint, fmHint,
FontUtilities.supplementarySubpixelGlyphResolution.width,
FontUtilities.supplementarySubpixelGlyphResolution.height);
glyphTx, invDevTxMatrix, aaHint, fmHint);
}
return nativeStrikePtr;

View File

@@ -76,72 +76,72 @@ final public class CDesktopPeer implements DesktopPeer {
@Override
public void addAppEventListener(SystemEventListener listener) {
Application.getApplication().addAppEventListener(listener);
//Application.getApplication().addAppEventListener(listener);
}
@Override
public void removeAppEventListener(SystemEventListener listener) {
Application.getApplication().removeAppEventListener(listener);
//Application.getApplication().removeAppEventListener(listener);
}
@Override
public void setAboutHandler(AboutHandler aboutHandler) {
Application.getApplication().setAboutHandler(aboutHandler);
// Application.getApplication().setAboutHandler(aboutHandler);
}
@Override
public void setPreferencesHandler(PreferencesHandler preferencesHandler) {
Application.getApplication().setPreferencesHandler(preferencesHandler);
// Application.getApplication().setPreferencesHandler(preferencesHandler);
}
@Override
public void setOpenFileHandler(OpenFilesHandler openFileHandler) {
Application.getApplication().setOpenFileHandler(openFileHandler);
// Application.getApplication().setOpenFileHandler(openFileHandler);
}
@Override
public void setPrintFileHandler(PrintFilesHandler printFileHandler) {
Application.getApplication().setPrintFileHandler(printFileHandler);
// Application.getApplication().setPrintFileHandler(printFileHandler);
}
@Override
public void setOpenURIHandler(OpenURIHandler openURIHandler) {
Application.getApplication().setOpenURIHandler(openURIHandler);
// Application.getApplication().setOpenURIHandler(openURIHandler);
}
@Override
public void setQuitHandler(QuitHandler quitHandler) {
Application.getApplication().setQuitHandler(quitHandler);
// Application.getApplication().setQuitHandler(quitHandler);
}
@Override
public void setQuitStrategy(QuitStrategy strategy) {
Application.getApplication().setQuitStrategy(strategy);
// Application.getApplication().setQuitStrategy(strategy);
}
@Override
public void enableSuddenTermination() {
Application.getApplication().enableSuddenTermination();
// Application.getApplication().enableSuddenTermination();
}
@Override
public void disableSuddenTermination() {
Application.getApplication().disableSuddenTermination();
// Application.getApplication().disableSuddenTermination();
}
@Override
public void requestForeground(boolean allWindows) {
Application.getApplication().requestForeground(allWindows);
// Application.getApplication().requestForeground(allWindows);
}
@Override
public void openHelpViewer() {
Application.getApplication().openHelpViewer();
// Application.getApplication().openHelpViewer();
}
@Override
public void setDefaultMenuBar(JMenuBar menuBar) {
Application.getApplication().setDefaultMenuBar(menuBar);
// Application.getApplication().setDefaultMenuBar(menuBar);
}
@Override

View File

@@ -52,7 +52,7 @@ final public class CTaskbarPeer implements TaskbarPeer {
@Override
public void setProgressValue(int value) {
Application.getApplication().setDockIconProgress(value);
//Application.getApplication().setDockIconProgress(value);
}
@Override

View File

@@ -34,7 +34,7 @@
#import "AWTView.h"
#import "AWTWindow.h"
#import "JavaComponentAccessibility.h"
#import "JavaStaticTextAccessibility.h"
#import "JavaTextAccessibility.h"
#import "JavaAccessibilityUtilities.h"
#import "GeomUtilities.h"
#import "CGLLayer.h"
@@ -843,8 +843,8 @@ extern bool isSystemShortcut_NextWindowInApplication(NSUInteger modifiersMask, N
- (NSString *)accessibleSelectedText
{
id focused = [self accessibilityFocusedUIElement];
if (![focused respondsToSelector:@selector(accessibilitySelectedText)]) return nil;
return [focused accessibilitySelectedTextAttribute];
if (![focused isKindOfClass:[JavaTextAccessibility class]]) return nil;
return [(JavaTextAccessibility *)focused accessibilitySelectedTextAttribute];
}
// same as above, but converts to RTFD
@@ -863,8 +863,8 @@ extern bool isSystemShortcut_NextWindowInApplication(NSUInteger modifiersMask, N
- (BOOL)replaceAccessibleTextSelection:(NSString *)text
{
id focused = [self accessibilityFocusedUIElement];
if (![focused respondsToSelector:@selector(setAccessibilitySelectedText)]) return NO;
[focused setAccessibilitySelectedText:text];
if (![focused isKindOfClass:[JavaTextAccessibility class]]) return NO;
[(JavaTextAccessibility *)focused accessibilitySetSelectedTextAttribute:text];
return YES;
}

View File

@@ -49,7 +49,6 @@
BOOL isMinimizing;
NSWindowTabbingMode javaWindowTabbingMode;
BOOL isEnterFullScreen;
BOOL isJustCreated;
}
// An instance of either AWTWindow_Normal or AWTWindow_Panel
@@ -67,7 +66,6 @@
@property (nonatomic) BOOL isMinimizing;
@property (nonatomic) NSWindowTabbingMode javaWindowTabbingMode;
@property (nonatomic) BOOL isEnterFullScreen;
@property (nonatomic) BOOL isJustCreated;
- (id) initWithPlatformWindow:(JNFWeakJObjectWrapper *)javaPlatformWindow
ownerWindow:owner

View File

@@ -303,7 +303,6 @@ AWT_NS_WINDOW_IMPLEMENTATION
@synthesize isMinimizing;
@synthesize javaWindowTabbingMode;
@synthesize isEnterFullScreen;
@synthesize isJustCreated;
- (void) updateMinMaxSize:(BOOL)resizable {
if (resizable) {
@@ -447,7 +446,6 @@ AWT_ASSERT_APPKIT_THREAD;
self.javaWindowTabbingMode = [self getJavaWindowTabbingMode];
self.isEnterFullScreen = NO;
self.isJustCreated = YES;
return self;
}
@@ -1193,11 +1191,6 @@ JNF_COCOA_ENTER(env);
nsWindow.contentView.frame = contentFrame;
resized = YES;
}
if (window.isJustCreated) {
// Perform Move/Resize event for just created windows
resized = YES;
window.isJustCreated = NO;
}
}
// resets the NSWindow's style mask if the mask intersects any of those bits

View File

@@ -35,7 +35,6 @@
#import <JavaNativeFoundation/JavaNativeFoundation.h>
#import "CPopupMenu.h"
#import "CMenuBar.h"
#import "ThreadUtilities.h"
#import "NSApplicationAWT.h"
@@ -825,23 +824,3 @@ JNF_COCOA_ENTER(env);
JNF_COCOA_EXIT(env);
}
/*
* Class: com_apple_eawt__AppMenuBarHandler
* Method: nativeActivateDefaultMenuBar
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMenuBarHandler_nativeActivateDefaultMenuBar
(JNIEnv *env, jclass clz, jlong cMenuBarPtr)
{
JNF_COCOA_ENTER(env);
CMenuBar *menu = (CMenuBar *)jlong_to_ptr(cMenuBarPtr);
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){
if (menu) {
[CMenuBar activate:menu modallyDisabled:NO];
}
}];
JNF_COCOA_EXIT(env);
}

View File

@@ -14,6 +14,7 @@
#import "JavaBaseAccessibility.h"
#import "JavaAccessibilityAction.h"
#import "JavaAccessibilityUtilities.h"
#import "JavaTextAccessibility.h"
#import "JavaListAccessibility.h"
#import "JavaTableAccessibility.h"
#import "JavaListRowAccessibility.h"
@@ -21,8 +22,6 @@
#import "JavaCellAccessibility.h"
#import "JavaOutlineAccessibility.h"
#import "JavaOutlineRowAccessibility.h"
#import "JavaStaticTextAccessibility.h"
#import "JavaNavigableTextAccessibility.h"
#import "JavaComponentAccessibility.h"
#import "ThreadUtilities.h"
#import "AWTView.h"
@@ -240,7 +239,7 @@ static jobject sAccessibilityClass = NULL;
{
if ([parent isKindOfClass:[JavaTableAccessibility class]]) {
if (whichChildren == JAVA_AX_SELECTED_CHILDREN) {
NSArray<NSNumber *> *selectedRowIndexses = [(JavaTableAccessibility *)parent selectedAccessibleRows];
NSArray<NSNumber *> *selectedRowIndexses = [parent selectedAccessibleRows];
NSMutableArray *children = [NSMutableArray arrayWithCapacity:[selectedRowIndexses count]];
for (NSNumber *index in selectedRowIndexses) {
[children addObject:[[JavaTableRowAccessibility alloc] initWithParent:parent
@@ -252,7 +251,7 @@ static jobject sAccessibilityClass = NULL;
}
return [NSArray arrayWithArray:children];
} else if (whichChildren == JAVA_AX_ALL_CHILDREN) {
int rowCount = [(JavaTableAccessibility *)parent accessibleRowCount];
int rowCount = [parent accessibleRowCount];
NSMutableArray *children = [NSMutableArray arrayWithCapacity:rowCount];
for (int i = 0; i < rowCount; i++) {
[children addObject:[[JavaTableRowAccessibility alloc] initWithParent:parent
@@ -376,10 +375,8 @@ static jobject sAccessibilityClass = NULL;
newChild = [ScrollAreaAccessibility alloc];
} else {
NSString *nsRole = [sRoles objectForKey:javaRole];
if ([nsRole isEqualToString:NSAccessibilityStaticTextRole]) {
newChild = [JavaStaticTextAccessibility alloc];
} else if ([nsRole isEqualToString:NSAccessibilityTextAreaRole] || [nsRole isEqualToString:NSAccessibilityTextFieldRole]) {
newChild = [JavaNavigableTextAccessibility alloc];
if ([nsRole isEqualToString:NSAccessibilityStaticTextRole] || [nsRole isEqualToString:NSAccessibilityTextAreaRole] || [nsRole isEqualToString:NSAccessibilityTextFieldRole]) {
newChild = [JavaTextAccessibility alloc];
} else if ([nsRole isEqualToString:NSAccessibilityListRole]) {
newChild = [JavaListAccessibility alloc];
} else if ([nsRole isEqualToString:NSAccessibilityTableRole]) {

View File

@@ -42,7 +42,7 @@
#import "JavaAccessibilityAction.h"
#import "JavaAccessibilityUtilities.h"
#import "JavaStaticTextAccessibility.h"
#import "JavaTextAccessibility.h"
#import "ThreadUtilities.h"
#import "AWTView.h"
@@ -582,8 +582,7 @@ static NSObject *sAttributeNamesLOCK = nil;
// The sRoles NSMutableDictionary maps popupmenu to Mac's popup button.
// JComboBox behavior currently relies on this. However this is not the
// proper mapping for a JPopupMenu so fix that.
if ([[self parent] isKindOfClass:[JavaBaseAccessibility class]] &&
[javaRole isEqualToString:@"popupmenu"] &&
if ( [javaRole isEqualToString:@"popupmenu"] &&
![[[self parent] javaRole] isEqualToString:@"combobox"] ) {
fNSRole = NSAccessibilityMenuRole;
}

View File

@@ -5,7 +5,6 @@
#import "ThreadUtilities.h"
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleName, sjc_CAccessibility, "getAccessibleName", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleDescription, sjc_CAccessibility, "getAccessibleDescription", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
static JNF_CLASS_CACHE(sjc_CAccessible, "sun/lwawt/macosx/CAccessible");
static JNF_MEMBER_CACHE(jm_getAccessibleContext, sjc_CAccessible, "getAccessibleContext", "()Ljavax/accessibility/AccessibleContext;");
@@ -51,15 +50,6 @@ static void RaiseMustOverrideException(NSString *method)
return str;
}
- (NSString *)accessibilityHelp {
// RaiseMustOverrideException(@"accessibilityLabel");
JNIEnv *env = [ThreadUtilities getJNIEnv];
jobject axName = JNFCallStaticObjectMethod(env, sjm_getAccessibleDescription, [javaBase accessible], [javaBase component]);
NSString* str = JNFJavaToNSString(env, axName);
(*env)->DeleteLocalRef(env, axName);
return str;
}
- (NSArray *)accessibilityChildren
{
JNIEnv *env = [ThreadUtilities getJNIEnv];
@@ -95,9 +85,8 @@ static void RaiseMustOverrideException(NSString *method)
- (id)accessibilityParent
{
id parent = [self.javaBase parent];
// Checking for protocol compliance can slow down at runtime. See: https://developer.apple.com/documentation/objectivec/nsobject/1418893-conformstoprotocol?language=objc
return [parent respondsToSelector:@selector(platformAxElement)] ? [parent platformAxElement] : parent;
JavaBaseAccessibility *parent = (JavaBaseAccessibility *) [self.javaBase parent];
return parent.platformAxElement;
}
- (BOOL)accessibilityIsIgnored

View File

@@ -4,6 +4,7 @@
#import "JavaListRowAccessibility.h"
#import "JavaAccessibilityAction.h"
#import "JavaAccessibilityUtilities.h"
#import "JavaTextAccessibility.h"
#import "JavaListAccessibility.h"
#import "ThreadUtilities.h"

View File

@@ -1,29 +0,0 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
#import "JavaStaticTextAccessibility.h"
@interface JavaNavigableTextAccessibility : JavaStaticTextAccessibility
// protocol methods
- (NSValue *)accessibleBoundsForRange:(NSRange)range;
- (NSNumber *)accessibleLineForIndex:(NSInteger)index;
- (NSValue *)accessibleRangeForLine:(NSInteger)line;
- (NSString *)accessibleStringForRange:(NSRange)range;
- (NSValue *)accessibleRangeForIndex:(NSInteger)index;
- (NSValue *)accessibleRangeForPosition:(NSPoint)point;
@property(readonly) NSString *accessibleSelectedText;
@property(readonly) NSValue *accessibleSelectedTextRange;
@property(readonly) NSNumber *accessibleNumberOfCharacters;
@property(readonly) NSNumber *accessibleInsertionPointLineNumber;
@property(readonly) BOOL accessibleIsValueSettable;
@property(readonly) BOOL accessibleIsPasswordText;
- (void)accessibleSetSelectedText:(NSString *)accessibilitySelectedText;
- (void)accessibleSetSelectedTextRange:(NSRange)accessibilitySelectedTextRange;
@end
@interface PlatformAxNavigableText : PlatformAxStaticText <NSAccessibilityNavigableStaticText>
@end

View File

@@ -1,267 +0,0 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
#import "JavaNavigableTextAccessibility.h"
#import "JavaAccessibilityUtilities.h"
#import "ThreadUtilities.h"
#import <JavaNativeFoundation/JavaNativeFoundation.h>
static JNF_CLASS_CACHE(sjc_CAccessibleText, "sun/lwawt/macosx/CAccessibleText");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleText, sjc_CAccessibility, "getAccessibleText", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleText;");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleEditableText, sjc_CAccessibleText, "getAccessibleEditableText", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleEditableText;");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleName, sjc_CAccessibility, "getAccessibleName", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
@implementation JavaNavigableTextAccessibility
- (NSString *)getPlatformAxElementClassName {
return @"PlatformAxNavigableText";
}
- (NSString *)accessibleValue {
JNIEnv *env = [ThreadUtilities getJNIEnv];
// cmcnote: inefficient to make three distinct JNI calls. Coalesce. radr://3951923
jobject axText = JNFCallStaticObjectMethod(env, sjm_getAccessibleText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (axText == NULL) return nil;
(*env)->DeleteLocalRef(env, axText);
jobject axEditableText = JNFCallStaticObjectMethod(env, sjm_getAccessibleEditableText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (axEditableText == NULL) return nil;
static JNF_STATIC_MEMBER_CACHE(jm_getTextRange, sjc_CAccessibleText, "getTextRange", "(Ljavax/accessibility/AccessibleEditableText;IILjava/awt/Component;)Ljava/lang/String;");
jobject jrange = JNFCallStaticObjectMethod(env, jm_getTextRange, axEditableText, 0, getAxTextCharCount(env, axEditableText, fComponent), fComponent);
NSString *string = JNFJavaToNSString(env, jrange); // AWT_THREADING Safe (AWTRunLoop)
(*env)->DeleteLocalRef(env, jrange);
(*env)->DeleteLocalRef(env, axEditableText);
if (string == nil) string = @"";
return string;
}
- (NSValue *)accessibleBoundsForRange:(NSRange)range {
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getBoundsForRange, sjc_CAccessibleText, "getBoundsForRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)[D");
jdoubleArray axBounds = (jdoubleArray)JNFCallStaticObjectMethod(env, jm_getBoundsForRange, fAccessible, fComponent, range.location, range.length); // AWT_THREADING Safe (AWTRunLoop)
if (axBounds == NULL) return nil;
// We cheat because we know that the array is 4 elements long (x, y, width, height)
jdouble *values = (*env)->GetDoubleArrayElements(env, axBounds, 0);
if (values == NULL) {
// Note: Java will not be on the stack here so a java exception can't happen and no need to call ExceptionCheck.
NSLog(@"%s failed calling GetDoubleArrayElements", __FUNCTION__);
return nil;
};
NSRect bounds;
bounds.origin.x = values[0];
bounds.origin.y = [[[[self view] window] screen] frame].size.height - values[1] - values[3]; //values[1] is y-coord from top-left of screen. Flip. Account for the height (values[3]) when flipping
bounds.size.width = values[2];
bounds.size.height = values[3];
NSValue *result = [NSValue valueWithRect:bounds];
(*env)->ReleaseDoubleArrayElements(env, axBounds, values, 0);
return result;
}
- (NSNumber *)accessibleLineForIndex:(NSInteger)index {
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getLineNumberForIndex, sjc_CAccessibleText, "getLineNumberForIndex", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;I)I");
jint row = JNFCallStaticIntMethod(env, jm_getLineNumberForIndex, fAccessible, fComponent, index); // AWT_THREADING Safe (AWTRunLoop)
if (row < 0) return nil;
return [NSNumber numberWithInt:row];
}
- (NSValue *)accessibleRangeForLine:(NSInteger)line {
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getRangeForLine, sjc_CAccessibleText, "getRangeForLine", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;I)[I");
jintArray axTextRange = (jintArray)JNFCallStaticObjectMethod(env, jm_getRangeForLine, fAccessible, fComponent, line); // AWT_THREADING Safe (AWTRunLoop)
if (axTextRange == NULL) return nil;
return javaConvertIntArrayToNSRangeValue(env,axTextRange);
}
- (NSString *)accessibleStringForRange:(NSRange)range {
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getStringForRange, sjc_CAccessibleText, "getStringForRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)Ljava/lang/String;");
jstring jstringForRange = (jstring)JNFCallStaticObjectMethod(env, jm_getStringForRange, fAccessible, fComponent, range.location, range.length); // AWT_THREADING Safe (AWTRunLoop)
if (jstringForRange == NULL) return @"";
NSString* str = JNFJavaToNSString(env, jstringForRange);
(*env)->DeleteLocalRef(env, jstringForRange);
return str;
}
- (NSValue *)accessibleRangeForIndex:(NSInteger)index {
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getRangeForIndex, sjc_CAccessibleText, "getRangeForIndex", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;I)[I");
jintArray axTextRange = (jintArray)JNFCallStaticObjectMethod(env, jm_getRangeForIndex, fAccessible, fComponent, index); // AWT_THREADING Safe (AWTRunLoop)
if (axTextRange == NULL) return nil;
return javaConvertIntArrayToNSRangeValue(env, axTextRange);
}
- (NSValue *)accessibleRangeForPosition:(NSPoint)point {
point.y = [[[[self view] window] screen] frame].size.height - point.y; // flip into java screen coords (0 is at upper-left corner of screen)
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getCharacterIndexAtPosition, sjc_CAccessibleText, "getCharacterIndexAtPosition", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)I");
jint charIndex = JNFCallStaticIntMethod(env, jm_getCharacterIndexAtPosition, fAccessible, fComponent, point.x, point.y); // AWT_THREADING Safe (AWTRunLoop)
if (charIndex == -1) return nil;
// AccessibleText.getIndexAtPoint returns -1 for an invalid point
NSRange range = NSMakeRange(charIndex, 1); //range's length is 1 - one-character range
return [NSValue valueWithRange:range];
}
- (NSString *)accessibleSelectedText {
JNIEnv* env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getSelectedText, sjc_CAccessibleText, "getSelectedText", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
jobject axText = JNFCallStaticObjectMethod(env, jm_getSelectedText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (axText == NULL) return @"";
NSString* str = JNFJavaToNSString(env, axText);
(*env)->DeleteLocalRef(env, axText);
return str;
}
- (NSValue *)accessibleSelectedTextRange {
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getSelectedTextRange, sjc_CAccessibleText, "getSelectedTextRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)[I");
jintArray axTextRange = JNFCallStaticObjectMethod(env, jm_getSelectedTextRange, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (axTextRange == NULL) return nil;
return javaConvertIntArrayToNSRangeValue(env, axTextRange);
}
- (NSNumber *)accessibleNumberOfCharacters {
// cmcnote: should coalesce these two calls - radr://3951923
// also, static text doesn't always have accessibleText. if axText is null, should get the charcount of the accessibleName instead
JNIEnv *env = [ThreadUtilities getJNIEnv];
jobject axText = JNFCallStaticObjectMethod(env, sjm_getAccessibleText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
NSNumber* num = [NSNumber numberWithInt:getAxTextCharCount(env, axText, fComponent)];
(*env)->DeleteLocalRef(env, axText);
return num;
}
- (NSNumber *)accessibleInsertionPointLineNumber {
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getLineNumberForInsertionPoint, sjc_CAccessibleText, "getLineNumberForInsertionPoint", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)I");
jint row = JNFCallStaticIntMethod(env, jm_getLineNumberForInsertionPoint, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (row < 0) return nil;
return [NSNumber numberWithInt:row];
}
- (BOOL)accessibleIsValueSettable {
// if text is enabled and editable, it's settable (according to NSCellTextAttributesAccessibility)
BOOL isEnabled = [(NSNumber *)[self accessibilityEnabledAttribute] boolValue];
if (!isEnabled) return NO;
JNIEnv* env = [ThreadUtilities getJNIEnv];
jobject axEditableText = JNFCallStaticObjectMethod(env, sjm_getAccessibleEditableText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (axEditableText == NULL) return NO;
(*env)->DeleteLocalRef(env, axEditableText);
return YES;
}
- (BOOL)accessibleIsPasswordText {
return [[self javaRole] isEqualToString:@"passwordtext"];
}
- (void)accessibleSetSelectedText:(NSString *)accessibilitySelectedText {
JNIEnv *env = [ThreadUtilities getJNIEnv];
jstring jstringValue = JNFNSToJavaString(env, accessibilitySelectedText);
static JNF_STATIC_MEMBER_CACHE(jm_setSelectedText, sjc_CAccessibleText, "setSelectedText", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;Ljava/lang/String;)V");
JNFCallStaticVoidMethod(env, jm_setSelectedText, fAccessible, fComponent, jstringValue); // AWT_THREADING Safe (AWTRunLoop)
}
- (void)accessibleSetSelectedTextRange:(NSRange)accessibilitySelectedTextRange {
jint startIndex = accessibilitySelectedTextRange.location;
jint endIndex = startIndex + accessibilitySelectedTextRange.length;
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_setSelectedTextRange, sjc_CAccessibleText, "setSelectedTextRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)V");
JNFCallStaticVoidMethod(env, jm_setSelectedTextRange, fAccessible, fComponent, startIndex, endIndex); // AWT_THREADING Safe (AWTRunLoop)
}
@end
@implementation PlatformAxNavigableText
- (NSRect)accessibilityFrameForRange:(NSRange)range {
return [[(JavaNavigableTextAccessibility *)[self javaBase] accessibleBoundsForRange:range] rectValue];
}
- (NSInteger)accessibilityLineForIndex:(NSInteger)index {
return [[(JavaNavigableTextAccessibility *)[self javaBase] accessibleLineForIndex:index] integerValue];
}
- (NSRange)accessibilityRangeForLine:(NSInteger)line {
return [[(JavaNavigableTextAccessibility *)[self javaBase] accessibleRangeForLine:line] rangeValue];
}
- (NSString *)accessibilityStringForRange:(NSRange)range {
return [(JavaNavigableTextAccessibility *)[self javaBase] accessibleStringForRange:range];
}
- (id)accessibilityValue {
return [(JavaNavigableTextAccessibility *)[self javaBase] accessibleValue];
}
- (NSAccessibilitySubrole)accessibilitySubrole {
if ([(JavaNavigableTextAccessibility *)[self javaBase] accessibleIsPasswordText]) {
return NSAccessibilitySecureTextFieldSubrole;
}
return nil;
}
- (NSRange)accessibilityRangeForIndex:(NSInteger)index {
return [[(JavaNavigableTextAccessibility *)[self javaBase] accessibleRangeForIndex:index] rangeValue];
}
- (NSAccessibilityRole)accessibilityRole {
return [sRoles objectForKey:[self javaBase].javaRole];
}
- (NSRange)accessibilityRangeForPosition:(NSPoint)point {
return [[(JavaNavigableTextAccessibility *)[self javaBase] accessibleRangeForPosition:point] rangeValue];
}
- (NSString *)accessibilitySelectedText {
return [(JavaNavigableTextAccessibility *)[self javaBase] accessibleSelectedText];
}
- (NSRange)accessibilitySelectedTextRange {
return [[(JavaNavigableTextAccessibility *)[self javaBase] accessibleSelectedTextRange] rangeValue];
}
- (NSInteger)accessibilityNumberOfCharacters {
return [[(JavaNavigableTextAccessibility *)[self javaBase] accessibleNumberOfCharacters] integerValue];
}
- (NSInteger)accessibilityInsertionPointLineNumber {
return [[(JavaNavigableTextAccessibility *)[self javaBase] accessibleInsertionPointLineNumber] integerValue];
}
- (void)setAccessibilitySelectedText:(NSString *)accessibilitySelectedText {
[(JavaNavigableTextAccessibility *)[self javaBase] accessibleSetSelectedText:accessibilitySelectedText];
}
- (void)setAccessibilitySelectedTextRange:(NSRange)accessibilitySelectedTextRange {
[(JavaNavigableTextAccessibility *)[self javaBase] accessibleSetSelectedTextRange:accessibilitySelectedTextRange];
}
- (BOOL)isAccessibilityEdited {
return YES;
}
- (BOOL)isAccessibilityEnabled {
return YES;
}
/*
* Other text methods
- (NSRange)accessibilitySharedCharacterRange;
- (NSArray *)accessibilitySharedTextUIElements;
- (NSData *)accessibilityRTFForRange:(NSRange)range;
- (NSRange)accessibilityStyleRangeForIndex:(NSInteger)index;
*/
@end

View File

@@ -1,19 +0,0 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
#import "JavaElementAccessibility.h"
@interface JavaStaticTextAccessibility : JavaElementAccessibility
/*
* Converts an int array to an NSRange wrapped inside an NSValue
* takes [start, end] values and returns [start, end - start]
*/
NSValue *javaConvertIntArrayToNSRangeValue(JNIEnv* env, jintArray array);
@property(readonly) NSString *accessibleValue;
@property(readonly) NSValue *accessibleVisibleCharacterRange;
@end
@interface PlatformAxStaticText : PlatformAxElement <NSAccessibilityStaticText>
@end

View File

@@ -1,72 +0,0 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
#import "JavaStaticTextAccessibility.h"
#import "JavaAccessibilityUtilities.h"
#import "ThreadUtilities.h"
#import <JavaNativeFoundation/JavaNativeFoundation.h>
static JNF_CLASS_CACHE(sjc_CAccessibleText, "sun/lwawt/macosx/CAccessibleText");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleText, sjc_CAccessibility, "getAccessibleText", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleText;");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleEditableText, sjc_CAccessibleText, "getAccessibleEditableText", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleEditableText;");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleName, sjc_CAccessibility, "getAccessibleName", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
@implementation JavaStaticTextAccessibility
- (NSString *)getPlatformAxElementClassName {
return @"PlatformAxStaticText";
}
- (NSString *)accessibleValue {
JNIEnv *env = [ThreadUtilities getJNIEnv];
jobject axName = JNFCallStaticObjectMethod(env, sjm_getAccessibleName, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (axName != NULL) {
NSString* str = JNFJavaToNSString(env, axName);
(*env)->DeleteLocalRef(env, axName);
return str;
}
return @"";
}
- (NSValue *)accessibleVisibleCharacterRange {
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getVisibleCharacterRange, sjc_CAccessibleText, "getVisibleCharacterRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)[I");
jintArray axTextRange = JNFCallStaticObjectMethod(env, jm_getVisibleCharacterRange, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (axTextRange == NULL) return nil;
return javaConvertIntArrayToNSRangeValue(env, axTextRange);
}
@end
@implementation PlatformAxStaticText
- (id)accessibilityValue {
return [(JavaStaticTextAccessibility *)[self javaBase] accessibleValue];
}
- (NSRect)accessibilityFrame {
return [super accessibilityFrame];
}
- (id)accessibilityParent {
return [super accessibilityParent];
}
- (NSRange)accessibilityVisibleCharacterRange {
return [[(JavaStaticTextAccessibility *)[self javaBase] accessibleVisibleCharacterRange] rangeValue];
}
@end
NSValue *javaConvertIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
jint *values = (*env)->GetIntArrayElements(env, array, 0);
if (values == NULL) {
// Note: Java will not be on the stack here so a java exception can't happen and no need to call ExceptionCheck.
NSLog(@"%s failed calling GetIntArrayElements", __FUNCTION__);
return nil;
};
NSValue *value = [NSValue valueWithRange:NSMakeRange(values[0], values[1] - values[0])];
(*env)->ReleaseIntArrayElements(env, array, values, 0);
return value;
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#import "JavaComponentAccessibility.h"
#import <AppKit/NSAccessibility.h>
@interface JavaTextAccessibility : JavaComponentAccessibility {
}
// attributes
- (NSArray *)initializeAttributeNamesWithEnv:(JNIEnv *)env;
- (NSString *)accessibilityValueAttribute;
- (BOOL)accessibilityIsValueAttributeSettable;
- (void)accessibilitySetValueAttribute:(id)value;
- (NSString *)accessibilitySelectedTextAttribute;
- (BOOL)accessibilityIsSelectedTextAttributeSettable;
- (NSValue *)accessibilitySelectedTextRangeAttribute;
- (BOOL)accessibilityIsSelectedTextRangeAttributeSettable;
- (NSNumber *)accessibilityNumberOfCharactersAttribute;
- (BOOL)accessibilityIsNumberOfCharactersAttributeSettable;
- (NSValue *)accessibilityVisibleCharacterRangeAttribute;
- (BOOL)accessibilityIsVisibleCharacterRangeAttributeSettable;
- (NSValue *)accessibilityInsertionPointLineNumberAttribute;
- (BOOL)accessibilityIsInsertionPointLineNumberAttributeSettable;
- (void)accessibilitySetSelectedTextAttribute:(id)value;
- (NSValue *)accessibilitySelectedTextRangeAttribute;
- (NSValue *)accessibilityInsertionPointLineNumberAttribute;
- (BOOL)accessibilityIsInsertionPointLineNumberAttributeSettable;
// parameterized attributes
- (NSArray *)accessibilityParameterizedAttributeNames;
- (NSValue *)accessibilityBoundsForRangeAttributeForParameter:(id)parameter;
- (NSNumber *)accessibilityLineForIndexAttributeForParameter:(id)parameter;
- (NSValue *)accessibilityRangeForLineAttributeForParameter:(id)parameter;
- (NSString *)accessibilityStringForRangeAttributeForParameter:(id)parameter;
- (NSValue *)accessibilityRangeForPositionAttributeForParameter:(id)parameter;
- (NSValue *)accessibilityRangeForIndexAttributeForParameter:(id)parameter;
@end

View File

@@ -0,0 +1,441 @@
/*
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#import "JavaTextAccessibility.h"
#import "JavaAccessibilityAction.h"
#import "JavaAccessibilityUtilities.h"
#import "ThreadUtilities.h"
static JNF_CLASS_CACHE(sjc_CAccessibleText, "sun/lwawt/macosx/CAccessibleText");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleText, sjc_CAccessibility, "getAccessibleText", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleText;");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleEditableText, sjc_CAccessibleText, "getAccessibleEditableText", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleEditableText;");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleName, sjc_CAccessibility, "getAccessibleName", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
/*
* Converts an int array to an NSRange wrapped inside an NSValue
* takes [start, end] values and returns [start, end - start]
*/
NSValue *javaIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
jint *values = (*env)->GetIntArrayElements(env, array, 0);
if (values == NULL) {
// Note: Java will not be on the stack here so a java exception can't happen and no need to call ExceptionCheck.
NSLog(@"%s failed calling GetIntArrayElements", __FUNCTION__);
return nil;
};
NSValue *value = [NSValue valueWithRange:NSMakeRange(values[0], values[1] - values[0])];
(*env)->ReleaseIntArrayElements(env, array, values, 0);
return value;
}
@implementation JavaTextAccessibility
// based strongly upon NSTextViewAccessibility:accessibilityAttributeNames
- (NSArray *)initializeAttributeNamesWithEnv:(JNIEnv *)env
{
static NSArray *attributes = nil;
if (attributes == nil) {
//APPKIT_LOCK;
if (attributes == nil) {
NSMutableArray *temp = [[super initializeAttributeNamesWithEnv:env] mutableCopy];
//[temp removeObject:NSAccessibilityTitleAttribute]; // title may have been set in the superclass implementation - some static text reports from java that it has a name
[temp addObjectsFromArray:[NSArray arrayWithObjects:
NSAccessibilityValueAttribute,
NSAccessibilitySelectedTextAttribute,
NSAccessibilitySelectedTextRangeAttribute,
NSAccessibilityNumberOfCharactersAttribute,
NSAccessibilityVisibleCharacterRangeAttribute,
NSAccessibilityInsertionPointLineNumberAttribute,
// NSAccessibilitySharedTextUIElementsAttribute, // cmcnote: investigate what these two are for. currently unimplemented
// NSAccessibilitySharedCharacterRangeAttribute,
nil]];
attributes = [[NSArray alloc] initWithArray:temp];
[temp release];
}
//APPKIT_UNLOCK;
}
return attributes;
}
// copied from NSTextViewAccessibility.
- (NSArray *)accessibilityParameterizedAttributeNames
{
static NSArray *attributes = nil;
if (attributes == nil) {
//APPKIT_LOCK;
if (attributes == nil) {
attributes = [[NSArray alloc] initWithObjects:
NSAccessibilityLineForIndexParameterizedAttribute,
NSAccessibilityRangeForLineParameterizedAttribute,
NSAccessibilityStringForRangeParameterizedAttribute,
NSAccessibilityRangeForPositionParameterizedAttribute,
NSAccessibilityRangeForIndexParameterizedAttribute,
NSAccessibilityBoundsForRangeParameterizedAttribute,
//NSAccessibilityRTFForRangeParameterizedAttribute, // cmcnote: not sure when/how these three are used. Investigate. radr://3960026
//NSAccessibilityStyleRangeForIndexParameterizedAttribute,
//NSAccessibilityAttributedStringForRangeParameterizedAttribute,
nil];
}
//APPKIT_UNLOCK;
}
return attributes;
}
- (NSString *)accessibilityValueAttribute
{
JNIEnv *env = [ThreadUtilities getJNIEnv];
if ([[self accessibilityRoleAttribute] isEqualToString:NSAccessibilityStaticTextRole]) {
// if it's static text, the AppKit AXValue is the java accessibleName
jobject axName = JNFCallStaticObjectMethod(env, sjm_getAccessibleName, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (axName != NULL) {
NSString* str = JNFJavaToNSString(env, axName);
(*env)->DeleteLocalRef(env, axName);
return str;
}
// value is still nil if no accessibleName for static text. Below, try to get the accessibleText.
}
// cmcnote: inefficient to make three distinct JNI calls. Coalesce. radr://3951923
jobject axText = JNFCallStaticObjectMethod(env, sjm_getAccessibleText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (axText == NULL) return nil;
(*env)->DeleteLocalRef(env, axText);
jobject axEditableText = JNFCallStaticObjectMethod(env, sjm_getAccessibleEditableText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (axEditableText == NULL) return nil;
static JNF_STATIC_MEMBER_CACHE(jm_getTextRange, sjc_CAccessibleText, "getTextRange", "(Ljavax/accessibility/AccessibleEditableText;IILjava/awt/Component;)Ljava/lang/String;");
jobject jrange = JNFCallStaticObjectMethod(env, jm_getTextRange, axEditableText, 0, getAxTextCharCount(env, axEditableText, fComponent), fComponent);
NSString *string = JNFJavaToNSString(env, jrange); // AWT_THREADING Safe (AWTRunLoop)
(*env)->DeleteLocalRef(env, jrange);
(*env)->DeleteLocalRef(env, axEditableText);
if (string == nil) string = @"";
return string;
}
- (BOOL)accessibilityIsValueAttributeSettable
{
// if text is enabled and editable, it's settable (according to NSCellTextAttributesAccessibility)
BOOL isEnabled = [(NSNumber *)[self accessibilityEnabledAttribute] boolValue];
if (!isEnabled) return NO;
JNIEnv* env = [ThreadUtilities getJNIEnv];
jobject axEditableText = JNFCallStaticObjectMethod(env, sjm_getAccessibleEditableText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (axEditableText == NULL) return NO;
(*env)->DeleteLocalRef(env, axEditableText);
return YES;
}
- (void)accessibilitySetValueAttribute:(id)value
{
// cmcnote: should set the accessibleEditableText to the stringValue of value - AccessibleEditableText.setTextContents(String s)
#ifdef JAVA_AX_DEBUG
NSLog(@"Not yet implemented: %s\n", __FUNCTION__); // radr://3954018
#endif
}
// Currently selected text (NSString)
- (NSString *)accessibilitySelectedTextAttribute
{
JNIEnv* env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getSelectedText, sjc_CAccessibleText, "getSelectedText", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
jobject axText = JNFCallStaticObjectMethod(env, jm_getSelectedText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (axText == NULL) return @"";
NSString* str = JNFJavaToNSString(env, axText);
(*env)->DeleteLocalRef(env, axText);
return str;
}
- (BOOL)accessibilityIsSelectedTextAttributeSettable
{
return YES; //cmcnote: for AXTextField that's selectable, it's settable. Investigate further.
}
- (void)accessibilitySetSelectedTextAttribute:(id)value
{
#ifdef JAVA_AX_DEBUG_PARMS
if (![value isKindOfClass:[NSString class]]) {
JavaAccessibilityRaiseSetAttributeToIllegalTypeException(__FUNCTION__, self, NSAccessibilitySelectedTextAttribute, value);
return;
}
#endif
JNIEnv *env = [ThreadUtilities getJNIEnv];
jstring jstringValue = JNFNSToJavaString(env, (NSString *)value);
static JNF_STATIC_MEMBER_CACHE(jm_setSelectedText, sjc_CAccessibleText, "setSelectedText", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;Ljava/lang/String;)V");
JNFCallStaticVoidMethod(env, jm_setSelectedText, fAccessible, fComponent, jstringValue); // AWT_THREADING Safe (AWTRunLoop)
}
// Range of selected text (NSValue)
- (NSValue *)accessibilitySelectedTextRangeAttribute
{
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getSelectedTextRange, sjc_CAccessibleText, "getSelectedTextRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)[I");
jintArray axTextRange = JNFCallStaticObjectMethod(env, jm_getSelectedTextRange, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (axTextRange == NULL) return nil;
return javaIntArrayToNSRangeValue(env, axTextRange);
}
- (BOOL)accessibilityIsSelectedTextRangeAttributeSettable
{
return [(NSNumber *)[self accessibilityEnabledAttribute] boolValue]; // cmcnote: also may want to find out if isSelectable. Investigate.
}
- (void)accessibilitySetSelectedTextRangeAttribute:(id)value
{
#ifdef JAVA_AX_DEBUG_PARMS
if (!([value isKindOfClass:[NSValue class]] && strcmp([(NSValue *)value objCType], @encode(NSRange)) == 0)) {
JavaAccessibilityRaiseSetAttributeToIllegalTypeException(__FUNCTION__, self, NSAccessibilitySelectedTextRangeAttribute, value);
return;
}
#endif
NSRange range = [(NSValue *)value rangeValue];
jint startIndex = range.location;
jint endIndex = startIndex + range.length;
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_setSelectedTextRange, sjc_CAccessibleText, "setSelectedTextRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)V");
JNFCallStaticVoidMethod(env, jm_setSelectedTextRange, fAccessible, fComponent, startIndex, endIndex); // AWT_THREADING Safe (AWTRunLoop)
}
- (NSNumber *)accessibilityNumberOfCharactersAttribute
{
// cmcnote: should coalesce these two calls - radr://3951923
// also, static text doesn't always have accessibleText. if axText is null, should get the charcount of the accessibleName instead
JNIEnv *env = [ThreadUtilities getJNIEnv];
jobject axText = JNFCallStaticObjectMethod(env, sjm_getAccessibleText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
NSNumber* num = [NSNumber numberWithInt:getAxTextCharCount(env, axText, fComponent)];
(*env)->DeleteLocalRef(env, axText);
return num;
}
- (BOOL)accessibilityIsNumberOfCharactersAttributeSettable
{
return NO; // according to NSTextViewAccessibility.m and NSCellTextAttributesAccessibility.m
}
- (NSValue *)accessibilityVisibleCharacterRangeAttribute
{
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getVisibleCharacterRange, sjc_CAccessibleText, "getVisibleCharacterRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)[I");
jintArray axTextRange = JNFCallStaticObjectMethod(env, jm_getVisibleCharacterRange, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (axTextRange == NULL) return nil;
return javaIntArrayToNSRangeValue(env, axTextRange);
}
- (BOOL)accessibilityIsVisibleCharacterRangeAttributeSettable
{
#ifdef JAVA_AX_DEBUG
NSLog(@"Not yet implemented: %s\n", __FUNCTION__);
#endif
return NO;
}
- (NSValue *)accessibilityInsertionPointLineNumberAttribute
{
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getLineNumberForInsertionPoint, sjc_CAccessibleText, "getLineNumberForInsertionPoint", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)I");
jint row = JNFCallStaticIntMethod(env, jm_getLineNumberForInsertionPoint, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (row < 0) return nil;
return [NSNumber numberWithInt:row];
}
- (BOOL)accessibilityIsInsertionPointLineNumberAttributeSettable
{
#ifdef JAVA_AX_DEBUG
NSLog(@"Not yet implemented: %s\n", __FUNCTION__);
#endif
return NO;
}
// parameterized attributes
//
// Usage of accessibilityBoundsForRangeAttributeForParameter:
// ---
// called by VoiceOver when interacting with text via ctrl-option-shift-downArrow.
// Need to know bounding box for the character / word / line of interest in
// order to draw VoiceOver cursor
//
- (NSValue *)accessibilityBoundsForRangeAttributeForParameter:(id)parameter
{
#ifdef JAVA_AX_DEBUG_PARMS
if (!([parameter isKindOfClass:[NSValue class]] && strcmp([(NSValue *)parameter objCType], @encode(NSRange)) == 0)) {
JavaAccessibilityRaiseIllegalParameterTypeException(__FUNCTION__, self, NSAccessibilityBoundsForRangeParameterizedAttribute, parameter);
return nil;
}
#endif
NSRange range = [(NSValue *)parameter rangeValue];
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getBoundsForRange, sjc_CAccessibleText, "getBoundsForRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)[D");
jdoubleArray axBounds = (jdoubleArray)JNFCallStaticObjectMethod(env, jm_getBoundsForRange, fAccessible, fComponent, range.location, range.length); // AWT_THREADING Safe (AWTRunLoop)
if (axBounds == NULL) return nil;
// We cheat because we know that the array is 4 elements long (x, y, width, height)
jdouble *values = (*env)->GetDoubleArrayElements(env, axBounds, 0);
if (values == NULL) {
// Note: Java will not be on the stack here so a java exception can't happen and no need to call ExceptionCheck.
NSLog(@"%s failed calling GetDoubleArrayElements", __FUNCTION__);
return nil;
};
NSRect bounds;
bounds.origin.x = values[0];
bounds.origin.y = [[[[self view] window] screen] frame].size.height - values[1] - values[3]; //values[1] is y-coord from top-left of screen. Flip. Account for the height (values[3]) when flipping
bounds.size.width = values[2];
bounds.size.height = values[3];
NSValue *result = [NSValue valueWithRect:bounds];
(*env)->ReleaseDoubleArrayElements(env, axBounds, values, 0);
return result;
}
- (NSNumber *)accessibilityLineForIndexAttributeForParameter:(id)parameter
{
NSNumber *line = (NSNumber *) parameter;
if (line == nil) return nil;
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getLineNumberForIndex, sjc_CAccessibleText, "getLineNumberForIndex", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;I)I");
jint row = JNFCallStaticIntMethod(env, jm_getLineNumberForIndex, fAccessible, fComponent, [line intValue]); // AWT_THREADING Safe (AWTRunLoop)
if (row < 0) return nil;
return [NSNumber numberWithInt:row];
}
- (NSValue *)accessibilityRangeForLineAttributeForParameter:(id)parameter
{
NSNumber *line = (NSNumber *) parameter;
if (line == nil) return nil;
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getRangeForLine, sjc_CAccessibleText, "getRangeForLine", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;I)[I");
jintArray axTextRange = (jintArray)JNFCallStaticObjectMethod(env, jm_getRangeForLine, fAccessible, fComponent, [line intValue]); // AWT_THREADING Safe (AWTRunLoop)
if (axTextRange == NULL) return nil;
return javaIntArrayToNSRangeValue(env,axTextRange);
}
//
// Usage of accessibilityStringForRangeAttributeForParameter:
// ---
// called by VoiceOver when interacting with text via ctrl-option-shift-downArrow.
// VO needs to know the particular string its currently dealing with so it can
// speak the string
//
- (NSString *)accessibilityStringForRangeAttributeForParameter:(id)parameter
{
#ifdef JAVA_AX_DEBUG_PARMS
if (!([parameter isKindOfClass:[NSValue class]] && strcmp([(NSValue *)parameter objCType], @encode(NSRange)) == 0)) {
JavaAccessibilityRaiseIllegalParameterTypeException(__FUNCTION__, self, NSAccessibilityBoundsForRangeParameterizedAttribute, parameter);
return nil;
}
#endif
NSRange range = [(NSValue *)parameter rangeValue];
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getStringForRange, sjc_CAccessibleText, "getStringForRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)Ljava/lang/String;");
jstring jstringForRange = (jstring)JNFCallStaticObjectMethod(env, jm_getStringForRange, fAccessible, fComponent, range.location, range.length); // AWT_THREADING Safe (AWTRunLoop)
if (jstringForRange == NULL) return @"";
NSString* str = JNFJavaToNSString(env, jstringForRange);
(*env)->DeleteLocalRef(env, jstringForRange);
return str;
}
//
// Usage of accessibilityRangeForPositionAttributeForParameter:
// ---
// cmcnote: I'm not sure when this is called / how it's used. Investigate.
// probably could be used in a special text-only accessibilityHitTest to
// find the index of the string under the mouse?
//
- (NSValue *)accessibilityRangeForPositionAttributeForParameter:(id)parameter
{
#ifdef JAVA_AX_DEBUG_PARMS
if (!([parameter isKindOfClass:[NSValue class]] && strcmp([(NSValue *)parameter objCType], @encode(NSPoint)) == 0)) {
JavaAccessibilityRaiseIllegalParameterTypeException(__FUNCTION__, self, NSAccessibilityRangeForPositionParameterizedAttribute, parameter);
return nil;
}
#endif
NSPoint point = [(NSValue *)parameter pointValue]; // point is in screen coords
point.y = [[[[self view] window] screen] frame].size.height - point.y; // flip into java screen coords (0 is at upper-left corner of screen)
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getCharacterIndexAtPosition, sjc_CAccessibleText, "getCharacterIndexAtPosition", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)I");
jint charIndex = JNFCallStaticIntMethod(env, jm_getCharacterIndexAtPosition, fAccessible, fComponent, point.x, point.y); // AWT_THREADING Safe (AWTRunLoop)
if (charIndex == -1) return nil;
// AccessibleText.getIndexAtPoint returns -1 for an invalid point
NSRange range = NSMakeRange(charIndex, 1); //range's length is 1 - one-character range
return [NSValue valueWithRange:range];
}
//
// Usage of accessibilityRangeForIndexAttributeForParameter:
// ---
// cmcnote: I'm not sure when this is called / how it's used. Investigate.
// AppKit version calls: [string rangeOfComposedCharacterSequenceAtIndex:index]
// We call: CAccessibility.getRangeForIndex, which calls AccessibleText.getAtIndex(AccessibleText.WORD, index)
// to determine the word closest to the given index. Then we find the length/location of this string.
//
- (NSValue *)accessibilityRangeForIndexAttributeForParameter:(id)parameter
{
#ifdef JAVA_AX_DEBUG_PARMS
if (![parameter isKindOfClass:[NSNumber class]]) {
JavaAccessibilityRaiseIllegalParameterTypeException(__FUNCTION__, self, NSAccessibilityRangeForIndexParameterizedAttribute, parameter);
return nil;
}
#endif
NSUInteger index = [(NSNumber *)parameter unsignedIntegerValue];
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getRangeForIndex, sjc_CAccessibleText, "getRangeForIndex", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;I)[I");
jintArray axTextRange = (jintArray)JNFCallStaticObjectMethod(env, jm_getRangeForIndex, fAccessible, fComponent, index); // AWT_THREADING Safe (AWTRunLoop)
if (axTextRange == NULL) return nil;
return javaIntArrayToNSRangeValue(env, axTextRange);
}
/*
* - (NSDictionary *)getActions:(JNIEnv *)env { ... }
*
* In the future, possibly add support: Editable text has AXShowMenu.
* Textfields have AXConfirm.
*
* Note: JLabels (static text) in JLists have a press/click selection action
* which is currently handled in superclass JavaComponentAccessibility.
* If function is added here be sure to use [super getActions:env] for JLabels.
*/
@end

View File

@@ -35,8 +35,6 @@
JRSFontRenderingStyle fStyle;
jint fAAStyle;
jint fFmHint;
jint fSubpixelResolutionX;
jint fSubpixelResolutionY;
CGAffineTransform fTx;
CGAffineTransform fDevTx;
@@ -44,13 +42,6 @@
CGAffineTransform fFontTx;
}
+ (AWTStrike *) awtStrikeForFont:(AWTFont *)awtFont
tx:(CGAffineTransform)tx
invDevTx:(CGAffineTransform)invDevTx
style:(JRSFontRenderingStyle)style
aaStyle:(jint)aaStyle
fmHint:(jint)fmHint
subpixelResolutionX:(jint)subpixelResolutionX
subpixelResolutionY:(jint)subpixelResolutionY;
+ (AWTStrike *) awtStrikeForFont:(AWTFont *)awtFont tx:(CGAffineTransform)tx invDevTx:(CGAffineTransform)invDevTx style:(JRSFontRenderingStyle)style aaStyle:(jint)aaStyle fmHint:(jint)fmHint;
@end

View File

@@ -42,9 +42,7 @@ static CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 };
invDevTx:(CGAffineTransform)invDevTx
style:(JRSFontRenderingStyle)style
aaStyle:(jint)aaStyle
fmHint:(jint)fmHint
subpixelResolutionX:(jint)subpixelResolutionX
subpixelResolutionY:(jint)subpixelResolutionY {
fmHint:(jint)fmHint {
self = [super init];
if (self) {
@@ -52,8 +50,6 @@ subpixelResolutionY:(jint)subpixelResolutionY {
fStyle = style;
fAAStyle = aaStyle;
fFmHint = fmHint;
fSubpixelResolutionX = subpixelResolutionX;
fSubpixelResolutionY = subpixelResolutionY;
fTx = tx; // composited glyph and device transform
@@ -84,17 +80,13 @@ subpixelResolutionY:(jint)subpixelResolutionY {
invDevTx:(CGAffineTransform)invDevTx
style:(JRSFontRenderingStyle)style
aaStyle:(jint)aaStyle
fmHint:(jint)fmHint
subpixelResolutionX:(jint)subpixelResolutionX
subpixelResolutionY:(jint)subpixelResolutionY {
fmHint:(jint)fmHint {
return [[[AWTStrike alloc] initWithFont:awtFont
tx:tx invDevTx:invDevTx
style:style
aaStyle:aaStyle
fmHint:fmHint
subpixelResolutionX:subpixelResolutionX
subpixelResolutionY:subpixelResolutionY] autorelease];
fmHint:fmHint] autorelease];
}
@end
@@ -413,8 +405,7 @@ JNF_COCOA_EXIT(env);
* Signature: (J[D[DII)J
*/
JNIEXPORT jlong JNICALL Java_sun_font_CStrike_createNativeStrikePtr
(JNIEnv *env, jclass clazz, jlong nativeFontPtr, jdoubleArray glyphTxArray, jdoubleArray invDevTxArray,
jint aaStyle, jint fmHint, jint subpixelResolutionX, jint subpixelResolutionY)
(JNIEnv *env, jclass clazz, jlong nativeFontPtr, jdoubleArray glyphTxArray, jdoubleArray invDevTxArray, jint aaStyle, jint fmHint)
{
AWTStrike *awtStrike = nil;
JNF_COCOA_ENTER(env);
@@ -425,8 +416,7 @@ JNF_COCOA_ENTER(env);
CGAffineTransform glyphTx = GetTxFromDoubles(env, glyphTxArray);
CGAffineTransform invDevTx = GetTxFromDoubles(env, invDevTxArray);
awtStrike = [AWTStrike awtStrikeForFont:awtFont tx:glyphTx invDevTx:invDevTx style:style
aaStyle:aaStyle fmHint:fmHint subpixelResolutionX:subpixelResolutionX subpixelResolutionY:subpixelResolutionY]; // autoreleased
awtStrike = [AWTStrike awtStrikeForFont:awtFont tx:glyphTx invDevTx:invDevTx style:style aaStyle:aaStyle fmHint:fmHint]; // autoreleased
if (awtStrike)
{

View File

@@ -285,64 +285,6 @@ CGGI_ConvertBWPixelToByteGray(UInt32 p)
return 0xFF - (((p >> 24 & 0xFF) + (p >> 16 & 0xFF) + (p >> 8 & 0xFF)) / 3);
}
static void
CGGI_CopySubpixelImageFromCanvasToAlphaInfo(const UInt32* srcImage, int srcRowWidth,
UInt8* dstImage,
int dstWidth, int dstHeight,
int subpixelResolutionX,
int subpixelResolutionY,
short *tempBuffer)
{
int srcWidth = dstWidth * subpixelResolutionX;
int srcHeight = dstHeight * subpixelResolutionY;
int imageSize = dstWidth * dstHeight;
int xGlyph, yGlyph, x, y;
// For each subpixel offset by x axis
for (xGlyph = 0; xGlyph < subpixelResolutionX; xGlyph++) {
// Sum values by x axis and store into temporary buffer
for (y = 0; y < srcHeight; y++) {
for (x = 0; x < dstWidth; x++) {
int value = 0;
int xFrom = x * subpixelResolutionX - xGlyph,
xTo = xFrom + subpixelResolutionX;
if (xFrom < 0) xFrom = 0;
if (xTo > srcWidth) xTo = srcWidth;
int i;
for (i = xFrom; i < xTo; i++) {
value += CGGI_ConvertBWPixelToByteGray(
srcImage[y * srcRowWidth + i]);
}
tempBuffer[y * dstWidth + x] = (short) value;
}
}
// For each subpixel offset by y axis
for (yGlyph = 0; yGlyph < subpixelResolutionY; yGlyph++) {
UInt8 *dst = dstImage +
imageSize * (xGlyph + yGlyph * subpixelResolutionX);
// Sum values by y axis and store average into destination image
for (y = 0; y < dstHeight; y++) {
for (x = 0; x < dstWidth; x++) {
int value = 0;
int yFrom = y * subpixelResolutionY - yGlyph,
yTo = yFrom + subpixelResolutionY;
if (yFrom < 0) yFrom = 0;
if (yTo > srcHeight) yTo = srcHeight;
int j;
for (j = yFrom; j < yTo; j++) {
value += tempBuffer[j * dstWidth + x];
}
dst[y * dstWidth + x] =
value / subpixelResolutionX / subpixelResolutionY;
}
}
}
}
}
/* Size (in pixels) of stack-allocated temporary buffer for glyph downscaling.
* If glyph is too big and requires more memory, it will use malloc. */
#define SUBPIXEL_DOWNSCALE_STATIC_BUFFER_SIZE 2048
static void
CGGI_CopyImageFromCanvasToAlphaInfo(CGGI_GlyphCanvas *canvas, GlyphInfo *info)
{
@@ -354,35 +296,16 @@ CGGI_CopyImageFromCanvasToAlphaInfo(CGGI_GlyphCanvas *canvas, GlyphInfo *info)
size_t height = info->height;
if (info->subpixelResolutionX > 1 || info->subpixelResolutionY > 1) {
int bufferSize = destRowWidth * height * info->subpixelResolutionY;
if (bufferSize <= SUBPIXEL_DOWNSCALE_STATIC_BUFFER_SIZE) {
short staticBuffer[bufferSize];
CGGI_CopySubpixelImageFromCanvasToAlphaInfo(
src, srcRowWidth,
dest, destRowWidth, height,
info->subpixelResolutionX, info->subpixelResolutionY,
staticBuffer);
} else {
short *buffer = malloc(sizeof(short) * bufferSize);
CGGI_CopySubpixelImageFromCanvasToAlphaInfo(
src, srcRowWidth,
dest, destRowWidth, height,
info->subpixelResolutionX, info->subpixelResolutionY,
buffer);
free(buffer);
}
} else {
size_t y;
// fill empty glyph image with black-on-white glyph
for (y = 0; y < height; y++) {
size_t destRow = y * destRowWidth;
size_t srcRow = y * srcRowWidth;
size_t x;
for (x = 0; x < destRowWidth; x++) {
UInt32 p = src[srcRow + x];
dest[destRow + x] = CGGI_ConvertBWPixelToByteGray(p);
}
size_t y;
// fill empty glyph image with black-on-white glyph
for (y = 0; y < height; y++) {
size_t destRow = y * destRowWidth;
size_t srcRow = y * srcRowWidth;
size_t x;
for (x = 0; x < destRowWidth; x++) {
UInt32 p = src[srcRow + x];
dest[destRow + x] = CGGI_ConvertBWPixelToByteGray(p);
}
}
}
@@ -430,10 +353,8 @@ typedef struct CGGI_GlyphInfoDescriptor {
} CGGI_GlyphInfoDescriptor;
typedef struct CGGI_RenderingMode {
CGGI_GlyphInfoDescriptor *mainFontDescriptor;
CGGI_GlyphInfoDescriptor *glyphDescriptor;
JRSFontRenderingStyle cgFontMode;
bool lcdRendering;
bool subpixelResolution;
} CGGI_RenderingMode;
static CGGI_GlyphInfoDescriptor grey =
@@ -458,7 +379,7 @@ static inline CGGI_GlyphInfoDescriptor*
CGGI_GetGlyphInfoDescriptor(const CGGI_RenderingMode *mode, CGFontRef font)
{
bool isFixedColor = CGGI_IsColorFont(font);
return isFixedColor ? &argb : mode->mainFontDescriptor;
return isFixedColor ? &argb : mode->glyphDescriptor;
}
static inline CGGI_RenderingMode
@@ -468,26 +389,16 @@ CGGI_GetRenderingMode(const AWTStrike *strike)
mode.cgFontMode = strike->fStyle;
NSException *e = nil;
#ifdef USE_IMAGE_ALIGNED_MEMORY
mode.subpixelResolution = false;
#else
mode.subpixelResolution = strike->fAAStyle == sun_awt_SunHints_INTVAL_TEXT_ANTIALIAS_ON &&
strike->fFmHint == sun_awt_SunHints_INTVAL_FRACTIONALMETRICS_ON &&
(strike->fSubpixelResolutionX > 1 || strike->fSubpixelResolutionY > 1);
#endif
switch (strike->fAAStyle) {
case sun_awt_SunHints_INTVAL_TEXT_ANTIALIAS_OFF:
case sun_awt_SunHints_INTVAL_TEXT_ANTIALIAS_ON:
mode.lcdRendering = false;
mode.mainFontDescriptor = &grey;
mode.glyphDescriptor = &grey;
break;
case sun_awt_SunHints_INTVAL_TEXT_ANTIALIAS_LCD_HRGB:
case sun_awt_SunHints_INTVAL_TEXT_ANTIALIAS_LCD_HBGR:
case sun_awt_SunHints_INTVAL_TEXT_ANTIALIAS_LCD_VRGB:
case sun_awt_SunHints_INTVAL_TEXT_ANTIALIAS_LCD_VBGR:
mode.lcdRendering = true;
mode.mainFontDescriptor = &rgb;
mode.glyphDescriptor = &rgb;
break;
case sun_awt_SunHints_INTVAL_TEXT_ANTIALIAS_GASP:
case sun_awt_SunHints_INTVAL_TEXT_ANTIALIAS_DEFAULT:
@@ -501,10 +412,6 @@ CGGI_GetRenderingMode(const AWTStrike *strike)
userInfo:nil];
@throw e;
}
if (CGGI_IsColorFont(strike->fAWTFont->fNativeCGFont)) {
mode.mainFontDescriptor = &argb;
mode.subpixelResolution = false;
}
return mode;
}
@@ -537,7 +444,7 @@ CGGI_InitCanvas(CGGI_GlyphCanvas *canvas,
}
uint32_t bmpInfo = kCGImageAlphaPremultipliedFirst;
if (mode->lcdRendering) {
if (mode->glyphDescriptor == &rgb) {
bmpInfo |= kCGBitmapByteOrder32Host;
}
@@ -615,8 +522,8 @@ CGGI_ClearCanvas(CGGI_GlyphCanvas *canvas, GlyphInfo *info, bool transparent)
{
vImage_Buffer canvasRectToClear;
canvasRectToClear.data = canvas->image->data;
canvasRectToClear.height = info->height * info->subpixelResolutionY;
canvasRectToClear.width = info->width * info->subpixelResolutionX;
canvasRectToClear.height = info->height;
canvasRectToClear.width = info->width;
// use the row stride of the canvas, not the info
canvasRectToClear.rowBytes = canvas->image->rowBytes;
@@ -654,8 +561,7 @@ static inline CGSize CGGI_ScaleAdvance(CGSize advance, const AWTStrike *strike)
static inline GlyphInfo *
CGGI_CreateNewGlyphInfoFrom(CGSize advance, CGRect bbox,
const AWTStrike *strike,
const CGGI_GlyphInfoDescriptor *glyphDescriptor,
bool subpixelResolution)
const CGGI_GlyphInfoDescriptor *glyphDescriptor)
{
size_t pixelSize = glyphDescriptor->pixelSize;
@@ -667,23 +573,8 @@ CGGI_CreateNewGlyphInfoFrom(CGSize advance, CGRect bbox,
bbox.origin.x -= CGGI_GLYPH_BBOX_PADDING;
bbox.origin.y -= CGGI_GLYPH_BBOX_PADDING;
int subpixelResX = 1;
int subpixelResY = 1;
int topLeftX, topLeftY;
vImagePixelCount width, height;
if (subpixelResolution) {
subpixelResX = strike->fSubpixelResolutionX;
subpixelResY = strike->fSubpixelResolutionY;
topLeftX = floorf(bbox.origin.x / (float) subpixelResX);
topLeftY = floorf(bbox.origin.y / (float) subpixelResY);
width = ceilf((bbox.origin.x + bbox.size.width) / (float) subpixelResX) - topLeftX;
height = ceilf((bbox.origin.y + bbox.size.height) / (float) subpixelResY) - topLeftY;
} else {
topLeftX = round(bbox.origin.x);
topLeftY = round(bbox.origin.y);
width = ceilf(bbox.size.width);
height = ceilf(bbox.size.height);
}
vImagePixelCount width = ceilf(bbox.size.width);
vImagePixelCount height = ceilf(bbox.size.height);
// if the glyph is larger than 1MB, don't even try...
// the GlyphVector path should have taken over by now
@@ -704,20 +595,19 @@ CGGI_CreateNewGlyphInfoFrom(CGSize advance, CGRect bbox,
void *image = (void *)malloc(imageBytes + extraPixelStorage);
#else
// create a GlyphInfo struct fused to the image it points to
GlyphInfo *glyphInfo = (GlyphInfo *)malloc(sizeof(GlyphInfo) +
(imageBytes + extraPixelStorage) * subpixelResX * subpixelResY);
GlyphInfo *glyphInfo = (GlyphInfo *)malloc(sizeof(GlyphInfo) + imageBytes + extraPixelStorage);
#endif
glyphInfo->advanceX = advance.width;
glyphInfo->advanceY = advance.height;
glyphInfo->topLeftX = topLeftX;
glyphInfo->topLeftY = topLeftY;
glyphInfo->topLeftX = round(bbox.origin.x);
glyphInfo->topLeftY = round(bbox.origin.y);
glyphInfo->width = width;
glyphInfo->height = height;
glyphInfo->rowBytes = width * pixelSize;
glyphInfo->cellInfo = NULL;
glyphInfo->subpixelResolutionX = subpixelResX;
glyphInfo->subpixelResolutionY = subpixelResY;
glyphInfo->subpixelResolutionX = 1;
glyphInfo->subpixelResolutionY = 1;
#ifdef USE_IMAGE_ALIGNED_MEMORY
glyphInfo->image = image;
@@ -734,19 +624,6 @@ CGGI_CreateNewGlyphInfoFrom(CGSize advance, CGRect bbox,
#pragma mark --- Glyph Striking onto Canvas ---
static inline void CGGI_ScaleTXForSubpixelResolution(CGAffineTransform *tx,
const AWTStrike *strike,
bool subpixelResolution) {
if (subpixelResolution) {
float subResX = (float) strike->fSubpixelResolutionX;
float subResY = (float) strike->fSubpixelResolutionY;
tx->a *= subResX;
tx->b *= subResY;
tx->c *= subResX;
tx->d *= subResY;
}
}
/*
* Clears the canvas, strikes the glyph with CoreGraphics, and then
* copies the struck pixels into the GlyphInfo image.
@@ -772,13 +649,12 @@ CGGI_CreateImageForGlyph
CGGI_ClearCanvas(canvas, info, glyphDescriptor == &argb);
// strike the glyph in the upper right corner
CGFloat x = -info->topLeftX * (float) info->subpixelResolutionX;
CGFloat y = canvas->image->height + info->topLeftY * (float) info->subpixelResolutionY;
CGFloat x = -info->topLeftX;
CGFloat y = canvas->image->height + info->topLeftY;
if (isCatalinaOrAbove || glyphDescriptor == &argb) {
CGAffineTransform matrix = CGContextGetTextMatrix(canvas->context);
CGFloat fontSize = sqrt(fabs(matrix.a * matrix.d - matrix.b * matrix.c) /
(float) info->subpixelResolutionX / (float) info->subpixelResolutionY);
CGFloat fontSize = sqrt(fabs(matrix.a * matrix.d - matrix.b * matrix.c));
CTFontRef font = CTFontCreateWithGraphicsFont(cgFont, fontSize, NULL, NULL);
CGFloat normFactor = 1.0 / fontSize;
@@ -823,10 +699,8 @@ CGGI_CreateImageForUnicode
const CGGI_RenderingMode *mode, const UnicodeScalarValue uniChar,
const bool isCatalinaOrAbove)
{
// save the graphics state
// save the state of the world
CGContextSaveGState(canvas->context);
// text matrix is not considered part of graphics state
CGAffineTransform originalTx = CGContextGetTextMatrix(canvas->context);
// get the glyph, measure it using CG
CGGlyph glyph;
@@ -843,32 +717,26 @@ CGGI_CreateImageForUnicode
fallback = CTS_CopyCTFallbackFontAndGlyphForUnicode(strike->fAWTFont, (const UTF16Char *)&charRef, &glyph, 1);
}
CGAffineTransform tx = strike->fTx;
JRSFontRenderingStyle style = JRSFontAlignStyleForFractionalMeasurement(strike->fStyle);
const CGFontRef cgFallback = CTFontCopyGraphicsFont(fallback, NULL);
CGGI_GlyphInfoDescriptor *glyphDescriptor = CGGI_GetGlyphInfoDescriptor(mode, cgFallback);
bool subpixelResolution = mode->subpixelResolution && glyphDescriptor == &grey;
CGAffineTransform tx = strike->fTx;
CGGI_ScaleTXForSubpixelResolution(&tx, strike, subpixelResolution);
CGRect bbox;
JRSFontGetBoundingBoxesForGlyphsAndStyle(fallback, &tx, style, &glyph, 1, &bbox);
CGSize advance;
CTFontGetAdvancesForGlyphs(fallback, kCTFontDefaultOrientation, &glyph, &advance, 1);
const CGFontRef cgFallback = CTFontCopyGraphicsFont(fallback, NULL);
CGGI_GlyphInfoDescriptor *glyphDescriptor = CGGI_GetGlyphInfoDescriptor(mode, cgFallback);
// create the Sun2D GlyphInfo we are going to strike into
GlyphInfo *info = CGGI_CreateNewGlyphInfoFrom(advance, bbox, strike, glyphDescriptor, subpixelResolution);
GlyphInfo *info = CGGI_CreateNewGlyphInfoFrom(advance, bbox, strike, glyphDescriptor);
// fix the context size, just in case the substituted character is unexpectedly large
CGGI_SizeCanvas(canvas, info->width * info->subpixelResolutionX, info->height * info->subpixelResolutionY, mode);
CGGI_SizeCanvas(canvas, info->width, info->height, mode);
// align the transform for the real CoreText strike
CGAffineTransform altTx = strike->fAltTx;
CGGI_ScaleTXForSubpixelResolution(&altTx, strike, subpixelResolution);
CGContextSetTextMatrix(canvas->context, altTx);
CGContextSetTextMatrix(canvas->context, strike->fAltTx);
CGContextSetFont(canvas->context, cgFallback);
CFRelease(cgFallback);
@@ -876,9 +744,8 @@ CGGI_CreateImageForUnicode
// clean the canvas - align, strike, and copy the glyph from the canvas into the info
CGGI_CreateImageForGlyph(cgFallback, canvas, glyph, info, glyphDescriptor, strike, isCatalinaOrAbove);
// restore graphics state
// restore the state of the world
CGContextRestoreGState(canvas->context);
CGContextSetTextMatrix(canvas->context, originalTx);
CFRelease(fallback);
#ifdef CGGI_DEBUG
@@ -913,20 +780,20 @@ CGGI_FillImagesForGlyphsWithSizedCanvas(CGGI_GlyphCanvas *canvas,
const CGGlyph glyphs[],
const CFIndex len)
{
CGAffineTransform tx = strike->fAltTx;
CGGI_ScaleTXForSubpixelResolution(&tx, strike, mode->subpixelResolution);
CGContextSetTextMatrix(canvas->context, tx);
CGContextSetTextMatrix(canvas->context, strike->fAltTx);
CGContextSetFont(canvas->context, strike->fAWTFont->fNativeCGFont);
JRSFontSetRenderingStyleOnContext(canvas->context, strike->fStyle);
CGGI_GlyphInfoDescriptor* mainFontDescriptor = CGGI_GetGlyphInfoDescriptor(mode, strike->fAWTFont->fNativeCGFont);
const bool isMojaveOrAbove = IS_OSX_GT10_13;
CFIndex i;
for (i = 0; i < len; i++) {
GlyphInfo *info = (GlyphInfo *)jlong_to_ptr(glyphInfos[i]);
if (info != NULL) {
CGGI_CreateImageForGlyph(strike->fAWTFont->fNativeCGFont,
canvas, glyphs[i], info, mode->mainFontDescriptor, strike, isMojaveOrAbove);
canvas, glyphs[i], info, mainFontDescriptor, strike, isMojaveOrAbove);
} else {
info = CGGI_CreateImageForUnicode(canvas, strike, mode, uniChars[i], isMojaveOrAbove);
glyphInfos[i] = ptr_to_jlong(info);
@@ -985,7 +852,7 @@ CGGI_FillImagesForGlyphs(jlong *glyphInfos, const AWTStrike *strike,
NSMutableDictionary *threadDict =
[[NSThread currentThread] threadDictionary];
NSString* theKey = mode->lcdRendering ?
NSString* theKey = (mode->glyphDescriptor == &rgb) ?
threadLocalLCDCanvasKey : threadLocalAACanvasKey;
CGGI_GlyphCanvas *canvas = [threadDict objectForKey:theKey];
@@ -1017,7 +884,6 @@ CGGI_CreateGlyphInfos(jlong *glyphInfos, const AWTStrike *strike,
{
AWTFont *font = strike->fAWTFont;
CGAffineTransform tx = strike->fTx;
CGGI_ScaleTXForSubpixelResolution(&tx, strike, mode->subpixelResolution);
JRSFontRenderingStyle bboxCGMode = JRSFontAlignStyleForFractionalMeasurement(strike->fStyle);
JRSFontGetBoundingBoxesForGlyphsAndStyle((CTFontRef)font->fFont, &tx, bboxCGMode, glyphs, len, bboxes);
@@ -1026,6 +892,8 @@ CGGI_CreateGlyphInfos(jlong *glyphInfos, const AWTStrike *strike,
size_t maxWidth = 1;
size_t maxHeight = 1;
CGGI_GlyphInfoDescriptor* mainFontDescriptor = CGGI_GetGlyphInfoDescriptor(mode, strike->fAWTFont->fNativeCGFont);
CFIndex i;
for (i = 0; i < len; i++)
{
@@ -1038,15 +906,10 @@ CGGI_CreateGlyphInfos(jlong *glyphInfos, const AWTStrike *strike,
CGSize advance = advances[i];
CGRect bbox = bboxes[i];
GlyphInfo *glyphInfo = CGGI_CreateNewGlyphInfoFrom(advance, bbox, strike,
mode->mainFontDescriptor,
mode->subpixelResolution);
GlyphInfo *glyphInfo = CGGI_CreateNewGlyphInfoFrom(advance, bbox, strike, mainFontDescriptor);
int w = glyphInfo->width * glyphInfo->subpixelResolutionX;
int h = glyphInfo->height * glyphInfo->subpixelResolutionY;
if (maxWidth < w) maxWidth = w;
if (maxHeight < h) maxHeight = h;
if (maxWidth < glyphInfo->width) maxWidth = glyphInfo->width;
if (maxHeight < glyphInfo->height) maxHeight = glyphInfo->height;
glyphInfos[i] = ptr_to_jlong(glyphInfo);
}

View File

@@ -41,7 +41,10 @@ import java.security.AccessController;
import java.security.PrivilegedExceptionAction;
import java.text.AttributedCharacterIterator.Attribute;
import java.text.CharacterIterator;
import java.util.*;
import java.util.EventListener;
import java.util.Hashtable;
import java.util.Locale;
import java.util.Map;
import sun.awt.ComponentFactory;
import sun.font.StandardGlyphVector;
@@ -582,7 +585,7 @@ public class Font implements java.io.Serializable
/* This constructor is used by deriveFont when attributes is null */
private Font(String name, int style, float sizePts,
boolean created, Font2DHandle handle, boolean useOldHandle) {
boolean created, Font2DHandle handle) {
this(name, style, sizePts);
this.createdFont = created;
/* Fonts created from a stream will use the same font2D instance
@@ -602,8 +605,6 @@ public class Font implements java.io.Serializable
} else {
this.font2DHandle = handle;
}
} else if (useOldHandle) {
this.font2DHandle = handle;
}
}
@@ -649,7 +650,7 @@ public class Font implements java.io.Serializable
* In these cases there is no need to interrogate "values".
*/
private Font(AttributeValues values, String oldName, int oldStyle,
boolean created, Font2DHandle handle, boolean useOldHandle) {
boolean created, Font2DHandle handle) {
this.createdFont = created;
if (created) {
@@ -678,8 +679,6 @@ public class Font implements java.io.Serializable
this.createdFont = false;
this.font2DHandle = null;
}
} else if (useOldHandle) {
this.font2DHandle = handle;
}
initFromValues(values);
}
@@ -849,7 +848,7 @@ public class Font implements java.io.Serializable
values = font.getAttributeValues().clone();
values.merge(attributes, SECONDARY_MASK);
return new Font(values, font.name, font.style,
font.createdFont, font.font2DHandle, false);
font.createdFont, font.font2DHandle);
}
return new Font(attributes);
}
@@ -860,7 +859,7 @@ public class Font implements java.io.Serializable
AttributeValues values = font.getAttributeValues().clone();
values.merge(attributes, SECONDARY_MASK);
return new Font(values, font.name, font.style,
font.createdFont, font.font2DHandle, false);
font.createdFont, font.font2DHandle);
}
return font;
@@ -2056,13 +2055,13 @@ public class Font implements java.io.Serializable
*/
public Font deriveFont(int style, float size){
if (values == null) {
return new Font(name, style, size, createdFont, font2DHandle, false);
return new Font(name, style, size, createdFont, font2DHandle);
}
AttributeValues newValues = getAttributeValues().clone();
int oldStyle = (this.style != style) ? this.style : -1;
applyStyle(style, newValues);
newValues.setSize(size);
return new Font(newValues, null, oldStyle, createdFont, font2DHandle, false);
return new Font(newValues, null, oldStyle, createdFont, font2DHandle);
}
/**
@@ -2081,7 +2080,7 @@ public class Font implements java.io.Serializable
int oldStyle = (this.style != style) ? this.style : -1;
applyStyle(style, newValues);
applyTransform(trans, newValues);
return new Font(newValues, null, oldStyle, createdFont, font2DHandle, false);
return new Font(newValues, null, oldStyle, createdFont, font2DHandle);
}
/**
@@ -2093,11 +2092,11 @@ public class Font implements java.io.Serializable
*/
public Font deriveFont(float size){
if (values == null) {
return new Font(name, style, size, createdFont, font2DHandle, true);
return new Font(name, style, size, createdFont, font2DHandle);
}
AttributeValues newValues = getAttributeValues().clone();
newValues.setSize(size);
return new Font(newValues, null, -1, createdFont, font2DHandle, true);
return new Font(newValues, null, -1, createdFont, font2DHandle);
}
/**
@@ -2113,7 +2112,7 @@ public class Font implements java.io.Serializable
public Font deriveFont(AffineTransform trans){
AttributeValues newValues = getAttributeValues().clone();
applyTransform(trans, newValues);
return new Font(newValues, null, -1, createdFont, font2DHandle, true);
return new Font(newValues, null, -1, createdFont, font2DHandle);
}
/**
@@ -2125,24 +2124,14 @@ public class Font implements java.io.Serializable
*/
public Font deriveFont(int style){
if (values == null) {
return new Font(name, style, size, createdFont, font2DHandle, false);
return new Font(name, style, size, createdFont, font2DHandle);
}
AttributeValues newValues = getAttributeValues().clone();
int oldStyle = (this.style != style) ? this.style : -1;
applyStyle(style, newValues);
return new Font(newValues, null, oldStyle, createdFont, font2DHandle, false);
return new Font(newValues, null, oldStyle, createdFont, font2DHandle);
}
/*
* Set of attributes, updating which on a Font instance cannot possibly
* change the underlying Font2D instance it uses.
*/
private static final Set<? extends Attribute> FONT_2D_UNRELATED_ATTRS
= Set.of(TextAttribute.KERNING,
TextAttribute.LIGATURES,
TextAttribute.SIZE,
TextAttribute.TRANSFORM);
/**
* Creates a new {@code Font} object by replicating the current
* {@code Font} object and applying a new set of font attributes
@@ -2160,15 +2149,7 @@ public class Font implements java.io.Serializable
AttributeValues newValues = getAttributeValues().clone();
newValues.merge(attributes, RECOGNIZED_MASK);
boolean keepFont2DHandle = true;
for (Attribute attribute : attributes.keySet()) {
if (!FONT_2D_UNRELATED_ATTRS.contains(attribute)) {
keepFont2DHandle = false;
break;
}
}
return new Font(newValues, name, style, createdFont, font2DHandle,
keepFont2DHandle);
return new Font(newValues, name, style, createdFont, font2DHandle);
}
/**

View File

@@ -57,9 +57,6 @@ struct _CacheCellInfo {
// REMIND: find better name?
// next cell info in the glyph's cell list (next Glyph Cache Info)
CacheCellInfo *nextGCI;
// Glyph subimage ID, used to distinguish between different images
// Only makes sense when subpixel resolution is enabled for the glyph
jint glyphSubimage;
jint timesRendered;
jint x;
jint y;

View File

@@ -242,7 +242,7 @@ OGLTR_InitGlyphCache(jboolean lcdCache)
* associated with the given OGLContext.
*/
static void
OGLTR_AddToGlyphCache(GlyphInfo *glyph, GLenum pixelFormat, jint subimage)
OGLTR_AddToGlyphCache(GlyphInfo *glyph, GLenum pixelFormat)
{
CacheCellInfo *ccinfo;
GlyphCacheInfo *gcinfo;
@@ -261,16 +261,15 @@ OGLTR_AddToGlyphCache(GlyphInfo *glyph, GLenum pixelFormat, jint subimage)
return;
}
ccinfo = AccelGlyphCache_AddGlyph(gcinfo, glyph);
AccelGlyphCache_AddGlyph(gcinfo, glyph);
ccinfo = (CacheCellInfo *) glyph->cellInfo;
if (ccinfo != NULL) {
ccinfo->glyphSubimage = subimage;
// store glyph image in texture cell
j2d_glTexSubImage2D(GL_TEXTURE_2D, 0,
ccinfo->x, ccinfo->y,
glyph->width, glyph->height,
pixelFormat, GL_UNSIGNED_BYTE, glyph->image +
(glyph->rowBytes * glyph->height) * subimage);
pixelFormat, GL_UNSIGNED_BYTE, glyph->image);
}
}
@@ -812,8 +811,7 @@ OGLTR_DisableGlyphModeState()
}
static jboolean
OGLTR_DrawGrayscaleGlyphViaCache(OGLContext *oglc, GlyphInfo *ginfo, jint x, jint y,
jboolean useFontSmoothing, jint subimage)
OGLTR_DrawGrayscaleGlyphViaCache(OGLContext *oglc, GlyphInfo *ginfo, jint x, jint y, jboolean useFontSmoothing)
{
CacheCellInfo *cell;
jfloat x1, y1, x2, y2;
@@ -836,39 +834,17 @@ OGLTR_DrawGrayscaleGlyphViaCache(OGLContext *oglc, GlyphInfo *ginfo, jint x, jin
glyphMode = MODE_USE_CACHE_GRAY;
}
int rx = ginfo->subpixelResolutionX;
int ry = ginfo->subpixelResolutionY;
if (subimage == 0 && ((rx == 1 && ry == 1) || rx <= 0 || ry <= 0)) {
// Subpixel rendering disabled, there must be only one cell info
cell = (CacheCellInfo *) (ginfo->cellInfo);
} else {
// Subpixel rendering enabled, find subimage in cell list
cell = NULL;
CacheCellInfo *c = (CacheCellInfo *) (ginfo->cellInfo);
while (c != NULL) {
if (c->glyphSubimage == subimage) {
cell = c;
break;
}
c = c->nextGCI;
}
}
if (cell == NULL) {
if (ginfo->cellInfo == NULL) {
// attempt to add glyph to accelerated glyph cache
OGLTR_AddToGlyphCache(ginfo, GL_LUMINANCE, subimage);
// Our image, added to cache will be the first, so we take it.
// If for whatever reason we failed to add it to our cache,
// take first cell anyway, it's still better to render glyph
// image with wrong subpixel offset than render nothing.
cell = (CacheCellInfo *) (ginfo->cellInfo);
OGLTR_AddToGlyphCache(ginfo, GL_LUMINANCE);
if (cell == NULL) {
if (ginfo->cellInfo == NULL) {
// we'll just no-op in the rare case that the cell is NULL
return JNI_TRUE;
}
}
cell = (CacheCellInfo *) (ginfo->cellInfo);
cell->timesRendered++;
x1 = (jfloat)x;
@@ -1063,7 +1039,7 @@ OGLTR_DrawLCDGlyphViaCache(OGLContext *oglc, OGLSDOps *dstOps, GlyphInfo *ginfo,
j2d_glActiveTextureARB(GL_TEXTURE0_ARB);
// attempt to add glyph to accelerated glyph cache
OGLTR_AddToGlyphCache(ginfo, rgbOrder ? GL_RGB : GL_BGR, 0);
OGLTR_AddToGlyphCache(ginfo, rgbOrder ? GL_RGB : GL_BGR);
if (ginfo->cellInfo == NULL) {
// we'll just no-op in the rare case that the cell is NULL
@@ -1120,8 +1096,7 @@ OGLTR_DrawLCDGlyphViaCache(OGLContext *oglc, OGLSDOps *dstOps, GlyphInfo *ginfo,
static jboolean
OGLTR_DrawGrayscaleGlyphNoCache(OGLContext *oglc,
GlyphInfo *ginfo, jint x, jint y,
jint subimage)
GlyphInfo *ginfo, jint x, jint y)
{
jint tw, th;
jint sx, sy, sw, sh;
@@ -1148,8 +1123,7 @@ OGLTR_DrawGrayscaleGlyphNoCache(OGLContext *oglc,
OGLVertexCache_AddMaskQuad(oglc,
sx, sy, x, y, sw, sh,
w, ginfo->image +
(ginfo->rowBytes * ginfo->height) * subimage);
w, ginfo->image);
}
}
@@ -1343,9 +1317,6 @@ extern int useFontSmoothing;
#define FLOOR_ASSIGN(l, r) \
if ((r)<0) (l) = ((int)floor(r)); else (l) = ((int)(r))
#define ADJUST_SUBPIXEL_GLYPH_POSITION(coord, res) \
if ((res) > 1) (coord) += 0.5f / ((float)(res)) - 0.5f
void
OGLTR_DrawGlyphList(JNIEnv *env, OGLContext *oglc, OGLSDOps *dstOps,
jint totalGlyphs, jboolean usePositions,
@@ -1417,15 +1388,11 @@ OGLTR_DrawGlyphList(JNIEnv *env, OGLContext *oglc, OGLSDOps *dstOps,
jfloat posy = NEXT_FLOAT(positions);
glyphx = glyphListOrigX + posx + ginfo->topLeftX;
glyphy = glyphListOrigY + posy + ginfo->topLeftY;
ADJUST_SUBPIXEL_GLYPH_POSITION(glyphx, ginfo->subpixelResolutionX);
ADJUST_SUBPIXEL_GLYPH_POSITION(glyphy, ginfo->subpixelResolutionY);
FLOOR_ASSIGN(x, glyphx);
FLOOR_ASSIGN(y, glyphy);
} else {
glyphx = glyphListOrigX + ginfo->topLeftX;
glyphy = glyphListOrigY + ginfo->topLeftY;
ADJUST_SUBPIXEL_GLYPH_POSITION(glyphx, ginfo->subpixelResolutionX);
ADJUST_SUBPIXEL_GLYPH_POSITION(glyphy, ginfo->subpixelResolutionY);
FLOOR_ASSIGN(x, glyphx);
FLOOR_ASSIGN(y, glyphy);
glyphListOrigX += ginfo->advanceX;
@@ -1439,20 +1406,12 @@ OGLTR_DrawGlyphList(JNIEnv *env, OGLContext *oglc, OGLSDOps *dstOps,
if (ginfo->rowBytes == ginfo->width) {
OGLMTVertexCache_disable();
// grayscale or monochrome glyph data
int rx = ginfo->subpixelResolutionX;
int ry = ginfo->subpixelResolutionY;
int subimage;
if ((rx == 1 && ry == 1) || rx <= 0 || ry <= 0) {
subimage = 0;
} else {
subimage = (jint)((glyphx - x) * rx) + (jint)((glyphy - y) * ry) * rx;
}
if (ginfo->width <= OGLTR_CACHE_CELL_WIDTH &&
ginfo->height <= OGLTR_CACHE_CELL_HEIGHT)
{
ok = OGLTR_DrawGrayscaleGlyphViaCache(oglc, ginfo, x, y, fontSmoothing, subimage);
ok = OGLTR_DrawGrayscaleGlyphViaCache(oglc, ginfo, x, y, fontSmoothing);
} else {
ok = OGLTR_DrawGrayscaleGlyphNoCache(oglc, ginfo, x, y, subimage);
ok = OGLTR_DrawGrayscaleGlyphNoCache(oglc, ginfo, x, y);
}
} else if (ginfo->rowBytes == ginfo->width * 4) {
OGLMTVertexCache_disable();

View File

@@ -87,7 +87,7 @@ jboolean storeGVData(JNIEnv* env,
unsigned int* indices;
jarray glyphArray, posArray, inxArray;
if (!init_JNI_IDs(env)) {
if (!init_JNI_IDs(env) || !initHBAPI()) {
return JNI_FALSE;
}
@@ -280,45 +280,45 @@ JNIEXPORT jboolean JNICALL Java_sun_font_SunLayoutEngine_shape
hbface = (hb_face_t*) jlong_to_ptr(pFace);
hbfont = hb_jdk_font_create(hbface, jdkFontInfo, NULL);
buffer = hb_buffer_create();
hb_buffer_set_script(buffer, getHBScriptCode(script));
hb_buffer_set_language(buffer,
hb_ot_tag_to_language(HB_OT_TAG_DEFAULT_LANGUAGE));
buffer = p_hb_buffer_create();
p_hb_buffer_set_script(buffer, getHBScriptCode(script));
p_hb_buffer_set_language(buffer,
p_hb_ot_tag_to_language(HB_OT_TAG_DEFAULT_LANGUAGE));
if ((flags & TYPO_RTL) != 0) {
direction = HB_DIRECTION_RTL;
}
hb_buffer_set_direction(buffer, direction);
hb_buffer_set_cluster_level(buffer,
p_hb_buffer_set_direction(buffer, direction);
p_hb_buffer_set_cluster_level(buffer,
HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS);
chars = (*env)->GetCharArrayElements(env, text, NULL);
if ((*env)->ExceptionCheck(env)) {
hb_buffer_destroy(buffer);
hb_font_destroy(hbfont);
p_hb_buffer_destroy(buffer);
p_hb_font_destroy(hbfont);
free((void*)jdkFontInfo);
return JNI_FALSE;
}
len = (*env)->GetArrayLength(env, text);
hb_buffer_add_utf16(buffer, chars, len, offset, limit-offset);
p_hb_buffer_add_utf16(buffer, chars, len, offset, limit-offset);
features = calloc(2, sizeof(hb_feature_t));
if (features) {
hb_feature_from_string(kern, -1, &features[featureCount++]);
hb_feature_from_string(liga, -1, &features[featureCount++]);
p_hb_feature_from_string(kern, -1, &features[featureCount++]);
p_hb_feature_from_string(liga, -1, &features[featureCount++]);
}
hb_shape_full(hbfont, buffer, features, featureCount, 0);
glyphCount = hb_buffer_get_length(buffer);
glyphInfo = hb_buffer_get_glyph_infos(buffer, 0);
glyphPos = hb_buffer_get_glyph_positions(buffer, &buflen);
p_hb_shape_full(hbfont, buffer, features, featureCount, 0);
glyphCount = p_hb_buffer_get_length(buffer);
glyphInfo = p_hb_buffer_get_glyph_infos(buffer, 0);
glyphPos = p_hb_buffer_get_glyph_positions(buffer, &buflen);
ret = storeGVData(env, gvdata, slot, baseIndex, offset, startPt,
limit - offset, glyphCount, glyphInfo, glyphPos,
jdkFontInfo->devScale);
hb_buffer_destroy (buffer);
hb_font_destroy(hbfont);
p_hb_buffer_destroy (buffer);
p_hb_font_destroy(hbfont);
free((void*)jdkFontInfo);
if (features != NULL) free(features);
(*env)->ReleaseCharArrayElements(env, text, chars, JNI_ABORT);

View File

@@ -27,8 +27,17 @@
#include "sun_font_SunLayoutEngine.h"
#include "hb.h"
#include "hb-ot.h"
#include "hb-jdk.h"
#include <stdlib.h>
#if !defined(_WIN32) && !defined(__APPLE__)
#include <dlfcn.h>
#endif
#include "jvm_md.h"
#include "jni_util.h"
#define JHARFBUZZ_DLL JNI_LIB_NAME("jharfbuzz")
#define HARFBUZZ_DLL JNI_LIB_NAME("harfbuzz")
#if defined(__GNUC__) && __GNUC__ >= 4
#define HB_UNUSED __attribute__((unused))
@@ -36,6 +45,169 @@
#define HB_UNUSED
#endif
p_hb_buffer_create_type p_hb_buffer_create;
p_hb_buffer_set_script_type p_hb_buffer_set_script;
p_hb_buffer_set_language_type p_hb_buffer_set_language;
p_hb_buffer_set_direction_type p_hb_buffer_set_direction;
p_hb_buffer_set_cluster_level_type p_hb_buffer_set_cluster_level;
p_hb_buffer_add_utf16_type p_hb_buffer_add_utf16;
p_hb_feature_from_string_type p_hb_feature_from_string;
p_hb_buffer_get_length_type p_hb_buffer_get_length;
p_hb_buffer_get_glyph_infos_type p_hb_buffer_get_glyph_infos;
p_hb_buffer_get_glyph_positions_type p_hb_buffer_get_glyph_positions;
p_hb_buffer_destroy_type p_hb_buffer_destroy;
p_hb_font_destroy_type p_hb_font_destroy;
p_hb_font_funcs_create_type p_hb_font_funcs_create;
p_hb_font_funcs_set_nominal_glyphs_func_type p_hb_font_funcs_set_nominal_glyphs_func;
p_hb_font_funcs_set_variation_glyph_func_type p_hb_font_funcs_set_variation_glyph_func;
p_hb_font_funcs_set_glyph_h_advance_func_type p_hb_font_funcs_set_glyph_h_advance_func;
p_hb_font_funcs_set_glyph_v_advance_func_type p_hb_font_funcs_set_glyph_v_advance_func;
p_hb_font_funcs_set_glyph_h_origin_func_type p_hb_font_funcs_set_glyph_h_origin_func;
p_hb_font_funcs_set_glyph_v_origin_func_type p_hb_font_funcs_set_glyph_v_origin_func;
p_hb_font_funcs_set_glyph_h_kerning_func_type p_hb_font_funcs_set_glyph_h_kerning_func;
p_hb_font_funcs_set_glyph_v_kerning_func_type p_hb_font_funcs_set_glyph_v_kerning_func;
p_hb_font_funcs_set_glyph_extents_func_type p_hb_font_funcs_set_glyph_extents_func;
p_hb_font_funcs_set_glyph_contour_point_func_type p_hb_font_funcs_set_glyph_contour_point_func;
p_hb_font_funcs_set_glyph_name_func_type p_hb_font_funcs_set_glyph_name_func;
p_hb_font_funcs_set_glyph_from_name_func_type p_hb_font_funcs_set_glyph_from_name_func;
p_hb_font_funcs_make_immutable_type p_hb_font_funcs_make_immutable;
p_hb_blob_create_type p_hb_blob_create;
p_hb_face_create_for_tables_type p_hb_face_create_for_tables;
p_hb_font_create_type p_hb_font_create;
p_hb_font_set_funcs_type p_hb_font_set_funcs;
p_hb_font_set_scale_type p_hb_font_set_scale;
p_hb_shape_full_type p_hb_shape_full;
p_hb_font_funcs_set_nominal_glyph_func_type p_hb_font_funcs_set_nominal_glyph_func;
p_hb_face_destroy_type p_hb_face_destroy;
p_hb_ot_tag_to_language_type p_hb_ot_tag_to_language;
static int initialisedHBAPI = 0;
static int initialisationFailed = 0;
int initHBAPI() {
if (initialisedHBAPI) {
return initialisedHBAPI;
}
if (initialisationFailed) {
return 0;
}
#if !defined(_WIN32) && !defined(__APPLE__)
void* libharfbuzz = NULL;
libharfbuzz = dlopen(JHARFBUZZ_DLL, RTLD_LOCAL | RTLD_LAZY);
if (libharfbuzz == NULL) {
initialisationFailed = 1;
CHECK_NULL_RETURN(libharfbuzz = dlopen(HARFBUZZ_DLL, RTLD_LOCAL | RTLD_LAZY), 0);
initialisationFailed = 0;
}
p_hb_buffer_create = (p_hb_buffer_create_type)dlsym(libharfbuzz, "hb_buffer_create");
p_hb_buffer_set_script = (p_hb_buffer_set_script_type)dlsym(libharfbuzz, "hb_buffer_set_script");
p_hb_buffer_set_language = (p_hb_buffer_set_language_type)dlsym(libharfbuzz, "hb_buffer_set_language");
p_hb_buffer_set_direction = (p_hb_buffer_set_direction_type)dlsym(libharfbuzz, "hb_buffer_set_direction");
p_hb_buffer_set_cluster_level = (p_hb_buffer_set_cluster_level_type)dlsym(libharfbuzz, "hb_buffer_set_cluster_level");
p_hb_buffer_add_utf16 = (p_hb_buffer_add_utf16_type)dlsym(libharfbuzz, "hb_buffer_add_utf16");
p_hb_feature_from_string = (p_hb_feature_from_string_type)dlsym(libharfbuzz, "hb_feature_from_string");
p_hb_buffer_get_length = (p_hb_buffer_get_length_type)dlsym(libharfbuzz, "hb_buffer_get_length");
p_hb_buffer_get_glyph_infos = (p_hb_buffer_get_glyph_infos_type)dlsym(libharfbuzz, "hb_buffer_get_glyph_infos");
p_hb_buffer_get_glyph_positions = (p_hb_buffer_get_glyph_positions_type)dlsym(libharfbuzz, "hb_buffer_get_glyph_positions");
p_hb_buffer_destroy = (p_hb_buffer_destroy_type)dlsym(libharfbuzz, "hb_buffer_destroy");
p_hb_font_destroy = (p_hb_font_destroy_type)dlsym(libharfbuzz, "hb_font_destroy");
p_hb_font_funcs_create = (p_hb_font_funcs_create_type)dlsym(libharfbuzz, "hb_font_funcs_create");
p_hb_font_funcs_set_nominal_glyphs_func =
(p_hb_font_funcs_set_nominal_glyphs_func_type)dlsym(
libharfbuzz, "hb_font_funcs_set_nominal_glyphs_func");
p_hb_font_funcs_set_nominal_glyph_func = (p_hb_font_funcs_set_nominal_glyph_func_type)dlsym(
libharfbuzz, "hb_font_funcs_set_nominal_glyph_func");
p_hb_font_funcs_set_variation_glyph_func =
(p_hb_font_funcs_set_variation_glyph_func_type)dlsym(
libharfbuzz, "hb_font_funcs_set_variation_glyph_func");
p_hb_font_funcs_set_glyph_h_advance_func =
(p_hb_font_funcs_set_glyph_h_advance_func_type)dlsym(
libharfbuzz, "hb_font_funcs_set_glyph_h_advance_func");
p_hb_font_funcs_set_glyph_v_advance_func =
(p_hb_font_funcs_set_glyph_v_advance_func_type)dlsym(
libharfbuzz, "hb_font_funcs_set_glyph_v_advance_func");
p_hb_font_funcs_set_glyph_h_origin_func =
(p_hb_font_funcs_set_glyph_h_origin_func_type)dlsym(
libharfbuzz, "hb_font_funcs_set_glyph_h_origin_func");
p_hb_font_funcs_set_glyph_v_origin_func =
(p_hb_font_funcs_set_glyph_v_origin_func_type)dlsym(
libharfbuzz, "hb_font_funcs_set_glyph_v_origin_func");
p_hb_font_funcs_set_glyph_h_kerning_func =
(p_hb_font_funcs_set_glyph_h_kerning_func_type)dlsym(
libharfbuzz, "hb_font_funcs_set_glyph_h_kerning_func");
p_hb_font_funcs_set_glyph_v_kerning_func =
(p_hb_font_funcs_set_glyph_v_kerning_func_type)dlsym(
libharfbuzz, "hb_font_funcs_set_glyph_v_kerning_func");
p_hb_font_funcs_set_glyph_extents_func =
(p_hb_font_funcs_set_glyph_extents_func_type)dlsym(
libharfbuzz, "hb_font_funcs_set_glyph_extents_func");
p_hb_font_funcs_set_glyph_contour_point_func =
(p_hb_font_funcs_set_glyph_contour_point_func_type)dlsym(
libharfbuzz, "hb_font_funcs_set_glyph_contour_point_func");
p_hb_font_funcs_set_glyph_name_func =
(p_hb_font_funcs_set_glyph_name_func_type)dlsym(
libharfbuzz, "hb_font_funcs_set_glyph_name_func");
p_hb_font_funcs_set_glyph_from_name_func =
(p_hb_font_funcs_set_glyph_from_name_func_type)dlsym(
libharfbuzz, "hb_font_funcs_set_glyph_from_name_func");
p_hb_font_funcs_make_immutable =
(p_hb_font_funcs_make_immutable_type)dlsym(
libharfbuzz, "hb_font_funcs_make_immutable");
p_hb_blob_create =
(p_hb_blob_create_type)dlsym(libharfbuzz, "hb_blob_create");
p_hb_face_create_for_tables =
(p_hb_face_create_for_tables_type)dlsym(libharfbuzz, "hb_face_create_for_tables");
p_hb_font_create =
(p_hb_font_create_type)dlsym(libharfbuzz, "hb_font_create");
p_hb_font_set_funcs =
(p_hb_font_set_funcs_type)dlsym(libharfbuzz, "hb_font_set_funcs");
p_hb_font_set_scale =
(p_hb_font_set_scale_type)dlsym(libharfbuzz, "hb_font_set_scale");
p_hb_shape_full = (p_hb_shape_full_type)dlsym(libharfbuzz, "hb_shape_full");
p_hb_ot_tag_to_language = (p_hb_ot_tag_to_language_type)dlsym(libharfbuzz, "hb_ot_tag_to_language");
#else
p_hb_buffer_create = hb_buffer_create;
p_hb_buffer_set_script = hb_buffer_set_script;
p_hb_buffer_set_language = hb_buffer_set_language;
p_hb_buffer_set_direction = hb_buffer_set_direction;
p_hb_buffer_set_cluster_level = hb_buffer_set_cluster_level;
p_hb_buffer_add_utf16 = hb_buffer_add_utf16;
p_hb_feature_from_string = hb_feature_from_string;
p_hb_buffer_get_length = hb_buffer_get_length;
p_hb_buffer_get_glyph_infos = hb_buffer_get_glyph_infos;
p_hb_buffer_get_glyph_positions = hb_buffer_get_glyph_positions;
p_hb_buffer_destroy = hb_buffer_destroy;
p_hb_font_destroy = hb_font_destroy;
p_hb_font_funcs_create = hb_font_funcs_create;
p_hb_font_funcs_set_nominal_glyph_func = hb_font_funcs_set_nominal_glyph_func;
p_hb_font_funcs_set_nominal_glyphs_func = hb_font_funcs_set_nominal_glyphs_func;
p_hb_font_funcs_set_variation_glyph_func = hb_font_funcs_set_variation_glyph_func;
p_hb_font_funcs_set_glyph_h_advance_func = hb_font_funcs_set_glyph_h_advance_func;
p_hb_font_funcs_set_glyph_v_advance_func = hb_font_funcs_set_glyph_v_advance_func;
p_hb_font_funcs_set_glyph_h_origin_func = hb_font_funcs_set_glyph_h_origin_func;
p_hb_font_funcs_set_glyph_v_origin_func = hb_font_funcs_set_glyph_v_origin_func;
p_hb_font_funcs_set_glyph_h_kerning_func = hb_font_funcs_set_glyph_h_kerning_func;
p_hb_font_funcs_set_glyph_v_kerning_func = hb_font_funcs_set_glyph_v_kerning_func;
p_hb_font_funcs_set_glyph_extents_func = hb_font_funcs_set_glyph_extents_func;
p_hb_font_funcs_set_glyph_contour_point_func = hb_font_funcs_set_glyph_contour_point_func;
p_hb_font_funcs_set_glyph_name_func = hb_font_funcs_set_glyph_name_func;
p_hb_font_funcs_set_glyph_from_name_func = hb_font_funcs_set_glyph_from_name_func;
p_hb_font_funcs_make_immutable = hb_font_funcs_make_immutable;
p_hb_blob_create = hb_blob_create;
p_hb_face_create_for_tables = hb_face_create_for_tables;
p_hb_font_create = hb_font_create;
p_hb_font_set_funcs = hb_font_set_funcs;
p_hb_font_set_scale = hb_font_set_scale;
p_hb_shape_full = hb_shape_full;
p_hb_ot_tag_to_language = hb_ot_tag_to_language;
#endif
initialisedHBAPI = 1;
return initialisedHBAPI;
}
static hb_bool_t
hb_jdk_get_nominal_glyph (hb_font_t *font HB_UNUSED,
@@ -268,31 +440,31 @@ _hb_jdk_get_font_funcs (void)
hb_font_funcs_t *ff;
if (!jdk_ffuncs) {
ff = hb_font_funcs_create();
ff = p_hb_font_funcs_create();
hb_font_funcs_set_nominal_glyph_func(ff, hb_jdk_get_nominal_glyph, NULL, NULL);
hb_font_funcs_set_variation_glyph_func(ff, hb_jdk_get_variation_glyph, NULL, NULL);
hb_font_funcs_set_glyph_h_advance_func(ff,
p_hb_font_funcs_set_nominal_glyph_func(ff, hb_jdk_get_nominal_glyph, NULL, NULL);
p_hb_font_funcs_set_variation_glyph_func(ff, hb_jdk_get_variation_glyph, NULL, NULL);
p_hb_font_funcs_set_glyph_h_advance_func(ff,
hb_jdk_get_glyph_h_advance, NULL, NULL);
hb_font_funcs_set_glyph_v_advance_func(ff,
p_hb_font_funcs_set_glyph_v_advance_func(ff,
hb_jdk_get_glyph_v_advance, NULL, NULL);
hb_font_funcs_set_glyph_h_origin_func(ff,
p_hb_font_funcs_set_glyph_h_origin_func(ff,
hb_jdk_get_glyph_h_origin, NULL, NULL);
hb_font_funcs_set_glyph_v_origin_func(ff,
p_hb_font_funcs_set_glyph_v_origin_func(ff,
hb_jdk_get_glyph_v_origin, NULL, NULL);
hb_font_funcs_set_glyph_h_kerning_func(ff,
p_hb_font_funcs_set_glyph_h_kerning_func(ff,
hb_jdk_get_glyph_h_kerning, NULL, NULL);
hb_font_funcs_set_glyph_v_kerning_func(ff,
p_hb_font_funcs_set_glyph_v_kerning_func(ff,
hb_jdk_get_glyph_v_kerning, NULL, NULL);
hb_font_funcs_set_glyph_extents_func(ff,
p_hb_font_funcs_set_glyph_extents_func(ff,
hb_jdk_get_glyph_extents, NULL, NULL);
hb_font_funcs_set_glyph_contour_point_func(ff,
p_hb_font_funcs_set_glyph_contour_point_func(ff,
hb_jdk_get_glyph_contour_point, NULL, NULL);
hb_font_funcs_set_glyph_name_func(ff,
p_hb_font_funcs_set_glyph_name_func(ff,
hb_jdk_get_glyph_name, NULL, NULL);
hb_font_funcs_set_glyph_from_name_func(ff,
p_hb_font_funcs_set_glyph_from_name_func(ff,
hb_jdk_get_glyph_from_name, NULL, NULL);
hb_font_funcs_make_immutable(ff); // done setting functions.
p_hb_font_funcs_make_immutable(ff); // done setting functions.
jdk_ffuncs = ff;
}
return jdk_ffuncs;
@@ -353,7 +525,7 @@ reference_table(hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data) {
}
env->GetByteArrayRegion(tableBytes, 0, length, (jbyte*)buffer);
return hb_blob_create((const char *)buffer, length,
return p_hb_blob_create((const char *)buffer, length,
HB_MEMORY_MODE_WRITABLE,
buffer, free);
}
@@ -382,7 +554,7 @@ JNIEXPORT jlong JNICALL Java_sun_font_SunLayoutEngine_createFace(JNIEnv *env,
free(fi);
return 0;
}
hb_face_t *face = hb_face_create_for_tables(reference_table, fi,
hb_face_t *face = p_hb_face_create_for_tables(reference_table, fi,
cleanupFontInfo);
return ptr_to_jlong(face);
}
@@ -396,7 +568,7 @@ JNIEXPORT void JNICALL Java_sun_font_SunLayoutEngine_disposeFace(JNIEnv *env,
jclass cls,
jlong ptr) {
hb_face_t* face = (hb_face_t*) jlong_to_ptr(ptr);
hb_face_destroy(face);
p_hb_face_destroy(face);
}
} // extern "C"
@@ -407,11 +579,11 @@ static hb_font_t* _hb_jdk_font_create(hb_face_t* face,
hb_font_t *font;
font = hb_font_create(face);
hb_font_set_funcs (font,
font = p_hb_font_create(face);
p_hb_font_set_funcs (font,
_hb_jdk_get_font_funcs (),
jdkFontInfo, (hb_destroy_func_t) _do_nothing);
hb_font_set_scale (font,
p_hb_font_set_scale (font,
HBFloatToFixed(jdkFontInfo->ptSize*jdkFontInfo->devScale),
HBFloatToFixed(jdkFontInfo->ptSize*jdkFontInfo->devScale));
return font;

View File

@@ -72,6 +72,166 @@ hb_jdk_font_create(hb_face_t* hbFace,
void
hb_jdk_font_set_funcs(hb_font_t *font);
typedef hb_buffer_t* (*p_hb_buffer_create_type) ();
typedef void (*p_hb_buffer_set_script_type) (hb_buffer_t *buffer,
hb_script_t script);
typedef void (*p_hb_buffer_set_language_type) (hb_buffer_t *buffer,
hb_language_t language);
typedef void (*p_hb_buffer_set_direction_type) (hb_buffer_t *buffer,
hb_direction_t direction);
typedef void (*p_hb_buffer_set_cluster_level_type) (hb_buffer_t *buffer,
hb_buffer_cluster_level_t cluster_level);
typedef void (*p_hb_buffer_add_utf16_type) (hb_buffer_t *buffer,
const uint16_t *text,
int text_length,
unsigned int item_offset,
int item_length);
typedef hb_bool_t (*p_hb_feature_from_string_type) (const char *str,
int len,
hb_feature_t *feature);
typedef unsigned int (*p_hb_buffer_get_length_type) (hb_buffer_t *buffer);
typedef hb_glyph_info_t* (*p_hb_buffer_get_glyph_infos_type) (hb_buffer_t *buffer,
unsigned int *length);
typedef hb_glyph_position_t* (*p_hb_buffer_get_glyph_positions_type) (hb_buffer_t *buffer,
unsigned int *length);
typedef void (*p_hb_buffer_destroy_type) (hb_buffer_t *buffer);
typedef void (*p_hb_font_destroy_type) (hb_font_t *font);
typedef hb_font_funcs_t* (*p_hb_font_funcs_create_type) ();
typedef void (*p_hb_font_funcs_set_nominal_glyphs_func_type) (hb_font_funcs_t *ffuncs,
hb_font_get_nominal_glyphs_func_t func,
void *user_data, hb_destroy_func_t destroy);
typedef void (*p_hb_font_funcs_set_variation_glyph_func_type) (hb_font_funcs_t *ffuncs,
hb_font_get_variation_glyph_func_t func,
void *user_data, hb_destroy_func_t destroy);
typedef void (*p_hb_font_funcs_set_glyph_h_advance_func_type) (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_h_advance_func_t func,
void *user_data, hb_destroy_func_t destroy);
typedef void (*p_hb_font_funcs_set_glyph_v_advance_func_type) (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_v_advance_func_t func,
void *user_data, hb_destroy_func_t destroy);
typedef void (*p_hb_font_funcs_set_glyph_h_origin_func_type) (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_h_origin_func_t func,
void *user_data, hb_destroy_func_t destroy);
typedef void (*p_hb_font_funcs_set_glyph_v_origin_func_type) (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_v_origin_func_t func,
void *user_data, hb_destroy_func_t destroy);
typedef void (*p_hb_font_funcs_set_glyph_h_kerning_func_type) (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_h_kerning_func_t func,
void *user_data, hb_destroy_func_t destroy);
typedef void (*p_hb_font_funcs_set_glyph_v_kerning_func_type) (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_v_kerning_func_t func,
void *user_data, hb_destroy_func_t destroy);
typedef void (*p_hb_font_funcs_set_glyph_extents_func_type) (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_extents_func_t func,
void *user_data, hb_destroy_func_t destroy);
typedef void (*p_hb_font_funcs_set_glyph_contour_point_func_type) (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_contour_point_func_t func,
void *user_data, hb_destroy_func_t destroy);
typedef void (*p_hb_font_funcs_set_glyph_name_func_type) (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_name_func_t func,
void *user_data, hb_destroy_func_t destroy);
typedef void (*p_hb_font_funcs_set_glyph_from_name_func_type) (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_from_name_func_t func,
void *user_data, hb_destroy_func_t destroy);
typedef void (*p_hb_font_funcs_make_immutable_type) (hb_font_funcs_t *ffuncs);
typedef hb_blob_t * (*p_hb_blob_create_type) (const char *data,
unsigned int length,
hb_memory_mode_t mode,
void *user_data,
hb_destroy_func_t destroy);
typedef hb_face_t *
(*p_hb_face_create_for_tables_type) (hb_reference_table_func_t reference_table_func,
void *user_data,
hb_destroy_func_t destroy);
typedef hb_font_t * (*p_hb_font_create_type) (hb_face_t *face);
typedef void (*p_hb_font_set_funcs_type) (hb_font_t *font,
hb_font_funcs_t *klass,
void *font_data,
hb_destroy_func_t destroy);
typedef void (*p_hb_font_set_scale_type) (hb_font_t *font,
int x_scale,
int y_scale);
typedef hb_bool_t (*p_hb_shape_full_type) (hb_font_t *font,
hb_buffer_t *buffer,
const hb_feature_t *features,
unsigned int num_features,
const char * const *shaper_list);
typedef void (*p_hb_font_funcs_set_nominal_glyph_func_type) (hb_font_funcs_t *ffuncs,
hb_font_get_nominal_glyph_func_t func,
void *user_data, hb_destroy_func_t destroy);
typedef void (*p_hb_face_destroy_type) (hb_face_t *face);
typedef hb_language_t (*p_hb_ot_tag_to_language_type) (hb_tag_t tag);
extern p_hb_buffer_create_type p_hb_buffer_create;
extern p_hb_buffer_set_script_type p_hb_buffer_set_script;
extern p_hb_buffer_set_language_type p_hb_buffer_set_language;
extern p_hb_buffer_set_direction_type p_hb_buffer_set_direction;
extern p_hb_buffer_set_cluster_level_type p_hb_buffer_set_cluster_level;
extern p_hb_buffer_add_utf16_type p_hb_buffer_add_utf16;
extern p_hb_feature_from_string_type p_hb_feature_from_string;
extern p_hb_buffer_get_length_type p_hb_buffer_get_length;
extern p_hb_buffer_get_glyph_infos_type p_hb_buffer_get_glyph_infos;
extern p_hb_buffer_get_glyph_positions_type p_hb_buffer_get_glyph_positions;
extern p_hb_buffer_destroy_type p_hb_buffer_destroy;
extern p_hb_font_destroy_type p_hb_font_destroy;
extern p_hb_font_funcs_create_type p_hb_font_funcs_create;
extern p_hb_font_funcs_set_nominal_glyphs_func_type p_hb_font_funcs_set_nominal_glyphs_func;
extern p_hb_font_funcs_set_variation_glyph_func_type p_hb_font_funcs_set_variation_glyph_func;
extern p_hb_font_funcs_set_glyph_h_advance_func_type p_hb_font_funcs_set_glyph_h_advance_func;
extern p_hb_font_funcs_set_glyph_v_advance_func_type p_hb_font_funcs_set_glyph_v_advance_func;
extern p_hb_font_funcs_set_glyph_h_origin_func_type p_hb_font_funcs_set_glyph_h_origin_func;
extern p_hb_font_funcs_set_glyph_v_origin_func_type p_hb_font_funcs_set_glyph_v_origin_func;
extern p_hb_font_funcs_set_glyph_h_kerning_func_type p_hb_font_funcs_set_glyph_h_kerning_func;
extern p_hb_font_funcs_set_glyph_v_kerning_func_type p_hb_font_funcs_set_glyph_v_kerning_func;
extern p_hb_font_funcs_set_glyph_extents_func_type p_hb_font_funcs_set_glyph_extents_func;
extern p_hb_font_funcs_set_glyph_contour_point_func_type p_hb_font_funcs_set_glyph_contour_point_func;
extern p_hb_font_funcs_set_glyph_name_func_type p_hb_font_funcs_set_glyph_name_func;
extern p_hb_font_funcs_set_glyph_from_name_func_type p_hb_font_funcs_set_glyph_from_name_func;
extern p_hb_font_funcs_make_immutable_type p_hb_font_funcs_make_immutable;
extern p_hb_blob_create_type p_hb_blob_create;
extern p_hb_face_create_for_tables_type p_hb_face_create_for_tables;
extern p_hb_font_create_type p_hb_font_create;
extern p_hb_font_set_funcs_type p_hb_font_set_funcs;
extern p_hb_font_set_scale_type p_hb_font_set_scale;
extern p_hb_shape_full_type p_hb_shape_full;
extern p_hb_font_funcs_set_nominal_glyph_func_type p_hb_font_funcs_set_nominal_glyph_func;
extern p_hb_face_destroy_type p_hb_face_destroy;
extern p_hb_ot_tag_to_language_type p_hb_ot_tag_to_language;
int initHBAPI();
# ifdef __cplusplus
}

View File

@@ -33,6 +33,7 @@
#include "sun_font_SunFontManager.h"
#include "sun_font_NullFontScaler.h"
#include "sun_font_StrikeCache.h"
#include "hb-jdk.h"
static void *theNullScalerContext = NULL;
extern void AccelGlyphCache_RemoveAllCellInfos(GlyphInfo *glyph);
@@ -199,6 +200,7 @@ Java_sun_font_SunFontManager_initIDs
(JNIEnv *env, jclass cls) {
initFontIDs(env);
initHBAPI();
}
JNIEXPORT FontManagerNativeIDs getSunFontIDs(JNIEnv *env) {

Some files were not shown because too many files have changed in this diff Show More