*/
#include "config.h"
-#include "Internals.h"
-
-#include <v8.h>
-#include "InspectorFrontendClientLocal.h"
-#include "InternalProfilers.h"
-#include "InternalRuntimeFlags.h"
-#include "InternalSettings.h"
-#include "LayerRect.h"
-#include "LayerRectList.h"
-#include "MallocStatistics.h"
-#include "MockPagePopupDriver.h"
-#include "RuntimeEnabledFeatures.h"
-#include "TypeConversions.h"
-#include "bindings/v8/ExceptionMessages.h"
-#include "bindings/v8/ExceptionState.h"
-#include "bindings/v8/ScriptFunction.h"
-#include "bindings/v8/ScriptPromise.h"
-#include "bindings/v8/ScriptPromiseResolver.h"
-#include "bindings/v8/SerializedScriptValue.h"
-#include "bindings/v8/V8ThrowException.h"
-#include "core/animation/DocumentTimeline.h"
+#include "core/testing/Internals.h"
+
+#include "bindings/core/v8/ExceptionMessages.h"
+#include "bindings/core/v8/ExceptionState.h"
+#include "bindings/core/v8/ScriptFunction.h"
+#include "bindings/core/v8/ScriptPromise.h"
+#include "bindings/core/v8/ScriptPromiseResolver.h"
+#include "bindings/core/v8/SerializedScriptValue.h"
+#include "bindings/core/v8/V8ThrowException.h"
+#include "core/InternalRuntimeFlags.h"
+#include "core/animation/AnimationTimeline.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"
+#include "core/dom/DOMArrayBuffer.h"
+#include "core/dom/DOMPoint.h"
#include "core/dom/DOMStringList.h"
#include "core/dom/Document.h"
#include "core/dom/DocumentMarker.h"
#include "core/dom/DocumentMarkerController.h"
#include "core/dom/Element.h"
#include "core/dom/ExceptionCode.h"
-#include "core/dom/FullscreenElementStack.h"
+#include "core/dom/Iterator.h"
#include "core/dom/NodeRenderStyle.h"
#include "core/dom/PseudoElement.h"
#include "core/dom/Range.h"
#include "core/dom/StaticNodeList.h"
+#include "core/dom/StyleEngine.h"
#include "core/dom/TreeScope.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/editing/SpellChecker.h"
#include "core/editing/SurroundingText.h"
#include "core/editing/TextIterator.h"
+#include "core/editing/markup.h"
#include "core/fetch/MemoryCache.h"
#include "core/fetch/ResourceFetcher.h"
-#include "core/frame/DOMPoint.h"
-#include "core/frame/DOMWindow.h"
+#include "core/frame/EventHandlerRegistry.h"
+#include "core/frame/FrameConsole.h"
#include "core/frame/FrameView.h"
+#include "core/frame/LocalDOMWindow.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/Settings.h"
#include "core/html/HTMLContentElement.h"
#include "core/html/HTMLIFrameElement.h"
#include "core/html/HTMLInputElement.h"
#include "core/html/HTMLMediaElement.h"
+#include "core/html/HTMLPlugInElement.h"
#include "core/html/HTMLSelectElement.h"
#include "core/html/HTMLTextAreaElement.h"
+#include "core/html/canvas/CanvasRenderingContext2D.h"
#include "core/html/forms/FormController.h"
+#include "core/html/shadow/PluginPlaceholderElement.h"
#include "core/html/shadow/ShadowElementNames.h"
#include "core/html/shadow/TextControlInnerElements.h"
+#include "core/inspector/ConsoleMessageStorage.h"
#include "core/inspector/InspectorClient.h"
#include "core/inspector/InspectorConsoleAgent.h"
#include "core/inspector/InspectorController.h"
#include "core/page/Chrome.h"
#include "core/page/ChromeClient.h"
#include "core/page/EventHandler.h"
+#include "core/page/FocusController.h"
+#include "core/page/NetworkStateNotifier.h"
#include "core/page/Page.h"
#include "core/page/PagePopupController.h"
#include "core/page/PrintContext.h"
+#include "core/plugins/testing/DictionaryPluginPlaceholder.h"
+#include "core/plugins/testing/DocumentFragmentPluginPlaceholder.h"
#include "core/rendering/RenderLayer.h"
#include "core/rendering/RenderMenuList.h"
#include "core/rendering/RenderObject.h"
#include "core/rendering/RenderView.h"
#include "core/rendering/compositing/CompositedLayerMapping.h"
#include "core/rendering/compositing/RenderLayerCompositor.h"
+#include "core/testing/DictionaryTest.h"
#include "core/testing/GCObservation.h"
+#include "core/testing/InternalProfilers.h"
+#include "core/testing/InternalSettings.h"
+#include "core/testing/LayerRect.h"
+#include "core/testing/LayerRectList.h"
+#include "core/testing/MockPagePopupDriver.h"
+#include "core/testing/PrivateScriptTest.h"
+#include "core/testing/TypeConversions.h"
+#include "core/testing/UnionTypesTest.h"
#include "core/workers/WorkerThread.h"
-#include "platform/ColorChooser.h"
#include "platform/Cursor.h"
#include "platform/Language.h"
+#include "platform/RuntimeEnabledFeatures.h"
#include "platform/TraceEvent.h"
#include "platform/geometry/IntRect.h"
#include "platform/geometry/LayoutRect.h"
#include "platform/graphics/filters/FilterOperations.h"
#include "platform/weborigin/SchemeRegistry.h"
#include "public/platform/Platform.h"
+#include "public/platform/WebConnectionType.h"
#include "public/platform/WebGraphicsContext3D.h"
#include "public/platform/WebGraphicsContext3DProvider.h"
#include "public/platform/WebLayer.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/dtoa.h"
#include "wtf/text/StringBuffer.h"
+#include <v8.h>
-namespace WebCore {
-
-// FIXME: oilpan: These will be removed soon.
-static MockPagePopupDriver* s_pagePopupDriver = 0;
+namespace blink {
-using namespace HTMLNames;
+namespace {
-class InspectorFrontendChannelDummy : public InspectorFrontendChannel {
+class InternalsIterator final : public Iterator {
public:
- explicit InspectorFrontendChannelDummy(Page*);
- virtual ~InspectorFrontendChannelDummy() { }
- virtual void sendMessageToFrontend(PassRefPtr<JSONObject> message) OVERRIDE;
- virtual void flush() OVERRIDE { }
+ InternalsIterator() : m_current(0) { }
+
+ virtual ScriptValue next(ScriptState* scriptState, ExceptionState& exceptionState) override
+ {
+ v8::Isolate* isolate = scriptState->isolate();
+ int value = m_current * m_current;
+ if (m_current >= 5)
+ return ScriptValue(scriptState, v8DoneIteratorResult(isolate));
+ ++m_current;
+ return ScriptValue(scriptState, v8IteratorResult(scriptState, value));
+ }
+
+ virtual ScriptValue next(ScriptState* scriptState, ScriptValue value, ExceptionState& exceptionState) override
+ {
+ exceptionState.throwTypeError("Not implemented");
+ return ScriptValue();
+ }
private:
- Page* m_frontendPage;
+ int m_current;
};
-InspectorFrontendChannelDummy::InspectorFrontendChannelDummy(Page* page)
- : m_frontendPage(page)
-{
-}
+} // namespace
-void InspectorFrontendChannelDummy::sendMessageToFrontend(PassRefPtr<JSONObject> message)
-{
- InspectorClient::doDispatchMessageOnFrontendPage(m_frontendPage, message->toJSONString());
-}
+// FIXME: oilpan: These will be removed soon.
+static MockPagePopupDriver* s_pagePopupDriver = 0;
+
+using namespace HTMLNames;
static bool markerTypesFrom(const String& markerType, DocumentMarker::MarkerTypes& result)
{
const char* Internals::internalsId = "internals";
-PassRefPtrWillBeRawPtr<Internals> Internals::create(Document* document)
+Internals* Internals::create(Document* document)
{
- return adoptRefWillBeNoop(new Internals(document));
+ return new Internals(document);
}
Internals::~Internals()
page->setDeviceScaleFactor(1);
page->setIsCursorVisible(true);
page->setPageScaleFactor(1, IntPoint(0, 0));
- TextRun::setAllowsRoundingHacks(false);
- WebCore::overrideUserPreferredLanguages(Vector<AtomicString>());
+ blink::overrideUserPreferredLanguages(Vector<AtomicString>());
delete s_pagePopupDriver;
s_pagePopupDriver = 0;
page->chrome().client().resetPagePopupDriver();
- if (!page->mainFrame()->spellChecker().isContinuousSpellCheckingEnabled())
- page->mainFrame()->spellChecker().toggleContinuousSpellChecking();
- if (page->mainFrame()->editor().isOverwriteModeEnabled())
- page->mainFrame()->editor().toggleOverwriteModeEnabled();
+ if (!page->deprecatedLocalMainFrame()->spellChecker().isContinuousSpellCheckingEnabled())
+ page->deprecatedLocalMainFrame()->spellChecker().toggleContinuousSpellChecking();
+ if (page->deprecatedLocalMainFrame()->editor().isOverwriteModeEnabled())
+ page->deprecatedLocalMainFrame()->editor().toggleOverwriteModeEnabled();
if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator())
scrollingCoordinator->reset();
- page->mainFrame()->view()->clear();
+ page->deprecatedLocalMainFrame()->view()->clear();
}
Internals::Internals(Document* document)
return String(buf);
}
-PassRefPtrWillBeRawPtr<GCObservation> Internals::observeGC(ScriptValue scriptValue)
+GCObservation* Internals::observeGC(ScriptValue scriptValue)
{
v8::Handle<v8::Value> observedValue = scriptValue.v8Value();
ASSERT(!observedValue.IsEmpty());
if (observedValue->IsNull() || observedValue->IsUndefined()) {
- V8ThrowException::throwTypeError("value to observe is null or undefined", v8::Isolate::GetCurrent());
+ V8ThrowException::throwTypeError(v8::Isolate::GetCurrent(), "value to observe is null or undefined");
return nullptr;
}
return needsLayoutObjects;
}
+unsigned Internals::hitTestCount(Document* doc, ExceptionState& exceptionState) const
+{
+ if (!doc) {
+ exceptionState.throwDOMException(InvalidAccessError, "Must supply document to check");
+ return 0;
+ }
+
+ return doc->renderView()->hitTestCount();
+}
+
+
bool Internals::isPreloaded(const String& url)
{
Document* document = contextDocument();
{
if (!contextDocument())
return false;
- Resource* resource = memoryCache()->resourceForURL(contextDocument()->completeURL(url));
+ const String cacheIdentifier = contextDocument()->fetcher()->getCacheIdentifier();
+ Resource* resource = memoryCache()->resourceForURL(contextDocument()->completeURL(url), cacheIdentifier);
return resource && resource->status() == Resource::Cached;
}
-void Internals::crash()
-{
- CRASH();
-}
-
-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();
-}
-
-bool Internals::isSharingStyle(Element* element1, Element* element2, ExceptionState& exceptionState) const
+bool Internals::isSharingStyle(Element* element1, Element* element2) const
{
- if (!element1 || !element2) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(element1 ? 2 : 1, "Element"));
- return false;
- }
+ ASSERT(element1 && element2);
return element1->renderStyle() == element2->renderStyle();
}
bool Internals::isValidContentSelect(Element* insertionPoint, ExceptionState& exceptionState)
{
- if (!insertionPoint || !insertionPoint->isInsertionPoint()) {
- exceptionState.throwDOMException(InvalidAccessError, "The insertion point provided is invalid.");
+ ASSERT(insertionPoint);
+ if (!insertionPoint->isInsertionPoint()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The element is not an insertion point.");
return false;
}
return isHTMLContentElement(*insertionPoint) && toHTMLContentElement(*insertionPoint).isSelectValid();
}
-Node* Internals::treeScopeRootNode(Node* node, ExceptionState& exceptionState)
+Node* Internals::treeScopeRootNode(Node* node)
{
- if (!node) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Node"));
- return 0;
- }
-
+ ASSERT(node);
return &node->treeScope().rootNode();
}
-Node* Internals::parentTreeScope(Node* node, ExceptionState& exceptionState)
+Node* Internals::parentTreeScope(Node* node)
{
- if (!node) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Node"));
- return 0;
- }
+ ASSERT(node);
const TreeScope* parentTreeScope = node->treeScope().parentTreeScope();
return parentTreeScope ? &parentTreeScope->rootNode() : 0;
}
bool Internals::hasSelectorForIdInShadow(Element* host, const AtomicString& idValue, ExceptionState& exceptionState)
{
- if (!host || !host->shadow()) {
- exceptionState.throwDOMException(InvalidAccessError, "The host element provided is invalid, or does not have a shadow.");
+ ASSERT(host);
+ if (!host->shadow()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The host element does not have a shadow.");
return 0;
}
bool Internals::hasSelectorForClassInShadow(Element* host, const AtomicString& className, ExceptionState& exceptionState)
{
- if (!host || !host->shadow()) {
- exceptionState.throwDOMException(InvalidAccessError, "The host element provided is invalid, or does not have a shadow.");
+ ASSERT(host);
+ if (!host->shadow()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The host element does not have a shadow.");
return 0;
}
bool Internals::hasSelectorForAttributeInShadow(Element* host, const AtomicString& attributeName, ExceptionState& exceptionState)
{
- if (!host || !host->shadow()) {
- exceptionState.throwDOMException(InvalidAccessError, "The host element provided is invalid, or does not have a shadow.");
+ ASSERT(host);
+ if (!host->shadow()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The host element does not have a shadow.");
return 0;
}
bool Internals::hasSelectorForPseudoClassInShadow(Element* host, const String& pseudoClass, ExceptionState& exceptionState)
{
- if (!host || !host->shadow()) {
- exceptionState.throwDOMException(InvalidAccessError, "The host element provided is invalid, or does not have a shadow.");
+ ASSERT(host);
+ if (!host->shadow()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The host element does not have a shadow.");
return 0;
}
-
- const SelectRuleFeatureSet& featureSet = host->shadow()->ensureSelectFeatureSet();
- if (pseudoClass == "checked")
- return featureSet.hasSelectorForChecked();
- if (pseudoClass == "enabled")
- return featureSet.hasSelectorForEnabled();
- if (pseudoClass == "disabled")
- return featureSet.hasSelectorForDisabled();
- if (pseudoClass == "indeterminate")
- return featureSet.hasSelectorForIndeterminate();
- if (pseudoClass == "link")
- return featureSet.hasSelectorForLink();
- if (pseudoClass == "target")
- return featureSet.hasSelectorForTarget();
- if (pseudoClass == "visited")
- return featureSet.hasSelectorForVisited();
-
- ASSERT_NOT_REACHED();
- return false;
+ return host->shadow()->ensureSelectFeatureSet().hasSelectorForPseudoType(CSSSelector::parsePseudoType(AtomicString(pseudoClass), false));
}
unsigned short Internals::compareTreeScopePosition(const Node* node1, const Node* node2, ExceptionState& exceptionState) const
{
- if (!node1 || !node2) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(node1 ? 2 : 1, "Node"));
- return 0;
- }
+ ASSERT(node1 && node2);
const TreeScope* treeScope1 = node1->isDocumentNode() ? static_cast<const TreeScope*>(toDocument(node1)) :
node1->isShadowRoot() ? static_cast<const TreeScope*>(toShadowRoot(node1)) : 0;
const TreeScope* treeScope2 = node2->isDocumentNode() ? static_cast<const TreeScope*>(toDocument(node2)) :
return treeScope1->comparePosition(*treeScope2);
}
-unsigned Internals::numberOfActiveAnimations() const
-{
- LocalFrame* contextFrame = frame();
- Document* document = contextFrame->document();
- return document->timeline().numberOfActiveAnimationsForTesting() + document->transitionTimeline().numberOfActiveAnimationsForTesting();
-}
-
void Internals::pauseAnimations(double pauseTime, ExceptionState& exceptionState)
{
if (pauseTime < 0) {
frame()->view()->updateLayoutAndStyleForPainting();
frame()->document()->timeline().pauseAnimationsForTesting(pauseTime);
- frame()->document()->transitionTimeline().pauseAnimationsForTesting(pauseTime);
}
bool Internals::hasShadowInsertionPoint(const Node* root, ExceptionState& exceptionState) const
{
- if (root && root->isShadowRoot())
- return toShadowRoot(root)->containsShadowElements();
-
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Node"));
- return 0;
+ ASSERT(root);
+ if (!root->isShadowRoot()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The node argument is not a shadow root.");
+ return 0;
+ }
+ return toShadowRoot(root)->containsShadowElements();
}
bool Internals::hasContentElement(const Node* root, ExceptionState& exceptionState) const
{
- if (root && root->isShadowRoot())
- return toShadowRoot(root)->containsContentElements();
-
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Node"));
- return 0;
+ ASSERT(root);
+ if (!root->isShadowRoot()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The node argument is not a shadow root.");
+ return 0;
+ }
+ return toShadowRoot(root)->containsContentElements();
}
size_t Internals::countElementShadow(const Node* root, ExceptionState& exceptionState) const
{
- if (!root || !root->isShadowRoot()) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Node"));
+ ASSERT(root);
+ if (!root->isShadowRoot()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The node argument is not a shadow root.");
return 0;
}
return toShadowRoot(root)->childShadowRootCount();
}
-Node* Internals::nextSiblingByWalker(Node* node, ExceptionState& exceptionState)
+Node* Internals::nextSiblingByWalker(Node* node)
{
- if (!node) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Node"));
- return 0;
- }
+ ASSERT(node);
ComposedTreeWalker walker(node);
walker.nextSibling();
return walker.get();
}
-Node* Internals::firstChildByWalker(Node* node, ExceptionState& exceptionState)
+Node* Internals::firstChildByWalker(Node* node)
{
- if (!node) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Node"));
- return 0;
- }
+ ASSERT(node);
ComposedTreeWalker walker(node);
walker.firstChild();
return walker.get();
}
-Node* Internals::lastChildByWalker(Node* node, ExceptionState& exceptionState)
+Node* Internals::lastChildByWalker(Node* node)
{
- if (!node) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Node"));
- return 0;
- }
+ ASSERT(node);
ComposedTreeWalker walker(node);
walker.lastChild();
return walker.get();
}
-Node* Internals::nextNodeByWalker(Node* node, ExceptionState& exceptionState)
+Node* Internals::nextNodeByWalker(Node* node)
{
- if (!node) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Node"));
- return 0;
- }
+ ASSERT(node);
ComposedTreeWalker walker(node);
walker.next();
return walker.get();
}
-Node* Internals::previousNodeByWalker(Node* node, ExceptionState& exceptionState)
+Node* Internals::previousNodeByWalker(Node* node)
{
- if (!node) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Node"));
- return 0;
- }
+ ASSERT(node);
ComposedTreeWalker walker(node);
walker.previous();
return walker.get();
String Internals::elementRenderTreeAsText(Element* element, ExceptionState& exceptionState)
{
- if (!element) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Element"));
- return String();
- }
-
+ ASSERT(element);
String representation = externalRepresentation(element);
if (representation.isEmpty()) {
exceptionState.throwDOMException(InvalidAccessError, "The element provided has no external representation.");
return representation;
}
-size_t Internals::numberOfScopedHTMLStyleChildren(const Node* scope, ExceptionState& exceptionState) const
+PassRefPtrWillBeRawPtr<CSSStyleDeclaration> Internals::computedStyleIncludingVisitedInfo(Node* node) const
{
- if (scope && (scope->isElementNode() || scope->isShadowRoot()))
- return scope->numberOfScopedHTMLStyleChildren();
-
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Node"));
- return 0;
+ ASSERT(node);
+ bool allowVisitedStyle = true;
+ return CSSComputedStyleDeclaration::create(node, allowVisitedStyle);
}
-PassRefPtr<CSSComputedStyleDeclaration> Internals::computedStyleIncludingVisitedInfo(Node* node, ExceptionState& exceptionState) const
+PassRefPtrWillBeRawPtr<ShadowRoot> Internals::createUserAgentShadowRoot(Element* host)
{
- if (!node) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Node"));
- return nullptr;
- }
-
- bool allowVisitedStyle = true;
- return CSSComputedStyleDeclaration::create(node, allowVisitedStyle);
+ ASSERT(host);
+ return PassRefPtrWillBeRawPtr<ShadowRoot>(host->ensureUserAgentShadowRoot());
}
-ShadowRoot* Internals::shadowRoot(Element* host, ExceptionState& exceptionState)
+ShadowRoot* Internals::shadowRoot(Element* host)
{
// FIXME: Internals::shadowRoot() in tests should be converted to youngestShadowRoot() or oldestShadowRoot().
// https://bugs.webkit.org/show_bug.cgi?id=78465
- return youngestShadowRoot(host, exceptionState);
+ return youngestShadowRoot(host);
}
-ShadowRoot* Internals::youngestShadowRoot(Element* host, ExceptionState& exceptionState)
+ShadowRoot* Internals::youngestShadowRoot(Element* host)
{
- if (!host) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Element"));
- return 0;
- }
-
+ ASSERT(host);
if (ElementShadow* shadow = host->shadow())
return shadow->youngestShadowRoot();
return 0;
}
-ShadowRoot* Internals::oldestShadowRoot(Element* host, ExceptionState& exceptionState)
+ShadowRoot* Internals::oldestShadowRoot(Element* host)
{
- if (!host) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Element"));
- return 0;
- }
-
+ ASSERT(host);
if (ElementShadow* shadow = host->shadow())
return shadow->oldestShadowRoot();
return 0;
ShadowRoot* Internals::youngerShadowRoot(Node* shadow, ExceptionState& exceptionState)
{
- if (!shadow || !shadow->isShadowRoot()) {
- exceptionState.throwDOMException(InvalidAccessError, "The node provided is not a valid shadow root.");
+ ASSERT(shadow);
+ if (!shadow->isShadowRoot()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The node provided is not a shadow root.");
return 0;
}
String Internals::shadowRootType(const Node* root, ExceptionState& exceptionState) const
{
- if (!root || !root->isShadowRoot()) {
- exceptionState.throwDOMException(InvalidAccessError, "The node provided is not a valid shadow root.");
+ ASSERT(root);
+ if (!root->isShadowRoot()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The node provided is not a shadow root.");
return String();
}
}
}
-const AtomicString& Internals::shadowPseudoId(Element* element, ExceptionState& exceptionState)
+const AtomicString& Internals::shadowPseudoId(Element* element)
{
- if (!element) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Element"));
- return nullAtom;
- }
-
+ ASSERT(element);
return element->shadowPseudoId();
}
-void Internals::setShadowPseudoId(Element* element, const AtomicString& id, ExceptionState& exceptionState)
-{
- if (!element) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Element"));
- return;
- }
-
- return element->setShadowPseudoId(id);
-}
-
String Internals::visiblePlaceholder(Element* element)
{
if (element && isHTMLTextFormControlElement(*element)) {
toHTMLInputElement(*element).selectColorInColorChooser(color);
}
+void Internals::endColorChooser(Element* element)
+{
+ ASSERT(element);
+ if (!isHTMLInputElement(*element))
+ return;
+ toHTMLInputElement(*element).endColorChooser();
+}
+
bool Internals::hasAutofocusRequest(Document* document)
{
if (!document)
exceptionState.throwDOMException(InvalidAccessError, "No history item is available.");
return;
}
+ mainItem->clearDocumentState();
mainItem->setDocumentState(state);
}
return;
}
if (!s_pagePopupDriver)
- s_pagePopupDriver = MockPagePopupDriver::create(page->mainFrame()).leakPtr();
+ s_pagePopupDriver = MockPagePopupDriver::create(page->deprecatedLocalMainFrame()).leakPtr();
page->chrome().client().setPagePopupDriver(s_pagePopupDriver);
}
return s_pagePopupDriver ? s_pagePopupDriver->pagePopupController() : 0;
}
-PassRefPtr<ClientRect> Internals::unscaledViewportRect(ExceptionState& exceptionState)
+LocalDOMWindow* Internals::pagePopupWindow() const
{
Document* document = contextDocument();
- if (!document || !document->view()) {
- exceptionState.throwDOMException(InvalidAccessError, document ? "The document's viewport cannot be retrieved." : "No context document can be obtained.");
- return ClientRect::create();
- }
-
- return ClientRect::create(document->view()->visibleContentRect());
+ if (!document)
+ return nullptr;
+ Page* page = document->page();
+ if (!page)
+ return nullptr;
+ PagePopupDriver* pagePopupDriver = page->chrome().client().pagePopupDriver();
+ if (!pagePopupDriver)
+ return nullptr;
+ return pagePopupDriver->pagePopupWindow();
}
-PassRefPtr<ClientRect> Internals::absoluteCaretBounds(ExceptionState& exceptionState)
+PassRefPtrWillBeRawPtr<ClientRect> Internals::absoluteCaretBounds(ExceptionState& exceptionState)
{
Document* document = contextDocument();
if (!document || !document->frame()) {
return ClientRect::create(document->frame()->selection().absoluteCaretBounds());
}
-PassRefPtr<ClientRect> Internals::boundingBox(Element* element, ExceptionState& exceptionState)
+PassRefPtrWillBeRawPtr<ClientRect> Internals::boundingBox(Element* element)
{
- if (!element) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Element"));
- return ClientRect::create();
- }
+ ASSERT(element);
element->document().updateLayoutIgnorePendingStylesheets();
RenderObject* renderer = element->renderer();
return ClientRect::create(renderer->absoluteBoundingBoxRectIgnoringTransforms());
}
-PassRefPtr<ClientRectList> Internals::inspectorHighlightRects(Document* document, ExceptionState& exceptionState)
-{
- if (!document || !document->page()) {
- exceptionState.throwDOMException(InvalidAccessError, document ? "The document's Page cannot be retrieved." : "No context document can be obtained.");
- return ClientRectList::create();
- }
-
- Highlight highlight;
- document->page()->inspectorController().getHighlight(&highlight);
- return ClientRectList::create(highlight.quads);
-}
-
unsigned Internals::markerCountForNode(Node* node, const String& markerType, ExceptionState& exceptionState)
{
- if (!node) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Node"));
- return 0;
- }
-
+ ASSERT(node);
DocumentMarker::MarkerTypes markerTypes = 0;
if (!markerTypesFrom(markerType, markerTypes)) {
exceptionState.throwDOMException(SyntaxError, "The marker type provided ('" + markerType + "') is invalid.");
return node->document().markers().markersFor(node, markerTypes).size();
}
-unsigned Internals::activeMarkerCountForNode(Node* node, ExceptionState& exceptionState)
+unsigned Internals::activeMarkerCountForNode(Node* node)
{
- if (!node) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Node"));
- return 0;
- }
+ ASSERT(node);
// Only TextMatch markers can be active.
DocumentMarker::MarkerType markerType = DocumentMarker::TextMatch;
- Vector<DocumentMarker*> markers = node->document().markers().markersFor(node, markerType);
+ DocumentMarkerVector markers = node->document().markers().markersFor(node, markerType);
unsigned activeMarkerCount = 0;
- for (Vector<DocumentMarker*>::iterator iter = markers.begin(); iter != markers.end(); ++iter) {
+ for (DocumentMarkerVector::iterator iter = markers.begin(); iter != markers.end(); ++iter) {
if ((*iter)->activeMatch())
activeMarkerCount++;
}
DocumentMarker* Internals::markerAt(Node* node, const String& markerType, unsigned index, ExceptionState& exceptionState)
{
- if (!node) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Node"));
- return 0;
- }
-
+ ASSERT(node);
DocumentMarker::MarkerTypes markerTypes = 0;
if (!markerTypesFrom(markerType, markerTypes)) {
exceptionState.throwDOMException(SyntaxError, "The marker type provided ('" + markerType + "') is invalid.");
return 0;
}
- Vector<DocumentMarker*> markers = node->document().markers().markersFor(node, markerTypes);
+ DocumentMarkerVector markers = node->document().markers().markersFor(node, markerTypes);
if (markers.size() <= index)
return 0;
return markers[index];
}
-PassRefPtr<Range> Internals::markerRangeForNode(Node* node, const String& markerType, unsigned index, ExceptionState& exceptionState)
+PassRefPtrWillBeRawPtr<Range> Internals::markerRangeForNode(Node* node, const String& markerType, unsigned index, ExceptionState& exceptionState)
{
+ ASSERT(node);
DocumentMarker* marker = markerAt(node, markerType, index, exceptionState);
if (!marker)
return nullptr;
void Internals::addTextMatchMarker(const Range* range, bool isActive)
{
+ ASSERT(range);
range->ownerDocument().updateLayoutIgnorePendingStylesheets();
range->ownerDocument().markers().addTextMatchMarker(range, isActive);
}
-void Internals::setMarkersActive(Node* node, unsigned startOffset, unsigned endOffset, bool active, ExceptionState& exceptionState)
+void Internals::setMarkersActive(Node* node, unsigned startOffset, unsigned endOffset, bool active)
{
- if (!node) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Node"));
- return;
- }
-
+ ASSERT(node);
node->document().markers().setMarkersActive(node, startOffset, endOffset, active);
}
-void Internals::setMarkedTextMatchesAreHighlighted(Document* document, bool highlight, ExceptionState&)
+void Internals::setMarkedTextMatchesAreHighlighted(Document* document, bool highlight)
{
if (!document || !document->frame())
return;
document->frame()->editor().setMarkedTextMatchesAreHighlighted(highlight);
}
-void Internals::setScrollViewPosition(Document* document, long x, long y, ExceptionState& exceptionState)
+void Internals::setFrameViewPosition(Document* document, long x, long y, ExceptionState& exceptionState)
{
- if (!document || !document->view()) {
- exceptionState.throwDOMException(InvalidAccessError, document ? "The document's view cannot be retrieved." : "The document provided is invalid.");
+ ASSERT(document);
+ if (!document->view()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The document provided is invalid.");
return;
}
String Internals::viewportAsText(Document* document, float, int availableWidth, int availableHeight, ExceptionState& exceptionState)
{
- if (!document || !document->page()) {
- exceptionState.throwDOMException(InvalidAccessError, document ? "The document's page cannot be retrieved." : "The document provided is invalid.");
+ ASSERT(document);
+ if (!document->page()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The document provided is invalid.");
return String();
}
// Update initial viewport size.
IntSize initialViewportSize(availableWidth, availableHeight);
- document->page()->mainFrame()->view()->setFrameRect(IntRect(IntPoint::zero(), initialViewportSize));
+ document->page()->deprecatedLocalMainFrame()->view()->setFrameRect(IntRect(IntPoint::zero(), initialViewportSize));
ViewportDescription description = page->viewportDescription();
- PageScaleConstraints constraints = description.resolve(initialViewportSize);
+ PageScaleConstraints constraints = description.resolve(initialViewportSize, Length());
constraints.fitToContentsWidth(constraints.layoutSize.width(), availableWidth);
bool Internals::wasLastChangeUserEdit(Element* textField, ExceptionState& exceptionState)
{
- if (!textField) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Element"));
- return false;
- }
-
+ ASSERT(textField);
if (isHTMLInputElement(*textField))
return toHTMLInputElement(*textField).lastChangeWasUserEdit();
bool Internals::elementShouldAutoComplete(Element* element, ExceptionState& exceptionState)
{
- if (!element) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Element"));
- return false;
- }
-
+ ASSERT(element);
if (isHTMLInputElement(*element))
return toHTMLInputElement(*element).shouldAutocomplete();
String Internals::suggestedValue(Element* element, ExceptionState& exceptionState)
{
- if (!element) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Element"));
- return String();
- }
-
+ ASSERT(element);
if (!element->isFormControlElement()) {
exceptionState.throwDOMException(InvalidNodeTypeError, "The element provided is not a form control element.");
return String();
void Internals::setSuggestedValue(Element* element, const String& value, ExceptionState& exceptionState)
{
- if (!element) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Element"));
- return;
- }
-
+ ASSERT(element);
if (!element->isFormControlElement()) {
exceptionState.throwDOMException(InvalidNodeTypeError, "The element provided is not a form control element.");
return;
void Internals::setEditingValue(Element* element, const String& value, ExceptionState& exceptionState)
{
- if (!element) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Element"));
- return;
- }
-
+ ASSERT(element);
if (!isHTMLInputElement(*element)) {
exceptionState.throwDOMException(InvalidNodeTypeError, "The element provided is not an INPUT.");
return;
void Internals::setAutofilled(Element* element, bool enabled, ExceptionState& exceptionState)
{
+ ASSERT(element);
if (!element->isFormControlElement()) {
exceptionState.throwDOMException(InvalidNodeTypeError, "The element provided is not a form control element.");
return;
void Internals::scrollElementToRect(Element* element, long x, long y, long w, long h, ExceptionState& exceptionState)
{
- if (!element || !element->document().view()) {
+ ASSERT(element);
+ if (!element->document().view()) {
exceptionState.throwDOMException(InvalidNodeTypeError, element ? "No view can be obtained from the provided element's document." : ExceptionMessages::argumentNullOrIncorrectType(1, "Element"));
return;
}
frameView->scrollElementToRect(element, IntRect(x, y, w, h));
}
-PassRefPtr<Range> Internals::rangeFromLocationAndLength(Element* scope, int rangeLocation, int rangeLength, ExceptionState& exceptionState)
+PassRefPtrWillBeRawPtr<Range> Internals::rangeFromLocationAndLength(Element* scope, int rangeLocation, int rangeLength)
{
- if (!scope) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Element"));
- return nullptr;
- }
+ ASSERT(scope);
// TextIterator depends on Layout information, make sure layout it up to date.
scope->document().updateLayoutIgnorePendingStylesheets();
return PlainTextRange(rangeLocation, rangeLocation + rangeLength).createRange(*scope);
}
-unsigned Internals::locationFromRange(Element* scope, const Range* range, ExceptionState& exceptionState)
+unsigned Internals::locationFromRange(Element* scope, const Range* range)
{
- if (!scope || !range) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(scope ? 2 : 1, scope ? "Range" : "Element"));
- return 0;
- }
-
+ ASSERT(scope && range);
// PlainTextRange depends on Layout information, make sure layout it up to date.
scope->document().updateLayoutIgnorePendingStylesheets();
return PlainTextRange::create(*scope, *range).start();
}
-unsigned Internals::lengthFromRange(Element* scope, const Range* range, ExceptionState& exceptionState)
+unsigned Internals::lengthFromRange(Element* scope, const Range* range)
{
- if (!scope || !range) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(scope ? 2 : 1, scope ? "Range" : "Element"));
- return 0;
- }
-
+ ASSERT(scope && range);
// PlainTextRange depends on Layout information, make sure layout it up to date.
scope->document().updateLayoutIgnorePendingStylesheets();
return PlainTextRange::create(*scope, *range).length();
}
-String Internals::rangeAsText(const Range* range, ExceptionState& exceptionState)
+String Internals::rangeAsText(const Range* range)
{
- if (!range) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Range"));
- return String();
- }
-
+ ASSERT(range);
return range->text();
}
-PassRefPtrWillBeRawPtr<DOMPoint> Internals::touchPositionAdjustedToBestClickableNode(long x, long y, long width, long height, Document* document, ExceptionState& exceptionState)
+// FIXME: The next four functions are very similar - combine them once
+// bestClickableNode/bestContextMenuNode have been combined..
+
+DOMPoint* Internals::touchPositionAdjustedToBestClickableNode(long x, long y, long width, long height, Document* document, ExceptionState& exceptionState)
{
- if (!document || !document->frame()) {
- exceptionState.throwDOMException(InvalidAccessError, document ? "The document's frame cannot be retrieved." : "The document provided is invalid.");
- return nullptr;
+ ASSERT(document);
+ if (!document->frame()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The document provided is invalid.");
+ return 0;
}
document->updateLayout();
IntSize radius(width / 2, height / 2);
IntPoint point(x + radius.width(), y + radius.height());
- Node* targetNode;
+ EventHandler& eventHandler = document->frame()->eventHandler();
+ IntPoint hitTestPoint = document->frame()->view()->windowToContents(point);
+ HitTestResult result = eventHandler.hitTestResultAtPoint(hitTestPoint, HitTestRequest::ReadOnly | HitTestRequest::Active, radius);
+
+ Node* targetNode = 0;
IntPoint adjustedPoint;
- bool foundNode = document->frame()->eventHandler().bestClickableNodeForTouchPoint(point, radius, adjustedPoint, targetNode);
+ bool foundNode = eventHandler.bestClickableNodeForHitTestResult(result, adjustedPoint, targetNode);
if (foundNode)
return DOMPoint::create(adjustedPoint.x(), adjustedPoint.y());
- return nullptr;
+ return 0;
}
Node* Internals::touchNodeAdjustedToBestClickableNode(long x, long y, long width, long height, Document* document, ExceptionState& exceptionState)
{
- if (!document || !document->frame()) {
- exceptionState.throwDOMException(InvalidAccessError, document ? "The document's frame cannot be retrieved." : "The document provided is invalid.");
+ ASSERT(document);
+ if (!document->frame()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The document provided is invalid.");
return 0;
}
IntSize radius(width / 2, height / 2);
IntPoint point(x + radius.width(), y + radius.height());
- Node* targetNode;
+ EventHandler& eventHandler = document->frame()->eventHandler();
+ IntPoint hitTestPoint = document->frame()->view()->windowToContents(point);
+ HitTestResult result = eventHandler.hitTestResultAtPoint(hitTestPoint, HitTestRequest::ReadOnly | HitTestRequest::Active, radius);
+
+ Node* targetNode = 0;
IntPoint adjustedPoint;
- document->frame()->eventHandler().bestClickableNodeForTouchPoint(point, radius, adjustedPoint, targetNode);
+ document->frame()->eventHandler().bestClickableNodeForHitTestResult(result, adjustedPoint, targetNode);
return targetNode;
}
-PassRefPtrWillBeRawPtr<DOMPoint> Internals::touchPositionAdjustedToBestContextMenuNode(long x, long y, long width, long height, Document* document, ExceptionState& exceptionState)
+DOMPoint* Internals::touchPositionAdjustedToBestContextMenuNode(long x, long y, long width, long height, Document* document, ExceptionState& exceptionState)
{
- if (!document || !document->frame()) {
- exceptionState.throwDOMException(InvalidAccessError, document ? "The document's frame cannot be retrieved." : "The document provided is invalid.");
- return nullptr;
+ ASSERT(document);
+ if (!document->frame()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The document provided is invalid.");
+ return 0;
}
document->updateLayout();
IntSize radius(width / 2, height / 2);
IntPoint point(x + radius.width(), y + radius.height());
+ EventHandler& eventHandler = document->frame()->eventHandler();
+ IntPoint hitTestPoint = document->frame()->view()->windowToContents(point);
+ HitTestResult result = eventHandler.hitTestResultAtPoint(hitTestPoint, HitTestRequest::ReadOnly | HitTestRequest::Active, radius);
+
Node* targetNode = 0;
IntPoint adjustedPoint;
- bool foundNode = document->frame()->eventHandler().bestContextMenuNodeForTouchPoint(point, radius, adjustedPoint, targetNode);
+ bool foundNode = eventHandler.bestContextMenuNodeForHitTestResult(result, adjustedPoint, targetNode);
if (foundNode)
return DOMPoint::create(adjustedPoint.x(), adjustedPoint.y());
Node* Internals::touchNodeAdjustedToBestContextMenuNode(long x, long y, long width, long height, Document* document, ExceptionState& exceptionState)
{
- if (!document || !document->frame()) {
- exceptionState.throwDOMException(InvalidAccessError, document ? "The document's frame cannot be retrieved." : "The document provided is invalid.");
+ ASSERT(document);
+ if (!document->frame()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The document provided is invalid.");
return 0;
}
IntSize radius(width / 2, height / 2);
IntPoint point(x + radius.width(), y + radius.height());
+ EventHandler& eventHandler = document->frame()->eventHandler();
+ IntPoint hitTestPoint = document->frame()->view()->windowToContents(point);
+ HitTestResult result = eventHandler.hitTestResultAtPoint(hitTestPoint, HitTestRequest::ReadOnly | HitTestRequest::Active, radius);
+
Node* targetNode = 0;
IntPoint adjustedPoint;
- document->frame()->eventHandler().bestContextMenuNodeForTouchPoint(point, radius, adjustedPoint, targetNode);
+ eventHandler.bestContextMenuNodeForHitTestResult(result, adjustedPoint, targetNode);
return targetNode;
}
-PassRefPtr<ClientRect> Internals::bestZoomableAreaForTouchPoint(long x, long y, long width, long height, Document* document, ExceptionState& exceptionState)
+PassRefPtrWillBeRawPtr<ClientRect> Internals::bestZoomableAreaForTouchPoint(long x, long y, long width, long height, Document* document, ExceptionState& exceptionState)
{
- if (!document || !document->frame()) {
- exceptionState.throwDOMException(InvalidAccessError, document ? "The document's frame cannot be retrieved." : "The document provided is invalid.");
+ ASSERT(document);
+ if (!document->frame()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The document provided is invalid.");
return nullptr;
}
IntSize radius(width / 2, height / 2);
IntPoint point(x + radius.width(), y + radius.height());
- Node* targetNode;
+ Node* targetNode = 0;
IntRect zoomableArea;
bool foundNode = document->frame()->eventHandler().bestZoomableAreaForTouchPoint(point, radius, zoomableArea, targetNode);
if (foundNode)
Vector<AtomicString> Internals::userPreferredLanguages() const
{
- return WebCore::userPreferredLanguages();
+ return blink::userPreferredLanguages();
}
// Optimally, the bindings generator would pass a Vector<AtomicString> here but
Vector<AtomicString> atomicLanguages;
for (size_t i = 0; i < languages.size(); ++i)
atomicLanguages.append(AtomicString(languages[i]));
- WebCore::overrideUserPreferredLanguages(atomicLanguages);
+ blink::overrideUserPreferredLanguages(atomicLanguages);
}
-unsigned Internals::activeDOMObjectCount(Document* document, ExceptionState& exceptionState)
+unsigned Internals::activeDOMObjectCount(Document* document)
{
- if (!document) {
- exceptionState.throwDOMException(InvalidAccessError, "No context document is available.");
- return 0;
- }
-
+ ASSERT(document);
return document->activeDOMObjectCount();
}
-unsigned Internals::wheelEventHandlerCount(Document* document, ExceptionState& exceptionState)
+static unsigned eventHandlerCount(Document& document, EventHandlerRegistry::EventHandlerClass handlerClass)
{
- if (!document) {
- exceptionState.throwDOMException(InvalidAccessError, "No context document is available.");
+ if (!document.frameHost())
return 0;
+ EventHandlerRegistry* registry = &document.frameHost()->eventHandlerRegistry();
+ unsigned count = 0;
+ const EventTargetSet* targets = registry->eventHandlerTargets(handlerClass);
+ if (targets) {
+ for (EventTargetSet::const_iterator iter = targets->begin(); iter != targets->end(); ++iter)
+ count += iter->value;
}
-
- return WheelController::from(*document)->wheelEventHandlerCount();
+ return count;
}
-unsigned Internals::touchEventHandlerCount(Document* document, ExceptionState& exceptionState)
+unsigned Internals::wheelEventHandlerCount(Document* document)
{
- if (!document) {
- exceptionState.throwDOMException(InvalidAccessError, "No context document is available.");
- return 0;
- }
+ ASSERT(document);
+ return eventHandlerCount(*document, EventHandlerRegistry::WheelEvent);
+}
- const TouchEventTargetSet* touchHandlers = document->touchEventTargets();
- if (!touchHandlers)
- return 0;
+unsigned Internals::scrollEventHandlerCount(Document* document)
+{
+ ASSERT(document);
+ return eventHandlerCount(*document, EventHandlerRegistry::ScrollEvent);
+}
- unsigned count = 0;
- for (TouchEventTargetSet::const_iterator iter = touchHandlers->begin(); iter != touchHandlers->end(); ++iter)
- count += iter->value;
- return count;
+unsigned Internals::touchEventHandlerCount(Document* document)
+{
+ ASSERT(document);
+ return eventHandlerCount(*document, EventHandlerRegistry::TouchEvent);
}
-static RenderLayer* findRenderLayerForGraphicsLayer(RenderLayer* searchRoot, GraphicsLayer* graphicsLayer, String* layerType)
+static RenderLayer* findRenderLayerForGraphicsLayer(RenderLayer* searchRoot, GraphicsLayer* graphicsLayer, IntSize* layerOffset, String* layerType)
{
- if (searchRoot->hasCompositedLayerMapping() && graphicsLayer == searchRoot->compositedLayerMapping()->mainGraphicsLayer())
+ *layerOffset = IntSize();
+ if (searchRoot->hasCompositedLayerMapping() && graphicsLayer == searchRoot->compositedLayerMapping()->mainGraphicsLayer()) {
+ LayoutRect rect;
+ RenderLayer::mapRectToPaintBackingCoordinates(searchRoot->renderer(), rect);
+ *layerOffset = IntSize(rect.x(), rect.y());
return searchRoot;
+ }
GraphicsLayer* layerForScrolling = searchRoot->scrollableArea() ? searchRoot->scrollableArea()->layerForScrolling() : 0;
if (graphicsLayer == layerForScrolling) {
return searchRoot;
}
- GraphicsLayer* layerForHorizontalScrollbar = searchRoot->scrollableArea() ? searchRoot->scrollableArea()->layerForHorizontalScrollbar() : 0;
+ if (searchRoot->compositingState() == PaintsIntoGroupedBacking) {
+ GraphicsLayer* squashingLayer = searchRoot->groupedMapping()->squashingLayer();
+ if (graphicsLayer == squashingLayer) {
+ *layerType ="squashing";
+ LayoutRect rect;
+ RenderLayer::mapRectToPaintBackingCoordinates(searchRoot->renderer(), rect);
+ *layerOffset = IntSize(rect.x(), rect.y());
+ return searchRoot;
+ }
+ }
+
+ GraphicsLayer* layerForHorizontalScrollbar = searchRoot->scrollableArea() ? searchRoot->scrollableArea()->layerForHorizontalScrollbar() : 0;
if (graphicsLayer == layerForHorizontalScrollbar) {
*layerType = "horizontalScrollbar";
return searchRoot;
return searchRoot;
}
- for (RenderLayer* child = searchRoot->firstChild(); child; child = child->nextSibling()) {
- RenderLayer* foundLayer = findRenderLayerForGraphicsLayer(child, graphicsLayer, layerType);
+ // Search right to left to increase the chances that we'll choose the top-most layers in a
+ // grouped mapping for squashing.
+ for (RenderLayer* child = searchRoot->lastChild(); child; child = child->previousSibling()) {
+ RenderLayer* foundLayer = findRenderLayerForGraphicsLayer(child, graphicsLayer, layerOffset, layerType);
if (foundLayer)
return foundLayer;
}
if (!layerRects.isEmpty()) {
mergeRects(layerRects);
String layerType;
- RenderLayer* renderLayer = findRenderLayerForGraphicsLayer(compositor->rootRenderLayer(), graphicsLayer, &layerType);
+ IntSize layerOffset;
+ RenderLayer* renderLayer = findRenderLayerForGraphicsLayer(compositor->rootRenderLayer(), graphicsLayer, &layerOffset, &layerType);
Node* node = renderLayer ? renderLayer->renderer()->node() : 0;
for (size_t i = 0; i < layerRects.size(); ++i) {
- if (!layerRects[i].isEmpty())
- rects->append(node, layerType, ClientRect::create(layerRects[i]));
+ if (!layerRects[i].isEmpty()) {
+ rects->append(node, layerType, layerOffset.width(), layerOffset.height(), ClientRect::create(layerRects[i]));
+ }
}
}
accumulateLayerRectList(compositor, graphicsLayer->children()[i], rects);
}
-PassRefPtrWillBeRawPtr<LayerRectList> Internals::touchEventTargetLayerRects(Document* document, ExceptionState& exceptionState)
+LayerRectList* Internals::touchEventTargetLayerRects(Document* document, ExceptionState& exceptionState)
{
- if (!document || !document->view() || !document->page() || document != contextDocument()) {
+ ASSERT(document);
+ if (!document->view() || !document->page() || document != contextDocument()) {
exceptionState.throwDOMException(InvalidAccessError, "The document provided is invalid.");
return nullptr;
}
if (RenderView* view = document->renderView()) {
if (RenderLayerCompositor* compositor = view->compositor()) {
if (GraphicsLayer* rootLayer = compositor->rootGraphicsLayer()) {
- RefPtrWillBeRawPtr<LayerRectList> rects = LayerRectList::create();
- accumulateLayerRectList(compositor, rootLayer, rects.get());
+ LayerRectList* rects = LayerRectList::create();
+ accumulateLayerRectList(compositor, rootLayer, rects);
return rects;
}
}
return nullptr;
}
-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& exceptionState) const
+PassRefPtrWillBeRawPtr<StaticNodeList> Internals::nodesFromRect(Document* document, int centerX, int centerY, unsigned topPadding, unsigned rightPadding,
+ unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allowChildFrameContent, ExceptionState& exceptionState) const
{
- if (!document || !document->frame() || !document->frame()->view()) {
+ ASSERT(document);
+ if (!document->frame() || !document->frame()->view()) {
exceptionState.throwDOMException(InvalidAccessError, "No view can be obtained from the provided document.");
return nullptr;
}
HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active;
if (ignoreClipping)
hitType |= HitTestRequest::IgnoreClipping;
- if (!allowShadowContent)
- hitType |= HitTestRequest::ConfusingAndOftenMisusedDisallowShadowContent;
if (allowChildFrameContent)
hitType |= HitTestRequest::AllowChildFrameContent;
if (!request.ignoreClipping() && !frameView->visibleContentRect().intersects(HitTestLocation::rectForPoint(point, topPadding, rightPadding, bottomPadding, leftPadding)))
return nullptr;
- Vector<RefPtr<Node> > matches;
+ WillBeHeapVector<RefPtrWillBeMember<Node> > matches;
// Need padding to trigger a rect based hit test, but we want to return a NodeList
// so we special case this.
if (!topPadding && !rightPadding && !bottomPadding && !leftPadding) {
HitTestResult result(point);
renderView->hitTest(request, result);
- if (result.innerNode())
- matches.append(result.innerNode()->deprecatedShadowAncestorNode());
+
+ if (Node* innerNode = result.innerNode()) {
+ if (innerNode->isInShadowTree())
+ innerNode = innerNode->shadowHost();
+ matches.append(innerNode);
+ }
} else {
HitTestResult result(point, topPadding, rightPadding, bottomPadding, leftPadding);
renderView->hitTest(request, result);
return StaticNodeList::adopt(matches);
}
-void Internals::emitInspectorDidBeginFrame(int frameId)
+bool Internals::hasSpellingMarker(Document* document, int from, int length)
{
- contextDocument()->page()->inspectorController().didBeginFrame(frameId);
-}
-
-void Internals::emitInspectorDidCancelFrame()
-{
- contextDocument()->page()->inspectorController().didCancelFrame();
-}
-
-bool Internals::hasSpellingMarker(Document* document, int from, int length, ExceptionState&)
-{
- if (!document || !document->frame())
+ ASSERT(document);
+ if (!document->frame())
return 0;
return document->frame()->spellChecker().selectionStartHasMarkerFor(DocumentMarker::Spelling, from, length);
}
-void Internals::setContinuousSpellCheckingEnabled(bool enabled, ExceptionState&)
+void Internals::setContinuousSpellCheckingEnabled(bool enabled)
{
if (!contextDocument() || !contextDocument()->frame())
return;
contextDocument()->frame()->spellChecker().toggleContinuousSpellChecking();
}
-bool Internals::isOverwriteModeEnabled(Document* document, ExceptionState&)
+bool Internals::isOverwriteModeEnabled(Document* document)
{
- if (!document || !document->frame())
+ ASSERT(document);
+ if (!document->frame())
return 0;
return document->frame()->editor().isOverwriteModeEnabled();
}
-void Internals::toggleOverwriteModeEnabled(Document* document, ExceptionState&)
+void Internals::toggleOverwriteModeEnabled(Document* document)
{
- if (!document || !document->frame())
+ ASSERT(document);
+ if (!document->frame())
return;
document->frame()->editor().toggleOverwriteModeEnabled();
Vector<String> Internals::consoleMessageArgumentCounts(Document* document) const
{
- InstrumentingAgents* instrumentingAgents = instrumentationForPage(document->page());
- if (!instrumentingAgents)
+ FrameHost* host = document->frameHost();
+ if (!host)
return Vector<String>();
- InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent();
- if (!consoleAgent)
- return Vector<String>();
- Vector<unsigned> counts = consoleAgent->consoleMessageArgumentCounts();
+
+ Vector<unsigned> counts = host->consoleMessageStorage().argumentCounts();
Vector<String> result(counts.size());
for (size_t i = 0; i < counts.size(); i++)
result[i] = String::number(counts[i]);
return result;
}
-PassRefPtrWillBeRawPtr<DOMWindow> Internals::openDummyInspectorFrontend(const String& url)
-{
- Page* page = contextDocument()->frame()->page();
- ASSERT(page);
-
- DOMWindow* window = page->mainFrame()->domWindow();
- ASSERT(window);
-
- m_frontendWindow = window->open(url, "", "", window, window);
- ASSERT(m_frontendWindow);
-
- Page* frontendPage = m_frontendWindow->document()->page();
- ASSERT(frontendPage);
-
- OwnPtr<InspectorFrontendClientLocal> frontendClient = adoptPtr(new InspectorFrontendClientLocal(page->inspectorController(), frontendPage));
-
- frontendPage->inspectorController().setInspectorFrontendClient(frontendClient.release());
-
- m_frontendChannel = adoptPtr(new InspectorFrontendChannelDummy(frontendPage));
-
- page->inspectorController().connectFrontend(m_frontendChannel.get());
-
- return m_frontendWindow;
-}
-
-void Internals::closeDummyInspectorFrontend()
-{
- Page* page = contextDocument()->frame()->page();
- ASSERT(page);
- ASSERT(m_frontendWindow);
-
- page->inspectorController().disconnectFrontend();
-
- m_frontendChannel.release();
-
- m_frontendWindow->close(m_frontendWindow->executionContext());
- m_frontendWindow.release();
-}
-
Vector<unsigned long> Internals::setMemoryCacheCapacities(unsigned long minDeadBytes, unsigned long maxDeadBytes, unsigned long totalBytes)
{
Vector<unsigned long> result;
page->inspectorController().setResourcesDataSizeLimitsFromInternals(maximumResourcesContentSize, maximumSingleResourceContentSize);
}
-bool Internals::hasGrammarMarker(Document* document, int from, int length, ExceptionState&)
+String Internals::inspectorHighlightJSON(Node* node, ExceptionState& exceptionState)
{
- if (!document || !document->frame())
+ Page* page = contextDocument()->frame()->page();
+ if (!page) {
+ exceptionState.throwDOMException(InvalidAccessError, "No page can be obtained from the current context document.");
+ return String();
+ }
+ RefPtr<JSONObject> json(page->inspectorController().highlightJSONForNode(node));
+ return json->toPrettyJSONString();
+}
+
+bool Internals::hasGrammarMarker(Document* document, int from, int length)
+{
+ ASSERT(document);
+ if (!document->frame())
return 0;
return document->frame()->spellChecker().selectionStartHasMarkerFor(DocumentMarker::Grammar, from, length);
}
-unsigned Internals::numberOfScrollableAreas(Document* document, ExceptionState&)
+unsigned Internals::numberOfScrollableAreas(Document* document)
{
+ ASSERT(document);
+ if (!document->frame())
+ return 0;
+
unsigned count = 0;
LocalFrame* frame = document->frame();
if (frame->view()->scrollableAreas())
count += frame->view()->scrollableAreas()->size();
- for (LocalFrame* child = frame->tree().firstChild(); child; child = child->tree().nextSibling()) {
- if (child->view() && child->view()->scrollableAreas())
- count += child->view()->scrollableAreas()->size();
+ for (Frame* child = frame->tree().firstChild(); child; child = child->tree().nextSibling()) {
+ if (child->isLocalFrame() && toLocalFrame(child)->view() && toLocalFrame(child)->view()->scrollableAreas())
+ count += toLocalFrame(child)->view()->scrollableAreas()->size();
}
return count;
}
-bool Internals::isPageBoxVisible(Document* document, int pageNumber, ExceptionState& exceptionState)
+bool Internals::isPageBoxVisible(Document* document, int pageNumber)
{
- if (!document) {
- exceptionState.throwDOMException(InvalidAccessError, "No context document is available.");
- return false;
- }
-
+ ASSERT(document);
return document->isPageBoxVisible(pageNumber);
}
String Internals::elementLayerTreeAsText(Element* element, ExceptionState& exceptionState) const
{
+ ASSERT(element);
FrameView* frameView = element->document().view();
frameView->updateLayoutAndStyleForPainting();
return elementLayerTreeAsText(element, 0, exceptionState);
}
-static PassRefPtr<NodeList> paintOrderList(Element* element, ExceptionState& exceptionState, RenderLayerStackingNode::PaintOrderListType type)
-{
- if (!element) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Element"));
- return nullptr;
- }
-
- element->document().updateLayout();
-
- RenderObject* renderer = element->renderer();
- if (!renderer || !renderer->isBox()) {
- exceptionState.throwDOMException(InvalidAccessError, renderer ? "The provided element's renderer is not a box." : "The provided element has no renderer.");
- return nullptr;
- }
-
- RenderLayer* layer = toRenderBox(renderer)->layer();
- if (!layer) {
- exceptionState.throwDOMException(InvalidAccessError, "No render layer can be obtained from the provided element.");
- return nullptr;
- }
-
- Vector<RefPtr<Node> > nodes;
- layer->stackingNode()->computePaintOrderList(type, nodes);
- return StaticNodeList::adopt(nodes);
-}
-
-PassRefPtr<NodeList> Internals::paintOrderListBeforePromote(Element* element, ExceptionState& exceptionState)
-{
- return paintOrderList(element, exceptionState, RenderLayerStackingNode::BeforePromote);
-}
-
-PassRefPtr<NodeList> Internals::paintOrderListAfterPromote(Element* element, ExceptionState& exceptionState)
-{
- return paintOrderList(element, exceptionState, RenderLayerStackingNode::AfterPromote);
-}
-
bool Internals::scrollsWithRespectTo(Element* element1, Element* element2, ExceptionState& exceptionState)
{
- if (!element1 || !element2) {
- exceptionState.throwDOMException(InvalidAccessError, String::format("The %s element provided is invalid.", element1 ? "second" : "first"));
- return 0;
- }
-
- element1->document().updateLayout();
+ ASSERT(element1 && element2);
+ element1->document().view()->updateLayoutAndStyleForPainting();
RenderObject* renderer1 = element1->renderer();
RenderObject* renderer2 = element2->renderer();
return layer1->scrollsWithRespectTo(layer2);
}
-bool Internals::isUnclippedDescendant(Element* element, ExceptionState& exceptionState)
-{
- if (!element) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Element"));
- return 0;
- }
-
- element->document().updateLayout();
-
- RenderObject* renderer = element->renderer();
- if (!renderer || !renderer->isBox()) {
- exceptionState.throwDOMException(InvalidAccessError, renderer ? "The provided element's renderer is not a box." : "The provided element has no renderer.");
- return 0;
- }
-
- RenderLayer* layer = toRenderBox(renderer)->layer();
- if (!layer) {
- exceptionState.throwDOMException(InvalidAccessError, "No render layer can be obtained from the provided element.");
- return 0;
- }
-
- return layer->isUnclippedDescendant();
-}
-
-bool Internals::needsCompositedScrolling(Element* element, ExceptionState& exceptionState)
-{
- if (!element) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Element"));
- return 0;
- }
-
- element->document().updateLayout();
-
- RenderObject* renderer = element->renderer();
- if (!renderer || !renderer->isBox()) {
- exceptionState.throwDOMException(InvalidAccessError, renderer ? "The provided element's renderer is not a box." : "The provided element has no renderer.");
- return 0;
- }
-
- RenderLayer* layer = toRenderBox(renderer)->layer();
- if (!layer) {
- exceptionState.throwDOMException(InvalidAccessError, "No render layer can be obtained from the provided element.");
- return 0;
- }
-
- return layer->needsCompositedScrolling();
-}
-
String Internals::layerTreeAsText(Document* document, unsigned flags, ExceptionState& exceptionState) const
{
- if (!document || !document->frame()) {
- exceptionState.throwDOMException(InvalidAccessError, document ? "The document's frame cannot be retrieved." : "The document provided is invalid.");
+ ASSERT(document);
+ if (!document->frame()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The document provided is invalid.");
return String();
}
String Internals::elementLayerTreeAsText(Element* element, unsigned flags, ExceptionState& exceptionState) const
{
- if (!element) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Element"));
- return String();
- }
-
+ ASSERT(element);
element->document().updateLayout();
RenderObject* renderer = element->renderer();
return layer->compositedLayerMapping()->mainGraphicsLayer()->layerTreeAsText(flags);
}
-static RenderLayer* getRenderLayerForElement(Element* element, ExceptionState& exceptionState)
-{
- if (!element) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Element"));
- return 0;
- }
-
- RenderObject* renderer = element->renderer();
- if (!renderer || !renderer->isBox()) {
- exceptionState.throwDOMException(InvalidAccessError, renderer ? "The provided element's renderer is not a box." : "The provided element has no renderer.");
- return 0;
- }
-
- RenderLayer* layer = toRenderBox(renderer)->layer();
- if (!layer) {
- exceptionState.throwDOMException(InvalidAccessError, "No render layer can be obtained from the provided element.");
- return 0;
- }
-
- return layer;
-}
-
-void Internals::setNeedsCompositedScrolling(Element* element, unsigned needsCompositedScrolling, ExceptionState& exceptionState)
-{
- if (!element) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Element"));
- return;
- }
-
- element->document().updateLayout();
-
- if (RenderLayer* layer = getRenderLayerForElement(element, exceptionState))
- layer->scrollableArea()->setForceNeedsCompositedScrolling(static_cast<ForceNeedsCompositedScrollingMode>(needsCompositedScrolling));
-}
-
-String Internals::repaintRectsAsText(Document* document, ExceptionState& exceptionState) const
-{
- if (!document || !document->frame()) {
- exceptionState.throwDOMException(InvalidAccessError, document ? "The document's frame cannot be retrieved." : "The document provided is invalid.");
- return String();
- }
-
- return document->frame()->trackedRepaintRectsAsText();
-}
-
-PassRefPtr<ClientRectList> Internals::repaintRects(Element* element, ExceptionState& exceptionState) const
-{
- if (!element) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Element"));
- return nullptr;
- }
-
- 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);
- }
- }
-
- exceptionState.throwDOMException(InvalidAccessError, "The provided element is not composited.");
- return nullptr;
-}
-
-String Internals::scrollingStateTreeAsText(Document* document, ExceptionState& exceptionState) const
+String Internals::scrollingStateTreeAsText(Document*) const
{
return String();
}
String Internals::mainThreadScrollingReasons(Document* document, ExceptionState& exceptionState) const
{
- if (!document || !document->frame()) {
- exceptionState.throwDOMException(InvalidAccessError, document ? "The document's frame cannot be retrieved." : "The document provided is invalid.");
+ ASSERT(document);
+ if (!document->frame()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The document provided is invalid.");
return String();
}
- // Force a re-layout and a compositing update.
- document->updateLayout();
- RenderView* view = document->renderView();
- if (view->compositor())
- view->compositor()->updateCompositingLayers();
+ document->frame()->view()->updateLayoutAndStyleForPainting();
Page* page = document->page();
if (!page)
return page->mainThreadScrollingReasonsAsText();
}
-PassRefPtr<ClientRectList> Internals::nonFastScrollableRects(Document* document, ExceptionState& exceptionState) const
+PassRefPtrWillBeRawPtr<ClientRectList> Internals::nonFastScrollableRects(Document* document, ExceptionState& exceptionState) const
{
- if (!document || !document->frame()) {
- exceptionState.throwDOMException(InvalidAccessError, document ? "The document's frame cannot be retrieved." : "The document provided is invalid.");
+ ASSERT(document);
+ if (!document->frame()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The document provided is invalid.");
return nullptr;
}
return page->nonFastScrollableRects(document->frame());
}
-void Internals::garbageCollectDocumentResources(Document* document, ExceptionState& exceptionState) const
+void Internals::garbageCollectDocumentResources(Document* document) const
{
- if (!document) {
- exceptionState.throwDOMException(InvalidAccessError, "No context document is available.");
- return;
- }
+ ASSERT(document);
ResourceFetcher* fetcher = document->fetcher();
if (!fetcher)
return;
memoryCache()->evictResources();
}
-void Internals::allowRoundingHacks() const
-{
- TextRun::setAllowsRoundingHacks(true);
-}
-
String Internals::counterValue(Element* element)
{
if (!element)
void Internals::setIsCursorVisible(Document* document, bool isVisible, ExceptionState& exceptionState)
{
- if (!document || !document->page()) {
- exceptionState.throwDOMException(InvalidAccessError, document ? "The document's page cannot be retrieved." : "No context document can be obtained.");
+ ASSERT(document);
+ if (!document->page()) {
+ exceptionState.throwDOMException(InvalidAccessError, "No context document can be obtained.");
return;
}
document->page()->setIsCursorVisible(isVisible);
}
-void Internals::webkitWillEnterFullScreenForElement(Document* document, Element* element)
-{
- if (!document)
- return;
- FullscreenElementStack::from(*document).webkitWillEnterFullScreenForElement(element);
-}
-
-void Internals::webkitDidEnterFullScreenForElement(Document* document, Element* element)
+void Internals::mediaPlayerRequestFullscreen(HTMLMediaElement* mediaElement)
{
- if (!document)
- return;
- FullscreenElementStack::from(*document).webkitDidEnterFullScreenForElement(element);
+ mediaElement->mediaPlayerRequestFullscreen();
}
-void Internals::webkitWillExitFullScreenForElement(Document* document, Element* element)
+double Internals::effectiveMediaVolume(HTMLMediaElement* mediaElement)
{
- if (!document)
- return;
- FullscreenElementStack::from(*document).webkitWillExitFullScreenForElement(element);
+ return mediaElement->effectiveMediaVolume();
}
-void Internals::webkitDidExitFullScreenForElement(Document* document, Element* element)
+void Internals::mediaPlayerRemoteRouteAvailabilityChanged(HTMLMediaElement* mediaElement, bool available)
{
- if (!document)
- return;
- FullscreenElementStack::from(*document).webkitDidExitFullScreenForElement(element);
+ mediaElement->remoteRouteAvailabilityChanged(available);
}
-void Internals::mediaPlayerRequestFullscreen(HTMLMediaElement* mediaElement)
+void Internals::mediaPlayerPlayingRemotelyChanged(HTMLMediaElement* mediaElement, bool remote)
{
- mediaElement->mediaPlayerRequestFullscreen();
+ if (remote)
+ mediaElement->connectedToRemoteDevice();
+ else
+ mediaElement->disconnectedFromRemoteDevice();
}
void Internals::registerURLSchemeAsBypassingContentSecurityPolicy(const String& scheme)
SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(scheme);
}
-PassRefPtrWillBeRawPtr<MallocStatistics> Internals::mallocStatistics() const
+TypeConversions* Internals::typeConversions() const
{
- return MallocStatistics::create();
+ return TypeConversions::create();
}
-PassRefPtrWillBeRawPtr<TypeConversions> Internals::typeConversions() const
+PrivateScriptTest* Internals::privateScriptTest() const
{
- return TypeConversions::create();
+ return PrivateScriptTest::create(frame()->document());
+}
+
+DictionaryTest* Internals::dictionaryTest() const
+{
+ return DictionaryTest::create();
+}
+
+UnionTypesTest* Internals::unionTypesTest() const
+{
+ return UnionTypesTest::create();
}
Vector<String> Internals::getReferencedFilePaths() const
{
- frame()->loader().saveDocumentState();
- return FormController::getReferencedFilePaths(frame()->loader().currentItem()->documentState());
+ return frame()->loader().currentItem()->getReferencedFilePaths();
}
void Internals::startTrackingRepaints(Document* document, ExceptionState& exceptionState)
{
- if (!document || !document->view()) {
- exceptionState.throwDOMException(InvalidAccessError, document ? "The document's view cannot be retrieved." : "The document provided is invalid.");
+ ASSERT(document);
+ if (!document->view()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The document provided is invalid.");
return;
}
FrameView* frameView = document->view();
- frameView->setTracksRepaints(true);
+ frameView->updateLayoutAndStyleForPainting();
+ frameView->setTracksPaintInvalidations(true);
}
void Internals::stopTrackingRepaints(Document* document, ExceptionState& exceptionState)
{
- if (!document || !document->view()) {
- exceptionState.throwDOMException(InvalidAccessError, document ? "The document's view cannot be retrieved." : "The document provided is invalid.");
+ ASSERT(document);
+ if (!document->view()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The document provided is invalid.");
return;
}
FrameView* frameView = document->view();
- frameView->setTracksRepaints(false);
+ frameView->updateLayoutAndStyleForPainting();
+ frameView->setTracksPaintInvalidations(false);
}
void Internals::updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(ExceptionState& exceptionState)
document->updateLayoutIgnorePendingStylesheets(Document::RunPostLayoutTasksSynchronously);
}
-PassRefPtr<ClientRectList> Internals::draggableRegions(Document* document, ExceptionState& exceptionState)
+void Internals::forceFullRepaint(Document* document, ExceptionState& exceptionState)
+{
+ ASSERT(document);
+ if (!document->view()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The document provided is invalid.");
+ return;
+ }
+
+ if (RenderView *renderView = document->renderView())
+ renderView->invalidatePaintForViewAndCompositedLayers();
+}
+
+PassRefPtrWillBeRawPtr<ClientRectList> Internals::draggableRegions(Document* document, ExceptionState& exceptionState)
{
return annotatedRegions(document, true, exceptionState);
}
-PassRefPtr<ClientRectList> Internals::nonDraggableRegions(Document* document, ExceptionState& exceptionState)
+PassRefPtrWillBeRawPtr<ClientRectList> Internals::nonDraggableRegions(Document* document, ExceptionState& exceptionState)
{
return annotatedRegions(document, false, exceptionState);
}
-PassRefPtr<ClientRectList> Internals::annotatedRegions(Document* document, bool draggable, ExceptionState& exceptionState)
+PassRefPtrWillBeRawPtr<ClientRectList> Internals::annotatedRegions(Document* document, bool draggable, ExceptionState& exceptionState)
{
- if (!document || !document->view()) {
- exceptionState.throwDOMException(InvalidAccessError, document ? "The document's view cannot be retrieved." : "The document provided is invalid.");
+ ASSERT(document);
+ if (!document->view()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The document provided is invalid.");
return ClientRectList::create();
}
String Internals::getCurrentCursorInfo(Document* document, ExceptionState& exceptionState)
{
- if (!document || !document->frame()) {
- exceptionState.throwDOMException(InvalidAccessError, document ? "The document's frame cannot be retrieved." : "The document provided is invalid.");
+ ASSERT(document);
+ if (!document->frame()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The document provided is invalid.");
return String();
}
Cursor cursor = document->frame()->eventHandler().currentMouseCursor();
StringBuilder result;
- result.append("type=");
+ result.appendLiteral("type=");
result.append(cursorTypeToString(cursor.type()));
- result.append(" hotSpot=");
+ result.appendLiteral(" hotSpot=");
result.appendNumber(cursor.hotSpot().x());
- result.append(",");
+ result.append(',');
result.appendNumber(cursor.hotSpot().y());
if (cursor.image()) {
IntSize size = cursor.image()->size();
- result.append(" image=");
+ result.appendLiteral(" image=");
result.appendNumber(size.width());
- result.append("x");
+ result.append('x');
result.appendNumber(size.height());
}
if (cursor.imageScaleFactor() != 1) {
- result.append(" scale=");
+ result.appendLiteral(" scale=");
NumberToStringBuffer buffer;
result.append(numberToFixedPrecisionString(cursor.imageScaleFactor(), 8, buffer, true));
}
return result.toString();
}
-PassRefPtr<ArrayBuffer> Internals::serializeObject(PassRefPtr<SerializedScriptValue> value) const
+PassRefPtr<DOMArrayBuffer> Internals::serializeObject(PassRefPtr<SerializedScriptValue> value) const
{
String stringValue = value->toWireString();
RefPtr<ArrayBuffer> buffer = ArrayBuffer::createUninitialized(stringValue.length(), sizeof(UChar));
stringValue.copyTo(static_cast<UChar*>(buffer->data()), 0, stringValue.length());
- return buffer.release();
+ return DOMArrayBuffer::create(buffer.release());
}
-PassRefPtr<SerializedScriptValue> Internals::deserializeBuffer(PassRefPtr<ArrayBuffer> buffer) const
+PassRefPtr<SerializedScriptValue> Internals::deserializeBuffer(PassRefPtr<DOMArrayBuffer> buffer) const
{
String value(static_cast<const UChar*>(buffer->data()), buffer->byteLength() / sizeof(UChar));
return SerializedScriptValue::createFromWire(value);
frame()->loader().reload(endToEnd ? EndToEndReload : NormalReload);
}
-PassRefPtr<ClientRect> Internals::selectionBounds(ExceptionState& exceptionState)
+PassRefPtrWillBeRawPtr<ClientRect> Internals::selectionBounds(ExceptionState& exceptionState)
{
Document* document = contextDocument();
if (!document || !document->frame()) {
return ClientRect::create(document->frame()->selection().bounds());
}
-String Internals::markerTextForListItem(Element* element, ExceptionState& exceptionState)
+String Internals::markerTextForListItem(Element* element)
{
- if (!element) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Element"));
- return String();
- }
- return WebCore::markerTextForListItem(element);
+ ASSERT(element);
+ return blink::markerTextForListItem(element);
}
-String Internals::getImageSourceURL(Element* element, ExceptionState& exceptionState)
+String Internals::getImageSourceURL(Element* element)
{
- if (!element) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Element"));
- return String();
- }
+ ASSERT(element);
return element->imageSourceURL();
}
-String Internals::baseURL(Document* document, ExceptionState& exceptionState)
-{
- if (!document) {
- exceptionState.throwDOMException(InvalidAccessError, "No context document is available.");
- return String();
- }
-
- return document->baseURL().string();
-}
-
bool Internals::isSelectPopupVisible(Node* node)
{
ASSERT(node);
HTMLSelectElement& select = toHTMLSelectElement(*node);
RenderObject* renderer = select.renderer();
- if (!renderer->isMenuList())
+ if (!renderer || !renderer->isMenuList())
return false;
RenderMenuList* menuList = toRenderMenuList(renderer);
return menuList->popupIsVisible();
}
+bool Internals::selectPopupItemStyleIsRtl(Node* node, int itemIndex)
+{
+ if (!node || !isHTMLSelectElement(*node))
+ return false;
+
+ HTMLSelectElement& select = toHTMLSelectElement(*node);
+
+ RenderObject* renderer = select.renderer();
+ if (!renderer || !renderer->isMenuList())
+ return false;
+
+ RenderMenuList& menuList = toRenderMenuList(*renderer);
+ PopupMenuStyle itemStyle = menuList.itemStyle(itemIndex);
+ return itemStyle.textDirection() == RTL;
+}
+
+int Internals::selectPopupItemStyleFontHeight(Node* node, int itemIndex)
+{
+ if (!node || !isHTMLSelectElement(*node))
+ return false;
+
+ HTMLSelectElement& select = toHTMLSelectElement(*node);
+
+ RenderObject* renderer = select.renderer();
+ if (!renderer || !renderer->isMenuList())
+ return false;
+
+ RenderMenuList& menuList = toRenderMenuList(*renderer);
+ PopupMenuStyle itemStyle = menuList.itemStyle(itemIndex);
+ return itemStyle.font().fontMetrics().height();
+}
+
bool Internals::loseSharedGraphicsContext3D()
{
OwnPtr<blink::WebGraphicsContext3DProvider> sharedProvider = adoptPtr(blink::Platform::current()->createSharedOffscreenGraphicsContext3DProvider());
void Internals::forceCompositingUpdate(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.");
+ ASSERT(document);
+ if (!document->renderView()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The document provided is invalid.");
return;
}
- document->updateLayout();
-
- RenderView* view = document->renderView();
- if (view->compositor())
- view->compositor()->updateCompositingLayers();
-}
-
-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();
+ document->frame()->view()->updateLayoutAndStyleForPainting();
}
void Internals::setZoomFactor(float factor)
void Internals::setShouldRevealPassword(Element* element, bool reveal, ExceptionState& exceptionState)
{
+ ASSERT(element);
if (!isHTMLInputElement(element)) {
- exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argumentNullOrIncorrectType(1, "Element"));
+ exceptionState.throwDOMException(InvalidNodeTypeError, "The element provided is not an INPUT.");
return;
}
class AddOneFunction : public ScriptFunction {
public:
- static PassOwnPtr<ScriptFunction> create(ExecutionContext* context)
+ static v8::Handle<v8::Function> createFunction(ScriptState* scriptState)
{
- return adoptPtr(new AddOneFunction(toIsolate(context)));
+ AddOneFunction* self = new AddOneFunction(scriptState);
+ return self->bindToV8Function();
}
private:
- AddOneFunction(v8::Isolate* isolate)
- : ScriptFunction(isolate)
+ explicit AddOneFunction(ScriptState* scriptState)
+ : ScriptFunction(scriptState)
{
}
- virtual ScriptValue call(ScriptValue value) OVERRIDE
+ virtual ScriptValue call(ScriptValue value) override
{
v8::Local<v8::Value> v8Value = value.v8Value();
- v8::Isolate* isolate = value.isolate();
ASSERT(v8Value->IsNumber());
int intValue = v8Value.As<v8::Integer>()->Value();
- ScriptValue result = ScriptValue(v8::Integer::New(isolate, intValue + 1), isolate);
- return result;
+ return ScriptValue(scriptState(), v8::Integer::New(scriptState()->isolate(), intValue + 1));
}
};
} // namespace
-ScriptPromise Internals::createPromise(ExecutionContext* context)
-{
- return ScriptPromiseResolver::create(context)->promise();
-}
-
-ScriptPromise Internals::createResolvedPromise(ExecutionContext* context, ScriptValue value)
+ScriptPromise Internals::createResolvedPromise(ScriptState* scriptState, ScriptValue value)
{
- RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(context);
+ RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState);
ScriptPromise promise = resolver->promise();
resolver->resolve(value);
return promise;
}
-ScriptPromise Internals::createRejectedPromise(ExecutionContext* context, ScriptValue value)
+ScriptPromise Internals::createRejectedPromise(ScriptState* scriptState, ScriptValue value)
{
- RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(context);
+ RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState);
ScriptPromise promise = resolver->promise();
resolver->reject(value);
return promise;
}
-ScriptPromise Internals::addOneToPromise(ExecutionContext* context, ScriptPromise promise)
+ScriptPromise Internals::addOneToPromise(ScriptState* scriptState, ScriptPromise promise)
{
- return promise.then(AddOneFunction::create(context));
+ return promise.then(AddOneFunction::createFunction(scriptState));
}
-void Internals::trace(Visitor* visitor)
+ScriptPromise Internals::promiseCheck(ScriptState* scriptState, long arg1, bool arg2, const Dictionary& arg3, const String& arg4, const Vector<String>& arg5, ExceptionState& exceptionState)
{
- visitor->trace(m_frontendWindow);
- visitor->trace(m_runtimeFlags);
- visitor->trace(m_profilers);
+ if (arg2)
+ return ScriptPromise::cast(scriptState, v8String(scriptState->isolate(), "done"));
+ exceptionState.throwDOMException(InvalidStateError, "Thrown from the native implementation.");
+ return ScriptPromise();
}
-void Internals::startSpeechInput(Element* element)
+ScriptPromise Internals::promiseCheckWithoutExceptionState(ScriptState* scriptState, const Dictionary& arg1, const String& arg2, const Vector<String>& arg3)
{
-#if ENABLE(INPUT_SPEECH)
- HTMLInputElement* input = toHTMLInputElement(element);
- if (!input->isSpeechEnabled())
- return;
+ return ScriptPromise::cast(scriptState, v8String(scriptState->isolate(), "done"));
+}
+
+ScriptPromise Internals::promiseCheckRange(ScriptState* scriptState, long arg1)
+{
+ return ScriptPromise::cast(scriptState, v8String(scriptState->isolate(), "done"));
+}
+
+ScriptPromise Internals::promiseCheckOverload(ScriptState* scriptState, Location*)
+{
+ return ScriptPromise::cast(scriptState, v8String(scriptState->isolate(), "done"));
+}
- InputFieldSpeechButtonElement* speechButton = toInputFieldSpeechButtonElement(input->userAgentShadowRoot()->getElementById(ShadowElementNames::speechButton()));
- if (speechButton)
- speechButton->startSpeechInput();
-#endif
+ScriptPromise Internals::promiseCheckOverload(ScriptState* scriptState, Document*)
+{
+ return ScriptPromise::cast(scriptState, v8String(scriptState->isolate(), "done"));
+}
+
+ScriptPromise Internals::promiseCheckOverload(ScriptState* scriptState, Location*, long, long)
+{
+ return ScriptPromise::cast(scriptState, v8String(scriptState->isolate(), "done"));
+}
+
+void Internals::trace(Visitor* visitor)
+{
+ visitor->trace(m_runtimeFlags);
+ visitor->trace(m_profilers);
}
void Internals::setValueForUser(Element* element, const String& value)
if (!node)
return String();
blink::WebPoint point(x, y);
- SurroundingText surroundingText(VisiblePosition(node->renderer()->positionForPoint(static_cast<IntPoint>(point))), maxLength);
+ SurroundingText surroundingText(VisiblePosition(node->renderer()->positionForPoint(static_cast<IntPoint>(point))).deepEquivalent().parentAnchoredEquivalent(), maxLength);
return surroundingText.content();
}
+void Internals::setFocused(bool focused)
+{
+ frame()->page()->focusController().setFocused(focused);
+}
+
+bool Internals::ignoreLayoutWithPendingStylesheets(Document* document)
+{
+ ASSERT(document);
+ return document->ignoreLayoutWithPendingStylesheets();
+}
+
+void Internals::setNetworkStateNotifierTestOnly(bool testOnly)
+{
+ networkStateNotifier().setTestUpdatesOnly(testOnly);
+}
+
+void Internals::setNetworkConnectionInfo(const String& type, ExceptionState& exceptionState)
+{
+ blink::WebConnectionType webtype;
+ if (type == "cellular") {
+ webtype = blink::ConnectionTypeCellular;
+ } else if (type == "bluetooth") {
+ webtype = blink::ConnectionTypeBluetooth;
+ } else if (type == "ethernet") {
+ webtype = blink::ConnectionTypeEthernet;
+ } else if (type == "wifi") {
+ webtype = blink::ConnectionTypeWifi;
+ } else if (type == "other") {
+ webtype = blink::ConnectionTypeOther;
+ } else if (type == "none") {
+ webtype = blink::ConnectionTypeNone;
+ } else if (type == "unknown") {
+ webtype = blink::ConnectionTypeUnknown;
+ } else {
+ exceptionState.throwDOMException(NotFoundError, ExceptionMessages::failedToEnumerate("connection type", type));
+ return;
+ }
+ networkStateNotifier().setWebConnectionTypeForTest(webtype);
+}
+
+unsigned Internals::countHitRegions(CanvasRenderingContext2D* context)
+{
+ return context->hitRegionsCount();
+}
+
+String Internals::serializeNavigationMarkup()
+{
+ Vector<Document::TransitionElementData> elementData;
+ frame()->document()->getTransitionElementData(elementData);
+
+ StringBuilder markup;
+ Vector<Document::TransitionElementData>::iterator iter = elementData.begin();
+ for (; iter != elementData.end(); ++iter)
+ markup.append(iter->markup);
+
+ return markup.toString();
+}
+
+void Internals::hideAllTransitionElements()
+{
+ Vector<Document::TransitionElementData> elementData;
+ frame()->document()->getTransitionElementData(elementData);
+
+ Vector<Document::TransitionElementData>::iterator iter = elementData.begin();
+ for (; iter != elementData.end(); ++iter)
+ frame()->document()->hideTransitionElements(AtomicString(iter->selector));
+}
+
+void Internals::forcePluginPlaceholder(HTMLElement* element, PassRefPtrWillBeRawPtr<DocumentFragment> fragment, ExceptionState& exceptionState)
+{
+ if (!element->isPluginElement()) {
+ exceptionState.throwDOMException(InvalidNodeTypeError, "The element provided is not a plugin.");
+ return;
+ }
+ toHTMLPlugInElement(element)->setPlaceholder(DocumentFragmentPluginPlaceholder::create(fragment));
+}
+
+void Internals::forcePluginPlaceholder(HTMLElement* element, const Dictionary& options, ExceptionState& exceptionState)
+{
+ if (!element->isPluginElement()) {
+ exceptionState.throwDOMException(InvalidNodeTypeError, "The element provided is not a plugin.");
+ return;
+ }
+ toHTMLPlugInElement(element)->setPlaceholder(DictionaryPluginPlaceholder::create(element->document(), options));
+}
+
+Iterator* Internals::iterator(ScriptState* scriptState, ExceptionState& exceptionState)
+{
+ return new InternalsIterator;
}
+
+} // namespace blink