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") { ...@@ -326,6 +326,8 @@ source_set("testing") {
"$bindings_core_v8_output_dir/V8RefCountedScriptWrappable.h", "$bindings_core_v8_output_dir/V8RefCountedScriptWrappable.h",
"$bindings_core_v8_output_dir/V8InternalDictionary.cpp", "$bindings_core_v8_output_dir/V8InternalDictionary.cpp",
"$bindings_core_v8_output_dir/V8InternalDictionary.h", "$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 @@ ...@@ -785,6 +785,8 @@
'<(bindings_core_v8_output_dir)/V8RefCountedScriptWrappable.h', '<(bindings_core_v8_output_dir)/V8RefCountedScriptWrappable.h',
'<(bindings_core_v8_output_dir)/V8InternalDictionary.cpp', '<(bindings_core_v8_output_dir)/V8InternalDictionary.cpp',
'<(bindings_core_v8_output_dir)/V8InternalDictionary.h', '<(bindings_core_v8_output_dir)/V8InternalDictionary.h',
'<(bindings_core_v8_output_dir)/V8PluginPlaceholderOptions.cpp',
'<(bindings_core_v8_output_dir)/V8PluginPlaceholderOptions.h',
], ],
'sources/': [ 'sources/': [
['exclude', 'testing/js'], ['exclude', 'testing/js'],
......
...@@ -3440,6 +3440,7 @@ ...@@ -3440,6 +3440,7 @@
], ],
'core_testing_dictionary_idl_files': [ 'core_testing_dictionary_idl_files': [
'testing/InternalDictionary.idl', 'testing/InternalDictionary.idl',
'testing/PluginPlaceholderOptions.idl',
], ],
'webcore_testing_idl_files': [ 'webcore_testing_idl_files': [
'testing/DictionaryTest.idl', 'testing/DictionaryTest.idl',
...@@ -3467,6 +3468,8 @@ ...@@ -3467,6 +3468,8 @@
'generated_core_testing_dictionary_files': [ 'generated_core_testing_dictionary_files': [
'<(blink_core_output_dir)/testing/InternalDictionary.cpp', '<(blink_core_output_dir)/testing/InternalDictionary.cpp',
'<(blink_core_output_dir)/testing/InternalDictionary.h', '<(blink_core_output_dir)/testing/InternalDictionary.h',
'<(blink_core_output_dir)/testing/PluginPlaceholderOptions.cpp',
'<(blink_core_output_dir)/testing/PluginPlaceholderOptions.h',
], ],
'webcore_testing_files': [ 'webcore_testing_files': [
'<(blink_core_output_dir)/InternalSettingsGenerated.cpp', '<(blink_core_output_dir)/InternalSettingsGenerated.cpp',
......
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
#ifndef DictionaryPluginPlaceholder_h #ifndef DictionaryPluginPlaceholder_h
#define DictionaryPluginPlaceholder_h #define DictionaryPluginPlaceholder_h
#include "bindings/core/v8/Dictionary.h"
#include "core/html/shadow/PluginPlaceholderElement.h" #include "core/html/shadow/PluginPlaceholderElement.h"
#include "core/plugins/PluginPlaceholder.h" #include "core/plugins/PluginPlaceholder.h"
#include "core/testing/PluginPlaceholderOptions.h"
#include "wtf/text/WTFString.h" #include "wtf/text/WTFString.h"
namespace blink { namespace blink {
...@@ -17,16 +17,14 @@ namespace blink { ...@@ -17,16 +17,14 @@ namespace blink {
class DictionaryPluginPlaceholder : public NoBaseWillBeGarbageCollected<DictionaryPluginPlaceholder>, public PluginPlaceholder { class DictionaryPluginPlaceholder : public NoBaseWillBeGarbageCollected<DictionaryPluginPlaceholder>, public PluginPlaceholder {
WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(DictionaryPluginPlaceholder); WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(DictionaryPluginPlaceholder);
public: 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); RefPtrWillBeRawPtr<PluginPlaceholderElement> placeholder = PluginPlaceholderElement::create(document);
String stringValue; if (options.hasMessage())
if (DictionaryHelper::get(options, "message", stringValue)) placeholder->setMessage(options.message());
placeholder->setMessage(stringValue);
bool booleanValue; if (options.hasCloseable())
if (DictionaryHelper::get(options, "closeable", booleanValue)) placeholder->setIsCloseable(options.closeable());
placeholder->setIsCloseable(booleanValue);
return adoptPtrWillBeNoop(new DictionaryPluginPlaceholder(placeholder.release())); return adoptPtrWillBeNoop(new DictionaryPluginPlaceholder(placeholder.release()));
} }
......
...@@ -123,6 +123,7 @@ ...@@ -123,6 +123,7 @@
#include "core/testing/LayerRect.h" #include "core/testing/LayerRect.h"
#include "core/testing/LayerRectList.h" #include "core/testing/LayerRectList.h"
#include "core/testing/MockPagePopupDriver.h" #include "core/testing/MockPagePopupDriver.h"
#include "core/testing/PluginPlaceholderOptions.h"
#include "core/testing/PrivateScriptTest.h" #include "core/testing/PrivateScriptTest.h"
#include "core/testing/TypeConversions.h" #include "core/testing/TypeConversions.h"
#include "core/testing/UnionTypesTest.h" #include "core/testing/UnionTypesTest.h"
...@@ -2327,7 +2328,7 @@ void Internals::forcePluginPlaceholder(HTMLElement* element, PassRefPtrWillBeRaw ...@@ -2327,7 +2328,7 @@ void Internals::forcePluginPlaceholder(HTMLElement* element, PassRefPtrWillBeRaw
toHTMLPlugInElement(element)->setPlaceholder(DocumentFragmentPluginPlaceholder::create(fragment)); 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()) { if (!element->isPluginElement()) {
exceptionState.throwDOMException(InvalidNodeTypeError, "The element provided is not a plugin."); exceptionState.throwDOMException(InvalidNodeTypeError, "The element provided is not a plugin.");
......
...@@ -66,6 +66,7 @@ class LocalFrame; ...@@ -66,6 +66,7 @@ class LocalFrame;
class Node; class Node;
class Page; class Page;
class PagePopupController; class PagePopupController;
class PluginPlaceholderOptions;
class PrivateScriptTest; class PrivateScriptTest;
class Range; class Range;
class SerializedScriptValue; class SerializedScriptValue;
...@@ -333,7 +334,7 @@ public: ...@@ -333,7 +334,7 @@ public:
unsigned countHitRegions(CanvasRenderingContext2D*); unsigned countHitRegions(CanvasRenderingContext2D*);
void forcePluginPlaceholder(HTMLElement* plugin, PassRefPtrWillBeRawPtr<DocumentFragment>, ExceptionState&); 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&); Iterator* iterator(ScriptState*, ExceptionState&);
......
...@@ -289,7 +289,7 @@ ...@@ -289,7 +289,7 @@
void showAllTransitionElements(); void showAllTransitionElements();
[RaisesException, TypeChecking=Interface] void forcePluginPlaceholder(HTMLElement plugin, DocumentFragment fragment); [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(); DictionaryTest dictionaryTest();
UnionTypesTest unionTypesTest(); 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