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

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: Nits. 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
« no previous file with comments | « xfa/fxfa/app/xfa_textlayout.cpp ('k') | xfa/fxfa/fm2js/xfa_simpleexpression.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3524 matching lines...) Expand 10 before | Expand all | Expand 10 after
3535 break; 3535 break;
3536 } 3536 }
3537 strUnit += (*(pData + u)); 3537 strUnit += (*(pData + u));
3538 ++u; 3538 ++u;
3539 } 3539 }
3540 strUnit.MakeLower(); 3540 strUnit.MakeLower();
3541 } else { 3541 } else {
3542 strUnit = strFirstUnit; 3542 strUnit = strFirstUnit;
3543 } 3543 }
3544 FX_DOUBLE dResult = 0; 3544 FX_DOUBLE dResult = 0;
3545 if (strFirstUnit.Equal("in") || strFirstUnit.Equal("inches")) { 3545 if (strFirstUnit == "in" || strFirstUnit == "inches") {
3546 if (strUnit.Equal("mm") || strUnit.Equal("millimeters")) { 3546 if (strUnit == "mm" || strUnit == "millimeters") {
3547 dResult = dFirstNumber * 25.4; 3547 dResult = dFirstNumber * 25.4;
3548 } else if (strUnit.Equal("cm") || strUnit.Equal("centimeters")) { 3548 } else if (strUnit == "cm" || strUnit == "centimeters") {
3549 dResult = dFirstNumber * 2.54; 3549 dResult = dFirstNumber * 2.54;
3550 } else if (strUnit.Equal("pt") || strUnit.Equal("points")) { 3550 } else if (strUnit == "pt" || strUnit == "points") {
3551 dResult = dFirstNumber / 72; 3551 dResult = dFirstNumber / 72;
3552 } else if (strUnit.Equal("mp") || strUnit.Equal("millipoints")) { 3552 } else if (strUnit == "mp" || strUnit == "millipoints") {
3553 dResult = dFirstNumber / 72000; 3553 dResult = dFirstNumber / 72000;
3554 } else { 3554 } else {
3555 dResult = dFirstNumber; 3555 dResult = dFirstNumber;
3556 } 3556 }
3557 } else if (strFirstUnit.Equal("mm") || 3557 } else if (strFirstUnit == "mm" || strFirstUnit == "millimeters") {
3558 strFirstUnit.Equal("millimeters")) { 3558 if (strUnit == "mm" || strUnit == "millimeters") {
3559 if (strUnit.Equal("mm") || strUnit.Equal("millimeters")) {
3560 dResult = dFirstNumber; 3559 dResult = dFirstNumber;
3561 } else if (strUnit.Equal("cm") || strUnit.Equal("centimeters")) { 3560 } else if (strUnit == "cm" || strUnit == "centimeters") {
3562 dResult = dFirstNumber / 10; 3561 dResult = dFirstNumber / 10;
3563 } else if (strUnit.Equal("pt") || strUnit.Equal("points")) { 3562 } else if (strUnit == "pt" || strUnit == "points") {
3564 dResult = dFirstNumber / 25.4 / 72; 3563 dResult = dFirstNumber / 25.4 / 72;
3565 } else if (strUnit.Equal("mp") || strUnit.Equal("millipoints")) { 3564 } else if (strUnit == "mp" || strUnit == "millipoints") {
3566 dResult = dFirstNumber / 25.4 / 72000; 3565 dResult = dFirstNumber / 25.4 / 72000;
3567 } else { 3566 } else {
3568 dResult = dFirstNumber / 25.4; 3567 dResult = dFirstNumber / 25.4;
3569 } 3568 }
3570 } else if (strFirstUnit.Equal("cm") || 3569 } else if (strFirstUnit == "cm" || strFirstUnit == "centimeters") {
3571 strFirstUnit.Equal("centimeters")) { 3570 if (strUnit == "mm" || strUnit == "millimeters") {
3572 if (strUnit.Equal("mm") || strUnit.Equal("millimeters")) {
3573 dResult = dFirstNumber * 10; 3571 dResult = dFirstNumber * 10;
3574 } else if (strUnit.Equal("cm") || strUnit.Equal("centimeters")) { 3572 } else if (strUnit == "cm" || strUnit == "centimeters") {
3575 dResult = dFirstNumber; 3573 dResult = dFirstNumber;
3576 } else if (strUnit.Equal("pt") || strUnit.Equal("points")) { 3574 } else if (strUnit == "pt" || strUnit == "points") {
3577 dResult = dFirstNumber / 2.54 / 72; 3575 dResult = dFirstNumber / 2.54 / 72;
3578 } else if (strUnit.Equal("mp") || strUnit.Equal("millipoints")) { 3576 } else if (strUnit == "mp" || strUnit == "millipoints") {
3579 dResult = dFirstNumber / 2.54 / 72000; 3577 dResult = dFirstNumber / 2.54 / 72000;
3580 } else { 3578 } else {
3581 dResult = dFirstNumber / 2.54; 3579 dResult = dFirstNumber / 2.54;
3582 } 3580 }
3583 } else if (strFirstUnit.Equal("pt") || strFirstUnit.Equal("points")) { 3581 } else if (strFirstUnit == "pt" || strFirstUnit == "points") {
3584 if (strUnit.Equal("mm") || strUnit.Equal("millimeters")) { 3582 if (strUnit == "mm" || strUnit == "millimeters") {
3585 dResult = dFirstNumber / 72 * 25.4; 3583 dResult = dFirstNumber / 72 * 25.4;
3586 } else if (strUnit.Equal("cm") || strUnit.Equal("centimeters")) { 3584 } else if (strUnit == "cm" || strUnit == "centimeters") {
3587 dResult = dFirstNumber / 72 * 2.54; 3585 dResult = dFirstNumber / 72 * 2.54;
3588 } else if (strUnit.Equal("pt") || strUnit.Equal("points")) { 3586 } else if (strUnit == "pt" || strUnit == "points") {
3589 dResult = dFirstNumber; 3587 dResult = dFirstNumber;
3590 } else if (strUnit.Equal("mp") || strUnit.Equal("millipoints")) { 3588 } else if (strUnit == "mp" || strUnit == "millipoints") {
3591 dResult = dFirstNumber * 1000; 3589 dResult = dFirstNumber * 1000;
3592 } else { 3590 } else {
3593 dResult = dFirstNumber / 72; 3591 dResult = dFirstNumber / 72;
3594 } 3592 }
3595 } else if (strFirstUnit.Equal("mp") || 3593 } else if (strFirstUnit == "mp" || strFirstUnit == "millipoints") {
3596 strFirstUnit.Equal("millipoints")) { 3594 if (strUnit == "mm" || strUnit == "millimeters") {
3597 if (strUnit.Equal("mm") || strUnit.Equal("millimeters")) {
3598 dResult = dFirstNumber / 72000 * 25.4; 3595 dResult = dFirstNumber / 72000 * 25.4;
3599 } else if (strUnit.Equal("cm") || strUnit.Equal("centimeters")) { 3596 } else if (strUnit == "cm" || strUnit == "centimeters") {
3600 dResult = dFirstNumber / 72000 * 2.54; 3597 dResult = dFirstNumber / 72000 * 2.54;
3601 } else if (strUnit.Equal("pt") || strUnit.Equal("points")) { 3598 } else if (strUnit == "pt" || strUnit == "points") {
3602 dResult = dFirstNumber / 1000; 3599 dResult = dFirstNumber / 1000;
3603 } else if (strUnit.Equal("mp") || strUnit.Equal("millipoints")) { 3600 } else if (strUnit == "mp" || strUnit == "millipoints") {
3604 dResult = dFirstNumber; 3601 dResult = dFirstNumber;
3605 } else { 3602 } else {
3606 dResult = dFirstNumber / 72000; 3603 dResult = dFirstNumber / 72000;
3607 } 3604 }
3608 } 3605 }
3609 FXJSE_Value_SetDouble(args.GetReturnValue(), dResult); 3606 FXJSE_Value_SetDouble(args.GetReturnValue(), dResult);
3610 } else { 3607 } else {
3611 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); 3608 FXJSE_Value_SetInteger(args.GetReturnValue(), 0);
3612 } 3609 }
3613 } 3610 }
(...skipping 2089 matching lines...) Expand 10 before | Expand all | Expand 10 after
5703 (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) 5700 (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond))
5704 ? 1 5701 ? 1
5705 : 0); 5702 : 0);
5706 } else if (FXJSE_Value_IsUTF8String(argFirst) && 5703 } else if (FXJSE_Value_IsUTF8String(argFirst) &&
5707 FXJSE_Value_IsUTF8String(argSecond)) { 5704 FXJSE_Value_IsUTF8String(argSecond)) {
5708 CFX_ByteString firstOutput; 5705 CFX_ByteString firstOutput;
5709 CFX_ByteString secondOutput; 5706 CFX_ByteString secondOutput;
5710 FXJSE_Value_ToUTF8String(argFirst, firstOutput); 5707 FXJSE_Value_ToUTF8String(argFirst, firstOutput);
5711 FXJSE_Value_ToUTF8String(argSecond, secondOutput); 5708 FXJSE_Value_ToUTF8String(argSecond, secondOutput);
5712 FXJSE_Value_SetInteger(args.GetReturnValue(), 5709 FXJSE_Value_SetInteger(args.GetReturnValue(),
5713 firstOutput.Equal(secondOutput) ? 1 : 0); 5710 firstOutput == secondOutput);
5714 } else { 5711 } else {
5715 FX_DOUBLE first = HValueToDouble(hThis, argFirst); 5712 FX_DOUBLE first = HValueToDouble(hThis, argFirst);
5716 FX_DOUBLE second = HValueToDouble(hThis, argSecond); 5713 FX_DOUBLE second = HValueToDouble(hThis, argSecond);
5717 FXJSE_Value_SetInteger(args.GetReturnValue(), 5714 FXJSE_Value_SetInteger(args.GetReturnValue(),
5718 (first == second) ? 1 : 0); 5715 (first == second) ? 1 : 0);
5719 } 5716 }
5720 FXJSE_Value_Release(argFirst); 5717 FXJSE_Value_Release(argFirst);
5721 FXJSE_Value_Release(argSecond); 5718 FXJSE_Value_Release(argSecond);
5722 } 5719 }
5723 } else { 5720 } else {
(...skipping 17 matching lines...) Expand all
5741 (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) 5738 (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond))
5742 ? 0 5739 ? 0
5743 : 1); 5740 : 1);
5744 } else if (FXJSE_Value_IsUTF8String(argFirst) && 5741 } else if (FXJSE_Value_IsUTF8String(argFirst) &&
5745 FXJSE_Value_IsUTF8String(argSecond)) { 5742 FXJSE_Value_IsUTF8String(argSecond)) {
5746 CFX_ByteString firstOutput; 5743 CFX_ByteString firstOutput;
5747 CFX_ByteString secondOutput; 5744 CFX_ByteString secondOutput;
5748 FXJSE_Value_ToUTF8String(argFirst, firstOutput); 5745 FXJSE_Value_ToUTF8String(argFirst, firstOutput);
5749 FXJSE_Value_ToUTF8String(argSecond, secondOutput); 5746 FXJSE_Value_ToUTF8String(argSecond, secondOutput);
5750 FXJSE_Value_SetInteger(args.GetReturnValue(), 5747 FXJSE_Value_SetInteger(args.GetReturnValue(),
5751 firstOutput.Equal(secondOutput) ? 0 : 1); 5748 firstOutput != secondOutput);
5752 } else { 5749 } else {
5753 FX_DOUBLE first = HValueToDouble(hThis, argFirst); 5750 FX_DOUBLE first = HValueToDouble(hThis, argFirst);
5754 FX_DOUBLE second = HValueToDouble(hThis, argSecond); 5751 FX_DOUBLE second = HValueToDouble(hThis, argSecond);
5755 FXJSE_Value_SetInteger(args.GetReturnValue(), 5752 FXJSE_Value_SetInteger(args.GetReturnValue(), first != second);
5756 (first == second) ? 0 : 1);
5757 } 5753 }
5758 FXJSE_Value_Release(argFirst); 5754 FXJSE_Value_Release(argFirst);
5759 FXJSE_Value_Release(argSecond); 5755 FXJSE_Value_Release(argSecond);
5760 } 5756 }
5761 } else { 5757 } else {
5762 CXFA_FM2JSContext* pContext = 5758 CXFA_FM2JSContext* pContext =
5763 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); 5759 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL);
5764 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); 5760 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR);
5765 } 5761 }
5766 } 5762 }
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after
6687 return iLength; 6683 return iLength;
6688 } 6684 }
6689 FX_BOOL CXFA_FM2JSContext::simpleValueCompare(FXJSE_HOBJECT hThis, 6685 FX_BOOL CXFA_FM2JSContext::simpleValueCompare(FXJSE_HOBJECT hThis,
6690 FXJSE_HVALUE firstValue, 6686 FXJSE_HVALUE firstValue,
6691 FXJSE_HVALUE secondValue) { 6687 FXJSE_HVALUE secondValue) {
6692 FX_BOOL bReturn = FALSE; 6688 FX_BOOL bReturn = FALSE;
6693 if (FXJSE_Value_IsUTF8String(firstValue)) { 6689 if (FXJSE_Value_IsUTF8String(firstValue)) {
6694 CFX_ByteString firstString, secondString; 6690 CFX_ByteString firstString, secondString;
6695 HValueToUTF8String(firstValue, firstString); 6691 HValueToUTF8String(firstValue, firstString);
6696 HValueToUTF8String(secondValue, secondString); 6692 HValueToUTF8String(secondValue, secondString);
6697 bReturn = firstString.Equal(secondString); 6693 bReturn = firstString == secondString;
6698 } else if (FXJSE_Value_IsNumber(firstValue)) { 6694 } else if (FXJSE_Value_IsNumber(firstValue)) {
6699 FX_FLOAT first = HValueToFloat(hThis, firstValue); 6695 FX_FLOAT first = HValueToFloat(hThis, firstValue);
6700 FX_FLOAT second = HValueToFloat(hThis, secondValue); 6696 FX_FLOAT second = HValueToFloat(hThis, secondValue);
6701 bReturn = (first == second); 6697 bReturn = (first == second);
6702 } else if (FXJSE_Value_IsBoolean(firstValue)) { 6698 } else if (FXJSE_Value_IsBoolean(firstValue)) {
6703 bReturn = (FXJSE_Value_ToBoolean(firstValue) == 6699 bReturn = (FXJSE_Value_ToBoolean(firstValue) ==
6704 FXJSE_Value_ToBoolean(secondValue)); 6700 FXJSE_Value_ToBoolean(secondValue));
6705 } else if (FXJSE_Value_IsNull(firstValue) && 6701 } else if (FXJSE_Value_IsNull(firstValue) &&
6706 FXJSE_Value_IsNull(secondValue)) { 6702 FXJSE_Value_IsNull(secondValue)) {
6707 bReturn = TRUE; 6703 bReturn = TRUE;
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
7218 FXSYS_assert(pAppProvider); 7214 FXSYS_assert(pAppProvider);
7219 CFX_WideString wsFormat; 7215 CFX_WideString wsFormat;
7220 pAppProvider->LoadString(iStringID, wsFormat); 7216 pAppProvider->LoadString(iStringID, wsFormat);
7221 CFX_WideString wsMessage; 7217 CFX_WideString wsMessage;
7222 va_list arg_ptr; 7218 va_list arg_ptr;
7223 va_start(arg_ptr, iStringID); 7219 va_start(arg_ptr, iStringID);
7224 wsMessage.FormatV((const FX_WCHAR*)wsFormat, arg_ptr); 7220 wsMessage.FormatV((const FX_WCHAR*)wsFormat, arg_ptr);
7225 va_end(arg_ptr); 7221 va_end(arg_ptr);
7226 FXJSE_ThrowMessage("", FX_UTF8Encode(wsMessage, wsMessage.GetLength())); 7222 FXJSE_ThrowMessage("", FX_UTF8Encode(wsMessage, wsMessage.GetLength()));
7227 } 7223 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_textlayout.cpp ('k') | xfa/fxfa/fm2js/xfa_simpleexpression.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698