[Shadow DOM]: scoped styles are not applied in the cascade order.
https://bugs.webkit.org/show_bug.cgi?id=103239

Reviewed by Dimitri Glazkov.

Source/WebCore:

If the scoping elements of two declarations have an ancestor/
descendant relationship, the declaration whose scoping element is
the descendant should win.
c.f. http://dev.w3.org/csswg/css3-cascade/#cascade

Test: fast/css/style-scoped/style-scoped-nested.html
      fast/css/style-scoped/style-scoped-with-important-rule.html

* css/RuleSet.cpp:
(WebCore::RuleSet::addRule):
Removed specificity for @host @-rules. Now @host @-rules use the
cascading order instead.
* css/RuleSet.h:
Removed increaseSpecificity. The method is used by only @host @-rules.
* css/StyleResolver.cpp:
(WebCore::StyleResolver::matchScopedAuthorRules):
(WebCore::StyleResolver::matchHostRules):
(WebCore::StyleResolver::matchAuthorRules):
Modified to invoke sortAndTransferMatchedRules per scoping element.
The order of "matchXXXRules" must be the same as the cascading order.
So matchHostRules was invoked after collecting all scoped author rules.
* css/StyleScopeResolver.cpp:
(WebCore::StyleScopeResolver::addHostRule):
Removed RuleIsHostRule. We don't need the flag.
* html/HTMLStyleElement.cpp:
(WebCore::HTMLStyleElement::registerWithScopingNode):
Needs to pass the last test case of style-scoped-nested.html.
When appending some style element to a shadow root, we should recalc
styles of all elements in the shadow dom tree. And if the style
element has @host @-rules, we have to update the host's style.

LayoutTests:

* fast/css/style-scoped/style-scoped-nested-expected.txt: Added.
* fast/css/style-scoped/style-scoped-nested.html: Added.
* fast/css/style-scoped/style-scoped-with-important-rule-expected.txt: Added.
* fast/css/style-scoped/style-scoped-with-important-rule.html: Added.
* fast/regions/style-scoped-in-flow-override-region-styling-expected.html:
* fast/regions/style-scoped-in-flow-override-region-styling.html:
Changed the test's expectation.
Since @region's scoping element is :root but scoped styles' scoping
element is a descendant element of :root, scoped styles should win.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@137708 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Attempt to rationalize and simplify WTF::binarySearch
https://bugs.webkit.org/show_bug.cgi?id=104890

Reviewed by Maciej Stachowiak.

Source/JavaScriptCore: 

Switch to using the new binarySearch() API. No change in behavior.

* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::bytecodeOffset):
(JSC::CodeBlock::codeOriginForReturn):
* bytecode/CodeBlock.h:
(JSC::CodeBlock::getStubInfo):
(JSC::CodeBlock::getByValInfo):
(JSC::CodeBlock::getCallLinkInfo):
(JSC::CodeBlock::dfgOSREntryDataForBytecodeIndex):
(JSC::CodeBlock::valueProfileForBytecodeOffset):
(JSC::CodeBlock::rareCaseProfileForBytecodeOffset):
(JSC::CodeBlock::specialFastCaseProfileForBytecodeOffset):
* dfg/DFGGraph.h:
(JSC::DFG::Graph::blockIndexForBytecodeOffset):
* dfg/DFGMinifiedGraph.h:
(JSC::DFG::MinifiedGraph::at):
* dfg/DFGOSRExitCompiler32_64.cpp:
(JSC::DFG::OSRExitCompiler::compileExit):
* dfg/DFGOSRExitCompiler64.cpp:
(JSC::DFG::OSRExitCompiler::compileExit):
* llint/LLIntSlowPaths.cpp:
(JSC::LLInt::LLINT_SLOW_PATH_DECL):
* profiler/ProfilerBytecodeSequence.cpp:
(JSC::Profiler::BytecodeSequence::indexForBytecodeIndex):

Source/WebCore: 

Switch to using the new binarySearch() API. No change in behavior, so no new tests.

* svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::findInstanceTime):

Source/WTF: 

Binary search now has three modes:

The default: assert that the key was found, but return an adjacent element if it
wasn't found, if asserts are turned off.
        
tryBinarySearch: return 0 if the key wasn't found.
        
approximateBinarySearch: if the key is not found, return an adjacent element (either
the left or right; no guarantee which).
        
This also reduces the number of variants of binarySearch. The functor variant is now
gone because binarySearch now always uses a functor for the key extractor. The
generic variant is now gone because binarySearch always expects an array type that
can do operator[].

* wtf/StdLibExtras.h:
(WTF::binarySearchImpl):
(WTF::binarySearch):
(WTF::tryBinarySearch):
(WTF::approximateBinarySearch):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@137709 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[chromium] Add a virtual test suite for enabling opt-in to composited scrolling
https://bugs.webkit.org/show_bug.cgi?id=104911

Reviewed by Dirk Pranke.

Tools:

Adds two virtual tests suites to run the tests in
compositing/overflow/ and scrollbars/ with the flag
--enable-accelerated-overflow-scroll, which I've also plumbed through
in the usual way.

* DumpRenderTree/chromium/DumpRenderTree.cpp:
(main):
* DumpRenderTree/chromium/TestRunner/public/WebPreferences.h:
(WebPreferences):
* DumpRenderTree/chromium/TestRunner/src/WebPreferences.cpp:
(WebTestRunner::WebPreferences::reset):
(WebTestRunner::WebPreferences::applyTo):
* DumpRenderTree/chromium/TestShell.cpp:
(TestShell::TestShell):
(TestShell::resetWebSettings):
* DumpRenderTree/chromium/TestShell.h:
(TestShell::setAcceleratedCompositingForOverflowScrollEnabled):
(TestShell):
* Scripts/webkitpy/layout_tests/port/chromium.py:
(ChromiumPort.virtual_test_suites):

LayoutTests:

Updated the test expectations for the virtual test suite to match the
usual chromium test expectations.

* platform/chromium/TestExpectations:


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