Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,23 @@ public default String retrieveCSSProperty(Object element, String property, Strin
return null;
}

/**
* Callback method called once after all CSS properties of a single
* declaration have been applied. Handlers that need to perform a final
* step (re-layout, redraw, batched commit, ...) override this method;
* the default is a no-op.
*/
default void onAllCSSPropertiesApplied(Object element, CSSEngine engine) throws Exception {
// do nothing
}

/**
* Variant of {@link #onAllCSSPropertiesApplied(Object, CSSEngine)} that
* also receives the pseudo class. Defaults to delegating to the
* pseudo-less form.
*/
default void onAllCSSPropertiesApplied(Object element, CSSEngine engine, String pseudo) throws Exception {
onAllCSSPropertiesApplied(element, engine);
}

}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@
import org.eclipse.e4.ui.css.core.dom.parsers.ICSSParserFactory;
import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyCompositeHandler;
import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandler;
import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandler2;
import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandler2Delegate;
import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandlerProvider;
import org.eclipse.e4.ui.css.core.dom.properties.converters.CSSValueBooleanConverterImpl;
import org.eclipse.e4.ui.css.core.dom.properties.converters.ICSSValueConverter;
Expand Down Expand Up @@ -155,7 +153,7 @@ public abstract class CSSEngineImpl implements CSSEngine {
*/
protected List<ICSSPropertyHandlerProvider> propertyHandlerProviders = new ArrayList<>();
// for performance hold a map of handlers to singleton list
private final Map<ICSSPropertyHandler2, List<ICSSPropertyHandler2>> propertyHandler2InstanceMap = new HashMap<>();
private final Map<ICSSPropertyHandler, List<ICSSPropertyHandler>> propertyHandlerInstanceMap = new HashMap<>();

private Map<String, String> currentCSSPropertiesApplied;

Expand Down Expand Up @@ -559,31 +557,25 @@ public void applyStyleDeclaration(Object element, CSSStyleDeclaration style, Str
if (avoidanceCacheInstalled) {
currentCSSPropertiesApplied = new HashMap<>();
}
List<ICSSPropertyHandler2> handlers2 = Collections.emptyList();
List<ICSSPropertyHandler> appliedHandlers = Collections.emptyList();
for (int i = 0; i < style.getLength(); i++) {
String property = style.item(i);
CSSValue value = style.getPropertyCSSValue(property);
try {
ICSSPropertyHandler handler = this.applyCSSProperty(element, property, value, pseudo);
ICSSPropertyHandler2 propertyHandler2 = null;
if (handler instanceof ICSSPropertyHandler2) {
propertyHandler2 = (ICSSPropertyHandler2) handler;
} else if (handler instanceof ICSSPropertyHandler2Delegate) {
propertyHandler2 = ((ICSSPropertyHandler2Delegate) handler).getCSSPropertyHandler2();
}
if (propertyHandler2 != null) {
switch (handlers2.size()) {
if (handler != null) {
switch (appliedHandlers.size()) {
case 0:
handlers2 = propertyHandler2InstanceMap.computeIfAbsent(propertyHandler2,
appliedHandlers = propertyHandlerInstanceMap.computeIfAbsent(handler,
Collections::singletonList);
break;
case 1:
handlers2 = new ArrayList<>(handlers2);
handlers2.add(propertyHandler2);
appliedHandlers = new ArrayList<>(appliedHandlers);
appliedHandlers.add(handler);
break;
default:
if (!handlers2.contains(propertyHandler2)) {
handlers2.add(propertyHandler2);
if (!appliedHandlers.contains(handler)) {
appliedHandlers.add(handler);
}
}
}
Expand All @@ -593,9 +585,9 @@ public void applyStyleDeclaration(Object element, CSSStyleDeclaration style, Str
}
}
}
for (ICSSPropertyHandler2 handler2 : handlers2) {
for (ICSSPropertyHandler handler : appliedHandlers) {
try {
handler2.onAllCSSPropertiesApplyed(element, this, pseudo);
handler.onAllCSSPropertiesApplied(element, this, pseudo);
} catch (Exception e) {
handleExceptions(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package org.eclipse.e4.ui.css.swt.properties.css2;

import org.eclipse.e4.ui.css.core.dom.properties.CSSBorderProperties;
import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandler2;
import org.eclipse.e4.ui.css.core.dom.properties.css2.AbstractCSSPropertyBorderHandler;
import org.eclipse.e4.ui.css.core.dom.properties.css2.ICSSPropertyBorderHandler;
import org.eclipse.e4.ui.css.core.engine.CSSEngine;
Expand All @@ -28,8 +27,7 @@
import org.w3c.dom.css.CSSPrimitiveValue;
import org.w3c.dom.css.CSSValue;

public class CSSPropertyBorderSWTHandler extends
AbstractCSSPropertyBorderHandler implements ICSSPropertyHandler2 {
public class CSSPropertyBorderSWTHandler extends AbstractCSSPropertyBorderHandler {

public static final ICSSPropertyBorderHandler INSTANCE = new CSSPropertyBorderSWTHandler();

Expand Down Expand Up @@ -70,7 +68,7 @@ public boolean applyCSSProperty(Object element, String property,
}

@Override
public void onAllCSSPropertiesApplyed(Object element, CSSEngine engine)
public void onAllCSSPropertiesApplied(Object element, CSSEngine engine)
throws Exception {
Control control = SWTElementHelpers.getControl(element);
if (control != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*******************************************************************************/
package org.eclipse.e4.ui.css.swt.properties.css2;

import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandler2;
import org.eclipse.e4.ui.css.core.dom.properties.css2.AbstractCSSPropertyFontHandler;
import org.eclipse.e4.ui.css.core.dom.properties.css2.CSS2FontProperties;
import org.eclipse.e4.ui.css.core.dom.properties.css2.ICSSPropertyFontHandler;
Expand All @@ -39,8 +38,7 @@
import org.w3c.dom.css.CSSStyleDeclaration;
import org.w3c.dom.css.CSSValue;

public class CSSPropertyFontSWTHandler extends AbstractCSSPropertyFontHandler
implements ICSSPropertyHandler2 {
public class CSSPropertyFontSWTHandler extends AbstractCSSPropertyFontHandler {

public static final ICSSPropertyFontHandler INSTANCE = new CSSPropertyFontSWTHandler();

Expand Down Expand Up @@ -232,7 +230,7 @@ public String retrieveCSSPropertyFontWeight(Object element, String pseudo,
}

@Override
public void onAllCSSPropertiesApplyed(Object element, CSSEngine engine)
public void onAllCSSPropertiesApplied(Object element, CSSEngine engine)
throws Exception {
final Widget widget = SWTElementHelpers.getWidget(element);
if (widget == null || widget instanceof CTabItem) {
Expand Down
Loading