OLD | NEW |
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/fde/css/fde_cssstyleselector.h" | 7 #include "xfa/fde/css/fde_cssstyleselector.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 if (pos != NULL) { | 430 if (pos != NULL) { |
431 if (m_pInlineStyleStore == NULL) { | 431 if (m_pInlineStyleStore == NULL) { |
432 m_pInlineStyleStore = FX_CreateAllocator(FX_ALLOCTYPE_Static, 2048, 0); | 432 m_pInlineStyleStore = FX_CreateAllocator(FX_ALLOCTYPE_Static, 2048, 0); |
433 } | 433 } |
434 CFDE_CSSDeclaration* pDecl = NULL; | 434 CFDE_CSSDeclaration* pDecl = NULL; |
435 CFX_WideStringC wsAttri, wsValue; | 435 CFX_WideStringC wsAttri, wsValue; |
436 uint32_t dwAttriHash; | 436 uint32_t dwAttriHash; |
437 do { | 437 do { |
438 pTag->GetNextAttribute(pos, wsAttri, wsValue); | 438 pTag->GetNextAttribute(pos, wsAttri, wsValue); |
439 dwAttriHash = | 439 dwAttriHash = |
440 FX_HashCode_String_GetW(wsAttri.GetPtr(), wsAttri.GetLength(), TRUE); | 440 FX_HashCode_String_GetW(wsAttri.raw_str(), wsAttri.GetLength(), TRUE); |
441 static const uint32_t s_dwStyleHash = | 441 static const uint32_t s_dwStyleHash = |
442 FX_HashCode_String_GetW(L"style", 5, TRUE); | 442 FX_HashCode_String_GetW(L"style", 5, TRUE); |
443 static const uint32_t s_dwAlignHash = | 443 static const uint32_t s_dwAlignHash = |
444 FX_HashCode_String_GetW(L"align", 5, TRUE); | 444 FX_HashCode_String_GetW(L"align", 5, TRUE); |
445 if (dwAttriHash == s_dwStyleHash) { | 445 if (dwAttriHash == s_dwStyleHash) { |
446 if (pDecl == NULL) { | 446 if (pDecl == NULL) { |
447 pDecl = FXTARGET_NewWith(m_pInlineStyleStore) CFDE_CSSDeclaration; | 447 pDecl = FXTARGET_NewWith(m_pInlineStyleStore) CFDE_CSSDeclaration; |
448 } | 448 } |
449 AppendInlineStyle(pDecl, wsValue.GetPtr(), wsValue.GetLength()); | 449 AppendInlineStyle(pDecl, wsValue.raw_str(), wsValue.GetLength()); |
450 } else if (dwAttriHash == s_dwAlignHash) { | 450 } else if (dwAttriHash == s_dwAlignHash) { |
451 if (pDecl == NULL) { | 451 if (pDecl == NULL) { |
452 pDecl = FXTARGET_NewWith(m_pInlineStyleStore) CFDE_CSSDeclaration; | 452 pDecl = FXTARGET_NewWith(m_pInlineStyleStore) CFDE_CSSDeclaration; |
453 } | 453 } |
454 FDE_CSSPROPERTYARGS args; | 454 FDE_CSSPROPERTYARGS args; |
455 args.pStringCache = NULL; | 455 args.pStringCache = NULL; |
456 args.pStaticStore = m_pInlineStyleStore; | 456 args.pStaticStore = m_pInlineStyleStore; |
457 args.pProperty = FDE_GetCSSPropertyByEnum(FDE_CSSPROPERTY_TextAlign); | 457 args.pProperty = FDE_GetCSSPropertyByEnum(FDE_CSSPROPERTY_TextAlign); |
458 pDecl->AddProperty(&args, wsValue.GetPtr(), wsValue.GetLength()); | 458 pDecl->AddProperty(&args, wsValue.raw_str(), wsValue.GetLength()); |
459 } | 459 } |
460 } while (pos != NULL); | 460 } while (pos != NULL); |
461 if (pDecl != NULL) { | 461 if (pDecl != NULL) { |
462 CFDE_CSSDeclarationArray decls; | 462 CFDE_CSSDeclarationArray decls; |
463 decls.SetSize(iDeclCount + 1); | 463 decls.SetSize(iDeclCount + 1); |
464 IFDE_CSSDeclaration** ppInline = decls.GetData(); | 464 IFDE_CSSDeclaration** ppInline = decls.GetData(); |
465 FXSYS_memcpy(ppInline, ppDeclArray, | 465 FXSYS_memcpy(ppInline, ppDeclArray, |
466 iDeclCount * sizeof(IFDE_CSSDeclaration*)); | 466 iDeclCount * sizeof(IFDE_CSSDeclaration*)); |
467 ppInline[iDeclCount++] = pDecl; | 467 ppInline[iDeclCount++] = pDecl; |
468 ApplyDeclarations(TRUE, (const IFDE_CSSDeclaration**)ppInline, iDeclCount, | 468 ApplyDeclarations(TRUE, (const IFDE_CSSDeclaration**)ppInline, iDeclCount, |
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1785 return FDE_CSSTEXTTRANSFORM_LowerCase; | 1785 return FDE_CSSTEXTTRANSFORM_LowerCase; |
1786 default: | 1786 default: |
1787 return FDE_CSSTEXTTRANSFORM_None; | 1787 return FDE_CSSTEXTTRANSFORM_None; |
1788 } | 1788 } |
1789 } | 1789 } |
1790 FDE_CSSFONTVARIANT CFDE_CSSStyleSelector::ToFontVariant( | 1790 FDE_CSSFONTVARIANT CFDE_CSSStyleSelector::ToFontVariant( |
1791 FDE_CSSPROPERTYVALUE eValue) { | 1791 FDE_CSSPROPERTYVALUE eValue) { |
1792 return eValue == FDE_CSSPROPERTYVALUE_SmallCaps ? FDE_CSSFONTVARIANT_SmallCaps | 1792 return eValue == FDE_CSSPROPERTYVALUE_SmallCaps ? FDE_CSSFONTVARIANT_SmallCaps |
1793 : FDE_CSSFONTVARIANT_Normal; | 1793 : FDE_CSSFONTVARIANT_Normal; |
1794 } | 1794 } |
OLD | NEW |