Add GetBreakPropertyFromProp() and GetLineBreakTypeFromPair(). [pdfium : master]

0 views
Skip to first unread message

Tom Sepez (Gerrit)

unread,
Jan 8, 2019, 1:35:27 PM1/8/19
to Lei Zhang, Chromium commit bot, pdfium-...@googlegroups.com

This change is ready for review.

View Change

    To view, visit change 47890. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: pdfium
    Gerrit-Branch: master
    Gerrit-Change-Id: I82300f96dd39ad400dbecccb9b9a88acfde5c5f6
    Gerrit-Change-Number: 47890
    Gerrit-PatchSet: 1
    Gerrit-Owner: Tom Sepez <tse...@chromium.org>
    Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
    Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
    Gerrit-CC: Chromium commit bot <commi...@chromium.org>
    Gerrit-Comment-Date: Tue, 08 Jan 2019 18:35:25 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: No
    Gerrit-MessageType: comment

    Lei Zhang (Gerrit)

    unread,
    Jan 8, 2019, 1:40:50 PM1/8/19
    to Tom Sepez, Lei Zhang, Chromium commit bot, pdfium-...@googlegroups.com

    Patch set 1:Code-Review +1

    View Change

      To view, visit change 47890. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: pdfium
      Gerrit-Branch: master
      Gerrit-Change-Id: I82300f96dd39ad400dbecccb9b9a88acfde5c5f6
      Gerrit-Change-Number: 47890
      Gerrit-PatchSet: 1
      Gerrit-Owner: Tom Sepez <tse...@chromium.org>
      Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
      Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
      Gerrit-CC: Chromium commit bot <commi...@chromium.org>
      Gerrit-Comment-Date: Tue, 08 Jan 2019 18:40:49 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      Gerrit-MessageType: comment

      Tom Sepez (Gerrit)

      unread,
      Jan 8, 2019, 3:18:33 PM1/8/19
      to Lei Zhang, Chromium commit bot, pdfium-...@googlegroups.com

      Patch set 1:Commit-Queue +2

      View Change

        To view, visit change 47890. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: pdfium
        Gerrit-Branch: master
        Gerrit-Change-Id: I82300f96dd39ad400dbecccb9b9a88acfde5c5f6
        Gerrit-Change-Number: 47890
        Gerrit-PatchSet: 1
        Gerrit-Owner: Tom Sepez <tse...@chromium.org>
        Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
        Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
        Gerrit-CC: Chromium commit bot <commi...@chromium.org>
        Gerrit-Comment-Date: Tue, 08 Jan 2019 20:18:31 +0000

        Chromium commit bot (Gerrit)

        unread,
        Jan 8, 2019, 3:18:50 PM1/8/19
        to Tom Sepez, Lei Zhang, pdfium-...@googlegroups.com

        Chromium commit bot merged this change.

        View Change

        Approvals: Lei Zhang: Looks good to me Tom Sepez: Commit
        Add GetBreakPropertyFromProp() and GetLineBreakTypeFromPair().

        Precursor to fixing table size issue.
        No functional change, just document current state of affairs.

        Change-Id: I82300f96dd39ad400dbecccb9b9a88acfde5c5f6
        Reviewed-on: https://pdfium-review.googlesource.com/c/47890
        Reviewed-by: Lei Zhang <the...@chromium.org>
        Commit-Queue: Tom Sepez <tse...@chromium.org>
        ---
        M core/fxcrt/fx_unicode.h
        M xfa/fgas/layout/cfx_linebreak.h
        M xfa/fgas/layout/cfx_rtfbreak.cpp
        M xfa/fgas/layout/cfx_txtbreak.cpp
        4 files changed, 28 insertions(+), 13 deletions(-)

        diff --git a/core/fxcrt/fx_unicode.h b/core/fxcrt/fx_unicode.h
        index b1c1b0d..9611011 100644
        --- a/core/fxcrt/fx_unicode.h
        +++ b/core/fxcrt/fx_unicode.h
        @@ -7,7 +7,7 @@
        #ifndef CORE_FXCRT_FX_UNICODE_H_
        #define CORE_FXCRT_FX_UNICODE_H_

        -#include <stdint.h>
        +#include "core/fxcrt/fx_system.h"

        uint32_t FX_GetUnicodeProperties(wchar_t wch);
        wchar_t FX_GetMirrorChar(wchar_t wch);
        @@ -16,7 +16,7 @@

        // As defined in http://www.unicode.org/reports/tr14
        constexpr uint8_t kBreakPropertySpace = 35;
        -constexpr uint8_t kBreakPropertyTB = 37; // Don't know what this is ...
        +constexpr uint8_t kBreakPropertyTB = 37; // Highest, don't know what this is.

        constexpr uint32_t FX_CHARTYPEBITS = 11;
        constexpr uint32_t FX_CHARTYPEBITSMASK = 0xF << FX_CHARTYPEBITS;
        @@ -41,6 +41,13 @@
        return static_cast<FX_CHARTYPE>(prop & FX_CHARTYPEBITSMASK);
        }

        +inline uint32_t GetBreakPropertyFromProp(uint32_t prop) {
        + // Analagous to ULineBreak in icu's uchar.h, but permuted order, and a
        + // subset lacking some more recent additions.
        + ASSERT((prop & 0x3f) <= kBreakPropertyTB);
        + return prop & 0x3f;
        +}
        +
        wchar_t FX_GetMirrorChar(wchar_t wch, uint32_t dwProps);

        #endif // PDF_ENABLE_XFA
        diff --git a/xfa/fgas/layout/cfx_linebreak.h b/xfa/fgas/layout/cfx_linebreak.h
        index ca2e4b5..ca3293f 100644
        --- a/xfa/fgas/layout/cfx_linebreak.h
        +++ b/xfa/fgas/layout/cfx_linebreak.h
        @@ -8,6 +8,7 @@
        #define XFA_FGAS_LAYOUT_CFX_LINEBREAK_H_

        #include "core/fxcrt/fx_system.h"
        +#include "core/fxcrt/fx_unicode.h"

        enum FX_LINEBREAKTYPE : uint8_t {
        FX_LBT_UNKNOWN = 0x00,
        @@ -19,6 +20,14 @@
        FX_LBT_HANGUL_SPACE_BRK = 0x6F,
        };

        +// TODO(tsepez): the dimensions of this table are wrong, should be 38x38.
        extern const FX_LINEBREAKTYPE gs_FX_LineBreak_PairTable[64][32];

        +inline FX_LINEBREAKTYPE GetLineBreakTypeFromPair(uint32_t curr_char_break,
        + uint32_t next_char_break) {
        + ASSERT(curr_char_break <= kBreakPropertyTB);
        + ASSERT(next_char_break <= kBreakPropertyTB);
        + return gs_FX_LineBreak_PairTable[curr_char_break][next_char_break];
        +}
        +
        #endif // XFA_FGAS_LAYOUT_CFX_LINEBREAK_H_
        diff --git a/xfa/fgas/layout/cfx_rtfbreak.cpp b/xfa/fgas/layout/cfx_rtfbreak.cpp
        index 9dce8d7..70a5756 100644
        --- a/xfa/fgas/layout/cfx_rtfbreak.cpp
        +++ b/xfa/fgas/layout/cfx_rtfbreak.cpp
        @@ -609,7 +609,7 @@
        pCur->m_nBreakType = FX_LBT_UNKNOWN;

        uint32_t nCodeProp = pCur->char_props();
        - uint32_t nNext = nCodeProp & 0x003F;
        + uint32_t nNext = GetBreakPropertyFromProp(nCodeProp);
        int32_t iCharWidth = pCur->m_iCharWidth;
        if (iCharWidth > 0)
        *pEndPos -= iCharWidth;
        @@ -617,21 +617,20 @@
        while (iLength >= 0) {
        pCur = pCharArray + iLength;
        nCodeProp = pCur->char_props();
        - uint32_t nCur = nCodeProp & 0x003F;
        + uint32_t nCur = GetBreakPropertyFromProp(nCodeProp);
        bool bNeedBreak = false;
        FX_LINEBREAKTYPE eType;
        if (nCur == kBreakPropertyTB) {
        bNeedBreak = true;
        - eType = nNext == kBreakPropertyTB
        - ? FX_LBT_PROHIBITED_BRK
        - : gs_FX_LineBreak_PairTable[nCur][nNext];
        + eType = nNext == kBreakPropertyTB ? FX_LBT_PROHIBITED_BRK
        + : GetLineBreakTypeFromPair(nCur, nNext);
        } else {
        if (nCur == kBreakPropertySpace)
        bNeedBreak = true;

        eType = nNext == kBreakPropertySpace
        ? FX_LBT_PROHIBITED_BRK
        - : gs_FX_LineBreak_PairTable[nCur][nNext];
        + : GetLineBreakTypeFromPair(nCur, nNext);
        }
        if (bAllChars)
        pCur->m_nBreakType = eType;
        @@ -656,7 +655,7 @@
        if (iCharWidth > 0)
        *pEndPos -= iCharWidth;
        }
        - nNext = nCodeProp & 0x003F;
        + nNext = GetBreakPropertyFromProp(nCodeProp);
        --iLength;
        }
        if (bOnlyBrk)
        diff --git a/xfa/fgas/layout/cfx_txtbreak.cpp b/xfa/fgas/layout/cfx_txtbreak.cpp
        index d861058..9d14305 100644
        --- a/xfa/fgas/layout/cfx_txtbreak.cpp
        +++ b/xfa/fgas/layout/cfx_txtbreak.cpp
        @@ -554,7 +554,7 @@
        pCur->m_nBreakType = FX_LBT_UNKNOWN;

        nCodeProp = pCur->char_props();
        - nNext = nCodeProp & 0x003F;
        + nNext = GetBreakPropertyFromProp(nCodeProp);
        int32_t iCharWidth = pCur->m_iCharWidth;
        if (iCharWidth > 0)
        *pEndPos -= iCharWidth;
        @@ -562,11 +562,11 @@
        while (iLength >= 0) {
        pCur = &chars[iLength];
        nCodeProp = pCur->char_props();
        - nCur = nCodeProp & 0x003F;
        + nCur = GetBreakPropertyFromProp(nCodeProp);
        if (nNext == kBreakPropertySpace)
        eType = FX_LBT_PROHIBITED_BRK;
        else
        - eType = gs_FX_LineBreak_PairTable[nCur][nNext];
        + eType = GetLineBreakTypeFromPair(nCur, nNext);
        if (bAllChars)
        pCur->m_nBreakType = static_cast<uint8_t>(eType);
        if (!bOnlyBrk) {
        @@ -590,7 +590,7 @@
        if (iCharWidth > 0)
        *pEndPos -= iCharWidth;
        }
        - nNext = nCodeProp & 0x003F;
        + nNext = GetBreakPropertyFromProp(nCodeProp);
        iLength--;
        }
        if (bOnlyBrk)

        To view, visit change 47890. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: pdfium
        Gerrit-Branch: master
        Gerrit-Change-Id: I82300f96dd39ad400dbecccb9b9a88acfde5c5f6
        Gerrit-Change-Number: 47890
        Gerrit-PatchSet: 2
        Gerrit-Owner: Tom Sepez <tse...@chromium.org>
        Gerrit-Reviewer: Chromium commit bot <commi...@chromium.org>
        Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
        Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
        Gerrit-MessageType: merged
        Reply all
        Reply to author
        Forward
        0 new messages