Skip to content

Commit

Permalink
Bug 573155 Accessibility improvements for HTML reports
Browse files Browse the repository at this point in the history
Add roles via css, lists for keywords, strong not b.

Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=573155
Change-Id: I6d31552bc6b939d5894e0eb0527daa6d508de374
  • Loading branch information
ajohnson1 committed Apr 26, 2021
1 parent e855073 commit ea7317e
Show file tree
Hide file tree
Showing 13 changed files with 228 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,6 @@ else if (snapshot.isClass(accumulationPointId))
{
threadDetails = extractThreadData(suspect, keywords, objectsForTroubleTicketInfo, overview, overviewResult);
}
overview.append("<br><br>"); //$NON-NLS-1$

/* append keywords */
appendKeywords(keywords, overview);
Expand Down Expand Up @@ -533,7 +532,7 @@ private CompositeResult getLeakDescriptionGroupOfObjects(SuspectRecordGroupOfObj
{
builder.append("<p>").append(Messages.LeakHunterQuery_BiggestInstances); //$NON-NLS-1$
builder.append("</p>"); //$NON-NLS-1$
builder.append("<ul>"); //$NON-NLS-1$
builder.append("<ul title=\"").append(escapeHTMLAttribute(Messages.LeakHunterQuery_BiggestInstances)).append("\">"); //$NON-NLS-1$ //$NON-NLS-2$
for (IObject inst : bigSuspectInstances)
{
builder.append("<li>").append(HTMLUtils.escapeText(inst.getDisplayName())); //$NON-NLS-1$
Expand All @@ -550,6 +549,7 @@ private CompositeResult getLeakDescriptionGroupOfObjects(SuspectRecordGroupOfObj
/* get accumulation point info */
if (suspect.getAccumulationPoint() != null)
{
builder.append("<p>"); //$NON-NLS-1$
int accumulationPointId = suspect.getAccumulationPoint().getObject().getObjectId();
if (snapshot.isClassLoader(accumulationPointId))
{
Expand Down Expand Up @@ -587,9 +587,9 @@ else if (snapshot.isClass(accumulationPointId))
builder.append(MessageUtil.format(Messages.LeakHunterQuery_Msg_ReferencedFromInstance, className,
classloaderName, formatRetainedHeap(suspect.getAccumulationPoint().getRetainedHeapSize(), totalHeap)));
}
builder.append("</p>"); //$NON-NLS-1$
}
ThreadInfoQuery.Result threadDetails = null;
builder.append("<br><br>"); //$NON-NLS-1$

// append keywords
appendKeywords(keywords, builder);
Expand Down Expand Up @@ -732,6 +732,11 @@ else if (suspect.getCommonPath().length > 0)
return composite;
}

private String escapeHTMLAttribute(String msg)
{
return HTMLUtils.escapeText(msg).replaceAll("\"", "&quote;").replaceAll("'", "&apos;"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}

/**
* Find the end of the path to GC roots.
* Relies on end being selected.
Expand Down Expand Up @@ -955,9 +960,13 @@ public String getOQL()

private void appendKeywords(Set<String> keywords, StringBuilder builder)
{
builder.append("<b>").append(Messages.LeakHunterQuery_Keywords).append("</b><br>"); //$NON-NLS-1$ //$NON-NLS-2$
String title = Messages.LeakHunterQuery_Keywords;
builder.append("<p><strong>").append(title).append("</strong>"); //$NON-NLS-1$ //$NON-NLS-2$
builder.append("</p>"); //$NON-NLS-1$
builder.append("<ul style=\"list-style-type:none;\" title=\"").append(escapeHTMLAttribute(title)).append("\">"); //$NON-NLS-1$ //$NON-NLS-2$
for (String s : keywords)
builder.append(HTMLUtils.escapeText(s)).append("<br>"); //$NON-NLS-1$
builder.append("<li>").append(HTMLUtils.escapeText(s)).append("</li>"); //$NON-NLS-1$ //$NON-NLS-2$
builder.append("</ul>"); //$NON-NLS-1$
}

private void appendTroubleTicketInformation(List<IObject> classloaders, StringBuilder builder)
Expand All @@ -969,13 +978,17 @@ private void appendTroubleTicketInformation(List<IObject> classloaders, StringBu

if (!mapping.isEmpty())
{
builder.append("<br><b>").append(HTMLUtils.escapeText(resolver.getTicketSystem())).append("</b><br>"); //$NON-NLS-1$ //$NON-NLS-2$
String title = resolver.getTicketSystem();
builder.append("<p><strong>").append(HTMLUtils.escapeText(title)).append("</strong>"); //$NON-NLS-1$ //$NON-NLS-2$
builder.append("</p>"); //$NON-NLS-1$
builder.append("<ul style=\"list-style-type:none;\" title=\"").append(escapeHTMLAttribute(title)).append("\">"); //$NON-NLS-1$ //$NON-NLS-2$
for (Map.Entry<String, String> entry : mapping.entrySet())
{
builder.append(
builder.append("<li>").append( //$NON-NLS-1$
MessageUtil.format(Messages.LeakHunterQuery_TicketForSuspect, HTMLUtils.escapeText(entry.getKey()), HTMLUtils.escapeText(entry
.getValue()))).append("<br>"); //$NON-NLS-1$
.getValue()))).append("</li>"); //$NON-NLS-1$
}
builder.append("</ul>"); //$NON-NLS-1$
}
}
}
Expand All @@ -1000,13 +1013,13 @@ private ThreadInfoQuery.Result extractThreadData(SuspectRecord suspect, Set<Stri
if (requestInfos != null && !requestInfos.isEmpty())
{
builder.append("<p>"); //$NON-NLS-1$

builder.append("</p>"); //$NON-NLS-1$
builder.append("<ul style=\"list-style-type:none;\">"); //$NON-NLS-1$
for (CompositeResult.Entry requestInfo : requestInfos.getResultEntries())
builder.append(HTMLUtils.escapeText(requestInfo.getName())).append(" ").append( //$NON-NLS-1$
builder.append("<li>").append(HTMLUtils.escapeText(requestInfo.getName())).append(" ").append( //$NON-NLS-1$ //$NON-NLS-2$
textResult.linkTo(Messages.LeakHunterQuery_RequestDetails,
requestInfo.getResult())).append("<br>"); //$NON-NLS-1$

builder.append("</p>"); //$NON-NLS-1$
requestInfo.getResult())).append("</li>"); //$NON-NLS-1$
builder.append("</ul>"); //$NON-NLS-1$
}

// Add stacktrace information if available
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*******************************************************************************
* Copyright (c) 2008, 2020 SAP AG, IBM Corporation and others
* Copyright (c) 2008, 2021 SAP AG, IBM Corporation and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
Expand Down Expand Up @@ -465,8 +465,8 @@ private void addDuplicateStrings(SectionSpec componentReport, Histogram histogra

StringBuilder comment = new StringBuilder();
comment.append(MessageUtil.format(Messages.ComponentReportQuery_Msg_FoundOccurrences, table.getRowCount(),
HTMLUtils.escapeText(totals.getLabel(2))));
comment.append("<p>").append(Messages.ComponentReportQuery_TopElementsInclude).append("</p><ul>"); //$NON-NLS-1$ //$NON-NLS-2$
HTMLUtils.escapeText(totals.getLabel(2))));
comment.append("<p>").append(Messages.ComponentReportQuery_TopElementsInclude).append("</p><ul title=\"").append(Messages.ComponentReportQuery_TopElementsInclude).append("\">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

for (int rowId = 0; rowId < table.getRowCount() && rowId < 5; rowId++)
{
Expand All @@ -478,7 +478,7 @@ private void addDuplicateStrings(SectionSpec componentReport, Histogram histogra
String size = table.getFormattedColumnValue(row, 3);

comment.append("<li>").append(table.getFormattedColumnValue(row, 1)); //$NON-NLS-1$
comment.append(" &times; <strong>").append(HTMLUtils.escapeText(value)).append("</strong> "); //$NON-NLS-1$ //$NON-NLS-2$
comment.append(" &times; <strong>").append(HTMLUtils.escapeText(value)).append("</strong> "); //$NON-NLS-1$ //$NON-NLS-2$
comment.append(MessageUtil.format(Messages.ComponentReportQuery_Label_Bytes, size)).append("</li>"); //$NON-NLS-1$
}
comment.append("</ul>"); //$NON-NLS-1$
Expand Down Expand Up @@ -578,11 +578,11 @@ private void addEmptyCollections(SectionSpec componentReport, long totalSize, Hi
String retainedSize = refinedTable.getFormattedColumnValue(row, 3);

if (comment.length() == 0)
comment.append(Messages.ComponentReportQuery_DetectedEmptyCollections + "<ul>"); //$NON-NLS-1$
comment.append(Messages.ComponentReportQuery_DetectedEmptyCollections).append("<ul title=\"").append(Messages.ComponentReportQuery_DetectedEmptyCollections).append("\">"); //$NON-NLS-1$ //$NON-NLS-2$

comment.append("<li>"); //$NON-NLS-1$
comment.append(MessageUtil.format(Messages.ComponentReportQuery_Msg_InstancesRetainBytes,
numberOfObjects, HTMLUtils.escapeText(clazz.getName()), HTMLUtils.escapeText(retainedSize)));
numberOfObjects, HTMLUtils.escapeText(clazz.getName()), HTMLUtils.escapeText(retainedSize)));
comment.append("</li>"); //$NON-NLS-1$
}

Expand Down Expand Up @@ -665,11 +665,11 @@ private void addCollectionFillRatios(SectionSpec componentReport, long totalSize
String retainedSize = refinedTable.getFormattedColumnValue(row, 3);

if (comment.length() == 0)
comment.append(Messages.ComponentReportQuery_Msg_DetectedCollectionFillRatios + "<ul>"); //$NON-NLS-1$
comment.append(Messages.ComponentReportQuery_Msg_DetectedCollectionFillRatios).append("<ul title=\"").append(Messages.ComponentReportQuery_Msg_DetectedCollectionFillRatios).append("\">"); //$NON-NLS-1$ //$NON-NLS-2$

comment.append("<li>"); //$NON-NLS-1$
comment.append(MessageUtil.format(Messages.ComponentReportQuery_Msg_InstancesRetainBytes,
numberOfObjects, HTMLUtils.escapeText(clazz.getName()), HTMLUtils.escapeText(retainedSize)));
numberOfObjects, HTMLUtils.escapeText(clazz.getName()), HTMLUtils.escapeText(retainedSize)));
comment.append("</li>"); //$NON-NLS-1$
}

Expand Down Expand Up @@ -755,11 +755,11 @@ private void addHashMapsCollisionRatios(SectionSpec componentReport, long totalS
String retainedSize = refinedTable.getFormattedColumnValue(row, 3);

if (comment.length() == 0)
comment.append(Messages.ComponentReportQuery_Msg_DetectedCollisionRatios + "<ul>"); //$NON-NLS-1$
comment.append(Messages.ComponentReportQuery_Msg_DetectedCollisionRatios).append("<ul title=\"").append(Messages.ComponentReportQuery_Msg_DetectedCollisionRatios).append("\">"); //$NON-NLS-1$ //$NON-NLS-2$

comment.append("<li>"); //$NON-NLS-1$
comment.append(MessageUtil.format(Messages.ComponentReportQuery_Msg_InstancesRetainBytes,
numberOfObjects, HTMLUtils.escapeText(clazz.getName()), HTMLUtils.escapeText(retainedSize)));
numberOfObjects, HTMLUtils.escapeText(clazz.getName()), HTMLUtils.escapeText(retainedSize)));
comment.append("</li>"); //$NON-NLS-1$
break;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
###############################################################################
# Copyright (c) 2008, 2020 SAP AG and IBM Corporation.
# Copyright (c) 2008, 2021 SAP AG and IBM Corporation.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
# which accompanies this distribution, and is available at
# https://www.eclipse.org/legal/epl-2.0/
#
# https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
Expand Down Expand Up @@ -389,22 +389,22 @@ LeakHunterQuery_FindingProblemSuspects=Finding problem suspects
LeakHunterQuery_Hint=Hint {0}
LeakHunterQuery_Keywords=Keywords
LeakHunterQuery_LeakHunter=Leak Hunter
LeakHunterQuery_Msg_AccumulatedBy=The memory is accumulated in classloader/component <b>&quot;{0}&quot;</b> which occupies <b>{1}</b> bytes.
LeakHunterQuery_Msg_AccumulatedByInstance=The memory is accumulated in one instance of <b>&quot;{0}&quot;</b>, loaded by <b>&quot;{1}&quot;</b>, which occupies <b>{2}</b> bytes.
LeakHunterQuery_Msg_AccumulatedByLoadedBy=The memory is accumulated in class <b>&quot;{0}&quot;</b>, loaded by <b>&quot;{1}&quot;</b>, which occupies <b>{2}</b> bytes.
LeakHunterQuery_Msg_AccumulatedBy=The memory is accumulated in classloader/component <strong><q>{0}</q></strong> which occupies <strong>{1}</strong> bytes.
LeakHunterQuery_Msg_AccumulatedByInstance=The memory is accumulated in one instance of <strong><q>{0}</q></strong>, loaded by <strong><q>{1}</q></strong>, which occupies <strong>{2}</strong> bytes.
LeakHunterQuery_Msg_AccumulatedByLoadedBy=The memory is accumulated in class <strong><q>{0}</q></strong>, loaded by <strong><q>{1}</q></strong>, which occupies <strong>{2}</strong> bytes.
LeakHunterQuery_Msg_Bytes={0} bytes.
LeakHunterQuery_Msg_Class=The class <b>&quot;{0}&quot;</b>, loaded by <b>&quot;{1}&quot;</b>, occupies <b>{2}</b> bytes.
LeakHunterQuery_Msg_ClassLoader=The classloader/component <b>&quot;{0}&quot;</b> occupies <b>{1}</b> bytes.
LeakHunterQuery_Msg_Instance=One instance of <b>&quot;{0}&quot;</b> loaded by <b>&quot;{1}&quot;</b> occupies <b>{2}</b> bytes.
LeakHunterQuery_Msg_InstancesOccupy={0} instances of <b>&quot;{1}&quot;</b>, loaded by <b>&quot;{2}&quot;</b> occupy <b>{3}</b> bytes.
LeakHunterQuery_Msg_ReferencedBy=The instance is referenced by classloader/component. <b>&quot;{0}&quot;</b>.
LeakHunterQuery_Msg_ReferencedByClass=The instance is referenced by class <b>&quot;{0}&quot;</b>, loaded by <b>&quot;{1}&quot;</b>.
LeakHunterQuery_Msg_ReferencedByInstance=The instance is referenced by <b>{0}</b>&nbsp;, loaded by <b>&quot;{1}&quot;</b>.
LeakHunterQuery_Msg_ReferencedFromClass=These instances are referenced from the class <b>&quot;{0}&quot;</b>, loaded by <b>&quot;{1}&quot;</b>, which occupies <b>{2}</b> bytes.
LeakHunterQuery_Msg_ReferencedFromClassLoader=These instances are referenced from classloader/component <b>&quot;{0}&quot;</b> which occupies <b>{1}</b> bytes.
LeakHunterQuery_Msg_ReferencedFromInstance=These instances are referenced from one instance of <b>&quot;{0}&quot;</b>, loaded by <b>&quot;{1}&quot;</b>, which occupies <b>{2}</b> bytes.
LeakHunterQuery_Msg_Class=The class <strong><q>{0}</q></strong>, loaded by <strong><q>{1}</q></strong>, occupies <strong>{2}</strong> bytes.
LeakHunterQuery_Msg_ClassLoader=The classloader/component <strong><q>{0}</q></strong> occupies <strong>{1}</strong> bytes.
LeakHunterQuery_Msg_Instance=One instance of <strong><q>{0}</q></strong> loaded by <strong><q>{1}</q></strong> occupies <strong>{2}</strong> bytes.
LeakHunterQuery_Msg_InstancesOccupy={0} instances of <strong><q>{1}</q></strong>, loaded by <strong><q>{2}</q></strong> occupy <strong>{3}</strong> bytes.
LeakHunterQuery_Msg_ReferencedBy=The instance is referenced by classloader/component. <strong><q>{0}</q></strong>.
LeakHunterQuery_Msg_ReferencedByClass=The instance is referenced by class <strong><q>{0}</q></strong>, loaded by <strong><q>{1}</q></strong>.
LeakHunterQuery_Msg_ReferencedByInstance=The instance is referenced by <strong>{0}</strong>&nbsp;, loaded by <strong><q>{1}</q></strong>.
LeakHunterQuery_Msg_ReferencedFromClass=These instances are referenced from the class <strong><q>{0}</q></strong>, loaded by <strong><q>{1}</q></strong>, which occupies <strong>{2}</strong> bytes.
LeakHunterQuery_Msg_ReferencedFromClassLoader=These instances are referenced from classloader/component <strong><q>{0}</q></strong> which occupies <strong>{1}</strong> bytes.
LeakHunterQuery_Msg_ReferencedFromInstance=These instances are referenced from one instance of <strong><q>{0}</q></strong>, loaded by <strong><q>{1}</q></strong>, which occupies <strong>{2}</strong> bytes.
LeakHunterQuery_Msg_SuspectsRelated=The problem suspects {0} and {1} may be related, because the reference chains to them have a common beginning.
LeakHunterQuery_Msg_Thread=The thread <b>{0}</b> keeps local variables with total size <b>{1}</b> bytes.
LeakHunterQuery_Msg_Thread=The thread <strong>{0}</strong> keeps local variables with total size <strong>{1}</strong> bytes.
LeakHunterQuery_NothingFound=No leak suspect was found
LeakHunterQuery_Overview=Overview
LeakHunterQuery_OtherSuspectInstances=Other suspect instances
Expand All @@ -422,7 +422,7 @@ LeakHunterQuery_ThreadDetails=Thread Details
LeakHunterQuery_ThreadRootShortestPath=Thread root on shortest path
LeakHunterQuery_ThreadStack=Thread Stack
LeakHunterQuery_ThreadStackAndLocals=Thread Stack and Involved Local Variables
LeakHunterQuery_TicketForSuspect={0} for &quot;{1}&quot;
LeakHunterQuery_TicketForSuspect={0} for <q>{1}</q>
LeakingPlugins_NoLeakingPlugInsDetected=No leaking plug-ins detected.
MapCollisionRatioQuery_CalculatingCollisionRatios=Calculating Map Collision Ratios...
MapCollisionRatioQuery_Column_CollisionRatio=Collision Ratio
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
Expand Down Expand Up @@ -315,9 +315,13 @@ public void callback(Object event, Object source, CallBackValue value)
private void formatSliceName()
{
sliceName = sliceName.replaceAll("<b>", ""); //$NON-NLS-1$ //$NON-NLS-2$
sliceName = sliceName.replaceAll("<strong>", ""); //$NON-NLS-1$ //$NON-NLS-2$
sliceName = sliceName.replaceAll("<p>", ""); //$NON-NLS-1$ //$NON-NLS-2$
sliceName = sliceName.replaceAll("<q>", ""); //$NON-NLS-1$ //$NON-NLS-2$
sliceName = sliceName.replaceAll("</p>", ""); //$NON-NLS-1$ //$NON-NLS-2$
sliceName = sliceName.replaceAll("</b>", ""); //$NON-NLS-1$ //$NON-NLS-2$
sliceName = sliceName.replaceAll("</strong>", ""); //$NON-NLS-1$ //$NON-NLS-2$
sliceName = sliceName.replaceAll("</q>", ""); //$NON-NLS-1$ //$NON-NLS-2$
sliceName = sliceName.replaceAll("<br>", ""); //$NON-NLS-1$ //$NON-NLS-2$
sliceName = sliceName.replaceAll("<br/>", ""); //$NON-NLS-1$ //$NON-NLS-2$
}
Expand Down
Loading

0 comments on commit ea7317e

Please sign in to comment.