Commit af579277 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Clean up

parent ad747752
......@@ -385,82 +385,6 @@ void MailWebEngineAccessKey::handleSearchAccessKey(const QVariant &res)
makeAccessKeyLabel(accessKey, element);
}
}
#if 0
QRect viewport = QRect(d->mWebView->page()->mainFrame()->scrollPosition(), d->mWebView->page()->viewportSize());
const QString selectorQuery(QStringLiteral("a[href],"
"area,"
"button:not([disabled]),"
"input:not([disabled]):not([hidden]),"
"label[for],"
"legend,"
"select:not([disabled]),"
"textarea:not([disabled])"));
QList<QWebElement> result = d->mWebView->page()->mainFrame()->findAllElements(selectorQuery).toList();
// Priority first goes to elements with accesskey attributes
Q_FOREACH (const QWebElement &element, result) {
const QRect geometry = element.geometry();
if (geometry.size().isEmpty() || !viewport.contains(geometry.topLeft())) {
continue;
}
if (isHiddenElement(element)) {
continue; // Do not show access key for hidden elements...
}
const QString accessKeyAttribute(element.attribute(QStringLiteral("accesskey")).toUpper());
if (accessKeyAttribute.isEmpty()) {
unLabeledElements.append(element);
continue;
}
QChar accessKey;
for (int i = 0; i < accessKeyAttribute.count(); i += 2) {
const QChar &possibleAccessKey = accessKeyAttribute[i];
if (unusedKeys.contains(possibleAccessKey)) {
accessKey = possibleAccessKey;
break;
}
}
if (accessKey.isNull()) {
unLabeledElements.append(element);
continue;
}
handleDuplicateLinkElements(element, &d->mDuplicateLinkElements, &accessKey);
if (!accessKey.isNull()) {
unusedKeys.removeOne(accessKey);
makeAccessKeyLabel(accessKey, element);
}
}
// Pick an access key first from the letters in the text and then from the
// list of unused access keys
Q_FOREACH (const QWebElement &element, unLabeledElements) {
const QRect geometry = element.geometry();
if (unusedKeys.isEmpty()
|| geometry.size().isEmpty()
|| !viewport.contains(geometry.topLeft())) {
continue;
}
QChar accessKey;
const QString text = element.toPlainText().toUpper();
for (int i = 0; i < text.count(); ++i) {
const QChar &c = text.at(i);
if (unusedKeys.contains(c)) {
accessKey = c;
break;
}
}
if (accessKey.isNull()) {
accessKey = unusedKeys.takeFirst();
}
handleDuplicateLinkElements(element, &d->mDuplicateLinkElements, &accessKey);
if (!accessKey.isNull()) {
unusedKeys.removeOne(accessKey);
makeAccessKeyLabel(accessKey, element);
}
}
#endif
d->mAccessKeyActivated = (d->mAccessKeyLabels.isEmpty() ? MailWebEngineAccessKeyPrivate::Activated : MailWebEngineAccessKeyPrivate::NotActivated);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment