Bug 489096 - HTML5 support
diff --git a/plugins/org.eclipse.actf.visualization.engines.blind.html/src/org/eclipse/actf/visualization/engines/blind/html/VisualizeEngine.java b/plugins/org.eclipse.actf.visualization.engines.blind.html/src/org/eclipse/actf/visualization/engines/blind/html/VisualizeEngine.java index 1655349..42c21f8 100644 --- a/plugins/org.eclipse.actf.visualization.engines.blind.html/src/org/eclipse/actf/visualization/engines/blind/html/VisualizeEngine.java +++ b/plugins/org.eclipse.actf.visualization.engines.blind.html/src/org/eclipse/actf/visualization/engines/blind/html/VisualizeEngine.java
@@ -36,6 +36,7 @@ import org.eclipse.actf.visualization.eval.EvaluationUtil; import org.eclipse.actf.visualization.eval.IEvaluationItem; import org.eclipse.actf.visualization.eval.guideline.GuidelineHolder; +import org.eclipse.actf.visualization.eval.html.HtmlTagUtil; import org.eclipse.actf.visualization.eval.html.statistics.PageData; import org.eclipse.actf.visualization.eval.problem.IProblemItem; import org.eclipse.actf.visualization.internal.engines.blind.html.BlindProblem; @@ -203,6 +204,27 @@ } } + private void replaceMathML_SVG_PacketCollection(IPacketCollection pc) { + // remove text in noscript tag + if (pc != null) { + int size = pc.size(); + for (int i = size - 1; i >= 0; i--) { + IPacket p = pc.get(i); + + Node tmpNode = p.getNode(); + while (tmpNode != null) { + String name = tmpNode.getNodeName(); + if (name.equals("math") || name.equals("svg")) { //$NON-NLS-1$ + // TODO replace + pc.remove(i); + break; + } + tmpNode = tmpNode.getParentNode(); + } + } + } + } + /** * Visualize blind users' usability */ @@ -372,6 +394,7 @@ VisualizeStyleInfoManager.getInstance().fireVisualizeStyleInfoUpdate(styleInfo); if (curParamBlind.visualizeMode.equals(ParamBlind.BLIND_BROWSER_MODE)) { + replaceMathML_SVG_PacketCollection(allPc); VisualizeViewUtil.returnTextView(result, allPc, baseUrl); return; } else { @@ -385,6 +408,46 @@ } @SuppressWarnings("nls") + private void replaceElement(Document doc, String tag, String[] childTags, String message) { + NodeList nl = doc.getElementsByTagName(tag); + int size = nl.getLength(); + for (int i = size - 1; i >= 0; i--) { + Element target = (Element) nl.item(i); + Element div = doc.createElement("div"); + div.setAttribute("comment", target.getAttribute("comment")); + div.setAttribute("id", target.getAttribute("id")); + + StringBuffer tmpSB = new StringBuffer(); + tmpSB.append("[" + message); + + for (int j = 0; j < childTags.length; j++) { + NodeList nl2 = target.getElementsByTagName(childTags[j]); + for (int k = 0; k < nl2.getLength(); k++) { + Node tmpN = nl2.item(0).getFirstChild(); + String tmpS = ""; + if (tmpN != null) { + tmpS = HtmlTagUtil.getTextDescendant(tmpN); + } + if (tmpS.length() > 0) { + tmpSB.append(" " + childTags[j] + ": \"" + tmpS+"\""); + break; + } + } + } + tmpSB.append("]"); + + // remove other tags and attributes + + div.appendChild(doc.createTextNode(tmpSB.toString())); + Node parent = target.getParentNode(); + parent.insertBefore(div, target); + mapData.addReplacedNodeMapping(target, div); + parent.removeChild(target); + } + + } + + @SuppressWarnings("nls") private void replaceImgAndCheck(Document doc, VisualizeMapDataImpl mapData, boolean remove) { NodeList mapList = doc.getElementsByTagName("map"); @@ -467,6 +530,10 @@ } } + // mathML/SVG + replaceElement(doc, "math", new String[0], "MathML"); + replaceElement(doc, "svg", new String[] { "title", "desc" }, "SVG"); + // image button nl = doc.getElementsByTagName("input"); size = nl.getLength();