Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8240218: IOS Webkit implementation broken #128

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -0,0 +1,109 @@
/*
* Copyright (c) 2016, 2020, 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.sun.java.scene.web;

import com.sun.javafx.geom.BaseBounds;
import com.sun.javafx.geom.PickRay;
import com.sun.javafx.geom.transform.BaseTransform;
import com.sun.javafx.scene.ParentHelper;
import com.sun.javafx.scene.input.PickResultChooser;
import com.sun.javafx.sg.prism.NGNode;
import com.sun.javafx.util.Utils;
import javafx.scene.web.WebView;
import javafx.scene.Node;

/**
* Used to access internal methods of WebView.
*/
public class WebViewHelper extends ParentHelper {

private static final WebViewHelper theInstance;
private static WebViewAccessor webViewAccessor;

static {
theInstance = new WebViewHelper();
Utils.forceInit(WebView.class);
}

private static WebViewHelper getInstance() {
return theInstance;
}

public static void initHelper(WebView webView) {
setHelper(webView, getInstance());
}

@Override
protected NGNode createPeerImpl(Node node) {
return webViewAccessor.doCreatePeer(node);
}

@Override
protected void updatePeerImpl(Node node) {
super.updatePeerImpl(node);
webViewAccessor.doUpdatePeer(node);
}

protected void transformsChangedImpl(Node node) {
super.transformsChangedImpl(node);
webViewAccessor.doTransformsChanged(node);
}

@Override
protected BaseBounds computeGeomBoundsImpl(Node node, BaseBounds bounds,
BaseTransform tx) {
return webViewAccessor.doComputeGeomBounds(node, bounds, tx);
}

@Override
protected boolean computeContainsImpl(Node node, double localX, double localY) {
return webViewAccessor.doComputeContains(node, localX, localY);
}

@Override
protected void pickNodeLocalImpl(Node node, PickRay localPickRay,
PickResultChooser result) {
webViewAccessor.doPickNodeLocal(node, localPickRay, result);
}

public static void setWebViewAccessor(final WebViewAccessor newAccessor) {
if (webViewAccessor != null) {
throw new IllegalStateException();
}

webViewAccessor = newAccessor;
}

public interface WebViewAccessor {
NGNode doCreatePeer(Node node);
void doUpdatePeer(Node node);
void doTransformsChanged(Node node);
BaseBounds doComputeGeomBounds(Node node, BaseBounds bounds, BaseTransform tx);
boolean doComputeContains(Node node, double localX, double localY);
void doPickNodeLocal(Node node, PickRay localPickRay, PickResultChooser result);
}

}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2020, 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
@@ -30,7 +30,11 @@
import java.util.ArrayList;
import java.util.List;
import com.sun.javafx.scene.control.behavior.BehaviorBase;
import com.sun.javafx.scene.control.behavior.KeyBinding;
import com.sun.javafx.scene.control.inputmap.InputMap;
import com.sun.javafx.scene.control.inputmap.KeyBinding;
import com.sun.javafx.scene.control.behavior.FocusTraversalInputMap;

import static com.sun.javafx.scene.control.inputmap.InputMap.KeyMapping;
import javafx.scene.web.HTMLEditorSkin;
import static javafx.scene.input.KeyCode.B;
import static javafx.scene.input.KeyCode.I;
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2020, 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,6 +26,8 @@
package javafx.scene.web;


import com.sun.javafx.scene.control.ControlHelper;

import javafx.css.StyleableProperty;

import javafx.scene.control.Control;
@@ -45,7 +47,7 @@
* Creates a new instance of the HTMLEditor control.
*/
public HTMLEditor() {
((StyleableProperty)super.skinClassNameProperty()).applyStyle(
((StyleableProperty) ControlHelper.skinClassNameProperty(this)).applyStyle(
null,
"com.sun.javafx.scene.web.skin.HTMLEditorSkin"
);
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2020, 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
@@ -23,7 +23,7 @@
* questions.
*/

package com.sun.javafx.scene.web.skin;
package javafx.scene.web;

import java.util.ResourceBundle;
import com.sun.javafx.scene.ParentHelper;
@@ -77,9 +77,6 @@
import com.sun.javafx.scene.web.behavior.HTMLEditorBehavior;
import com.sun.javafx.scene.traversal.TraversalEngine;
import com.sun.javafx.scene.traversal.TraverseListener;
//import com.sun.webkit.WebPage;
//import com.sun.webkit.event.WCFocusEvent;
//import com.sun.javafx.webkit.Accessor;

import java.security.AccessController;
import java.security.PrivilegedAction;
@@ -90,15 +87,17 @@
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import com.sun.javafx.scene.control.skin.BehaviorSkinBase;
import javafx.collections.ListChangeListener;

import static javafx.geometry.NodeOrientation.*;

import static javafx.scene.web.HTMLEditorSkin.Command.*;


/**
* HTML editor skin.
*/
public class HTMLEditorSkin extends BehaviorSkinBase<HTMLEditor, HTMLEditorBehavior> implements TraverseListener {
public class HTMLEditorSkin extends SkinBase<HTMLEditor> implements TraverseListener {
private GridPane gridPane;

private ToolBar toolbar1;
@@ -108,8 +107,6 @@
private Button copyButton;
private Button pasteButton;

// private Button undoButton;
// private Button redoButton;

private Button insertHorizontalRuleButton;

@@ -144,7 +141,6 @@
private ColorPicker bgColorButton;

private WebView webView;
// private WebPage webPage;

private static final String CUT_COMMAND = "cut";
private static final String COPY_COMMAND = "copy";
@@ -258,7 +254,7 @@
}
};
public HTMLEditorSkin(HTMLEditor htmlEditor) {
super(htmlEditor, new HTMLEditorBehavior(htmlEditor));
super(htmlEditor);

getChildren().clear();

@@ -764,14 +760,14 @@ public void handle(ActionEvent event) {
fgColorButton.setFocusTraversable(false);
toolbar1.getItems().add(fgColorButton);

fgColorButton.applyCss();
ColorPickerSkin fgColorPickerSkin = (ColorPickerSkin) fgColorButton.getSkin();
String fgIcon = AccessController.doPrivileged(new PrivilegedAction<String>() {
@Override public String run() {
return HTMLEditorSkin.class.getResource(resources.getString("foregroundColorIcon")).toString();
}
});
((StyleableProperty)fgColorPickerSkin.imageUrlProperty()).applyStyle(null,fgIcon);
// fgColorButton.applyCss();
// ColorPickerSkin fgColorPickerSkin = (ColorPickerSkin) fgColorButton.getSkin();
// String fgIcon = AccessController.doPrivileged(new PrivilegedAction<String>() {
// @Override public String run() {
// return HTMLEditorSkin.class.getResource(resources.getString("foregroundColorIcon")).toString();
// }
// });
// ((StyleableProperty)fgColorPickerSkin.imageUrlProperty()).applyStyle(null,fgIcon);

fgColorButton.setValue(DEFAULT_FG_COLOR);
fgColorButton.setTooltip(new Tooltip(resources.getString("foregroundColor")));
@@ -790,14 +786,14 @@ public void handle(ActionEvent event) {
bgColorButton.setFocusTraversable(false);
toolbar1.getItems().add(bgColorButton);

bgColorButton.applyCss();
ColorPickerSkin bgColorPickerSkin = (ColorPickerSkin) bgColorButton.getSkin();
String bgIcon = AccessController.doPrivileged(new PrivilegedAction<String>() {
@Override public String run() {
return HTMLEditorSkin.class.getResource(resources.getString("backgroundColorIcon")).toString();
}
});
((StyleableProperty)bgColorPickerSkin.imageUrlProperty()).applyStyle(null,bgIcon);
// bgColorButton.applyCss();
// ColorPickerSkin bgColorPickerSkin = (ColorPickerSkin) bgColorButton.getSkin();
// String bgIcon = AccessController.doPrivileged(new PrivilegedAction<String>() {
// @Override public String run() {
// return HTMLEditorSkin.class.getResource(resources.getString("backgroundColorIcon")).toString();
// }
// });
// ((StyleableProperty)bgColorPickerSkin.imageUrlProperty()).applyStyle(null,bgIcon);

bgColorButton.setValue(DEFAULT_BG_COLOR);
bgColorButton.setTooltip(new Tooltip(resources.getString("backgroundColor")));
@@ -1220,4 +1216,61 @@ protected void layoutChildren(final double x, final double y,
private static final int FONT_FAMILY_MENU_WIDTH = 100;
private static final int FONT_SIZE_MENUBUTTON_WIDTH = 80;

public void performCommand(final Command command) {
switch (command) {
case BOLD: boldButton.fire(); break;
case ITALIC: italicButton.setSelected(!italicButton.isSelected()); break;
case UNDERLINE: underlineButton.setSelected(!underlineButton.isSelected()); break;
}
}

public enum Command {
CUT("cut"),
COPY("copy"),
PASTE("paste"),

UNDO("undo"),
REDO("redo"),

INSERT_HORIZONTAL_RULE("inserthorizontalrule"),

ALIGN_LEFT("justifyleft"),
ALIGN_CENTER("justifycenter"),
ALIGN_RIGHT("justifyright"),
ALIGN_JUSTIFY("justifyfull"),

BULLETS("insertUnorderedList"),
NUMBERS("insertOrderedList"),

INDENT("indent"),
OUTDENT("outdent"),

FORMAT("formatblock"),
FONT_FAMILY("fontname"),
FONT_SIZE("fontsize"),

BOLD("bold"),
ITALIC("italic"),
UNDERLINE("underline"),
STRIKETHROUGH("strikethrough"),

FOREGROUND_COLOR("forecolor"),
BACKGROUND_COLOR("backcolor"),
STYLEWITHCSS("styleWithCSS"),

INSERT_NEW_LINE("insertnewline"),
INSERT_TAB("inserttab");

private final String command;

Command(String command) {
this.command = command;
}

public String getCommand() {
return command;
}
}


}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2020, 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
@@ -41,8 +41,9 @@
import com.sun.javafx.scene.DirtyBits;
import com.sun.javafx.scene.NodeHelper;
import com.sun.javafx.scene.input.PickResultChooser;
import com.sun.java.scene.web.WebViewHelper;
import com.sun.javafx.scene.SceneHelper;
import com.sun.java.scene.web.WebViewHelper;

import com.sun.javafx.sg.prism.NGNode;
import com.sun.javafx.tk.TKPulseListener;
import com.sun.javafx.tk.Toolkit;
@@ -335,7 +336,7 @@ public void changed(ObservableValue<? extends Bounds> observable, Bounds oldValu

});

impl_treeVisibleProperty().addListener(new ChangeListener<Boolean>() {
NodeHelper.treeVisibleProperty(this).addListener(new ChangeListener<Boolean>() {

@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
@@ -1020,7 +1021,7 @@ private void handleStagePulse() {
// pending render queues, if any, become obsolete and should be
// discarded.

boolean reallyVisible = impl_isTreeVisible()
boolean reallyVisible = NodeHelper.isTreeVisible(this)
&& getScene() != null
&& getScene().getWindow() != null
&& getScene().getWindow().isShowing();
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.