ASSERTION FAILED: m_numBreakpoints >= numBreakpoints when deleting breakpoints.
<https://webkit.org/b/129393>

Reviewed by Geoffrey Garen.

The issue manifests because the debugger will iterate all CodeBlocks in
the heap when setting / clearing breakpoints, but it is possible for a
CodeBlock to have been instantiate but is not yet registered with the
debugger.  This can happen because of the following:

1. DFG worklist compilation is still in progress, and the target
   codeBlock is not ready for installation in its executable yet.

2. DFG compilation failed and we have a codeBlock that will never be
   installed in its executable, and the codeBlock has not been cleaned
   up by the GC yet.

The code for installing the codeBlock in its executable is the same code
that registers it with the debugger.  Hence, these codeBlocks are not
registered with the debugger, and any pending breakpoints that would map
to that CodeBlock is as yet unset or will never be set.  As such, an
attempt to remove a breakpoint in that CodeBlock will fail that assertion.

To fix this, we do the following:

1. We'll eagerly clean up any zombie CodeBlocks due to failed DFG / FTL
   compilation.  This is achieved by providing a
   DeferredCompilationCallback::compilationDidComplete() that does this
   clean up, and have all sub classes call it at the end of their
   compilationDidComplete() methods.

2. Before the debugger or profiler iterates CodeBlocks in the heap, they
   will wait for all compilations to complete before proceeding.  This
   ensures that:
   1. any zombie CodeBlocks would have been cleaned up, and won't be
      seen by the debugger or profiler.
   2. all CodeBlocks that the debugger and profiler needs to operate on
      will be "ready" for whatever needs to be done to them e.g.
      jettison'ing of DFG codeBlocks.

* bytecode/DeferredCompilationCallback.cpp:
(JSC::DeferredCompilationCallback::compilationDidComplete):
* bytecode/DeferredCompilationCallback.h:
- Provide default implementation method to clean up zombie CodeBlocks.

* debugger/Debugger.cpp:
(JSC::Debugger::forEachCodeBlock):
- Utility function to iterate CodeBlocks.  It ensures that all compilations
  are complete before proceeding.
(JSC::Debugger::setSteppingMode):
(JSC::Debugger::toggleBreakpoint):
(JSC::Debugger::recompileAllJSFunctions):
(JSC::Debugger::clearBreakpoints):
(JSC::Debugger::clearDebuggerRequests):
- Use the utility iterator function.

* debugger/Debugger.h:
* dfg/DFGOperations.cpp:
- Added an assert to ensure that zombie CodeBlocks will be imminently cleaned up.

* dfg/DFGPlan.cpp:
(JSC::DFG::Plan::finalizeWithoutNotifyingCallback):
- Remove unneeded code (that was not the best solution anyway) for ensuring
  that we don't generate new DFG codeBlocks after enabling the debugger or
  profiler.  Now that we wait for compilations to complete before proceeding
  with debugger and profiler work, this scenario will never happen.

* dfg/DFGToFTLDeferredCompilationCallback.cpp:
(JSC::DFG::ToFTLDeferredCompilationCallback::compilationDidComplete):
- Call the super class method to clean up zombie codeBlocks.

* dfg/DFGToFTLForOSREntryDeferredCompilationCallback.cpp:
(JSC::DFG::ToFTLForOSREntryDeferredCompilationCallback::compilationDidComplete):
- Call the super class method to clean up zombie codeBlocks.

* heap/CodeBlockSet.cpp:
(JSC::CodeBlockSet::remove):
* heap/CodeBlockSet.h:
* heap/Heap.h:
(JSC::Heap::removeCodeBlock):
- New method to remove a codeBlock from the codeBlock set.

* jit/JITOperations.cpp:
- Added an assert to ensure that zombie CodeBlocks will be imminently cleaned up.

* jit/JITToDFGDeferredCompilationCallback.cpp:
(JSC::JITToDFGDeferredCompilationCallback::compilationDidComplete):
- Call the super class method to clean up zombie codeBlocks.

* runtime/VM.cpp:
(JSC::VM::waitForCompilationsToComplete):
- Renamed from prepareToDiscardCode() to be clearer about what it does.

(JSC::VM::discardAllCode):
(JSC::VM::releaseExecutableMemory):
(JSC::VM::setEnabledProfiler):
- Wait for compilation to complete before enabling the profiler.

* runtime/VM.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@165005 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Allow overflow-scroll to be one-finger scrolled until we hook up UIScrollViews
https://bugs.webkit.org/show_bug.cgi?id=129621

Reviewed by Benjamin Poulain.

Temporary change to allow overflow:scroll to be scrolled in iOS WK2.

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::hasAcceleratedTouchScrolling):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@165006 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Fix an exception caused by trying to access the DOM before it is loaded.

https://bugs.webkit.org/show_bug.cgi?id=129617

Reviewed by Andreas Kling.

* UserInterface/Base/Main.js:
(WebInspector.loaded): Move global event listeners from here...
(WebInspector.contentLoaded): ... to here.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@165007 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Web Inspector: debugger statements do not break.
<https://webkit.org/b/129524>

Reviewed by Geoff Garen.

Source/JavaScriptCore: 

Since we no longer call op_debug hooks unless there is a debugger request
made on the CodeBlock, the op_debug for the debugger statement never gets
serviced.

With this fix, we check in the CodeBlock constructor if any debugger
statements are present.  If so, we set a m_hasDebuggerStatement flag that
causes the CodeBlock to show as having debugger requests.  Hence,
breaking at debugger statements is now restored.

* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::CodeBlock):
* bytecode/CodeBlock.h:
(JSC::CodeBlock::hasDebuggerRequests):
(JSC::CodeBlock::clearDebuggerRequests):

LayoutTests: 

* inspector-protocol/debugger/debugger-statement-expected.txt: Added.
* inspector-protocol/debugger/debugger-statement.html: Added.
* inspector-protocol/debugger/resources/breakpoint.js:
(debuggerStatement):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@165008 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[x86] Improve code generation of byte test
https://bugs.webkit.org/show_bug.cgi?id=129597

Reviewed by Geoffrey Garen.

When possible, test the 8 bit register to itself instead of comparing it
to a literal.

* assembler/MacroAssemblerX86Common.h:
(JSC::MacroAssemblerX86Common::test32):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@165009 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Remove unused DataView code from JSDOMBinding.h
<https://webkit.org/b/129616>

Reviewed by Antti Koivisto.

* bindings/js/JSDOMBinding.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@165010 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Add Jeremy Jones to the contributors list as a contributor.

* Scripts/webkitpy/common/config/contributors.json:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@165011 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Remove an innocuous error message and support default views for Resource and Debugger sidebars.

https://bugs.webkit.org/show_bug.cgi?id=129622

Reviewed by Joseph Pecoraro.

* UserInterface/Views/DebuggerSidebarPanel.js:
(WebInspector.DebuggerSidebarPanel.prototype.showDefaultContentView): Added.
* UserInterface/Views/ResourceSidebarPanel.js:
(WebInspector.ResourceSidebarPanel.prototype.showDefaultContentView): Added.
(WebInspector.ResourceSidebarPanel.prototype.treeElementForRepresentedObject): Don't log an error
if the tree element isn't a Script. We try to find any represented object, and it can fail.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@165012 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Add support for sessions to MemoryCache.
https://bugs.webkit.org/show_bug.cgi?id=127794

Patch by Martin Hock <mhock@apple.com> on 2014-03-03
Reviewed by Sam Weinig.

Source/WebCore:

* WebCore.exp.in:
* editing/DeleteButtonController.cpp:
(WebCore::DeleteButtonController::createDeletionUI): Initialize CachedImage with sessionID.
* html/DOMURL.cpp:
(WebCore::DOMURL::revokeObjectURL): Remove URL from MemoryCache for all sessions.
* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::cachedResource): Pass sessionID to MemoryCache.
* inspector/InspectorResourceAgent.cpp:
(WebCore::InspectorResourceAgent::replayXHR): Ditto.
* loader/DocumentLoader.cpp:
(WebCore::areAllLoadersPageCacheAcceptable): Ditto.
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::tellClientAboutPastMemoryCacheLoads): Ditto.
* loader/ImageLoader.cpp:
(WebCore::ImageLoader::updateFromElement): Initialize CachedImage with sessionID.
* loader/archive/cf/LegacyWebArchive.cpp:
(WebCore::LegacyWebArchive::create): Pass sessionID to MemoryCache.
* loader/cache/CachedCSSStyleSheet.cpp:
(WebCore::CachedCSSStyleSheet::CachedCSSStyleSheet): Constructor takes sessionID.
* loader/cache/CachedCSSStyleSheet.h:
* loader/cache/CachedFont.cpp: Ditto.
(WebCore::CachedFont::CachedFont):
* loader/cache/CachedFont.h:
* loader/cache/CachedImage.cpp: Ditto.
(WebCore::CachedImage::CachedImage):
* loader/cache/CachedImage.h:
* loader/cache/CachedRawResource.cpp: Ditto.
(WebCore::CachedRawResource::CachedRawResource):
* loader/cache/CachedRawResource.h:
* loader/cache/CachedResource.cpp: Ditto.
(WebCore::CachedResource::CachedResource):
(WebCore::CachedResource::~CachedResource): Pass sessionID to MemoryCache.
* loader/cache/CachedResource.h:
(WebCore::CachedResource::sessionID):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::createResource): Constructors take sessionID.
(WebCore::CachedResourceLoader::sessionID): Retrieve sessionID from page.
(WebCore::CachedResourceLoader::requestUserCSSStyleSheet): Pass sessionID to MemoryCache.
(WebCore::CachedResourceLoader::requestResource): Initialize CachedCSSStyleSheet with sessionID.
(WebCore::CachedResourceLoader::revalidateResource): Initialize cached resource with sessionID.
(WebCore::CachedResourceLoader::loadResource): Pass sessionID to MemoryCache and initialize cached resource with sessionID.
* loader/cache/CachedResourceLoader.h:
* loader/cache/CachedSVGDocument.cpp: Constructor takes sessionID.
(WebCore::CachedSVGDocument::CachedSVGDocument):
* loader/cache/CachedSVGDocument.h:
* loader/cache/CachedScript.cpp: Ditto.
(WebCore::CachedScript::CachedScript):
* loader/cache/CachedScript.h:
* loader/cache/CachedTextTrack.cpp: Ditto.
(WebCore::CachedTextTrack::CachedTextTrack):
* loader/cache/CachedTextTrack.h:
* loader/cache/CachedXSLStyleSheet.cpp: Ditto.
(WebCore::CachedXSLStyleSheet::CachedXSLStyleSheet):
* loader/cache/CachedXSLStyleSheet.h:
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::getSessionMap): Retrieve CachedResourceMap based on sessionID.
(WebCore::MemoryCache::add): Use sessionID from CachedResource parameter.
(WebCore::MemoryCache::revalidationSucceeded): Add sessionID parameter.
(WebCore::MemoryCache::resourceForURL): Ditto.
(WebCore::MemoryCache::resourceForRequest): Ditto, also move impl into impl method.
(WebCore::MemoryCache::resourceForRequestImpl): Add CachedResourceMap parameter.
(WebCore::MemoryCache::addImageToCache): Use default sessionID.
(WebCore::MemoryCache::removeImageFromCache): Ditto.
(WebCore::MemoryCache::evict): Use sessionID from CachedResource parameter.
(WebCore::MemoryCache::removeResourcesWithOrigin): Iterate through all CachedResourceMaps.
(WebCore::MemoryCache::getOriginsWithCache): Ditto.
(WebCore::MemoryCache::removeUrlFromCache): Add sessionID parameter.
(WebCore::MemoryCache::removeRequestFromCache): Ditto.
(WebCore::MemoryCache::removeRequestFromCacheImpl): Ditto.
(WebCore::MemoryCache::removeRequestFromSessionCaches): Iterate through all CachedResourceMaps.
(WebCore::MemoryCache::crossThreadRemoveRequestFromCache): Add sessionID parameter.
(WebCore::MemoryCache::getStatistics): Iterate through all CachedResourceMaps.
(WebCore::MemoryCache::setDisabled): Ditto.
* loader/cache/MemoryCache.h: Create another level for cache.
* platform/CrossThreadCopier.cpp: Allow copying SessionIDs across threads.
(WebCore::SessionID>::copy):
* platform/CrossThreadCopier.h:
* platform/network/cf/ResourceRequest.h:
(WebCore::ResourceRequest::ResourceRequest): Remove trailing whitespace.
* rendering/RenderSnapshottedPlugIn.cpp:
(WebCore::RenderSnapshottedPlugIn::updateSnapshot): Initialize CachedImage with sessionID.
* testing/Internals.cpp:
(WebCore::Internals::isLoadingFromMemoryCache): Pass sessionID to MemoryCache.

Source/WebKit:

* WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in:

Source/WebKit2:

* NetworkProcess/NetworkResourceLoader.h: Add sessionID() method.
(WebKit::NetworkResourceLoader::sessionID):
* NetworkProcess/mac/DiskCacheMonitor.h: Add sessionID member.
* NetworkProcess/mac/DiskCacheMonitor.mm:
(WebKit::DiskCacheMonitor::DiskCacheMonitor): Send sessionID to NetworkProcessConnection::DidCacheResource.
* WebProcess/Network/NetworkProcessConnection.cpp: Add sessionID parameter to didCacheResource and pass to MemoryCache.
(WebKit::NetworkProcessConnection::didCacheResource):
* WebProcess/Network/NetworkProcessConnection.h: Ditto.
* WebProcess/Network/NetworkProcessConnection.messages.in: Ditto.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@165013 268f45cc-cd09-0410-ab3c-d52691b4dbfc
AX: Support IOS Accessibility in WK2
https://bugs.webkit.org/show_bug.cgi?id=129527

Reviewed by Sam Weinig.

Source/WebCore: 

Update the iOS wrapper so that it can convert points to screen space in WebKit2.

* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(-[WebAccessibilityObjectWrapper convertPointToScreenSpace:]):
(-[WebAccessibilityObjectWrapper convertRectToScreenSpace:]):

Source/WebKit2: 

Implement enough AX hooks so that accessibility can work in WebKit2.

* Platform/IPC/Connection.h:
* Platform/IPC/mac/ConnectionMac.cpp:
(IPC::Connection::identifier):
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::accessibilityWebProcessTokenReceived):
* UIProcess/ios/WKContentView.h:
* UIProcess/ios/WKContentView.mm:
(-[WKContentView _updateForScreen:]):
(-[WKContentView _setAccessibilityWebProcessToken:]):
(-[WKContentView _accessibilityRegisterUIProcessTokens]):
(-[WKContentView _didRelaunchProcess]):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::registerWebProcessAccessibilityToken):
(WebKit::WebPageProxy::registerUIProcessAccessibilityTokens):
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/Plugins/PDF/PDFPlugin.mm:
* WebProcess/WebPage/WKAccessibilityWebPageObjectIOS.h: Added.
* WebProcess/WebPage/WKAccessibilityWebPageObjectIOS.mm: Added.
(-[WKAccessibilityWebPageObject init]):
(-[WKAccessibilityWebPageObject _accessibilityCategoryInstalled:]):
(-[WKAccessibilityWebPageObject pageScale]):
(-[WKAccessibilityWebPageObject dealloc]):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::platformInitialize):
(WebKit::WebPage::platformInitializeAccessibility):
(WebKit::WebPage::accessibilityObjectForMainFramePlugin):
(WebKit::WebPage::registerUIProcessAccessibilityTokens):
* WebProcess/WebPage/mac/WKAccessibilityWebPageObjectBase.h: Copied from Source/WebKit2/WebProcess/WebPage/mac/WKAccessibilityWebPageObject.h.
* WebProcess/WebPage/mac/WKAccessibilityWebPageObjectBase.mm: Copied from Source/WebKit2/WebProcess/WebPage/mac/WKAccessibilityWebPageObject.mm.
(-[WKAccessibilityWebPageObjectBase accessibilityFocusedUIElement]):
* WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.h: Added.
* WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm: Added.
(-[WKAccessibilityWebPageObject accessibilityIsIgnored]):
(-[WKAccessibilityWebPageObject accessibilityAttributeNames]):
(-[WKAccessibilityWebPageObject accessibilityParameterizedAttributeNames]):
(-[WKAccessibilityWebPageObject accessibilityIsAttributeSettable:]):
(-[WKAccessibilityWebPageObject accessibilitySetValue:forAttribute:]):
(-[WKAccessibilityWebPageObject convertScreenPointToRootView:]):
(-[WKAccessibilityWebPageObject accessibilityActionNames]):
(-[WKAccessibilityWebPageObject accessibilityChildren]):
(-[WKAccessibilityWebPageObject accessibilityAttributeValue:]):
(-[WKAccessibilityWebPageObject accessibilityAttributeValue:forParameter:]):
(-[WKAccessibilityWebPageObject accessibilityShouldUseUniqueId]):
(-[WKAccessibilityWebPageObject accessibilityHitTest:]):
* WebProcess/WebPage/mac/WebPageMac.mm:
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformInitializeProcess):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@165014 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Composited masks not working on iOS after r164890
https://bugs.webkit.org/show_bug.cgi?id=129630

Reviewed by Jer Noble.

Fix typo in UIView-related masks code; set the mask layer
on the view, not the maskView.

* Shared/mac/RemoteLayerTreePropertyApplier.mm:
(WebKit::RemoteLayerTreePropertyApplier::applyProperties):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@165015 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Space between double underlines does not scale with font size
https://bugs.webkit.org/show_bug.cgi?id=129521

Reviewed by Simon Fraser.

Source/WebCore:

This patch moves the logic about how far to draw the second underline (when text-decoration-style: double
is specified) from InlineTextBox to GraphicsContext, because GraphicsContext is the authoritative source
about how thick underlines should be. The space between the two underlines is set to the thickness of
each of the underlines.

This patch also deletes some unused code in InlineTextBox that was never getting triggered, in addition
to unifying drawLineForText with drawLinesForText. This didn't have any performance impact in my testing.

Test: fast/css3-text/css3-text-decoration/text-decoration-style-double-space-scales.html

* platform/graphics/GraphicsContext.h: drawLineForText takes a boolean for if we should draw double
underlines.
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::drawLineForText):
(WebCore::GraphicsContext::drawLinesForText):
* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContext::drawLineForText):
* platform/graphics/wince/GraphicsContextWinCE.cpp:
(WebCore::GraphicsContext::drawLineForText):
* rendering/InlineTextBox.cpp: Use new boolean argument
(WebCore::drawSkipInkUnderline):
(WebCore::InlineTextBox::paintDecoration):

LayoutTests:

This test renders large text with a double underline, but then barely clips off the bottom underline
using overflow: hidden. It makes sure that this is exactly the same as a single underline. If the
space between the two underlines does not scale with font size, it will appear as though there is a
single thick underline (because they will be drawn on top of each other) and will thus fail this test.

* fast/css3-text/css3-text-decoration/text-decoration-style-double-space-scales-expected.html: Added.
* fast/css3-text/css3-text-decoration/text-decoration-style-double-space-scales.html: Added.

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