@@ -213,6 +213,9 @@ public class ComputedCssStyleDeclaration extends AbstractCssStyleDeclaration {
213213 /** The computed, cached shrink-wrapped width (used by getBoundingClientRect()). */
214214 private Integer shrinkWrapWidth_ ;
215215
216+ /** The computed, cached content width (sum/max of children's widths) of the element. */
217+ private Integer contentWidth_ ;
218+
216219 /**
217220 * The computed, cached height of the element to which this computed style belongs (no padding, borders, etc.),
218221 * taking child elements into account.
@@ -1775,6 +1778,11 @@ private static boolean hasOnlyInlineOrTextChildren(final DomElement element) {
17751778 * @return the total width of the element's children
17761779 */
17771780 public int getContentWidth () {
1781+ final Integer cachedContentWidth = getCachedContentWidth ();
1782+ if (cachedContentWidth != null ) {
1783+ return cachedContentWidth .intValue ();
1784+ }
1785+
17781786 int inlineWidth = 0 ;
17791787 int maxBlockWidth = 0 ;
17801788 final DomElement element = getDomElement ();
@@ -1830,7 +1838,8 @@ else if (child instanceof DomText) {
18301838 }
18311839 }
18321840 }
1833- return Math .max (maxBlockWidth , inlineWidth );
1841+
1842+ return updateCachedContentWidth (Math .max (maxBlockWidth , inlineWidth ));
18341843 }
18351844
18361845 /**
@@ -2329,6 +2338,24 @@ public int updateCachedShrinkWrapWidth(final int width) {
23292338 return width ;
23302339 }
23312340
2341+ /**
2342+ * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span>
2343+ * @return the cached content width
2344+ */
2345+ public Integer getCachedContentWidth () {
2346+ return contentWidth_ ;
2347+ }
2348+
2349+ /**
2350+ * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span>
2351+ * @param contentWidth the new value
2352+ * @return the param contentWidth
2353+ */
2354+ public int updateCachedContentWidth (final int contentWidth ) {
2355+ contentWidth_ = Integer .valueOf (contentWidth );
2356+ return contentWidth ;
2357+ }
2358+
23322359 /**
23332360 * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span>
23342361 * @return the cached height
0 commit comments