Move WebCore/loader to std::unique_ptr
https://bugs.webkit.org/show_bug.cgi?id=138646

Reviewed by Chris Dumez.

Replace OwnPtr with std::unique_ptr<> and std::make_unique<>.
However this patch leaves ResourceRequest::adopt() because this need
to be handled by different patch.

No new tests, no behavior changes.

* loader/DocumentThreadableLoader.cpp:
(WebCore::DocumentThreadableLoader::makeCrossOriginAccessRequest):
(WebCore::DocumentThreadableLoader::preflightSuccess):
* loader/DocumentThreadableLoader.h:
* loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::SubresourceLoader):
(WebCore::SubresourceLoader::didReceiveResponse):
(WebCore::SubresourceLoader::notifyDone):
* loader/SubresourceLoader.h:
* loader/TextTrackLoader.h:
* loader/appcache/ApplicationCacheHost.h:
* loader/appcache/ApplicationCacheStorage.cpp:
(WebCore::ApplicationCacheStorage::storeCopyOfCache):
* loader/archive/cf/LegacyWebArchive.cpp:
(WebCore::LegacyWebArchive::create):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::requestPreload):
(WebCore::CachedResourceLoader::clearPreloads):
(WebCore::CachedResourceLoader::printPreloadStats):
* loader/cache/CachedResourceLoader.h:
* loader/icon/IconDatabase.cpp:
(WebCore::IconDatabase::deleteAllPreparedStatements):
(WebCore::readySQLiteStatement):
* loader/icon/IconDatabase.h:
* loader/icon/IconRecord.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@176172 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[TexMap] Add typecasting support for GraphicsLayerTextureMapper
https://bugs.webkit.org/show_bug.cgi?id=138741

Reviewed by Martin Robinson.

Source/WebCore:

Add type traits for the GraphicsLayerTextureMapper class.
This enables using typecasting functions instead of
toGraphicsLayerTextureMapper().

Remove toTextureMapperLayer() casting function which actually
returned the TextureMapperLayer object that belonged to the
passed-in GraphicsLayerTextureMapper. Instead, the GraphicsLayer
object is now downcasted and the TextureMapperLayer is accessed
by calling the GraphicsLayerTextureMapper::layer() method.

* platform/graphics/GraphicsLayer.h:
(WebCore::GraphicsLayer::isGraphicsLayerTextureMapper):
* platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
(WebCore::toTextureMapperLayerVector):
(WebCore::GraphicsLayerTextureMapper::commitLayerChanges):
(WebCore::toTextureMapperLayer): Deleted.
* platform/graphics/texmap/GraphicsLayerTextureMapper.h:
(WebCore::toGraphicsLayerTextureMapper): Deleted.

Source/WebKit/win:

Switch to using downcast<GraphicsLayerTextureMapper>() and replace
uses of toTextureMapperLayer() with downcasting and calling
the GraphicsLayerTextureMapper::layer() method.

* WebCoreSupport/AcceleratedCompositingContext.cpp:
(AcceleratedCompositingContext::initialize):
(AcceleratedCompositingContext::startedAnimation):
(AcceleratedCompositingContext::compositeLayersToContext):

Source/WebKit2:

Replace uses of toTextureMapperLayer() with downcasting and
calling the GraphicsLayerTextureMapper::layer() method.

* WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:
(WebKit::LayerTreeHostGtk::initialize):
(WebKit::LayerTreeHostGtk::layerFlushTimerFired):
(WebKit::LayerTreeHostGtk::compositeLayersToContext):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@176173 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Implement :valid and :invalid matching for the fieldset element
https://bugs.webkit.org/show_bug.cgi?id=138769

Reviewed by Darin Adler.

Source/WebCore:

In the latest HTML spec, the pseudo classes :valid and :invalid match
a fieldset element based on its descendants:
    https://html.spec.whatwg.org/#selector-valid
    https://html.spec.whatwg.org/#selector-invalid

This patch adds that behavior.

There are two key problems to solve with these pseudo classes on fieldset:
-Efficient matching.
-Style invalidation when any of the descendant changes.

To implement the style invalidation, I have modified HTMLFormControlElement
to notify its ancestor when its state changes.

The first change is making the state fully internal to HTMLFormControlElement,
we do not want subclass to be able to change the behavior and forget to update
the ancestors.

To achieve that encapsulation, the interface was changed a bit:
-Neither willValidate() nor isValidFormControlElement() inherit from Element.
 Instead, willValidate() is the implementation of FormAssociatedElement's interface
 and it is final. The method isValidFormControlElement() becomes completely internal
 to HTMLFormControlElement.
-Since willValidate() should no longer be re-implemented by subclass, the elements
 that were depending on it have been migrated to recalcWillValidate() to set
 the initial state as needed.

With the validity state fully encapsulated in HTMLFormControlElement, all I need
is a way to communicate that information to HTMLFieldSetElement ancestors.
This is done in two cases:
-The validity state changes.
-The tree changes in a way that would make the input element not a descendant
 of a HTMLFieldSetElement.

The invalidation is simply done by walking up the ancestors and adding the current
element to a "validity dependency list" on each HTMLFieldSetElement.

Tests: fast/css/pseudo-invalid-fieldset-invalidation-optimization.html
       fast/css/pseudo-invalid-fieldset-style-sharing.html
       fast/css/pseudo-invalid-fieldset.html
       fast/css/pseudo-valid-fieldset-invalidation-optimization.html
       fast/css/pseudo-valid-fieldset-style-sharing.html
       fast/css/pseudo-valid-fieldset.html
       fast/selectors/invalid-fieldset-style-update-1.html
       fast/selectors/invalid-fieldset-style-update-2.html
       fast/selectors/invalid-fieldset-style-update-3.html
       fast/selectors/invalid-fieldset-style-update-4.html
       fast/selectors/invalid-fieldset-style-update-5.html
       fast/selectors/valid-fieldset-style-update-1.html
       fast/selectors/valid-fieldset-style-update-2.html
       fast/selectors/valid-fieldset-style-update-3.html
       fast/selectors/valid-fieldset-style-update-4.html
       fast/selectors/valid-fieldset-style-update-5.html

* css/SelectorCheckerTestFunctions.h:
(WebCore::isInRange):
(WebCore::isOutOfRange):
(WebCore::isInvalid):
(WebCore::isValid):
The hack "ContainsValidityStyleRules" is in the way of correct styling
of FieldSet and Form.
It is not the right way to get stylesheet properties anyway.

* css/StyleResolver.cpp:
(WebCore::StyleResolver::canShareStyleWithControl):
Make sure style sharing does not incorrectly share style for fieldset elements.

* dom/Document.cpp:
(WebCore::Document::Document):
* dom/Document.h:
(WebCore::Document::containsValidityStyleRules): Deleted.
(WebCore::Document::setContainsValidityStyleRules): Deleted.
* dom/Element.h:
(WebCore::Element::matchesValidPseudoClass):
(WebCore::Element::matchesInvalidPseudoClass):
(WebCore::Element::willValidate): Deleted.
(WebCore::Element::isValidFormControlElement): Deleted.
* html/FormAssociatedElement.cpp:
(WebCore::FormAssociatedElement::customError):
* html/FormAssociatedElement.h:

* html/HTMLFieldSetElement.cpp:
(WebCore::HTMLFieldSetElement::matchesValidPseudoClass):
(WebCore::HTMLFieldSetElement::matchesInvalidPseudoClass):
(WebCore::HTMLFieldSetElement::addInvalidDescendant):
(WebCore::HTMLFieldSetElement::removeInvalidDescendant):
Each HTMLFormControlElement that has constraint validation adds or removes
itself from its HTMLFieldSetElement ancestors.

It should be possible to just keep track of a count instead of a HashSet.
I decided to got with the HashSet to make the code more robust and easier
to debug. A few assertions ensure that the HashSet is actually used as a counter.

* html/HTMLFieldSetElement.h:
* html/HTMLFormControlElement.cpp:
(WebCore::addInvalidElementToAncestorFromInsertionPoint):
(WebCore::removeInvalidElementToAncestorFromInsertionPoint):

(WebCore::HTMLFormControlElement::insertedInto):
(WebCore::HTMLFormControlElement::removedFrom):
One tricky part of those two functions is that we cannot use
matchesValidPseudoClass() or matchesInvalidPseudoClass().

The reason is that HTMLFieldSetElement is a subclass of HTMLFormControlElement
and it has its own definition of what Valid and Invalid mean when matching selectors.

In HTMLFormControlElement, we must use the internal state,
willValidate() and isValidFormControlElement() must be used directly.

(WebCore::HTMLFormControlElement::matchesValidPseudoClass):
(WebCore::HTMLFormControlElement::matchesInvalidPseudoClass):
(WebCore::HTMLFormControlElement::willValidate):
(WebCore::addInvalidElementToAncestors):
(WebCore::removeInvalidElementFromAncestors):
(WebCore::HTMLFormControlElement::setNeedsWillValidateCheck):
(WebCore::HTMLFormControlElement::setNeedsValidityCheck):
(WebCore::HTMLFormControlElement::isValidFormControlElement): Deleted.
* html/HTMLFormControlElement.h:
(WebCore::HTMLFormControlElement::isValidFormControlElement):
* html/HTMLKeygenElement.h:
* html/HTMLObjectElement.h:
* html/HTMLOutputElement.h:

LayoutTests:

There are many ways to change the validation state of a submittable element.
I included a series of test trying to exercises as many combination
as possible.

* fast/css/pseudo-valid-unapplied-expected.txt:
* fast/css/pseudo-valid-unapplied.html:
This test was checking that :valid and :invalid are not applied
to fieldset. Such results are incorrect with the latest specification.

* fast/css/pseudo-invalid-fieldset-expected.html: Added.
* fast/css/pseudo-invalid-fieldset-invalidation-optimization-expected.txt: Added.
* fast/css/pseudo-invalid-fieldset-invalidation-optimization.html: Added.
* fast/css/pseudo-invalid-fieldset-style-sharing-expected.html: Added.
* fast/css/pseudo-invalid-fieldset-style-sharing.html: Added.
* fast/css/pseudo-invalid-fieldset.html: Added.
* fast/css/pseudo-valid-fieldset-expected.html: Added.
* fast/css/pseudo-valid-fieldset-invalidation-optimization-expected.txt: Added.
* fast/css/pseudo-valid-fieldset-invalidation-optimization.html: Added.
* fast/css/pseudo-valid-fieldset-style-sharing-expected.html: Added.
* fast/css/pseudo-valid-fieldset-style-sharing.html: Added.
* fast/css/pseudo-valid-fieldset.html: Added.
* fast/selectors/invalid-fieldset-style-update-1-expected.txt: Added.
* fast/selectors/invalid-fieldset-style-update-1.html: Added.
* fast/selectors/invalid-fieldset-style-update-2-expected.txt: Added.
* fast/selectors/invalid-fieldset-style-update-2.html: Added.
* fast/selectors/invalid-fieldset-style-update-3-expected.txt: Added.
* fast/selectors/invalid-fieldset-style-update-3.html: Added.
* fast/selectors/invalid-fieldset-style-update-4-expected.txt: Added.
* fast/selectors/invalid-fieldset-style-update-4.html: Added.
* fast/selectors/invalid-fieldset-style-update-5-expected.txt: Added.
* fast/selectors/invalid-fieldset-style-update-5.html: Added.
* fast/selectors/valid-fieldset-style-update-1-expected.txt: Added.
* fast/selectors/valid-fieldset-style-update-1.html: Added.
* fast/selectors/valid-fieldset-style-update-2-expected.txt: Added.
* fast/selectors/valid-fieldset-style-update-2.html: Added.
* fast/selectors/valid-fieldset-style-update-3-expected.txt: Added.
* fast/selectors/valid-fieldset-style-update-3.html: Added.
* fast/selectors/valid-fieldset-style-update-4-expected.txt: Added.
* fast/selectors/valid-fieldset-style-update-4.html: Added.
* fast/selectors/valid-fieldset-style-update-5-expected.txt: Added.
* fast/selectors/valid-fieldset-style-update-5.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@176174 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Start cleaning up minimal UI from WKWebView
https://bugs.webkit.org/show_bug.cgi?id=138725

Patch by Benjamin Poulain <bpoulain@apple.com> on 2014-11-16
Reviewed by Sam Weinig.

Start removing the old update path for minimumLayoutSize/maximumUnobscuredSize.

Unfortunately, I cannot remove everything yet because the clients still did not have
alternatives to [_overrideLayoutParametersWithMinimumLayoutSize:minimumLayoutSizeForMinimalUI:maximumUnobscuredSizeOverride]
and might change the minimal UI options.

This patch adds [_overrideLayoutParametersWithMinimumLayoutSize:maximumUnobscuredSizeOverride] to move
in the right direction. Next we'll udpate the client code and get rid of all the useless code.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _overrideLayoutParametersWithMinimumLayoutSize:minimumLayoutSizeForMinimalUI:maximumUnobscuredSizeOverride:]):
(-[WKWebView _overrideLayoutParametersWithMinimumLayoutSize:maximumUnobscuredSizeOverride:]):
(-[WKWebView _minimumLayoutSizeOverrideForMinimalUI]): Deleted.
* UIProcess/API/Cocoa/WKWebViewPrivate.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@176175 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Replace RenderSVGResource::cast<T>() with downcast<T>()
https://bugs.webkit.org/show_bug.cgi?id=138290

Reviewed by Chris Dumez.

Add type traits for the RenderSVGResource hierarchy. This enables
using the typecasting framework in getRenderSVGResourceById() that
in return renders the RenderSVGResource::cast<>() template and all
the static s_resourceType member variables in the hierarchy removable.

* WebCore.order:
* rendering/svg/RenderSVGResource.h:
(WebCore::RenderSVGResource::cast): Deleted.
* rendering/svg/RenderSVGResourceClipper.h:
* rendering/svg/RenderSVGResourceContainer.h:
(WebCore::getRenderSVGResourceById):
* rendering/svg/RenderSVGResourceFilter.h:
(isType):
* rendering/svg/RenderSVGResourceLinearGradient.h:
* rendering/svg/RenderSVGResourceMarker.h:
* rendering/svg/RenderSVGResourceMasker.h:
* rendering/svg/RenderSVGResourcePattern.h:
* rendering/svg/RenderSVGResourceRadialGradient.h:
* rendering/svg/RenderSVGResourceSolidColor.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@176180 268f45cc-cd09-0410-ab3c-d52691b4dbfc