You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2009/07/30 17:21:19 UTC

svn commit: r799326 - in /myfaces/tobago/trunk: core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterImpl.java theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java

Author: lofwyr
Date: Thu Jul 30 15:21:19 2009
New Revision: 799326

URL: http://svn.apache.org/viewvc?rev=799326&view=rev
Log:
TOBAGO-606: Layout-Manager
 - setting doctype to "strict"
 - substracting borders and paddings automatically, if they are configured.
remark: the box-model has changed, with the "strict" doctype

Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterImpl.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterImpl.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterImpl.java?rev=799326&r1=799325&r2=799326&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterImpl.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterImpl.java Thu Jul 30 15:21:19 2009
@@ -21,6 +21,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.tobago.component.Attributes;
+import org.apache.myfaces.tobago.config.ThemeConfig;
 import org.apache.myfaces.tobago.layout.Display;
 import org.apache.myfaces.tobago.layout.LayoutComponent;
 import org.apache.myfaces.tobago.layout.Measure;
@@ -32,6 +33,7 @@
 import org.apache.myfaces.tobago.util.XmlUtils;
 
 import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
 import java.io.IOException;
 import java.io.Writer;
@@ -165,7 +167,11 @@
 
   public void write(final char[] cbuf, final int off, final int len)
       throws IOException {
-    writer.write(cbuf, off, len);
+    if (new String(cbuf).equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")) {
+      LOG.error("Filtering XML header: " + new String(cbuf) + " FIXME"); // FIXME
+    } else {
+      writer.write(cbuf, off, len);
+    }
   }
 
   @Override
@@ -413,13 +419,26 @@
   private HtmlStyleMap addLayout(HtmlStyleMap styles) {
     if (component instanceof LayoutComponent) {
       LayoutComponent layoutComponent = (LayoutComponent) component;
+      FacesContext facesContext = FacesContext.getCurrentInstance();
+
       Measure width = layoutComponent.getWidth();
       if (width != null) {
+        // TODO: Make configurable: this is needed if the box-sizing is border-box, not content-box (see CSS3)
+        width = width.substractNotNegative(ThemeConfig.getMeasure(facesContext, component, "css.border-left-width"));
+        width = width.substractNotNegative(ThemeConfig.getMeasure(facesContext, component, "css.padding-left"));
+        width = width.substractNotNegative(ThemeConfig.getMeasure(facesContext, component, "css.padding-right"));
+        width = width.substractNotNegative(ThemeConfig.getMeasure(facesContext, component, "css.border-right-width"));
         styles = ensureHtmlStyleMap(component, styles);
         styles.put(Attributes.WIDTH, width);
       }
       Measure height = layoutComponent.getHeight();
       if (height != null) {
+        // TODO: Make configurable: this is needed if the box-sizing is border-box, not content-box (see CSS3)
+        height = height.substractNotNegative(ThemeConfig.getMeasure(facesContext, component, "css.border-top-width"));
+        height = height.substractNotNegative(ThemeConfig.getMeasure(facesContext, component, "css.padding-top"));
+        height = height.substractNotNegative(ThemeConfig.getMeasure(facesContext, component, "css.padding-bottom"));
+        height
+            = height.substractNotNegative(ThemeConfig.getMeasure(facesContext, component, "css.border-bottom-width"));
         styles = ensureHtmlStyleMap(component, styles);
         styles.put(Attributes.HEIGHT, height);
       }

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java?rev=799326&r1=799325&r2=799326&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java Thu Jul 30 15:21:19 2009
@@ -17,11 +17,6 @@
  * limitations under the License.
  */
 
-/*
- * Created 07.02.2003 16:00:00.
- * $Id$
- */
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import static org.apache.myfaces.tobago.TobagoConstants.SUBCOMPONENT_SEP;
@@ -65,29 +60,12 @@
 
   private static final Log LOG = LogFactory.getLog(PageRenderer.class);
 
-//      values for doctype :
-//      'strict'   : HTML 4.01 Strict DTD
-//      'loose'    : HTML 4.01 Transitional DTD
-//      'frameset' : HTML 4.01 Frameset DTD
-//      all other values are ignored and no DOCTYPE is set.
-//      default value is 'loose'
-
-  private static final String LOOSE =
-      "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\""
-          + /*" \"http://www.w3.org/TR/html4/loose.dtd\*/">";
-  // TODO: this is commented, because the some pages in IE and mozilla
-  // does work properly with it:
-  // tobago-demo: sometimes the body has not height=100% in mozilla.
-
-  private static final String STRICT =
+  private static final String DOCTYPE_STRICT =
       "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\""
           + " \"http://www.w3.org/TR/html4/strict.dtd\">";
 
-  private static final String FRAMESET =
-      "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\""
-          + " \"http://www.w3.org/TR/html4/frameset.dtd\">";
   private static final String CLIENT_DEBUG_SEVERITY = "clientDebugSeverity";
-  private static final String LAST_FOCUS_ID = "lastFocusId";  
+  private static final String LAST_FOCUS_ID = "lastFocusId";
 
   @Override
   public void decode(FacesContext facesContext, UIComponent component) {
@@ -158,12 +136,8 @@
 
     String title = (String) page.getAttributes().get(Attributes.LABEL);
 
-    String doctype = generateDoctype(page);
-
-    if (doctype != null) {
-      writer.write(doctype);
-      writer.write("\n");
-    }
+    writer.write(DOCTYPE_STRICT);
+    writer.write('\n');
 
     writer.startElement(HtmlConstants.HTML, null);
     writer.startElement(HtmlConstants.HEAD, null);
@@ -628,25 +602,8 @@
     return method == null ? "post" : method;
   }
 
-  protected String generateDoctype(UIPage page) {
-    String doctype = (String) page.getAttributes().get(Attributes.DOCTYPE);
-    String type = null;
-    if (doctype == null || "loose".equals(doctype)) {
-      //default
-      type = LOOSE;
-    } else if ("strict".equals(doctype)) {
-      type = STRICT;
-    } else if ("frameset".equals(doctype)) {
-      type = FRAMESET;
-    } else {
-      LOG.warn("Unsupported DOCTYPE keyword :'" + doctype + "'");
-    }
-    return type;
-  }
-
   public boolean getRendersChildren() {
     return true;
   }
 
 }
-