#include "core/css/resolver/ViewportStyleResolver.h"
#include "core/dom/ClientRect.h"
#include "core/dom/ClientRectList.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/editing/TextIterator.h"
#include "core/fetch/MemoryCache.h"
#include "core/fetch/ResourceFetcher.h"
-#include "core/frame/LocalDOMWindow.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/frame/WebKitPoint.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/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"
namespace blink {
+namespace {
+
+class InternalsIterator FINAL : public Iterator {
+public:
+ 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:
+ int m_current;
+};
+
+} // namespace
+
// FIXME: oilpan: These will be removed soon.
static MockPagePopupDriver* s_pagePopupDriver = 0;
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()
: ContextLifecycleObserver(document)
, m_runtimeFlags(InternalRuntimeFlags::create())
{
- ScriptWrappable::init(this);
}
Document* Internals::contextDocument() const
return String(buf);
}
-PassRefPtrWillBeRawPtr<GCObservation> Internals::observeGC(ScriptValue scriptValue)
+GCObservation* Internals::observeGC(ScriptValue scriptValue)
{
v8::Handle<v8::Value> observedValue = scriptValue.v8Value();
ASSERT(!observedValue.IsEmpty());
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) {
- exceptionState.throwDOMException(InvalidAccessError, "No context document is available.");
- return String();
- }
- 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) {
- exceptionState.throwDOMException(InvalidAccessError, "No context document is available.");
- return String();
- }
- 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) const
{
ASSERT(element1 && element2);
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
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 element->shadowPseudoId();
}
-void Internals::setShadowPseudoId(Element* element, const AtomicString& id)
-{
- ASSERT(element);
- 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)
return s_pagePopupDriver ? s_pagePopupDriver->pagePopupController() : 0;
}
-PassRefPtrWillBeRawPtr<ClientRect> Internals::unscaledViewportRect(ExceptionState& exceptionState)
-{
- 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());
-}
-
PassRefPtrWillBeRawPtr<ClientRect> Internals::absoluteCaretBounds(ExceptionState& exceptionState)
{
Document* document = contextDocument();
// FIXME: The next four functions are very similar - combine them once
// bestClickableNode/bestContextMenuNode have been combined..
-PassRefPtrWillBeRawPtr<WebKitPoint> Internals::touchPositionAdjustedToBestClickableNode(long x, long y, long width, long height, Document* document, ExceptionState& exceptionState)
+DOMPoint* Internals::touchPositionAdjustedToBestClickableNode(long x, long y, long width, long height, Document* document, ExceptionState& exceptionState)
{
ASSERT(document);
if (!document->frame()) {
exceptionState.throwDOMException(InvalidAccessError, "The document provided is invalid.");
- return nullptr;
+ return 0;
}
document->updateLayout();
bool foundNode = eventHandler.bestClickableNodeForHitTestResult(result, adjustedPoint, targetNode);
if (foundNode)
- return WebKitPoint::create(adjustedPoint.x(), adjustedPoint.y());
+ 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)
return targetNode;
}
-PassRefPtrWillBeRawPtr<WebKitPoint> 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)
{
ASSERT(document);
if (!document->frame()) {
exceptionState.throwDOMException(InvalidAccessError, "The document provided is invalid.");
- return nullptr;
+ return 0;
}
document->updateLayout();
bool foundNode = eventHandler.bestContextMenuNodeForHitTestResult(result, adjustedPoint, targetNode);
if (foundNode)
- return WebKitPoint::create(adjustedPoint.x(), adjustedPoint.y());
+ return DOMPoint::create(adjustedPoint.x(), adjustedPoint.y());
- return WebKitPoint::create(x, y);
+ return DOMPoint::create(x, y);
}
Node* Internals::touchNodeAdjustedToBestContextMenuNode(long x, long y, long width, long height, Document* document, ExceptionState& exceptionState)
accumulateLayerRectList(compositor, graphicsLayer->children()[i], rects);
}
-PassRefPtrWillBeRawPtr<LayerRectList> Internals::touchEventTargetLayerRects(Document* document, ExceptionState& exceptionState)
+LayerRectList* Internals::touchEventTargetLayerRects(Document* document, ExceptionState& exceptionState)
{
ASSERT(document);
if (!document->view() || !document->page() || document != contextDocument()) {
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 StaticNodeList::adopt(matches);
}
-void Internals::emitInspectorDidBeginFrame(int frameId)
-{
- contextDocument()->page()->inspectorController().didBeginFrame(frameId);
-}
-
-void Internals::emitInspectorDidCancelFrame()
-{
- contextDocument()->page()->inspectorController().didCancelFrame();
-}
-
bool Internals::hasSpellingMarker(Document* document, int from, int length)
{
ASSERT(document);
Vector<String> Internals::consoleMessageArgumentCounts(Document* document) const
{
- InstrumentingAgents* instrumentingAgents = instrumentationForPage(document->page());
- if (!instrumentingAgents)
- return Vector<String>();
- InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent();
- if (!consoleAgent)
+ LocalFrame* frame = document->frame();
+ if (!frame)
return Vector<String>();
- Vector<unsigned> counts = consoleAgent->consoleMessageArgumentCounts();
+
+ Vector<unsigned> counts = frame->console().messageStorage()->argumentCounts();
Vector<String> result(counts.size());
for (size_t i = 0; i < counts.size(); i++)
result[i] = String::number(counts[i]);
return 0;
}
- // We used to compute isUnclippedDescendant only when acceleratedCompositingForOverflowScrollEnabled,
- // but now we compute it all the time.
- // FIXME: Remove this if statement and rebaseline the tests that make this assumption.
- if (!layer->compositor()->acceleratedCompositingForOverflowScrollEnabled())
- return false;
-
return layer->isUnclippedDescendant();
}
return mediaElement->effectiveMediaVolume();
}
+void Internals::mediaPlayerRemoteRouteAvailabilityChanged(HTMLMediaElement* mediaElement, bool available)
+{
+ mediaElement->remoteRouteAvailabilityChanged(available);
+}
+
void Internals::registerURLSchemeAsBypassingContentSecurityPolicy(const String& scheme)
{
SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy(scheme);
SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(scheme);
}
-PassRefPtrWillBeRawPtr<TypeConversions> Internals::typeConversions() const
+TypeConversions* Internals::typeConversions() const
{
return TypeConversions::create();
}
return PrivateScriptTest::create(frame());
}
+DictionaryTest* Internals::dictionaryTest() const
+{
+ return DictionaryTest::create();
+}
+
Vector<String> Internals::getReferencedFilePaths() const
{
return frame()->loader().currentItem()->getReferencedFilePaths();
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 element->imageSourceURL();
}
-String Internals::baseURL(Document* document)
-{
- ASSERT(document);
- return document->baseURL().string();
-}
-
bool Internals::isSelectPopupVisible(Node* node)
{
ASSERT(node);
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)
{
}
v8::Local<v8::Value> v8Value = value.v8Value();
ASSERT(v8Value->IsNumber());
int intValue = v8Value.As<v8::Integer>()->Value();
- ScriptValue result = ScriptValue(ScriptState::current(isolate()), v8::Integer::New(isolate(), intValue + 1));
- return result;
+ return ScriptValue(scriptState(), v8::Integer::New(scriptState()->isolate(), intValue + 1));
}
};
ScriptPromise Internals::addOneToPromise(ScriptState* scriptState, ScriptPromise promise)
{
- return promise.then(AddOneFunction::create(scriptState->executionContext()));
+ return promise.then(AddOneFunction::createFunction(scriptState));
}
ScriptPromise Internals::promiseCheck(ScriptState* scriptState, long arg1, bool arg2, const Dictionary& arg3, const String& arg4, const Vector<String>& arg5, ExceptionState& exceptionState)
frame()->document()->hideTransitionElements(AtomicString(iter->selector));
}
+void Internals::forcePluginPlaceholder(HTMLElement* element, const String& htmlSource, 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);
+}
+
+void Internals::forcePluginPlaceholder(HTMLElement* element, const Dictionary& options, ExceptionState& exceptionState)
+{
+ if (!element->isPluginElement()) {
+ 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);
+}
+
+Iterator* Internals::iterator(ScriptState* scriptState, ExceptionState& exceptionState)
+{
+ return new InternalsIterator;
+}
+
} // namespace blink