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 #include <memory> | |
10 | 11 |
11 #include "xfa/fde/css/fde_csscache.h" | 12 #include "xfa/fde/css/fde_csscache.h" |
12 #include "xfa/fde/css/fde_cssdeclaration.h" | 13 #include "xfa/fde/css/fde_cssdeclaration.h" |
13 #include "xfa/fde/css/fde_cssstylesheet.h" | 14 #include "xfa/fde/css/fde_cssstylesheet.h" |
14 #include "xfa/fde/css/fde_csssyntax.h" | 15 #include "xfa/fde/css/fde_csssyntax.h" |
15 #include "xfa/fxfa/app/xfa_textlayout.h" | 16 #include "xfa/fxfa/app/xfa_textlayout.h" |
16 | 17 |
17 #define FDE_CSSUNIVERSALHASH ('*') | 18 #define FDE_CSSUNIVERSALHASH ('*') |
18 | 19 |
19 int32_t CFDE_CSSCounterStyle::FindIndex(const FX_WCHAR* pszIdentifier) { | 20 int32_t CFDE_CSSCounterStyle::FindIndex(const FX_WCHAR* pszIdentifier) { |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
531 while (pos) { | 532 while (pos) { |
532 pDecl->GetNextCustom(pos, wsName, wsValue); | 533 pDecl->GetNextCustom(pos, wsName, wsValue); |
533 pComputedStyle->AddCustomStyle(wsName, wsValue); | 534 pComputedStyle->AddCustomStyle(wsName, wsValue); |
534 } | 535 } |
535 } | 536 } |
536 } | 537 } |
537 void CFDE_CSSStyleSelector::AppendInlineStyle(CFDE_CSSDeclaration* pDecl, | 538 void CFDE_CSSStyleSelector::AppendInlineStyle(CFDE_CSSDeclaration* pDecl, |
538 const FX_WCHAR* psz, | 539 const FX_WCHAR* psz, |
539 int32_t iLen) { | 540 int32_t iLen) { |
540 ASSERT(pDecl && psz && iLen > 0); | 541 ASSERT(pDecl && psz && iLen > 0); |
542 std::unique_ptr<CFDE_CSSSyntaxParser> pSyntax(new CFDE_CSSSyntaxParser); | |
543 if (!pSyntax->Init(psz, iLen, 32, TRUE)) | |
544 return; | |
541 | 545 |
542 CFDE_CSSSyntaxParser* pSyntax = new CFDE_CSSSyntaxParser; | 546 int32_t iLen2; |
543 if (pSyntax->Init(psz, iLen, 32, TRUE)) { | 547 const FX_WCHAR* psz2; |
544 int32_t iLen; | 548 FDE_CSSPROPERTYARGS args; |
Tom Sepez
2016/05/06 21:41:13
note: these two are shadows, rename.
| |
545 const FX_WCHAR* psz; | 549 args.pStringCache = nullptr; |
546 FDE_CSSPROPERTYARGS args; | 550 args.pStaticStore = m_pInlineStyleStore; |
547 args.pStringCache = NULL; | 551 args.pProperty = nullptr; |
548 args.pStaticStore = m_pInlineStyleStore; | 552 CFX_WideString wsName; |
549 args.pProperty = NULL; | 553 while (1) { |
550 CFX_WideString wsName; | 554 FDE_CSSSYNTAXSTATUS eStatus = pSyntax->DoSyntaxParse(); |
551 for (;;) { | 555 if (eStatus == FDE_CSSSYNTAXSTATUS_PropertyName) { |
552 FDE_CSSSYNTAXSTATUS eStatus = pSyntax->DoSyntaxParse(); | 556 psz2 = pSyntax->GetCurrentString(iLen2); |
553 if (eStatus == FDE_CSSSYNTAXSTATUS_PropertyName) { | 557 args.pProperty = FDE_GetCSSPropertyByName(CFX_WideStringC(psz2, iLen2)); |
554 psz = pSyntax->GetCurrentString(iLen); | 558 if (!args.pProperty) |
555 args.pProperty = FDE_GetCSSPropertyByName(CFX_WideStringC(psz, iLen)); | 559 wsName = CFX_WideStringC(psz2, iLen2); |
556 if (args.pProperty == NULL) { | 560 } else if (eStatus == FDE_CSSSYNTAXSTATUS_PropertyValue) { |
557 wsName = CFX_WideStringC(psz, iLen); | 561 if (args.pProperty) { |
562 psz2 = pSyntax->GetCurrentString(iLen2); | |
563 if (iLen2 > 0) | |
564 pDecl->AddProperty(&args, psz2, iLen2); | |
565 } else if (iLen2 > 0) { | |
566 psz2 = pSyntax->GetCurrentString(iLen2); | |
567 if (iLen2 > 0) { | |
568 pDecl->AddProperty(&args, wsName.c_str(), wsName.GetLength(), psz2, | |
569 iLen2); | |
558 } | 570 } |
559 } else if (eStatus == FDE_CSSSYNTAXSTATUS_PropertyValue) { | |
560 if (args.pProperty != NULL) { | |
561 psz = pSyntax->GetCurrentString(iLen); | |
562 if (iLen > 0) { | |
563 pDecl->AddProperty(&args, psz, iLen); | |
564 } | |
565 } else if (iLen > 0) { | |
566 psz = pSyntax->GetCurrentString(iLen); | |
567 if (iLen > 0) { | |
568 pDecl->AddProperty(&args, wsName.c_str(), wsName.GetLength(), psz, | |
569 iLen); | |
570 } | |
571 } | |
572 } else { | |
573 break; | |
574 } | 571 } |
572 } else { | |
573 break; | |
575 } | 574 } |
576 } | 575 } |
577 pSyntax->Release(); | |
578 } | 576 } |
577 | |
579 #define FDE_CSSNONINHERITS (pComputedStyle->m_NonInheritedData) | 578 #define FDE_CSSNONINHERITS (pComputedStyle->m_NonInheritedData) |
580 #define FDE_CSSINHERITS (pComputedStyle->m_InheritedData) | 579 #define FDE_CSSINHERITS (pComputedStyle->m_InheritedData) |
581 #define FDE_CSSFONTSIZE (FDE_CSSINHERITS.m_fFontSize) | 580 #define FDE_CSSFONTSIZE (FDE_CSSINHERITS.m_fFontSize) |
582 void CFDE_CSSStyleSelector::ApplyProperty( | 581 void CFDE_CSSStyleSelector::ApplyProperty( |
583 FDE_CSSPROPERTY eProperty, | 582 FDE_CSSPROPERTY eProperty, |
584 IFDE_CSSValue* pValue, | 583 IFDE_CSSValue* pValue, |
585 CFDE_CSSComputedStyle* pComputedStyle) { | 584 CFDE_CSSComputedStyle* pComputedStyle) { |
586 if (pValue->GetType() == FDE_CSSVALUETYPE_Primitive) { | 585 if (pValue->GetType() == FDE_CSSVALUETYPE_Primitive) { |
587 IFDE_CSSPrimitiveValue* pPrimitive = (IFDE_CSSPrimitiveValue*)pValue; | 586 IFDE_CSSPrimitiveValue* pPrimitive = (IFDE_CSSPrimitiveValue*)pValue; |
588 FDE_CSSPRIMITIVETYPE eType = pPrimitive->GetPrimitiveType(); | 587 FDE_CSSPRIMITIVETYPE eType = pPrimitive->GetPrimitiveType(); |
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1775 return FDE_CSSTEXTTRANSFORM_LowerCase; | 1774 return FDE_CSSTEXTTRANSFORM_LowerCase; |
1776 default: | 1775 default: |
1777 return FDE_CSSTEXTTRANSFORM_None; | 1776 return FDE_CSSTEXTTRANSFORM_None; |
1778 } | 1777 } |
1779 } | 1778 } |
1780 FDE_CSSFONTVARIANT CFDE_CSSStyleSelector::ToFontVariant( | 1779 FDE_CSSFONTVARIANT CFDE_CSSStyleSelector::ToFontVariant( |
1781 FDE_CSSPROPERTYVALUE eValue) { | 1780 FDE_CSSPROPERTYVALUE eValue) { |
1782 return eValue == FDE_CSSPROPERTYVALUE_SmallCaps ? FDE_CSSFONTVARIANT_SmallCaps | 1781 return eValue == FDE_CSSPROPERTYVALUE_SmallCaps ? FDE_CSSFONTVARIANT_SmallCaps |
1783 : FDE_CSSFONTVARIANT_Normal; | 1782 : FDE_CSSFONTVARIANT_Normal; |
1784 } | 1783 } |
OLD | NEW |