#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/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/EventHandlerRegistry.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/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/Cursor.h"
#include "platform/Language.h"
namespace {
-class InternalsIterator FINAL : public Iterator {
+class InternalsIterator final : public Iterator {
public:
InternalsIterator() : m_current(0) { }
- virtual ScriptValue next(ScriptState* scriptState, ExceptionState& exceptionState) OVERRIDE
+ virtual ScriptValue next(ScriptState* scriptState, ExceptionState& exceptionState) override
{
v8::Isolate* isolate = scriptState->isolate();
int value = m_current * m_current;
return ScriptValue(scriptState, v8IteratorResult(scriptState, value));
}
- virtual ScriptValue next(ScriptState* scriptState, ScriptValue value, ExceptionState& exceptionState) OVERRIDE
+ virtual ScriptValue next(ScriptState* scriptState, ScriptValue value, ExceptionState& exceptionState) override
{
exceptionState.throwTypeError("Not implemented");
return 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;
}
{
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;
}
return CSSComputedStyleDeclaration::create(node, allowVisitedStyle);
}
+PassRefPtrWillBeRawPtr<ShadowRoot> Internals::createUserAgentShadowRoot(Element* host)
+{
+ ASSERT(host);
+ return PassRefPtrWillBeRawPtr<ShadowRoot>(host->ensureUserAgentShadowRoot());
+}
+
ShadowRoot* Internals::shadowRoot(Element* host)
{
// FIXME: Internals::shadowRoot() in tests should be converted to youngestShadowRoot() or oldestShadowRoot().
return s_pagePopupDriver ? s_pagePopupDriver->pagePopupController() : 0;
}
+LocalDOMWindow* Internals::pagePopupWindow() const
+{
+ Document* document = contextDocument();
+ 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();
+}
+
PassRefPtrWillBeRawPtr<ClientRect> Internals::absoluteCaretBounds(ExceptionState& exceptionState)
{
Document* document = contextDocument();
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)
{
ASSERT(document);
if (!document->view()) {
IntPoint hitTestPoint = document->frame()->view()->windowToContents(point);
HitTestResult result = eventHandler.hitTestResultAtPoint(hitTestPoint, HitTestRequest::ReadOnly | HitTestRequest::Active, radius);
- Node* targetNode;
+ Node* targetNode = 0;
IntPoint adjustedPoint;
bool foundNode = eventHandler.bestClickableNodeForHitTestResult(result, adjustedPoint, targetNode);
IntPoint hitTestPoint = document->frame()->view()->windowToContents(point);
HitTestResult result = eventHandler.hitTestResultAtPoint(hitTestPoint, HitTestRequest::ReadOnly | HitTestRequest::Active, radius);
- Node* targetNode;
+ Node* targetNode = 0;
IntPoint adjustedPoint;
document->frame()->eventHandler().bestClickableNodeForHitTestResult(result, adjustedPoint, targetNode);
return targetNode;
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<String> Internals::consoleMessageArgumentCounts(Document* document) const
{
- LocalFrame* frame = document->frame();
- if (!frame)
+ FrameHost* host = document->frameHost();
+ if (!host)
return Vector<String>();
- Vector<unsigned> counts = frame->console().messageStorage()->argumentCounts();
+ 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]);
page->inspectorController().setResourcesDataSizeLimitsFromInternals(maximumResourcesContentSize, maximumSingleResourceContentSize);
}
+String Internals::inspectorHighlightJSON(Node* node, ExceptionState& exceptionState)
+{
+ 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);
return layer1->scrollsWithRespectTo(layer2);
}
-bool Internals::isUnclippedDescendant(Element* element, ExceptionState& exceptionState)
-{
- ASSERT(element);
- element->document().view()->updateLayoutAndStyleForPainting();
-
- 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();
-}
-
String Internals::layerTreeAsText(Document* document, unsigned flags, ExceptionState& exceptionState) const
{
ASSERT(document);
PrivateScriptTest* Internals::privateScriptTest() const
{
- return PrivateScriptTest::create(frame());
+ return PrivateScriptTest::create(frame()->document());
}
DictionaryTest* Internals::dictionaryTest() const
return DictionaryTest::create();
}
+UnionTypesTest* Internals::unionTypesTest() const
+{
+ return UnionTypesTest::create();
+}
+
Vector<String> Internals::getReferencedFilePaths() const
{
return frame()->loader().currentItem()->getReferencedFilePaths();
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);
{
}
- virtual ScriptValue call(ScriptValue value) OVERRIDE
+ virtual ScriptValue call(ScriptValue value) override
{
v8::Local<v8::Value> v8Value = value.v8Value();
ASSERT(v8Value->IsNumber());
return ScriptPromise::cast(scriptState, v8String(scriptState->isolate(), "done"));
}
+ScriptPromise Internals::promiseCheckOverload(ScriptState* scriptState, Location*)
+{
+ return ScriptPromise::cast(scriptState, v8String(scriptState->isolate(), "done"));
+}
+
+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);
frame()->document()->hideTransitionElements(AtomicString(iter->selector));
}
-void Internals::forcePluginPlaceholder(HTMLElement* element, const String& htmlSource, ExceptionState& exceptionState)
+void Internals::forcePluginPlaceholder(HTMLElement* element, PassRefPtrWillBeRawPtr<DocumentFragment> fragment, ExceptionState& exceptionState)
{
if (!element->isPluginElement()) {
exceptionState.throwDOMException(InvalidNodeTypeError, "The element provided is not a plugin.");
return;
}
-
- element->ensureUserAgentShadowRoot().setInnerHTML(htmlSource, exceptionState);
- if (exceptionState.hadException())
- return;
-
- toHTMLPlugInElement(element)->setUsePlaceholderContent(true);
+ toHTMLPlugInElement(element)->setPlaceholder(DocumentFragmentPluginPlaceholder::create(fragment));
}
void Internals::forcePluginPlaceholder(HTMLElement* element, const Dictionary& options, ExceptionState& exceptionState)
exceptionState.throwDOMException(InvalidNodeTypeError, "The element provided is not a plugin.");
return;
}
-
- RefPtrWillBeRawPtr<PluginPlaceholderElement> placeholder = PluginPlaceholderElement::create(element->document());
- String stringValue;
- if (DictionaryHelper::get(options, "message", stringValue))
- placeholder->setMessage(stringValue);
-
- ShadowRoot& shadowRoot = element->ensureUserAgentShadowRoot();
- shadowRoot.removeChildren();
- shadowRoot.appendChild(placeholder.release(), exceptionState);
- if (exceptionState.hadException())
- return;
-
- toHTMLPlugInElement(element)->setUsePlaceholderContent(true);
+ toHTMLPlugInElement(element)->setPlaceholder(DictionaryPluginPlaceholder::create(element->document(), options));
}
Iterator* Internals::iterator(ScriptState* scriptState, ExceptionState& exceptionState)