diff options
Diffstat (limited to 'chromium/third_party/WebKit/Source/core/testing')
17 files changed, 952 insertions, 536 deletions
diff --git a/chromium/third_party/WebKit/Source/core/testing/DummyPageHolder.cpp b/chromium/third_party/WebKit/Source/core/testing/DummyPageHolder.cpp new file mode 100644 index 00000000000..e4095502200 --- /dev/null +++ b/chromium/third_party/WebKit/Source/core/testing/DummyPageHolder.cpp @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2013, 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 "core/testing/DummyPageHolder.h" + +#include "core/frame/DOMWindow.h" +#include "core/frame/Frame.h" +#include "core/frame/FrameView.h" +#include "wtf/Assertions.h" + +namespace WebCore { + +PassOwnPtr<DummyPageHolder> DummyPageHolder::create(const IntSize& initialViewSize) +{ + return adoptPtr(new DummyPageHolder(initialViewSize)); +} + +DummyPageHolder::DummyPageHolder(const IntSize& initialViewSize) +{ + m_pageClients.chromeClient = &m_chromeClient; + m_pageClients.contextMenuClient = &m_contextMenuClient; + m_pageClients.editorClient = &m_editorClient; + m_pageClients.dragClient = &m_dragClient; + m_pageClients.inspectorClient = &m_inspectorClient; + m_pageClients.backForwardClient = &m_backForwardClient; + + m_page = adoptPtr(new Page(m_pageClients)); + + m_frame = Frame::create(FrameInit::create(0, m_page.get(), &m_frameLoaderClient)); + m_frame->setView(FrameView::create(m_frame.get(), initialViewSize)); + m_frame->init(); +} + +DummyPageHolder::~DummyPageHolder() +{ + m_page.clear(); + ASSERT(m_frame->hasOneRef()); + m_frame.clear(); +} + +Page& DummyPageHolder::page() const +{ + return *m_page; +} + +Frame& DummyPageHolder::frame() const +{ + return *m_frame; +} + +FrameView& DummyPageHolder::frameView() const +{ + return *m_frame->view(); +} + +Document& DummyPageHolder::document() const +{ + return *m_frame->domWindow()->document(); +} + +} // namespace WebCore diff --git a/chromium/third_party/WebKit/Source/core/testing/DummyPageHolder.h b/chromium/third_party/WebKit/Source/core/testing/DummyPageHolder.h new file mode 100644 index 00000000000..d80f4dc083b --- /dev/null +++ b/chromium/third_party/WebKit/Source/core/testing/DummyPageHolder.h @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2013, 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. + */ + +#ifndef DummyPageHolder_h +#define DummyPageHolder_h + +#include "core/loader/EmptyClients.h" +#include "core/page/Page.h" +#include "platform/geometry/IntSize.h" +#include "wtf/FastAllocBase.h" +#include "wtf/Noncopyable.h" +#include "wtf/OwnPtr.h" +#include "wtf/PassOwnPtr.h" + +namespace WebCore { + +class Document; +class Frame; +class FrameView; +class IntSize; + +// Creates a dummy Page, Frame, and FrameView whose clients are all no-op. +// +// This class can be used when you write unit tests for components which do not work correctly without renderers. +// To make sure the renderers are created, you need to call |frameView().layout()| after you add nodes into +// |document()|. +// +// Since DummyPageHolder stores empty clients in it, it must outlive the Page, Frame, FrameView and any other objects +// created by it. DummyPageHolder's destructor ensures this condition by checking remaining references to the Frame. + +class DummyPageHolder { + WTF_MAKE_NONCOPYABLE(DummyPageHolder); + WTF_MAKE_FAST_ALLOCATED; +public: + static PassOwnPtr<DummyPageHolder> create(const IntSize& initialViewSize = IntSize()); + ~DummyPageHolder(); + + Page& page() const; + Frame& frame() const; + FrameView& frameView() const; + Document& document() const; + +private: + explicit DummyPageHolder(const IntSize& initialViewSize); + + OwnPtr<Page> m_page; + RefPtr<Frame> m_frame; + + Page::PageClients m_pageClients; + EmptyChromeClient m_chromeClient; + EmptyContextMenuClient m_contextMenuClient; + EmptyEditorClient m_editorClient; + EmptyDragClient m_dragClient; + EmptyInspectorClient m_inspectorClient; + EmptyBackForwardClient m_backForwardClient; + EmptyFrameLoaderClient m_frameLoaderClient; +}; + +} // namespace WebCore + +#endif // DummyPageHolder_h diff --git a/chromium/third_party/WebKit/Source/core/testing/GCObservation.cpp b/chromium/third_party/WebKit/Source/core/testing/GCObservation.cpp index 90738d495bb..7c25450115b 100644 --- a/chromium/third_party/WebKit/Source/core/testing/GCObservation.cpp +++ b/chromium/third_party/WebKit/Source/core/testing/GCObservation.cpp @@ -33,9 +33,9 @@ namespace WebCore { -static void makeWeakCallback(v8::Isolate*, v8::Persistent<v8::Value>*, GCObservation* observation) +static void setWeakCallback(const v8::WeakCallbackData<v8::Value, GCObservation>& data) { - observation->setWasCollected(); + data.GetParameter()->setWasCollected(); } void GCObservation::setWasCollected() @@ -49,8 +49,7 @@ GCObservation::GCObservation(v8::Handle<v8::Value> observedValue) : m_observed(v8::Isolate::GetCurrent(), observedValue) , m_collected(false) { - m_observed.makeWeak(this, makeWeakCallback); + m_observed.setWeak(this, setWeakCallback); } } // namespace WebCore - diff --git a/chromium/third_party/WebKit/Source/core/testing/InspectorFrontendClientLocal.cpp b/chromium/third_party/WebKit/Source/core/testing/InspectorFrontendClientLocal.cpp index 3d57d2617a4..f61a422654d 100644 --- a/chromium/third_party/WebKit/Source/core/testing/InspectorFrontendClientLocal.cpp +++ b/chromium/third_party/WebKit/Source/core/testing/InspectorFrontendClientLocal.cpp @@ -32,15 +32,15 @@ #include "InspectorFrontendClientLocal.h" #include "bindings/v8/ScriptObject.h" +#include "bindings/v8/ScriptState.h" #include "core/inspector/InspectorController.h" #include "core/inspector/InspectorFrontendHost.h" #include "core/page/Page.h" -#include "core/page/Settings.h" -#include "core/platform/Timer.h" +#include "core/frame/Settings.h" +#include "platform/Timer.h" #include "public/platform/Platform.h" #include "public/platform/WebThread.h" #include "wtf/Deque.h" -#include "wtf/text/WTFString.h" namespace WebCore { @@ -68,7 +68,7 @@ public: private: void schedule() { - class TaskImpl : public WebKit::WebThread::Task { + class TaskImpl : public blink::WebThread::Task { public: RefPtr<InspectorBackendMessageQueue> owner; virtual void run() @@ -78,7 +78,7 @@ private: }; TaskImpl* taskImpl = new TaskImpl; taskImpl->owner = this; - WebKit::Platform::current()->currentThread()->postTask(taskImpl); + blink::Platform::current()->currentThread()->postTask(taskImpl); } void deliver() diff --git a/chromium/third_party/WebKit/Source/core/testing/InternalProfilers.cpp b/chromium/third_party/WebKit/Source/core/testing/InternalProfilers.cpp index 4560ee4ae35..95d706f90cb 100644 --- a/chromium/third_party/WebKit/Source/core/testing/InternalProfilers.cpp +++ b/chromium/third_party/WebKit/Source/core/testing/InternalProfilers.cpp @@ -40,22 +40,22 @@ namespace WebCore { void InternalProfilers::startHeapProfiling(const String& prefix) { - WebKit::Platform::current()->startHeapProfiling(prefix); + blink::Platform::current()->startHeapProfiling(prefix); } void InternalProfilers::stopHeapProfiling() { - WebKit::Platform::current()->stopHeapProfiling(); + blink::Platform::current()->stopHeapProfiling(); } void InternalProfilers::dumpHeapProfiling(const String& reason) { - WebKit::Platform::current()->dumpHeapProfiling(reason); + blink::Platform::current()->dumpHeapProfiling(reason); } String InternalProfilers::getHeapProfile() { - String text = WebKit::Platform::current()->getHeapProfile(); + String text = blink::Platform::current()->getHeapProfile(); // Only return the first line which contains total numbers // because whole dump is too big and too noisy to process in JavaScript. return text.substring(0, text.find('\n')); diff --git a/chromium/third_party/WebKit/Source/core/testing/InternalSettings.cpp b/chromium/third_party/WebKit/Source/core/testing/InternalSettings.cpp index 33c45eb4a23..41c75658894 100644 --- a/chromium/third_party/WebKit/Source/core/testing/InternalSettings.cpp +++ b/chromium/third_party/WebKit/Source/core/testing/InternalSettings.cpp @@ -31,26 +31,26 @@ #include "bindings/v8/ExceptionState.h" #include "core/dom/ExceptionCode.h" #include "core/page/Page.h" -#include "core/page/Settings.h" -#include "core/platform/ColorChooser.h" -#include "core/platform/Supplementable.h" -#include "core/platform/text/LocaleToScriptMapping.h" +#include "core/frame/Settings.h" +#include "platform/ColorChooser.h" +#include "platform/Supplementable.h" +#include "platform/text/LocaleToScriptMapping.h" #define InternalSettingsGuardForSettingsReturn(returnValue) \ if (!settings()) { \ - es.throwDOMException(InvalidAccessError); \ + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); \ return returnValue; \ } #define InternalSettingsGuardForSettings() \ if (!settings()) { \ - es.throwDOMException(InvalidAccessError); \ + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); \ return; \ } #define InternalSettingsGuardForPage() \ if (!page()) { \ - es.throwDOMException(InvalidAccessError); \ + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); \ return; \ } @@ -65,16 +65,18 @@ InternalSettings::Backup::Backup(Settings* settings) , m_originalEditingBehavior(settings->editingBehaviorType()) , m_originalTextAutosizingEnabled(settings->textAutosizingEnabled()) , m_originalTextAutosizingWindowSizeOverride(settings->textAutosizingWindowSizeOverride()) - , m_originalTextAutosizingFontScaleFactor(settings->textAutosizingFontScaleFactor()) + , m_originalAccessibilityFontScaleFactor(settings->accessibilityFontScaleFactor()) , m_originalMediaTypeOverride(settings->mediaTypeOverride()) , m_originalMockScrollbarsEnabled(settings->mockScrollbarsEnabled()) , m_langAttributeAwareFormControlUIEnabled(RuntimeEnabledFeatures::langAttributeAwareFormControlUIEnabled()) - , m_imagesEnabled(settings->areImagesEnabled()) + , m_imagesEnabled(settings->imagesEnabled()) , m_shouldDisplaySubtitles(settings->shouldDisplaySubtitles()) , m_shouldDisplayCaptions(settings->shouldDisplayCaptions()) , m_shouldDisplayTextDescriptions(settings->shouldDisplayTextDescriptions()) , m_defaultVideoPosterURL(settings->defaultVideoPosterURL()) - , m_originalCompositorDrivenAcceleratedScrollEnabled(settings->isCompositorDrivenAcceleratedScrollingEnabled()) + , m_originalCompositorDrivenAcceleratedScrollEnabled(settings->compositorDrivenAcceleratedScrollingEnabled()) + , m_originalLayerSquashingEnabled(settings->layerSquashingEnabled()) + , m_originalPasswordGenerationDecorationEnabled(settings->passwordGenerationDecorationEnabled()) { } @@ -88,7 +90,7 @@ void InternalSettings::Backup::restoreTo(Settings* settings) settings->setEditingBehaviorType(m_originalEditingBehavior); settings->setTextAutosizingEnabled(m_originalTextAutosizingEnabled); settings->setTextAutosizingWindowSizeOverride(m_originalTextAutosizingWindowSizeOverride); - settings->setTextAutosizingFontScaleFactor(m_originalTextAutosizingFontScaleFactor); + settings->setAccessibilityFontScaleFactor(m_originalAccessibilityFontScaleFactor); settings->setMediaTypeOverride(m_originalMediaTypeOverride); settings->setMockScrollbarsEnabled(m_originalMockScrollbarsEnabled); RuntimeEnabledFeatures::setLangAttributeAwareFormControlUIEnabled(m_langAttributeAwareFormControlUIEnabled); @@ -98,6 +100,9 @@ void InternalSettings::Backup::restoreTo(Settings* settings) settings->setShouldDisplayTextDescriptions(m_shouldDisplayTextDescriptions); settings->setDefaultVideoPosterURL(m_defaultVideoPosterURL); settings->setCompositorDrivenAcceleratedScrollingEnabled(m_originalCompositorDrivenAcceleratedScrollEnabled); + settings->setLayerSquashingEnabled(m_originalLayerSquashingEnabled); + settings->setPasswordGenerationDecorationEnabled(m_originalPasswordGenerationDecorationEnabled); + settings->genericFontFamilySettings().reset(); } // We can't use RefCountedSupplement because that would try to make InternalSettings RefCounted @@ -157,7 +162,7 @@ Settings* InternalSettings::settings() const return &page()->settings(); } -void InternalSettings::setMockScrollbarsEnabled(bool enabled, ExceptionState& es) +void InternalSettings::setMockScrollbarsEnabled(bool enabled, ExceptionState& exceptionState) { InternalSettingsGuardForSettings(); settings()->setMockScrollbarsEnabled(enabled); @@ -183,13 +188,13 @@ void InternalSettings::setOverlayScrollbarsEnabled(bool enabled) RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(enabled); } -void InternalSettings::setTouchEventEmulationEnabled(bool enabled, ExceptionState& es) +void InternalSettings::setTouchEventEmulationEnabled(bool enabled, ExceptionState& exceptionState) { InternalSettingsGuardForSettings(); settings()->setTouchEventEmulationEnabled(enabled); } -void InternalSettings::setViewportEnabled(bool enabled, ExceptionState& es) +void InternalSettings::setViewportEnabled(bool enabled, ExceptionState& exceptionState) { InternalSettingsGuardForSettings(); settings()->setViewportEnabled(enabled); @@ -197,84 +202,112 @@ void InternalSettings::setViewportEnabled(bool enabled, ExceptionState& es) // FIXME: This is a temporary flag and should be removed once accelerated // overflow scroll is ready (crbug.com/254111). -void InternalSettings::setCompositorDrivenAcceleratedScrollingEnabled(bool enabled, ExceptionState& es) +void InternalSettings::setCompositorDrivenAcceleratedScrollingEnabled(bool enabled, ExceptionState& exceptionState) { InternalSettingsGuardForSettings(); settings()->setCompositorDrivenAcceleratedScrollingEnabled(enabled); } -typedef void (Settings::*SetFontFamilyFunction)(const AtomicString&, UScriptCode); -static void setFontFamily(Settings* settings, const String& family, const String& script, SetFontFamilyFunction setter) +// FIXME: This is a temporary flag and should be removed once squashing is +// ready (crbug.com/261605). +void InternalSettings::setLayerSquashingEnabled(bool enabled, ExceptionState& exceptionState) { - UScriptCode code = scriptNameToCode(script); - if (code != USCRIPT_INVALID_CODE) - (settings->*setter)(family, code); + InternalSettingsGuardForSettings(); + settings()->setLayerSquashingEnabled(enabled); } -void InternalSettings::setStandardFontFamily(const String& family, const String& script, ExceptionState& es) +void InternalSettings::setStandardFontFamily(const String& family, const String& script, ExceptionState& exceptionState) { InternalSettingsGuardForSettings(); - setFontFamily(settings(), family, script, &Settings::setStandardFontFamily); + UScriptCode code = scriptNameToCode(script); + if (code == USCRIPT_INVALID_CODE) + return; + settings()->genericFontFamilySettings().setStandard(family, code); + m_page->setNeedsRecalcStyleInAllFrames(); } -void InternalSettings::setSerifFontFamily(const String& family, const String& script, ExceptionState& es) +void InternalSettings::setSerifFontFamily(const String& family, const String& script, ExceptionState& exceptionState) { InternalSettingsGuardForSettings(); - setFontFamily(settings(), family, script, &Settings::setSerifFontFamily); + UScriptCode code = scriptNameToCode(script); + if (code == USCRIPT_INVALID_CODE) + return; + settings()->genericFontFamilySettings().setSerif(family, code); + m_page->setNeedsRecalcStyleInAllFrames(); } -void InternalSettings::setSansSerifFontFamily(const String& family, const String& script, ExceptionState& es) +void InternalSettings::setSansSerifFontFamily(const String& family, const String& script, ExceptionState& exceptionState) { InternalSettingsGuardForSettings(); - setFontFamily(settings(), family, script, &Settings::setSansSerifFontFamily); + UScriptCode code = scriptNameToCode(script); + if (code == USCRIPT_INVALID_CODE) + return; + settings()->genericFontFamilySettings().setSansSerif(family, code); + m_page->setNeedsRecalcStyleInAllFrames(); } -void InternalSettings::setFixedFontFamily(const String& family, const String& script, ExceptionState& es) +void InternalSettings::setFixedFontFamily(const String& family, const String& script, ExceptionState& exceptionState) { InternalSettingsGuardForSettings(); - setFontFamily(settings(), family, script, &Settings::setFixedFontFamily); + UScriptCode code = scriptNameToCode(script); + if (code == USCRIPT_INVALID_CODE) + return; + settings()->genericFontFamilySettings().setFixed(family, code); + m_page->setNeedsRecalcStyleInAllFrames(); } -void InternalSettings::setCursiveFontFamily(const String& family, const String& script, ExceptionState& es) +void InternalSettings::setCursiveFontFamily(const String& family, const String& script, ExceptionState& exceptionState) { InternalSettingsGuardForSettings(); - setFontFamily(settings(), family, script, &Settings::setCursiveFontFamily); + UScriptCode code = scriptNameToCode(script); + if (code == USCRIPT_INVALID_CODE) + return; + settings()->genericFontFamilySettings().setCursive(family, code); + m_page->setNeedsRecalcStyleInAllFrames(); } -void InternalSettings::setFantasyFontFamily(const String& family, const String& script, ExceptionState& es) +void InternalSettings::setFantasyFontFamily(const String& family, const String& script, ExceptionState& exceptionState) { InternalSettingsGuardForSettings(); - setFontFamily(settings(), family, script, &Settings::setFantasyFontFamily); + UScriptCode code = scriptNameToCode(script); + if (code == USCRIPT_INVALID_CODE) + return; + settings()->genericFontFamilySettings().setFantasy(family, code); + m_page->setNeedsRecalcStyleInAllFrames(); } -void InternalSettings::setPictographFontFamily(const String& family, const String& script, ExceptionState& es) +void InternalSettings::setPictographFontFamily(const String& family, const String& script, ExceptionState& exceptionState) { InternalSettingsGuardForSettings(); - setFontFamily(settings(), family, script, &Settings::setPictographFontFamily); + UScriptCode code = scriptNameToCode(script); + if (code == USCRIPT_INVALID_CODE) + return; + settings()->genericFontFamilySettings().setPictograph(family, code); + m_page->setNeedsRecalcStyleInAllFrames(); } -void InternalSettings::setTextAutosizingEnabled(bool enabled, ExceptionState& es) +void InternalSettings::setTextAutosizingEnabled(bool enabled, ExceptionState& exceptionState) { InternalSettingsGuardForSettings(); settings()->setTextAutosizingEnabled(enabled); } -void InternalSettings::setTextAutosizingWindowSizeOverride(int width, int height, ExceptionState& es) +void InternalSettings::setTextAutosizingWindowSizeOverride(int width, int height, ExceptionState& exceptionState) { InternalSettingsGuardForSettings(); settings()->setTextAutosizingWindowSizeOverride(IntSize(width, height)); } -void InternalSettings::setMediaTypeOverride(const String& mediaType, ExceptionState& es) +void InternalSettings::setMediaTypeOverride(const String& mediaType, ExceptionState& exceptionState) { InternalSettingsGuardForSettings(); settings()->setMediaTypeOverride(mediaType); } -void InternalSettings::setTextAutosizingFontScaleFactor(float fontScaleFactor, ExceptionState& es) +void InternalSettings::setAccessibilityFontScaleFactor(float fontScaleFactor, ExceptionState& exceptionState) { InternalSettingsGuardForSettings(); - settings()->setTextAutosizingFontScaleFactor(fontScaleFactor); + settings()->setAccessibilityFontScaleFactor(fontScaleFactor); } void InternalSettings::setCSSExclusionsEnabled(bool enabled) @@ -282,7 +315,7 @@ void InternalSettings::setCSSExclusionsEnabled(bool enabled) RuntimeEnabledFeatures::setCSSExclusionsEnabled(enabled); } -void InternalSettings::setEditingBehavior(const String& editingBehavior, ExceptionState& es) +void InternalSettings::setEditingBehavior(const String& editingBehavior, ExceptionState& exceptionState) { InternalSettingsGuardForSettings(); if (equalIgnoringCase(editingBehavior, "win")) @@ -294,7 +327,7 @@ void InternalSettings::setEditingBehavior(const String& editingBehavior, Excepti else if (equalIgnoringCase(editingBehavior, "android")) settings()->setEditingBehaviorType(EditingAndroidBehavior); else - es.throwDOMException(SyntaxError); + exceptionState.throwUninformativeAndGenericDOMException(SyntaxError); } void InternalSettings::setLangAttributeAwareFormControlUIEnabled(bool enabled) @@ -302,16 +335,22 @@ void InternalSettings::setLangAttributeAwareFormControlUIEnabled(bool enabled) RuntimeEnabledFeatures::setLangAttributeAwareFormControlUIEnabled(enabled); } -void InternalSettings::setImagesEnabled(bool enabled, ExceptionState& es) +void InternalSettings::setImagesEnabled(bool enabled, ExceptionState& exceptionState) { InternalSettingsGuardForSettings(); settings()->setImagesEnabled(enabled); } -void InternalSettings::setDefaultVideoPosterURL(const String& url, ExceptionState& es) +void InternalSettings::setDefaultVideoPosterURL(const String& url, ExceptionState& exceptionState) { InternalSettingsGuardForSettings(); settings()->setDefaultVideoPosterURL(url); } +void InternalSettings::setPasswordGenerationDecorationEnabled(bool enabled, ExceptionState& exceptionState) +{ + InternalSettingsGuardForSettings(); + settings()->setPasswordGenerationDecorationEnabled(enabled); +} + } diff --git a/chromium/third_party/WebKit/Source/core/testing/InternalSettings.h b/chromium/third_party/WebKit/Source/core/testing/InternalSettings.h index 7433e1eb89e..cc064baa413 100644 --- a/chromium/third_party/WebKit/Source/core/testing/InternalSettings.h +++ b/chromium/third_party/WebKit/Source/core/testing/InternalSettings.h @@ -29,7 +29,7 @@ #include "InternalSettingsGenerated.h" #include "core/editing/EditingBehaviorTypes.h" -#include "core/platform/graphics/IntSize.h" +#include "platform/geometry/IntSize.h" #include "wtf/PassRefPtr.h" #include "wtf/RefCounted.h" #include "wtf/text/WTFString.h" @@ -57,7 +57,7 @@ public: EditingBehaviorType m_originalEditingBehavior; bool m_originalTextAutosizingEnabled; IntSize m_originalTextAutosizingWindowSizeOverride; - float m_originalTextAutosizingFontScaleFactor; + float m_originalAccessibilityFontScaleFactor; String m_originalMediaTypeOverride; bool m_originalMockScrollbarsEnabled; bool m_langAttributeAwareFormControlUIEnabled; @@ -67,6 +67,8 @@ public: bool m_shouldDisplayTextDescriptions; String m_defaultVideoPosterURL; bool m_originalCompositorDrivenAcceleratedScrollEnabled; + bool m_originalLayerSquashingEnabled; + bool m_originalPasswordGenerationDecorationEnabled; }; static PassRefPtr<InternalSettings> create(Page* page) @@ -92,8 +94,9 @@ public: void setImagesEnabled(bool, ExceptionState&); void setMediaTypeOverride(const String& mediaType, ExceptionState&); void setMockScrollbarsEnabled(bool, ExceptionState&); + void setPasswordGenerationDecorationEnabled(bool, ExceptionState&); void setTextAutosizingEnabled(bool, ExceptionState&); - void setTextAutosizingFontScaleFactor(float fontScaleFactor, ExceptionState&); + void setAccessibilityFontScaleFactor(float fontScaleFactor, ExceptionState&); void setTextAutosizingWindowSizeOverride(int width, int height, ExceptionState&); void setTouchEventEmulationEnabled(bool, ExceptionState&); void setViewportEnabled(bool, ExceptionState&); @@ -102,6 +105,10 @@ public: // overflow scroll is ready (crbug.com/254111). void setCompositorDrivenAcceleratedScrollingEnabled(bool, ExceptionState&); + // FIXME: This is a temporary flag and should be removed once squashing is + // ready (crbug.com/261605). + void setLayerSquashingEnabled(bool, ExceptionState&); + // FIXME: The following are RuntimeEnabledFeatures and likely // cannot be changed after process start. These setters should // be removed or moved onto internals.runtimeFlags: diff --git a/chromium/third_party/WebKit/Source/core/testing/InternalSettings.idl b/chromium/third_party/WebKit/Source/core/testing/InternalSettings.idl index 9e03edce2b8..d4f598460ea 100644 --- a/chromium/third_party/WebKit/Source/core/testing/InternalSettings.idl +++ b/chromium/third_party/WebKit/Source/core/testing/InternalSettings.idl @@ -38,10 +38,10 @@ [RaisesException] void setPictographFontFamily(DOMString family, DOMString script); [RaisesException] void setTextAutosizingEnabled(boolean enabled); [RaisesException] void setTextAutosizingWindowSizeOverride(long width, long height); - [RaisesException] void setTextAutosizingFontScaleFactor(float fontScaleFactor); + [RaisesException] void setAccessibilityFontScaleFactor(float fontScaleFactor); [RaisesException] void setMediaTypeOverride(DOMString mediaTypeOverride); [RaisesException] void setEditingBehavior(DOMString behavior); - + [RaisesException] void setPasswordGenerationDecorationEnabled(boolean enabled); [RaisesException] void setImagesEnabled(boolean enabled); [RaisesException] void setDefaultVideoPosterURL(DOMString poster); [RaisesException] void setViewportEnabled(boolean enabled); @@ -50,6 +50,10 @@ // overflow scroll is ready (crbug.com/254111). [RaisesException] void setCompositorDrivenAcceleratedScrollingEnabled(boolean enabled); + // FIXME: This is a temporary flag and should be removed once squashing is + // ready (crbug.com/261605). + [RaisesException] void setLayerSquashingEnabled(boolean enabled); + // FIXME: The following are RuntimeEnabledFeatures and likely // cannot be changed after process start. These setters should // be removed or moved onto internals.runtimeFlags: diff --git a/chromium/third_party/WebKit/Source/core/testing/Internals.cpp b/chromium/third_party/WebKit/Source/core/testing/Internals.cpp index 746a0ab4884..5abaf92407e 100644 --- a/chromium/third_party/WebKit/Source/core/testing/Internals.cpp +++ b/chromium/third_party/WebKit/Source/core/testing/Internals.cpp @@ -27,6 +27,7 @@ #include "config.h" #include "Internals.h" +#include <v8.h> #include "HTMLNames.h" #include "InspectorFrontendClientLocal.h" #include "InternalProfilers.h" @@ -44,6 +45,7 @@ #include "core/animation/DocumentTimeline.h" #include "core/css/StyleSheetContents.h" #include "core/css/resolver/StyleResolver.h" +#include "core/css/resolver/StyleResolverStats.h" #include "core/css/resolver/ViewportStyleResolver.h" #include "core/dom/ClientRect.h" #include "core/dom/ClientRectList.h" @@ -58,19 +60,23 @@ #include "core/dom/Range.h" #include "core/dom/StaticNodeList.h" #include "core/dom/TreeScope.h" -#include "core/dom/ViewportArguments.h" +#include "core/dom/ViewportDescription.h" #include "core/dom/WheelController.h" #include "core/dom/shadow/ComposedTreeWalker.h" #include "core/dom/shadow/ElementShadow.h" #include "core/dom/shadow/SelectRuleFeatureSet.h" #include "core/dom/shadow/ShadowRoot.h" #include "core/editing/Editor.h" +#include "core/editing/PlainTextRange.h" #include "core/editing/SpellCheckRequester.h" +#include "core/editing/SpellChecker.h" #include "core/editing/TextIterator.h" #include "core/fetch/MemoryCache.h" #include "core/fetch/ResourceFetcher.h" -#include "core/history/BackForwardController.h" +#include "core/frame/DOMPoint.h" +#include "core/frame/Frame.h" #include "core/history/HistoryItem.h" +#include "core/html/HTMLIFrameElement.h" #include "core/html/HTMLInputElement.h" #include "core/html/HTMLMediaElement.h" #include "core/html/HTMLSelectElement.h" @@ -88,29 +94,16 @@ #include "core/loader/FrameLoader.h" #include "core/page/Chrome.h" #include "core/page/ChromeClient.h" -#include "core/page/DOMPoint.h" -#include "core/page/DOMWindow.h" +#include "core/frame/DOMWindow.h" #include "core/page/EventHandler.h" -#include "core/page/Frame.h" -#include "core/page/FrameView.h" +#include "core/frame/FrameView.h" #include "core/page/Page.h" #include "core/page/PagePopupController.h" #include "core/page/PrintContext.h" -#include "core/page/Settings.h" -#include "core/page/animation/AnimationController.h" -#include "core/page/scrolling/ScrollingCoordinator.h" -#include "core/platform/ColorChooser.h" -#include "core/platform/Cursor.h" -#include "core/platform/Language.h" -#include "core/platform/chromium/TraceEvent.h" -#include "core/platform/graphics/GraphicsLayer.h" -#include "core/platform/graphics/IntRect.h" -#include "core/platform/graphics/filters/FilterOperation.h" -#include "core/platform/graphics/filters/FilterOperations.h" -#include "core/platform/graphics/gpu/SharedGraphicsContext3D.h" -#include "core/platform/mock/PlatformSpeechSynthesizerMock.h" +#include "core/frame/Settings.h" +#include "core/frame/animation/AnimationController.h" +#include "core/rendering/CompositedLayerMapping.h" #include "core/rendering/RenderLayer.h" -#include "core/rendering/RenderLayerBacking.h" #include "core/rendering/RenderLayerCompositor.h" #include "core/rendering/RenderMenuList.h" #include "core/rendering/RenderObject.h" @@ -118,13 +111,21 @@ #include "core/rendering/RenderView.h" #include "core/testing/GCObservation.h" #include "core/workers/WorkerThread.h" -#include "modules/speech/DOMWindowSpeechSynthesis.h" -#include "modules/speech/SpeechSynthesis.h" +#include "platform/ColorChooser.h" +#include "platform/Cursor.h" +#include "platform/Language.h" +#include "platform/TraceEvent.h" +#include "platform/geometry/IntRect.h" +#include "platform/geometry/LayoutRect.h" +#include "platform/graphics/GraphicsLayer.h" +#include "platform/graphics/filters/FilterOperation.h" +#include "platform/graphics/filters/FilterOperations.h" +#include "platform/graphics/gpu/SharedGraphicsContext3D.h" +#include "platform/weborigin/SchemeRegistry.h" #include "public/platform/WebLayer.h" -#include "weborigin/SchemeRegistry.h" +#include "wtf/InstanceCounter.h" #include "wtf/dtoa.h" #include "wtf/text/StringBuffer.h" -#include <v8.h> namespace WebCore { @@ -172,7 +173,7 @@ static SpellCheckRequester* spellCheckRequester(Document* document) { if (!document || !document->frame()) return 0; - return &document->frame()->editor().spellCheckRequester(); + return &document->frame()->spellChecker().spellCheckRequester(); } const char* Internals::internalsId = "internals"; @@ -191,6 +192,7 @@ void Internals::resetToConsistentState(Page* page) ASSERT(page); page->setDeviceScaleFactor(1); + page->setIsCursorVisible(true); page->setPageScaleFactor(1, IntPoint(0, 0)); page->setPagination(Pagination()); TextRun::setAllowsRoundingHacks(false); @@ -198,10 +200,15 @@ void Internals::resetToConsistentState(Page* page) delete s_pagePopupDriver; s_pagePopupDriver = 0; page->chrome().client().resetPagePopupDriver(); - if (!page->mainFrame()->editor().isContinuousSpellCheckingEnabled()) - page->mainFrame()->editor().toggleContinuousSpellChecking(); + if (!page->mainFrame()->spellChecker().isContinuousSpellCheckingEnabled()) + page->mainFrame()->spellChecker().toggleContinuousSpellChecking(); if (page->mainFrame()->editor().isOverwriteModeEnabled()) page->mainFrame()->editor().toggleOverwriteModeEnabled(); + + if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator()) + scrollingCoordinator->reset(); + + page->mainFrame()->view()->clear(); } Internals::Internals(Document* document) @@ -213,7 +220,7 @@ Internals::Internals(Document* document) Document* Internals::contextDocument() const { - return toDocument(scriptExecutionContext()); + return toDocument(executionContext()); } Frame* Internals::frame() const @@ -271,6 +278,19 @@ PassRefPtr<GCObservation> Internals::observeGC(ScriptValue scriptValue) return GCObservation::create(observedValue); } +unsigned Internals::updateStyleAndReturnAffectedElementCount(ExceptionState& exceptionState) const +{ + Document* document = contextDocument(); + if (!document) { + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); + return 0; + } + + unsigned beforeCount = document->styleEngine()->resolverAccessCount(); + document->updateStyleIfNeeded(); + return document->styleEngine()->resolverAccessCount() - beforeCount; +} + bool Internals::isPreloaded(const String& url) { Document* document = contextDocument(); @@ -290,81 +310,110 @@ void Internals::crash() CRASH(); } -PassRefPtr<Element> Internals::createContentElement(ExceptionState& es) +void Internals::setStyleResolverStatsEnabled(bool enabled) +{ + Document* document = contextDocument(); + if (enabled) + document->ensureStyleResolver().enableStats(StyleResolver::ReportSlowStats); + else + document->ensureStyleResolver().disableStats(); +} + +String Internals::styleResolverStatsReport(ExceptionState& exceptionState) const +{ + Document* document = contextDocument(); + if (!document->ensureStyleResolver().stats()) { + exceptionState.throwDOMException(InvalidStateError, "Style resolver stats not enabled"); + return String(); + } + return document->ensureStyleResolver().stats()->report(); +} + +String Internals::styleResolverStatsTotalsReport(ExceptionState& exceptionState) const +{ + Document* document = contextDocument(); + if (!document->ensureStyleResolver().statsTotals()) { + exceptionState.throwDOMException(InvalidStateError, "Style resolver stats not enabled"); + return String(); + } + return document->ensureStyleResolver().statsTotals()->report(); +} + +PassRefPtr<Element> Internals::createContentElement(ExceptionState& exceptionState) { Document* document = contextDocument(); if (!document) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } return HTMLContentElement::create(*document); } -bool Internals::isValidContentSelect(Element* insertionPoint, ExceptionState& es) +bool Internals::isValidContentSelect(Element* insertionPoint, ExceptionState& exceptionState) { if (!insertionPoint || !insertionPoint->isInsertionPoint()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return false; } return isHTMLContentElement(insertionPoint) && toHTMLContentElement(insertionPoint)->isSelectValid(); } -Node* Internals::treeScopeRootNode(Node* node, ExceptionState& es) +Node* Internals::treeScopeRootNode(Node* node, ExceptionState& exceptionState) { if (!node) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } return node->treeScope().rootNode(); } -Node* Internals::parentTreeScope(Node* node, ExceptionState& es) +Node* Internals::parentTreeScope(Node* node, ExceptionState& exceptionState) { if (!node) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } const TreeScope* parentTreeScope = node->treeScope().parentTreeScope(); return parentTreeScope ? parentTreeScope->rootNode() : 0; } -bool Internals::hasSelectorForIdInShadow(Element* host, const String& idValue, ExceptionState& es) +bool Internals::hasSelectorForIdInShadow(Element* host, const String& idValue, ExceptionState& exceptionState) { if (!host || !host->shadow()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } return host->shadow()->ensureSelectFeatureSet().hasSelectorForId(idValue); } -bool Internals::hasSelectorForClassInShadow(Element* host, const String& className, ExceptionState& es) +bool Internals::hasSelectorForClassInShadow(Element* host, const String& className, ExceptionState& exceptionState) { if (!host || !host->shadow()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } return host->shadow()->ensureSelectFeatureSet().hasSelectorForClass(className); } -bool Internals::hasSelectorForAttributeInShadow(Element* host, const String& attributeName, ExceptionState& es) +bool Internals::hasSelectorForAttributeInShadow(Element* host, const String& attributeName, ExceptionState& exceptionState) { if (!host || !host->shadow()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } return host->shadow()->ensureSelectFeatureSet().hasSelectorForAttribute(attributeName); } -bool Internals::hasSelectorForPseudoClassInShadow(Element* host, const String& pseudoClass, ExceptionState& es) +bool Internals::hasSelectorForPseudoClassInShadow(Element* host, const String& pseudoClass, ExceptionState& exceptionState) { if (!host || !host->shadow()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } @@ -388,10 +437,10 @@ bool Internals::hasSelectorForPseudoClassInShadow(Element* host, const String& p return false; } -unsigned short Internals::compareTreeScopePosition(const Node* node1, const Node* node2, ExceptionState& es) const +unsigned short Internals::compareTreeScopePosition(const Node* node1, const Node* node2, ExceptionState& exceptionState) const { if (!node1 || !node2) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } const TreeScope* treeScope1 = node1->isDocumentNode() ? static_cast<const TreeScope*>(toDocument(node1)) : @@ -399,7 +448,7 @@ unsigned short Internals::compareTreeScopePosition(const Node* node1, const Node const TreeScope* treeScope2 = node2->isDocumentNode() ? static_cast<const TreeScope*>(toDocument(node2)) : node2->isShadowRoot() ? static_cast<const TreeScope*>(toShadowRoot(node2)) : 0; if (!treeScope1 || !treeScope2) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } return treeScope1->comparePosition(*treeScope2); @@ -408,99 +457,58 @@ unsigned short Internals::compareTreeScopePosition(const Node* node1, const Node unsigned Internals::numberOfActiveAnimations() const { Frame* contextFrame = frame(); + Document* document = contextFrame->document(); if (RuntimeEnabledFeatures::webAnimationsCSSEnabled()) - return frame()->document()->timeline()->numberOfActiveAnimationsForTesting(); - if (AnimationController* controller = contextFrame->animation()) - return controller->numberOfActiveAnimations(contextFrame->document()); - return 0; -} - -void Internals::suspendAnimations(Document* document, ExceptionState& es) const -{ - if (!document || !document->frame()) { - es.throwDOMException(InvalidAccessError); - return; - } - - if (!RuntimeEnabledFeatures::webAnimationsCSSEnabled()) { - AnimationController* controller = document->frame()->animation(); - if (!controller) - return; - - controller->suspendAnimations(); - } + return document->timeline()->numberOfActiveAnimationsForTesting() + document->transitionTimeline()->numberOfActiveAnimationsForTesting(); + return contextFrame->animation().numberOfActiveAnimations(document); } -void Internals::resumeAnimations(Document* document, ExceptionState& es) const -{ - if (!document || !document->frame()) { - es.throwDOMException(InvalidAccessError); - return; - } - - if (!RuntimeEnabledFeatures::webAnimationsCSSEnabled()) { - AnimationController* controller = document->frame()->animation(); - if (!controller) - return; - - controller->resumeAnimations(); - } -} - -void Internals::pauseAnimations(double pauseTime, ExceptionState& es) +void Internals::pauseAnimations(double pauseTime, ExceptionState& exceptionState) { if (pauseTime < 0) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return; } - if (RuntimeEnabledFeatures::webAnimationsCSSEnabled()) + if (RuntimeEnabledFeatures::webAnimationsCSSEnabled()) { frame()->document()->timeline()->pauseAnimationsForTesting(pauseTime); - else - frame()->animation()->pauseAnimationsForTesting(pauseTime); + frame()->document()->transitionTimeline()->pauseAnimationsForTesting(pauseTime); + } else { + frame()->animation().pauseAnimationsForTesting(pauseTime); + } } -bool Internals::hasShadowInsertionPoint(const Node* root, ExceptionState& es) const +bool Internals::hasShadowInsertionPoint(const Node* root, ExceptionState& exceptionState) const { if (root && root->isShadowRoot()) return toShadowRoot(root)->containsShadowElements(); - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } -bool Internals::hasContentElement(const Node* root, ExceptionState& es) const +bool Internals::hasContentElement(const Node* root, ExceptionState& exceptionState) const { if (root && root->isShadowRoot()) return toShadowRoot(root)->containsContentElements(); - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } -size_t Internals::countElementShadow(const Node* root, ExceptionState& es) const +size_t Internals::countElementShadow(const Node* root, ExceptionState& exceptionState) const { if (!root || !root->isShadowRoot()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } return toShadowRoot(root)->childShadowRootCount(); } -bool Internals::attached(Node* node, ExceptionState& es) -{ - if (!node) { - es.throwDOMException(InvalidAccessError); - return false; - } - - return node->attached(); -} - -Node* Internals::nextSiblingByWalker(Node* node, ExceptionState& es) +Node* Internals::nextSiblingByWalker(Node* node, ExceptionState& exceptionState) { if (!node) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } ComposedTreeWalker walker(node); @@ -508,10 +516,10 @@ Node* Internals::nextSiblingByWalker(Node* node, ExceptionState& es) return walker.get(); } -Node* Internals::firstChildByWalker(Node* node, ExceptionState& es) +Node* Internals::firstChildByWalker(Node* node, ExceptionState& exceptionState) { if (!node) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } ComposedTreeWalker walker(node); @@ -519,10 +527,10 @@ Node* Internals::firstChildByWalker(Node* node, ExceptionState& es) return walker.get(); } -Node* Internals::lastChildByWalker(Node* node, ExceptionState& es) +Node* Internals::lastChildByWalker(Node* node, ExceptionState& exceptionState) { if (!node) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } ComposedTreeWalker walker(node); @@ -530,10 +538,10 @@ Node* Internals::lastChildByWalker(Node* node, ExceptionState& es) return walker.get(); } -Node* Internals::nextNodeByWalker(Node* node, ExceptionState& es) +Node* Internals::nextNodeByWalker(Node* node, ExceptionState& exceptionState) { if (!node) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } ComposedTreeWalker walker(node); @@ -541,10 +549,10 @@ Node* Internals::nextNodeByWalker(Node* node, ExceptionState& es) return walker.get(); } -Node* Internals::previousNodeByWalker(Node* node, ExceptionState& es) +Node* Internals::previousNodeByWalker(Node* node, ExceptionState& exceptionState) { if (!node) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } ComposedTreeWalker walker(node); @@ -552,35 +560,35 @@ Node* Internals::previousNodeByWalker(Node* node, ExceptionState& es) return walker.get(); } -String Internals::elementRenderTreeAsText(Element* element, ExceptionState& es) +String Internals::elementRenderTreeAsText(Element* element, ExceptionState& exceptionState) { if (!element) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return String(); } String representation = externalRepresentation(element); if (representation.isEmpty()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return String(); } return representation; } -size_t Internals::numberOfScopedHTMLStyleChildren(const Node* scope, ExceptionState& es) const +size_t Internals::numberOfScopedHTMLStyleChildren(const Node* scope, ExceptionState& exceptionState) const { if (scope && (scope->isElementNode() || scope->isShadowRoot())) return scope->numberOfScopedHTMLStyleChildren(); - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } -PassRefPtr<CSSComputedStyleDeclaration> Internals::computedStyleIncludingVisitedInfo(Node* node, ExceptionState& es) const +PassRefPtr<CSSComputedStyleDeclaration> Internals::computedStyleIncludingVisitedInfo(Node* node, ExceptionState& exceptionState) const { if (!node) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } @@ -588,30 +596,30 @@ PassRefPtr<CSSComputedStyleDeclaration> Internals::computedStyleIncludingVisited return CSSComputedStyleDeclaration::create(node, allowVisitedStyle); } -ShadowRoot* Internals::ensureShadowRoot(Element* host, ExceptionState& es) +ShadowRoot* Internals::ensureShadowRoot(Element* host, ExceptionState& exceptionState) { if (!host) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } if (ElementShadow* shadow = host->shadow()) return shadow->youngestShadowRoot(); - return host->createShadowRoot(es).get(); + return host->createShadowRoot(exceptionState).get(); } -ShadowRoot* Internals::shadowRoot(Element* host, ExceptionState& es) +ShadowRoot* Internals::shadowRoot(Element* host, ExceptionState& exceptionState) { // FIXME: Internals::shadowRoot() in tests should be converted to youngestShadowRoot() or oldestShadowRoot(). // https://bugs.webkit.org/show_bug.cgi?id=78465 - return youngestShadowRoot(host, es); + return youngestShadowRoot(host, exceptionState); } -ShadowRoot* Internals::youngestShadowRoot(Element* host, ExceptionState& es) +ShadowRoot* Internals::youngestShadowRoot(Element* host, ExceptionState& exceptionState) { if (!host) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } @@ -620,10 +628,10 @@ ShadowRoot* Internals::youngestShadowRoot(Element* host, ExceptionState& es) return 0; } -ShadowRoot* Internals::oldestShadowRoot(Element* host, ExceptionState& es) +ShadowRoot* Internals::oldestShadowRoot(Element* host, ExceptionState& exceptionState) { if (!host) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } @@ -632,30 +640,30 @@ ShadowRoot* Internals::oldestShadowRoot(Element* host, ExceptionState& es) return 0; } -ShadowRoot* Internals::youngerShadowRoot(Node* shadow, ExceptionState& es) +ShadowRoot* Internals::youngerShadowRoot(Node* shadow, ExceptionState& exceptionState) { if (!shadow || !shadow->isShadowRoot()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } return toShadowRoot(shadow)->youngerShadowRoot(); } -ShadowRoot* Internals::olderShadowRoot(Node* shadow, ExceptionState& es) +ShadowRoot* Internals::olderShadowRoot(Node* shadow, ExceptionState& exceptionState) { if (!shadow || !shadow->isShadowRoot()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } return toShadowRoot(shadow)->olderShadowRoot(); } -String Internals::shadowRootType(const Node* root, ExceptionState& es) const +String Internals::shadowRootType(const Node* root, ExceptionState& exceptionState) const { if (!root || !root->isShadowRoot()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return String(); } @@ -670,36 +678,24 @@ String Internals::shadowRootType(const Node* root, ExceptionState& es) const } } -Element* Internals::includerFor(Node* node, ExceptionState& es) -{ - if (!node) { - es.throwDOMException(InvalidAccessError); - return 0; - } - - NodeRenderingTraversal::ParentDetails parentDetails; - NodeRenderingTraversal::parent(node, &parentDetails); - return parentDetails.insertionPoint(); -} - -String Internals::shadowPseudoId(Element* element, ExceptionState& es) +String Internals::shadowPseudoId(Element* element, ExceptionState& exceptionState) { if (!element) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return String(); } return element->shadowPseudoId().string(); } -void Internals::setShadowPseudoId(Element* element, const String& id, ExceptionState& es) +void Internals::setShadowPseudoId(Element* element, const String& id, ExceptionState& exceptionState) { if (!element) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return; } - return element->setPart(id); + return element->setPseudo(id); } String Internals::visiblePlaceholder(Element* element) @@ -719,50 +715,27 @@ void Internals::selectColorInColorChooser(Element* element, const String& colorV toHTMLInputElement(element)->selectColorInColorChooser(Color(colorValue)); } -Vector<String> Internals::formControlStateOfPreviousHistoryItem(ExceptionState& es) +Vector<String> Internals::formControlStateOfHistoryItem(ExceptionState& exceptionState) { - HistoryItem* mainItem = frame()->loader()->history()->previousItem(); + HistoryItem* mainItem = frame()->loader().currentItem(); if (!mainItem) { - es.throwDOMException(InvalidAccessError); - return Vector<String>(); - } - String uniqueName = frame()->tree()->uniqueName(); - if (mainItem->target() != uniqueName && !mainItem->childItemWithTarget(uniqueName)) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return Vector<String>(); } - return mainItem->target() == uniqueName ? mainItem->documentState() : mainItem->childItemWithTarget(uniqueName)->documentState(); + return mainItem->documentState(); } -void Internals::setFormControlStateOfPreviousHistoryItem(const Vector<String>& state, ExceptionState& es) +void Internals::setFormControlStateOfHistoryItem(const Vector<String>& state, ExceptionState& exceptionState) { - HistoryItem* mainItem = frame()->loader()->history()->previousItem(); + HistoryItem* mainItem = frame()->loader().currentItem(); if (!mainItem) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return; } - String uniqueName = frame()->tree()->uniqueName(); - if (mainItem->target() == uniqueName) - mainItem->setDocumentState(state); - else if (HistoryItem* subItem = mainItem->childItemWithTarget(uniqueName)) - subItem->setDocumentState(state); - else - es.throwDOMException(InvalidAccessError); + mainItem->setDocumentState(state); } -void Internals::enableMockSpeechSynthesizer() -{ - Document* document = contextDocument(); - if (!document || !document->domWindow()) - return; - SpeechSynthesis* synthesis = DOMWindowSpeechSynthesis::speechSynthesis(document->domWindow()); - if (!synthesis) - return; - - synthesis->setPlatformSynthesizer(PlatformSpeechSynthesizerMock::create(synthesis)); -} - -void Internals::setEnableMockPagePopup(bool enabled, ExceptionState& es) +void Internals::setEnableMockPagePopup(bool enabled, ExceptionState& exceptionState) { Document* document = contextDocument(); if (!document || !document->page()) @@ -782,32 +755,32 @@ PassRefPtr<PagePopupController> Internals::pagePopupController() return s_pagePopupDriver ? s_pagePopupDriver->pagePopupController() : 0; } -PassRefPtr<ClientRect> Internals::unscaledViewportRect(ExceptionState& es) +PassRefPtr<ClientRect> Internals::unscaledViewportRect(ExceptionState& exceptionState) { Document* document = contextDocument(); if (!document || !document->view()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return ClientRect::create(); } return ClientRect::create(document->view()->visibleContentRect()); } -PassRefPtr<ClientRect> Internals::absoluteCaretBounds(ExceptionState& es) +PassRefPtr<ClientRect> Internals::absoluteCaretBounds(ExceptionState& exceptionState) { Document* document = contextDocument(); if (!document || !document->frame()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return ClientRect::create(); } return ClientRect::create(document->frame()->selection().absoluteCaretBounds()); } -PassRefPtr<ClientRect> Internals::boundingBox(Element* element, ExceptionState& es) +PassRefPtr<ClientRect> Internals::boundingBox(Element* element, ExceptionState& exceptionState) { if (!element) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return ClientRect::create(); } @@ -818,10 +791,10 @@ PassRefPtr<ClientRect> Internals::boundingBox(Element* element, ExceptionState& return ClientRect::create(renderer->absoluteBoundingBoxRectIgnoringTransforms()); } -PassRefPtr<ClientRectList> Internals::inspectorHighlightRects(Document* document, ExceptionState& es) +PassRefPtr<ClientRectList> Internals::inspectorHighlightRects(Document* document, ExceptionState& exceptionState) { if (!document || !document->page()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return ClientRectList::create(); } @@ -830,26 +803,26 @@ PassRefPtr<ClientRectList> Internals::inspectorHighlightRects(Document* document return ClientRectList::create(highlight.quads); } -unsigned Internals::markerCountForNode(Node* node, const String& markerType, ExceptionState& es) +unsigned Internals::markerCountForNode(Node* node, const String& markerType, ExceptionState& exceptionState) { if (!node) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } DocumentMarker::MarkerTypes markerTypes = 0; if (!markerTypesFrom(markerType, markerTypes)) { - es.throwDOMException(SyntaxError); + exceptionState.throwUninformativeAndGenericDOMException(SyntaxError); return 0; } return node->document().markers()->markersFor(node, markerTypes).size(); } -unsigned Internals::activeMarkerCountForNode(Node* node, ExceptionState& es) +unsigned Internals::activeMarkerCountForNode(Node* node, ExceptionState& exceptionState) { if (!node) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } @@ -866,16 +839,16 @@ unsigned Internals::activeMarkerCountForNode(Node* node, ExceptionState& es) return activeMarkerCount; } -DocumentMarker* Internals::markerAt(Node* node, const String& markerType, unsigned index, ExceptionState& es) +DocumentMarker* Internals::markerAt(Node* node, const String& markerType, unsigned index, ExceptionState& exceptionState) { if (!node) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } DocumentMarker::MarkerTypes markerTypes = 0; if (!markerTypesFrom(markerType, markerTypes)) { - es.throwDOMException(SyntaxError); + exceptionState.throwUninformativeAndGenericDOMException(SyntaxError); return 0; } @@ -885,17 +858,17 @@ DocumentMarker* Internals::markerAt(Node* node, const String& markerType, unsign return markers[index]; } -PassRefPtr<Range> Internals::markerRangeForNode(Node* node, const String& markerType, unsigned index, ExceptionState& es) +PassRefPtr<Range> Internals::markerRangeForNode(Node* node, const String& markerType, unsigned index, ExceptionState& exceptionState) { - DocumentMarker* marker = markerAt(node, markerType, index, es); + DocumentMarker* marker = markerAt(node, markerType, index, exceptionState); if (!marker) return 0; return Range::create(node->document(), node, marker->startOffset(), node, marker->endOffset()); } -String Internals::markerDescriptionForNode(Node* node, const String& markerType, unsigned index, ExceptionState& es) +String Internals::markerDescriptionForNode(Node* node, const String& markerType, unsigned index, ExceptionState& exceptionState) { - DocumentMarker* marker = markerAt(node, markerType, index, es); + DocumentMarker* marker = markerAt(node, markerType, index, exceptionState); if (!marker) return String(); return marker->description(); @@ -907,20 +880,20 @@ void Internals::addTextMatchMarker(const Range* range, bool isActive) range->ownerDocument().markers()->addTextMatchMarker(range, isActive); } -void Internals::setMarkersActive(Node* node, unsigned startOffset, unsigned endOffset, bool active, ExceptionState& es) +void Internals::setMarkersActive(Node* node, unsigned startOffset, unsigned endOffset, bool active, ExceptionState& exceptionState) { if (!node) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return; } node->document().markers()->setMarkersActive(node, startOffset, endOffset, active); } -void Internals::setScrollViewPosition(Document* document, long x, long y, ExceptionState& es) +void Internals::setScrollViewPosition(Document* document, long x, long y, ExceptionState& exceptionState) { if (!document || !document->view()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return; } @@ -935,10 +908,10 @@ void Internals::setScrollViewPosition(Document* document, long x, long y, Except frameView->setConstrainsScrollingToContentEdge(constrainsScrollingToContentEdgeOldValue); } -void Internals::setPagination(Document* document, const String& mode, int gap, int pageLength, ExceptionState& es) +void Internals::setPagination(Document* document, const String& mode, int gap, int pageLength, ExceptionState& exceptionState) { if (!document || !document->page()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return; } Page* page = document->page(); @@ -955,7 +928,7 @@ void Internals::setPagination(Document* document, const String& mode, int gap, i else if (mode == "BottomToTopPaginated") pagination.mode = Pagination::BottomToTopPaginated; else { - es.throwDOMException(SyntaxError); + exceptionState.throwUninformativeAndGenericDOMException(SyntaxError); return; } @@ -964,20 +937,23 @@ void Internals::setPagination(Document* document, const String& mode, int gap, i page->setPagination(pagination); } -String Internals::viewportAsText(Document* document, float, int availableWidth, int availableHeight, ExceptionState& es) +String Internals::viewportAsText(Document* document, float, int availableWidth, int availableHeight, ExceptionState& exceptionState) { if (!document || !document->page()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return String(); } + + document->updateLayoutIgnorePendingStylesheets(); + Page* page = document->page(); // Update initial viewport size. IntSize initialViewportSize(availableWidth, availableHeight); document->page()->mainFrame()->view()->setFrameRect(IntRect(IntPoint::zero(), initialViewportSize)); - ViewportArguments arguments = page->viewportArguments(); - PageScaleConstraints constraints = arguments.resolve(initialViewportSize); + ViewportDescription description = page->viewportDescription(); + PageScaleConstraints constraints = description.resolve(initialViewportSize); constraints.fitToContentsWidth(constraints.layoutSize.width(), availableWidth); @@ -996,15 +972,15 @@ String Internals::viewportAsText(Document* document, float, int availableWidth, builder.append(String::number(constraints.maximumScale)); builder.appendLiteral("] and userScalable "); - builder.append(arguments.userZoom ? "true" : "false"); + builder.append(description.userZoom ? "true" : "false"); return builder.toString(); } -bool Internals::wasLastChangeUserEdit(Element* textField, ExceptionState& es) +bool Internals::wasLastChangeUserEdit(Element* textField, ExceptionState& exceptionState) { if (!textField) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return false; } @@ -1015,92 +991,92 @@ bool Internals::wasLastChangeUserEdit(Element* textField, ExceptionState& es) if (textField->tagName() == "TEXTAREA") return toHTMLTextAreaElement(textField)->lastChangeWasUserEdit(); - es.throwDOMException(InvalidNodeTypeError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidNodeTypeError); return false; } -bool Internals::elementShouldAutoComplete(Element* element, ExceptionState& es) +bool Internals::elementShouldAutoComplete(Element* element, ExceptionState& exceptionState) { if (!element) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return false; } if (element->hasTagName(inputTag)) return toHTMLInputElement(element)->shouldAutocomplete(); - es.throwDOMException(InvalidNodeTypeError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidNodeTypeError); return false; } -String Internals::suggestedValue(Element* element, ExceptionState& es) +String Internals::suggestedValue(Element* element, ExceptionState& exceptionState) { if (!element) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return String(); } if (!element->hasTagName(inputTag)) { - es.throwDOMException(InvalidNodeTypeError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidNodeTypeError); return String(); } return toHTMLInputElement(element)->suggestedValue(); } -void Internals::setSuggestedValue(Element* element, const String& value, ExceptionState& es) +void Internals::setSuggestedValue(Element* element, const String& value, ExceptionState& exceptionState) { if (!element) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return; } if (!element->hasTagName(inputTag)) { - es.throwDOMException(InvalidNodeTypeError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidNodeTypeError); return; } toHTMLInputElement(element)->setSuggestedValue(value); } -void Internals::setEditingValue(Element* element, const String& value, ExceptionState& es) +void Internals::setEditingValue(Element* element, const String& value, ExceptionState& exceptionState) { if (!element) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return; } if (!element->hasTagName(inputTag)) { - es.throwDOMException(InvalidNodeTypeError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidNodeTypeError); return; } toHTMLInputElement(element)->setEditingValue(value); } -void Internals::setAutofilled(Element* element, bool enabled, ExceptionState& es) +void Internals::setAutofilled(Element* element, bool enabled, ExceptionState& exceptionState) { - if (!element->hasTagName(inputTag)) { - es.throwDOMException(InvalidAccessError); + if (!element->isFormControlElement()) { + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return; } - toHTMLInputElement(element)->setAutofilled(enabled); + toHTMLFormControlElement(element)->setAutofilled(enabled); } -void Internals::scrollElementToRect(Element* element, long x, long y, long w, long h, ExceptionState& es) +void Internals::scrollElementToRect(Element* element, long x, long y, long w, long h, ExceptionState& exceptionState) { if (!element || !element->document().view()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return; } FrameView* frameView = element->document().view(); frameView->scrollElementToRect(element, IntRect(x, y, w, h)); } -void Internals::paintControlTints(Document* document, ExceptionState& es) +void Internals::paintControlTints(Document* document, ExceptionState& exceptionState) { if (!document || !document->view()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return; } @@ -1108,65 +1084,59 @@ void Internals::paintControlTints(Document* document, ExceptionState& es) frameView->paintControlTints(); } -PassRefPtr<Range> Internals::rangeFromLocationAndLength(Element* scope, int rangeLocation, int rangeLength, ExceptionState& es) +PassRefPtr<Range> Internals::rangeFromLocationAndLength(Element* scope, int rangeLocation, int rangeLength, ExceptionState& exceptionState) { if (!scope) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } // TextIterator depends on Layout information, make sure layout it up to date. scope->document().updateLayoutIgnorePendingStylesheets(); - return TextIterator::rangeFromLocationAndLength(scope, rangeLocation, rangeLength); + return PlainTextRange(rangeLocation, rangeLocation + rangeLength).createRange(*scope); } -unsigned Internals::locationFromRange(Element* scope, const Range* range, ExceptionState& es) +unsigned Internals::locationFromRange(Element* scope, const Range* range, ExceptionState& exceptionState) { if (!scope || !range) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } - // TextIterator depends on Layout information, make sure layout it up to date. + // PlainTextRange depends on Layout information, make sure layout it up to date. scope->document().updateLayoutIgnorePendingStylesheets(); - size_t location = 0; - size_t unusedLength = 0; - TextIterator::getLocationAndLengthFromRange(scope, range, location, unusedLength); - return location; + return PlainTextRange::create(*scope, *range).start(); } -unsigned Internals::lengthFromRange(Element* scope, const Range* range, ExceptionState& es) +unsigned Internals::lengthFromRange(Element* scope, const Range* range, ExceptionState& exceptionState) { if (!scope || !range) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } - // TextIterator depends on Layout information, make sure layout it up to date. + // PlainTextRange depends on Layout information, make sure layout it up to date. scope->document().updateLayoutIgnorePendingStylesheets(); - size_t unusedLocation = 0; - size_t length = 0; - TextIterator::getLocationAndLengthFromRange(scope, range, unusedLocation, length); - return length; + return PlainTextRange::create(*scope, *range).length(); } -String Internals::rangeAsText(const Range* range, ExceptionState& es) +String Internals::rangeAsText(const Range* range, ExceptionState& exceptionState) { if (!range) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return String(); } return range->text(); } -PassRefPtr<DOMPoint> Internals::touchPositionAdjustedToBestClickableNode(long x, long y, long width, long height, Document* document, ExceptionState& es) +PassRefPtr<DOMPoint> Internals::touchPositionAdjustedToBestClickableNode(long x, long y, long width, long height, Document* document, ExceptionState& exceptionState) { if (!document || !document->frame()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } @@ -1178,17 +1148,17 @@ PassRefPtr<DOMPoint> Internals::touchPositionAdjustedToBestClickableNode(long x, Node* targetNode; IntPoint adjustedPoint; - bool foundNode = document->frame()->eventHandler()->bestClickableNodeForTouchPoint(point, radius, adjustedPoint, targetNode); + bool foundNode = document->frame()->eventHandler().bestClickableNodeForTouchPoint(point, radius, adjustedPoint, targetNode); if (foundNode) return DOMPoint::create(adjustedPoint.x(), adjustedPoint.y()); return 0; } -Node* Internals::touchNodeAdjustedToBestClickableNode(long x, long y, long width, long height, Document* document, ExceptionState& es) +Node* Internals::touchNodeAdjustedToBestClickableNode(long x, long y, long width, long height, Document* document, ExceptionState& exceptionState) { if (!document || !document->frame()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } @@ -1199,14 +1169,14 @@ Node* Internals::touchNodeAdjustedToBestClickableNode(long x, long y, long width Node* targetNode; IntPoint adjustedPoint; - document->frame()->eventHandler()->bestClickableNodeForTouchPoint(point, radius, adjustedPoint, targetNode); + document->frame()->eventHandler().bestClickableNodeForTouchPoint(point, radius, adjustedPoint, targetNode); return targetNode; } -PassRefPtr<DOMPoint> Internals::touchPositionAdjustedToBestContextMenuNode(long x, long y, long width, long height, Document* document, ExceptionState& es) +PassRefPtr<DOMPoint> Internals::touchPositionAdjustedToBestContextMenuNode(long x, long y, long width, long height, Document* document, ExceptionState& exceptionState) { if (!document || !document->frame()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } @@ -1218,17 +1188,17 @@ PassRefPtr<DOMPoint> Internals::touchPositionAdjustedToBestContextMenuNode(long Node* targetNode = 0; IntPoint adjustedPoint; - bool foundNode = document->frame()->eventHandler()->bestContextMenuNodeForTouchPoint(point, radius, adjustedPoint, targetNode); + bool foundNode = document->frame()->eventHandler().bestContextMenuNodeForTouchPoint(point, radius, adjustedPoint, targetNode); if (foundNode) return DOMPoint::create(adjustedPoint.x(), adjustedPoint.y()); return DOMPoint::create(x, y); } -Node* Internals::touchNodeAdjustedToBestContextMenuNode(long x, long y, long width, long height, Document* document, ExceptionState& es) +Node* Internals::touchNodeAdjustedToBestContextMenuNode(long x, long y, long width, long height, Document* document, ExceptionState& exceptionState) { if (!document || !document->frame()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } @@ -1239,14 +1209,14 @@ Node* Internals::touchNodeAdjustedToBestContextMenuNode(long x, long y, long wid Node* targetNode = 0; IntPoint adjustedPoint; - document->frame()->eventHandler()->bestContextMenuNodeForTouchPoint(point, radius, adjustedPoint, targetNode); + document->frame()->eventHandler().bestContextMenuNodeForTouchPoint(point, radius, adjustedPoint, targetNode); return targetNode; } -PassRefPtr<ClientRect> Internals::bestZoomableAreaForTouchPoint(long x, long y, long width, long height, Document* document, ExceptionState& es) +PassRefPtr<ClientRect> Internals::bestZoomableAreaForTouchPoint(long x, long y, long width, long height, Document* document, ExceptionState& exceptionState) { if (!document || !document->frame()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } @@ -1257,7 +1227,7 @@ PassRefPtr<ClientRect> Internals::bestZoomableAreaForTouchPoint(long x, long y, Node* targetNode; IntRect zoomableArea; - bool foundNode = document->frame()->eventHandler()->bestZoomableAreaForTouchPoint(point, radius, zoomableArea, targetNode); + bool foundNode = document->frame()->eventHandler().bestZoomableAreaForTouchPoint(point, radius, zoomableArea, targetNode); if (foundNode) return ClientRect::create(zoomableArea); @@ -1265,24 +1235,24 @@ PassRefPtr<ClientRect> Internals::bestZoomableAreaForTouchPoint(long x, long y, } -int Internals::lastSpellCheckRequestSequence(Document* document, ExceptionState& es) +int Internals::lastSpellCheckRequestSequence(Document* document, ExceptionState& exceptionState) { SpellCheckRequester* requester = spellCheckRequester(document); if (!requester) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return -1; } return requester->lastRequestSequence(); } -int Internals::lastSpellCheckProcessedSequence(Document* document, ExceptionState& es) +int Internals::lastSpellCheckProcessedSequence(Document* document, ExceptionState& exceptionState) { SpellCheckRequester* requester = spellCheckRequester(document); if (!requester) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return -1; } @@ -1299,20 +1269,20 @@ void Internals::setUserPreferredLanguages(const Vector<String>& languages) WebCore::overrideUserPreferredLanguages(languages); } -unsigned Internals::wheelEventHandlerCount(Document* document, ExceptionState& es) +unsigned Internals::wheelEventHandlerCount(Document* document, ExceptionState& exceptionState) { if (!document) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } return WheelController::from(document)->wheelEventHandlerCount(); } -unsigned Internals::touchEventHandlerCount(Document* document, ExceptionState& es) +unsigned Internals::touchEventHandlerCount(Document* document, ExceptionState& exceptionState) { if (!document) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } @@ -1328,25 +1298,29 @@ unsigned Internals::touchEventHandlerCount(Document* document, ExceptionState& e static RenderLayer* findRenderLayerForGraphicsLayer(RenderLayer* searchRoot, GraphicsLayer* graphicsLayer, String* layerType) { - if (searchRoot->backing() && graphicsLayer == searchRoot->backing()->graphicsLayer()) + if (searchRoot->hasCompositedLayerMapping() && graphicsLayer == searchRoot->compositedLayerMapping()->mainGraphicsLayer()) return searchRoot; - if (graphicsLayer == searchRoot->layerForScrolling()) { + GraphicsLayer* layerForScrolling = searchRoot->scrollableArea() ? searchRoot->scrollableArea()->layerForScrolling() : 0; + if (graphicsLayer == layerForScrolling) { *layerType = "scrolling"; return searchRoot; } - if (graphicsLayer == searchRoot->layerForHorizontalScrollbar()) { + GraphicsLayer* layerForHorizontalScrollbar = searchRoot->scrollableArea() ? searchRoot->scrollableArea()->layerForHorizontalScrollbar() : 0; + if (graphicsLayer == layerForHorizontalScrollbar) { *layerType = "horizontalScrollbar"; return searchRoot; } - if (graphicsLayer == searchRoot->layerForVerticalScrollbar()) { + GraphicsLayer* layerForVerticalScrollbar = searchRoot->scrollableArea() ? searchRoot->scrollableArea()->layerForVerticalScrollbar() : 0; + if (graphicsLayer == layerForVerticalScrollbar) { *layerType = "verticalScrollbar"; return searchRoot; } - if (graphicsLayer == searchRoot->layerForScrollCorner()) { + GraphicsLayer* layerForScrollCorner = searchRoot->scrollableArea() ? searchRoot->scrollableArea()->layerForScrollCorner() : 0; + if (graphicsLayer == layerForScrollCorner) { *layerType = "scrollCorner"; return searchRoot; } @@ -1365,7 +1339,7 @@ static RenderLayer* findRenderLayerForGraphicsLayer(RenderLayer* searchRoot, Gra // of rects returned by an SkRegion (which have been split apart for sorting // purposes). No attempt is made to do this efficiently (eg. by relying on the // sort criteria of SkRegion). -static void mergeRects(WebKit::WebVector<WebKit::WebRect>& rects) +static void mergeRects(blink::WebVector<blink::WebRect>& rects) { for (size_t i = 0; i < rects.size(); ++i) { if (rects[i].isEmpty()) @@ -1380,23 +1354,23 @@ static void mergeRects(WebKit::WebVector<WebKit::WebRect>& rects) if (rects[i].y == rects[j].y && rects[i].height == rects[j].height) { if (rects[i].x + rects[i].width == rects[j].x) { rects[i].width += rects[j].width; - rects[j] = WebKit::WebRect(); + rects[j] = blink::WebRect(); updated = true; } else if (rects[i].x == rects[j].x + rects[j].width) { rects[i].x = rects[j].x; rects[i].width += rects[j].width; - rects[j] = WebKit::WebRect(); + rects[j] = blink::WebRect(); updated = true; } } else if (rects[i].x == rects[j].x && rects[i].width == rects[j].width) { if (rects[i].y + rects[i].height == rects[j].y) { rects[i].height += rects[j].height; - rects[j] = WebKit::WebRect(); + rects[j] = blink::WebRect(); updated = true; } else if (rects[i].y == rects[j].y + rects[j].height) { rects[i].y = rects[j].y; rects[i].height += rects[j].height; - rects[j] = WebKit::WebRect(); + rects[j] = blink::WebRect(); updated = true; } } @@ -1407,7 +1381,7 @@ static void mergeRects(WebKit::WebVector<WebKit::WebRect>& rects) static void accumulateLayerRectList(RenderLayerCompositor* compositor, GraphicsLayer* graphicsLayer, LayerRectList* rects) { - WebKit::WebVector<WebKit::WebRect> layerRects = graphicsLayer->platformLayer()->touchEventHandlerRegion(); + blink::WebVector<blink::WebRect> layerRects = graphicsLayer->platformLayer()->touchEventHandlerRegion(); if (!layerRects.isEmpty()) { mergeRects(layerRects); String layerType; @@ -1424,16 +1398,18 @@ static void accumulateLayerRectList(RenderLayerCompositor* compositor, GraphicsL accumulateLayerRectList(compositor, graphicsLayer->children()[i], rects); } -PassRefPtr<LayerRectList> Internals::touchEventTargetLayerRects(Document* document, ExceptionState& es) +PassRefPtr<LayerRectList> Internals::touchEventTargetLayerRects(Document* document, ExceptionState& exceptionState) { if (!document || !document->view() || !document->page() || document != contextDocument()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } - // Do any pending layouts (which may call touchEventTargetRectsChange) to ensure this + // Do any pending layout and compositing update (which may call touchEventTargetRectsChange) to ensure this // really takes any previous changes into account. - document->updateLayout(); + forceCompositingUpdate(document, exceptionState); + if (exceptionState.hadException()) + return 0; if (RenderView* view = document->renderView()) { if (RenderLayerCompositor* compositor = view->compositor()) { @@ -1449,10 +1425,10 @@ PassRefPtr<LayerRectList> Internals::touchEventTargetLayerRects(Document* docume } PassRefPtr<NodeList> Internals::nodesFromRect(Document* document, int centerX, int centerY, unsigned topPadding, unsigned rightPadding, - unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allowShadowContent, bool allowChildFrameContent, ExceptionState& es) const + unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allowShadowContent, bool allowChildFrameContent, ExceptionState& exceptionState) const { if (!document || !document->frame() || !document->frame()->view()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } @@ -1470,7 +1446,7 @@ PassRefPtr<NodeList> Internals::nodesFromRect(Document* document, int centerX, i if (ignoreClipping) hitType |= HitTestRequest::IgnoreClipping; if (!allowShadowContent) - hitType |= HitTestRequest::DisallowShadowContent; + hitType |= HitTestRequest::ConfusingAndOftenMisusedDisallowShadowContent; if (allowChildFrameContent) hitType |= HitTestRequest::AllowChildFrameContent; @@ -1498,9 +1474,9 @@ PassRefPtr<NodeList> Internals::nodesFromRect(Document* document, int centerX, i return StaticNodeList::adopt(matches); } -void Internals::emitInspectorDidBeginFrame() +void Internals::emitInspectorDidBeginFrame(int frameId) { - contextDocument()->page()->inspectorController().didBeginFrame(); + contextDocument()->page()->inspectorController().didBeginFrame(frameId); } void Internals::emitInspectorDidCancelFrame() @@ -1513,7 +1489,7 @@ bool Internals::hasSpellingMarker(Document* document, int from, int length, Exce if (!document || !document->frame()) return 0; - return document->frame()->editor().selectionStartHasMarkerFor(DocumentMarker::Spelling, from, length); + return document->frame()->spellChecker().selectionStartHasMarkerFor(DocumentMarker::Spelling, from, length); } void Internals::setContinuousSpellCheckingEnabled(bool enabled, ExceptionState&) @@ -1521,8 +1497,8 @@ void Internals::setContinuousSpellCheckingEnabled(bool enabled, ExceptionState&) if (!contextDocument() || !contextDocument()->frame()) return; - if (enabled != contextDocument()->frame()->editor().isContinuousSpellCheckingEnabled()) - contextDocument()->frame()->editor().toggleContinuousSpellChecking(); + if (enabled != contextDocument()->frame()->spellChecker().isContinuousSpellCheckingEnabled()) + contextDocument()->frame()->spellChecker().toggleContinuousSpellChecking(); } bool Internals::isOverwriteModeEnabled(Document* document, ExceptionState&) @@ -1543,20 +1519,19 @@ void Internals::toggleOverwriteModeEnabled(Document* document, ExceptionState&) unsigned Internals::numberOfLiveNodes() const { - if (StyleResolver* resolver = contextDocument()->styleResolverIfExists()) - resolver->clearStyleSharingList(); - return InspectorCounters::counterValue(InspectorCounters::NodeCounter); } unsigned Internals::numberOfLiveDocuments() const { - if (StyleResolver* resolver = contextDocument()->styleResolverIfExists()) - resolver->clearStyleSharingList(); - return InspectorCounters::counterValue(InspectorCounters::DocumentCounter); } +String Internals::dumpRefCountedInstanceCounts() const +{ + return WTF::dumpRefCountedInstanceCounts(); +} + Vector<String> Internals::consoleMessageArgumentCounts(Document* document) const { InstrumentingAgents* instrumentingAgents = instrumentationForPage(document->page()); @@ -1607,7 +1582,7 @@ void Internals::closeDummyInspectorFrontend() m_frontendChannel.release(); - m_frontendWindow->close(m_frontendWindow->scriptExecutionContext()); + m_frontendWindow->close(m_frontendWindow->executionContext()); m_frontendWindow.release(); } @@ -1621,11 +1596,11 @@ Vector<unsigned long> Internals::setMemoryCacheCapacities(unsigned long minDeadB return result; } -void Internals::setInspectorResourcesDataSizeLimits(int maximumResourcesContentSize, int maximumSingleResourceContentSize, ExceptionState& es) +void Internals::setInspectorResourcesDataSizeLimits(int maximumResourcesContentSize, int maximumSingleResourceContentSize, ExceptionState& exceptionState) { Page* page = contextDocument()->frame()->page(); if (!page) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return; } page->inspectorController().setResourcesDataSizeLimitsFromInternals(maximumResourcesContentSize, maximumSingleResourceContentSize); @@ -1636,7 +1611,7 @@ bool Internals::hasGrammarMarker(Document* document, int from, int length, Excep if (!document || !document->frame()) return 0; - return document->frame()->editor().selectionStartHasMarkerFor(DocumentMarker::Grammar, from, length); + return document->frame()->spellChecker().selectionStartHasMarkerFor(DocumentMarker::Grammar, from, length); } unsigned Internals::numberOfScrollableAreas(Document* document, ExceptionState&) @@ -1646,7 +1621,7 @@ unsigned Internals::numberOfScrollableAreas(Document* document, ExceptionState&) if (frame->view()->scrollableAreas()) count += frame->view()->scrollableAreas()->size(); - for (Frame* child = frame->tree()->firstChild(); child; child = child->tree()->nextSibling()) { + for (Frame* child = frame->tree().firstChild(); child; child = child->tree().nextSibling()) { if (child->view() && child->view()->scrollableAreas()) count += child->view()->scrollableAreas()->size(); } @@ -1654,30 +1629,30 @@ unsigned Internals::numberOfScrollableAreas(Document* document, ExceptionState&) return count; } -bool Internals::isPageBoxVisible(Document* document, int pageNumber, ExceptionState& es) +bool Internals::isPageBoxVisible(Document* document, int pageNumber, ExceptionState& exceptionState) { if (!document) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return false; } return document->isPageBoxVisible(pageNumber); } -String Internals::layerTreeAsText(Document* document, ExceptionState& es) const +String Internals::layerTreeAsText(Document* document, ExceptionState& exceptionState) const { - return layerTreeAsText(document, 0, es); + return layerTreeAsText(document, 0, exceptionState); } -String Internals::elementLayerTreeAsText(Element* element, ExceptionState& es) const +String Internals::elementLayerTreeAsText(Element* element, ExceptionState& exceptionState) const { - return elementLayerTreeAsText(element, 0, es); + return elementLayerTreeAsText(element, 0, exceptionState); } -static PassRefPtr<NodeList> paintOrderList(Element* element, ExceptionState& es, RenderLayer::PaintOrderListType type) +static PassRefPtr<NodeList> paintOrderList(Element* element, ExceptionState& exceptionState, RenderLayerStackingNode::PaintOrderListType type) { if (!element) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } @@ -1685,35 +1660,35 @@ static PassRefPtr<NodeList> paintOrderList(Element* element, ExceptionState& es, RenderObject* renderer = element->renderer(); if (!renderer || !renderer->isBox()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } RenderLayer* layer = toRenderBox(renderer)->layer(); if (!layer) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } Vector<RefPtr<Node> > nodes; - layer->computePaintOrderList(type, nodes); + layer->stackingNode()->computePaintOrderList(type, nodes); return StaticNodeList::adopt(nodes); } -PassRefPtr<NodeList> Internals::paintOrderListBeforePromote(Element* element, ExceptionState& es) +PassRefPtr<NodeList> Internals::paintOrderListBeforePromote(Element* element, ExceptionState& exceptionState) { - return paintOrderList(element, es, RenderLayer::BeforePromote); + return paintOrderList(element, exceptionState, RenderLayerStackingNode::BeforePromote); } -PassRefPtr<NodeList> Internals::paintOrderListAfterPromote(Element* element, ExceptionState& es) +PassRefPtr<NodeList> Internals::paintOrderListAfterPromote(Element* element, ExceptionState& exceptionState) { - return paintOrderList(element, es, RenderLayer::AfterPromote); + return paintOrderList(element, exceptionState, RenderLayerStackingNode::AfterPromote); } -bool Internals::scrollsWithRespectTo(Element* element1, Element* element2, ExceptionState& es) +bool Internals::scrollsWithRespectTo(Element* element1, Element* element2, ExceptionState& exceptionState) { if (!element1 || !element2) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } @@ -1722,24 +1697,24 @@ bool Internals::scrollsWithRespectTo(Element* element1, Element* element2, Excep RenderObject* renderer1 = element1->renderer(); RenderObject* renderer2 = element2->renderer(); if (!renderer1 || !renderer2 || !renderer1->isBox() || !renderer2->isBox()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } RenderLayer* layer1 = toRenderBox(renderer1)->layer(); RenderLayer* layer2 = toRenderBox(renderer2)->layer(); if (!layer1 || !layer2) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } return layer1->scrollsWithRespectTo(layer2); } -bool Internals::isUnclippedDescendant(Element* element, ExceptionState& es) +bool Internals::isUnclippedDescendant(Element* element, ExceptionState& exceptionState) { if (!element) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } @@ -1747,33 +1722,57 @@ bool Internals::isUnclippedDescendant(Element* element, ExceptionState& es) RenderObject* renderer = element->renderer(); if (!renderer || !renderer->isBox()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } RenderLayer* layer = toRenderBox(renderer)->layer(); if (!layer) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } return layer->isUnclippedDescendant(); } -String Internals::layerTreeAsText(Document* document, unsigned flags, ExceptionState& es) const +bool Internals::needsCompositedScrolling(Element* element, ExceptionState& exceptionState) +{ + if (!element) { + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); + return 0; + } + + element->document().updateLayout(); + + RenderObject* renderer = element->renderer(); + if (!renderer || !renderer->isBox()) { + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); + return 0; + } + + RenderLayer* layer = toRenderBox(renderer)->layer(); + if (!layer) { + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); + return 0; + } + + return layer->needsCompositedScrolling(); +} + +String Internals::layerTreeAsText(Document* document, unsigned flags, ExceptionState& exceptionState) const { if (!document || !document->frame()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return String(); } return document->frame()->layerTreeAsText(flags); } -String Internals::elementLayerTreeAsText(Element* element, unsigned flags, ExceptionState& es) const +String Internals::elementLayerTreeAsText(Element* element, unsigned flags, ExceptionState& exceptionState) const { if (!element) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return String(); } @@ -1781,78 +1780,107 @@ String Internals::elementLayerTreeAsText(Element* element, unsigned flags, Excep RenderObject* renderer = element->renderer(); if (!renderer || !renderer->isBox()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return String(); } RenderLayer* layer = toRenderBox(renderer)->layer(); if (!layer - || !layer->backing() - || !layer->backing()->graphicsLayer()) { + || !layer->hasCompositedLayerMapping() + || !layer->compositedLayerMapping()->mainGraphicsLayer()) { // Don't raise exception in these cases which may be normally used in tests. return String(); } - return layer->backing()->graphicsLayer()->layerTreeAsText(flags); + return layer->compositedLayerMapping()->mainGraphicsLayer()->layerTreeAsText(flags); } -static RenderLayer* getRenderLayerForElement(Element* element, ExceptionState& es) +static RenderLayer* getRenderLayerForElement(Element* element, ExceptionState& exceptionState) { if (!element) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } RenderObject* renderer = element->renderer(); if (!renderer || !renderer->isBox()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } RenderLayer* layer = toRenderBox(renderer)->layer(); if (!layer) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } return layer; } -void Internals::setNeedsCompositedScrolling(Element* element, unsigned needsCompositedScrolling, ExceptionState& es) +void Internals::setNeedsCompositedScrolling(Element* element, unsigned needsCompositedScrolling, ExceptionState& exceptionState) { if (!element) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return; } element->document().updateLayout(); - if (RenderLayer* layer = getRenderLayerForElement(element, es)) - layer->setForceNeedsCompositedScrolling(static_cast<RenderLayer::ForceNeedsCompositedScrollingMode>(needsCompositedScrolling)); + if (RenderLayer* layer = getRenderLayerForElement(element, exceptionState)) + layer->scrollableArea()->setForceNeedsCompositedScrolling(static_cast<ForceNeedsCompositedScrollingMode>(needsCompositedScrolling)); } -String Internals::repaintRectsAsText(Document* document, ExceptionState& es) const +String Internals::repaintRectsAsText(Document* document, ExceptionState& exceptionState) const { if (!document || !document->frame()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return String(); } return document->frame()->trackedRepaintRectsAsText(); } -String Internals::scrollingStateTreeAsText(Document* document, ExceptionState& es) const +PassRefPtr<ClientRectList> Internals::repaintRects(Element* element, ExceptionState& exceptionState) const +{ + if (!element) { + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); + return 0; + } + + if (RenderLayer* layer = getRenderLayerForElement(element, exceptionState)) { + if (layer->compositingState() == PaintsIntoOwnBacking) { + OwnPtr<Vector<FloatRect> > rects = layer->collectTrackedRepaintRects(); + ASSERT(rects.get()); + Vector<FloatQuad> quads(rects->size()); + for (size_t i = 0; i < rects->size(); ++i) + quads[i] = FloatRect(rects->at(i)); + return ClientRectList::create(quads); + } + } + + // It's an error to call this on an element that's not composited. + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); + return 0; +} + +String Internals::scrollingStateTreeAsText(Document* document, ExceptionState& exceptionState) const { return String(); } -String Internals::mainThreadScrollingReasons(Document* document, ExceptionState& es) const +String Internals::mainThreadScrollingReasons(Document* document, ExceptionState& exceptionState) const { if (!document || !document->frame()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return String(); } + // Force a re-layout and a compositing update. + document->updateLayout(); + RenderView* view = document->renderView(); + if (view->compositor()) + view->compositor()->updateCompositingLayers(CompositingUpdateFinishAllDeferredWork); + Page* page = document->page(); if (!page) return String(); @@ -1860,10 +1888,10 @@ String Internals::mainThreadScrollingReasons(Document* document, ExceptionState& return page->mainThreadScrollingReasonsAsText(); } -PassRefPtr<ClientRectList> Internals::nonFastScrollableRects(Document* document, ExceptionState& es) const +PassRefPtr<ClientRectList> Internals::nonFastScrollableRects(Document* document, ExceptionState& exceptionState) const { if (!document || !document->frame()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } @@ -1874,18 +1902,12 @@ PassRefPtr<ClientRectList> Internals::nonFastScrollableRects(Document* document, return page->nonFastScrollableRects(document->frame()); } -void Internals::garbageCollectDocumentResources(Document* document, ExceptionState& es) const +void Internals::garbageCollectDocumentResources(Document* document, ExceptionState& exceptionState) const { if (!document) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return; } - - if (StyleResolver* resolver = contextDocument()->styleResolverIfExists()) - resolver->clearStyleSharingList(); - if (StyleResolver* resolver = document->styleResolverIfExists()) - resolver->clearStyleSharingList(); - ResourceFetcher* fetcher = document->fetcher(); if (!fetcher) return; @@ -1902,28 +1924,6 @@ void Internals::allowRoundingHacks() const TextRun::setAllowsRoundingHacks(true); } -void Internals::insertAuthorCSS(Document* document, const String& css) const -{ - if (!document) - return; - - RefPtr<StyleSheetContents> parsedSheet = StyleSheetContents::create(*document); - parsedSheet->setIsUserStyleSheet(false); - parsedSheet->parseString(css); - document->styleEngine()->addAuthorSheet(parsedSheet); -} - -void Internals::insertUserCSS(Document* document, const String& css) const -{ - if (!document) - return; - - RefPtr<StyleSheetContents> parsedSheet = StyleSheetContents::create(*document); - parsedSheet->setIsUserStyleSheet(true); - parsedSheet->parseString(css); - document->styleEngine()->addUserSheet(parsedSheet); -} - String Internals::counterValue(Element* element) { if (!element) @@ -1970,41 +1970,41 @@ int Internals::numberOfPages(float pageWidth, float pageHeight) return PrintContext::numberOfPages(frame(), FloatSize(pageWidth, pageHeight)); } -String Internals::pageProperty(String propertyName, int pageNumber, ExceptionState& es) const +String Internals::pageProperty(String propertyName, int pageNumber, ExceptionState& exceptionState) const { if (!frame()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return String(); } return PrintContext::pageProperty(frame(), propertyName.utf8().data(), pageNumber); } -String Internals::pageSizeAndMarginsInPixels(int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft, ExceptionState& es) const +String Internals::pageSizeAndMarginsInPixels(int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft, ExceptionState& exceptionState) const { if (!frame()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return String(); } return PrintContext::pageSizeAndMarginsInPixels(frame(), pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft); } -void Internals::setDeviceScaleFactor(float scaleFactor, ExceptionState& es) +void Internals::setDeviceScaleFactor(float scaleFactor, ExceptionState& exceptionState) { Document* document = contextDocument(); if (!document || !document->page()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return; } Page* page = document->page(); page->setDeviceScaleFactor(scaleFactor); } -void Internals::setIsCursorVisible(Document* document, bool isVisible, ExceptionState& es) +void Internals::setIsCursorVisible(Document* document, bool isVisible, ExceptionState& exceptionState) { if (!document || !document->page()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return; } document->page()->setIsCursorVisible(isVisible); @@ -2060,14 +2060,14 @@ PassRefPtr<TypeConversions> Internals::typeConversions() const Vector<String> Internals::getReferencedFilePaths() const { - frame()->loader()->history()->saveDocumentAndScrollState(); - return FormController::getReferencedFilePaths(frame()->loader()->history()->currentItem()->documentState()); + frame()->loader().saveDocumentAndScrollState(); + return FormController::getReferencedFilePaths(frame()->loader().currentItem()->documentState()); } -void Internals::startTrackingRepaints(Document* document, ExceptionState& es) +void Internals::startTrackingRepaints(Document* document, ExceptionState& exceptionState) { if (!document || !document->view()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return; } @@ -2075,10 +2075,10 @@ void Internals::startTrackingRepaints(Document* document, ExceptionState& es) frameView->setTracksRepaints(true); } -void Internals::stopTrackingRepaints(Document* document, ExceptionState& es) +void Internals::stopTrackingRepaints(Document* document, ExceptionState& exceptionState) { if (!document || !document->view()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return; } @@ -2086,6 +2086,56 @@ void Internals::stopTrackingRepaints(Document* document, ExceptionState& es) frameView->setTracksRepaints(false); } +void Internals::updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(ExceptionState& exceptionState) +{ + updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(0, exceptionState); +} + +void Internals::updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(Node* node, ExceptionState& exceptionState) +{ + Document* document; + if (!node) { + document = contextDocument(); + } else if (node->isDocumentNode()) { + document = toDocument(node); + } else if (node->hasTagName(HTMLNames::iframeTag)) { + document = toHTMLIFrameElement(node)->contentDocument(); + } else { + exceptionState.throwUninformativeAndGenericDOMException(TypeError); + return; + } + document->updateLayoutIgnorePendingStylesheets(Document::RunPostLayoutTasksSynchronously); +} + +PassRefPtr<ClientRectList> Internals::draggableRegions(Document* document, ExceptionState& exceptionState) +{ + return annotatedRegions(document, true, exceptionState); +} + +PassRefPtr<ClientRectList> Internals::nonDraggableRegions(Document* document, ExceptionState& exceptionState) +{ + return annotatedRegions(document, false, exceptionState); +} + +PassRefPtr<ClientRectList> Internals::annotatedRegions(Document* document, bool draggable, ExceptionState& exceptionState) +{ + if (!document || !document->view()) { + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); + return ClientRectList::create(); + } + + document->updateLayout(); + document->view()->updateAnnotatedRegions(); + Vector<AnnotatedRegionValue> regions = document->annotatedRegions(); + + Vector<FloatQuad> quads; + for (size_t i = 0; i < regions.size(); ++i) { + if (regions[i].draggable == draggable) + quads.append(FloatQuad(regions[i].bounds)); + } + return ClientRectList::create(quads); +} + static const char* cursorTypeToString(Cursor::Type cursorType) { switch (cursorType) { @@ -2139,14 +2189,14 @@ static const char* cursorTypeToString(Cursor::Type cursorType) return "UNKNOWN"; } -String Internals::getCurrentCursorInfo(Document* document, ExceptionState& es) +String Internals::getCurrentCursorInfo(Document* document, ExceptionState& exceptionState) { if (!document || !document->frame()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return String(); } - Cursor cursor = document->frame()->eventHandler()->currentMouseCursor(); + Cursor cursor = document->frame()->eventHandler().currentMouseCursor(); StringBuilder result; result.append("type="); @@ -2187,42 +2237,42 @@ PassRefPtr<SerializedScriptValue> Internals::deserializeBuffer(PassRefPtr<ArrayB void Internals::forceReload(bool endToEnd) { - frame()->loader()->reload(endToEnd ? EndToEndReload : NormalReload); + frame()->loader().reload(endToEnd ? EndToEndReload : NormalReload); } -PassRefPtr<ClientRect> Internals::selectionBounds(ExceptionState& es) +PassRefPtr<ClientRect> Internals::selectionBounds(ExceptionState& exceptionState) { Document* document = contextDocument(); if (!document || !document->frame()) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return 0; } return ClientRect::create(document->frame()->selection().bounds()); } -String Internals::markerTextForListItem(Element* element, ExceptionState& es) +String Internals::markerTextForListItem(Element* element, ExceptionState& exceptionState) { if (!element) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return String(); } return WebCore::markerTextForListItem(element); } -String Internals::getImageSourceURL(Element* element, ExceptionState& es) +String Internals::getImageSourceURL(Element* element, ExceptionState& exceptionState) { if (!element) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return String(); } return element->imageSourceURL(); } -String Internals::baseURL(Document* document, ExceptionState& es) +String Internals::baseURL(Document* document, ExceptionState& exceptionState) { if (!document) { - es.throwDOMException(InvalidAccessError); + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); return String(); } @@ -2257,4 +2307,33 @@ bool Internals::loseSharedGraphicsContext3D() return true; } +void Internals::forceCompositingUpdate(Document* document, ExceptionState& exceptionState) +{ + if (!document || !document->renderView()) { + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); + return; + } + + document->updateLayout(); + + RenderView* view = document->renderView(); + if (view->compositor()) + view->compositor()->updateCompositingLayers(CompositingUpdateFinishAllDeferredWork); +} + +bool Internals::isCompositorFramePending(Document* document, ExceptionState& exceptionState) +{ + if (!document || !document->renderView()) { + exceptionState.throwDOMException(InvalidAccessError, document ? "The document's render view cannot be retrieved." : "The document provided is invalid."); + return false; + } + + return document->page()->chrome().client().isCompositorFramePending(); +} + +void Internals::setZoomFactor(float factor) +{ + frame()->setPageZoomFactor(factor); +} + } diff --git a/chromium/third_party/WebKit/Source/core/testing/Internals.h b/chromium/third_party/WebKit/Source/core/testing/Internals.h index 18350ecd52d..32c969a3d74 100644 --- a/chromium/third_party/WebKit/Source/core/testing/Internals.h +++ b/chromium/third_party/WebKit/Source/core/testing/Internals.h @@ -61,7 +61,7 @@ class Node; class Page; class PagePopupController; class Range; -class ScriptExecutionContext; +class ExecutionContext; class SerializedScriptValue; class ShadowRoot; class TypeConversions; @@ -85,6 +85,10 @@ public: void crash(); + void setStyleResolverStatsEnabled(bool); + String styleResolverStatsReport(ExceptionState&) const; + String styleResolverStatsTotalsReport(ExceptionState&) const; + size_t numberOfScopedHTMLStyleChildren(const Node*, ExceptionState&) const; PassRefPtr<CSSComputedStyleDeclaration> computedStyleIncludingVisitedInfo(Node*, ExceptionState&) const; @@ -98,14 +102,11 @@ public: bool hasShadowInsertionPoint(const Node*, ExceptionState&) const; bool hasContentElement(const Node*, ExceptionState&) const; size_t countElementShadow(const Node*, ExceptionState&) const; - Element* includerFor(Node*, ExceptionState&); String shadowPseudoId(Element*, ExceptionState&); void setShadowPseudoId(Element*, const String&, ExceptionState&); // CSS Animation / Transition testing. unsigned numberOfActiveAnimations() const; - void suspendAnimations(Document*, ExceptionState&) const; - void resumeAnimations(Document*, ExceptionState&) const; void pauseAnimations(double pauseTime, ExceptionState&); PassRefPtr<Element> createContentElement(ExceptionState&); @@ -118,8 +119,6 @@ public: bool hasSelectorForPseudoClassInShadow(Element* host, const String& pseudoClass, ExceptionState&); unsigned short compareTreeScopePosition(const Node*, const Node*, ExceptionState&) const; - bool attached(Node*, ExceptionState&); - // FIXME: Rename these functions if walker is prefered. Node* nextSiblingByWalker(Node*, ExceptionState&); Node* firstChildByWalker(Node*, ExceptionState&); @@ -127,10 +126,12 @@ public: Node* nextNodeByWalker(Node*, ExceptionState&); Node* previousNodeByWalker(Node*, ExceptionState&); + unsigned updateStyleAndReturnAffectedElementCount(ExceptionState&) const; + String visiblePlaceholder(Element*); void selectColorInColorChooser(Element*, const String& colorValue); - Vector<String> formControlStateOfPreviousHistoryItem(ExceptionState&); - void setFormControlStateOfPreviousHistoryItem(const Vector<String>&, ExceptionState&); + Vector<String> formControlStateOfHistoryItem(ExceptionState&); + void setFormControlStateOfHistoryItem(const Vector<String>&, ExceptionState&); void setEnableMockPagePopup(bool, ExceptionState&); PassRefPtr<PagePopupController> pagePopupController(); @@ -189,7 +190,7 @@ public: PassRefPtr<NodeList> nodesFromRect(Document*, int x, int y, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allowShadowContent, bool allowChildFrameContent, ExceptionState&) const; - void emitInspectorDidBeginFrame(); + void emitInspectorDidBeginFrame(int frameId = 0); void emitInspectorDidCancelFrame(); bool hasSpellingMarker(Document*, int from, int length, ExceptionState&); @@ -222,10 +223,13 @@ public: bool scrollsWithRespectTo(Element*, Element*, ExceptionState&); bool isUnclippedDescendant(Element*, ExceptionState&); + bool needsCompositedScrolling(Element*, ExceptionState&); void setNeedsCompositedScrolling(Element*, unsigned value, ExceptionState&); String repaintRectsAsText(Document*, ExceptionState&) const; + PassRefPtr<ClientRectList> repaintRects(Element*, ExceptionState&) const; + String scrollingStateTreeAsText(Document*, ExceptionState&) const; String mainThreadScrollingReasons(Document*, ExceptionState&) const; PassRefPtr<ClientRectList> nonFastScrollableRects(Document*, ExceptionState&) const; @@ -235,11 +239,9 @@ public: void allowRoundingHacks() const; - void insertAuthorCSS(Document*, const String&) const; - void insertUserCSS(Document*, const String&) const; - unsigned numberOfLiveNodes() const; unsigned numberOfLiveDocuments() const; + String dumpRefCountedInstanceCounts() const; Vector<String> consoleMessageArgumentCounts(Document*) const; PassRefPtr<DOMWindow> openDummyInspectorFrontend(const String& url); void closeDummyInspectorFrontend(); @@ -275,6 +277,11 @@ public: void startTrackingRepaints(Document*, ExceptionState&); void stopTrackingRepaints(Document*, ExceptionState&); + void updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(ExceptionState&); + void updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(Node*, ExceptionState&); + + PassRefPtr<ClientRectList> draggableRegions(Document*, ExceptionState&); + PassRefPtr<ClientRectList> nonDraggableRegions(Document*, ExceptionState&); PassRefPtr<ArrayBuffer> serializeObject(PassRefPtr<SerializedScriptValue>) const; PassRefPtr<SerializedScriptValue> deserializeBuffer(PassRefPtr<ArrayBuffer>) const; @@ -285,8 +292,6 @@ public: void forceReload(bool endToEnd); - void enableMockSpeechSynthesizer(); - String getImageSourceURL(Element*, ExceptionState&); bool isSelectPopupVisible(Node*); @@ -296,11 +301,18 @@ public: bool loseSharedGraphicsContext3D(); + void forceCompositingUpdate(Document*, ExceptionState&); + + bool isCompositorFramePending(Document*, ExceptionState&); + + void setZoomFactor(float); + private: explicit Internals(Document*); Document* contextDocument() const; Frame* frame() const; Vector<String> iconURLs(Document*, int iconTypesMask) const; + PassRefPtr<ClientRectList> annotatedRegions(Document*, bool draggable, ExceptionState&); DocumentMarker* markerAt(Node*, const String& markerType, unsigned index, ExceptionState&); RefPtr<DOMWindow> m_frontendWindow; diff --git a/chromium/third_party/WebKit/Source/core/testing/Internals.idl b/chromium/third_party/WebKit/Source/core/testing/Internals.idl index 0d21489b177..be6087df535 100644 --- a/chromium/third_party/WebKit/Source/core/testing/Internals.idl +++ b/chromium/third_party/WebKit/Source/core/testing/Internals.idl @@ -37,6 +37,10 @@ void crash(); + void setStyleResolverStatsEnabled(boolean enabled); + [RaisesException] DOMString styleResolverStatsReport(); + [RaisesException] DOMString styleResolverStatsTotalsReport(); + [RaisesException] unsigned long numberOfScopedHTMLStyleChildren(Node scope); [RaisesException] CSSStyleDeclaration computedStyleIncludingVisitedInfo(Node node); @@ -51,7 +55,6 @@ [RaisesException] boolean hasShadowInsertionPoint(Node root); [RaisesException] boolean hasContentElement(Node root); [RaisesException] unsigned long countElementShadow(Node Root); - [RaisesException] Element includerFor(Node node); [RaisesException] DOMString shadowPseudoId(Element element); [RaisesException] void setShadowPseudoId(Element element, DOMString id); [RaisesException] Element createContentElement(); @@ -63,11 +66,10 @@ [RaisesException] boolean hasSelectorForAttributeInShadow(Element host, DOMString attributeName); [RaisesException] boolean hasSelectorForPseudoClassInShadow(Element host, DOMString pseudoClass); [RaisesException] unsigned short compareTreeScopePosition(Node treeScope1, Node treeScope2); + [RaisesException] unsigned long updateStyleAndReturnAffectedElementCount(); // CSS Animation and Transition testing. unsigned long numberOfActiveAnimations(); - [RaisesException] void suspendAnimations(Document document); - [RaisesException] void resumeAnimations(Document document); [RaisesException] void pauseAnimations(double pauseTime); [RaisesException] Node nextSiblingByWalker(Node node); @@ -76,14 +78,12 @@ [RaisesException] Node nextNodeByWalker(Node node); [RaisesException] Node previousNodeByWalker(Node node); - [RaisesException] boolean attached(Node node); - DOMString visiblePlaceholder(Element element); void selectColorInColorChooser(Element element, DOMString colorValue); - [RaisesException] DOMString[] formControlStateOfPreviousHistoryItem(); - [RaisesException] void setFormControlStateOfPreviousHistoryItem(sequence<DOMString> values); + [RaisesException] DOMString[] formControlStateOfHistoryItem(); + [RaisesException] void setFormControlStateOfHistoryItem(sequence<DOMString> values); [RaisesException] void setEnableMockPagePopup(boolean enabled); readonly attribute PagePopupController pagePopupController; @@ -148,7 +148,7 @@ unsigned long topPadding, unsigned long rightPadding, unsigned long bottomPadding, unsigned long leftPadding, boolean ignoreClipping, boolean allowShadowContent, boolean allowChildFrameContent); - void emitInspectorDidBeginFrame(); + void emitInspectorDidBeginFrame(optional long frameId); void emitInspectorDidCancelFrame(); [RaisesException] boolean hasSpellingMarker(Document document, long from, long length); @@ -172,6 +172,7 @@ const unsigned short LAYER_TREE_INCLUDES_REPAINT_RECTS = 2; const unsigned short LAYER_TREE_INCLUDES_PAINTING_PHASES = 4; const unsigned short LAYER_TREE_INCLUDES_ROOT_LAYER = 8; + const unsigned short LAYER_TREE_INCLUDES_CLIP_AND_SCROLL_PARENTS = 16; [RaisesException] DOMString layerTreeAsText(Document document, optional unsigned short flags); [RaisesException] DOMString elementLayerTreeAsText(Element element, optional unsigned short flags); @@ -180,6 +181,7 @@ [RaisesException] boolean scrollsWithRespectTo(Element element1, Element element2); [RaisesException] boolean isUnclippedDescendant(Element element); + [RaisesException] boolean needsCompositedScrolling(Element element); // The values of these constants must be kept in sync with those in RenderLayer. const unsigned short DO_NOT_FORCE_COMPOSITED_SCROLLING = 0; @@ -192,17 +194,16 @@ [RaisesException] ClientRectList nonFastScrollableRects(Document document); [RaisesException] DOMString repaintRectsAsText(Document document); + [RaisesException] ClientRectList repaintRects(Element element); [RaisesException] void garbageCollectDocumentResources(Document document); void evictAllResources(); void allowRoundingHacks(); - void insertAuthorCSS(Document document, DOMString css); - void insertUserCSS(Document document, DOMString css); - unsigned long numberOfLiveNodes(); unsigned long numberOfLiveDocuments(); + DOMString dumpRefCountedInstanceCounts(); sequence<DOMString> consoleMessageArgumentCounts(Document document); Window openDummyInspectorFrontend(DOMString url); void closeDummyInspectorFrontend(); @@ -239,6 +240,15 @@ [RaisesException] void startTrackingRepaints(Document document); [RaisesException] void stopTrackingRepaints(Document document); + // |node| should be Document, HTMLIFrameElement, or unspecified. + // If |node| is an HTMLIFrameElement, it assumes node.contentDocument is + // specified without security checks. Unspecified means this document. + [RaisesException] void updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(optional Node node); + + // Returns a list of draggable/non-draggable regions in the document. + [RaisesException] ClientRectList draggableRegions(Document document); + [RaisesException] ClientRectList nonDraggableRegions(Document document); + // Returns a string with information about the mouse cursor used at the specified client location. [RaisesException] DOMString getCurrentCursorInfo(Document document); @@ -251,8 +261,6 @@ void forceReload(boolean endToEnd); - void enableMockSpeechSynthesizer(); - [RaisesException] DOMString getImageSourceURL(Element element); boolean isSelectPopupVisible(Node node); @@ -260,4 +268,9 @@ [RaisesException] ClientRect selectionBounds(); boolean loseSharedGraphicsContext3D(); + + [RaisesException] void forceCompositingUpdate(Document document); + [RaisesException] boolean isCompositorFramePending(Document document); + + void setZoomFactor(float factor); }; diff --git a/chromium/third_party/WebKit/Source/core/testing/MockPagePopupDriver.cpp b/chromium/third_party/WebKit/Source/core/testing/MockPagePopupDriver.cpp index 5ca92ce099a..56cc2482698 100644 --- a/chromium/third_party/WebKit/Source/core/testing/MockPagePopupDriver.cpp +++ b/chromium/third_party/WebKit/Source/core/testing/MockPagePopupDriver.cpp @@ -33,11 +33,10 @@ #include "core/loader/DocumentLoader.h" #include "core/loader/DocumentWriter.h" #include "core/loader/FrameLoader.h" -#include "core/page/Frame.h" +#include "core/frame/Frame.h" #include "core/page/PagePopup.h" -#include "core/page/PagePopupClient.h" #include "core/page/PagePopupController.h" -#include "core/platform/Timer.h" +#include "platform/Timer.h" namespace WebCore { @@ -62,7 +61,7 @@ inline MockPagePopup::MockPagePopup(PagePopupClient* client, const IntRect& orig { Document* document = mainFrame->document(); ASSERT(document); - m_iframe = HTMLIFrameElement::create(HTMLNames::iframeTag, *document); + m_iframe = HTMLIFrameElement::create(*document); m_iframe->setIdAttribute("mock-page-popup"); m_iframe->setInlineStyleProperty(CSSPropertyBorderWidth, 0.0, CSSPrimitiveValue::CSS_PX); m_iframe->setInlineStyleProperty(CSSPropertyPosition, CSSValueAbsolute); @@ -71,11 +70,11 @@ inline MockPagePopup::MockPagePopup(PagePopupClient* client, const IntRect& orig if (document->body()) document->body()->appendChild(m_iframe.get()); Frame* contentFrame = m_iframe->contentFrame(); - DocumentWriter* writer = contentFrame->loader()->activeDocumentLoader()->beginWriting("text/html", "UTF-8"); + DocumentWriter* writer = contentFrame->loader().activeDocumentLoader()->beginWriting("text/html", "UTF-8"); const char scriptToSetUpPagePopupController[] = "<script>window.pagePopupController = parent.internals.pagePopupController;</script>"; writer->addData(scriptToSetUpPagePopupController, sizeof(scriptToSetUpPagePopupController)); m_popupClient->writeDocument(*writer); - contentFrame->loader()->activeDocumentLoader()->endWriting(writer); + contentFrame->loader().activeDocumentLoader()->endWriting(writer); } PassRefPtr<MockPagePopup> MockPagePopup::create(PagePopupClient* client, const IntRect& originBoundsInRootView, Frame* mainFrame) diff --git a/chromium/third_party/WebKit/Source/core/testing/TypeConversions.h b/chromium/third_party/WebKit/Source/core/testing/TypeConversions.h index 10f675f42f4..9a2625d0643 100644 --- a/chromium/third_party/WebKit/Source/core/testing/TypeConversions.h +++ b/chromium/third_party/WebKit/Source/core/testing/TypeConversions.h @@ -38,31 +38,23 @@ public: long testLong() { return m_long; } void setTestLong(long value) { m_long = value; } - long testEnforceRangeLong() { return m_long; } - void setTestEnforceRangeLong(long value) { m_long = value; } unsigned long testUnsignedLong() { return m_unsignedLong; } void setTestUnsignedLong(unsigned long value) { m_unsignedLong = value; } - unsigned long testEnforceRangeUnsignedLong() { return m_unsignedLong; } - void setTestEnforceRangeUnsignedLong(unsigned long value) { m_unsignedLong = value; } long long testLongLong() { return m_longLong; } void setTestLongLong(long long value) { m_longLong = value; } - long long testEnforceRangeLongLong() { return m_longLong; } - void setTestEnforceRangeLongLong(long long value) { m_longLong = value; } unsigned long long testUnsignedLongLong() { return m_unsignedLongLong; } void setTestUnsignedLongLong(unsigned long long value) { m_unsignedLongLong = value; } - unsigned long long testEnforceRangeUnsignedLongLong() { return m_unsignedLongLong; } - void setTestEnforceRangeUnsignedLongLong(unsigned long long value) { m_unsignedLongLong = value; } int8_t testByte() { return m_byte; } void setTestByte(int8_t value) { m_byte = value; } - int8_t testEnforceRangeByte() { return m_byte; } - void setTestEnforceRangeByte(int8_t value) { m_byte = value; } - uint8_t testOctet() { return m_octet; } void setTestOctet(uint8_t value) { m_octet = value; } - uint8_t testEnforceRangeOctet() { return m_octet; } - void setTestEnforceRangeOctet(uint8_t value) { m_octet = value; } + + int16_t testShort() { return m_short; } + void setTestShort(int16_t value) { m_short = value; } + uint16_t testUnsignedShort() { return m_unsignedShort; } + void setTestUnsignedShort(uint16_t value) { m_unsignedShort = value; } private: TypeConversions() @@ -75,6 +67,8 @@ private: unsigned long long m_unsignedLongLong; int8_t m_byte; uint8_t m_octet; + int16_t m_short; + uint16_t m_unsignedShort; }; } // namespace WebCore diff --git a/chromium/third_party/WebKit/Source/core/testing/TypeConversions.idl b/chromium/third_party/WebKit/Source/core/testing/TypeConversions.idl index 1f3df0c12fb..7a70cc5d3fd 100644 --- a/chromium/third_party/WebKit/Source/core/testing/TypeConversions.idl +++ b/chromium/third_party/WebKit/Source/core/testing/TypeConversions.idl @@ -26,17 +26,22 @@ [ ] interface TypeConversions { attribute long testLong; - [EnforceRange] attribute long testEnforceRangeLong; + [EnforceRange, ImplementedAs=testLong] attribute long testEnforceRangeLong; attribute unsigned long testUnsignedLong; - [EnforceRange] attribute unsigned long testEnforceRangeUnsignedLong; + [EnforceRange, ImplementedAs=testUnsignedLong] attribute unsigned long testEnforceRangeUnsignedLong; attribute long long testLongLong; - [EnforceRange] attribute long long testEnforceRangeLongLong; + [EnforceRange, ImplementedAs=testLongLong] attribute long long testEnforceRangeLongLong; attribute unsigned long long testUnsignedLongLong; - [EnforceRange] attribute unsigned long long testEnforceRangeUnsignedLongLong; + [EnforceRange, ImplementedAs=testUnsignedLongLong] attribute unsigned long long testEnforceRangeUnsignedLongLong; attribute byte testByte; - [EnforceRange] attribute byte testEnforceRangeByte; + [EnforceRange, ImplementedAs=testByte] attribute byte testEnforceRangeByte; attribute octet testOctet; - [EnforceRange] attribute octet testEnforceRangeOctet; + [EnforceRange, ImplementedAs=testOctet] attribute octet testEnforceRangeOctet; + + attribute short testShort; + [EnforceRange, ImplementedAs=testShort] attribute short testEnforceRangeShort; + attribute unsigned short testUnsignedShort; + [EnforceRange, ImplementedAs=testUnsignedShort] attribute unsigned short testEnforceRangeUnsignedShort; }; diff --git a/chromium/third_party/WebKit/Source/core/testing/UnitTestHelpers.cpp b/chromium/third_party/WebKit/Source/core/testing/UnitTestHelpers.cpp new file mode 100644 index 00000000000..8c5bc5bbe45 --- /dev/null +++ b/chromium/third_party/WebKit/Source/core/testing/UnitTestHelpers.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2013 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: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS 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 APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * (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 "core/testing/UnitTestHelpers.h" + +#include "public/platform/Platform.h" +#include "public/platform/WebThread.h" + + +namespace WebCore { +namespace testing { + +class QuitTask : public blink::WebThread::Task { +public: + virtual void run() + { + blink::Platform::current()->currentThread()->exitRunLoop(); + } +}; + +void runPendingTasks() +{ + blink::Platform::current()->currentThread()->postTask(new QuitTask); + blink::Platform::current()->currentThread()->enterRunLoop(); +} + +} +} diff --git a/chromium/third_party/WebKit/Source/core/testing/UnitTestHelpers.h b/chromium/third_party/WebKit/Source/core/testing/UnitTestHelpers.h new file mode 100644 index 00000000000..cb8fe5880b3 --- /dev/null +++ b/chromium/third_party/WebKit/Source/core/testing/UnitTestHelpers.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2013 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: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS 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 APPLE OR ITS 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. + */ + +#ifndef UnitTestHelpers_h +#define UnitTestHelpers_h + +namespace WebCore { +namespace testing { + +void runPendingTasks(); + +} // namespace testing +} // namespace WebCore + +#endif diff --git a/chromium/third_party/WebKit/Source/core/testing/v8/WebCoreTestSupport.cpp b/chromium/third_party/WebKit/Source/core/testing/v8/WebCoreTestSupport.cpp index e18e3694d45..f28fecbb2a4 100644 --- a/chromium/third_party/WebKit/Source/core/testing/v8/WebCoreTestSupport.cpp +++ b/chromium/third_party/WebKit/Source/core/testing/v8/WebCoreTestSupport.cpp @@ -30,8 +30,8 @@ #include "Internals.h" #include "V8Internals.h" #include "core/dom/Document.h" -#include "core/dom/ScriptExecutionContext.h" -#include "core/page/Frame.h" +#include "core/dom/ExecutionContext.h" +#include "core/frame/Frame.h" #include <v8.h> @@ -43,9 +43,9 @@ void injectInternalsObject(v8::Local<v8::Context> context) { v8::Context::Scope contextScope(context); v8::HandleScope scope(context->GetIsolate()); - ScriptExecutionContext* scriptContext = getScriptExecutionContext(); + ExecutionContext* scriptContext = getExecutionContext(); if (scriptContext->isDocument()) - context->Global()->Set(v8::String::New(Internals::internalsId), toV8(Internals::create(toDocument(scriptContext)), v8::Handle<v8::Object>(), context->GetIsolate())); + context->Global()->Set(v8::String::NewFromUtf8(context->GetIsolate(), Internals::internalsId), toV8(Internals::create(toDocument(scriptContext)), v8::Handle<v8::Object>(), context->GetIsolate())); } void resetInternalsObject(v8::Local<v8::Context> context) @@ -57,7 +57,7 @@ void resetInternalsObject(v8::Local<v8::Context> context) v8::Context::Scope contextScope(context); v8::HandleScope scope(context->GetIsolate()); - ScriptExecutionContext* scriptContext = getScriptExecutionContext(); + ExecutionContext* scriptContext = getExecutionContext(); Page* page = toDocument(scriptContext)->frame()->page(); Internals::resetToConsistentState(page); InternalSettings::from(page)->resetToConsistentState(); |