1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.rendering.wikimodel.xhtml.handler

File ListTagHandler.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

2
7
4
1
65
28
5
0.71
1.75
4
1.25

Classes

Class Line # Actions
ListTagHandler 28 7 0% 5 0
1.0100%
 

Contributing tests

This file is covered by 322 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.rendering.wikimodel.xhtml.handler;
21   
22    import org.xwiki.rendering.wikimodel.xhtml.impl.TagContext;
23   
24    /**
25    * @version $Id: 52d3406bd97b44e70cf64ba34b284b2a9fa4ee2d $
26    * @since 4.0M1
27    */
 
28    public class ListTagHandler extends TagHandler
29    {
 
30  437 toggle public ListTagHandler()
31    {
32  437 super(false);
33    }
34   
 
35  300 toggle @Override
36    public boolean isBlockHandler(TagContext context)
37    {
38  300 TagContext parent = context.getParent();
39    // A new list is considered a block element only if the parent is not a
40    // list item since nested lists
41    // are not new block elements
42  300 return !(parent.isTag("li") || parent.isTag("dd") || parent.isTag("dt"));
43    }
44   
 
45  150 toggle @Override
46    protected void begin(TagContext context)
47    {
48  150 sendEmptyLines(context);
49    // We only send a new list event if we're not already inside a list.
50  150 context.getScannerContext().beginList(context.getParams());
51    }
52   
 
53  150 toggle @Override
54    protected void end(TagContext context)
55    {
56    // We only need to close the list if we're on the last list item.
57    // Note that we need to close the list explicitely and not wait for the
58    // next element to close it
59    // since the next element could be an implicit paragraph.
60    // For example: <html><ul><li>item</li></ul>a</html>
61  150 if (context.getTagStack().isEndOfList()) {
62  85 context.getScannerContext().endList();
63    }
64    }
65    }