summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin
diff options
context:
space:
mode:
authorjotatu <jotatu@g-10-64-12-127.guest.vaadin.com>2015-08-07 14:45:50 +0300
committerPatrik Lindström <patrik@vaadin.com>2015-11-05 12:47:16 +0200
commit9c1908d0a5fdba09167414e837cc08a2f746584b (patch)
treefe8fec7d5118134d72af5c7de49890bba8b2bd0c /server/src/com/vaadin
parent2b8cd659685c48fd6284ba3566009b2285132751 (diff)
downloadvaadin-framework-9c1908d0a5fdba09167414e837cc08a2f746584b.tar.gz
vaadin-framework-9c1908d0a5fdba09167414e837cc08a2f746584b.zip
Optimize layout performance of Table (#17947)
Adds functions for skipping child component layout measuring. Removes unnecessary code from VScrollTable. 1. case: no components - render time without the fix: ~105ms - render time with fix: ~105ms 2. case: 2 button and 2 textfield cols - render time without the fix: ~279ms - render time with fix: ~240ms (~17% faster) 3. case: 3 button and 3 textfield cols - render time without the fix: ~350ms - render time with fix: ~281ms (~20% faster) Change-Id: I6025f8ee2fd438d228ff3b65f43535961cf12c0b
Diffstat (limited to 'server/src/com/vaadin')
-rw-r--r--server/src/com/vaadin/ui/HasChildMeasurementHint.java69
-rw-r--r--server/src/com/vaadin/ui/Table.java27
2 files changed, 95 insertions, 1 deletions
diff --git a/server/src/com/vaadin/ui/HasChildMeasurementHint.java b/server/src/com/vaadin/ui/HasChildMeasurementHint.java
new file mode 100644
index 0000000000..dadf7d0be6
--- /dev/null
+++ b/server/src/com/vaadin/ui/HasChildMeasurementHint.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.ui;
+
+/**
+ * Component with layout measuring hint. Used to improve granularity of control
+ * over child component measurements.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public interface HasChildMeasurementHint extends HasComponents {
+
+ /**
+ * Specifies how you would like child components measurements to be handled.
+ * Since this is a hint, it can be ignored when deemed necessary.
+ */
+ public enum ChildMeasurementHint {
+
+ /**
+ * Always measure all child components (default).
+ */
+ MEASURE_ALWAYS,
+
+ /**
+ * Measure child component only if child component is a Layout or
+ * implements either ManagedLayout or ElementResizeListener.
+ */
+ MEASURE_IF_NEEDED,
+
+ /**
+ * Never measure child components. This can improve rendering speed of
+ * components with lots of children (e.g. Table), but can cause some
+ * child components to be rendered incorrectly (e.g. ComboBox).
+ */
+ MEASURE_NEVER
+
+ }
+
+ /**
+ * Sets desired child size measurement hint.
+ *
+ * @param hint
+ * desired hint. A value of null will reset value back to the
+ * default (MEASURE_ALWAYS)
+ */
+ void setChildMeasurementHint(ChildMeasurementHint hint);
+
+ /**
+ * Returns the current child size measurement hint.
+ *
+ * @return a child measurement hint value
+ */
+ ChildMeasurementHint getChildMeasurementHint();
+
+}
diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java
index 69874d9947..3edfe7845f 100644
--- a/server/src/com/vaadin/ui/Table.java
+++ b/server/src/com/vaadin/ui/Table.java
@@ -100,7 +100,7 @@ import com.vaadin.util.ReflectTools;
@SuppressWarnings({ "deprecation" })
public class Table extends AbstractSelect implements Action.Container,
Container.Ordered, Container.Sortable, ItemClickNotifier, DragSource,
- DropTarget, HasComponents {
+ DropTarget, HasComponents, HasChildMeasurementHint {
private transient Logger logger = null;
@@ -357,6 +357,11 @@ public class Table extends AbstractSelect implements Action.Container,
private static final Object ROW_HEADER_FAKE_PROPERTY_ID = new UniqueSerializable() {
};
+ /**
+ * How layout manager should behave when measuring Table's child components
+ */
+ private ChildMeasurementHint childMeasurementHint = ChildMeasurementHint.MEASURE_ALWAYS;
+
/* Private table extensions to Select */
/**
@@ -3542,6 +3547,7 @@ public class Table extends AbstractSelect implements Action.Container,
paintTabIndex(target);
paintDragMode(target);
paintSelectMode(target);
+ paintTableChildLayoutMeasureMode(target);
if (cacheRate != CACHE_RATE_DEFAULT) {
target.addAttribute("cr", cacheRate);
@@ -3882,6 +3888,11 @@ public class Table extends AbstractSelect implements Action.Container,
}
}
+ private void paintTableChildLayoutMeasureMode(PaintTarget target)
+ throws PaintException {
+ target.addAttribute("measurehint", getChildMeasurementHint().ordinal());
+ }
+
/**
* Checks whether row headers are visible.
*
@@ -6467,4 +6478,18 @@ public class Table extends AbstractSelect implements Action.Container,
}
return logger;
}
+
+ @Override
+ public void setChildMeasurementHint(ChildMeasurementHint hint) {
+ if (hint == null) {
+ childMeasurementHint = ChildMeasurementHint.MEASURE_ALWAYS;
+ } else {
+ childMeasurementHint = hint;
+ }
+ }
+
+ @Override
+ public ChildMeasurementHint getChildMeasurementHint() {
+ return childMeasurementHint;
+ }
}