Use the Selector Code Generator for matching in SelectorQuery
https://bugs.webkit.org/show_bug.cgi?id=126185

Reviewed by Ryosuke Niwa.

Source/WebCore: 

Compile selectors on demand and use the generated binary to perform
element matching in SelectorQuery.

Tests: fast/selectors/querySelector-long-adjacent-backtracking.html
       fast/selectors/querySelector-long-child-backtracking.html
       fast/selectors/querySelector-mixed-child-adjacent-backtracking.html
       fast/selectors/querySelector-multiple-simple-child-backtracking.html
       fast/selectors/querySelector-simple-adjacent-backtracking.html
       fast/selectors/querySelector-simple-child-backtracking.html

* dom/SelectorQuery.cpp:
(WebCore::SelectorDataList::executeCompiledSimpleSelectorChecker):
(WebCore::SelectorDataList::executeCompiledSelectorCheckerWithContext):
(WebCore::SelectorDataList::execute):
* dom/SelectorQuery.h:

LayoutTests: 

Add some tests for longer backtracking cases typically not covered by the other tests.

* fast/selectors/querySelector-long-adjacent-backtracking-expected.txt: Added.
* fast/selectors/querySelector-long-adjacent-backtracking.html: Added.
* fast/selectors/querySelector-long-child-backtracking-expected.txt: Added.
* fast/selectors/querySelector-long-child-backtracking.html: Added.
* fast/selectors/querySelector-mixed-child-adjacent-backtracking-expected.txt: Added.
* fast/selectors/querySelector-mixed-child-adjacent-backtracking.html: Added.
* fast/selectors/querySelector-multiple-simple-child-backtracking-expected.txt: Added.
* fast/selectors/querySelector-multiple-simple-child-backtracking.html: Added.
* fast/selectors/querySelector-simple-adjacent-backtracking-expected.txt: Added.
* fast/selectors/querySelector-simple-adjacent-backtracking.html: Added.
* fast/selectors/querySelector-simple-child-backtracking-expected.txt: Added.
* fast/selectors/querySelector-simple-child-backtracking.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@161839 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Reduce use of String::characters
https://bugs.webkit.org/show_bug.cgi?id=126854

Reviewed by Sam Weinig.

Source/JavaScriptCore:

* API/JSValueRef.cpp:
(JSValueMakeFromJSONString): Use characters16 instead of characters for 16-bit case.
Had to remove length check because an empty string could be either 8 bit or 16 bit.
Don't need a null string check before calling is8Bit because JSStringRef can't hold
a null string.

* bindings/ScriptValue.cpp:
(Deprecated::jsToInspectorValue): Use the existing string here instead of creating
a new one by calling characters and length on the old string. I think this may be
left over from when string types were not the same in JavaScriptCore and WebCore.
Also rewrite the property names loop to use modern for syntax and fewer locals.

* inspector/InspectorValues.cpp:
(Inspector::escapeChar): Changed to use appendLiteral instead of hard-coding string
lengths. Moved handling of "<" and ">" in here instead of at the call site.
(Inspector::doubleQuoteString): Simplify the code so there is no use of characters
and length. This is still an inefficient way of doing this job and could use a rethink.

* runtime/DatePrototype.cpp:
(JSC::formatLocaleDate): Use RetainPtr, createCFString, and the conversion from
CFStringRef to WTF::String to remove a lot of unneeded code.

* runtime/Identifier.h: Removed unneeded Identifier::characters function.

* runtime/JSStringBuilder.h:
(JSC::JSStringBuilder::append): Use characters16 instead of characters function here,
since we have already checked is8Bit above.

Source/WebCore:

* bindings/objc/WebScriptObject.mm:
(+[WebScriptObject _convertValueToObjcValue:JSC::originRootObject:rootObject:]):
Get rid of unneeded code to turn a WTF::String into an NSString, since that's
built into the WTF::String class.

* editing/CompositeEditCommand.cpp:
(WebCore::containsOnlyWhitespace): Use WTF::String's [] operator instead of
an explicit call to the characters function. Small performance cost.
* editing/TypingCommand.cpp:
(WebCore::TypingCommand::insertText): Ditto.

* editing/VisibleUnits.cpp:
(WebCore::startOfParagraph): Use reverseFind instead of writing our own loop.
(WebCore::endOfParagraph): Use find instead of writing our own loop.

* html/parser/HTMLParserIdioms.cpp:
(WebCore::stripLeadingAndTrailingHTMLSpaces): Use characters16 instead of
characters since we have already checked is8Bit.
(WebCore::parseHTMLNonNegativeInteger): Ditto. Replace the length check with
a check of isNull since a zero length string could be 8 bit, but it's not
safe to call is8Bit on a null WTF::String. (That should probably be fixed.)

* inspector/ContentSearchUtils.cpp:
(WebCore::ContentSearchUtils::createSearchRegexSource): Use StringBuilder
instead of String in code that builds up a string one character at a time.
The old way was ridiculously slow because it allocated a new string for every
character; the new way still isn't all that efficient, but it's better. Also
changed to use strchr instead of WTF::String::find for special characters.

* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyle::newLineAndWhitespaceDelimiters): Use WTF::String's
[] operator instead of an explicit call to the characters function.
* inspector/InspectorStyleTextEditor.cpp:
(WebCore::InspectorStyleTextEditor::insertProperty): Ditto.
(WebCore::InspectorStyleTextEditor::internalReplaceProperty): Ditto.
* platform/Length.cpp:
(WebCore::newCoordsArray): Ditto.

* platform/LinkHash.cpp:
(WebCore::visitedLinkHash): Use characters16 instead of characters since
we have already checked is8Bit. Replace the length check with a check of
isNull (as above in parseHTMLNonNegativeInteger).

* platform/graphics/Color.cpp:
(WebCore::Color::parseHexColor): Use characters16 since we already checked is8Bit.
(WebCore::Color::Color): Ditto.

* platform/graphics/TextRun.h:
(WebCore::TextRun::TextRun): Use characters16 instead of characters since
we have already checked is8Bit. Replace the length check with a check of
isNull (as above in parseHTMLNonNegativeInteger).

* platform/text/TextEncodingRegistry.cpp:
(WebCore::atomicCanonicalTextEncodingName): Use characters16 instead of
characters since we already checked is8Bit. Also use isEmpty instead of !length.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::constructTextRun): Use characters16 instead of characters
since we have already checked is8Bit. Replace the length check with a check of
isNull (as above in parseHTMLNonNegativeInteger).

* rendering/RenderCombineText.cpp:
(WebCore::RenderCombineText::width): Check for zero length instead of checking
for null characters.

* svg/SVGFontElement.cpp:
(WebCore::SVGFontElement::registerLigaturesInGlyphCache): Rewrite ligatures
for loop and give local variables a better name. Construct the substring with
the substring function. Still a really inefficient approach -- allocating a new
string for every character is absurdly expensive.

* xml/XPathFunctions.cpp:
(WebCore::XPath::FunId::evaluate): Use String instead of StringBuilder. Still
not all that efficient, but better than before. Use substring to construct the
substring.

* xml/XPathNodeSet.h: Added begin and end functions so we can use a C++11 for
loop with this class.

Source/WTF:

* wtf/text/StringImpl.cpp:
(WTF::StringImpl::replace): Use characters16 here since is8Bit was already checked.
* wtf/text/WTFString.h:
(WTF::String::isAllSpecialCharacters): Use characters16 here since is8Bit was
already checked. Also renamed "len" to "length".

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@161840 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Fix the Mac build after r161777.

* gtest/xcode/Config/General.xcconfig: AspenFamily.xcconfig excludes
macosx from SUPPORTED_PLATFORMS, so add it back in ourselves.

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