提交 b6d85726 编写于 作者: A Adam Barth 提交者: GitHub

Remove dead code (#2743)

We don't use this code anymore.
上级 633d674c
......@@ -14,12 +14,6 @@ source_set("bindings") {
"dart_runtime_hooks.h",
"dart_ui.cc",
"dart_ui.h",
"exception_messages.cc",
"exception_messages.h",
"exception_state.cc",
"exception_state.h",
"exception_state_placeholder.cc",
"exception_state_placeholder.h",
"flutter_dart_state.cc",
"flutter_dart_state.h",
"mojo_services.cc",
......
// Copyright 2015 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.
#include "sky/engine/bindings/exception_messages.h"
#include "sky/engine/platform/Decimal.h"
#include "sky/engine/wtf/MathExtras.h"
namespace blink {
String ExceptionMessages::failedToConstruct(const char* type,
const String& detail) {
return "Failed to construct '" + String(type) +
(!detail.isEmpty() ? String("': " + detail) : String("'"));
}
String ExceptionMessages::failedToEnumerate(const char* type,
const String& detail) {
return "Failed to enumerate the properties of '" + String(type) +
(!detail.isEmpty() ? String("': " + detail) : String("'"));
}
String ExceptionMessages::failedToExecute(const char* method,
const char* type,
const String& detail) {
return "Failed to execute '" + String(method) + "' on '" + String(type) +
(!detail.isEmpty() ? String("': " + detail) : String("'"));
}
String ExceptionMessages::failedToGet(const char* property,
const char* type,
const String& detail) {
return "Failed to read the '" + String(property) + "' property from '" +
String(type) + "': " + detail;
}
String ExceptionMessages::failedToSet(const char* property,
const char* type,
const String& detail) {
return "Failed to set the '" + String(property) + "' property on '" +
String(type) + "': " + detail;
}
String ExceptionMessages::failedToDelete(const char* property,
const char* type,
const String& detail) {
return "Failed to delete the '" + String(property) + "' property from '" +
String(type) + "': " + detail;
}
String ExceptionMessages::failedToGetIndexed(const char* type,
const String& detail) {
return "Failed to read an indexed property from '" + String(type) + "': " +
detail;
}
String ExceptionMessages::failedToSetIndexed(const char* type,
const String& detail) {
return "Failed to set an indexed property on '" + String(type) + "': " +
detail;
}
String ExceptionMessages::failedToDeleteIndexed(const char* type,
const String& detail) {
return "Failed to delete an indexed property from '" + String(type) + "': " +
detail;
}
String ExceptionMessages::constructorNotCallableAsFunction(const char* type) {
return failedToConstruct(type,
"Please use the 'new' operator, this DOM object "
"constructor cannot be called as a function.");
}
String ExceptionMessages::incorrectPropertyType(const String& property,
const String& detail) {
return "The '" + property + "' property " + detail;
}
String ExceptionMessages::invalidArity(const char* expected,
unsigned provided) {
return "Valid arities are: " + String(expected) + ", but " +
String::number(provided) + " arguments provided.";
}
String ExceptionMessages::argumentNullOrIncorrectType(
int argumentIndex,
const String& expectedType) {
return "The " + ordinalNumber(argumentIndex) +
" argument provided is either null, or an invalid " + expectedType +
" object.";
}
String ExceptionMessages::notAnArrayTypeArgumentOrValue(int argumentIndex) {
String kind;
if (argumentIndex) // method argument
kind = ordinalNumber(argumentIndex) + " argument";
else // value, e.g. attribute setter
kind = "value provided";
return "The " + kind +
" is neither an array, nor does it have indexed properties.";
}
String ExceptionMessages::notASequenceTypeProperty(const String& propertyName) {
return "'" + propertyName +
"' property is neither an array, nor does it have indexed properties.";
}
String ExceptionMessages::notEnoughArguments(unsigned expected,
unsigned provided) {
return String::number(expected) + " argument" + (expected > 1 ? "s" : "") +
" required, but only " + String::number(provided) + " present.";
}
String ExceptionMessages::notAFiniteNumber(double value, const char* name) {
ASSERT(!std::isfinite(value));
return String::format("The %s is %s.", name,
std::isinf(value) ? "infinite" : "not a number");
}
String ExceptionMessages::notAFiniteNumber(const Decimal& value,
const char* name) {
ASSERT(!value.isFinite());
return String::format("The %s is %s.", name,
value.isInfinity() ? "infinite" : "not a number");
}
String ExceptionMessages::ordinalNumber(int number) {
String suffix("th");
switch (number % 10) {
case 1:
if (number % 100 != 11)
suffix = "st";
break;
case 2:
if (number % 100 != 12)
suffix = "nd";
break;
case 3:
if (number % 100 != 13)
suffix = "rd";
break;
}
return String::number(number) + suffix;
}
String ExceptionMessages::readOnly(const char* detail) {
DEFINE_STATIC_LOCAL(String, readOnly, ("This object is read-only."));
return detail
? String::format("This object is read-only, because %s.", detail)
: readOnly;
}
template <>
String ExceptionMessages::formatNumber<float>(float number) {
return formatPotentiallyNonFiniteNumber(number);
}
template <>
String ExceptionMessages::formatNumber<double>(double number) {
return formatPotentiallyNonFiniteNumber(number);
}
} // namespace blink
// Copyright 2015 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.
#ifndef SKY_ENGINE_BINDINGS_EXCEPTIONMESSAGES_H_
#define SKY_ENGINE_BINDINGS_EXCEPTIONMESSAGES_H_
#include "sky/engine/wtf/MathExtras.h"
#include "sky/engine/wtf/text/StringBuilder.h"
#include "sky/engine/wtf/text/WTFString.h"
namespace blink {
class Decimal;
class ExceptionMessages {
public:
enum BoundType {
InclusiveBound,
ExclusiveBound,
};
static String argumentNullOrIncorrectType(int argumentIndex,
const String& expectedType);
static String constructorNotCallableAsFunction(const char* type);
static String failedToConstruct(const char* type, const String& detail);
static String failedToEnumerate(const char* type, const String& detail);
static String failedToExecute(const char* method,
const char* type,
const String& detail);
static String failedToGet(const char* property,
const char* type,
const String& detail);
static String failedToSet(const char* property,
const char* type,
const String& detail);
static String failedToDelete(const char* property,
const char* type,
const String& detail);
static String failedToGetIndexed(const char* type, const String& detail);
static String failedToSetIndexed(const char* type, const String& detail);
static String failedToDeleteIndexed(const char* type, const String& detail);
template <typename NumType>
static String formatNumber(NumType number) {
return formatFiniteNumber(number);
}
static String incorrectPropertyType(const String& property,
const String& detail);
template <typename NumberType>
static String indexExceedsMaximumBound(const char* name,
NumberType given,
NumberType bound) {
bool eq = given == bound;
StringBuilder result;
result.appendLiteral("The ");
result.append(name);
result.appendLiteral(" provided (");
result.append(formatNumber(given));
result.appendLiteral(") is greater than ");
result.append(eq ? "or equal to " : "");
result.appendLiteral("the maximum bound (");
result.append(formatNumber(bound));
result.appendLiteral(").");
return result.toString();
}
template <typename NumberType>
static String indexExceedsMinimumBound(const char* name,
NumberType given,
NumberType bound) {
bool eq = given == bound;
StringBuilder result;
result.appendLiteral("The ");
result.append(name);
result.appendLiteral(" provided (");
result.append(formatNumber(given));
result.appendLiteral(") is less than ");
result.append(eq ? "or equal to " : "");
result.appendLiteral("the minimum bound (");
result.append(formatNumber(bound));
result.appendLiteral(").");
return result.toString();
}
template <typename NumberType>
static String indexOutsideRange(const char* name,
NumberType given,
NumberType lowerBound,
BoundType lowerType,
NumberType upperBound,
BoundType upperType) {
StringBuilder result;
result.appendLiteral("The ");
result.append(name);
result.appendLiteral(" provided (");
result.append(formatNumber(given));
result.appendLiteral(") is outside the range ");
result.append(lowerType == ExclusiveBound ? '(' : '[');
result.append(formatNumber(lowerBound));
result.appendLiteral(", ");
result.append(formatNumber(upperBound));
result.append(upperType == ExclusiveBound ? ')' : ']');
result.append('.');
return result.toString();
}
static String invalidArity(const char* expected, unsigned provided);
// If > 0, the argument index that failed type check (1-indexed.)
// If == 0, a (non-argument) value (e.g., a setter) failed the same check.
static String notAnArrayTypeArgumentOrValue(int argumentIndex);
static String notASequenceTypeProperty(const String& propertyName);
static String notAFiniteNumber(double value,
const char* name = "value provided");
static String notAFiniteNumber(const Decimal& value,
const char* name = "value provided");
static String notEnoughArguments(unsigned expected, unsigned provided);
static String readOnly(const char* detail = 0);
private:
template <typename NumType>
static String formatFiniteNumber(NumType number) {
if (number > 1e20 || number < -1e20)
return String::format("%e", 1.0 * number);
return String::number(number);
}
template <typename NumType>
static String formatPotentiallyNonFiniteNumber(NumType number) {
if (std::isnan(number))
return "NaN";
if (std::isinf(number))
return number > 0 ? "Infinity" : "-Infinity";
if (number > 1e20 || number < -1e20)
return String::format("%e", number);
return String::number(number);
}
static String ordinalNumber(int number);
};
template <>
String ExceptionMessages::formatNumber<float>(float number);
template <>
String ExceptionMessages::formatNumber<double>(double number);
} // namespace blink
#endif // SKY_ENGINE_BINDINGS_EXCEPTIONMESSAGES_H_
// 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.
#include "sky/engine/bindings/exception_state.h"
namespace blink {
ExceptionState::ExceptionState() : code_(0), had_exception_(false) {
}
ExceptionState::ExceptionState(Context context,
const char* propertyName,
const char* interfaceName) {
}
ExceptionState::ExceptionState(Context context, const char* interfaceName) {
}
ExceptionState::~ExceptionState() {
}
// TODO(iansf): Implement exceptions.
void ExceptionState::ThrowDOMException(const ExceptionCode&,
const String& message) {
had_exception_ = true;
}
void ExceptionState::ThrowTypeError(const String& message) {
had_exception_ = true;
}
void ExceptionState::ThrowRangeError(const String& message) {
had_exception_ = true;
}
bool ExceptionState::ThrowIfNeeded() {
return had_exception_;
}
void ExceptionState::ClearException() {
had_exception_ = false;
}
Dart_Handle ExceptionState::GetDartException(Dart_NativeArguments args,
bool auto_scope) {
// TODO(abarth): Still don't understand autoscope.
DCHECK(auto_scope);
// TODO(eseidel): This should be a real exception object!
if (!message_.isEmpty()) {
CString utf8 = message_.utf8();
return Dart_NewStringFromUTF8(reinterpret_cast<const unsigned char*>(utf8.data()), utf8.length());
}
return Dart_NewStringFromCString("Exception support missing. See exception_state.cc");
}
} // namespace blink
// 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.
#ifndef SKY_ENGINE_BINDINGS_EXCEPTION_STATE_H_
#define SKY_ENGINE_BINDINGS_EXCEPTION_STATE_H_
#include "flutter/tonic/dart_persistent_value.h"
#include "sky/engine/wtf/Noncopyable.h"
#include "sky/engine/wtf/text/WTFString.h"
namespace blink {
typedef int ExceptionCode;
class ExceptionState {
WTF_MAKE_NONCOPYABLE(ExceptionState);
public:
enum Context {
ConstructionContext,
ExecutionContext,
DeletionContext,
GetterContext,
SetterContext,
EnumerationContext,
QueryContext,
IndexedGetterContext,
IndexedSetterContext,
IndexedDeletionContext,
UnknownContext, // FIXME: Remove this once we've flipped over to the new
// API.
};
ExceptionState();
ExceptionState(Context context, const char* interfaceName);
ExceptionState(Context context,
const char* propertyName,
const char* interfaceName);
~ExceptionState();
void ThrowDOMException(const ExceptionCode& code, const String& message);
void ThrowTypeError(const String& message);
void ThrowRangeError(const String& message);
bool ThrowIfNeeded();
void ClearException();
ExceptionCode code() const { return code_; }
const String& message() const { return message_; }
bool had_exception() const { return had_exception_ || code_; }
Dart_Handle GetDartException(Dart_NativeArguments args, bool auto_scope);
private:
ExceptionCode code_;
String message_;
bool had_exception_;
DartPersistentValue exception_;
};
class NonThrowableExceptionState final : public ExceptionState {};
class TrackExceptionState final : public ExceptionState {};
} // namespace blink
#endif // SKY_ENGINE_BINDINGS_EXCEPTION_STATE_H_
// 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.
#include "sky/engine/bindings/exception_state_placeholder.h"
namespace blink {
#if ENABLE(ASSERT)
NoExceptionStateAssertionChecker::NoExceptionStateAssertionChecker(
const char* file,
int line) {
}
#endif
} // namespace blink
// 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.
#ifndef SKY_ENGINE_BINDINGS_EXCEPTION_STATE_PLACEHOLDER_H_
#define SKY_ENGINE_BINDINGS_EXCEPTION_STATE_PLACEHOLDER_H_
#include "sky/engine/bindings/exception_state.h"
#include "sky/engine/wtf/Assertions.h"
namespace blink {
class IgnorableExceptionState final : public ExceptionState {
public:
ExceptionState& ReturnThis() { return *this; }
};
#define IGNORE_EXCEPTION (::blink::IgnorableExceptionState().ReturnThis())
#if ENABLE(ASSERT)
class NoExceptionStateAssertionChecker final : public ExceptionState {
public:
NoExceptionStateAssertionChecker(const char* file, int line);
ExceptionState& ReturnThis() { return *this; }
};
#define ASSERT_NO_EXCEPTION \
(::blink::NoExceptionStateAssertionChecker(__FILE__, __LINE__).ReturnThis())
#else
#define ASSERT_NO_EXCEPTION (::blink::IgnorableExceptionState().ReturnThis())
#endif
} // namespace blink
#endif // SKY_ENGINE_BINDINGS_EXCEPTION_STATE_PLACEHOLDER_H_
......@@ -12,7 +12,6 @@
#include "flow/layers/container_layer.h"
#include "flutter/tonic/dart_wrappable.h"
#include "flutter/tonic/float64_list.h"
#include "sky/engine/bindings/exception_state.h"
#include "sky/engine/core/compositing/Scene.h"
#include "sky/engine/core/painting/CanvasPath.h"
#include "sky/engine/core/painting/ImageFilter.h"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册