Source/WebCore:
Add support to -webkit-line-break property for CSS3 Text line-break property values and semantics.
https://bugs.webkit.org/show_bug.cgi?id=89235

Reviewed by Eric Seidel and Dave Hyatt.

This patch adds semantic support for the CSS3 line-break property (qua -webkit-line-break),
and enables testing on (apple) mac ports. Follow on patches will enable these tests on
other ports as they are incrementally verified.

See also wiki documentation at:
[1] http://trac.webkit.org/wiki/LineBreaking
[2] http://trac.webkit.org/wiki/LineBreakingCSS3Mapping

Tests: css3/line-break/line-break-auto-centered.html
       css3/line-break/line-break-auto-half-kana.html
       css3/line-break/line-break-auto-hyphens.html
       css3/line-break/line-break-auto-inseparables.html
       css3/line-break/line-break-auto-iteration-marks.html
       css3/line-break/line-break-auto-postfixes.html
       css3/line-break/line-break-auto-prefixes.html
       css3/line-break/line-break-auto-sound-marks.html
       css3/line-break/line-break-loose-centered.html
       css3/line-break/line-break-loose-half-kana.html
       css3/line-break/line-break-loose-hyphens.html
       css3/line-break/line-break-loose-inseparables.html
       css3/line-break/line-break-loose-iteration-marks.html
       css3/line-break/line-break-loose-postfixes.html
       css3/line-break/line-break-loose-prefixes.html
       css3/line-break/line-break-loose-sound-marks.html
       css3/line-break/line-break-normal-centered.html
       css3/line-break/line-break-normal-half-kana.html
       css3/line-break/line-break-normal-hyphens.html
       css3/line-break/line-break-normal-inseparables.html
       css3/line-break/line-break-normal-iteration-marks.html
       css3/line-break/line-break-normal-postfixes.html
       css3/line-break/line-break-normal-prefixes.html
       css3/line-break/line-break-normal-sound-marks.html
       css3/line-break/line-break-strict-centered.html
       css3/line-break/line-break-strict-half-kana.html
       css3/line-break/line-break-strict-hyphens.html
       css3/line-break/line-break-strict-inseparables.html
       css3/line-break/line-break-strict-iteration-marks.html
       css3/line-break/line-break-strict-postfixes.html
       css3/line-break/line-break-strict-prefixes.html
       css3/line-break/line-break-strict-sound-marks.html

These tests were previously added in http://trac.webkit.org/changeset/143378, but skipped
in generic TestExpectations. In this patch, they are marked as Pass for the (apple) mac ports.

* platform/text/LineBreakIteratorPoolICU.h:
(WebCore::LineBreakIteratorPool::makeLocaleWithBreakKeyword):
Add static function to construct ICU locale argument (also used as pool key) with additional
break keyword.
(LineBreakIteratorPool):
(WebCore::LineBreakIteratorPool::take):
(WebCore::LineBreakIteratorPool::put):
Remove direct dependency from ICU library (and types), moving that dependency into
new {open,close}LineBreakIterator() functions (defined in TextBreakIteratorICU.cpp).
Update to take line break mode into account.
Create (and cache) different break iterators depending on line break mode (in addition to locale),
which entails expanding pool entry key format to optionally append "@break=" +
"loose"|"normal"|"strict" keyword to locale string.

* platform/text/TextBreakIterator.h:
(WebCore::LazyLineBreakIterator::LazyLineBreakIterator):
(WebCore::LazyLineBreakIterator::isLooseCJKMode):
(WebCore::LazyLineBreakIterator::get):
(WebCore::LazyLineBreakIterator::reset):
(LazyLineBreakIterator):
Define LineBreakIteratorMode enumeration for use in TextBreakIterator et al.
Add state member to indicate line break mode.

* platform/text/TextBreakIteratorICU.cpp:
(WebCore::acquireLineBreakIterator):
Use new line break mode when making iterator from pool.
Handle change of return type of LineBreakIteratorPool::take() to non-ICU type,
i.e., TextBreakIterator* instead of ICU's UBreakIterator*.
(WebCore::releaseLineBreakIterator):
Handle change of parameter type of LineBreakIteratorPool::put() to non-ICU type,
i.e., TextBreakIterator* instead of ICU's UBreakIterator*.
(WebCore):
(WebCore::isCJKLocale):
New functions for determining if CJK rules apply.
(WebCore::openLineBreakIterator):
New function for abstracting opening of ICU style line break iterator. This is now
used in LineBreakIteratorPoolICU.h rather than having direct ICU API dependency there.
This function also takes into account the line break mode.

Note that this function only calls ubrk_openRules() when the author has opted-in via
using the -webkit-line-break CSS property. Eventually, we would like to be able to
customize the rules that ICU's line breaking algorithm uses (especially for CJK text);
however, ubrk_openRules() currently parses its input string to create a DFA and is
therefore very slow. In fact, it's so slow that increasing our cache size in
LineBreakIteratorPool doesn't actually help enough. Also note that the default value
for the line-break CSS property is 'auto'.
(WebCore::closeLineBreakIterator):
(WebCore::mapLineIteratorModeToRules):
New function for abstracting closing of ICU style line break iterator. This is now
used in LineBreakIteratorPoolICU.h rather than having direct ICU API dependency there.

* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::LineBreaker::nextSegmentBreak):
Pass line break iterator mode flag when reseting LazyLineBreakIterator.
Add looseMode local variable to prevent need for computing under isBreakable().

* rendering/RenderText.cpp:
(WebCore::mapLineBreakToIteratorMode):
Add implementation for mapLineBreakToIteratorMode(), used by both RenderText::computePreferredLogicalWidths
and RenderBlock::LineBreaker::nextLineBreak.
(WebCore):
(WebCore::RenderText::computePreferredLogicalWidths):
Ensure (lazy line) breakIterator is initialized for line break mode.
Ensure isBreakable() is passed loose mode flag to match behavior in RenderBlock::LineBreaker::nextLineBreak.

* rendering/RenderText.h:
(WebCore):
Add declaration for mapLineBreakToIteratorMode(), used by both RenderText::computePreferredLogicalWidths
and RenderBlock::LineBreaker::nextLineBreak.

* rendering/break_lines.cpp:
(WebCore):
Introduce (local) enum NBSPBehavior for expanding template on nextBreakablePosition.
(WebCore::isBreakableSpace):
Add externally specified loose mode parameter to prevent need to invoke line break iterator
accessor method on each invocation. Use new loose mode flavors off NBP functions.
(WebCore::needsLineBreakIterator):
Use enum NBSP behavior template parameter rather than boolean.
(WebCore::nextBreakablePositionNonLoosely):
Extend name to distinguish from loose flavor of this function.
(WebCore::nextBreakablePositionLoosely):
Add loose flavor of NBP invoked only when loose mode applies, in which case ASCII shortcut
table cannot be used.
(WebCore::nextBreakablePosition):
(WebCore::nextBreakablePositionIgnoringNBSP):
Use (renamed) non-loose flavor of NBP.
(WebCore::nextBreakablePositionLoose):
(WebCore::nextBreakablePositionIgnoringNBSPLoose):
Introduce loose flavor of NBP template expansions.

* rendering/break_lines.h:
(WebCore):
(WebCore::isBreakable):
Add externally specified loose mode parameter to prevent need to invoke line break iterator
accessor method on each invocation.

LayoutTests:
CSS3: line-break property support
https://bugs.webkit.org/show_bug.cgi?id=89235

Reviewed by Eric Seidel and Dave Hyatt.

* platform/mac/TestExpectations: Mark css3/line-break tests as passing.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@176473 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Crashes while encoding a TextIndicator with no contentImageWithHighlight
https://bugs.webkit.org/show_bug.cgi?id=138984
<rdar://problem/19063717>

Reviewed by Sam Weinig.

* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<TextIndicatorData>::encode):
(IPC::ArgumentCoder<TextIndicatorData>::decode):
encodeImage doesn't deal with null images, so handle that case gracefully.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@176474 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Mac] Delay of 1-2s after the first paint of a video frame.
https://bugs.webkit.org/show_bug.cgi?id=138979

Reviewed by Eric Carlson.

Only bother waiting for a signal that a new image is ready when the image isn't ready in the first place.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@176475 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Mac] Random crashes inside media libraries when creating then destroying media quickly.
https://bugs.webkit.org/show_bug.cgi?id=138980

Reviewed by Eric Carlson.

Speculative fix for random crashes in the layout tests which occur randomly but regularly. The theory is
that creating-then-destroying our media objects too quickly triggers crashes deep within the media frameworks
when their initialization threads don't have a chance to complete before the main player object is destroyed.
Test out this theory by delaying the destruction of the AVPlayer object for 1s after its owner is destroyed.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::cancelLoad):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@176476 268f45cc-cd09-0410-ab3c-d52691b4dbfc
REGRESSION (r176351): Parts of apple.com/contact aren't Lookup-able
​https://bugs.webkit.org/show_bug.cgi?id=138960
<rdar://problem/19056715>

Reviewed by Anders Carlsson.

* UIProcess/mac/WKActionMenuController.mm:
(-[WKActionMenuController _defaultMenuItemsForDataDetectedText]):
(-[WKActionMenuController _defaultMenuItemsForMailtoLink]): Deleted.
* WebView/WebActionMenuController.mm:
(-[WebActionMenuController _defaultMenuItemsForMailtoLink]):
(-[WebActionMenuController _defaultMenuItemsForDataDetectedText]):
Use DataDetectors SPI instead of an explicit blacklist.

* platform/spi/mac/DataDetectorsSPI.h:
Add some DataDetectors SPI.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@176477 268f45cc-cd09-0410-ab3c-d52691b4dbfc
RenderElement::removeChild() doesn't need a return value.
<https://webkit.org/b/138985>

Reviewed by Pantti Koivisto.

Nobody uses the return value from RenderElement::removeChild().
Change it to return void and remove all the unnecessary plumbing.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::removeChild):
* rendering/RenderBlock.h:
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::removeChild):
* rendering/RenderBlockFlow.h:
* rendering/RenderButton.cpp:
(WebCore::RenderButton::removeChild):
* rendering/RenderButton.h:
* rendering/RenderElement.cpp:
(WebCore::RenderElement::removeChild):
(WebCore::RenderElement::removeChildInternal):
* rendering/RenderElement.h:
* rendering/RenderMenuList.cpp:
(RenderMenuList::removeChild):
* rendering/RenderMenuList.h:
* rendering/RenderRuby.cpp:
(WebCore::RenderRubyAsInline::removeChild):
(WebCore::RenderRubyAsBlock::removeChild):
* rendering/RenderRuby.h:
* rendering/RenderRubyRun.cpp:
(WebCore::RenderRubyRun::removeChild):
* rendering/RenderRubyRun.h:
* rendering/mathml/RenderMathMLRoot.cpp:
(WebCore::RenderMathMLRootWrapper::removeChildWithoutRestructuring):
(WebCore::RenderMathMLRootWrapper::removeChild):
* rendering/mathml/RenderMathMLRoot.h:
* rendering/mathml/RenderMathMLScripts.cpp:
(WebCore::RenderMathMLScripts::removeChildInternal):
(WebCore::RenderMathMLScripts::removeChild):
(WebCore::RenderMathMLScriptsWrapper::removeChildInternal):
(WebCore::RenderMathMLScriptsWrapper::removeChild):
* rendering/mathml/RenderMathMLScripts.h:
* rendering/svg/RenderSVGContainer.cpp:
(WebCore::RenderSVGContainer::removeChild):
* rendering/svg/RenderSVGContainer.h:
* rendering/svg/RenderSVGInline.cpp:
(WebCore::RenderSVGInline::removeChild):
* rendering/svg/RenderSVGInline.h:
* rendering/svg/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::removeChild):
* rendering/svg/RenderSVGRoot.h:
* rendering/svg/RenderSVGText.cpp:
(WebCore::RenderSVGText::removeChild):
* rendering/svg/RenderSVGText.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@176478 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Allocate local ScopeChain register
https://bugs.webkit.org/show_bug.cgi?id=138793

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

Now we allocate the scope register as a local.  The allocated register is stored in the 
CodeBlock for use by other components.  Update the DFG to work with a local scope register.
Changed usage of JSStack::ScopeChain access to the CallFrame header to use the allocated
local register.

* bytecode/BytecodeUseDef.h:
(JSC::computeUsesForBytecodeOffset):
(JSC::computeDefsForBytecodeOffset):
Updated to properly represent the operand inputs and bytecode result.

* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::CodeBlock):
* bytecode/CodeBlock.h:
(JSC::CodeBlock::setScopeRegister):
(JSC::CodeBlock::scopeRegister):
* bytecode/UnlinkedCodeBlock.h:
(JSC::UnlinkedCodeBlock::setScopeRegister):
(JSC::UnlinkedCodeBlock::scopeRegister):
Added scope register member and accessors.

* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::BytecodeGenerator):
(JSC::BytecodeGenerator::allocateAndEmitScope):
* bytecompiler/BytecodeGenerator.h:
(JSC::BytecodeGenerator::scopeRegister):
Change m_scopeRegister to an allocated register.  Added allocateAndEmitScope helper to
allocate the scope register, set the CodeBlock with its value and emit op_get_scope.

* debugger/DebuggerCallFrame.cpp:
(JSC::DebuggerCallFrame::scope): Changed to access the scope using the new convention.

* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::get):
(JSC::DFG::ByteCodeParser::flush):
(JSC::DFG::ByteCodeParser::inlineCall):
(JSC::DFG::ByteCodeParser::parseBlock):
Changed op_create_lexical_environment to set the scope VirtualRegister operand.
Filled out op_get_scope processing to emit a GetScope node putting the result in
the scope VirtualRegister result operand.
Added Phantoms where appropriate to keep the Scope register alive in places where
it use is optimized away, but where the baseline JIT would need to use its value.
Eliminated uses of JSStack::ScopeChain.

* dfg/DFGStackLayoutPhase.cpp:
(JSC::DFG::StackLayoutPhase::run):
Make sure that the scope register stack location is allocated using the same place
that the codeBlock expects. 

* dfg/DFGStrengthReductionPhase.cpp:
(JSC::DFG::StrengthReductionPhase::handleNode):
Allow strength reduction of Flush to skip of GetScope nodes looking for a prior
corresponding SetLocal.

* interpreter/CallFrame.h:
(JSC::ExecState::scope):
(JSC::ExecState::setScope):
Added new scope() and setScope() helpers that take a VirtualRegister offset.

* interpreter/Interpreter.cpp:
(JSC::eval):
Changed eval() to get the scope from the caller's scope register instead of from the
temporary frame created for eval.

* interpreter/Interpreter.cpp:
(JSC::Interpreter::unwind):
Changed unwind() to manipulate the scope n the allocated register instead of from the
call frame slot.

* interpreter/StackVisitor.cpp:
(JSC::StackVisitor::readNonInlinedFrame):
(JSC::StackVisitor::readInlinedFrame):
* interpreter/StackVisitor.h:
(JSC::StackVisitor::Frame::callee):
(JSC::StackVisitor::Frame::scope): Deleted.
Eliminated the scope member as it needed to change and no StackVisitor users use it.

* jit/JITOperations.cpp:
(JSC::operationPushNameScope):
(JSC::operationPushWithScope):
* runtime/JSNameScope.h:
(JSC::JSNameScope::create):
* runtime/JSWithScope.h:
(JSC::JSWithScope::create): Deleted.
* llint/LLIntSlowPaths.cpp:
(JSC::LLInt::LLINT_SLOW_PATH_DECL):
Deleted JSNameScope::create() and JSWithScope::create() flavors tht used the ScopeChain slot
in the CallFrame header.  Changed the only user of these function, op_push_name_scope and
op_push_with_scope helpers, to use the remaining create variants that require explicit scope.  
Those operations get the scope from the register pointed to by their scope operands.

* llint/LowLevelInterpreter32_64.asm:
* llint/LowLevelInterpreter64.asm:
Changed resolveScope to use the allocated register.

LayoutTests:

New test that sets a breakpoint in a callee of a DFG caller.  While stopped in the
breakpoint, it modifies a global via the scope chain of the DFG caller as well as
a local of the DFG caller.

* inspector-protocol/debugger/resources/breakpoint.js:
(notInlineable3):
(dfgWithoutInline3):
* inspector-protocol/debugger/setBreakpoint-dfg-callee-and-examine-dfg-local-expected.txt: Added.
* inspector-protocol/debugger/setBreakpoint-dfg-callee-and-examine-dfg-local.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@176479 268f45cc-cd09-0410-ab3c-d52691b4dbfc
REGRESSION (r176415): Can get stuck, unable to invoke any DataDetectors popovers
https://bugs.webkit.org/show_bug.cgi?id=138955
<rdar://problem/19056442>

Reviewed by Anders Carlsson.

* UIProcess/API/mac/WKView.mm:
(-[WKView mouseDown:]):
* UIProcess/mac/WKActionMenuController.h:
* UIProcess/mac/WKActionMenuController.mm:
(-[WKActionMenuController wkView:willHandleMouseDown:]):
(-[WKActionMenuController didCloseMenu:withEvent:]):
(-[WKActionMenuController menuNeedsUpdate:]):
Keep track of whether we have called shouldUseActionsWithContext: on a
DDActionContext; if we get a mouseDown without having seen didCloseMenu:
(and thus don't properly pair the shouldUseActionsWithContext: with a didUseActions),
tear down the old DDActionContext before proceeding.


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