Fix 25408 - Update fixup script to correct HREFs in generated IDL.
authorGary Kacmarcik <garykac@google.com>
Sun, 27 Apr 2014 10:13:22 -0700
changeset 596 18f90bc297a4
parent 595 94e701e465ee
child 597 21cd9f302b38
Fix 25408 - Update fixup script to correct HREFs in generated IDL.
Also increase the delay timer that waits for respec to finish.
html/fixup.js
--- a/html/fixup.js	Sun Apr 27 10:10:04 2014 -0700
+++ b/html/fixup.js	Sun Apr 27 10:13:22 2014 -0700
@@ -16,40 +16,100 @@
 	["widl-EventTarget-removeEventListener", "-void-DOMString-type-EventListener-listener-boolean-useCapture"],
 	["widl-EventListener-handleEvent", "-void-Event-event"],
 	["widl-DocumentEvent-createEvent", "-Event-DOMString-eventInterface"],
-	["widl-UIEvent-initUIEvent", "-void-DOMString-typeArg-boolean-bubblesArg-boolean-cancelableArg-AbstractView-viewArg-long-detailArg"],
+	["widl-UIEvent-initUIEvent", "-void-DOMString-typeArg-boolean-bubblesArg-boolean-cancelableArg-Window-viewArg-long-detailArg"],
 	["widl-MouseEvent-getModifierState", "-boolean-DOMString-keyArg"],
-	["widl-MouseEvent-initMouseEvent", "-void-DOMString-typeArg-boolean-bubblesArg-boolean-cancelableArg-AbstractView-viewArg-long-detailArg-long-screenXArg-long-screenYArg-long-clientXArg-long-clientYArg-boolean-ctrlKeyArg-boolean-altKeyArg-boolean-shiftKeyArg-boolean-metaKeyArg-unsigned-short-buttonArg-EventTarget-relatedTargetArg"],
+	["widl-MouseEvent-initMouseEvent", "-void-DOMString-typeArg-boolean-bubblesArg-boolean-cancelableArg-Window-viewArg-long-detailArg-long-screenXArg-long-screenYArg-long-clientXArg-long-clientYArg-boolean-ctrlKeyArg-boolean-altKeyArg-boolean-shiftKeyArg-boolean-metaKeyArg-short-buttonArg-EventTarget-relatedTargetArg"],
 	["widl-KeyboardEvent-getModifierState", "-boolean-DOMString-keyArg"],
 	["widl-MutationEvent-initMutationEvent", "-void-DOMString-typeArg-boolean-bubblesArg-boolean-cancelableArg-Node-relatedNodeArg-DOMString-prevValueArg-DOMString-newValueArg-DOMString-attrNameArg-unsigned-short-attrChangeArg"],
 	["widl-CustomEvent-initCustomEvent", "-void-DOMString-typeArg-boolean-bubblesArg-boolean-cancelableArg-any-detailArg"],
-	["widl-FocusEvent-initFocusEvent", "-void-DOMString-typeArg-boolean-bubblesArg-boolean-cancelableArg-AbstractView-viewArg-long-detailArg-EventTarget-relatedTargetArg"],
-	["widl-WheelEvent-initWheelEvent", "-void-DOMString-typeArg-boolean-bubblesArg-boolean-cancelableArg-AbstractView-viewArg-long-detailArg-long-screenXArg-long-screenYArg-long-clientXArg-long-clientYArg-unsigned-short-buttonArg-EventTarget-relatedTargetArg-DOMString-modifiersListArg-double-deltaXArg-double-deltaYArg-double-deltaZArg-unsigned-long-deltaMode"],
-	["widl-KeyboardEvent-initKeyboardEvent", "-void-DOMString-typeArg-boolean-bubblesArg-boolean-cancelableArg-AbstractView-viewArg-long-detailArg-DOMString-keyArg-unsigned-long-locationArg-DOMString-modifiersListArg-boolean-repeat"],
-	["widl-CompositionEvent-initCompositionEvent", "-void-DOMString-typeArg-boolean-bubblesArg-boolean-cancelableArg-AbstractView-viewArg-DOMString-dataArg"],
+	["widl-FocusEvent-initFocusEvent", "-void-DOMString-typeArg-boolean-bubblesArg-boolean-cancelableArg-Window-viewArg-long-detailArg-EventTarget-relatedTargetArg"],
+	["widl-WheelEvent-initWheelEvent", "-void-DOMString-typeArg-boolean-bubblesArg-boolean-cancelableArg-Window-viewArg-long-detailArg-long-screenXArg-long-screenYArg-long-clientXArg-long-clientYArg-short-buttonArg-EventTarget-relatedTargetArg-DOMString-modifiersListArg-double-deltaXArg-double-deltaYArg-double-deltaZArg-unsigned-long-deltaMode"],
+	["widl-KeyboardEvent-initKeyboardEvent", "-void-DOMString-typeArg-boolean-bubblesArg-boolean-cancelableArg-Window-viewArg-long-detailArg-DOMString-keyArg-unsigned-long-locationArg-DOMString-modifiersListArg-boolean-repeat"],
+	["widl-CompositionEvent-initCompositionEvent", "-void-DOMString-typeArg-boolean-bubblesArg-boolean-cancelableArg-Window-viewArg-DOMString-dataArg-DOMString-locale"],
 ];
- 
+
+idl_constants = {
+	"DOM_DELTA_LINE": "#widl-WheelEvent-",
+	"DOM_DELTA_PAGE": "#widl-WheelEvent-",
+	"DOM_DELTA_PIXEL": "#widl-WheelEvent-",
+	"DOM_KEY_LOCATION_LEFT": "#widl-KeyboardEvent-",
+	"DOM_KEY_LOCATION_NUMPAD": "#widl-KeyboardEvent-",
+	"DOM_KEY_LOCATION_RIGHT": "#widl-KeyboardEvent-",
+	"DOM_KEY_LOCATION_STANDARD": "#widl-KeyboardEvent-",
+	"AT_TARGET": "#widl-Event-",
+	"BUBBLING_PHASE": "#widl-Event-",
+	"CAPTURING_PHASE": "#widl-Event-",
+	"NONE": "#widl-Event-",
+	"ADDITION": "#widl-MutationEvent-",
+	"MODIFICATION": "#widl-MutationEvent-",
+	"REMOVAL": "#widl-MutationEvent-",
+};
+
 function fixup_ids() {
-	// Wait until ReSpec is done.
-	var check = bad_ids[0][0] + bad_ids[0][1];
-	if (!document.getElementById(check)) {
-		setTimeout(fixup_ids, 100);
-		return;
-	}
+	console.log('Fixing up bad ids');
 	for (var i = 0; i < bad_ids.length; i++) {
-		fixup(bad_ids[i][0], bad_ids[i][1]);
+		var name = bad_ids[i][0];
+		var signature = bad_ids[i][1];
+		var el = document.getElementById(name + signature);
+		if (el) {
+			el.id = name;
+		} else {
+			console.log('ERROR - unable to fixup: ' + name + signature);
+		}
 	}
 	console.log("Finished fixing up bad ids");
 }
 
-function fixup(name, signature) {
-	var el = document.getElementById(name + signature);
-	if (el) {
-		el.id = name;
-	} else {
-		console.log('ERROR - unable to fixup: ' + name + signature);
+function fixup_idl_method_hrefs() {
+	console.log('Fixing up IDL hrefs');
+	var els = document.getElementsByClassName('idlMethName');
+	for (var i = 0; i < els.length; i++) {
+		var href = els[i].firstChild.attributes[0].nodeValue;
+		var found = false;
+		for (var j = 0; j < bad_ids.length; j++) {
+			var badid = bad_ids[j][0] + bad_ids[j][1];
+			if (href == '#' + badid) {
+				els[i].firstChild.href = '#' + bad_ids[j][0];
+				found = true;
+			}
+		}
+		if (!found) {
+			console.log('ERROR - unable to find href match: ' + href);
+		}
 	}
+	console.log('Finished fixing up IDL hrefs');
+}
+
+function fixup_idl_constant_hrefs() {
+	console.log('Fixing up IDL constants');
+	var els = document.getElementsByClassName('idlConstName');
+	for (var i = 0; i < els.length; i++) {
+		var href = els[i].firstChild.attributes[0].nodeValue;
+		var raw_href = href.slice(1)
+		if (raw_href in idl_constants) {
+			var new_href = idl_constants[raw_href] + raw_href;
+			//console.log('found: ' + raw_href + " changing to " + new_href);
+			els[i].firstChild.href = new_href;
+		} else {
+			console.log('ERROR - unable to find: ' + raw_href);
+		}
+	}
+	console.log('Finished fixing up IDL constants');
+}
+
+function fixup() {
+	// Wait until ReSpec is done.
+	var check = bad_ids[0][0] + bad_ids[0][1];
+	if (!document.getElementById(check)) {
+		setTimeout(fixup, 500);
+		return;
+	}
+
+	fixup_ids();
+	fixup_idl_method_hrefs();
+	fixup_idl_constant_hrefs();
 }
 
 if (window.addEventListener) {
-	window.addEventListener('load', fixup_ids, false);
+	window.addEventListener('load', fixup, false);
 }