Implement a Shadow DOM spec's section 6 'Events'.
https://bugs.webkit.org/show_bug.cgi?id=78586

Reviewed by Dimitri Glazkov.

Source/WebCore:

This implements a Shadow DOM spec's section 6 'Events', introducing a new
algorithm so that event dispatching use a composed shadow DOM tree,
instead of normal DOM tree, in dispatching events to each node.

The spec is here: http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#events

Summary of changes:
- Attaching shadow DOM does not affect an event dispatching
behavior of enclosing DOM tree. This applies even if some nodes
are distributed to insertion points. We keep a compatibility of
existing event dispatching mechanism so that we won't break Web.
- Event ancestors, which are used in dispatching events in capture (or
bubble) phase, are now the result of traversing ancestors in composed
shadow DOM tree order, instead of normal DOM tree order.
- Event's target and related-target are correctly adjusted so that
we don't leak any node which is inaccessible from the event's
current-target node. We enforce both upper and lower boundary
encapsulation of Shadow DOM in event dispatching

Here is an example of event dispatching. Suppose we have the following DOM tree, which
includes some nested shadow hosts and insertion points
A
`--B-----[SR-B]
   |-C     `--G--------------[SR-G]
   | `-D      |-<H select=C>    |--J---------------[SR-J]
   `-E        `-<I select=E>    |  `-<K select=H>    `-<N select=K>
     `-F                        |
                                `--L---------------[SR-L]
                                   `-<M select=I>    `-<O select=M>

  Notation: [SR-X]: Shadow Root
            <X select=Y>: Insertion Point, called X, which selects Y.

If a mouse moves from node '#F' to node '#D', the following
'mouseover' events are dispatched in each ancestor node:

[currentTarget] [target] [related-target]
  #D             #D       #F
  #C             #D       #F
  #H             #H       #I
  #K             #K       #M
  #N             #N       #M
  #SR-J          #N       #M
  #J             #K       #M
  #SR-G          #K       #M
  #G             #H       #I
  #SR-B          #H       #I
  #B             #D       #F
  #A             #D       #F

Details are:
- Insertion points, such as <content> or <shadow>, are resolved correctly
in calculating event ancestors. That means if a node is distributed to
an insertion point, the insertion point is now an ancestor of the node in
bubbling (or capturing) events.
- Both insertion points and shadow roots now can receive events. We can add
event listeners to insertion points and shadow roots.
- Dispatched event's target is now adjusted correctly using the re-targeting
algorithm. The algorithm is now fully aware of insertion points.
- Dispatched event's related-target can now differ in each tree scope of
event ancestors. We choose the most appropriate related-target using the
related target resolution algorithm for each node.

Performance consideration:
This patch can achieve the competitive performance. The results of
./Tools/Scripts/run-perf-tests PerformanceTests/DOM/Events.html for
before/after this patch are:

Before applying this patch:
    Running DOM/Events.html (1 of 1)
    RESULT DOM: Events= 270.310714286 ms
    median= 269.75 ms, stdev= 2.0042397663 ms, min= 267.357142857 ms, max= 276.5 ms

After applying this patch:
    Running DOM/Events.html (1 of 1)
    RESULT DOM: Events= 268.108333333 ms
    median= 267.5 ms, stdev= 2.41883157195 ms, min= 263.625 ms, max= 273.142857143 ms

I've also conducted a micro benchmark using both
Shadow-Free-DOM-Tree and DOM-Tree-With-Shadow-Host.
See https://bugs.webkit.org/show_bug.cgi?id=78586#c40 for the results.
It seems that the new implementation has more capabilities, but
doesn't sacrifice a performance of event dispatching in either cases.

Test: fast/dom/shadow/shadow-dom-event-dispatching.html

* dom/ComposedShadowTreeWalker.cpp:
(WebCore::ComposedShadowTreeWalker::parentIncludingInsertionPointAndShadowRoot):
(WebCore):
(WebCore::ComposedShadowTreeWalker::traverseParentIncludingInsertionPointAndShadowRoot):
* dom/ComposedShadowTreeWalker.h:
(ComposedShadowTreeWalker):
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext):
(WebCore::EventContext::handleLocalEvents):
* dom/EventContext.h:
(EventContext):
(WebCore::EventContext::relatedTarget):
(WebCore):
(WebCore::EventContext::setRelatedTarget):
* dom/EventDispatcher.cpp:
(WebCore::EventRelatedTargetAdjuster::EventRelatedTargetAdjuster):
(WebCore):
(WebCore::EventRelatedTargetAdjuster::adjust):
(WebCore::EventRelatedTargetAdjuster::findRelatedTarget):
(WebCore::EventDispatcher::adjustRelatedTarget):
(WebCore::EventDispatcher::ensureEventAncestors):
(WebCore::EventDispatcher::dispatchEvent):
(WebCore::EventDispatcher::determineDispatchBehavior):
* dom/EventDispatcher.h:
(WebCore):
(EventRelatedTargetAdjuster):
(EventDispatcher):
* dom/MouseEvent.cpp:
(WebCore::MouseEventDispatchMediator::dispatchEvent):
* dom/MouseEvent.h:
(WebCore::toMouseEvent):
(WebCore):

LayoutTests:

* fast/dom/shadow/shadow-dom-event-dispatching-expected.txt: Added.
* fast/dom/shadow/shadow-dom-event-dispatching.html: Added.
* platform/efl/Skipped:
* platform/qt/Skipped:
* platform/win/Skipped:
* platform/wincairo/Skipped:
* platform/wk2/Skipped:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117394 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[EFL] Fix bug number for video-controls-drag.html in the test_expectation.txt
https://bugs.webkit.org/show_bug.cgi?id=86607

Unreviewed EFL gardening.

Change BUGWK number to point to right patch.

Patch by Kihong Kwon <kihong.kwon@samsung.com> on 2012-05-16

* platform/efl/test_expectations.txt:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117395 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Chromium] Implement WebViewImpl::textInputInfo() for Android
https://bugs.webkit.org/show_bug.cgi?id=86440

Reviewed by Darin Fisher.

This patch adds WebView::textInputInfo(), which describes the text
input that currently has focus.  Android is planning to use this to
determine what sort of keyboard or text entry UI to show.  This API
subsumes the textInputType() API, which will be removed once the
clients have been updated.

* WebKit.gyp:
* public/WebTextInputInfo.h: Added.
(WebKit):
(WebTextInputInfo):
(WebKit::WebTextInputInfo::WebTextInputInfo):
(WebKit::operator==):
(WebKit::operator!=):
* public/WebTextInputType.h:
* public/WebWidget.h:
(WebWidget):
(WebKit::WebWidget::textInputInfo):
(WebKit::WebWidget::textInputType):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::textInputInfo):
(WebKit):
(WebKit::WebViewImpl::textInputType):
* src/WebViewImpl.h:
(WebViewImpl):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117396 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Performance test] Support "description" for PerfTestRunner.run and PerfTestRunner.runPerSecond
https://bugs.webkit.org/show_bug.cgi?id=86696

Reviewed by Ryosuke Niwa.

We want to add some description for each PerfTestRunner.run and
PerfTestRunner.runPerSecond, so that people can know what each
run is testing.

Output example:

$ ./Tools/Scripts/run-perf-tests Bindings/first-child.html
Running Bindings/first-child.html (1 of 1)
DESCRIPTION: Benchmark for DOM attributes that return a Node object.
RESULT Bindings: first-child= 788.359076534 runs/s
median= 797.508097751 runs/s, stdev= 19.0972905207 runs/s, min= 746.666666667 runs/s, max= 801.001251564 runs/s

PerformanceTests:

* resources/runner.js:
(PerfTestRunner.logStatistics):
(PerfTestRunner.printStatistics):
(PerfTestRunner.runPerSecond):

Tools:

* Scripts/webkitpy/performance_tests/perftest.py:
(PerfTest):
(PerfTest.parse_output):
(PerfTest.output_statistics):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117397 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[chromium] Get text direction at the start and end of selection.
https://bugs.webkit.org/show_bug.cgi?id=86573

Patch by Hao Zheng <zhenghao@chromium.org> on 2012-05-16
Reviewed by Adam Barth.

Add an interface to get text direction at the start and end of
selection for Android, as on Android different selection delimiters
are needed for RTL text. Unlike other platforms, the start and end
delimiters of selection are different, so we need determine the shape
of delimiter based on text direction.

* public/WebWidget.h:
(WebWidget):
(WebKit::WebWidget::selectionTextDirection):
* src/WebViewImpl.cpp:
(WebKit):
(WebKit::WebViewImpl::selectionTextDirection):
* src/WebViewImpl.h:
(WebViewImpl):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117398 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[EFL] Restore accidentally changed copyrights.
https://bugs.webkit.org/show_bug.cgi?id=86471

Patch by Tomasz Morawski <t.morawski@samsung.com> on 2012-05-16
Reviewed by Antonio Gomes.

Restore accidentally changed copyrights.

* ewk/ewk_js_private.h:
* ewk/ewk_security_origin_private.h:
* ewk/ewk_view_private.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117399 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed expectations update.

* fast/repaint/float-overflow-expected.png: Renamed from LayoutTests/platform/efl/fast/repaint/float-overflow-expected.png.
* fast/repaint/float-overflow-expected.txt: Renamed from LayoutTests/platform/efl/fast/repaint/float-overflow-expected.txt.
* fast/repaint/float-overflow-right-expected.png: Renamed from LayoutTests/platform/efl/fast/repaint/float-overflow-right-expected.png.
* fast/repaint/float-overflow-right-expected.txt: Renamed from LayoutTests/platform/efl/fast/repaint/float-overflow-right-expected.txt.
* platform/chromium-linux/fast/block/float/overhanging-tall-block-expected.txt: Added.
* platform/chromium-mac/fast/repaint/float-overflow-expected.png: Added.
* platform/chromium-mac/fast/repaint/float-overflow-expected.txt: Renamed from LayoutTests/platform/gtk/fast/repaint/float-overflow-expected.txt.
* platform/chromium-mac/fast/repaint/float-overflow-right-expected.png: Added.
* platform/chromium-mac/fast/repaint/float-overflow-right-expected.txt: Renamed from LayoutTests/platform/gtk/fast/repaint/float-overflow-right-expected.txt.
* platform/chromium/test_expectations.txt:
* platform/gtk/fast/repaint/float-overflow-expected.png: Removed.
* platform/gtk/fast/repaint/float-overflow-right-expected.png: Removed.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117400 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Qt] Web process hangs while waiting for plugin process connection during layouttests
https://bugs.webkit.org/show_bug.cgi?id=86620

* platform/qt/Skipped: Skip failing tests after r117288.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117401 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed, rolling out r117396.
http://trac.webkit.org/changeset/117396
https://bugs.webkit.org/show_bug.cgi?id=86709

"breaks chromium tree" (Requested by morrita on #webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2012-05-16

* WebKit.gyp:
* public/WebTextInputInfo.h: Removed.
* public/WebTextInputType.h:
* public/WebWidget.h:
(WebKit::WebWidget::textInputType):
* src/WebTextInputInfo.cpp: Removed.
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::textInputType):
* src/WebViewImpl.h:
(WebViewImpl):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117402 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed GTK gardening after r117373.

* platform/gtk/fast/forms/input-align-image-expected.txt:
* platform/gtk/fast/forms/preserveFormDuringResidualStyle-expected.txt:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117403 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed, rolling out r117372.
http://trac.webkit.org/changeset/117372
https://bugs.webkit.org/show_bug.cgi?id=86710

"triggerring crashes" (Requested by morrita on #webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2012-05-16

Source/WebCore:

* Modules/webaudio/AudioParam.cpp:
(WebCore::AudioParam::calculateSampleAccurateValues):
(WebCore::AudioParam::calculateAudioRateSignalValues):
(WebCore::AudioParam::connect):
(WebCore::AudioParam::disconnect):
* Modules/webaudio/AudioParam.h:
(WebCore::AudioParam::context):
(WebCore::AudioParam::hasSampleAccurateValues):
(WebCore::AudioParam::AudioParam):
(AudioParam):

LayoutTests:

* webaudio/audioparam-connect-audioratesignal.html:
* webaudio/audioparam-summingjunction-expected.txt: Removed.
* webaudio/audioparam-summingjunction.html: Removed.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117404 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Qt] Web process hangs while waiting for plugin process connection during layouttests
https://bugs.webkit.org/show_bug.cgi?id=86620

* platform/qt/Skipped: Skip failing tests after r117288.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117405 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Qt] Unreviewed gardening after r117339.
https://bugs.webkit.org/show_bug.cgi?id=84167

* platform/qt/Skipped:
* platform/qt/editing/pasteboard/innerText-inline-table-expected.png:
* platform/qt/editing/pasteboard/innerText-inline-table-expected.txt:
* platform/qt/editing/selection/iframe-expected.png:
* platform/qt/editing/selection/iframe-expected.txt:
* platform/qt/editing/selection/inline-table-expected.png:
* platform/qt/editing/selection/inline-table-expected.txt:
* platform/qt/editing/selection/table-caret-3-expected.png:
* platform/qt/editing/selection/table-caret-3-expected.txt:
* platform/qt/fast/css-generated-content/inline-display-types-expected.png:
* platform/qt/fast/css-generated-content/inline-display-types-expected.txt:
* platform/qt/fast/css-generated-content/nested-tables-with-before-after-content-crash-expected.png:
* platform/qt/fast/css-generated-content/nested-tables-with-before-after-content-crash-expected.txt: Added.
* platform/qt/fast/inline-block/001-expected.png:
* platform/qt/fast/inline-block/001-expected.txt:
* platform/qt/tables/mozilla/bugs/bug2479-2-expected.png:
* platform/qt/tables/mozilla/bugs/bug2479-2-expected.txt:
* platform/qt/test_expectations.txt:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117406 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed, marking backgr_position-table.html and some others as fail.

* platform/chromium/test_expectations.txt:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117407 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed, marking input-appearance-range.html as fail.

* platform/chromium/test_expectations.txt:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117408 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[EFL] fast/frames/frame-crash-with-page-cache.html is crashing
https://bugs.webkit.org/show_bug.cgi?id=85879

Patch by Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com> on 2012-05-17
Reviewed by Noam Rosenthal.

Source/WebKit/efl:

_ewk_frame_smart_del() is considering now that the frame can be present in cache.
loader()->detachFromParent() is only applied for the main frame.
loader()->cancelAndClear() is not used anymore.

* ewk/ewk_frame.cpp:
(_ewk_frame_smart_del):

LayoutTests:

* platform/efl/test_expectations.txt: Removed fast/frames/frame-crash-with-page-cache.html.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117409 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Performance test] Always fill results['description'] in perftest.py
https://bugs.webkit.org/show_bug.cgi?id=86696

Reviewed by Ryosuke Niwa.

This is a follow-up patch for r117397 to fix perf bot failures.
This patch fills results['description'] always.

* Scripts/webkitpy/performance_tests/perftest.py:
(PageLoadingPerfTest.run):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117410 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Worker] Web Worker lacks test to check the name attribute of SharedWorker
https://bugs.webkit.org/show_bug.cgi?id=86714

Patch by Li Yin <li.yin@intel.com> on 2012-05-17
Reviewed by Kentaro Hara.

Spec: http://www.w3.org/TR/2012/CR-workers-20120501/#sharedworkerglobalscope
The name attribute must return the value it was assigned when the SharedWorkerGlobalScope object was created.
So we should have a test to check it, there is a related test "fast/worker/shared-worker-name.html" already,
but it doesn't cover this.

* fast/workers/resources/shared-worker-common.js:
(handleMessage):
* fast/workers/resources/shared-worker-name.js:
(test11.worker.port.onmessage):
(test11):
* fast/workers/shared-worker-name-expected.txt:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117411 268f45cc-cd09-0410-ab3c-d52691b4dbfc
CSS3 Multicolumn: Content in normal flow extending into column gaps should be clipped at middle of column-gap
https://bugs.webkit.org/show_bug.cgi?id=86441

Patch by Uday Kiran <udaykiran@motorola.com> on 2012-05-17
Reviewed by Eric Seidel.

Source/WebCore:

Content in the normal flow that extends into column gaps (e.g., long words or images)
is clipped in the middle of the column gap.
http://www.w3.org/TR/css3-multicol/#overflow-inside-multicol-elements

Test: fast/multicol/overflow-into-columngap.html

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::paintColumnContents):

LayoutTests:

Test for content in normal flow that extends into column gaps.
http://www.w3.org/TR/css3-multicol/#overflow-inside-multicol-elements

* fast/multicol/overflow-into-columngap-expected.html: Added.
* fast/multicol/overflow-into-columngap.html: Added.
* platform/chromium/test_expectations.txt:
* platform/efl/test_expectations.txt:
* platform/gtk/test_expectations.txt:
* platform/mac/test_expectations.txt:
* platform/qt/test_expectations.txt:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117412 268f45cc-cd09-0410-ab3c-d52691b4dbfc
REGRESSION (r116331): RSS Headlines/links are missing (-webkit-box-flex broken?)
https://bugs.webkit.org/show_bug.cgi?id=85991

Source/WebCore:

Fix for regression failures on deprecated flex box test cases.

Patch by Pravin D <pravind.2k4@gmail.com> on 2012-05-17
Reviewed by Eric Seidel.

Test: fast/css/deprecated-flex-box-zero-width-intrinsic-max-width.html

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::computePreferredLogicalWidths):
Fix to use intrinsic width when the fixed width:0 , for deprecated flex boxes.

LayoutTests:

Patch by Pravin D <pravind.2k4@gmail.com> on 2012-05-17
Reviewed by Eric Seidel.

* fast/css/deprecated-flex-box-zero-width-intrinsic-max-width-expected.txt: Added.
* fast/css/deprecated-flex-box-zero-width-intrinsic-max-width.html: Added.

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