[iOS] Upstream disk image cache
https://bugs.webkit.org/show_bug.cgi?id=121985

Reviewed by Joseph Pecoraro.

Source/WebCore:

* WebCore.exp.in:
* WebCore.xcodeproj/project.pbxproj:
* loader/ResourceBuffer.cpp:
(WebCore::ResourceBuffer::isUsingDiskImageCache):
* loader/ResourceBuffer.h:
* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::canUseDiskImageCache): Added.
(WebCore::CachedImage::useDiskImageCache): Added.
* loader/cache/CachedImage.h:
* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::isSafeToMakePurgeable):
(WebCore::CachedResource::isUsingDiskImageCache): Added.
* loader/cache/CachedResource.h:
(WebCore::CachedResource::canUseDiskImageCache): Added.
(WebCore::CachedResource::useDiskImageCache): Added.
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::flushCachedImagesToDisk): Added.
(WebCore::MemoryCache::TypeStatistic::addResource):
(WebCore::MemoryCache::dumpStats):
(WebCore::MemoryCache::dumpLRULists):
* loader/cache/MemoryCache.h:
(WebCore::MemoryCache::TypeStatistic::TypeStatistic):
* loader/ios/DiskImageCacheClientIOS.h: Added.
* loader/ios/DiskImageCacheIOS.h: Added.
* loader/ios/DiskImageCacheIOS.mm: Added.
* platform/Logging.h:
* platform/SharedBuffer.cpp:
(WebCore::SharedBuffer::SharedBuffer):
(WebCore::SharedBuffer::~SharedBuffer):
(WebCore::SharedBuffer::isAllowedToBeMemoryMapped): Added.
(WebCore::SharedBuffer::allowToBeMemoryMapped): Added.
(WebCore::SharedBuffer::failedMemoryMap): Added.
(WebCore::SharedBuffer::markAsMemoryMapped): Added.
(WebCore::SharedBuffer::memoryMappedNotificationCallbackData): Added.
(WebCore::SharedBuffer::memoryMappedNotificationCallback): Added.
(WebCore::SharedBuffer::setMemoryMappedNotificationCallback): Added.
(WebCore::SharedBuffer::data):
(WebCore::SharedBuffer::append):
(WebCore::SharedBuffer::buffer):
(WebCore::SharedBuffer::getSomeData):
* platform/SharedBuffer.h:
(WebCore::SharedBuffer::isMemoryMapped): Added.
* platform/cf/SharedBufferCF.cpp:
(WebCore::SharedBuffer::SharedBuffer):

Source/WebKit:

* WebKit.xcodeproj/project.pbxproj:
* ios/WebCoreSupport/WebDiskImageCacheClientIOS.h: Added.
* ios/WebCoreSupport/WebDiskImageCacheClientIOS.mm: Added.

Source/WebKit/mac:

* Misc/WebCache.mm:
(+[WebCache statistics]):
* WebView/WebDataSource.mm:
(BufferMemoryMapped): Added.
(-[WebDataSource _setAllowToBeMemoryMapped]): Added.
(-[WebDataSource setDataSourceDelegate:]): Added.
(-[WebDataSource dataSourceDelegate]): Added.
(-[WebDataSource dealloc]):
* WebView/WebDataSourcePrivate.h: Declared private delegate
protocol, WebDataSourcePrivateDelegate.
* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.mm:
(+[WebPreferences initialize]):
(-[WebPreferences diskImageCacheEnabled]): Added.
(-[WebPreferences setDiskImageCacheEnabled:]): Added.
(-[WebPreferences diskImageCacheMinimumImageSize]): Added.
(-[WebPreferences setDiskImageCacheMinimumImageSize:]): Added.
(-[WebPreferences diskImageCacheMaximumCacheSize]): Added.
(-[WebPreferences setDiskImageCacheMaximumCacheSize:]): Added.
(-[WebPreferences _diskImageCacheSavedCacheDirectory]): Added.
(-[WebPreferences _setDiskImageCacheSavedCacheDirectory:]): Added.
* WebView/WebView.mm:
(-[WebView _commonInitializationWithFrameName:groupName:]):
(-[WebView _preferencesChanged:]):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156918 268f45cc-cd09-0410-ab3c-d52691b4dbfc
FTL: Add support for ValueToInt32(bool(x))
https://bugs.webkit.org/show_bug.cgi?id=122346

Patch by Nadav Rotem <nrotem@apple.com> on 2013-10-04
Reviewed by Geoffrey Garen.

* ftl/FTLCapabilities.cpp:
(JSC::FTL::canCompile):
* ftl/FTLLowerDFGToLLVM.cpp:
(JSC::FTL::LowerDFGToLLVM::compileNode):
(JSC::FTL::LowerDFGToLLVM::compileValueToInt32):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156919 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Update all the tests, and include new file.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156920 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Remove some unneeded code from WidgetMac
https://bugs.webkit.org/show_bug.cgi?id=122355

Reviewed by Dan Bernstein.

Source/WebCore:

Remove code to manage the visible rect, it's not needed anymore.

* platform/Widget.h:
* platform/mac/WidgetMac.mm:
(WebCore::Widget::~Widget):
(WebCore::Widget::setFrameRect):
(WebCore::Widget::setPlatformWidget):

Source/WebKit/mac:

Remove code to handle the visible rect changing, it's not needed anymore since we always put Netscape plug-ins into their own layers now.

* Plugins/Hosted/WebHostedNetscapePluginView.mm:
* Plugins/WebBaseNetscapePluginView.h:
* Plugins/WebBaseNetscapePluginView.mm:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156921 268f45cc-cd09-0410-ab3c-d52691b4dbfc
CTTE: SubframeLoader backpointer to Frame should be a reference.
<https://webkit.org/b/122350>

Reviewed by Anders Carlsson.

SubframeLoader is tied to the lifetime of FrameLoader, which in turn
is tied to the lifetime of Frame.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156922 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Web Inspector: pressing the Cmd key over a CSS property should underline it immediately (jump to definition mode)
https://bugs.webkit.org/show_bug.cgi?id=119012

Reviewed by Joseph Pecoraro.

We add an "enabled" state to the tokenTrackingController to indicate that we're interested
in tracking hovered tokens. The tokenTrackingController is now only enabled in the
CSSStyleDeclarationTextEditor when the Cmd key is pressed and in the SourceCodeTextEditor
when either the Cmd key is pressed (NonSymbolTokens mode) or when the debugger is paused
(JavaScriptExpression mode).

The tokenTrackingController is now smarter about how it tracks mouse events when it's enabled,
tracking "mouseenter" and "mouseleave" events to enable tracking allowing immediate detection of
tokens being hovered or no longer being hovered even with quick mouse movements. Additioanlly,
using the new top-level mouse coordinates tracking, we can detect a hovered token as soon as
it's being enabled to provide instant feedback to the user.

This new top-level mouse coordinates tracking couple with tracking of modifier keys also fixes
http://webkit.org/b/119011.

* UserInterface/CSSStyleDeclarationTextEditor.js:
(WebInspector.CSSStyleDeclarationTextEditor.prototype._updateJumpToSymbolTrackingMode):
Highlight the last known hovered candidate's range as soon as the Cmd key is pressed and enable
the tokenTrackingController if we're dealing with a non-read-only editor. When the Cmd key is
released, disable the tokenTrackingController.

* UserInterface/CodeMirrorTokenTrackingController.js:
(WebInspector.CodeMirrorTokenTrackingController):
(WebInspector.CodeMirrorTokenTrackingController.prototype.get enabled):
(WebInspector.CodeMirrorTokenTrackingController.prototype.set enabled):
New enabled state for the tokenTrackingController which indicates whether it should be tracking
mouse events to track hovered tokens in the editor. Upon being enabled, the tokenTrackingController
looks up the mouse coordinates continuously tracked at the window level to check for a token
at the last known mouse coordinates in case we're already over a token that may be highlighted.

(WebInspector.CodeMirrorTokenTrackingController.prototype.highlightLastHoveredRange):
New public method allowing to highlight the last know candidate range, if any. This is used from
editor code when the Cmd key is pressed and we want to force the last know candidate to be
highlighted.

(WebInspector.CodeMirrorTokenTrackingController.prototype._startTracking):
(WebInspector.CodeMirrorTokenTrackingController.prototype._stopTracking):
Make these two methods private now that they're automatically called by the "mouseenter" and
"mouseleave" event handling when we're in the "enabled" state. Additionally, the public
"tracking" property has been removed since it is no longer useful to the developer.

(WebInspector.CodeMirrorTokenTrackingController.prototype.handleEvent):
(WebInspector.CodeMirrorTokenTrackingController.prototype._mouseEntered):
(WebInspector.CodeMirrorTokenTrackingController.prototype._mouseLeft):
New handlers for the "mouseenter" and "mouseleave" events enabling tracking of hovered tokens.

(WebInspector.CodeMirrorTokenTrackingController.prototype._mouseMovedOverEditor):
(WebInspector.CodeMirrorTokenTrackingController.prototype._updateHoveredTokenInfo):
Refactor _mouseMovedOverEditor() into two methods with the new _updateHoveredTokenInfo()
allowing to customize the mouse coordinates to be used since we may call
_updateHoveredTokenInfo() outside of the context of a mouse event (ie. a keypress event).

(WebInspector.CodeMirrorTokenTrackingController.prototype._windowLostFocus):
(WebInspector.CodeMirrorTokenTrackingController.prototype._resetTrackingStates):
New private method combining all the various states that need to be reset when tracking
is turned off, including the removal of the highlighted range if any. This is now called
when the window loses focus.

* UserInterface/Main.js:
(WebInspector.loaded):
(WebInspector._mouseMoved):
Add a new window-level "mousemove" event handler to always track mouse coordinates and key modifier
states. This ensures that we may have the most accurate information possible for key modifiers and
allow code to query the last recorded mouse position in situations where it wouldn't be possible
to have dealt with a mouse event, as is the case when the tokenTrackingController just started tracking.

* UserInterface/SourceCodeTextEditor.js:
(WebInspector.SourceCodeTextEditor.prototype._updateTokenTrackingControllerEnabled):
(WebInspector.SourceCodeTextEditor.prototype._debuggerDidPause):
(WebInspector.SourceCodeTextEditor.prototype._debuggerDidResume):
(WebInspector.SourceCodeTextEditor.prototype._enableJumpToSymbolTrackingModeSettings):
(WebInspector.SourceCodeTextEditor.prototype._disableJumpToSymbolTrackingModeSettings):
Update the "enabled" state on the tokenTrackingController when it may have changed based
on those two conditions: we should have either an active debugger call frame or the
Cmd key should have been pressed. This ensures we only track hovered tokens as needed.

(WebInspector.SourceCodeTextEditor.prototype._updateJumpToSymbolTrackingMode):
Highlight the last known hovered candidate's range as soon as the Cmd key is pressed.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156923 268f45cc-cd09-0410-ab3c-d52691b4dbfc
../WebCore: Unify rubberband control
https://bugs.webkit.org/show_bug.cgi?id=122341

Reviewed by Tim Horton.

- Consolidates the two ways we were passing state about whether
  to rubber-band on a particular edge down to one.

* WebCore.exp.in:
* page/Page.cpp:
* page/Page.h:
* page/scrolling/ScrollingCoordinator.h:
(WebCore::ScrollingCoordinator::isRubberBandInProgress):
* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::ScrollingTree):
(WebCore::ScrollingTree::setCanRubberBandState):
(WebCore::ScrollingTree::rubberBandsAtLeft):
(WebCore::ScrollingTree::rubberBandsAtRight):
(WebCore::ScrollingTree::rubberBandsAtBottom):
(WebCore::ScrollingTree::rubberBandsAtTop):
(WebCore::ScrollingTree::willWheelEventStartSwipeGesture):
* page/scrolling/ScrollingTree.h:
* page/scrolling/mac/ScrollingCoordinatorMac.h:
* page/scrolling/mac/ScrollingCoordinatorMac.mm:
* page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm:
(WebCore::ScrollingTreeScrollingNodeMac::shouldRubberBandInDirection):

../WebKit2: Unify rubber-band control
https://bugs.webkit.org/show_bug.cgi?id=122341

Reviewed by Tim Horton.

- Consolidates the two ways we were passing state about whether
  to rubber-band on a particular edge down to one.
- Adds SPI to control whether you can rubber band on the left
  or right edge.
- Add a linked-on-or-after check to control whether we use the
  legacy implicit rubber band control based on back/forward.

* UIProcess/API/C/WKPage.cpp:
(WKPageRubberBandsAtLeft):
(WKPageSetRubberBandsAtLeft):
(WKPageRubberBandsAtRight):
(WKPageSetRubberBandsAtRight):
(WKPageRubberBandsAtBottom):
(WKPageSetRubberBandsAtBottom):
* UIProcess/API/C/WKPage.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::sendWheelEvent):
(WebKit::WebPageProxy::rubberBandsAtLeft):
(WebKit::WebPageProxy::setRubberBandsAtLeft):
(WebKit::WebPageProxy::rubberBandsAtRight):
(WebKit::WebPageProxy::setRubberBandsAtRight):
(WebKit::WebPageProxy::rubberBandsAtTop):
(WebKit::WebPageProxy::setRubberBandsAtTop):
(WebKit::WebPageProxy::rubberBandsAtBottom):
(WebKit::WebPageProxy::setRubberBandsAtBottom):
* UIProcess/WebPageProxy.h:
* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::shouldUseLegacyImplicitRubberBandControl):
(WebKit::WebPageProxy::platformInitialize):
* WebProcess/WebPage/EventDispatcher.cpp:
(WebKit::EventDispatcher::wheelEvent):
* WebProcess/WebPage/EventDispatcher.h:
* WebProcess/WebPage/EventDispatcher.messages.in:
* WebProcess/WebPage/WebPage.cpp:
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156924 268f45cc-cd09-0410-ab3c-d52691b4dbfc
FocusController::advanceFocus spends a lot of time in HTMLMapElement::imageElement
https://bugs.webkit.org/show_bug.cgi?id=122313

Reviewed by Andreas Kling.

The bug was caused by HTMLMapElement::imageElement traversing the entire document to look for
the image element associated with a given map element. Because HTMLCollection used to find the
image element is not cached, it traversed the entire document on every area element we visit,
resulting in O(n^2) behavior.

Fixed the bug by adding the name-to-image-element map on document to avoid the traversal in
HTMLMapElement::imageElement.

* dom/Document.cpp:
(WebCore::Document::addImageElementByLowercasedUsemap): Added.
(WebCore::Document::removeImageElementByLowercasedUsemap): Added.
(WebCore::Document::imageElementByLowercasedUsemap): Added.

* dom/Document.h: Added m_imagesByUsemap.

* dom/DocumentOrderedMap.cpp:
(WebCore::keyMatchesLowercasedUsemap): Added.
(WebCore::DocumentOrderedMap::getElementByLowercasedUsemap): Added.

* dom/DocumentOrderedMap.h:
* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::parseAttribute): Update the name-to-usemap map. The code to parse
the usemap attribute and strip # was moved from HTMLMapElement::imageElement.
(WebCore::HTMLImageElement::insertedInto): Ditto.
(WebCore::HTMLImageElement::removedFrom): Ditto.
(WebCore::HTMLImageElement::matchesLowercasedUsemap): Added; called by DocumentOrderedMap.

* html/HTMLImageElement.h:

* html/HTMLMapElement.cpp:
(WebCore::HTMLMapElement::imageElement): Call Document::imageElementByUsemap instead of
looking through all image elements in the document.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156925 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Teach webkitdirs.pm to honor the --64-bit flag
https://bugs.webkit.org/show_bug.cgi?id=122357

Reviewed by David Kilzer.

* Scripts/webkitdirs.pm:
(argumentsForConfiguration): Modify to check if --64-bit is supplied
by the user.
(findMatchingArguments): Added.
(hasArgument): Added.
(checkForArgumentAndRemoveFromArrayRef): Refactor to use the new
findMatchingArguments subroutine.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156926 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Clean out some FrameLoaderClient hooks that no ports were using.
<https://webkit.org/b/122356>

Reviewed by Anders Carlsson.

Removed the following hooks that were leftovers from dead ports:

    - didExhaustMemoryAvailableForScript
    - didNotAllowScript
    - didNotAllowPlugins
    - willCheckAndDispatchMessageEvent
    - didChangeName
    - dispatchWillInsertBody
    - dispatchDidChangeResourcePriority


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156927 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Windows] Correct run-path when using 64-bit binaries.

Reviewed by David Kilzer.

* Scripts/webkitdirs.pm:
(determineConfigurationProductDir): If running in 64-bit mode, use the 'bin64'
directory. Otherwise use the existing 'bin32' directory.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156928 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Build fix after r156925. It collided with r156903.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::insertedInto):
(WebCore::HTMLImageElement::removedFrom):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156929 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[MathML] Remove RenderTree modification during layout and refactor the StretchyOp code
https://bugs.webkit.org/show_bug.cgi?id=121416

Source/WebCore:

Reviewed by David Hyatt.

Tests: mathml/presentation/mo-minus.html
       mathml/presentation/mo-stacked-glyphs.html
       mathml/presentation/mo-stretchy-vertical-bar.html
       mathml/very-large-stretchy-operators.html

MathML stretched operators by both modifying the width of the operator
and adding children to the operator node in the render tree.

Instead we make the operator width equal to the widest glyph possible that we use
to represent the operator.  Additionally instead of rendering stretchy glyphs via
stacked operator pieces in separate render tree nodes, keep only one node for the
glyph, and use a custom paint method to paint the stacked representation.

With this patch, rendering seems roughly equivalent on Mac and markedly better
on Linux.

* css/mathml.css:
Not sure what this line-height:0 was here for, but it caused bugs with the new code

* mathml/MathMLTextElement.cpp:
(WebCore::MathMLTextElement::attach):
(WebCore):
(WebCore::MathMLTextElement::childrenChanged):
Need to update the anonymous render tree below <mo> elements when their
children change or when the renderer is first attached.

* mathml/MathMLTextElement.h:
(MathMLTextElement):
* rendering/mathml/RenderMathMLBlock.cpp:
(WebCore::RenderMathMLBlock::RenderMathMLBlock):
* rendering/mathml/RenderMathMLBlock.h:
Now that the preferred width doesn't depend on the height, we don't
need to override computePreferredLogicalWidths at all.

* rendering/mathml/RenderMathMLFenced.cpp:
(WebCore::RenderMathMLFenced::makeFences):
(WebCore::RenderMathMLFenced::styleDidChange):
Need to update the anonymous renderers for the anonymous RenderMathMLOperators.

* rendering/mathml/RenderMathMLOperator.cpp:
(WebCore::RenderMathMLOperator::expandedStretchHeight):
Store the non-expanded stretch height so that we can detect when the height
actually changed.

(WebCore::RenderMathMLOperator::stretchToHeight):
Only update the style on the anonymous render tree since this is called
from RenderMathMLRow::layout

(WebCore::RenderMathMLOperator::styleDidChange):
(WebCore::RenderMathMLOperator::glyphBoundsForCharacter): A helper to get glyph boundaries.
(WebCore::RenderMathMLOperator::glyphHeightForCharacter): Ditto for glyph width.
(WebCore::RenderMathMLOperator::advanceForCharacter): The advance is different from the width,
and we want the width of the operator to be the advance instead of the tight bounding width.
(WebCore::RenderMathMLOperator::computePreferredLogicalWidths): Use the max of all possible glyphs
we can use to render this operator.
(WebCore::RenderMathMLOperator::updateFromElement): We add a child for rendering the non-scaled
version of the glyph.
(WebCore::RenderMathMLOperator::firstCharacterForStretching): Helper to figure out what character
is the character used for stretching operations.
(WebCore::RenderMathMLOperator::findAcceptableStretchyCharacter): Helper to find an acceptable set
of glyph pieces for stretching characters.
(WebCore::RenderMathMLOperator::updateStyle): Resize the operator to the appropriate height and hide
the child if we are using the stretchy style.
(WebCore::RenderMathMLOperator::firstLineBoxBaseline):
(WebCore::RenderMathMLOperator::paintCharacter): Helper to paint a single character component of the
stretchy glyph.
(WebCore::RenderMathMLOperator::fillWithExtensionGlyph): Helper to paint the extender glue between
features of the stretchy glyph.
(WebCore::RenderMathMLOperator::paint): Properly paint stretchy glyphs.
* rendering/mathml/RenderMathMLOperator.h: Update method declarations.

LayoutTests:

Patch by Frédéric Wang <fred.wang@free.fr> on 2013-10-04
Reviewed by David Hyatt.

Add some reftests for stretchy operators.

* TestExpectations: The remaining MathML pixel tests are broken by this patch.
* LayoutTests/platform/gtk/TestExpectations:
* LayoutTests/platform/mac/TestExpectations:
* LayoutTests/platform/win/TestExpectations:
* mathml/presentation/mo-minus.html: Added.
* mathml/presentation/mo-stacked-glyphs-expected.html: Added.
* mathml/presentation/mo-stacked-glyphs.html: Added.
* mathml/presentation/mo-stretchy-vertical-bar-expected-mismatch.html: Added.
* mathml/presentation/mo-stretchy-vertical-bar.html: Added.
* mathml/very-large-stretchy-operators-expected.txt: Added.
* mathml/very-large-stretchy-operators.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156930 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Remove WTF smart pointers 'const_pointer_cast'
https://bugs.webkit.org/show_bug.cgi?id=122325

Reviewed by Darin Adler.

Removed WTF smart pointers 'const_pointer_cast' functions as:
- they were not used
- their implementation was wrong as they tried to cast to a different pointer type

* wtf/PassOwnPtr.h:
* wtf/PassRefPtr.h:
* wtf/RefPtr.h:


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