Example usage for com.google.gwt.dom.client Style getDisplay

List of usage examples for com.google.gwt.dom.client Style getDisplay

Introduction

In this page you can find the example usage for com.google.gwt.dom.client Style getDisplay.

Prototype

public String getDisplay() 

Source Link

Usage

From source file:com.dom_distiller.client.DomUtil.java

License:Open Source License

public static boolean isVisible(Element e) {
    Style style = getComputedStyle(e);
    float opacity = 1.0F;
    try {/*from   w  w  w .  j ava  2s  .c om*/
        opacity = Float.parseFloat(style.getOpacity());
    } catch (NumberFormatException exception) {
    }
    return !(style.getDisplay().equals("none") || style.getVisibility().equals("hidden") || opacity == 0.0F);
}

From source file:com.dom_distiller.client.FilteringDomVisitor.java

License:Open Source License

private static void logVisibilityInfo(Element e, boolean visible) {
    if (!LogUtil.isLoggable(LogUtil.DEBUG_LEVEL_VISIBILITY_INFO))
        return;// www  . j a v a  2  s .co m
    Style style = DomUtil.getComputedStyle(e);
    LogUtil.logToConsole((visible ? "KEEP " : "SKIP ") + e.getTagName() + ": id=" + e.getId() + ", dsp="
            + style.getDisplay() + ", vis=" + style.getVisibility() + ", opaq=" + style.getOpacity());
}

From source file:de.l3s.boilerpipe.sax.BoilerpipeHTMLContentHandler.java

License:Open Source License

private TagAction getComputedTagAction(Element element) {
    Style style = DomUtil.getComputedStyle(element);
    if (displayStyleToTagAction.containsKey(style.getDisplay())) {
        return displayStyleToTagAction.get(style.getDisplay());
    }//from   w  ww  .  java 2 s . c  o  m
    return null;
}

From source file:org.chromium.distiller.DomUtil.java

License:Open Source License

public static boolean isVisible(Element e) {
    Style style = getComputedStyle(e);
    double opacity = JavaScript.parseFloat(style.getOpacity());
    return !(style.getDisplay().equals("none") || style.getVisibility().equals("hidden") || opacity == 0.0F);
}

From source file:org.chromium.distiller.webdocument.ElementAction.java

License:Open Source License

public static ElementAction getForElement(Element element) {
    Style style = DomUtil.getComputedStyle(element);
    ElementAction action = new ElementAction();
    String tagName = element.getTagName();
    switch (style.getDisplay()) {
    case "inline":
        break;/*from   w ww. j a v  a  2 s. c  o m*/
    case "inline-block":
    case "inline-flex":
        action.changesTagLevel = true;
        break;
    case "block":
        // Special casing for drop cap letter with "float".
        // Having style "float" would imply "display: block".
        // Ref: http://crbug.com/593128
        if (!"none".equals(style.getProperty("float")) && "SPAN".equals(tagName)) {
            break;
        }
        // Intentional fall through.
        // See http://www.w3.org/TR/CSS2/tables.html#table-display
        // and http://www.w3.org/TR/css-flexbox-1/#flex-containers
        // The default case includes the following display types:
        // list-item
        // inline-table
        // table-row
        // table-row-group
        // table-header-group
        // table-footer-group
        // table-column
        // table-column-group
        // table-cell
        // table-caption
        // flex
    default:
        action.flush = true;
        action.changesTagLevel = true;
        break;
    }

    if (!"HTML".equals(tagName) && !"BODY".equals(tagName)) {
        String className = element.getAttribute("class");
        int classCount = DomUtil.getClassList(element).length();
        String id = element.getAttribute("id");
        if ((REG_COMMENT.test(className) || REG_COMMENT.test(id)) && classCount <= MAX_CLASS_COUNT) {
            action.labels.push(DefaultLabels.STRICTLY_NOT_CONTENT);
        }

        switch (tagName) {
        case "ASIDE":
        case "NAV":
            action.labels.push(DefaultLabels.STRICTLY_NOT_CONTENT);
            break;
        case "LI":
            action.labels.push(DefaultLabels.LI);
            break;
        case "H1":
            action.labels.push(DefaultLabels.H1);
            action.labels.push(DefaultLabels.HEADING);
            break;
        case "H2":
            action.labels.push(DefaultLabels.H2);
            action.labels.push(DefaultLabels.HEADING);
            break;
        case "H3":
            action.labels.push(DefaultLabels.H3);
            action.labels.push(DefaultLabels.HEADING);
            break;
        case "A":
            // TODO(cjhopman): Anchors probably shouldn't unconditionally change the tag
            // level.
            action.changesTagLevel = true;
            if (element.hasAttribute("href")) {
                action.isAnchor = true;
            }
            break;
        }
    }
    return action;
}