From: Manolo Carrasco Date: Wed, 17 Dec 2014 08:40:31 +0000 (+0100) Subject: Reuse the same document style implementation. X-Git-Tag: gwtquery-project-1.4.3~11^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=49431e9159e45d4099e157daedf6f7ba0c92afd8;p=gwtquery.git Reuse the same document style implementation. This facilitates customized filters and selectors. As a bonus removed a couple of deprecated use of JsRegexp --- diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java index 09e69fe3..4c375806 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java @@ -651,7 +651,7 @@ public class GQuery implements Lazy { protected static DocumentStyleImpl getStyleImpl() { if (styleImpl == null) { - styleImpl = GWT.create(DocumentStyleImpl.class); + styleImpl = getSelectorEngine().getDocumentStyleImpl(); } return styleImpl; } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/AttributeImpl.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/AttributeImpl.java index fcdba699..0a6a6642 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/AttributeImpl.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/AttributeImpl.java @@ -16,8 +16,8 @@ package com.google.gwt.query.client.impl; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.InputElement; import com.google.gwt.query.client.GQuery; -import com.google.gwt.query.client.js.JsRegexp; import com.google.gwt.query.client.js.JsUtils; +import com.google.gwt.regexp.shared.RegExp; /** * Helper class for setting and getting attribute on an element. @@ -128,7 +128,7 @@ public class AttributeImpl { */ private static class TypeAttrSetter extends DefaultSetter { private static AttributeSetter INSTANCE; - private static JsRegexp NOT_AUTHORIZED_NODE = new JsRegexp( + private static RegExp NOT_AUTHORIZED_NODE = RegExp.compile( "^(?:button|input)$", "i"); public static AttributeSetter getInstance() { @@ -161,7 +161,7 @@ public class AttributeImpl { } } - private static final JsRegexp BOOLEAN_ATTR_REGEX = new JsRegexp( + private static final RegExp BOOLEAN_ATTR_REGEX = RegExp.compile( "^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$", "i"); @@ -198,7 +198,7 @@ public class AttributeImpl { } } - protected Object fixValue(String key, Object value) { + protected Object fixValue(@SuppressWarnings("unused") String key, Object value) { return value; } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java index ac932e90..24008e1b 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java @@ -22,8 +22,8 @@ import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Node; import com.google.gwt.query.client.GQuery; import com.google.gwt.query.client.js.JsNamedArray; -import com.google.gwt.query.client.js.JsRegexp; import com.google.gwt.query.client.js.JsUtils; +import com.google.gwt.regexp.shared.RegExp; import com.google.gwt.user.client.DOM; /** @@ -31,8 +31,8 @@ import com.google.gwt.user.client.DOM; */ public class DocumentStyleImpl { - private static final JsRegexp cssNumberRegex = new JsRegexp("^(fillOpacity|fontWeight|lineHeight|opacity|orphans|widows|zIndex|zoom)$", "i"); - private static final JsRegexp sizeRegex = new JsRegexp("^(client|offset|)(width|height)$", "i"); + private static final RegExp cssNumberRegex = RegExp.compile("^(fillOpacity|fontWeight|lineHeight|opacity|orphans|widows|zIndex|zoom)$", "i"); + private static final RegExp sizeRegex = RegExp.compile("^(client|offset|)(width|height)$", "i"); /** diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngine.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngine.java index 78b69e3e..967961e8 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngine.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngine.java @@ -290,4 +290,11 @@ public class SelectorEngine implements HasSelector { public static native boolean hasXpathEvaluate() /*-{ return !!$doc.evaluate; }-*/; + + /** + * Return the DocumentStyleImpl used by this selector engine. + */ + public DocumentStyleImpl getDocumentStyleImpl() { + return styleImpl; + } }