Tiles on bottom of screen are not always allocated when necessary
https://bugs.webkit.org/show_bug.cgi?id=134272

Reviewed by Simon Fraser.

Source/WebCore:
The initial visibleRect is in the coordinate of the root layer, so its origin
is at the top left of the view. The initial rect we were using doesn't
include the contents inset, so it was too short, which was causing tiles near
the bottom of the screen to not always be allocated if the tile threshold was
close to the bottom of the view. Instead, we want to include the contents
inset size so the visible rect includes the entire view.
GraphicsLayerCA::recursiveCommitChanges() takes care of mapping and cropping
the visible rect into the tiled layer's coordinate system, at which point it
is used for visible tile logic.

Test: platform/mac-wk2/tiled-drawing/visible-rect-content-inset.html

* platform/graphics/ca/TileCoverageMap.cpp:
(WebCore::TileCoverageMap::update):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::flushPendingLayerChanges):

LayoutTests:
Apply a content inset, then dump visible rects.

* platform/mac-wk2/tiled-drawing/visible-rect-content-inset-expected.txt: Added.
* platform/mac-wk2/tiled-drawing/visible-rect-content-inset.html: Added.
* compositing/visible-rect/iframe-no-layers.html: For WK2, the size of the visibleRect
includes the size of the border of the iframe. In order to elliminate platform
differences, set this border to 0.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Use non-thumb registers in armv7 css jit.
https://bugs.webkit.org/show_bug.cgi?id=134450

Reviewed by Geoff Garen.

* cssjit/RegisterAllocator.h:
(WebCore::RegisterAllocator::isValidRegister):
(WebCore::RegisterAllocator::isCallerSavedRegister):
Use additional general purpose registers.
* cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::SelectorCodeGenerator::compile):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateSelectorChecker):
Always succeed when compiling css selectors.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170598 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Add code for encoding legacy session history entries
https://bugs.webkit.org/show_bug.cgi?id=134452

Reviewed by Andreas Kling.

Source/WebKit2:
* UIProcess/mac/LegacySessionStateCoding.cpp:
(WebKit::HistoryEntryDataEncoder::HistoryEntryDataEncoder):
(WebKit::HistoryEntryDataEncoder::operator<<):
(WebKit::HistoryEntryDataEncoder::finishEncoding):
(WebKit::HistoryEntryDataEncoder::encodeArithmeticType):
(WebKit::HistoryEntryDataEncoder::encodeFixedLengthData):
(WebKit::HistoryEntryDataEncoder::grow):
(WebKit::HistoryEntryDataEncoder::growCapacity):
(WebKit::encodeFrameStateNode):
(WebKit::encodeLegacySessionHistoryEntryData):
(WebKit::decodeSessionHistoryEntryData):
(WebKit::decodeLegacySessionHistoryEntryData):
* UIProcess/mac/LegacySessionStateCoding.h:

Source/WTF:
* wtf/MallocPtr.h:
(WTF::MallocPtr::malloc):
(WTF::MallocPtr::realloc):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170599 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[iOS][WK2] Move tap highlight to the inverseScaleRootView
https://bugs.webkit.org/show_bug.cgi?id=134424
<rdar://problem/17480880>

Patch by Benjamin Poulain <bpoulain@apple.com> on 2014-06-30
Reviewed by Tim Horton.

Enrica introduced the inverseScaleRootView that is a dynamic version of _highlightRootView.

This patch moves the tap highlight from its own inverse root to inverseScaleRootView. This provides better handling
of scale, better behavior on crash, and remove one extra view from the hierarchy.

The code is pretty much the same, just moved around. Some of the changes:

Now the code needs to handle repainting live when the view scale. To do that, _showTapHighlightXXX was split in two:
-_showTapHighlight to setup the view.
-_updateTapHighlight to update the view based on the current scale.

Since the view updates live on scaling, we need to recompute the coordinates for each update. To do that, the _potentialTapHighlightInformation
was generalized to handle all cases of highlight.

Since we can no longer test for the nullity of _potentialTapHighlightInformation,
a new attribute is introduced for that: _hasTapHighlightForPotentialTap.

The last bit of change concern reentering the tap highlight. This becomes quite simple:
1) _isTapHighlightIDValid is updated before the animation starts
   so that it can be set again during an animation.
2) The animation checks the "finished" flags before removing the view from its superview
   to avoid breaking the new animation.

* UIProcess/API/Cocoa/WKWebView.mm:
(withinEpsilon): Deleted.
* UIProcess/ios/WKContentView.mm:
(-[WKContentView didUpdateVisibleRect:unobscuredRect:unobscuredRectInScrollViewCoordinates:scale:minimumScale:inStableState:isChangingObscuredInsetsInteractively:]):
Make _updateUnscaledView conditional to scale changes, that thing isn't cheap!

* UIProcess/ios/WKContentViewInteraction.h:
(withinEpsilon):
Move withinEpsilon() from WKContentView to use it from both classes.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView cleanupInteraction]):
(-[WKContentView _updateUnscaledView]):
(-[WKContentView _updateTapHighlight]):
(-[WKContentView _showTapHighlight]):
(-[WKContentView _didGetTapHighlightForRequest:color:quads:topLeftRadius:topRightRadius:bottomLeftRadius:bottomRightRadius:]):
(-[WKContentView _cancelInteraction]):
(-[WKContentView _finishInteraction]):
(-[WKContentView _singleTapDidReset:]):
(-[WKContentView _singleTapCommited:]):
(-[WKContentView _showTapHighlightWithColor:quads:topLeftRadius:topRightRadius:bottomLeftRadius:bottomRightRadius:]): Deleted.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170600 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Add option to run-jsc-stress-testes to filter out tests that use large heaps
https://bugs.webkit.org/show_bug.cgi?id=134458

Reviewed by Filip Pizlo.


Source/JavaScriptCore: 
Added test to skip js1_5/Regress/regress-159334.js when testing on a memory limited device.

* tests/mozilla/mozilla-tests.yaml:

Tools: 
Added new --memory-limited to filter out tests that have large heap usage.
Such tests are either tagged with //@largeHeap or logic is added to their .yaml file.

* Scripts/run-jsc-stress-tests:

LayoutTests: 
* js/regress/script-tests/lots-of-fields.js: Added //@largeHeap tag to skip when
running on a memoryLimited device.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170601 268f45cc-cd09-0410-ab3c-d52691b4dbfc
js/script-tests/function-apply-many-args.js fails on ARM
https://bugs.webkit.org/show_bug.cgi?id=126588

Reviewed by Mark Lam.

Removed three test cases that fail on some platforms and pass on others due
to stack size.  Other test cases cover what will fit on a stack or what will
throw an out of stack exception.

* js/function-apply-many-args-expected.txt:
* js/script-tests/function-apply-many-args.js:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170602 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Implement the last pieces of encodeFrameStateNode
https://bugs.webkit.org/show_bug.cgi?id=134460

Reviewed by Andreas Kling.

* UIProcess/mac/LegacySessionStateCoding.cpp:
(WebKit::HistoryEntryDataEncoder::operator<<):
(WebKit::isValidEnum):
(WebKit::encodeFormDataElement):
(WebKit::encodeFormData):
(WebKit::encodeFrameStateNode):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Reduce dynamic memory allocation in css jit.
https://bugs.webkit.org/show_bug.cgi?id=134416

Reviewed by Benjamin Poulain.


Source/WebCore: 
* cssjit/FunctionCall.h:
(WebCore::FunctionCall::FunctionCall):
(WebCore::FunctionCall::saveAllocatedCallerSavedRegisters):
* cssjit/RegisterAllocator.h:
* cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::addPseudoClassType):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generatePrologue):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateSelectorChecker):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsNthChild):
Use inlineCapacity template parameter to reduce malloc calls.
I use 16 and 32 as the inline capacity for non-register related vectors because that
is probably big enough for the selector compiler, and if it is not then a malloc
call will not be significant because the selector is very complex.
* cssjit/StackAllocator.h:
(WebCore::StackAllocator::push):
Pass a vector of stack references to match calls to pop and to avoid a call to appendVector.

Source/WTF: 
* wtf/Deque.h:
Added inlineCapacity optional template parameter.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170605 268f45cc-cd09-0410-ab3c-d52691b4dbfc
REGRESSION (Okemo): The contextual menu on tap and hold does not cancel the other gestures.
https://bugs.webkit.org/show_bug.cgi?id=134463
<rdar://problem/17388907>

Reviewed by Benjamin Poulain.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _longPressRecognized:]):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170606 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[iOS WK2] Turn off scrollsToTop on overflow UIScrollViews
https://bugs.webkit.org/show_bug.cgi?id=134456

Reviewed by Tim Horton.

Set scrollsToTop to NO on our UIScrollViews created for overflow scrolling, since
we don't have a good strategy for when to allow it, and doing so would also require
some smarts in the main UIScrollView.

* UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:
(WebKit::ScrollingTreeOverflowScrollingNodeIOS::updateAfterChildren):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170607 268f45cc-cd09-0410-ab3c-d52691b4dbfc
       Restrict network process sandbox
       https://bugs.webkit.org/show_bug.cgi?id=134360

       Reviewed by Sam Weinig.

       Add more restrictions to the network process sandbox.

       * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
       (WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa):
 Always use the cache directory provided in the initialization parameters,
 and make sure we consume the cookie directory extension.
       * Resources/SandboxProfiles/ios/com.apple.WebKit.Networking.sb:
 Make the sandbox profile much more restrictive.
       * Shared/Network/NetworkProcessCreationParameters.cpp:
       (WebKit::NetworkProcessCreationParameters::encode):
       (WebKit::NetworkProcessCreationParameters::decode):
       * Shared/Network/NetworkProcessCreationParameters.h:
 The network process now requires an extension to access
 its cookie storage.
       * Shared/mac/SandboxUtilities.cpp:
       (WebKit::pathForProcessContainer):
       * Shared/mac/SandboxUtilities.h:
 We need to be able to get hold of our container so
 that we can get the correct cookie storage directory.
       * UIProcess/WebContext.cpp:
       (WebKit::WebContext::ensureNetworkProcess):
 We have to pass in the an extension for the cookie storage directory when
       initalising the network process
       * UIProcess/mac/WebContextMac.mm:
       (WebKit::WebContext::platformDefaultCookieStorageDirectory):
 Make sure we provide the correct location on IOS
       * WebProcess/cocoa/WebProcessCocoa.mm:
       (WebKit::WebProcess::platformInitializeWebProcess):
 Consume the cookie storage extension

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170608 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed, rolling out r170578.
https://bugs.webkit.org/show_bug.cgi?id=134462

causes assertions loading nytimes.com on iOS (Requested by
smfr on #webkit).

Reverted changeset:

"Create NSURLRequest lazily when USE(CFNETWORK) is enabled"
https://bugs.webkit.org/show_bug.cgi?id=134441
http://trac.webkit.org/changeset/170578

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170609 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[iOS WK2] Don't crash on status bar tap with overflow scroll views
https://bugs.webkit.org/show_bug.cgi?id=134459

Reviewed by Tim Horton.

The tiled scrolling indicator parents UIViews under CALayers, but that causes
those views to miss -willMoveToWindow:nil notifications on teardown. This can leave
deleted UIScrollViews in UIKit's "scroll to top" list.

Fix by not making UIScrollViews in the debug layer tree host.

* UIProcess/ios/RemoteLayerTreeHostIOS.mm:
(WebKit::RemoteLayerTreeHost::createLayer):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170610 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Adopt the legacy session decoding inside WebPage::restoreSession for now
https://bugs.webkit.org/show_bug.cgi?id=134465

Reviewed by Sam Weinig.

Source/WebCore:
* WebCore.exp.in:

Source/WebKit2:
* UIProcess/mac/LegacySessionStateCoding.cpp:
(WebKit::decodeLegacySessionHistoryEntryData):
* UIProcess/mac/LegacySessionStateCoding.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::restoreSession):

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