use of com.gargoylesoftware.htmlunit.javascript.host.event.MouseEvent in project htmlunit by HtmlUnit.
the class HTMLTableCellElement method getOffsetWidth.
/**
* {@inheritDoc}
*/
@Override
public int getOffsetWidth() {
float w = super.getOffsetWidth();
final MouseEvent event = MouseEvent.getCurrentMouseEvent();
if (isAncestorOfEventTarget(event)) {
return (int) w;
}
if (isDisplayNone()) {
return 0;
}
final ComputedCSSStyleDeclaration style = getWindow().getComputedStyle(this, null);
if ("collapse".equals(style.getStyleAttribute(StyleAttributes.Definition.BORDER_COLLAPSE))) {
final HtmlTableRow row = getRow();
if (row != null) {
final HtmlElement thiz = getDomNodeOrDie();
final List<HtmlTableCell> cells = row.getCells();
final boolean ie = getBrowserVersion().hasFeature(JS_TABLE_CELL_OFFSET_INCLUDES_BORDER);
final boolean leftmost = cells.indexOf(thiz) == 0;
final boolean rightmost = cells.indexOf(thiz) == cells.size() - 1;
w -= (ie && leftmost ? 0 : 0.5) * style.getBorderLeftValue();
w -= (ie && rightmost ? 0 : 0.5) * style.getBorderRightValue();
}
}
return (int) w;
}
use of com.gargoylesoftware.htmlunit.javascript.host.event.MouseEvent in project htmlunit by HtmlUnit.
the class HTMLElement method getOffsetHeight.
/**
* Returns this element's <tt>offsetHeight</tt>, which is the element height plus the element's padding
* plus the element's border. This method returns a dummy value compatible with mouse event coordinates
* during mouse events.
* @return this element's <tt>offsetHeight</tt>
* @see <a href="http://msdn2.microsoft.com/en-us/library/ms534199.aspx">MSDN Documentation</a>
* @see <a href="http://www.quirksmode.org/js/elementdimensions.html">Element Dimensions</a>
*/
@JsxGetter
public int getOffsetHeight() {
if (isDisplayNone() || !getDomNodeOrDie().isAttachedToPage()) {
return 0;
}
final MouseEvent event = MouseEvent.getCurrentMouseEvent();
if (isAncestorOfEventTarget(event)) {
// compute appropriate offset height to pretend mouse event was produced within this element
return event.getClientY() - getPosY() + 50;
}
final ComputedCSSStyleDeclaration style = getWindow().getComputedStyle(this, null);
return style.getCalculatedHeight(true, true);
}
use of com.gargoylesoftware.htmlunit.javascript.host.event.MouseEvent in project htmlunit by HtmlUnit.
the class HTMLElement method getOffsetWidth.
/**
* Returns this element's <tt>offsetWidth</tt>, which is the element width plus the element's padding
* plus the element's border. This method returns a dummy value compatible with mouse event coordinates
* during mouse events.
* @return this element's <tt>offsetWidth</tt>
* @see <a href="http://msdn2.microsoft.com/en-us/library/ms534304.aspx">MSDN Documentation</a>
* @see <a href="http://www.quirksmode.org/js/elementdimensions.html">Element Dimensions</a>
*/
@JsxGetter
public int getOffsetWidth() {
if (isDisplayNone() || !getDomNodeOrDie().isAttachedToPage()) {
return 0;
}
final MouseEvent event = MouseEvent.getCurrentMouseEvent();
if (isAncestorOfEventTarget(event)) {
// compute appropriate offset width to pretend mouse event was produced within this element
return event.getClientX() - getPosX() + 50;
}
final ComputedCSSStyleDeclaration style = getWindow().getComputedStyle(this, null);
return style.getCalculatedWidth(true, true);
}
Aggregations