Browse Source

Re-factoring: moving classes from client package to specific packages. Improving javadocs

tags/release-1.3.2
Manolo Carrasco 13 years ago
parent
commit
1c7a59fe81
29 changed files with 146 additions and 145 deletions
  1. 0
    43
      gwtquery-core/src/main/java/com/google/gwt/query/client/DeferredGQuery.java
  2. 12
    7
      gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java
  3. 2
    0
      gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java
  4. 4
    4
      gwtquery-core/src/main/java/com/google/gwt/query/client/JSRegexp.java
  5. 9
    0
      gwtquery-core/src/main/java/com/google/gwt/query/client/Predicate.java
  6. 42
    2
      gwtquery-core/src/main/java/com/google/gwt/query/client/Selectors.java
  7. 2
    2
      gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngine.java
  8. 2
    3
      gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineCssToXPath.java
  9. 1
    1
      gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineImpl.java
  10. 0
    1
      gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNative.java
  11. 0
    1
      gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNativeIE8.java
  12. 0
    1
      gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNativeMin.java
  13. 0
    1
      gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNativeMinIE8.java
  14. 30
    30
      gwtquery-core/src/main/java/com/google/gwt/query/client/impl/research/SelectorEngineJS.java
  15. 11
    11
      gwtquery-core/src/main/java/com/google/gwt/query/client/impl/research/SelectorEngineXPath.java
  16. 0
    1
      gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Effects.java
  17. 0
    1
      gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java
  18. 1
    0
      gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/GQueryQueue.java
  19. 0
    1
      gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/GQueryUi.java
  20. 0
    1
      gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEffects.java
  21. 0
    1
      gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEvents.java
  22. 0
    1
      gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyWidgets.java
  23. 3
    1
      gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Plugin.java
  24. 3
    3
      gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/PropertiesAnimation.java
  25. 0
    1
      gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Widgets.java
  26. 1
    1
      gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/Widgets.java
  27. 9
    12
      gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorBase.java
  28. 1
    1
      samples/pom.xml
  29. 13
    13
      samples/src/main/java/gwtquery/samples/client/GwtQueryBenchModule.java

+ 0
- 43
gwtquery-core/src/main/java/com/google/gwt/query/client/DeferredGQuery.java View File

@@ -1,43 +0,0 @@
/*
* Copyright 2011, The gwtquery team.
*
* Licensed 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 com.google.gwt.query.client;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.NodeList;
/**
* A compiled selector that can be lazily turned into a GQuery.
*/
public interface DeferredGQuery {
/**
* Evaluate the compiled selector with the given DOM node as a context.
* Returns a NodeList as a result.
*/
NodeList<Element> array(Node ctx);
/**
* Evaluate the compiled selector with the given DOM node as a context.
* Returns the result as a GQuery object.
*/
GQuery eval(Node ctx);
/**
* The selector which was compiled.
*/
String getSelector();
}

+ 12
- 7
gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java View File

@@ -25,14 +25,13 @@ import com.google.gwt.user.client.ui.Widget;
public abstract class Function {
/**
* Override this to define a cancel action.
* Override this for methods which invoke a cancel action.
*/
public void cancel(Element e) {
}

/**
* Override this to define a function which does not need any parameter.
*
*/
public void f() {
throw new RuntimeException("You have to override the adequate method to handle this action, or you have to override 'public void f()' to avoid this error");
@@ -78,8 +77,10 @@ public abstract class Function {
}
/**
* Override this for GQuery methods which take a callback, but do not expect a
* return value, apply to a single element only.
* Override this for GQuery methods which take a callback and do not expect a
* return value.
*
* @param e takes a com.google.gwt.dom.client.Element
*/
public void f(Element e) {
Widget w = GQuery.getAssociatedWidget(e);
@@ -90,7 +91,12 @@ public abstract class Function {
}
}

/**
* Override this for GQuery methods which take a callback and do not expect a
* return value.
*
* @param e takes a com.google.gwt.user.client.Element
*/
public void f(com.google.gwt.user.client.Element e) {
f((Element)e);
}
@@ -100,9 +106,8 @@ public abstract class Function {
* return value, apply to a single widget.
*
* NOTE: If your query is returning non-widget elements you might need to override
* 'public void f()' or 'public void f(Element e)' to handle these elements or to
* 'public void f()' or 'public void f(Element e)' to handle these elements and
* avoid a runtime exception.
*
*/
public void f(Widget w){
f();

+ 2
- 0
gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java View File

@@ -41,7 +41,9 @@ import com.google.gwt.query.client.css.HasCssValue;
import com.google.gwt.query.client.css.TakesCssValue;
import com.google.gwt.query.client.css.TakesCssValue.CssSetter;
import com.google.gwt.query.client.impl.DocumentStyleImpl;
import com.google.gwt.query.client.impl.SelectorEngine;
import com.google.gwt.query.client.plugins.EventsListener;
import com.google.gwt.query.client.plugins.Plugin;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.EventListener;

gwtquery-core/src/main/java/com/google/gwt/query/client/Regexp.java → gwtquery-core/src/main/java/com/google/gwt/query/client/JSRegexp.java View File

@@ -20,7 +20,7 @@ import com.google.gwt.core.client.JavaScriptObject;
/**
* A wrapper around Javascript Regexps.
*/
public class Regexp {
public class JSRegexp {
public static native JavaScriptObject compile(String pat) /*-{
return new RegExp(pat);
@@ -31,7 +31,7 @@ public class Regexp {
}-*/;
public static JSArray match(String regexp, String flags, String string) {
return new Regexp(regexp, flags).match(string);
return new JSRegexp(regexp, flags).match(string);
}
private static native JSArray exec0(JavaScriptObject regexp, String str) /*-{
@@ -40,11 +40,11 @@ public class Regexp {
private final JavaScriptObject regexp;
public Regexp(String pattern) {
public JSRegexp(String pattern) {
this.regexp = compile(pattern);
}
public Regexp(String pat, String flags) {
public JSRegexp(String pat, String flags) {
this.regexp = compileFlags(pat, flags);
}

+ 9
- 0
gwtquery-core/src/main/java/com/google/gwt/query/client/Predicate.java View File

@@ -22,5 +22,14 @@ import com.google.gwt.dom.client.Element;
*/
public interface Predicate {

/**
* Used by GQuery methods which loop over matched widgets and
* invoke a callback on each widget expecting a boolean value.
*
* @param e
* the element for this call
* @param index
* the element position in the gquery elements array.
*/
boolean f(Element e, int index);
}

+ 42
- 2
gwtquery-core/src/main/java/com/google/gwt/query/client/Selectors.java View File

@@ -15,18 +15,58 @@
*/
package com.google.gwt.query.client;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.NodeList;
/**
* Tagging interface used to generate compile time selectors.
*/
public interface Selectors {
/**
* A compiled selector that can be lazily turned into a GQuery.
*/
public interface DeferredSelector {
/**
* Evaluate the compiled selector with the given DOM node as a context.
*
* Returns a NodeList as a result which you could transform into a GQuery
* object passing it as argument to the $() function.
*/
NodeList<Element> runSelector(Node ctx);
/**
* The selector which was compiled.
*/
String getSelector();
}
DeferredGQuery[] getAllSelectors();
/**
* Return all the selectors defined for this interface, so as
* we can get the css representation of each one and lazily evaluate it
* in runtime.
*/
DeferredSelector[] getAllSelectors();
/**
* Set the context for all the selectors.
* By default they are evaluated in all the document.
*/
public void setRoot(Node node);
/**
* Get the configured root context.
*/
public Node getRoot();
/**
* Used for benchmarking purposes, it returns true if the selector engine
* for this browser is using a pure javascript implementation or a native
* one.
*
* It is useful to check if IE8 native selectors are being used.
*/
public boolean isDegradated();
}

gwtquery-core/src/main/java/com/google/gwt/query/client/SelectorEngine.java → gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngine.java View File

@@ -13,14 +13,14 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.gwt.query.client;
package com.google.gwt.query.client.impl;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.NodeList;
import com.google.gwt.query.client.impl.SelectorEngineImpl;
import com.google.gwt.query.client.JSArray;
/**
* Core Selector engine functions, and native JS utility functions.

+ 2
- 3
gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineCssToXPath.java View File

@@ -24,8 +24,7 @@ import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.NodeList;
import com.google.gwt.query.client.GQUtils;
import com.google.gwt.query.client.JSArray;
import com.google.gwt.query.client.Regexp;
import com.google.gwt.query.client.SelectorEngine;
import com.google.gwt.query.client.JSRegexp;
/**
* Runtime selector engine implementation which translates selectors to XPath
@@ -150,7 +149,7 @@ public class SelectorEngineCssToXPath extends SelectorEngineImpl {
// when using this engine in generators and tests for the JVM
private Replacer replacer = new Replacer() {
public String replaceAll(String s, String r, Object o) {
Regexp p = new Regexp(r);
JSRegexp p = new JSRegexp(r);
if (o instanceof ReplaceCallback) {
ReplaceCallback callback = (ReplaceCallback) o;
while (p.test(s)) {

+ 1
- 1
gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineImpl.java View File

@@ -19,7 +19,7 @@ import static com.google.gwt.query.client.GQUtils.truth;
import com.google.gwt.query.client.GQUtils;
import com.google.gwt.query.client.JSArray;
import com.google.gwt.query.client.Regexp;
import com.google.gwt.query.client.JSRegexp;
/**
* Base/Utility class for runtime selector engine implementations.

+ 0
- 1
gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNative.java View File

@@ -19,7 +19,6 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.NodeList;
import com.google.gwt.query.client.SelectorEngine;

/**
* Runtime selector engine implementation for browsers with native

+ 0
- 1
gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNativeIE8.java View File

@@ -18,7 +18,6 @@ package com.google.gwt.query.client.impl;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.NodeList;
import com.google.gwt.query.client.SelectorEngine;

/**
* Runtime selector engine implementation for IE with native

+ 0
- 1
gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNativeMin.java View File

@@ -18,7 +18,6 @@ package com.google.gwt.query.client.impl;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.NodeList;
import com.google.gwt.query.client.SelectorEngine;
import com.google.gwt.user.client.Window;

/**

+ 0
- 1
gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNativeMinIE8.java View File

@@ -18,7 +18,6 @@ package com.google.gwt.query.client.impl;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.NodeList;
import com.google.gwt.query.client.SelectorEngine;
import com.google.gwt.user.client.Window;

/**

+ 30
- 30
gwtquery-core/src/main/java/com/google/gwt/query/client/impl/research/SelectorEngineJS.java View File

@@ -26,8 +26,8 @@ import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.NodeList;
import com.google.gwt.query.client.GQUtils;
import com.google.gwt.query.client.JSArray;
import com.google.gwt.query.client.Regexp;
import com.google.gwt.query.client.SelectorEngine;
import com.google.gwt.query.client.JSRegexp;
import com.google.gwt.query.client.impl.SelectorEngine;
import com.google.gwt.query.client.impl.SelectorEngineImpl;
/**
@@ -90,7 +90,7 @@ public class SelectorEngineJS extends SelectorEngineImpl {
protected static Sequence getSequence(String expression) {
int start = 0, add = 2, max = -1, modVal = -1;
Regexp expressionRegExp = new Regexp(
JSRegexp expressionRegExp = new JSRegexp(
"^((odd|even)|([1-9]\\d*)|((([1-9]\\d*)?)n((\\+|\\-)(\\d+))?)|(\\-(([1-9]\\d*)?)n\\+(\\d+)))$");
JSArray pseudoValue = expressionRegExp.exec(expression);
if (!truth(pseudoValue)) {
@@ -212,7 +212,7 @@ public class SelectorEngineJS extends SelectorEngineImpl {
}
private static void getGeneralSiblingNodes(JSArray matchingElms,
JSArray nextTag, Regexp nextRegExp, Node prevRef) {
JSArray nextTag, JSRegexp nextRegExp, Node prevRef) {
while (
GQUtils.truth((prevRef = SelectorEngine.getNextSibling(prevRef)))
&& !isAdded(prevRef)) {
@@ -225,7 +225,7 @@ public class SelectorEngineJS extends SelectorEngineImpl {
}
private static void getSiblingNodes(JSArray matchingElms, JSArray nextTag,
Regexp nextRegExp, Node prevRef) {
JSRegexp nextRegExp, Node prevRef) {
while (
GQUtils.truth(prevRef = SelectorEngine.getNextSibling(prevRef))
&& prevRef.getNodeType() != Node.ELEMENT_NODE) {
@@ -267,16 +267,16 @@ public class SelectorEngineJS extends SelectorEngineImpl {
return arr;
}-*/;
private Regexp cssSelectorRegExp;
private JSRegexp cssSelectorRegExp;
private Regexp selectorSplitRegExp;
private JSRegexp selectorSplitRegExp;
private Regexp childOrSiblingRefRegExp;
private JSRegexp childOrSiblingRefRegExp;
public SelectorEngineJS() {
selectorSplitRegExp = new Regexp("[^\\s]+", "g");
childOrSiblingRefRegExp = new Regexp("^(>|\\+|~)$");
cssSelectorRegExp = new Regexp(
selectorSplitRegExp = new JSRegexp("[^\\s]+", "g");
childOrSiblingRefRegExp = new JSRegexp("^(>|\\+|~)$");
cssSelectorRegExp = new JSRegexp(
"^(\\w+)?(#[\\w\\u00C0-\\uFFFF\\-\\_]+|(\\*))?((\\.[\\w\\u00C0-\\uFFFF\\-_]+)*)?((\\[\\w+(\\^|\\$|\\*|\\||~)?(=[\"']*[\\w\\u00C0-\\uFFFF\\s\\-\\_\\.]+[\"']*)?\\]+)*)?(((:\\w+[\\w\\-]*)(\\((odd|even|\\-?\\d*n?((\\+|\\-)\\d+)?|[\\w\\u00C0-\\uFFFF\\-_]+|((\\w*\\.[\\w\\u00C0-\\uFFFF\\-_]+)*)?|(\\[#?\\w+(\\^|\\$|\\*|\\||~)?=?[\\w\\u00C0-\\uFFFF\\s\\-\\_\\.]+\\]+)|(:\\w+[\\w\\-]*))\\))?)*)?");
}
@@ -306,13 +306,13 @@ public class SelectorEngineJS extends SelectorEngineImpl {
if (i > 0 && childOrSiblingRefRegExp.test(rule)) {
JSArray childOrSiblingRef = childOrSiblingRefRegExp.exec(rule);
if (GQUtils.truth(childOrSiblingRef)) {
JSArray nextTag = new Regexp("^\\w+")
JSArray nextTag = new JSRegexp("^\\w+")
.exec(cssSelectors.getStr(i + 1));
Regexp nextRegExp = null;
JSRegexp nextRegExp = null;
String nextTagStr = null;
if (GQUtils.truth(nextTag)) {
nextTagStr = nextTag.getStr(0);
nextRegExp = new Regexp("(^|\\s)" + nextTagStr + "(\\s|$)", "i");
nextRegExp = new JSRegexp("(^|\\s)" + nextTagStr + "(\\s|$)", "i");
}
for (int j = 0, jlen = prevElem.size(); j < jlen; j++) {
Node prevRef = prevElem.getNode(j);
@@ -329,7 +329,7 @@ public class SelectorEngineJS extends SelectorEngineImpl {
prevElem = matchingElms;
clearAdded(prevElem);
rule = cssSelectors.getStr(++i);
if (new Regexp("^\\w+$").test(rule)) {
if (new JSRegexp("^\\w+$").test(rule)) {
continue;
}
setSkipTag(prevElem, true);
@@ -379,9 +379,9 @@ public class SelectorEngineJS extends SelectorEngineImpl {
if (GQUtils.truth(splitRule.allClasses)) {
String[] allClasses = splitRule.allClasses.replaceFirst("^\\.", "")
.split("\\.");
Regexp[] regExpClassNames = new Regexp[allClasses.length];
JSRegexp[] regExpClassNames = new JSRegexp[allClasses.length];
for (int n = 0, nl = allClasses.length; n < nl; n++) {
regExpClassNames[n] = new Regexp(
regExpClassNames[n] = new JSRegexp(
"(^|\\s)" + allClasses[n] + "(\\s|$)");
}
JSArray matchingClassElms = JSArray.create();
@@ -406,11 +406,11 @@ public class SelectorEngineJS extends SelectorEngineImpl {
prevElem = matchingElms = matchingClassElms;
}
if (GQUtils.truth(splitRule.allAttr)) {
JSArray allAttr = Regexp
JSArray allAttr = JSRegexp
.match("\\[[^\\]]+\\]", "g", splitRule.allAttr);
Regexp[] regExpAttributes = new Regexp[allAttr.size()];
JSRegexp[] regExpAttributes = new JSRegexp[allAttr.size()];
String[] regExpAttributesStr = new String[allAttr.size()];
Regexp attributeMatchRegExp = new Regexp(
JSRegexp attributeMatchRegExp = new JSRegexp(
"(\\w+)(\\^|\\$|\\*|\\||~)?=?[\"']?([\\w\u00C0-\uFFFF\\s\\-_\\.]+)?");
for (int q = 0, ql = allAttr.size(); q < ql; q++) {
JSArray attributeMatch = attributeMatchRegExp
@@ -421,7 +421,7 @@ public class SelectorEngineJS extends SelectorEngineImpl {
: null;
String attrVal = attrToRegExp(attributeValue,
(GQUtils.or(attributeMatch.getStr(2), null)));
regExpAttributes[q] = (GQUtils.truth(attrVal) ? new Regexp(
regExpAttributes[q] = (GQUtils.truth(attrVal) ? new JSRegexp(
attrVal) : null);
regExpAttributesStr[q] = attributeMatch.getStr(1);
}
@@ -433,7 +433,7 @@ public class SelectorEngineJS extends SelectorEngineImpl {
for (int s = 0, sl = regExpAttributes.length;
s < sl; s++) {
addElm = false;
Regexp attributeRegexp = regExpAttributes[s];
JSRegexp attributeRegexp = regExpAttributes[s];
String currentAttr = getAttr(current, regExpAttributesStr[s]);
if (GQUtils.truth(currentAttr)
&& currentAttr.length() != 0) {
@@ -453,10 +453,10 @@ public class SelectorEngineJS extends SelectorEngineImpl {
prevElem = matchingElms = matchingAttributeElms;
}
if (GQUtils.truth(splitRule.allPseudos)) {
Regexp pseudoSplitRegExp = new Regexp(
JSRegexp pseudoSplitRegExp = new JSRegexp(
":(\\w[\\w\\-]*)(\\(([^\\)]+)\\))?");
JSArray allPseudos = Regexp
JSArray allPseudos = JSRegexp
.match("(:\\w+[\\w\\-]*)(\\([^\\)]+\\))?", "g",
splitRule.allPseudos);
for (int t = 0, tl = allPseudos.size(); t < tl; t++) {
@@ -638,19 +638,19 @@ public class SelectorEngineJS extends SelectorEngineImpl {
private JSArray getNotPseudo(JSArray previousMatch, String pseudoValue,
JSArray matchingElms) {
if (new Regexp("(:\\w+[\\w\\-]*)$").test(pseudoValue)) {
if (new JSRegexp("(:\\w+[\\w\\-]*)$").test(pseudoValue)) {
matchingElms = subtractArray(previousMatch,
getElementsByPseudo(previousMatch, pseudoValue.substring(1), ""));
} else {
pseudoValue = pseudoValue
.replace("^\\[#([\\w\\u00C0-\\uFFFF\\-\\_]+)\\]$", "[id=$1]");
JSArray notTag = new Regexp("^(\\w+)").exec(pseudoValue);
JSArray notClass = new Regexp("^\\.([\\w\u00C0-\uFFFF\\-_]+)")
JSArray notTag = new JSRegexp("^(\\w+)").exec(pseudoValue);
JSArray notClass = new JSRegexp("^\\.([\\w\u00C0-\uFFFF\\-_]+)")
.exec(pseudoValue);
JSArray notAttr = new Regexp(
JSArray notAttr = new JSRegexp(
"\\[(\\w+)(\\^|\\$|\\*|\\||~)?=?([\\w\\u00C0-\\uFFFF\\s\\-_\\.]+)?\\]")
.exec(pseudoValue);
Regexp notRegExp = new Regexp("(^|\\s)"
JSRegexp notRegExp = new JSRegexp("(^|\\s)"
+ (GQUtils.truth(notTag) ? notTag.getStr(1)
: GQUtils.truth(notClass) ? notClass.getStr(1) : "")
+ "(\\s|$)", "i");
@@ -659,7 +659,7 @@ public class SelectorEngineJS extends SelectorEngineImpl {
.getStr(3).replace("\\.", "\\.") : null;
String notMatchingAttrVal = attrToRegExp(notAttribute,
notAttr.getStr(2));
notRegExp = new Regexp(notMatchingAttrVal, "i");
notRegExp = new JSRegexp(notMatchingAttrVal, "i");
}
for (int v = 0, vlen = previousMatch.size(); v < vlen; v++) {
Element notElm = previousMatch.getElement(v);

+ 11
- 11
gwtquery-core/src/main/java/com/google/gwt/query/client/impl/research/SelectorEngineXPath.java View File

@@ -24,8 +24,8 @@ import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.NodeList;
import com.google.gwt.query.client.GQUtils;
import com.google.gwt.query.client.JSArray;
import com.google.gwt.query.client.Regexp;
import com.google.gwt.query.client.SelectorEngine;
import com.google.gwt.query.client.JSRegexp;
import com.google.gwt.query.client.impl.SelectorEngine;
import com.google.gwt.query.client.impl.SelectorEngineImpl;
import com.google.gwt.query.client.impl.research.SelectorEngineJS.Sequence;
import com.google.gwt.query.client.impl.research.SelectorEngineJS.SplitRule;
@@ -59,11 +59,11 @@ public class SelectorEngineXPath extends SelectorEngineImpl {
return "@" + p1 + (truth(p3) ? "='" + p3 + "'" : "");
}
private Regexp cssSelectorRegExp;
private JSRegexp cssSelectorRegExp;
private Regexp selectorSplitRegExp;
private JSRegexp selectorSplitRegExp;
private Regexp combinator;
private JSRegexp combinator;
public SelectorEngineXPath() {
}
@@ -125,9 +125,9 @@ public class SelectorEngineXPath extends SelectorEngineImpl {
GQUtils.or(splitRule.allAttr, ""));
}
if (truth(splitRule.allPseudos)) {
Regexp pseudoSplitRegExp = new Regexp(
JSRegexp pseudoSplitRegExp = new JSRegexp(
":(\\w[\\w\\-]*)(\\(([^\\)]+)\\))?");
Regexp pseudoMatchRegExp = new Regexp(
JSRegexp pseudoMatchRegExp = new JSRegexp(
"(:\\w+[\\w\\-]*)(\\([^\\)]+\\))?", "g");
JSArray allPseudos = pseudoMatchRegExp.match(splitRule.allPseudos);
for (int k = 0, kl = allPseudos.size(); k < kl; k++) {
@@ -151,10 +151,10 @@ public class SelectorEngineXPath extends SelectorEngineImpl {
private void init() {
if (cssSelectorRegExp == null) {
cssSelectorRegExp = new Regexp(
cssSelectorRegExp = new JSRegexp(
"^(\\w+)?(#[\\w\\u00C0-\\uFFFF\\-\\_]+|(\\*))?((\\.[\\w\\u00C0-\\uFFFF\\-_]+)*)?((\\[\\w+(\\^|\\$|\\*|\\||~)?(=[\"']*[\\w\\u00C0-\\uFFFF\\s\\-\\_\\.]+[\"']*)?\\]+)*)?(((:\\w+[\\w\\-]*)(\\((odd|even|\\-?\\d*n?((\\+|\\-)\\d+)?|[\\w\\u00C0-\\uFFFF\\-_]+|((\\w*\\.[\\w\\u00C0-\\uFFFF\\-_]+)*)?|(\\[#?\\w+(\\^|\\$|\\*|\\||~)?=?[\\w\\u00C0-\\uFFFF\\s\\-\\_\\.]+\\]+)|(:\\w+[\\w\\-]*))\\))?)*)?(>|\\+|~)?");
selectorSplitRegExp = new Regexp("[^\\s]+", "g");
combinator = new Regexp("(>|\\+|~)");
selectorSplitRegExp = new JSRegexp("[^\\s]+", "g");
combinator = new JSRegexp("(>|\\+|~)");
}
}
@@ -215,7 +215,7 @@ public class SelectorEngineXPath extends SelectorEngineImpl {
} else if (eq("checked", pseudoClass)) {
xpath = "@checked='checked'"; // Doesn't work in Opera 9.24
} else if (eq("not", pseudoClass)) {
if (new Regexp("^(:\\w+[\\w\\-]*)$").test(pseudoValue)) {
if (new JSRegexp("^(:\\w+[\\w\\-]*)$").test(pseudoValue)) {
xpath = "not(" + pseudoToXPath(tag, pseudoValue.substring(1), "") + ")";
} else {

+ 0
- 1
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Effects.java View File

@@ -21,7 +21,6 @@ import com.google.gwt.dom.client.NodeList;
import com.google.gwt.query.client.Function;
import com.google.gwt.query.client.GQuery;
import com.google.gwt.query.client.JSArray;
import com.google.gwt.query.client.Plugin;
import com.google.gwt.query.client.Properties;
import com.google.gwt.query.client.plugins.ClipAnimation.Action;
import com.google.gwt.query.client.plugins.ClipAnimation.Direction;

+ 0
- 1
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java View File

@@ -21,7 +21,6 @@ import com.google.gwt.dom.client.NodeList;
import com.google.gwt.query.client.Function;
import com.google.gwt.query.client.GQuery;
import com.google.gwt.query.client.JSArray;
import com.google.gwt.query.client.Plugin;
import com.google.gwt.user.client.Event;

/**

+ 1
- 0
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/GQueryQueue.java View File

@@ -149,6 +149,7 @@ public abstract class GQueryQueue<T extends GQueryQueue<?>> extends GQuery {
}
private void stop(Element elem, boolean clear) {
Function ff = null;
Queue<?> q = queue(elem, null);
if (q != null) {
Object f = q.peek();

+ 0
- 1
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/GQueryUi.java View File

@@ -23,7 +23,6 @@ import com.google.gwt.event.shared.HasHandlers;
import com.google.gwt.query.client.Function;
import com.google.gwt.query.client.GQuery;
import com.google.gwt.query.client.JSArray;
import com.google.gwt.query.client.Plugin;
import com.google.gwt.query.client.Predicate;

/**

+ 0
- 1
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEffects.java View File

@@ -20,7 +20,6 @@ import com.google.gwt.dom.client.NodeList;
import com.google.gwt.query.client.Function;
import com.google.gwt.query.client.GQuery;
import com.google.gwt.query.client.JSArray;
import com.google.gwt.query.client.Plugin;
import com.google.gwt.query.client.Properties;
import com.google.gwt.query.client.plugins.ClipAnimation.Action;
import com.google.gwt.query.client.plugins.ClipAnimation.Direction;

+ 0
- 1
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEvents.java View File

@@ -20,7 +20,6 @@ import com.google.gwt.dom.client.NodeList;
import com.google.gwt.query.client.Function;
import com.google.gwt.query.client.GQuery;
import com.google.gwt.query.client.JSArray;
import com.google.gwt.query.client.Plugin;
import com.google.gwt.user.client.Event;
import com.google.gwt.query.client.LazyBase;


+ 0
- 1
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyWidgets.java View File

@@ -18,7 +18,6 @@ import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NodeList;
import com.google.gwt.query.client.GQuery;
import com.google.gwt.query.client.JSArray;
import com.google.gwt.query.client.Plugin;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.TextBox;

gwtquery-core/src/main/java/com/google/gwt/query/client/Plugin.java → gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Plugin.java View File

@@ -13,7 +13,9 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.gwt.query.client;
package com.google.gwt.query.client.plugins;
import com.google.gwt.query.client.GQuery;
/**
* A GQuery plugin. All GQuery plugins must implement this interface.

+ 3
- 3
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/PropertiesAnimation.java View File

@@ -23,7 +23,7 @@ import com.google.gwt.query.client.Function;
import com.google.gwt.query.client.GQuery;
import com.google.gwt.query.client.JSArray;
import com.google.gwt.query.client.Properties;
import com.google.gwt.query.client.Regexp;
import com.google.gwt.query.client.JSRegexp;
/**
* Animation effects on any numeric CSS property.
@@ -70,7 +70,7 @@ public class PropertiesAnimation extends Animation {
private static final String[] attrsToSave = new String[] { "overflow",
"visibility" };
private static Regexp nonPxRegExp = new Regexp(
private static JSRegexp nonPxRegExp = new JSRegexp(
"z-?index|font-?weight|opacity|zoom|line-?height", "i");
@@ -103,7 +103,7 @@ public class PropertiesAnimation extends Animation {
end = 0;
unit = nonPxRegExp.test(key) ? "" : "px";
} else {
JSArray parts = new Regexp("^([+-]=)?([0-9+-.]+)(.*)?$").match(val);
JSArray parts = new JSRegexp("^([+-]=)?([0-9+-.]+)(.*)?$").match(val);
if (parts != null) {
unit = nonPxRegExp.test(key) ? "" : parts.getStr(3) == null ? "px"

+ 0
- 1
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Widgets.java View File

@@ -19,7 +19,6 @@ import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NodeList;
import com.google.gwt.query.client.GQuery;
import com.google.gwt.query.client.JSArray;
import com.google.gwt.query.client.Plugin;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.TextBox;

+ 1
- 1
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/Widgets.java View File

@@ -19,8 +19,8 @@ import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NodeList;
import com.google.gwt.query.client.GQuery;
import com.google.gwt.query.client.JSArray;
import com.google.gwt.query.client.Plugin;
import com.google.gwt.query.client.plugins.GQueryQueue;
import com.google.gwt.query.client.plugins.Plugin;
import com.google.gwt.query.client.plugins.widgets.widgetfactory.ButtonWidgetFactory;
import com.google.gwt.query.client.plugins.widgets.widgetfactory.TabPanelWidgetFactory;
import com.google.gwt.query.client.plugins.widgets.widgetfactory.WidgetFactory;

+ 9
- 12
gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorBase.java View File

@@ -137,11 +137,11 @@ public abstract class SelectorGeneratorBase extends Generator {
}
ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(
packageName, className);
composerFactory.setSuperclass("com.google.gwt.query.client.SelectorEngine");
composerFactory.addImport("com.google.gwt.core.client.GWT");
composerFactory.setSuperclass("com.google.gwt.query.client.impl.SelectorEngine");
composerFactory.addImport("com.google.gwt.query.client.impl.*");
composerFactory.addImport("com.google.gwt.query.client.Selectors.*");
composerFactory.addImport("com.google.gwt.query.client.*");
// composerFactory.addImport("com.google.gwt.query.client.JSArray");
composerFactory.addImport("com.google.gwt.core.client.*");
composerFactory.addImport("com.google.gwt.dom.client.*");
for (String interfaceName : interfaceNames) {
composerFactory.addImplementedInterface(interfaceName);
@@ -177,9 +177,9 @@ public abstract class SelectorGeneratorBase extends Generator {
// used by benchmark harness
private void genGetAllMethod(SourceWriter sw, JMethod[] methods,
TreeLogger treeLogger) {
sw.println("public DeferredGQuery[] getAllSelectors() {");
sw.println("public DeferredSelector[] getAllSelectors() {");
sw.indent();
sw.println("DeferredGQuery[] dg = new DeferredGQuery[" + (methods.length)
sw.println("DeferredSelector[] ds = new DeferredSelector[" + (methods.length)
+ "];");
int i = 0;
for (JMethod m : methods) {
@@ -189,16 +189,13 @@ public abstract class SelectorGeneratorBase extends Generator {
}
String selector = selectorAnnotation.value();
sw.println("dg[" + i + "]=new DeferredGQuery() {");
sw.println("ds[" + i + "]=new DeferredSelector() {");
sw.indent();
sw
.println("public String getSelector() { return \"" + selector
+ "\"; }");
sw.println("public GQuery eval(Node ctx) { return "
+ wrapJS(m, m.getName()
+ (m.getParameters().length == 0 ? "()" : "(ctx)") + "") + " ;}");
sw
.println("public NodeList<Element> array(Node ctx) { return "
.println("public NodeList<Element> runSelector(Node ctx) { return "
+ ("NodeList".equals(m.getReturnType().getSimpleSourceName()) ? (m
.getName() + (m.getParameters().length == 0 ? "(); "
: "(ctx); "))
@@ -210,7 +207,7 @@ public abstract class SelectorGeneratorBase extends Generator {
sw.outdent();
sw.println("};");
}
sw.println("return dg;");
sw.println("return ds;");
sw.outdent();
sw.println("}");
}

+ 1
- 1
samples/pom.xml View File

@@ -44,8 +44,8 @@
<gwtVersion>${gwtversion}</gwtVersion>
<compileReport>true</compileReport>
<modules>
<module>gwtquery.samples.GwtQuerySample</module>
<module>gwtquery.samples.GwtQueryBench</module>
<module>gwtquery.samples.GwtQuerySample</module>
<module>gwtquery.samples.GwtQueryDemo</module>
<module>gwtquery.samples.GwtQueryEffects</module>
<module>gwtquery.samples.GwtQueryEffectsMin</module>

+ 13
- 13
samples/src/main/java/gwtquery/samples/client/GwtQueryBenchModule.java View File

@@ -25,9 +25,9 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.RepeatingCommand;
import com.google.gwt.dom.client.Element;
import com.google.gwt.query.client.DeferredGQuery;
import com.google.gwt.query.client.Function;
import com.google.gwt.query.client.GQuery;
import com.google.gwt.query.client.Selectors.*;
import com.google.gwt.query.client.impl.SelectorEngineCssToXPath;
import com.google.gwt.query.client.impl.SelectorEngineImpl;
import com.google.gwt.query.client.impl.SelectorEngineNative;
@@ -67,7 +67,7 @@ public class GwtQueryBenchModule implements EntryPoint {
public interface Benchmark {
String getId();
String getName();
int runSelector(DeferredGQuery dq);
int runSelector(DeferredSelector dq);
}
/**
@@ -92,7 +92,7 @@ public class GwtQueryBenchModule implements EntryPoint {
return name;
}
public int runSelector(DeferredGQuery dq) {
public int runSelector(DeferredSelector dq) {
return engine.select(dq.getSelector(), gwtiframe).getLength();
}
}
@@ -125,8 +125,8 @@ public class GwtQueryBenchModule implements EntryPoint {
return name;
}
public int runSelector(DeferredGQuery dq) {
return dq.array(gwtiframe).getLength();
public int runSelector(DeferredSelector dq) {
return dq.runSelector(gwtiframe).getLength();
}
}
@@ -148,7 +148,7 @@ public class GwtQueryBenchModule implements EntryPoint {
return id;
}
public int runSelector(DeferredGQuery dq) {
public int runSelector(DeferredSelector dq) {
return runSelector(id, dq.getSelector());
}
@@ -200,7 +200,7 @@ public class GwtQueryBenchModule implements EntryPoint {
*/
private String[] defaultBenchmarks = {"gwt_compiled", "gwt_dynamic", "jquery", "prototype", "dojo"};
private DeferredGQuery dg[];
private DeferredSelector ds[];
private FlexTable grid = new FlexTable();
@@ -226,7 +226,7 @@ public class GwtQueryBenchModule implements EntryPoint {
$("#startrace").text("Stop Race");
$("#results").show();
initResultsTable(dg, selectedBenchmarks);
initResultsTable(ds, selectedBenchmarks);
initTrack(selectedBenchmarks);
Scheduler.get().scheduleIncremental(new RepeatingCommand() {
@@ -255,7 +255,7 @@ public class GwtQueryBenchModule implements EntryPoint {
selectorNumber++;
winner = -1;
winTime = Double.MAX_VALUE;
if (selectorNumber >= dg.length) {
if (selectorNumber >= ds.length) {
double min = Double.MAX_VALUE;
for (int i = 0; i < totalTimes.length; i++) {
if (totalTimes[i] < min) {
@@ -275,7 +275,7 @@ public class GwtQueryBenchModule implements EntryPoint {
return false;
}
}
DeferredGQuery d = dg[selectorNumber];
DeferredSelector d = ds[selectorNumber];
long start = System.currentTimeMillis();
int num = 0;
long end = start;
@@ -329,7 +329,7 @@ public class GwtQueryBenchModule implements EntryPoint {
final MySelectors m = GWT.create(MySelectors.class);
dg = m.getAllSelectors();
ds = m.getAllSelectors();
String par = Window.Location.getParameter("min");
if (par != null) {
@@ -393,7 +393,7 @@ public class GwtQueryBenchModule implements EntryPoint {
/**
* Reset the result table
*/
private void initResultsTable(DeferredGQuery[] dg, Benchmark... benchs) {
private void initResultsTable(DeferredSelector[] dg, Benchmark... benchs) {
int numRows = dg.length;
grid = new FlexTable();
grid.addStyleName("resultstable");
@@ -474,7 +474,7 @@ public class GwtQueryBenchModule implements EntryPoint {
for (double d : totalTimes) {
winnerTime = Math.min(winnerTime, d);
}
double winnerPos = row * (double) trackWidth / (double) dg.length;
double winnerPos = row * (double) trackWidth / (double) ds.length;
for (int i = 0; i < b.length; i++) {
GQuery g = $("#" + b[i].getId() + "horse");
double pos = winnerPos * winnerTime / totalTimes[i];

Loading…
Cancel
Save