Properly reset UStringSearch object in SearchBuffer constructor.
https://bugs.webkit.org/show_bug.cgi?id=133662
<rdar://problem/17240136>

Reviewed by Tim Horton.

* editing/TextIterator.cpp: (WebCore::SearchBuffer::~SearchBuffer):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@169726 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[iOS] Expose _WKWebViewPrintFormatter and -_webView:printFrame: as SPI
https://bugs.webkit.org/show_bug.cgi?id=133600

Reviewed by David Kilzer.

Expose -_webView:printFrame: in WKUIDelegatePrivate so that clients can implement support for window.print().
Since window.print() can be called from a subframe, expose _WKWebViewPrintFormatter (renamed from
WKWebViewPrintFormatter to reflect its new SPI status) as SPI and add a frameToPrint property.

* UIProcess/API/Cocoa/WKUIDelegatePrivate.h: Forward-declared _WKFrameHandle and declared -_webView:printFrame:.
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _webViewPrintFormatter]): Added to get a _WKWebViewPrintFormatter.
(-[WKWebView _printFormatterClass]): Updated the class name to _WKWebViewPrintFormatter.
(-[WKWebView _computePageCountAndStartDrawingToPDFForFrame:printInfo:WebKit::firstPage:computedTotalScaleFactor:]):
Added a frame argument. If frame is nil, print the main frame.
(-[WKWebView _computePageCountAndStartDrawingToPDFWithPrintInfo:WebKit::firstPage:computedTotalScaleFactor:]): Deleted.
* UIProcess/API/Cocoa/WKWebViewInternal.h: Forward-declared _WKFrameHandle; removed an unneccessary
forward-declaration of WKWebViewPrintFormatter.
* UIProcess/API/Cocoa/WKWebViewPrivate.h: Added a _webViewPrintFormatter property.
* UIProcess/Cocoa/UIDelegate.h:
* UIProcess/Cocoa/UIDelegate.mm:
(WebKit::UIDelegate::setDelegate):
(WebKit::UIDelegate::UIClient::printFrame): Called -_webView:printFrame:.
* UIProcess/_WKWebViewPrintFormatter.h: Renamed from Source/WebKit2/UIProcess/WKWebViewPrintFormatter.h.
* UIProcess/_WKWebViewPrintFormatter.mm: Renamed from Source/WebKit2/UIProcess/WKWebViewPrintFormatter.mm.
* WebKit2.xcodeproj/project.pbxproj:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@169727 268f45cc-cd09-0410-ab3c-d52691b4dbfc
iOS WebKit: Crash in charactersAroundPosition.
https://bugs.webkit.org/show_bug.cgi?id=133659
<rdar://problem/17220870>

Reviewed by Benjamin Poulain.


Source/WebCore: 
Ensure that we stay within the vector boundaries
when returning the characters around the position.

* editing/VisibleUnits.cpp:
(WebCore::charactersAroundPosition):

Source/WebKit2: 
We only need to compute charactersAroundPosition when we are in
editable content.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::editorState):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@169728 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Document::updateStyleIfNeededForNode can get very expensive
https://bugs.webkit.org/show_bug.cgi?id=133599

Patch by Benjamin Poulain <bpoulain@apple.com> on 2014-06-09
Reviewed by Andreas Kling.

When pages are querying their style, we first run through
Document::updateStyleIfNeededForNode() to find if that particular node needs style recalc.

The problem was that updateStyleIfNeededForNode() could get really expensive. For each node,
it needs to check the whole parent chain to find if any needs style recalc.
When web pages get a bunch of nodes and querying their style, we ended up going over a lot
of nodes just to find there is nothing to do.

This patch adds two tweaks to reduce the problem:
First, before querying nodeOrItsAncestorNeedsStyleRecalc() we check if the Document is dirty at all.
The other part is making nodeOrItsAncestorNeedsStyleRecalc() faster by removing useless elements check.

* dom/Document.cpp:
(WebCore::nodeOrItsAncestorNeedsStyleRecalc):
(WebCore::Document::updateStyleIfNeededForNode):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@169729 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[iOS WebGL] Fix EXT_shader_texture_lod.
https://bugs.webkit.org/show_bug.cgi?id=133633

Patch by Alex Christensen <achristensen@webkit.org> on 2014-06-09
Reviewed by Brady Eidson.

Covered by the Khronos test (and in LayoutTests):
conformance/extensions/ext-shader-texture-lod.html

* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::getExtension):
(WebCore::WebGLRenderingContext::getSupportedExtensions):
Added shader texture lod name to match value from glGetString(GL_EXTENSIONS) on iOS.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@169730 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Improve CSSPrimitiveValue::customCSSText for ARMv7
https://bugs.webkit.org/show_bug.cgi?id=133597

Patch by Benjamin Poulain <bpoulain@apple.com> on 2014-06-09
Reviewed by Andreas Kling.


Source/WebCore: 
On imgur, some script is updating some layout on timers and on scroll.

It looks like CSSPrimitiveValue::customCSSText() is a little constrained
by the instruction cache on ARMv7. This patch improve the situation a bit.

First, the creation of the string itself is changed to go from two allocation to one.
Previously, we would allocate a StringBuffer and adopt it. Now we allocate a StringImpl
directly with the inline buffer.

The second issue is that the compiler was generating a real copy constructor for every
assignment of the "text" variable (likely because the variable span is so large).
This was solved by moving the string creating into a separate function (to fix the span)
and being careful with passing PassRef<StringImpl> around.

Then there was the problem that the compiler was a little too aggressive with inlining
which caused each "case" to repeat the same prologue and epilogue before formatValue().
This was solved by adding formatNumberValue() with NEVER_INLINE to have the prologue/epilogue
in a single place.

On older device, that's about 3% improvement on style access. On modern ARM64/x86_64
there is no noticeable difference.

* css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::formatNumberValue):
(WebCore::CSSPrimitiveValue::formatNumberForcustomCSSText):
(WebCore::CSSPrimitiveValue::customCSSText):
(WebCore::formatNumber): Deleted.
* css/CSSPrimitiveValue.h:

Source/WTF: 
* wtf/RefPtr.h:
(WTF::RefPtr<T>::RefPtr):
* wtf/text/WTFString.h:
(WTF::String::String):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@169731 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Give callbacks real status codes
https://bugs.webkit.org/show_bug.cgi?id=133668

Reviewed by Dan Bernstein.

This makes it possible to know whether a callback was invalidated due to the webpage being closed,
or whether it was due the a web process crash.

* UIProcess/GenericCallback.h:
(WebKit::GenericCallback::create):
(WebKit::GenericCallback::performCallbackWithReturnValue):
(WebKit::GenericCallback::invalidate):
(WebKit::invalidateCallbackMap):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::close):
(WebKit::WebPageProxy::resetState):
(WebKit::WebPageProxy::resetStateAfterProcessExited):
* UIProcess/WebPageProxy.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@169732 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Work towards having frames in the scrolling tree
https://bugs.webkit.org/show_bug.cgi?id=133665

Reviewed by Tim Horton.

Source/WebCore:
Optionally (based on Setting) create nodes in the scrolling tree for frames which
contain async-scrollable content. This will be used on iOS/WK2 to support accelerated
overflow-scroll in iframes. The setting allows for testing on OS X.

The change breaks an assumption in ScrollingCoordinator/AsyncScrollingCoordinator
that we're always dealing with the main frame, and changes logic in RenderLayerCompositor
so that we can connect the scrolling tree across frame boundaries. RenderLayerCompositor
maintains a m_subframeScrollLayersNeedReattach flag that gets set whenever we add or remove
scroll-coordinated layers in the current frame. When set, after updating compositing
layers we walk child frames, and, if they have scrolling nodes, re-attach them to the
scrolling tree (which will find the new ancestor node).

Tests: platform/mac-wk2/tiled-drawing/scrolling/frames/coordinated-frame-in-fixed.html
       platform/mac-wk2/tiled-drawing/scrolling/frames/coordinated-frame.html

* WebCore.exp.in:
* page/FrameView.cpp:
(WebCore::FrameView::scrollLayerID): Use the new "for role" way of getting the node ID.
* page/Settings.cpp:
* page/Settings.in: Add scrollingTreeIncludesFrames.
* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::frameViewLayoutUpdated):
(WebCore::AsyncScrollingCoordinator::frameViewNonFastScrollableRegionChanged): Only set
the region for the main frame.
(WebCore::AsyncScrollingCoordinator::frameViewForScrollingNode): updateScrollPositionAfterAsyncScroll()
needs to know which FrameView a given nodeID is hosted in; doing a walk of the frame tree for
non-main frames seems to be the safest way.
(WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll):
(WebCore::AsyncScrollingCoordinator::syncChildPositions):
* page/scrolling/AsyncScrollingCoordinator.h:
* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::ScrollingCoordinator::coordinatesScrollingForFrameView): Consult the new setting.
(WebCore::ScrollingCoordinator::frameViewHasSlowRepaintObjectsDidChange):
(WebCore::ScrollingCoordinator::frameViewFixedObjectsDidChange):
(WebCore::ScrollingCoordinator::frameViewRootLayerDidChange):
(WebCore::ScrollingCoordinator::synchronousScrollingReasons):
(WebCore::ScrollingCoordinator::updateSynchronousScrollingReasons):
(WebCore::ScrollingCoordinator::setForceSynchronousScrollLayerPositionUpdates):
(WebCore::ScrollingCoordinator::shouldUpdateScrollLayerPositionSynchronously):
(WebCore::ScrollingCoordinator::replaySessionStateDidChange):
(WebCore::ScrollingCoordinator::synchronousScrollingReasonsAsText):
* page/scrolling/ScrollingCoordinator.h:
(WebCore::ScrollingCoordinator::shouldUpdateScrollLayerPositionSynchronously): Deleted.
* rendering/RenderLayerBacking.h: Rather than separate functions to get the two scrolling
node IDs, having one scrollingNodeIDForRole() makes calling code cleaner.
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::RenderLayerCompositor):
(WebCore::RenderLayerCompositor::updateCompositingLayers):  call reattachSubframeScrollLayers()
after a compositing tree update.
(WebCore::RenderLayerCompositor::isAsyncScrollableStickyLayer): Deals with the various configurations
in which we can do async scrolling of sticky elements.
(WebCore::RenderLayerCompositor::isViewportConstrainedFixedOrStickyLayer):
(WebCore::useCoordinatedScrollingForLayer):
(WebCore::RenderLayerCompositor::requiresCompositingForPosition):
(WebCore::RenderLayerCompositor::requiresCompositingForScrolling): Moved.
(WebCore::RenderLayerCompositor::notifyIFramesOfCompositingChange): This is a bug fix;
we only need to notify child frames, not all descendant frames.
(WebCore::RenderLayerCompositor::updateScrollCoordinatedStatus):
(WebCore::RenderLayerCompositor::removeFromScrollCoordinatedLayers):
(WebCore::enclosingScrollingNodeID):
(WebCore::scrollCoordinatedAncestorInParentOfFrame):
(WebCore::RenderLayerCompositor::reattachSubframeScrollLayers):
(WebCore::RenderLayerCompositor::attachScrollingNode):
(WebCore::RenderLayerCompositor::updateScrollCoordinationForThisFrame):
(WebCore::RenderLayerCompositor::updateScrollCoordinatedLayer):
(WebCore::RenderLayerCompositor::detachScrollCoordinatedLayer):
(WebCore::RenderLayerCompositor::registerAllViewportConstrainedLayers):
(WebCore::RenderLayerCompositor::willRemoveScrollingLayer):
(WebCore::isStickyInAcceleratedScrollingLayerOrViewport): Deleted.
(WebCore::isViewportConstrainedFixedOrStickyLayer): Deleted.
(WebCore::isMainFrameScrollingOrOverflowScrolling): Deleted.
(WebCore::nearestScrollCoordinatedAncestor): Deleted.
* rendering/RenderLayerCompositor.h:
* rendering/RenderView.cpp:
(WebCore::RenderView::setSelection): Added comment.
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::setScrollingTreeIncludesFrames):
* testing/InternalSettings.h: Removed some useless parameter names.
* testing/InternalSettings.idl: Added setScrollingTreeIncludesFrames() setting.

Source/WebKit2:
Override coordinatesScrollingForFrameView() to always return true for composited
frames, for iOS WK2 (eventually this class will have to be specialized for iOS and OS X).

* WebProcess/Scrolling/RemoteScrollingCoordinator.h:
* WebProcess/Scrolling/RemoteScrollingCoordinator.mm:
(WebKit::RemoteScrollingCoordinator::coordinatesScrollingForFrameView):

LayoutTests:
Tests that dump the scrolling tree with subframes.

* platform/mac-wk2/tiled-drawing/scrolling/frames/coordinated-frame-expected.txt: Added.
* platform/mac-wk2/tiled-drawing/scrolling/frames/coordinated-frame-in-fixed-expected.txt: Added.
* platform/mac-wk2/tiled-drawing/scrolling/frames/coordinated-frame-in-fixed.html: Added.
* platform/mac-wk2/tiled-drawing/scrolling/frames/coordinated-frame.html: Added.
* platform/mac-wk2/tiled-drawing/scrolling/frames/resources/doc-with-sticky.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@169733 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Debug build fix after r169731.

* css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::formatNumberValue):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@169734 268f45cc-cd09-0410-ab3c-d52691b4dbfc
REGRESSION: Web Inspector: Exception showing the DOM tree for a node with too many children
https://bugs.webkit.org/show_bug.cgi?id=129696

Fix issue where sometimes inspecting an element will try to attach the "show all nodes" button
before the expand function is called in TreeElement before _childrenListNode has been set.

Patch by Jono Wells <jonowells@apple.com> on 2014-06-09
Reviewed by Joseph Pecoraro.

* UserInterface/Views/TreeOutline.js:
(TreeOutline.prototype.appendChild):
(TreeOutline.prototype.insertChild):
Added check for existance of this._childrenListNode.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@169735 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Commit the right fix.

* css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::formatNumberValue):



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

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::resetState):

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