[Shadow DOM] Some distribution invalidation can drop necessary reattachment.
https://bugs.webkit.org/show_bug.cgi?id=88843

Reviewed by Dimitri Glazkov.

Source/WebCore:

Following scenario caused this problem:

- Inserting a Text node as a shadow child triggers invalidateDistribution(),
  which doen't reattach the shadow's host element.
- Then inserting a <content> element after that triggers another invalidateDistribution(),
  which should reattach its host because <content> can affect not only distribution of new nodes,
  but also existing distribution.
- Since the first invalidateDistribution() has marked the distribution as invalidated,
  the second invalidateDistribution() call returns early without any reattachment,
  even though it needs one.

This change adds InvalidationType parameter to invalidateDistribution(), which asks ElementShadow to
reattach the host regardless of its validity state. InsertionPoint::insertedInto() uses
this flag to ensure that its insertion always results a reattachment.

Test: fast/dom/shadow/content-after-style.html

* dom/ElementShadow.cpp:
(WebCore::ElementShadow::addShadowRoot): Passes InvalidationType.
(WebCore::ElementShadow::removeAllShadowRoots): Passes InvalidationType.
(WebCore::ElementShadow::invalidateDistribution): Added a InvalidationType parameter.
* dom/ElementShadow.h:
* html/shadow/InsertionPoint.cpp:
(WebCore::InsertionPoint::insertedInto): Passes InvalidationType.

LayoutTests:

* fast/dom/shadow/content-after-style-expected.html: Added.
* fast/dom/shadow/content-after-style.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@122915 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Test cases in DecimalTest should use EXPECT_STREQ for ease of debugging test case
https://bugs.webkit.org/show_bug.cgi?id=91572

Reviewed by Kent Tamura.

This patch introduces EXPECT_DECIMAL_STREQ macro to replace EXPECT_EQ
with String class for displaying text string rather than object dump
for ease of debugging test cases.

* tests/DecimalTest.cpp:
(DecimalTest::stepDown): Changed to return Decimal instead of String
to use EXPECT_DECIMAL_STREQ.
(DecimalTest::stepUp): ditto.
(TEST_F): Replaced EXPECT_EQ + String class to EXPECT_DECIMAL_STREQ.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@122916 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Form state: Make a new class handling HashMap<FormElementKey, Deque<>>
https://bugs.webkit.org/show_bug.cgi?id=91480

Reviewed by Hajime Morita.

This is a preparation of Bug 91209, "Form state restore: Need to
identify a from by its content."

Make a new class which is responsible to handle "HashMap<FormElementKey,
Deque<FormControlState>, FormElementKeyHash, FormElementKeyHashTraits>."
Also, move the FormElementKey class declaration and related structs from
FormController.h to FormController.cpp because FormElementKey is used
only in FormController.cpp.

No new tests. Just a refactoring.

* html/FormController.cpp:
(WebCore::FormElementKey): Moeved from FormController.h.
(WebCore::FormElementKey::FormElementKey):
Moved from the bottom of FormController.cpp
(WebCore::FormElementKey::~FormElementKey): ditto.
(WebCore::FormElementKey::operator=): ditto.
(WebCore::FormElementKey::ref): ditto.
(WebCore::FormElementKey::deref): ditto.
(WebCore::operator==): Moved from FormController.h
(FormElementKeyHash): ditto.
(WebCore::FormElementKeyHash::equal): ditto.
(WebCore::FormElementKeyHash::hash):
Moved from the bottom of FormController.cpp
(WebCore::FormElementKeyHashTraits::constructDeletedValue):
Moved from FormController.h
(WebCore::FormElementKeyHashTraits::isDeletedValue): ditto.

(WebCore::SavedFormState): Added.
(WebCore::SavedFormState::isEmpty):
(WebCore::SavedFormState::SavedFormState): Added. The constructor.
(WebCore::SavedFormState::create): Added. A factory function.
(WebCore::SavedFormState::appendControlState):
Moved some code from FormController::setStateForNewFormElements.
(WebCore::SavedFormState::takeControlState):
Moved some code from FormController::takeStateForFormElement.

(WebCore::FormController::setStateForNewFormElements):
- Creates SavedFormState if needed.
- Uses SavedFormState::appendControlState.
(WebCore::FormController::takeStateForFormElement):
Uses SavedFormState.
* html/FormController.h:
(FormController):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@122917 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Fix an assertion failure in CalendarPickerElement::hostInput().
https://bugs.webkit.org/show_bug.cgi?id=91568

Reviewed by Hajime Morita.

Source/WebCore:

Test: fast/forms/date/calendar-picker-type-change-onclick.html

* html/shadow/CalendarPickerElement.cpp:
(WebCore::CalendarPickerElement::defaultEventHandler):
It's possible that this function is called when the element is detached
from the document tree.

LayoutTests:

* fast/forms/date/calendar-picker-type-change-onclick-expected.txt: Added.
* fast/forms/date/calendar-picker-type-change-onclick.html: Added.

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