You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by jw...@apache.org on 2009/04/14 01:10:41 UTC
svn commit: r764644 - in /myfaces/trinidad/branches/jwaldman_StyleMap:
trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/
trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/
trinidad-impl/src/main/java/org/apach...
Author: jwaldman
Date: Mon Apr 13 23:10:40 2009
New Revision: 764644
URL: http://svn.apache.org/viewvc?rev=764644&view=rev
Log:
added more comments
Modified:
myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RenderingContext.java
myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/StyleContextImpl.java
myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java
myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/StyleProvider.java
myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java
Modified: myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RenderingContext.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RenderingContext.java?rev=764644&r1=764643&r2=764644&view=diff
==============================================================================
--- myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RenderingContext.java (original)
+++ myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RenderingContext.java Mon Apr 13 23:10:40 2009
@@ -91,6 +91,8 @@
abstract public String getStyleClass(String styleClass);
/**
* Return the Styles object that is attached to this RenderingContext.
+ * Styles is a useful object if you need to know the css properties for a given
+ * selector.
* @return Styles
*/
abstract public Styles getStyles();
Modified: myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/StyleContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/StyleContextImpl.java?rev=764644&r1=764643&r2=764644&view=diff
==============================================================================
--- myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/StyleContextImpl.java (original)
+++ myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/StyleContextImpl.java Mon Apr 13 23:10:40 2009
@@ -54,7 +54,7 @@
assert(_arc.getAccessibilityProfile() != null);
}
-
+ @Override
public StyleProvider getStyleProvider()
{
if (_styleProvider == null)
@@ -67,6 +67,7 @@
/* added this in case we switch the skin after the styleProvider was cached above. */
/* we want to recompute, not get it from the cache. */
+ @Override
public StyleProvider getStyleProvider(boolean recompute)
{
if (recompute)
@@ -80,6 +81,10 @@
return getStyleProvider();
}
+ /**
+ *
+ */
+ @Override
public Styles getStyles()
{
if (_styles == null)
@@ -90,12 +95,13 @@
/**
* Returns the end user's locale.
*/
+ @Override
public LocaleContext getLocaleContext()
{
return _arc.getLocaleContext();
}
-
+ @Override
public String getGeneratedFilesPath()
{
return _generatedFilesPath;
@@ -104,11 +110,12 @@
/**
* Returns the end user's Agent.
*/
+ @Override
public TrinidadAgent getAgent()
{
return ((CoreRenderingContext) _arc).getTrinidadAgent();
}
-
+ @Override
public boolean checkStylesModified()
{
FacesContext context = FacesContext.getCurrentInstance();
@@ -116,13 +123,15 @@
context.getExternalContext().getInitParameter(Configuration.CHECK_TIMESTAMP_PARAM);
return "true".equals(checkTimestamp);
}
-
+
+ @Override
public boolean disableStandardsMode()
{
FacesContext fContext = FacesContext.getCurrentInstance();
return HtmlRenderer.isStandardsModeDisabled(fContext);
}
-
+
+ @Override
public AccessibilityProfile getAccessibilityProfile()
{
return _arc.getAccessibilityProfile();
Modified: myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java?rev=764644&r1=764643&r2=764644&view=diff
==============================================================================
--- myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java (original)
+++ myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java Mon Apr 13 23:10:40 2009
@@ -696,7 +696,7 @@
if (includeStyle.endsWith(":alias"))
{
// strip off :alias first and the . at the beginning
-
+
int endIndex = includeStyle.indexOf(":alias");
int startIndex = 0;
if (includeStyle.charAt(0) == '.')
Modified: myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/StyleProvider.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/StyleProvider.java?rev=764644&r1=764643&r2=764644&view=diff
==============================================================================
--- myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/StyleProvider.java (original)
+++ myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/StyleProvider.java Mon Apr 13 23:10:40 2009
@@ -70,7 +70,14 @@
*/
public List<String> getStyleSheetURIs(StyleContext context);
-
+ /**
+ * Return the Styles object that is attached to this StyleProvider. You can use the Styles
+ * object to retrieve a map of the skin selectors and their css properties, already resolved
+ * for this specific request. A skin has selectors for all agents, locales, etc., and there
+ * might be blocks for ie-only or gecko-only or rtl, etc., and the resolved styles are styles
+ * for the specific request (agent, locale, aliases are merged, etc).
+ * @return
+ */
public Styles getStyles(StyleContext context);
/**
Modified: myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java?rev=764644&r1=764643&r2=764644&view=diff
==============================================================================
--- myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java (original)
+++ myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java Mon Apr 13 23:10:40 2009
@@ -171,6 +171,7 @@
/**
* Implementation of StyleProvider.getStyles().
*/
+ @Override
public Styles getStyles(StyleContext context)
{
@@ -1401,7 +1402,7 @@
private class StylesImpl extends Styles
{
/**
- * This constructor takes an array of StyleNode where each StyleNode has
+ * This constructor takes an array of StyleNode Objects where each StyleNode has
* already been resolved based on the StyleContext. Therefore there is no
* more merging that needs to be done, and the 'included' properties on
* StyleNode are all null. This way we do not have to resolve the
@@ -1429,22 +1430,20 @@
{
Style style = _convertStyleNodeToStyle(_resolvedStyles[i]);
_resolvedSelectorStyleMap.put(Selector.createSelector(selector), style);
-
- // TODO create a map for native selectors. Given a selector, return
- // the native selector?
- // I might need a map of native selectors to styles, but for now I
- // think I only need to given a selector, return the native selector.
- // store the _namespacePrefixArray and the _afSelectorMap.
-
-
}
- /*
+ /*
else
{
// For now, do not add the named styles to the map. If we do add the named styles
// to the map then we should in SkinStyleSheetParserUtils put the full name in
- // the StyleNode, not strip out the '.' or the ':alias'.
-
+ // the StyleNode, not strip out the '.' or the ':alias'. However, in the XSS
+ // the named styles do not have the '.' or the ':alias' which is why we string them out.
+ // if we put them back, then things won't merge correctly. How do I workaround this?
+ // Do I change all the named styles in the XSS file?
+ // I think the best thing to do is to change the XSS file, since that is proprietary,
+ // and no one should be relying on it. If we instead kept stripping out the . and the alias
+ // and required the person to ask for the alias without this,
+ // that is much more confusing to the user.
String name = _resolvedStyles[i].getName();
if (name != null)
{
@@ -1464,8 +1463,10 @@
* (contains all the css property names/values) as the value. This Map can then be used
* to get all the selector keys, or to get the Style Object for a Selector, or to
* get all the selectors that match some criteria, like they contain a certain simple selector.
+ * This map does not contain 'alias' (aka named) selectors. It only contains selectors
+ * that would be in the generated css file.
*
- * @return unmodifiableMamp of the resolved Selector -> Style map.
+ * @return unmodifiableMap of the resolved Selector -> Style map.
*/
@Override
public Map<Selector, Style> getSelectorStyleMap()
@@ -1473,16 +1474,15 @@
return Collections.unmodifiableMap(_resolvedSelectorStyleMap);
}
- // Given a Selector, return the uncompressed valid css2-formatted selectors.
- // TODO is it necessary to return shortened styles if there is a shortened
- // map??
- // Right now we plan to use this to write out selectors in the html
- // page for emailable page, and that is uncompressed, but I suppose
- // it could be compressed somehow.
- // TODO This will need to move to the public API when we need it.
- // TODO should we build up a Map as we go along?
- // Right now we plan to get the style selectors in their css-3 skin format
- // and we'll need to convert it to something that is writeable to the page.
+ /**
+ * Returns the Selector in String form, converted to a format that
+ * is suitable to be written to the browse. This is the css-2 format which doesn't have
+ * namespaces and our psuedo-elements.
+ * @param selector Selector
+ * @return String the Selector in a String form that is suitable to be
+ * written to the client.
+ */
+ @Override
public String getNativeSelectorString(Selector selector)
{
// convert the selector to a valid css2 selector like the ones we write
@@ -1499,9 +1499,21 @@
mappedSelector, _namespacePrefixArray);
}
- // TODO Do I need ConcurrentHashMap??
+
+ /**
+ * Given a StyleNode object, which is an internal API that denotes a Style object
+ * with additional information like includedSelectors, create a simple public
+ * Style object which will be used in the SelectorStyleMap. The StyleNode object
+ * should already be resolved (included selectors have been merged in)
+ * so that all the css properties are there.
+ * @param styleNode
+ * @return A Style object created from the information in the styleNode.
+ */
public Style _convertStyleNodeToStyle(StyleNode styleNode)
{
+ // TODO Do I need ConcurrentHashMap? Do I need more than that? Note the icon
+ // and property map only use ConcurrentHashMap, but the cache maps use Hashtable (maybe
+ // because the code is old?)
Map<String, String> styleProperties = new ConcurrentHashMap<String, String>();
// Add in the properties for the style
Iterable<PropertyNode> propertyNodeList = styleNode.getProperties();
@@ -1513,7 +1525,6 @@
// See the BaseStyle(Map<String, String> propertiesMap) constructor.
if (name != null && value != null)
styleProperties.put(name, value);
-
}
return new CSSStyle(styleProperties);