Picture element needs to respond to dynamic viewport changes.
authorhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Dec 2015 21:42:25 +0000 (21:42 +0000)
committerhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Dec 2015 21:42:25 +0000 (21:42 +0000)
commitefbf90ced329050d3d456a92f6955b72cd4a0141
tree3ea05a3af763afe791e59e9431f214d0ad65f462
parentd32c5857fb7947d0ed3032c6ff87f817d888e508
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.
Picture element needs to respond to dynamic viewport changes.
https://bugs.webkit.org/show_bug.cgi?id=152013
<rdar://problem/23766375>

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/picture.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evalCheckingViewportDependentResults):
Add new evaluation method that adds viewport dependent results to a vector. A follow-up patch
will refactor the style resolver code to use this function instead of the special style resolver one, in order to
get rid of the code duplication. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152089.

* css/MediaQueryEvaluator.h:
(WebCore::MediaQueryResult::MediaQueryResult):
* css/StyleResolver.h:
(WebCore::MediaQueryResult::MediaQueryResult): Deleted.
Move MediaQueryResult into a header since it is used in multiple places now and not just by the style
resolver.

* dom/Document.cpp:
(WebCore::Document::evaluateMediaQueryList):
(WebCore::Document::checkViewportDependentPictures):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired):
(WebCore::Document::applyContentDispositionAttachmentSandbox):
(WebCore::Document::addViewportDependentPicture):
(WebCore::Document::removeViewportDependentPicture):
* dom/Document.h:
The document now maintains a HashSet of viewport-dependent pictures, and it checks them whenever the
viewport changes. If their media queries stay the same, then nothing happens. If they change, then
the <picture> will go back and re-check all its <source> elements to see what the new best candidate is.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
Revised to check for viewport dependencies and to cache viewport-dependent results on the <picture> elements.
When a <picture> is found to be viewport-dependent (or not) it is also added to or removed from the document's
set of tracked pictures.

* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::HTMLPictureElement):
(WebCore::HTMLPictureElement::~HTMLPictureElement):
(WebCore::HTMLPictureElement::didMoveToNewDocument):
(WebCore::HTMLPictureElement::create):
(WebCore::HTMLPictureElement::sourcesChanged):
(WebCore::HTMLPictureElement::viewportChangeAffectedPicture):
* html/HTMLPictureElement.h:
New caching of results and updating of the document HashSet when the picture gets destroyed or moves to
a different document.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLSourceElement.h:
Cache the media attribute in a parsed form. A follow-up patch will improve the <video>/<audio>
code to make use of this parsed result. Tracked by https://bugs.webkit.org/show_bug.cgi?id=152090.

LayoutTests:

* fast/picture/resources/resize-test.js: Added.
* fast/picture/viewport-resize-expected.txt: Added.
* fast/picture/viewport-resize.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@193859 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/picture/resources/resize-test.js [new file with mode: 0644]
LayoutTests/fast/picture/viewport-resize-expected.txt [new file with mode: 0644]
LayoutTests/fast/picture/viewport-resize.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/MediaQueryEvaluator.cpp
Source/WebCore/css/MediaQueryEvaluator.h
Source/WebCore/css/StyleResolver.h
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/html/HTMLImageElement.cpp
Source/WebCore/html/HTMLPictureElement.cpp
Source/WebCore/html/HTMLPictureElement.h
Source/WebCore/html/HTMLSourceElement.cpp
Source/WebCore/html/HTMLSourceElement.h