You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mc...@apache.org on 2008/04/02 22:31:09 UTC

svn commit: r644040 [1/2] - in /myfaces/trinidad/trunk: src/site/xdoc/ src/site/xdoc/devguide/ trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ trinidad-api/src/main/resources/ trinidad-api/src/test/java/org/apache/myfaces/trinidad/conte...

Author: mcooper
Date: Wed Apr  2 13:31:06 2008
New Revision: 644040

URL: http://svn.apache.org/viewvc?rev=644040&view=rev
Log:
TRINIDAD-822

Thank you Andy Schwartz for your patch.

Add additional accessibility features to skinning.

- The AccessibilityProfile API provides access to accessibility preferences at runtime.
- getAccessibilityProfile() methods have been added to RenderingContext, RequestContext.
- trinidad-config.xml now supports an <accessibility-profile> configuration element. This is a whitespace-separated list of accessibility profile options. Currently the two available options are "high-contrast" and "large-fonts". Typically this will just be an EL binding (like accessibility-mode).
- Skins now support @accessibility-profile rule, which allows "high-contrast" and "large-fonts" as values.

Note that the AccessibilityProfile API currently exposes two properties:

1. Color contrast: This property indicates whether the user prefers high contrast vs. default contrast content.
2. Font size: This property indicates whether the user prefers "large" fonts vs. the default fonts.

Each of these properties are defined as enumerations, allowing for future expansion.

Also added an "accdemo" skin, and an accessibilityPofileDemo.jspx page for testing/demonstrating this new functionality.

Added:
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/AccessibilityProfile.java   (with props)
    myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/DemoAccessibilityProfileBean.java   (with props)
    myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/demos/accessibilityProfileDemo.jspx   (with props)
    myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/skins/accdemo/
    myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/skins/accdemo/accdemo.css
Modified:
    myfaces/trinidad/trunk/src/site/xdoc/devguide/configuration.xml
    myfaces/trinidad/trunk/src/site/xdoc/devguide/skinning.xml
    myfaces/trinidad/trunk/src/site/xdoc/release-notes.xml
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RenderingContext.java
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RequestContext.java
    myfaces/trinidad/trunk/trinidad-api/src/main/resources/trinidad-config.xsd
    myfaces/trinidad/trunk/trinidad-api/src/test/java/org/apache/myfaces/trinidad/context/MockRequestContext.java
    myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PreferencesProxy.java
    myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/email/PreferencesData.java
    myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/faces-config.xml
    myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-config.xml
    myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-skins.xml
    myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/demos/demos.jspx
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/ConfigParser.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextBean.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderingContext.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/StyleContextImpl.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinCSSDocumentHandler.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetNode.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/StyleContext.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/NameUtils.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/XMLConstants.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetDocument.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNode.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNodeParser.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts
    myfaces/trinidad/trunk/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/renderkit/MRequestContext.java
    myfaces/trinidad/trunk/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNodeEqualsTest.java

Modified: myfaces/trinidad/trunk/src/site/xdoc/devguide/configuration.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/src/site/xdoc/devguide/configuration.xml?rev=644040&r1=644039&r2=644040&view=diff
==============================================================================
--- myfaces/trinidad/trunk/src/site/xdoc/devguide/configuration.xml (original)
+++ myfaces/trinidad/trunk/src/site/xdoc/devguide/configuration.xml Wed Apr  2 13:31:06 2008
@@ -154,6 +154,39 @@
 </ul>
 </p>
         </subsection>
+        <subsection name="accessibility-profile">
+<p>
+The <code>&lt;accessibility-profile&gt;</code> element defines finer-grained
+accessibility preferences than is possible to support with the acccessibility
+mode.  Accepted values are:
+</p>
+<p>
+<ul>
+<li>"high-contrast": Indicates that the end user prefers high contrast-friendly content.</li>
+<li>"large-fonts": Indicates that the end user prefers large fonts (larger fonts than the default font size provided by the skin).</li>
+</ul>
+</p>
+<p>
+Multiple values may be specified using whitespace to separate the values, eg:
+</p>
+<source><![CDATA[
+  <!-- Enable both high-contrast and large-fonts content -->
+  <accessibility-profile>high-contrast large-fonts</accessibility-profile>
+]]>
+</source>
+<p>
+Since accessibility preferences are user-specific, the accessibility-profile is typically bound, similar to the accessibility-mode.  The preferences specified by the accessibility profile can be used at runtime to tune both styles/icons defined by the skin as well as the content produced by Renderers.
+</p>
+<p>
+The typical use case for the "high-contrast" preference is to work around issues relating to CSS background images when platform/browser high contrast features are enabled.  For example, when Windows High Contrast mode is enabled (Control Panel->Accessibility Options->Display->High Contrast->Use High Contrast), all background images are hidden.  In cases where background images are used to convey information, this information is lost to high contrast users.  The high-contrast accessibility profile option allows skin implementations to replace such background images with &lt;img&gt; element-based icons, thus avoiding the loss of information.
+</p>
+<p>
+The typical use case for the "large-fonts" preference is to allow skins which specify small or non-scalable fonts (eg. px-based fonts on IE) to provide an alternate set of fonts for users who find the default fonts insufficient.
+</p>
+<p>
+Note that at the moment, the Trinidad core renderers/skins do not yet take advantage of the accessibility profile preferences.  These properties are primarily provided for skin authors who wish to design skins which provide styles/icons optimized for high contrast/large font users.
+</p>
+        </subsection>
         <subsection name="oracle-help-servlet-url">
 <p>
 The <code>&lt;oracle-help-servlet-url&gt;</code> element defines

Modified: myfaces/trinidad/trunk/src/site/xdoc/devguide/skinning.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/src/site/xdoc/devguide/skinning.xml?rev=644040&r1=644039&r2=644040&view=diff
==============================================================================
--- myfaces/trinidad/trunk/src/site/xdoc/devguide/skinning.xml (original)
+++ myfaces/trinidad/trunk/src/site/xdoc/devguide/skinning.xml Wed Apr  2 13:31:06 2008
@@ -748,6 +748,11 @@
         This is to define styles only for a particular agent.          
         </li>
         <li>
+        <strong>@accessibility-profile</strong> {/skin definitions go here/} - > 
+        Possible values are: high-contrast, large-fonts. 
+        This is to define styles only for a particular accessibility profile.  See the <a href="configuration.html#accessibility-profile">Configuring Apache Trinidad</a> chapter for information on setting the accessibility profile.
+        </li>
+        <li>
         <strong>:rtl</strong> - >  pseudo-class to create a style or icon definition when the browser 
         is in a right-to-left language. The best example is that of images that are not symmetric.
         If you set a skin selector that uses a asymmetrical image, when you set your browser to

Modified: myfaces/trinidad/trunk/src/site/xdoc/release-notes.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/src/site/xdoc/release-notes.xml?rev=644040&r1=644039&r2=644040&view=diff
==============================================================================
--- myfaces/trinidad/trunk/src/site/xdoc/release-notes.xml (original)
+++ myfaces/trinidad/trunk/src/site/xdoc/release-notes.xml Wed Apr  2 13:31:06 2008
@@ -54,6 +54,7 @@
 replaced by PPR.</li>
 <li>A new "mode" attribute on tr:document and trh:html lets you force Trinidad to enable "quirks" mode or to a "strict" DTD.  By default, Trinidad still renders with a transitional DTD but with standards-mode rendering.  Note: "strict" mode does not currently change how Trinidad renders - it simply swaps the DTD.</li>
 <li>The "toolbar" facet is now supported on showDetailItems in panelAccordion.</li>
+<li>A new accessibility "profile" API has been added as a companion to the existing accessibility "mode".  The accessibility profile API provides support for finer-grained accessibility preferences than can be supported by a mode-based API.  The first two accessibility profile preferences are "high-contrast", for users who prefer high contrast styles/content, and "large-fonts", for users who prefer larger/scalable fonts.  The accessibility profile value can be specified/bound in trinidad-config.xml via the new &lt;accessibility-profile&gt; element.  Trinidad skinning has been enhanced to allow accessibility profile-specific styles/icons to be specified via within @accessibility-profile blocks.  Accessibility profile information can be accessed at runtime (eg. from within a Renderer) via the new RequestContext/RenderingContext.getAccessibilityProfile() APIs. </li>
 </ul>
 
 </subsection>

Added: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/AccessibilityProfile.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/AccessibilityProfile.java?rev=644040&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/AccessibilityProfile.java (added)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/AccessibilityProfile.java Wed Apr  2 13:31:06 2008
@@ -0,0 +1,146 @@
+/*
+ *  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.myfaces.trinidad.context;
+
+/**
+ * Specifies a set of accessibility-related properties that are applied
+ * to the current request.
+ * 
+ * AccessibilityProfile instances are obtained by the getInstance() 
+ * factory method.
+ * 
+ * AccessibilityProfile instances are immutable.
+ */
+public class AccessibilityProfile
+{
+  /**
+   * Color contrast values
+   */
+  public enum ColorContrast
+  {
+    /**
+     * Color contrast value for users who prefer styles/content optimized
+     * for high contrast settings.
+     */
+    HIGH,
+    
+    /**
+     * Color contrast value for users who prefer the default
+     * (non-high contrast-optimized) styles/content.
+     */
+    STANDARD
+  }
+
+  /**
+   * Font size values.
+   * 
+   * Note that the font size property is not used to define a specific
+   * (eg. pixel-based) font size, but rather to provide a hint that the
+   * use may prefer larger fonts.  The physical font size to use is specified
+   * by the skin.
+   */
+  public enum FontSize
+  {
+    /**
+     * Font size value for users who prefer larger font sizes.
+     */
+    LARGE,
+    
+    /**
+     * Font size value for users who prefer the default (medium) font sizes.
+     */
+    MEDIUM
+  }
+  
+  /**
+   * Returns an AccessibilityProfile instance with the specified properties.
+   * @param colorContrast Specifies the user's color contrast preference.  If 
+   *   null, defaults to ColorContrast.STANDARD.
+   * @param fontSize Specifies the user's font size preference.  If null, 
+   *   defaults to FontSize.MEDIUM.
+   */
+  public static AccessibilityProfile getInstance(
+    ColorContrast colorContrast,
+    FontSize      fontSize
+    )
+  {    
+    // Note: we could cache and share AccessibilityProfile instances
+    // here if that seems useful.
+    return new AccessibilityProfile(colorContrast, fontSize);
+  }
+
+  /**
+   * Returns an AccessiblityProfile instance with the default preferences.
+   */
+  public static AccessibilityProfile getDefaultInstance()
+  {
+    return _sDefaultInstance;
+  }
+
+  /**
+   * Returns the user's preferred color contrast setting.
+   */
+  public ColorContrast getColorContrast()
+  {
+    return _colorContrast;
+  }
+  
+  /**
+   * Returns the user's preferred font size setting.
+   */
+  public FontSize getFontSize()
+  {
+    return _fontSize;    
+  }
+
+  /**
+   * Convenience method for testing whether high contrast content is required.
+   */
+  public final boolean isHighContrast()
+  {
+    return (_colorContrast == ColorContrast.HIGH);
+  }
+    
+  /**
+   * Convenience method for testing whether large fonts are required.
+   */
+  public final boolean isLargeFonts()
+  {
+    return (_fontSize == FontSize.LARGE);
+  }
+  
+  // No need to support subclassing yet, so keep the constructor private.
+  // Clients should use the getInstance() factory method.
+  private AccessibilityProfile(
+    ColorContrast colorContrast,
+    FontSize      fontSize
+    )
+  {
+
+    _colorContrast = (colorContrast == null) ? ColorContrast.STANDARD : colorContrast;
+    _fontSize = (fontSize == null) ? FontSize.MEDIUM : fontSize;
+  }
+
+  private final ColorContrast _colorContrast;
+  private final FontSize      _fontSize;
+  
+  // Default instance
+  private static final AccessibilityProfile _sDefaultInstance =
+    AccessibilityProfile.getInstance(ColorContrast.STANDARD, FontSize.MEDIUM);
+}

Propchange: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/AccessibilityProfile.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RenderingContext.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RenderingContext.java?rev=644040&r1=644039&r2=644040&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RenderingContext.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RenderingContext.java Wed Apr  2 13:31:06 2008
@@ -92,6 +92,7 @@
   abstract public boolean isRightToLeft();
   abstract public String getOutputMode();
   abstract public RequestContext.Accessibility getAccessibilityMode();
+  abstract public AccessibilityProfile getAccessibilityProfile();
   abstract public boolean isAnimationEnabled();
 
   // TODO This is a hack API to enable caching of the client ID.

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RequestContext.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RequestContext.java?rev=644040&r1=644039&r2=644040&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RequestContext.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RequestContext.java Wed Apr  2 13:31:06 2008
@@ -268,6 +268,11 @@
   public abstract Accessibility getAccessibilityMode();
 
   /**
+   * Returns the accessibility profile for the current request.
+   */
+  public abstract AccessibilityProfile getAccessibilityProfile();
+
+  /**
    * Returns the name of the current client validation mode.
    */
   public abstract ClientValidation getClientValidation();

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/resources/trinidad-config.xsd
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/resources/trinidad-config.xsd?rev=644040&r1=644039&r2=644040&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/resources/trinidad-config.xsd (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/resources/trinidad-config.xsd Wed Apr  2 13:31:06 2008
@@ -101,6 +101,15 @@
           </annotation>
         </element>
 
+        <element name="accessibility-profile" minOccurs="0" maxOccurs="1"
+                 type="config:accessibilityProfileExpressionType">
+          <annotation>
+            <documentation>The &lt;accessibility-profile&gt; element controls 
+            accessibility profile preferences used by Apache MyFaces Trinidad.
+            </documentation>
+          </annotation>
+        </element>
+
         <element name="oracle-help-servlet-url" minOccurs="0" maxOccurs="1"
                  type="config:anyURIExpressionType">
           <annotation>
@@ -215,6 +224,17 @@
     </restriction>
   </simpleType>
 
+  <simpleType name="accessibilityProfileType">
+    <restriction base="string">
+      <enumeration value="high-contrast"/>
+      <enumeration value="large-fonts"/>
+    </restriction>
+  </simpleType>
+
+  <simpleType name="accessibilityProfileListType">
+    <list itemType="config.accessibilityProfileType"/>
+  </simpleType>
+
   <simpleType name="clientValidationType">
     <restriction base="string">
       <enumeration value="ALERT"/>
@@ -241,6 +261,10 @@
 
   <simpleType name="accessibilityModeExpressionType">
     <union memberTypes="config:accessibilityModeType config:expressionType" />
+  </simpleType>
+
+  <simpleType name="accessibilityProfileExpressionType">
+    <union memberTypes="config:accessibilityProfileListType config:expressionType" />
   </simpleType>
 
   <simpleType name="clientValidationExpressionType">

Modified: myfaces/trinidad/trunk/trinidad-api/src/test/java/org/apache/myfaces/trinidad/context/MockRequestContext.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/test/java/org/apache/myfaces/trinidad/context/MockRequestContext.java?rev=644040&r1=644039&r2=644040&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/test/java/org/apache/myfaces/trinidad/context/MockRequestContext.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/test/java/org/apache/myfaces/trinidad/context/MockRequestContext.java Wed Apr  2 13:31:06 2008
@@ -155,6 +155,17 @@
   }
 
   @Override
+  public AccessibilityProfile getAccessibilityProfile()
+  {
+    return _accProfile;
+  }
+
+  public void setAccessibilityProfile(AccessibilityProfile accProfile)
+  {
+    _accProfile = accProfile;
+  }
+
+  @Override
   public boolean isRightToLeft()
   {
     return _rtl;
@@ -342,8 +353,9 @@
 
   private String _skin;
   private Accessibility _accMode;
+  private AccessibilityProfile _accProfile;
   private Agent _agent;
   private boolean _rtl = false;
   private boolean _animationEnabled = true;
   private Locale _formattingLocale;
-}
\ No newline at end of file
+}

Added: myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/DemoAccessibilityProfileBean.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/DemoAccessibilityProfileBean.java?rev=644040&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/DemoAccessibilityProfileBean.java (added)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/DemoAccessibilityProfileBean.java Wed Apr  2 13:31:06 2008
@@ -0,0 +1,116 @@
+/*
+ *  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.myfaces.trinidaddemo;
+
+import javax.faces.event.ActionEvent;
+
+import org.apache.myfaces.trinidad.context.AccessibilityProfile;
+
+/**
+ * Bean for accessibilityProfileDemo.jspx demo.
+ */
+public class DemoAccessibilityProfileBean
+{
+  public DemoAccessibilityProfileBean()
+  {
+  }
+
+  /**
+   * Return the accessibility mode preference.
+   */
+  public String getAccessibilityMode()
+  {
+    // At the moment, we don't actually surface this preference
+    // the demo, so just return the default value.
+    return "default";
+  }
+
+  /**
+   * Return the accessibility profile preference.
+   */
+  public AccessibilityProfile getAccessibilityProfile()
+  {
+    return _accProfile;
+  }
+
+  /**
+   * Return the skin family preference.
+   */
+  public String getSkinFamily()
+  {
+    // We force the skin family to the accessibility demo
+    // skin, which contains various demonstrations of
+    // how to use @accessibility-profile.
+    return "accdemo";
+  }
+
+  /**
+   * Is high contrast enabled?
+   */
+  public boolean isHighContrast()
+  {
+    return _highContrast;
+  }
+  
+  /**
+   * Are large fonts enabled?
+   */
+  public boolean isLargeFonts()
+  {
+    return _largeFonts;
+  }
+
+  /**
+   * Sets a new high contrast value.
+   */  
+  public void setHighContrast(boolean highContrast)
+  {
+    _highContrast = highContrast;
+  }
+  
+  /**
+   * Sets a new large fonts value
+   */  
+  public void setLargeFonts(boolean largeFonts)
+  {
+    _largeFonts = largeFonts;
+  }
+
+  /**
+   * ActionListener for handling accessibility profile updates.
+   */  
+  public void update(ActionEvent event)
+  {
+    AccessibilityProfile.ColorContrast colorContrast =
+      isHighContrast() ?
+        AccessibilityProfile.ColorContrast.HIGH : 
+        AccessibilityProfile.ColorContrast.STANDARD;
+
+    AccessibilityProfile.FontSize fontSize =
+      isLargeFonts() ?
+        AccessibilityProfile.FontSize.LARGE : 
+        AccessibilityProfile.FontSize.MEDIUM;
+    
+    _accProfile = AccessibilityProfile.getInstance(colorContrast, fontSize);
+  }
+
+  private boolean              _highContrast;
+  private boolean              _largeFonts;
+  private AccessibilityProfile _accProfile;
+}

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/DemoAccessibilityProfileBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PreferencesProxy.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PreferencesProxy.java?rev=644040&r1=644039&r2=644040&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PreferencesProxy.java (original)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PreferencesProxy.java Wed Apr  2 13:31:06 2008
@@ -20,6 +20,7 @@
 
 import java.util.Collections;
 
+import javax.faces.component.UIViewRoot;
 import javax.faces.context.FacesContext;
 import javax.faces.el.ValueBinding;
 
@@ -31,27 +32,41 @@
 {
   public Object getProxy()
   {
-    // If we're in the e-mail demo, use its preferences
     FacesContext context = FacesContext.getCurrentInstance();
-    if ((context.getViewRoot() != null) &&
-        (context.getViewRoot().getViewId().indexOf("/email/") >= 0))
-    {
-      ValueBinding vb =
-        context.getApplication().createValueBinding("#{email.preferences}");
-      return vb.getValue(context);
-    }
-    // If we are showing the SkinDemo page, get the skinFamily from the 
-    // sessionScope.
-    else if ((context.getViewRoot() != null) &&
-        (context.getViewRoot().getViewId().indexOf("SkinDemo") >= 0))
+    String viewId = _getViewId(context);
+
+    if (viewId != null)
     {
-      ValueBinding vb =
-        context.getApplication().createValueBinding("#{sessionScope}");
-      return vb.getValue(context);     
+      // Certain views have their own preferences
+      // storage.  Figure out which preferences
+      // we are proxying.
+      String preferencesExpression = null;
+      
+      if (viewId.indexOf("/email/") >= 0)
+        preferencesExpression = "#{email.preferences}";
+      else if (viewId.indexOf("SkinDemo") >= 0)
+        preferencesExpression = "#{sessionScope}";
+      else if (viewId.indexOf("accessibilityProfileDemo") >= 0)
+        preferencesExpression = "#{accProfileDemo}";
+
+      if (preferencesExpression != null)
+      {
+        ValueBinding vb =
+          context.getApplication().createValueBinding(preferencesExpression);
+        return vb.getValue(context);
+      }
     }
-    // Otherwise, go to an empty map (blank preferences)
-    else
-      return Collections.EMPTY_MAP;
+    
+    return Collections.EMPTY_MAP;
+  }
 
+  // Returns the current viewId.  
+  private String _getViewId(FacesContext context)
+  {
+    UIViewRoot viewRoot = context.getViewRoot();
+    if (viewRoot != null)
+      return viewRoot.getViewId();
+    
+    return null;
   }
 }

Modified: myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/email/PreferencesData.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/email/PreferencesData.java?rev=644040&r1=644039&r2=644040&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/email/PreferencesData.java (original)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/email/PreferencesData.java Wed Apr  2 13:31:06 2008
@@ -22,6 +22,8 @@
 import java.util.List;
 import javax.faces.model.SelectItem;
 
+import org.apache.myfaces.trinidad.context.AccessibilityProfile;
+
 /**
  * Bean which provides preferences data
  *
@@ -109,6 +111,14 @@
     return _accessibilityMode;
   }
 
+  /**
+   * Returns the AccessibilityProfile for this user.
+   */
+  public AccessibilityProfile getAccessibilityProfile()
+  {
+    // For the moment, just use the default profile.
+    return AccessibilityProfile.getDefaultInstance();
+  }
 
   /**
    * Returns the branding type: REGULAR_BRANDING,

Modified: myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/faces-config.xml?rev=644040&r1=644039&r2=644040&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/faces-config.xml (original)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/faces-config.xml Wed Apr  2 13:31:06 2008
@@ -3071,4 +3071,11 @@
     <managed-bean-class>org.apache.myfaces.trinidaddemo.TestRelativePartialTriggers</managed-bean-class>
     <managed-bean-scope>request</managed-bean-scope>
   </managed-bean>
+
+  <managed-bean>
+    <managed-bean-name>accProfileDemo</managed-bean-name>
+    <managed-bean-class>org.apache.myfaces.trinidaddemo.DemoAccessibilityProfileBean</managed-bean-class>
+    <managed-bean-scope>session</managed-bean-scope>
+  </managed-bean>
+
 </faces-config>

Modified: myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-config.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-config.xml?rev=644040&r1=644039&r2=644040&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-config.xml (original)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-config.xml Wed Apr  2 13:31:06 2008
@@ -26,6 +26,8 @@
   -->
 
   <accessibility-mode>#{prefs.proxy.accessibilityMode}</accessibility-mode>
+  <accessibility-profile>#{prefs.proxy.accessibilityProfile}</accessibility-profile> 
+
   <!-- you can use EL to get the skin. This allows the skin to change between
        requests. -->
 

Modified: myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-skins.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-skins.xml?rev=644040&r1=644039&r2=644040&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-skins.xml (original)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-skins.xml Wed Apr  2 13:31:06 2008
@@ -90,4 +90,15 @@
     <skin-addition>
       <skin-id>purpleBigFont.desktop</skin-id>
     </skin-addition>
+
+    <!-- A skin which demonstrates accessibility features,
+         eg. @accessibility-profile -->
+    <skin>
+      <id>accdemo.desktop</id>
+      <family>accdemo</family>
+        <extends>minimal.desktop</extends>
+      <render-kit-id>org.apache.myfaces.trinidad.desktop</render-kit-id>
+      <style-sheet-name>skins/accdemo/accdemo.css</style-sheet-name>
+    </skin>
+
 </skins>

Added: myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/demos/accessibilityProfileDemo.jspx
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/demos/accessibilityProfileDemo.jspx?rev=644040&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/demos/accessibilityProfileDemo.jspx (added)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/demos/accessibilityProfileDemo.jspx Wed Apr  2 13:31:06 2008
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
+<!--
+    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.
+	   
+-->
+<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
+          xmlns:f="http://java.sun.com/jsf/core"
+          xmlns:h="http://java.sun.com/jsf/html"
+          xmlns:trh="http://myfaces.apache.org/trinidad/html"
+          xmlns:tr="http://myfaces.apache.org/trinidad">
+ <jsp:directive.page contentType="text/html;charset=utf-8"/>
+ <f:view>
+  <tr:document title="Accessibility Profile Demo">
+    <tr:form>
+
+     <tr:panelPage>
+      <f:facet name="navigationGlobal">
+       <tr:navigationPane hint="buttons">
+        <tr:commandNavigationItem text="Return to Feature Demos page"
+                                immediate="true"
+                                action="demos"/>
+       </tr:navigationPane>
+      </f:facet>
+
+    <tr:panelHeader text="Accessibility Profile Demo">
+      <tr:outputFormatted styleUsage="instruction"
+        value="This page demonstrates the how the accessibility profile API can be
+          used to provide styles targeted at specific groups of end users.  Use the 
+          checkboxes to specify accessibility profile preferences, hit the Update 
+          button to chanage the preferences, and then review the content below to 
+          see how it changes based on the sepcified preferences." />
+
+      <tr:panelGroupLayout layout="vertical">
+
+       <tr:panelFormLayout>
+         <tr:selectBooleanCheckbox text="High Contrast" 
+                                   value="#{accProfileDemo.highContrast}"/>
+         <tr:selectBooleanCheckbox text="Large Fonts"
+                                   value="#{accProfileDemo.largeFonts}"/>
+         <tr:commandButton text="Update"
+                           actionListener="#{accProfileDemo.update}"/>
+       </tr:panelFormLayout>
+
+       <tr:panelHeader text="High Contrast">
+         <tr:panelGroupLayout layout="vertical">
+           <f:facet name="separator">
+             <tr:spacer height="10px"/>
+           </f:facet>
+       
+           <tr:outputFormatted styleUsage="instruction"
+             value="This section contains content which is styled differently
+                    when the high contrast setting is enabled."/>
+
+
+           <tr:panelBox background="dark" text="A Dark PanelBox">
+             <tr:outputText value="This is a dark panelBox.  With the default
+               accessibility profile settings, this should have a dark background.
+               However, the skin has been customized so that the background
+               is changed to yellow when high contrast is enabled."/>
+           </tr:panelBox>
+         </tr:panelGroupLayout>
+       </tr:panelHeader>
+
+       <tr:panelHeader text="Large Fonts">
+         <tr:panelGroupLayout layout="vertical">
+           <f:facet name="separator">
+             <tr:spacer height="10px"/>
+           </f:facet>
+
+           <tr:outputFormatted styleUsage="instruction"
+              value="This section contains content which is styled differently
+                     when the large fonts setting is enabled."/>
+
+           <tr:outputText styleClass="makeMeLarge"
+             value="This text is small under the default accessibility profile
+                    settings.  However, the skin has been customized so that the
+                    text size is increased when the large fonts setting is
+                    enabled."/>
+                    
+           <tr:panelGroupLayout>
+             <tr:outputText value="This is the info icon: "/>
+             <tr:icon name="info"/>
+             <tr:outputText value=" It has been customized so that the icon
+               should become larger when the large fonts setting is enabled."/>
+           </tr:panelGroupLayout>
+             
+
+         </tr:panelGroupLayout>
+       </tr:panelHeader>
+
+       <tr:panelHeader text="High Contrast or Large Fonts">
+         <tr:panelGroupLayout layout="vertical">
+           <f:facet name="separator">
+             <tr:spacer height="10px"/>
+           </f:facet>
+           
+           <tr:outputFormatted styleUsage="instruction"
+              value="This section contains content which is styled differently
+                     when either the high contrast or the large fonts setting is 
+                     enabled."/>
+
+           <tr:outputText styleClass="eitherOr"
+             value="This is small black text on white background under the 
+                    default accessibility profile settings.  However, the when
+                    either high contrast or large fonts are enabled, the text
+                    becomes larger, and the colors are inverted."/>
+         </tr:panelGroupLayout>
+       </tr:panelHeader>
+
+       <tr:panelHeader text="High Contrast and Large Fonts">
+         <tr:panelGroupLayout layout="vertical">
+           <f:facet name="separator">
+             <tr:spacer height="10px"/>
+           </f:facet>
+           <tr:outputFormatted styleUsage="instruction"
+              value="This section contains content which is styled differently
+                     when both the high contrast and the large fonts settings are 
+                     enabled at the same time."/>
+
+           <tr:outputText styleClass="both"
+             value="This is small black text on white background under the 
+                    default accessibility profile settings.  However, the when
+                    both high contrast and large fonts are enabled, the text
+                    becomes larger, and the colors are inverted."/>
+         </tr:panelGroupLayout>
+        </tr:panelHeader>
+      </tr:panelGroupLayout>
+     </tr:panelHeader>
+
+     </tr:panelPage>
+    </tr:form>
+  </tr:document>
+ </f:view>
+</jsp:root>

Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/demos/accessibilityProfileDemo.jspx
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/demos/demos.jspx
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/demos/demos.jspx?rev=644040&r1=644039&r2=644040&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/demos/demos.jspx (original)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/demos/demos.jspx Wed Apr  2 13:31:06 2008
@@ -51,6 +51,8 @@
                               action="demos.changePersistence" />
               <tr:commandLink text="Table Demos" action="demos.tableDemos" />
               <tr:commandLink text="Skin Demo" action="demos.skin" />
+              <tr:goLink text="Accessibility Profile Demo"
+                destination="accessibilityProfileDemo.jspx" />
               <tr:goLink text="Show Detail Disclosure Demo"
                 destination="showDetailDiscloseOne.jspx" />
               <tr:goLink text="FileDownloadActionListener Demo"

Added: myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/skins/accdemo/accdemo.css
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/skins/accdemo/accdemo.css?rev=644040&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/skins/accdemo/accdemo.css (added)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/skins/accdemo/accdemo.css Wed Apr  2 13:31:06 2008
@@ -0,0 +1,73 @@
+/*
+ *  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.
+ */
+
+.makeMeLarge {
+  font-size: 11px;
+}
+
+.eitherOr {
+  font-size: 11px;
+  color: black;
+  background-color: white;
+}
+
+.both {
+  font-size: 11px;
+  color: black;
+  background-color: white;
+}
+
+@accessibility-profile large-fonts {
+  .makeMeLarge {
+    font-size: x-large;
+  }
+
+  .AFInfoIcon:alias {
+    content: 'i';
+    font-family: monospace;
+    font-weight:bold;
+    color: #669966;
+    font-size: 3em;
+  }
+}
+
+@accessibility-profile high-contrast {
+  af|panelBox::dark af|panelBox::body {
+    background-color: yellow;
+  }
+}
+
+@accessibility-profile large-fonts, high-contrast {
+  .eitherOr {
+    font-size: x-large;
+    color: white;
+    background-color: black;
+  }
+}
+
+@accessibility-profile large-fonts {
+  @accessibility-profile high-contrast {
+  
+    .both {
+      font-size: x-large;
+      color: white;
+      background-color: black;
+    }
+  }
+}

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/ConfigParser.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/ConfigParser.java?rev=644040&r1=644039&r2=644040&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/ConfigParser.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/ConfigParser.java Wed Apr  2 13:31:06 2008
@@ -22,6 +22,7 @@
 import java.io.InputStream;
 import java.util.Locale;
 import java.util.Map;
+import java.util.StringTokenizer;
 import java.util.TimeZone;
 
 import javax.faces.context.ExternalContext;
@@ -30,6 +31,7 @@
 import javax.xml.parsers.SAXParserFactory;
 
 import org.apache.myfaces.trinidad.bean.PropertyKey;
+import org.apache.myfaces.trinidad.context.AccessibilityProfile;
 import org.apache.myfaces.trinidad.context.RequestContext;
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 import org.apache.myfaces.trinidad.util.ClassLoaderUtils;
@@ -245,6 +247,10 @@
                 return;
               }
             }
+            else if (key.getType() == AccessibilityProfile.class)
+            {
+              value = _getAccessibilityProfile(currentText);
+            }
             else
             {
               value = currentText;
@@ -286,6 +292,41 @@
         }
       }
       return value;
+    }
+
+    // Parses the text into an AccessibilityProfile.
+    private static AccessibilityProfile _getAccessibilityProfile(
+      String text)
+    {
+      AccessibilityProfile.ColorContrast colorContrast = null;
+      AccessibilityProfile.FontSize fontSize = null;
+
+      // Note: we do the parsing here in the ConfigParser instead of in 
+      // RequestContextImpl so that we can easily detect/log any problems 
+      // once at startup.  Also nice to do this here so that we have some 
+      // chance of actually logging line numbers, though at the moment it 
+      // looks like our Handler doesn't implement Locator.
+      
+      StringTokenizer tokens = new StringTokenizer(text);
+      while (tokens.hasMoreTokens())
+      {
+        String token = tokens.nextToken();
+        
+        if ("high-contrast".equals(token))
+        {
+          colorContrast = AccessibilityProfile.ColorContrast.HIGH;
+        }
+        else if ("large-fonts".equals(token))
+        {
+          fontSize = AccessibilityProfile.FontSize.LARGE;
+        }
+        else
+        {
+          _LOG.warning("INVALID_ACC_PROFILE", new Object[]{token});
+        }
+      }
+
+      return AccessibilityProfile.getInstance(colorContrast, fontSize);
     }
 
     private RequestContextBean  _bean;

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextBean.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextBean.java?rev=644040&r1=644039&r2=644040&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextBean.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextBean.java Wed Apr  2 13:31:06 2008
@@ -24,6 +24,7 @@
 import org.apache.myfaces.trinidad.bean.FacesBeanImpl;
 import org.apache.myfaces.trinidad.bean.PropertyKey;
 
+import org.apache.myfaces.trinidad.context.AccessibilityProfile;
 import org.apache.myfaces.trinidad.context.RequestContext;
 
 public class RequestContextBean extends FacesBeanImpl
@@ -47,6 +48,9 @@
     TYPE.registerKey("look-and-feel");
   static public final PropertyKey ACCESSIBILITY_MODE_KEY =
     TYPE.registerKey("accessibility-mode");
+  static public final PropertyKey ACCESSIBILITY_PROFILE_KEY =
+    TYPE.registerKey("accessibility-profile",
+                     AccessibilityProfile.class);
   static public final PropertyKey RIGHT_TO_LEFT_KEY =
     TYPE.registerKey("right-to-left", Boolean.class);
   static public final PropertyKey FORMATTING_LOCALE_KEY =

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java?rev=644040&r1=644039&r2=644040&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java Wed Apr  2 13:31:06 2008
@@ -40,6 +40,7 @@
 import org.apache.myfaces.trinidad.change.SessionChangeManager;
 import org.apache.myfaces.trinidad.component.UIXCollection;
 import org.apache.myfaces.trinidad.config.RegionManager;
+import org.apache.myfaces.trinidad.context.AccessibilityProfile;
 import org.apache.myfaces.trinidad.context.Agent;
 import org.apache.myfaces.trinidad.context.DialogService;
 import org.apache.myfaces.trinidad.context.PageFlowScopeProvider;
@@ -245,6 +246,13 @@
     }
 
     return _ACCESSIBILITY_NAMES.get(name);
+  }
+
+  @Override
+  public AccessibilityProfile getAccessibilityProfile()
+  { 
+    return (AccessibilityProfile) _bean.getProperty(
+      RequestContextBean.ACCESSIBILITY_PROFILE_KEY);
   }
 
   @Override

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderingContext.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderingContext.java?rev=644040&r1=644039&r2=644040&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderingContext.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderingContext.java Wed Apr  2 13:31:06 2008
@@ -30,6 +30,7 @@
 
 import javax.servlet.ServletContext;
 
+import org.apache.myfaces.trinidad.context.AccessibilityProfile;
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 
 import org.apache.myfaces.trinidad.context.Agent;
@@ -86,6 +87,12 @@
     // Get and cache (since it can be EL-bound)
     _accessibilityMode = afContext.getAccessibilityMode();
     _animationEnabled = afContext.isAnimationEnabled();
+
+    // Initialize the accessibility profile, providing a default
+    // instance if necessary.
+    _accessibilityProfile = afContext.getAccessibilityProfile();
+    if (_accessibilityProfile == null)
+      _accessibilityProfile = AccessibilityProfile.getDefaultInstance();
   }
 
 
@@ -184,6 +191,12 @@
   }
 
   @Override
+  public AccessibilityProfile getAccessibilityProfile()
+  {
+    return _accessibilityProfile;
+  }
+
+  @Override
   public boolean isAnimationEnabled()
   {
     return _animationEnabled;
@@ -675,6 +688,7 @@
   private Map<String, String> _skinResourceKeyMap;
   private String              _outputMode;
   private RequestContext.Accessibility _accessibilityMode;
+  private AccessibilityProfile         _accessibilityProfile;
   private boolean _animationEnabled;
   private PartialPageContext  _pprContext;
   private LocaleContext       _localeContext;

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/StyleContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/StyleContextImpl.java?rev=644040&r1=644039&r2=644040&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/StyleContextImpl.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/StyleContextImpl.java Wed Apr  2 13:31:06 2008
@@ -24,12 +24,14 @@
 
 import javax.faces.context.FacesContext;
 
+import org.apache.myfaces.trinidad.context.AccessibilityProfile;
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 
 import org.apache.myfaces.trinidadinternal.agent.TrinidadAgent;
 import org.apache.myfaces.trinidad.context.RenderingContext;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.HtmlRenderer;
 import org.apache.myfaces.trinidad.context.LocaleContext;
+import org.apache.myfaces.trinidad.context.RequestContext;
 import org.apache.myfaces.trinidad.skin.Icon;
 import org.apache.myfaces.trinidad.skin.Skin;
 import org.apache.myfaces.trinidadinternal.share.config.Configuration;
@@ -46,6 +48,10 @@
   {
     _arc = arc;
     _generatedFilesPath = generatedFilesPath;
+
+    // Our style/skin code assumes that we have access to a 
+    // non-null accessibility profile.  Check that here.
+    assert(_arc.getAccessibilityProfile() != null);
   }
 
 
@@ -98,6 +104,11 @@
   {
     FacesContext fContext = FacesContext.getCurrentInstance();
     return HtmlRenderer.isStandardsModeDisabled(fContext);
+  }
+
+  public AccessibilityProfile getAccessibilityProfile()
+  {
+    return _arc.getAccessibilityProfile();
   }
 
   // Creates a default StyleProvider

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinCSSDocumentHandler.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinCSSDocumentHandler.java?rev=644040&r1=644039&r2=644040&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinCSSDocumentHandler.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinCSSDocumentHandler.java Wed Apr  2 13:31:06 2008
@@ -21,9 +21,13 @@
 import java.io.StringReader;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
+import java.util.Set;
+
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 import org.apache.myfaces.trinidadinternal.agent.TrinidadAgent;
 import org.apache.myfaces.trinidadinternal.style.util.NameUtils;
@@ -107,7 +111,8 @@
          _createCompleteSelectorNode(selector, 
                                      _propertyNodeList,
                                      _selectorAgents,
-                                     _selectorPlatforms);
+                                     _selectorPlatforms,
+                                     _getSelectorAccProperties());
        _completeSelectorNodeList.add(node);
     }
     // reset flags
@@ -182,6 +187,10 @@
       {
         _parseCustomAtRule(_AT_PLATFORM, atRule);        
       }
+      else if (atRule.startsWith(_AT_ACC_PROFILE))
+      {
+        _parseCustomAtRule(_AT_ACC_PROFILE, atRule);        
+      }
       // for now, ignore other atRules in a skinning css file
       
     }
@@ -198,8 +207,7 @@
     // save the atRule type, so the document handler code can get to it.
     // run this through parser again
     String content = _getAtRuleContent(atRule);
-    int[] targetTypes = _getAtRuleTargetTypes(type, atRule);
-    _setAtRuleTargetTypes(type, targetTypes);
+    _initAtRuleTargetTypes(type, atRule);
     
     // use this current DocumentHandler. This way we can add to the 
     // CompleteSelectorNode list with agent information.
@@ -211,17 +219,6 @@
 
   }
   
-  private void _setAtRuleTargetTypes(
-    String type,
-    int[]  targetTypes)
-  {
-    
-    if (_AT_AGENT.equals(type))
-      _selectorAgents = targetTypes;
-    else if (_AT_PLATFORM.equals(type))
-      _selectorPlatforms = targetTypes;
-  }
-  
   private void _resetAtRuleTargetTypes(
     String type)
   {
@@ -229,6 +226,13 @@
       _selectorAgents = null;
     else if (_AT_PLATFORM.equals(type))
       _selectorPlatforms = null;
+    else if (_AT_ACC_PROFILE.equals(type))
+    {
+      assert(!_selectorAccPropertiesStack.isEmpty());
+      
+      if (!_selectorAccPropertiesStack.isEmpty())
+        _selectorAccPropertiesStack.removeLast();        
+    }
   }
   
    // create a CompleteSelectorNode (this is the selector, properties, and
@@ -237,7 +241,8 @@
     String selector, 
     List<PropertyNode> propertyNodeList,
     int[] selectorAgents,
-    int[] selectorPlatforms)
+    int[] selectorPlatforms,
+    Set<String> selectorAccProperties)
   {
     // parse the selector to see if there is a :rtl or :ltr ending.
     // if so, then set the reading direction.
@@ -263,7 +268,8 @@
         propertyNodeList, 
         direction, 
         selectorAgents, 
-        selectorPlatforms);
+        selectorPlatforms,
+        selectorAccProperties);
   }
 
   /**
@@ -287,7 +293,8 @@
       int direction = completeSelectorNode.getDirection();
       int[] agents = completeSelectorNode.getAgents();
       int[] platforms = completeSelectorNode.getPlatforms();
-         
+      Set<String> accProperties = completeSelectorNode.getAccessibilityProperties();
+
       // loop through the skinStyleSheetNodeList to find a match
       // of direction, agents, platforms, etc.
       boolean match = false;
@@ -297,7 +304,7 @@
       for (int i=skinStyleSheetNodes.size()-1; i >=0 && !match; i--)
       {
         SkinStyleSheetNode ssNode = skinStyleSheetNodes.get(i);
-        match = ssNode.matches(direction, agents, platforms);
+        match = ssNode.matches(direction, agents, platforms, accProperties);
         if (match)
           ssNode.add(completeSelectorNode.getSkinSelectorPropertiesNode());
       }
@@ -306,7 +313,7 @@
       {
        // no matching stylesheet node found, so create a new one
         SkinStyleSheetNode ssNode = 
-         new SkinStyleSheetNode(namespaceMap, direction, agents, platforms);
+         new SkinStyleSheetNode(namespaceMap, direction, agents, platforms, accProperties);
         ssNode.add(completeSelectorNode.getSkinSelectorPropertiesNode());
         skinStyleSheetNodes.add(ssNode);
       }       
@@ -315,13 +322,12 @@
   }
 
   /**
+   * Initialized at rule target types.
    * 
-   * @param type type of the at rule. _AT_AGENT or _AT_PLATFORM
+   * @param type type of the at rule. _AT_AGENT, _AT_PLATFORM, or _AT_ACC_PROFILE
    * @param atRule - the atRule string
-   * @return int[] the target types using AdfFacesAgent constants like
-   * AdfFacesAgent.APPLICATION_IEXPLORER
    */
-  private int[] _getAtRuleTargetTypes(
+  private void _initAtRuleTargetTypes(
     String type, 
     String atRule)
   {
@@ -334,10 +340,11 @@
     {
       String types = atRule.substring(firstSpace, openBrace);
       String[] typeArray = types.split(",");
-      List<Integer> list = new ArrayList<Integer>();
       
       if (_AT_AGENT.equals(type))
       {
+        List<Integer> list = new ArrayList<Integer>();
+
         for (int i=0; i < typeArray.length; i++)
         {
           int agentInt = NameUtils.getBrowser(typeArray[i].trim());
@@ -345,20 +352,54 @@
           if (agentInt != TrinidadAgent.APPLICATION_UNKNOWN)
             list.add(agentInt);
         }
+        
+        _selectorAgents = _getIntArray(list);
       }
       else if (_AT_PLATFORM.equals(type))
       {
+        List<Integer> list = new ArrayList<Integer>();
+
         for (int i=0; i < typeArray.length; i++)
         {
           int platformInt = NameUtils.getPlatform(typeArray[i].trim());           
 
           if (platformInt != TrinidadAgent.OS_UNKNOWN)
             list.add(platformInt);
-        }          
+        }
+        
+        _selectorPlatforms = _getIntArray(list);
       }
-      return _getIntArray(list);
-   }
-   else return null;
+      else if (_AT_ACC_PROFILE.equals(type))
+      {
+        // The number of profile properties is always going to be 
+        // very small, so we need to specify some initial capacity -
+        // the default is too large.  Make the hash set twice as
+        // large as the number of properties so that there is some
+        // room to avoid collisions.  This probably isn't especially
+        // effective, but probably doesn't matter much given the
+        // small size of our sets.
+        Set<String> set = new HashSet<String>(typeArray.length * 2);
+
+        for (int i=0; i < typeArray.length; i++)
+        {
+          String accProp = typeArray[i].trim();
+
+          if (NameUtils.isAccessibilityPropertyName(accProp))
+          {
+            set.add(accProp);
+          }
+          else
+          {
+            _LOG.warning("INVALID_ACC_PROFILE", new Object[]{accProp});
+          }
+        }
+        
+        if (!_selectorAccPropertiesStack.isEmpty())
+          set = _mergeAccProperties(_selectorAccPropertiesStack.getLast(), set);
+
+        _selectorAccPropertiesStack.add(set);
+      }
+    }
   }
 
   // Copies Integers from a List of Integers into an int array
@@ -397,7 +438,69 @@
      return atRule.substring(openBraceIndex+1, endBraceIndex);
    
   }
-   
+
+  // Returns the accessibility properties in effect for the current selector
+  private Set<String> _getSelectorAccProperties()
+  {
+    return _selectorAccPropertiesStack.isEmpty() ? 
+             null : 
+             _selectorAccPropertiesStack.getLast();
+  }
+
+  // When specifying multiple values in an @accessibility-profile rule, eg:
+  //
+  // @accessibility-profile high-contrast, large-fonts {
+  //   .selector { property: value }
+  // }
+  //
+  // We treat the ',' separator as a logical "or" - ie. we match if either
+  // high-contrast or large-fonts is specified by the AccessibilityProfile.
+  //
+  // In order to "and" accessibility profile properties together, we need
+  // to support nested @accessibility-profile rules, eg:
+  //
+  // @accessibility-profile high-contract {
+  //   @accessibility-profile large-fonts {
+  //      .selector { property: value}
+  //   }
+  // }
+  //
+  // Where we only match the inner rule if both the outer rule *and* the
+  // inner rule are matched.  We need some way to represent the fact that
+  // we both rules must match.  We can't simply add the individual values
+  // into the accessibility properties Set - since we will match either
+  // value rather than require that both are present.  Instead we create
+  // new compound values, eg. "high-contrast&large-fonts".  This allows the
+  // accessibility matching logic in StyleSheetNode to detect cases where
+  // multiple properties are required in order to accept the match.
+  private Set<String> _mergeAccProperties(
+    Set<String> oldProperties, 
+    Set<String> newProperties)
+  {
+    // If we don't have any old properties, no merging to do, just use
+    // the new properties.
+    if ((oldProperties == null) || oldProperties.isEmpty())
+      return newProperties;
+
+    // If we don't have any new properties, no merging to do, but we
+    // want to inherit the old properties, so make a copy.
+    if ((newProperties == null) || newProperties.isEmpty())
+      return new HashSet<String>(oldProperties);
+    
+    // We have both old and new properties.  We need to merge
+    // these into a single set.  At the most the merged set contains 
+    // oldProperties.size() * newProperties.size().  (We double this to
+    // avoid collisions/re-allocations.)
+    int mergedSize = oldProperties.size() + newProperties.size();
+    Set<String> mergedProperties = new HashSet<String>(mergedSize * 2);
+    for (String oldProperty : oldProperties)
+    {
+      for (String newProperty : newProperties)
+        mergedProperties.add(oldProperty + "&" + newProperty);
+    }
+
+    return mergedProperties;    
+  }
 
    /**
     * This Class contains a SkinSelectorPropertiesNode and a rtl direction.
@@ -410,7 +513,8 @@
       List<PropertyNode> propertyNodes,
       int    direction,
       int[]  agents,
-      int[]  platforms
+      int[]  platforms,
+      Set<String> accProperties
       )
     {
       _node = new SkinSelectorPropertiesNode(selectorName, propertyNodes);
@@ -419,6 +523,14 @@
       // at the end of the @rule parsing.
       _agents = _copyIntArray(agents);
       _platforms = _copyIntArray(platforms);
+      
+      if (accProperties != null)
+      {
+        // Copy acc properties just to be safe.  Note that we don't
+        // bother wrapping in an unmodifiable set - just following
+        // the pattern used for the agents/platforms arrays.
+        _accProperties = new HashSet<String>(accProperties);
+      }
     }
     
     public SkinSelectorPropertiesNode getSkinSelectorPropertiesNode()
@@ -440,7 +552,12 @@
     {
       return _platforms;
     }
-    
+
+    public Set<String> getAccessibilityProperties()
+    {
+      return _accProperties;
+    }
+
     // Returns a copy of the int array
     private static int[] _copyIntArray(int[] array)
     {
@@ -452,16 +569,18 @@
     
       return copy;
     }
-     
+
     private SkinSelectorPropertiesNode _node;
     private int _direction;  // the reading direction
     private int[] _agents;
     private int[] _platforms;
+    private Set<String> _accProperties;
 
   }
 
   private static String _AT_AGENT = "@agent";
   private static String _AT_PLATFORM = "@platform";
+  private static String _AT_ACC_PROFILE = "@accessibility-profile";
 
   // below are properties that we set and reset 
   // as the methods of this documentHandler get called.
@@ -471,10 +590,17 @@
   // list to create a list of SkinStyleSheetNodes
   private List <CompleteSelectorNode> _completeSelectorNodeList = 
     new ArrayList<CompleteSelectorNode>();
-  // these are the selector platform and agents of the selectors we
-  // are currently parsing in this document.
+  // these are the selector platform, agents and accessiblity properties of the 
+  // selectors we are currently parsing in this document.
   private int[] _selectorPlatforms = null;
   private int[] _selectorAgents = null;
+
+  // Stack of accessibility property sets.  While java.util.Stack has the
+  // push/pop API that we want, we don't need the synchronization, so we
+  // just use a LinkedList instead and pretend its a stack.
+  private LinkedList<Set<String>> _selectorAccPropertiesStack =
+    new LinkedList<Set<String>>();
+
   private Map<String, String> _namespaceMap = new HashMap<String, String>();
   private static final TrinidadLogger _LOG = 
     TrinidadLogger.createTrinidadLogger(SkinCSSDocumentHandler.class);

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetNode.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetNode.java?rev=644040&r1=644039&r2=644040&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetNode.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetNode.java Wed Apr  2 13:31:06 2008
@@ -22,6 +22,7 @@
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /** Stores information about the .css skin file.
  * namespaceMap, a List of SkinSelectorPropertiesNodes, and direction.
@@ -41,13 +42,15 @@
       List <SkinSelectorPropertiesNode> skinSelectorNodeList,
       Map<String, String> namespaceMap,
       int  direction,
-      int[] agents
+      int[] agents,
+      Set<String> accProperties
       )
     {
       _skinSelectorNodeList = skinSelectorNodeList;
       _namespaceMap     = namespaceMap;
       _direction        = direction;
       _agents           = agents;
+      _accProperties    = accProperties;
     } 
     
   
@@ -55,13 +58,14 @@
     Map<String, String> namespaceMap,
     int  direction,
     int[] agents,
-    int[] platforms
+    int[] platforms,
+    Set<String> accProperties
     )
   {
     _namespaceMap     = namespaceMap;
     _direction        = direction;
     _agents           = agents;
-    _platforms        = platforms;
+    _accProperties    = accProperties;
   }     
     
   public void add(SkinSelectorPropertiesNode node)
@@ -107,11 +111,17 @@
     {
       return _platforms;
     }
-    
+
+    public Set<String> getAcessibilityProperties()
+    {
+      return _accProperties;
+    }
+
     public boolean matches(
       int direction, 
       int[] agents, 
-      int[] platforms)
+      int[] platforms,
+      Set<String> accProperties)
     {
       if (direction == _direction)
       {
@@ -121,7 +131,12 @@
         {
           boolean platformsMatch = _intArraysEqual(platforms, _platforms);
           if (platformsMatch)
-            return true;
+          {
+            boolean accMatch = _setsEqual(accProperties, _accProperties);
+            
+            if (accMatch)
+              return true;
+          }
         }
       }
       return false;
@@ -137,11 +152,18 @@
         Arrays.sort(a2);
       return Arrays.equals(a1, a2); 
     }
-    
+
+    private boolean _setsEqual(
+      Set s1, 
+      Set s2)
+    {
+      return (s1 == null) ? (s2 == null) : (s1.equals(s2));
+    }
+
     private Map<String, String> _namespaceMap;
     private List <SkinSelectorPropertiesNode> _skinSelectorNodeList;
     private int  _direction;  // reading direction
     private int[] _agents;
     private int[] _platforms;
-
+    private Set<String> _accProperties;
 }

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java?rev=644040&r1=644039&r2=644040&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java Wed Apr  2 13:31:06 2008
@@ -272,7 +272,8 @@
                              skinSSNode.getAgents(),
                              null,/*versions, not supported*/
                              skinSSNode.getPlatforms(),
-                             0);
+                             0,
+                             skinSSNode.getAcessibilityProperties());
         ssNodeList.add(ssNode);
       }
  

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/StyleContext.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/StyleContext.java?rev=644040&r1=644039&r2=644040&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/StyleContext.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/StyleContext.java Wed Apr  2 13:31:06 2008
@@ -19,6 +19,7 @@
 package org.apache.myfaces.trinidadinternal.style;
 
 import org.apache.myfaces.trinidadinternal.agent.TrinidadAgent;
+import org.apache.myfaces.trinidad.context.AccessibilityProfile;
 import org.apache.myfaces.trinidad.context.LocaleContext;
 
 /**
@@ -47,4 +48,5 @@
 
   public StyleProvider getStyleProvider();
   public StyleMap getStyleMap();
+  public AccessibilityProfile getAccessibilityProfile();
 }

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java?rev=644040&r1=644039&r2=644040&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java Wed Apr  2 13:31:06 2008
@@ -45,6 +45,7 @@
 
 import javax.faces.context.FacesContext;
 
+import org.apache.myfaces.trinidad.context.AccessibilityProfile;
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 import org.apache.myfaces.trinidadinternal.agent.TrinidadAgent;
 import org.apache.myfaces.trinidadinternal.renderkit.core.CoreRenderingContext;
@@ -1062,8 +1063,8 @@
     public Key(StyleContext context)
     {
       TrinidadAgent agent = context.getAgent();
-
       LocaleContext localeContext = context.getLocaleContext();
+      AccessibilityProfile accProfile = context.getAccessibilityProfile();
 
       _init(
        localeContext.getTranslationLocale(),
@@ -1071,7 +1072,8 @@
        agent.getAgentApplication(),
        agent.getAgentMajorVersion(),
        agent.getAgentOS(),
-       true);
+       true,
+       accProfile);
     }
 
     @Override
@@ -1084,7 +1086,8 @@
                (_browser  << 2)            ^
                (_version  << 4)            ^
                (_platform << 8)            ^
-               shortHash);
+               shortHash                   ^
+               _accProfile.hashCode());
     }
 
     @Override
@@ -1103,7 +1106,8 @@
             (_browser != key._browser)     ||
             (_version != key._version)     ||
             (_platform != key._platform)   ||
-            !_locale.equals(key._locale))
+            !_locale.equals(key._locale)   ||
+            !_accProfile.equals(key._accProfile))
         {
           return false;
         }
@@ -1118,7 +1122,8 @@
       int browser,
       int version,
       int platform,
-      boolean useShort
+      boolean useShort,
+      AccessibilityProfile accessibilityProfile
       )
     {
       // Make sure direction is non-null
@@ -1134,6 +1139,7 @@
       _version = version;
       _platform = platform;
       _short = useShort;
+      _accProfile = accessibilityProfile;
     }
 
     private Locale         _locale;
@@ -1142,6 +1148,7 @@
     private int            _version;
     private int            _platform;
     private boolean        _short;  // Do we use short style classes?
+    private AccessibilityProfile _accProfile;
   }
 
   // Cache entry class

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/NameUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/NameUtils.java?rev=644040&r1=644039&r2=644040&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/NameUtils.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/NameUtils.java Wed Apr  2 13:31:06 2008
@@ -29,6 +29,7 @@
 
 import org.apache.myfaces.trinidadinternal.style.StyleContext;
 
+import org.apache.myfaces.trinidadinternal.style.xml.XMLConstants;
 import org.apache.myfaces.trinidadinternal.style.xml.parse.StyleSheetDocument;
 import org.apache.myfaces.trinidadinternal.style.xml.parse.StyleSheetNode;
 
@@ -316,6 +317,9 @@
     boolean browserMatch = _isBrowserMatch(context, styleSheets);
     boolean versionMatch = _isVersionMatch(context, styleSheets);
     boolean platformMatch = _isPlatformMatch(context, styleSheets);
+    boolean highContrastMatch = _isHighContrastMatch(context, styleSheets);
+    boolean largeFontsMatch = _isLargeFontsMatch(context, styleSheets);
+    
     boolean needSeparator = false;
 
     StringBuffer buffer = new StringBuffer();
@@ -385,8 +389,34 @@
       needSeparator = true;
     }
 
+    if(highContrastMatch)
+    {
+      if(needSeparator)
+        buffer.append(_VARIANT_SEPARATOR);
+      buffer.append(_getHighContrastString(context));
+      needSeparator = true;
+    }
+
+    if(largeFontsMatch)
+    {
+      if(needSeparator)
+        buffer.append(_VARIANT_SEPARATOR);
+      buffer.append(_getLargeFontsString(context));
+      needSeparator = true;
+    }
+
     return buffer.toString();
   }
+  
+  /**
+   * Tests whether the specified name is a valid accessibility profile
+   * property name (eg. "high-contrast" or "large-fonts").
+   */
+  public static boolean isAccessibilityPropertyName(String name)
+  {
+    return (XMLConstants.ACC_HIGH_CONTRAST.equals(name) || 
+            XMLConstants.ACC_LARGE_FONTS.equals(name));
+  }
 
   // Get the locale as a String
   private static String _getLocaleString(StyleContext context)
@@ -474,6 +504,24 @@
     return name;
   }
 
+  // Get the platform as a String
+  private static String _getHighContrastString(StyleContext context)
+  {
+    if (context.getAccessibilityProfile().isHighContrast())
+      return _ACC_HIGH_CONTRAST;
+    
+    return _UNKNOWN_NAME;
+  }
+
+  // Get the platform as a String
+  private static String _getLargeFontsString(StyleContext context)
+  {
+    if (context.getAccessibilityProfile().isLargeFonts())
+      return _ACC_LARGE_FONTS;
+    
+    return _UNKNOWN_NAME;
+  }
+
   // Tests whether the locale specified in the context match the
   // locale variant of any matching style sheet. Returns an integer
   // indicating whether the language matches, the language and
@@ -612,6 +660,48 @@
     return false;
   }
 
+  // Tests whether the high contrast value specified in the context matches
+  // the high contrast value of any matching style sheet
+  private static boolean _isHighContrastMatch(
+      StyleContext context,
+      StyleSheetNode[] styleSheets)
+  {
+    if (!context.getAccessibilityProfile().isHighContrast())
+      return false;
+
+    // If the high-contrast accessibility profile property is specified
+    // on any style sheet, we have a match.
+    for (int i = 0; i < styleSheets.length; i++)
+    {
+      if (styleSheets[i].getAccessibilityProperties().contains(
+            XMLConstants.ACC_HIGH_CONTRAST))
+        return true;
+    }
+
+    return false;
+  }
+
+  // Tests whether the high contrast value specified in the context matches
+  // the high contrast value of any matching style sheet
+  private static boolean _isLargeFontsMatch(
+      StyleContext context,
+      StyleSheetNode[] styleSheets)
+  {
+    if (!context.getAccessibilityProfile().isLargeFonts())
+      return false;
+
+    // If the large-fonts accessibility profile property is specified
+    // on any style sheet, we have a match.
+    for (int i = 0; i < styleSheets.length; i++)
+    {
+      if (styleSheets[i].getAccessibilityProperties().contains(
+            XMLConstants.ACC_LARGE_FONTS))
+        return true;
+    }
+
+    return false;
+  }
+
   // Direction constants
   private static final String _DIRECTION_RTL = "rtl";
 
@@ -646,6 +736,11 @@
   private static final String _PLATFORM_PPC = "ppc";
 
   private static final String _PLATFORM_BLACKBERRY = "blackberry";
+
+  // Accessibility constants
+  private static final String _ACC_HIGH_CONTRAST = "hc";
+
+  private static final String _ACC_LARGE_FONTS = "lf";
 
   // Name for unknown values (ie. browser, platforms, etc...)
   private static final String _UNKNOWN_NAME = "0";

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/XMLConstants.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/XMLConstants.java?rev=644040&r1=644039&r2=644040&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/XMLConstants.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/XMLConstants.java Wed Apr  2 13:31:06 2008
@@ -47,6 +47,7 @@
   public static final String BROWSERS_ATTR  = "browsers";
   public static final String VERSIONS_ATTR  = "versions";
   public static final String PLATFORMS_ATTR = "platforms";
+  public static final String ACC_PROFILE_ATTR = "accessibilityProfile";
   public static final String HREF_ATTR      = "href";
   public static final String PROPERTY_NAME_ATTR       = "propertyName";
   public static final String LOCAL_PROPERTY_NAME_ATTR = "localPropertyName";
@@ -56,5 +57,9 @@
   // Some value constants
   public static final String DIRECTION_RIGHTTOLEFT  = "rtl";
   public static final String DIRECTION_LEFTTORIGHT  = "ltr";
+
+  // AccessibilityProfile contstants
+  public static final String ACC_HIGH_CONTRAST  = "high-contrast";
+  public static final String ACC_LARGE_FONTS    = "large-fonts";
 }
 

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetDocument.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetDocument.java?rev=644040&r1=644039&r2=644040&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetDocument.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetDocument.java Wed Apr  2 13:31:06 2008
@@ -34,6 +34,7 @@
 import java.util.Set;
 import java.util.Stack;
 
+import org.apache.myfaces.trinidad.context.AccessibilityProfile;
 import org.apache.myfaces.trinidad.context.LocaleContext;
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 import org.apache.myfaces.trinidad.util.IntegerUtils;
@@ -312,6 +313,7 @@
     int direction = LocaleUtils.getReadingDirection(localeContext);
     int mode = NameUtils.getMode(ModeUtils.getCurrentMode(context));
     TrinidadAgent agent = context.getAgent();
+    AccessibilityProfile accProfile = context.getAccessibilityProfile();
 
     List<StyleSheetNode> v = new ArrayList<StyleSheetNode>(); // List of matching style sheets
     Iterator<StyleSheetNode> e = getStyleSheets();  // Iterator of all style sheets
@@ -321,7 +323,7 @@
     {
       StyleSheetNode styleSheet = e.next();
 
-      if (styleSheet.compareVariants(locale, direction, agent, mode) > 0)
+      if (styleSheet.compareVariants(locale, direction, agent, mode, accProfile) > 0)
         v.add(styleSheet);
     }
 
@@ -336,7 +338,8 @@
                                direction,
                                agent,
                                mode,
-                               _styleSheets);
+                               _styleSheets,
+                               accProfile);
 
     Arrays.sort(styleSheets, comparator);
 
@@ -869,7 +872,8 @@
       int direction,
       TrinidadAgent agent,
       int mode,
-      StyleSheetNode[] styleSheets
+      StyleSheetNode[] styleSheets,
+      AccessibilityProfile accessibilityProfile
       )
     {
       _direction = direction;
@@ -877,6 +881,7 @@
       _agent = agent;
       _styleSheets = styleSheets;
       _mode = mode;
+      _accProfile = accessibilityProfile;
     }
 
     public int compare(StyleSheetNode item1, StyleSheetNode item2)
@@ -887,12 +892,14 @@
       int match1 = item1.compareVariants(_locale, 
                                          _direction, 
                                          _agent, 
-                                         _mode);
+                                         _mode,
+                                         _accProfile);
       
       int match2 = item2.compareVariants(_locale, 
                                          _direction, 
                                          _agent, 
-                                         _mode);
+                                         _mode,
+                                         _accProfile);
 
       if (match1 == match2)
       {
@@ -932,6 +939,7 @@
     // precedence of two stylesheets with the same attributes.
     // Later style sheets take precedence over earlier ones
     private StyleSheetNode[] _styleSheets;
+    private AccessibilityProfile _accProfile;
   }
 
   // Private style class that we use when we're building up