Bug 152983 - Picture element needs to work properly with the preload scanner
Summary: Picture element needs to work properly with the preload scanner
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Images (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Dave Hyatt
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-11 12:18 PST by Dave Hyatt
Modified: 2016-01-11 15:43 PST (History)
4 users (show)

See Also:


Attachments
Patch (100.09 KB, patch)
2016-01-11 12:22 PST, Dave Hyatt
no flags Details | Formatted Diff | Diff
Patch (122.51 KB, patch)
2016-01-11 12:25 PST, Dave Hyatt
dino: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dave Hyatt 2016-01-11 12:18:35 PST
The preloader needs to do source selection properly on picture elements.
Comment 1 Dave Hyatt 2016-01-11 12:22:25 PST
Created attachment 268703 [details]
Patch
Comment 2 WebKit Commit Bot 2016-01-11 12:23:37 PST
Attachment 268703 [details] did not pass style-queue:


ERROR: Source/WebCore/html/parser/HTMLPreloadScanner.cpp:124:  Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.  [readability/comparison_to_zero] [5]
ERROR: Source/WebCore/html/parser/HTMLPreloadScanner.cpp:177:  Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.  [readability/comparison_to_zero] [5]
Total errors found: 2 in 14 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Dave Hyatt 2016-01-11 12:25:00 PST
Created attachment 268704 [details]
Patch
Comment 4 WebKit Commit Bot 2016-01-11 12:26:23 PST
Attachment 268704 [details] did not pass style-queue:


ERROR: Source/WebCore/html/parser/HTMLPreloadScanner.cpp:124:  Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.  [readability/comparison_to_zero] [5]
ERROR: Source/WebCore/html/parser/HTMLPreloadScanner.cpp:177:  Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.  [readability/comparison_to_zero] [5]
Total errors found: 2 in 14 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 Dean Jackson 2016-01-11 12:36:02 PST
Comment on attachment 268704 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=268704&action=review

> Source/WebCore/html/parser/HTMLPreloadScanner.cpp:124
> +        if (m_tagId == TagId::Source && !pictureState.isEmpty() && pictureState.last() == false && m_mediaMatched && !m_srcSetAttribute.isEmpty()) {

Why not !pictureState.last() ?

> Source/WebCore/html/parser/HTMLPreloadScanner.cpp:177
> +        bool alreadyMatchedSource = inPicture && pictureState.last() == true;

Same here.
Comment 6 Chris Dumez 2016-01-11 13:00:31 PST
Comment on attachment 268704 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=268704&action=review

> Source/WebCore/html/parser/HTMLPreloadScanner.cpp:128
> +                pictureState.removeLast();

I believe we could replace these 2 lines with: pictureState.last() = true;
and avoid any vector resizing.

> Source/WebCore/html/parser/HTMLPreloadScanner.cpp:174
> +    void processAttribute(const AtomicString& attributeName, const String& attributeValue, Document& document, Vector<bool> pictureState)

const Vector<bool>& ?

> Source/WebCore/html/parser/HTMLPreloadScanner.cpp:210
> +                RefPtr<MediaQuerySet> mediaSet = MediaQuerySet::createAllowingDescriptionSyntax(attributeValue);

Ref<>

> Source/WebCore/html/parser/HTMLPreloadScanner.cpp:213
> +                m_mediaMatched = evaluator.evalCheckingViewportDependentResults(mediaSet.get(), viewportDependentMediaQueryResults);

.ptr() instead of .get() if you switch to Ref<>.

> Source/WebCore/html/parser/HTMLPreloadScanner.cpp:326
> +    bool m_mediaMatched { true };

Would be clearer with a 'is' / 'was' prefix, as per coding style.

> Source/WebCore/html/parser/HTMLPreloadScanner.cpp:364
>              m_inStyle = false;

We probably want to add an early return after this to avoid running your new check.
Comment 7 Dave Hyatt 2016-01-11 13:49:46 PST
Fixed in r194865.