Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(750)

Unified Diff: Source/core/dom/WhitespaceChildList.h

Issue 24350009: Reverse style resolution to avoid N^2 walk when building the render tree (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Merge to ToT Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/Element.cpp ('k') | Source/core/dom/shadow/ShadowRoot.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/WhitespaceChildList.h
diff --git a/Source/core/platform/Task.h b/Source/core/dom/WhitespaceChildList.h
similarity index 56%
copy from Source/core/platform/Task.h
copy to Source/core/dom/WhitespaceChildList.h
index b9d2e46802aebf6391df4ec3dabb580d43b2483c..b5a4fb14f656e6ca69c20b1dbf92c26bc71b2b9b 100644
--- a/Source/core/platform/Task.h
+++ b/Source/core/dom/WhitespaceChildList.h
@@ -7,10 +7,6 @@
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
@@ -28,30 +24,48 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef Task_h
-#define Task_h
+#ifndef WhitespaceChildList_h
+#define WhitespaceChildList_h
-#include "wtf/Functional.h"
-#include "public/platform/WebThread.h"
+#include "core/dom/Text.h"
+#include "core/rendering/style/RenderStyleConstants.h"
namespace WebCore {
-class Task : public WebKit::WebThread::Task {
+class Text;
+
+// Tracks a limited number of whitespace text children during style recalc
+// to postpone their style recalc as part of optimization to avoid creating
+// unnecessary whitespace text renderers. If we hit the limit, it recalcs
+// the whitespace text's style and clears the list.
+class WhitespaceChildList {
public:
- explicit Task(const Closure& closure)
- : m_closure(closure)
+ WhitespaceChildList(StyleRecalcChange change)
+ : m_change(change)
+ { }
+
+ void append(Text* textChild)
{
+ ASSERT(textChild->containsOnlyWhitespace());
+ if (m_list.size() == maxWhitespaceChildrenToDefer) {
+ recalcStyle();
+ m_list.clear();
+ }
+ m_list.append(textChild);
}
- virtual void run() OVERRIDE
+ void recalcStyle() const
{
- m_closure();
+ for (unsigned i = 0; i < m_list.size(); ++i)
+ m_list[i]->recalcTextStyle(m_change);
}
-
private:
- Closure m_closure;
+ StyleRecalcChange m_change;
+
+ static const unsigned maxWhitespaceChildrenToDefer = 10;
+ Vector<Text*, maxWhitespaceChildrenToDefer> m_list;
};
} // namespace WebCore
-#endif // Task_h
+#endif // WhitespaceChildList_h
« no previous file with comments | « Source/core/dom/Element.cpp ('k') | Source/core/dom/shadow/ShadowRoot.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698