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

Unified Diff: third_party/WebKit/PerformanceTests/HTMLToDOM/dom/bindings/fakedomparserbindings.js

Issue 2189533004: Add blink_perf.html_to_dom benchmark. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes to the original benchmark Created 4 years, 5 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 | « no previous file | third_party/WebKit/PerformanceTests/HTMLToDOM/dom/bindings/realdomparserbindings.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/PerformanceTests/HTMLToDOM/dom/bindings/fakedomparserbindings.js
diff --git a/third_party/WebKit/PerformanceTests/HTMLToDOM/dom/bindings/fakedomparserbindings.js b/third_party/WebKit/PerformanceTests/HTMLToDOM/dom/bindings/fakedomparserbindings.js
new file mode 100644
index 0000000000000000000000000000000000000000..10281c0fbfa4f5949d9f8dd6a9520cea0c48c8e2
--- /dev/null
+++ b/third_party/WebKit/PerformanceTests/HTMLToDOM/dom/bindings/fakedomparserbindings.js
@@ -0,0 +1,99 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+"use strict";
+
+(function(exports) {
+
+class FakeNode {
+ constructor() {
+ this.parentNode = null;
+ this.nextSibling = null;
+ this.previousSibling = null;
+ }
+ contains(other) {
+ while (other && other != this)
+ other = other.parentNode;
+ return other === this;
+ }
+ remove() {
+ if (!this.parentNode)
+ return;
+ if (this.nextSibling)
+ this.nextSibling._previousSibling = this._previousSibling;
+ if (this.previousSibling)
+ this.previousSibling._nextSibling = this._nextSibling;
+ this._parentNode = null;
+ this._nextSibling = null;
+ this._previousSibling = null;
+ }
+}
+
+class FakeParentNode extends FakeNode {
+ constructor() {
+ super();
+ this.firstChild = null;
+ this.lastChild = null;
+ }
+ appendChild(node) {
+ if (node.contains(this))
+ throw new Error("HierarchyRequestError");
+ node.remove();
+ node.parentNode = this;
+ node.previousSibling = this.lastChild;
+ if (this.lastChild)
+ this.lastChild.nextSibling = node;
+ this.lastChild = node;
+ if (!this.firstChild)
+ this.firstChild = node;
+ return node;
+ }
+}
+
+class FakeDocumentFragment extends FakeParentNode {
+}
+
+class FakeElement extends FakeParentNode {
+ constructor(tagName) {
+ super();
+ this.tagName = tagName;
+ this.attributes = new Map();
+ this.children = [];
+ }
+ setAttribute(name, value) {
+ this.attributes.set(name, value);
+ }
+}
+
+class FakeText extends FakeNode {
+ constructor(value) {
+ super();
+ this.value = value;
+ }
+}
+
+class FakeDomParserBindings {
+ static setAttribute(element, name, value) {
+ element.setAttribute(name, value);
+ }
+
+ static appendChild(parent, child) {
+ parent.appendChild(child);
+ }
+
+ static createText(value) {
+ return new FakeText(value);
+ }
+
+ static createElement(tagName) {
+ return new FakeElement(tagName);
+ }
+
+ static createDocumentFragment() {
+ return new FakeDocumentFragment();
+ }
+}
+
+exports.FakeDomParserBindings = FakeDomParserBindings;
+
+})(this);
« no previous file with comments | « no previous file | third_party/WebKit/PerformanceTests/HTMLToDOM/dom/bindings/realdomparserbindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698