diff options
author | Ben Murdoch <benm@google.com> | 2010-07-22 15:37:06 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-07-27 10:20:25 +0100 |
commit | 967717af5423377c967781471ee106e2bb4e11c8 (patch) | |
tree | 1e701dc0a12f7f07cce1df4a7681717de77a211b /WebKit/chromium/src | |
parent | dcc30a9fca45f634b1d3a12b276d3a0ccce99fc3 (diff) | |
download | external_webkit-967717af5423377c967781471ee106e2bb4e11c8.zip external_webkit-967717af5423377c967781471ee106e2bb4e11c8.tar.gz external_webkit-967717af5423377c967781471ee106e2bb4e11c8.tar.bz2 |
Merge WebKit at r63859 : Initial merge by git.
Change-Id: Ie8096c63ec7c991c9a9cba8bdd9c3b74a3b8ed62
Diffstat (limited to 'WebKit/chromium/src')
47 files changed, 740 insertions, 2109 deletions
diff --git a/WebKit/chromium/src/ApplicationCacheHostInternal.h b/WebKit/chromium/src/ApplicationCacheHostInternal.h index 902b9b5..c88420b 100644 --- a/WebKit/chromium/src/ApplicationCacheHostInternal.h +++ b/WebKit/chromium/src/ApplicationCacheHostInternal.h @@ -53,6 +53,11 @@ public: m_outerHost.set(webFrame->client()->createApplicationCacheHost(webFrame, this)); } + virtual void didChangeCacheAssociation() + { + // FIXME: Prod the inspector to update it's notion of what cache the page is using. + } + virtual void notifyEventListener(WebKit::WebApplicationCacheHost::EventID eventID) { m_innerHost->notifyDOMApplicationCache(static_cast<ApplicationCacheHost::EventID>(eventID), 0, 0); diff --git a/WebKit/chromium/src/AutoFillPopupMenuClient.cpp b/WebKit/chromium/src/AutoFillPopupMenuClient.cpp index 1294561..6b74f60 100644 --- a/WebKit/chromium/src/AutoFillPopupMenuClient.cpp +++ b/WebKit/chromium/src/AutoFillPopupMenuClient.cpp @@ -66,28 +66,47 @@ unsigned AutoFillPopupMenuClient::getSuggestionsCount() const WebString AutoFillPopupMenuClient::getSuggestion(unsigned listIndex) const { - if (listIndex == static_cast<unsigned>(m_separatorIndex)) + int index = convertListIndexToInternalIndex(listIndex); + if (index == -1) return WebString(); - if (m_separatorIndex != -1 && listIndex > static_cast<unsigned>(m_separatorIndex)) - --listIndex; - - // FIXME: Modify the PopupMenu to add the label in gray right-justified. - ASSERT(listIndex < m_names.size()); + ASSERT(index >= 0 && static_cast<size_t>(index) < m_names.size()); + return m_names[index]; +} - WebString suggestion = m_names[listIndex]; - if (m_labels[listIndex].isEmpty()) - return suggestion; +WebString AutoFillPopupMenuClient::getLabel(unsigned listIndex) const +{ + int index = convertListIndexToInternalIndex(listIndex); + if (index == -1) + return WebString(); - return suggestion + String(" (") + m_labels[listIndex] + String(")"); + ASSERT(index >= 0 && static_cast<size_t>(index) < m_labels.size()); + return m_labels[index]; } void AutoFillPopupMenuClient::removeSuggestionAtIndex(unsigned listIndex) { - // FIXME: Do we want to remove AutoFill suggestions? - ASSERT(listIndex < m_names.size()); - m_names.remove(listIndex); - m_labels.remove(listIndex); + if (!canRemoveSuggestionAtIndex(listIndex)) + return; + + int index = convertListIndexToInternalIndex(listIndex); + + ASSERT(static_cast<unsigned>(index) < m_names.size()); + + m_names.remove(index); + m_labels.remove(index); + + // Shift the separator index if necessary. + if (m_separatorIndex != -1) + m_separatorIndex--; +} + +bool AutoFillPopupMenuClient::canRemoveSuggestionAtIndex(unsigned listIndex) +{ + // Only allow deletion of items before the separator and those that don't + // have a label (autocomplete). + int index = convertListIndexToInternalIndex(listIndex); + return m_labels[index].isEmpty() && (m_separatorIndex == -1 || listIndex < static_cast<unsigned>(m_separatorIndex)); } void AutoFillPopupMenuClient::valueChanged(unsigned listIndex, bool fireEvents) @@ -119,6 +138,7 @@ void AutoFillPopupMenuClient::valueChanged(unsigned listIndex, bool fireEvents) webView->client()->didAcceptAutoFillSuggestion(WebNode(getTextField()), m_names[listIndex], m_labels[listIndex], + m_uniqueIDs[listIndex], listIndex); } } @@ -136,13 +156,15 @@ void AutoFillPopupMenuClient::selectionChanged(unsigned listIndex, bool fireEven webView->client()->didSelectAutoFillSuggestion(WebNode(getTextField()), m_names[listIndex], - m_labels[listIndex]); + m_labels[listIndex], + m_uniqueIDs[listIndex]); } void AutoFillPopupMenuClient::selectionCleared() { - // Same effect desired as popupDidHide, so call through. - popupDidHide(); + WebViewImpl* webView = getWebView(); + if (webView) + webView->client()->didClearAutoFillSelection(WebNode(getTextField())); } String AutoFillPopupMenuClient::itemText(unsigned listIndex) const @@ -150,6 +172,11 @@ String AutoFillPopupMenuClient::itemText(unsigned listIndex) const return getSuggestion(listIndex); } +String AutoFillPopupMenuClient::itemLabel(unsigned listIndex) const +{ + return getLabel(listIndex); +} + PopupMenuStyle AutoFillPopupMenuClient::itemStyle(unsigned listIndex) const { return *m_style; @@ -222,9 +249,11 @@ void AutoFillPopupMenuClient::initialize( HTMLInputElement* textField, const WebVector<WebString>& names, const WebVector<WebString>& labels, + const WebVector<int>& uniqueIDs, int separatorIndex) { ASSERT(names.size() == labels.size()); + ASSERT(names.size() == uniqueIDs.size()); ASSERT(separatorIndex < static_cast<int>(names.size())); m_selectedIndex = -1; @@ -232,7 +261,7 @@ void AutoFillPopupMenuClient::initialize( // The suggestions must be set before initializing the // AutoFillPopupMenuClient. - setSuggestions(names, labels, separatorIndex); + setSuggestions(names, labels, uniqueIDs, separatorIndex); FontDescription fontDescription; RenderTheme::defaultTheme()->systemFont(CSSValueWebkitControl, @@ -251,16 +280,20 @@ void AutoFillPopupMenuClient::initialize( void AutoFillPopupMenuClient::setSuggestions(const WebVector<WebString>& names, const WebVector<WebString>& labels, + const WebVector<int>& uniqueIDs, int separatorIndex) { ASSERT(names.size() == labels.size()); + ASSERT(names.size() == uniqueIDs.size()); ASSERT(separatorIndex < static_cast<int>(names.size())); m_names.clear(); m_labels.clear(); + m_uniqueIDs.clear(); for (size_t i = 0; i < names.size(); ++i) { m_names.append(names[i]); m_labels.append(labels[i]); + m_uniqueIDs.append(uniqueIDs[i]); } m_separatorIndex = separatorIndex; @@ -270,6 +303,16 @@ void AutoFillPopupMenuClient::setSuggestions(const WebVector<WebString>& names, setSelectedIndex(-1); } +int AutoFillPopupMenuClient::convertListIndexToInternalIndex(unsigned listIndex) const +{ + if (listIndex == static_cast<unsigned>(m_separatorIndex)) + return -1; + + if (m_separatorIndex == -1 || listIndex < static_cast<unsigned>(m_separatorIndex)) + return listIndex; + return listIndex - 1; +} + WebViewImpl* AutoFillPopupMenuClient::getWebView() const { Frame* frame = m_textField->document()->frame(); @@ -288,7 +331,7 @@ RenderStyle* AutoFillPopupMenuClient::textFieldStyle() const RenderStyle* style = m_textField->computedStyle(); if (!style) { // It seems we can only have a 0 style in a TextField if the - // node is detached, in which case we the popup shoud not be + // node is detached, in which case we the popup should not be // showing. Please report this in http://crbug.com/7708 and // include the page you were visiting. ASSERT_NOT_REACHED(); diff --git a/WebKit/chromium/src/AutoFillPopupMenuClient.h b/WebKit/chromium/src/AutoFillPopupMenuClient.h index a7d6693..289c8d0 100644 --- a/WebKit/chromium/src/AutoFillPopupMenuClient.h +++ b/WebKit/chromium/src/AutoFillPopupMenuClient.h @@ -57,14 +57,21 @@ public: // Returns the suggestion at |listIndex|. virtual WebString getSuggestion(unsigned listIndex) const; + // Returns the label at |listIndex|. + virtual WebString getLabel(unsigned listIndex) const; + // Removes the suggestion at |listIndex| from the list of suggestions. virtual void removeSuggestionAtIndex(unsigned listIndex); + // Returns true if the suggestion at |listIndex| can be removed. + bool canRemoveSuggestionAtIndex(unsigned listIndex); + // WebCore::PopupMenuClient methods: virtual void valueChanged(unsigned listIndex, bool fireEvents = true); virtual void selectionChanged(unsigned, bool); virtual void selectionCleared(); virtual WebCore::String itemText(unsigned listIndex) const; + virtual WebCore::String itemLabel(unsigned listIndex) const; virtual WebCore::String itemToolTip(unsigned lastIndex) const { return WebCore::String(); } virtual WebCore::String itemAccessibilityText(unsigned lastIndex) const { return WebCore::String(); } virtual bool itemIsEnabled(unsigned listIndex) const { return true; } @@ -93,10 +100,12 @@ public: void initialize(WebCore::HTMLInputElement*, const WebVector<WebString>& names, const WebVector<WebString>& labels, + const WebVector<int>& uniqueIDs, int separatorIndex); void setSuggestions(const WebVector<WebString>& names, const WebVector<WebString>& labels, + const WebVector<int>& uniqueIDs, int separatorIndex); // DEPRECATED: Will be removed once Autocomplete and AutoFill merge is @@ -104,6 +113,10 @@ public: void setAutocompleteMode(bool enabled) { m_AutocompleteModeEnabled = enabled; } private: + // Convert the specified index from an index into the visible list (which might + // include a separator entry) to an index to |m_names| and |m_labels|. + // Returns -1 if the given index points to the separator. + int convertListIndexToInternalIndex(unsigned) const; WebViewImpl* getWebView() const; WebCore::HTMLInputElement* getTextField() const { return m_textField.get(); } WebCore::RenderStyle* textFieldStyle() const; @@ -114,6 +127,7 @@ private: // The names and labels that make up the text of the menu items. Vector<WebCore::String> m_names; Vector<WebCore::String> m_labels; + Vector<int> m_uniqueIDs; // The index of the separator. -1 if there is no separator. int m_separatorIndex; diff --git a/WebKit/chromium/src/ChromeClientImpl.cpp b/WebKit/chromium/src/ChromeClientImpl.cpp index 54c81aa..d43d88a 100644 --- a/WebKit/chromium/src/ChromeClientImpl.cpp +++ b/WebKit/chromium/src/ChromeClientImpl.cpp @@ -31,8 +31,8 @@ #include "config.h" #include "ChromeClientImpl.h" -#include "AccessibilityObject.h" #include "AXObjectCache.h" +#include "AccessibilityObject.h" #include "CharacterNames.h" #include "Console.h" #include "Cursor.h" @@ -43,9 +43,9 @@ #include "FloatRect.h" #include "FrameLoadRequest.h" #include "FrameView.h" +#include "GLES2Context.h" #include "Geolocation.h" #include "GeolocationService.h" -#include "WebGeolocationService.h" #include "GeolocationServiceChromium.h" #include "GraphicsLayer.h" #include "HTMLNames.h" @@ -56,6 +56,7 @@ #include "Page.h" #include "PopupMenuChromium.h" #include "ScriptController.h" +#include "WebGeolocationService.h" #if USE(V8) #include "V8Proxy.h" #endif @@ -588,6 +589,11 @@ void ChromeClientImpl::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> fileCh WebFileChooserParams params; params.multiSelect = fileChooser->allowsMultipleFiles(); +#if ENABLE(DIRECTORY_UPLOAD) + params.directory = fileChooser->allowsDirectoryUpload(); +#else + params.directory = false; +#endif params.acceptTypes = fileChooser->acceptTypes(); params.selectedFiles = fileChooser->filenames(); if (params.selectedFiles.size() > 0) @@ -728,6 +734,16 @@ void ChromeClientImpl::scheduleCompositingLayerSync() { m_webView->setRootLayerNeedsDisplay(); } + +PassOwnPtr<GLES2Context> ChromeClientImpl::getOnscreenGLES2Context() +{ + return m_webView->getOnscreenGLES2Context(); +} + +PassOwnPtr<GLES2Context> ChromeClientImpl::getOffscreenGLES2Context() +{ + return m_webView->getOffscreenGLES2Context(); +} #endif bool ChromeClientImpl::supportsFullscreenForNode(const WebCore::Node* node) diff --git a/WebKit/chromium/src/ChromeClientImpl.h b/WebKit/chromium/src/ChromeClientImpl.h index 84355c3..e824381 100644 --- a/WebKit/chromium/src/ChromeClientImpl.h +++ b/WebKit/chromium/src/ChromeClientImpl.h @@ -126,7 +126,7 @@ public: virtual void cancelGeolocationPermissionRequestForFrame(WebCore::Frame*, WebCore::Geolocation*); virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>); virtual void chooseIconForFiles(const Vector<WebCore::String>&, WebCore::FileChooser*); - virtual bool setCursor(WebCore::PlatformCursorHandle) { return false; } + virtual void setCursor(const WebCore::Cursor&) { } virtual void formStateDidChange(const WebCore::Node*); virtual PassOwnPtr<WebCore::HTMLParserQuirks> createHTMLParserQuirks() { return 0; } #if ENABLE(TOUCH_EVENTS) @@ -145,7 +145,11 @@ public: // Sets a flag to specify that the view needs to be updated, so we need // to do an eager layout before the drawing. virtual void scheduleCompositingLayerSync(); + + virtual PassOwnPtr<WebCore::GLES2Context> getOnscreenGLES2Context(); + virtual PassOwnPtr<WebCore::GLES2Context> getOffscreenGLES2Context(); #endif + virtual bool supportsFullscreenForNode(const WebCore::Node*); virtual void enterFullscreenForNode(WebCore::Node*); virtual void exitFullscreenForNode(WebCore::Node*); diff --git a/WebKit/chromium/src/ChromiumBridge.cpp b/WebKit/chromium/src/ChromiumBridge.cpp index 5124a7f..333020f 100644 --- a/WebKit/chromium/src/ChromiumBridge.cpp +++ b/WebKit/chromium/src/ChromiumBridge.cpp @@ -691,6 +691,14 @@ void ChromiumBridge::paintScrollbarTrack( alignRect); } +void ChromiumBridge::paintSpinButton( + GraphicsContext* gc, int part, int state, int classicState, + const IntRect& rect) +{ + webKitClient()->themeEngine()->paintSpinButton( + gc->platformContext()->canvas(), part, state, classicState, rect); +} + void ChromiumBridge::paintTextField( GraphicsContext* gc, int part, int state, int classicState, const IntRect& rect, const Color& color, bool fillContentArea, diff --git a/WebKit/chromium/src/DebuggerAgentManager.cpp b/WebKit/chromium/src/DebuggerAgentManager.cpp index 939f4ed..1cc6740 100644 --- a/WebKit/chromium/src/DebuggerAgentManager.cpp +++ b/WebKit/chromium/src/DebuggerAgentManager.cpp @@ -119,10 +119,8 @@ DebuggerAgentManager::AttachedAgentsMap* DebuggerAgentManager::s_attachedAgentsM void DebuggerAgentManager::debugAttach(DebuggerAgentImpl* debuggerAgent) { -#if ENABLE(V8_SCRIPT_DEBUG_SERVER) if (!s_exposeV8DebuggerProtocol) return; -#endif if (!s_attachedAgentsMap) { s_attachedAgentsMap = new AttachedAgentsMap(); v8::Debug::SetMessageHandler2(&DebuggerAgentManager::onV8DebugMessage); @@ -135,10 +133,8 @@ void DebuggerAgentManager::debugAttach(DebuggerAgentImpl* debuggerAgent) void DebuggerAgentManager::debugDetach(DebuggerAgentImpl* debuggerAgent) { -#if ENABLE(V8_SCRIPT_DEBUG_SERVER) if (!s_exposeV8DebuggerProtocol) return; -#endif if (!s_attachedAgentsMap) { ASSERT_NOT_REACHED(); return; diff --git a/WebKit/chromium/src/EditorClientImpl.cpp b/WebKit/chromium/src/EditorClientImpl.cpp index 4ae4934..11977b6 100644 --- a/WebKit/chromium/src/EditorClientImpl.cpp +++ b/WebKit/chromium/src/EditorClientImpl.cpp @@ -935,10 +935,14 @@ void EditorClientImpl::getGuessesForWord(const String&, notImplemented(); } -void EditorClientImpl::setInputMethodState(bool enabled) +void EditorClientImpl::willSetInputMethodState() { if (m_webView->client()) m_webView->client()->resetInputMethod(); } +void EditorClientImpl::setInputMethodState(bool) +{ +} + } // namesace WebKit diff --git a/WebKit/chromium/src/EditorClientImpl.h b/WebKit/chromium/src/EditorClientImpl.h index 006b609..549a512 100644 --- a/WebKit/chromium/src/EditorClientImpl.h +++ b/WebKit/chromium/src/EditorClientImpl.h @@ -108,6 +108,7 @@ public: virtual bool spellingUIIsShowing(); virtual void getGuessesForWord(const WebCore::String& word, WTF::Vector<WebCore::String>& guesses); + virtual void willSetInputMethodState(); virtual void setInputMethodState(bool enabled); // Shows the form autofill popup for |node| if it is an HTMLInputElement and diff --git a/WebKit/chromium/src/GLES2Context.cpp b/WebKit/chromium/src/GLES2Context.cpp index f342436..b4b4bb2 100644 --- a/WebKit/chromium/src/GLES2Context.cpp +++ b/WebKit/chromium/src/GLES2Context.cpp @@ -31,6 +31,7 @@ #include "config.h" #include "GLES2Context.h" +#include "GLES2ContextInternal.h" #include "IntSize.h" #include "WebGLES2Context.h" #include "WebKit.h" @@ -52,68 +53,23 @@ using namespace WebKit; namespace WebCore { -class GLES2ContextInternal { -public: - GLES2ContextInternal() {} - ~GLES2ContextInternal() {} - - bool initializeOnscreen(Page*); - bool initializeOffscreen(GLES2Context*); - - WebGLES2Context* getWebGLES2Context() { return m_impl; } - -private: - WebGLES2Context* m_impl; -}; - -bool GLES2ContextInternal::initializeOnscreen(Page* page) +PassOwnPtr<GLES2ContextInternal> GLES2ContextInternal::create(WebGLES2Context* impl, bool owns) { - ASSERT(page); - WebViewImpl* webView = WebViewImpl::fromPage(page); - m_impl = webView->gles2Context(); - if (!m_impl) - return false; - - return true; -} - -bool GLES2ContextInternal::initializeOffscreen(GLES2Context* parent) -{ - m_impl = webKitClient()->createGLES2Context(); - if (!m_impl) - return false; - if (!m_impl->initialize(0, parent ? parent->m_internal->m_impl : 0)) { - delete m_impl; - return false; - } - return true; + PassOwnPtr<GLES2ContextInternal> result = new GLES2ContextInternal(impl, owns); + return result; } -PassOwnPtr<GLES2Context> GLES2Context::createOnscreen(Page* page) +PassOwnPtr<GLES2Context> GLES2Context::create(PassOwnPtr<GLES2ContextInternal> internal) { - GLES2ContextInternal* internal = new GLES2ContextInternal(); - if (!internal->initializeOnscreen(page)) { - delete internal; - return 0; - } PassOwnPtr<GLES2Context> result = new GLES2Context(); - result->m_internal.set(internal); + result->m_internal = internal; return result; } -PassOwnPtr<GLES2Context> GLES2Context::createOffscreen(GLES2Context* parent) +GLES2Context::GLES2Context() { - GLES2ContextInternal* internal = new GLES2ContextInternal(); - if (!internal->initializeOffscreen(parent)) { - delete internal; - return 0; - } - PassOwnPtr<GLES2Context> result = new GLES2Context(); - result->m_internal.set(internal); - return result; } - GLES2Context::~GLES2Context() { } diff --git a/WebKit/chromium/src/GLES2ContextInternal.cpp b/WebKit/chromium/src/GLES2ContextInternal.cpp new file mode 100644 index 0000000..33eb602 --- /dev/null +++ b/WebKit/chromium/src/GLES2ContextInternal.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "GLES2ContextInternal.h" + +#include "WebGLES2Context.h" + +namespace WebCore { + +GLES2ContextInternal::GLES2ContextInternal(WebKit::WebGLES2Context* impl, bool owns) + : m_impl(impl) + , m_owns(owns) +{ +} + +GLES2ContextInternal::~GLES2ContextInternal() +{ + if (m_owns) + delete m_impl; +} + +} // namespace WebCore + diff --git a/WebKit/chromium/src/GLES2ContextInternal.h b/WebKit/chromium/src/GLES2ContextInternal.h new file mode 100644 index 0000000..4668311 --- /dev/null +++ b/WebKit/chromium/src/GLES2ContextInternal.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <wtf/PassOwnPtr.h> + +namespace WebKit { +class WebGLES2Context; +} + +namespace WebCore { + +class GLES2ContextInternal { +public: + // If 'owns' is set to true, this GLES2ContextInternal takes ownership of the passed in WebKit::WebGLES2Context. + static PassOwnPtr<GLES2ContextInternal> create(WebKit::WebGLES2Context* impl, bool owns); + + WebKit::WebGLES2Context* getWebGLES2Context() { return m_impl; } + + ~GLES2ContextInternal(); + +private: + GLES2ContextInternal(WebKit::WebGLES2Context* impl, bool owns); + + WebKit::WebGLES2Context* m_impl; + bool m_owns; +}; + +} diff --git a/WebKit/chromium/src/GraphicsContext3D.cpp b/WebKit/chromium/src/GraphicsContext3D.cpp index 7ba0bce..fec0b20 100644 --- a/WebKit/chromium/src/GraphicsContext3D.cpp +++ b/WebKit/chromium/src/GraphicsContext3D.cpp @@ -112,6 +112,7 @@ public: void reshape(int width, int height); + void paintRenderingResultsToCanvas(WebGLRenderingContext* context); void beginPaint(WebGLRenderingContext* context); void endPaint(); @@ -139,7 +140,9 @@ public: void blendFuncSeparate(unsigned long srcRGB, unsigned long dstRGB, unsigned long srcAlpha, unsigned long dstAlpha); void bufferData(unsigned long target, int size, unsigned long usage); + void bufferData(unsigned long target, ArrayBuffer* data, unsigned long usage); void bufferData(unsigned long target, ArrayBufferView* data, unsigned long usage); + void bufferSubData(unsigned long target, long offset, ArrayBuffer* data); void bufferSubData(unsigned long target, long offset, ArrayBufferView* data); unsigned long checkFramebufferStatus(unsigned long target); @@ -397,7 +400,7 @@ WebGLLayerChromium* GraphicsContext3DInternal::platformLayer() const } #endif -void GraphicsContext3DInternal::beginPaint(WebGLRenderingContext* context) +void GraphicsContext3DInternal::paintRenderingResultsToCanvas(WebGLRenderingContext* context) { HTMLCanvasElement* canvas = context->canvas(); ImageBuffer* imageBuffer = canvas->buffer(); @@ -447,44 +450,20 @@ void GraphicsContext3DInternal::beginPaint(WebGLRenderingContext* context) canvas.drawBitmapRect(m_resizingBitmap, 0, dst); } #elif PLATFORM(CG) - if (m_renderOutput) { - int rowBytes = m_impl->width() * 4; - CGDataProviderRef dataProvider = CGDataProviderCreateWithData(0, m_renderOutput, rowBytes * m_impl->height(), 0); - CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); - CGImageRef cgImage = CGImageCreate(m_impl->width(), - m_impl->height(), - 8, - 32, - rowBytes, - colorSpace, - kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, - dataProvider, - 0, - false, - kCGRenderingIntentDefault); - // CSS styling may cause the canvas's content to be resized on - // the page. Go back to the Canvas to figure out the correct - // width and height to draw. - CGRect rect = CGRectMake(0, 0, - context->canvas()->width(), - context->canvas()->height()); - // We want to completely overwrite the previous frame's - // rendering results. - CGContextSetBlendMode(imageBuffer->context()->platformContext(), - kCGBlendModeCopy); - CGContextSetInterpolationQuality(imageBuffer->context()->platformContext(), - kCGInterpolationNone); - CGContextDrawImage(imageBuffer->context()->platformContext(), - rect, cgImage); - CGImageRelease(cgImage); - CGColorSpaceRelease(colorSpace); - CGDataProviderRelease(dataProvider); - } + if (m_renderOutput) + context->graphicsContext3D()->paintToCanvas(m_renderOutput, m_impl->width(), m_impl->height(), + canvas->width(), canvas->height(), + imageBuffer->context()->platformContext()); #else #error Must port to your platform #endif } +void GraphicsContext3DInternal::beginPaint(WebGLRenderingContext* context) +{ + paintRenderingResultsToCanvas(context); +} + void GraphicsContext3DInternal::endPaint() { } @@ -718,11 +697,21 @@ void GraphicsContext3DInternal::bufferData(unsigned long target, int size, unsig m_impl->bufferData(target, size, 0, usage); } +void GraphicsContext3DInternal::bufferData(unsigned long target, ArrayBuffer* array, unsigned long usage) +{ + m_impl->bufferData(target, array->byteLength(), array->data(), usage); +} + void GraphicsContext3DInternal::bufferData(unsigned long target, ArrayBufferView* array, unsigned long usage) { m_impl->bufferData(target, array->byteLength(), array->baseAddress(), usage); } +void GraphicsContext3DInternal::bufferSubData(unsigned long target, long offset, ArrayBuffer* array) +{ + m_impl->bufferSubData(target, offset, array->byteLength(), array->data()); +} + void GraphicsContext3DInternal::bufferSubData(unsigned long target, long offset, ArrayBufferView* array) { m_impl->bufferSubData(target, offset, array->byteLength(), array->baseAddress()); @@ -1165,7 +1154,9 @@ DELEGATE_TO_INTERNAL_2(blendFunc, unsigned long, unsigned long) DELEGATE_TO_INTERNAL_4(blendFuncSeparate, unsigned long, unsigned long, unsigned long, unsigned long) DELEGATE_TO_INTERNAL_3(bufferData, unsigned long, int, unsigned long) +DELEGATE_TO_INTERNAL_3(bufferData, unsigned long, ArrayBuffer*, unsigned long) DELEGATE_TO_INTERNAL_3(bufferData, unsigned long, ArrayBufferView*, unsigned long) +DELEGATE_TO_INTERNAL_3(bufferSubData, unsigned long, long, ArrayBuffer*) DELEGATE_TO_INTERNAL_3(bufferSubData, unsigned long, long, ArrayBufferView*) DELEGATE_TO_INTERNAL_1R(checkFramebufferStatus, unsigned long, unsigned long) @@ -1311,6 +1302,7 @@ DELEGATE_TO_INTERNAL_6(vertexAttribPointer, unsigned long, int, int, bool, unsig DELEGATE_TO_INTERNAL_4(viewport, long, long, unsigned long, unsigned long) +DELEGATE_TO_INTERNAL_1(paintRenderingResultsToCanvas, WebGLRenderingContext*) DELEGATE_TO_INTERNAL_1(beginPaint, WebGLRenderingContext*) DELEGATE_TO_INTERNAL(endPaint) diff --git a/WebKit/chromium/src/InspectorFrontendClientImpl.cpp b/WebKit/chromium/src/InspectorFrontendClientImpl.cpp index 83b925a..73cedfa 100644 --- a/WebKit/chromium/src/InspectorFrontendClientImpl.cpp +++ b/WebKit/chromium/src/InspectorFrontendClientImpl.cpp @@ -71,9 +71,6 @@ void InspectorFrontendClientImpl::windowObjectCleared() v8::Handle<v8::Object> global = frameContext->Global(); global->Set(v8::String::New("InspectorFrontendHost"), frontendHostObj); -#if ENABLE(V8_SCRIPT_DEBUG_SERVER) - global->Set(v8::String::New("v8ScriptDebugServerEnabled"), v8::True()); -#endif } void InspectorFrontendClientImpl::frontendLoaded() diff --git a/WebKit/chromium/src/ResourceHandle.cpp b/WebKit/chromium/src/ResourceHandle.cpp index a13400d..88f7f39 100644 --- a/WebKit/chromium/src/ResourceHandle.cpp +++ b/WebKit/chromium/src/ResourceHandle.cpp @@ -226,7 +226,7 @@ PassRefPtr<ResourceHandle> ResourceHandle::create(const ResourceRequest& request return 0; } -const ResourceRequest& ResourceHandle::request() const +ResourceRequest& ResourceHandle::firstRequest() { return d->m_request; } @@ -252,6 +252,11 @@ bool ResourceHandle::start(Frame* deprecated) return true; } +bool ResourceHandle::hasAuthenticationChallenge() const +{ + return false; +} + void ResourceHandle::clearAuthentication() { } diff --git a/WebKit/chromium/src/WebAccessibilityCacheImpl.cpp b/WebKit/chromium/src/WebAccessibilityCacheImpl.cpp index 03e5f46..abb63cc 100644 --- a/WebKit/chromium/src/WebAccessibilityCacheImpl.cpp +++ b/WebKit/chromium/src/WebAccessibilityCacheImpl.cpp @@ -64,14 +64,15 @@ WebAccessibilityCache* WebAccessibilityCache::create() PassRefPtr<WebAccessibilityCacheImpl::WeakHandle> WebAccessibilityCacheImpl::WeakHandle::create(AccessibilityObject* object) { // FIXME: Remove resetting ref-count from AccessibilityObjectWrapper - // and convert to use adoptRef. - return new WebAccessibilityCacheImpl::WeakHandle(object); + RefPtr<WebAccessibilityCacheImpl::WeakHandle> weakHandle = adoptRef(new WebAccessibilityCacheImpl::WeakHandle(object)); + weakHandle->m_object->setWrapper(weakHandle.get()); + + return weakHandle.release(); } WebAccessibilityCacheImpl::WeakHandle::WeakHandle(AccessibilityObject* object) : AccessibilityObjectWrapper(object) { - m_object->setWrapper(this); } // WebAccessibilityCacheImpl ---------------------------------------- diff --git a/WebKit/chromium/src/WebDevToolsAgentImpl.cpp b/WebKit/chromium/src/WebDevToolsAgentImpl.cpp index 4205c62..0d8cbad 100644 --- a/WebKit/chromium/src/WebDevToolsAgentImpl.cpp +++ b/WebKit/chromium/src/WebDevToolsAgentImpl.cpp @@ -231,9 +231,7 @@ WebDevToolsAgentImpl::WebDevToolsAgentImpl( WebDevToolsAgentImpl::~WebDevToolsAgentImpl() { DebuggerAgentManager::onWebViewClosed(m_webViewImpl); -#if ENABLE(V8_SCRIPT_DEBUG_SERVER) ClientMessageLoopAdapter::inspectedViewClosed(m_webViewImpl); -#endif disposeUtilityContext(); } @@ -250,10 +248,8 @@ void WebDevToolsAgentImpl::attach() if (m_attached) return; -#if ENABLE(V8_SCRIPT_DEBUG_SERVER) if (!m_client->exposeV8DebuggerProtocol()) ClientMessageLoopAdapter::ensureClientMessageLoopCreated(m_client); -#endif m_debuggerAgentImpl.set( new DebuggerAgentImpl(m_webViewImpl, @@ -294,9 +290,7 @@ void WebDevToolsAgentImpl::detach() void WebDevToolsAgentImpl::didNavigate() { -#if ENABLE(V8_SCRIPT_DEBUG_SERVER) ClientMessageLoopAdapter::didNavigate(); -#endif DebuggerAgentManager::onNavigate(); } @@ -432,11 +426,9 @@ void WebDevToolsAgentImpl::createInspectorFrontendProxy() m_utilityContext = v8::Context::New(); compileUtilityScripts(); initDevToolsAgentHost(); -#if ENABLE(V8_SCRIPT_DEBUG_SERVER) WebCString debuggerScriptJs = m_client->debuggerScriptSource(); WebCore::ScriptDebugServer::shared().setDebuggerScriptSource( WebCore::String(debuggerScriptJs.data(), debuggerScriptJs.length())); -#endif } void WebDevToolsAgentImpl::setInspectorFrontendProxyToInspectorController() diff --git a/WebKit/chromium/src/WebDevToolsFrontendImpl.cpp b/WebKit/chromium/src/WebDevToolsFrontendImpl.cpp index eda2f77..3e83f18 100644 --- a/WebKit/chromium/src/WebDevToolsFrontendImpl.cpp +++ b/WebKit/chromium/src/WebDevToolsFrontendImpl.cpp @@ -105,9 +105,9 @@ WebDevToolsFrontendImpl::WebDevToolsFrontendImpl( InspectorController* ic = m_webViewImpl->page()->inspectorController(); ic->setInspectorFrontendClient(new InspectorFrontendClientImpl(m_webViewImpl->page(), m_client, this)); - // Put DevTools frontend Page into its own group so that it's not - // deferred along with inspected page. - m_webViewImpl->page()->setGroupName("DevToolsFrontend"); + // Put each DevTools frontend Page into its own (single page) group so that it's not + // deferred along with the inspected page. + m_webViewImpl->page()->setGroupName(String()); WebFrameImpl* frame = m_webViewImpl->mainFrameImpl(); v8::HandleScope scope; @@ -174,6 +174,8 @@ void WebDevToolsFrontendImpl::executeScript(const Vector<String>& v) Vector< v8::Handle<v8::Value> > args; for (size_t i = 0; i < v.size(); i++) args.append(ToV8String(v.at(i))); + v8::TryCatch tryCatch; + tryCatch.SetVerbose(true); function->Call(frameContext->Global(), args.size(), args.data()); } diff --git a/WebKit/chromium/src/WebFormElement.cpp b/WebKit/chromium/src/WebFormElement.cpp index 8b4ce04..9c77732 100644 --- a/WebKit/chromium/src/WebFormElement.cpp +++ b/WebKit/chromium/src/WebFormElement.cpp @@ -31,6 +31,7 @@ #include "config.h" #include "WebFormElement.h" +#include "FormState.h" #include "HTMLFormControlElement.h" #include "HTMLFormElement.h" #include "HTMLInputElement.h" @@ -55,16 +56,21 @@ WebString WebFormElement::action() const return constUnwrap<HTMLFormElement>()->action(); } -WebString WebFormElement::name() const +WebString WebFormElement::name() const { return constUnwrap<HTMLFormElement>()->name(); } -WebString WebFormElement::method() const +WebString WebFormElement::method() const { return constUnwrap<HTMLFormElement>()->method(); } - + +bool WebFormElement::wasUserSubmitted() const +{ + return constUnwrap<HTMLFormElement>()->submissionTrigger() == NotSubmittedByJavaScript; +} + void WebFormElement::submit() { unwrap<HTMLFormElement>()->submit(); @@ -77,7 +83,7 @@ void WebFormElement::getNamedElements(const WebString& name, unwrap<HTMLFormElement>()->getNamedElements(name, tempVector); result.assign(tempVector); } - + void WebFormElement::getFormControlElements(WebVector<WebFormControlElement>& result) const { const HTMLFormElement* form = constUnwrap<HTMLFormElement>(); diff --git a/WebKit/chromium/src/WebFrameImpl.cpp b/WebKit/chromium/src/WebFrameImpl.cpp index 535d128..f1c30e2 100644 --- a/WebKit/chromium/src/WebFrameImpl.cpp +++ b/WebKit/chromium/src/WebFrameImpl.cpp @@ -2101,9 +2101,9 @@ int WebFrameImpl::ordinalOfFirstMatchForFrame(WebFrameImpl* frame) const bool WebFrameImpl::shouldScopeMatches(const String& searchText) { - // Don't scope if we can't find a frame or if the frame is not visible. + // Don't scope if we can't find a frame or a view or if the frame is not visible. // The user may have closed the tab/application, so abort. - if (!frame() || !hasVisibleContent()) + if (!frame() || !frame()->view() || !hasVisibleContent()) return false; ASSERT(frame()->document() && frame()->view()); diff --git a/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.cpp b/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.cpp index 0863ec8..47bb5a0 100644 --- a/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.cpp +++ b/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.cpp @@ -710,7 +710,7 @@ bool WebGraphicsContext3DDefaultImpl::readBackFramebuffer(unsigned char* pixels, // vertical flip is only a temporary solution anyway until Chrome // is fully GPU composited, it wasn't worth the complexity. - bool mustRestoreFBO; + bool mustRestoreFBO = false; if (m_attributes.antialias) { glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO); glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo); @@ -1120,6 +1120,10 @@ void WebGraphicsContext3DDefaultImpl::getIntegerv(unsigned long pname, int* valu // Need to emulate IMPLEMENTATION_COLOR_READ_FORMAT/TYPE for GL. Any valid // combination should work, but GL_RGB/GL_UNSIGNED_BYTE might be the most // useful for desktop WebGL users. + // Need to emulate MAX_FRAGMENT/VERTEX_UNIFORM_VECTORS and MAX_VARYING_VECTORS + // because desktop GL's corresponding queries return the number of components + // whereas GLES2 return the number of vectors (each vector has 4 components). + // Therefore, the value returned by desktop GL needs to be divided by 4. makeContextCurrent(); switch (pname) { case 0x8B9B: // IMPLEMENTATION_COLOR_READ_FORMAT @@ -1128,6 +1132,18 @@ void WebGraphicsContext3DDefaultImpl::getIntegerv(unsigned long pname, int* valu case 0x8B9A: // IMPLEMENTATION_COLOR_READ_TYPE *value = GL_UNSIGNED_BYTE; break; + case 0x8DFD: // MAX_FRAGMENT_UNIFORM_VECTORS + glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, value); + *value /= 4; + break; + case 0x8DFB: // MAX_VERTEX_UNIFORM_VECTORS + glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, value); + *value /= 4; + break; + case 0x8DFC: // MAX_VARYING_VECTORS + glGetIntegerv(GL_MAX_VARYING_FLOATS, value); + *value /= 4; + break; default: glGetIntegerv(pname, value); } diff --git a/WebKit/chromium/src/WebIDBDatabaseError.cpp b/WebKit/chromium/src/WebIDBDatabaseError.cpp index 17fdd38..cbbe14a 100644 --- a/WebKit/chromium/src/WebIDBDatabaseError.cpp +++ b/WebKit/chromium/src/WebIDBDatabaseError.cpp @@ -40,11 +40,6 @@ using namespace WebCore; namespace WebKit { -WebIDBDatabaseError::~WebIDBDatabaseError() -{ - m_private.reset(); -} - void WebIDBDatabaseError::assign(const WebIDBDatabaseError& value) { m_private = value.m_private; @@ -55,6 +50,11 @@ void WebIDBDatabaseError::assign(unsigned short code, const WebString& message) m_private = IDBDatabaseError::create(code, message); } +void WebIDBDatabaseError::reset() +{ + m_private.reset(); +} + unsigned short WebIDBDatabaseError::code() const { return m_private->code(); diff --git a/WebKit/chromium/src/WebIDBKey.cpp b/WebKit/chromium/src/WebIDBKey.cpp index a52ea56..1c4c685 100644 --- a/WebKit/chromium/src/WebIDBKey.cpp +++ b/WebKit/chromium/src/WebIDBKey.cpp @@ -36,11 +36,6 @@ using namespace WebCore; namespace WebKit { -WebIDBKey::~WebIDBKey() -{ - m_private.reset(); -} - WebIDBKey WebIDBKey::createNull() { WebIDBKey key; @@ -80,6 +75,11 @@ void WebIDBKey::assignInvalid() m_private = 0; } +void WebIDBKey::reset() +{ + m_private.reset(); +} + WebIDBKey::Type WebIDBKey::type() const { if (!m_private.get()) diff --git a/WebKit/chromium/src/WebMediaElement.cpp b/WebKit/chromium/src/WebMediaElement.cpp new file mode 100644 index 0000000..4adda1e --- /dev/null +++ b/WebKit/chromium/src/WebMediaElement.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebMediaElement.h" + +#include "HTMLMediaElement.h" +#include "MediaPlayer.h" +#include "WebMediaPlayer.h" +#include "WebMediaPlayerClientImpl.h" +#include <wtf/PassRefPtr.h> + +using namespace WebCore; + +namespace WebKit { + +WebMediaPlayer* WebMediaElement::player() const +{ + return WebMediaPlayerClientImpl::fromMediaElement(this)->mediaPlayer(); +} + +WebMediaElement::WebMediaElement(const PassRefPtr<HTMLMediaElement>& elem) + : WebElement(elem) +{ +} + +WebMediaElement& WebMediaElement::operator=(const PassRefPtr<HTMLMediaElement>& elem) +{ + m_private = elem; + return *this; +} + +WebMediaElement::operator PassRefPtr<HTMLMediaElement>() const +{ + return static_cast<HTMLMediaElement*>(m_private.get()); +} +} // namespace WebKit diff --git a/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp b/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp index 03051c3..2b0c9a7 100644 --- a/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp +++ b/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp @@ -14,7 +14,13 @@ #include "KURL.h" #include "MediaPlayer.h" #include "NotImplemented.h" +#include "RenderView.h" #include "TimeRanges.h" +#include "VideoLayerChromium.h" + +#if USE(ACCELERATED_COMPOSITING) +#include "RenderLayerCompositor.h" +#endif #include "WebCanvas.h" #include "WebCString.h" @@ -22,12 +28,14 @@ #include "WebFrameImpl.h" #include "WebKit.h" #include "WebKitClient.h" +#include "WebMediaElement.h" #include "WebMediaPlayer.h" #include "WebMimeRegistry.h" #include "WebRect.h" #include "WebSize.h" #include "WebString.h" #include "WebURL.h" +#include "WebViewImpl.h" // WebCommon.h defines WEBKIT_USING_SKIA so this has to be included last. #if WEBKIT_USING_SKIA @@ -45,6 +53,7 @@ static WebMediaPlayer* createWebMediaPlayer( WebMediaPlayerClient* client, Frame* frame) { WebFrameImpl* webFrame = WebFrameImpl::fromFrame(frame); + if (!webFrame->client()) return 0; return webFrame->client()->createMediaPlayer(webFrame, client); @@ -71,6 +80,17 @@ void WebMediaPlayerClientImpl::registerSelf(MediaEngineRegistrar registrar) } } +WebMediaPlayerClientImpl* WebMediaPlayerClientImpl::fromMediaElement(const WebMediaElement* element) +{ + PlatformMedia pm = element->constUnwrap<HTMLMediaElement>()->platformMedia(); + return static_cast<WebMediaPlayerClientImpl*>(pm.media.chromiumMediaPlayer); +} + +WebMediaPlayer* WebMediaPlayerClientImpl::mediaPlayer() const +{ + return m_webMediaPlayer.get(); +} + // WebMediaPlayerClient -------------------------------------------------------- void WebMediaPlayerClientImpl::networkStateChanged() @@ -146,6 +166,7 @@ void WebMediaPlayerClientImpl::load(const String& url) { Frame* frame = static_cast<HTMLMediaElement*>( m_mediaPlayer->mediaPlayerClient())->document()->frame(); + m_webMediaPlayer.set(createWebMediaPlayer(this, frame)); if (m_webMediaPlayer.get()) m_webMediaPlayer->load(KURL(ParsedURLString, url)); @@ -157,6 +178,22 @@ void WebMediaPlayerClientImpl::cancelLoad() m_webMediaPlayer->cancelLoad(); } +#if USE(ACCELERATED_COMPOSITING) +PlatformLayer* WebMediaPlayerClientImpl::platformLayer() const +{ + ASSERT(m_supportsAcceleratedCompositing); + return m_videoLayer.get(); +} +#endif + +PlatformMedia WebMediaPlayerClientImpl::platformMedia() const +{ + PlatformMedia pm; + pm.type = PlatformMedia::ChromiumMediaPlayerType; + pm.media.chromiumMediaPlayer = const_cast<WebMediaPlayerClientImpl*>(this); + return pm; +} + void WebMediaPlayerClientImpl::play() { if (m_webMediaPlayer.get()) @@ -360,6 +397,13 @@ bool WebMediaPlayerClientImpl::hasSingleSecurityOrigin() const return false; } +#if USE(ACCELERATED_COMPOSITING) +bool WebMediaPlayerClientImpl::supportsAcceleratedRendering() const +{ + return m_supportsAcceleratedCompositing; +} +#endif + MediaPlayer::MovieLoadType WebMediaPlayerClientImpl::movieLoadType() const { if (m_webMediaPlayer.get()) @@ -372,6 +416,22 @@ MediaPlayerPrivateInterface* WebMediaPlayerClientImpl::create(MediaPlayer* playe { WebMediaPlayerClientImpl* client = new WebMediaPlayerClientImpl(); client->m_mediaPlayer = player; + +#if USE(ACCELERATED_COMPOSITING) + Frame* frame = static_cast<HTMLMediaElement*>( + client->m_mediaPlayer->mediaPlayerClient())->document()->frame(); + + // This does not actually check whether the hardware can support accelerated + // compositing, but only if the flag is set. However, this is checked lazily + // in WebViewImpl::setIsAcceleratedCompositingActive() and will fail there + // if necessary. + client->m_supportsAcceleratedCompositing = + frame->contentRenderer()->compositor()->hasAcceleratedCompositing(); + + if (client->m_supportsAcceleratedCompositing) + client->m_videoLayer = VideoLayerChromium::create(0); +#endif + return client; } @@ -402,6 +462,10 @@ MediaPlayer::SupportsType WebMediaPlayerClientImpl::supportsType(const String& t WebMediaPlayerClientImpl::WebMediaPlayerClientImpl() : m_mediaPlayer(0) +#if USE(ACCELERATED_COMPOSITING) + , m_videoLayer(0) + , m_supportsAcceleratedCompositing(false) +#endif { } diff --git a/WebKit/chromium/src/WebMediaPlayerClientImpl.h b/WebKit/chromium/src/WebMediaPlayerClientImpl.h index 57c93b7..0faac26 100644 --- a/WebKit/chromium/src/WebMediaPlayerClientImpl.h +++ b/WebKit/chromium/src/WebMediaPlayerClientImpl.h @@ -39,6 +39,7 @@ namespace WebKit { +class WebMediaElement; class WebMediaPlayer; // This class serves as a bridge between WebCore::MediaPlayer and @@ -50,6 +51,11 @@ public: static void setIsEnabled(bool); static void registerSelf(WebCore::MediaEngineRegistrar); + static WebMediaPlayerClientImpl* fromMediaElement(const WebMediaElement* element); + + // Returns the encapsulated WebKit::WebMediaPlayer. + WebMediaPlayer* mediaPlayer() const; + // WebMediaPlayerClient methods: virtual void networkStateChanged(); virtual void readyStateChanged(); @@ -66,6 +72,10 @@ public: // MediaPlayerPrivateInterface methods: virtual void load(const WebCore::String& url); virtual void cancelLoad(); +#if USE(ACCELERATED_COMPOSITING) + virtual WebCore::PlatformLayer* platformLayer() const; +#endif + virtual WebCore::PlatformMedia platformMedia() const; virtual void play(); virtual void pause(); virtual bool supportsFullscreen() const; @@ -94,6 +104,10 @@ public: virtual void setSize(const WebCore::IntSize&); virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect&); virtual bool hasSingleSecurityOrigin() const; +#if USE(ACCELERATED_COMPOSITING) + virtual bool supportsAcceleratedRendering() const; +#endif + virtual WebCore::MediaPlayer::MovieLoadType movieLoadType() const; private: @@ -106,6 +120,10 @@ private: WebCore::MediaPlayer* m_mediaPlayer; OwnPtr<WebMediaPlayer> m_webMediaPlayer; +#if USE(ACCELERATED_COMPOSITING) + RefPtr<WebCore::PlatformLayer> m_videoLayer; + bool m_supportsAcceleratedCompositing; +#endif static bool m_isEnabled; }; diff --git a/WebKit/chromium/src/WebOptionElement.cpp b/WebKit/chromium/src/WebOptionElement.cpp new file mode 100644 index 0000000..49bff3b --- /dev/null +++ b/WebKit/chromium/src/WebOptionElement.cpp @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebOptionElement.h" + +#include "HTMLNames.h" +#include "HTMLOptionElement.h" +#include "HTMLSelectElement.h" +#include "WebString.h" +#include <wtf/PassRefPtr.h> + +using namespace WebCore; + +namespace WebKit { + +void WebOptionElement::setValue(const WebString& newValue) +{ + return unwrap<HTMLOptionElement>()->setValue(newValue); +} + +WebString WebOptionElement::value() const +{ + return constUnwrap<HTMLOptionElement>()->value(); +} + +int WebOptionElement::index() const +{ + return constUnwrap<HTMLOptionElement>()->index(); +} + +WebString WebOptionElement::text() const +{ + return constUnwrap<HTMLOptionElement>()->text(); +} + +bool WebOptionElement::defaultSelected() const +{ + return constUnwrap<HTMLOptionElement>()->defaultSelected(); +} + +void WebOptionElement::setDefaultSelected(bool newSelected) +{ + return unwrap<HTMLOptionElement>()->setDefaultSelected(newSelected); +} + +WebString WebOptionElement::label() const +{ + return constUnwrap<HTMLOptionElement>()->label(); +} + +bool WebOptionElement::isEnabled() const +{ + return !(constUnwrap<HTMLOptionElement>()->disabled()); +} + +WebOptionElement::WebOptionElement(const PassRefPtr<HTMLOptionElement>& elem) + : WebFormControlElement(elem) +{ +} + +WebOptionElement& WebOptionElement::operator=(const PassRefPtr<HTMLOptionElement>& elem) +{ + m_private = elem; + return *this; +} + +WebOptionElement::operator PassRefPtr<HTMLOptionElement>() const +{ + return static_cast<HTMLOptionElement*>(m_private.get()); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebPopupMenuImpl.cpp b/WebKit/chromium/src/WebPopupMenuImpl.cpp index 2abdc62..75d6cc1 100644 --- a/WebKit/chromium/src/WebPopupMenuImpl.cpp +++ b/WebKit/chromium/src/WebPopupMenuImpl.cpp @@ -318,6 +318,10 @@ void WebPopupMenuImpl::scrollbarsModeDidChange() const // Nothing to be done since we have no concept of different scrollbar modes. } +void WebPopupMenuImpl::setCursor(const WebCore::Cursor&) +{ +} + //----------------------------------------------------------------------------- // WebCore::FramelessScrollViewClient diff --git a/WebKit/chromium/src/WebPopupMenuImpl.h b/WebKit/chromium/src/WebPopupMenuImpl.h index 4f5c2de..edbb4ab 100644 --- a/WebKit/chromium/src/WebPopupMenuImpl.h +++ b/WebKit/chromium/src/WebPopupMenuImpl.h @@ -110,6 +110,7 @@ public: virtual PlatformPageClient platformPageClient() const { return 0; } virtual void scrollRectIntoView(const WebCore::IntRect&, const WebCore::ScrollView*) const; virtual void scrollbarsModeDidChange() const; + virtual void setCursor(const WebCore::Cursor&); // WebCore::FramelessScrollViewClient methods: virtual void popupClosed(WebCore::FramelessScrollView*); diff --git a/WebKit/chromium/src/WebRuntimeFeatures.cpp b/WebKit/chromium/src/WebRuntimeFeatures.cpp index 595a47f..efb287c 100644 --- a/WebKit/chromium/src/WebRuntimeFeatures.cpp +++ b/WebKit/chromium/src/WebRuntimeFeatures.cpp @@ -226,4 +226,14 @@ bool WebRuntimeFeatures::isTouchEnabled() #endif } +void WebRuntimeFeatures::enableDeviceOrientation(bool enable) +{ + RuntimeEnabledFeatures::setDeviceOrientationEnabled(enable); +} + +bool WebRuntimeFeatures::isDeviceOrientationEnabled() +{ + return RuntimeEnabledFeatures::deviceOrientationEnabled(); +} + } // namespace WebKit diff --git a/WebKit/chromium/src/WebSelectElement.cpp b/WebKit/chromium/src/WebSelectElement.cpp index 6516cc3..79a4d85 100644 --- a/WebKit/chromium/src/WebSelectElement.cpp +++ b/WebKit/chromium/src/WebSelectElement.cpp @@ -31,6 +31,8 @@ #include "config.h" #include "WebSelectElement.h" +#include "HTMLNames.h" +#include "HTMLOptionElement.h" #include "HTMLSelectElement.h" #include "WebString.h" #include <wtf/PassRefPtr.h> @@ -49,6 +51,16 @@ WebString WebSelectElement::value() return unwrap<HTMLSelectElement>()->value(); } +WebVector<WebElement> WebSelectElement::listItems() +{ + const Vector<Element*>& sourceItems = unwrap<HTMLSelectElement>()->listItems(); + WebVector<WebElement> items(sourceItems.size()); + for (size_t i = 0; i < sourceItems.size(); ++i) + items[i] = WebElement(static_cast<HTMLElement*>(sourceItems[i])); + + return items; +} + WebSelectElement::WebSelectElement(const PassRefPtr<HTMLSelectElement>& elem) : WebFormControlElement(elem) { diff --git a/WebKit/chromium/src/WebSettingsImpl.cpp b/WebKit/chromium/src/WebSettingsImpl.cpp index 7e89a77..6a02ed6 100644 --- a/WebKit/chromium/src/WebSettingsImpl.cpp +++ b/WebKit/chromium/src/WebSettingsImpl.cpp @@ -284,4 +284,9 @@ void WebSettingsImpl::setHTML5ParserEnabled(bool enabled) m_settings->setHTML5ParserEnabled(enabled); } +void WebSettingsImpl::setMemoryInfoEnabled(bool enabled) +{ + m_settings->setMemoryInfoEnabled(enabled); +} + } // namespace WebKit diff --git a/WebKit/chromium/src/WebSettingsImpl.h b/WebKit/chromium/src/WebSettingsImpl.h index 70bd792..fe5db51 100644 --- a/WebKit/chromium/src/WebSettingsImpl.h +++ b/WebKit/chromium/src/WebSettingsImpl.h @@ -88,6 +88,7 @@ public: virtual void setEditingBehavior(EditingBehavior); virtual void setAcceleratedCompositingEnabled(bool); virtual void setHTML5ParserEnabled(bool); + virtual void setMemoryInfoEnabled(bool); private: WebCore::Settings* m_settings; diff --git a/WebKit/chromium/src/WebURLRequest.cpp b/WebKit/chromium/src/WebURLRequest.cpp index 3b2d251..69dfac4 100644 --- a/WebKit/chromium/src/WebURLRequest.cpp +++ b/WebKit/chromium/src/WebURLRequest.cpp @@ -245,6 +245,16 @@ void WebURLRequest::setAppCacheHostID(int appCacheHostID) m_private->m_resourceRequest->setAppCacheHostID(appCacheHostID); } +bool WebURLRequest::downloadToFile() const +{ + return m_private->m_downloadToFile; +} + +void WebURLRequest::setDownloadToFile(bool downloadToFile) +{ + m_private->m_downloadToFile = downloadToFile; +} + ResourceRequest& WebURLRequest::toMutableResourceRequest() { ASSERT(m_private); diff --git a/WebKit/chromium/src/WebURLRequestPrivate.h b/WebKit/chromium/src/WebURLRequestPrivate.h index 2f7c25f..79f6451 100644 --- a/WebKit/chromium/src/WebURLRequestPrivate.h +++ b/WebKit/chromium/src/WebURLRequestPrivate.h @@ -37,13 +37,19 @@ namespace WebKit { class WebURLRequestPrivate { public: - WebURLRequestPrivate() : m_resourceRequest(0), m_allowStoredCredentials(true) { } + WebURLRequestPrivate() + : m_resourceRequest(0) + , m_allowStoredCredentials(true) + , m_downloadToFile(false) { } // Called by WebURLRequest when it no longer needs this object. virtual void dispose() = 0; WebCore::ResourceRequest* m_resourceRequest; bool m_allowStoredCredentials; + + // FIXME: Move this to ResourceRequest once we have an internal consumer. + bool m_downloadToFile; }; } // namespace WebKit diff --git a/WebKit/chromium/src/WebURLResponse.cpp b/WebKit/chromium/src/WebURLResponse.cpp index 2b7facc..0511f8d 100644 --- a/WebKit/chromium/src/WebURLResponse.cpp +++ b/WebKit/chromium/src/WebURLResponse.cpp @@ -107,6 +107,16 @@ void WebURLResponse::setConnectionID(unsigned connectionID) m_private->m_resourceResponse->setConnectionID(connectionID); } +bool WebURLResponse::connectionReused() const +{ + return m_private->m_resourceResponse->connectionReused(); +} + +void WebURLResponse::setConnectionReused(bool connectionReused) +{ + m_private->m_resourceResponse->setConnectionReused(connectionReused); +} + WebURLLoadTiming WebURLResponse::loadTiming() { return WebURLLoadTiming(m_private->m_resourceResponse->resourceLoadTiming()); @@ -352,6 +362,16 @@ void WebURLResponse::setIsMultipartPayload(bool value) m_private->m_resourceResponse->setIsMultipartPayload(value); } +WebString WebURLResponse::downloadFilePath() const +{ + return m_private->m_downloadFilePath; +} + +void WebURLResponse::setDownloadFilePath(const WebString& downloadFilePath) +{ + m_private->m_downloadFilePath = downloadFilePath; +} + void WebURLResponse::assign(WebURLResponsePrivate* p) { // Subclasses may call this directly so a self-assignment check is needed diff --git a/WebKit/chromium/src/WebURLResponsePrivate.h b/WebKit/chromium/src/WebURLResponsePrivate.h index 716c8db..dc5ce22 100644 --- a/WebKit/chromium/src/WebURLResponsePrivate.h +++ b/WebKit/chromium/src/WebURLResponsePrivate.h @@ -31,6 +31,8 @@ #ifndef WebURLResponsePrivate_h #define WebURLResponsePrivate_h +#include "WebString.h" + namespace WebCore { class ResourceResponse; } namespace WebKit { @@ -43,6 +45,9 @@ public: virtual void dispose() = 0; WebCore::ResourceResponse* m_resourceResponse; + + // FIXME: Move this to ResourceResponse once we have an internal consumer. + WebString m_downloadFilePath; }; } // namespace WebKit diff --git a/WebKit/chromium/src/WebViewImpl.cpp b/WebKit/chromium/src/WebViewImpl.cpp index d1ca71e..83c8822 100644 --- a/WebKit/chromium/src/WebViewImpl.cpp +++ b/WebKit/chromium/src/WebViewImpl.cpp @@ -54,10 +54,12 @@ #include "FrameLoader.h" #include "FrameTree.h" #include "FrameView.h" +#include "GLES2Context.h" +#include "GLES2ContextInternal.h" #include "GraphicsContext.h" -#include "HitTestResult.h" #include "HTMLInputElement.h" #include "HTMLMediaElement.h" +#include "HitTestResult.h" #include "HTMLNames.h" #include "Image.h" #include "InspectorController.h" @@ -73,6 +75,7 @@ #include "PlatformContextSkia.h" #include "PlatformKeyboardEvent.h" #include "PlatformMouseEvent.h" +#include "PlatformThemeChromiumGtk.h" #include "PlatformWheelEvent.h" #include "PopupMenuChromium.h" #include "PopupMenuClient.h" @@ -91,6 +94,7 @@ #include "WebDragData.h" #include "WebFrameImpl.h" #include "WebImage.h" +#include "WebInputElement.h" #include "WebInputEvent.h" #include "WebInputEventConversion.h" #include "WebKit.h" @@ -157,10 +161,11 @@ COMPILE_ASSERT_MATCHING_ENUM(DragOperationDelete); COMPILE_ASSERT_MATCHING_ENUM(DragOperationEvery); static const PopupContainerSettings autoFillPopupSettings = { - false, // setTextOnIndexChange - false, // acceptOnAbandon - true, // loopSelectionNavigation - true, // restrictWidthOfListBox. Same as other browser (Fx, IE, and safari) + false, // setTextOnIndexChange + false, // acceptOnAbandon + true, // loopSelectionNavigation + false, // restrictWidthOfListBox (For security reasons show the entire entry + // so the user doesn't enter information it did not intend to.) // For suggestions, we use the direction of the input field as the direction // of the popup items. The main reason is to keep the display of items in // drop-down the same as the items in the input field. @@ -588,8 +593,11 @@ bool WebViewImpl::autocompleteHandleKeyEvent(const WebKeyboardEvent& event) } int selectedIndex = m_autoFillPopup->selectedIndex(); - HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(element); - WebString name = inputElement->name(); + + if (!m_autoFillPopupClient->canRemoveSuggestionAtIndex(selectedIndex)) + return false; + + WebString name = WebInputElement(static_cast<HTMLInputElement*>(element)).nameForAutofill(); WebString value = m_autoFillPopupClient->itemText(selectedIndex); m_client->removeAutofillSuggestions(name, value); // Update the entries in the currently showing popup to reflect the @@ -1237,6 +1245,9 @@ WebRect WebViewImpl::caretOrSelectionBounds() if (controller->isCaret()) rect = view->contentsToWindow(controller->absoluteCaretBounds()); else if (controller->isRange()) { + node = controller->end().node(); + if (!node || !node->renderer()) + return rect; RefPtr<Range> range = controller->toNormalizedRange(); rect = view->contentsToWindow(focused->firstRectForRange(range.get())); } @@ -1722,7 +1733,19 @@ void WebViewImpl::applyAutoFillSuggestions( const WebVector<WebString>& labels, int separatorIndex) { + WebVector<int> uniqueIDs(names.size()); + applyAutoFillSuggestions(node, names, labels, uniqueIDs, separatorIndex); +} + +void WebViewImpl::applyAutoFillSuggestions( + const WebNode& node, + const WebVector<WebString>& names, + const WebVector<WebString>& labels, + const WebVector<int>& uniqueIDs, + int separatorIndex) +{ ASSERT(names.size() == labels.size()); + ASSERT(names.size() == uniqueIDs.size()); ASSERT(separatorIndex < static_cast<int>(names.size())); if (names.isEmpty()) { @@ -1747,7 +1770,8 @@ void WebViewImpl::applyAutoFillSuggestions( if (!m_autoFillPopupClient.get()) m_autoFillPopupClient.set(new AutoFillPopupMenuClient); - m_autoFillPopupClient->initialize(inputElem, names, labels, separatorIndex); + m_autoFillPopupClient->initialize( + inputElem, names, labels, uniqueIDs, separatorIndex); if (!m_autoFillPopup.get()) { m_autoFillPopup = PopupContainer::create(m_autoFillPopupClient.get(), @@ -1756,7 +1780,8 @@ void WebViewImpl::applyAutoFillSuggestions( } if (m_autoFillPopupShowing) { - m_autoFillPopupClient->setSuggestions(names, labels, separatorIndex); + m_autoFillPopupClient->setSuggestions( + names, labels, uniqueIDs, separatorIndex); refreshAutoFillPopup(); } else { m_autoFillPopup->show(focusedNode->getRect(), @@ -1778,13 +1803,12 @@ void WebViewImpl::applyAutocompleteSuggestions( { WebVector<WebString> names(suggestions.size()); WebVector<WebString> labels(suggestions.size()); + WebVector<int> uniqueIDs(suggestions.size()); - for (size_t i = 0; i < suggestions.size(); ++i) { + for (size_t i = 0; i < suggestions.size(); ++i) names[i] = suggestions[i]; - labels[i] = WebString(); - } - applyAutoFillSuggestions(node, names, labels, -1); + applyAutoFillSuggestions(node, names, labels, uniqueIDs, -1); if (m_autoFillPopupClient) m_autoFillPopupClient->setAutocompleteMode(true); } @@ -1852,7 +1876,7 @@ void WebViewImpl::setScrollbarColors(unsigned inactiveColor, unsigned activeColor, unsigned trackColor) { #if OS(LINUX) - RenderThemeChromiumLinux::setScrollbarColors(inactiveColor, + PlatformThemeChromiumGtk::setScrollbarColors(inactiveColor, activeColor, trackColor); #endif @@ -2058,7 +2082,7 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active) return; if (active) { - m_layerRenderer = LayerRendererChromium::create(page()); + m_layerRenderer = LayerRendererChromium::create(getOnscreenGLES2Context()); if (m_layerRenderer->hardwareCompositing()) m_isAcceleratedCompositingActive = true; else { @@ -2132,6 +2156,21 @@ void WebViewImpl::setRootLayerNeedsDisplay() } #endif // USE(ACCELERATED_COMPOSITING) +PassOwnPtr<GLES2Context> WebViewImpl::getOnscreenGLES2Context() +{ + return GLES2Context::create(GLES2ContextInternal::create(gles2Context(), false)); +} + +PassOwnPtr<GLES2Context> WebViewImpl::getOffscreenGLES2Context() +{ + WebGLES2Context* context = webKitClient()->createGLES2Context(); + if (!context) + return 0; + if (!context->initialize(0, gles2Context())) + return 0; + return GLES2Context::create(GLES2ContextInternal::create(context, true)); +} + // Returns the GLES2 context associated with this View. If one doesn't exist // it will get created first. WebGLES2Context* WebViewImpl::gles2Context() diff --git a/WebKit/chromium/src/WebViewImpl.h b/WebKit/chromium/src/WebViewImpl.h index db2a1d2..312f20f 100644 --- a/WebKit/chromium/src/WebViewImpl.h +++ b/WebKit/chromium/src/WebViewImpl.h @@ -53,6 +53,7 @@ namespace WebCore { class ChromiumDataObject; class Frame; +class GLES2Context; class HistoryItem; class HitTestResult; class KeyboardEvent; @@ -164,11 +165,18 @@ public: const WebString& value); virtual WebDevToolsAgent* devToolsAgent(); virtual WebAccessibilityObject accessibilityObject(); + // DEPRECATED. virtual void applyAutoFillSuggestions( const WebNode&, const WebVector<WebString>& names, const WebVector<WebString>& labels, int separatorIndex); + virtual void applyAutoFillSuggestions( + const WebNode&, + const WebVector<WebString>& names, + const WebVector<WebString>& labels, + const WebVector<int>& uniqueIDs, + int separatorIndex); // DEPRECATED: replacing with applyAutoFillSuggestions. virtual void applyAutocompleteSuggestions( const WebNode&, @@ -183,7 +191,6 @@ public: unsigned inactiveBackgroundColor, unsigned inactiveForegroundColor); virtual void performCustomContextMenuAction(unsigned action); - virtual WebGLES2Context* gles2Context(); // WebViewImpl @@ -314,6 +321,14 @@ public: void setRootLayerNeedsDisplay(); void setRootGraphicsLayer(WebCore::PlatformLayer*); #endif + // Onscreen contexts display to the screen associated with this view. + // Offscreen contexts render offscreen but can share resources with the + // onscreen context and thus can be composited. + PassOwnPtr<WebCore::GLES2Context> getOnscreenGLES2Context(); + PassOwnPtr<WebCore::GLES2Context> getOffscreenGLES2Context(); + + // Returns an onscreen context + virtual WebGLES2Context* gles2Context(); WebCore::PopupContainer* selectPopup() const { return m_selectPopup.get(); } diff --git a/WebKit/chromium/src/gtk/WebFontInfo.cpp b/WebKit/chromium/src/gtk/WebFontInfo.cpp index 3ac0b00..dd25eb1 100644 --- a/WebKit/chromium/src/gtk/WebFontInfo.cpp +++ b/WebKit/chromium/src/gtk/WebFontInfo.cpp @@ -165,6 +165,23 @@ void WebFontInfo::renderStyleForStrike(const char* family, int sizeAndStyle, Web out->useHinting = b; if (FcPatternGetInteger(match, FC_HINT_STYLE, 0, &i) == FcResultMatch) out->hintStyle = i; + if (FcPatternGetInteger(match, FC_RGBA, 0, &i) == FcResultMatch) { + switch (i) { + case FC_RGBA_NONE: + out->useSubpixel = 0; + break; + case FC_RGBA_RGB: + case FC_RGBA_BGR: + case FC_RGBA_VRGB: + case FC_RGBA_VBGR: + out->useSubpixel = 1; + break; + default: + // This includes FC_RGBA_UNKNOWN. + out->useSubpixel = 2; + break; + } + } FcPatternDestroy(match); } diff --git a/WebKit/chromium/src/js/DebuggerAgent.js b/WebKit/chromium/src/js/DebuggerAgent.js deleted file mode 100644 index 01d7627..0000000 --- a/WebKit/chromium/src/js/DebuggerAgent.js +++ /dev/null @@ -1,1605 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @fileoverview Provides communication interface to remote v8 debugger. See - * protocol decription at http://code.google.com/p/v8/wiki/DebuggerProtocol - */ - -/** - * FIXME: change field naming style to use trailing underscore. - * @constructor - */ -devtools.DebuggerAgent = function() -{ - RemoteDebuggerAgent.debuggerOutput = this.handleDebuggerOutput_.bind(this); - RemoteDebuggerAgent.setContextId = this.setContextId_.bind(this); - - /** - * Id of the inspected page global context. It is used for filtering scripts. - * @type {number} - */ - this.contextId_ = null; - - /** - * Mapping from script id to script info. - * @type {Object} - */ - this.parsedScripts_ = null; - - /** - * Mapping from the request id to the devtools.BreakpointInfo for the - * breakpoints whose v8 ids are not set yet. These breakpoints are waiting for - * "setbreakpoint" responses to learn their ids in the v8 debugger. - * @see #handleSetBreakpointResponse_ - * @type {Object} - */ - this.requestNumberToBreakpointInfo_ = null; - - /** - * Information on current stack frames. - * @type {Array.<devtools.CallFrame>} - */ - this.callFrames_ = []; - - /** - * Whether to stop in the debugger on the exceptions. - * @type {boolean} - */ - this.pauseOnExceptions_ = false; - - /** - * Mapping: request sequence number->callback. - * @type {Object} - */ - this.requestSeqToCallback_ = null; - - /** - * Whether the scripts panel has been shown and initialilzed. - * @type {boolean} - */ - this.scriptsPanelInitialized_ = false; - - /** - * Whether the scripts list should be requested next time when context id is - * set. - * @type {boolean} - */ - this.requestScriptsWhenContextIdSet_ = false; - - /** - * Whether the agent is waiting for initial scripts response. - * @type {boolean} - */ - this.waitingForInitialScriptsResponse_ = false; - - /** - * If backtrace response is received when initial scripts response - * is not yet processed the backtrace handling will be postponed until - * after the scripts response processing. The handler bound to its arguments - * and this agent will be stored in this field then. - * @type {?function()} - */ - this.pendingBacktraceResponseHandler_ = null; - - /** - * Container of all breakpoints set using resource URL. These breakpoints - * survive page reload. Breakpoints set by script id(for scripts that don't - * have URLs) are stored in ScriptInfo objects. - * @type {Object} - */ - this.urlToBreakpoints_ = {}; - - /** - * Exception message that is shown to user while on exception break. - * @type {WebInspector.ConsoleMessage} - */ - this.currentExceptionMessage_ = null; - - /** - * Whether breakpoints should suspend execution. - * @type {boolean} - */ - this.breakpointsActivated_ = true; -}; - - -/** - * A copy of the scope types from v8/src/mirror-delay.js - * @enum {number} - */ -devtools.DebuggerAgent.ScopeType = { - Global: 0, - Local: 1, - With: 2, - Closure: 3, - Catch: 4 -}; - - -/** - * Resets debugger agent to its initial state. - */ -devtools.DebuggerAgent.prototype.reset = function() -{ - this.contextId_ = null; - // No need to request scripts since they all will be pushed in AfterCompile - // events. - this.requestScriptsWhenContextIdSet_ = false; - this.waitingForInitialScriptsResponse_ = false; - - this.parsedScripts_ = {}; - this.requestNumberToBreakpointInfo_ = {}; - this.callFrames_ = []; - this.requestSeqToCallback_ = {}; -}; - - -/** - * Initializes scripts UI. This method is called every time Scripts panel - * is shown. It will send request for context id if it's not set yet. - */ -devtools.DebuggerAgent.prototype.initUI = function() -{ - // Initialize scripts cache when Scripts panel is shown first time. - if (this.scriptsPanelInitialized_) - return; - this.scriptsPanelInitialized_ = true; - if (this.contextId_) { - // We already have context id. This means that we are here from the - // very beginning of the page load cycle and hence will get all scripts - // via after-compile events. No need to request scripts for this session. - // - // There can be a number of scripts from after-compile events that are - // pending addition into the UI. - for (var scriptId in this.parsedScripts_) { - var script = this.parsedScripts_[scriptId]; - WebInspector.parsedScriptSource(scriptId, script.getUrl(), undefined /* script source */, script.getLineOffset() + 1, script.worldType()); - this.restoreBreakpoints_(scriptId, script.getUrl()); - } - return; - } - this.waitingForInitialScriptsResponse_ = true; - // Script list should be requested only when current context id is known. - RemoteDebuggerAgent.getContextId(); - this.requestScriptsWhenContextIdSet_ = true; -}; - - -/** - * Asynchronously requests the debugger for the script source. - * @param {number} scriptId Id of the script whose source should be resolved. - * @param {function(source:?string):void} callback Function that will be called - * when the source resolution is completed. "source" parameter will be null - * if the resolution fails. - */ -devtools.DebuggerAgent.prototype.resolveScriptSource = function(scriptId, callback) -{ - var script = this.parsedScripts_[scriptId]; - if (!script || script.isUnresolved()) { - callback(null); - return; - } - - var cmd = new devtools.DebugCommand("scripts", { - "ids": [scriptId], - "includeSource": true - }); - devtools.DebuggerAgent.sendCommand_(cmd); - // Force v8 execution so that it gets to processing the requested command. - RemoteDebuggerAgent.processDebugCommands(); - - var self = this; - this.requestSeqToCallback_[cmd.getSequenceNumber()] = function(msg) { - if (msg.isSuccess()) { - var scriptJson = msg.getBody()[0]; - if (scriptJson) { - script.source = scriptJson.source; - callback(scriptJson.source); - } - else - callback(null); - } else - callback(null); - }; -}; - - -/** - * Tells the v8 debugger to stop on as soon as possible. - */ -devtools.DebuggerAgent.prototype.pauseExecution = function() -{ - RemoteDebuggerCommandExecutor.DebuggerPauseScript(); -}; - - -/** - * @param {number} sourceId Id of the script fot the breakpoint. - * @param {number} line Number of the line for the breakpoint. - * @param {?string} condition The breakpoint condition. - */ -devtools.DebuggerAgent.prototype.addBreakpoint = function(sourceId, line, enabled, condition) -{ - var script = this.parsedScripts_[sourceId]; - if (!script) - return; - - line = devtools.DebuggerAgent.webkitToV8LineNumber_(line); - - var commandArguments; - if (script.getUrl()) { - var breakpoints = this.urlToBreakpoints_[script.getUrl()]; - if (breakpoints && breakpoints[line]) - return; - if (!breakpoints) { - breakpoints = {}; - this.urlToBreakpoints_[script.getUrl()] = breakpoints; - } - - var breakpointInfo = new devtools.BreakpointInfo(line, enabled, condition); - breakpoints[line] = breakpointInfo; - - commandArguments = { - "groupId": this.contextId_, - "type": "script", - "target": script.getUrl(), - "line": line, - "condition": condition - }; - } else { - var breakpointInfo = script.getBreakpointInfo(line); - if (breakpointInfo) - return; - - breakpointInfo = new devtools.BreakpointInfo(line, enabled, condition); - script.addBreakpointInfo(breakpointInfo); - - commandArguments = { - "groupId": this.contextId_, - "type": "scriptId", - "target": sourceId, - "line": line, - "condition": condition - }; - } - - if (!enabled) - return; - - var cmd = new devtools.DebugCommand("setbreakpoint", commandArguments); - - this.requestNumberToBreakpointInfo_[cmd.getSequenceNumber()] = breakpointInfo; - - devtools.DebuggerAgent.sendCommand_(cmd); - // Force v8 execution so that it gets to processing the requested command. - // It is necessary for being able to change a breakpoint just after it - // has been created (since we need an existing breakpoint id for that). - RemoteDebuggerAgent.processDebugCommands(); -}; - - -/** - * Changes given line of the script. - */ -devtools.DebuggerAgent.prototype.editScriptSource = function(sourceId, newContent, callback) -{ - var commandArguments = { - "script_id": sourceId, - "new_source": newContent - }; - - var cmd = new devtools.DebugCommand("changelive", commandArguments); - devtools.DebuggerAgent.sendCommand_(cmd); - this.requestSeqToCallback_[cmd.getSequenceNumber()] = function(msg) { - if (!msg.isSuccess()) { - callback(false, "Unable to modify source code within given scope. Only function bodies are editable at the moment.", null); - return; - } - - this.resolveScriptSource(sourceId, requestBacktrace.bind(this)); - }.bind(this); - - - function requestBacktrace(newScriptSource) { - if (WebInspector.panels.scripts.paused) - this.requestBacktrace_(handleBacktraceResponse.bind(this, newScriptSource)); - else - reportDidCommitEditing(newScriptSource); - } - - function handleBacktraceResponse(newScriptSource, msg) { - this.updateCallFramesFromBacktraceResponse_(msg); - reportDidCommitEditing(newScriptSource, this.callFrames_); - } - - function reportDidCommitEditing(newScriptSource, callFrames) { - callback(true, newScriptSource, callFrames); - } - - RemoteDebuggerAgent.processDebugCommands(); -}; - - -/** - * @param {number} sourceId Id of the script for the breakpoint. - * @param {number} line Number of the line for the breakpoint. - */ -devtools.DebuggerAgent.prototype.removeBreakpoint = function(sourceId, line) -{ - var script = this.parsedScripts_[sourceId]; - if (!script) - return; - - line = devtools.DebuggerAgent.webkitToV8LineNumber_(line); - - var breakpointInfo; - if (script.getUrl()) { - var breakpoints = this.urlToBreakpoints_[script.getUrl()]; - if (!breakpoints) - return; - breakpointInfo = breakpoints[line]; - delete breakpoints[line]; - } else { - breakpointInfo = script.getBreakpointInfo(line); - if (breakpointInfo) - script.removeBreakpointInfo(breakpointInfo); - } - - if (!breakpointInfo) - return; - - breakpointInfo.markAsRemoved(); - - var id = breakpointInfo.getV8Id(); - - // If we don't know id of this breakpoint in the v8 debugger we cannot send - // "clearbreakpoint" request. In that case it will be removed in - // "setbreakpoint" response handler when we learn the id. - if (id !== -1) { - this.requestClearBreakpoint_(id); - } -}; - - -/** - * @param {boolean} activated Whether breakpoints should be activated. - */ -devtools.DebuggerAgent.prototype.setBreakpointsActivated = function(activated) -{ - this.breakpointsActivated_ = activated; -}; - - -/** - * Tells the v8 debugger to step into the next statement. - */ -devtools.DebuggerAgent.prototype.stepIntoStatement = function() -{ - this.stepCommand_("in"); -}; - - -/** - * Tells the v8 debugger to step out of current function. - */ -devtools.DebuggerAgent.prototype.stepOutOfFunction = function() -{ - this.stepCommand_("out"); -}; - - -/** - * Tells the v8 debugger to step over the next statement. - */ -devtools.DebuggerAgent.prototype.stepOverStatement = function() -{ - this.stepCommand_("next"); -}; - - -/** - * Tells the v8 debugger to continue execution after it has been stopped on a - * breakpoint or an exception. - */ -devtools.DebuggerAgent.prototype.resumeExecution = function() -{ - this.clearExceptionMessage_(); - var cmd = new devtools.DebugCommand("continue"); - devtools.DebuggerAgent.sendCommand_(cmd); -}; - - -/** - * Creates exception message and schedules it for addition to the resource upon - * backtrace availability. - * @param {string} url Resource url. - * @param {number} line Resource line number. - * @param {string} message Exception text. - */ -devtools.DebuggerAgent.prototype.createExceptionMessage_ = function(url, line, message) -{ - this.currentExceptionMessage_ = new WebInspector.ConsoleMessage( - WebInspector.ConsoleMessage.MessageSource.JS, - WebInspector.ConsoleMessage.MessageType.Log, - WebInspector.ConsoleMessage.MessageLevel.Error, - line, - url, - 0 /* group level */, - 1 /* repeat count */, - "[Exception] " + message); -}; - - -/** - * Shows pending exception message that is created with createExceptionMessage_ - * earlier. - */ -devtools.DebuggerAgent.prototype.showPendingExceptionMessage_ = function() -{ - if (!this.currentExceptionMessage_) - return; - var msg = this.currentExceptionMessage_; - var resource = WebInspector.resourceURLMap[msg.url]; - if (resource) { - msg.resource = resource; - WebInspector.panels.resources.addMessageToResource(resource, msg); - } else - this.currentExceptionMessage_ = null; -}; - - -/** - * Clears exception message from the resource. - */ -devtools.DebuggerAgent.prototype.clearExceptionMessage_ = function() -{ - if (this.currentExceptionMessage_) { - var messageElement = this.currentExceptionMessage_._resourceMessageLineElement; - var bubble = messageElement.parentElement; - bubble.removeChild(messageElement); - if (!bubble.firstChild) { - // Last message in bubble removed. - bubble.parentElement.removeChild(bubble); - } - this.currentExceptionMessage_ = null; - } -}; - - -/** - * @return {boolean} True iff the debugger will pause execution on the - * exceptions. - */ -devtools.DebuggerAgent.prototype.pauseOnExceptions = function() -{ - return this.pauseOnExceptions_; -}; - - -/** - * Tells whether to pause in the debugger on the exceptions or not. - * @param {boolean} value True iff execution should be stopped in the debugger - * on the exceptions. - */ -devtools.DebuggerAgent.prototype.setPauseOnExceptions = function(value) -{ - this.pauseOnExceptions_ = value; -}; - - -/** - * Sends "evaluate" request to the debugger. - * @param {Object} arguments Request arguments map. - * @param {function(devtools.DebuggerMessage)} callback Callback to be called - * when response is received. - */ -devtools.DebuggerAgent.prototype.requestEvaluate = function(arguments, callback) -{ - var cmd = new devtools.DebugCommand("evaluate", arguments); - devtools.DebuggerAgent.sendCommand_(cmd); - this.requestSeqToCallback_[cmd.getSequenceNumber()] = callback; -}; - - -/** - * Sends "lookup" request for each unresolved property of the object. When - * response is received the properties will be changed with their resolved - * values. - * @param {Object} object Object whose properties should be resolved. - * @param {function(devtools.DebuggerMessage)} Callback to be called when all - * children are resolved. - * @param {boolean} noIntrinsic Whether intrinsic properties should be included. - */ -devtools.DebuggerAgent.prototype.resolveChildren = function(object, callback, noIntrinsic) -{ - if ("handle" in object) { - var result = []; - devtools.DebuggerAgent.formatObjectProperties_(object, result, noIntrinsic); - callback(result); - } else { - this.requestLookup_([object.ref], function(msg) { - var result = []; - if (msg.isSuccess()) { - var handleToObject = msg.getBody(); - var resolved = handleToObject[object.ref]; - devtools.DebuggerAgent.formatObjectProperties_(resolved, result, noIntrinsic); - callback(result); - } else - callback([]); - }); - } -}; - - -/** - * Sends "scope" request for the scope object to resolve its variables. - * @param {Object} scope Scope to be resolved. - * @param {function(Array.<WebInspector.ObjectPropertyProxy>)} callback - * Callback to be called when all scope variables are resolved. - */ -devtools.DebuggerAgent.prototype.resolveScope = function(scope, callback) -{ - var cmd = new devtools.DebugCommand("scope", { - "frameNumber": scope.frameNumber, - "number": scope.index, - "compactFormat": true - }); - devtools.DebuggerAgent.sendCommand_(cmd); - this.requestSeqToCallback_[cmd.getSequenceNumber()] = function(msg) { - var result = []; - if (msg.isSuccess()) { - var scopeObjectJson = msg.getBody().object; - devtools.DebuggerAgent.formatObjectProperties_(scopeObjectJson, result, true /* no intrinsic */); - } - callback(result); - }; -}; - - -/** - * Sends "scopes" request for the frame object to resolve all variables - * available in the frame. - * @param {number} callFrameId Id of call frame whose variables need to - * be resolved. - * @param {function(Object)} callback Callback to be called when all frame - * variables are resolved. - */ -devtools.DebuggerAgent.prototype.resolveFrameVariables_ = function(callFrameId, callback) -{ - var result = {}; - - var frame = this.callFrames_[callFrameId]; - if (!frame) { - callback(result); - return; - } - - var waitingResponses = 0; - function scopeResponseHandler(msg) { - waitingResponses--; - - if (msg.isSuccess()) { - var properties = msg.getBody().object.properties; - for (var j = 0; j < properties.length; j++) - result[properties[j].name] = true; - } - - // When all scopes are resolved invoke the callback. - if (waitingResponses === 0) - callback(result); - }; - - for (var i = 0; i < frame.scopeChain.length; i++) { - var scope = frame.scopeChain[i].objectId; - if (scope.type === devtools.DebuggerAgent.ScopeType.Global) { - // Do not resolve global scope since it takes for too long. - // TODO(yurys): allow to send only property names in the response. - continue; - } - var cmd = new devtools.DebugCommand("scope", { - "frameNumber": scope.frameNumber, - "number": scope.index, - "compactFormat": true - }); - devtools.DebuggerAgent.sendCommand_(cmd); - this.requestSeqToCallback_[cmd.getSequenceNumber()] = scopeResponseHandler; - waitingResponses++; - } -}; - -/** - * Evaluates the expressionString to an object in the call frame and reports - * all its properties. - * @param{string} expressionString Expression whose properties should be - * collected. - * @param{number} callFrameId The frame id. - * @param{function(Object result,bool isException)} reportCompletions Callback - * function. - */ -devtools.DebuggerAgent.prototype.resolveCompletionsOnFrame = function(expressionString, callFrameId, reportCompletions) -{ - if (expressionString) { - expressionString = "var obj = " + expressionString + - "; var names = {}; for (var n in obj) { names[n] = true; };" + - "names;"; - this.evaluateInCallFrame( - callFrameId, - expressionString, - function(result) { - var names = {}; - if (!result.isException) { - var props = result.value.objectId.properties; - // Put all object properties into the map. - for (var i = 0; i < props.length; i++) - names[props[i].name] = true; - } - reportCompletions(names, result.isException); - }); - } else { - this.resolveFrameVariables_(callFrameId, - function(result) { - reportCompletions(result, false /* isException */); - }); - } -}; - - -/** - * @param{number} scriptId - * @return {string} Type of the context of the script with specified id. - */ -devtools.DebuggerAgent.prototype.getScriptContextType = function(scriptId) -{ - return this.parsedScripts_[scriptId].getContextType(); -}; - - -/** - * Removes specified breakpoint from the v8 debugger. - * @param {number} breakpointId Id of the breakpoint in the v8 debugger. - */ -devtools.DebuggerAgent.prototype.requestClearBreakpoint_ = function(breakpointId) -{ - var cmd = new devtools.DebugCommand("clearbreakpoint", { - "breakpoint": breakpointId - }); - devtools.DebuggerAgent.sendCommand_(cmd); -}; - - -/** - * Sends "backtrace" request to v8. - */ -devtools.DebuggerAgent.prototype.requestBacktrace_ = function(opt_customHandler) -{ - var cmd = new devtools.DebugCommand("backtrace", { - "compactFormat":true - }); - devtools.DebuggerAgent.sendCommand_(cmd); - var responseHandler = opt_customHandler ? opt_customHandler : this.handleBacktraceResponse_.bind(this); - this.requestSeqToCallback_[cmd.getSequenceNumber()] = responseHandler; -}; - - -/** - * Sends command to v8 debugger. - * @param {devtools.DebugCommand} cmd Command to execute. - */ -devtools.DebuggerAgent.sendCommand_ = function(cmd) -{ - RemoteDebuggerCommandExecutor.DebuggerCommand(cmd.toJSONProtocol()); -}; - - -/** - * Tells the v8 debugger to make the next execution step. - * @param {string} action "in", "out" or "next" action. - */ -devtools.DebuggerAgent.prototype.stepCommand_ = function(action) -{ - this.clearExceptionMessage_(); - var cmd = new devtools.DebugCommand("continue", { - "stepaction": action, - "stepcount": 1 - }); - devtools.DebuggerAgent.sendCommand_(cmd); -}; - - -/** - * Sends "lookup" request to v8. - * @param {number} handle Handle to the object to lookup. - */ -devtools.DebuggerAgent.prototype.requestLookup_ = function(handles, callback) -{ - var cmd = new devtools.DebugCommand("lookup", { - "compactFormat":true, - "handles": handles - }); - devtools.DebuggerAgent.sendCommand_(cmd); - this.requestSeqToCallback_[cmd.getSequenceNumber()] = callback; -}; - - -/** - * Sets debugger context id for scripts filtering. - * @param {number} contextId Id of the inspected page global context. - */ -devtools.DebuggerAgent.prototype.setContextId_ = function(contextId) -{ - this.contextId_ = contextId; - - // If it's the first time context id is set request scripts list. - if (this.requestScriptsWhenContextIdSet_) { - this.requestScriptsWhenContextIdSet_ = false; - var cmd = new devtools.DebugCommand("scripts", { - "includeSource": false - }); - devtools.DebuggerAgent.sendCommand_(cmd); - // Force v8 execution so that it gets to processing the requested command. - RemoteDebuggerAgent.processDebugCommands(); - - var debuggerAgent = this; - this.requestSeqToCallback_[cmd.getSequenceNumber()] = function(msg) { - // Handle the response iff the context id hasn't changed since the request - // was issued. Otherwise if the context id did change all up-to-date - // scripts will be pushed in after compile events and there is no need to - // handle the response. - if (contextId === debuggerAgent.contextId_) - debuggerAgent.handleScriptsResponse_(msg); - - // We received initial scripts response so flush the flag and - // see if there is an unhandled backtrace response. - debuggerAgent.waitingForInitialScriptsResponse_ = false; - if (debuggerAgent.pendingBacktraceResponseHandler_) { - debuggerAgent.pendingBacktraceResponseHandler_(); - debuggerAgent.pendingBacktraceResponseHandler_ = null; - } - }; - } -}; - - -/** - * Handles output sent by v8 debugger. The output is either asynchronous event - * or response to a previously sent request. See protocol definitioun for more - * details on the output format. - * @param {string} output - */ -devtools.DebuggerAgent.prototype.handleDebuggerOutput_ = function(output) -{ - var msg; - try { - msg = new devtools.DebuggerMessage(output); - } catch(e) { - debugPrint("Failed to handle debugger response:\n" + e); - throw e; - } - - if (msg.getType() === "event") { - if (msg.getEvent() === "break") - this.handleBreakEvent_(msg); - else if (msg.getEvent() === "exception") - this.handleExceptionEvent_(msg); - else if (msg.getEvent() === "afterCompile") - this.handleAfterCompileEvent_(msg); - } else if (msg.getType() === "response") { - if (msg.getCommand() === "scripts") - this.invokeCallbackForResponse_(msg); - else if (msg.getCommand() === "setbreakpoint") - this.handleSetBreakpointResponse_(msg); - else if (msg.getCommand() === "changelive") - this.invokeCallbackForResponse_(msg); - else if (msg.getCommand() === "clearbreakpoint") - this.handleClearBreakpointResponse_(msg); - else if (msg.getCommand() === "backtrace") - this.invokeCallbackForResponse_(msg); - else if (msg.getCommand() === "lookup") - this.invokeCallbackForResponse_(msg); - else if (msg.getCommand() === "evaluate") - this.invokeCallbackForResponse_(msg); - else if (msg.getCommand() === "scope") - this.invokeCallbackForResponse_(msg); - } -}; - - -/** - * @param {devtools.DebuggerMessage} msg - */ -devtools.DebuggerAgent.prototype.handleBreakEvent_ = function(msg) -{ - if (!this.breakpointsActivated_) { - this.resumeExecution(); - return; - } - - // Force scripts panel to be shown first. - WebInspector.currentPanel = WebInspector.panels.scripts; - - var body = msg.getBody(); - - var line = devtools.DebuggerAgent.v8ToWwebkitLineNumber_(body.sourceLine); - this.requestBacktrace_(); -}; - - -/** - * @param {devtools.DebuggerMessage} msg - */ -devtools.DebuggerAgent.prototype.handleExceptionEvent_ = function(msg) -{ - var body = msg.getBody(); - // No script field in the body means that v8 failed to parse the script. We - // resume execution on parser errors automatically. - if (this.pauseOnExceptions_ && body.script) { - var line = devtools.DebuggerAgent.v8ToWwebkitLineNumber_(body.sourceLine); - this.createExceptionMessage_(body.script.name, line, body.exception.text); - this.requestBacktrace_(); - - // Force scripts panel to be shown. - WebInspector.currentPanel = WebInspector.panels.scripts; - } else - this.resumeExecution(); -}; - - -/** - * @param {devtools.DebuggerMessage} msg - */ -devtools.DebuggerAgent.prototype.handleScriptsResponse_ = function(msg) -{ - var scripts = msg.getBody(); - for (var i = 0; i < scripts.length; i++) { - var script = scripts[i]; - - // Skip scripts from other tabs. - if (!this.isScriptFromInspectedContext_(script, msg)) - continue; - - // We may already have received the info in an afterCompile event. - if (script.id in this.parsedScripts_) - continue; - this.addScriptInfo_(script, msg); - } -}; - - -/** - * @param {Object} script Json object representing script. - * @param {devtools.DebuggerMessage} msg Debugger response. - */ -devtools.DebuggerAgent.prototype.isScriptFromInspectedContext_ = function(script, msg) -{ - if (!script.context) { - // Always ignore scripts from the utility context. - return false; - } - var context = msg.lookup(script.context.ref); - var scriptContextId = context.data; - if (typeof scriptContextId === "undefined") - return false; // Always ignore scripts from the utility context. - if (this.contextId_ === null) - return true; - // Find the id from context data. The context data has the format "type,id". - var comma = context.data.indexOf(","); - if (comma < 0) - return false; - return (context.data.substring(comma + 1) == this.contextId_); -}; - - -/** - * @param {devtools.DebuggerMessage} msg - */ -devtools.DebuggerAgent.prototype.handleSetBreakpointResponse_ = function(msg) -{ - var requestSeq = msg.getRequestSeq(); - var breakpointInfo = this.requestNumberToBreakpointInfo_[requestSeq]; - if (!breakpointInfo) { - // TODO(yurys): handle this case - return; - } - delete this.requestNumberToBreakpointInfo_[requestSeq]; - if (!msg.isSuccess()) { - // TODO(yurys): handle this case - return; - } - var idInV8 = msg.getBody().breakpoint; - breakpointInfo.setV8Id(idInV8); - - if (breakpointInfo.isRemoved()) - this.requestClearBreakpoint_(idInV8); -}; - - -/** - * @param {devtools.DebuggerMessage} msg - */ -devtools.DebuggerAgent.prototype.handleAfterCompileEvent_ = function(msg) -{ - if (!this.contextId_) { - // Ignore scripts delta if main request has not been issued yet. - return; - } - var script = msg.getBody().script; - - // Ignore scripts from other tabs. - if (!this.isScriptFromInspectedContext_(script, msg)) - return; - this.addScriptInfo_(script, msg); -}; - - -/** - * Adds the script info to the local cache. This method assumes that the script - * is not in the cache yet. - * @param {Object} script Script json object from the debugger message. - * @param {devtools.DebuggerMessage} msg Debugger message containing the script - * data. - */ -devtools.DebuggerAgent.prototype.addScriptInfo_ = function(script, msg) -{ - var context = msg.lookup(script.context.ref); - // Find the type from context data. The context data has the format - // "type,id". - var comma = context.data.indexOf(","); - if (comma < 0) - return; - var contextType = context.data.substring(0, comma); - var info = new devtools.ScriptInfo(script.id, script.name, script.lineOffset, contextType); - this.parsedScripts_[script.id] = info; - if (this.scriptsPanelInitialized_) { - // Only report script as parsed after scripts panel has been shown. - WebInspector.parsedScriptSource(script.id, script.name, script.source, script.lineOffset + 1, info.worldType()); - this.restoreBreakpoints_(script.id, script.name); - } -}; - - -/** - * @param {devtools.DebuggerMessage} msg - */ -devtools.DebuggerAgent.prototype.handleClearBreakpointResponse_ = function(msg) -{ - // Do nothing. -}; - - -/** - * Handles response to "backtrace" command. - * @param {devtools.DebuggerMessage} msg - */ -devtools.DebuggerAgent.prototype.handleBacktraceResponse_ = function(msg) -{ - if (this.waitingForInitialScriptsResponse_) - this.pendingBacktraceResponseHandler_ = this.doHandleBacktraceResponse_.bind(this, msg); - else - this.doHandleBacktraceResponse_(msg); -}; - - -/** - * @param {devtools.DebuggerMessage} msg - */ -devtools.DebuggerAgent.prototype.doHandleBacktraceResponse_ = function(msg) -{ - this.updateCallFramesFromBacktraceResponse_(msg); - WebInspector.pausedScript(this.callFrames_); - this.showPendingExceptionMessage_(); - InspectorFrontendHost.bringToFront(); -}; - - -devtools.DebuggerAgent.prototype.updateCallFramesFromBacktraceResponse_ = function(msg) -{ - var frames = msg.getBody().frames; - this.callFrames_ = []; - for (var i = 0; i < frames.length; ++i) - this.callFrames_.push(this.formatCallFrame_(frames[i])); - return this.callFrames_; -}; - - -/** - * Evaluates code on given callframe. - */ -devtools.DebuggerAgent.prototype.evaluateInCallFrame = function(callFrameId, code, callback) -{ - var callFrame = this.callFrames_[callFrameId]; - callFrame.evaluate_(code, callback); -}; - - -/** - * Handles response to a command by invoking its callback (if any). - * @param {devtools.DebuggerMessage} msg - * @return {boolean} Whether a callback for the given message was found and - * excuted. - */ -devtools.DebuggerAgent.prototype.invokeCallbackForResponse_ = function(msg) -{ - var callback = this.requestSeqToCallback_[msg.getRequestSeq()]; - if (!callback) { - // It may happend if reset was called. - return false; - } - delete this.requestSeqToCallback_[msg.getRequestSeq()]; - callback(msg); - return true; -}; - - -/** - * @param {Object} stackFrame Frame json object from "backtrace" response. - * @return {!devtools.CallFrame} Object containing information related to the - * call frame in the format expected by ScriptsPanel and its panes. - */ -devtools.DebuggerAgent.prototype.formatCallFrame_ = function(stackFrame) -{ - var func = stackFrame.func; - var sourceId = func.scriptId; - - // Add service script if it does not exist. - var existingScript = this.parsedScripts_[sourceId]; - if (!existingScript) { - this.parsedScripts_[sourceId] = new devtools.ScriptInfo(sourceId, null /* name */, 0 /* line */, "unknown" /* type */, true /* unresolved */); - WebInspector.parsedScriptSource(sourceId, null, null, 0, WebInspector.Script.WorldType.MAIN_WORLD); - } - - var funcName = func.name || func.inferredName; - var line = devtools.DebuggerAgent.v8ToWwebkitLineNumber_(stackFrame.line); - - // Add basic scope chain info with scope variables. - var scopeChain = []; - var ScopeType = devtools.DebuggerAgent.ScopeType; - for (var i = 0; i < stackFrame.scopes.length; i++) { - var scope = stackFrame.scopes[i]; - scope.frameNumber = stackFrame.index; - var scopeObjectProxy = new WebInspector.ObjectProxy(0, scope, [], "", true); - scopeObjectProxy.isScope = true; - switch(scope.type) { - case ScopeType.Global: - scopeObjectProxy.isDocument = true; - break; - case ScopeType.Local: - scopeObjectProxy.isLocal = true; - scopeObjectProxy.thisObject = devtools.DebuggerAgent.formatObjectProxy_(stackFrame.receiver); - break; - case ScopeType.With: - // Catch scope is treated as a regular with scope by WebKit so we - // also treat it this way. - case ScopeType.Catch: - scopeObjectProxy.isWithBlock = true; - break; - case ScopeType.Closure: - scopeObjectProxy.isClosure = true; - break; - } - scopeChain.push(scopeObjectProxy); - } - return new devtools.CallFrame(stackFrame.index, "function", funcName, sourceId, line, scopeChain); -}; - - -/** - * Restores breakpoints associated with the URL of a newly parsed script. - * @param {number} sourceID The id of the script. - * @param {string} scriptUrl URL of the script. - */ -devtools.DebuggerAgent.prototype.restoreBreakpoints_ = function(sourceID, scriptUrl) -{ - var breakpoints = this.urlToBreakpoints_[scriptUrl]; - for (var line in breakpoints) { - if (parseInt(line) == line) { - var v8Line = devtools.DebuggerAgent.v8ToWwebkitLineNumber_(parseInt(line)); - WebInspector.restoredBreakpoint(sourceID, scriptUrl, v8Line, breakpoints[line].enabled(), breakpoints[line].condition()); - } - } -}; - - -/** - * Collects properties for an object from the debugger response. - * @param {Object} object An object from the debugger protocol response. - * @param {Array.<WebInspector.ObjectPropertyProxy>} result An array to put the - * properties into. - * @param {boolean} noIntrinsic Whether intrinsic properties should be - * included. - */ -devtools.DebuggerAgent.formatObjectProperties_ = function(object, result, noIntrinsic) -{ - devtools.DebuggerAgent.propertiesToProxies_(object.properties, result); - if (noIntrinsic) - return; - - result.push(new WebInspector.ObjectPropertyProxy("__proto__", devtools.DebuggerAgent.formatObjectProxy_(object.protoObject))); - result.push(new WebInspector.ObjectPropertyProxy("constructor", devtools.DebuggerAgent.formatObjectProxy_(object.constructorFunction))); - // Don't add 'prototype' property since it is one of the regualar properties. -}; - - -/** - * For each property in "properties" creates its proxy representative. - * @param {Array.<Object>} properties Receiver properties or locals array from - * "backtrace" response. - * @param {Array.<WebInspector.ObjectPropertyProxy>} Results holder. - */ -devtools.DebuggerAgent.propertiesToProxies_ = function(properties, result) -{ - var map = {}; - for (var i = 0; i < properties.length; ++i) { - var property = properties[i]; - var name = String(property.name); - if (name in map) - continue; - map[name] = true; - var value = devtools.DebuggerAgent.formatObjectProxy_(property.value); - var propertyProxy = new WebInspector.ObjectPropertyProxy(name, value); - result.push(propertyProxy); - } -}; - - -/** - * @param {Object} v An object reference from the debugger response. - * @return {*} The value representation expected by ScriptsPanel. - */ -devtools.DebuggerAgent.formatObjectProxy_ = function(v) -{ - var description; - var hasChildren = false; - if (v.type === "object") { - description = v.className; - hasChildren = true; - } else if (v.type === "function") { - if (v.source) - description = v.source; - else - description = "function " + v.name + "()"; - hasChildren = true; - } else if (v.type === "undefined") - description = "undefined"; - else if (v.type === "null") - description = "null"; - else if (typeof v.value !== "undefined") { - // Check for undefined and null types before checking the value, otherwise - // null/undefined may have blank value. - description = v.value; - } else - description = "<unresolved ref: " + v.ref + ", type: " + v.type + ">"; - - var proxy = new WebInspector.ObjectProxy(0, v, [], description, hasChildren); - proxy.type = v.type; - proxy.isV8Ref = true; - return proxy; -}; - - -/** - * Converts line number from Web Inspector UI(1-based) to v8(0-based). - * @param {number} line Resource line number in Web Inspector UI. - * @return {number} The line number in v8. - */ -devtools.DebuggerAgent.webkitToV8LineNumber_ = function(line) -{ - return line - 1; -}; - - -/** - * Converts line number from v8(0-based) to Web Inspector UI(1-based). - * @param {number} line Resource line number in v8. - * @return {number} The line number in Web Inspector. - */ -devtools.DebuggerAgent.v8ToWwebkitLineNumber_ = function(line) -{ - return line + 1; -}; - - -/** - * @param {number} scriptId Id of the script. - * @param {?string} url Script resource URL if any. - * @param {number} lineOffset First line 0-based offset in the containing - * document. - * @param {string} contextType Type of the script's context: - * "page" - regular script from html page - * "injected" - extension content script - * @param {bool} opt_isUnresolved If true, script will not be resolved. - * @constructor - */ -devtools.ScriptInfo = function(scriptId, url, lineOffset, contextType, opt_isUnresolved) -{ - this.scriptId_ = scriptId; - this.lineOffset_ = lineOffset; - this.contextType_ = contextType; - this.url_ = url; - this.isUnresolved_ = opt_isUnresolved; - - this.lineToBreakpointInfo_ = {}; -}; - - -/** - * @return {number} - */ -devtools.ScriptInfo.prototype.getLineOffset = function() -{ - return this.lineOffset_; -}; - - -/** - * @return {string} - */ -devtools.ScriptInfo.prototype.getContextType = function() -{ - return this.contextType_; -}; - - -/** - * @return {?string} - */ -devtools.ScriptInfo.prototype.getUrl = function() -{ - return this.url_; -}; - - -/** - * @return {?bool} - */ -devtools.ScriptInfo.prototype.isUnresolved = function() -{ - return this.isUnresolved_; -}; - - -devtools.ScriptInfo.prototype.worldType = function() -{ - if (this.contextType_ === "injected") - return WebInspector.Script.WorldType.EXTENSIONS_WORLD; - return WebInspector.Script.WorldType.MAIN_WORLD; -}; - - -/** - * @param {number} line 0-based line number in the script. - * @return {?devtools.BreakpointInfo} Information on a breakpoint at the - * specified line in the script or undefined if there is no breakpoint at - * that line. - */ -devtools.ScriptInfo.prototype.getBreakpointInfo = function(line) -{ - return this.lineToBreakpointInfo_[line]; -}; - - -/** - * Adds breakpoint info to the script. - * @param {devtools.BreakpointInfo} breakpoint - */ -devtools.ScriptInfo.prototype.addBreakpointInfo = function(breakpoint) -{ - this.lineToBreakpointInfo_[breakpoint.getLine()] = breakpoint; -}; - - -/** - * @param {devtools.BreakpointInfo} breakpoint Breakpoint info to be removed. - */ -devtools.ScriptInfo.prototype.removeBreakpointInfo = function(breakpoint) -{ - var line = breakpoint.getLine(); - delete this.lineToBreakpointInfo_[line]; -}; - - - -/** - * @param {number} line Breakpoint 0-based line number in the containing script. - * @constructor - */ -devtools.BreakpointInfo = function(line, enabled, condition) -{ - this.line_ = line; - this.enabled_ = enabled; - this.condition_ = condition; - this.v8id_ = -1; - this.removed_ = false; -}; - - -/** - * @return {number} - */ -devtools.BreakpointInfo.prototype.getLine = function(n) -{ - return this.line_; -}; - - -/** - * @return {number} Unique identifier of this breakpoint in the v8 debugger. - */ -devtools.BreakpointInfo.prototype.getV8Id = function(n) -{ - return this.v8id_; -}; - - -/** - * Sets id of this breakpoint in the v8 debugger. - * @param {number} id - */ -devtools.BreakpointInfo.prototype.setV8Id = function(id) -{ - this.v8id_ = id; -}; - - -/** - * Marks this breakpoint as removed from the front-end. - */ -devtools.BreakpointInfo.prototype.markAsRemoved = function() -{ - this.removed_ = true; -}; - - -/** - * @return {boolean} Whether this breakpoint has been removed from the - * front-end. - */ -devtools.BreakpointInfo.prototype.isRemoved = function() -{ - return this.removed_; -}; - - -/** - * @return {boolean} Whether this breakpoint is enabled. - */ -devtools.BreakpointInfo.prototype.enabled = function() -{ - return this.enabled_; -}; - - -/** - * @return {?string} Breakpoint condition. - */ -devtools.BreakpointInfo.prototype.condition = function() -{ - return this.condition_; -}; - - -/** - * Call stack frame data. - * @param {string} id CallFrame id. - * @param {string} type CallFrame type. - * @param {string} functionName CallFrame type. - * @param {string} sourceID Source id. - * @param {number} line Source line. - * @param {Array.<Object>} scopeChain Array of scoped objects. - * @construnctor - */ -devtools.CallFrame = function(id, type, functionName, sourceID, line, scopeChain) -{ - this.id = id; - this.type = type; - this.functionName = functionName; - this.sourceID = sourceID; - this.line = line; - this.scopeChain = scopeChain; -}; - - -/** - * This method issues asynchronous evaluate request, reports result to the - * callback. - * @param {string} expression An expression to be evaluated in the context of - * this call frame. - * @param {function(Object):undefined} callback Callback to report result to. - */ -devtools.CallFrame.prototype.evaluate_ = function(expression, callback) -{ - devtools.tools.getDebuggerAgent().requestEvaluate({ - "expression": expression, - "frame": this.id, - "global": false, - "disable_break": false, - "compactFormat": true, - "maxStringLength": -1 - }, - function(response) { - var result = {}; - if (response.isSuccess()) - result.value = devtools.DebuggerAgent.formatObjectProxy_(response.getBody()); - else { - result.value = response.getMessage(); - result.isException = true; - } - callback(result); - }); -}; - - -/** - * JSON based commands sent to v8 debugger. - * @param {string} command Name of the command to execute. - * @param {Object} opt_arguments Command-specific arguments map. - * @constructor - */ -devtools.DebugCommand = function(command, opt_arguments) -{ - this.command_ = command; - this.type_ = "request"; - this.seq_ = ++devtools.DebugCommand.nextSeq_; - if (opt_arguments) - this.arguments_ = opt_arguments; -}; - - -/** - * Next unique number to be used as debugger request sequence number. - * @type {number} - */ -devtools.DebugCommand.nextSeq_ = 1; - - -/** - * @return {number} - */ -devtools.DebugCommand.prototype.getSequenceNumber = function() -{ - return this.seq_; -}; - - -/** - * @return {string} - */ -devtools.DebugCommand.prototype.toJSONProtocol = function() -{ - var json = { - "seq": this.seq_, - "type": this.type_, - "command": this.command_ - } - if (this.arguments_) - json.arguments = this.arguments_; - return JSON.stringify(json); -}; - - -/** - * JSON messages sent from v8 debugger. See protocol definition for more - * details: http://code.google.com/p/v8/wiki/DebuggerProtocol - * @param {string} msg Raw protocol packet as JSON string. - * @constructor - */ -devtools.DebuggerMessage = function(msg) -{ - this.packet_ = JSON.parse(msg); - this.refs_ = []; - if (this.packet_.refs) { - for (var i = 0; i < this.packet_.refs.length; i++) - this.refs_[this.packet_.refs[i].handle] = this.packet_.refs[i]; - } -}; - - -/** - * @return {string} The packet type. - */ -devtools.DebuggerMessage.prototype.getType = function() -{ - return this.packet_.type; -}; - - -/** - * @return {?string} The packet event if the message is an event. - */ -devtools.DebuggerMessage.prototype.getEvent = function() -{ - return this.packet_.event; -}; - - -/** - * @return {?string} The packet command if the message is a response to a - * command. - */ -devtools.DebuggerMessage.prototype.getCommand = function() -{ - return this.packet_.command; -}; - - -/** - * @return {number} The packet request sequence. - */ -devtools.DebuggerMessage.prototype.getRequestSeq = function() -{ - return this.packet_.request_seq; -}; - - -/** - * @return {number} Whether the v8 is running after processing the request. - */ -devtools.DebuggerMessage.prototype.isRunning = function() -{ - return this.packet_.running ? true : false; -}; - - -/** - * @return {boolean} Whether the request succeeded. - */ -devtools.DebuggerMessage.prototype.isSuccess = function() -{ - return this.packet_.success ? true : false; -}; - - -/** - * @return {string} - */ -devtools.DebuggerMessage.prototype.getMessage = function() -{ - return this.packet_.message; -}; - - -/** - * @return {Object} Parsed message body json. - */ -devtools.DebuggerMessage.prototype.getBody = function() -{ - return this.packet_.body; -}; - - -/** - * @param {number} handle Object handle. - * @return {?Object} Returns the object with the handle if it was sent in this - * message(some objects referenced by handles may be missing in the message). - */ -devtools.DebuggerMessage.prototype.lookup = function(handle) -{ - return this.refs_[handle]; -}; diff --git a/WebKit/chromium/src/js/DebuggerScript.js b/WebKit/chromium/src/js/DebuggerScript.js index 70c2fbe..7181d74 100644 --- a/WebKit/chromium/src/js/DebuggerScript.js +++ b/WebKit/chromium/src/js/DebuggerScript.js @@ -97,7 +97,8 @@ DebuggerScript.setBreakpoint = function(execState, args) if (!args.enabled) Debug.disableScriptBreakPoint(breakId); - var actualLineNumber = args.lineNumber; // TODO: replace with real stuff after v8 roll. + var locations = Debug.findBreakPointActualLocations(breakId); + var actualLineNumber = locations.length ? locations[0].line : args.lineNumber; var key = args.scriptId + ":" + actualLineNumber; if (key in DebuggerScript._breakpoints) { @@ -181,7 +182,7 @@ DebuggerScript.editScriptSource = function(scriptId, newSource) throw("Script not found"); var changeLog = []; - Debug.LiveEdit.SetScriptSource(scriptToEdit, newSource, changeLog); + Debug.LiveEdit.SetScriptSource(scriptToEdit, newSource, false, changeLog); return scriptToEdit.source; } diff --git a/WebKit/chromium/src/js/DevTools.js b/WebKit/chromium/src/js/DevTools.js index 851c934..35cca2f 100644 --- a/WebKit/chromium/src/js/DevTools.js +++ b/WebKit/chromium/src/js/DevTools.js @@ -62,21 +62,11 @@ devtools.ToolsAgent = function() { RemoteToolsAgent.didDispatchOn = WebInspector.Callback.processCallback; RemoteToolsAgent.dispatchOnClient = this.dispatchOnClient_.bind(this); - this.debuggerAgent_ = new devtools.DebuggerAgent(); this.profilerAgent_ = new devtools.ProfilerAgent(); }; /** - * Resets tools agent to its initial state. - */ -devtools.ToolsAgent.prototype.reset = function() -{ - this.debuggerAgent_.reset(); -}; - - -/** * @param {string} script Script exression to be evaluated in the context of the * inspected page. * @param {function(Object|string, boolean):undefined} opt_callback Function to @@ -89,15 +79,6 @@ devtools.ToolsAgent.prototype.evaluateJavaScript = function(script, opt_callback /** - * @return {devtools.DebuggerAgent} Debugger agent instance. - */ -devtools.ToolsAgent.prototype.getDebuggerAgent = function() -{ - return this.debuggerAgent_; -}; - - -/** * @return {devtools.ProfilerAgent} Profiler agent instance. */ devtools.ToolsAgent.prototype.getProfilerAgent = function() @@ -106,16 +87,6 @@ devtools.ToolsAgent.prototype.getProfilerAgent = function() }; -(function () { -var orig = WebInspector.reset; -WebInspector.reset = function() -{ - devtools.tools.reset(); - orig.call(this); -}; -})(); - - /** * @param {string} message Serialized call to be dispatched on WebInspector. * @private @@ -165,7 +136,6 @@ var oldLoaded = WebInspector.loaded; WebInspector.loaded = function() { devtools.tools = new devtools.ToolsAgent(); - devtools.tools.reset(); Preferences.ignoreWhitespace = false; Preferences.samplingCPUProfiler = true; @@ -173,6 +143,7 @@ WebInspector.loaded = function() Preferences.debuggerAlwaysEnabled = true; Preferences.profilerAlwaysEnabled = true; Preferences.canEditScriptSource = true; + Preferences.appCacheEnabled = false; oldLoaded.call(this); @@ -197,76 +168,6 @@ devtools.domContentLoaded = function() document.addEventListener("DOMContentLoaded", devtools.domContentLoaded, false); -if (!window.v8ScriptDebugServerEnabled) { - -(function() -{ - var oldShow = WebInspector.ScriptsPanel.prototype.show; - WebInspector.ScriptsPanel.prototype.show = function() - { - devtools.tools.getDebuggerAgent().initUI(); - this.enableToggleButton.visible = false; - oldShow.call(this); - }; -})(); - - -(function () { -var orig = InjectedScriptAccess.prototype.getProperties; -InjectedScriptAccess.prototype.getProperties = function(objectProxy, ignoreHasOwnProperty, abbreviate, callback) -{ - if (objectProxy.isScope) - devtools.tools.getDebuggerAgent().resolveScope(objectProxy.objectId, callback); - else if (objectProxy.isV8Ref) - devtools.tools.getDebuggerAgent().resolveChildren(objectProxy.objectId, callback, false); - else - orig.apply(this, arguments); -}; -})(); - - -(function() -{ -InjectedScriptAccess.prototype.evaluateInCallFrame = function(callFrameId, code, objectGroup, callback) -{ - //TODO(pfeldman): remove once 49084 is rolled. - if (!callback) - callback = objectGroup; - devtools.tools.getDebuggerAgent().evaluateInCallFrame(callFrameId, code, callback); -}; -})(); - - -(function() -{ -var orig = InjectedScriptAccess.prototype.getCompletions; -InjectedScriptAccess.prototype.getCompletions = function(expressionString, includeInspectorCommandLineAPI, callFrameId, reportCompletions) -{ - if (typeof callFrameId === "number") - devtools.tools.getDebuggerAgent().resolveCompletionsOnFrame(expressionString, callFrameId, reportCompletions); - else - return orig.apply(this, arguments); -}; -})(); - -// Highlight extension content scripts in the scripts list. -(function () { - var original = WebInspector.ScriptsPanel.prototype._addScriptToFilesMenu; - WebInspector.ScriptsPanel.prototype._addScriptToFilesMenu = function(script) - { - var result = original.apply(this, arguments); - var debuggerAgent = devtools.tools.getDebuggerAgent(); - var type = debuggerAgent.getScriptContextType(script.sourceID); - var option = script.filesSelectOption; - if (type === "injected" && option) - option.addStyleClass("injected"); - return result; - }; -})(); - -} - - (function InterceptProfilesPanelEvents() { var oldShow = WebInspector.ProfilesPanel.prototype.show; @@ -369,3 +270,8 @@ WebInspector.resetToolbarColors = function() WebInspector._themeStyleElement.textContent = ""; } + +// TODO(yurys): should be removed when eclipse debugger stops using it. +if (window.RemoteDebuggerAgent) { + RemoteDebuggerAgent.setContextId = function() {}; +} diff --git a/WebKit/chromium/src/js/DevToolsHostStub.js b/WebKit/chromium/src/js/DevToolsHostStub.js index bab73a9..a2f356f 100644 --- a/WebKit/chromium/src/js/DevToolsHostStub.js +++ b/WebKit/chromium/src/js/DevToolsHostStub.js @@ -33,8 +33,7 @@ * DevTools frontend to function as a standalone web app. */ -if (!window["RemoteDebuggerAgent"]) { - window["RemoteDebuggerAgent"] = { setDebuggerScriptSource: function() {} }; +if (!window["RemoteDebuggerCommandExecutor"]) { window["RemoteDebuggerCommandExecutor"] = {}; window["RemoteProfilerAgent"] = {}; window["RemoteToolsAgent"] = { diff --git a/WebKit/chromium/src/js/InspectorControllerImpl.js b/WebKit/chromium/src/js/InspectorControllerImpl.js index cbe607d..5ed506a 100644 --- a/WebKit/chromium/src/js/InspectorControllerImpl.js +++ b/WebKit/chromium/src/js/InspectorControllerImpl.js @@ -102,7 +102,6 @@ devtools.InspectorBackendImpl = function() this.installInspectorControllerDelegate_("setRuleSelector"); this.installInspectorControllerDelegate_("addRule"); - if (window.v8ScriptDebugServerEnabled) { this.installInspectorControllerDelegate_("disableDebugger"); this.installInspectorControllerDelegate_("editScriptSource"); this.installInspectorControllerDelegate_("getScriptSource"); @@ -111,129 +110,20 @@ devtools.InspectorBackendImpl = function() this.installInspectorControllerDelegate_("removeBreakpoint"); this.installInspectorControllerDelegate_("activateBreakpoints"); this.installInspectorControllerDelegate_("deactivateBreakpoints"); - this.installInspectorControllerDelegate_("resumeDebugger"); - this.installInspectorControllerDelegate_("stepIntoStatementInDebugger"); - this.installInspectorControllerDelegate_("stepOutOfFunctionInDebugger"); - this.installInspectorControllerDelegate_("stepOverStatementInDebugger"); + this.installInspectorControllerDelegate_("resume"); + this.installInspectorControllerDelegate_("stepIntoStatement"); + this.installInspectorControllerDelegate_("stepOutOfFunction"); + this.installInspectorControllerDelegate_("stepOverStatement"); this.installInspectorControllerDelegate_("setPauseOnExceptionsState"); - } }; devtools.InspectorBackendImpl.prototype.__proto__ = WebInspector.InspectorBackendStub.prototype; -if (!window.v8ScriptDebugServerEnabled) { - -devtools.InspectorBackendImpl.prototype.setBreakpoint = function(sourceID, line, enabled, condition) -{ - this.removeBreakpoint(sourceID, line); - devtools.tools.getDebuggerAgent().addBreakpoint(sourceID, line, enabled, condition); -}; - - -devtools.InspectorBackendImpl.prototype.removeBreakpoint = function(sourceID, line) -{ - devtools.tools.getDebuggerAgent().removeBreakpoint(sourceID, line); -}; - - -devtools.InspectorBackendImpl.prototype.editScriptSource = function(callID, sourceID, newContent) -{ - devtools.tools.getDebuggerAgent().editScriptSource(sourceID, newContent, function(success, newBodyOrErrorMessage, callFrames) { - WebInspector.didEditScriptSource(callID, success, newBodyOrErrorMessage, callFrames); - }); -}; - - -devtools.InspectorBackendImpl.prototype.getScriptSource = function(callID, sourceID) -{ - devtools.tools.getDebuggerAgent().resolveScriptSource( - sourceID, - function(source) { - WebInspector.didGetScriptSource(callID, source); - }); -}; - - -devtools.InspectorBackendImpl.prototype.activateBreakpoints = function() -{ - devtools.tools.getDebuggerAgent().setBreakpointsActivated(true); -}; - - -devtools.InspectorBackendImpl.prototype.deactivateBreakpoints = function() -{ - devtools.tools.getDebuggerAgent().setBreakpointsActivated(false); -}; - - -devtools.InspectorBackendImpl.prototype.pauseInDebugger = function() -{ - devtools.tools.getDebuggerAgent().pauseExecution(); -}; - - -devtools.InspectorBackendImpl.prototype.resumeDebugger = function() -{ - devtools.tools.getDebuggerAgent().resumeExecution(); -}; - - -devtools.InspectorBackendImpl.prototype.stepIntoStatementInDebugger = function() -{ - devtools.tools.getDebuggerAgent().stepIntoStatement(); -}; - - -devtools.InspectorBackendImpl.prototype.stepOutOfFunctionInDebugger = function() -{ - devtools.tools.getDebuggerAgent().stepOutOfFunction(); -}; - - -devtools.InspectorBackendImpl.prototype.stepOverStatementInDebugger = function() -{ - devtools.tools.getDebuggerAgent().stepOverStatement(); -}; - -/** - * @override - */ -devtools.InspectorBackendImpl.prototype.setPauseOnExceptionsState = function(state) -{ - this._setPauseOnExceptionsState = state; - // TODO(yurys): support all three states. See http://crbug.com/32877 - var enabled = (state !== WebInspector.ScriptsPanel.PauseOnExceptionsState.DontPauseOnExceptions); - WebInspector.updatePauseOnExceptionsState(enabled ? WebInspector.ScriptsPanel.PauseOnExceptionsState.PauseOnUncaughtExceptions : WebInspector.ScriptsPanel.PauseOnExceptionsState.DontPauseOnExceptions); - devtools.tools.getDebuggerAgent().setPauseOnExceptions(enabled); -}; - - -/** - * @override - */ -devtools.InspectorBackendImpl.prototype.pauseOnExceptions = function() -{ - return devtools.tools.getDebuggerAgent().pauseOnExceptions(); -}; - - -/** - * @override - */ -devtools.InspectorBackendImpl.prototype.setPauseOnExceptions = function(value) -{ - return devtools.tools.getDebuggerAgent().setPauseOnExceptions(value); -}; - -} else { - -devtools.InspectorBackendImpl.prototype.pauseInDebugger = function() +devtools.InspectorBackendImpl.prototype.pause = function() { RemoteDebuggerCommandExecutor.DebuggerPauseScript(); }; -} - /** * @override diff --git a/WebKit/chromium/src/js/Tests.js b/WebKit/chromium/src/js/Tests.js index 81432eb..e2ab3b3 100644 --- a/WebKit/chromium/src/js/Tests.js +++ b/WebKit/chromium/src/js/Tests.js @@ -863,29 +863,6 @@ TestSuite.prototype.evaluateInConsole_ = function(code, callback) }; -/* - * Waits for "setbreakpoint" response, checks that corresponding breakpoint - * was successfully set and invokes the callback if it was. - * @param {string} scriptUrl - * @param {number} breakpointLine - * @param {function()} callback - */ -TestSuite.prototype.waitForSetBreakpointResponse_ = function(scriptUrl, breakpointLine, callback) -{ - var test = this; - test.addSniffer( - devtools.DebuggerAgent.prototype, - "handleSetBreakpointResponse_", - function(msg) { - var bps = this.urlToBreakpoints_[scriptUrl]; - test.assertTrue(!!bps, "No breakpoints for line " + breakpointLine); - var line = devtools.DebuggerAgent.webkitToV8LineNumber_(breakpointLine); - test.assertTrue(!!bps[line].getV8Id(), "Breakpoint id was not assigned."); - callback(); - }); -}; - - /** * Tests eval on call frame. */ @@ -996,60 +973,7 @@ TestSuite.prototype.testCompletionOnPause = function() */ TestSuite.prototype.testAutoContinueOnSyntaxError = function() { - if (window.v8ScriptDebugServerEnabled) - return; - - this.showPanel("scripts"); - var test = this; - - function checkScriptsList() { - var scriptSelect = document.getElementById("scripts-files"); - var options = scriptSelect.options; - // There should be only console API source (see - // InjectedScript._ensureCommandLineAPIInstalled) since the page script - // contains a syntax error. - for (var i = 0 ; i < options.length; i++) { - if (options[i].text.search("script_syntax_error.html") !== -1) - test.fail("Script with syntax error should not be in the list of parsed scripts."); - } - } - - - this.addSniffer(devtools.DebuggerAgent.prototype, "handleScriptsResponse_", - function(msg) { - checkScriptsList(); - - // Reload inspected page. - test.evaluateInConsole_( - "window.location.reload(true);", - function(resultText) { - test.assertEquals("undefined", resultText, "Unexpected result of reload()."); - waitForExceptionEvent(); - }); - }); - - function waitForExceptionEvent() { - var exceptionCount = 0; - test.addSniffer( - devtools.DebuggerAgent.prototype, - "handleExceptionEvent_", - function(msg) { - exceptionCount++; - test.assertEquals(1, exceptionCount, "Too many exceptions."); - test.assertEquals(undefined, msg.getBody().script, "Unexpected exception: " + JSON.stringify(msg)); - test.releaseControl(); - }); - - // Check that the script is not paused on parse error. - test.addSniffer( - WebInspector, - "pausedScript", - function(callFrames) { - test.fail("Script execution should not pause on syntax error."); - }); - } - - this.takeControl(); + // TODO(yurys): provide an implementation that works with ScriptDebugServer. }; @@ -1500,14 +1424,14 @@ TestSuite.prototype.testExpandScope = function() properties: { x:"2009", innerFunctionLocalVar:"2011", - "this": (window.v8ScriptDebugServerEnabled ? "DOMWindow" : "global"), + "this": "DOMWindow", } }, { title: "Closure", properties: { - n: (window.v8ScriptDebugServerEnabled ? '"TextParam"' : "TextParam"), - makeClosureLocalVar: (window.v8ScriptDebugServerEnabled ? '"local.TextParam"' : "local.TextParam"), + n: '"TextParam"', + makeClosureLocalVar: '"local.TextParam"', } }, { @@ -1611,7 +1535,6 @@ TestSuite.prototype.testDebugIntrinsicProperties = function() } function examineLocalScope() { - if (window.v8ScriptDebugServerEnabled) { var scopeExpectations = [ "a", "Child", [ "__proto__", "Child", [ @@ -1633,47 +1556,12 @@ TestSuite.prototype.testDebugIntrinsicProperties = function() "childField", "20", null, ] ]; - } else { - var scopeExpectations = [ - "a", "Object", [ - "constructor", "function Child()", [ - "constructor", "function Function()", null, - "name", "Child", null, - "prototype", "Object", [ - "childProtoField", 21, null - ] - ], - - "__proto__", "Object", [ - "__proto__", "Object", [ - "__proto__", "Object", [ - "__proto__", "null", null, - "constructor", "function Object()", null, - ], - "constructor", "function Parent()", [ - "name", "Parent", null, - "prototype", "Object", [ - "parentProtoField", 11, null, - ] - ], - "parentProtoField", 11, null, - ], - "constructor", "function Child()", null, - "childProtoField", 21, null, - ], - - "parentField", 10, null, - "childField", 20, null, - ] - ]; - } - checkProperty(localScopeSection.propertiesTreeOutline, "<Local Scope>", scopeExpectations); } var propQueue = []; var index = 0; - var expectedFinalIndex = (window.v8ScriptDebugServerEnabled ? 5 : 8); + var expectedFinalIndex = 5; function expandAndCheckNextProperty() { if (index === propQueue.length) { diff --git a/WebKit/chromium/src/js/devTools.css b/WebKit/chromium/src/js/devTools.css index 0e6d284..dfcaadf 100755 --- a/WebKit/chromium/src/js/devTools.css +++ b/WebKit/chromium/src/js/devTools.css @@ -171,10 +171,6 @@ body.platform-linux #scripts-files { padding-left: 6px; } -.crumbs .crumb.end { - -webkit-border-image: url(Images/segmentEndChromium.png) 0 2 0 2; -} - .crumbs .crumb.selected { -webkit-border-image: url(Images/segmentSelectedChromium.png) 0 12 0 2; color: white; |