Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(474)

Side by Side Diff: xfa/fxfa/fm2js/xfa_fm2jscontext.cpp

Issue 1846083002: Remove CFX_{Byte,Wide}String::Equal in favor of "==". (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h" 7 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h"
8 8
9 #include <time.h> 9 #include <time.h>
10 10
(...skipping 3521 matching lines...) Expand 10 before | Expand all | Expand 10 after
3532 break; 3532 break;
3533 } 3533 }
3534 strUnit += (*(pData + u)); 3534 strUnit += (*(pData + u));
3535 ++u; 3535 ++u;
3536 } 3536 }
3537 strUnit.MakeLower(); 3537 strUnit.MakeLower();
3538 } else { 3538 } else {
3539 strUnit = strFirstUnit; 3539 strUnit = strFirstUnit;
3540 } 3540 }
3541 FX_DOUBLE dResult = 0; 3541 FX_DOUBLE dResult = 0;
3542 if (strFirstUnit.Equal("in") || strFirstUnit.Equal("inches")) { 3542 if (strFirstUnit == "in" || strFirstUnit == "inches") {
3543 if (strUnit.Equal("mm") || strUnit.Equal("millimeters")) { 3543 if (strUnit == "mm" || strUnit == "millimeters") {
3544 dResult = dFirstNumber * 25.4; 3544 dResult = dFirstNumber * 25.4;
3545 } else if (strUnit.Equal("cm") || strUnit.Equal("centimeters")) { 3545 } else if (strUnit == "cm" || strUnit == "centimeters") {
3546 dResult = dFirstNumber * 2.54; 3546 dResult = dFirstNumber * 2.54;
3547 } else if (strUnit.Equal("pt") || strUnit.Equal("points")) { 3547 } else if (strUnit == "pt" || strUnit == "points") {
3548 dResult = dFirstNumber / 72; 3548 dResult = dFirstNumber / 72;
3549 } else if (strUnit.Equal("mp") || strUnit.Equal("millipoints")) { 3549 } else if (strUnit == "mp" || strUnit == "millipoints") {
3550 dResult = dFirstNumber / 72000; 3550 dResult = dFirstNumber / 72000;
3551 } else { 3551 } else {
3552 dResult = dFirstNumber; 3552 dResult = dFirstNumber;
3553 } 3553 }
3554 } else if (strFirstUnit.Equal("mm") || 3554 } else if (strFirstUnit == "mm" || strFirstUnit == "millimeters") {
3555 strFirstUnit.Equal("millimeters")) { 3555 if (strUnit == "mm" || strUnit == "millimeters") {
3556 if (strUnit.Equal("mm") || strUnit.Equal("millimeters")) {
3557 dResult = dFirstNumber; 3556 dResult = dFirstNumber;
3558 } else if (strUnit.Equal("cm") || strUnit.Equal("centimeters")) { 3557 } else if (strUnit == "cm" || strUnit == "centimeters") {
3559 dResult = dFirstNumber / 10; 3558 dResult = dFirstNumber / 10;
3560 } else if (strUnit.Equal("pt") || strUnit.Equal("points")) { 3559 } else if (strUnit == "pt" || strUnit == "points") {
3561 dResult = dFirstNumber / 25.4 / 72; 3560 dResult = dFirstNumber / 25.4 / 72;
3562 } else if (strUnit.Equal("mp") || strUnit.Equal("millipoints")) { 3561 } else if (strUnit == "mp" || strUnit == "millipoints") {
3563 dResult = dFirstNumber / 25.4 / 72000; 3562 dResult = dFirstNumber / 25.4 / 72000;
3564 } else { 3563 } else {
3565 dResult = dFirstNumber / 25.4; 3564 dResult = dFirstNumber / 25.4;
3566 } 3565 }
3567 } else if (strFirstUnit.Equal("cm") || 3566 } else if (strFirstUnit == "cm" || strFirstUnit == "centimeters") {
3568 strFirstUnit.Equal("centimeters")) { 3567 if (strUnit == "mm" || strUnit == "millimeters") {
3569 if (strUnit.Equal("mm") || strUnit.Equal("millimeters")) {
3570 dResult = dFirstNumber * 10; 3568 dResult = dFirstNumber * 10;
3571 } else if (strUnit.Equal("cm") || strUnit.Equal("centimeters")) { 3569 } else if (strUnit == "cm" || strUnit == "centimeters") {
3572 dResult = dFirstNumber; 3570 dResult = dFirstNumber;
3573 } else if (strUnit.Equal("pt") || strUnit.Equal("points")) { 3571 } else if (strUnit == "pt" || strUnit == "points") {
3574 dResult = dFirstNumber / 2.54 / 72; 3572 dResult = dFirstNumber / 2.54 / 72;
3575 } else if (strUnit.Equal("mp") || strUnit.Equal("millipoints")) { 3573 } else if (strUnit == "mp" || strUnit == "millipoints") {
3576 dResult = dFirstNumber / 2.54 / 72000; 3574 dResult = dFirstNumber / 2.54 / 72000;
3577 } else { 3575 } else {
3578 dResult = dFirstNumber / 2.54; 3576 dResult = dFirstNumber / 2.54;
3579 } 3577 }
3580 } else if (strFirstUnit.Equal("pt") || strFirstUnit.Equal("points")) { 3578 } else if (strFirstUnit == "pt" || strFirstUnit == "points") {
3581 if (strUnit.Equal("mm") || strUnit.Equal("millimeters")) { 3579 if (strUnit == "mm" || strUnit == "millimeters") {
3582 dResult = dFirstNumber / 72 * 25.4; 3580 dResult = dFirstNumber / 72 * 25.4;
3583 } else if (strUnit.Equal("cm") || strUnit.Equal("centimeters")) { 3581 } else if (strUnit == "cm" || strUnit == "centimeters") {
3584 dResult = dFirstNumber / 72 * 2.54; 3582 dResult = dFirstNumber / 72 * 2.54;
3585 } else if (strUnit.Equal("pt") || strUnit.Equal("points")) { 3583 } else if (strUnit == "pt" || strUnit == "points") {
3586 dResult = dFirstNumber; 3584 dResult = dFirstNumber;
3587 } else if (strUnit.Equal("mp") || strUnit.Equal("millipoints")) { 3585 } else if (strUnit == "mp" || strUnit == "millipoints") {
3588 dResult = dFirstNumber * 1000; 3586 dResult = dFirstNumber * 1000;
3589 } else { 3587 } else {
3590 dResult = dFirstNumber / 72; 3588 dResult = dFirstNumber / 72;
3591 } 3589 }
3592 } else if (strFirstUnit.Equal("mp") || 3590 } else if (strFirstUnit == "mp" || strFirstUnit == "millipoints") {
3593 strFirstUnit.Equal("millipoints")) { 3591 if (strUnit == "mm" || strUnit == "millimeters") {
3594 if (strUnit.Equal("mm") || strUnit.Equal("millimeters")) {
3595 dResult = dFirstNumber / 72000 * 25.4; 3592 dResult = dFirstNumber / 72000 * 25.4;
3596 } else if (strUnit.Equal("cm") || strUnit.Equal("centimeters")) { 3593 } else if (strUnit == "cm" || strUnit == "centimeters") {
3597 dResult = dFirstNumber / 72000 * 2.54; 3594 dResult = dFirstNumber / 72000 * 2.54;
3598 } else if (strUnit.Equal("pt") || strUnit.Equal("points")) { 3595 } else if (strUnit == "pt" || strUnit == "points") {
3599 dResult = dFirstNumber / 1000; 3596 dResult = dFirstNumber / 1000;
3600 } else if (strUnit.Equal("mp") || strUnit.Equal("millipoints")) { 3597 } else if (strUnit == "mp" || strUnit == "millipoints") {
3601 dResult = dFirstNumber; 3598 dResult = dFirstNumber;
3602 } else { 3599 } else {
3603 dResult = dFirstNumber / 72000; 3600 dResult = dFirstNumber / 72000;
3604 } 3601 }
3605 } 3602 }
3606 FXJSE_Value_SetDouble(args.GetReturnValue(), dResult); 3603 FXJSE_Value_SetDouble(args.GetReturnValue(), dResult);
3607 } else { 3604 } else {
3608 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); 3605 FXJSE_Value_SetInteger(args.GetReturnValue(), 0);
3609 } 3606 }
3610 } 3607 }
(...skipping 2089 matching lines...) Expand 10 before | Expand all | Expand 10 after
5700 (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) 5697 (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond))
5701 ? 1 5698 ? 1
5702 : 0); 5699 : 0);
5703 } else if (FXJSE_Value_IsUTF8String(argFirst) && 5700 } else if (FXJSE_Value_IsUTF8String(argFirst) &&
5704 FXJSE_Value_IsUTF8String(argSecond)) { 5701 FXJSE_Value_IsUTF8String(argSecond)) {
5705 CFX_ByteString firstOutput; 5702 CFX_ByteString firstOutput;
5706 CFX_ByteString secondOutput; 5703 CFX_ByteString secondOutput;
5707 FXJSE_Value_ToUTF8String(argFirst, firstOutput); 5704 FXJSE_Value_ToUTF8String(argFirst, firstOutput);
5708 FXJSE_Value_ToUTF8String(argSecond, secondOutput); 5705 FXJSE_Value_ToUTF8String(argSecond, secondOutput);
5709 FXJSE_Value_SetInteger(args.GetReturnValue(), 5706 FXJSE_Value_SetInteger(args.GetReturnValue(),
5710 firstOutput.Equal(secondOutput) ? 1 : 0); 5707 firstOutput == secondOutput);
5711 } else { 5708 } else {
5712 FX_DOUBLE first = HValueToDouble(hThis, argFirst); 5709 FX_DOUBLE first = HValueToDouble(hThis, argFirst);
5713 FX_DOUBLE second = HValueToDouble(hThis, argSecond); 5710 FX_DOUBLE second = HValueToDouble(hThis, argSecond);
5714 FXJSE_Value_SetInteger(args.GetReturnValue(), 5711 FXJSE_Value_SetInteger(args.GetReturnValue(),
5715 (first == second) ? 1 : 0); 5712 (first == second) ? 1 : 0);
5716 } 5713 }
5717 FXJSE_Value_Release(argFirst); 5714 FXJSE_Value_Release(argFirst);
5718 FXJSE_Value_Release(argSecond); 5715 FXJSE_Value_Release(argSecond);
5719 } 5716 }
5720 } else { 5717 } else {
(...skipping 17 matching lines...) Expand all
5738 (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) 5735 (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond))
5739 ? 0 5736 ? 0
5740 : 1); 5737 : 1);
5741 } else if (FXJSE_Value_IsUTF8String(argFirst) && 5738 } else if (FXJSE_Value_IsUTF8String(argFirst) &&
5742 FXJSE_Value_IsUTF8String(argSecond)) { 5739 FXJSE_Value_IsUTF8String(argSecond)) {
5743 CFX_ByteString firstOutput; 5740 CFX_ByteString firstOutput;
5744 CFX_ByteString secondOutput; 5741 CFX_ByteString secondOutput;
5745 FXJSE_Value_ToUTF8String(argFirst, firstOutput); 5742 FXJSE_Value_ToUTF8String(argFirst, firstOutput);
5746 FXJSE_Value_ToUTF8String(argSecond, secondOutput); 5743 FXJSE_Value_ToUTF8String(argSecond, secondOutput);
5747 FXJSE_Value_SetInteger(args.GetReturnValue(), 5744 FXJSE_Value_SetInteger(args.GetReturnValue(),
5748 firstOutput.Equal(secondOutput) ? 0 : 1); 5745 firstOutput == secondOutput ? 0 : 1);
Lei Zhang 2016/04/01 01:02:36 !=
Tom Sepez 2016/04/01 17:06:12 Done.
5749 } else { 5746 } else {
5750 FX_DOUBLE first = HValueToDouble(hThis, argFirst); 5747 FX_DOUBLE first = HValueToDouble(hThis, argFirst);
5751 FX_DOUBLE second = HValueToDouble(hThis, argSecond); 5748 FX_DOUBLE second = HValueToDouble(hThis, argSecond);
5752 FXJSE_Value_SetInteger(args.GetReturnValue(), 5749 FXJSE_Value_SetInteger(args.GetReturnValue(),
5753 (first == second) ? 0 : 1); 5750 (first == second) ? 0 : 1);
5754 } 5751 }
5755 FXJSE_Value_Release(argFirst); 5752 FXJSE_Value_Release(argFirst);
5756 FXJSE_Value_Release(argSecond); 5753 FXJSE_Value_Release(argSecond);
5757 } 5754 }
5758 } else { 5755 } else {
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after
6684 return iLength; 6681 return iLength;
6685 } 6682 }
6686 FX_BOOL CXFA_FM2JSContext::simpleValueCompare(FXJSE_HOBJECT hThis, 6683 FX_BOOL CXFA_FM2JSContext::simpleValueCompare(FXJSE_HOBJECT hThis,
6687 FXJSE_HVALUE firstValue, 6684 FXJSE_HVALUE firstValue,
6688 FXJSE_HVALUE secondValue) { 6685 FXJSE_HVALUE secondValue) {
6689 FX_BOOL bReturn = FALSE; 6686 FX_BOOL bReturn = FALSE;
6690 if (FXJSE_Value_IsUTF8String(firstValue)) { 6687 if (FXJSE_Value_IsUTF8String(firstValue)) {
6691 CFX_ByteString firstString, secondString; 6688 CFX_ByteString firstString, secondString;
6692 HValueToUTF8String(firstValue, firstString); 6689 HValueToUTF8String(firstValue, firstString);
6693 HValueToUTF8String(secondValue, secondString); 6690 HValueToUTF8String(secondValue, secondString);
6694 bReturn = firstString.Equal(secondString); 6691 bReturn = firstString == secondString;
6695 } else if (FXJSE_Value_IsNumber(firstValue)) { 6692 } else if (FXJSE_Value_IsNumber(firstValue)) {
6696 FX_FLOAT first = HValueToFloat(hThis, firstValue); 6693 FX_FLOAT first = HValueToFloat(hThis, firstValue);
6697 FX_FLOAT second = HValueToFloat(hThis, secondValue); 6694 FX_FLOAT second = HValueToFloat(hThis, secondValue);
6698 bReturn = (first == second); 6695 bReturn = (first == second);
6699 } else if (FXJSE_Value_IsBoolean(firstValue)) { 6696 } else if (FXJSE_Value_IsBoolean(firstValue)) {
6700 bReturn = (FXJSE_Value_ToBoolean(firstValue) == 6697 bReturn = (FXJSE_Value_ToBoolean(firstValue) ==
6701 FXJSE_Value_ToBoolean(secondValue)); 6698 FXJSE_Value_ToBoolean(secondValue));
6702 } else if (FXJSE_Value_IsNull(firstValue) && 6699 } else if (FXJSE_Value_IsNull(firstValue) &&
6703 FXJSE_Value_IsNull(secondValue)) { 6700 FXJSE_Value_IsNull(secondValue)) {
6704 bReturn = TRUE; 6701 bReturn = TRUE;
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
7215 FXSYS_assert(pAppProvider); 7212 FXSYS_assert(pAppProvider);
7216 CFX_WideString wsFormat; 7213 CFX_WideString wsFormat;
7217 pAppProvider->LoadString(iStringID, wsFormat); 7214 pAppProvider->LoadString(iStringID, wsFormat);
7218 CFX_WideString wsMessage; 7215 CFX_WideString wsMessage;
7219 va_list arg_ptr; 7216 va_list arg_ptr;
7220 va_start(arg_ptr, iStringID); 7217 va_start(arg_ptr, iStringID);
7221 wsMessage.FormatV((const FX_WCHAR*)wsFormat, arg_ptr); 7218 wsMessage.FormatV((const FX_WCHAR*)wsFormat, arg_ptr);
7222 va_end(arg_ptr); 7219 va_end(arg_ptr);
7223 FXJSE_ThrowMessage("", FX_UTF8Encode(wsMessage, wsMessage.GetLength())); 7220 FXJSE_ThrowMessage("", FX_UTF8Encode(wsMessage, wsMessage.GetLength()));
7224 } 7221 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698