You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ar...@apache.org on 2011/09/07 17:46:58 UTC
svn commit: r1166236 [1/3] - in /myfaces/trinidad/trunk:
src/site/xdoc/devguide/
trinidad-examples/trinidad-components-showcase/src/main/webapp/skins/
trinidad-examples/trinidad-demo/src/main/webapp/skins/beach/
trinidad-examples/trinidad-demo/src/main...
Author: arobinson74
Date: Wed Sep 7 15:46:57 2011
New Revision: 1166236
URL: http://svn.apache.org/viewvc?rev=1166236&view=rev
Log:
TRINIDAD-2111 - Commit patch by Anand Nath
Modified:
myfaces/trinidad/trunk/src/site/xdoc/devguide/skinning.xml
myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/webapp/skins/layout.css
myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/skins/beach/beach.css
myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/skins/purple/purpleBigFontSkinTwo.css (contents, props changed)
myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/skins/purple/purpleSkin.css
myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/skins/suede/suede.css
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/AgentAtRuleMatcher.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/resources/META-INF/adf/styles/base-desktop.css (contents, props changed)
myfaces/trinidad/trunk/trinidad-impl/src/main/resources/META-INF/adf/styles/casablancaSkin.css
myfaces/trinidad/trunk/trinidad-impl/src/main/xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts
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=1166236&r1=1166235&r2=1166236&view=diff
==============================================================================
--- myfaces/trinidad/trunk/src/site/xdoc/devguide/skinning.xml (original)
+++ myfaces/trinidad/trunk/src/site/xdoc/devguide/skinning.xml Wed Sep 7 15:46:57 2011
@@ -1078,6 +1078,32 @@ this resolves to
<source>
@agent ie and (min-version: 6) and (max-version: 7), gecko and (version: 1.9)
</source>
+ You can use touchScreen to specify styles/selectors for touch screen devices. Agent captures a capability named "touchScreen" which is set to none, single or multiple.
+ <source>
+ @agent (touchScreen:none)
+ @agent (touchScreen:single)
+ @agent (touchScreen:multiple)
+ </source>
+ Matches the corresponding touchScreen agent capability.
+ A short cut provided to specify any touchScreen device is:
+ <source>
+ @agent (touchScreen)
+ </source>
+ Matches all agents with touchScreen capability set to single or multiple.
+ You may notice that we have not specified agent name for the touchScreen examples till now. Agent name is made optional for touchScreen rules.
+ <source>
+ @agent webkit and (touchScreen)
+ </source>
+ Matches webkit run on all touch devices (single or multiple touch).
+ touchScreen can be specified with multiple ANDs and ORs as well.
+ <source>
+ @agent webkit and (version: 9) and (touchScreen:single)
+ </source>
+ Matches single touch device running version 9 of webkit.
+ <source>
+ @agent ie and (version: 9), webkit and (touchScreen:multiple)
+ </source>
+ Matches either version 9 of Internet Explorer or agent with multiple touch capability.
</P>
</li>
<li>
Modified: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/webapp/skins/layout.css
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/webapp/skins/layout.css?rev=1166236&r1=1166235&r2=1166236&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/webapp/skins/layout.css (original)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/webapp/skins/layout.css Wed Sep 7 15:46:57 2011
@@ -550,11 +550,13 @@ code {
.components_list af|navigationPane::list-inactive-enabled af|navigationPane::list-content a {
-tr-rule-ref: selector(".CBNavPaneListOption_Custom");
}
-.components_list af|navigationPane::list-inactive-enabled af|navigationPane::list-content a:hover {
- -tr-rule-ref: selector(".CBNavPaneListOptionHover_Custom");
-}
-.components_list af|navigationPane::list-active-enabled af|navigationPane::list-content a:hover {
- -tr-rule-ref: selector(".CBNavPaneListOptionSelectedHover_Custom");
+@agent (touchScreen:none) {
+ .components_list af|navigationPane::list-inactive-enabled af|navigationPane::list-content a:hover {
+ -tr-rule-ref: selector(".CBNavPaneListOptionHover_Custom");
+ }
+ .components_list af|navigationPane::list-active-enabled af|navigationPane::list-content a:hover {
+ -tr-rule-ref: selector(".CBNavPaneListOptionSelectedHover_Custom");
+ }
}
.components_list af|navigationPane::list-active-disabled af|navigationPane::list-content,
af|navigationPane::list-inactive-disabled af|navigationPane::list-content {
@@ -718,10 +720,29 @@ code {
float: none;
}
}
-#page_bar a:hover {
- text-decoration: none;
- color: white;
- background: #7D7873 url("/skins/slices/menu_hover.png") no-repeat bottom right;
+@agent (touchScreen:none) {
+ #page_bar a:hover {
+ text-decoration: none;
+ color: white;
+ background: #7D7873 url("/skins/slices/menu_hover.png") no-repeat bottom right;
+ }
+ #page_bar a:hover span {
+ border-top: 1px solid #88847F;
+ border-bottom: 1px solid #423F3B;
+ }
+ #page_bar .menu_anchor, #page_bar a:hover .menu_anchor {
+ display: block;
+ position: relative;
+ z-index: 10000;
+ border: none;
+ padding: 0;
+ }
+ #main_menu li a:hover {
+ }
+ #page_bar .expand:hover .submenu {
+ display: block;
+ }
+
}
#page_bar a span {
display: block;
@@ -732,10 +753,6 @@ code {
line-height: 1em;
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
}
-#page_bar a:hover span {
- border-top: 1px solid #88847F;
- border-bottom: 1px solid #423F3B;
-}
#page_bar a.expand span {
padding-right: 24px;
background: url("/skins/slices/expand_arrow.png") no-repeat center right;
@@ -747,13 +764,6 @@ code {
padding-right: 12px;
background: none;
}
-#page_bar .menu_anchor, #page_bar a:hover .menu_anchor {
- display: block;
- position: relative;
- z-index: 10000;
- border: none;
- padding: 0;
-}
/* Main Menu -------------------------------------------------------------------------------------------------------- */
#main_menu li {
float: left;
@@ -762,8 +772,6 @@ code {
#main_menu li a {
text-decoration: none;
}
-#main_menu li a:hover {
-}
/* Submenu ---------------------------------------------------------------------------------------------------------- */
#page_bar .submenu_container {
min-width: 100%;
@@ -787,9 +795,6 @@ code {
background: #615D59;
border: 1px solid #56524E;
}
-#page_bar .expand:hover .submenu {
- display: block;
-}
@agent ie and (version: 5), ie and (version: 6), ie and (version: 7), ie and (version: 8) {
#page_bar .expand:hover .submenu {
width: 100%;
@@ -798,8 +803,10 @@ code {
#page_bar .expand .submenu a {
background: #78736E;
}
-#page_bar .expand .submenu a:hover {
- background: #7D7873 url("/skins/slices/menu_hover.png") no-repeat bottom center;
+@agent (touchScreen:none) {
+ #page_bar .expand .submenu a:hover {
+ background: #7D7873 url("/skins/slices/menu_hover.png") no-repeat bottom center;
+ }
}
#page_bar .expand .submenu a span {
border-bottom: none;
@@ -822,8 +829,10 @@ code {
#skin_menu li a {
text-decoration: none;
}
-#skin_menu a:hover {
- background-position: bottom left;
+@agent (touchScreen:none) {
+ #skin_menu a:hover {
+ background-position: bottom left;
+ }
}
/* ------------------------------------------------------------------------------------------------------------------ */
@@ -874,10 +883,12 @@ code {
float: none;
}
}
-#page_bar a:hover {
- text-decoration: none;
- color: white;
- background: #7D7873 url("/skins/slices/menu_hover.png") no-repeat bottom right;
+@agent (touchScreen:none) {
+ #page_bar a:hover {
+ text-decoration: none;
+ color: white;
+ background: #7D7873 url("/skins/slices/menu_hover.png") no-repeat bottom right;
+ }
}
#page_bar a span {
display: block;
@@ -886,9 +897,11 @@ code {
padding: 7px 12px;
white-space: nowrap;
}
-#page_bar a:hover span {
- border-top: 1px solid #88847F;
- border-bottom: 1px solid #423F3B;
+@agent (touchScreen:none) {
+ #page_bar a:hover span {
+ border-top: 1px solid #88847F;
+ border-bottom: 1px solid #423F3B;
+ }
}
#page_bar a.expand span {
padding-right: 24px;
@@ -906,18 +919,30 @@ code {
padding-right: 12px;
background: none;
}
-#page_bar .menu_anchor, #page_bar a:hover .menu_anchor {
+
+#page_bar .menu_anchor {
display: block;
position: relative;
z-index: 10000;
border: none;
padding: 0;
}
+@agent (touchScreen:none) {
+ #page_bar a:hover .menu_anchor {
+ display: block;
+ position: relative;
+ z-index: 10000;
+ border: none;
+ padding: 0;
+ }
+}
/* Main Menu -------------------------------------------------------------------------------------------------------- */
#main_menu li {
float: left;
}
-#main_menu li a:hover {
+@agent (touchScreen:none) {
+ #main_menu li a:hover {
+ }
}
/* Submenu ---------------------------------------------------------------------------------------------------------- */
#page_bar .submenu_container {
@@ -939,8 +964,10 @@ code {
background: #615D59;
border: 1px solid #56524E;
}
-#page_bar .expand:hover .submenu {
- display: block;
+@agent (touchScreen:none) {
+ #page_bar .expand:hover .submenu {
+ display: block;
+ }
}
@agent ie and (version: 5), ie and (version: 6), ie and (version: 7), ie and (version: 8) {
#page_bar .expand:hover .submenu {
@@ -950,8 +977,10 @@ code {
#page_bar .expand .submenu a {
background: #78736E;
}
-#page_bar .expand .submenu a:hover {
- background: #7D7873 url("/skins/slices/menu_hover.png") no-repeat bottom center;
+@agent (touchScreen:none) {
+ #page_bar .expand .submenu a:hover {
+ background: #7D7873 url("/skins/slices/menu_hover.png") no-repeat bottom center;
+ }
}
#page_bar .expand .submenu a span {
border-bottom: none;
@@ -971,8 +1000,10 @@ code {
#skin_menu a {
background-position: bottom left;
}
-#skin_menu a:hover {
- background-position: bottom left;
+@agent (touchScreen:none) {
+ #skin_menu a:hover {
+ background-position: bottom left;
+ }
}
/* ------------------------------------------------------------------------------------------------------------------ */
@@ -1002,8 +1033,16 @@ code {
color: #0C87D1;
text-decoration: none;
}
-.gs-result a.gs-title:hover {
- text-decoration: underline;
+@agent (touchScreen:none) {
+ .gs-result a.gs-title:hover {
+ text-decoration: underline;
+ }
+ .gsc-cursor .gsc-cursor-page:hover {
+ -tr-rule-ref: selector(".CBPaginatorScrollerHover:alias");
+ }
+ .gsc-cursor .gsc-cursor-current-page:hover {
+ -tr-rule-ref: selector(".CBPaginatorScrollerSelectedHover:alias");
+ }
}
/* Search-result item body */
.gs-result .gs-snippet {
@@ -1013,12 +1052,6 @@ code {
text-decoration: none;
-tr-rule-ref: selector(".CBPaginatorScroller:alias");
}
-.gsc-cursor .gsc-cursor-page:hover {
- -tr-rule-ref: selector(".CBPaginatorScrollerHover:alias");
-}
.gsc-cursor .gsc-cursor-current-page {
-tr-rule-ref: selector(".CBPaginatorScrollerSelected:alias");
}
-.gsc-cursor .gsc-cursor-current-page:hover {
- -tr-rule-ref: selector(".CBPaginatorScrollerSelectedHover:alias");
-}
Modified: myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/skins/beach/beach.css
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/skins/beach/beach.css?rev=1166236&r1=1166235&r2=1166236&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/skins/beach/beach.css (original)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/skins/beach/beach.css Wed Sep 7 15:46:57 2011
@@ -134,9 +134,31 @@ af|panelTabbed::tab-link {
text-decoration: none;
}
-af|panelTabbed::tab-link:hover
-{
- -tr-rule-ref:selector(".MyLinkHoverColor:alias");
+@agent (touchScreen:none) {
+ af|panelTabbed::tab-link:hover
+ {
+ -tr-rule-ref:selector(".MyLinkHoverColor:alias");
+ }
+ af|menuTabs::enabled-link:hover, af|menuTabs::selected-link:hover
+ {
+ -tr-rule-ref:selector(".MyLinkHoverColor:alias");
+ }
+ af|menuBar::enabled-link:hover
+ {
+ -tr-rule-ref:selector(".MyLinkHoverColor:alias");
+ }
+ af|menuButtons::text:hover
+ {
+ -tr-rule-ref:selector(".MyLinkHoverColor:alias");
+ }
+ af|menuButtons::text-selected:hover
+ {
+ -tr-rule-ref:selector(".MyLinkHoverColor:alias");
+ }
+ af|menuButtons::text-disabled:hover
+ {
+ -tr-rule-ref:selector(".MyLinkHoverColor:alias");
+ }
}
/* put some space in the
@@ -209,10 +231,6 @@ af|menuTabs::selected-link
{
COLOR: black;
}
-af|menuTabs::enabled-link:hover, af|menuTabs::selected-link:hover
-{
- -tr-rule-ref:selector(".MyLinkHoverColor:alias");
-}
@@ -238,10 +256,6 @@ af|menuBar::body
background-color:#02B0AE;
}
-af|menuBar::enabled-link:hover
-{
- -tr-rule-ref:selector(".MyLinkHoverColor:alias");
-}
af|menuBar::separator
{
padding: 0px 2px 0px 2px;
@@ -265,18 +279,6 @@ af|menuBar::separator
text-decoration:none;
}
-af|menuButtons::text:hover
-{
- -tr-rule-ref:selector(".MyLinkHoverColor:alias");
-}
-af|menuButtons::text-selected:hover
-{
- -tr-rule-ref:selector(".MyLinkHoverColor:alias");
-}
-af|menuButtons::text-disabled:hover
-{
- -tr-rule-ref:selector(".MyLinkHoverColor:alias");
-}
/** panelBox **/
Modified: myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/skins/purple/purpleBigFontSkinTwo.css
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/skins/purple/purpleBigFontSkinTwo.css?rev=1166236&r1=1166235&r2=1166236&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/skins/purple/purpleBigFontSkinTwo.css (original)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/skins/purple/purpleBigFontSkinTwo.css Wed Sep 7 15:46:57 2011
@@ -1,25 +1,26 @@
-
-/*
- * 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.
- */
-
-.AFPurpleBigFontSkinTwo {color: green; background-color: purple }
-.AFPurpleBigFontSkinTwo {color: green; background-color: purple }
-
-
-af|panelList:hover {color: orange;}
+
+/*
+ * 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.
+ */
+
+.AFPurpleBigFontSkinTwo {color: green; background-color: purple }
+.AFPurpleBigFontSkinTwo {color: green; background-color: purple }
+
+@agent (touchScreen:none) {
+ af|panelList:hover {color: orange;}
+}
Propchange: myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/skins/purple/purpleBigFontSkinTwo.css
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/skins/purple/purpleSkin.css
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/skins/purple/purpleSkin.css?rev=1166236&r1=1166235&r2=1166236&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/skins/purple/purpleSkin.css (original)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/skins/purple/purpleSkin.css Wed Sep 7 15:46:57 2011
@@ -144,11 +144,20 @@ af|panelTabbed::tab-link {
text-decoration: none;
}
-af|panelTabbed::tab-link:hover
-{
- -tr-rule-ref:selector(".MyLinkHoverColor:alias");
+@agent (touchScreen:none) {
+ af|panelTabbed::tab-link:hover
+ {
+ -tr-rule-ref:selector(".MyLinkHoverColor:alias");
+ }
+ af|menuTabs::enabled-link:hover
+ {
+ -tr-rule-ref:selector(".MyLinkHoverColor:alias");
+ }
+ af|menuBar::enabled-link:hover
+ {
+ -tr-rule-ref:selector(".MyLinkHoverColor:alias");
+ }
}
-
/* put some space in the
first cell */
af|panelTabbed::cell-start {
@@ -206,12 +215,6 @@ af|menuTabs::enabled-link
color: white;
}
-af|menuTabs::enabled-link:hover
-{
- -tr-rule-ref:selector(".MyLinkHoverColor:alias");
-}
-
-
/** menuTabs that use icons are define like the following */
af|menuTabs::enabled-start-icon
{
@@ -299,10 +302,6 @@ af|menuBar::selected-link
{
font-weight:bold;
}
-af|menuBar::enabled-link:hover
-{
- -tr-rule-ref:selector(".MyLinkHoverColor:alias");
-}
af|menuBar::separator
{
padding: 0px 2px 0px 2px;
@@ -498,14 +497,15 @@ af|inputDate::launch-icon:rtl
height:24px
}
-
+@agent (touchScreen:none) {
+ af|breadCrumbs::step:hover {color: green}
+ af|breadCrumbs::selected-step:hover {color: green;}
+ af|treeTable::path-step:hover {color: green}
+ af|treeTable::path-selected-step:hover {color: green;}
+}
af|breadCrumbs::step {color: purple;}
-af|breadCrumbs::step:hover {color: green}
-af|breadCrumbs::selected-step:hover {color: green;}
af|treeTable::path-step {color: purple; text-decoration:none}
-af|treeTable::path-step:hover {color: green}
-af|treeTable::path-selected-step:hover {color: green;}
/** if, for some reason, you don't want an icon to show up, you
@@ -726,10 +726,11 @@ is a right-to-left language. */
font-size: 24em;
}
/* test css parsing only */
-.AFPanelNavigationHorizontal ul li.on:hover ul {
- background: #224d6f;
-}
-
+@agent (touchScreen:none) {
+ .AFPanelNavigationHorizontal ul li.on:hover ul {
+ background: #224d6f;
+ }
+}
af|navigationPane::bar {
background-color: pink;
}
@@ -742,10 +743,11 @@ af|navigationPane::bar-active-enabled af
color: blue;
}
-af|navigationPane::bar-active-enabled af|navigationPane::bar-content A:hover {
- color: purple;
+@agent (touchScreen:none) {
+ af|navigationPane::bar-active-enabled af|navigationPane::bar-content A:hover {
+ color: purple;
+ }
}
-
af|navigationPane::bar-content {
padding-top: 6px;
padding-bottom: 6px;
Modified: myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/skins/suede/suede.css
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/skins/suede/suede.css?rev=1166236&r1=1166235&r2=1166236&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/skins/suede/suede.css (original)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/skins/suede/suede.css Wed Sep 7 15:46:57 2011
@@ -456,10 +456,11 @@ af|navigationPane::bar-inactive-disabled
af|navigationPane::bar-active-disabled af|navigationPane::bar-content {
-tr-rule-ref: selector(".AFMediumForeground:alias");
}
-
-af|navigationPane::bar-active-enabled af|navigationPane::bar-content a:hover,
-af|navigationPane::bar-inactive-enabled af|navigationPane::bar-content a:hover {
- text-decoration:none;
+@agent (touchScreen:none) {
+ af|navigationPane::bar-active-enabled af|navigationPane::bar-content a:hover,
+ af|navigationPane::bar-inactive-enabled af|navigationPane::bar-content a:hover {
+ text-decoration:none;
+ }
}
af|navigationPane::bar-separator {
Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/AgentAtRuleMatcher.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/AgentAtRuleMatcher.java?rev=1166236&r1=1166235&r2=1166236&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/AgentAtRuleMatcher.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/AgentAtRuleMatcher.java Wed Sep 7 15:46:57 2011
@@ -19,8 +19,8 @@
package org.apache.myfaces.trinidadinternal.skin;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
-import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -31,7 +31,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.myfaces.trinidad.context.Version;
-import org.apache.myfaces.trinidad.util.CollectionUtils;
+import org.apache.myfaces.trinidad.logging.TrinidadLogger;
import org.apache.myfaces.trinidadinternal.agent.TrinidadAgent;
import org.apache.myfaces.trinidadinternal.style.util.NameUtils;
@@ -44,6 +44,7 @@ import org.apache.myfaces.trinidadintern
*/
public final class AgentAtRuleMatcher
{
+
/**
* Enumeration representing the result of a call to <code>match</code>.
* @see #match
@@ -53,7 +54,9 @@ public final class AgentAtRuleMatcher
/** The Match matched the agent applications */
APPLICATION,
/** The Match matched the agent version */
- VERSION
+ VERSION,
+ /** the Match matched capability touchScreen */
+ CAP_TOUCH_SCREEN
};
/**
@@ -81,7 +84,8 @@ public final class AgentAtRuleMatcher
public AgentAtRuleMatcher(String[] selectors)
{
Map<TrinidadAgent.Application, Set<AgentMatcher>> selectorAgents = Collections.emptyMap();
-
+ Set<AgentMatcher> capTouchMatchers = new HashSet<AgentMatcher>();
+
// process each of the selectors to build the Map of the AgentMatchers to run for any
// particular agent in this array of rules.
for (int selectorIndex = 0; selectorIndex < selectors.length; selectorIndex++)
@@ -91,30 +95,41 @@ public final class AgentAtRuleMatcher
// @agent ie and (version:6.*)
// @agent ie and (version:5.0.*)
// @agent ie and (min-version:5.*) and (max-version:6)
- // @agent ie and (version:6), ie and (version:7), gecko and (version:1.1)
-
- String currSelector = selectors[selectorIndex];
-
+ // @agent ie and (version:6), ie and (version:7), gecko and (version:1.1)
+ // @agent (touchScreen)
+ // @agent (touchScreen:none)
+ // @agent (touchScreen:none), ie and (version:6)
+ // @agent webkit and (version:6), (touchScreen)
+ // @agent webkit and (touchScreen:single)
+ // @agent webkit and (version:9) and (touchScreen:multiple)
+
+ String currSelector = selectors[selectorIndex].trim();
+ if (currSelector.startsWith(TOUCH_SCREEN_RULE_STR))
+ {
+ capTouchMatchers.add(_getTouchScreenMatcher(currSelector));
+ continue;
+ }
+
// split each of the sections between the "and"s. For example
// gecko and (min-version:1.5) and (max-version:1.9) would result in
// {"gecko", "(min-version:1.5)", "(max-version:1.9)"}
String[] sections = _AND_SPLITTER.split(currSelector);
-
+
// the agent is always the first section and is required.
// We trim because we are often passed strings with trailing whitespace
String agentName = sections[0].trim();
-
+
// convert the name of the agent to its TrinidadAgent.Application enum
TrinidadAgent.Application browser = NameUtils.getAgentApplication(agentName);
-
+
// turn the array of sections into the Set of AgentMatchers
//
if (browser != TrinidadAgent.Application.UNKNOWN)
{
int sectionCount = sections.length;
-
+
Set<AgentMatcher> agentMatchers;
-
+
if (sectionCount == 1)
{
// we only have the agent identifier, so no matchers
@@ -122,51 +137,53 @@ public final class AgentAtRuleMatcher
}
else
{
- AgentMatcher newVersionMatcher;
-
+ AgentMatcher newAgentMatcher;
+
if (sectionCount > 2)
{
// we have multiple ands, so we need to build up the list of sections to pass to
// to the AndMatcher, which will AND the results of each of the matches together
List<AgentMatcher> andedMatchers = new ArrayList<AgentMatcher>(sectionCount - 1);
-
- // create version matchers for each section
+
+ // create agent matchers for each section
+ // this could be version matcher or touchScreen matcher
for (int sectionIndex = 1; sectionIndex < sectionCount; sectionIndex++)
{
- andedMatchers.add(_getVersionMatcher(sections[sectionIndex]));
+ andedMatchers.add(_getAgentMatcher(sections[sectionIndex]));
}
-
- newVersionMatcher = new AndMatcher(andedMatchers);
+
+ newAgentMatcher = new AndMatcher(andedMatchers);
}
else
{
- // only a single and with a version match, so return that matcher directly
- newVersionMatcher = _getVersionMatcher(sections[1]);
+ // only a single and with a agent match, so return that matcher directly
+ // this could be version matcher or touchScreen matcher
+ newAgentMatcher = _getAgentMatcher(sections[1]);
}
-
+
// if you have selectors that repeat the browser, then get the agentMatchers that
- // you have so far for that browser so you can append to it.
+ // you have so far for that browser so you can append to it.
// @agent ie and (version: 6), ie and (version: 7), gecko and (version: 1.9)
// Th comma ORs the rules together.
agentMatchers = selectorAgents.get(browser);
-
+
// create the Version Set if it doesn't already exist, or add the Version to the
// current Version Set if it isn't already in there. Since most Version entries are
// a single value, we optimize for that case
if ((agentMatchers == null) || agentMatchers.isEmpty())
- agentMatchers = Collections.singleton(newVersionMatcher);
- else if (!agentMatchers.contains(newVersionMatcher))
+ agentMatchers = Collections.singleton(newAgentMatcher);
+ else if (!agentMatchers.contains(newAgentMatcher))
{
// we didn't already have an entry for this matcher. If the old size is 1, then
// the current set is going to be a Collections.singleton(), which is immutable,
// so we need to copy the the singleton Set into a HashSet, which IS mutable
if (agentMatchers.size() == 1)
agentMatchers = new HashSet<AgentMatcher>(agentMatchers);
-
- agentMatchers.add(newVersionMatcher);
+
+ agentMatchers.add(newAgentMatcher);
}
}
-
+
// optimize the size of the SelectorAgents Map when we add the new Versions
if (selectorAgents.isEmpty())
selectorAgents = Collections.singletonMap(browser, agentMatchers);
@@ -180,52 +197,114 @@ public final class AgentAtRuleMatcher
// a size of 3 seems a good start.
Map<TrinidadAgent.Application, Set<AgentMatcher>> newSelectorAgents =
new HashMap<TrinidadAgent.Application, Set<AgentMatcher>>(3);
-
+
// get the single entry out of here so we can add it into the new mutable map
- Map.Entry<TrinidadAgent.Application, Set<AgentMatcher>> singleEntry =
+ Map.Entry<TrinidadAgent.Application, Set<AgentMatcher>> singleEntry =
selectorAgents.entrySet().iterator().next();
-
+
newSelectorAgents.put(singleEntry.getKey(), singleEntry.getValue());
-
+
selectorAgents = newSelectorAgents;
}
-
+
// add the new mapping
- selectorAgents.put(browser, agentMatchers);
+ selectorAgents.put(browser, agentMatchers);
}
}
}
-
+
_selectorAgents = selectorAgents;
- _hashCode = _calculateStableHashCode(selectorAgents);
+ _capTouchMatchers = capTouchMatchers;
+ _hashCode = _calculateStableHashCode(_selectorAgents, _capTouchMatchers);
}
-
+
+ /**
+ * Parses touchScreen rule and creates appropriate AgentMatcher
+ * @param currSelector
+ */
+ private TouchScreenCapabilityMatcher _getTouchScreenMatcher(String currSelector) {
+ // split out the separate <capability> and <value> parts of the property selector. The
+ // <capability> will be in the first group, the <value> in the second.
+ Matcher m = _PROPERTY_SPLITTER.matcher(currSelector);
+ String[] capTouchArray = new String[]{};
+
+ if (m.find())
+ {
+ String propName = m.group(1);
+ String propValue = m.group(2);
+
+ // Needless to check if propName is touchScreen or not. It is already done in the caller side.
+ if (propValue != null)
+ {
+ String capValue = propValue.trim();
+ if (_ALL_TOUCH_CAPABILITIES.contains(capValue))
+ capTouchArray = new String[] {capValue};
+ else
+ {
+ _LOG.warning("INVALID_AGENT_PROPERTY", new Object[]{propName, capValue});
+ }
+ }
+ }
+ else
+ {
+ // when (touchScreen) is specified _PROPERTY_SPLITTER fails to match
+ // in this case add single and multiple
+ capTouchArray = _AFFIRMATIVE_TOUCH_CAPABILITIES;
+ }
+
+ if (capTouchArray.length > 0) {
+ Set<String> capTouchValues = Collections.unmodifiableSet(new HashSet<String>(Arrays.<String>asList(capTouchArray)));
+ TouchScreenCapabilityMatcher matcher = new TouchScreenCapabilityMatcher(capTouchValues);
+ return matcher;
+ }
+
+ // If touchScreen syntax was not parsed and no AgentMatcher was created.
+ throw new IllegalArgumentException("Invalid @agent rule specified: " + currSelector);
+ }
+
+
+
/**
* Because Enums don't have stable hash codes, we can't use their hash code directly. Instead
* we want to use the has code of the enum's name, which should be stable. Here we essentially
* duplicate the hash code calculation of Map, using the stable hash code instead
* @return stable hash code
*/
- private static int _calculateStableHashCode(
- Map<TrinidadAgent.Application, Set<AgentMatcher>> selectorAgents)
+ private static int _calculateStableHashCode(final Map<TrinidadAgent.Application, Set<AgentMatcher>> selectorAgents,
+ final Set<AgentMatcher> capTouchMatchers)
{
int hashCode = 0;
-
+
// Map hash code is defined as the additive hash code of the entries
for (Map.Entry<TrinidadAgent.Application, Set<AgentMatcher>> entry : selectorAgents.entrySet())
{
// use the enum's name to have a stable hash code
int stableKeyHashCode = entry.getKey().name().hashCode();
-
+
// entry hash code is defined as the XOR of the key and value.
int entryHashCode = stableKeyHashCode ^ entry.getValue().hashCode();
-
+
hashCode += entryHashCode;
}
-
+
+ hashCode += capTouchMatchers.hashCode();
+
return hashCode;
}
-
+
+ private AgentMatcher _getAgentMatcher(String propertySelector)
+ {
+ propertySelector = propertySelector.trim();
+ if (propertySelector.startsWith(TOUCH_SCREEN_RULE_STR))
+ {
+ return _getTouchScreenMatcher(propertySelector);
+ } else
+ {
+ return _getVersionMatcher(propertySelector);
+ }
+
+ }
+
/**
* Given a property selector of the form
* (<opt whitespace><identifier><opt whitespace>:<opt whitespace><version><opt whitespace>)
@@ -241,32 +320,32 @@ public final class AgentAtRuleMatcher
// split out the separate <identifier> and <version> parts of the property selector. The
// <identifier> will be in the first group, the <version> in the second.
Matcher m = _PROPERTY_SPLITTER.matcher(propertySelector);
-
+
if (m.find())
{
String propName = m.group(1);
String version = m.group(2);
-
+
// turn the property name--either "min-version", "max-version" or "version" into the
// type of comparison to perform
Comparison comparison = _COMPARISON_PARSER.get(propName);
-
+
if (comparison == null)
{
throw new IllegalArgumentException("Invalid @agent property name: " + propName);
}
-
+
// create the new Version, padding the version number out with wildcards
Version newVersion = new Version(version, "*");
-
- return new VersionMatcher(newVersion, comparison);
+
+ return new VersionMatcher(newVersion, comparison);
}
else
{
throw new IllegalArgumentException("Invalid @agent property selector: " + propertySelector);
}
}
-
+
/**
* <p>
* Called to actually determine if this AgentAtRuleMatcher applies to the current agent. The
@@ -290,27 +369,62 @@ public final class AgentAtRuleMatcher
*/
public Set<Match> match(TrinidadAgent agent)
{
+ Set<Match> matches = new HashSet<Match>();
// If we have browser exact match, compare versions
TrinidadAgent.Application browser = agent.getAgentApplication();
-
+
if (_selectorAgents.containsKey(browser))
{
+ matches.add(Match.APPLICATION);
Set<AgentMatcher> agentMatchers = _selectorAgents.get(browser);
- if (agentMatchers.isEmpty())
- return _APPLICATION_ONLY_MATCH;
-
- for (AgentMatcher currMatcher : agentMatchers)
+ if (!agentMatchers.isEmpty())
+ {
+ for (AgentMatcher currMatcher : agentMatchers)
+ {
+ if (currMatcher.match(agent))
+ {
+ if (currMatcher instanceof VersionMatcher)
+ matches.add(Match.VERSION);
+ else if (currMatcher instanceof TouchScreenCapabilityMatcher)
+ matches.add(Match.CAP_TOUCH_SCREEN);
+ else if (currMatcher instanceof AndMatcher)
+ {
+ AndMatcher andMatcher = (AndMatcher) currMatcher;
+ if (andMatcher.hasVersionMatcher())
+ matches.add(Match.VERSION);
+ if (andMatcher.hasTouchScreenCapabilityMatcher())
+ matches.add(Match.CAP_TOUCH_SCREEN);
+ }
+ }
+ }
+
+ // Expect at least one match from the matchers
+ if (!matches.contains(Match.CAP_TOUCH_SCREEN) && !matches.contains(Match.VERSION))
+ {
+ // There were one or many matchers but none matched, so remove all matchers.
+ matches.clear();
+ }
+ }
+ }
+
+ // If touchScreen is already matched then no need to check further.
+ if (!matches.contains(Match.CAP_TOUCH_SCREEN) && !_capTouchMatchers.isEmpty())
+ {
+ for (AgentMatcher currMatcher : _capTouchMatchers)
{
if (currMatcher.match(agent))
{
- return _APPLICATION_AND_VERSION_MATCH;
+ // If there is a capability matching then APPLICATION match should be by default.
+ matches.add(Match.APPLICATION);
+ matches.add(Match.CAP_TOUCH_SCREEN);
+ break;
}
}
}
- return _NO_MATCH;
+ return Collections.unmodifiableSet(matches);
}
-
+
@Override
public boolean equals(Object other)
{
@@ -320,7 +434,9 @@ public final class AgentAtRuleMatcher
{
if (other instanceof AgentAtRuleMatcher)
{
- return _selectorAgents.equals(((AgentAtRuleMatcher)other)._selectorAgents);
+ AgentAtRuleMatcher otherAgentMatcher = (AgentAtRuleMatcher) other;
+ return (_selectorAgents.equals(otherAgentMatcher._selectorAgents))
+ && (_capTouchMatchers.equals(otherAgentMatcher._capTouchMatchers));
}
else
{
@@ -328,17 +444,17 @@ public final class AgentAtRuleMatcher
}
}
}
-
+
@Override
public final int hashCode()
{
return _hashCode;
}
-
+
@Override
public String toString()
{
- return super.toString() + "agents=" + _selectorAgents.toString();
+ return super.toString() + "agents=" + _selectorAgents.toString() + "touchScreenCap=" + _capTouchMatchers.toString();
}
// the type of comparison to perform on the version
@@ -360,7 +476,7 @@ public final class AgentAtRuleMatcher
* implement <code>equals</code> and <code>hashCode</code>
* </p>
* <p>
- * While used to hide the differences between VersionMatchers and AndMatchers,
+ * While used to hide the differences between VersionMatchers and AndMatchers,
* this class should be abstract enough to support any new types of Agent matchers that we might
* want to add in the future.
* </p>
@@ -374,14 +490,14 @@ public final class AgentAtRuleMatcher
* @return <code>true</code> if the match succeeds
*/
public abstract boolean match(TrinidadAgent agent);
-
+
@Override
public abstract int hashCode();
-
- @Override
+
+ @Override
public abstract boolean equals(Object o);
}
-
+
/**
* Immutable and thread-safe AgentMatcher that matches the supplied Version against the
* version of a TrinidadAgent using the supplied, MAX, MIN, or EQUALS Comparison
@@ -397,12 +513,12 @@ public final class AgentAtRuleMatcher
{
_version = version;
_comparison = comparison;
-
+
// cache the hash code. Because enums don't have stable hash codes,
// we use the hash code of the name of the enum, which is stable
_hashCode = _version.hashCode() * 37 + _comparison.name().hashCode();
}
-
+
/**
* Matches the Version of this VersionMatcher against the Version of the supplied Agent,
* using the VersionMatcher's comparison
@@ -414,7 +530,7 @@ public final class AgentAtRuleMatcher
{
// use the Version's comparator
int result = _version.compareTo(agent.getVersion());
-
+
// since MIN means less than or equal to and MAX means greater than or equal to, a result
// of equality always means success
if (result == 0)
@@ -425,26 +541,26 @@ public final class AgentAtRuleMatcher
{
case MIN:
return result < 0; // min version has to be less than current version
-
+
case MAX:
return result > 0; // max version has to be bigger than current version
-
+
case EQUALS:
return false; // if the result were equal, we wouldn't have gotten this far
-
+
default:
assert false : "Unknown comparison type " + _comparison;
return false; // this should never happen, but the compiler doesn't know that
}
}
}
-
+
@Override
public final int hashCode()
{
return _hashCode;
}
-
+
@Override
public boolean equals(Object other)
{
@@ -455,7 +571,7 @@ public final class AgentAtRuleMatcher
if (other instanceof VersionMatcher)
{
VersionMatcher otherVersionMatcher = (VersionMatcher)other;
-
+
return _version.equals(otherVersionMatcher._version) &&
_comparison.equals(otherVersionMatcher._comparison);
}
@@ -465,18 +581,18 @@ public final class AgentAtRuleMatcher
}
}
}
-
+
@Override
public String toString()
{
return super.toString() + ", version=" + _version + ", comparison=" + _comparison;
}
-
+
private final Version _version;
private final Comparison _comparison;
private final int _hashCode;
}
-
+
/**
* AgentMatcher that ANDs the results of all calling match() on its AgentMatchers together,
* short-circuiting on the first AgentMatcher.match() that returns false.
@@ -492,12 +608,30 @@ public final class AgentAtRuleMatcher
// =-= btsulliv should we do anything if matchers contains fewer than two items? The code
// will still work, it just suggests a lack of optimization in the caller
_matchers = matchers;
-
+
// cache the hashcode so we don't traverse the list asking all of the other matchers for
// their hash codes each time our hash code is called
_hashCode = matchers.hashCode();
+
+ for (AgentMatcher matcher : matchers)
+ {
+ if (matcher instanceof VersionMatcher)
+ hasVersionMatcher = true;
+ if (matcher instanceof TouchScreenCapabilityMatcher)
+ hasTouchScreenCapabilityMatcher = true;
+ }
+ }
+
+ protected boolean hasTouchScreenCapabilityMatcher()
+ {
+ return hasTouchScreenCapabilityMatcher;
+ }
+
+ protected boolean hasVersionMatcher()
+ {
+ return hasVersionMatcher;
}
-
+
/**
* @param agent Agent to match againt
* @return <code>true</code> if all of the matchers matched the Agent
@@ -506,7 +640,7 @@ public final class AgentAtRuleMatcher
public boolean match(TrinidadAgent agent)
{
int matcherCount = _matchers.size();
-
+
for (int i = 0; i < matcherCount; i++)
{
// a matcher failed, so no sense in trying to match any more. Let's pick up our
@@ -514,17 +648,17 @@ public final class AgentAtRuleMatcher
if (!_matchers.get(i).match(agent))
return false;
}
-
+
// all of the matchers matched. Yay!
return true;
}
-
+
@Override
public int hashCode()
{
return _hashCode;
}
-
+
@Override
public boolean equals(Object other)
{
@@ -533,7 +667,7 @@ public final class AgentAtRuleMatcher
else
{
if (other instanceof AndMatcher)
- {
+ {
return _matchers.equals(((AndMatcher)other)._matchers);
}
else
@@ -542,15 +676,92 @@ public final class AgentAtRuleMatcher
}
}
}
-
+
@Override
public String toString()
{
return super.toString() + ", matchers=" + _matchers;
}
-
+
private final List<AgentMatcher> _matchers;
private final int _hashCode;
+ private boolean hasVersionMatcher;
+ private boolean hasTouchScreenCapabilityMatcher;
+
+ }
+
+ /**
+ * Immutable and thread-safe AgentMatcher that matches the supplied touchScreen capability against the
+ * that of the agent's.
+ */
+ private static final class TouchScreenCapabilityMatcher extends AgentMatcher
+ {
+ /**
+ * Creates a TouchScreenCapabilityMatcher
+ * @param touchCapabilities
+ */
+ public TouchScreenCapabilityMatcher(Set<String> touchCapabilities)
+ {
+ if (touchCapabilities == null)
+ throw new NullPointerException("touchCapabilities must be non-null");
+
+ _touchCapabilities = touchCapabilities;
+ _hashCode = _touchCapabilities.hashCode();
+ }
+
+ /**
+ * Matches the TouchScreenCapabilityMatcher against the touchScreen capability of the supplied Agent
+ * @param agent Agent to check the touchScreen capability of
+ * @return <code>true</code> if the comparison is successful
+ */
+ @Override
+ public boolean match(TrinidadAgent agent)
+ {
+ String capTouchScreen = (String) agent.getCapabilities().get(TrinidadAgent.CAP_TOUCH_SCREEN);
+ for (String touchCap : _touchCapabilities)
+ {
+ if (capTouchScreen.equals(touchCap))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public final int hashCode()
+ {
+ return _hashCode;
+ }
+
+ @Override
+ public boolean equals(Object other)
+ {
+ if (this == other)
+ return true;
+ else
+ {
+ if (other instanceof TouchScreenCapabilityMatcher)
+ {
+ TouchScreenCapabilityMatcher otherMatcher = (TouchScreenCapabilityMatcher)other;
+ return _touchCapabilities.equals(otherMatcher._touchCapabilities);
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return super.toString() + ", touchCapabilities=" + _touchCapabilities;
+ }
+
+ private final Set<String> _touchCapabilities;
+ private final int _hashCode;
}
// RegExp Pattern used to breaking apart the property selectors into a separate property name
@@ -578,33 +789,41 @@ public final class AgentAtRuleMatcher
// is added later, we require the "and" to be surrounded with whitespace.
private static final Pattern _AND_SPLITTER = Pattern.compile("\\s+and\\s+");
- // constants representing the three types of Match sets match returns
- private static final Set<Match> _NO_MATCH = Collections.emptySet();
- private static final Set<Match> _APPLICATION_ONLY_MATCH = Collections.singleton(Match.APPLICATION);
-
- private static final Set<Match> _APPLICATION_AND_VERSION_MATCH =
- Collections.unmodifiableSet(EnumSet.of(Match.APPLICATION, Match.VERSION));
+ private static final String[] _AFFIRMATIVE_TOUCH_CAPABILITIES =
+ new String[]
+ { TrinidadAgent.TOUCH_SCREEN_MULTIPLE.toString(),
+ TrinidadAgent.TOUCH_SCREEN_SINGLE.toString()
+ };
+
+ private static final Set<String> _ALL_TOUCH_CAPABILITIES =
+ new HashSet<String>(Arrays.<String>asList(new String[]
+ { TrinidadAgent.TOUCH_SCREEN_MULTIPLE.toString(),
+ TrinidadAgent.TOUCH_SCREEN_SINGLE.toString(),
+ TrinidadAgent.TOUCH_SCREEN_NONE.toString()
+ }));
-
// map of property names to the types of comparison to use for each name
private static final Map<String, Comparison> _COMPARISON_PARSER;
-
+
static
{
// initialize property-name to Comparison type Map. Thread-safe because the Map is not
// modified after initialization
_COMPARISON_PARSER = new HashMap<String, Comparison>(4);
-
+
_COMPARISON_PARSER.put("version", Comparison.EQUALS);
_COMPARISON_PARSER.put("max-version", Comparison.MAX);
_COMPARISON_PARSER.put("min-version", Comparison.MIN);
}
// As we need to be able to have multiple version matching rules for the same agent:
- // @agent ie and (version:5), ie and (version:6), gecko.
+ // @agent ie and (version:5), ie and (version:6), gecko.
// We store a map of agents and their version sets
private final Map<TrinidadAgent.Application, Set<AgentMatcher>> _selectorAgents;
-
+ private final Set<AgentMatcher> _capTouchMatchers;
+
// cached hash code
private final int _hashCode;
+ private static final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(AgentAtRuleMatcher.class);
+ private static final String TOUCH_SCREEN_RULE_STR = "(" + TrinidadAgent.CAP_TOUCH_SCREEN.getCapabilityName();
}
Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNode.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNode.java?rev=1166236&r1=1166235&r2=1166236&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNode.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNode.java Wed Sep 7 15:46:57 2011
@@ -372,7 +372,7 @@ public class StyleSheetNode
// On the other hand, if we do have a browser specified, but
// the client browser is not known, we don't have a match
if (application == TrinidadAgent.Application.UNKNOWN)
- return 0;
+ return _NO_MATCH;
Set<AgentAtRuleMatcher.Match> matches = _agentMatcher.match(agent);
@@ -388,6 +388,11 @@ public class StyleSheetNode
? _VERSION_EXACT_MATCH
: _VERSION_UNKNOWN_MATCH;
matchResult |= versionMatch;
+
+ int capTouchMatch = (matches.contains(AgentAtRuleMatcher.Match.CAP_TOUCH_SCREEN))
+ ? _CAP_TOUCH_SCREEN_EXACT_MATCH
+ : _CAP_TOUCH_SCREEN_UNKNOWN_MATCH;
+ matchResult |= capTouchMatch;
}
return matchResult;
@@ -587,6 +592,10 @@ public class StyleSheetNode
private static final int _VERSION_EXACT_MATCH = 0x00000020;
private static final int _VERSION_UNKNOWN_MATCH = 0x00000010;
+ // Constants for capability touchScreen matches - 0x000000f0 bits
+ private static final int _CAP_TOUCH_SCREEN_EXACT_MATCH = 0x00000040;
+ private static final int _CAP_TOUCH_SCREEN_UNKNOWN_MATCH = 0x00000030;
+
// Constants for os matches - 0x0000000f bits
private static final int _OS_EXACT_MATCH = 0x00000004;
private static final int _OS_PARTIAL_MATCH = 0x00000002;