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

Patch by Glenn Adams <glenn@skynav.com> on 2012-11-05
Reviewed by Eric Seidel.

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

Source/WebCore:

Web exposed changes include:
(1) The default (initial) value for -webkit-line-break becomes 'auto', instead of 'normal';
(2) The values 'auto', 'loose', 'normal', and 'strict' are added to -webkit-line-break;
(3) See [2] above for details regarding interpretation.

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

* platform/text/LineBreakIteratorPoolICU.h:
(WebCore::LineBreakIteratorPool::makeLocaleWithBreakKeyword):
Add static function to construct ICU locale argument (also used as pool key) with additional
break keyword.
(WebCore::LineBreakIteratorPool::take):
(WebCore::LineBreakIteratorPool::put):
(LineBreakIteratorPool):
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::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.
(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::nextLineBreak):
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::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 two (local) enums NBSPBehavior and LooseBehavior for expanding template on nextBreakablePosition
to include loose mode parameter.
(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):
Introduce loose mode behavior template parameter to optimize loose mode behavior code path in order
to prevent regression to non loose mode path.
(WebCore::nextBreakablePosition):
(WebCore::nextBreakablePositionIgnoringNBSP):
Use new template parameter enums described above.
(WebCore::nextBreakablePositionIgnoringNBSPLoose):
(WebCore::nextBreakablePositionLoose):
Introduce two additional 'loose' mode flavors 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/line-break-auto-centered-expected.html: Added.
* css3/line-break/line-break-auto-centered.html: Added.
* css3/line-break/line-break-auto-half-kana-expected.html: Added.
* css3/line-break/line-break-auto-half-kana.html: Added.
* css3/line-break/line-break-auto-hyphens-expected.html: Added.
* css3/line-break/line-break-auto-hyphens.html: Added.
* css3/line-break/line-break-auto-inseparables-expected.html: Added.
* css3/line-break/line-break-auto-inseparables.html: Added.
* css3/line-break/line-break-auto-iteration-marks-expected.html: Added.
* css3/line-break/line-break-auto-iteration-marks.html: Added.
* css3/line-break/line-break-auto-postfixes-expected.html: Added.
* css3/line-break/line-break-auto-postfixes.html: Added.
* css3/line-break/line-break-auto-prefixes-expected.html: Added.
* css3/line-break/line-break-auto-prefixes.html: Added.
* css3/line-break/line-break-auto-sound-marks-expected.html: Added.
* css3/line-break/line-break-auto-sound-marks.html: Added.
* css3/line-break/line-break-loose-centered-expected.html: Added.
* css3/line-break/line-break-loose-centered.html: Added.
* css3/line-break/line-break-loose-half-kana-expected.html: Added.
* css3/line-break/line-break-loose-half-kana.html: Added.
* css3/line-break/line-break-loose-hyphens-expected.html: Added.
* css3/line-break/line-break-loose-hyphens.html: Added.
* css3/line-break/line-break-loose-inseparables-expected.html: Added.
* css3/line-break/line-break-loose-inseparables.html: Added.
* css3/line-break/line-break-loose-iteration-marks-expected.html: Added.
* css3/line-break/line-break-loose-iteration-marks.html: Added.
* css3/line-break/line-break-loose-postfixes-expected.html: Added.
* css3/line-break/line-break-loose-postfixes.html: Added.
* css3/line-break/line-break-loose-prefixes-expected.html: Added.
* css3/line-break/line-break-loose-prefixes.html: Added.
* css3/line-break/line-break-loose-sound-marks-expected.html: Added.
* css3/line-break/line-break-loose-sound-marks.html: Added.
* css3/line-break/line-break-normal-centered-expected.html: Added.
* css3/line-break/line-break-normal-centered.html: Added.
* css3/line-break/line-break-normal-half-kana-expected.html: Added.
* css3/line-break/line-break-normal-half-kana.html: Added.
* css3/line-break/line-break-normal-hyphens-expected.html: Added.
* css3/line-break/line-break-normal-hyphens.html: Added.
* css3/line-break/line-break-normal-inseparables-expected.html: Added.
* css3/line-break/line-break-normal-inseparables.html: Added.
* css3/line-break/line-break-normal-iteration-marks-expected.html: Added.
* css3/line-break/line-break-normal-iteration-marks.html: Added.
* css3/line-break/line-break-normal-postfixes-expected.html: Added.
* css3/line-break/line-break-normal-postfixes.html: Added.
* css3/line-break/line-break-normal-prefixes-expected.html: Added.
* css3/line-break/line-break-normal-prefixes.html: Added.
* css3/line-break/line-break-normal-sound-marks-expected.html: Added.
* css3/line-break/line-break-normal-sound-marks.html: Added.
* css3/line-break/line-break-strict-centered-expected.html: Added.
* css3/line-break/line-break-strict-centered.html: Added.
* css3/line-break/line-break-strict-half-kana-expected.html: Added.
* css3/line-break/line-break-strict-half-kana.html: Added.
* css3/line-break/line-break-strict-hyphens-expected.html: Added.
* css3/line-break/line-break-strict-hyphens.html: Added.
* css3/line-break/line-break-strict-inseparables-expected.html: Added.
* css3/line-break/line-break-strict-inseparables.html: Added.
* css3/line-break/line-break-strict-iteration-marks-expected.html: Added.
* css3/line-break/line-break-strict-iteration-marks.html: Added.
* css3/line-break/line-break-strict-postfixes-expected.html: Added.
* css3/line-break/line-break-strict-postfixes.html: Added.
* css3/line-break/line-break-strict-prefixes-expected.html: Added.
* css3/line-break/line-break-strict-prefixes.html: Added.
* css3/line-break/line-break-strict-sound-marks-expected.html: Added.
* css3/line-break/line-break-strict-sound-marks.html: Added.

* platform/chromium/css3/line-break/line-break-auto-half-kana-expected.html: Added.
* platform/chromium/css3/line-break/line-break-auto-sound-marks-expected.html: Added.
Override reftest expectations on chromium due to different ICU auto behavior.

* platform/chromium-android/css3/line-break/line-break-auto-half-kana-expected.html: Added.
* platform/chromium-android/css3/line-break/line-break-auto-sound-marks-expected.html: Added.
Override override of reftest expectations on chromium due to different ICU auto behavior;
that is, chromium-android seems to follow the generic expectations.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@133529 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Begin stubbing out the new remote layer tree drawing area
https://bugs.webkit.org/show_bug.cgi?id=101256

Reviewed by Andreas Kling.

* Shared/DrawingAreaInfo.h:
* UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h:
* UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/WebPage/DrawingArea.cpp:
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h:
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@133530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Webkit does not handle some media keys correctly On Linux gtk platform.
https://bugs.webkit.org/show_bug.cgi?id=101221

Patch by Peng Huang <penghuang@google.com> on 2012-11-05
Reviewed by Alexey Proskuryakov.

Add media keyboard support on Linux gtk platform.

* platform/chromium/KeyCodeConversionGtk.cpp:
(WebCore::windowsKeyCodeForKeyEvent):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@133531 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[chromium] Unreviewed gardening.

* platform/chromium-mac-mountainlion/TestExpectations:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@133532 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Back out controversial changes from Bug 98665.
https://bugs.webkit.org/show_bug.cgi?id=101244

Patch by Dima Gorbik <dgorbik@apple.com> on 2012-11-05
Reviewed by David Kilzer.

Backing out changes from Bug 98665 until further discussions take place on rules for including Platform.h in Assertions.h.

Source/JavaScriptCore:

* API/tests/minidom.c:
* API/tests/testapi.c:

Source/WTF:

* wtf/Assertions.h:

Tools:

* DumpRenderTree/mac/MockGeolocationProvider.mm:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@133533 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Cleaned up the Font class in preparation for optimizing kerning and ligatures
https://bugs.webkit.org/show_bug.cgi?id=101258

Reviewed by Dan Bernstein.

* platform/graphics/Font.h:
(WebCore::Font::typesettingFeatures):
(WebCore::Font::computeTypesettingFeatures): Compute and cache our
typesetting features instead of recomputing each time a client asks
for them. This makes the class interface easier to use because
"typesettingFeatures()" can appear in more than one expression without
undue performance cost. This may also be a small speedup to code that
calls typesettingFeatures() often for other reasons.

* platform/graphics/Font.cpp:
(WebCore::Font::Font):
(WebCore::Font::operator=):
(WebCore::Font::update): Ditto.

(WebCore::Font::width): Unforked the width() function so all width-related
interfaces can benefit from optimization without duplicate code.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@133534 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed gardening. Mark fonts/cursive.html as flaky on MountainLion as well as Lion.
https://bugs.webkit.org/show_bug.cgi?id=83219

* platform/chromium/TestExpectations:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@133535 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://bugs.webkit.org/show_bug.cgi?id=101001
Pages with position:fixed elements should still be able to scroll on 
the scrolling thread
-and corresponding-
<rdar://problem/10857315>

Reviewed by Simon Fraser.

Source/WebCore: 

This patch adds two new classes. ScrollingStateFixedNode is a class 
to represent fixed nodes in the state tree, and 
ScrollingTreeFixedNode represents fixed node in the scrolling tree 
over on the scrolling thread.
* WebCore.xcodeproj/project.pbxproj:

When we are (non-programatically) scrolling fixed objects on the 
scrolling thread, we do not want to do any work here. 
* page/FrameView.cpp:
(WebCore::FrameView::updateFixedElementsAfterScrolling):

Whenever we sync the position of the main frame's layer, we have to 
do the same for scrolling tree children.
* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::ScrollingCoordinator::updateMainFrameScrollPosition):

New ScrollingNodeType -- FixedNode, yay! And two new functions 
specific to dealing with FixedNodes.
* page/scrolling/ScrollingCoordinator.h:
(WebCore::ScrollingCoordinator::updateViewportConstrainedNode):
(WebCore::ScrollingCoordinator::syncChildPositions):

This is the new class that represents fixed nodes in the state tree. 
All of the changed properties are stored within 
FixedPositionViewportConstraints.
* page/scrolling/ScrollingStateFixedNode.cpp: Added.
(WebCore):
(WebCore::ScrollingStateFixedNode::create):
(WebCore::ScrollingStateFixedNode::ScrollingStateFixedNode):
(WebCore::ScrollingStateFixedNode::~ScrollingStateFixedNode):
(WebCore::ScrollingStateFixedNode::updateConstraints):
(WebCore::ScrollingStateFixedNode::dumpProperties):
* page/scrolling/ScrollingStateFixedNode.h: Added.
(WebCore):
(ScrollingStateFixedNode):
(WebCore::ScrollingStateFixedNode::viewportConstraints):
(WebCore::toScrollingStateFixedNode):

Make sure to create the right type of clone for each node.
* page/scrolling/ScrollingStateNode.cpp:
(WebCore::ScrollingStateNode::cloneAndReset):

Now that m_children may be anything other than null, I found this 
bug. We encounter it when the parameter to removeChild is this and we 
want to remove all of our children. In that case, this is obviously 
not found in its own child array.
(WebCore::ScrollingStateNode::removeChild):

ScrollingStateNode now caches the GraphicsLayer in addition to the 
PlatformLayer. This will allow us to sync the GraphicsLayer position 
at the appropriate times.
* page/scrolling/ScrollingStateNode.h:
(WebCore::ScrollingStateNode::isScrollingStateFixedNode):
(WebCore::ScrollingStateNode::graphicsLayer):
(ScrollingStateNode):

Handle fixed nodes.
* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::updateTreeFromStateNode):

New function parentScrollPositionDidChange() is called on children 
when the parent has scrolled.
* page/scrolling/ScrollingTreeNode.h:
(ScrollingTreeNode):
* page/scrolling/ScrollingTreeScrollingNode.h:
(ScrollingTreeScrollingNode):

Return true for supportsFixedPositionLayers(). 
* page/scrolling/mac/ScrollingCoordinatorMac.h:
(ScrollingCoordinatorMac):

Handle fixed nodes.
* page/scrolling/mac/ScrollingCoordinatorMac.mm:
(WebCore::ScrollingCoordinatorMac::attachToStateTree):

Now that m_children can be non-null I caught this pre-existing bug 
where we would come times remove a node without updating the HashMap. 
This patch fixes that by consolidating the removal into one function.
(WebCore::ScrollingCoordinatorMac::removeNode):
(WebCore::ScrollingCoordinatorMac::detachFromStateTree):
(WebCore::ScrollingCoordinatorMac::clearStateTree):

Update the GraphicsLayers to reflect the new position that the 
Scrolling thread has moved the underlying CALayer to already.
(WebCore::ScrollingCoordinatorMac::syncChildPositions):

Pass new constraints over to the appropriate state node.
(WebCore::ScrollingCoordinatorMac::updateViewportConstrainedNode):

Cache the GraphicsLayer in addition to the PlatformLayer.
* page/scrolling/mac/ScrollingStateNodeMac.mm:
(WebCore::ScrollingStateNode::setScrollLayer):

Here is the new class that represents fixed nodes over on the 
scrolling thread. 
* page/scrolling/mac/ScrollingTreeFixedNode.h: Added.
(WebCore):
(ScrollingTreeFixedNode):
* page/scrolling/mac/ScrollingTreeFixedNode.mm: Added.
(WebCore):
(WebCore::ScrollingTreeFixedNode::create):
(WebCore::ScrollingTreeFixedNode::ScrollingTreeFixedNode):
(WebCore::ScrollingTreeFixedNode::~ScrollingTreeFixedNode):
(WebCore::ScrollingTreeFixedNode::update):

This is where the magic happens. re-position the fixed object when 
its parent has scrolled so that it appears to have not moved at all.
(WebCore::ScrollingTreeFixedNode::parentScrollPositionDidChange):

Whenever we change the position of a scrolling layer, tell our 
children.
* page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm:
(WebCore::ScrollingTreeScrollingNodeMac::setScrollLayerPosition):

Handle fixed nodes.
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::attachToScrollingCoordinator):

detachFromScrollingCoordinator() needs to be public so that it can be 
called from RenderLayerCompositor for fixed nodes.
* rendering/RenderLayerBacking.h:
(RenderLayerBacking):

RenderLayerCompositor takes control of attaching and detaching fixed 
nodes to/from the ScrollingCoordinator. 
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::flushPendingLayerChanges):
(WebCore::RenderLayerCompositor::didFlushChangesForLayer):
(WebCore::RenderLayerCompositor::updateBacking):
(WebCore::RenderLayerCompositor::layerWillBeRemoved):
(WebCore::RenderLayerCompositor::didMoveOnscreen):
(WebCore::RenderLayerCompositor::willMoveOffscreen):
(WebCore::RenderLayerCompositor::clearBackingForLayerIncludingDescendants):
(WebCore::isRootmostFixedOrStickyLayer):
(WebCore):
(WebCore::RenderLayerCompositor::updateViewportConstraintStatus):
(WebCore::RenderLayerCompositor::addViewportConstrainedLayer):
(WebCore::RenderLayerCompositor::removeViewportConstrainedLayer):
(WebCore::RenderLayerCompositor::computeViewportConstraints):
(WebCore::nearestScrollingCoordinatorAncestor):
(WebCore::RenderLayerCompositor::registerOrUpdateViewportConstrainedLayer):
(WebCore::RenderLayerCompositor::unregisterViewportConstrainedLayer):
(WebCore::RenderLayerCompositor::registerAllViewportConstrainedLayers):
(WebCore::RenderLayerCompositor::unregisterAllViewportConstrainedLayers):
* rendering/RenderLayerCompositor.h:
(WebCore):
(RenderLayerCompositor):

LayoutTests: 

New tests.
* platform/mac/tiled-drawing/fixed: Added.
* platform/mac/tiled-drawing/fixed/absolute-inside-fixed-expected.txt: Added.
* platform/mac/tiled-drawing/fixed/absolute-inside-fixed.html: Added.
* platform/mac/tiled-drawing/fixed/fixed-position-out-of-view-expected.txt: Added.
* platform/mac/tiled-drawing/fixed/fixed-position-out-of-view-negative-zindex-expected.txt: Added.
* platform/mac/tiled-drawing/fixed/fixed-position-out-of-view-negative-zindex.html: Added.
* platform/mac/tiled-drawing/fixed/fixed-position-out-of-view.html: Added.
* platform/mac/tiled-drawing/fixed/four-bars-expected.txt: Added.
* platform/mac/tiled-drawing/fixed/four-bars.html: Added.
* platform/mac/tiled-drawing/fixed/nested-fixed-expected.txt: Added.
* platform/mac/tiled-drawing/fixed/nested-fixed.html: Added.
* platform/mac/tiled-drawing/fixed/percentage-inside-fixed-expected.txt: Added.
* platform/mac/tiled-drawing/fixed/percentage-inside-fixed.html: Added.

These two tests are supposed to be in "slow scrolling" mode. Now that 
fixed elements can scroll "fast," we need something else to force 
slow scrolling. We should probably just add something to 
window.internals to do that, but in the meantime, 
background-attachment:fixed will work.
* platform/mac/tiled-drawing/scrolling-tree-slow-scrolling-expected.txt:
* platform/mac/tiled-drawing/scrolling-tree-slow-scrolling.html:
* platform/mac/tiled-drawing/tile-coverage-slow-scrolling-expected.txt:
* platform/mac/tiled-drawing/tile-coverage-slow-scrolling.html:



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