+ CSS-basiertes Layout
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This code displays on non-IE browsers and on IE 7 or higher.
+
+
+
+
+
+
+
Index: src/test/java/org/apache/wicket/markup/html/basic/SimplePageExpectedResult_12b.html
===================================================================
--- src/test/java/org/apache/wicket/markup/html/basic/SimplePageExpectedResult_12b.html (revision 0)
+++ src/test/java/org/apache/wicket/markup/html/basic/SimplePageExpectedResult_12b.html (revision 0)
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: src/test/java/org/apache/wicket/markup/html/basic/SimplePage_12b.java
===================================================================
--- src/test/java/org/apache/wicket/markup/html/basic/SimplePage_12b.java (revision 0)
+++ src/test/java/org/apache/wicket/markup/html/basic/SimplePage_12b.java (revision 0)
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.markup.html.basic;
+
+import org.apache.wicket.markup.html.WebPage;
+
+
+/**
+ * Conditional comments
+ *
+ * @author Juergen Donnerstag
+ */
+public class SimplePage_12b extends WebPage
+{
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Construct.
+ */
+ public SimplePage_12b()
+ {
+ }
+}
Index: src/test/java/org/apache/wicket/markup/html/basic/SimplePage_12c.html
===================================================================
--- src/test/java/org/apache/wicket/markup/html/basic/SimplePage_12c.html (revision 0)
+++ src/test/java/org/apache/wicket/markup/html/basic/SimplePage_12c.html (revision 0)
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: src/test/java/org/apache/wicket/markup/html/basic/SimplePage_12b.html
===================================================================
--- src/test/java/org/apache/wicket/markup/html/basic/SimplePage_12b.html (revision 0)
+++ src/test/java/org/apache/wicket/markup/html/basic/SimplePage_12b.html (revision 0)
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: src/test/java/org/apache/wicket/markup/html/basic/SimplePage_12c.java
===================================================================
--- src/test/java/org/apache/wicket/markup/html/basic/SimplePage_12c.java (revision 0)
+++ src/test/java/org/apache/wicket/markup/html/basic/SimplePage_12c.java (revision 0)
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.markup.html.basic;
+
+import org.apache.wicket.markup.html.WebPage;
+
+
+/**
+ * Conditional comments
+ *
+ * @author Juergen Donnerstag
+ */
+public class SimplePage_12c extends WebPage
+{
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Construct.
+ */
+ public SimplePage_12c()
+ {
+ }
+}
Index: src/main/java/org/apache/wicket/markup/parser/XmlTag.java
===================================================================
--- src/main/java/org/apache/wicket/markup/parser/XmlTag.java (revision 1072301)
+++ src/main/java/org/apache/wicket/markup/parser/XmlTag.java (working copy)
@@ -101,6 +101,8 @@
/** True if the name of this tag was changed. */
private boolean nameChanged = false;
+ boolean insideConditionalComments = false;
+
/**
* Construct.
*/
@@ -659,4 +661,12 @@
buffer.append('>');
return buffer;
}
+
+ /**
+ * @return insideConditionalComments
+ */
+ public boolean isInsideConditionalComments()
+ {
+ return insideConditionalComments;
+ }
}
Index: src/test/java/org/apache/wicket/markup/html/basic/SimplePage_12a.java
===================================================================
--- src/test/java/org/apache/wicket/markup/html/basic/SimplePage_12a.java (revision 0)
+++ src/test/java/org/apache/wicket/markup/html/basic/SimplePage_12a.java (revision 0)
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.markup.html.basic;
+
+import org.apache.wicket.markup.html.WebPage;
+
+
+/**
+ * Conditional comments
+ *
+ * @author Juergen Donnerstag
+ */
+public class SimplePage_12a extends WebPage
+{
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Construct.
+ */
+ public SimplePage_12a()
+ {
+ }
+}
Index: src/test/java/org/apache/wicket/markup/html/basic/SimplePageTest.java
===================================================================
--- src/test/java/org/apache/wicket/markup/html/basic/SimplePageTest.java (revision 1072301)
+++ src/test/java/org/apache/wicket/markup/html/basic/SimplePageTest.java (working copy)
@@ -333,6 +333,30 @@
/**
* @throws Exception
*/
+ public void testRenderHomePage_12a() throws Exception
+ {
+ executeTest(SimplePage_12a.class, "SimplePageExpectedResult_12a.html");
+ }
+
+ /**
+ * @throws Exception
+ */
+ public void testRenderHomePage_12b() throws Exception
+ {
+ executeTest(SimplePage_12b.class, "SimplePageExpectedResult_12b.html");
+ }
+
+ /**
+ * @throws Exception
+ */
+ public void testRenderHomePage_12c() throws Exception
+ {
+ executeTest(SimplePage_12c.class, "SimplePageExpectedResult_12c.html");
+ }
+
+ /**
+ * @throws Exception
+ */
public void testRenderHomePage_13() throws Exception
{
executeTest(SimplePage_13.class, "SimplePageExpectedResult_13.html");
Index: src/test/java/org/apache/wicket/markup/html/basic/SimplePageExpectedResult_12a.html
===================================================================
--- src/test/java/org/apache/wicket/markup/html/basic/SimplePageExpectedResult_12a.html (revision 0)
+++ src/test/java/org/apache/wicket/markup/html/basic/SimplePageExpectedResult_12a.html (revision 0)
@@ -0,0 +1,56 @@
+
+
+
+ CSS-basiertes Layout
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: src/main/java/org/apache/wicket/markup/parser/XmlPullParser.java
===================================================================
--- src/main/java/org/apache/wicket/markup/parser/XmlPullParser.java (revision 1072301)
+++ src/main/java/org/apache/wicket/markup/parser/XmlPullParser.java (working copy)
@@ -67,6 +67,8 @@
/** If lastType == TAG, than ... */
private XmlTag lastTag;
+ boolean readingConditionalMarkup;
+
/**
* Construct.
*/
@@ -298,43 +300,65 @@
// Handle comments
if (tagText.startsWith("!--"))
{
- // Normal comment section.
- // Skip ahead to "-->". Note that you can not simply test for
- // tagText.endsWith("--") as the comment might contain a '>'
- // inside.
- int pos = input.find("-->", openBracketIndex + 1);
- if (pos == -1)
+ // bypassing downlevel-revealed conditional comments -
+ if (readingConditionalMarkup)
{
- throw new ParseException("Unclosed comment beginning at" + getLineAndColumnText(),
- openBracketIndex);
+ if (tagText.contains("![endif]--"))
+ {
+ lastType = ELEMENT_TYPE.CONDITIONAL_COMMENT;
+ readingConditionalMarkup = false;
+ }
+ input.setPosition(closeBracketIndex + 1);
}
+ // Conditional comment? E.g.
+ // ""
+ else if (tagText.startsWith("!--[if ") && tagText.endsWith("]"))
+ {
+ int pos = input.find("]-->", openBracketIndex + 1);
+ if (pos == -1)
+ {
+ throw new ParseException("Unclosed conditional comment beginning at" +
+ getLineAndColumnText(), openBracketIndex);
+ }
- pos += 3;
- lastText = input.getSubstring(openBracketIndex, pos);
- lastType = ELEMENT_TYPE.COMMENT;
+ pos += 4;
+ lastText = input.getSubstring(openBracketIndex, pos);
- // Conditional comment? E.g. ""
- if (tagText.startsWith("!--[if ") && tagText.endsWith("]") &&
- lastText.toString().endsWith(""))
- {
lastType = ELEMENT_TYPE.CONDITIONAL_COMMENT;
-
+ readingConditionalMarkup = true;
// Actually it is no longer a comment. It is now
// up to the browser to select the section appropriate.
input.setPosition(closeBracketIndex + 1);
}
else
{
+ // Normal comment section.
+ // Skip ahead to "-->". Note that you can not simply test for
+ // tagText.endsWith("--") as the comment might contain a '>'
+ // inside.
+ int pos = input.find("-->", openBracketIndex + 1);
+ if (pos == -1)
+ {
+ throw new ParseException("Unclosed comment beginning at" +
+ getLineAndColumnText(), openBracketIndex);
+ }
+
+ pos += 3;
+ lastText = input.getSubstring(openBracketIndex, pos);
+ lastType = ELEMENT_TYPE.COMMENT;
+
input.setPosition(pos);
}
return;
}
// The closing tag of a conditional comment, e.g.
- // ""
+ // "
+ // and also "
if (tagText.equals("![endif]--"))
{
lastType = ELEMENT_TYPE.CONDITIONAL_COMMENT;
+ readingConditionalMarkup = false;
input.setPosition(closeBracketIndex + 1);
return;
}
@@ -592,6 +616,7 @@
// Extract the tag from the pattern matcher
tag.name = tagnameParser.getName();
tag.namespace = tagnameParser.getNamespace();
+ tag.insideConditionalComments = readingConditionalMarkup;
// Are we at the end? Then there are no attributes, so we just
// return the tag
Index: src/main/java/org/apache/wicket/markup/parser/filter/HtmlHandler.java
===================================================================
--- src/main/java/org/apache/wicket/markup/parser/filter/HtmlHandler.java (revision 1072301)
+++ src/main/java/org/apache/wicket/markup/parser/filter/HtmlHandler.java (working copy)
@@ -58,6 +58,8 @@
doesNotRequireCloseTag.put("meta", Boolean.TRUE);
}
+ private ComponentTag next;
+
/**
* Construct.
*/
@@ -67,8 +69,17 @@
public MarkupElement nextTag() throws ParseException
{
- // Get the next tag. If null, no more tags are available
- final ComponentTag tag = (ComponentTag)getNextFilter().nextTag();
+ ComponentTag tag = null;
+ if (next != null)
+ {
+ tag = next;
+ next = null;
+ }
+ else
+ {
+ // Get the next tag. If null, no more tags are available
+ tag = (ComponentTag)getNextFilter().nextTag();
+ }
if (tag == null)
{
// No more tags from the markup.
@@ -89,6 +100,18 @@
return tag;
}
+ else
+ {
+ if (tag.isInsideConditionalComments())
+ {
+ do
+ {
+ next = (ComponentTag)getNextFilter().nextTag();
+ }
+ while (next != null && next.isInsideConditionalComments() &&
+ tag.getName().equals(next.getName()) && tag.getType().equals(next.getType()));
+ }
+ }
if (log.isDebugEnabled())
{
Index: src/test/java/org/apache/wicket/markup/html/basic/SimplePageExpectedResult_12c.html
===================================================================
--- src/test/java/org/apache/wicket/markup/html/basic/SimplePageExpectedResult_12c.html (revision 0)
+++ src/test/java/org/apache/wicket/markup/html/basic/SimplePageExpectedResult_12c.html (revision 0)
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: src/test/java/org/apache/wicket/markup/parser/XmlPullParserTest.java
===================================================================
--- src/test/java/org/apache/wicket/markup/parser/XmlPullParserTest.java (revision 1072301)
+++ src/test/java/org/apache/wicket/markup/parser/XmlPullParserTest.java (working copy)
@@ -369,6 +369,23 @@
*
* @throws Exception
*/
+ public final void testDownlevelRevealedConditionalComments() throws Exception
+ {
+ final XmlPullParser parser = new XmlPullParser();
+ parser.parse(" test");
+ XmlTag tag = (XmlTag)parser.nextTag();
+ System.out.println(tag.toString());
+ assertTrue(tag.isInsideConditionalComments());
+ assertEquals("html", tag.getName());
+ tag = (XmlTag)parser.nextTag();
+ assertFalse(tag.isInsideConditionalComments());
+ assertEquals("span", tag.getName());
+ }
+
+ /**
+ *
+ * @throws Exception
+ */
public final void testNames() throws Exception
{
final XmlPullParser parser = new XmlPullParser();
@@ -400,4 +417,5 @@
assertEquals(ELEMENT_TYPE.DOCTYPE, type);
assertEquals("!DOCTYPE html", parser.getDoctype());
}
+
}
Index: src/main/java/org/apache/wicket/markup/ComponentTag.java
===================================================================
--- src/main/java/org/apache/wicket/markup/ComponentTag.java (revision 1072301)
+++ src/main/java/org/apache/wicket/markup/ComponentTag.java (working copy)
@@ -741,6 +741,14 @@
}
/**
+ * @return isInsideConditionalComments
+ */
+ public boolean isInsideConditionalComments()
+ {
+ return xmlTag.isInsideConditionalComments();
+ }
+
+ /**
* Manually mark the ComponentTag being modified. Flagging the tag being modified does not
* happen automatically.
*