Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2019-09-02 12:41:10 +0000
committerLars Vogel2019-09-12 08:38:11 +0000
commit296571c9eb10b0ab3cb153bb487f34462cef7cb5 (patch)
treeb82a543f3ba001db9443988caed5727032844468
parent17ce07c58488a8d56de6ccae2b59a26b52c74a56 (diff)
downloadeclipse.platform.ui-296571c9eb10b0ab3cb153bb487f34462cef7cb5.tar.gz
eclipse.platform.ui-296571c9eb10b0ab3cb153bb487f34462cef7cb5.tar.xz
eclipse.platform.ui-296571c9eb10b0ab3cb153bb487f34462cef7cb5.zip
Bug 550651 - Improve readability of CSS code around
ViewCSSImpl#getComputedStyle Includes 4.14 version bump Change-Id: I1d9cdd065b715a7682289e95d67bf935c25d7cd2 Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
-rw-r--r--bundles/org.eclipse.e4.ui.css.core/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/ViewCSSImpl.java68
2 files changed, 29 insertions, 41 deletions
diff --git a/bundles/org.eclipse.e4.ui.css.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.ui.css.core/META-INF/MANIFEST.MF
index 254ced16f74..2368438430e 100644
--- a/bundles/org.eclipse.e4.ui.css.core/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.e4.ui.css.core/META-INF/MANIFEST.MF
@@ -4,7 +4,7 @@ Bundle-SymbolicName: org.eclipse.e4.ui.css.core;singleton:=true
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
-Bundle-Version: 0.12.800.qualifier
+Bundle-Version: 0.12.900.qualifier
Export-Package: org.eclipse.e4.ui.css.core;x-internal:=true,
org.eclipse.e4.ui.css.core.css2;x-friends:="org.eclipse.e4.ui.css.swt.theme,org.eclipse.e4.ui.css.swt,org.eclipse.e4.ui.css.jface",
org.eclipse.e4.ui.css.core.dom;x-friends:="org.eclipse.e4.ui.css.swt,org.eclipse.ui.views.properties.tabbed",
diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/ViewCSSImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/ViewCSSImpl.java
index 0e02fbfd4b0..134e9b4782f 100644
--- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/ViewCSSImpl.java
+++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/ViewCSSImpl.java
@@ -113,54 +113,42 @@ public class ViewCSSImpl implements ViewCSS, ExtendedDocumentCSS.StyleSheetChang
public CSSStyleDeclaration getComputedStyle(List<CSSRule> ruleList, Element elt, String pseudoElt) {
List<StyleWrapper> styleDeclarations = null;
StyleWrapper firstStyleDeclaration = null;
- int length = ruleList.size();
int position = 0;
- for (int i = 0; i < length; i++) {
- CSSRule rule = ruleList.get(i);
- if (rule.getType() == CSSRule.STYLE_RULE) {
- CSSStyleRule styleRule = (CSSStyleRule) rule;
- if (rule instanceof ExtendedCSSRule) {
- ExtendedCSSRule r = (ExtendedCSSRule) rule;
- SelectorList selectorList = r.getSelectorList();
- // Loop for SelectorList
- int l = selectorList.getLength();
- for (int j = 0; j < l; j++) {
- Selector selector = selectorList.item(j);
- if (selector instanceof ExtendedSelector) {
- ExtendedSelector extendedSelector = (ExtendedSelector) selector;
- if (extendedSelector.match(elt, pseudoElt)) {
- CSSStyleDeclaration style = styleRule
- .getStyle();
- int specificity = extendedSelector
- .getSpecificity();
- StyleWrapper wrapper = new StyleWrapper(style,
- specificity, position++);
- if (firstStyleDeclaration == null) {
- firstStyleDeclaration = wrapper;
- } else {
- // There is several Style Declarations which
- // match the current element
- if (styleDeclarations == null) {
- styleDeclarations = new ArrayList<>();
- styleDeclarations.add(firstStyleDeclaration);
- }
- styleDeclarations.add(wrapper);
- }
- }
+ for (CSSRule rule : ruleList) {
+ if (rule.getType() != CSSRule.STYLE_RULE || (!(rule instanceof ExtendedCSSRule)) ) {
+ continue; // we only handle the CSSRule.STYLE_RULE and ExtendedCSSRule case
+ }
+ CSSStyleRule styleRule = (CSSStyleRule) rule;
+ ExtendedCSSRule r = (ExtendedCSSRule) rule;
+ SelectorList selectorList = r.getSelectorList();
+ // Loop for SelectorList
+ int l = selectorList.getLength();
+ for (int j = 0; j < l; j++) {
+ Selector selector = selectorList.item(j);
+ if (selector instanceof ExtendedSelector) {
+ ExtendedSelector extendedSelector = (ExtendedSelector) selector;
+ if (extendedSelector.match(elt, pseudoElt)) {
+ CSSStyleDeclaration style = styleRule.getStyle();
+ int specificity = extendedSelector.getSpecificity();
+ StyleWrapper wrapper = new StyleWrapper(style, specificity, position++);
+ if (firstStyleDeclaration == null) {
+ firstStyleDeclaration = wrapper;
} else {
- // TODO : selector is not batik ExtendedSelector,
- // Manage this case...
+ // There is several Style Declarations which
+ // match the current element
+ if (styleDeclarations == null) {
+ styleDeclarations = new ArrayList<>();
+ styleDeclarations.add(firstStyleDeclaration);
+ }
+ styleDeclarations.add(wrapper);
}
}
- } else {
- // TODO : CSS rule is not ExtendedCSSRule,
- // Manage this case...
}
}
}
if (styleDeclarations != null) {
- // There is several Style Declarations wich match
- // the element, merge the CSS Property value.
+ // There is several Style Declarations which match the element, merge the CSS
+ // Property value.
return new CSSComputedStyleImpl(styleDeclarations);
}
if (firstStyleDeclaration != null) {

Back to the top