Commit c928e19e authored by bashi@chromium.org's avatar bashi@chromium.org

Replace generic Dictionary with DictionaryPluginPlaceholderOptions

Dictionary.h has some problems (it cannot handle ExceptionState,
difficult to understand). We want to reduce Dictionary uses
in core/modules so that make it more maintainable.

Tests under fast/plugins cover this change.

BUG=403150

Review URL: https://codereview.chromium.org/720673002

git-svn-id: svn://svn.chromium.org/blink/trunk@185194 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 91448214
......@@ -326,6 +326,8 @@ source_set("testing") {
"$bindings_core_v8_output_dir/V8RefCountedScriptWrappable.h",
"$bindings_core_v8_output_dir/V8InternalDictionary.cpp",
"$bindings_core_v8_output_dir/V8InternalDictionary.h",
"$bindings_core_v8_output_dir/V8PluginPlaceholderOptions.cpp",
"$bindings_core_v8_output_dir/V8PluginPlaceholderOptions.h",
]
}
......
......@@ -785,6 +785,8 @@
'<(bindings_core_v8_output_dir)/V8RefCountedScriptWrappable.h',
'<(bindings_core_v8_output_dir)/V8InternalDictionary.cpp',
'<(bindings_core_v8_output_dir)/V8InternalDictionary.h',
'<(bindings_core_v8_output_dir)/V8PluginPlaceholderOptions.cpp',
'<(bindings_core_v8_output_dir)/V8PluginPlaceholderOptions.h',
],
'sources/': [
['exclude', 'testing/js'],
......
......@@ -3440,6 +3440,7 @@
],
'core_testing_dictionary_idl_files': [
'testing/InternalDictionary.idl',
'testing/PluginPlaceholderOptions.idl',
],
'webcore_testing_idl_files': [
'testing/DictionaryTest.idl',
......@@ -3467,6 +3468,8 @@
'generated_core_testing_dictionary_files': [
'<(blink_core_output_dir)/testing/InternalDictionary.cpp',
'<(blink_core_output_dir)/testing/InternalDictionary.h',
'<(blink_core_output_dir)/testing/PluginPlaceholderOptions.cpp',
'<(blink_core_output_dir)/testing/PluginPlaceholderOptions.h',
],
'webcore_testing_files': [
'<(blink_core_output_dir)/InternalSettingsGenerated.cpp',
......
......@@ -5,9 +5,9 @@
#ifndef DictionaryPluginPlaceholder_h
#define DictionaryPluginPlaceholder_h
#include "bindings/core/v8/Dictionary.h"
#include "core/html/shadow/PluginPlaceholderElement.h"
#include "core/plugins/PluginPlaceholder.h"
#include "core/testing/PluginPlaceholderOptions.h"
#include "wtf/text/WTFString.h"
namespace blink {
......@@ -17,16 +17,14 @@ namespace blink {
class DictionaryPluginPlaceholder : public NoBaseWillBeGarbageCollected<DictionaryPluginPlaceholder>, public PluginPlaceholder {
WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(DictionaryPluginPlaceholder);
public:
static PassOwnPtrWillBeRawPtr<DictionaryPluginPlaceholder> create(Document& document, const Dictionary& options)
static PassOwnPtrWillBeRawPtr<DictionaryPluginPlaceholder> create(Document& document, const PluginPlaceholderOptions& options)
{
RefPtrWillBeRawPtr<PluginPlaceholderElement> placeholder = PluginPlaceholderElement::create(document);
String stringValue;
if (DictionaryHelper::get(options, "message", stringValue))
placeholder->setMessage(stringValue);
if (options.hasMessage())
placeholder->setMessage(options.message());
bool booleanValue;
if (DictionaryHelper::get(options, "closeable", booleanValue))
placeholder->setIsCloseable(booleanValue);
if (options.hasCloseable())
placeholder->setIsCloseable(options.closeable());
return adoptPtrWillBeNoop(new DictionaryPluginPlaceholder(placeholder.release()));
}
......
......@@ -123,6 +123,7 @@
#include "core/testing/LayerRect.h"
#include "core/testing/LayerRectList.h"
#include "core/testing/MockPagePopupDriver.h"
#include "core/testing/PluginPlaceholderOptions.h"
#include "core/testing/PrivateScriptTest.h"
#include "core/testing/TypeConversions.h"
#include "core/testing/UnionTypesTest.h"
......@@ -2327,7 +2328,7 @@ void Internals::forcePluginPlaceholder(HTMLElement* element, PassRefPtrWillBeRaw
toHTMLPlugInElement(element)->setPlaceholder(DocumentFragmentPluginPlaceholder::create(fragment));
}
void Internals::forcePluginPlaceholder(HTMLElement* element, const Dictionary& options, ExceptionState& exceptionState)
void Internals::forcePluginPlaceholder(HTMLElement* element, const PluginPlaceholderOptions& options, ExceptionState& exceptionState)
{
if (!element->isPluginElement()) {
exceptionState.throwDOMException(InvalidNodeTypeError, "The element provided is not a plugin.");
......
......@@ -66,6 +66,7 @@ class LocalFrame;
class Node;
class Page;
class PagePopupController;
class PluginPlaceholderOptions;
class PrivateScriptTest;
class Range;
class SerializedScriptValue;
......@@ -333,7 +334,7 @@ public:
unsigned countHitRegions(CanvasRenderingContext2D*);
void forcePluginPlaceholder(HTMLElement* plugin, PassRefPtrWillBeRawPtr<DocumentFragment>, ExceptionState&);
void forcePluginPlaceholder(HTMLElement* plugin, const Dictionary& options, ExceptionState&);
void forcePluginPlaceholder(HTMLElement* plugin, const PluginPlaceholderOptions&, ExceptionState&);
Iterator* iterator(ScriptState*, ExceptionState&);
......
......@@ -289,7 +289,7 @@
void showAllTransitionElements();
[RaisesException, TypeChecking=Interface] void forcePluginPlaceholder(HTMLElement plugin, DocumentFragment fragment);
[RaisesException, TypeChecking=Interface] void forcePluginPlaceholder(HTMLElement plugin, Dictionary options);
[RaisesException, TypeChecking=Interface] void forcePluginPlaceholder(HTMLElement plugin, PluginPlaceholderOptions options);
DictionaryTest dictionaryTest();
UnionTypesTest unionTypesTest();
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
dictionary PluginPlaceholderOptions {
DOMString message;
boolean closeable;
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment