Commit 9dc47921 authored by Xidorn Quan's avatar Xidorn Quan
Browse files

Bug 1368418 part 1 - Remove nsISemanticUnitScanner. r=emk

Code search indicates that this is not used internally, and the only
addon uses this is Breadcrumbs, which hasn't been updated since 2009,
thus it is already not compatible with current Firefox.

MozReview-Commit-ID: 1lUs7ceaaE1

--HG--
extra : rebase_source : 87060c33291ba415c6c70767c132c4a5b74d29fb
parent 5b4491bb
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -259,7 +259,6 @@
@RESPATH@/components/layout_xul_tree.xpt
@RESPATH@/components/layout_xul.xpt
@RESPATH@/components/locale.xpt
@RESPATH@/components/lwbrk.xpt
#ifdef MOZ_GECKO_PROFILER
@RESPATH@/components/memory_profiler.xpt
#endif
+0 −7
Original line number Diff line number Diff line
@@ -10,8 +10,6 @@
#include "nsJISx4051LineBreaker.h"
#include "nsSampleWordBreaker.h"

#include "nsSemanticUnitScanner.h"

// unicharutil
#include "nsCategoryImp.h"
#include "nsUnicharUtilCIID.h"
@@ -32,8 +30,6 @@
NS_GENERIC_FACTORY_CONSTRUCTOR(nsJISx4051LineBreaker)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSampleWordBreaker)

NS_GENERIC_FACTORY_CONSTRUCTOR(nsSemanticUnitScanner)

NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsStringBundleService, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsStringBundleTextOverride, Init)

@@ -48,7 +44,6 @@ NS_DEFINE_NAMED_CID(MOZ_LOCALESERVICE_CID);
NS_DEFINE_NAMED_CID(MOZ_OSPREFERENCES_CID);
NS_DEFINE_NAMED_CID(NS_LBRK_CID);
NS_DEFINE_NAMED_CID(NS_WBRK_CID);
NS_DEFINE_NAMED_CID(NS_SEMANTICUNITSCANNER_CID);
NS_DEFINE_NAMED_CID(NS_UNICHARUTIL_CID);
NS_DEFINE_NAMED_CID(NS_UNICHARCATEGORY_CID);
NS_DEFINE_NAMED_CID(NS_ENTITYCONVERTER_CID);
@@ -67,7 +62,6 @@ static const mozilla::Module::CIDEntry kIntlCIDs[] = {
    { &kMOZ_OSPREFERENCES_CID, false, nullptr, mozilla::intl::OSPreferencesConstructor },
    { &kNS_LBRK_CID, false, nullptr, nsJISx4051LineBreakerConstructor },
    { &kNS_WBRK_CID, false, nullptr, nsSampleWordBreakerConstructor },
    { &kNS_SEMANTICUNITSCANNER_CID, false, nullptr, nsSemanticUnitScannerConstructor },
    { &kNS_UNICHARUTIL_CID, false, nullptr, nsCaseConversionImp2Constructor },
    { &kNS_UNICHARCATEGORY_CID, false, nullptr, nsCategoryImpConstructor },
    { &kNS_ENTITYCONVERTER_CID, false, nullptr, nsEntityConverterConstructor },
@@ -88,7 +82,6 @@ static const mozilla::Module::ContractIDEntry kIntlContracts[] = {
    { MOZ_OSPREFERENCES_CONTRACTID, &kMOZ_OSPREFERENCES_CID },
    { NS_LBRK_CONTRACTID, &kNS_LBRK_CID },
    { NS_WBRK_CONTRACTID, &kNS_WBRK_CID },
    { NS_SEMANTICUNITSCANNER_CONTRACTID, &kNS_SEMANTICUNITSCANNER_CID },
    { NS_UNICHARUTIL_CONTRACTID, &kNS_UNICHARUTIL_CID },
    { NS_UNICHARCATEGORY_CONTRACTID, &kNS_UNICHARCATEGORY_CID },
    { NS_ENTITYCONVERTER_CONTRACTID, &kNS_ENTITYCONVERTER_CID },
+0 −7
Original line number Diff line number Diff line
@@ -6,12 +6,6 @@

TEST_DIRS += ['gtest']

XPIDL_SOURCES += [
    'nsISemanticUnitScanner.idl',
]

XPIDL_MODULE = 'lwbrk'

EXPORTS += [
    'nsILineBreaker.h',
    'nsIWordBreaker.h',
@@ -21,7 +15,6 @@ EXPORTS += [
UNIFIED_SOURCES += [
    'nsJISx4051LineBreaker.cpp',
    'nsSampleWordBreaker.cpp',
    'nsSemanticUnitScanner.cpp',
]

if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']:
+0 −48
Original line number Diff line number Diff line
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"

%{C++
// {ADF42751-1CEF-4ad2-AA8E-BCB849D8D31F}
#define NS_SEMANTICUNITSCANNER_CID { 0xadf42751, 0x1cef, 0x4ad2, { 0xaa, 0x8e, 0xbc, 0xb8, 0x49, 0xd8, 0xd3, 0x1f}}
#define NS_SEMANTICUNITSCANNER_CONTRACTID "@mozilla.org/intl/semanticunitscanner;1"
%}

/**
 * Provides a language independent way to break UNICODE
 * text into meaningful semantic units (e.g. words).
 */
[scriptable, uuid(9f620be4-e535-11d6-b254-00039310a47a)]
interface nsISemanticUnitScanner : nsISupports {
    /**
     * start()
     *
     * Starts up the semantic unit scanner with an optional
     * character set, which acts as a hint to optimize the heuristics
     * used to determine the language(s) of the processed text.
     *
     * @param characterSet the character set the text was originally
     *                     encoded in (can be NULL)
     */
    void start(in string characterSet);

    /**
     * next()
     * Get the begin / end offset of the next unit in the current text
     *
     * @param text the text to be scanned
     * @param length the number of characters in the text to be processed
     * @param pos the current position
     * @param isLastBuffer, the buffer is the last one
     * @param begin the begin offset of the next unit 
     * @param begin the end offset of the next unit 
     * @return has more unit in the current text
     */
    boolean next(in wstring text, in long length, in long pos, 
              in boolean isLastBuffer,
              out long begin, out long end );

};
+0 −76
Original line number Diff line number Diff line
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsSemanticUnitScanner.h"

NS_IMPL_ISUPPORTS_INHERITED(nsSemanticUnitScanner, nsSampleWordBreaker, nsISemanticUnitScanner)

nsSemanticUnitScanner::nsSemanticUnitScanner() : nsSampleWordBreaker()
{
  /* member initializers and constructor code */
}

nsSemanticUnitScanner::~nsSemanticUnitScanner()
{
  /* destructor code */
}


NS_IMETHODIMP nsSemanticUnitScanner::Start(const char *characterSet)
{
    // do nothing for now.
    return NS_OK;
}

NS_IMETHODIMP nsSemanticUnitScanner::Next(const char16_t *text, int32_t length, int32_t pos, bool isLastBuffer, int32_t *begin, int32_t *end, bool *_retval)
{
    // xxx need to bullet proff and check input pointer 
    //  make sure begin, end and _retval is not nullptr here

    // if we reach the end, just return
    if (pos >= length) {
       *begin = pos;
       *end = pos;
       *_retval = false;
       return NS_OK;
    }

    uint8_t char_class = nsSampleWordBreaker::GetClass(text[pos]);

    // if we are in chinese mode, return one han letter at a time
    // we should not do this if we are in Japanese or Korean mode
    if (kWbClassHanLetter == char_class) {
       *begin = pos;
       *end = pos+1;
       *_retval = true;
       return NS_OK;
    }

    int32_t next;
    // find the next "word"
    next = NextWord(text, (uint32_t) length, (uint32_t) pos);

    // if we don't have enough text to make decision, return 
    if (next == NS_WORDBREAKER_NEED_MORE_TEXT) {
       *begin = pos;
       *end = isLastBuffer ? length : pos;
       *_retval = isLastBuffer;
       return NS_OK;
    } 
    
    // if what we got is space or punct, look at the next break
    if ((char_class == kWbClassSpace) || (char_class == kWbClassPunct)) {
        // if the next "word" is not letters, 
        // call itself recursively with the new pos
        return Next(text, length, next, isLastBuffer, begin, end, _retval);
    }

    // for the rest, return 
    *begin = pos;
    *end = next;
    *_retval = true;
    return NS_OK;
}
Loading