зеркало из https://github.com/mozilla/gecko-dev.git
Merge inbound to mozilla-central. a=merge
This commit is contained in:
Коммит
876022232b
|
@ -139,14 +139,14 @@ HTMLHRElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
|
||||
if (!aDecls.PropertyIsSet(eCSSProperty_border_top_style))
|
||||
aDecls.SetKeywordValue(eCSSProperty_border_top_style,
|
||||
NS_STYLE_BORDER_STYLE_SOLID);
|
||||
StyleBorderStyle::Solid);
|
||||
if (allSides) {
|
||||
aDecls.SetKeywordValueIfUnset(eCSSProperty_border_right_style,
|
||||
NS_STYLE_BORDER_STYLE_SOLID);
|
||||
StyleBorderStyle::Solid);
|
||||
aDecls.SetKeywordValueIfUnset(eCSSProperty_border_bottom_style,
|
||||
NS_STYLE_BORDER_STYLE_SOLID);
|
||||
StyleBorderStyle::Solid);
|
||||
aDecls.SetKeywordValueIfUnset(eCSSProperty_border_left_style,
|
||||
NS_STYLE_BORDER_STYLE_SOLID);
|
||||
StyleBorderStyle::Solid);
|
||||
|
||||
// If it would be noticeable, set the border radius to
|
||||
// 10000px on all corners; this triggers the clamping to make
|
||||
|
|
|
@ -1442,13 +1442,13 @@ nsGenericHTMLElement::MapImageBorderAttributeInto(const nsMappedAttributes* aAtt
|
|||
aDecls.SetPixelValueIfUnset(eCSSProperty_border_left_width, (float)val);
|
||||
|
||||
aDecls.SetKeywordValueIfUnset(eCSSProperty_border_top_style,
|
||||
NS_STYLE_BORDER_STYLE_SOLID);
|
||||
StyleBorderStyle::Solid);
|
||||
aDecls.SetKeywordValueIfUnset(eCSSProperty_border_right_style,
|
||||
NS_STYLE_BORDER_STYLE_SOLID);
|
||||
StyleBorderStyle::Solid);
|
||||
aDecls.SetKeywordValueIfUnset(eCSSProperty_border_bottom_style,
|
||||
NS_STYLE_BORDER_STYLE_SOLID);
|
||||
StyleBorderStyle::Solid);
|
||||
aDecls.SetKeywordValueIfUnset(eCSSProperty_border_left_style,
|
||||
NS_STYLE_BORDER_STYLE_SOLID);
|
||||
StyleBorderStyle::Solid);
|
||||
|
||||
aDecls.SetCurrentColorIfUnset(eCSSProperty_border_top_color);
|
||||
aDecls.SetCurrentColorIfUnset(eCSSProperty_border_right_color);
|
||||
|
|
|
@ -134,7 +134,7 @@ MerchantValidationEvent::ResolvedCallback(JSContext* aCx,
|
|||
// conformance, which is why at this point we throw a
|
||||
// NS_ERROR_DOM_NOT_SUPPORTED_ERR.
|
||||
|
||||
mRequest->AbortUpdate(NS_ERROR_DOM_NOT_SUPPORTED_ERR, false);
|
||||
mRequest->AbortUpdate(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
mRequest->SetUpdating(false);
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ MerchantValidationEvent::RejectedCallback(JSContext* aCx,
|
|||
return;
|
||||
}
|
||||
mWaitForUpdate = false;
|
||||
mRequest->AbortUpdate(NS_ERROR_DOM_ABORT_ERR, false);
|
||||
mRequest->AbortUpdate(NS_ERROR_DOM_ABORT_ERR);
|
||||
mRequest->SetUpdating(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -664,7 +664,6 @@ PaymentRequest::PaymentRequest(nsPIDOMWindowInner* aWindow, const nsAString& aIn
|
|||
, mShippingAddress(nullptr)
|
||||
, mUpdating(false)
|
||||
, mRequestShipping(false)
|
||||
, mDeferredShow(false)
|
||||
, mUpdateError(NS_OK)
|
||||
, mState(eCreated)
|
||||
, mIPC(nullptr)
|
||||
|
@ -756,7 +755,6 @@ PaymentRequest::Show(const Optional<OwningNonNull<Promise>>& aDetailsPromise,
|
|||
if (aDetailsPromise.WasPassed()) {
|
||||
aDetailsPromise.Value().AppendNativeHandler(this);
|
||||
mUpdating = true;
|
||||
mDeferredShow = true;
|
||||
}
|
||||
|
||||
RefPtr<PaymentRequestManager> manager = PaymentRequestManager::GetSingleton();
|
||||
|
@ -858,9 +856,7 @@ PaymentRequest::Abort(ErrorResult& aRv)
|
|||
|
||||
RefPtr<PaymentRequestManager> manager = PaymentRequestManager::GetSingleton();
|
||||
MOZ_ASSERT(manager);
|
||||
// It's possible to be called between show and its promise resolving.
|
||||
nsresult rv = manager->AbortPayment(this, mDeferredShow);
|
||||
mDeferredShow = false;
|
||||
nsresult rv = manager->AbortPayment(this);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
|
@ -905,8 +901,7 @@ PaymentRequest::RespondAbortPayment(bool aSuccess)
|
|||
}
|
||||
|
||||
nsresult
|
||||
PaymentRequest::UpdatePayment(JSContext* aCx, const PaymentDetailsUpdate& aDetails,
|
||||
bool aDeferredShow)
|
||||
PaymentRequest::UpdatePayment(JSContext* aCx, const PaymentDetailsUpdate& aDetails)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCx);
|
||||
if (mState != eInteractive) {
|
||||
|
@ -916,8 +911,7 @@ PaymentRequest::UpdatePayment(JSContext* aCx, const PaymentDetailsUpdate& aDetai
|
|||
if (NS_WARN_IF(!manager)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsresult rv = manager->UpdatePayment(aCx, this, aDetails, mRequestShipping,
|
||||
aDeferredShow);
|
||||
nsresult rv = manager->UpdatePayment(aCx, this, aDetails, mRequestShipping);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -925,7 +919,7 @@ PaymentRequest::UpdatePayment(JSContext* aCx, const PaymentDetailsUpdate& aDetai
|
|||
}
|
||||
|
||||
void
|
||||
PaymentRequest::AbortUpdate(nsresult aRv, bool aDeferredShow)
|
||||
PaymentRequest::AbortUpdate(nsresult aRv)
|
||||
{
|
||||
MOZ_ASSERT(NS_FAILED(aRv));
|
||||
|
||||
|
@ -935,7 +929,7 @@ PaymentRequest::AbortUpdate(nsresult aRv, bool aDeferredShow)
|
|||
// Close down any remaining user interface.
|
||||
RefPtr<PaymentRequestManager> manager = PaymentRequestManager::GetSingleton();
|
||||
MOZ_ASSERT(manager);
|
||||
nsresult rv = manager->AbortPayment(this, aDeferredShow);
|
||||
nsresult rv = manager->AbortPayment(this);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
@ -1138,33 +1132,29 @@ PaymentRequest::ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue)
|
|||
// Converting value to a PaymentDetailsUpdate dictionary
|
||||
PaymentDetailsUpdate details;
|
||||
if (!details.Init(aCx, aValue)) {
|
||||
AbortUpdate(NS_ERROR_DOM_TYPE_ERR, mDeferredShow);
|
||||
AbortUpdate(NS_ERROR_DOM_TYPE_ERR);
|
||||
JS_ClearPendingException(aCx);
|
||||
return;
|
||||
}
|
||||
|
||||
nsresult rv = IsValidDetailsUpdate(details, mRequestShipping);
|
||||
if (NS_FAILED(rv)) {
|
||||
AbortUpdate(rv, mDeferredShow);
|
||||
AbortUpdate(rv);
|
||||
return;
|
||||
}
|
||||
|
||||
// Update the PaymentRequest with the new details
|
||||
if (NS_FAILED(UpdatePayment(aCx, details, mDeferredShow))) {
|
||||
AbortUpdate(NS_ERROR_DOM_ABORT_ERR, mDeferredShow);
|
||||
if (NS_FAILED(UpdatePayment(aCx, details))) {
|
||||
AbortUpdate(NS_ERROR_DOM_ABORT_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
mDeferredShow = false;
|
||||
}
|
||||
|
||||
void
|
||||
PaymentRequest::RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue)
|
||||
{
|
||||
MOZ_ASSERT(mDeferredShow);
|
||||
mUpdating = false;
|
||||
AbortUpdate(NS_ERROR_DOM_ABORT_ERR, mDeferredShow);
|
||||
mDeferredShow = false;
|
||||
AbortUpdate(NS_ERROR_DOM_ABORT_ERR);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -143,9 +143,8 @@ public:
|
|||
nsresult UpdateShippingOption(const nsAString& aShippingOption);
|
||||
|
||||
nsresult UpdatePayment(JSContext* aCx,
|
||||
const PaymentDetailsUpdate& aDetails,
|
||||
bool aDeferredShow);
|
||||
void AbortUpdate(nsresult aRv, bool aDeferredShow);
|
||||
const PaymentDetailsUpdate& aDetails);
|
||||
void AbortUpdate(nsresult aRv);
|
||||
|
||||
void SetShippingType(const Nullable<PaymentShippingType>& aShippingType);
|
||||
Nullable<PaymentShippingType> GetShippingType() const;
|
||||
|
@ -210,10 +209,6 @@ protected:
|
|||
// but we don't actually store the full [[options]] internal slot.
|
||||
bool mRequestShipping;
|
||||
|
||||
// True if the user passed a promise to show, causing us to defer telling the
|
||||
// front end about it.
|
||||
bool mDeferredShow;
|
||||
|
||||
// The error is set in AbortUpdate(). The value is NS_OK by default.
|
||||
nsresult mUpdateError;
|
||||
|
||||
|
|
|
@ -537,33 +537,25 @@ PaymentRequestManager::CanMakePayment(PaymentRequest* aRequest)
|
|||
nsAutoString requestId;
|
||||
aRequest->GetInternalId(requestId);
|
||||
IPCPaymentCanMakeActionRequest action(requestId);
|
||||
|
||||
return SendRequestPayment(aRequest, action);
|
||||
}
|
||||
|
||||
nsresult
|
||||
PaymentRequestManager::ShowPayment(PaymentRequest* aRequest)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (!aRequest->IsUpdating()) {
|
||||
nsAutoString requestId;
|
||||
aRequest->GetInternalId(requestId);
|
||||
IPCPaymentShowActionRequest action(requestId);
|
||||
rv = SendRequestPayment(aRequest, action);
|
||||
}
|
||||
return rv;
|
||||
nsAutoString requestId;
|
||||
aRequest->GetInternalId(requestId);
|
||||
IPCPaymentShowActionRequest action(requestId, aRequest->IsUpdating());
|
||||
return SendRequestPayment(aRequest, action);
|
||||
}
|
||||
|
||||
nsresult
|
||||
PaymentRequestManager::AbortPayment(PaymentRequest* aRequest, bool aDeferredShow)
|
||||
PaymentRequestManager::AbortPayment(PaymentRequest* aRequest)
|
||||
{
|
||||
nsAutoString requestId;
|
||||
aRequest->GetInternalId(requestId);
|
||||
IPCPaymentAbortActionRequest action(requestId);
|
||||
|
||||
// If aDeferredShow is true, then show was called with a promise that was
|
||||
// rejected. In that case, we need to remember that we called show earlier.
|
||||
return SendRequestPayment(aRequest, action, aDeferredShow);
|
||||
return SendRequestPayment(aRequest, action);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -585,7 +577,6 @@ PaymentRequestManager::CompletePayment(PaymentRequest* aRequest,
|
|||
nsAutoString requestId;
|
||||
aRequest->GetInternalId(requestId);
|
||||
IPCPaymentCompleteActionRequest action(requestId, completeStatusString);
|
||||
|
||||
return SendRequestPayment(aRequest, action, false);
|
||||
}
|
||||
|
||||
|
@ -593,8 +584,7 @@ nsresult
|
|||
PaymentRequestManager::UpdatePayment(JSContext* aCx,
|
||||
PaymentRequest* aRequest,
|
||||
const PaymentDetailsUpdate& aDetails,
|
||||
bool aRequestShipping,
|
||||
bool aDeferredShow)
|
||||
bool aRequestShipping)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCx);
|
||||
IPCPaymentDetails details;
|
||||
|
@ -613,10 +603,7 @@ PaymentRequestManager::UpdatePayment(JSContext* aCx,
|
|||
nsAutoString requestId;
|
||||
aRequest->GetInternalId(requestId);
|
||||
IPCPaymentUpdateActionRequest action(requestId, details, shippingOption);
|
||||
|
||||
// If aDeferredShow is true, then this call serves as the ShowUpdate call for
|
||||
// this request.
|
||||
return SendRequestPayment(aRequest, action, aDeferredShow);
|
||||
return SendRequestPayment(aRequest, action, false);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -48,15 +48,14 @@ public:
|
|||
|
||||
nsresult CanMakePayment(PaymentRequest* aRequest);
|
||||
nsresult ShowPayment(PaymentRequest* aRequest);
|
||||
nsresult AbortPayment(PaymentRequest* aRequest, bool aDeferredShow);
|
||||
nsresult AbortPayment(PaymentRequest* aRequest);
|
||||
nsresult CompletePayment(PaymentRequest* aRequest,
|
||||
const PaymentComplete& aComplete,
|
||||
bool aTimedOut = false);
|
||||
nsresult UpdatePayment(JSContext* aCx,
|
||||
PaymentRequest* aRequest,
|
||||
const PaymentDetailsUpdate& aDetails,
|
||||
bool aRequestShipping,
|
||||
bool aDeferredShow);
|
||||
bool aRequestShipping);
|
||||
nsresult ClosePayment(PaymentRequest* aRequest);
|
||||
nsresult RetryPayment(JSContext* aCx,
|
||||
PaymentRequest* aRequest,
|
||||
|
|
|
@ -279,7 +279,8 @@ PaymentRequestService::RequestPayment(const nsAString& aRequestId,
|
|||
break;
|
||||
}
|
||||
case IPCPaymentActionRequest::TIPCPaymentShowActionRequest: {
|
||||
rv = ShowPayment(aRequestId);
|
||||
const IPCPaymentShowActionRequest& action = aAction;
|
||||
rv = ShowPayment(aRequestId, action.isUpdating());
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -316,21 +317,18 @@ PaymentRequestService::RequestPayment(const nsAString& aRequestId,
|
|||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// mShowingRequest exists and it equals to the updated PaymentRequest
|
||||
// Call UI::UpdatePayment
|
||||
if (mShowingRequest && mShowingRequest == request) {
|
||||
rv = LaunchUIAction(aRequestId, type);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
} else {
|
||||
// mShowingRequest does not equal to the updated PaymentRequest, try to
|
||||
// show the updated one.
|
||||
rv = ShowPayment(aRequestId);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
nsAutoString completeStatus;
|
||||
rv = request->GetCompleteStatus(completeStatus);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
if (completeStatus.Equals(NS_LITERAL_STRING("initial"))) {
|
||||
request->SetCompleteStatus(EmptyString());
|
||||
}
|
||||
MOZ_ASSERT(mShowingRequest && mShowingRequest == request);
|
||||
rv = LaunchUIAction(aRequestId, type);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -516,7 +514,7 @@ PaymentRequestService::CanMakePayment(const nsAString& aRequestId)
|
|||
}
|
||||
|
||||
nsresult
|
||||
PaymentRequestService::ShowPayment(const nsAString& aRequestId)
|
||||
PaymentRequestService::ShowPayment(const nsAString& aRequestId, bool aIsUpdating)
|
||||
{
|
||||
nsresult rv;
|
||||
RefPtr<payments::PaymentRequest> request;
|
||||
|
@ -526,6 +524,9 @@ PaymentRequestService::ShowPayment(const nsAString& aRequestId)
|
|||
}
|
||||
MOZ_ASSERT(request);
|
||||
request->SetState(payments::PaymentRequest::eInteractive);
|
||||
if (aIsUpdating) {
|
||||
request->SetCompleteStatus(NS_LITERAL_STRING("initial"));
|
||||
}
|
||||
|
||||
if (mShowingRequest || !CanMakePayment(aRequestId)) {
|
||||
uint32_t responseStatus;
|
||||
|
|
|
@ -50,7 +50,7 @@ private:
|
|||
CanMakePayment(const nsAString& aRequestId);
|
||||
|
||||
nsresult
|
||||
ShowPayment(const nsAString& aRequestId);
|
||||
ShowPayment(const nsAString& aRequestId, bool aIsUpdating);
|
||||
|
||||
bool
|
||||
IsBasicCardPayment(const nsAString& aRequestId);
|
||||
|
|
|
@ -64,7 +64,7 @@ PaymentRequestUpdateEvent::ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value
|
|||
// Converting value to a PaymentDetailsUpdate dictionary
|
||||
PaymentDetailsUpdate details;
|
||||
if (!details.Init(aCx, aValue)) {
|
||||
mRequest->AbortUpdate(NS_ERROR_TYPE_ERR, false);
|
||||
mRequest->AbortUpdate(NS_ERROR_TYPE_ERR);
|
||||
JS_ClearPendingException(aCx);
|
||||
return;
|
||||
}
|
||||
|
@ -76,13 +76,13 @@ PaymentRequestUpdateEvent::ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value
|
|||
// PaymentRequest.
|
||||
nsresult rv = mRequest->IsValidDetailsUpdate(details, true/*aRequestShipping*/);
|
||||
if (NS_FAILED(rv)) {
|
||||
mRequest->AbortUpdate(rv, false);
|
||||
mRequest->AbortUpdate(rv);
|
||||
return;
|
||||
}
|
||||
|
||||
// Update the PaymentRequest with the new details
|
||||
if (NS_FAILED(mRequest->UpdatePayment(aCx, details, false))) {
|
||||
mRequest->AbortUpdate(NS_ERROR_DOM_ABORT_ERR, false);
|
||||
if (NS_FAILED(mRequest->UpdatePayment(aCx, details))) {
|
||||
mRequest->AbortUpdate(NS_ERROR_DOM_ABORT_ERR);
|
||||
return;
|
||||
}
|
||||
mWaitForUpdate = false;
|
||||
|
@ -94,7 +94,7 @@ PaymentRequestUpdateEvent::RejectedCallback(JSContext* aCx, JS::Handle<JS::Value
|
|||
{
|
||||
MOZ_ASSERT(mRequest);
|
||||
|
||||
mRequest->AbortUpdate(NS_ERROR_DOM_ABORT_ERR, false);
|
||||
mRequest->AbortUpdate(NS_ERROR_DOM_ABORT_ERR);
|
||||
mWaitForUpdate = false;
|
||||
mRequest->SetUpdating(false);
|
||||
}
|
||||
|
|
|
@ -87,6 +87,7 @@ struct IPCPaymentCanMakeActionRequest
|
|||
struct IPCPaymentShowActionRequest
|
||||
{
|
||||
nsString requestId;
|
||||
bool isUpdating;
|
||||
};
|
||||
|
||||
struct IPCPaymentAbortActionRequest
|
||||
|
|
|
@ -6,15 +6,12 @@
|
|||
const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
const paymentSrv = Cc["@mozilla.org/dom/payments/payment-request-service;1"].getService(Ci.nsIPaymentRequestService);
|
||||
let expectedCompleteStatus = null;
|
||||
let expectedShowAction = "accept";
|
||||
let expectedUpdateAction = "accept";
|
||||
|
||||
function emitTestFail(message) {
|
||||
sendAsyncMessage("test-fail", message);
|
||||
sendAsyncMessage("test-fail", `${DummyUIService.testName}: ${message}`);
|
||||
}
|
||||
function emitTestPass(message) {
|
||||
sendAsyncMessage("test-pass", message);
|
||||
sendAsyncMessage("test-pass", `${DummyUIService.testName}: ${message}`);
|
||||
}
|
||||
|
||||
const shippingAddress = Cc["@mozilla.org/dom/payments/payment-address;1"].
|
||||
|
@ -68,24 +65,29 @@ function rejectShow(requestId) {
|
|||
}
|
||||
|
||||
function updateShow(requestId) {
|
||||
if (expectedUpdateAction == "updateaddress") {
|
||||
if (DummyUIService.expectedUpdateAction == "updateaddress") {
|
||||
paymentSrv.changeShippingAddress(requestId, shippingAddress);
|
||||
} else if (expectedUpdateAction == "accept" || expectedUpdateAction == "error"){
|
||||
} else if (DummyUIService.expectedUpdateAction == "accept" ||
|
||||
DummyUIService.expectedUpdateAction == "error"){
|
||||
paymentSrv.changeShippingOption(requestId, "FastShipping");
|
||||
} else {
|
||||
emitTestFail("Unknown expected update action: " + expectedUpdateAction);
|
||||
emitTestFail("Unknown expected update action: " + DummyUIService.expectedUpdateAction);
|
||||
}
|
||||
}
|
||||
|
||||
function showRequest(requestId) {
|
||||
if (expectedShowAction == "accept") {
|
||||
const request = paymentSrv.getPaymentRequestById(requestId);
|
||||
if (request.completeStatus == "initial") {
|
||||
return;
|
||||
}
|
||||
if (DummyUIService.expectedShowAction == "accept") {
|
||||
acceptShow(requestId);
|
||||
} else if (expectedShowAction == "reject") {
|
||||
} else if (DummyUIService.expectedShowAction == "reject") {
|
||||
rejectShow(requestId);
|
||||
} else if (expectedShowAction == "update") {
|
||||
} else if (DummyUIService.expectedShowAction == "update") {
|
||||
updateShow(requestId);
|
||||
} else {
|
||||
emitTestFail("Unknown expected show action: " + expectedShowAction);
|
||||
emitTestFail("Unknown expected show action: " + DummyUIService.expectedShowAction);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,14 +99,14 @@ function abortRequest(requestId) {
|
|||
}
|
||||
|
||||
function completeRequest(requestId) {
|
||||
let payRequest = paymentSrv.getPaymentRequestById(requestId);
|
||||
if (expectedCompleteStatus) {
|
||||
if (payRequest.completeStatus == expectedCompleteStatus) {
|
||||
let request = paymentSrv.getPaymentRequestById(requestId);
|
||||
if (DummyUIService.expectedCompleteStatus) {
|
||||
if (request.completeStatus == DummyUIService.expectedCompleteStatus) {
|
||||
emitTestPass("request.completeStatus matches expectation of " +
|
||||
expectedCompleteStatus);
|
||||
DummyUIService.expectedCompleteStatus);
|
||||
} else {
|
||||
emitTestFail("request.completeStatus incorrect. Expected " +
|
||||
expectedCompleteStatus + ", got " + payRequest.completeStatus);
|
||||
DummyUIService.expectedCompleteStatus + ", got " + request.completeStatus);
|
||||
}
|
||||
}
|
||||
let completeResponse = Cc["@mozilla.org/dom/payments/payment-complete-action-response;1"].
|
||||
|
@ -115,7 +117,10 @@ function completeRequest(requestId) {
|
|||
|
||||
function updateRequest(requestId) {
|
||||
let request = paymentSrv.getPaymentRequestById(requestId);
|
||||
if (expectedUpdateAction == "accept") {
|
||||
if (request.completeStatus !== "") {
|
||||
emitTestFail("request.completeStatus should be empty, but got '" + request.completeStatus + "'.");
|
||||
}
|
||||
if (DummyUIService.expectedUpdateAction == "accept") {
|
||||
if (request.paymentDetails.error != "") {
|
||||
emitTestFail("updatedDetails should not have errors(" + request.paymentDetails.error + ").");
|
||||
}
|
||||
|
@ -129,23 +134,27 @@ function updateRequest(requestId) {
|
|||
emitTestFail(shippingOption.label + " should be selected.");
|
||||
}
|
||||
acceptShow(requestId);
|
||||
} else if (expectedUpdateAction == "error") {
|
||||
} else if (DummyUIService.expectedUpdateAction == "error") {
|
||||
if (request.paymentDetails.error != "Update with Error") {
|
||||
emitTestFail("details.error should be 'Update with Error', but got " + request.paymentDetails.error + ".");
|
||||
}
|
||||
rejectShow(requestId);
|
||||
} else if (expectedUpdateAction == "updateaddress") {
|
||||
} else if (DummyUIService.expectedUpdateAction == "updateaddress") {
|
||||
if (request.paymentDetails.error != "") {
|
||||
emitTestFail("updatedDetails should not have errors(" + request.paymentDetails.error + ").");
|
||||
}
|
||||
expectedUpdateAction = "accept";
|
||||
DummyUIService.expectedUpdateAction = "accept";
|
||||
paymentSrv.changeShippingOption(requestId, "FastShipping");
|
||||
} else {
|
||||
emitTestFail("Unknown expected update aciton: " + expectedUpdateAction);
|
||||
emitTestFail("Unknown expected update aciton: " + DummyUIService.expectedUpdateAction);
|
||||
}
|
||||
}
|
||||
|
||||
const DummyUIService = {
|
||||
testName: "",
|
||||
expectedCompleteStatus: null,
|
||||
expectedShowAction: "accept",
|
||||
expectedUpdateAction: "accept",
|
||||
showPayment: showRequest,
|
||||
abortPayment: abortRequest,
|
||||
completePayment: completeRequest,
|
||||
|
@ -214,48 +223,61 @@ function testShowResponseInit() {
|
|||
sendAsyncMessage("test-show-response-init-complete");
|
||||
}
|
||||
|
||||
addMessageListener("set-simple-ui-service", function() {
|
||||
expectedCompleteStatus = null;
|
||||
expectedShowAction = "accept";
|
||||
expectedUpdateAction = "accept";
|
||||
addMessageListener("set-simple-ui-service", function(testName) {
|
||||
DummyUIService.testName = testName;
|
||||
DummyUIService.expectedCompleteStatus = null;
|
||||
DummyUIService.expectedShowAction = "accept";
|
||||
DummyUIService.expectedUpdateAction = "accept";
|
||||
sendAsyncMessage("set-simple-ui-service-complete");
|
||||
});
|
||||
|
||||
addMessageListener("set-normal-ui-service", function() {
|
||||
expectedCompleteStatus = null;
|
||||
expectedShowAction = "update";
|
||||
expectedUpdateAction = "updateaddress";
|
||||
addMessageListener("set-normal-ui-service", function(testName) {
|
||||
DummyUIService.testName = testName;
|
||||
DummyUIService.expectedCompleteStatus = null;
|
||||
DummyUIService.expectedShowAction = "update";
|
||||
DummyUIService.expectedUpdateAction = "updateaddress";
|
||||
sendAsyncMessage("set-normal-ui-service-complete");
|
||||
});
|
||||
|
||||
addMessageListener("set-reject-ui-service", function() {
|
||||
expectedCompleteStatus = null;
|
||||
expectedShowAction = "reject";
|
||||
expectedUpdateAction = "accept";
|
||||
addMessageListener("set-reject-ui-service", function(testName) {
|
||||
DummyUIService.testName = testName;
|
||||
DummyUIService.expectedCompleteStatus = null;
|
||||
DummyUIService.expectedShowAction = "reject";
|
||||
DummyUIService.expectedUpdateAction = "error";
|
||||
sendAsyncMessage("set-reject-ui-service-complete");
|
||||
});
|
||||
|
||||
addMessageListener("set-update-with-ui-service", function() {
|
||||
expectedCompleteStatus = null;
|
||||
expectedShowAction = "update";
|
||||
expectedUpdateAction = "accept";
|
||||
addMessageListener("set-update-with-ui-service", function(testName) {
|
||||
DummyUIService.testName = testName;
|
||||
DummyUIService.expectedCompleteStatus = null;
|
||||
DummyUIService.expectedShowAction = "update";
|
||||
DummyUIService.expectedUpdateAction = "accept";
|
||||
sendAsyncMessage("set-update-with-ui-service-complete");
|
||||
});
|
||||
|
||||
addMessageListener("set-update-with-error-ui-service", function() {
|
||||
expectedCompleteStatus = null;
|
||||
expectedShowAction = "update";
|
||||
expectedUpdateAction = "error";
|
||||
addMessageListener("set-update-with-error-ui-service", function(testName) {
|
||||
DummyUIService.testName = testName;
|
||||
DummyUIService.expectedCompleteStatus = null;
|
||||
DummyUIService.expectedShowAction = "update";
|
||||
DummyUIService.expectedUpdateAction = "error";
|
||||
sendAsyncMessage("set-update-with-error-ui-service-complete");
|
||||
});
|
||||
|
||||
addMessageListener("test-show-response-init", testShowResponseInit);
|
||||
|
||||
addMessageListener("set-complete-status-success", function() {
|
||||
expectedCompleteStatus = "success";
|
||||
DummyUIService.expectedCompleteStatus = "success";
|
||||
sendAsyncMessage("set-complete-status-success-complete");
|
||||
});
|
||||
|
||||
addMessageListener("set-complete-status-fail", function() {
|
||||
expectedCompleteStatus = "fail";
|
||||
DummyUIService.expectedCompleteStatus = "fail";
|
||||
sendAsyncMessage("set-complete-status-fail-complete");
|
||||
});
|
||||
|
||||
addMessageListener("set-complete-status-unknown", function() {
|
||||
expectedCompleteStatus = "unknown";
|
||||
DummyUIService.expectedCompleteStatus = "unknown";
|
||||
sendAsyncMessage("set-complete-status-unknown-complete");
|
||||
});
|
||||
|
||||
addMessageListener("teardown", function() {
|
||||
|
|
|
@ -25,6 +25,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1345366
|
|||
gScript.addMessageListener("test-fail", testFailHandler);
|
||||
gScript.addMessageListener("test-pass", testPassHandler);
|
||||
|
||||
async function requestChromeAction(action, params) {
|
||||
await new Promise(resolve => {
|
||||
gScript.addMessageListener(`${action}-complete`, function completeListener() {
|
||||
gScript.removeMessageListener(`${action}-complete`, completeListener);
|
||||
resolve();
|
||||
});
|
||||
gScript.sendAsyncMessage(action, params);
|
||||
});
|
||||
}
|
||||
|
||||
// testing data declaration
|
||||
// default parameters for PaymentRequest construction
|
||||
const defaultMethods = [{
|
||||
|
@ -127,303 +137,335 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1345366
|
|||
|
||||
|
||||
// checking functions
|
||||
function checkAddress(address, fromEvent) {
|
||||
is(address.country, "USA", "address.country should be 'USA'.");
|
||||
is(address.region, "CA", "address.region should be 'CA'.");
|
||||
is(address.city, "San Bruno", "address.city should be 'San Bruno'.");
|
||||
is(address.dependentLocality, "Test locality",
|
||||
"address.dependentLocality should be 'Test locality'.");
|
||||
is(address.postalCode, "94066", "address.postalCode should be '94066'.");
|
||||
is(address.sortingCode, "123456", "address.sortingCode should be '123456'.");
|
||||
function checkAddress(testName, address, fromEvent) {
|
||||
is(address.country,
|
||||
"USA",
|
||||
`${testName}: address.country should be 'USA'.`);
|
||||
is(address.region,
|
||||
"CA",
|
||||
`${testName}: address.region should be 'CA'.`);
|
||||
is(address.city,
|
||||
"San Bruno",
|
||||
`${testName}: address.city should be 'San Bruno'.`);
|
||||
is(address.dependentLocality,
|
||||
"Test locality",
|
||||
`${testName}: address.dependentLocality should be 'Test locality'.`);
|
||||
is(address.postalCode,
|
||||
"94066",
|
||||
`${testName}: address.postalCode should be '94066'.`);
|
||||
is(address.sortingCode,
|
||||
"123456",
|
||||
`${testName}: address.sortingCode should be '123456'.`);
|
||||
if (fromEvent) {
|
||||
is(address.addressLine.length, 0, "address.addressLine.length should be 0 from event.");
|
||||
is(address.organization, "", "address.organization should be empty from event.");
|
||||
is(address.recipient, "", "address.recipient should be empty from event.");
|
||||
is(address.phone, "", "address.phone should be empty from event.");
|
||||
is(address.addressLine.length,
|
||||
0,
|
||||
`${testName}: address.addressLine.length should be 0 from event.`);
|
||||
is(address.organization,
|
||||
"",
|
||||
`${testName}: address.organization should be empty from event.`);
|
||||
is(address.recipient,
|
||||
"",
|
||||
`${testName}: address.recipient should be empty from event.`);
|
||||
is(address.phone,
|
||||
"",
|
||||
`${testName}: address.phone should be empty from event.`);
|
||||
} else {
|
||||
is(address.addressLine.length, 1, "address.addressLine.length should be 1 from promise.");
|
||||
is(address.addressLine[0], "Easton Ave", "address.addressLine[0] should be 'Easton Ave' from promise.");
|
||||
is(address.organization, "Testing Org", "address.organization should be 'Testing Org' from promise.");
|
||||
is(address.recipient, "Bill A. Pacheco", "address.recipient should be 'Bill A. Pacheco' from promise.");
|
||||
is(address.phone, "+1-434-441-3879", "address.phone should be '+1-434-441-3879' from promise.");
|
||||
is(address.addressLine.length,
|
||||
1,
|
||||
`${testName}: address.addressLine.length should be 1 from promise.`);
|
||||
is(address.addressLine[0],
|
||||
"Easton Ave",
|
||||
`${testName}: address.addressLine[0] should be 'Easton Ave' from promise.`);
|
||||
is(address.organization,
|
||||
"Testing Org",
|
||||
`${testName}: address.organization should be 'Testing Org' from promise.`);
|
||||
is(address.recipient,
|
||||
"Bill A. Pacheco",
|
||||
`${testName}: address.recipient should be 'Bill A. Pacheco' from promise.`);
|
||||
is(address.phone,
|
||||
"+1-434-441-3879",
|
||||
`${testName}: address.phone should be '+1-434-441-3879' from promise.`);
|
||||
}
|
||||
}
|
||||
|
||||
function checkResponse(response) {
|
||||
is(response.requestId, "test payment", "response.requestId should be 'test payment'.");
|
||||
is(response.methodName, "testing-payment-method", "response.methodName should be 'testing-payment-method'.");
|
||||
is(response.details.paymentToken, "6880281f-0df3-4b8e-916f-66575e2457c1", "response.details.paymentToken should be '6880281f-0df3-4b8e-916f-66575e2457c1'.");
|
||||
checkAddress(response.shippingAddress, false/*fromEvent*/);
|
||||
is(response.shippingOption, "FastShipping", "response.shippingOption should be 'FastShipping'.");
|
||||
is(response.payerName, "Bill A. Pacheco", "response.payerName should be 'Bill A. Pacheco'.");
|
||||
ok(!response.payerEmail, "response.payerEmail should be empty");
|
||||
ok(!response.payerPhone, "response.payerPhone should be empty");
|
||||
function checkResponse(testName, response) {
|
||||
is(response.requestId,
|
||||
"test payment",
|
||||
`${testName}: response.requestId should be 'test payment'.`);
|
||||
is(response.methodName,
|
||||
"testing-payment-method",
|
||||
`${testName}: response.methodName should be 'testing-payment-method'.`);
|
||||
is(response.details.paymentToken,
|
||||
"6880281f-0df3-4b8e-916f-66575e2457c1",
|
||||
`${testName}: response.details.paymentToken should be '6880281f-0df3-4b8e-916f-66575e2457c1'.`);
|
||||
checkAddress(testName, response.shippingAddress, false/*fromEvent*/);
|
||||
is(response.shippingOption,
|
||||
"FastShipping",
|
||||
`${testName}: response.shippingOption should be 'FastShipping'.`);
|
||||
is(response.payerName,
|
||||
"Bill A. Pacheco",
|
||||
`${testName}: response.payerName should be 'Bill A. Pacheco'.`);
|
||||
ok(!response.payerEmail,
|
||||
`${testName}: response.payerEmail should be empty`);
|
||||
ok(!response.payerPhone,
|
||||
`${testName}: response.payerPhone should be empty`);
|
||||
}
|
||||
|
||||
// testing functions
|
||||
function testShowNormalFlow() {
|
||||
gScript.sendAsyncMessage("set-normal-ui-service");
|
||||
return new Promise((resolve, reject) => {
|
||||
const payRequest = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions);
|
||||
payRequest.addEventListener("shippingaddresschange", event => {
|
||||
checkAddress(payRequest.shippingAddress, true/*fromEvent*/);
|
||||
async function testShowNormalFlow() {
|
||||
const testName = "testShowNormalFlow";
|
||||
await requestChromeAction("set-normal-ui-service", testName);
|
||||
return new Promise(async (resolve) => {
|
||||
const request = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions);
|
||||
request.addEventListener("shippingaddresschange", event => {
|
||||
checkAddress(testName, request.shippingAddress, true/*fromEvent*/);
|
||||
event.updateWith(updateWithPromise(defaultDetails));
|
||||
});
|
||||
payRequest.addEventListener("shippingoptionchange", event => {
|
||||
request.addEventListener("shippingoptionchange", event => {
|
||||
event.updateWith(updateWithPromise(updatedShippingOptionsDetails));
|
||||
});
|
||||
const handler = SpecialPowers.getDOMWindowUtils(window).setHandlingUserInput(true);
|
||||
payRequest.show().then(response => {
|
||||
checkResponse(response, false);
|
||||
checkAddress(payRequest.shippingAddress, false);
|
||||
response.complete().then(() =>{
|
||||
resolve();
|
||||
}).catch(e => {
|
||||
ok(false, "Unexpected error: " + e.name);
|
||||
resolve();
|
||||
});
|
||||
}).catch( e => {
|
||||
ok(false, "Unexpected error: " + e.name);
|
||||
resolve();
|
||||
}).finally(handler.destruct);
|
||||
try {
|
||||
let response = await request.show();
|
||||
checkResponse(testName, response, false);
|
||||
await response.complete();
|
||||
} catch (error) {
|
||||
ok(false, `${testName} Unexpected error: ${e.name}`);
|
||||
}
|
||||
await handler.destruct();
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
||||
// testing show with nonsupported methods
|
||||
function testCannotMakePaymentShow() {
|
||||
gScript.sendAsyncMessage("set-simple-ui-service");
|
||||
return new Promise((resolve, reject) => {
|
||||
const payRequest = new PaymentRequest(nonSupportedMethods, defaultDetails);
|
||||
async function testCannotMakePaymentShow() {
|
||||
const testName = "testCannotMakePaymentShow";
|
||||
await requestChromeAction("set-simple-ui-service", testName);
|
||||
return new Promise(async (resolve) => {
|
||||
const request = new PaymentRequest(nonSupportedMethods, defaultDetails);
|
||||
const handler = SpecialPowers.getDOMWindowUtils(window).setHandlingUserInput(true);
|
||||
payRequest.canMakePayment().then(result => {
|
||||
ok(!result, "canMakePayment() should return false, but got " + result + ".");
|
||||
payRequest.show().then( () => {
|
||||
ok(false, "Should be rejected with 'NotSupportedError', but got resolved");
|
||||
resolve();
|
||||
}).catch( e => {
|
||||
is(e.name, "NotSupportedError", "Should be rejected with 'NotSupportedError', but got " + e.name + ".");
|
||||
resolve();
|
||||
});
|
||||
}).finally(handler.destruct);
|
||||
let result = await request.canMakePayment();
|
||||
ok(!result, `${testName}: canMakePayment() should return false.`);
|
||||
try {
|
||||
await request.show();
|
||||
ok(false, `${testName}: should be rejected with 'NotSupportedError' but got resolved.`);
|
||||
} catch (error) {
|
||||
is(error.name, "NotSupportedError", `${testName}: should be rejected with 'NotSupportedError'.`);
|
||||
}
|
||||
await handler.destruct();
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
||||
// testing show rejected by user
|
||||
function testRejectShow() {
|
||||
gScript.sendAsyncMessage("set-reject-ui-service");
|
||||
return new Promise((resolve, reject) => {
|
||||
const payRequest = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions);
|
||||
async function testRejectShow() {
|
||||
const testName = "testRejectShow";
|
||||
await requestChromeAction("set-reject-ui-service", testName);
|
||||
return new Promise(async(resolve) => {
|
||||
const request = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions);
|
||||
const handler = SpecialPowers.getDOMWindowUtils(window).setHandlingUserInput(true);
|
||||
payRequest.show().then((result) => {
|
||||
ok(false, "Should be rejected with 'AbortError', but got resolved");
|
||||
resolve();
|
||||
}, (result) => {
|
||||
is(result.name, "AbortError", "Should be rejected with 'AbortError', but got " + result.name + ".");
|
||||
resolve();
|
||||
}).catch(e => {
|
||||
ok(false, "Unexpected error: " + e.name);
|
||||
resolve();
|
||||
}).finally(handler.destruct);
|
||||
try {
|
||||
await request.show();
|
||||
ok(false, `${testName}: Should be rejected with 'AbortError' but got resolved.`);
|
||||
} catch(error) {
|
||||
is(error.name, "AbortError", `${testName}: Should be rejected with 'AbortError'.`);
|
||||
}
|
||||
await handler.destruct();
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
||||
// testing PaymentResponse.complete() with specified result
|
||||
function testCompleteStatus(result) {
|
||||
gScript.sendAsyncMessage("set-simple-ui-service");
|
||||
async function testCompleteStatus(testName, result) {
|
||||
await requestChromeAction("set-simple-ui-service", testName);
|
||||
if (result) {
|
||||
gScript.sendAsyncMessage("set-complete-status-"+result);
|
||||
await requestChromeAction(`set-complete-status-${result}`);
|
||||
} else {
|
||||
gScript.sendAsyncMessage("set-complete-status-unknown");
|
||||
await requestChromeAction(`set-complete-status-unknown`);
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
const payRequest = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions);
|
||||
return new Promise(async (resolve) => {
|
||||
const request = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions);
|
||||
const handler = SpecialPowers.getDOMWindowUtils(window).setHandlingUserInput(true);
|
||||
payRequest.show().then(response => {
|
||||
response.complete(result).then(() => {
|
||||
resolve();
|
||||
}).catch(e => {
|
||||
ok(false, "Unexpected error: " + e.name);
|
||||
resolve();
|
||||
});
|
||||
}).catch( e => {
|
||||
ok(false, "Unexpected error: " + e.name);
|
||||
resolve();
|
||||
}).finally(handler.destruct);
|
||||
try {
|
||||
let response = await request.show();
|
||||
await response.complete(result);
|
||||
} catch (error) {
|
||||
ok(false, `${testName}: Unexpected error ${error.name}.`);
|
||||
}
|
||||
await handler.destruct();
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
||||
function testCompleteFail() {
|
||||
return testCompleteStatus("fail");
|
||||
async function testCompleteFail() {
|
||||
const testName = "testCompleteFail";
|
||||
return testCompleteStatus(testName, "fail");
|
||||
}
|
||||
|
||||
function testCompleteSuccess() {
|
||||
return testCompleteStatus("success");
|
||||
async function testCompleteSuccess() {
|
||||
const testName = "testCompleteSuccess";
|
||||
return testCompleteStatus(testName, "success");
|
||||
}
|
||||
|
||||
function testCompleteUnknown() {
|
||||
return testCompleteStatus("unknown");
|
||||
async function testCompleteUnknown() {
|
||||
const testName = "testCompleteUnknown"
|
||||
return testCompleteStatus(testName, "unknown");
|
||||
}
|
||||
|
||||
function testCompleteEmpty() {
|
||||
return testCompleteStatus();
|
||||
async function testCompleteEmpty() {
|
||||
const testName = "testCompleteEmpty";
|
||||
return testCompleteStatus(testName);
|
||||
}
|
||||
|
||||
// testing PaymentRequestUpdateEvent.updateWith with specified details and error
|
||||
function testUpdateWith(detailsUpdate, expectedError) {
|
||||
async function testUpdateWith(testName, detailsUpdate, expectedError) {
|
||||
if (expectedError) {
|
||||
gScript.sendAsyncMessage("set-update-with-error-ui-service");
|
||||
await requestChromeAction("set-update-with-error-ui-service", testName);
|
||||
} else {
|
||||
gScript.sendAsyncMessage("set-update-with-ui-service");
|
||||
await requestChromeAction("set-update-with-ui-service", testName);
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
const payRequest = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions);
|
||||
payRequest.addEventListener("shippingaddresschange", event => {
|
||||
return new Promise(async (resolve) => {
|
||||
const request = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions);
|
||||
request.addEventListener("shippingaddresschange", event => {
|
||||
event.updateWith(updateWithPromise(detailsUpdate));
|
||||
});
|
||||
payRequest.addEventListener("shippingoptionchange", event => {
|
||||
request.addEventListener("shippingoptionchange", event => {
|
||||
event.updateWith(updateWithPromise(detailsUpdate));
|
||||
});
|
||||
const handler = SpecialPowers.getDOMWindowUtils(window).setHandlingUserInput(true);
|
||||
payRequest.show().then(response => {
|
||||
try {
|
||||
const response = await request.show();
|
||||
if (expectedError) {
|
||||
ok(false, "Should be rejected with " + expectedError + ", but got resolved");
|
||||
resolve();
|
||||
} else {
|
||||
response.complete("success").then(() => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
}, response => {
|
||||
ok(false, `${testName}: Should be rejected with ${expectedError} but got resolved.`);
|
||||
} else {
|
||||
await response.complete("success");
|
||||
}
|
||||
} catch(error) {
|
||||
if (expectedError) {
|
||||
is(response.name, expectedError,
|
||||
"Should be rejected with " + expectedError + ", but got " + response.name);
|
||||
} else {
|
||||
ok(false, "Unexpected error: " + response.name);
|
||||
}
|
||||
resolve();
|
||||
}).catch(e => {
|
||||
ok(false, "Unexpected error: " + e.name);
|
||||
resolve();
|
||||
}).finally(handler.destruct);
|
||||
is(error.name, expectedError, `${testName}: Should be rejected with ${expectedError}.`);
|
||||
} else {
|
||||
ok(false, `${testName}: Unexpected error ${error.name}.`);
|
||||
}
|
||||
}
|
||||
await handler.destruct();
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
||||
function testUpdateWithReject() {
|
||||
return testUpdateWith(null, "AbortError");
|
||||
async function testUpdateWithReject() {
|
||||
const testName = "testUpdateWithReject";
|
||||
return testUpdateWith(testName, null, "AbortError");
|
||||
}
|
||||
|
||||
function testUpdateWithValidDetails() {
|
||||
return testUpdateWith(updatedShippingOptionsDetails, null);
|
||||
async function testUpdateWithValidDetails() {
|
||||
const testName = "testUpdateWithValidDetails";
|
||||
return testUpdateWith(testName, updatedShippingOptionsDetails, null);
|
||||
}
|
||||
|
||||
function testUpdateWithInvalidDetails() {
|
||||
return testUpdateWith({total: "invalid details"}, "TypeError");
|
||||
async function testUpdateWithInvalidDetails() {
|
||||
const testName = "testUpdateWithInvalidDetails";
|
||||
return testUpdateWith(testName, {total: "invalid details"}, "TypeError");
|
||||
}
|
||||
|
||||
function testUpdateWithError() {
|
||||
return testUpdateWith(updatedErrorDetails, "AbortError");
|
||||
async function testUpdateWithError() {
|
||||
const testName = "testUpdateWithError";
|
||||
return testUpdateWith(testName, updatedErrorDetails, "AbortError");
|
||||
}
|
||||
|
||||
// testing show with detailsUpdate promise
|
||||
function testShowWithDetailsPromise(detailsUpdate, expectedError) {
|
||||
async function testShowWithDetailsPromise(testName, detailsUpdate, expectedError) {
|
||||
if (expectedError) {
|
||||
gScript.sendAsyncMessage("set-reject-ui-service");
|
||||
await requestChromeAction("set-reject-ui-service", testName);
|
||||
} else {
|
||||
gScript.sendAsyncMessage("set-simple-ui-service");
|
||||
await requestChromeAction("set-simple-ui-service", testName);
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
const payRequest = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions);
|
||||
ok(!payRequest.shippingOption, "payRequest.shippingOption should be null.");
|
||||
return new Promise(async (resolve) => {
|
||||
const request = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions);
|
||||
ok(!request.shippingOption, `${testName}: request.shippingOption should be null.`);
|
||||
const handler = SpecialPowers.getDOMWindowUtils(window).setHandlingUserInput(true);
|
||||
payRequest.show(updateWithPromise(detailsUpdate)).then(response => {
|
||||
try {
|
||||
let response = await request.show(updateWithPromise(detailsUpdate));
|
||||
if (expectedError) {
|
||||
ok(false, "Should be rejected with " + expectedError + ", but got resolved");
|
||||
resolve();
|
||||
} else {
|
||||
ok(response.shippingOption, "response.shippingOption should not be null.");
|
||||
response.complete().then(() => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
}, response => {
|
||||
ok(false, `${testName}: Should be rejected with ${expectedError} but got resolved.`);
|
||||
} else {
|
||||
ok(response.shippingOption,
|
||||
`${testName}: response.shippingOption should not be null.`);
|
||||
}
|
||||
await response.complete();
|
||||
} catch(error) {
|
||||
if (expectedError) {
|
||||
is(response.name, expectedError,
|
||||
"Should be rejected with " + expectedError + ", but got " + response.name);
|
||||
} else {
|
||||
ok(false, "Unexpected error: " + response.name);
|
||||
}
|
||||
resolve();
|
||||
}).catch(e => {
|
||||
ok(false, "Unexpected error: " + e.name);
|
||||
resolve();
|
||||
}).finally(handler.destruct);
|
||||
is(error.name, expectedError, `${testName}: Should be rejected with ${expectedError}.`);
|
||||
} else {
|
||||
ok(false, `${testName}: Unexpected error ${error.name}.`);
|
||||
}
|
||||
}
|
||||
await handler.destruct();
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
function testShowWithValidPromise() {
|
||||
return testShowWithDetailsPromise(updatedShippingOptionsDetails, null);
|
||||
async function testShowWithValidPromise() {
|
||||
const testName = "testShowWithValidPromise";
|
||||
return testShowWithDetailsPromise(testName, updatedShippingOptionsDetails, null);
|
||||
}
|
||||
|
||||
function testShowWithRejectedPromise() {
|
||||
return testShowWithDetailsPromise(null, "AbortError");
|
||||
async function testShowWithRejectedPromise() {
|
||||
const testName = "testShowWithRejectedPromise";
|
||||
return testShowWithDetailsPromise(testName, null, "AbortError");
|
||||
}
|
||||
|
||||
function testShowWithInvalidPromise() {
|
||||
return testShowWithDetailsPromise({total: "invalid details"}, "TypeError");
|
||||
async function testShowWithInvalidPromise() {
|
||||
const testName = "testShowWithInvalidPromise";
|
||||
return testShowWithDetailsPromise(testName, {total: "invalid details"}, "TypeError");
|
||||
}
|
||||
|
||||
function testShowWithErrorPromise() {
|
||||
return testShowWithDetailsPromise(updatedErrorDetails, "AbortError");
|
||||
async function testShowWithErrorPromise() {
|
||||
const testName = "testShowWithErrorPromise";
|
||||
return testShowWithDetailsPromise(testName, updatedErrorDetails, "AbortError");
|
||||
}
|
||||
|
||||
function testShowWithPromiseResolvedByRejectedPromise() {
|
||||
gScript.sendAsyncMessage("set-reject-ui-service");
|
||||
return new Promise((resolve, reject)=> {
|
||||
async function testShowWithPromiseResolvedByRejectedPromise() {
|
||||
const testName = "testShowWithPromiseResolvedByRejectedPromise";
|
||||
await requestChromeAction("set-reject-ui-service", testName);
|
||||
return new Promise(async (resolve)=> {
|
||||
const request = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions);
|
||||
const handler = SpecialPowers.getDOMWindowUtils(window).setHandlingUserInput(true);
|
||||
let rejectPromise = Promise.reject(new TypeError());
|
||||
let detailsUpdatePromise = Promise.resolve(rejectPromise);
|
||||
request.show(detailsUpdatePromise).then(response => {
|
||||
ok(false, "should be rejected with 'AbortError', but got resolved.");
|
||||
resolve();
|
||||
}, response => {
|
||||
is(response.name, "AbortError", "Exepcted 'AbortError', but got " + response.name + ".");
|
||||
resolve();
|
||||
}).catch(error => {
|
||||
ok(false, "Unexpected error: " + error.name + ".");
|
||||
}).finally(handler.destruct);
|
||||
try {
|
||||
await request.show(detailsUpdatePromise);
|
||||
ok(false, `${testName}: should be rejected with AbortError but got resolved.`);
|
||||
} catch(error) {
|
||||
is(error.name, "AbortError", `${testName}: should be rejected with AbortError.`);
|
||||
}
|
||||
await handler.destruct();
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
||||
// testing show response initialization in chrome process
|
||||
function testShowResponseInit() {
|
||||
return new Promise((resolve, reject) => {
|
||||
gScript.addMessageListener("test-show-response-init-complete",
|
||||
function showResponseInitCompleteHandler() {
|
||||
gScript.removeMessageListener("test-show-response-init-complete",
|
||||
showResponseInitCompleteHandler);
|
||||
resolve();
|
||||
});
|
||||
gScript.sendAsyncMessage("test-show-response-init");
|
||||
});
|
||||
async function testShowResponseInit() {
|
||||
const testName = "testShowResponseInit";
|
||||
await requestChromeAction("test-show-response-init", testName);
|
||||
}
|
||||
|
||||
// testing show that is not triggered by user.
|
||||
function testShowNotTriggeredByUser() {
|
||||
gScript.sendAsyncMessage("set-simple-ui-service");
|
||||
return new Promise((resolve, reject) => {
|
||||
const payRequest = new PaymentRequest(defaultMethods, defaultDetails);
|
||||
payRequest.show().then(() => {
|
||||
ok(false, "Expected 'SecurityError', but got resolved")
|
||||
resolve();
|
||||
}).catch((err) => {
|
||||
is(err.name, "SecurityError", `Should be rejected with 'SecurityError', but got ${err.name}`);
|
||||
resolve();
|
||||
});
|
||||
async function testShowNotTriggeredByUser() {
|
||||
const testName = "testShowNotTriggeredByUser";
|
||||
await requestChromeAction("set-simple-ui-service", testName);
|
||||
return new Promise(async (resolve) => {
|
||||
const request = new PaymentRequest(defaultMethods, defaultDetails);
|
||||
try {
|
||||
await request.show();
|
||||
ok(false, `${testName}: should be rejected with SecurityError, but got resolved.`);
|
||||
} catch (error) {
|
||||
is(error.name, "SecurityError", `${testName}: should be rejected with SecurityError.`);
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
||||
// teardown function
|
||||
function teardown() {
|
||||
async function teardown() {
|
||||
gScript.addMessageListener("teardown-complete", function teardownCompleteHandler() {
|
||||
gScript.removeMessageListener("teardown-complete", teardownCompleteHandler);
|
||||
gScript.removeMessageListener("test-fail", testFailHandler);
|
||||
|
@ -435,30 +477,31 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1345366
|
|||
}
|
||||
|
||||
// test main body
|
||||
function runTests() {
|
||||
testCannotMakePaymentShow()
|
||||
.then(testRejectShow)
|
||||
.then(testShowNormalFlow)
|
||||
.then(testCompleteSuccess)
|
||||
.then(testCompleteFail)
|
||||
.then(testCompleteUnknown)
|
||||
.then(testCompleteEmpty)
|
||||
.then(testUpdateWithReject)
|
||||
.then(testUpdateWithValidDetails)
|
||||
.then(testUpdateWithInvalidDetails)
|
||||
.then(testUpdateWithError)
|
||||
.then(testShowWithValidPromise)
|
||||
.then(testShowWithInvalidPromise)
|
||||
.then(testShowWithRejectedPromise)
|
||||
.then(testShowWithErrorPromise)
|
||||
.then(testShowWithPromiseResolvedByRejectedPromise)
|
||||
.then(testShowResponseInit)
|
||||
.then(testShowNotTriggeredByUser)
|
||||
.then(teardown)
|
||||
.catch( e => {
|
||||
ok(false, "Unexpected error: " + e.name);
|
||||
async function runTests() {
|
||||
try {
|
||||
await testCannotMakePaymentShow();
|
||||
await testRejectShow();
|
||||
await testShowNormalFlow();
|
||||
await testCompleteSuccess();
|
||||
await testCompleteFail();
|
||||
await testCompleteUnknown();
|
||||
await testCompleteEmpty();
|
||||
await testUpdateWithReject();
|
||||
await testUpdateWithValidDetails();
|
||||
await testUpdateWithInvalidDetails();
|
||||
await testUpdateWithError();
|
||||
await testShowWithValidPromise();
|
||||
await testShowWithInvalidPromise();
|
||||
await testShowWithRejectedPromise();
|
||||
await testShowWithErrorPromise();
|
||||
await testShowWithPromiseResolvedByRejectedPromise();
|
||||
await testShowResponseInit();
|
||||
await testShowNotTriggeredByUser();
|
||||
await teardown();
|
||||
} catch (error) {
|
||||
ok(false, `test_showPayment: Unexpected error: ${error.name}`);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('load', function() {
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/TypedEnumBits.h"
|
||||
#include "nsRegion.h"
|
||||
#include "nsStyleConsts.h"
|
||||
|
||||
#include <stdio.h> // FILE
|
||||
#include "mozilla/Logging.h" // for PR_LOG
|
||||
|
@ -392,7 +393,7 @@ typedef gfx::Matrix4x4Typed<CSSTransformedLayerPixel, ParentLayerPixel> AsyncTra
|
|||
typedef Array<gfx::Color, 4> BorderColors;
|
||||
typedef Array<LayerSize, 4> BorderCorners;
|
||||
typedef Array<LayerCoord, 4> BorderWidths;
|
||||
typedef Array<uint8_t, 4> BorderStyles;
|
||||
typedef Array<StyleBorderStyle, 4> BorderStyles;
|
||||
|
||||
typedef Maybe<LayerRect> MaybeLayerRect;
|
||||
|
||||
|
|
|
@ -452,28 +452,28 @@ static inline wr::LayoutTransform ToLayoutTransform(const gfx::Matrix4x4Typed<S,
|
|||
return transform;
|
||||
}
|
||||
|
||||
static inline wr::BorderStyle ToBorderStyle(const uint8_t& style)
|
||||
static inline wr::BorderStyle ToBorderStyle(const StyleBorderStyle& style)
|
||||
{
|
||||
switch (style) {
|
||||
case NS_STYLE_BORDER_STYLE_NONE:
|
||||
case StyleBorderStyle::None:
|
||||
return wr::BorderStyle::None;
|
||||
case NS_STYLE_BORDER_STYLE_SOLID:
|
||||
case StyleBorderStyle::Solid:
|
||||
return wr::BorderStyle::Solid;
|
||||
case NS_STYLE_BORDER_STYLE_DOUBLE:
|
||||
case StyleBorderStyle::Double:
|
||||
return wr::BorderStyle::Double;
|
||||
case NS_STYLE_BORDER_STYLE_DOTTED:
|
||||
case StyleBorderStyle::Dotted:
|
||||
return wr::BorderStyle::Dotted;
|
||||
case NS_STYLE_BORDER_STYLE_DASHED:
|
||||
case StyleBorderStyle::Dashed:
|
||||
return wr::BorderStyle::Dashed;
|
||||
case NS_STYLE_BORDER_STYLE_HIDDEN:
|
||||
case StyleBorderStyle::Hidden:
|
||||
return wr::BorderStyle::Hidden;
|
||||
case NS_STYLE_BORDER_STYLE_GROOVE:
|
||||
case StyleBorderStyle::Groove:
|
||||
return wr::BorderStyle::Groove;
|
||||
case NS_STYLE_BORDER_STYLE_RIDGE:
|
||||
case StyleBorderStyle::Ridge:
|
||||
return wr::BorderStyle::Ridge;
|
||||
case NS_STYLE_BORDER_STYLE_INSET:
|
||||
case StyleBorderStyle::Inset:
|
||||
return wr::BorderStyle::Inset;
|
||||
case NS_STYLE_BORDER_STYLE_OUTSET:
|
||||
case StyleBorderStyle::Outset:
|
||||
return wr::BorderStyle::Outset;
|
||||
default:
|
||||
MOZ_ASSERT(false);
|
||||
|
@ -481,7 +481,7 @@ static inline wr::BorderStyle ToBorderStyle(const uint8_t& style)
|
|||
return wr::BorderStyle::None;
|
||||
}
|
||||
|
||||
static inline wr::BorderSide ToBorderSide(const gfx::Color& color, const uint8_t& style)
|
||||
static inline wr::BorderSide ToBorderSide(const gfx::Color& color, const StyleBorderStyle& style)
|
||||
{
|
||||
wr::BorderSide bs;
|
||||
bs.color = ToColorF(color);
|
||||
|
|
|
@ -1771,12 +1771,12 @@ public:
|
|||
static SamplingFilter GetSamplingFilterForFrame(nsIFrame* aFrame);
|
||||
|
||||
static inline void InitDashPattern(StrokeOptions& aStrokeOptions,
|
||||
uint8_t aBorderStyle) {
|
||||
if (aBorderStyle == NS_STYLE_BORDER_STYLE_DOTTED) {
|
||||
mozilla::StyleBorderStyle aBorderStyle) {
|
||||
if (aBorderStyle == mozilla::StyleBorderStyle::Dotted) {
|
||||
static Float dot[] = { 1.f, 1.f };
|
||||
aStrokeOptions.mDashLength = MOZ_ARRAY_LENGTH(dot);
|
||||
aStrokeOptions.mDashPattern = dot;
|
||||
} else if (aBorderStyle == NS_STYLE_BORDER_STYLE_DASHED) {
|
||||
} else if (aBorderStyle == mozilla::StyleBorderStyle::Dashed) {
|
||||
static Float dash[] = { 5.f, 5.f };
|
||||
aStrokeOptions.mDashLength = MOZ_ARRAY_LENGTH(dash);
|
||||
aStrokeOptions.mDashPattern = dash;
|
||||
|
|
|
@ -1638,7 +1638,7 @@ void nsComboboxControlFrame::PaintFocus(DrawTarget& aDrawTarget, nsPoint aPt)
|
|||
// draw focus
|
||||
|
||||
StrokeOptions strokeOptions;
|
||||
nsLayoutUtils::InitDashPattern(strokeOptions, NS_STYLE_BORDER_STYLE_DOTTED);
|
||||
nsLayoutUtils::InitDashPattern(strokeOptions, StyleBorderStyle::Dotted);
|
||||
ColorPattern color(ToDeviceColor(StyleColor()->mColor));
|
||||
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
|
||||
clipRect.width -= onePixel;
|
||||
|
|
|
@ -195,13 +195,13 @@ nsColumnSetFrame::CreateBorderRenderers(nsTArray<nsCSSBorderRenderer>& aBorderRe
|
|||
WritingMode wm = GetWritingMode();
|
||||
bool isVertical = wm.IsVertical();
|
||||
const nsStyleColumn* colStyle = StyleColumn();
|
||||
uint8_t ruleStyle;
|
||||
StyleBorderStyle ruleStyle;
|
||||
|
||||
// Per spec, inset => ridge and outset => groove
|
||||
if (colStyle->mColumnRuleStyle == NS_STYLE_BORDER_STYLE_INSET)
|
||||
ruleStyle = NS_STYLE_BORDER_STYLE_RIDGE;
|
||||
else if (colStyle->mColumnRuleStyle == NS_STYLE_BORDER_STYLE_OUTSET)
|
||||
ruleStyle = NS_STYLE_BORDER_STYLE_GROOVE;
|
||||
if (colStyle->mColumnRuleStyle == StyleBorderStyle::Inset)
|
||||
ruleStyle = StyleBorderStyle::Ridge;
|
||||
else if (colStyle->mColumnRuleStyle == StyleBorderStyle::Outset)
|
||||
ruleStyle = StyleBorderStyle::Groove;
|
||||
else
|
||||
ruleStyle = colStyle->mColumnRuleStyle;
|
||||
|
||||
|
|
|
@ -9480,7 +9480,7 @@ ComputeAndIncludeOutlineArea(nsIFrame* aFrame, nsOverflowAreas& aOverflowAreas,
|
|||
nsRect outerRect(innerRect);
|
||||
bool useOutlineAuto = false;
|
||||
if (nsLayoutUtils::IsOutlineStyleAutoEnabled()) {
|
||||
useOutlineAuto = outline->mOutlineStyle == NS_STYLE_BORDER_STYLE_AUTO;
|
||||
useOutlineAuto = outline->mOutlineStyle == StyleBorderStyle::Auto;
|
||||
if (MOZ_UNLIKELY(useOutlineAuto)) {
|
||||
nsPresContext* presContext = aFrame->PresContext();
|
||||
nsITheme* theme = presContext->GetTheme();
|
||||
|
|
|
@ -1365,7 +1365,7 @@ struct nsRecessedBorder : public nsStyleBorder {
|
|||
mBorder.Side(side) = aBorderWidth;
|
||||
// Note: use SetBorderStyle here because we want to affect
|
||||
// mComputedBorder
|
||||
SetBorderStyle(side, NS_STYLE_BORDER_STYLE_INSET);
|
||||
SetBorderStyle(side, StyleBorderStyle::Inset);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1912,7 +1912,7 @@ nsImageFrame::PaintImage(gfxContext& aRenderingContext, nsPoint aPt,
|
|||
// then dashed black stroke over the top:
|
||||
ColorPattern black(ToDeviceColor(Color(0.f, 0.f, 0.f, 1.f)));
|
||||
StrokeOptions strokeOptions;
|
||||
nsLayoutUtils::InitDashPattern(strokeOptions, NS_STYLE_BORDER_STYLE_DOTTED);
|
||||
nsLayoutUtils::InitDashPattern(strokeOptions, StyleBorderStyle::Dotted);
|
||||
map->Draw(this, *drawTarget, black, strokeOptions);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,11 +51,11 @@ ParseStyleValue(nsAtom* aAttribute, const nsAString& aAttributeValue)
|
|||
} else if (aAttribute == nsGkAtoms::rowlines_ ||
|
||||
aAttribute == nsGkAtoms::columnlines_) {
|
||||
if (aAttributeValue.EqualsLiteral("solid"))
|
||||
return NS_STYLE_BORDER_STYLE_SOLID;
|
||||
return static_cast<int8_t>(StyleBorderStyle::Solid);
|
||||
else if (aAttributeValue.EqualsLiteral("dashed"))
|
||||
return NS_STYLE_BORDER_STYLE_DASHED;
|
||||
return static_cast<int8_t>(StyleBorderStyle::Dashed);
|
||||
else
|
||||
return NS_STYLE_BORDER_STYLE_NONE;
|
||||
return static_cast<int8_t>(StyleBorderStyle::None);
|
||||
} else {
|
||||
MOZ_CRASH("Unrecognized attribute.");
|
||||
}
|
||||
|
@ -200,11 +200,11 @@ ApplyBorderToStyle(const nsMathMLmtdFrame* aFrame,
|
|||
// values, we simply repeat the last value.
|
||||
uint32_t listLength = rowLinesList->Length();
|
||||
if (rowIndex < listLength) {
|
||||
aStyleBorder.SetBorderStyle(eSideTop,
|
||||
rowLinesList->ElementAt(rowIndex - 1));
|
||||
aStyleBorder.SetBorderStyle(eSideTop, static_cast<StyleBorderStyle>(
|
||||
rowLinesList->ElementAt(rowIndex - 1)));
|
||||
} else {
|
||||
aStyleBorder.SetBorderStyle(eSideTop,
|
||||
rowLinesList->ElementAt(listLength - 1));
|
||||
aStyleBorder.SetBorderStyle(eSideTop, static_cast<StyleBorderStyle>(
|
||||
rowLinesList->ElementAt(listLength - 1)));
|
||||
}
|
||||
aStyleBorder.SetBorderWidth(eSideTop, borderWidth);
|
||||
}
|
||||
|
@ -215,11 +215,11 @@ ApplyBorderToStyle(const nsMathMLmtdFrame* aFrame,
|
|||
// values, we simply repeat the last value.
|
||||
uint32_t listLength = columnLinesList->Length();
|
||||
if (columnIndex < listLength) {
|
||||
aStyleBorder.SetBorderStyle(eSideLeft,
|
||||
columnLinesList->ElementAt(columnIndex - 1));
|
||||
aStyleBorder.SetBorderStyle(eSideLeft, static_cast<StyleBorderStyle>(
|
||||
columnLinesList->ElementAt(columnIndex - 1)));
|
||||
} else {
|
||||
aStyleBorder.SetBorderStyle(eSideLeft,
|
||||
columnLinesList->ElementAt(listLength - 1));
|
||||
aStyleBorder.SetBorderStyle(eSideLeft, static_cast<StyleBorderStyle>(
|
||||
columnLinesList->ElementAt(listLength - 1)));
|
||||
}
|
||||
aStyleBorder.SetBorderWidth(eSideLeft, borderWidth);
|
||||
}
|
||||
|
|
|
@ -456,7 +456,7 @@ nsCSSRendering::Shutdown()
|
|||
*/
|
||||
static nscolor
|
||||
MakeBevelColor(mozilla::Side whichSide,
|
||||
uint8_t style,
|
||||
StyleBorderStyle style,
|
||||
nscolor aBorderColor)
|
||||
{
|
||||
|
||||
|
@ -467,8 +467,8 @@ MakeBevelColor(mozilla::Side whichSide,
|
|||
// calculate the color used for the shading
|
||||
NS_GetSpecial3DColors(colors, aBorderColor);
|
||||
|
||||
if ((style == NS_STYLE_BORDER_STYLE_OUTSET) ||
|
||||
(style == NS_STYLE_BORDER_STYLE_RIDGE)) {
|
||||
if ((style == StyleBorderStyle::Outset) ||
|
||||
(style == StyleBorderStyle::Ridge)) {
|
||||
// Flip colors for these two border styles
|
||||
switch (whichSide) {
|
||||
case eSideBottom:
|
||||
|
@ -894,7 +894,7 @@ ConstructBorderRenderer(nsPresContext* aPresContext,
|
|||
Float(border.left) / oneDevPixel };
|
||||
Rect dirtyRect = NSRectToRect(aDirtyRect, oneDevPixel);
|
||||
|
||||
uint8_t borderStyles[4];
|
||||
StyleBorderStyle borderStyles[4];
|
||||
nscolor borderColors[4];
|
||||
|
||||
// pull out styles, colors
|
||||
|
@ -905,10 +905,10 @@ ConstructBorderRenderer(nsPresContext* aPresContext,
|
|||
}
|
||||
|
||||
PrintAsFormatString(" borderStyles: %d %d %d %d\n",
|
||||
borderStyles[0],
|
||||
borderStyles[1],
|
||||
borderStyles[2],
|
||||
borderStyles[3]);
|
||||
static_cast<int>(borderStyles[0]),
|
||||
static_cast<int>(borderStyles[1]),
|
||||
static_cast<int>(borderStyles[2]),
|
||||
static_cast<int>(borderStyles[3]));
|
||||
|
||||
nsIDocument* document = nullptr;
|
||||
nsIContent* content = aForFrame->GetContent();
|
||||
|
@ -1153,8 +1153,8 @@ nsCSSRendering::CreateBorderRendererForOutline(nsPresContext* aPresContext,
|
|||
RectCornerRadii outlineRadii;
|
||||
ComputePixelRadii(twipsRadii, oneDevPixel, &outlineRadii);
|
||||
|
||||
uint8_t outlineStyle = ourOutline->mOutlineStyle;
|
||||
if (outlineStyle == NS_STYLE_BORDER_STYLE_AUTO) {
|
||||
StyleBorderStyle outlineStyle = ourOutline->mOutlineStyle;
|
||||
if (outlineStyle == StyleBorderStyle::Auto) {
|
||||
if (nsLayoutUtils::IsOutlineStyleAutoEnabled()) {
|
||||
nsITheme* theme = aPresContext->GetTheme();
|
||||
if (theme && theme->ThemeSupportsWidget(
|
||||
|
@ -1172,10 +1172,10 @@ nsCSSRendering::CreateBorderRendererForOutline(nsPresContext* aPresContext,
|
|||
}
|
||||
// http://dev.w3.org/csswg/css-ui/#outline
|
||||
// "User agents may treat 'auto' as 'solid'."
|
||||
outlineStyle = NS_STYLE_BORDER_STYLE_SOLID;
|
||||
outlineStyle = StyleBorderStyle::Solid;
|
||||
}
|
||||
|
||||
uint8_t outlineStyles[4] = {
|
||||
StyleBorderStyle outlineStyles[4] = {
|
||||
outlineStyle, outlineStyle, outlineStyle, outlineStyle
|
||||
};
|
||||
|
||||
|
@ -1263,10 +1263,10 @@ nsCSSRendering::PaintFocus(nsPresContext* aPresContext,
|
|||
Float(oneCSSPixel) / oneDevPixel,
|
||||
Float(oneCSSPixel) / oneDevPixel };
|
||||
|
||||
uint8_t focusStyles[4] = { NS_STYLE_BORDER_STYLE_DOTTED,
|
||||
NS_STYLE_BORDER_STYLE_DOTTED,
|
||||
NS_STYLE_BORDER_STYLE_DOTTED,
|
||||
NS_STYLE_BORDER_STYLE_DOTTED };
|
||||
StyleBorderStyle focusStyles[4] = { StyleBorderStyle::Dotted,
|
||||
StyleBorderStyle::Dotted,
|
||||
StyleBorderStyle::Dotted,
|
||||
StyleBorderStyle::Dotted };
|
||||
nscolor focusColors[4] = { aColor, aColor, aColor, aColor };
|
||||
|
||||
// Because this renders a dotted border, the background color
|
||||
|
@ -2230,11 +2230,11 @@ IsOpaqueBorderEdge(const nsStyleBorder& aBorder, mozilla::Side aSide)
|
|||
if (aBorder.GetComputedBorder().Side(aSide) == 0)
|
||||
return true;
|
||||
switch (aBorder.GetBorderStyle(aSide)) {
|
||||
case NS_STYLE_BORDER_STYLE_SOLID:
|
||||
case NS_STYLE_BORDER_STYLE_GROOVE:
|
||||
case NS_STYLE_BORDER_STYLE_RIDGE:
|
||||
case NS_STYLE_BORDER_STYLE_INSET:
|
||||
case NS_STYLE_BORDER_STYLE_OUTSET:
|
||||
case StyleBorderStyle::Solid:
|
||||
case StyleBorderStyle::Groove:
|
||||
case StyleBorderStyle::Ridge:
|
||||
case StyleBorderStyle::Inset:
|
||||
case StyleBorderStyle::Outset:
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
|
@ -3751,7 +3751,7 @@ GetDashInfo(nscoord aBorderLength,
|
|||
|
||||
void
|
||||
nsCSSRendering::DrawTableBorderSegment(DrawTarget& aDrawTarget,
|
||||
uint8_t aBorderStyle,
|
||||
StyleBorderStyle aBorderStyle,
|
||||
nscolor aBorderColor,
|
||||
const nsRect& aBorder,
|
||||
int32_t aAppUnitsPerDevPixel,
|
||||
|
@ -3765,28 +3765,28 @@ nsCSSRendering::DrawTableBorderSegment(DrawTarget& aDrawTarget,
|
|||
nscoord oneDevPixel = NSIntPixelsToAppUnits(1, aAppUnitsPerDevPixel);
|
||||
|
||||
if ((oneDevPixel >= aBorder.width) || (oneDevPixel >= aBorder.height) ||
|
||||
(NS_STYLE_BORDER_STYLE_DASHED == aBorderStyle) ||
|
||||
(NS_STYLE_BORDER_STYLE_DOTTED == aBorderStyle)) {
|
||||
(StyleBorderStyle::Dashed == aBorderStyle) ||
|
||||
(StyleBorderStyle::Dotted == aBorderStyle)) {
|
||||
// no beveling for 1 pixel border, dash or dot
|
||||
aStartBevelOffset = 0;
|
||||
aEndBevelOffset = 0;
|
||||
}
|
||||
|
||||
switch (aBorderStyle) {
|
||||
case NS_STYLE_BORDER_STYLE_NONE:
|
||||
case NS_STYLE_BORDER_STYLE_HIDDEN:
|
||||
case StyleBorderStyle::None:
|
||||
case StyleBorderStyle::Hidden:
|
||||
// NS_ASSERTION(false, "style of none or hidden");
|
||||
break;
|
||||
case NS_STYLE_BORDER_STYLE_DOTTED:
|
||||
case NS_STYLE_BORDER_STYLE_DASHED: {
|
||||
nscoord dashLength = (NS_STYLE_BORDER_STYLE_DASHED == aBorderStyle)
|
||||
case StyleBorderStyle::Dotted:
|
||||
case StyleBorderStyle::Dashed: {
|
||||
nscoord dashLength = (StyleBorderStyle::Dashed == aBorderStyle)
|
||||
? DASH_LENGTH
|
||||
: DOT_LENGTH;
|
||||
// make the dash length proportional to the border thickness
|
||||
dashLength *= (horizontal) ? aBorder.height : aBorder.width;
|
||||
// make the min dash length for the ends 1/2 the dash length
|
||||
nscoord minDashLength =
|
||||
(NS_STYLE_BORDER_STYLE_DASHED == aBorderStyle)
|
||||
(StyleBorderStyle::Dashed == aBorderStyle)
|
||||
? RoundFloatToPixel(((float)dashLength) / 2.0f, aAppUnitsPerDevPixel)
|
||||
: dashLength;
|
||||
minDashLength = std::max(minDashLength, oneDevPixel);
|
||||
|
@ -3874,28 +3874,28 @@ nsCSSRendering::DrawTableBorderSegment(DrawTarget& aDrawTarget,
|
|||
void
|
||||
nsCSSRendering::GetTableBorderSolidSegments(
|
||||
nsTArray<SolidBeveledBorderSegment>& aSegments,
|
||||
uint8_t aBorderStyle,
|
||||
nscolor aBorderColor,
|
||||
const nsRect& aBorder,
|
||||
int32_t aAppUnitsPerDevPixel,
|
||||
mozilla::Side aStartBevelSide,
|
||||
nscoord aStartBevelOffset,
|
||||
mozilla::Side aEndBevelSide,
|
||||
nscoord aEndBevelOffset)
|
||||
StyleBorderStyle aBorderStyle,
|
||||
nscolor aBorderColor,
|
||||
const nsRect& aBorder,
|
||||
int32_t aAppUnitsPerDevPixel,
|
||||
mozilla::Side aStartBevelSide,
|
||||
nscoord aStartBevelOffset,
|
||||
mozilla::Side aEndBevelSide,
|
||||
nscoord aEndBevelOffset)
|
||||
{
|
||||
const bool horizontal = eSideTop == aStartBevelSide || eSideBottom == aStartBevelSide;
|
||||
const nscoord oneDevPixel = NSIntPixelsToAppUnits(1, aAppUnitsPerDevPixel);
|
||||
|
||||
switch (aBorderStyle) {
|
||||
case NS_STYLE_BORDER_STYLE_NONE:
|
||||
case NS_STYLE_BORDER_STYLE_HIDDEN:
|
||||
case StyleBorderStyle::None:
|
||||
case StyleBorderStyle::Hidden:
|
||||
return;
|
||||
case NS_STYLE_BORDER_STYLE_DOTTED:
|
||||
case NS_STYLE_BORDER_STYLE_DASHED:
|
||||
case StyleBorderStyle::Dotted:
|
||||
case StyleBorderStyle::Dashed:
|
||||
MOZ_ASSERT_UNREACHABLE("Caller should have checked");
|
||||
return;
|
||||
case NS_STYLE_BORDER_STYLE_GROOVE:
|
||||
case NS_STYLE_BORDER_STYLE_RIDGE:
|
||||
case StyleBorderStyle::Groove:
|
||||
case StyleBorderStyle::Ridge:
|
||||
if ((horizontal && (oneDevPixel >= aBorder.height)) ||
|
||||
(!horizontal && (oneDevPixel >= aBorder.width))) {
|
||||
aSegments.AppendElement(SolidBeveledBorderSegment {
|
||||
|
@ -3995,7 +3995,7 @@ nsCSSRendering::GetTableBorderSolidSegments(
|
|||
}
|
||||
}
|
||||
break;
|
||||
case NS_STYLE_BORDER_STYLE_DOUBLE:
|
||||
case StyleBorderStyle::Double:
|
||||
// We can only do "double" borders if the thickness of the border
|
||||
// is more than 2px. Otherwise, we fall through to painting a
|
||||
// solid border.
|
||||
|
@ -4086,7 +4086,7 @@ nsCSSRendering::GetTableBorderSolidSegments(
|
|||
}
|
||||
// else fall through to solid
|
||||
MOZ_FALLTHROUGH;
|
||||
case NS_STYLE_BORDER_STYLE_SOLID:
|
||||
case StyleBorderStyle::Solid:
|
||||
aSegments.AppendElement(SolidBeveledBorderSegment {
|
||||
aBorder,
|
||||
aBorderColor,
|
||||
|
@ -4094,11 +4094,11 @@ nsCSSRendering::GetTableBorderSolidSegments(
|
|||
{ aEndBevelSide, aEndBevelOffset }
|
||||
});
|
||||
break;
|
||||
case NS_STYLE_BORDER_STYLE_OUTSET:
|
||||
case NS_STYLE_BORDER_STYLE_INSET:
|
||||
case StyleBorderStyle::Outset:
|
||||
case StyleBorderStyle::Inset:
|
||||
MOZ_ASSERT_UNREACHABLE("inset, outset should have been converted to groove, ridge");
|
||||
break;
|
||||
case NS_STYLE_BORDER_STYLE_AUTO:
|
||||
case StyleBorderStyle::Auto:
|
||||
MOZ_ASSERT_UNREACHABLE("Unexpected 'auto' table border");
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -595,7 +595,7 @@ struct nsCSSRendering
|
|||
// corners.
|
||||
static void DrawTableBorderSegment(
|
||||
DrawTarget& aDrawTarget,
|
||||
uint8_t aBorderStyle,
|
||||
mozilla::StyleBorderStyle aBorderStyle,
|
||||
nscolor aBorderColor,
|
||||
const nsRect& aBorderRect,
|
||||
int32_t aAppUnitsPerDevPixel,
|
||||
|
@ -624,7 +624,7 @@ struct nsCSSRendering
|
|||
// dashed / dotted borders, since we don't support beveling those.
|
||||
static void GetTableBorderSolidSegments(
|
||||
nsTArray<SolidBeveledBorderSegment>& aSegments,
|
||||
uint8_t aBorderStyle,
|
||||
mozilla::StyleBorderStyle aBorderStyle,
|
||||
nscolor aBorderColor,
|
||||
const nsRect& aBorderRect,
|
||||
int32_t aAppUnitsPerDevPixel,
|
||||
|
|
|
@ -174,7 +174,7 @@ nsCSSBorderRenderer::nsCSSBorderRenderer(nsPresContext* aPresContext,
|
|||
DrawTarget* aDrawTarget,
|
||||
const Rect& aDirtyRect,
|
||||
Rect& aOuterRect,
|
||||
const uint8_t* aBorderStyles,
|
||||
const StyleBorderStyle* aBorderStyles,
|
||||
const Float* aBorderWidths,
|
||||
RectCornerRadii& aBorderRadii,
|
||||
const nscolor* aBorderColors,
|
||||
|
@ -194,10 +194,10 @@ nsCSSBorderRenderer::nsCSSBorderRenderer(nsPresContext* aPresContext,
|
|||
PodCopy(mBorderColors, aBorderColors, 4);
|
||||
mInnerRect = mOuterRect;
|
||||
mInnerRect.Deflate(Margin(
|
||||
mBorderStyles[0] != NS_STYLE_BORDER_STYLE_NONE ? mBorderWidths[0] : 0,
|
||||
mBorderStyles[1] != NS_STYLE_BORDER_STYLE_NONE ? mBorderWidths[1] : 0,
|
||||
mBorderStyles[2] != NS_STYLE_BORDER_STYLE_NONE ? mBorderWidths[2] : 0,
|
||||
mBorderStyles[3] != NS_STYLE_BORDER_STYLE_NONE ? mBorderWidths[3] : 0));
|
||||
mBorderStyles[0] != StyleBorderStyle::None ? mBorderWidths[0] : 0,
|
||||
mBorderStyles[1] != StyleBorderStyle::None ? mBorderWidths[1] : 0,
|
||||
mBorderStyles[2] != StyleBorderStyle::None ? mBorderWidths[2] : 0,
|
||||
mBorderStyles[3] != StyleBorderStyle::None ? mBorderWidths[3] : 0));
|
||||
|
||||
ComputeBorderCornerDimensions(
|
||||
mBorderWidths, mBorderRadii, &mBorderCornerDimensions);
|
||||
|
@ -338,34 +338,34 @@ nsCSSBorderRenderer::AreBorderSideFinalStylesSame(uint8_t aSides)
|
|||
/* Then if it's one of the two-tone styles and we're not
|
||||
* just comparing the TL or BR sides */
|
||||
switch (mBorderStyles[firstStyle]) {
|
||||
case NS_STYLE_BORDER_STYLE_GROOVE:
|
||||
case NS_STYLE_BORDER_STYLE_RIDGE:
|
||||
case NS_STYLE_BORDER_STYLE_INSET:
|
||||
case NS_STYLE_BORDER_STYLE_OUTSET:
|
||||
case StyleBorderStyle::Groove:
|
||||
case StyleBorderStyle::Ridge:
|
||||
case StyleBorderStyle::Inset:
|
||||
case StyleBorderStyle::Outset:
|
||||
return ((aSides & ~(eSideBitsTop | eSideBitsLeft)) == 0 ||
|
||||
(aSides & ~(eSideBitsBottom | eSideBitsRight)) == 0);
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
nsCSSBorderRenderer::IsSolidCornerStyle(uint8_t aStyle, Corner aCorner)
|
||||
nsCSSBorderRenderer::IsSolidCornerStyle(StyleBorderStyle aStyle, Corner aCorner)
|
||||
{
|
||||
switch (aStyle) {
|
||||
case NS_STYLE_BORDER_STYLE_SOLID:
|
||||
case StyleBorderStyle::Solid:
|
||||
return true;
|
||||
|
||||
case NS_STYLE_BORDER_STYLE_INSET:
|
||||
case NS_STYLE_BORDER_STYLE_OUTSET:
|
||||
case StyleBorderStyle::Inset:
|
||||
case StyleBorderStyle::Outset:
|
||||
return (aCorner == eCornerTopLeft || aCorner == eCornerBottomRight);
|
||||
|
||||
case NS_STYLE_BORDER_STYLE_GROOVE:
|
||||
case NS_STYLE_BORDER_STYLE_RIDGE:
|
||||
case StyleBorderStyle::Groove:
|
||||
case StyleBorderStyle::Ridge:
|
||||
return mOneUnitBorder &&
|
||||
(aCorner == eCornerTopLeft || aCorner == eCornerBottomRight);
|
||||
|
||||
case NS_STYLE_BORDER_STYLE_DOUBLE:
|
||||
case StyleBorderStyle::Double:
|
||||
return mOneUnitBorder;
|
||||
|
||||
default:
|
||||
|
@ -406,9 +406,9 @@ nsCSSBorderRenderer::IsCornerMergeable(Corner aCorner)
|
|||
// | |
|
||||
mozilla::Side sideH(GetHorizontalSide(aCorner));
|
||||
mozilla::Side sideV(GetVerticalSide(aCorner));
|
||||
uint8_t styleH = mBorderStyles[sideH];
|
||||
uint8_t styleV = mBorderStyles[sideV];
|
||||
if (styleH != styleV || styleH != NS_STYLE_BORDER_STYLE_DOTTED) {
|
||||
StyleBorderStyle styleH = mBorderStyles[sideH];
|
||||
StyleBorderStyle styleV = mBorderStyles[sideV];
|
||||
if (styleH != styleV || styleH != StyleBorderStyle::Dotted) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -424,31 +424,33 @@ nsCSSBorderRenderer::IsCornerMergeable(Corner aCorner)
|
|||
}
|
||||
|
||||
BorderColorStyle
|
||||
nsCSSBorderRenderer::BorderColorStyleForSolidCorner(uint8_t aStyle,
|
||||
nsCSSBorderRenderer::BorderColorStyleForSolidCorner(StyleBorderStyle aStyle,
|
||||
Corner aCorner)
|
||||
{
|
||||
// note that this function assumes that the corner is already solid,
|
||||
// as per the earlier function
|
||||
switch (aStyle) {
|
||||
case NS_STYLE_BORDER_STYLE_SOLID:
|
||||
case NS_STYLE_BORDER_STYLE_DOUBLE:
|
||||
case StyleBorderStyle::Solid:
|
||||
case StyleBorderStyle::Double:
|
||||
return BorderColorStyleSolid;
|
||||
|
||||
case NS_STYLE_BORDER_STYLE_INSET:
|
||||
case NS_STYLE_BORDER_STYLE_GROOVE:
|
||||
case StyleBorderStyle::Inset:
|
||||
case StyleBorderStyle::Groove:
|
||||
if (aCorner == eCornerTopLeft)
|
||||
return BorderColorStyleDark;
|
||||
else if (aCorner == eCornerBottomRight)
|
||||
return BorderColorStyleLight;
|
||||
break;
|
||||
|
||||
case NS_STYLE_BORDER_STYLE_OUTSET:
|
||||
case NS_STYLE_BORDER_STYLE_RIDGE:
|
||||
case StyleBorderStyle::Outset:
|
||||
case StyleBorderStyle::Ridge:
|
||||
if (aCorner == eCornerTopLeft)
|
||||
return BorderColorStyleLight;
|
||||
else if (aCorner == eCornerBottomRight)
|
||||
return BorderColorStyleDark;
|
||||
break;
|
||||
default:
|
||||
return BorderColorStyleNone;
|
||||
}
|
||||
|
||||
return BorderColorStyleNone;
|
||||
|
@ -616,7 +618,7 @@ nsCSSBorderRenderer::GetSideClipSubPath(mozilla::Side aSide)
|
|||
Point start[2];
|
||||
Point end[2];
|
||||
|
||||
#define IS_DOTTED(_s) ((_s) == NS_STYLE_BORDER_STYLE_DOTTED)
|
||||
#define IS_DOTTED(_s) ((_s) == StyleBorderStyle::Dotted)
|
||||
bool isDotted = IS_DOTTED(mBorderStyles[aSide]);
|
||||
bool startIsDotted = IS_DOTTED(mBorderStyles[PREV_SIDE(aSide)]);
|
||||
bool endIsDotted = IS_DOTTED(mBorderStyles[NEXT_SIDE(aSide)]);
|
||||
|
@ -736,7 +738,7 @@ nsCSSBorderRenderer::GetStraightBorderPoint(mozilla::Side aSide,
|
|||
*aIsUnfilled = false;
|
||||
|
||||
Point P = mOuterRect.AtCorner(aCorner);
|
||||
uint8_t style = mBorderStyles[aSide];
|
||||
StyleBorderStyle style = mBorderStyles[aSide];
|
||||
Float borderWidth = mBorderWidths[aSide];
|
||||
Size dim = mBorderCornerDimensions[aCorner];
|
||||
bool isHorizontal = IsHorizontalSide(aSide);
|
||||
|
@ -750,14 +752,14 @@ nsCSSBorderRenderer::GetStraightBorderPoint(mozilla::Side aSide,
|
|||
// | |
|
||||
mozilla::Side otherSide =
|
||||
((uint8_t)aSide == (uint8_t)aCorner) ? PREV_SIDE(aSide) : NEXT_SIDE(aSide);
|
||||
uint8_t otherStyle = mBorderStyles[otherSide];
|
||||
StyleBorderStyle otherStyle = mBorderStyles[otherSide];
|
||||
Float otherBorderWidth = mBorderWidths[otherSide];
|
||||
Size radius = mBorderRadii[aCorner];
|
||||
if (IsZeroSize(radius)) {
|
||||
radius.width = 0.0f;
|
||||
radius.height = 0.0f;
|
||||
}
|
||||
if (style == NS_STYLE_BORDER_STYLE_DOTTED) {
|
||||
if (style == StyleBorderStyle::Dotted) {
|
||||
// Offset the dot's location along the side toward the corner by a
|
||||
// multiple of its width.
|
||||
if (isHorizontal) {
|
||||
|
@ -766,8 +768,8 @@ nsCSSBorderRenderer::GetStraightBorderPoint(mozilla::Side aSide,
|
|||
P.y -= signs[1] * aDotOffset * borderWidth;
|
||||
}
|
||||
}
|
||||
if (style == NS_STYLE_BORDER_STYLE_DOTTED &&
|
||||
otherStyle == NS_STYLE_BORDER_STYLE_DOTTED) {
|
||||
if (style == StyleBorderStyle::Dotted &&
|
||||
otherStyle == StyleBorderStyle::Dotted) {
|
||||
if (borderWidth == otherBorderWidth) {
|
||||
if (radius.width < borderWidth / 2.0f &&
|
||||
radius.height < borderWidth / 2.0f) {
|
||||
|
@ -963,7 +965,7 @@ nsCSSBorderRenderer::GetStraightBorderPoint(mozilla::Side aSide,
|
|||
return P;
|
||||
}
|
||||
|
||||
if (style == NS_STYLE_BORDER_STYLE_DOTTED) {
|
||||
if (style == StyleBorderStyle::Dotted) {
|
||||
// If only this side is dotted, other side draws the corner.
|
||||
//
|
||||
// otherBorderWidth + borderWidth / 2.0
|
||||
|
@ -1024,7 +1026,7 @@ nsCSSBorderRenderer::GetStraightBorderPoint(mozilla::Side aSide,
|
|||
return P;
|
||||
}
|
||||
|
||||
if (otherStyle == NS_STYLE_BORDER_STYLE_DOTTED && IsZeroSize(radius)) {
|
||||
if (otherStyle == StyleBorderStyle::Dotted && IsZeroSize(radius)) {
|
||||
// If other side is dotted and radius=0, draw side to the end of corner.
|
||||
//
|
||||
// +-------------------------------
|
||||
|
@ -1290,7 +1292,7 @@ nsCSSBorderRenderer::DrawBorderSides(int aSides)
|
|||
return;
|
||||
}
|
||||
|
||||
uint8_t borderRenderStyle = NS_STYLE_BORDER_STYLE_NONE;
|
||||
StyleBorderStyle borderRenderStyle = StyleBorderStyle::None;
|
||||
nscolor borderRenderColor;
|
||||
|
||||
uint32_t borderColorStyleCount = 0;
|
||||
|
@ -1306,12 +1308,12 @@ nsCSSBorderRenderer::DrawBorderSides(int aSides)
|
|||
break;
|
||||
}
|
||||
|
||||
if (borderRenderStyle == NS_STYLE_BORDER_STYLE_NONE ||
|
||||
borderRenderStyle == NS_STYLE_BORDER_STYLE_HIDDEN)
|
||||
if (borderRenderStyle == StyleBorderStyle::None ||
|
||||
borderRenderStyle == StyleBorderStyle::Hidden)
|
||||
return;
|
||||
|
||||
if (borderRenderStyle == NS_STYLE_BORDER_STYLE_DASHED ||
|
||||
borderRenderStyle == NS_STYLE_BORDER_STYLE_DOTTED) {
|
||||
if (borderRenderStyle == StyleBorderStyle::Dashed ||
|
||||
borderRenderStyle == StyleBorderStyle::Dotted) {
|
||||
// Draw each corner separately, with the given side's color.
|
||||
if (aSides & eSideBitsTop) {
|
||||
DrawDashedOrDottedCorner(eSideTop, C_TL);
|
||||
|
@ -1344,13 +1346,13 @@ nsCSSBorderRenderer::DrawBorderSides(int aSides)
|
|||
// If the border width is 1, we need to change the borderRenderStyle
|
||||
// a bit to make sure that we get the right colors -- e.g. 'ridge'
|
||||
// with a 1px border needs to look like solid, not like 'outset'.
|
||||
if (mOneUnitBorder && (borderRenderStyle == NS_STYLE_BORDER_STYLE_RIDGE ||
|
||||
borderRenderStyle == NS_STYLE_BORDER_STYLE_GROOVE ||
|
||||
borderRenderStyle == NS_STYLE_BORDER_STYLE_DOUBLE))
|
||||
borderRenderStyle = NS_STYLE_BORDER_STYLE_SOLID;
|
||||
if (mOneUnitBorder && (borderRenderStyle == StyleBorderStyle::Ridge ||
|
||||
borderRenderStyle == StyleBorderStyle::Groove ||
|
||||
borderRenderStyle == StyleBorderStyle::Double))
|
||||
borderRenderStyle = StyleBorderStyle::Solid;
|
||||
|
||||
switch (borderRenderStyle) {
|
||||
case NS_STYLE_BORDER_STYLE_SOLID:
|
||||
case StyleBorderStyle::Solid:
|
||||
borderColorStyleTopLeft[0] = BorderColorStyleSolid;
|
||||
|
||||
borderColorStyleBottomRight[0] = BorderColorStyleSolid;
|
||||
|
@ -1358,7 +1360,7 @@ nsCSSBorderRenderer::DrawBorderSides(int aSides)
|
|||
borderColorStyleCount = 1;
|
||||
break;
|
||||
|
||||
case NS_STYLE_BORDER_STYLE_GROOVE:
|
||||
case StyleBorderStyle::Groove:
|
||||
borderColorStyleTopLeft[0] = BorderColorStyleDark;
|
||||
borderColorStyleTopLeft[1] = BorderColorStyleLight;
|
||||
|
||||
|
@ -1368,7 +1370,7 @@ nsCSSBorderRenderer::DrawBorderSides(int aSides)
|
|||
borderColorStyleCount = 2;
|
||||
break;
|
||||
|
||||
case NS_STYLE_BORDER_STYLE_RIDGE:
|
||||
case StyleBorderStyle::Ridge:
|
||||
borderColorStyleTopLeft[0] = BorderColorStyleLight;
|
||||
borderColorStyleTopLeft[1] = BorderColorStyleDark;
|
||||
|
||||
|
@ -1378,7 +1380,7 @@ nsCSSBorderRenderer::DrawBorderSides(int aSides)
|
|||
borderColorStyleCount = 2;
|
||||
break;
|
||||
|
||||
case NS_STYLE_BORDER_STYLE_DOUBLE:
|
||||
case StyleBorderStyle::Double:
|
||||
borderColorStyleTopLeft[0] = BorderColorStyleSolid;
|
||||
borderColorStyleTopLeft[1] = BorderColorStyleNone;
|
||||
borderColorStyleTopLeft[2] = BorderColorStyleSolid;
|
||||
|
@ -1390,14 +1392,14 @@ nsCSSBorderRenderer::DrawBorderSides(int aSides)
|
|||
borderColorStyleCount = 3;
|
||||
break;
|
||||
|
||||
case NS_STYLE_BORDER_STYLE_INSET:
|
||||
case StyleBorderStyle::Inset:
|
||||
borderColorStyleTopLeft[0] = BorderColorStyleDark;
|
||||
borderColorStyleBottomRight[0] = BorderColorStyleLight;
|
||||
|
||||
borderColorStyleCount = 1;
|
||||
break;
|
||||
|
||||
case NS_STYLE_BORDER_STYLE_OUTSET:
|
||||
case StyleBorderStyle::Outset:
|
||||
borderColorStyleTopLeft[0] = BorderColorStyleLight;
|
||||
borderColorStyleBottomRight[0] = BorderColorStyleDark;
|
||||
|
||||
|
@ -1492,38 +1494,38 @@ nsCSSBorderRenderer::DrawBorderSides(int aSides)
|
|||
// If there is at least one dotted side, every side is rendered separately.
|
||||
if (IsSingleSide(aSides)) {
|
||||
if (aSides == eSideBitsTop) {
|
||||
if (mBorderStyles[eSideRight] == NS_STYLE_BORDER_STYLE_DOTTED &&
|
||||
if (mBorderStyles[eSideRight] == StyleBorderStyle::Dotted &&
|
||||
IsZeroSize(mBorderRadii[C_TR])) {
|
||||
noMarginRight = true;
|
||||
}
|
||||
if (mBorderStyles[eSideLeft] == NS_STYLE_BORDER_STYLE_DOTTED &&
|
||||
if (mBorderStyles[eSideLeft] == StyleBorderStyle::Dotted &&
|
||||
IsZeroSize(mBorderRadii[C_TL])) {
|
||||
noMarginLeft = true;
|
||||
}
|
||||
} else if (aSides == eSideBitsRight) {
|
||||
if (mBorderStyles[eSideTop] == NS_STYLE_BORDER_STYLE_DOTTED &&
|
||||
if (mBorderStyles[eSideTop] == StyleBorderStyle::Dotted &&
|
||||
IsZeroSize(mBorderRadii[C_TR])) {
|
||||
noMarginTop = true;
|
||||
}
|
||||
if (mBorderStyles[eSideBottom] == NS_STYLE_BORDER_STYLE_DOTTED &&
|
||||
if (mBorderStyles[eSideBottom] == StyleBorderStyle::Dotted &&
|
||||
IsZeroSize(mBorderRadii[C_BR])) {
|
||||
noMarginBottom = true;
|
||||
}
|
||||
} else if (aSides == eSideBitsBottom) {
|
||||
if (mBorderStyles[eSideRight] == NS_STYLE_BORDER_STYLE_DOTTED &&
|
||||
if (mBorderStyles[eSideRight] == StyleBorderStyle::Dotted &&
|
||||
IsZeroSize(mBorderRadii[C_BR])) {
|
||||
noMarginRight = true;
|
||||
}
|
||||
if (mBorderStyles[eSideLeft] == NS_STYLE_BORDER_STYLE_DOTTED &&
|
||||
if (mBorderStyles[eSideLeft] == StyleBorderStyle::Dotted &&
|
||||
IsZeroSize(mBorderRadii[C_BL])) {
|
||||
noMarginLeft = true;
|
||||
}
|
||||
} else {
|
||||
if (mBorderStyles[eSideTop] == NS_STYLE_BORDER_STYLE_DOTTED &&
|
||||
if (mBorderStyles[eSideTop] == StyleBorderStyle::Dotted &&
|
||||
IsZeroSize(mBorderRadii[C_TL])) {
|
||||
noMarginTop = true;
|
||||
}
|
||||
if (mBorderStyles[eSideBottom] == NS_STYLE_BORDER_STYLE_DOTTED &&
|
||||
if (mBorderStyles[eSideBottom] == StyleBorderStyle::Dotted &&
|
||||
IsZeroSize(mBorderRadii[C_BL])) {
|
||||
noMarginBottom = true;
|
||||
}
|
||||
|
@ -1580,11 +1582,11 @@ nsCSSBorderRenderer::SetupDashedOptions(StrokeOptions* aStrokeOptions,
|
|||
Float aBorderLength,
|
||||
bool isCorner)
|
||||
{
|
||||
MOZ_ASSERT(mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DASHED ||
|
||||
mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DOTTED,
|
||||
MOZ_ASSERT(mBorderStyles[aSide] == StyleBorderStyle::Dashed ||
|
||||
mBorderStyles[aSide] == StyleBorderStyle::Dotted,
|
||||
"Style should be dashed or dotted.");
|
||||
|
||||
uint8_t style = mBorderStyles[aSide];
|
||||
StyleBorderStyle style = mBorderStyles[aSide];
|
||||
Float borderWidth = mBorderWidths[aSide];
|
||||
|
||||
// Dashed line starts and ends with half segment in most case.
|
||||
|
@ -1614,7 +1616,7 @@ nsCSSBorderRenderer::SetupDashedOptions(StrokeOptions* aStrokeOptions,
|
|||
// | | | |
|
||||
bool fullStart = false, fullEnd = false;
|
||||
Float halfDash;
|
||||
if (style == NS_STYLE_BORDER_STYLE_DASHED) {
|
||||
if (style == StyleBorderStyle::Dashed) {
|
||||
// If either end of the side is not connecting onto a corner then we want a
|
||||
// full dash at that end.
|
||||
//
|
||||
|
@ -1626,7 +1628,7 @@ nsCSSBorderRenderer::SetupDashedOptions(StrokeOptions* aStrokeOptions,
|
|||
|
||||
if (mBorderRadii[GetCCWCorner(aSide)].IsEmpty() &&
|
||||
(mBorderCornerDimensions[GetCCWCorner(aSide)].IsEmpty() ||
|
||||
mBorderStyles[PREV_SIDE(aSide)] == NS_STYLE_BORDER_STYLE_DOTTED ||
|
||||
mBorderStyles[PREV_SIDE(aSide)] == StyleBorderStyle::Dotted ||
|
||||
// XXX why this <=1 check?
|
||||
borderWidth <= 1.0f)) {
|
||||
fullStart = true;
|
||||
|
@ -1634,7 +1636,7 @@ nsCSSBorderRenderer::SetupDashedOptions(StrokeOptions* aStrokeOptions,
|
|||
|
||||
if (mBorderRadii[GetCWCorner(aSide)].IsEmpty() &&
|
||||
(mBorderCornerDimensions[GetCWCorner(aSide)].IsEmpty() ||
|
||||
mBorderStyles[NEXT_SIDE(aSide)] == NS_STYLE_BORDER_STYLE_DOTTED)) {
|
||||
mBorderStyles[NEXT_SIDE(aSide)] == StyleBorderStyle::Dotted)) {
|
||||
fullEnd = true;
|
||||
}
|
||||
|
||||
|
@ -1643,7 +1645,7 @@ nsCSSBorderRenderer::SetupDashedOptions(StrokeOptions* aStrokeOptions,
|
|||
halfDash = borderWidth * DOT_LENGTH / 2.0f;
|
||||
}
|
||||
|
||||
if (style == NS_STYLE_BORDER_STYLE_DASHED && aBorderLength > 0.0f) {
|
||||
if (style == StyleBorderStyle::Dashed && aBorderLength > 0.0f) {
|
||||
// The number of half segments, with maximum dash length.
|
||||
int32_t count = floor(aBorderLength / halfDash);
|
||||
Float minHalfDash = borderWidth * DOT_LENGTH / 2.0f;
|
||||
|
@ -1735,12 +1737,12 @@ nsCSSBorderRenderer::SetupDashedOptions(StrokeOptions* aStrokeOptions,
|
|||
aDash[0] = fullDash;
|
||||
aDash[1] = fullDash;
|
||||
|
||||
if (style == NS_STYLE_BORDER_STYLE_DASHED && fullDash > 1.0f) {
|
||||
if (style == StyleBorderStyle::Dashed && fullDash > 1.0f) {
|
||||
if (!fullStart) {
|
||||
// Draw half segments on both ends.
|
||||
aStrokeOptions->mDashOffset = halfDash;
|
||||
}
|
||||
} else if (style != NS_STYLE_BORDER_STYLE_DOTTED && isCorner) {
|
||||
} else if (style != StyleBorderStyle::Dotted && isCorner) {
|
||||
// If side ends with filled full segment, corner should start with unfilled
|
||||
// full segment. Not needed for dotted corners, as they overlap one dot with
|
||||
// the side's end.
|
||||
|
@ -1809,8 +1811,8 @@ nsCSSBorderRenderer::DrawDashedOrDottedSide(mozilla::Side aSide)
|
|||
// the line ends with unfilled dot.
|
||||
// (see comment for GetStraightBorderPoint for more detail)
|
||||
|
||||
NS_ASSERTION(mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DASHED ||
|
||||
mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DOTTED,
|
||||
NS_ASSERTION(mBorderStyles[aSide] == StyleBorderStyle::Dashed ||
|
||||
mBorderStyles[aSide] == StyleBorderStyle::Dotted,
|
||||
"Style should be dashed or dotted.");
|
||||
|
||||
Float borderWidth = mBorderWidths[aSide];
|
||||
|
@ -1818,7 +1820,7 @@ nsCSSBorderRenderer::DrawDashedOrDottedSide(mozilla::Side aSide)
|
|||
return;
|
||||
}
|
||||
|
||||
if (mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DOTTED &&
|
||||
if (mBorderStyles[aSide] == StyleBorderStyle::Dotted &&
|
||||
borderWidth > 2.0f) {
|
||||
DrawDottedSideSlow(aSide);
|
||||
return;
|
||||
|
@ -1881,7 +1883,7 @@ nsCSSBorderRenderer::DrawDashedOrDottedSide(mozilla::Side aSide)
|
|||
}
|
||||
|
||||
DrawOptions drawOptions;
|
||||
if (mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DOTTED) {
|
||||
if (mBorderStyles[aSide] == StyleBorderStyle::Dotted) {
|
||||
drawOptions.mAntialiasMode = AntialiasMode::NONE;
|
||||
}
|
||||
|
||||
|
@ -1898,7 +1900,7 @@ nsCSSBorderRenderer::DrawDottedSideSlow(mozilla::Side aSide)
|
|||
// Draw each circles separately for dotted with borderWidth > 2.0.
|
||||
// Dashed line with CapStyle::ROUND doesn't render perfect circles.
|
||||
|
||||
NS_ASSERTION(mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DOTTED,
|
||||
NS_ASSERTION(mBorderStyles[aSide] == StyleBorderStyle::Dotted,
|
||||
"Style should be dotted.");
|
||||
|
||||
Float borderWidth = mBorderWidths[aSide];
|
||||
|
@ -2302,8 +2304,8 @@ nsCSSBorderRenderer::DrawDashedOrDottedCorner(mozilla::Side aSide,
|
|||
// DrawDashedOrDottedSide. So this may draw no circles if there's no space
|
||||
// between 2 dots at both ends.
|
||||
|
||||
NS_ASSERTION(mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DASHED ||
|
||||
mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DOTTED,
|
||||
NS_ASSERTION(mBorderStyles[aSide] == StyleBorderStyle::Dashed ||
|
||||
mBorderStyles[aSide] == StyleBorderStyle::Dotted,
|
||||
"Style should be dashed or dotted.");
|
||||
|
||||
if (IsCornerMergeable(aCorner)) {
|
||||
|
@ -2319,13 +2321,13 @@ nsCSSBorderRenderer::DrawDashedOrDottedCorner(mozilla::Side aSide,
|
|||
return;
|
||||
}
|
||||
|
||||
Float styleH = mBorderStyles[sideH];
|
||||
Float styleV = mBorderStyles[sideV];
|
||||
StyleBorderStyle styleH = mBorderStyles[sideH];
|
||||
StyleBorderStyle styleV = mBorderStyles[sideV];
|
||||
|
||||
// Corner between dotted and others with radius=0 is drawn by side.
|
||||
if (IsZeroSize(mBorderRadii[aCorner]) &&
|
||||
(styleV == NS_STYLE_BORDER_STYLE_DOTTED ||
|
||||
styleH == NS_STYLE_BORDER_STYLE_DOTTED)) {
|
||||
(styleV == StyleBorderStyle::Dotted ||
|
||||
styleH == StyleBorderStyle::Dotted)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2337,8 +2339,8 @@ nsCSSBorderRenderer::DrawDashedOrDottedCorner(mozilla::Side aSide,
|
|||
}
|
||||
|
||||
if (borderWidthH != borderWidthV || borderWidthH > 2.0f) {
|
||||
uint8_t style = mBorderStyles[aSide];
|
||||
if (style == NS_STYLE_BORDER_STYLE_DOTTED) {
|
||||
StyleBorderStyle style = mBorderStyles[aSide];
|
||||
if (style == StyleBorderStyle::Dotted) {
|
||||
DrawDottedCornerSlow(aSide, aCorner);
|
||||
} else {
|
||||
DrawDashedCornerSlow(aSide, aCorner);
|
||||
|
@ -2384,7 +2386,7 @@ nsCSSBorderRenderer::DrawDashedOrDottedCorner(mozilla::Side aSide,
|
|||
void
|
||||
nsCSSBorderRenderer::DrawDottedCornerSlow(mozilla::Side aSide, Corner aCorner)
|
||||
{
|
||||
NS_ASSERTION(mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DOTTED,
|
||||
NS_ASSERTION(mBorderStyles[aSide] == StyleBorderStyle::Dotted,
|
||||
"Style should be dotted.");
|
||||
|
||||
mozilla::Side sideH(GetHorizontalSide(aCorner));
|
||||
|
@ -2468,7 +2470,7 @@ DashedPathOverlapsRect(Rect& pathRect,
|
|||
void
|
||||
nsCSSBorderRenderer::DrawDashedCornerSlow(mozilla::Side aSide, Corner aCorner)
|
||||
{
|
||||
NS_ASSERTION(mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DASHED,
|
||||
NS_ASSERTION(mBorderStyles[aSide] == StyleBorderStyle::Dashed,
|
||||
"Style should be dashed.");
|
||||
|
||||
mozilla::Side sideH(GetHorizontalSide(aCorner));
|
||||
|
@ -2589,8 +2591,8 @@ nsCSSBorderRenderer::DrawFallbackSolidCorner(mozilla::Side aSide,
|
|||
// Render too large dashed or dotted corner with solid style, to avoid hangup
|
||||
// inside DashedCornerFinder and DottedCornerFinder.
|
||||
|
||||
NS_ASSERTION(mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DASHED ||
|
||||
mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DOTTED,
|
||||
NS_ASSERTION(mBorderStyles[aSide] == StyleBorderStyle::Dashed ||
|
||||
mBorderStyles[aSide] == StyleBorderStyle::Dotted,
|
||||
"Style should be dashed or dotted.");
|
||||
|
||||
nscolor borderColor = mBorderColors[aSide];
|
||||
|
@ -2619,7 +2621,7 @@ nsCSSBorderRenderer::DrawFallbackSolidCorner(mozilla::Side aSide,
|
|||
mDocument,
|
||||
nsContentUtils::eCSS_PROPERTIES,
|
||||
mBorderStyles[aSide] ==
|
||||
NS_STYLE_BORDER_STYLE_DASHED
|
||||
StyleBorderStyle::Dashed
|
||||
? "TooLargeDashedRadius"
|
||||
: "TooLargeDottedRadius");
|
||||
}
|
||||
|
@ -2643,9 +2645,9 @@ nsCSSBorderRenderer::AllBordersSolid()
|
|||
{
|
||||
NS_FOR_CSS_SIDES(i)
|
||||
{
|
||||
if (mBorderStyles[i] == NS_STYLE_BORDER_STYLE_SOLID ||
|
||||
mBorderStyles[i] == NS_STYLE_BORDER_STYLE_NONE ||
|
||||
mBorderStyles[i] == NS_STYLE_BORDER_STYLE_HIDDEN) {
|
||||
if (mBorderStyles[i] == StyleBorderStyle::Solid ||
|
||||
mBorderStyles[i] == StyleBorderStyle::None ||
|
||||
mBorderStyles[i] == StyleBorderStyle::Hidden) {
|
||||
continue;
|
||||
}
|
||||
return false;
|
||||
|
@ -2655,10 +2657,10 @@ nsCSSBorderRenderer::AllBordersSolid()
|
|||
}
|
||||
|
||||
static bool
|
||||
IsVisible(int aStyle)
|
||||
IsVisible(StyleBorderStyle aStyle)
|
||||
{
|
||||
if (aStyle != NS_STYLE_BORDER_STYLE_NONE &&
|
||||
aStyle != NS_STYLE_BORDER_STYLE_HIDDEN) {
|
||||
if (aStyle != StyleBorderStyle::None &&
|
||||
aStyle != StyleBorderStyle::Hidden) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -3157,8 +3159,8 @@ void
|
|||
nsCSSBorderRenderer::DrawBorders()
|
||||
{
|
||||
if (mAllBordersSameStyle &&
|
||||
(mBorderStyles[0] == NS_STYLE_BORDER_STYLE_NONE ||
|
||||
mBorderStyles[0] == NS_STYLE_BORDER_STYLE_HIDDEN ||
|
||||
(mBorderStyles[0] == StyleBorderStyle::None ||
|
||||
mBorderStyles[0] == StyleBorderStyle::Hidden ||
|
||||
mBorderColors[0] == NS_RGBA(0, 0, 0, 0))) {
|
||||
// All borders are the same style, and the style is either none or hidden,
|
||||
// or the color is transparent.
|
||||
|
@ -3206,7 +3208,7 @@ nsCSSBorderRenderer::DrawBorders()
|
|||
// drawing paths, when none of these can be used we move on to the generalized
|
||||
// border drawing code.
|
||||
if (mAllBordersSameStyle && mAllBordersSameWidth &&
|
||||
mBorderStyles[0] == NS_STYLE_BORDER_STYLE_SOLID && mNoBorderRadius &&
|
||||
mBorderStyles[0] == StyleBorderStyle::Solid && mNoBorderRadius &&
|
||||
!mAvoidStroke) {
|
||||
// Very simple case.
|
||||
Rect rect = mOuterRect;
|
||||
|
@ -3215,7 +3217,7 @@ nsCSSBorderRenderer::DrawBorders()
|
|||
return;
|
||||
}
|
||||
|
||||
if (mAllBordersSameStyle && mBorderStyles[0] == NS_STYLE_BORDER_STYLE_SOLID &&
|
||||
if (mAllBordersSameStyle && mBorderStyles[0] == StyleBorderStyle::Solid &&
|
||||
!mAvoidStroke && !mNoBorderRadius) {
|
||||
// Relatively simple case.
|
||||
RoundedRect borderInnerRect(mOuterRect, mBorderRadii);
|
||||
|
@ -3288,9 +3290,9 @@ nsCSSBorderRenderer::DrawBorders()
|
|||
|
||||
NS_FOR_CSS_SIDES(i)
|
||||
{
|
||||
uint8_t style = mBorderStyles[i];
|
||||
if (style == NS_STYLE_BORDER_STYLE_DASHED ||
|
||||
style == NS_STYLE_BORDER_STYLE_DOTTED) {
|
||||
StyleBorderStyle style = mBorderStyles[i];
|
||||
if (style == StyleBorderStyle::Dashed ||
|
||||
style == StyleBorderStyle::Dotted) {
|
||||
// we need to draw things separately for dashed/dotting
|
||||
forceSeparateCorners = true;
|
||||
dashedSides |= (1 << i);
|
||||
|
@ -3430,13 +3432,13 @@ nsCSSBorderRenderer::DrawBorders()
|
|||
|
||||
for (int cornerSide = 0; cornerSide < 2; cornerSide++) {
|
||||
mozilla::Side side = mozilla::Side(sides[cornerSide]);
|
||||
uint8_t style = mBorderStyles[side];
|
||||
StyleBorderStyle style = mBorderStyles[side];
|
||||
|
||||
PrintAsFormatString("corner: %d cornerSide: %d side: %d style: %d\n",
|
||||
corner,
|
||||
cornerSide,
|
||||
side,
|
||||
style);
|
||||
static_cast<int>(style));
|
||||
|
||||
RefPtr<Path> path = GetSideClipSubPath(side);
|
||||
mDrawTarget->PushClip(path);
|
||||
|
@ -3488,8 +3490,8 @@ nsCSSBorderRenderer::DrawBorders()
|
|||
|
||||
// If there's no border on this side, skip it
|
||||
if (mBorderWidths[side] == 0.0 ||
|
||||
mBorderStyles[side] == NS_STYLE_BORDER_STYLE_HIDDEN ||
|
||||
mBorderStyles[side] == NS_STYLE_BORDER_STYLE_NONE)
|
||||
mBorderStyles[side] == StyleBorderStyle::Hidden ||
|
||||
mBorderStyles[side] == StyleBorderStyle::None)
|
||||
continue;
|
||||
|
||||
if (dashedSides & (1 << side)) {
|
||||
|
|
|
@ -92,7 +92,7 @@ public:
|
|||
DrawTarget* aDrawTarget,
|
||||
const Rect& aDirtyRect,
|
||||
Rect& aOuterRect,
|
||||
const uint8_t* aBorderStyles,
|
||||
const mozilla::StyleBorderStyle* aBorderStyles,
|
||||
const Float* aBorderWidths,
|
||||
RectCornerRadii& aBorderRadii,
|
||||
const nscolor* aBorderColors,
|
||||
|
@ -139,7 +139,7 @@ private:
|
|||
Rect mInnerRect;
|
||||
|
||||
// the style and size of the border
|
||||
uint8_t mBorderStyles[4];
|
||||
mozilla::StyleBorderStyle mBorderStyles[4];
|
||||
Float mBorderWidths[4];
|
||||
RectCornerRadii mBorderRadii;
|
||||
|
||||
|
@ -160,13 +160,13 @@ private:
|
|||
bool AreBorderSideFinalStylesSame(uint8_t aSides);
|
||||
|
||||
// For the given style, is the given corner a solid color?
|
||||
bool IsSolidCornerStyle(uint8_t aStyle, mozilla::Corner aCorner);
|
||||
bool IsSolidCornerStyle(mozilla::StyleBorderStyle aStyle, mozilla::Corner aCorner);
|
||||
|
||||
// For the given corner, is the given corner mergeable into one dot?
|
||||
bool IsCornerMergeable(mozilla::Corner aCorner);
|
||||
|
||||
// For the given solid corner, what color style should be used?
|
||||
BorderColorStyle BorderColorStyleForSolidCorner(uint8_t aStyle,
|
||||
BorderColorStyle BorderColorStyleForSolidCorner(mozilla::StyleBorderStyle aStyle,
|
||||
mozilla::Corner aCorner);
|
||||
|
||||
//
|
||||
|
|
|
@ -5307,8 +5307,8 @@ nsDisplayOutline::CreateWebRenderCommands(
|
|||
{
|
||||
ContainerLayerParameters parameter;
|
||||
|
||||
uint8_t outlineStyle = mFrame->Style()->StyleOutline()->mOutlineStyle;
|
||||
if (outlineStyle == NS_STYLE_BORDER_STYLE_AUTO &&
|
||||
StyleBorderStyle outlineStyle = mFrame->Style()->StyleOutline()->mOutlineStyle;
|
||||
if (outlineStyle == StyleBorderStyle::Auto &&
|
||||
nsLayoutUtils::IsOutlineStyleAutoEnabled()) {
|
||||
nsITheme* theme = mFrame->PresContext()->GetTheme();
|
||||
if (theme && theme->ThemeSupportsWidget(mFrame->PresContext(),
|
||||
|
|
|
@ -133,6 +133,7 @@ rusty-enums = [
|
|||
"mozilla::StyleImageLayerRepeat",
|
||||
"mozilla::StyleImageLayerAttachment",
|
||||
"mozilla::StyleBoxDecorationBreak",
|
||||
"mozilla::StyleBorderStyle",
|
||||
"mozilla::StyleRuleInclusion",
|
||||
"mozilla::StyleGridTrackBreadth",
|
||||
"mozilla::StyleOverscrollBehavior",
|
||||
|
|
|
@ -189,16 +189,16 @@ nsCSSProps::GetStringValue(nsCSSCounterDesc aCounterDesc)
|
|||
/***************************************************************************/
|
||||
|
||||
const KTableEntry nsCSSProps::kBorderStyleKTable[] = {
|
||||
{ eCSSKeyword_none, NS_STYLE_BORDER_STYLE_NONE },
|
||||
{ eCSSKeyword_hidden, NS_STYLE_BORDER_STYLE_HIDDEN },
|
||||
{ eCSSKeyword_dotted, NS_STYLE_BORDER_STYLE_DOTTED },
|
||||
{ eCSSKeyword_dashed, NS_STYLE_BORDER_STYLE_DASHED },
|
||||
{ eCSSKeyword_solid, NS_STYLE_BORDER_STYLE_SOLID },
|
||||
{ eCSSKeyword_double, NS_STYLE_BORDER_STYLE_DOUBLE },
|
||||
{ eCSSKeyword_groove, NS_STYLE_BORDER_STYLE_GROOVE },
|
||||
{ eCSSKeyword_ridge, NS_STYLE_BORDER_STYLE_RIDGE },
|
||||
{ eCSSKeyword_inset, NS_STYLE_BORDER_STYLE_INSET },
|
||||
{ eCSSKeyword_outset, NS_STYLE_BORDER_STYLE_OUTSET },
|
||||
{ eCSSKeyword_none, StyleBorderStyle::None },
|
||||
{ eCSSKeyword_hidden, StyleBorderStyle::Hidden },
|
||||
{ eCSSKeyword_dotted, StyleBorderStyle::Dotted },
|
||||
{ eCSSKeyword_dashed, StyleBorderStyle::Dashed },
|
||||
{ eCSSKeyword_solid, StyleBorderStyle::Solid },
|
||||
{ eCSSKeyword_double, StyleBorderStyle::Double },
|
||||
{ eCSSKeyword_groove, StyleBorderStyle::Groove },
|
||||
{ eCSSKeyword_ridge, StyleBorderStyle::Ridge },
|
||||
{ eCSSKeyword_inset, StyleBorderStyle::Inset },
|
||||
{ eCSSKeyword_outset, StyleBorderStyle::Outset },
|
||||
{ eCSSKeyword_UNKNOWN, -1 }
|
||||
};
|
||||
|
||||
|
@ -498,16 +498,16 @@ const KTableEntry nsCSSProps::kContainKTable[] = {
|
|||
|
||||
// Same as kBorderStyleKTable except 'hidden'.
|
||||
const KTableEntry nsCSSProps::kOutlineStyleKTable[] = {
|
||||
{ eCSSKeyword_none, NS_STYLE_BORDER_STYLE_NONE },
|
||||
{ eCSSKeyword_auto, NS_STYLE_BORDER_STYLE_AUTO },
|
||||
{ eCSSKeyword_dotted, NS_STYLE_BORDER_STYLE_DOTTED },
|
||||
{ eCSSKeyword_dashed, NS_STYLE_BORDER_STYLE_DASHED },
|
||||
{ eCSSKeyword_solid, NS_STYLE_BORDER_STYLE_SOLID },
|
||||
{ eCSSKeyword_double, NS_STYLE_BORDER_STYLE_DOUBLE },
|
||||
{ eCSSKeyword_groove, NS_STYLE_BORDER_STYLE_GROOVE },
|
||||
{ eCSSKeyword_ridge, NS_STYLE_BORDER_STYLE_RIDGE },
|
||||
{ eCSSKeyword_inset, NS_STYLE_BORDER_STYLE_INSET },
|
||||
{ eCSSKeyword_outset, NS_STYLE_BORDER_STYLE_OUTSET },
|
||||
{ eCSSKeyword_none, StyleBorderStyle::None },
|
||||
{ eCSSKeyword_auto, StyleBorderStyle::Auto },
|
||||
{ eCSSKeyword_dotted, StyleBorderStyle::Dotted },
|
||||
{ eCSSKeyword_dashed, StyleBorderStyle::Dashed },
|
||||
{ eCSSKeyword_solid, StyleBorderStyle::Solid },
|
||||
{ eCSSKeyword_double, StyleBorderStyle::Double },
|
||||
{ eCSSKeyword_groove, StyleBorderStyle::Groove },
|
||||
{ eCSSKeyword_ridge, StyleBorderStyle::Ridge },
|
||||
{ eCSSKeyword_inset, StyleBorderStyle::Inset },
|
||||
{ eCSSKeyword_outset, StyleBorderStyle::Outset },
|
||||
{ eCSSKeyword_UNKNOWN, -1 }
|
||||
};
|
||||
|
||||
|
|
|
@ -2205,7 +2205,7 @@ nsComputedDOMStyle::DoGetOutlineWidth()
|
|||
const nsStyleOutline* outline = StyleOutline();
|
||||
|
||||
nscoord width;
|
||||
if (outline->mOutlineStyle == NS_STYLE_BORDER_STYLE_NONE) {
|
||||
if (outline->mOutlineStyle == StyleBorderStyle::None) {
|
||||
NS_ASSERTION(outline->GetOutlineWidth() == 0, "unexpected width");
|
||||
width = 0;
|
||||
} else {
|
||||
|
|
|
@ -306,18 +306,19 @@ enum class StyleImageLayerRepeat : uint8_t {
|
|||
#define NS_STYLE_BORDER_WIDTH_THICK 2
|
||||
// XXX chopping block #define NS_STYLE_BORDER_WIDTH_LENGTH_VALUE 3
|
||||
|
||||
// See nsStyleBorder mBorderStyle
|
||||
#define NS_STYLE_BORDER_STYLE_NONE 0
|
||||
#define NS_STYLE_BORDER_STYLE_GROOVE 1
|
||||
#define NS_STYLE_BORDER_STYLE_RIDGE 2
|
||||
#define NS_STYLE_BORDER_STYLE_DOTTED 3
|
||||
#define NS_STYLE_BORDER_STYLE_DASHED 4
|
||||
#define NS_STYLE_BORDER_STYLE_SOLID 5
|
||||
#define NS_STYLE_BORDER_STYLE_DOUBLE 6
|
||||
#define NS_STYLE_BORDER_STYLE_INSET 7
|
||||
#define NS_STYLE_BORDER_STYLE_OUTSET 8
|
||||
#define NS_STYLE_BORDER_STYLE_HIDDEN 9
|
||||
#define NS_STYLE_BORDER_STYLE_AUTO 10 // for outline-style only
|
||||
enum class StyleBorderStyle : uint8_t {
|
||||
None,
|
||||
Groove,
|
||||
Ridge,
|
||||
Dotted,
|
||||
Dashed,
|
||||
Solid,
|
||||
Double,
|
||||
Inset,
|
||||
Outset,
|
||||
Hidden,
|
||||
Auto, // for outline-style only
|
||||
};
|
||||
|
||||
// border-image-repeat
|
||||
enum class StyleBorderImageRepeat : uint8_t {
|
||||
|
|
|
@ -291,7 +291,7 @@ nsStyleBorder::nsStyleBorder(const nsPresContext* aContext)
|
|||
mBorderImageOutset.Set(side, nsStyleCoord(0.0f, eStyleUnit_Factor));
|
||||
|
||||
mBorder.Side(side) = medium;
|
||||
mBorderStyle[side] = NS_STYLE_BORDER_STYLE_NONE;
|
||||
mBorderStyle[side] = StyleBorderStyle::None;
|
||||
}
|
||||
|
||||
mTwipsPerPixel = aContext->DevPixelsToAppUnits(1);
|
||||
|
@ -449,7 +449,7 @@ nsStyleOutline::nsStyleOutline(const nsPresContext* aContext)
|
|||
->GetBorderWidthTable())[NS_STYLE_BORDER_WIDTH_MEDIUM])
|
||||
, mOutlineOffset(0)
|
||||
, mOutlineColor(StyleComplexColor::CurrentColor())
|
||||
, mOutlineStyle(NS_STYLE_BORDER_STYLE_NONE)
|
||||
, mOutlineStyle(StyleBorderStyle::None)
|
||||
, mActualOutlineWidth(0)
|
||||
, mTwipsPerPixel(aContext->DevPixelsToAppUnits(1))
|
||||
{
|
||||
|
@ -476,7 +476,7 @@ nsStyleOutline::nsStyleOutline(const nsStyleOutline& aSrc)
|
|||
void
|
||||
nsStyleOutline::RecalcData()
|
||||
{
|
||||
if (NS_STYLE_BORDER_STYLE_NONE == mOutlineStyle) {
|
||||
if (StyleBorderStyle::None == mOutlineStyle) {
|
||||
mActualOutlineWidth = 0;
|
||||
} else {
|
||||
mActualOutlineWidth =
|
||||
|
@ -667,7 +667,7 @@ nsStyleXUL::CalcDifference(const nsStyleXUL& aNewData) const
|
|||
nsStyleColumn::nsStyleColumn(const nsPresContext* aContext)
|
||||
: mColumnWidth(eStyleUnit_Auto)
|
||||
, mColumnRuleColor(StyleComplexColor::CurrentColor())
|
||||
, mColumnRuleStyle(NS_STYLE_BORDER_STYLE_NONE)
|
||||
, mColumnRuleStyle(StyleBorderStyle::None)
|
||||
, mColumnRuleWidth((StaticPresData::Get()
|
||||
->GetBorderWidthTable())[NS_STYLE_BORDER_WIDTH_MEDIUM])
|
||||
, mTwipsPerPixel(aContext->AppUnitsPerDevPixel())
|
||||
|
|
|
@ -965,10 +965,10 @@ private:
|
|||
((l) == 0) ? 0 : std::max((tpp), (l) / (tpp) * (tpp))
|
||||
|
||||
// Returns if the given border style type is visible or not
|
||||
static bool IsVisibleBorderStyle(uint8_t aStyle)
|
||||
static bool IsVisibleBorderStyle(mozilla::StyleBorderStyle aStyle)
|
||||
{
|
||||
return (aStyle != NS_STYLE_BORDER_STYLE_NONE &&
|
||||
aStyle != NS_STYLE_BORDER_STYLE_HIDDEN);
|
||||
return (aStyle != mozilla::StyleBorderStyle::None &&
|
||||
aStyle != mozilla::StyleBorderStyle::Hidden);
|
||||
}
|
||||
|
||||
struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleBorder
|
||||
|
@ -1028,13 +1028,13 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleBorder
|
|||
return GetComputedBorder().Side(aSide);
|
||||
}
|
||||
|
||||
uint8_t GetBorderStyle(mozilla::Side aSide) const
|
||||
mozilla::StyleBorderStyle GetBorderStyle(mozilla::Side aSide) const
|
||||
{
|
||||
NS_ASSERTION(aSide <= mozilla::eSideLeft, "bad side");
|
||||
return mBorderStyle[aSide];
|
||||
}
|
||||
|
||||
void SetBorderStyle(mozilla::Side aSide, uint8_t aStyle)
|
||||
void SetBorderStyle(mozilla::Side aSide, mozilla::StyleBorderStyle aStyle)
|
||||
{
|
||||
NS_ASSERTION(aSide <= mozilla::eSideLeft, "bad side");
|
||||
mBorderStyle[aSide] = aStyle;
|
||||
|
@ -1071,7 +1071,7 @@ public:
|
|||
mozilla::StyleBoxDecorationBreak mBoxDecorationBreak;
|
||||
|
||||
protected:
|
||||
uint8_t mBorderStyle[4]; // NS_STYLE_BORDER_STYLE_*
|
||||
mozilla::StyleBorderStyle mBorderStyle[4]; // StyleBorderStyle::*
|
||||
|
||||
public:
|
||||
// the colors to use for a simple border.
|
||||
|
@ -1172,7 +1172,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleOutline
|
|||
nscoord mOutlineWidth;
|
||||
nscoord mOutlineOffset;
|
||||
mozilla::StyleComplexColor mOutlineColor;
|
||||
uint8_t mOutlineStyle; // NS_STYLE_BORDER_STYLE_*
|
||||
mozilla::StyleBorderStyle mOutlineStyle; // StyleBorderStyle::*
|
||||
|
||||
nscoord GetOutlineWidth() const
|
||||
{
|
||||
|
@ -1181,9 +1181,9 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleOutline
|
|||
|
||||
bool ShouldPaintOutline() const
|
||||
{
|
||||
return mOutlineStyle == NS_STYLE_BORDER_STYLE_AUTO ||
|
||||
return mOutlineStyle == mozilla::StyleBorderStyle::Auto ||
|
||||
(GetOutlineWidth() > 0 &&
|
||||
mOutlineStyle != NS_STYLE_BORDER_STYLE_NONE);
|
||||
mOutlineStyle != mozilla::StyleBorderStyle::None);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -2781,7 +2781,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleColumn
|
|||
nsStyleCoord mColumnWidth; // coord, auto
|
||||
|
||||
mozilla::StyleComplexColor mColumnRuleColor;
|
||||
uint8_t mColumnRuleStyle; // NS_STYLE_BORDER_STYLE_*
|
||||
mozilla::StyleBorderStyle mColumnRuleStyle; // StyleborderStyle::*
|
||||
mozilla::StyleColumnFill mColumnFill = mozilla::StyleColumnFill::Balance;
|
||||
mozilla::StyleColumnSpan mColumnSpan = mozilla::StyleColumnSpan::None;
|
||||
|
||||
|
|
|
@ -4425,8 +4425,8 @@ struct BCCellBorder
|
|||
void Reset(uint32_t aRowIndex, uint32_t aRowSpan);
|
||||
nscolor color; // border segment color
|
||||
BCPixelSize width; // border segment width in pixel coordinates !!
|
||||
uint8_t style; // border segment style, possible values are defined
|
||||
// in nsStyleConsts.h as NS_STYLE_BORDER_STYLE_*
|
||||
StyleBorderStyle style; // border segment style, possible values are defined
|
||||
// in nsStyleConsts.h as StyleBorderStyle::*
|
||||
BCBorderOwner owner; // border segment owner, possible values are defined
|
||||
// in celldata.h. In the cellmap for each border
|
||||
// segment we store the owner and later when
|
||||
|
@ -4442,7 +4442,7 @@ void
|
|||
BCCellBorder::Reset(uint32_t aRowIndex,
|
||||
uint32_t aRowSpan)
|
||||
{
|
||||
style = NS_STYLE_BORDER_STYLE_NONE;
|
||||
style = StyleBorderStyle::None;
|
||||
color = 0;
|
||||
width = 0;
|
||||
owner = eTableOwner;
|
||||
|
@ -5002,18 +5002,18 @@ BCMapCellIterator::PeekBEnd(BCMapCellInfo& aRefInfo,
|
|||
aAjaInfo.SetInfo(nextRow, aColIndex, cellData, this, cellMap);
|
||||
}
|
||||
|
||||
// Assign priorities to border styles. For example, styleToPriority(NS_STYLE_BORDER_STYLE_SOLID)
|
||||
// will return the priority of NS_STYLE_BORDER_STYLE_SOLID.
|
||||
static uint8_t styleToPriority[13] = { 0, // NS_STYLE_BORDER_STYLE_NONE
|
||||
2, // NS_STYLE_BORDER_STYLE_GROOVE
|
||||
4, // NS_STYLE_BORDER_STYLE_RIDGE
|
||||
5, // NS_STYLE_BORDER_STYLE_DOTTED
|
||||
6, // NS_STYLE_BORDER_STYLE_DASHED
|
||||
7, // NS_STYLE_BORDER_STYLE_SOLID
|
||||
8, // NS_STYLE_BORDER_STYLE_DOUBLE
|
||||
1, // NS_STYLE_BORDER_STYLE_INSET
|
||||
3, // NS_STYLE_BORDER_STYLE_OUTSET
|
||||
9 };// NS_STYLE_BORDER_STYLE_HIDDEN
|
||||
// Assign priorities to border styles. For example, styleToPriority(StyleBorderStyle::Solid)
|
||||
// will return the priority of StyleBorderStyle::Solid.
|
||||
static uint8_t styleToPriority[13] = { 0, // StyleBorderStyle::None
|
||||
2, // StyleBorderStyle::Groove
|
||||
4, // StyleBorderStyle::Ridge
|
||||
5, // StyleBorderStyle::Dotted
|
||||
6, // StyleBorderStyle::Dashed
|
||||
7, // StyleBorderStyle::Solid
|
||||
8, // StyleBorderStyle::Double
|
||||
1, // StyleBorderStyle::Inset
|
||||
3, // StyleBorderStyle::Outset
|
||||
9 };// StyleBorderStyle::Hidden
|
||||
// priority rules follow CSS 2.1 spec
|
||||
// 'hidden', 'double', 'solid', 'dashed', 'dotted', 'ridge', 'outset', 'groove',
|
||||
// and the lowest: 'inset'. none is even weaker
|
||||
|
@ -5032,7 +5032,7 @@ static void
|
|||
GetColorAndStyle(const nsIFrame* aFrame,
|
||||
WritingMode aTableWM,
|
||||
LogicalSide aSide,
|
||||
uint8_t* aStyle,
|
||||
StyleBorderStyle* aStyle,
|
||||
nscolor* aColor,
|
||||
BCPixelSize* aWidth = nullptr)
|
||||
{
|
||||
|
@ -5049,8 +5049,8 @@ GetColorAndStyle(const nsIFrame* aFrame,
|
|||
mozilla::Side physicalSide = aTableWM.PhysicalSide(aSide);
|
||||
*aStyle = styleData->GetBorderStyle(physicalSide);
|
||||
|
||||
if ((NS_STYLE_BORDER_STYLE_NONE == *aStyle) ||
|
||||
(NS_STYLE_BORDER_STYLE_HIDDEN == *aStyle)) {
|
||||
if ((StyleBorderStyle::None == *aStyle) ||
|
||||
(StyleBorderStyle::Hidden == *aStyle)) {
|
||||
return;
|
||||
}
|
||||
*aColor = aFrame->Style()->
|
||||
|
@ -5073,14 +5073,14 @@ static void
|
|||
GetPaintStyleInfo(const nsIFrame* aFrame,
|
||||
WritingMode aTableWM,
|
||||
LogicalSide aSide,
|
||||
uint8_t* aStyle,
|
||||
StyleBorderStyle* aStyle,
|
||||
nscolor* aColor)
|
||||
{
|
||||
GetColorAndStyle(aFrame, aTableWM, aSide, aStyle, aColor);
|
||||
if (NS_STYLE_BORDER_STYLE_INSET == *aStyle) {
|
||||
*aStyle = NS_STYLE_BORDER_STYLE_RIDGE;
|
||||
} else if (NS_STYLE_BORDER_STYLE_OUTSET == *aStyle) {
|
||||
*aStyle = NS_STYLE_BORDER_STYLE_GROOVE;
|
||||
if (StyleBorderStyle::Inset == *aStyle) {
|
||||
*aStyle = StyleBorderStyle::Ridge;
|
||||
} else if (StyleBorderStyle::Outset == *aStyle) {
|
||||
*aStyle = StyleBorderStyle::Groove;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5151,20 +5151,22 @@ CompareBorders(bool aIsCorner, // Pass true for corner calculatio
|
|||
{
|
||||
bool firstDominates = true;
|
||||
|
||||
if (NS_STYLE_BORDER_STYLE_HIDDEN == aBorder1.style) {
|
||||
if (StyleBorderStyle::Hidden == aBorder1.style) {
|
||||
firstDominates = (aIsCorner) ? false : true;
|
||||
}
|
||||
else if (NS_STYLE_BORDER_STYLE_HIDDEN == aBorder2.style) {
|
||||
else if (StyleBorderStyle::Hidden == aBorder2.style) {
|
||||
firstDominates = (aIsCorner) ? true : false;
|
||||
}
|
||||
else if (aBorder1.width < aBorder2.width) {
|
||||
firstDominates = false;
|
||||
}
|
||||
else if (aBorder1.width == aBorder2.width) {
|
||||
if (styleToPriority[aBorder1.style] < styleToPriority[aBorder2.style]) {
|
||||
if (styleToPriority[static_cast<uint8_t>(aBorder1.style)] <
|
||||
styleToPriority[static_cast<uint8_t>(aBorder2.style)]) {
|
||||
firstDominates = false;
|
||||
}
|
||||
else if (styleToPriority[aBorder1.style] == styleToPriority[aBorder2.style]) {
|
||||
else if (styleToPriority[static_cast<uint8_t>(aBorder1.style)] ==
|
||||
styleToPriority[static_cast<uint8_t>(aBorder2.style)]) {
|
||||
if (aBorder1.owner == aBorder2.owner) {
|
||||
firstDominates = !aSecondIsInlineDir;
|
||||
}
|
||||
|
@ -5220,7 +5222,7 @@ CompareBorders(const nsIFrame* aTableFrame,
|
|||
GetColorAndStyle(aTableFrame, aTableWM, aSide,
|
||||
&border.style, &border.color, &border.width);
|
||||
border.owner = eTableOwner;
|
||||
if (NS_STYLE_BORDER_STYLE_HIDDEN == border.style) {
|
||||
if (StyleBorderStyle::Hidden == border.style) {
|
||||
return border;
|
||||
}
|
||||
}
|
||||
|
@ -5231,7 +5233,7 @@ CompareBorders(const nsIFrame* aTableFrame,
|
|||
tempBorder.owner = aAja && !inlineAxis ? eAjaColGroupOwner : eColGroupOwner;
|
||||
// pass here and below false for aSecondIsInlineDir as it is only used for corner calculations.
|
||||
border = CompareBorders(!CELL_CORNER, border, tempBorder, false);
|
||||
if (NS_STYLE_BORDER_STYLE_HIDDEN == border.style) {
|
||||
if (StyleBorderStyle::Hidden == border.style) {
|
||||
return border;
|
||||
}
|
||||
}
|
||||
|
@ -5241,7 +5243,7 @@ CompareBorders(const nsIFrame* aTableFrame,
|
|||
&tempBorder.style, &tempBorder.color, &tempBorder.width);
|
||||
tempBorder.owner = aAja && !inlineAxis ? eAjaColOwner : eColOwner;
|
||||
border = CompareBorders(!CELL_CORNER, border, tempBorder, false);
|
||||
if (NS_STYLE_BORDER_STYLE_HIDDEN == border.style) {
|
||||
if (StyleBorderStyle::Hidden == border.style) {
|
||||
return border;
|
||||
}
|
||||
}
|
||||
|
@ -5251,7 +5253,7 @@ CompareBorders(const nsIFrame* aTableFrame,
|
|||
&tempBorder.style, &tempBorder.color, &tempBorder.width);
|
||||
tempBorder.owner = aAja && inlineAxis ? eAjaRowGroupOwner : eRowGroupOwner;
|
||||
border = CompareBorders(!CELL_CORNER, border, tempBorder, false);
|
||||
if (NS_STYLE_BORDER_STYLE_HIDDEN == border.style) {
|
||||
if (StyleBorderStyle::Hidden == border.style) {
|
||||
return border;
|
||||
}
|
||||
}
|
||||
|
@ -5261,7 +5263,7 @@ CompareBorders(const nsIFrame* aTableFrame,
|
|||
&tempBorder.style, &tempBorder.color, &tempBorder.width);
|
||||
tempBorder.owner = aAja && inlineAxis ? eAjaRowOwner : eRowOwner;
|
||||
border = CompareBorders(!CELL_CORNER, border, tempBorder, false);
|
||||
if (NS_STYLE_BORDER_STYLE_HIDDEN == border.style) {
|
||||
if (StyleBorderStyle::Hidden == border.style) {
|
||||
return border;
|
||||
}
|
||||
}
|
||||
|
@ -5283,7 +5285,7 @@ Perpendicular(mozilla::LogicalSide aSide1,
|
|||
}
|
||||
|
||||
// Initial value indicating that BCCornerInfo's ownerStyle hasn't been set yet.
|
||||
#define BORDER_STYLE_UNSET 0xF
|
||||
#define BORDER_STYLE_UNSET static_cast<StyleBorderStyle>(255)
|
||||
|
||||
// XXX allocate this as number-of-cols+1 instead of number-of-cols+1 * number-of-rows+1
|
||||
struct BCCornerInfo
|
||||
|
@ -5291,7 +5293,7 @@ struct BCCornerInfo
|
|||
BCCornerInfo() { ownerColor = 0; ownerWidth = subWidth = ownerElem = subSide =
|
||||
subElem = hasDashDot = numSegs = bevel = 0; ownerSide = eLogicalSideBStart;
|
||||
ownerStyle = BORDER_STYLE_UNSET;
|
||||
subStyle = NS_STYLE_BORDER_STYLE_SOLID; }
|
||||
subStyle = StyleBorderStyle::Solid; }
|
||||
|
||||
void Set(mozilla::LogicalSide aSide,
|
||||
BCCellBorder border);
|
||||
|
@ -5299,20 +5301,20 @@ struct BCCornerInfo
|
|||
void Update(mozilla::LogicalSide aSide,
|
||||
BCCellBorder border);
|
||||
|
||||
nscolor ownerColor; // color of borderOwner
|
||||
uint16_t ownerWidth; // pixel width of borderOwner
|
||||
uint16_t subWidth; // pixel width of the largest border intersecting the border perpendicular
|
||||
// to ownerSide
|
||||
uint32_t ownerSide:2; // LogicalSide (e.g eLogicalSideBStart, etc) of the border
|
||||
// owning the corner relative to the corner
|
||||
uint32_t ownerElem:4; // elem type (e.g. eTable, eGroup, etc) owning the corner
|
||||
uint32_t ownerStyle:4; // border style of ownerElem
|
||||
uint32_t subSide:2; // side of border with subWidth relative to the corner
|
||||
uint32_t subElem:4; // elem type (e.g. eTable, eGroup, etc) of sub owner
|
||||
uint32_t subStyle:4; // border style of subElem
|
||||
uint32_t hasDashDot:1; // does a dashed, dotted segment enter the corner, they cannot be beveled
|
||||
uint32_t numSegs:3; // number of segments entering corner
|
||||
uint32_t bevel:1; // is the corner beveled (uses the above two fields together with subWidth)
|
||||
nscolor ownerColor; // color of borderOwner
|
||||
uint16_t ownerWidth; // pixel width of borderOwner
|
||||
uint16_t subWidth; // pixel width of the largest border intersecting the border perpendicular
|
||||
// to ownerSide
|
||||
StyleBorderStyle subStyle; // border style of subElem
|
||||
StyleBorderStyle ownerStyle;// border style of ownerElem
|
||||
uint16_t ownerSide:2; // LogicalSide (e.g eLogicalSideBStart, etc) of the border
|
||||
// owning the corner relative to the corner
|
||||
uint16_t ownerElem:4; // elem type (e.g. eTable, eGroup, etc) owning the corner
|
||||
uint16_t subSide:2; // side of border with subWidth relative to the corner
|
||||
uint16_t subElem:4; // elem type (e.g. eTable, eGroup, etc) of sub owner
|
||||
uint16_t hasDashDot:1; // does a dashed, dotted segment enter the corner, they cannot be beveled
|
||||
uint16_t numSegs:3; // number of segments entering corner
|
||||
uint16_t bevel:1; // is the corner beveled (uses the above two fields together with subWidth)
|
||||
// 7 bits are unused
|
||||
};
|
||||
|
||||
|
@ -5332,15 +5334,15 @@ BCCornerInfo::Set(mozilla::LogicalSide aSide,
|
|||
numSegs = 0;
|
||||
if (aBorder.width > 0) {
|
||||
numSegs++;
|
||||
hasDashDot = (NS_STYLE_BORDER_STYLE_DASHED == aBorder.style) ||
|
||||
(NS_STYLE_BORDER_STYLE_DOTTED == aBorder.style);
|
||||
hasDashDot = (StyleBorderStyle::Dashed == aBorder.style) ||
|
||||
(StyleBorderStyle::Dotted == aBorder.style);
|
||||
}
|
||||
bevel = 0;
|
||||
subWidth = 0;
|
||||
// the following will get set later
|
||||
subSide = IsInline(aSide) ? eLogicalSideBStart : eLogicalSideIStart;
|
||||
subElem = eTableOwner;
|
||||
subStyle = NS_STYLE_BORDER_STYLE_SOLID;
|
||||
subStyle = StyleBorderStyle::Solid;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -5398,8 +5400,8 @@ BCCornerInfo::Update(mozilla::LogicalSide aSide,
|
|||
}
|
||||
if (aBorder.width > 0) {
|
||||
numSegs++;
|
||||
if (!hasDashDot && ((NS_STYLE_BORDER_STYLE_DASHED == aBorder.style) ||
|
||||
(NS_STYLE_BORDER_STYLE_DOTTED == aBorder.style))) {
|
||||
if (!hasDashDot && ((StyleBorderStyle::Dashed == aBorder.style) ||
|
||||
(StyleBorderStyle::Dotted == aBorder.style))) {
|
||||
hasDashDot = 1;
|
||||
}
|
||||
}
|
||||
|
@ -6503,7 +6505,7 @@ class BCPaintBorderIterator;
|
|||
|
||||
struct BCBorderParameters
|
||||
{
|
||||
uint8_t mBorderStyle;
|
||||
StyleBorderStyle mBorderStyle;
|
||||
nscolor mBorderColor;
|
||||
nsRect mBorderRect;
|
||||
int32_t mAppUnitsPerDevPixel;
|
||||
|
@ -6519,8 +6521,8 @@ struct BCBorderParameters
|
|||
return false;
|
||||
}
|
||||
|
||||
if (mBorderStyle == NS_STYLE_BORDER_STYLE_DASHED ||
|
||||
mBorderStyle == NS_STYLE_BORDER_STYLE_DOTTED) {
|
||||
if (mBorderStyle == StyleBorderStyle::Dashed ||
|
||||
mBorderStyle == StyleBorderStyle::Dotted) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -7384,7 +7386,7 @@ BCBlockDirSeg::BuildBorderParameters(BCPaintBorderIterator& aIter,
|
|||
nsTableColFrame* col = mCol; if (!col) ABORT1(Nothing());
|
||||
nsTableCellFrame* cell = mFirstCell; // ???
|
||||
nsIFrame* owner = nullptr;
|
||||
result.mBorderStyle = NS_STYLE_BORDER_STYLE_SOLID;
|
||||
result.mBorderStyle = StyleBorderStyle::Solid;
|
||||
result.mBorderColor = 0xFFFFFFFF;
|
||||
result.mBackfaceIsVisible = true;
|
||||
|
||||
|
@ -7534,7 +7536,7 @@ AdjustAndPushBevel(wr::DisplayListBuilder& aBuilder,
|
|||
wr::LayoutRect bevelRect = aRect;
|
||||
wr::BorderSide bevelBorder[4];
|
||||
NS_FOR_CSS_SIDES(i) {
|
||||
bevelBorder[i] = wr::ToBorderSide(ToDeviceColor(aColor), NS_STYLE_BORDER_STYLE_SOLID);
|
||||
bevelBorder[i] = wr::ToBorderSide(ToDeviceColor(aColor), StyleBorderStyle::Solid);
|
||||
}
|
||||
|
||||
// We're creating a half-transparent triangle using the border primitive.
|
||||
|
@ -7669,7 +7671,7 @@ CreateWRCommandsForBorderSegment(const BCBorderParameters& aBorderParams,
|
|||
wr::LayoutRect roundedRect = wr::ToRoundedLayoutRect(borderRect);
|
||||
wr::BorderSide wrSide[4];
|
||||
NS_FOR_CSS_SIDES(i) {
|
||||
wrSide[i] = wr::ToBorderSide(ToDeviceColor(aBorderParams.mBorderColor), NS_STYLE_BORDER_STYLE_NONE);
|
||||
wrSide[i] = wr::ToBorderSide(ToDeviceColor(aBorderParams.mBorderColor), StyleBorderStyle::None);
|
||||
}
|
||||
const bool horizontal = aBorderParams.mStartBevelSide == eSideTop ||
|
||||
aBorderParams.mStartBevelSide == eSideBottom;
|
||||
|
@ -7833,7 +7835,7 @@ BCInlineDirSeg::BuildBorderParameters(BCPaintBorderIterator& aIter)
|
|||
nsPresContext* presContext = aIter.mTable->PresContext();
|
||||
result.mAppUnitsPerDevPixel = presContext->AppUnitsPerDevPixel();
|
||||
|
||||
result.mBorderStyle = NS_STYLE_BORDER_STYLE_SOLID;
|
||||
result.mBorderStyle = StyleBorderStyle::Solid;
|
||||
result.mBorderColor = 0xFFFFFFFF;
|
||||
|
||||
switch (mOwner) {
|
||||
|
|
|
@ -3227,7 +3227,7 @@ nsTreeBodyFrame::PaintCell(int32_t aRowIndex,
|
|||
nscolor color = borderStyle->mBorderLeftColor.CalcColor(lineContext);
|
||||
ColorPattern colorPatt(ToDeviceColor(color));
|
||||
|
||||
uint8_t style = borderStyle->GetBorderStyle(eSideLeft);
|
||||
StyleBorderStyle style = borderStyle->GetBorderStyle(eSideLeft);
|
||||
StrokeOptions strokeOptions;
|
||||
nsLayoutUtils::InitDashPattern(strokeOptions, style);
|
||||
|
||||
|
|
|
@ -1516,7 +1516,9 @@ fn static_assert() {
|
|||
|
||||
|
||||
<% border_style_keyword = Keyword("border-style",
|
||||
"none solid double dotted dashed hidden groove ridge inset outset") %>
|
||||
"none solid double dotted dashed hidden groove ridge inset outset",
|
||||
gecko_enum_prefix="StyleBorderStyle",
|
||||
gecko_inexhaustive=True) %>
|
||||
|
||||
<% skip_border_longhands = " ".join(["border-{0}-{1}".format(x.ident, y)
|
||||
for x in SIDES
|
||||
|
|
|
@ -63,7 +63,9 @@
|
|||
|
||||
${helpers.gecko_keyword_conversion(
|
||||
Keyword('border-style',
|
||||
"none solid double dotted dashed hidden groove ridge inset outset"),
|
||||
"none solid double dotted dashed hidden groove ridge inset outset",
|
||||
gecko_enum_prefix="StyleBorderStyle",
|
||||
gecko_inexhaustive=True),
|
||||
type="crate::values::specified::BorderStyle",
|
||||
)}
|
||||
|
||||
|
|
|
@ -83,7 +83,8 @@ ${helpers.single_keyword(
|
|||
"none hidden dotted dashed solid double groove ridge inset outset",
|
||||
products="gecko",
|
||||
extra_prefixes="moz",
|
||||
gecko_constant_prefix="NS_STYLE_BORDER_STYLE",
|
||||
gecko_enum_prefix="StyleBorderStyle",
|
||||
gecko_inexhaustive=True,
|
||||
animation_value_type="discrete",
|
||||
spec="https://drafts.csswg.org/css-multicol/#propdef-column-rule-style",
|
||||
)}
|
||||
|
|
|
@ -3925,10 +3925,10 @@ nsNativeThemeCocoa::CreateWebRenderCommandsForWidget(mozilla::wr::DisplayListBui
|
|||
wr::ToColorF(Color(1.0, 1.0, 1.0, 1.0)));
|
||||
|
||||
wr::BorderSide side[4] = {
|
||||
wr::ToBorderSide(kMultilineTextFieldTopBorderColor, NS_STYLE_BORDER_STYLE_SOLID),
|
||||
wr::ToBorderSide(kMultilineTextFieldSidesAndBottomBorderColor, NS_STYLE_BORDER_STYLE_SOLID),
|
||||
wr::ToBorderSide(kMultilineTextFieldSidesAndBottomBorderColor, NS_STYLE_BORDER_STYLE_SOLID),
|
||||
wr::ToBorderSide(kMultilineTextFieldSidesAndBottomBorderColor, NS_STYLE_BORDER_STYLE_SOLID),
|
||||
wr::ToBorderSide(kMultilineTextFieldTopBorderColor, StyleBorderStyle::Solid),
|
||||
wr::ToBorderSide(kMultilineTextFieldSidesAndBottomBorderColor, StyleBorderStyle::Solid),
|
||||
wr::ToBorderSide(kMultilineTextFieldSidesAndBottomBorderColor, StyleBorderStyle::Solid),
|
||||
wr::ToBorderSide(kMultilineTextFieldSidesAndBottomBorderColor, StyleBorderStyle::Solid),
|
||||
};
|
||||
|
||||
wr::BorderRadius borderRadius = wr::EmptyBorderRadius();
|
||||
|
@ -3948,10 +3948,10 @@ nsNativeThemeCocoa::CreateWebRenderCommandsForWidget(mozilla::wr::DisplayListBui
|
|||
wr::ToColorF(Color(1.0, 1.0, 1.0, 1.0)));
|
||||
|
||||
wr::BorderSide side[4] = {
|
||||
wr::ToBorderSide(kListboxTopBorderColor, NS_STYLE_BORDER_STYLE_SOLID),
|
||||
wr::ToBorderSide(kListBoxSidesAndBottomBorderColor, NS_STYLE_BORDER_STYLE_SOLID),
|
||||
wr::ToBorderSide(kListBoxSidesAndBottomBorderColor, NS_STYLE_BORDER_STYLE_SOLID),
|
||||
wr::ToBorderSide(kListBoxSidesAndBottomBorderColor, NS_STYLE_BORDER_STYLE_SOLID),
|
||||
wr::ToBorderSide(kListboxTopBorderColor, StyleBorderStyle::Solid),
|
||||
wr::ToBorderSide(kListBoxSidesAndBottomBorderColor, StyleBorderStyle::Solid),
|
||||
wr::ToBorderSide(kListBoxSidesAndBottomBorderColor, StyleBorderStyle::Solid),
|
||||
wr::ToBorderSide(kListBoxSidesAndBottomBorderColor, StyleBorderStyle::Solid),
|
||||
};
|
||||
|
||||
wr::BorderRadius borderRadius = wr::EmptyBorderRadius();
|
||||
|
|
Загрузка…
Ссылка в новой задаче