Author: yzhishko
Date: 2009-10-30 12:55:03 -0400 (Fri, 30 Oct 2009)
New Revision: 18371
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java
Log:
Fix for
https://jira.jboss.org/jira/browse/JBIDE-5117
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java 2009-10-30
16:23:36 UTC (rev 18370)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java 2009-10-30
16:55:03 UTC (rev 18371)
@@ -51,7 +51,7 @@
/**
* @author Sergey Vasilyev (svasilyev(a)exadel.com)
- *
+ *
*/
public class XulRunnerEditor extends XulRunnerBrowser {
/** IVpeResizeListener */
@@ -59,30 +59,30 @@
/** IXulRunnerVpeResizer */
private IXulRunnerVpeResizer xulRunnerVpeResizer;
-
+
/**
* color which used for highlight elements which user can see, blue color
*/
public static final String flasherVisialElementColor = "#0000ff";
//$NON-NLS-1$
-
+
/**
- * color which used for highlight parent elements for elements which user, red color
- * can't see.
+ * color which used for highlight parent elements for elements which user,
+ * red color can't see.
*/
public static final String flasherHiddentElementColor = "#ff0000";
//$NON-NLS-1$
-
- //added by Maksim Areshkau as element for which we
- //have drowed border. When we draw new border,
- //we should remove old one;
+
+ // added by Maksim Areshkau as element for which we
+ // have drowed border. When we draw new border,
+ // we should remove old one;
private nsIDOMElement lastBorderedElement;
private static final String INVISIBLE_ELEMENT_BORDER = "border: 2px solid
red;";//$NON-NLS-1$
private static final String VISIBLE_ELEMENT_BORDER = "border: 2px solid
blue;";//$NON-NLS-1$
private static final String PREV_STYLE_ATTR_NAME = "oldstyle";//$NON-NLS-1$
-
+
/**
* Contains name of attribute for inIFLasher drawing
*/
- public static String VPEFLASHERCOLORATTRIBUTE="vpeFlasherColorAttribute";
//$NON-NLS-1$
+ public static String VPEFLASHERCOLORATTRIBUTE = "vpeFlasherColorAttribute";
//$NON-NLS-1$
public static final String TRANS_FLAVOR_kHTMLMime = "text/html";
//$NON-NLS-1$
public static final String TRANS_FLAVOR_kURLDataMime = "text/x-moz-url-data";
//$NON-NLS-1$
@@ -90,28 +90,30 @@
public static final String TRANS_FLAVOR_kURLMime = "text/x-moz-url";
//$NON-NLS-1$
public static final String TRANS_FLAVOR_kUnicodeMime = "text/unicode";
//$NON-NLS-1$
public static final String TRANS_FLAVOR_kNativeHTMLMime =
"application/x-moz-nativehtml"; //$NON-NLS-1$
-
+
/**
- * xpcom flasher component which used to draw lines
+ * xpcom flasher component which used to draw lines
*/
private inIFlasher iFlasher;
private nsIDocShell docShell = null;
-
+
/**
* RegExp for find expression 'display : none' in style string
*/
- private static final Pattern PATTERN =
Pattern.compile(".*\\s*(display)\\s*:\\s*(none)\\s*;.*",Pattern.CASE_INSENSITIVE+Pattern.DOTALL);
//$NON-NLS-1$
+ private static final Pattern PATTERN = Pattern
+ .compile(
+ ".*\\s*(display)\\s*:\\s*(none)\\s*;.*", Pattern.CASE_INSENSITIVE +
Pattern.DOTALL); //$NON-NLS-1$
/**
* Contains attribute name for style
*/
- private static final String STYLE_ATTR="style"; //$NON-NLS-1$
+ private static final String STYLE_ATTR = "style"; //$NON-NLS-1$
-// private nsIDOMElement lastSelectedElement;
+ // private nsIDOMElement lastSelectedElement;
private nsIDOMNode lastSelectedNode;
private int lastResizerConstrains;
/**
- * Scroll selection into view flag
+ * Scroll selection into view flag
*/
private boolean scrollRegtangleFlag = false;
@@ -120,21 +122,24 @@
private Listener eventListenet = new Listener() {
public void handleEvent(Event event) {
- Display.getCurrent().asyncExec(new Thread(){
+ Display.getCurrent().asyncExec(new Thread() {
@Override
- public void run(){
- /*
- *
https://jira.jboss.org/jira/browse/JBIDE-3917
- * Resizer should be updated together with selection rectangle.
- * Otherwise after window maximizing/restoring resizer shows old position.
- */
- if(getBrowser()!=null && !getBrowser().isDisposed()) {
- showResizer();
- showSelectionRectangle();
+ public void run() {
+ /*
+ *
https://jira.jboss.org/jira/browse/JBIDE-3917 Resizer
+ * should be updated together with selection rectangle.
+ * Otherwise after window maximizing/restoring resizer shows
+ * old position.
+ */
+ if (getBrowser() != null && !getBrowser().isDisposed()) {
+ showResizer();
+ showSelectionRectangle();
}
}
});
- }};
+ }
+ };
+
/**
* @param parent
* @throws XulRunnerException
@@ -144,12 +149,16 @@
getBrowser().addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
- //TODO Max Areshkau this caused en error when we close editor under Mac OS
-// getWebBrowser().removeWebBrowserListener(XulRunnerEditor.this,
nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID);
- getWebBrowser().removeWebBrowserListener(XulRunnerEditor.this,
nsITooltipListener.NS_ITOOLTIPLISTENER_IID);
+ // TODO Max Areshkau this caused en error when we close editor
+ // under Mac OS
+ // getWebBrowser().removeWebBrowserListener(XulRunnerEditor.this,
+ // nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID);
+ getWebBrowser().removeWebBrowserListener(XulRunnerEditor.this,
+ nsITooltipListener.NS_ITOOLTIPLISTENER_IID);
removeSelectionListener();
if (resizeListener != null)
- getIXulRunnerVpeResizer().removeResizeListener(resizeListener);
+ getIXulRunnerVpeResizer().removeResizeListener(
+ resizeListener);
xulRunnerVpeResizer.dispose();
xulRunnerVpeResizer = null;
resizeListener = null;
@@ -164,34 +173,36 @@
getBrowser().removeDisposeListener(this);
onDispose();
}
-
+
});
-
-// addListener(SWT.Activate, eventListenet);
- addListener(SWT.Paint, eventListenet);
- /*
- *
https://jira.jboss.org/jira/browse/JBIDE-3917
- * Resizer and selection rectangle should be updated
- * after eclipse window resizing.
- * Need to test on Mac OS.
- */
- //Commented by Max Areshkau (bug on Mac OS X10.4
- //when switch from visual to preview selection rectangle doen't disappear
- addListener(SWT.Resize, eventListenet);
-
- addListener(SWT.Show, eventListenet);
- addListener(SWT.FocusIn, eventListenet);
- //Commented by Max Areshkau (bug on Mac OS X10.4
- //when switch from visual to preview selection rectangle doen't disappear
-// addListener(SWT.FocusOut, eventListenet);
- addListener(SWT.Selection, eventListenet);
- addListener(SWT.Paint, eventListenet);
-
+
+ // addListener(SWT.Activate, eventListenet);
+ addListener(SWT.Paint, eventListenet);
+ /*
+ *
https://jira.jboss.org/jira/browse/JBIDE-3917 Resizer and selection
+ * rectangle should be updated after eclipse window resizing. Need to
+ * test on Mac OS.
+ */
+ // Commented by Max Areshkau (bug on Mac OS X10.4
+ // when switch from visual to preview selection rectangle doen't
+ // disappear
+ addListener(SWT.Resize, eventListenet);
+
+ addListener(SWT.Show, eventListenet);
+ addListener(SWT.FocusIn, eventListenet);
+ // Commented by Max Areshkau (bug on Mac OS X10.4
+ // when switch from visual to preview selection rectangle doen't
+ // disappear
+ // addListener(SWT.FocusOut, eventListenet);
+ addListener(SWT.Selection, eventListenet);
+ addListener(SWT.Paint, eventListenet);
+
resizeListener = new IVpeResizeListener() {
public void onEndResizing(int usedResizeMarkerHandle, int top,
int left, int width, int height,
nsIDOMElement resizedDomElement) {
- endResizing(usedResizeMarkerHandle, top, left, width, height, resizedDomElement);
+ endResizing(usedResizeMarkerHandle, top, left, width, height,
+ resizedDomElement);
}
public nsISupports queryInterface(String uuid) {
@@ -199,16 +210,15 @@
}
};
-
}
public boolean isMozillaDragFlavor() {
-
+
nsIDragSession dragSession = getCurrentDragSession();
if (dragSession != null) {
nsITransferable transferable = createTransferable();
if (transferable != null) {
-// transferable.flavorsTransferableCanImport();
+ // transferable.flavorsTransferableCanImport();
transferable.addDataFlavor(TRANS_FLAVOR_kURLDataMime);
transferable.addDataFlavor(TRANS_FLAVOR_kFileMime);
@@ -216,21 +226,22 @@
transferable.addDataFlavor(TRANS_FLAVOR_kUnicodeMime);
dragSession.getData(transferable, 0);
-// transferable.flavorsTransferableCanImport();
- String[] flavors = new String[] {null};
- nsISupports[] data = new nsISupports[] {null};
- long[] length = new long[] {0};
+ // transferable.flavorsTransferableCanImport();
+ String[] flavors = new String[] { null };
+ nsISupports[] data = new nsISupports[] { null };
+ long[] length = new long[] { 0 };
transferable.getAnyTransferData(flavors, data, length);
-
+
return length[0] > 0;
}
}
return false;
}
-
- public void onElementResize(nsIDOMElement element, int handle, int top, int left, int
width, int height) {
+
+ public void onElementResize(nsIDOMElement element, int handle, int top,
+ int left, int width, int height) {
}
-
+
/**
* Removes resizer listener
*/
@@ -238,32 +249,36 @@
if (resizeListener != null)
getIXulRunnerVpeResizer().removeResizeListener(resizeListener);
}
+
/**
* Add Resizer Listener
*/
public void addResizerListener() {
- if (getIXulRunnerVpeResizer() != null) {
- getIXulRunnerVpeResizer().init(getDOMDocument());
- getIXulRunnerVpeResizer().addResizeListener(resizeListener);
- }
+ if (getIXulRunnerVpeResizer() != null) {
+ getIXulRunnerVpeResizer().init(getDOMDocument());
+ getIXulRunnerVpeResizer().addResizeListener(resizeListener);
+ }
}
-
+
public void onLoadWindow() {
addResizerListener();
}
-
+
public nsIDragSession getCurrentDragSession() {
nsIServiceManager serviceManager = getServiceManager();
- nsIDragService dragService = (nsIDragService)
serviceManager.getServiceByContractID(XPCOM.NS_DRAGSERVICE_CONTRACTID,
nsIDragService.NS_IDRAGSERVICE_IID);
-
+ nsIDragService dragService = (nsIDragService) serviceManager
+ .getServiceByContractID(XPCOM.NS_DRAGSERVICE_CONTRACTID,
+ nsIDragService.NS_IDRAGSERVICE_IID);
+
return dragService.getCurrentSession();
}
-
+
public nsIClipboardDragDropHookList getClipboardDragDropHookList() {
nsIDocShell docShell = getDocShell();
-
+
if (docShell != null) {
- nsIClipboardDragDropHookList hookList = (nsIClipboardDragDropHookList)
docShell.queryInterface(nsIClipboardDragDropHookList.NS_ICLIPBOARDDRAGDROPHOOKLIST_IID);
+ nsIClipboardDragDropHookList hookList = (nsIClipboardDragDropHookList) docShell
+ .queryInterface(nsIClipboardDragDropHookList.NS_ICLIPBOARDDRAGDROPHOOKLIST_IID);
return hookList;
}
return null;
@@ -271,43 +286,51 @@
public nsIDocShell getDocShell() {
if (docShell == null) {
- nsIInterfaceRequestor interfaceRequestor = (nsIInterfaceRequestor)
getWebBrowser().queryInterface(nsIInterfaceRequestor.NS_IINTERFACEREQUESTOR_IID);
- docShell = (nsIDocShell)
interfaceRequestor.getInterface(nsIDocShell.NS_IDOCSHELL_IID);
+ nsIInterfaceRequestor interfaceRequestor = (nsIInterfaceRequestor) getWebBrowser()
+ .queryInterface(
+ nsIInterfaceRequestor.NS_IINTERFACEREQUESTOR_IID);
+ docShell = (nsIDocShell) interfaceRequestor
+ .getInterface(nsIDocShell.NS_IDOCSHELL_IID);
}
-
+
return docShell;
}
-
+
public nsIDOMDocument getDOMDocument() {
nsIDOMWindow domWindow = getWebBrowser().getContentDOMWindow();
return domWindow.getDocument();
}
-
+
public nsIDOMDocumentRange getDOMDocumentRange() {
- return (nsIDOMDocumentRange)
getDOMDocument().queryInterface(nsIDOMDocumentRange.NS_IDOMDOCUMENTRANGE_IID);
+ return (nsIDOMDocumentRange) getDOMDocument().queryInterface(
+ nsIDOMDocumentRange.NS_IDOMDOCUMENTRANGE_IID);
}
-
+
public nsIDOMRange createDOMRange() {
return getDOMDocumentRange().createRange();
}
-
+
public void showDragCaret(nsIDOMNode node, long offcet) {
// TODO Sergey Vasilyev figure out with caret
- System.out.println("Show drag caret for " + node.getNodeName() +
":" + offcet); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out
+ .println("Show drag caret for " + node.getNodeName() + ":" +
offcet); //$NON-NLS-1$ //$NON-NLS-2$
}
-
+
public void hideDragCaret() {
// TODO Sergey Vasilyev figure out with caret
System.out.println("Hide drag caret"); //$NON-NLS-1$
}
-
+
public nsITransferable createTransferable() {
nsIComponentManager componentManager = getComponentManager();
- return (nsITransferable)
componentManager.createInstanceByContractID(XPCOM.NS_TRANSFERABLE_CONTRACTID, this,
nsITransferable.NS_ITRANSFERABLE_IID);
+ return (nsITransferable) componentManager.createInstanceByContractID(
+ XPCOM.NS_TRANSFERABLE_CONTRACTID, this,
+ nsITransferable.NS_ITRANSFERABLE_IID);
}
/**
* Returns selection controller which used in selection functionality
+ *
* @return
*/
public nsISelection getSelection() {
@@ -316,16 +339,17 @@
nsISelection selection = domWindow.getSelection();
return selection;
}
-
+
/**
* Function created to restore functionality of MozillaBrowser
+ *
* @return
*/
public nsIDOMElement getLastSelectedElement() {
return getElement(lastSelectedNode);
}
-
+
public nsIDOMNode getLastSelectedNode() {
return lastSelectedNode;
}
@@ -337,29 +361,80 @@
// private void setLastSelectedElement(nsIDOMElement lastSelectedElement) {
// this.lastSelectedElement = lastSelectedElement;
// }
-
+
private void setLastSelectedNode(nsIDOMNode lastSelectedNode) {
this.lastSelectedNode = lastSelectedNode;
}
/**
- * Draws rectangle around the element.
+ * Draws rectangle around the element.
+ *
* @param element
* @param resizerConstrains
* @param scroll
*/
- public void setSelectionRectangle(nsIDOMNode node, int resizerConstrains, boolean
scroll) {
- if (getIFlasher() == null) {
-
+ public void setSelectionRectangle(nsIDOMNode node, int resizerConstrains,
+ boolean scroll) {
+ if (getIFlasher() == null) {
+
return;
}
-
+
nsIDOMElement element = getElement(node);
+
+ //See
https://jira.jboss.org/jira/browse/JBIDE-5117. We make
+ //unnecessary redrawing of previously selected component in VE
+ //which happens in drawElementOutline(nsIDOMElement domElement)
+ //method and call IFlasher.drawElementOutline(nsIDOMElement domElement)
+ //twice for different elements without browser repainting. So, for some
+ //conflicts in Mozilla browser border above TR element wasn't repainted.
- if (getLastSelectedElement() != null) {
-
- scrollRegtangleFlag = scroll && node != null;
-
+ // if (getLastSelectedElement() != null) {
+ //
+ // scrollRegtangleFlag = scroll && node != null;
+ //
+ // try {
+ // ((nsIBaseWindow) getWebBrowser().queryInterface(
+ // nsIBaseWindow.NS_IBASEWINDOW_IID)).repaint(true);
+ // } catch (XPCOMException ex) {
+ // // just ignore its
+ // BrowserPlugin.getDefault().logInfo("repaint failed", ex);
//$NON-NLS-1$
+ // }
+ // if(checkVisability(getLastSelectedElement())){
+ //
+ // if((getLastSelectedElement().getAttribute(VPEFLASHERCOLORATTRIBUTE)==null)||
+ //
(!getLastSelectedElement().getAttribute(VPEFLASHERCOLORATTRIBUTE).equals(flasherHiddentElementColor)))
+ // {
+ //
+ // getIFlasher().setColor(flasherVisialElementColor);
+ // } else{
+ // getIFlasher().setColor(flasherHiddentElementColor);
+ // }
+ //
+ // drawElementOutline(getLastSelectedElement());
+ //
+ // }else {
+ //
+ // getIFlasher().setColor(flasherHiddentElementColor);
+ // nsIDOMElement domElement =
+ // findVisbleParentElement(getLastSelectedElement());
+ //
+ // if(domElement!=null) {
+ //
+ // drawElementOutline(domElement);
+ // }
+ //
+ // }
+ // try {
+ // ((nsIBaseWindow) getWebBrowser().queryInterface(
+ // nsIBaseWindow.NS_IBASEWINDOW_IID)).repaint(true);
+ // } catch (XPCOMException ex) {
+ // // just ignore its
+ // BrowserPlugin.getDefault().logInfo("repaint failed", ex);
//$NON-NLS-1$
+ // }
+
+ // } else
+ if (element != null) {
try {
((nsIBaseWindow) getWebBrowser().queryInterface(
nsIBaseWindow.NS_IBASEWINDOW_IID)).repaint(true);
@@ -367,66 +442,33 @@
// just ignore its
BrowserPlugin.getDefault().logInfo("repaint failed", ex); //$NON-NLS-1$
}
- if(checkVisability(getLastSelectedElement())){
-
- if((getLastSelectedElement().getAttribute(VPEFLASHERCOLORATTRIBUTE)==null)||
- (!getLastSelectedElement().getAttribute(VPEFLASHERCOLORATTRIBUTE).equals(flasherHiddentElementColor)))
{
-
- getIFlasher().setColor(flasherVisialElementColor);
- } else{
- getIFlasher().setColor(flasherHiddentElementColor);
- }
-
- drawElementOutline(getLastSelectedElement());
- }else {
-
- getIFlasher().setColor(flasherHiddentElementColor);
- nsIDOMElement domElement = findVisbleParentElement(getLastSelectedElement());
-
- if(domElement!=null) {
-
- drawElementOutline(domElement);
- }
-
- }
-// try {
-// ((nsIBaseWindow) getWebBrowser().queryInterface(
-// nsIBaseWindow.NS_IBASEWINDOW_IID)).repaint(true);
-// } catch (XPCOMException ex) {
-// // just ignore its
-// BrowserPlugin.getDefault().logInfo("repaint failed", ex); //$NON-NLS-1$
-// }
-
- } else if (element != null) {
-
if (scroll) {
scrollToElement(element);
scrollRegtangleFlag = true;
}
- if(checkVisability(element)){
-
-
- if((element.getAttribute(VPEFLASHERCOLORATTRIBUTE)==null)||
- (!element.getAttribute(VPEFLASHERCOLORATTRIBUTE).equals(flasherHiddentElementColor)))
{
-
- getIFlasher().setColor(flasherVisialElementColor);
- }else {
+ if (checkVisability(element)) {
+
+ if ((element.getAttribute(VPEFLASHERCOLORATTRIBUTE) == null)
+ || (!element.getAttribute(VPEFLASHERCOLORATTRIBUTE)
+ .equals(flasherHiddentElementColor))) {
+
+ getIFlasher().setColor(flasherVisialElementColor);
+ } else {
getIFlasher().setColor(flasherHiddentElementColor);
}
drawElementOutline(element);
- }else {
-
+ } else {
+
getIFlasher().setColor(flasherHiddentElementColor);
nsIDOMElement domElement = findVisbleParentElement(element);
-
- if(domElement!=null) {
-
- drawElementOutline(domElement);
+
+ if (domElement != null) {
+
+ drawElementOutline(domElement);
}
}
-
}
if (xulRunnerVpeResizer != null) {
@@ -437,63 +479,66 @@
}
}
-// setLastSelectedElement(element);
+ // setLastSelectedElement(element);
setLastSelectedNode(node);
lastResizerConstrains = resizerConstrains;
}
-
/**
* @return the iFlasher
*/
private inIFlasher getIFlasher() {
-
- if(iFlasher==null) {
- nsIServiceManager serviceManager = Mozilla.getInstance().getServiceManager();
- iFlasher = (inIFlasher)
serviceManager.getServiceByContractID(XPCOM.IN_FLASHER_CONTRACTID,
inIFlasher.INIFLASHER_IID);
+
+ if (iFlasher == null) {
+ nsIServiceManager serviceManager = Mozilla.getInstance()
+ .getServiceManager();
+ iFlasher = (inIFlasher) serviceManager.getServiceByContractID(
+ XPCOM.IN_FLASHER_CONTRACTID, inIFlasher.INIFLASHER_IID);
iFlasher.setThickness(2);
}
return iFlasher;
}
-
-
+
private IXulRunnerVpeResizer getIXulRunnerVpeResizer() {
-
- if (xulRunnerVpeResizer==null) {
+
+ if (xulRunnerVpeResizer == null) {
xulRunnerVpeResizer = new XulRunnerVpeResizer();
}
return xulRunnerVpeResizer;
}
-
-
-
- /**Function created for checking if user can see element or not.
- * Element doesn't shows in VPE if it's has 'display:none;' attribute in
style.
+
+ /**
+ * Function created for checking if user can see element or not. Element
+ * doesn't shows in VPE if it's has 'display:none;' attribute in style.
*
- * @param node for checking it's visability
- * @param iFlasher flasher which used for drawning border for elements adn in
- * which was setted color in depends of visability of element
+ * @param node
+ * for checking it's visability
+ * @param iFlasher
+ * flasher which used for drawning border for elements adn in
+ * which was setted color in depends of visability of element
*
* @return false for hiddent elements and true for visble elements
*/
- private boolean checkVisability(nsIDOMNode node){
-
+ private boolean checkVisability(nsIDOMNode node) {
+
nsIDOMElement domElement;
- try{
-
- domElement = (nsIDOMElement) node.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
-
- } catch(XPCOMException exception) {
- //if we can cast it's is invisible elenebt
+ try {
+
+ domElement = (nsIDOMElement) node
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+
+ } catch (XPCOMException exception) {
+ // if we can cast it's is invisible elenebt
return false;
}
-
- //TODO add check not inline styles attribute such as styleclass
+
+ // TODO add check not inline styles attribute such as styleclass
String inlineStyle = domElement.getAttribute(STYLE_ATTR);
-
- return inlineStyle==null?true:!PATTERN.matcher(inlineStyle).matches();
+
+ return inlineStyle == null ? true : !PATTERN.matcher(inlineStyle)
+ .matches();
}
-
+
/**
* Finds visible nearest visible node for hidden node
*
@@ -501,27 +546,27 @@
*
* @return nearest visible node or null if can't find
*/
- private nsIDOMElement findVisbleParentElement(nsIDOMElement element) {
-
+ private nsIDOMElement findVisbleParentElement(nsIDOMElement element) {
+
nsIDOMElement parentElement;
-
- try {
-
- parentElement = (nsIDOMElement) element.getParentNode()
+
+ try {
+
+ parentElement = (nsIDOMElement) element.getParentNode()
.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- } catch (XPCOMException ex) {
- // if parent node isn't nsIDOMElement just return null;
- return null;
- }
- while(parentElement!=null&&!checkVisability(parentElement)) {
- if(checkVisability(parentElement)) {
-
+ } catch (XPCOMException ex) {
+ // if parent node isn't nsIDOMElement just return null;
+ return null;
+ }
+ while (parentElement != null && !checkVisability(parentElement)) {
+ if (checkVisability(parentElement)) {
+
return parentElement;
- }else {
-
- parentElement = (nsIDOMElement) parentElement.getParentNode()
+ } else {
+
+ parentElement = (nsIDOMElement) parentElement.getParentNode()
.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
-
+
}
}
return parentElement;
@@ -535,16 +580,20 @@
* @param newHeight
* @param aResizedObject
*/
- private void endResizing(int usedHandle, int newTop, int newLeft, int newWidth, int
newHeight, nsIDOMElement aResizedObject) {
- onElementResize(aResizedObject, usedHandle, newTop, newLeft, newWidth, newHeight);
+ private void endResizing(int usedHandle, int newTop, int newLeft,
+ int newWidth, int newHeight, nsIDOMElement aResizedObject) {
+ onElementResize(aResizedObject, usedHandle, newTop, newLeft, newWidth,
+ newHeight);
}
-
+
/**
*
*/
public void showResizer() {
- if (xulRunnerVpeResizer != null && getLastSelectedElement() != null &&
lastResizerConstrains != 0) {
- xulRunnerVpeResizer.show(getLastSelectedElement(), lastResizerConstrains);
+ if (xulRunnerVpeResizer != null && getLastSelectedElement() != null
+ && lastResizerConstrains != 0) {
+ xulRunnerVpeResizer.show(getLastSelectedElement(),
+ lastResizerConstrains);
}
}
@@ -552,99 +601,114 @@
* Hide resizer markers
*/
public void hideResizer() {
- if(xulRunnerVpeResizer != null) {
+ if (xulRunnerVpeResizer != null) {
xulRunnerVpeResizer.hide();
}
}
-
+
public void showSelectionRectangle() {
-
-// ((nsIBaseWindow)getWebBrowser().queryInterface(nsIBaseWindow.NS_IBASEWINDOW_IID)).repaint(false);
+ //
((nsIBaseWindow)getWebBrowser().queryInterface(nsIBaseWindow.NS_IBASEWINDOW_IID)).repaint(false);
+
if (getIFlasher() != null && getLastSelectedElement() != null) {
if (scrollRegtangleFlag) {
scrollRegtangleFlag = false;
-
- scrollToElement(getLastSelectedElement());
- }
- //checks visability of element
- if(checkVisability(getLastSelectedElement())){
-
- if((getLastSelectedElement().getAttribute(VPEFLASHERCOLORATTRIBUTE)==null)||
- (!getLastSelectedElement().getAttribute(VPEFLASHERCOLORATTRIBUTE).equals(flasherHiddentElementColor)))
{
-
- getIFlasher().setColor(flasherVisialElementColor);
- }else{
-
+
+ scrollToElement(getLastSelectedElement());
+ }
+ // checks visability of element
+ if (checkVisability(getLastSelectedElement())) {
+
+ if ((getLastSelectedElement().getAttribute(
+ VPEFLASHERCOLORATTRIBUTE) == null)
+ || (!getLastSelectedElement().getAttribute(
+ VPEFLASHERCOLORATTRIBUTE).equals(
+ flasherHiddentElementColor))) {
+
+ getIFlasher().setColor(flasherVisialElementColor);
+ } else {
+
getIFlasher().setColor(flasherHiddentElementColor);
}
-
+
drawElementOutline(getLastSelectedElement());
- }else {
-
+ } else {
+
getIFlasher().setColor(flasherHiddentElementColor);
nsIDOMElement domElement = findVisbleParentElement(getLastSelectedElement());
-
- if(domElement!=null) {
+
+ if (domElement != null) {
drawElementOutline(domElement);
}
}
- }
-// else if(getIFlasher()!=null&&Platform.OS_MACOSX.equals(Platform.getOS())){
-// //Max Areshkau (bug on Mac OS X, when we switch to preview from other view,
selection rectangle doesn't disappear
-// //TODO Max Areshkau (may be exist passability not draw selection on resize event
when we switches to other view)
-// try {
-// ((nsIBaseWindow)getWebBrowser().queryInterface(nsIBaseWindow.NS_IBASEWINDOW_IID)).repaint(true);
-// } catch(XPCOMException ex) {
-// //just ignore its
-// BrowserPlugin.getDefault().logInfo("repaint failed", ex); //$NON-NLS-1$
-// }
-// }
+ }
+ // else
+ // if(getIFlasher()!=null&&Platform.OS_MACOSX.equals(Platform.getOS())){
+ // //Max Areshkau (bug on Mac OS X, when we switch to preview from other
+ // view, selection rectangle doesn't disappear
+ // //TODO Max Areshkau (may be exist passability not draw selection on
+ // resize event when we switches to other view)
+ // try {
+ //
((nsIBaseWindow)getWebBrowser().queryInterface(nsIBaseWindow.NS_IBASEWINDOW_IID)).repaint(true);
+ // } catch(XPCOMException ex) {
+ // //just ignore its
+ // BrowserPlugin.getDefault().logInfo("repaint failed", ex);
//$NON-NLS-1$
+ // }
+ // }
}
+
/**
* Scrools viiew to some elements
- * @param element -element to which we should scroll
+ *
+ * @param element
+ * -element to which we should scroll
*/
- private void scrollToElement(nsIDOMElement element){
-
+ private void scrollToElement(nsIDOMElement element) {
+
getIFlasher().scrollElementIntoView(element);
}
/**
* Adds selection listener
+ *
* @param selectionListener
*/
- public void addSelectionListener (
- nsISelectionListener selectionListener) {
+ public void addSelectionListener(nsISelectionListener selectionListener) {
nsISelection selection = getSelection();
- nsISelectionPrivate selectionPrivate = (nsISelectionPrivate)
selection.queryInterface(nsISelectionPrivate.NS_ISELECTIONPRIVATE_IID);
+ nsISelectionPrivate selectionPrivate = (nsISelectionPrivate) selection
+ .queryInterface(nsISelectionPrivate.NS_ISELECTIONPRIVATE_IID);
selectionPrivate.addSelectionListener(selectionListener);
this.selectionListener = selectionListener;
}
+
/**
* Removes selection listener
*/
public void removeSelectionListener() {
if (this.selectionListener != null) {
nsISelection selection = getSelection();
- nsISelectionPrivate selectionPrivate = (nsISelectionPrivate)
selection.queryInterface(nsISelectionPrivate.NS_ISELECTIONPRIVATE_IID);
+ nsISelectionPrivate selectionPrivate = (nsISelectionPrivate) selection
+ .queryInterface(nsISelectionPrivate.NS_ISELECTIONPRIVATE_IID);
try {
- selectionPrivate.removeSelectionListener(this.selectionListener);
+ selectionPrivate
+ .removeSelectionListener(this.selectionListener);
} catch (XPCOMException xpcomException) {
- //this exception throws when progress listener already has been deleted,
- //so just ignore if error code NS_ERROR_FAILURE
- //mareshkau fix for jbide-3155
- if(xpcomException.errorcode!=XulRunnerBrowser.NS_ERROR_FAILURE) {
- throw xpcomException;
- }
+ // this exception throws when progress listener already has been
+ // deleted,
+ // so just ignore if error code NS_ERROR_FAILURE
+ // mareshkau fix for jbide-3155
+ if (xpcomException.errorcode != XulRunnerBrowser.NS_ERROR_FAILURE) {
+ throw xpcomException;
+ }
}
}
- this.selectionListener=null;
+ this.selectionListener = null;
}
+
/**
* get nsIDomElement from nsIDomNode
*
- * if node is nsIDomElement - return it
+ * if node is nsIDomElement - return it
*
* if node is text node - return it's
*
@@ -671,54 +735,62 @@
return null;
}
-
+
/**
* Decorator
+ *
* @author mareshkau
- * @param domElement arround which border will be shown
+ * @param domElement
+ * arround which border will be shown
*
*/
private void drawElementOutline(nsIDOMElement domElement) {
- //fix for JBIDE-3969
-// if(Platform.OS_MACOSX.equals(Platform.getOS())&&hasSelectInParenNodes(domElement.getParentNode()))
{
-// return;
-// }
- //restore style for previously bordered element
- if(this.lastBorderedElement!=null &&
this.lastBorderedElement.getAttribute(STYLE_ATTR)!=null) {
- String style = this.lastBorderedElement.getAttribute(PREV_STYLE_ATTR_NAME);
+ // fix for JBIDE-3969
+ //
if(Platform.OS_MACOSX.equals(Platform.getOS())&&hasSelectInParenNodes(domElement.getParentNode()))
+ // {
+ // return;
+ // }
+ // restore style for previously bordered element
+ if (this.lastBorderedElement != null
+ && this.lastBorderedElement.getAttribute(STYLE_ATTR) != null) {
+ String style = this.lastBorderedElement
+ .getAttribute(PREV_STYLE_ATTR_NAME);
this.lastBorderedElement.removeAttribute(PREV_STYLE_ATTR_NAME);
this.lastBorderedElement.setAttribute(STYLE_ATTR, style);
}
-
- //save style for early bordered element
+
+ // save style for early bordered element
String oldstyle = domElement.getAttribute(STYLE_ATTR);
- if(flasherHiddentElementColor.equals(getIFlasher().getColor())) {
- domElement.setAttribute(STYLE_ATTR,domElement.getAttribute(STYLE_ATTR)+';'+XulRunnerEditor.INVISIBLE_ELEMENT_BORDER);
- }else {
- domElement.setAttribute(STYLE_ATTR,domElement.getAttribute(STYLE_ATTR)+';'+
XulRunnerEditor.VISIBLE_ELEMENT_BORDER);
+ if (flasherHiddentElementColor.equals(getIFlasher().getColor())) {
+ domElement.setAttribute(STYLE_ATTR, domElement
+ .getAttribute(STYLE_ATTR)
+ + ';' + XulRunnerEditor.INVISIBLE_ELEMENT_BORDER);
+ } else {
+ domElement.setAttribute(STYLE_ATTR, domElement
+ .getAttribute(STYLE_ATTR)
+ + ';' + XulRunnerEditor.VISIBLE_ELEMENT_BORDER);
}
this.lastBorderedElement = domElement;
this.lastBorderedElement.setAttribute(PREV_STYLE_ATTR_NAME, oldstyle);
- //under osx function drawElementOutline not works
- if(!Platform.OS_MACOSX.equals(Platform.getOS())){
+ // under osx function drawElementOutline not works
+ if (!Platform.OS_MACOSX.equals(Platform.getOS())) {
getIFlasher().drawElementOutline(domElement);
}
}
/**
- * Checks if node has select in parent node, if has it's cause crash
- * on OSX and xulrunner 1.8.1.3
+ * Checks if node has select in parent node, if has it's cause crash on OSX
+ * and xulrunner 1.8.1.3
+ *
* @param domElement
* @return
*/
-// private boolean hasSelectInParenNodes(nsIDOMNode domNode){
-// if(domNode==null) {
-// return false;
-// }else if("select".equalsIgnoreCase(domNode.getNodeName())){ //$NON-NLS-1$
-// return true;
-// } else {
-// return hasSelectInParenNodes(domNode.getParentNode());
-// }
-// }
+ // private boolean hasSelectInParenNodes(nsIDOMNode domNode){
+ // if(domNode==null) {
+ // return false;
+ // }else if("select".equalsIgnoreCase(domNode.getNodeName())){ //$NON-NLS-1$
+ // return true;
+ // } else {
+ // return hasSelectInParenNodes(domNode.getParentNode());
+ // }
+ // }
}
-
-