WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
184753
Detect system preview links
https://bugs.webkit.org/show_bug.cgi?id=184753
Summary
Detect system preview links
Dean Jackson
Reported
2018-04-18 13:29:44 PDT
Detect system preview links
Attachments
Patch
(17.36 KB, patch)
2018-04-18 13:34 PDT
,
Dean Jackson
no flags
Details
Formatted Diff
Diff
Patch
(16.97 KB, patch)
2018-04-18 13:59 PDT
,
Dean Jackson
graouts
: review+
Details
Formatted Diff
Diff
Patch
(17.05 KB, patch)
2018-04-18 14:59 PDT
,
Dean Jackson
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Dean Jackson
Comment 1
2018-04-18 13:30:25 PDT
<
rdar://problem/39500514
>
Dean Jackson
Comment 2
2018-04-18 13:34:30 PDT
Created
attachment 338256
[details]
Patch
Dean Jackson
Comment 3
2018-04-18 13:59:59 PDT
Created
attachment 338260
[details]
Patch
Antoine Quint
Comment 4
2018-04-18 14:07:54 PDT
Comment on
attachment 338260
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=338260&action=review
> Source/WebCore/html/HTMLAnchorElement.cpp:388 > + return (numChildren == 1 || numChildren == 2);
Don't need the parentheses.
> Source/WebCore/testing/Internals.cpp:4494 > + return downcast<HTMLAnchorElement>(element).isSystemPreviewLink();
return is<HTMLAnchorElement>(element) && downcast<HTMLAnchorElement>(element).isSystemPreviewLink();
> LayoutTests/system-preview/detection.html:12 > + children = link.children;
Single-clause if statement should not use curly braces.
> LayoutTests/system-preview/detection.html:25 > +window.addEventListener("load", function () {
() =>
> LayoutTests/system-preview/detection.html:44 > + addResult(result, "No link.");
Single-clause else statement should not use curly braces.
Dean Jackson
Comment 5
2018-04-18 14:59:02 PDT
Created
attachment 338267
[details]
Patch
Said Abou-Hallawa
Comment 6
2018-04-18 15:09:04 PDT
Comment on
attachment 338260
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=338260&action=review
> Source/WebCore/html/HTMLAnchorElement.cpp:380 > + // The relList is created on demand, which means that calling relList() > + // is only available in a non-const method.
Does this comment describe the new code or the existing code? I think in your patch relList() is const which means it can be called from const and non-const methods.
>> Source/WebCore/html/HTMLAnchorElement.cpp:388 >> + return (numChildren == 1 || numChildren == 2); > > Don't need the parentheses.
It can also be written like this: auto* child = firstElementChild(); if (!child || childElementCount() > 2) return false; return is<HTMLImageElement>(child) || is<HTMLPictureElement>(child); Or even shorter auto* child = firstElementChild(); return child && childElementCount() <= 2 && (is<HTMLImageElement>(child) || is<HTMLPictureElement>(child));
> Source/WebCore/html/HTMLPictureElement.cpp:79 > +bool HTMLPictureElement::isSystemPreviewImage() const
Why this function is named isSystemPreviewImage()? Should not this function be named isSystemPreviewPicture()? Or maybe it is better to remove the element name from all these functions: isSystemPreviewLink() isSystemPreviewImage() isSystemPreviewPicture() and have a single name for all of them isSystemPreviewable()
> Source/WebCore/testing/Internals.cpp:4504 > +bool Internals::isSystemPreviewLink(Element& element) const > +{ > + if (!is<HTMLAnchorElement>(element)) > + return false; > + return downcast<HTMLAnchorElement>(element).isSystemPreviewLink(); > +} > + > +bool Internals::isSystemPreviewImage(Element& element) const > +{ > + if (is<HTMLImageElement>(element)) > + return downcast<HTMLImageElement>(element).isSystemPreviewImage(); > + if (is<HTMLPictureElement>(element)) > + return downcast<HTMLPictureElement>(element).isSystemPreviewImage(); > + return false; > +}
Repeating the casting in the Internals and in HTMLPictureElement and HTMLImageElement may suggest having a virtual function Element::isSystemPreviewable() which returns false. HTMLPictureElement and HTMLImageElement override isSystemPreviewable() by just calling parent->isSystemPreviewable(). And of course HTMLAnchorElement::isSystemPreviewable() will have the real logic.
Dean Jackson
Comment 7
2018-04-18 15:14:15 PDT
Committed
r230788
: <
https://trac.webkit.org/changeset/230788
>
Dean Jackson
Comment 8
2018-04-18 16:04:58 PDT
Thanks Said. I'll make follow-up fixes.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug