Exemple #1
0
 public void doLayout(
     int availWidth,
     int availHeight,
     boolean expandWidth,
     boolean expandHeight,
     FloatingBoundsSource floatBoundsSource,
     int defaultOverflowX,
     int defaultOverflowY,
     boolean sizeOnly) {
   RenderState renderState = this.modelNode.getRenderState();
   int counterStart = 1;
   Object rootNode = this.modelNode;
   if (!(rootNode instanceof HTMLElementImpl)) {
     return;
   }
   HTMLElementImpl rootElement = (HTMLElementImpl) rootNode;
   String startText = rootElement.getAttribute("start");
   if (startText != null) {
     try {
       counterStart = Integer.parseInt(startText);
     } catch (NumberFormatException nfe) {
       // ignore
     }
   }
   renderState.resetCount(DEFAULT_COUNTER_NAME, this.listNesting, counterStart);
   super.doLayout(
       availWidth,
       availHeight,
       expandWidth,
       expandHeight,
       floatBoundsSource,
       defaultOverflowX,
       defaultOverflowY,
       sizeOnly);
 }
Exemple #2
0
 protected void applyStyle(int availWidth, int availHeight) {
   super.applyStyle(availWidth, availHeight);
   ListStyle listStyle = this.listStyle;
   if (listStyle == null || listStyle.type == ListStyle.TYPE_UNSET) {
     Object rootNode = this.modelNode;
     if (!(rootNode instanceof HTMLElementImpl)) {
       return;
     }
     HTMLElementImpl rootElement = (HTMLElementImpl) rootNode;
     if (listStyle == null) {
       listStyle = new ListStyle();
       this.listStyle = listStyle;
     }
     if ("ul".equalsIgnoreCase(rootElement.getTagName())) {
       int listNesting = this.listNesting;
       if (listNesting == 0) {
         listStyle.type = ListStyle.TYPE_DISC;
       } else if (listNesting == 1) {
         listStyle.type = ListStyle.TYPE_CIRCLE;
       } else {
         listStyle.type = ListStyle.TYPE_SQUARE;
       }
     } else {
       listStyle.type = ListStyle.TYPE_DECIMAL;
     }
   }
 }
Exemple #3
0
 public static StyleSheet jParseInlineStyle(
     final String style,
     final String encoding,
     final HTMLElementImpl element,
     final boolean inlinePriority) {
   try {
     return CSSParserFactory.getInstance()
         .parse(
             style,
             new SafeNetworkProcessor(null),
             null,
             SourceType.INLINE,
             element,
             inlinePriority,
             element.getDocumentURL());
   } catch (IOException | CSSException e) {
     logger.log(Level.SEVERE, "Unable to parse CSS. CSS=[" + style + "].", e);
     return getEmptyStyleSheet();
   }
 }
 public BorderInfo getBorderInfo() {
   BorderInfo binfo = this.borderInfo;
   if (binfo != INVALID_BORDER_INFO) {
     return binfo;
   }
   binfo = super.getBorderInfo();
   if (binfo == null
       || (binfo.topStyle == HtmlValues.BORDER_STYLE_NONE
           && binfo.bottomStyle == HtmlValues.BORDER_STYLE_NONE
           && binfo.leftStyle == HtmlValues.BORDER_STYLE_NONE
           && binfo.rightStyle == HtmlValues.BORDER_STYLE_NONE)) {
     if (binfo == null) {
       binfo = new BorderInfo();
     }
     HTMLElementImpl element = this.element;
     if (element != null) {
       String border = element.getAttribute("border");
       if (border != null) {
         border = border.trim();
         int value;
         int valueType;
         if (border.endsWith("%")) {
           valueType = HtmlInsets.TYPE_PERCENT;
           try {
             value = Integer.parseInt(border.substring(0, border.length() - 1));
           } catch (NumberFormatException nfe) {
             value = 0;
           }
         } else {
           valueType = HtmlInsets.TYPE_PIXELS;
           try {
             value = Integer.parseInt(border);
           } catch (NumberFormatException nfe) {
             value = 0;
           }
         }
         HtmlInsets borderInsets = new HtmlInsets();
         borderInsets.top = borderInsets.left = borderInsets.right = borderInsets.bottom = value;
         borderInsets.topType =
             borderInsets.leftType = borderInsets.rightType = borderInsets.bottomType = valueType;
         binfo.insets = borderInsets;
         if (binfo.topColor == null) {
           binfo.topColor = Color.BLACK;
         }
         if (binfo.leftColor == null) {
           binfo.leftColor = Color.BLACK;
         }
         if (binfo.rightColor == null) {
           binfo.rightColor = Color.BLACK;
         }
         if (binfo.bottomColor == null) {
           binfo.bottomColor = Color.BLACK;
         }
         if (value != 0) {
           binfo.topStyle =
               binfo.leftStyle =
                   binfo.rightStyle = binfo.bottomStyle = HtmlValues.BORDER_STYLE_SOLID;
         }
       }
     }
   }
   this.borderInfo = binfo;
   return binfo;
 }