[OS X] Make checking if a font is the system font more robust
https://bugs.webkit.org/show_bug.cgi?id=132030

Reviewed by Dean Jackson.

Instead of inspecting a font's name to determine if it is a system font,
on OS X we can ask the system directly.

This patch also moves a platform-specific check into platform-specific
code, so that other platforms don't check for OS X-specific behavior.

Covered by existing tests.

* platform/graphics/Font.cpp:
(WebCore::Font::hasValidAverageCharWidth):
* platform/graphics/Font.h:
* platform/graphics/mac/FontMac.mm:
(WebCore::Font::primaryFontDataIsSystemFont):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@167713 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[New Multicolumn] Nested columns not working at all.
https://bugs.webkit.org/show_bug.cgi?id=131805

Reviewed by Dean Jackson.

Add support for nested pagination contexts, allowing for an arbitrary level
of nesting of multicolumn layouts. There were a number of things that had to
be patched in order for this to work.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::regionAtBlockOffset):
Make sure RenderMultiColumnFlowThreads just return null for regions at any
block offset. Individual region sets will be created as you cross ancestor
regions eventually, so this is just getting in the way.

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::enclosingPaginationLayerInSubtree):
Add a new helper method for obtaining an enclosingPaginationLayer when
constrained by some root. This function ensures you don't accidentally
cross your subtree root when looking for enclosing pagination layers.

(WebCore::RenderLayer::collectFragments):
Patch collectFragments to know how to recur to collect ancestor fragments
in order to apply nested splitting as you cross pagination boundaries.

(WebCore::RenderLayer::updatePaintingInfoForFragments):
(WebCore::RenderLayer::calculateClipRects):
* rendering/RenderLayer.h:
(WebCore::LayerFragment::LayerFragment):
(WebCore::LayerFragment::setRects):
(WebCore::LayerFragment::moveBy):
(WebCore::LayerFragment::intersect):
Improve the LayerFragment so that it caches transformed bounding boxes as
well. This is needed to fix intersectsDamageRect so that it doesn't grab
the wrong bounding box when checking inline layers that are paginated.

* rendering/RenderMultiColumnFlowThread.cpp:
(WebCore::RenderMultiColumnFlowThread::flowThreadDescendantInserted):
Ignore inserted flow threads inside an ancestor flow thread, since we only
care about what the sets do.
        
* rendering/RenderObject.cpp:
(WebCore::RenderObject::insertedIntoTree):
Make sure that nested flow thread layers return themselves when a child
is inserted directly under them.



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

broke hundreds of tests (Requested by thorton on #webkit).

Reverted changeset:

"[OS X] Make checking if a font is the system font more
robust"
https://bugs.webkit.org/show_bug.cgi?id=132030
http://trac.webkit.org/changeset/167713

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@167715 268f45cc-cd09-0410-ab3c-d52691b4dbfc
REGRESSION (Safari 6 - ToT): Incorrectly assumes that RenderStyle data can be shared
https://bugs.webkit.org/show_bug.cgi?id=113058

Patch by Morten Stenshorne <mstensho@opera.com> on 2014-04-23
Reviewed by David Hyatt.

Source/WebCore:
Before sharing CSS properties with an element in the cache, we need to
check that the new element is suitable for this, just like we check
elements before inserting them into the cache.

Test: fast/css/identical-logical-height-decl.html

* css/StyleResolver.cpp:
(WebCore::StyleResolver::applyMatchedProperties):

LayoutTests:
* fast/css/identical-logical-height-decl-expected.html: Added.
* fast/css/identical-logical-height-decl.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@167716 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[iOS WebKit2] IOSurfacePool should force CA to actually garbage collect surfaces.
<https://webkit.org/b/132065>
<rdar://problem/16110687>

Add a platformGarbageCollectNow() helper function to IOSurfacePool that
triggers a sweep of the IOSurfaces. Call this from collectionTimerFired()
and discardAllSurfaces().

This lets us drop all otherwise-unused 420f surfaces on memory pressure.

Reviewed by Tim Horton.

* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/cg/IOSurfacePool.cpp:
(WebCore::IOSurfacePool::collectionTimerFired):
(WebCore::IOSurfacePool::discardAllSurfaces):
* platform/graphics/cg/IOSurfacePool.h:
* platform/graphics/cocoa/IOSurfacePoolCocoa.mm: Added.
(WebCore::IOSurfacePool::platformGarbageCollectNow):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@167717 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[New Multicolumn] Crasher when clearing out a flow thread in multicolumn layout.
https://bugs.webkit.org/show_bug.cgi?id=132069

Reviewed by Dean Jackson.


Source/WebCore: 
This is imported from a patch Morten did for Blink, but I had to change it a fair
bit. deleteLines() is used to handle simple line box layout instead of just calling
deleteLineBoxTree.
        
I also had to disable the layout state to stop asserts on repaint when the children
get moved. Not sure why Blink didn't hit this, but it's simple enough to add a
LayoutStateDisabler to stop the assert.

Added fast/multicol/inline-children-crash.html

* rendering/RenderMultiColumnFlowThread.cpp:
(WebCore::RenderMultiColumnFlowThread::evacuateAndDestroy):

LayoutTests: 
* fast/multicol/inline-children-crash-expected.txt: Added.
* fast/multicol/inline-children-crash.html: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@167718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Support encoding/decoding NSUInteger arguments in WKRemoteObjectCoder.
https://bugs.webkit.org/show_bug.cgi?id=132040

Add support for encoding/decoding NSUInteger arguments.

Patch by Yongjun Zhang <yongjun_zhang@apple.com> on 2014-04-23
Reviewed by Sam Weinig.

* Shared/API/Cocoa/WKRemoteObjectCoder.mm:
(encodeInvocation):
(decodeInvocationArguments):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@167719 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[New Multicolumn] Assertion failure in huge-column-count.html
https://bugs.webkit.org/show_bug.cgi?id=132071

Reviewed by Dean Jackson.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::regionAtBlockOffset):
Remove the code that returned 0 here, since we're going to patch a lower-level
function to catch all cases.

* rendering/RenderFlowThread.cpp:
(WebCore::RenderFlowThread::getRegionRangeForBox):
Don't allow in-flow RenderFlowThreads to ever have a region range. The sets
are what should have ranges... the flow thread needs to just be ignored.



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

broke eight newmulticol tests (Requested by thorton on
#webkit).

Reverted changeset:

"[New Multicolumn] Assertion failure in huge-column-
count.html"
https://bugs.webkit.org/show_bug.cgi?id=132071
http://trac.webkit.org/changeset/167720

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@167721 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[iOS] Memory pressure notification should fire on main thread.
<https://webkit.org/b/132074>

Rejig the memory pressure notification to fire on the main queue
directly instead of rerouting it manually.

Reviewed by Mark Rowe.

* platform/cocoa/MemoryPressureHandlerCocoa.mm:
(WebCore::MemoryPressureHandler::install):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@167722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[New Multicolumn] Assertion failure in huge-column-count.html
https://bugs.webkit.org/show_bug.cgi?id=132071

Reviewed by Dean Jackson.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::regionAtBlockOffset):
Back out this change, since it wasn't general enough.

* rendering/RenderFlowThread.cpp:
(WebCore::RenderFlowThread::getRegionRangeForBox):
The real issue was that this loop needed to consider the actual box
rather than starting from the parent. This was a non-issue for normal
regions (which cannot have nested flow threads), but for columns, you 
have to consider the fact that the box could itself be a flow thread.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@167723 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[OS X] Make checking if a font is the system font more robust
https://bugs.webkit.org/show_bug.cgi?id=132030

Reviewed by Dean Jackson.

Instead of inspecting a font's name to determine if it is a system font,
on OS X we can ask the system directly.

This patch also moves a platform-specific check into platform-specific
code, so that other platforms don't check for OS X-specific behavior.

Covered by existing tests.

* platform/graphics/Font.cpp:
(WebCore::Font::hasValidAverageCharWidth):
* platform/graphics/Font.h:
* platform/graphics/mac/FontMac.mm:
(WebCore::Font::primaryFontDataIsSystemFont):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@167724 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[New Multicolumn] fast/multicol/fixed-column-percent-logical-height-orthogonal-writing-mode.html fails
https://bugs.webkit.org/show_bug.cgi?id=132078

Reviewed by Anders Carlsson.

* rendering/RenderBox.cpp:
(WebCore::RenderBox::skipContainingBlockForPercentHeightCalculation):
Add a parameter to test for orthogonal writing modes. If we're perpendicular,
then we should not skip the flow thread, since we resolve relative to the column width,
and that is always set.

(WebCore::RenderBox::computePercentageLogicalHeight):
Patched to pass in whether or not the box and the ancestor block are perpendicular.

* rendering/RenderBox.h:
Patched the signature of skipContainingBlockForPercentHeightCalculation



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@167727 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Mock scrollbars don't always work in DumpRenderTree
https://bugs.webkit.org/show_bug.cgi?id=132082

Reviewed by Alexey Proskuryakov.

* DumpRenderTree/mac/DumpRenderTree.mm:
(prepareConsistentTestingEnvironment):
Set the mock scrollbar setting before creating the WebView, as this setting
cannot be dynamically changed, so any scrollbars that are created during
WebView initialization and are not replaced before snapshotting will end
up being platform scrollbars instead of mock ones.
WebKitTestRunner already sets this preference before creating WKViews,
so we're just matching its behavior.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@167728 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Arguments::copyBackingStore needs to update m_registers in tandem with m_registerArray
https://bugs.webkit.org/show_bug.cgi?id=132079

Reviewed by Michael Saboff.

Since we're moving the register backing store, we don't want to leave a dangling pointer into a random CopiedBlock.

Also added a test that previously triggered this bug.

* runtime/Arguments.cpp:
(JSC::Arguments::copyBackingStore): D'oh!
* tests/stress/arguments-copy-register-array-backing-store.js: Added.
(foo):
(bar):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@167729 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Don't migrate the WKView.h header from WebCore to WebKit
https://bugs.webkit.org/show_bug.cgi?id=132086

Reviewed by Dan Bernstein.

Source/WebCore:
* WebCore.xcodeproj/project.pbxproj:
Add WAKViewInternal.h.

* platform/WAKViewInternal.h: Added.

* platform/ios/wak/WAKClipView.m:
Import WAKViewInternal.h instead of WAKViewPrivate.h.

* platform/ios/wak/WAKScrollView.mm:
Import WAKViewInternal.h instead of WAKViewPrivate.h.

* platform/ios/wak/WAKView.h:
Move ivars to a class extension in WAKViewInternal.h and remove WKView.h import.

* platform/ios/wak/WAKView.mm:
Import WAKViewInternal.h instead of WAKViewPrivate.h.

* platform/ios/wak/WAKViewPrivate.h:
Import WKViewPrivate.h.

Source/WebKit/mac:
* MigrateHeaders.make:
Remove WKView.h from the list of headers to migrate.

* WebView/WebView.mm:
Import WKView.h.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@167730 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed. Moving myself from Contributors to Committers list.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@167731 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Eliminate internals.setMockScrollbarsEnabled()
https://bugs.webkit.org/show_bug.cgi?id=132085

Reviewed by Tim Horton.

Source/WebCore:
This was essentially unused, and also didnt work.

* testing/InternalSettings.cpp:
(WebCore::InternalSettings::Backup::restoreTo):
(WebCore::InternalSettings::setMockScrollbarsEnabled): Deleted.
* testing/InternalSettings.h:
* testing/InternalSettings.idl:

Tools:
* DumpRenderTree/mac/DumpRenderTree.mm: (resetWebPreferencesToConsistentValues):
No need to reset the preference, there is no way it can change.

LayoutTests:
Remove calls, all of which were resetting it to true (which is the default, and
the only value that makes sense).

* compositing/geometry/fixed-position.html:
* compositing/geometry/horizontal-scroll-composited.html:
* compositing/geometry/vertical-scroll-composited.html:
* compositing/iframes/resources/scrollgrandchild-inner.html:
* compositing/overflow/fixed-position-ancestor-clip.html:
* compositing/resources/mock_scrollbars.js: Removed.
* css3/filters/blur-filter-page-scroll-parents.html:
* css3/filters/blur-filter-page-scroll-self.html:
* css3/filters/blur-filter-page-scroll.html:
* fast/dom/window-scroll-scaling.html:
* fast/events/touch/gesture/gesture-scrollbar.html:
* fast/sub-pixel/sub-pixel-iframe-copy-on-scroll.html:
* fast/sub-pixel/transformed-iframe-copy-on-scroll.html:
* media/video-controls-rendering.html:
* media/video-zoom.html:
* scrollingcoordinator/resources/non-fast-scrollable-region-testing.js:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@167732 268f45cc-cd09-0410-ab3c-d52691b4dbfc
The GC should only resume compiler threads that it suspended in the same GC pass.
<https://webkit.org/b/132088>

Reviewed by Mark Hahnenberg.

Previously, this scenario can occur:
1. Thread 1 starts a GC and tries to suspend DFG worklist threads.  However,
   no worklists were created yet at the that time.
2. Thread 2 starts to compile some functions and creates a DFG worklist, and
   acquires the worklist thread's lock.
3. Thread 1's GC completes and tries to resume suspended DFG worklist thread.
   This time, it sees the worklist created by Thread 2 and ends up unlocking
   the worklist thread's lock that is supposedly held by Thread 2.
Thereafter, chaos ensues.

The fix is to cache the worklists that were actually suspended by each GC pass,
and only resume those when the GC is done.

This issue was discovered by enabling COLLECT_ON_EVERY_ALLOCATION and running
the fast/workers layout tests.

* heap/Heap.cpp:
(JSC::Heap::visitCompilerWorklists):
(JSC::Heap::deleteAllCompiledCode):
(JSC::Heap::suspendCompilerThreads):
(JSC::Heap::resumeCompilerThreads):
* heap/Heap.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@167733 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Mac, iOS] Stop buffering media when on an inactive tab. 
https://bugs.webkit.org/show_bug.cgi?id=132077

Reviewed by Eric Carlson.

* html/HTMLMediaElement.cpp: Rename 'm_isDisplaySleepDisablingSuspended'
to 'm_elementIsHidden'.
(WebCore::HTMLMediaElement::HTMLMediaElement):
(WebCore::HTMLMediaElement::visibilityStatusChanged): Notify the
media session that the element is (or is not) hidden.
(WebCore::HTMLMediaElement::setShouldBufferData): Added.
* html/HTMLMediaElement.h:
* platform/audio/MediaSession.cpp:
(WebCore::MediaSession::clientWillBeginPlayback): Tell media to
buffer if not hidden or playing.
(WebCore::MediaSession::clientWillPausePlayback): Ditto.
(WebCore::MediaSession::visibilityChanged): Added. Client API, just relays call
to updateClientDataBuffering.
(WebCore::MediaSession::updateClientDataBuffering): Tell client it should only
buffer data if it's currently playing, or not hidden.
* platform/audio/MediaSession.h:
* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::setShouldBufferData): Added: Just relays to
MediaPlayerPrivate object.
* platform/graphics/MediaPlayer.h:
* platform/graphics/MediaPlayerPrivate.h:
(WebCore::MediaPlayerPrivateInterface::setShouldBufferData):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC):
(WebCore::MediaPlayerPrivateAVFoundationObjC::setShouldBufferData): Added.
Detach the player item from the player if we don't want to continue
buffering or other background tasks.


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