[HtmlUnit] SVN: [15506] trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/ javascript/host/Window.java
rbri--- via HtmlUnit-develop <[email protected]> Wed, 01 Aug 2018 20:20:02 +0000
| Newsgroups | gmane.comp.java.htmlunit.devel |
|---|---|
| Message-ID | <[email protected]> |
Revision: 15506
http://sourceforge.net/p/htmlunit/code/15506
Author: rbri
Date: 2018-08-01 20:20:01 +0000 (Wed, 01 Aug 2018)
Log Message:
-----------
try to do a bit more houskeeping to make hopefully the processing of large style sheets faster
Modified Paths:
--------------
trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java
Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java 2018-07-31 18:07:46 UTC (rev 15505)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java 2018-08-01 20:20:01 UTC (rev 15506)
@@ -168,6 +168,10 @@
private static final class CSSPropertiesCache implements Serializable {
private transient WeakHashMap<Element, Map<String, CSS2Properties>> computedStyles_ = new WeakHashMap<>();
+ // Dummy value to associate with an Object in the backing Map
+ private static final Object PRESENT = new Object();
+ private transient WeakHashMap<DomNode, Object> cleanedNodes_ = new WeakHashMap<>();
+
public synchronized CSS2Properties get(final Element element, final String normalizedPseudo) {
final Map<String, CSS2Properties> elementMap = computedStyles_.get(element);
if (elementMap != null) {
@@ -181,11 +185,16 @@
if (elementMap == null) {
elementMap = new WeakHashMap<>();
computedStyles_.put(element, elementMap);
+ cleanedNodes_.remove(element.getDomNodeOrDie());
}
elementMap.put(normalizedPseudo, style);
}
public synchronized void nodeChanged(final DomNode changed, final boolean clearParents) {
+ if (cleanedNodes_.containsKey(changed)) {
+ return;
+ }
+
for (final Iterator<Map.Entry<Element, Map<String, CSS2Properties>>> i
= computedStyles_.entrySet().iterator(); i.hasNext();) {
final Map.Entry<Element, Map<String, CSS2Properties>> entry = i.next();
@@ -194,6 +203,7 @@
|| changed.getParentNode() == node.getParentNode()
|| changed.isAncestorOf(node)
|| clearParents && node.isAncestorOf(changed)) {
+ cleanedNodes_.put(node, PRESENT);
i.remove();
}
}
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot