Distribution state becomes inconsistent with content/shadow reprojection
https://bugs.webkit.org/show_bug.cgi?id=106634

Reviewed by Hajime Morita.

Source/WebCore:

Distribution should be resolved from shallower ShadowDOM to deeper Shadow DOM. However, in the current implementation,
there is a case that distribution for deeper ShadowDOM happens to be resolved before distribution
for shallower ShadowDOM is resolved.

Here, we have 2 problems about distribution.
1) Invalidation state is not propagated to nested (= deeper) ShadowDOM.
    - This causes deeper ShadowDOM looks having a valid distribution though it should be invalid.
2) We are not resolving shallower ShadowDOM when deeper ShadowDOM's distribution is needed.
    - Because of (1), we have to check all the ancestor ShadowDOM.

For (1), we change invalidate() to invalidate nested ShadowDOM's distribution as well.
For (2), when resolving distribution, we will check the ancestor ShadowDOM's distribution state. If the ancestor's
distribution is not valid, we resolve it first.

For optimization of (1), actually we can skip invalidating distribution of some ShadowDOMs.
If ShadowRoot of deeper ShadowDOM does not have an InsertionPoint as children, we can skip invalidating
its distribution, because only children can be distributed to InsertionPoint.

Tests: fast/dom/shadow/distribution-crash.html
       fast/dom/shadow/nested-reprojection-inconsistent.html

* dom/ElementShadow.cpp:
(WebCore::ElementShadow::attach): Should resolve distribution from ancestor.
* dom/ElementShadow.h:
* html/shadow/ContentDistributor.cpp:
(WebCore::ContentDistributor::distribute): Added ASSERT that the parent ShadowRoot's distribution is resolved.
(WebCore::ContentDistributor::invalidate): For each InsertionPoint, we have to invalidate
its parent element's distribution (if it has ElementShadow).
(WebCore::ContentDistributor::ensureDistribution):
* html/shadow/ContentDistributor.h:
(WebCore::ContentDistributor::isValid):
* html/shadow/HTMLShadowElement.cpp:
(WebCore::HTMLShadowElement::olderShadowRoot): Should resolve distribution from ancestor.
* html/shadow/InsertionPoint.cpp:
(WebCore::InsertionPoint::attach): ditto.
(WebCore::InsertionPoint::detach): ditto.
(WebCore::InsertionPoint::getDistributedNodes): ditto.
(WebCore::resolveReprojection): ditto.

LayoutTests:

* fast/dom/shadow/distribution-crash-expected.txt: Added.
* fast/dom/shadow/distribution-crash.html: Added.
* fast/dom/shadow/nested-reprojection-inconsistent-expected.txt: Added.
* fast/dom/shadow/nested-reprojection-inconsistent.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@140299 268f45cc-cd09-0410-ab3c-d52691b4dbfc
CSS3 calc: unprefix implementation
https://bugs.webkit.org/show_bug.cgi?id=91951

Reviewed by Ojan Vafai.

Source/WebCore:

Add support for the unprefixed 'calc()' function, while retaining support for the prefixed version.

Test: css3/calc/simple-calcs-prefixed.html

* css/CSSCalculationValue.cpp:
(WebCore::buildCssText):
(WebCore::CSSCalcValue::create):
* css/CSSParser.cpp:
(WebCore::CSSParser::isCalculation):
(WebCore::CSSParser::detectFunctionTypeToken):

LayoutTests:

Changed all -webkit-calc() occurrences to calc().
Made a copy of the simplest test file so very basic tests for the prefixed version
are retained.

* css3/calc/background-position-parsing.html:
* css3/calc/block-mask-overlay-image-outset.html:
* css3/calc/border-radius.html:
* css3/calc/border.html:
* css3/calc/box-reflect.html:
* css3/calc/calc-errors.html:
* css3/calc/color-hsl.html:
* css3/calc/color-rgb.html:
* css3/calc/css3-radial-gradients.html:
* css3/calc/cssom-expected.txt:
* css3/calc/cssom.html:
* css3/calc/font-monospace.html:
* css3/calc/font-size-fractional.html:
* css3/calc/font-size.html:
* css3/calc/font.html:
* css3/calc/getComputedStyle-margin-percentage.html:
* css3/calc/gradient-color-stops.html:
* css3/calc/img-size.html:
* css3/calc/line-height.html:
* css3/calc/margin.html:
* css3/calc/negative-padding.html:
* css3/calc/padding.html:
* css3/calc/reflection-computed-style-expected.txt:
* css3/calc/reflection-computed-style.html:
* css3/calc/regression-62276.html:
* css3/calc/simple-calcs-prefixed-expected.txt: Added.
* css3/calc/simple-calcs-prefixed.html: Copied from LayoutTests/css3/calc/simple-calcs.html.
* css3/calc/simple-calcs.html:
* css3/calc/simple-composited-mask.html:
* css3/calc/table-border-spacing.html:
* css3/calc/table-calcs.html:
* css3/calc/table-empty-cells.html:
* css3/calc/transforms-scale.html:
* css3/calc/transforms-translate.html:
* css3/calc/transition-crash.html:
* css3/calc/transition-crash2.html:
* css3/calc/transition-crash3.html:
* css3/calc/transition-crash4.html:
* css3/calc/transitions-dependent.html:
* css3/calc/transitions.html:
* css3/calc/vertical-align-expected.html:
* css3/calc/vertical-align.html:
* css3/calc/zoom-with-em.html:


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