Changeset 14273 in webkit


Ignore:
Timestamp:
May 9, 2006 9:59:57 PM (18 years ago)
Author:
darin
Message:

LayoutTests:

  • fast/css/case-transform.html: Added.
  • fast/css/case-transform-expected.txt: Added.

WebCore:

Rubber stamped by Hyatt.

Test: fast/css/case-transform.html

By using ICU more, this fixes some bugs in a few places.

  • bindings/js/JSXMLSerializer.cpp:
  • css/css_valueimpl.h:
  • kwq/KWQTextStream.cpp:
  • loader/CachedObject.h:
  • platform/Color.cpp: Add includes of DeprecatedString.h as needed, now that StringImpl.h no longer includes it.
  • bindings/js/kjs_css.cpp: (KJS::cssPropertyName): Eliminate use of QChar::latin1() in a case where it's not helpful.
  • bindings/js/kjs_proxy.cpp: (WebCore::KJSProxy::evaluate): Use characters() function instead of the old unicode() function.
  • bindings/js/kjs_window.cpp: (KJS::isSeparator): Use UChar instead of QChar.
  • bindings/objc/DOMInternal.mm: (StringImpl::operator NSString*): Remove typecast that's no longer needed. (String::String): Ditto. Also use Vector for local buffer to make code read simpler.
  • bridge/mac/FrameMac.mm: (WebCore::selectorForKeyEvent): Remove call to unicode() function, no longer needed. (WebCore::FrameMac::setTitle): Remove QChar cast, no longer needed. (WebCore::FrameMac::setStatusBarText): Ditto. (WebCore::FrameMac::advanceToNextMisspelling): Use UChar instead of QChar. (WebCore::FrameMac::runJavaScriptAlert): Remove QChar cast, no longer needed. (WebCore::FrameMac::runJavaScriptConfirm): Ditto. (WebCore::FrameMac::runJavaScriptPrompt): Ditto. (WebCore::FrameMac::attributedString): Replaces calls of QChar::direction() with calls to u_charDirection and use ICU constants instead of QChar ones. (WebCore::FrameMac::markMisspellings): Remove QChar cast, no longer needed. Added a QChar cast so we can call isSpace -- slated to be removed later. (WebCore::FrameMac::shouldClose): Remove QChar cast, no longer needed.
  • bridge/mac/WebCoreFrameBridge.mm: (-[WebCoreFrameBridge selectedString]): Remove QChar cast, no longer needed. (-[WebCoreFrameBridge stringForRange:]): Ditto.
  • css/CSSGrammar.y: Update for field name change from string to characters. Use UChar instead of unsigned short.
  • css/css_valueimpl.cpp: (WebCore::propertyID): Use UChar instead of unsigned short and get rid of call to unicode() function, no longer needed. (WebCore::quoteStringIfNeeded): Use strings when building up a resulting string, instead of depending on the feature where you can append characters to a string.
  • css/csshelper.cpp: (WebCore::parseURL): Remove calls to unicode() function and rewrite to obviate the need to call lower() just to check for a few constant character values. Also remove a now-unneeded type cast.
  • css/cssparser.h: Changed ParseString field to use UChar and to be named characters instead of string. Changed many other fields to be UChar instead of unsigned short. (WebCore::domString): Update for that. (WebCore::atomicString): Ditto.
  • css/cssparser.cpp: (WebCore::ParseString::lower): Use u_tolower instead of QChar::lower(). Also change name to characters from string. (WebCore::CSSParser::setupParser): Use UChar instead of unsigned short. (WebCore::CSSParser::lex): Ditto. Also update for characters name change. (WebCore::CSSParser::text): Use UChar instead of unsigned short. Also tweak some of the code a little bit to handle a couple of overflow cases better and reduce type casting. (WebCore::deprecatedString): Moved here so we don't have to include DeprecatedString.h in the header file.
  • css/cssstyleselector.cpp: (WebCore::checkPseudoState): Added a type cast since this code now bridges the world between modern code and QChar/DeprecatedString.
  • dom/CharacterData.cpp: (WebCore::CharacterData::CharacterData): Changed QChar to UChar.
  • dom/Document.h:
  • dom/Document.cpp: (WebCore::Document::isValidName): Updated for name change from unicode to characters. (WebCore::Document::parseQualifiedName): Ditto. (WebCore::Document::backslashAsCurrencySymbol): Changed return type to UChar.
  • dom/NamedMappedAttrMap.cpp: (WebCore::isClassWhitespace): Changed parameter to UChar from QChar. (WebCore::NamedMappedAttrMap::parseClassAttribute): Changed from UChar to QChar and from unicode to characters.
  • dom/Position.cpp: (WebCore::Position::leadingWhitespacePosition): Changed from QChar to UChar. (WebCore::Position::trailingWhitespacePosition): Ditto.
  • dom/StyledElement.cpp: (WebCore::isClassWhitespace): Changed from QChar to UChar. (WebCore::StyledElement::addCSSLength): Changed from QChar to UChar, and remove one case where latin1() was used and was not helpful. (WebCore::StyledElement::addCSSColor): Removed unicode() function call, no longer needed.
  • dom/dom2_eventsimpl.cpp: (WebCore::KeyboardEvent::charCode):
  • html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::constrainValue): Removed unicode() function call, no longer needed.
  • dom/xml_tokenizer.h: Removed default parameter for xmlDocPtrForString so we don't have to include the DeprecatedString.h header in this file (and since no one uses it).
  • editing/HTMLInterchange.cpp: (convertHTMLTextToInterchangeFormat): Added a couple calls to the unicode() function to bridge the gap from QChar/DeprecatedString back to modern code.
  • editing/InsertTextCommand.cpp: Removed unused function.
  • editing/TextIterator.h: Changed from QChar to UChar.
  • editing/TextIterator.cpp: (WebCore::TextIterator::TextIterator): Initialize m_lastCharacter since it's now a UChar (which is just a typedef) rather than a QChar (which was a class with a default value of 0). (WebCore::TextIterator::handleTextNode): Updated to use characters() instead of unicode(). (WebCore::TextIterator::handleTextBox): Removed unicode() call since it's now a UChar instead of a QChar. (WebCore::TextIterator::emitCharacter): More of the same. (WebCore::SimplifiedBackwardsTextIterator::handleTextNode): Ditto. (WebCore::SimplifiedBackwardsTextIterator::emitCharacter): Ditto. (WebCore::CharacterIterator::string): Ditto. (WebCore::WordAwareIterator::advance): Ditto. (WebCore::WordAwareIterator::length): Ditto. (WebCore::WordAwareIterator::characters): Ditto. (WebCore::CircularSearchBuffer::CircularSearchBuffer): Changed to use UChar instead of QChar, but also to use foldCase() instead of lower(), because we want case folding here, not lowercasing. (WebCore::CircularSearchBuffer::append): Ditto, with u_foldCase. (WebCore::CircularSearchBuffer::isMatch): Ditto. (WebCore::plainText): Added type cast since this bridges the gap from the modern stuff to QChar/DeprecatedString.
  • editing/VisiblePosition.h: Changed from QChar to UChar.
  • editing/VisiblePosition.cpp: (WebCore::VisiblePosition::characterAfter): Ditto.
  • editing/markup.cpp: (WebCore::escapeTextForMarkup): Changed code that used latin1() for no good reason to use unicode() instead.


  • html/HTMLTokenizer.h: Changed from QChar to UChar.
  • html/HTMLTokenizer.cpp: Changed from QChar to UChar, including removing the KHTML_ALLOC_QCHAR_VEC and KHTML_DELETE_QCHAR_VEC macros, which weren't being used consistently anyway. (WebCore::fixUpChar): More of the same. (WebCore::tagMatch): Ditto. (WebCore::HTMLTokenizer::reset): Ditto. (WebCore::HTMLTokenizer::begin): Ditto. Also corrected anomaly where buffer size was not the same as the size value -- this was only true in the initial allocation, so I believe there was no value in it. (WebCore::HTMLTokenizer::parseSpecial): Ditto. Also removed a use of latin1() that was unnnecessary extra work. (WebCore::HTMLTokenizer::scriptHandler): More of the same. (WebCore::HTMLTokenizer::parseComment): Ditto. (WebCore::HTMLTokenizer::parseServer): Ditto. (WebCore::HTMLTokenizer::parseProcessingInstruction): Ditto. Another unnecessary use of latin1() removed. (WebCore::HTMLTokenizer::parseText): Ditto. (WebCore::HTMLTokenizer::parseEntity): Ditto. Changed hex-parsing code to handle uppercase hex a more-efficient way than calling QChar::lower() on each character. Also changed surrogate code logic to fix a couple things -- reject character codes

    0x10FFFF as it should and use U16_LEAD and U16_TRAIL instead of writing our

    own versions of these. (WebCore::HTMLTokenizer::parseTag): Ditto. (WebCore::HTMLTokenizer::write): Ditto. (WebCore::HTMLTokenizer::end): Ditto. (WebCore::HTMLTokenizer::finish): Ditto. (WebCore::HTMLTokenizer::enlargeBuffer): Ditto. (WebCore::HTMLTokenizer::enlargeScriptBuffer): Ditto. (WebCore::HTMLTokenizer::notifyFinished): (WebCore::decodeNamedEntity): Ditto.
  • html/html_inlineimpl.cpp: (WebCore::parseFontSizeNumber): Changed from QChar to UChar, including using u_isdigit and u_charDigitValue instead of QChar::isNumber and QChar::digitValue. Also removed unneeded range checking that's already done by WebCore::String.
  • kwq/KWQLoader.mm: (KWQIsResponseURLEqualToURL): Rewrote to use Vector and UChar, removing all the type casts and making the whole function much shorter.
  • kwq/WebCoreAXObject.mm: (AXAttributedStringAppendText): Use UChar instead of QChar. (-[WebCoreAXObject doAXAttributedStringForTextMarkerRange:]): More of the same.
  • loader/Cache.h: Remove unnecessary default parameters, preventing the need to include the DeprecatedString.h header in this header. Cleaned up the header structure a bit, removing some obsolete and redundant comments and fixing typos.
  • loader/Cache.cpp: Removed unused preload functions.
  • page/Frame.h:
  • page/Frame.cpp: (WebCore::UserStyleSheetLoader::UserStyleSheetLoader): Added explicit arguments. This was the only caller anywhere that took advantage of the default parameter values in one of the Cache class request functions. (WebCore::Frame::backslashAsCurrencySymbol): Changed QChar to UChar.
  • platform/AtomicString.h: Changed QChar to UChar. Removed constructor that makes an AtomicString from a single character. Renamed unicode() function to characters(). Renamed KHTML_ATOMICSTRING_HIDE_GLOBALS to ATOMICSTRING_HIDE_GLOBALS.
  • platform/AtomicString.cpp: (WebCore::CStringTranslator::equal): Changed QChar to UChar. (WebCore::operator==): Changed unicode() to characters(). (WebCore::UCharBufferTranslator::hash): More of the same. (WebCore::UCharBufferTranslator::equal): Ditto. (WebCore::UCharBufferTranslator::translate): Ditto. (WebCore::AtomicString::add): Ditto. (WebCore::AtomicString::operator Identifier): Ditto. (WebCore::AtomicString::operator UString): Ditto. (WebCore::AtomicString::AtomicString): Moved here so we don't need DeprecatedString.h in the header. (WebCore::AtomicString::deprecatedString): Ditto.
  • platform/DeprecatedString.h: Removed QChar::Direction enum and all the DirXXX values, isDigit, isLetter, isNumber, isLetterOrNumber, isPunct, digitValue, and direction functions. (QChar::isSpace): Changed to use u_charDirection instead of QChar::direction.
  • platform/Font.h: (WebCore::Font::width): Changed QChar to UChar.
  • platform/Font.cpp: (WebCore::Font::width): Ditto.
  • platform/GraphicsContext.h:
  • platform/GraphicsContext.cpp: (WebCore::GraphicsContext::drawText): Changed QChar to UChar. Removed horizontalAlignment parameter from simplified string drawing entry point, since it's not used. (WebCore::GraphicsContext::drawHighlightForText): Changed QChar to UChar.
  • platform/PlatformString.h: Changed QChar to UChar. Removed constructor that makes a String from a single character. Renamed unicode() function to characters(). Added an append function and changed += operator to just call that. Added a foldCase() function. Removed the concatenation operators that add individual strings before or after.
  • platform/String.cpp: (WebCore::String::String): Changed QChar to UChar. (WebCore::String::append): Renamed from operator+= and removed the return value. (WebCore::String::operator[]): Changed QChar to UChar. (WebCore::String::foldCase): Added. (WebCore::String::percentage): More of the same. (WebCore::String::characters): Renamed from unicode(). (WebCore::String::deprecatedString): More of the same. (WebCore::String::sprintf): Fixed mistakes in the comments. (WebCore::String::isEmpty): Tweaked a bit. (WebCore::operator==): More of the same. (WebCore::String::operator Identifier): Ditto. (WebCore::String::operator UString): Ditto.
  • platform/SegmentedString.h: Changed from QChar to UChar. Had to initialize data members that are now UChar.
  • platform/SegmentedString.cpp: (WebCore::SegmentedString::length): Updated for change from QChar to UChar. (WebCore::SegmentedString::append): Ditto. (WebCore::SegmentedString::prepend): Ditto. (WebCore::SegmentedString::toString): Ditto.
  • platform/StringHash.h: Updated to use UChar instead of QChar and for name changes. Also changed to use case folding intead of lowercasing for case insensitive hashing.
  • platform/StringImpl.h:
  • platform/StringImpl.cpp: (WebCore::newUCharVector): Changed to UChar from QChar. (WebCore::deleteUCharVector): Ditto. (WebCore::StringImpl::StringImpl): Ditto. (WebCore::StringImpl::init): Ditto. Also renamed from initWithChar and initWithQChar. (WebCore::StringImpl::~StringImpl): Ditto. (WebCore::StringImpl::append): Ditto. (WebCore::StringImpl::insert): Ditto. (WebCore::StringImpl::truncate): Ditto. (WebCore::StringImpl::remove): Ditto. (WebCore::StringImpl::split): Ditto. (WebCore::StringImpl::containsOnlyWhitespace): Ditto. Also added comment because this function seems a little broken. (WebCore::parseLength): More of the same. (WebCore::StringImpl::toCoordsArray): Ditto. (WebCore::StringImpl::toLengthArray): Ditto. (WebCore::StringImpl::isLower): Ditto. (WebCore::StringImpl::lower): Rewrote to use u_strToLower. (WebCore::StringImpl::upper): Rewrote to use u_strToUpper. (WebCore::StringImpl::foldCase): Added. Uses u_strFoldCase. (WebCore::getWordBreakIterator): Changed to use U_FAILURE instead of accepting only U_ZERO_ERROR as a success code. (WebCore::StringImpl::capitalize): More QChar to UChar changes. (WebCore::StringImpl::toInt): Ditto. (WebCore::equal): Changed from QChar to UChar and was careful to preserve the old semantics where "high ASCII" is treated as U+0080-U+00FF even though I don't know if this feature is important. (WebCore::equalIgnoringCase): Ditto, but used case folding instead of lowercasing by using the u_foldCase and u_memcasecmp functions. Also renamed from equalCaseInsensitive for more-consistent naming. (WebCore::StringImpl::find): Ditto. Use case folding for the case insensitive branch. (WebCore::StringImpl::replace): More of the same. (WebCore::StringImpl::computeHash): Ditto. (WebCore::StringImpl::ascii): Ditto.
  • platform/TextBoundaries.h: Changed from QChar to UChar.
  • platform/mac/TextBoundaries.mm: (WebCore::findWordBoundary): Made the change to UChar and removed some type casts. (WebCore::findNextWordFromIndex): Ditto. (WebCore::findSentenceBoundary): Ditto. (WebCore::findNextSentenceFromIndex): Ditto.
  • platform/TextEncoding.h:
  • platform/TextEncoding.cpp: (WebCore::TextEncoding::backslashAsCurrencySymbol): Changed from QChar to UChar. (WebCore::TextEncoding::fromUnicode): More of the same.
  • platform/mac/TextEncodingMac.cpp: (WebCore::TextEncoding::fromUnicode): More of the same.
  • platform/mac/FontFamilyMac.mm: (WebCore::FontFamily::getNSFamily): Removed a now-unneeded type cast.
  • platform/mac/FontMac.mm: (WebCore::Font::selectionRectForText): (WebCore::Font::drawText): (WebCore::Font::drawHighlightForText): (WebCore::Font::floatWidth): (WebCore::Font::checkSelectionPoint): Changed QChar to UChar and removed some now-unneeded type casts.
  • editing/RebalanceWhitespaceCommand.cpp: (WebCore::isWhitespace):
  • editing/ReplaceSelectionCommand.cpp: (WebCore::ReplaceSelectionCommand::doApply):
  • editing/visible_units.cpp: (WebCore::previousBoundary): (WebCore::nextBoundary): (WebCore::startWordBoundary): (WebCore::endWordBoundary): (WebCore::previousWordPositionBoundary): (WebCore::nextWordPositionBoundary): (WebCore::startSentenceBoundary): (WebCore::endSentenceBoundary): (WebCore::previousSentencePositionBoundary): (WebCore::nextSentencePositionBoundary): (WebCore::startOfParagraph): (WebCore::endOfParagraph):
  • html/HTMLParser.cpp: (WebCore::HTMLParser::handleError):
  • rendering/InlineTextBox.cpp: (WebCore::InlineTextBox::selectionRect): (WebCore::InlineTextBox::paint): (WebCore::InlineTextBox::paintSelection): (WebCore::InlineTextBox::paintMarkedTextBackground): (WebCore::InlineTextBox::paintTextMatchMarker): (WebCore::InlineTextBox::offsetForPosition): (WebCore::InlineTextBox::positionForOffset):
  • rendering/RenderBlock.cpp: (WebCore::stripTrailingSpace): (WebCore::RenderBlock::updateFirstLetter):
  • rendering/RenderFlexibleBox.cpp: (WebCore::RenderFlexibleBox::layoutVerticalBox):
  • rendering/RenderObject.h:
  • rendering/RenderObject.cpp: (WebCore::RenderObject::backslashAsCurrencySymbol):
  • rendering/RenderTreeAsText.cpp: (quoteAndEscapeNonPrintables):
  • rendering/break_lines.cpp: (WebCore::nextBreakablePosition):
  • rendering/break_lines.h: (WebCore::isBreakable):
  • rendering/render_style.h: (WebCore::RenderStyle::isCollapsibleWhiteSpace):
  • xml/XSLStyleSheet.cpp: (WebCore::XSLStyleSheet::parseString):
  • xml/xmlhttprequest.cpp: (WebCore::getMIMEType): (WebCore::getCharset): Changed QChar to UChar.
  • rendering/RenderImage.cpp: (WebCore::RenderImage::imageChanged): Changed QChar to UChar. (WebCore::RenderImage::paint): Changed callers of drawText to no-longer pass 0 for the horizontal alignment, since I removed that parameters.
  • rendering/RenderText.h: Changed QChar to UChar.
  • rendering/RenderText.cpp: (WebCore::characterBreakIterator): Update for name change. (WebCore::RenderText::RenderText): Ditto. (WebCore::RenderText::allAscii): Remove uneeded unicode() and allow the value U+007F to count as ASCII. (WebCore::RenderText::cacheWidths): Changed QChar to UChar. (WebCore::RenderText::widthFromCache): Changed code that deals with direction to use the ICU direction calls. (WebCore::RenderText::trimmedMinMaxWidth): Changed QChar to UChar. (WebCore::RenderText::calcMinMaxWidth): Ditto. (WebCore::RenderText::containsOnlyWhitespace): Ditto. (WebCore::RenderText::setText): Ditto. (WebCore::RenderText::width): Ditto.
  • rendering/RenderTextField.cpp: (WebCore::RenderTextField::updateFromElement): Removed unneeded QChar cast. (WebCore::RenderTextField::calcMinMaxWidth): Changed from QChar to UChar.
  • rendering/bidi.h:
  • rendering/bidi.cpp: (WebCore::BidiIterator::BidiIterator): (WebCore::BidiState::BidiState): (WebCore::BidiContext::BidiContext): (WebCore::bidiNext): (WebCore::bidiFirst): (WebCore::BidiIterator::current): (WebCore::BidiIterator::direction): (WebCore::addRun): (WebCore::checkMidpoints): (WebCore::appendRun): (WebCore::embed): (WebCore::RenderBlock::tabWidth): (WebCore::RenderBlock::computeHorizontalPositionsForLine): (WebCore::RenderBlock::bidiReorderLine): (WebCore::RenderBlock::layoutInlineChildren): (WebCore::skipNonBreakingSpace): (WebCore::RenderBlock::skipWhitespace): (WebCore::RenderBlock::findNextLineBreak): (WebCore::RenderBlock::checkLinesForTextOverflow): Changed from QChar to UChar and all direction from QChar constants to the ones from ICU.
  • rendering/render_form.cpp: (WebCore::RenderLineEdit::updateFromElement): (WebCore::RenderSelect::updateFromElement): (WebCore::RenderTextArea::updateFromElement): (WebCore::RenderTextArea::text): (WebCore::RenderTextArea::textWithHardLineBreaks): Got rid of now-unneeded QChar type casts.
  • rendering/render_line.cpp: (WebCore::InlineFlowBox::placeBoxesHorizontally): Updated for change from QChar to UChar. (WebCore::EllipsisBox::paint): Updated for unicode() -> characters() name change.
  • rendering/render_list.cpp: (WebCore::toRoman): Updated from QChar to UChar. (WebCore::toLetterString): Ditto. (WebCore::toHebrew): More of the same, also cleaned up the logic a bit. (WebCore::RenderListMarker::paint): Removed the alignment parameters from the various functions. Also removed all reliance on the width-measuring functions that take a string. (WebCore::RenderListMarker::calcMinMaxWidth): More of the same. (WebCore::RenderListMarker::getRelativeMarkerRect): Ditto.
Location:
trunk
Files:
2 added
104 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r14270 r14273  
     12006-05-09  Darin Adler  <darin@apple.com>
     2
     3        - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=6310
     4          text-transform: uppercase/lowercase don't handle cases one character becomes two
     5
     6        * fast/css/case-transform.html: Added.
     7        * fast/css/case-transform-expected.txt: Added.
     8
    192006-05-09  Levi Weintraub  <lweintraub@apple.com>
    210
  • trunk/WebCore/ChangeLog

    r14271 r14273  
     12006-05-09  Darin Adler  <darin@apple.com>
     2
     3        Rubber stamped by Hyatt.
     4
     5        - http://bugzilla.opendarwin.org/show_bug.cgi?id=8782
     6          use ICU and UChar more, QChar less
     7
     8        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=6310
     9          text-transform: uppercase/lowercase don't handle cases one character becomes two
     10
     11        Test: fast/css/case-transform.html
     12
     13        By using ICU more, this fixes some bugs in a few places.
     14
     15        * bindings/js/JSXMLSerializer.cpp:
     16        * css/css_valueimpl.h:
     17        * kwq/KWQTextStream.cpp:
     18        * loader/CachedObject.h:
     19        * platform/Color.cpp:
     20        Add includes of DeprecatedString.h as needed, now that StringImpl.h no longer
     21        includes it.
     22
     23        * bindings/js/kjs_css.cpp: (KJS::cssPropertyName):
     24        Eliminate use of QChar::latin1() in a case where it's not helpful.
     25
     26        * bindings/js/kjs_proxy.cpp: (WebCore::KJSProxy::evaluate):
     27        Use characters() function instead of the old unicode() function.
     28
     29        * bindings/js/kjs_window.cpp: (KJS::isSeparator):
     30        Use UChar instead of QChar.
     31
     32        * bindings/objc/DOMInternal.mm:
     33        (StringImpl::operator NSString*): Remove typecast that's no longer needed.
     34        (String::String): Ditto. Also use Vector for local buffer to make code read simpler.
     35
     36        * bridge/mac/FrameMac.mm:
     37        (WebCore::selectorForKeyEvent): Remove call to unicode() function, no longer needed.
     38        (WebCore::FrameMac::setTitle): Remove QChar cast, no longer needed.
     39        (WebCore::FrameMac::setStatusBarText): Ditto.
     40        (WebCore::FrameMac::advanceToNextMisspelling): Use UChar instead of QChar.
     41        (WebCore::FrameMac::runJavaScriptAlert): Remove QChar cast, no longer needed.
     42        (WebCore::FrameMac::runJavaScriptConfirm): Ditto.
     43        (WebCore::FrameMac::runJavaScriptPrompt): Ditto.
     44        (WebCore::FrameMac::attributedString): Replaces calls of QChar::direction() with
     45        calls to u_charDirection and use ICU constants instead of QChar ones.
     46        (WebCore::FrameMac::markMisspellings): Remove QChar cast, no longer needed. Added a
     47        QChar cast so we can call isSpace -- slated to be removed later.
     48        (WebCore::FrameMac::shouldClose): Remove QChar cast, no longer needed.
     49
     50        * bridge/mac/WebCoreFrameBridge.mm:
     51        (-[WebCoreFrameBridge selectedString]): Remove QChar cast, no longer needed.
     52        (-[WebCoreFrameBridge stringForRange:]): Ditto.
     53
     54        * css/CSSGrammar.y: Update for field name change from string to characters.
     55        Use UChar instead of unsigned short.
     56
     57        * css/css_valueimpl.cpp:
     58        (WebCore::propertyID): Use UChar instead of unsigned short and get rid of call to
     59        unicode() function, no longer needed.
     60        (WebCore::quoteStringIfNeeded): Use strings when building up a resulting string,
     61        instead of depending on the feature where you can append characters to a string.
     62
     63        * css/csshelper.cpp: (WebCore::parseURL): Remove calls to unicode() function and
     64        rewrite to obviate the need to call lower() just to check for a few constant
     65        character values. Also remove a now-unneeded type cast.
     66
     67        * css/cssparser.h: Changed ParseString field to use UChar and to be named characters
     68        instead of string. Changed many other fields to be UChar instead of unsigned short.
     69        (WebCore::domString): Update for that.
     70        (WebCore::atomicString): Ditto.
     71        * css/cssparser.cpp:
     72        (WebCore::ParseString::lower): Use u_tolower instead of QChar::lower(). Also change
     73        name to characters from string.
     74        (WebCore::CSSParser::setupParser): Use UChar instead of unsigned short.
     75        (WebCore::CSSParser::lex): Ditto. Also update for characters name change.
     76        (WebCore::CSSParser::text): Use UChar instead of unsigned short. Also tweak some
     77        of the code a little bit to handle a couple of overflow cases better and reduce
     78        type casting.
     79        (WebCore::deprecatedString): Moved here so we don't have to include DeprecatedString.h
     80        in the header file.
     81
     82        * css/cssstyleselector.cpp: (WebCore::checkPseudoState): Added a type cast since this
     83        code now bridges the world between modern code and QChar/DeprecatedString.
     84
     85        * dom/CharacterData.cpp: (WebCore::CharacterData::CharacterData): Changed QChar to UChar.
     86
     87        * dom/Document.h:
     88        * dom/Document.cpp:
     89        (WebCore::Document::isValidName): Updated for name change from unicode to characters.
     90        (WebCore::Document::parseQualifiedName): Ditto.
     91        (WebCore::Document::backslashAsCurrencySymbol): Changed return type to UChar.
     92
     93        * dom/NamedMappedAttrMap.cpp:
     94        (WebCore::isClassWhitespace): Changed parameter to UChar from QChar.
     95        (WebCore::NamedMappedAttrMap::parseClassAttribute): Changed from UChar to QChar and
     96        from unicode to characters.
     97
     98        * dom/Position.cpp:
     99        (WebCore::Position::leadingWhitespacePosition): Changed from QChar to UChar.
     100        (WebCore::Position::trailingWhitespacePosition): Ditto.
     101
     102        * dom/StyledElement.cpp:
     103        (WebCore::isClassWhitespace): Changed from QChar to UChar.
     104        (WebCore::StyledElement::addCSSLength): Changed from QChar to UChar, and remove one
     105        case where latin1() was used and was not helpful.
     106        (WebCore::StyledElement::addCSSColor): Removed unicode() function call, no longer needed.
     107
     108        * dom/dom2_eventsimpl.cpp: (WebCore::KeyboardEvent::charCode):
     109        * html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::constrainValue):
     110        Removed unicode() function call, no longer needed.
     111
     112        * dom/xml_tokenizer.h: Removed default parameter for xmlDocPtrForString so we don't have
     113        to include the DeprecatedString.h header in this file (and since no one uses it).
     114
     115        * editing/HTMLInterchange.cpp: (convertHTMLTextToInterchangeFormat): Added a couple calls
     116        to the unicode() function to bridge the gap from QChar/DeprecatedString back to modern
     117        code.
     118
     119        * editing/InsertTextCommand.cpp: Removed unused function.
     120
     121        * editing/TextIterator.h: Changed from QChar to UChar.
     122        * editing/TextIterator.cpp:
     123        (WebCore::TextIterator::TextIterator): Initialize m_lastCharacter since it's now a UChar
     124        (which is just a typedef) rather than a QChar (which was a class with a default value of 0).
     125        (WebCore::TextIterator::handleTextNode): Updated to use characters() instead of unicode().
     126        (WebCore::TextIterator::handleTextBox): Removed unicode() call since it's now a UChar instead
     127        of a QChar.
     128        (WebCore::TextIterator::emitCharacter): More of the same.
     129        (WebCore::SimplifiedBackwardsTextIterator::handleTextNode): Ditto.
     130        (WebCore::SimplifiedBackwardsTextIterator::emitCharacter): Ditto.
     131        (WebCore::CharacterIterator::string): Ditto.
     132        (WebCore::WordAwareIterator::advance): Ditto.
     133        (WebCore::WordAwareIterator::length): Ditto.
     134        (WebCore::WordAwareIterator::characters): Ditto.
     135        (WebCore::CircularSearchBuffer::CircularSearchBuffer): Changed to use UChar
     136        instead of QChar, but also to use foldCase() instead of lower(), because
     137        we want case folding here, not lowercasing.
     138        (WebCore::CircularSearchBuffer::append): Ditto, with u_foldCase.
     139        (WebCore::CircularSearchBuffer::isMatch): Ditto.
     140        (WebCore::plainText): Added type cast since this bridges the gap from the modern stuff
     141        to QChar/DeprecatedString.
     142
     143        * editing/VisiblePosition.h: Changed from QChar to UChar.
     144        * editing/VisiblePosition.cpp: (WebCore::VisiblePosition::characterAfter): Ditto.
     145
     146        * editing/markup.cpp: (WebCore::escapeTextForMarkup): Changed code that used latin1()
     147        for no good reason to use unicode() instead.
     148 
     149        * html/HTMLTokenizer.h: Changed from QChar to UChar.
     150        * html/HTMLTokenizer.cpp: Changed from QChar to UChar, including removing the
     151        KHTML_ALLOC_QCHAR_VEC and KHTML_DELETE_QCHAR_VEC macros, which weren't being
     152        used consistently anyway.
     153        (WebCore::fixUpChar): More of the same.
     154        (WebCore::tagMatch): Ditto.
     155        (WebCore::HTMLTokenizer::reset): Ditto.
     156        (WebCore::HTMLTokenizer::begin): Ditto. Also corrected anomaly where buffer
     157        size was not the same as the size value -- this was only true in the initial
     158        allocation, so I believe there was no value in it.
     159        (WebCore::HTMLTokenizer::parseSpecial): Ditto. Also removed a use of latin1()
     160        that was unnnecessary extra work.
     161        (WebCore::HTMLTokenizer::scriptHandler): More of the same.
     162        (WebCore::HTMLTokenizer::parseComment): Ditto.
     163        (WebCore::HTMLTokenizer::parseServer): Ditto.
     164        (WebCore::HTMLTokenizer::parseProcessingInstruction): Ditto. Another unnecessary
     165        use of latin1() removed.
     166        (WebCore::HTMLTokenizer::parseText): Ditto.
     167        (WebCore::HTMLTokenizer::parseEntity): Ditto. Changed hex-parsing code to handle
     168        uppercase hex a more-efficient way than calling QChar::lower() on each character.
     169        Also changed surrogate code logic to fix a couple things -- reject character codes
     170        > 0x10FFFF as it should and use U16_LEAD and U16_TRAIL instead of writing our
     171        own versions of these.
     172        (WebCore::HTMLTokenizer::parseTag): Ditto.
     173        (WebCore::HTMLTokenizer::write): Ditto.
     174        (WebCore::HTMLTokenizer::end): Ditto.
     175        (WebCore::HTMLTokenizer::finish): Ditto.
     176        (WebCore::HTMLTokenizer::enlargeBuffer): Ditto.
     177        (WebCore::HTMLTokenizer::enlargeScriptBuffer): Ditto.
     178        (WebCore::HTMLTokenizer::notifyFinished):
     179        (WebCore::decodeNamedEntity): Ditto.
     180
     181        * html/html_inlineimpl.cpp: (WebCore::parseFontSizeNumber): Changed from QChar
     182        to UChar, including using u_isdigit and u_charDigitValue instead of QChar::isNumber
     183        and QChar::digitValue. Also removed unneeded range checking that's already done
     184        by WebCore::String.
     185
     186        * kwq/KWQLoader.mm: (KWQIsResponseURLEqualToURL): Rewrote to use Vector and UChar,
     187        removing all the type casts and making the whole function much shorter.
     188
     189        * kwq/WebCoreAXObject.mm:
     190        (AXAttributedStringAppendText): Use UChar instead of QChar.
     191        (-[WebCoreAXObject doAXAttributedStringForTextMarkerRange:]): More of the same.
     192
     193        * loader/Cache.h: Remove unnecessary default parameters, preventing the need to
     194        include the DeprecatedString.h header in this header. Cleaned up the header
     195        structure a bit, removing some obsolete and redundant comments and fixing typos.
     196        * loader/Cache.cpp: Removed unused preload functions.
     197
     198        * page/Frame.h:
     199        * page/Frame.cpp:
     200        (WebCore::UserStyleSheetLoader::UserStyleSheetLoader): Added explicit arguments.
     201        This was the only caller anywhere that took advantage of the default parameter
     202        values in one of the Cache class request functions.
     203        (WebCore::Frame::backslashAsCurrencySymbol): Changed QChar to UChar.
     204
     205        * platform/AtomicString.h: Changed QChar to UChar. Removed constructor that makes
     206        an AtomicString from a single character. Renamed unicode() function to characters().
     207        Renamed KHTML_ATOMICSTRING_HIDE_GLOBALS to ATOMICSTRING_HIDE_GLOBALS.
     208        * platform/AtomicString.cpp:
     209        (WebCore::CStringTranslator::equal): Changed QChar to UChar.
     210        (WebCore::operator==): Changed unicode() to characters().
     211        (WebCore::UCharBufferTranslator::hash): More of the same.
     212        (WebCore::UCharBufferTranslator::equal): Ditto.
     213        (WebCore::UCharBufferTranslator::translate): Ditto.
     214        (WebCore::AtomicString::add): Ditto.
     215        (WebCore::AtomicString::operator Identifier): Ditto.
     216        (WebCore::AtomicString::operator UString): Ditto.
     217        (WebCore::AtomicString::AtomicString): Moved here so we don't need DeprecatedString.h
     218        in the header.
     219        (WebCore::AtomicString::deprecatedString): Ditto.
     220
     221        * platform/DeprecatedString.h: Removed QChar::Direction enum and all the DirXXX values,
     222        isDigit, isLetter, isNumber, isLetterOrNumber, isPunct, digitValue, and direction functions.
     223        (QChar::isSpace): Changed to use u_charDirection instead of QChar::direction.
     224
     225        * platform/Font.h: (WebCore::Font::width): Changed QChar to UChar.
     226        * platform/Font.cpp: (WebCore::Font::width): Ditto.
     227
     228        * platform/GraphicsContext.h:
     229        * platform/GraphicsContext.cpp:
     230        (WebCore::GraphicsContext::drawText): Changed QChar to UChar. Removed horizontalAlignment
     231        parameter from simplified string drawing entry point, since it's not used.
     232        (WebCore::GraphicsContext::drawHighlightForText): Changed QChar to UChar.
     233
     234        * platform/PlatformString.h: Changed QChar to UChar. Removed constructor that makes
     235        a String from a single character. Renamed unicode() function to characters(). Added
     236        an append function and changed += operator to just call that. Added a foldCase() function.
     237        Removed the concatenation operators that add individual strings before or after.
     238        * platform/String.cpp:
     239        (WebCore::String::String): Changed QChar to UChar.
     240        (WebCore::String::append): Renamed from operator+= and removed the return value.
     241        (WebCore::String::operator[]): Changed QChar to UChar.
     242        (WebCore::String::foldCase): Added.
     243        (WebCore::String::percentage): More of the same.
     244        (WebCore::String::characters): Renamed from unicode().
     245        (WebCore::String::deprecatedString): More of the same.
     246        (WebCore::String::sprintf): Fixed mistakes in the comments.
     247        (WebCore::String::isEmpty): Tweaked a bit.
     248        (WebCore::operator==): More of the same.
     249        (WebCore::String::operator Identifier): Ditto.
     250        (WebCore::String::operator UString): Ditto.
     251
     252        * platform/SegmentedString.h: Changed from QChar to UChar. Had to initialize
     253        data members that are now UChar.
     254        * platform/SegmentedString.cpp:
     255        (WebCore::SegmentedString::length): Updated for change from QChar to UChar.
     256        (WebCore::SegmentedString::append): Ditto.
     257        (WebCore::SegmentedString::prepend): Ditto.
     258        (WebCore::SegmentedString::toString): Ditto.
     259
     260        * platform/StringHash.h: Updated to use UChar instead of QChar and for name changes.
     261        Also changed to use case folding intead of lowercasing for case insensitive hashing.
     262
     263        * platform/StringImpl.h:
     264        * platform/StringImpl.cpp:
     265        (WebCore::newUCharVector): Changed to UChar from QChar.
     266        (WebCore::deleteUCharVector): Ditto.
     267        (WebCore::StringImpl::StringImpl): Ditto.
     268        (WebCore::StringImpl::init): Ditto. Also renamed from initWithChar and initWithQChar.
     269        (WebCore::StringImpl::~StringImpl): Ditto.
     270        (WebCore::StringImpl::append): Ditto.
     271        (WebCore::StringImpl::insert): Ditto.
     272        (WebCore::StringImpl::truncate): Ditto.
     273        (WebCore::StringImpl::remove): Ditto.
     274        (WebCore::StringImpl::split): Ditto.
     275        (WebCore::StringImpl::containsOnlyWhitespace): Ditto. Also added comment because this
     276        function seems a little broken.
     277        (WebCore::parseLength): More of the same.
     278        (WebCore::StringImpl::toCoordsArray): Ditto.
     279        (WebCore::StringImpl::toLengthArray): Ditto.
     280        (WebCore::StringImpl::isLower): Ditto.
     281        (WebCore::StringImpl::lower): Rewrote to use u_strToLower.
     282        (WebCore::StringImpl::upper): Rewrote to use u_strToUpper.
     283        (WebCore::StringImpl::foldCase): Added. Uses u_strFoldCase.
     284        (WebCore::getWordBreakIterator): Changed to use U_FAILURE instead of accepting only
     285        U_ZERO_ERROR as a success code.
     286        (WebCore::StringImpl::capitalize): More QChar to UChar changes.
     287        (WebCore::StringImpl::toInt): Ditto.
     288        (WebCore::equal): Changed from QChar to UChar and was careful to preserve the old
     289        semantics where "high ASCII" is treated as U+0080-U+00FF even though I don't know
     290        if this feature is important.
     291        (WebCore::equalIgnoringCase): Ditto, but used case folding instead of lowercasing
     292        by using the u_foldCase and u_memcasecmp functions. Also renamed from
     293        equalCaseInsensitive for more-consistent naming.
     294        (WebCore::StringImpl::find): Ditto. Use case folding for the case insensitive branch.
     295        (WebCore::StringImpl::replace): More of the same.
     296        (WebCore::StringImpl::computeHash): Ditto.
     297        (WebCore::StringImpl::ascii): Ditto.
     298
     299        * platform/TextBoundaries.h: Changed from QChar to UChar.
     300        * platform/mac/TextBoundaries.mm:
     301        (WebCore::findWordBoundary): Made the change to UChar and removed some type casts.
     302        (WebCore::findNextWordFromIndex): Ditto.
     303        (WebCore::findSentenceBoundary): Ditto.
     304        (WebCore::findNextSentenceFromIndex): Ditto.
     305
     306        * platform/TextEncoding.h:
     307        * platform/TextEncoding.cpp:
     308        (WebCore::TextEncoding::backslashAsCurrencySymbol): Changed from QChar to UChar.
     309        (WebCore::TextEncoding::fromUnicode): More of the same.
     310        * platform/mac/TextEncodingMac.cpp: (WebCore::TextEncoding::fromUnicode): More
     311        of the same.
     312
     313        * platform/mac/FontFamilyMac.mm: (WebCore::FontFamily::getNSFamily): Removed a
     314        now-unneeded type cast.
     315
     316        * platform/mac/FontMac.mm:
     317        (WebCore::Font::selectionRectForText):
     318        (WebCore::Font::drawText):
     319        (WebCore::Font::drawHighlightForText):
     320        (WebCore::Font::floatWidth):
     321        (WebCore::Font::checkSelectionPoint):
     322        Changed QChar to UChar and removed some now-unneeded type casts.
     323
     324        * editing/RebalanceWhitespaceCommand.cpp: (WebCore::isWhitespace):
     325        * editing/ReplaceSelectionCommand.cpp: (WebCore::ReplaceSelectionCommand::doApply):
     326        * editing/visible_units.cpp:
     327        (WebCore::previousBoundary):
     328        (WebCore::nextBoundary):
     329        (WebCore::startWordBoundary):
     330        (WebCore::endWordBoundary):
     331        (WebCore::previousWordPositionBoundary):
     332        (WebCore::nextWordPositionBoundary):
     333        (WebCore::startSentenceBoundary):
     334        (WebCore::endSentenceBoundary):
     335        (WebCore::previousSentencePositionBoundary):
     336        (WebCore::nextSentencePositionBoundary):
     337        (WebCore::startOfParagraph):
     338        (WebCore::endOfParagraph):
     339        * html/HTMLParser.cpp: (WebCore::HTMLParser::handleError):
     340        * rendering/InlineTextBox.cpp:
     341        (WebCore::InlineTextBox::selectionRect):
     342        (WebCore::InlineTextBox::paint):
     343        (WebCore::InlineTextBox::paintSelection):
     344        (WebCore::InlineTextBox::paintMarkedTextBackground):
     345        (WebCore::InlineTextBox::paintTextMatchMarker):
     346        (WebCore::InlineTextBox::offsetForPosition):
     347        (WebCore::InlineTextBox::positionForOffset):
     348        * rendering/RenderBlock.cpp:
     349        (WebCore::stripTrailingSpace):
     350        (WebCore::RenderBlock::updateFirstLetter):
     351        * rendering/RenderFlexibleBox.cpp:
     352        (WebCore::RenderFlexibleBox::layoutVerticalBox):
     353        * rendering/RenderObject.h:
     354        * rendering/RenderObject.cpp:
     355        (WebCore::RenderObject::backslashAsCurrencySymbol):
     356        * rendering/RenderTreeAsText.cpp: (quoteAndEscapeNonPrintables):
     357        * rendering/break_lines.cpp: (WebCore::nextBreakablePosition):
     358        * rendering/break_lines.h: (WebCore::isBreakable):
     359        * rendering/render_style.h: (WebCore::RenderStyle::isCollapsibleWhiteSpace):
     360        * xml/XSLStyleSheet.cpp: (WebCore::XSLStyleSheet::parseString):
     361        * xml/xmlhttprequest.cpp:
     362        (WebCore::getMIMEType):
     363        (WebCore::getCharset):
     364        Changed QChar to UChar.
     365
     366        * rendering/RenderImage.cpp:
     367        (WebCore::RenderImage::imageChanged): Changed QChar to UChar.
     368        (WebCore::RenderImage::paint): Changed callers of drawText to no-longer pass 0
     369        for the horizontal alignment, since I removed that parameters.
     370
     371        * rendering/RenderText.h: Changed QChar to UChar.
     372        * rendering/RenderText.cpp:
     373        (WebCore::characterBreakIterator): Update for name change.
     374        (WebCore::RenderText::RenderText): Ditto.
     375        (WebCore::RenderText::allAscii): Remove uneeded unicode() and allow the value
     376        U+007F to count as ASCII.
     377        (WebCore::RenderText::cacheWidths): Changed QChar to UChar.
     378        (WebCore::RenderText::widthFromCache): Changed code that deals with direction to
     379        use the ICU direction calls.
     380        (WebCore::RenderText::trimmedMinMaxWidth): Changed QChar to UChar.
     381        (WebCore::RenderText::calcMinMaxWidth): Ditto.
     382        (WebCore::RenderText::containsOnlyWhitespace): Ditto.
     383        (WebCore::RenderText::setText): Ditto.
     384        (WebCore::RenderText::width): Ditto.
     385
     386        * rendering/RenderTextField.cpp:
     387        (WebCore::RenderTextField::updateFromElement): Removed unneeded QChar cast.
     388        (WebCore::RenderTextField::calcMinMaxWidth): Changed from QChar to UChar.
     389
     390        * rendering/bidi.h:
     391        * rendering/bidi.cpp:
     392        (WebCore::BidiIterator::BidiIterator):
     393        (WebCore::BidiState::BidiState):
     394        (WebCore::BidiContext::BidiContext):
     395        (WebCore::bidiNext):
     396        (WebCore::bidiFirst):
     397        (WebCore::BidiIterator::current):
     398        (WebCore::BidiIterator::direction):
     399        (WebCore::addRun):
     400        (WebCore::checkMidpoints):
     401        (WebCore::appendRun):
     402        (WebCore::embed):
     403        (WebCore::RenderBlock::tabWidth):
     404        (WebCore::RenderBlock::computeHorizontalPositionsForLine):
     405        (WebCore::RenderBlock::bidiReorderLine):
     406        (WebCore::RenderBlock::layoutInlineChildren):
     407        (WebCore::skipNonBreakingSpace):
     408        (WebCore::RenderBlock::skipWhitespace):
     409        (WebCore::RenderBlock::findNextLineBreak):
     410        (WebCore::RenderBlock::checkLinesForTextOverflow):
     411        Changed from QChar to UChar and all direction from QChar constants to the
     412        ones from ICU.
     413
     414        * rendering/render_form.cpp:
     415        (WebCore::RenderLineEdit::updateFromElement):
     416        (WebCore::RenderSelect::updateFromElement):
     417        (WebCore::RenderTextArea::updateFromElement):
     418        (WebCore::RenderTextArea::text):
     419        (WebCore::RenderTextArea::textWithHardLineBreaks):
     420        Got rid of now-unneeded QChar type casts.
     421
     422        * rendering/render_line.cpp:
     423        (WebCore::InlineFlowBox::placeBoxesHorizontally): Updated for change from QChar
     424        to UChar.
     425        (WebCore::EllipsisBox::paint): Updated for unicode() -> characters() name change.
     426
     427        * rendering/render_list.cpp:
     428        (WebCore::toRoman): Updated from QChar to UChar.
     429        (WebCore::toLetterString): Ditto.
     430        (WebCore::toHebrew): More of the same, also cleaned up the logic a bit.
     431        (WebCore::RenderListMarker::paint): Removed the alignment parameters from the
     432        various functions. Also removed all reliance on the width-measuring functions
     433        that take a string.
     434        (WebCore::RenderListMarker::calcMinMaxWidth): More of the same.
     435        (WebCore::RenderListMarker::getRelativeMarkerRect): Ditto.
     436
    14372006-05-09  Tim Omernick  <timo@apple.com>
    2438
     
    6551091        * css/quirks.css:
    6561092
    657 2006-05-06  Darin Adler  <darin@apple.com>
     10932006-05-07  Darin Adler  <darin@apple.com>
    6581094       
    6591095        Suggested by Mitz. Reviewed and landed by Maciej.
  • trunk/WebCore/bindings/js/JSXMLSerializer.cpp

    r13992 r14273  
    2323#include "JSXMLSerializer.lut.h"
    2424
     25#include "DeprecatedString.h"
    2526#include "PlatformString.h"
    2627#include "kjs_dom.h"
  • trunk/WebCore/bindings/js/kjs_css.cpp

    r14094 r14273  
    4949    int i = prop.length();
    5050    while (--i) {
    51         char c = prop[i].latin1();
     51        ::UChar c = prop[i].unicode();
    5252        if (c >= 'A' && c <= 'Z')
    5353            prop.insert(i, '-');
  • trunk/WebCore/bindings/js/kjs_navigator.cpp

    r13821 r14273  
    159159    return jsString("Mozilla");
    160160  case AppName:
    161     // If we find "Mozilla" but not "(compatible, ...)" we are a real Netscape
    162     if (userAgent.find("Mozilla") >= 0 && userAgent.find("compatible") == -1)
    163       return jsString("Netscape");
    164     if (userAgent.find("Microsoft") >= 0 || userAgent.find("MSIE") >= 0)
    165       return jsString("Microsoft Internet Explorer");
    166     return jsUndefined();
     161    return jsString("Netscape");
    167162  case AppVersion:
    168163    // We assume the string is something like Mozilla/version (properties)
    169164    return jsString(userAgent.substring(userAgent.find('/') + 1));
    170165  case Product:
    171     // When acting normal, we pretend to be "Gecko".
    172     if (userAgent.find("Mozilla/5.0") >= 0 && userAgent.find("compatible") == -1)
    173         return jsString("Gecko");
    174     // When spoofing as IE, we use jsUndefined().
    175     return jsUndefined();
     166    return jsString("Gecko");
    176167  case ProductSub:
    177168    return jsString("20030107");
     
    185176    return jsString(userAgent);
    186177  case Platform:
    187     if (userAgent.find("Win", 0, false) >= 0)
    188       return jsString("Win32");
    189     if (userAgent.find("Macintosh", 0, false) >= 0 || userAgent.find("Mac_PowerPC", 0, false) >= 0)
    190       return jsString("MacPPC");
    191     // FIXME: What about Macintosh Intel?
    192     return jsString("X11");
     178#if __APPLE__
     179    return jsString("MacPPC");
     180#elif WIN32
     181    return jsString("Win32");
     182#else
     183    return jsString("");
     184#endif
    193185  case _Plugins:
    194186    return new Plugins(exec);
  • trunk/WebCore/bindings/js/kjs_proxy.cpp

    r13865 r14273  
    3535namespace WebCore {
    3636
    37 KJSProxy::KJSProxy(Frame *frame)
     37KJSProxy::KJSProxy(Frame* frame)
    3838{
    3939    m_script = 0;
     
    4949}
    5050
    51 JSValue* KJSProxy::evaluate(const String& filename, int baseLine, const String& str, Node *n)
     51JSValue* KJSProxy::evaluate(const String& filename, int baseLine, const String& str, Node* n)
    5252{
    5353  // evaluate code. Returns the JS return value or 0
     
    6666
    6767  JSValue* thisNode = n ? Window::retrieve(m_frame) : toJS(m_script->globalExec(), n);
    68   Completion comp = m_script->evaluate(filename, baseLine, reinterpret_cast<const KJS::UChar *>(str.unicode()), str.length(), thisNode);
     68  Completion comp = m_script->evaluate(filename, baseLine, reinterpret_cast<const KJS::UChar*>(str.characters()), str.length(), thisNode);
    6969
    7070  if (comp.complType() == Normal || comp.complType() == ReturnValue)
     
    9292}
    9393
    94 EventListener* KJSProxy::createHTMLEventHandler(const String& functionName, const String& code, Node *node)
     94EventListener* KJSProxy::createHTMLEventHandler(const String& functionName, const String& code, Node* node)
    9595{
    9696    initScriptIfNeeded();
     
    100100
    101101#if SVG_SUPPORT
    102 EventListener* KJSProxy::createSVGEventHandler(const String& functionName, const String& code, Node *node)
     102EventListener* KJSProxy::createSVGEventHandler(const String& functionName, const String& code, Node* node)
    103103{
    104104    initScriptIfNeeded();
     
    108108#endif
    109109
    110 void KJSProxy::finishedWithEvent(Event *event)
     110void KJSProxy::finishedWithEvent(Event* event)
    111111{
    112112  // This is called when the DOM implementation has finished with a particular event. This
     
    117117}
    118118
    119 ScriptInterpreter *KJSProxy::interpreter()
     119ScriptInterpreter* KJSProxy::interpreter()
    120120{
    121121  initScriptIfNeeded();
     
    128128public:
    129129  virtual bool implementsCall() const { return true; }
    130   virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
     130  virtual JSValue* callAsFunction(ExecState*, JSObject*, const List& args);
    131131};
    132132
    133 JSValue *TestFunctionImp::callAsFunction(ExecState *exec, JSObject */*thisObj*/, const List &args)
     133JSValue *TestFunctionImp::callAsFunction(ExecState* exec, JSObject*, const List& args)
    134134{
    135   fprintf(stderr,"--> %s\n",args[0]->toString(exec).ascii());
     135  fprintf(stderr,"--> %s\n", args[0]->toString(exec).ascii());
    136136  return jsUndefined();
    137137}
  • trunk/WebCore/bindings/js/kjs_window.cpp

    r14094 r14273  
    13791379
    13801380// Though isspace() considers \t and \v to be whitespace, Win IE doesn't.
    1381 static bool isSeparator(QChar c)
     1381static bool isSeparator(UChar c)
    13821382{
    13831383    return c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '=' || c == ',' || c == '\0';
  • trunk/WebCore/bindings/objc/DOMInternal.mm

    r13821 r14273  
    101101StringImpl::operator NSString *() const
    102102{
    103     return [NSString stringWithCharacters:reinterpret_cast<const unichar *>(m_data) length:m_length];
     103    return [NSString stringWithCharacters:m_data length:m_length];
    104104}
    105105
    106 String::String(NSString *str)
     106String::String(NSString* str)
    107107{
    108108    if (!str)
     
    113113        m_impl = StringImpl::empty();
    114114    else {
    115         UniChar fixedSizeBuffer[1024];
    116         UniChar *buffer;
    117         if (size > static_cast<CFIndex>(sizeof(fixedSizeBuffer) / sizeof(UniChar)))
    118             buffer = static_cast<UniChar *>(fastMalloc(size * sizeof(UniChar)));
    119         else
    120             buffer = fixedSizeBuffer;
    121         CFStringGetCharacters(reinterpret_cast<CFStringRef>(str), CFRangeMake(0, size), buffer);
    122         m_impl = new StringImpl(reinterpret_cast<const QChar *>(buffer), (unsigned)size);
    123         if (buffer != fixedSizeBuffer)
    124             fastFree(buffer);
     115        Vector<UChar, 1024> buffer(size);
     116        CFStringGetCharacters(reinterpret_cast<CFStringRef>(str), CFRangeMake(0, size), buffer.data());
     117        m_impl = new StringImpl(buffer.data(), size);
    125118    }
    126119}
  • trunk/WebCore/bridge/mac/FrameMac.mm

    r14185 r14273  
    7979
    8080using namespace std;
    81 
    82 using namespace KJS;
    83 using namespace Bindings;
    84 
     81using namespace KJS::Bindings;
    8582using namespace KIO;
     83
     84using KJS::JSLock;
     85using KJS::PausedTimeouts;
     86using KJS::SavedBuiltins;
     87using KJS::SavedProperties;
    8688
    8789namespace WebCore {
     
    9092using namespace HTMLNames;
    9193
    92 NSEvent *FrameMac::_currentEvent = nil;
     94NSEvent* FrameMac::_currentEvent = nil;
    9395
    9496static NSMutableDictionary* createNSDictionary(const HashMap<String, String>& map)
     
    115117
    116118    SEL selector = NULL;
    117     switch (key[0U].unicode()) {
     119    switch (key[0U]) {
    118120    case NSUpArrowFunctionKey:
    119121        selector = @selector(moveUp:); break;
     
    633635{
    634636    String text = title;
    635     text.replace(QChar('\\'), backslashAsCurrencySymbol());
     637    text.replace('\\', backslashAsCurrencySymbol());
    636638
    637639    BEGIN_BLOCK_OBJC_EXCEPTIONS;
     
    643645{
    644646    String text = status;
    645     text.replace(QChar('\\'), backslashAsCurrencySymbol());
     647    text.replace('\\', backslashAsCurrencySymbol());
    646648   
    647649    BEGIN_BLOCK_OBJC_EXCEPTIONS;
     
    731733    while (1) {
    732734        if (!it.atEnd()) {      // we may be starting at the end of the doc, and already by atEnd
    733             const QChar *chars = it.characters();
     735            const UChar* chars = it.characters();
    734736            int len = it.length();
    735             if (len > 1 || !chars[0].isSpace()) {
    736                 NSString *chunk = [[NSString alloc] initWithCharactersNoCopy:(unichar *)chars length:len freeWhenDone:NO];
     737            if (len > 1 || !QChar(chars[0]).isSpace()) {
     738                NSString *chunk = [[NSString alloc] initWithCharactersNoCopy:const_cast<UChar*>(chars) length:len freeWhenDone:NO];
    737739                NSRange misspelling = [checker checkSpellingOfString:chunk startingAt:0 language:nil wrap:NO inSpellDocumentWithTag:[_bridge spellCheckerDocumentTag] wordCount:NULL];
    738740                [chunk release];
     
    12271229{
    12281230    String text = message;
    1229     text.replace(QChar('\\'), backslashAsCurrencySymbol());
     1231    text.replace('\\', backslashAsCurrencySymbol());
    12301232    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    12311233    [_bridge runJavaScriptAlertPanelWithMessage:text];
     
    12361238{
    12371239    String text = message;
    1238     text.replace(QChar('\\'), backslashAsCurrencySymbol());
     1240    text.replace('\\', backslashAsCurrencySymbol());
    12391241
    12401242    BEGIN_BLOCK_OBJC_EXCEPTIONS;
     
    12481250{
    12491251    String promptText = prompt;
    1250     promptText.replace(QChar('\\'), backslashAsCurrencySymbol());
     1252    promptText.replace('\\', backslashAsCurrencySymbol());
    12511253    String defaultValueText = defaultValue;
    1252     defaultValueText.replace(QChar('\\'), backslashAsCurrencySymbol());
     1254    defaultValueText.replace('\\', backslashAsCurrencySymbol());
    12531255
    12541256    bool ok;
     
    12611263    if (ok) {
    12621264        result = String(returnedText);
    1263         result.replace(backslashAsCurrencySymbol(), QChar('\\'));
     1265        result.replace(backslashAsCurrencySymbol(), '\\');
    12641266    }
    12651267
     
    22842286                        [pendingStyledSpace release];
    22852287                        pendingStyledSpace = nil;
    2286                         addedSpace = str[runEnd-1].direction() == QChar::DirWS;
     2288                        addedSpace = u_charDirection(str[runEnd - 1].unicode()) == U_WHITE_SPACE_NEUTRAL;
    22872289                    }
    22882290                    else {
     
    23192321                                    [pendingStyledSpace release];
    23202322                                    pendingStyledSpace = nil;
    2321                                     addedSpace = str[runEnd-1].direction() == QChar::DirWS;
     2323                                    addedSpace = u_charDirection(str[runEnd - 1].unicode()) == U_WHITE_SPACE_NEUTRAL;
    23222324                                    start = -1;
    23232325                                }
     
    23292331                }
    23302332               
    2331                 text.replace(QChar('\\'), renderer->backslashAsCurrencySymbol());
     2333                text.replace('\\', renderer->backslashAsCurrencySymbol());
    23322334   
    23332335                if (text.length() > 0 || needSpace) {
     
    31063108   
    31073109    while (!it.atEnd()) {      // we may be starting at the end of the doc, and already by atEnd
    3108         const QChar *chars = it.characters();
     3110        const UChar* chars = it.characters();
    31093111        int len = it.length();
    3110         if (len > 1 || !chars[0].isSpace()) {
    3111             NSString *chunk = [[NSString alloc] initWithCharactersNoCopy:(unichar *)chars length:len freeWhenDone:NO];
     3112        if (len > 1 || !QChar(chars[0]).isSpace()) {
     3113            NSString *chunk = [[NSString alloc] initWithCharactersNoCopy:const_cast<UChar*>(chars) length:len freeWhenDone:NO];
    31123114            int startIndex = 0;
    31133115            // Loop over the chunk to find each misspelling in it.
     
    34033405
    34043406    String text = event->result();
    3405     text.replace(QChar('\\'), backslashAsCurrencySymbol());
     3407    text.replace('\\', backslashAsCurrencySymbol());
    34063408
    34073409    return [_bridge runBeforeUnloadConfirmPanelWithMessage:text];
  • trunk/WebCore/bridge/mac/WebCoreFrameBridge.mm

    r14258 r14273  
    752752{
    753753    String text = m_frame->selectedText();
    754     text.replace(QChar('\\'), m_frame->backslashAsCurrencySymbol());
     754    text.replace('\\', m_frame->backslashAsCurrencySymbol());
    755755    return [[(NSString*)text copy] autorelease];
    756756}
     
    759759{
    760760    String text = plainText([range _range]);
    761     text.replace(QChar('\\'), m_frame->backslashAsCurrencySymbol());
     761    text.replace('\\', m_frame->backslashAsCurrencySymbol());
    762762    return [[(NSString*)text copy] autorelease];
    763763}
  • trunk/WebCore/css/CSSGrammar.y

    r13874 r14273  
    5656namespace WebCore {
    5757
    58 int getPropertyID(const char *tagStr, int len)
     58int getPropertyID(const char* tagStr, int len)
    5959{
    6060    DeprecatedString prop;
     
    7979        }
    8080    }
    81    
    82     const struct props *propsPtr = findProp(tagStr, len);
     81
     82    const struct props* propsPtr = findProp(tagStr, len);
    8383    if (!propsPtr)
    8484        return 0;
     
    8989}
    9090
    91 static inline int getValueID(const char *tagStr, int len)
     91static inline int getValueID(const char* tagStr, int len)
    9292{
    9393    DeprecatedString prop;
     
    370370
    371371maybe_ns_prefix:
    372 /* empty */ { $$.string = 0; }
     372/* empty */ { $$.characters = 0; }
    373373| IDENT WHITESPACE { $$ = $1; }
    374374;
     
    390390    medium {
    391391        $$ = static_cast<CSSParser*>(parser)->createMediaList();
    392         $$->appendMedium( domString($1).lower() );
     392        $$->appendMedium(domString($1).lower());
    393393    }
    394394    | media_list ',' maybe_space medium {
    395395        $$ = $1;
    396396        if ($$)
    397             $$->appendMedium( domString($4) );
     397            $$->appendMedium(domString($4).lower());
    398398    }
    399399    | media_list error {
     
    530530
    531531namespace_selector:
    532     /* empty */ '|' { $$.string = 0; $$.length = 0; }
    533     | '*' '|' { static unsigned short star = '*'; $$.string = &star; $$.length = 1; }
     532    /* empty */ '|' { $$.characters = 0; $$.length = 0; }
     533    | '*' '|' { static UChar star = '*'; $$.characters = &star; $$.length = 1; }
    534534    | IDENT '|' { $$ = $1; }
    535535;
     
    601601    }
    602602    | '*' {
    603         static unsigned short star = '*';
    604         $$.string = &star;
     603        static UChar star = '*';
     604        $$.characters = &star;
    605605        $$.length = 1;
    606606    }
     
    842842property:
    843843    IDENT maybe_space {
     844        $1.lower();
    844845        DeprecatedString str = deprecatedString($1);
    845         $$ = getPropertyID(str.lower().latin1(), str.length());
     846        const char* s = str.ascii();
     847        int l = str.length();
     848        $$ = getPropertyID(s, l);
    846849#if SVG_SUPPORT
    847       if ($$ == 0)
    848           $$ = SVG::getSVGCSSPropertyID(str.lower().latin1(), str.length());
     850        if ($$ == 0)
     851            $$ = SVG::getSVGCSSPropertyID(s, l);
    849852#endif
    850853    }
  • trunk/WebCore/css/css_valueimpl.cpp

    r14008 r14273  
    4747
    4848// Defined in CSSGrammar.y, but not in any header, so just declare it here for now.
    49 int getPropertyID(const char *str, int len);
    50 
    51 static int propertyID(const String &s)
     49int getPropertyID(const char* str, int len);
     50
     51static int propertyID(const String& s)
    5252{
    5353    char buffer[maxCSSPropertyNameLength];
     
    5858
    5959    for (unsigned i = 0; i != len; ++i) {
    60         unsigned short c = s[i].unicode();
     60        UChar c = s[i];
    6161        if (c == 0 || c >= 0x7F)
    6262            return 0; // illegal character
     
    8686    s.replace('\\', "\\\\");
    8787    s.replace('\'', "\\'");
    88     return '\'' + s + '\'';
     88    return "'" + s + "'";
    8989}
    9090
  • trunk/WebCore/css/css_valueimpl.h

    r14256 r14273  
    2727#include "css_base.h"
    2828#include "DeprecatedPtrList.h"
     29#include "DeprecatedString.h"
    2930#include "DeprecatedValueList.h"
    3031#include <wtf/PassRefPtr.h>
  • trunk/WebCore/css/csshelper.cpp

    r14256 r14273  
    3939    int l = i->length();
    4040
    41     while (o < l && (*i)[o].unicode() <= ' ') {
     41    while (o < l && (*i)[o] <= ' ') {
    4242        ++o;
    4343        --l;
    4444    }
    45     while (l > 0 && (*i)[o+l-1].unicode() <= ' ')
     45    while (l > 0 && (*i)[o+l-1] <= ' ')
    4646        --l;
    4747
    4848    if (l >= 5
    49             && (*i)[o].lower() == 'u'
    50             && (*i)[o + 1].lower() == 'r'
    51             && (*i)[o + 2].lower() == 'l'
     49            && ((*i)[o] == 'u' || (*i)[o] == 'U')
     50            && ((*i)[o + 1] == 'r' || (*i)[o + 1] == 'R')
     51            && ((*i)[o + 2] == 'l' || (*i)[o + 2] == 'L')
    5252            && (*i)[o + 3] == '('
    5353            && (*i)[o + l - 1] == ')') {
     
    5656    }
    5757
    58     while (o < l && (*i)[o].unicode() <= ' ') {
     58    while (o < l && (*i)[o] <= ' ') {
    5959        ++o;
    6060        --l;
    6161    }
    62     while (l > 0 && (*i)[o+l-1].unicode() <= ' ')
     62    while (l > 0 && (*i)[o+l-1] <= ' ')
    6363        --l;
    6464
     
    6868    }
    6969
    70     while (o < l && (*i)[o].unicode() <= ' ') {
     70    while (o < l && (*i)[o] <= ' ') {
    7171        ++o;
    7272        --l;
    7373    }
    74     while (l > 0 && (*i)[o+l-1].unicode() <= ' ')
     74    while (l > 0 && (*i)[o+l-1] <= ' ')
    7575        --l;
    7676
    77     Vector<unsigned short, 2048> buffer(l);
     77    Vector<UChar, 2048> buffer(l);
    7878
    7979    int nl = 0;
    8080    for (int k = o; k < o + l; k++) {
    81         unsigned short c = (*i)[k].unicode();
     81        UChar c = (*i)[k];
    8282        if (c > '\r')
    8383            buffer[nl++] = c;
    8484    }
    8585
    86     return new StringImpl(reinterpret_cast<QChar*>(buffer.data()), nl);
     86    return new StringImpl(buffer.data(), nl);
    8787}
    8888
  • trunk/WebCore/css/cssparser.cpp

    r14008 r14273  
    117117void ParseString::lower()
    118118{
     119    // Fast case for all-ASCII.
     120    UChar ored = 0;
    119121    for (int i = 0; i < length; i++)
    120         string[i] = QChar(string[i]).lower().unicode();
     122        ored |= characters[i];
     123    if (ored & ~0x7F)
     124        for (int i = 0; i < length; i++)
     125            characters[i] = u_tolower(characters[i]);
     126    else
     127        for (int i = 0; i < length; i++)
     128            characters[i] = tolower(characters[i]);
    121129}
    122130
     
    125133    int length = string.length() + strlen(prefix) + strlen(suffix) + 2;
    126134   
    127     data = (unsigned short*)fastMalloc(length * sizeof(unsigned short));
     135    data = static_cast<UChar*>(fastMalloc(length * sizeof(UChar)));
    128136    for (unsigned i = 0; i < strlen(prefix); i++)
    129137        data[i] = prefix[i];
    130138   
    131     memcpy(data + strlen(prefix), string.unicode(), string.length() * sizeof(unsigned short));
     139    memcpy(data + strlen(prefix), string.characters(), string.length() * sizeof(UChar));
    132140
    133141    unsigned start = strlen(prefix) + string.length();
     
    25712579#include "CSSGrammar.h"
    25722580
    2573 int CSSParser::lex(void *_yylval) {
    2574     YYSTYPE *yylval = (YYSTYPE *)_yylval;
     2581int CSSParser::lex(void* yylvalWithoutType)
     2582{
     2583    YYSTYPE* yylval = static_cast<YYSTYPE*>(yylvalWithoutType);
    25752584    int token = lex();
    25762585    int length;
    2577     unsigned short *t = text(&length);
     2586    UChar* t = text(&length);
    25782587
    25792588#ifdef TOKEN_DEBUG
     
    25942603    case UNICODERANGE:
    25952604    case FUNCTION:
    2596         yylval->string.string = t;
     2605        yylval->string.characters = t;
    25972606        yylval->string.length = length;
    25982607        break;
     
    26522661}
    26532662
    2654 unsigned short *CSSParser::text(int *length)
    2655 {
    2656     unsigned short *start = yytext;
     2663UChar* CSSParser::text(int *length)
     2664{
     2665    UChar* start = yytext;
    26572666    int l = yyleng;
    26582667    switch(yyTok) {
     
    26932702
    26942703    // process escapes
    2695     unsigned short *out = start;
    2696     unsigned short *escape = 0;
     2704    UChar* out = start;
     2705    UChar* escape = 0;
    26972706
    26982707    for (int i = 0; i < l; i++) {
    2699         unsigned short *current = start+i;
     2708        UChar* current = start + i;
    27002709        if (escape == current - 1) {
    27012710            if ((*current >= '0' && *current <= '9') ||
     
    27282737        if (escape) {
    27292738            // add escaped char
    2730             int uc = 0;
     2739            unsigned uc = 0;
    27312740            escape++;
    27322741            while (escape < current) {
     
    27382747            if (uc > 0xffff)
    27392748                uc = 0xfffd;
    2740             *(out++) = (unsigned short)uc;
     2749            *out++ = uc;
    27412750            escape = 0;
    27422751            if (*current == ' ' ||
     
    27512760            continue;
    27522761        }
    2753         *(out++) = *current;
     2762        *out++ = *current;
    27542763    }
    27552764    if (escape) {
    27562765        // add escaped char
    2757         int uc = 0;
     2766        unsigned uc = 0;
    27582767        escape++;
    27592768        while (escape < start+l) {
     
    27652774        if (uc > 0xffff)
    27662775            uc = 0xfffd;
    2767         *(out++) = (unsigned short)uc;
     2776        *out++ = uc;
    27682777    }
    27692778   
     
    28822891    clearProperties();
    28832892    return rule;
     2893}
     2894
     2895DeprecatedString deprecatedString(const ParseString& ps)
     2896{
     2897    return DeprecatedString(reinterpret_cast<const QChar*>(ps.characters), ps.length);
    28842898}
    28852899
  • trunk/WebCore/css/cssparser.h

    r14256 r14273  
    4646
    4747    struct ParseString {
    48         unsigned short* string;
     48        UChar* characters;
    4949        int length;
    5050       
     
    7070    };
    7171
    72     static inline DeprecatedString deprecatedString(const ParseString& ps) {
    73         return DeprecatedString((QChar *)ps.string, ps.length);
    74     }
     72    DeprecatedString deprecatedString(const ParseString&);
    7573    static inline String domString(const ParseString& ps) {
    76         return String((QChar *)ps.string, ps.length);
     74        return String(ps.characters, ps.length);
    7775    }
    7876    static inline AtomicString atomicString(const ParseString& ps) {
    79         return AtomicString(ps.string, ps.length);
     77        return AtomicString(ps.characters, ps.length);
    8078    }
    8179
     
    202200        int lex(void* yylval);
    203201        int token() { return yyTok; }
    204         unsigned short* text(int* length);
     202        UChar* text(int* length);
    205203        int lex();
    206204       
     
    212210        bool inShorthand() const { return m_inParseShorthand; }
    213211
    214         unsigned short* data;
    215         unsigned short* yytext;
    216         unsigned short* yy_c_buf_p;
    217         unsigned short yy_hold_char;
     212        UChar* data;
     213        UChar* yytext;
     214        UChar* yy_c_buf_p;
     215        UChar yy_hold_char;
    218216        int yy_last_accepting_state;
    219         unsigned short* yy_last_accepting_cpos;
     217        UChar* yy_last_accepting_cpos;
    220218        int yyleng;
    221219        int yyTok;
  • trunk/WebCore/css/cssstyleselector.cpp

    r14261 r14273  
    557557    }
    558558   
    559     QConstString cu(attr.unicode(), attr.length());
     559    QConstString cu(reinterpret_cast<const QChar*>(attr.characters()), attr.length());
    560560    DeprecatedString u = cu.string();
    561561    if (!u.contains("://")) {
  • trunk/WebCore/dom/CharacterData.cpp

    r13973 r14273  
    4545    : EventTargetNode(doc)
    4646{
    47     str = _text.impl() ? _text.impl() : new StringImpl((QChar*)0, 0);
     47    str = _text.impl() ? _text.impl() : new StringImpl(static_cast<UChar*>(0), 0);
    4848    str->ref();
    4949}
  • trunk/WebCore/dom/Document.cpp

    r14234 r14273  
    23932393bool Document::isValidName(const String &name)
    23942394{
    2395     const UChar *s = reinterpret_cast<const UChar *>(name.unicode());
     2395    const UChar* s = reinterpret_cast<const UChar*>(name.characters());
    23962396    unsigned length = name.length();
    23972397
     
    24262426    int colonPos = 0;
    24272427
    2428     const UChar* s = reinterpret_cast<const UChar*>(qualifiedName.unicode());
     2428    const UChar* s = reinterpret_cast<const UChar*>(qualifiedName.characters());
    24292429    for (unsigned i = 0; i < length;) {
    24302430        UChar32 c;
     
    24902490}
    24912491
    2492 QChar Document::backslashAsCurrencySymbol() const
     2492UChar Document::backslashAsCurrencySymbol() const
    24932493{
    24942494    if (!m_decoder)
     
    30993099
    31003100#if XPATH_SUPPORT
     3101
    31013102PassRefPtr<XPathExpression> Document::createExpression(const String& expression,
    31023103                                                       XPathNSResolver* resolver,
     
    31053106    if (!m_xpathEvaluator)
    31063107        m_xpathEvaluator = new XPathEvaluator;
    3107    
    31083108    return m_xpathEvaluator->createExpression(expression, resolver, ec);
    31093109}
    31103110
    3111 PassRefPtr<XPathNSResolver> Document::createNSResolver(Node *nodeResolver)
     3111PassRefPtr<XPathNSResolver> Document::createNSResolver(Node* nodeResolver)
    31123112{
    31133113    if (!m_xpathEvaluator)
    31143114        m_xpathEvaluator = new XPathEvaluator;
    3115    
    31163115    return m_xpathEvaluator->createNSResolver(nodeResolver);
    31173116}
     
    31263125    if (!m_xpathEvaluator)
    31273126        m_xpathEvaluator = new XPathEvaluator;
    3128    
    31293127    return m_xpathEvaluator->evaluate(expression, contextNode, resolver, type, result, ec);
    31303128}
  • trunk/WebCore/dom/Document.h

    r14256 r14273  
    706706    Decoder* decoder() const { return m_decoder.get(); }
    707707
    708     QChar backslashAsCurrencySymbol() const;
     708    UChar backslashAsCurrencySymbol() const;
    709709
    710710#if __APPLE__
  • trunk/WebCore/dom/NamedMappedAttrMap.cpp

    r13547 r14273  
    7777}
    7878
    79 inline static bool isClassWhitespace(QChar c)
     79inline static bool isClassWhitespace(UChar c)
    8080{
    8181    return c == ' ' || c == '\r' || c == '\n' || c == '\t';
     
    9494    AtomicStringList* curr = 0;
    9595   
    96     const QChar* str = classAttr.unicode();
     96    const UChar* str = classAttr.characters();
    9797    int length = classAttr.length();
    9898    int sPos = 0;
  • trunk/WebCore/dom/Position.cpp

    r14172 r14273  
    4040
    4141using namespace HTMLNames;
     42
     43const UChar nonBreakingSpace = 0xa0;
    4244
    4345static Node *nextRenderedEditable(Node *node)
     
    627629    if (prev != *this && prev.node()->inSameContainingBlockFlowElement(node()) && prev.node()->isTextNode()) {
    628630        String string = static_cast<Text *>(prev.node())->data();
    629         const QChar &c = string[prev.offset()];
    630         if (considerNonCollapsibleWhitespace ? (c.isSpace() || c.unicode() == 0xa0) : isCollapsibleWhitespace(c))
     631        UChar c = string[prev.offset()];
     632        if (considerNonCollapsibleWhitespace ? (QChar(c).isSpace() || c == nonBreakingSpace) : isCollapsibleWhitespace(c))
    631633            return prev;
    632634    }
     
    641643
    642644    if (node()->isTextNode()) {
    643         Text *textNode = static_cast<Text *>(node());
     645        Text* textNode = static_cast<Text*>(node());
    644646        if (offset() < (int)textNode->length()) {
    645             String string = static_cast<Text *>(node())->data();
    646             const QChar &c = string[offset()];
    647             if (considerNonCollapsibleWhitespace ? (c.isSpace() || c.unicode() == 0xa0) : isCollapsibleWhitespace(c))
     647            String string = textNode->data();
     648            UChar c = string[offset()];
     649            if (considerNonCollapsibleWhitespace ? (QChar(c).isSpace() || c == nonBreakingSpace) : isCollapsibleWhitespace(c))
    648650                return *this;
    649651            return Position();
     
    656658    Position next = nextCharacterPosition(affinity);
    657659    if (next != *this && next.node()->inSameContainingBlockFlowElement(node()) && next.node()->isTextNode()) {
    658         String string = static_cast<Text *>(next.node())->data();
    659         const QChar &c = string[0];
    660         if (considerNonCollapsibleWhitespace ? (c.isSpace() || c.unicode() == 0xa0) : isCollapsibleWhitespace(c))
     660        String string = static_cast<Text*>(next.node())->data();
     661        UChar c = string[0];
     662        if (considerNonCollapsibleWhitespace ? (QChar(c).isSpace() || c == nonBreakingSpace) : isCollapsibleWhitespace(c))
    661663            return next;
    662664    }
  • trunk/WebCore/dom/StyledElement.cpp

    r14256 r14273  
    102102}
    103103
    104 inline static bool isClassWhitespace(QChar c)
     104inline static bool isClassWhitespace(UChar c)
    105105{
    106106    return c == ' ' || c == '\r' || c == '\n' || c == '\t';
     
    296296        unsigned int l = 0;
    297297       
    298         while (l < v->length() && (*v)[l].unicode() <= ' ')
     298        while (l < v->length() && (*v)[l] <= ' ')
    299299            l++;
    300300       
    301301        for (; l < v->length(); l++) {
    302             char cc = (*v)[l].latin1();
     302            UChar cc = (*v)[l];
    303303            if (cc > '9' || (cc < '0' && cc != '*' && cc != '%' && cc != '.'))
    304304                break;
     
    359359                int numDigits = 0;
    360360                while (pos < (int)color.length() && numDigits < basicLength) {
    361                     int hex = toHex(color[pos].unicode());
     361                    int hex = toHex(color[pos]);
    362362                    colors[component] = (colors[component] << 4);
    363363                    if (hex > 0) {
  • trunk/WebCore/dom/dom2_eventsimpl.cpp

    r13821 r14273  
    514514    if (text.length() != 1)
    515515        return 0;
    516     return text[0].unicode();
     516    return text[0];
    517517}
    518518
  • trunk/WebCore/dom/xml_tokenizer.h

    r14256 r14273  
    6363Tokenizer* newXMLTokenizer(Document*, FrameView* = 0);
    6464#if KHTML_XSLT
    65 void* xmlDocPtrForString(const DeprecatedString& source, const DeprecatedString& URL = DeprecatedString());
     65void* xmlDocPtrForString(const DeprecatedString& source, const DeprecatedString& URL);
    6666void setLoaderForLibXMLCallbacks(DocLoader*);
    6767#endif
  • trunk/WebCore/editing/HTMLInterchange.cpp

    r13821 r14273  
    6262    while (i < in.length()) {
    6363        consumed = 1;
    64         if (isCollapsibleWhitespace(in[i])) {
     64        if (isCollapsibleWhitespace(in[i].unicode())) {
    6565            // count number of adjoining spaces
    6666            unsigned int j = i + 1;
    67             while (j < in.length() && isCollapsibleWhitespace(in[j]))
     67            while (j < in.length() && isCollapsibleWhitespace(in[j].unicode()))
    6868                j++;
    6969            unsigned int count = j - i;
  • trunk/WebCore/editing/InsertTextCommand.cpp

    r13821 r14273  
    7979
    8080    return pos;
    81 }
    82 
    83 static inline bool isNBSP(const QChar &c)
    84 {
    85     return c.unicode() == 0xa0;
    8681}
    8782
  • trunk/WebCore/editing/RebalanceWhitespaceCommand.cpp

    r14256 r14273  
    3939}
    4040
    41 static inline bool isWhitespace(const QChar &c)
     41static inline bool isWhitespace(UChar c)
    4242{
    43     return c.unicode() == 0xa0 || isCollapsibleWhitespace(c);
     43    return c == 0xa0 || isCollapsibleWhitespace(c);
    4444}
    4545
  • trunk/WebCore/editing/ReplaceSelectionCommand.cpp

    r14212 r14273  
    620620        addLeadingSpace = startPos.leadingWhitespacePosition(VP_DEFAULT_AFFINITY, true).isNull() && !isStartOfParagraph(visiblePos);
    621621        if (addLeadingSpace) {
    622             QChar previousChar = visiblePos.previous().characterAfter();
    623             if (previousChar.unicode())
     622            UChar previousChar = visiblePos.previous().characterAfter();
     623            if (previousChar)
    624624                addLeadingSpace = !frame->isCharacterSmartReplaceExempt(previousChar, true);
    625625        }
    626626        addTrailingSpace = startPos.trailingWhitespacePosition(VP_DEFAULT_AFFINITY, true).isNull() && !isEndOfParagraph(visiblePos);
    627627        if (addTrailingSpace) {
    628             QChar thisChar = visiblePos.characterAfter();
    629             if (thisChar.unicode())
     628            UChar thisChar = visiblePos.characterAfter();
     629            if (thisChar)
    630630                addTrailingSpace = !frame->isCharacterSmartReplaceExempt(thisChar, false);
    631631        }
  • trunk/WebCore/editing/TextIterator.cpp

    r14248 r14273  
    4444using namespace HTMLNames;
    4545
    46 const unsigned short nonBreakingSpace = 0xA0;
     46const UChar nonBreakingSpace = 0xA0;
    4747
    4848// Buffer that knows how to compare with a search target.
     
    5555
    5656    void clear() { m_cursor = m_buffer; m_bufferFull = false; }
    57     void append(int length, const QChar *characters);
    58     void append(const QChar&);
     57    void append(int length, const UChar* characters);
     58    void append(UChar);
    5959
    6060    int neededCharacters() const;
     
    6666    bool m_isCaseSensitive;
    6767
    68     QChar *m_buffer;
    69     QChar *m_cursor;
     68    UChar* m_buffer;
     69    UChar* m_cursor;
    7070    bool m_bufferFull;
    7171
     
    7474};
    7575
    76 TextIterator::TextIterator() : m_endContainer(0), m_endOffset(0), m_positionNode(0)
     76TextIterator::TextIterator() : m_endContainer(0), m_endOffset(0), m_positionNode(0), m_lastCharacter(0)
    7777{
    7878}
     
    230230        m_positionStartOffset = runStart;
    231231        m_positionEndOffset = runEnd;
    232         m_textCharacters = str.unicode() + runStart;
     232        m_textCharacters = str.characters() + runStart;
    233233        m_textLength = runEnd - runStart;
    234234
     
    272272        bool needSpace = m_lastTextNodeEndedWithCollapsedSpace
    273273            || (m_textBox == firstTextBox && textBoxStart == runStart && runStart > 0);
    274         if (needSpace && !isCollapsibleWhitespace(m_lastCharacter) && m_lastCharacter.unicode()) {
     274        if (needSpace && !isCollapsibleWhitespace(m_lastCharacter) && m_lastCharacter) {
    275275            emitCharacter(' ', m_node, 0, runStart, runStart);
    276276            return;
     
    305305                m_positionStartOffset = runStart;
    306306                m_positionEndOffset = subrunEnd;
    307                 m_textCharacters = str.unicode() + runStart;
     307                m_textCharacters = str.characters() + runStart;
    308308                m_textLength = subrunEnd - runStart;
    309309
     
    506506}
    507507
    508 void TextIterator::emitCharacter(QChar c, Node *textNode, Node *offsetBaseNode, int textStartOffset, int textEndOffset)
     508void TextIterator::emitCharacter(UChar c, Node *textNode, Node *offsetBaseNode, int textStartOffset, int textEndOffset)
    509509{
    510510    // remember information with which to construct the TextIterator::range()
     
    690690    m_positionStartOffset = m_offset;
    691691    m_textLength = m_positionEndOffset - m_positionStartOffset;
    692     m_textCharacters = str.unicode() + m_positionStartOffset;
     692    m_textCharacters = str.characters() + m_positionStartOffset;
    693693
    694694    m_lastCharacter = str[m_positionEndOffset - 1];
     
    735735}
    736736
    737 void SimplifiedBackwardsTextIterator::emitCharacter(QChar c, Node *node, int startOffset, int endOffset)
     737void SimplifiedBackwardsTextIterator::emitCharacter(UChar c, Node *node, int startOffset, int endOffset)
    738738{
    739739    m_singleCharacterBuffer = c;
     
    844844    while (numChars > 0 && !atEnd()) {
    845845        int runSize = min(numChars, length());
    846         result.append(characters(), runSize);
     846        result.append(reinterpret_cast<const QChar*>(characters()), runSize);
    847847        numChars -= runSize;
    848848        advance(runSize);
     
    895895    while (1) {
    896896        // If this chunk ends in whitespace we can just use it as our chunk.
    897         if (m_textIterator.characters()[m_textIterator.length()-1].isSpace())
     897        if (QChar(m_textIterator.characters()[m_textIterator.length() - 1]).isSpace())
    898898            return;
    899899
     
    906906        // Look ahead to next chunk.  If it is whitespace or a break, we can use the previous stuff
    907907        m_textIterator.advance();
    908         if (m_textIterator.atEnd() || m_textIterator.length() == 0 || m_textIterator.characters()[0].isSpace()) {
     908        if (m_textIterator.atEnd() || m_textIterator.length() == 0 || QChar(m_textIterator.characters()[0]).isSpace()) {
    909909            m_didLookAhead = true;
    910910            return;
     
    913913        if (m_buffer.isEmpty()) {
    914914            // Start gobbling chunks until we get to a suitable stopping point
    915             m_buffer.append(m_previousText, m_previousLength);
     915            m_buffer.append(reinterpret_cast<const QChar*>(m_previousText), m_previousLength);
    916916            m_previousText = 0;
    917917        }
    918         m_buffer.append(m_textIterator.characters(), m_textIterator.length());
     918        m_buffer.append(reinterpret_cast<const QChar*>(m_textIterator.characters()), m_textIterator.length());
    919919        int exception = 0;
    920920        m_range->setEnd(m_textIterator.range()->endContainer(exception), m_textIterator.range()->endOffset(exception), exception);
     
    926926    if (!m_buffer.isEmpty())
    927927        return m_buffer.length();
    928     else if (m_previousText)
     928    if (m_previousText)
    929929        return m_previousLength;
    930     else
    931         return m_textIterator.length();
    932 }
    933 
    934 const QChar *WordAwareIterator::characters() const
     930    return m_textIterator.length();
     931}
     932
     933const UChar* WordAwareIterator::characters() const
    935934{
    936935    if (!m_buffer.isEmpty())
    937         return m_buffer.unicode();
    938     else if (m_previousText)
     936        return reinterpret_cast<const UChar*>(m_buffer.unicode());
     937    if (m_previousText)
    939938        return m_previousText;
    940     else
    941         return m_textIterator.characters();
     939    return m_textIterator.characters();
    942940}
    943941
     
    948946
    949947    if (!isCaseSensitive)
    950         m_target = s.lower();
     948        m_target = s.foldCase();
    951949    m_target.replace(nonBreakingSpace, ' ');
    952950    m_isCaseSensitive = isCaseSensitive;
    953951
    954     m_buffer = static_cast<QChar *>(fastMalloc(s.length() * sizeof(QChar)));
     952    m_buffer = static_cast<UChar*>(fastMalloc(s.length() * sizeof(UChar)));
    955953    m_cursor = m_buffer;
    956954    m_bufferFull = false;
    957955}
    958956
    959 void CircularSearchBuffer::append(const QChar &c)
     957void CircularSearchBuffer::append(UChar c)
    960958{
    961959    if (m_isCaseSensitive)
    962         *m_cursor++ = c.unicode() == nonBreakingSpace ? ' ' : c.unicode();
     960        *m_cursor++ = c == nonBreakingSpace ? ' ' : c;
    963961    else
    964         *m_cursor++ = c.unicode() == nonBreakingSpace ? ' ' : c.lower().unicode();
     962        *m_cursor++ = c == nonBreakingSpace ? ' ' : u_foldCase(c, U_FOLD_CASE_DEFAULT);
    965963    if (m_cursor == m_buffer + length()) {
    966964        m_cursor = m_buffer;
     
    972970// and when then count is small enough to fit in the buffer.
    973971// No need for a more general version for the search algorithm.
    974 void CircularSearchBuffer::append(int count, const QChar *characters)
     972void CircularSearchBuffer::append(int count, const UChar* characters)
    975973{
    976974    int tailSpace = m_buffer + length() - m_cursor;
     
    981979    if (m_isCaseSensitive) {
    982980        for (int i = 0; i != count; ++i) {
    983             QChar c = characters[i];
    984             m_cursor[i] = c.unicode() == nonBreakingSpace ? ' ' : c.unicode();
     981            UChar c = characters[i];
     982            m_cursor[i] = c == nonBreakingSpace ? ' ' : c;
    985983        }
    986984    } else {
    987985        for (int i = 0; i != count; ++i) {
    988             QChar c = characters[i];
    989             m_cursor[i] = c.unicode() == nonBreakingSpace ? ' ' : c.lower().unicode();
     986            UChar c = characters[i];
     987            m_cursor[i] = c == nonBreakingSpace ? ' ' : u_foldCase(c, U_FOLD_CASE_DEFAULT);
    990988        }
    991989    }
     
    10091007    int headSpace = m_cursor - m_buffer;
    10101008    int tailSpace = length() - headSpace;
    1011     return memcmp(m_cursor, m_target.unicode(), tailSpace * sizeof(QChar)) == 0
    1012         && memcmp(m_buffer, m_target.unicode() + tailSpace, headSpace * sizeof(QChar)) == 0;
     1009    return memcmp(m_cursor, m_target.characters(), tailSpace * sizeof(UChar)) == 0
     1010        && memcmp(m_buffer, m_target.characters() + tailSpace, headSpace * sizeof(UChar)) == 0;
    10131011}
    10141012
     
    10951093}
    10961094
    1097 DeprecatedString plainText(const Range *r)
     1095DeprecatedString plainText(const Range* r)
    10981096{
    10991097    DeprecatedString result("");
    1100     for (TextIterator it(r); !it.atEnd(); it.advance()) {
    1101         result.append(it.characters(), it.length());
    1102     }
     1098    for (TextIterator it(r); !it.atEnd(); it.advance())
     1099        result.append(reinterpret_cast<const QChar*>(it.characters()), it.length());
    11031100    return result;
    11041101}
  • trunk/WebCore/editing/TextIterator.h

    r14256 r14273  
    11/*
    2  * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
     2 * Copyright (C) 2004, 2006 Apple Computer, Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3636// FIXME: Move this along with the white-space position functions above
    3737// somewhere else in the editing directory. It doesn't belong here.
    38 inline bool isCollapsibleWhitespace(const QChar& c)
     38inline bool isCollapsibleWhitespace(UChar c)
    3939{
    40     switch (c.unicode()) {
     40    switch (c) {
    4141        case ' ':
    4242        case '\n':
     
    6666   
    6767    int length() const { return m_textLength; }
    68     const QChar *characters() const { return m_textCharacters; }
     68    const UChar* characters() const { return m_textCharacters; }
    6969   
    7070    PassRefPtr<Range> range() const;
     
    7979    bool handleNonTextNode();
    8080    void handleTextBox();
    81     void emitCharacter(QChar, Node *textNode, Node *offsetBaseNode, int textStartOffset, int textEndOffset);
     81    void emitCharacter(UChar, Node *textNode, Node *offsetBaseNode, int textStartOffset, int textEndOffset);
    8282   
    8383    // Current position, not necessarily of the text being returned, but position
     
    9898    mutable int m_positionStartOffset;
    9999    mutable int m_positionEndOffset;
    100     const QChar *m_textCharacters;
     100    const UChar* m_textCharacters;
    101101    int m_textLength;
    102102   
     
    109109    Node *m_lastTextNode;   
    110110    bool m_lastTextNodeEndedWithCollapsedSpace;
    111     QChar m_lastCharacter;
     111    UChar m_lastCharacter;
    112112   
    113113    // Used for whitespace characters that aren't in the DOM, so we can point at them.
    114     QChar m_singleCharacterBuffer;
     114    UChar m_singleCharacterBuffer;
    115115   
    116116    // Used when text boxes are out of order (Hebrew/Arabic w/ embeded LTR text)
     
    132132   
    133133    int length() const { return m_textLength; }
    134     const QChar *characters() const { return m_textCharacters; }
     134    const UChar* characters() const { return m_textCharacters; }
    135135   
    136136    PassRefPtr<Range> range() const;
     
    141141    bool handleReplacedElement();
    142142    bool handleNonTextNode();
    143     void emitCharacter(QChar, Node *Node, int startOffset, int endOffset);
     143    void emitCharacter(UChar, Node *Node, int startOffset, int endOffset);
    144144    void emitNewline();
    145145   
    146146    // Current position, not necessarily of the text being returned, but position
    147147    // as we walk through the DOM tree.
    148     Node *m_node;
     148    Node* m_node;
    149149    int m_offset;
    150150    bool m_handledNode;
     
    152152   
    153153    // End of the range.
    154     Node *m_startNode;
     154    Node* m_startNode;
    155155    int m_startOffset;
    156156   
    157157    // The current text and its position, in the form to be returned from the iterator.
    158     Node *m_positionNode;
     158    Node* m_positionNode;
    159159    int m_positionStartOffset;
    160160    int m_positionEndOffset;
    161     const QChar *m_textCharacters;
     161    const UChar* m_textCharacters;
    162162    int m_textLength;
    163163
    164164    // Used to do the whitespace logic.
    165     Node *m_lastTextNode;   
    166     QChar m_lastCharacter;
     165    Node* m_lastTextNode;   
     166    UChar m_lastCharacter;
    167167   
    168168    // Used for whitespace characters that aren't in the DOM, so we can point at them.
    169     QChar m_singleCharacterBuffer;
     169    UChar m_singleCharacterBuffer;
    170170};
    171171
     
    183183   
    184184    int length() const { return m_textIterator.length() - m_runOffset; }
    185     const QChar *characters() const { return m_textIterator.characters() + m_runOffset; }
     185    const UChar* characters() const { return m_textIterator.characters() + m_runOffset; }
    186186    DeprecatedString string(int numChars);
    187187   
     
    208208   
    209209    int length() const;
    210     const QChar *characters() const;
     210    const UChar* characters() const;
    211211   
    212212    // Range of the text we're currently returning
     
    215215private:
    216216    // text from the previous chunk from the textIterator
    217     const QChar *m_previousText;
     217    const UChar* m_previousText;
    218218    int m_previousLength;
    219219
  • trunk/WebCore/editing/VisiblePosition.cpp

    r14172 r14273  
    199199}
    200200
    201 QChar VisiblePosition::characterAfter() const
     201UChar VisiblePosition::characterAfter() const
    202202{
    203203    // We canonicalize to the first of two equivalent candidates, but the second of the two candidates
    204204    // is the one that will be inside the text node containing the character after this visible position.
    205205    Position pos = m_deepPosition.downstream();
    206     Node *node = pos.node();
    207     if (!node || !node->isTextNode()) {
    208         return QChar();
    209     }
    210     Text *textNode = static_cast<Text *>(pos.node());
     206    Node* node = pos.node();
     207    if (!node || !node->isTextNode())
     208        return 0;
     209    Text* textNode = static_cast<Text*>(pos.node());
    211210    int offset = pos.offset();
    212     if ((unsigned)offset >= textNode->length()) {
    213         return QChar();
    214     }
     211    if ((unsigned)offset >= textNode->length())
     212        return 0;
    215213    return textNode->data()[offset];
    216214}
  • trunk/WebCore/editing/VisiblePosition.h

    r14172 r14273  
    6767    bool isLastInBlock() const;
    6868
    69     QChar characterAfter() const;
     69    UChar characterAfter() const;
    7070   
    7171    void debugPosition(const char* msg = "") const;
  • trunk/WebCore/editing/markup.cpp

    r14234 r14273  
    5555    unsigned len = in.length();
    5656    for (unsigned i = 0; i < len; ++i) {
    57         switch (in[i].latin1()) {
     57        switch (in[i].unicode()) {
    5858            case '&':
    5959                s += "&amp;";
  • trunk/WebCore/editing/visible_units.cpp

    r13868 r14273  
    3939using namespace HTMLNames;
    4040
    41 static VisiblePosition previousBoundary(const VisiblePosition &c, unsigned (*searchFunction)(const QChar *, unsigned))
     41static VisiblePosition previousBoundary(const VisiblePosition &c, unsigned (*searchFunction)(const UChar *, unsigned))
    4242{
    4343    Position pos = c.deepEquivalent();
     
    7373    while (!it.atEnd() && it.length() > 0) {
    7474        // iterate to get chunks until the searchFunction returns a non-zero value.
    75         string.prepend(it.characters(), it.length());
    76         next = searchFunction(string.unicode(), string.length());
     75        string.prepend(reinterpret_cast<const QChar*>(it.characters()), it.length());
     76        next = searchFunction(reinterpret_cast<const UChar*>(string.unicode()), string.length());
    7777        if (next != 0)
    7878            break;
     
    9393        chars[1] = ' ';
    9494        string.prepend(chars, 2);
    95         unsigned pastImage = searchFunction(string.unicode(), string.length());
     95        unsigned pastImage = searchFunction(reinterpret_cast<const UChar*>(string.unicode()), string.length());
    9696        RefPtr<Range> range(it.range());
    9797        if (pastImage == 0)
     
    116116}
    117117
    118 static VisiblePosition nextBoundary(const VisiblePosition &c, unsigned (*searchFunction)(const QChar *, unsigned))
     118static VisiblePosition nextBoundary(const VisiblePosition &c, unsigned (*searchFunction)(const UChar *, unsigned))
    119119{
    120120    Position pos = c.deepEquivalent();
     
    144144        // Keep asking the iterator for chunks until the search function
    145145        // returns an end value not equal to the length of the string passed to it.
    146         string.append(it.characters(), it.length());
    147         next = searchFunction(string.unicode(), string.length());
     146        string.append(reinterpret_cast<const QChar*>(it.characters()), it.length());
     147        next = searchFunction(reinterpret_cast<const UChar*>(string.unicode()), string.length());
    148148        if (next != string.length())
    149149            break;
     
    165165        chars[1] = 'X';
    166166        string.append(chars, 2);
    167         unsigned pastImage = searchFunction(string.unicode(), string.length());
     167        unsigned pastImage = searchFunction(reinterpret_cast<const UChar*>(string.unicode()), string.length());
    168168        RefPtr<Range> range(it.range());
    169169        int exception = 0;
     
    185185// ---------
    186186
    187 static unsigned startWordBoundary(const QChar *characters, unsigned length)
     187static unsigned startWordBoundary(const UChar* characters, unsigned length)
    188188{
    189189    int start, end;
     
    207207}
    208208
    209 static unsigned endWordBoundary(const QChar *characters, unsigned length)
     209static unsigned endWordBoundary(const UChar* characters, unsigned length)
    210210{
    211211    int start, end;
     
    235235}
    236236
    237 static unsigned previousWordPositionBoundary(const QChar *characters, unsigned length)
     237static unsigned previousWordPositionBoundary(const UChar* characters, unsigned length)
    238238{
    239239    return findNextWordFromIndex(characters, length, length, false);
     
    245245}
    246246
    247 static unsigned nextWordPositionBoundary(const QChar *characters, unsigned length)
     247static unsigned nextWordPositionBoundary(const UChar* characters, unsigned length)
    248248{
    249249    return findNextWordFromIndex(characters, length, 0, true);
     
    491491// ---------
    492492
    493 static unsigned startSentenceBoundary(const QChar *characters, unsigned length)
     493static unsigned startSentenceBoundary(const UChar* characters, unsigned length)
    494494{
    495495    int start, end;
     
    503503}
    504504
    505 static unsigned endSentenceBoundary(const QChar *characters, unsigned length)
     505static unsigned endSentenceBoundary(const UChar* characters, unsigned length)
    506506{
    507507    int start, end;
     
    515515}
    516516
    517 static unsigned previousSentencePositionBoundary(const QChar *characters, unsigned length)
     517static unsigned previousSentencePositionBoundary(const UChar* characters, unsigned length)
    518518{
    519519    return findNextSentenceFromIndex(characters, length, length, false);
     
    525525}
    526526
    527 static unsigned nextSentencePositionBoundary(const QChar *characters, unsigned length)
     527static unsigned nextSentencePositionBoundary(const UChar* characters, unsigned length)
    528528{
    529529    return findNextSentenceFromIndex(characters, length, 0, true);
     
    564564        if (r->isText()) {
    565565            if (style->preserveNewline()) {
    566                 const QChar* text = static_cast<RenderText*>(r)->text();
     566                const UChar* text = static_cast<RenderText*>(r)->text();
    567567                int i = static_cast<RenderText*>(r)->length();
    568568                int o = offset;
     
    624624            int length = static_cast<RenderText *>(r)->length();
    625625            if (style->preserveNewline()) {
    626                 const QChar* text = static_cast<RenderText *>(r)->text();
     626                const UChar* text = static_cast<RenderText *>(r)->text();
    627627                int o = n == startNode ? offset : 0;
    628628                for (int i = o; i < length; ++i)
  • trunk/WebCore/html/HTMLInputElement.cpp

    r14212 r14273  
    14431443        int newLen = numCharactersInGraphemeClusters(s, maxLen);
    14441444        for (int i = 0; i < newLen; ++i)
    1445             if ((*s)[i].unicode() < ' ') {
     1445            if ((*s)[i] < ' ') {
    14461446                newLen = i;
    14471447                break;
  • trunk/WebCore/html/HTMLParser.cpp

    r14207 r14273  
    4949
    5050using namespace HTMLNames;
     51
     52const UChar nonBreakingSpace = 0xa0;
    5153
    5254/**
     
    474476                    StringImpl *i = t->string();
    475477                    unsigned int pos = 0;
    476                     while (pos < i->length() && ((*i)[pos] == ' ' || (*i)[pos] == QChar(0xa0)))
     478                    while (pos < i->length() && ((*i)[pos] == ' ' || (*i)[pos] == nonBreakingSpace))
    477479                        pos++;
    478480                    if (pos == i->length())
  • trunk/WebCore/html/HTMLTokenizer.cpp

    r14212 r14273  
    6666static const char textareaEnd [] = "</textarea";
    6767static const char titleEnd [] = "</title";
    68 
    69 #define KHTML_ALLOC_QCHAR_VEC( N ) (QChar*) fastMalloc( sizeof(QChar)*( N ) )
    70 #define KHTML_DELETE_QCHAR_VEC( P ) fastFree((char*)( P ))
    7168
    7269// Full support for MS Windows extensions to Latin-1.
     
    8582// We only need this for entities. For non-entity text, we handle this in the text encoding.
    8683
    87 static const unsigned short windowsLatin1ExtensionArray[32] = {
     84static const UChar windowsLatin1ExtensionArray[32] = {
    8885    0x20AC, 0x0081, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, // 80-87
    8986    0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x008D, 0x017D, 0x008F, // 88-8F
     
    9289};
    9390
    94 static inline QChar fixUpChar(QChar c)
    95 {
    96     unsigned short code = c.unicode();
    97     if ((code & ~0x1F) != 0x0080)
     91static inline UChar fixUpChar(UChar c)
     92{
     93    if ((c & ~0x1F) != 0x0080)
    9894        return c;
    99     return windowsLatin1ExtensionArray[code - 0x80];
    100 }
    101 
    102 inline bool tagMatch(const char *s1, const QChar *s2, unsigned length)
     95    return windowsLatin1ExtensionArray[c - 0x80];
     96}
     97
     98static inline bool tagMatch(const char* s1, const UChar* s2, unsigned length)
    10399{
    104100    for (unsigned i = 0; i != length; ++i) {
    105         char c1 = s1[i];
    106         char uc1 = toupper(c1);
    107         QChar c2 = s2[i];
     101        unsigned char c1 = s1[i];
     102        unsigned char uc1 = toupper(c1);
     103        UChar c2 = s2[i];
    108104        if (c1 != c2 && uc1 != c2)
    109105            return false;
     
    112108}
    113109
    114 void Token::addAttribute(Document* doc, const AtomicString& attrName, const AtomicString& v)
    115 {
    116     Attribute* a = 0;
     110inline void Token::addAttribute(Document* doc, const AtomicString& attrName, const AtomicString& v)
     111{
    117112    if (!attrName.isEmpty() && attrName != "/") {
    118         a = new MappedAttribute(attrName, v);
     113        Attribute* a = new MappedAttribute(attrName, v);
    119114        if (!attrs)
    120115            attrs = new NamedMappedAttrMap(0);
     
    167162    }
    168163   
    169     if (buffer)
    170         KHTML_DELETE_QCHAR_VEC(buffer);
     164    fastFree(buffer);
    171165    buffer = dest = 0;
    172166    size = 0;
    173167
    174     if (scriptCode)
    175         KHTML_DELETE_QCHAR_VEC(scriptCode);
     168    fastFree(scriptCode);
    176169    scriptCode = 0;
    177170    scriptCodeSize = scriptCodeMaxSize = scriptCodeResync = 0;
     
    190183    reset();
    191184    size = 254;
    192     buffer = KHTML_ALLOC_QCHAR_VEC( 255 );
     185    buffer = static_cast<UChar*>(fastMalloc(sizeof(UChar) * 254));
    193186    dest = buffer;
    194187    tquote = NoQuote;
     
    262255    while ( !src.isEmpty() ) {
    263256        checkScriptBuffer();
    264         unsigned char ch = src->latin1();
     257        UChar ch = *src;
    265258        if (!scriptCodeResync && !brokenComments && !state.inTextArea() && !state.inXmp() && !state.inTitle() && ch == '-' && scriptCodeSize >= 3 && !src.escaped() && scriptCode[scriptCodeSize-3] == '<' && scriptCode[scriptCodeSize-2] == '!' && scriptCode[scriptCodeSize-1] == '-') {
    266259            state.setInComment(true);
     
    268261            continue;
    269262        }
    270         if ( scriptCodeResync && !tquote && ( ch == '>' ) ) {
     263        if (scriptCodeResync && !tquote && ch == '>') {
    271264            ++src;
    272265            scriptCodeSize = scriptCodeResync-1;
     
    303296        }
    304297        // possible end of tagname, lets check.
    305         if ( !scriptCodeResync && !state.escaped() && !src.escaped() && ( ch == '>' || ch == '/' || ch <= ' ' ) && ch &&
     298        if (!scriptCodeResync && !state.escaped() && !src.escaped() && (ch == '>' || ch == '/' || ch <= ' ') && ch &&
    306299             scriptCodeSize >= searchStopperLen &&
    307300             tagMatch( searchStopper, scriptCode+scriptCodeSize-searchStopperLen, searchStopperLen )) {
     
    310303            continue;
    311304        }
    312         if ( scriptCodeResync && !state.escaped() ) {
    313             if(ch == '\"')
     305        if (scriptCodeResync && !state.escaped()) {
     306            if (ch == '\"')
    314307                tquote = (tquote == NoQuote) ? DoubleQuote : ((tquote == SingleQuote) ? SingleQuote : NoQuote);
    315             else if(ch == '\'')
     308            else if (ch == '\'')
    316309                tquote = (tquote == NoQuote) ? SingleQuote : (tquote == DoubleQuote) ? DoubleQuote : NoQuote;
    317310            else if (tquote != NoQuote && (ch == '\r' || ch == '\n'))
     
    320313        state.setEscaped(!state.escaped() && ch == '\\');
    321314        if (!scriptCodeResync && (state.inTextArea() || state.inTitle()) && !src.escaped() && ch == '&') {
    322             QChar *scriptCodeDest = scriptCode+scriptCodeSize;
     315            UChar* scriptCodeDest = scriptCode+scriptCodeSize;
    323316            ++src;
    324317            state = parseEntity(src, scriptCodeDest, state, m_cBufferPos, true, false);
    325318            scriptCodeSize = scriptCodeDest-scriptCode;
    326         }
    327         else {
     319        } else {
    328320            scriptCode[scriptCodeSize++] = *src;
    329321            ++src;
     
    371363    }
    372364    state = processListing(SegmentedString(scriptCode, scriptCodeSize), state);
    373     DeprecatedString exScript( buffer, dest-buffer );
     365    DeprecatedString exScript(reinterpret_cast<QChar*>(buffer), dest - buffer);
    374366    processToken();
    375367    currToken.tagName = scriptTag.localName();
     
    507499    while ( !src.isEmpty() ) {
    508500        scriptCode[ scriptCodeSize++ ] = *src;
    509 #if defined(TOKEN_DEBUG) && TOKEN_DEBUG > 1
    510         qDebug("comment is now: *%s*",
    511                QConstString((QChar*)src.operator->(), min(16U, src.length())).string().latin1());
    512 #endif
    513 
    514         if (src->unicode() == '>') {
     501
     502        if (*src == '>') {
    515503            bool handleBrokenComments = brokenComments && !(state.inScript() || state.inStyle());
    516504            int endCharsCount = 1; // start off with one for the '>' character
     
    556544    while (!src.isEmpty()) {
    557545        scriptCode[scriptCodeSize++] = *src;
    558         if (src->unicode() == '>' &&
     546        if (*src == '>' &&
    559547            scriptCodeSize > 1 && scriptCode[scriptCodeSize-2] == '%') {
    560548            ++src;
     
    570558HTMLTokenizer::State HTMLTokenizer::parseProcessingInstruction(SegmentedString &src, State state)
    571559{
    572     char oldchar = 0;
    573     while ( !src.isEmpty() )
    574     {
    575         unsigned char chbegin = src->latin1();
    576         if(chbegin == '\'') {
     560    UChar oldchar = 0;
     561    while (!src.isEmpty()) {
     562        UChar chbegin = *src;
     563        if (chbegin == '\'')
    577564            tquote = tquote == SingleQuote ? NoQuote : SingleQuote;
    578         }
    579         else if(chbegin == '\"') {
     565        else if (chbegin == '\"')
    580566            tquote = tquote == DoubleQuote ? NoQuote : DoubleQuote;
    581         }
    582567        // Look for '?>'
    583         // some crappy sites omit the "?" before it, so
     568        // Some crappy sites omit the "?" before it, so
    584569        // we look for an unquoted '>' instead. (IE compatible)
    585         else if ( chbegin == '>' && ( !tquote || oldchar == '?' ) )
    586         {
     570        else if (chbegin == '>' && (!tquote || oldchar == '?')) {
    587571            // We got a '?>' sequence
    588572            state.setInProcessingInstruction(false);
     
    601585{
    602586    while (!src.isEmpty()) {
    603         unsigned short cc = src->unicode();
     587        UChar cc = *src;
    604588
    605589        if (state.skipLF()) {
     
    626610
    627611
    628 HTMLTokenizer::State HTMLTokenizer::parseEntity(SegmentedString &src, QChar *&dest, State state, unsigned &cBufferPos, bool start, bool parsingTag)
     612HTMLTokenizer::State HTMLTokenizer::parseEntity(SegmentedString &src, UChar*& dest, State state, unsigned &cBufferPos, bool start, bool parsingTag)
    629613{
    630614    if (start)
     
    637621    while(!src.isEmpty())
    638622    {
    639         unsigned short cc = src->unicode();
     623        UChar cc = *src;
    640624        switch(state.entityState()) {
    641625        case NoEntity:
     
    655639
    656640        case NumericSearch:
    657             if(cc == 'x' || cc == 'X') {
     641            if (cc == 'x' || cc == 'X') {
    658642                cBuffer[cBufferPos++] = cc;
    659643                ++src;
    660644                state.setEntityState(Hexadecimal);
    661             }
    662             else if(cc >= '0' && cc <= '9')
     645            } else if (cc >= '0' && cc <= '9')
    663646                state.setEntityState(Decimal);
    664647            else
    665648                state.setEntityState(SearchSemicolon);
    666 
    667649            break;
    668650
    669         case Hexadecimal:
    670         {
    671             int ll = min(src.length(), 10-cBufferPos);
    672             while(ll--) {
    673                 QChar csrc(src->lower());
    674                 cc = csrc.unicode();
    675 
    676                 if (!((cc >= '0' && cc <= '9') || (cc >= 'a' && cc <= 'f'))) {
     651        case Hexadecimal: {
     652            int ll = min(src.length(), 10 - cBufferPos);
     653            while (ll--) {
     654                cc = *src;
     655                if (!((cc >= '0' && cc <= '9') || (cc >= 'a' && cc <= 'f') || (cc >= 'A' && cc <= 'F'))) {
    677656                    state.setEntityState(SearchSemicolon);
    678657                    break;
    679658                }
    680                 EntityUnicodeValue = EntityUnicodeValue*16 + (cc - ( cc < 'a' ? '0' : 'a' - 10));
     659                int digit;
     660                if (cc < 'A')
     661                    digit = cc - '0';
     662                else
     663                    digit = (cc - 'A' + 10) & 0xF; // handle both upper and lower case without a branch
     664                EntityUnicodeValue = EntityUnicodeValue * 16 + digit;
    681665                cBuffer[cBufferPos++] = cc;
    682666                ++src;
     
    690674            int ll = min(src.length(), 9-cBufferPos);
    691675            while(ll--) {
    692                 cc = src->unicode();
     676                cc = *src;
    693677
    694678                if (!(cc >= '0' && cc <= '9')) {
     
    709693            int ll = min(src.length(), 9-cBufferPos);
    710694            while(ll--) {
    711                 QChar csrc = *src;
    712                 cc = csrc.unicode();
     695                cc = *src;
    713696
    714697                if (!((cc >= 'a' && cc <= 'z') || (cc >= '0' && cc <= '9') || (cc >= 'A' && cc <= 'Z'))) {
     
    738721        case SearchSemicolon:
    739722            // Don't allow values that are more than 21 bits.
    740             if (EntityUnicodeValue > 0 && EntityUnicodeValue <= 0x1FFFFF) {
    741            
     723            if (EntityUnicodeValue > 0 && EntityUnicodeValue <= 0x10FFFF) {
    742724                if (*src == ';')
    743725                    ++src;
    744 
    745726                if (EntityUnicodeValue <= 0xFFFF) {
    746727                    checkBuffer();
     
    748729                } else {
    749730                    // Convert to UTF-16, using surrogate code points.
    750                     QChar c1(0xD800 | (((EntityUnicodeValue >> 16) - 1) << 6) | ((EntityUnicodeValue >> 10) & 0x3F));
    751                     QChar c2(0xDC00 | (EntityUnicodeValue & 0x3FF));
    752731                    checkBuffer(2);
    753                     src.push(c1);
    754                     src.push(c2);
     732                    src.push(U16_LEAD(EntityUnicodeValue));
     733                    src.push(U16_TRAIL(EntityUnicodeValue));
    755734                }
    756735            } else {
     
    780759    {
    781760        checkBuffer();
    782 #if defined(TOKEN_DEBUG) && TOKEN_DEBUG > 1
    783         unsigned l = 0;
    784         while(l < src.length() && (*(src.operator->()+l)).latin1() != '>')
    785             l++;
    786         qDebug("src is now: *%s*, tquote: %d",
    787                QConstString((QChar*)src.operator->(), l).deprecatedString().latin1(), tquote);
    788 #endif
    789761        switch(state.tagState()) {
    790762        case NoTag:
     
    822794                          if (!src.isEmpty())
    823795                              // cuts off high bits, which is okay
    824                               cBuffer[cBufferPos++] = src->unicode();
     796                              cBuffer[cBufferPos++] = *src;
    825797                        }
    826798                        else
     
    831803                    }
    832804                    // cuts off high bits, which is okay
    833                     cBuffer[cBufferPos++] = src->unicode();
     805                    cBuffer[cBufferPos++] = *src;
    834806                    ++src;
    835807                    break;
     
    842814            unsigned int ll = min(src.length(), CBUFLEN-cBufferPos);
    843815            while(ll--) {
    844                 unsigned short curchar = src->unicode();
     816                UChar curchar = *src;
    845817                if(curchar <= ' ' || curchar == '>' ) {
    846818                    finish = true;
     
    894866#endif
    895867            while(!src.isEmpty()) {
    896                 unsigned short curchar = src->unicode();
     868                UChar curchar = *src;
    897869                // In this mode just ignore any quotes we encounter and treat them like spaces.
    898870                if (curchar > ' ' && curchar != '\'' && curchar != '"') {
     
    915887            int ll = min(src.length(), CBUFLEN-cBufferPos);
    916888            while(ll--) {
    917                 unsigned short curchar = src->unicode();
     889                UChar curchar = *src;
    918890                if (curchar <= '>' && (curchar >= '=' || curchar <= ' ')) {
    919891                    cBuffer[cBufferPos] = '\0';
     
    953925#endif
    954926            while(!src.isEmpty()) {
    955                 unsigned short curchar = src->unicode();
     927                UChar curchar = *src;
    956928                // In this mode just ignore any quotes we encounter and treat them like spaces.
    957929                if (curchar > ' ' && curchar != '\'' && curchar != '"') {
     
    975947        case SearchValue:
    976948            while(!src.isEmpty()) {
    977                 unsigned short curchar = src->unicode();
     949                UChar curchar = *src;
    978950                if(curchar > ' ') {
    979951                    if(( curchar == '\'' || curchar == '\"' )) {
     
    996968                checkBuffer();
    997969
    998                 unsigned short curchar = src->unicode();
     970                UChar curchar = *src;
    999971                if (curchar == '>' && attrName.isEmpty()) {
    1000972                    // Handle a case like <img '>.  Just go ahead and be willing
     
    10521024            while(!src.isEmpty()) {
    10531025                checkBuffer();
    1054                 unsigned short curchar = src->unicode();
     1026                UChar curchar = *src;
    10551027                if(curchar <= '>' && !src.escaped()) {
    10561028                    // parse Entities
     
    13411313        checkBuffer();
    13421314
    1343         unsigned short cc = src->unicode();
     1315        UChar cc = *src;
    13441316
    13451317        bool wasSkipLF = state.skipLF();
     
    15061478            processToken();
    15071479
    1508         if (scriptCode)
    1509             KHTML_DELETE_QCHAR_VEC(scriptCode);
     1480        fastFree(scriptCode);
    15101481        scriptCode = 0;
    15111482        scriptCodeSize = scriptCodeMaxSize = scriptCodeResync = 0;
    15121483
    1513         KHTML_DELETE_QCHAR_VEC(buffer);
     1484        fastFree(buffer);
    15141485        buffer = 0;
    15151486    }
     
    15331504        DeprecatedString food;
    15341505        if (m_state.inScript() || m_state.inStyle())
    1535             food.setUnicode(scriptCode, scriptCodeSize);
     1506            food.setUnicode(reinterpret_cast<QChar*>(scriptCode), scriptCodeSize);
    15361507        else if (m_state.inServer()) {
    15371508            food = "<";
    1538             food += DeprecatedString(scriptCode, scriptCodeSize);
     1509            food += DeprecatedString(reinterpret_cast<QChar*>(scriptCode), scriptCodeSize);
    15391510        } else {
    1540             pos = QConstString(scriptCode, scriptCodeSize).string().find('>');
    1541             food.setUnicode(scriptCode+pos+1, scriptCodeSize-pos-1); // deep copy
    1542         }
    1543         KHTML_DELETE_QCHAR_VEC(scriptCode);
     1511            pos = QConstString(reinterpret_cast<QChar*>(scriptCode), scriptCodeSize).string().find('>');
     1512            food.setUnicode(reinterpret_cast<QChar*>(scriptCode) + pos + 1, scriptCodeSize - pos - 1); // deep copy
     1513        }
     1514        fastFree(scriptCode);
    15441515        scriptCode = 0;
    15451516        scriptCodeSize = scriptCodeMaxSize = scriptCodeResync = 0;
     
    16271598void HTMLTokenizer::enlargeBuffer(int len)
    16281599{
    1629     int newsize = max(size*2, size+len);
    1630     int oldoffs = (dest - buffer);
    1631 
    1632     buffer = (QChar*)fastRealloc(buffer, newsize*sizeof(QChar));
    1633     dest = buffer + oldoffs;
    1634     size = newsize;
     1600    int newSize = max(size * 2, size + len);
     1601    int oldOffset = dest - buffer;
     1602    buffer = static_cast<UChar*>(fastRealloc(buffer, newSize * sizeof(UChar)));
     1603    dest = buffer + oldOffset;
     1604    size = newSize;
    16351605}
    16361606
    16371607void HTMLTokenizer::enlargeScriptBuffer(int len)
    16381608{
    1639     int newsize = max(scriptCodeMaxSize*2, scriptCodeMaxSize+len);
    1640     scriptCode = (QChar*)fastRealloc(scriptCode, newsize*sizeof(QChar));
    1641     scriptCodeMaxSize = newsize;
    1642 }
    1643 
    1644 void HTMLTokenizer::notifyFinished(CachedObject */*finishedObj*/)
     1609    int newSize = max(scriptCodeMaxSize * 2, scriptCodeMaxSize + len);
     1610    scriptCode = static_cast<UChar*>(fastRealloc(scriptCode, newSize * sizeof(UChar)));
     1611    scriptCodeMaxSize = newSize;
     1612}
     1613
     1614void HTMLTokenizer::notifyFinished(CachedObject*)
    16451615{
    16461616#if INSTRUMENT_LAYOUT_SCHEDULING
     
    17291699}
    17301700
    1731 unsigned short decodeNamedEntity(const char* name)
     1701UChar decodeNamedEntity(const char* name)
    17321702{
    17331703    const Entity* e = findEntity(name, strlen(name));
  • trunk/WebCore/html/HTMLTokenizer.h

    r13858 r14273  
    8383    virtual ~HTMLTokenizer();
    8484
    85     virtual bool write(const SegmentedString &str, bool appendData);
     85    virtual bool write(const SegmentedString&, bool appendData);
    8686    virtual void finish();
    8787    virtual void setForceSynchronous(bool force);
     
    107107    State parseSpecial(SegmentedString&, State);
    108108    State parseTag(SegmentedString&, State);
    109     State parseEntity(SegmentedString &, QChar*& dest, State, unsigned& _cBufferPos, bool start, bool parsingTag);
     109    State parseEntity(SegmentedString&, UChar*& dest, State, unsigned& _cBufferPos, bool start, bool parsingTag);
    110110    State parseProcessingInstruction(SegmentedString&, State);
    111111    State scriptHandler(State);
    112112    State scriptExecution(const DeprecatedString& script, State state, DeprecatedString scriptURL = DeprecatedString(), int baseLine = 0);
    113     void setSrc(const SegmentedString &source);
     113    void setSrc(const SegmentedString&);
    114114
    115115    // check if we have enough space in the buffer.
     
    129129    void enlargeScriptBuffer(int len);
    130130
    131     bool continueProcessing(int& processedCount, double startTime, State &state);
     131    bool continueProcessing(int& processedCount, double startTime, State&);
    132132    void timerFired(Timer<HTMLTokenizer>*);
    133133    void allDataProcessed();
     
    138138    // Internal buffers
    139139    ///////////////////
    140     QChar *buffer;
    141     QChar *dest;
     140    UChar* buffer;
     141    UChar* dest;
    142142
    143143    Token currToken;
     
    149149    //////////////////
    150150    // are we in quotes within a html tag
    151     enum
    152     {
    153         NoQuote = 0,
    154         SingleQuote,
    155         DoubleQuote
    156     } tquote;
     151    enum { NoQuote, SingleQuote, DoubleQuote } tquote;
    157152
    158153    // Are we in a &... character entity description?
     
    274269   
    275270    // Used to store the code of a srcipting sequence
    276     QChar *scriptCode;
     271    UChar* scriptCode;
    277272    // Size of the script sequenze stored in @ref #scriptCode
    278273    int scriptCodeSize;
     
    283278
    284279    // Stores characters if we are scanning for a string like "</script>"
    285     QChar searchBuffer[ 10 ];
     280    UChar searchBuffer[10];
    286281    // Counts where we are in the string we are scanning for
    287282    int searchCount;
    288283    // The string we are searching for
    289     const QChar *searchFor;
     284    const UChar* searchFor;
    290285    // the stopper string
    291286    const char* searchStopper;
     
    340335void parseHTMLDocumentFragment(const String&, DocumentFragment*);
    341336
    342 unsigned short decodeNamedEntity(const char*);
     337UChar decodeNamedEntity(const char*);
    343338
    344339}
  • trunk/WebCore/html/html_inlineimpl.cpp

    r14212 r14273  
    407407// Allows trailing nonnumeric characters.
    408408// Returns 10 for any size greater than 9.
    409 static bool parseFontSizeNumber(const String &s, int &size)
     409static bool parseFontSizeNumber(const String& s, int& size)
    410410{
    411411    unsigned pos = 0;
    412412   
    413413    // Skip leading spaces.
    414     while (pos < s.length() && s[pos].isSpace())
     414    while (QChar(s[pos]).isSpace())
    415415        ++pos;
    416416   
     
    418418    bool sawPlus = false;
    419419    bool sawMinus = false;
    420     if (pos < s.length() && s[pos] == '+') {
     420    if (s[pos] == '+') {
    421421        ++pos;
    422422        sawPlus = true;
    423     } else if (pos < s.length() && s[pos] == '-') {
     423    } else if (s[pos] == '-') {
    424424        ++pos;
    425425        sawMinus = true;
     
    427427   
    428428    // Parse a single digit.
    429     if (pos >= s.length() || !s[pos].isNumber())
     429    if (!u_isdigit(s[pos]))
    430430        return false;
    431     int num = s[pos++].digitValue();
     431    int num = u_charDigitValue(s[pos++]);
    432432   
    433433    // Check for an additional digit.
    434     if (pos < s.length() && s[pos].isNumber())
     434    if (u_isdigit(s[pos]))
    435435        num = 10;
    436436   
  • trunk/WebCore/kwq/KWQLoader.mm

    r13821 r14273  
    2727#import "KWQLoader.h"
    2828
     29#import "BlockExceptions.h"
    2930#import "Cache.h"
    3031#import "CachedImage.h"
    3132#import "DocLoader.h"
    3233#import "FoundationExtras.h"
    33 #import "BlockExceptions.h"
     34#import "FrameMac.h"
    3435#import "KWQFormData.h"
     36#import "KWQResourceLoader.h"
     37#import "Logging.h"
     38#import "Request.h"
    3539#import "TransferJob.h"
    36 #import "Logging.h"
    37 #import "KWQResourceLoader.h"
    38 #import "FrameMac.h"
    39 #import "Request.h"
    4040#import "WebCoreFrameBridge.h"
    4141#import "loader.h"
    42 #import "loader.h"
    43 
    4442#import <Foundation/NSURLResponse.h>
    4543
     
    216214}
    217215
    218 #define LOCAL_STRING_BUFFER_SIZE 1024
    219 
    220 bool KWQIsResponseURLEqualToURL(NSURLResponse *response, const WebCore::String &m_url)
    221 {
    222     unichar _buffer[LOCAL_STRING_BUFFER_SIZE];
    223     unichar *urlStringCharacters;
    224    
     216bool KWQIsResponseURLEqualToURL(NSURLResponse *response, const WebCore::String& m_url)
     217{
    225218    NSURL *responseURL = [(NSURLResponse *)response URL];
    226219    NSString *urlString = [responseURL absoluteString];
    227220
    228     if (m_url.length() != [urlString length])
     221    size_t length = m_url.length();
     222    if (length != [urlString length])
    229223        return false;
    230        
    231     // Nasty hack to directly compare strings buffers of NSString
    232     // and String.  We do this for speed.
    233     if ([urlString length] > LOCAL_STRING_BUFFER_SIZE) {
    234         urlStringCharacters = (unichar *)fastMalloc(sizeof(unichar)*[urlString length]);
    235     }
    236     else {
    237         urlStringCharacters = _buffer;
    238     }
    239     [urlString getCharacters:urlStringCharacters];
    240    
    241     bool ret = false;
    242     if(!memcmp(urlStringCharacters, m_url.unicode(), m_url.length()*sizeof(QChar)))
    243         ret = true;
    244    
    245     if (urlStringCharacters != _buffer)
    246         fastFree(urlStringCharacters);
    247        
    248     return ret;
     224
     225    Vector<UChar, 1024> buffer(length);
     226    [urlString getCharacters:buffer.data()];   
     227    return !memcmp(buffer.data(), m_url.characters(), length * sizeof(UChar));
    249228}
    250229
  • trunk/WebCore/kwq/KWQTextStream.cpp

    r13404 r14273  
    2727#include "KWQTextStream.h"
    2828
     29#include "DeprecatedString.h"
    2930#include "PlatformString.h"
    3031#include "Logging.h"
  • trunk/WebCore/kwq/WebCoreAXObject.mm

    r13901 r14273  
    12691269}
    12701270
    1271 static void AXAttributedStringAppendText (NSMutableAttributedString *attrString, Node *nodeImpl, const QChar *chars, int length)
     1271static void AXAttributedStringAppendText(NSMutableAttributedString* attrString, Node* nodeImpl, const UChar* chars, int length)
    12721272{
    12731273    // skip invisible text
     
    12791279   
    12801280    // append the string from this node
    1281     [[attrString mutableString] appendString:[NSString stringWithCharacters:(const UniChar*)chars length:length]];
     1281    [[attrString mutableString] appendString:[NSString stringWithCharacters:chars length:length]];
    12821282
    12831283    // add new attributes and remove irrelevant inherited ones
     
    13511351        // non-zero length means textual node, zero length means replaced node (AKA "attachments" in AX)
    13521352        if (it.length() != 0) {
    1353             AXAttributedStringAppendText (attrString, nodeImpl, it.characters(), it.length());
     1353            AXAttributedStringAppendText(attrString, nodeImpl, it.characters(), it.length());
    13541354        } else {
    1355             AXAttributedStringAppendReplaced (attrString, nodeImpl->childNode(it.range()->startOffset(exception)));
     1355            AXAttributedStringAppendReplaced(attrString, nodeImpl->childNode(it.range()->startOffset(exception)));
    13561356        }
    13571357       
  • trunk/WebCore/loader/Cache.cpp

    r14251 r14273  
    228228}
    229229
    230 void Cache::preloadStyleSheet(const DeprecatedString& url, const DeprecatedString& stylesheet_data)
    231 {
    232     CachedObject *o = cache->get(String(url).impl());
    233     if (o)
    234         remove(o);
    235     cache->set(String(url).impl(), new CachedCSSStyleSheet(url, stylesheet_data));
    236 }
    237 
    238230CachedScript *Cache::requestScript(DocLoader* dl, const String& url, bool reload, time_t expireDate, const DeprecatedString& charset)
    239231{
     
    285277    updateCacheStatus(dl, url, o);
    286278    return static_cast<CachedScript *>(o);
    287 }
    288 
    289 void Cache::preloadScript(const DeprecatedString& url, const DeprecatedString& script_data)
    290 {
    291     CachedObject *o = cache->get(String(url).impl());
    292     if (o)
    293         remove(o);
    294     cache->set(String(url).impl(), new CachedScript(url, script_data));
    295279}
    296280
  • trunk/WebCore/loader/Cache.h

    r14256 r14273  
    4949    /**
    5050     * Provides a cache/loader for objects needed for displaying the html page.
    51      * At the moment these are stylesheets, scripts and images
    5251     */
    5352    class Cache {
     
    5554    public:
    5655        /**
    57          * init the cache in case it's not already. This needs to get called once
    58          * before using it.
     56         * Initialize the cache in case it's not already.
     57         * This needs to get called once before using it.
    5958         */
    6059        static void init();
    6160       
    6261        /**
    63          * Ask the cache for some url. Will return a cachedObject, and
    64          * load the requested data in case it's not cahced
    65          * if the DocLoader is zero, the url must be full-qualified.
    66          * Otherwise, it is automatically base-url expanded
     62         * Ask the cache for some URL.
     63         * If the DocLoader is zero, the URL must be fully-qualified. Otherwise, it is automatically base-URL expanded
    6764         */
    6865        static CachedImage* requestImage(DocLoader*, const String& URL, bool reload = false, time_t expireDate = 0);
    69         static CachedImage* requestImage(DocLoader*, const KURL& url, bool reload = false, time_t expireDate = 0);
    70 
    71         /**
    72          * Ask the cache for some url. Will return a cachedObject, and
    73          * load the requested data in case it's not cached
    74          */
    75         static CachedCSSStyleSheet* requestStyleSheet(DocLoader*, const String& URL, bool reload = false, time_t expireDate = 0, const DeprecatedString& charset = DeprecatedString::null);
    76 
    77         /**
    78          * Pre-loads a stylesheet into the cache.
    79          */
    80         static void preloadStyleSheet(const DeprecatedString &url, const DeprecatedString& stylesheetData);
    81 
    82         /**
    83          * Ask the cache for some url. Will return a cachedObject, and
    84          * load the requested data in case it's not cahced
    85          */
    86         static CachedScript* requestScript(DocLoader*, const String& URL, bool reload = false, time_t expireDate = 0, const DeprecatedString& charset = DeprecatedString::null);
    87 
    88         /**
    89          * Pre-loads a script into the cache.
    90          */
    91         static void preloadScript(const DeprecatedString &url, const DeprecatedString& scriptData);
     66        static CachedImage* requestImage(DocLoader*, const KURL& URL, bool reload, time_t expireDate);
     67        static CachedCSSStyleSheet* requestStyleSheet(DocLoader*, const String& URL, bool reload, time_t expireDate, const DeprecatedString& charset);
     68        static CachedScript* requestScript(DocLoader*, const String& URL, bool reload, time_t expireDate, const DeprecatedString& charset);
    9269
    9370#ifdef KHTML_XSLT
    94         // Ask the cache for an XSL stylesheet.
    95         static CachedXSLStyleSheet* requestXSLStyleSheet(DocLoader*, const String& URL, bool reload = false, time_t expireDate = 0);
     71        static CachedXSLStyleSheet* requestXSLStyleSheet(DocLoader*, const String& URL, bool reload, time_t expireDate);
    9672#endif
    9773
    9874#ifndef KHTML_NO_XBL
    99         // Ask the cache for an XBL document.
    100         static CachedXBLDocument* requestXBLDocument(DocLoader*, const String& URL, bool reload = false, time_t expireDate = 0);
     75        static CachedXBLDocument* requestXBLDocument(DocLoader*, const String& URL, bool reload, time_t expireDate);
    10176#endif
    10277
    10378        /**
    104          * Sets the size of the cache. This will only hod approximately, since the size some
    105          * cached objects (like stylesheets) take up in memory is not exaclty known.
     79         * Sets the size of the cache. This will only hold approximately, since the size some
     80         * cached objects (like stylesheets) take up in memory is not exactly known.
    10681         */
    10782        static void setSize(int bytes);
     83
    10884        /**
    10985         * returns the size of the cache
     
    126102        /**
    127103         * clears the cache
    128          * Warning: call this only at the end of your program, to clean
    129          * up memory (useful for finding memory holes)
     104         * Warning: call this only at the end of your program, to clean up memory
     105         * (useful for finding memory leaks).
    130106         */
    131107        static void clear();
  • trunk/WebCore/loader/CachedObject.h

    r14256 r14273  
    2828#define KHTML_CachedObject_h
    2929
     30#include "DeprecatedString.h"
    3031#include "PlatformString.h"
    3132#include "KWQKIOGlobal.h"
  • trunk/WebCore/page/Frame.cpp

    r14258 r14273  
    8383
    8484using namespace std;
    85 using namespace KJS;
     85
     86using KJS::JSLock;
     87using KJS::JSValue;
     88using KJS::Location;
     89using KJS::PausedTimeouts;
     90using KJS::SavedProperties;
     91using KJS::SavedBuiltins;
     92using KJS::UString;
     93using KJS::Window;
    8694
    8795namespace WebCore {
     
    97105    UserStyleSheetLoader(Frame* frame, const String& url, DocLoader* dl)
    98106        : m_frame(frame)
    99         , m_cachedSheet(Cache::requestStyleSheet(dl, url))
     107        , m_cachedSheet(Cache::requestStyleSheet(dl, url, false, 0, ""))
    100108    {
    101109        m_cachedSheet->ref(this);
     
    32553263}
    32563264
    3257 QChar Frame::backslashAsCurrencySymbol() const
     3265UChar Frame::backslashAsCurrencySymbol() const
    32583266{
    32593267    Document *doc = document();
  • trunk/WebCore/page/Frame.h

    r14256 r14273  
    713713  // Convenience, to avoid repeating the code to dig down to get this.
    714714
    715   QChar backslashAsCurrencySymbol() const;
     715  UChar backslashAsCurrencySymbol() const;
    716716
    717717  DeprecatedValueList<MarkedTextUnderline> markedTextUnderlines() const; 
  • trunk/WebCore/platform/AtomicString.cpp

    r14256 r14273  
    2424
    2525#if AVOID_STATIC_CONSTRUCTORS
    26 #define KHTML_ATOMICSTRING_HIDE_GLOBALS 1
     26#define ATOMICSTRING_HIDE_GLOBALS 1
    2727#endif
    2828
    2929#include "AtomicString.h"
    3030
     31#include "DeprecatedString.h"
    3132#include "StaticConstructors.h"
    3233#include "StringHash.h"
     
    3435#include <wtf/HashSet.h>
    3536
    36 using namespace KJS;
     37using KJS::Identifier;
     38using KJS::UString;
    3739
    3840namespace WebCore {
    39    
     41
    4042static HashSet<StringImpl*>* stringTable;
    4143
     
    5052    {
    5153        int length = r->length();
    52         const QChar* d = r->unicode();
     54        const UChar* d = r->characters();
    5355        for (int i = 0; i != length; ++i)
    5456            if (d[i] != s[i])
     
    6971{
    7072    StringImpl* impl = a.impl();
    71     if ((!impl || !impl->unicode()) && !b)
     73    if ((!impl || !impl->characters()) && !b)
    7274        return true;
    73     if ((!impl || !impl->unicode()) || !b)
     75    if ((!impl || !impl->characters()) || !b)
    7476        return false;
    7577    return CStringTranslator::equal(impl, b);
     
    8789}
    8890
    89 struct QCharBuffer {
    90     const QChar* s;
     91struct UCharBuffer {
     92    const UChar* s;
    9193    unsigned length;
    9294};
    9395
    94 struct QCharBufferTranslator {
    95     static unsigned hash(const QCharBuffer& buf)
     96struct UCharBufferTranslator {
     97    static unsigned hash(const UCharBuffer& buf)
    9698    {
    9799        return StringImpl::computeHash(buf.s, buf.length);
    98100    }
    99101
    100     static bool equal(StringImpl* const& str, const QCharBuffer& buf)
     102    static bool equal(StringImpl* const& str, const UCharBuffer& buf)
    101103    {
    102104        unsigned strLength = str->length();
     
    105107            return false;
    106108       
    107         const uint32_t* strChars = reinterpret_cast<const uint32_t*>(str->unicode());
     109        const uint32_t* strChars = reinterpret_cast<const uint32_t*>(str->characters());
    108110        const uint32_t* bufChars = reinterpret_cast<const uint32_t*>(buf.s);
    109111       
     
    121123    }
    122124
    123     static void translate(StringImpl*& location, const QCharBuffer& buf, unsigned hash)
     125    static void translate(StringImpl*& location, const UCharBuffer& buf, unsigned hash)
    124126    {
    125127        StringImpl *r = new StringImpl(buf.s, buf.length);
     
    131133};
    132134
    133 StringImpl* AtomicString::add(const QChar* s, int length)
     135StringImpl* AtomicString::add(const UChar* s, int length)
    134136{
    135137    if (!s)
     
    139141        return StringImpl::empty();
    140142   
    141     QCharBuffer buf = {s, length};
    142     return *stringTable->add<QCharBuffer, QCharBufferTranslator>(buf).first;
     143    UCharBuffer buf = {s, length};
     144    return *stringTable->add<UCharBuffer, UCharBufferTranslator>(buf).first;
    143145}
    144146
     
    164166StringImpl* AtomicString::add(const KJS::Identifier& str)
    165167{
    166     return add(reinterpret_cast<const QChar*>(str.data()), str.size());
     168    return add(reinterpret_cast<const UChar*>(str.data()), str.size());
    167169}
    168170
    169171StringImpl* AtomicString::add(const KJS::UString& str)
    170172{
    171     return add(reinterpret_cast<const QChar*>(str.data()), str.size());
     173    return add(reinterpret_cast<const UChar*>(str.data()), str.size());
    172174}
    173175
    174176AtomicString::operator Identifier() const
    175177{
    176     return domString();
     178    return m_string;
    177179}
    178180
    179181AtomicString::operator UString() const
    180182{
    181     return domString();
     183    return m_string;
     184}
     185
     186AtomicString::AtomicString(const DeprecatedString& s)
     187    : m_string(add(reinterpret_cast<const UChar*>(s.unicode()), s.length()))
     188{
     189}
     190
     191DeprecatedString AtomicString::deprecatedString() const
     192{
     193    return m_string.deprecatedString();
    182194}
    183195
  • trunk/WebCore/platform/AtomicString.h

    r13706 r14273  
    3434   
    3535    AtomicString() { }
    36     AtomicString(QChar c) : m_string(add(&c, 1)) { }
    3736    AtomicString(const char* s) : m_string(add(s)) { }
    38     AtomicString(const QChar* s, int length) : m_string(add(s, length)) { }
    39     AtomicString(const unsigned short* s, int length) : m_string(add((QChar*)s, length)) { }
    40     AtomicString(const DeprecatedString& s) : m_string(add(s.unicode(), s.length())) { }
     37    AtomicString(const UChar* s, int length) : m_string(add(s, length)) { }
    4138    AtomicString(const KJS::UString& s) : m_string(add(s)) { }
    4239    AtomicString(const KJS::Identifier& s) : m_string(add(s)) { }
     
    4441    AtomicString(AtomicStringImpl* imp) : m_string(imp) { }
    4542    AtomicString(const String& s) : m_string(add(s.impl())) { }
    46    
     43
    4744    operator const String&() const { return m_string; }
    4845    const String& domString() const { return m_string; };
    49     DeprecatedString deprecatedString() const { return m_string.deprecatedString(); };
    50    
     46
    5147    operator KJS::Identifier() const;
    5248    operator KJS::UString() const;
     
    5450    AtomicStringImpl* impl() const { return static_cast<AtomicStringImpl *>(m_string.impl()); }
    5551   
    56     const QChar* unicode() const { return m_string.unicode(); }
     52    const UChar* characters() const { return m_string.characters(); }
    5753    unsigned length() const { return m_string.length(); }
    5854   
    59     const QChar& operator [](unsigned int i) const { return m_string[i]; }
     55    UChar operator[](unsigned int i) const { return m_string[i]; }
    6056   
    61     bool contains(QChar c) const { return m_string.contains(c); }
     57    bool contains(UChar c) const { return m_string.contains(c); }
    6258    bool contains(const AtomicString& s, bool caseSensitive = true) const
    6359        { return m_string.contains(s.domString(), caseSensitive); }
    6460
    65     int find(QChar c, int start = 0) const { return m_string.find(c, start); }
     61    int find(UChar c, int start = 0) const { return m_string.find(c, start); }
    6662    int find(const AtomicString& s, int start = 0, bool caseSentitive = true) const
    6763        { return m_string.find(s.domString(), start, caseSentitive); }
     
    8783#endif
    8884
     85    AtomicString(const DeprecatedString&);
     86    DeprecatedString deprecatedString() const;
     87
    8988private:
    9089    String m_string;
    9190   
    9291    static StringImpl* add(const char*);
    93     static StringImpl* add(const QChar*, int length);
     92    static StringImpl* add(const UChar*, int length);
    9493    static StringImpl* add(StringImpl*);
    9594    static StringImpl* add(const KJS::UString&);
     
    116115
    117116// Define external global variables for the commonly used atomic strings.
    118 #if !KHTML_ATOMICSTRING_HIDE_GLOBALS
     117#if !ATOMICSTRING_HIDE_GLOBALS
    119118    extern const AtomicString nullAtom;
    120119    extern const AtomicString emptyAtom;
  • trunk/WebCore/platform/Color.cpp

    r14256 r14273  
    2727#include "Color.h"
    2828
     29#include "DeprecatedString.h"
    2930#include "PlatformString.h"
    3031#include <wtf/Assertions.h>
  • trunk/WebCore/platform/DeprecatedString.h

    r14212 r14273  
    5151class QChar {
    5252public:
    53 
    54     enum Direction {
    55         DirL = 0, DirR, DirEN, DirES, DirET, DirAN, DirCS, DirB, DirS, DirWS, DirON,
    56         DirLRE, DirLRO, DirAL, DirRLE, DirRLO, DirPDF, DirNSM, DirBN
    57     };
    58    
    5953    QChar();
    6054    QChar(char);
     
    6862    char latin1() const;
    6963    bool isSpace() const;
    70     bool isDigit() const;
    71     bool isLetter() const;
    72     bool isNumber() const;
    73     bool isLetterOrNumber() const;
    74     bool isPunct() const;
    75     int digitValue() const;
    7664    QChar lower() const;
    7765    QChar upper() const;
    78     Direction direction() const;
    7966
    8067private:
     
    119106    // Use isspace() for basic Latin-1.
    120107    // This will include newlines, which aren't included in unicode DirWS.
    121     return c <= 0x7F ? isspace(c) : direction() == DirWS;
    122 }
    123 
    124 inline bool QChar::isDigit() const
    125 {
    126     // FIXME: If fast enough, we should just call u_isdigit directly.
    127     return c <= 0x7F ? isdigit(c) : u_isdigit(c);
    128 }
    129 
    130 inline bool QChar::isLetter() const
    131 {
    132     // FIXME: If fast enough, we should just call u_isalpha directly.
    133     return c <= 0x7F ? isalpha(c) : u_isalpha(c);
    134 }
    135 
    136 inline bool QChar::isNumber() const
    137 {
    138     // FIXME: If fast enough, we should just call u_isdigit directly.
    139     return c <= 0x7F ? isdigit(c) : u_isdigit(c);
    140 }
    141 
    142 inline bool QChar::isLetterOrNumber() const
    143 {
    144     // FIXME: If fast enough, we should just call u_isalnum directly.
    145     return c <= 0x7F ? isalnum(c) : u_isalnum(c);
    146 }
    147 
    148 inline bool QChar::isPunct() const
    149 {
    150     return u_ispunct(c);
    151 }
    152 
    153 inline int QChar::digitValue() const
    154 {
    155     // FIXME: If fast enough, we should just call u_charDigitValue directly.
    156     return c <= '9' ? c - '0' : u_charDigitValue(c);
     108    return c <= 0x7F ? isspace(c) : (u_charDirection(c) == U_WHITE_SPACE_NEUTRAL);
    157109}
    158110
     
    167119    // FIXME: If fast enough, we should just call u_toupper directly.
    168120    return c <= 0x7F ? toupper(c) : u_toupper(c);
    169 }
    170 
    171 inline QChar::Direction QChar::direction() const
    172 {
    173     return static_cast<Direction>(u_charDirection(c));
    174121}
    175122
  • trunk/WebCore/platform/Font.cpp

    r14216 r14273  
    7777}
    7878
    79 int Font::width(const QChar* chs, int slen, int pos, int len, int tabWidth, int xpos) const
     79int Font::width(const UChar* chs, int slen, int pos, int len, int tabWidth, int xpos) const
    8080{
    8181    // FIXME: Want to define an lroundf for win32.
  • trunk/WebCore/platform/Font.h

    r14216 r14273  
    7474
    7575    void drawText(GraphicsContext*, const IntPoint&, int tabWidth, int xpos,
    76                   const QChar*, int len, int from, int to, int toAdd,
     76                  const UChar*, int len, int from, int to, int toAdd,
    7777                  TextDirection, bool visuallyOrdered) const;
    7878    void drawHighlightForText(GraphicsContext*, const IntPoint&, int h, int tabWidth, int xpos,
    79                               const QChar*, int len, int from, int to, int toAdd,
     79                              const UChar*, int len, int from, int to, int toAdd,
    8080                              TextDirection d, bool visuallyOrdered, const Color& backgroundColor) const;
    8181    void drawLineForText(GraphicsContext*, const IntPoint&, int yOffset, int width) const;
     
    8383    int misspellingLineThickness(GraphicsContext*) const;
    8484
    85     float floatWidth(const QChar*, int slen, int pos, int len, int tabWidth, int xpos, bool runRounding = true) const;
     85    float floatWidth(const UChar*, int slen, int pos, int len, int tabWidth, int xpos, bool runRounding = true) const;
    8686   
    87     int checkSelectionPoint(const QChar*, int slen, int pos, int len, int toAdd, int tabWidth, int xpos,
     87    int checkSelectionPoint(const UChar*, int slen, int pos, int len, int toAdd, int tabWidth, int xpos,
    8888        int x, TextDirection, bool visuallyOrdered, bool includePartialGlyphs) const;
    8989    IntRect selectionRectForText(const IntPoint&, int h, int tabWidth, int xpos,
    90         const QChar*, int slen, int pos, int len, int width,
     90        const UChar*, int slen, int pos, int len, int width,
    9191        bool rtl, bool visuallyOrdered = false, int from = -1, int to = -1) const;
    9292   
    93     int width(const QChar*, int slen, int pos, int len, int tabWidth, int xpos) const;
    94     int width(const QChar* chs, int slen, int tabWidth = 0, int xpos = 0) const { return width(chs, slen, 0, slen, tabWidth, xpos); }
    95     int width(const DeprecatedString& s) const { return width(s.unicode(), s.length(), 0, 0); }
     93    int width(const UChar*, int slen, int pos, int len, int tabWidth, int xpos) const;
     94    int width(const UChar* chs, int slen, int tabWidth = 0, int xpos = 0) const { return width(chs, slen, 0, slen, tabWidth, xpos); }
    9695
    9796    bool isSmallCaps() const { return m_fontDescription.smallCaps(); }
  • trunk/WebCore/platform/GraphicsContext.cpp

    r14174 r14273  
    2727#include "GraphicsContext.h"
    2828
     29#include "DeprecatedString.h"
    2930#include "Font.h"
    3031
     
    193194
    194195// FIXME: We should consider removing this function and having callers just call the lower-level drawText directly.
    195 // FIXME: The int parameter should change to a HorizontalAlignment parameter.
    196 // FIXME: HorizontalAlignment should be moved into a separate header so it's not in Widget.h.
    197196// FIXME: We should consider changing this function to take a character pointer and length instead of a DeprecatedString.
    198 void GraphicsContext::drawText(const IntPoint& point, int horizontalAlignment, const DeprecatedString& str)
    199 {
    200     if (paintingDisabled())
    201         return;
    202 
    203     IntPoint p = point;
    204     if (horizontalAlignment == AlignRight)
    205         p.setX(p.x() - font().width(str.unicode(), str.length(), 0, 0));
    206     drawText(p, 0, 0, str.unicode(), str.length(), 0, str.length(), 0);
    207 }
    208 
    209 void GraphicsContext::drawText(const IntPoint& point, int tabWidth, int xpos, const QChar *str, int slen, int pos, int len, int toAdd,
     197void GraphicsContext::drawText(const IntPoint& point, const DeprecatedString& str)
     198{
     199    if (paintingDisabled())
     200        return;
     201
     202    drawText(point, 0, 0, reinterpret_cast<const UChar*>(str.unicode()), str.length(), 0, str.length(), 0);
     203}
     204
     205void GraphicsContext::drawText(const IntPoint& point, int tabWidth, int xpos, const UChar* str, int slen, int pos, int len, int toAdd,
    210206                               TextDirection d, bool visuallyOrdered, int from, int to)
    211207{
     
    220216}
    221217
    222 void GraphicsContext::drawHighlightForText(const IntPoint& point, int h, int tabWidth, int xpos, const QChar *str, int slen, int pos, int len, int toAdd,
     218void GraphicsContext::drawHighlightForText(const IntPoint& point, int h, int tabWidth, int xpos, const UChar* str, int slen, int pos, int len, int toAdd,
    223219                                           TextDirection d, bool visuallyOrdered, int from, int to, const Color& backgroundColor)
    224220{
  • trunk/WebCore/platform/GraphicsContext.h

    r14256 r14273  
    3333#include "TextDirection.h"
    3434#include <wtf/Noncopyable.h>
     35#include <unicode/umachine.h>
    3536
    3637#if __APPLE__
     
    4445
    4546class DeprecatedString;
    46 class QChar;
    4747
    4848namespace WebCore {
     
    107107        void clearFocusRingClip();
    108108
    109         void drawText(const IntPoint&, int alignmentFlags, const DeprecatedString&);
     109        void drawText(const IntPoint&, const DeprecatedString&);
     110        void drawText(const IntPoint&, int tabWidth, int xpos,
     111            const UChar*, int slen, int pos, int len, int toAdd,
     112            TextDirection = LTR, bool visuallyOrdered = false, int from = -1, int to = -1);
    110113        void drawHighlightForText(const IntPoint&, int h, int tabWidth, int xpos,
    111             const QChar*, int slen, int pos, int len, int toAdd,
     114            const UChar*, int slen, int pos, int len, int toAdd,
    112115            TextDirection, bool visuallyOrdered,
    113116            int from, int to, const Color& backgroundColor);
    114         void drawText(const IntPoint&, int tabWidth, int xpos,
    115             const QChar*, int slen, int pos, int len, int toAdd,
    116             TextDirection = LTR, bool visuallyOrdered = false, int from = -1, int to = -1);
    117117        void drawLineForText(const IntPoint&, int yOffset, int width);
    118118        void drawLineForMisspelling(const IntPoint&, int width);
  • trunk/WebCore/platform/PlatformString.h

    r14256 r14273  
    3939 */
    4040
    41 // FIXME: Move to unsigned short instead of QChar.
    42 
    4341class String {
    4442public:
    4543    String() { } // gives null string, distinguishable from an empty string
    46     String(QChar c) : m_impl(new StringImpl(&c, 1)) { }
    47     String(const QChar*, unsigned length);
    48     String(const DeprecatedString&);
     44    String(const UChar*, unsigned length);
    4945    String(const KJS::Identifier&);
    5046    String(const KJS::UString&);
     
    5652    operator KJS::UString() const;
    5753
    58     String& operator +=(const String&);
     54    unsigned length() const;
     55    const UChar* characters() const;
    5956
    60     void insert(const String&, unsigned pos);
    61 
    62     const QChar& operator[](unsigned i) const; // if i >= length(), returns 0
     57    UChar operator[](unsigned i) const; // if i >= length(), returns 0
    6358   
    64     bool contains(QChar c) const { return find(c) != -1; }
     59    bool contains(UChar c) const { return find(c) != -1; }
    6560    bool contains(const char* str, bool caseSensitive = true) const { return find(str, 0, caseSensitive) != -1; }
    6661    bool contains(const String& str, bool caseSensitive = true) const { return find(str, 0, caseSensitive) != -1; }
    6762
    68     int find(QChar c, int start = 0) const
     63    int find(UChar c, int start = 0) const
    6964        { return m_impl ? m_impl->find(c, start) : -1; }
    7065    int find(const char* str, int start = 0, bool caseSensitive = true) const
     
    7873        { return m_impl ? m_impl->endsWith(s.impl(), caseSensitive) : s.isEmpty(); }
    7974
    80     String& replace(QChar a, QChar b) { if (m_impl) m_impl = m_impl->replace(a, b); return *this; }
    81     String& replace(QChar a, const String& b) { if (m_impl) m_impl = m_impl->replace(a, b.impl()); return *this; }
     75    void append(const String&);
     76    void insert(const String&, unsigned pos);
     77
     78    String& replace(UChar a, UChar b) { if (m_impl) m_impl = m_impl->replace(a, b); return *this; }
     79    String& replace(UChar a, const String& b) { if (m_impl) m_impl = m_impl->replace(a, b.impl()); return *this; }
    8280    String& replace(unsigned index, unsigned len, const String& b) { if (m_impl) m_impl = m_impl->replace(index, len, b.impl()); return *this; }
    8381
    84     unsigned length() const;
    8582    void truncate(unsigned len);
    8683    void remove(unsigned pos, int len = 1);
     
    9794    String upper() const;
    9895
    99     const QChar* unicode() const;
    100     DeprecatedString deprecatedString() const;
    101    
     96    // Return the string with case folded for case insensitive comparison.
     97    String foldCase() const;
     98
    10299    static String number(int);
    103100    static String number(unsigned);
     
    108105    static String sprintf(const char *, ...)
    109106#if __GNUC__
    110     __attribute__ ((format (printf, 1, 2)))
     107        __attribute__ ((format (printf, 1, 2)))
    111108#endif
    112     ;
     109        ;
    113110
    114111    int toInt(bool* ok = 0) const;
     
    138135#endif
    139136
     137    String(const DeprecatedString&);
     138    DeprecatedString deprecatedString() const;
     139   
    140140private:
    141141    RefPtr<StringImpl> m_impl;
     
    145145String operator+(const String&, const char*);
    146146String operator+(const char*, const String&);
    147 String operator+(const String&, QChar);
    148 String operator+(QChar, const String&);
    149 String operator+(const String&, char);
    150 String operator+(char, const String&);
     147
     148inline String& operator+=(String& a, const String& b) { a.append(b); return a; }
    151149
    152150inline bool operator==(const String& a, const String& b) { return equal(a.impl(), b.impl()); }
     
    163161
    164162bool operator==(const String& a, const DeprecatedString& b);
    165 inline bool operator==( const DeprecatedString& b, const String& a) { return a == b; }
     163inline bool operator==(const DeprecatedString& b, const String& a) { return a == b; }
    166164inline bool operator!=(const String& a, const DeprecatedString& b) { return !(a == b); }
    167165inline bool operator!=(const DeprecatedString& b, const String& a ) { return !(a == b); }
  • trunk/WebCore/platform/SegmentedString.cpp

    r14212 r14273  
    5757{
    5858    unsigned length = m_currentString.m_length;
    59     if (m_pushedChar1.unicode()) {
     59    if (m_pushedChar1) {
    6060        ++length;
    61         if (m_pushedChar2.unicode())
     61        if (m_pushedChar2)
    6262            ++length;
    6363    }
     
    119119            append(*i);
    120120    }
    121     m_currentChar = m_pushedChar1.unicode() ? &m_pushedChar1 : m_currentString.m_current;
     121    m_currentChar = m_pushedChar1 ? &m_pushedChar1 : m_currentString.m_current;
    122122}
    123123
     
    133133    }
    134134    prepend(s.m_currentString);
    135     m_currentChar = m_pushedChar1.unicode() ? &m_pushedChar1 : m_currentString.m_current;
     135    m_currentChar = m_pushedChar1 ? &m_pushedChar1 : m_currentString.m_current;
    136136}
    137137
     
    151151{
    152152    DeprecatedString result;
    153     if (m_pushedChar1.unicode()) {
     153    if (m_pushedChar1) {
    154154        result.append(m_pushedChar1);
    155         if (m_pushedChar2.unicode())
     155        if (m_pushedChar2)
    156156            result.append(m_pushedChar2);
    157157    }
  • trunk/WebCore/platform/SegmentedString.h

    r14213 r14273  
    22    This file is part of the KDE libraries
    33
    4     Copyright (C) 2004-6 Apple Computer
     4    Copyright (C) 2004, 2005, 2006 Apple Computer
    55
    66    This library is free software; you can redistribute it and/or
     
    1919    Boston, MA 02111-1307, USA.
    2020*/
    21 //----------------------------------------------------------------------------
    22 //
    23 // KDE HTML Widget -- String class
    2421
    25 #ifndef KHTMLSTRING_H
    26 #define KHTMLSTRING_H
     22#ifndef SegmentedString_h
     23#define SegmentedString_h
    2724
     25#include "DeprecatedString.h"
    2826#include "DeprecatedValueList.h"
    2927#include "PlatformString.h"
     
    4038    SegmentedSubstring() : m_length(0), m_current(0) {}
    4139    SegmentedSubstring(const DeprecatedString &str) : m_string(str), m_length(str.length()) {
    42         m_current = m_length == 0 ? 0 : m_string.stableUnicode();
     40        m_current = m_length == 0 ? 0 : reinterpret_cast<const UChar*>(m_string.stableUnicode());
    4341    }
    4442
    45     SegmentedSubstring(const QChar *str, int length) : m_length(length), m_current(length == 0 ? 0 : str) {}
     43    SegmentedSubstring(const UChar* str, int length) : m_length(length), m_current(length == 0 ? 0 : str) {}
    4644
    4745    void clear() { m_length = 0; m_current = 0; }
    4846   
    49     void appendTo(DeprecatedString &str) const {
    50         if (m_string.unicode() == m_current) {
     47    void appendTo(DeprecatedString& str) const {
     48        if (reinterpret_cast<const UChar*>(m_string.unicode()) == m_current) {
    5149            if (str.isEmpty())
    5250                str = m_string;
     
    5452                str.append(m_string);
    5553        } else {
    56             str.insert(str.length(), m_current, m_length);
     54            str.insert(str.length(), reinterpret_cast<const QChar*>(m_current), m_length);
    5755        }
    5856    }
     
    6058    DeprecatedString m_string;
    6159    int m_length;
    62     const QChar *m_current;
     60    const UChar* m_current;
    6361};
    6462
    6563class SegmentedString {
    6664public:
    67     SegmentedString() : m_currentChar(0), m_lines(0), m_composite(false) {}
    68     SegmentedString(const QChar *str, int length) : m_currentString(str, length), m_currentChar(m_currentString.m_current), m_lines(0), m_composite(false) {}
    69     SegmentedString(const DeprecatedString &str) : m_currentString(str), m_currentChar(m_currentString.m_current), m_lines(0), m_composite(false) {}
     65    SegmentedString()
     66        : m_pushedChar1(0), m_pushedChar2(0), m_currentChar(0)
     67        , m_lines(0), m_composite(false) {}
     68    SegmentedString(const UChar* str, int length) : m_pushedChar1(0), m_pushedChar2(0)
     69        , m_currentString(str, length), m_currentChar(m_currentString.m_current)
     70        , m_lines(0), m_composite(false) {}
     71    SegmentedString(const DeprecatedString &str)
     72        : m_pushedChar1(0), m_pushedChar2(0), m_currentString(str)
     73        , m_currentChar(m_currentString.m_current)
     74        , m_lines(0), m_composite(false) {}
    7075    SegmentedString(const SegmentedString&);
    7176
     
    7782    void prepend(const SegmentedString &);
    7883   
    79     void push(QChar c) {
    80         if (!m_pushedChar1.unicode()) {
     84    void push(UChar c) {
     85        if (!m_pushedChar1) {
    8186            m_pushedChar1 = c;
    82             m_currentChar = m_pushedChar1.unicode() ? &m_pushedChar1 : m_currentString.m_current;
     87            m_currentChar = m_pushedChar1 ? &m_pushedChar1 : m_currentString.m_current;
    8388        } else {
    84             assert(!m_pushedChar2.unicode());
     89            assert(!m_pushedChar2);
    8590            m_pushedChar2 = c;
    8691        }
     
    9196
    9297    void advance() {
    93         if (m_pushedChar1.unicode()) {
     98        if (m_pushedChar1) {
    9499            m_pushedChar1 = m_pushedChar2;
    95100            m_pushedChar2 = 0;
     
    99104                advanceSubstring();
    100105        }
    101         m_currentChar = m_pushedChar1.unicode() ? &m_pushedChar1 : m_currentString.m_current;
     106        m_currentChar = m_pushedChar1 ? &m_pushedChar1 : m_currentString.m_current;
    102107    }
    103108   
    104     bool escaped() const { return m_pushedChar1.unicode(); }
     109    bool escaped() const { return m_pushedChar1; }
    105110
    106111    int lineCount() const { return m_lines; }
     
    110115
    111116    void operator++() { advance(); }
    112     const QChar &operator*() const { return *current(); }
    113     const QChar *operator->() const { return current(); }
     117    const UChar& operator*() const { return *current(); }
     118    const UChar* operator->() const { return current(); }
    114119   
    115120private:
     
    118123
    119124    void advanceSubstring();
    120     const QChar *current() const { return m_currentChar; }
     125    const UChar* current() const { return m_currentChar; }
    121126
    122     QChar m_pushedChar1;
    123     QChar m_pushedChar2;
     127    UChar m_pushedChar1;
     128    UChar m_pushedChar2;
    124129    SegmentedSubstring m_currentString;
    125     const QChar *m_currentChar;
     130    const UChar* m_currentChar;
    126131    DeprecatedValueList<SegmentedSubstring> m_substrings;
    127132    int m_lines;
  • trunk/WebCore/platform/StreamingTextDecoder.cpp

    r14256 r14273  
    4545static const UChar replacementCharacter = 0xFFFD;
    4646static const UChar BOM = 0xFEFF;
    47 static const int ConversionBufferSize = 16384;
     47static const size_t ConversionBufferSize = 16384;
    4848   
    4949static UConverter* cachedConverterICU;
     
    6060}
    6161
    62 DeprecatedString StreamingTextDecoder::convertUTF16(const unsigned char *s, int length)
     62DeprecatedString StreamingTextDecoder::convertUTF16(const unsigned char* s, int length)
    6363{
    6464    ASSERT(m_numBufferedBytes == 0 || m_numBufferedBytes == 1);
    6565
    66     const unsigned char *p = s;
    67     unsigned len = length;
     66    const unsigned char* p = s;
     67    size_t len = length;
    6868   
    6969    DeprecatedString result("");
     
    8080
    8181        if (c)
    82             result.append(reinterpret_cast<QChar *>(&c), 1);
     82            result.append(reinterpret_cast<QChar*>(&c), 1);
    8383
    8484        m_numBufferedBytes = 0;
     
    8989    while (len > 1) {
    9090        UChar buffer[ConversionBufferSize];
    91         int runLength = min(len / 2, (unsigned)(sizeof(buffer) / sizeof(buffer[0])));
     91        int runLength = min(len / 2, ConversionBufferSize);
    9292        int bufferLength = 0;
    9393        if (m_littleEndian) {
     
    9595                UChar c = p[0] | (p[1] << 8);
    9696                p += 2;
    97                 if (c && c != BOM)
     97                if (c != BOM)
    9898                    buffer[bufferLength++] = c;
    9999            }
     
    102102                UChar c = (p[0] << 8) | p[1];
    103103                p += 2;
    104                 if (c && c != BOM)
     104                if (c != BOM)
    105105                    buffer[bufferLength++] = c;
    106106            }
    107107        }
    108         result.append(reinterpret_cast<QChar *>(buffer), bufferLength);
     108        result.append(reinterpret_cast<QChar*>(buffer), bufferLength);
    109109        len -= runLength * 2;
    110110    }
     
    119119}
    120120
     121bool StreamingTextDecoder::convertIfASCII(const unsigned char* s, int length, DeprecatedString& str)
     122{
     123    ASSERT(m_numBufferedBytes == 0 || m_numBufferedBytes == 1);
     124
     125    DeprecatedString result("");
     126    result.reserve(length);
     127
     128    const unsigned char* p = s;
     129    size_t len = length;
     130    unsigned char ored = 0;
     131    while (len) {
     132        UChar buffer[ConversionBufferSize];
     133        int runLength = min(len, ConversionBufferSize);
     134        int bufferLength = 0;
     135        for (int i = 0; i < runLength; ++i) {
     136            unsigned char c = *p++;
     137            ored |= c;
     138            buffer[bufferLength++] = c;
     139        }
     140        if (ored & 0x80)
     141            return false;
     142        result.append(reinterpret_cast<QChar*>(buffer), bufferLength);
     143        len -= runLength;
     144    }
     145
     146    str = result;
     147    return true;
     148}
     149
    121150static inline TextEncoding effectiveEncoding(const TextEncoding& encoding)
    122151{
     
    127156}
    128157
    129 UErrorCode StreamingTextDecoder::createICUConverter()
     158void StreamingTextDecoder::createICUConverter()
    130159{
    131160    TextEncoding encoding = effectiveEncoding(m_encoding);
     
    142171        ASSERT(!m_converterICU);
    143172        m_converterICU = ucnv_open(encodingName, &err);
     173#if !LOG_DISABLED
    144174        if (err == U_AMBIGUOUS_ALIAS_WARNING)
    145175            LOG_ERROR("ICU ambiguous alias warning for encoding: %s", encodingName);
    146 
    147         if (!m_converterICU) {
     176        if (!m_converterICU)
    148177            LOG_ERROR("the ICU Converter won't convert from text encoding 0x%X, error %d", encoding.encodingID(), err);
    149             return err;
    150         }
    151     }
    152    
    153     return U_ZERO_ERROR;
     178#endif
     179    }
    154180}
    155181
     
    163189}
    164190
    165 void StreamingTextDecoder::appendOmittingUnwanted(DeprecatedString &s, const UChar *characters, int byteCount)
     191void StreamingTextDecoder::appendOmittingUnwanted(DeprecatedString& s, const UChar* characters, int byteCount)
    166192{
    167193    ASSERT(byteCount % sizeof(UChar) == 0);
     
    171197        if (unwanted(characters[i])) {
    172198            if (start != i)
    173                 s.append(reinterpret_cast<const QChar *>(&characters[start]), i - start);
     199                s.append(reinterpret_cast<const QChar*>(&characters[start]), i - start);
    174200            start = i + 1;
    175201        }
    176202    }
    177203    if (start != characterCount)
    178         s.append(reinterpret_cast<const QChar *>(&characters[start]), characterCount - start);
    179 }
    180 
    181 DeprecatedString StreamingTextDecoder::convertUsingICU(const unsigned char *chs, int len, bool flush)
     204        s.append(reinterpret_cast<const QChar*>(&characters[start]), characterCount - start);
     205}
     206
     207DeprecatedString StreamingTextDecoder::convertUsingICU(const unsigned char* chs, int len, bool flush)
    182208{
    183209    // Get a converter for the passed-in encoding.
    184     if (!m_converterICU && U_FAILURE(createICUConverter()))
    185         return DeprecatedString();
    186 
    187     ASSERT(m_converterICU);
     210    if (!m_converterICU) {
     211        createICUConverter();
     212        if (!m_converterICU)
     213            return DeprecatedString();
     214    }
    188215
    189216    DeprecatedString result("");
     
    191218
    192219    UChar buffer[ConversionBufferSize];
    193     const char *source = reinterpret_cast<const char *>(chs);
    194     const char *sourceLimit = source + len;
    195     int32_t *offsets = NULL;
     220    const char* source = reinterpret_cast<const char*>(chs);
     221    const char* sourceLimit = source + len;
     222    int32_t* offsets = NULL;
    196223    UErrorCode err;
    197    
     224
    198225    do {
    199         UChar *target = buffer;
    200         const UChar *targetLimit = target + ConversionBufferSize;
     226        UChar* target = buffer;
     227        const UChar* targetLimit = target + ConversionBufferSize;
    201228        err = U_ZERO_ERROR;
    202229        ucnv_toUnicode(m_converterICU, &target, targetLimit, &source, sourceLimit, offsets, flush, &err);
    203230        int count = target - buffer;
    204         appendOmittingUnwanted(result, reinterpret_cast<const UChar *>(buffer), count * sizeof(UChar));
     231        appendOmittingUnwanted(result, reinterpret_cast<const UChar*>(buffer), count * sizeof(UChar));
    205232    } while (err == U_BUFFER_OVERFLOW_ERROR);
    206233
     
    216243        return DeprecatedString();
    217244    }
    218    
     245
    219246    return result;
    220247}
    221248
    222 DeprecatedString StreamingTextDecoder::convert(const unsigned char *chs, int len, bool flush)
    223 {
     249DeprecatedString StreamingTextDecoder::convert(const unsigned char* chs, int len, bool flush)
     250{
     251    switch (m_encoding.encodingID()) {
     252        case UTF16Encoding:
     253            return convertUTF16(chs, len);
     254
     255        case ASCIIEncoding:
     256        case Latin1Encoding:
     257        case WinLatin1Encoding: {
     258            DeprecatedString result;
     259            if (convertIfASCII(chs, len, result))
     260                return result;
     261            break;
     262        }
     263
     264        case UTF8Encoding:
     265            // If a previous run used ICU, we might have a partly converted character.
     266            // If so, don't use the optimized ASCII code path.
     267            if (!m_converterICU) {
     268                DeprecatedString result;
     269                if (convertIfASCII(chs, len, result))
     270                    return result;
     271            }
     272            break;
     273
     274        default:
     275            break;
     276    }
     277
    224278    //#define PARTIAL_CHARACTER_HANDLING_TEST_CHUNK_SIZE 1000
    225 
    226     switch (m_encoding.encodingID()) {
    227     case UTF16Encoding:
    228         return convertUTF16(chs, len);
    229 
    230     default:
    231279#if PARTIAL_CHARACTER_HANDLING_TEST_CHUNK_SIZE
    232         DeprecatedString result;
    233         int chunkSize;
    234         for (int i = 0; i != len; i += chunkSize) {
    235             chunkSize = len - i;
    236             if (chunkSize > PARTIAL_CHARACTER_HANDLING_TEST_CHUNK_SIZE) {
    237                 chunkSize = PARTIAL_CHARACTER_HANDLING_TEST_CHUNK_SIZE;
    238             }
    239             result += convertUsingICU(chs + i, chunkSize, flush && (i + chunkSize == len));
    240         }
    241         return result;
     280    DeprecatedString result;
     281    int chunkSize;
     282    for (int i = 0; i != len; i += chunkSize) {
     283        chunkSize = len - i;
     284        if (chunkSize > PARTIAL_CHARACTER_HANDLING_TEST_CHUNK_SIZE) {
     285            chunkSize = PARTIAL_CHARACTER_HANDLING_TEST_CHUNK_SIZE;
     286        }
     287        result += convertUsingICU(chs + i, chunkSize, flush && (i + chunkSize == len));
     288    }
     289    return result;
    242290#else
    243         return convertUsingICU(chs, len, flush);
     291    return convertUsingICU(chs, len, flush);
    244292#endif
    245     }
    246     ASSERT_NOT_REACHED();
    247     return DeprecatedString();
    248 }
    249 
    250 DeprecatedString StreamingTextDecoder::toUnicode(const char *chs, int len, bool flush)
     293}
     294
     295DeprecatedString StreamingTextDecoder::toUnicode(const char* chs, int len, bool flush)
    251296{
    252297    ASSERT_ARG(len, len >= 0);
     
    266311    int buf1Len = numBufferedBytes;
    267312    int buf2Len = len;
    268     const unsigned char *buf1 = m_bufferedBytes;
    269     const unsigned char *buf2 = reinterpret_cast<const unsigned char *>(chs);
     313    const unsigned char* buf1 = m_bufferedBytes;
     314    const unsigned char* buf2 = reinterpret_cast<const unsigned char*>(chs);
    270315    unsigned char c1 = buf1Len ? (--buf1Len, *buf1++) : buf2Len ? (--buf2Len, *buf2++) : 0;
    271316    unsigned char c2 = buf1Len ? (--buf1Len, *buf1++) : buf2Len ? (--buf2Len, *buf2++) : 0;
  • trunk/WebCore/platform/StreamingTextDecoder.h

    r14256 r14273  
    3838        StreamingTextDecoder(const TextEncoding&);
    3939        ~StreamingTextDecoder();
    40        
     40
    4141        DeprecatedString toUnicode(const char* chs, int len, bool flush = false);
    42        
     42
    4343    private:
    44         DeprecatedString convert(const char*chs, int len, bool flush)
     44        DeprecatedString convert(const char* chs, int len, bool flush)
    4545            { return convert(reinterpret_cast<const unsigned char*>(chs), len, flush); }
    4646        DeprecatedString convert(const unsigned char* chs, int len, bool flush);
    47         DeprecatedString convertUTF16(const unsigned char* chs, int len);
    48        
    49         // ICU decoding.
    50         DeprecatedString convertUsingICU(const unsigned char *chs, int len, bool flush);
    51         UErrorCode createICUConverter();
    5247
    53         static void appendOmittingUnwanted(DeprecatedString& s, const UChar* characters, int byteCount);
     48        bool convertIfASCII(const unsigned char*, int len, DeprecatedString&);
     49        DeprecatedString convertUTF16(const unsigned char*, int len);
     50        DeprecatedString convertUsingICU(const unsigned char*, int len, bool flush);
     51
     52        void createICUConverter();
     53
     54        static void appendOmittingUnwanted(DeprecatedString&, const UChar* characters, int byteCount);
    5455
    5556        TextEncoding m_encoding;
  • trunk/WebCore/platform/String.cpp

    r14256 r14273  
    2424#include "PlatformString.h"
    2525
     26#include "DeprecatedString.h"
    2627#include <kjs/identifier.h>
    2728#include <wtf/Vector.h>
    2829#include <stdarg.h>
    2930
    30 using namespace KJS;
     31using KJS::Identifier;
     32using KJS::UString;
    3133
    3234namespace WebCore {
    3335
    34 String::String(const QChar* str, unsigned len)
     36String::String(const UChar* str, unsigned len)
    3537{
    3638    if (!str)
     
    5153        m_impl = StringImpl::empty();
    5254    else
    53         m_impl = new StringImpl(str.unicode(), str.length());
     55        m_impl = new StringImpl(reinterpret_cast<const UChar*>(str.unicode()), str.length());
    5456}
    5557
     
    7779}
    7880
    79 String& String::operator+=(const String &str)
     81void String::append(const String &str)
    8082{
    8183    if (str.m_impl) {
     
    8385            // ### FIXME!!!
    8486            m_impl = str.m_impl;
    85             return *this;
     87            return;
    8688        }
    8789        m_impl = m_impl->copy();
    8890        m_impl->append(str.m_impl.get());
    8991    }
    90     return *this;
    9192}
    9293
     
    112113}
    113114
    114 String operator+(const String& s, QChar c)
    115 {
    116     return s + String(c);
    117 }
    118 
    119 String operator+(QChar c, const String& s)
    120 {
    121     return String(c) + s;
    122 }
    123 
    124 String operator+(const String& s, char c)
    125 {
    126     return s + String(c);
    127 }
    128 
    129 String operator+(char c, const String& s)
    130 {
    131     return String(c) + s;
    132 }
    133 
    134115void String::insert(const String& str, unsigned pos)
    135116{
     
    140121}
    141122
    142 const QChar& String::operator[](unsigned i) const
    143 {
    144     static const QChar nullChar = 0;
    145     if (!m_impl || i >= m_impl->length() )
    146         return nullChar;
    147     return *(m_impl->unicode()+i);
     123UChar String::operator[](unsigned i) const
     124{
     125    if (!m_impl || i >= m_impl->length())
     126        return 0;
     127    return m_impl->characters()[i];
    148128}
    149129
     
    195175}
    196176
     177String String::foldCase() const
     178{
     179    if (!m_impl)
     180        return String();
     181    return m_impl->foldCase();
     182}
     183
    197184bool String::percentage(int& result) const
    198185{
     
    200187        return false;
    201188
    202     if (*(m_impl->unicode()+m_impl->length()-1) != '%')
     189    if ((*m_impl)[m_impl->length() - 1] != '%')
    203190       return false;
    204191
    205     result = QConstString(m_impl->unicode(), m_impl->length()-1).string().toInt();
     192    result = QConstString(reinterpret_cast<const QChar*>(m_impl->characters()), m_impl->length() - 1).string().toInt();
    206193    return true;
    207194}
    208195
    209 const QChar* String::unicode() const
     196const UChar* String::characters() const
    210197{
    211198    if (!m_impl)
    212199        return 0;
    213     return m_impl->unicode();
     200    return m_impl->characters();
    214201}
    215202
     
    218205    if (!m_impl)
    219206        return DeprecatedString::null;
    220     if (!m_impl->unicode())
     207    if (!m_impl->characters())
    221208        return DeprecatedString("", 0);
    222     return DeprecatedString(m_impl->unicode(), m_impl->length());
     209    return DeprecatedString(reinterpret_cast<const QChar*>(m_impl->characters()), m_impl->length());
    223210}
    224211
     
    230217    Vector<char, 256> buffer;
    231218#if PLATFORM(WIN_OS)
    232     // Windows vnsprintf does not return the expected size on overflow
     219    // Windows vsnprintf does not return the expected size on overflow
    233220    // So we just have to keep looping until our vsprintf call works!
    234221    int result = 0;
     
    237224            buffer.resize(buffer.capacity() * 2);
    238225        result = vsnprintf(buffer.data(), buffer.capacity(), format, args);
    239         // Windows vnsprintf returns -1 both for all errors.  There is no
     226        // Windows vsnprintf returns -1 for both errors. Since there is no
    240227        // way to distinguish between "not enough room" and "invalid format"
    241228        // we just keep trying until we hit an arbitrary size and then stop.
     
    309296bool String::isEmpty() const
    310297{
    311     return (!m_impl || m_impl->length() == 0);
     298    return !m_impl || !m_impl->length();
    312299}
    313300
     
    334321    if (l != b.length())
    335322        return false;
    336     if (!memcmp(a.unicode(), b.unicode(), l * sizeof(QChar)))
     323    if (!memcmp(a.characters(), b.unicode(), l * sizeof(UChar)))
    337324        return true;
    338325    return false;
     
    347334        m_impl = StringImpl::empty();
    348335    else
    349         m_impl = new StringImpl(reinterpret_cast<const QChar*>(str.data()), str.size());
     336        m_impl = new StringImpl(reinterpret_cast<const UChar*>(str.data()), str.size());
    350337}
    351338
     
    358345        m_impl = StringImpl::empty();
    359346    else
    360         m_impl = new StringImpl(reinterpret_cast<const QChar*>(str.data()), str.size());
     347        m_impl = new StringImpl(reinterpret_cast<const UChar*>(str.data()), str.size());
    361348}
    362349
     
    365352    if (!m_impl)
    366353        return Identifier();
    367     return Identifier(reinterpret_cast<const KJS::UChar*>(m_impl->unicode()), m_impl->length());
     354    return Identifier(reinterpret_cast<const KJS::UChar*>(m_impl->characters()), m_impl->length());
    368355}
    369356
     
    372359    if (!m_impl)
    373360        return UString();
    374     return UString(reinterpret_cast<const KJS::UChar*>(m_impl->unicode()), m_impl->length());
    375 }
    376 
    377 }
     361    return UString(reinterpret_cast<const KJS::UChar*>(m_impl->characters()), m_impl->length());
     362}
     363
     364}
  • trunk/WebCore/platform/StringHash.h

    r14256 r14273  
    2525#include "PlatformString.h"
    2626#include <wtf/HashTraits.h>
     27#include <unicode/uchar.h>
     28#include <unicode/ustring.h>
    2729
    2830namespace WTF {
     
    4446                return false;
    4547
    46             const uint32_t* aChars = reinterpret_cast<const uint32_t*>(a->unicode());
    47             const uint32_t* bChars = reinterpret_cast<const uint32_t*>(b->unicode());
     48            const uint32_t* aChars = reinterpret_cast<const uint32_t*>(a->characters());
     49            const uint32_t* bChars = reinterpret_cast<const uint32_t*>(b->characters());
    4850
    4951            unsigned halfLength = aLength >> 1;
     
    6971        {
    7072            unsigned l = str->length();
    71             const QChar* s = str->unicode();
     73            const UChar* s = str->characters();
    7274            uint32_t hash = PHI;
    7375            uint32_t tmp;
     
    7880            // Main loop
    7981            for (; l > 0; l--) {
    80                 hash += s[0].lower().unicode();
    81                 tmp = (s[1].lower().unicode() << 11) ^ hash;
     82                hash += u_foldCase(s[0], U_FOLD_CASE_DEFAULT);
     83                tmp = (u_foldCase(s[1], U_FOLD_CASE_DEFAULT) << 11) ^ hash;
    8284                hash = (hash << 16) ^ tmp;
    8385                s += 2;
     
    8789            // Handle end case
    8890            if (rem) {
    89                 hash += s[0].lower().unicode();
     91                hash += u_foldCase(s[0], U_FOLD_CASE_DEFAULT);
    9092                hash ^= hash << 11;
    9193                hash += hash >> 17;
     
    124126            // Main loop
    125127            for (; l > 0; l--) {
    126                 hash += QChar(s[0]).lower().unicode();
    127                 tmp = (QChar(s[1]).lower().unicode() << 11) ^ hash;
     128                hash += u_foldCase(s[0], U_FOLD_CASE_DEFAULT);
     129                tmp = (u_foldCase(s[1], U_FOLD_CASE_DEFAULT) << 11) ^ hash;
    128130                hash = (hash << 16) ^ tmp;
    129131                s += 2;
     
    133135            // Handle end case
    134136            if (rem) {
    135                 hash += QChar(s[0]).lower().unicode();
     137                hash += u_foldCase(s[0], U_FOLD_CASE_DEFAULT);
    136138                hash ^= hash << 11;
    137139                hash += hash >> 17;
     
    156158        static bool equal(const WebCore::StringImpl* a, const WebCore::StringImpl* b)
    157159        {
    158             if (a == b) return true;
    159             if (!a || !b) return false;
     160            if (a == b)
     161                return true;
     162            if (!a || !b)
     163                return false;
    160164            unsigned length = a->length();
    161165            if (length != b->length())
    162166                return false;
    163             const QChar* as = a->unicode();
    164             const QChar* bs = b->unicode();
    165             for (unsigned i = 0; i != length; ++i)
    166                 if (as[i].lower() != bs[i].lower())
    167                     return false;
    168             return true;
    169         }
    170     };
    171 
    172     template<> struct StrHash<WebCore::AtomicStringImpl*> : public StrHash<WebCore::StringImpl*> {
    173     };
     167            return u_memcasecmp(a->characters(), b->characters(), length, U_FOLD_CASE_DEFAULT) == 0;
     168        }
     169    };
     170
     171    template<> struct StrHash<WebCore::AtomicStringImpl*> : public StrHash<WebCore::StringImpl*> { };
    174172
    175173    template<> struct StrHash<RefPtr<WebCore::StringImpl> > {
  • trunk/WebCore/platform/StringImpl.cpp

    r14256 r14273  
    2929
    3030#include "AtomicString.h"
     31#include "DeprecatedString.h"
    3132#include "Length.h"
    3233#include "StringHash.h"
     
    3435#include <wtf/Assertions.h>
    3536#include <unicode/ubrk.h>
     37#include <unicode/ustring.h>
    3638#include <assert.h>
    3739
    38 using namespace KJS;
    3940using namespace WTF;
    4041
     42using KJS::Identifier;
     43using KJS::UString;
     44
    4145namespace WebCore {
    4246
    43 static inline QChar* newQCharVector(unsigned n)
    44 {
    45     return static_cast<QChar*>(fastMalloc(sizeof(QChar) * n));
    46 }
    47 
    48 static inline void deleteQCharVector(QChar* p)
     47const UChar nonBreakingSpace = 0xA0;
     48
     49static inline UChar* newUCharVector(unsigned n)
     50{
     51    return static_cast<UChar*>(fastMalloc(sizeof(UChar) * n));
     52}
     53
     54static inline void deleteUCharVector(UChar* p)
    4955{
    5056    fastFree(p);
     
    6066StringImpl::StringImpl(const DeprecatedString& str)
    6167{
    62     initWithQChar(str.unicode(), str.length());
    63 }
    64 
    65 StringImpl::StringImpl(const QChar* str, unsigned len)
    66 {
    67     initWithQChar(str, len);
     68    init(reinterpret_cast<const UChar*>(str.unicode()), str.length());
     69}
     70
     71StringImpl::StringImpl(const UChar* str, unsigned len)
     72{
     73    init(str, len);
    6874}
    6975
    7076StringImpl::StringImpl(const char* str)
    7177{
    72     initWithChar(str, strlen(str));
     78    init(str, strlen(str));
    7379}
    7480
    7581StringImpl::StringImpl(const char* str, unsigned len)
    7682{
    77     initWithChar(str, len);
    78 }
    79 
    80 void StringImpl::initWithChar(const char* str, unsigned len)
     83    init(str, len);
     84}
     85
     86void StringImpl::init(const char* str, unsigned len)
    8187{
    8288    m_hash = 0;
     
    8894    }
    8995   
    90     m_data = newQCharVector(m_length);
     96    m_data = newUCharVector(m_length);
    9197    int i = m_length;
    92     QChar* ptr = m_data;
     98    UChar* ptr = m_data;
    9399    while (i--)
    94100        *ptr++ = *str++;
    95101}
    96102
    97 void StringImpl::initWithQChar(const QChar* str, unsigned len)
     103void StringImpl::init(const UChar* str, unsigned len)
    98104{
    99105    m_hash = 0;
     
    105111    }
    106112   
    107     m_data = newQCharVector(len);
    108     memcpy(m_data, str, len * sizeof(QChar));
     113    m_data = newUCharVector(len);
     114    memcpy(m_data, str, len * sizeof(UChar));
    109115}
    110116
     
    113119    if (m_inTable)
    114120        AtomicString::remove(this);
    115     deleteQCharVector(m_data);
     121    deleteUCharVector(m_data);
    116122}
    117123
     
    122128    {
    123129        int newlen = m_length+str->m_length;
    124         QChar* c = newQCharVector(newlen);
    125         memcpy(c, m_data, m_length*sizeof(QChar));
    126         memcpy(c+m_length, str->m_data, str->m_length*sizeof(QChar));
    127         deleteQCharVector(m_data);
     130        UChar* c = newUCharVector(newlen);
     131        memcpy(c, m_data, m_length * sizeof(UChar));
     132        memcpy(c + m_length, str->m_data, str->m_length * sizeof(UChar));
     133        deleteUCharVector(m_data);
    128134        m_data = c;
    129135        m_length = newlen;
     
    140146    if (str && str->m_length != 0) {
    141147        int newlen = m_length + str->m_length;
    142         QChar* c = newQCharVector(newlen);
    143         memcpy(c, m_data, pos*sizeof(QChar));
    144         memcpy(c+pos, str->m_data, str->m_length*sizeof(QChar));
    145         memcpy(c+pos+str->m_length, m_data+pos, (m_length-pos)*sizeof(QChar));
    146         deleteQCharVector(m_data);
     148        UChar* c = newUCharVector(newlen);
     149        memcpy(c, m_data, pos * sizeof(UChar));
     150        memcpy(c + pos, str->m_data, str->m_length * sizeof(UChar));
     151        memcpy(c + pos + str->m_length, m_data + pos, (m_length - pos) * sizeof(UChar));
     152        deleteUCharVector(m_data);
    147153        m_data = c;
    148154        m_length = newlen;
     
    156162        return;
    157163    int nl = len < 1 ? 1 : len;
    158     QChar* c = newQCharVector(nl);
    159     memcpy(c, m_data, nl*sizeof(QChar));
    160     deleteQCharVector(m_data);
     164    UChar* c = newUCharVector(nl);
     165    memcpy(c, m_data, nl * sizeof(UChar));
     166    deleteUCharVector(m_data);
    161167    m_data = c;
    162168    m_length = len;
     
    168174    if (len <= 0)
    169175        return;
    170     if (pos >= m_length )
     176    if (pos >= m_length)
    171177        return;
    172178    if ((unsigned)len > m_length - pos)
     
    174180
    175181    unsigned newLen = m_length-len;
    176     QChar* c = newQCharVector(newLen);
    177     memcpy(c, m_data, pos*sizeof(QChar));
    178     memcpy(c+pos, m_data+pos+len, (m_length-len-pos)*sizeof(QChar));
    179     deleteQCharVector(m_data);
     182    UChar* c = newUCharVector(newLen);
     183    memcpy(c, m_data, pos * sizeof(UChar));
     184    memcpy(c + pos, m_data + pos + len, (m_length - len - pos) * sizeof(UChar));
     185    deleteUCharVector(m_data);
    180186    m_data = c;
    181187    m_length = newLen;
     
    188194
    189195    unsigned newLen = m_length-pos;
    190     QChar* c = newQCharVector(newLen);
    191     memcpy(c, m_data+pos, newLen*sizeof(QChar));
     196    UChar* c = newUCharVector(newLen);
     197    memcpy(c, m_data + pos, newLen * sizeof(UChar));
    192198
    193199    StringImpl* str = new StringImpl(m_data + pos, newLen);
     
    205211    if (!m_data)
    206212        return true;
    207    
    208     for (unsigned i = from; i < len; i++) {
    209         QChar c = m_data[i];
    210         if (c.unicode() <= 0x7F) {
    211             if (!isspace(c.unicode()))
    212                 return false;
    213         }
    214         else
     213    // FIXME: Both the definition of what whitespace is, and the definition of what
     214    // the "len" parameter means are different here from what's done in RenderText.
     215    // FIXME: No range checking here.
     216    for (unsigned i = from; i < len; i++)
     217        if (m_data[i] > 0x7F || !isspace(m_data[i]))
    215218            return false;
    216     }
    217219    return true;
    218220}
     
    227229}
    228230
    229 static Length parseLength(const QChar* m_data, unsigned int m_length)
     231static Length parseLength(const UChar* m_data, unsigned int m_length)
    230232{
    231233    if (m_length == 0)
     
    233235
    234236    unsigned i = 0;
    235     while (i < m_length && m_data[i].isSpace())
     237    while (i < m_length && QChar(m_data[i]).isSpace())
    236238        ++i;
    237239    if (i < m_length && (m_data[i] == '+' || m_data[i] == '-'))
    238240        ++i;
    239     while (i < m_length && m_data[i].isDigit())
     241    while (i < m_length && u_isdigit(m_data[i]))
    240242        ++i;
    241243
    242244    bool ok;
    243     int r = QConstString(m_data, i).string().toInt(&ok);
     245    int r = QConstString(reinterpret_cast<const QChar*>(m_data), i).string().toInt(&ok);
    244246
    245247    /* Skip over any remaining digits, we are not that accurate (5.5% => 5%) */
    246     while (i < m_length && (m_data[i].isDigit() || m_data[i] == '.'))
     248    while (i < m_length && (u_isdigit(m_data[i]) || m_data[i] == '.'))
    247249        ++i;
    248250
    249251    /* IE Quirk: Skip any whitespace (20 % => 20%) */
    250     while (i < m_length && m_data[i].isSpace())
     252    while (i < m_length && QChar(m_data[i]).isSpace())
    251253        ++i;
    252254
    253255    if (ok) {
    254         if (i == m_length)
    255             return Length(r, Fixed);
    256         else {
    257             const QChar* next = m_data+i;
    258 
    259             if (*next == '%')
     256        if (i < m_length) {
     257            UChar next = m_data[i];
     258            if (next == '%')
    260259                return Length(r, Percent);
    261 
    262             if (*next == '*')
     260            if (next == '*')
    263261                return Length(r, Relative);
    264262        }
     
    266264    } else {
    267265        if (i < m_length) {
    268             const QChar* next = m_data + i;
    269 
    270             if (*next == '*')
     266            UChar next = m_data[i];
     267            if (next == '*')
    271268                return Length(1, Relative);
    272 
    273             if (*next == '%')
     269            if (next == '%')
    274270                return Length(1, Relative);
    275271        }
     
    285281Length* StringImpl::toCoordsArray(int& len) const
    286282{
    287     QChar* spacified = newQCharVector(m_length);
    288     QChar space(' ');
    289     for (unsigned int i=0; i < m_length; i++) {
    290         QChar cc = m_data[i];
    291         if (cc.unicode() > '9' || (cc.unicode() < '0' && cc != '-' && cc != '*' && cc != '.'))
    292             spacified[i] = space;
     283    UChar* spacified = newUCharVector(m_length);
     284    for (unsigned i = 0; i < m_length; i++) {
     285        UChar cc = m_data[i];
     286        if (cc > '9' || (cc < '0' && cc != '-' && cc != '*' && cc != '.'))
     287            spacified[i] = ' ';
    293288        else
    294289            spacified[i] = cc;
    295290    }
    296     DeprecatedString str(spacified, m_length);
    297     deleteQCharVector(spacified);
     291    DeprecatedString str(reinterpret_cast<const QChar*>(spacified), m_length);
     292    deleteUCharVector(spacified);
    298293
    299294    str = str.simplifyWhiteSpace();
     
    307302
    308303    while((pos2 = str.find(' ', pos)) != -1) {
    309         r[i++] = parseLength(str.unicode() + pos, pos2-pos);
     304        r[i++] = parseLength(reinterpret_cast<const UChar*>(str.unicode()) + pos, pos2 - pos);
    310305        pos = pos2+1;
    311306    }
    312     r[i] = parseLength(str.unicode() + pos, str.length()-pos);
     307    r[i] = parseLength(reinterpret_cast<const UChar*>(str.unicode()) + pos, str.length() - pos);
    313308
    314309    return r;
     
    321316        return 0;
    322317    }
    323     DeprecatedString str(m_data, m_length);
     318    DeprecatedString str(reinterpret_cast<const QChar*>(m_data), m_length);
    324319    str = str.simplifyWhiteSpace();
    325320
     
    331326    int pos2;
    332327
    333     while((pos2 = str.find(',', pos)) != -1) {
    334         r[i++] = parseLength(str.unicode() + pos, pos2 - pos);
     328    while ((pos2 = str.find(',', pos)) != -1) {
     329        r[i++] = parseLength(reinterpret_cast<const UChar*>(str.unicode()) + pos, pos2 - pos);
    335330        pos = pos2+1;
    336331    }
     
    338333    /* IE Quirk: If the last comma is the last char skip it and reduce len by one */
    339334    if (str.length()-pos > 0)
    340         r[i] = parseLength(str.unicode() + pos, str.length() - pos);
     335        r[i] = parseLength(reinterpret_cast<const UChar*>(str.unicode()) + pos, str.length() - pos);
    341336    else
    342337        len--;
     
    347342bool StringImpl::isLower() const
    348343{
    349     unsigned int i;
    350     for (i = 0; i < m_length; i++)
    351         if (m_data[i].lower() != m_data[i])
    352             return false;
    353     return true;
     344    // Do a quick check for the case where it's all ASCII.
     345    int allLower = true;
     346    UChar ored = 0;
     347    for (unsigned i = 0; i < m_length; i++) {
     348        UChar c = m_data[i];
     349        allLower &= islower(c);
     350        ored |= c;
     351    }
     352    if (!(ored & ~0x7F))
     353        return allLower;
     354
     355    // Do a slower check for the other cases.
     356    UBool allLower2 = true;
     357    for (unsigned i = 0; i < m_length; i++)
     358        allLower2 &= u_islower(m_data[i]);
     359    return allLower2;
    354360}
    355361
     
    360366        return c;
    361367
    362     c->m_data = newQCharVector(m_length);
    363     c->m_length = m_length;
    364 
    365     for (unsigned int i = 0; i < m_length; i++)
    366         c->m_data[i] = m_data[i].lower();
    367 
     368    UChar* data = newUCharVector(m_length);
     369    int length = m_length;
     370
     371    c->m_data = data;
     372    c->m_length = length;
     373
     374    // Do a faster loop for the case where it's all ASCII.
     375    UChar ored = 0;
     376    for (int i = 0; i < length; i++) {
     377        UChar c = m_data[i];
     378        ored |= c;
     379        data[i] = tolower(c);
     380    }
     381    if (!(ored & ~0x7F))
     382        return c;
     383
     384    UErrorCode status = U_ZERO_ERROR;
     385    int32_t realLength = u_strToLower(data, length, m_data, length, "", &status);
     386    if (U_SUCCESS(status) && realLength == length)
     387        return c;
     388
     389    if (realLength > length) {
     390        deleteUCharVector(data);
     391        data = newUCharVector(realLength);
     392    }
     393    length = realLength;
     394
     395    c->m_data = data;
     396    c->m_length = length;
     397
     398    status = U_ZERO_ERROR;
     399    u_strToLower(data, length, m_data, m_length, "", &status);
     400    if (U_FAILURE(status)) {
     401        c->ref();
     402        c->deref();
     403        return copy();
     404    }
    368405    return c;
    369406}
     
    374411    if (!m_length)
    375412        return c;
    376 
    377     c->m_data = newQCharVector(m_length);
    378     c->m_length = m_length;
    379 
    380     for (unsigned int i = 0; i < m_length; i++)
    381         c->m_data[i] = m_data[i].upper();
    382 
     413    UErrorCode status = U_ZERO_ERROR;
     414    int32_t length = u_strToUpper(0, 0, m_data, m_length, "", &status);
     415    c->m_data = newUCharVector(length);
     416    c->m_length = length;
     417    status = U_ZERO_ERROR;
     418    u_strToUpper(c->m_data, length, m_data, m_length, "", &status);
     419    if (U_FAILURE(status)) {
     420        c->ref();
     421        c->deref();
     422        return copy();
     423    }
    383424    return c;
    384425}
    385426
    386 static UBreakIterator* getWordBreakIterator(const QChar* string, int length)
     427StringImpl* StringImpl::foldCase() const
     428{
     429    StringImpl* c = new StringImpl;
     430    if (!m_length)
     431        return c;
     432    UErrorCode status = U_ZERO_ERROR;
     433    int32_t length = u_strFoldCase(0, 0, m_data, m_length, U_FOLD_CASE_DEFAULT, &status);
     434    c->m_data = newUCharVector(length);
     435    c->m_length = length;
     436    status = U_ZERO_ERROR;
     437    u_strFoldCase(c->m_data, length, m_data, m_length, U_FOLD_CASE_DEFAULT, &status);
     438    if (U_FAILURE(status)) {
     439        c->ref();
     440        c->deref();
     441        return copy();
     442    }
     443    return c;
     444}
     445
     446static UBreakIterator* getWordBreakIterator(const UChar* string, int length)
    387447{
    388448    // The locale is currently ignored when determining character cluster breaks.
     
    401461    status = U_ZERO_ERROR;
    402462    ubrk_setText(iterator, reinterpret_cast<const ::UChar*>(string), length, &status);
    403     if (status != U_ZERO_ERROR)
     463    if (U_FAILURE(status))
    404464        return 0;
    405465
     
    407467}
    408468
    409 StringImpl* StringImpl::capitalize(QChar previous) const
     469StringImpl* StringImpl::capitalize(UChar previous) const
    410470{
    411471    StringImpl* capitalizedString = new StringImpl;
     
    413473        return capitalizedString;
    414474   
    415     QChar* stringWithPrevious = newQCharVector(m_length + 1);
     475    UChar* stringWithPrevious = newUCharVector(m_length + 1);
    416476    stringWithPrevious[0] = previous;
    417     const char nonBreakingSpace = '\xa0';
    418477    for (unsigned i = 1; i < m_length + 1; i++) {
    419478        // Replace &nbsp with a real space since ICU no longer treats &nbsp as a word separator.
     
    423482            stringWithPrevious[i] = m_data[i - 1];
    424483    }
    425    
     484
    426485    UBreakIterator* boundary = getWordBreakIterator(stringWithPrevious, m_length + 1);
    427486    if (!boundary) {
    428         deleteQCharVector(stringWithPrevious);
     487        deleteUCharVector(stringWithPrevious);
    429488        return capitalizedString;
    430489    }
    431490   
    432     capitalizedString->m_data = newQCharVector(m_length);
     491    capitalizedString->m_data = newUCharVector(m_length);
    433492    capitalizedString->m_length = m_length;
    434493   
     
    437496    for (endOfWord = ubrk_next(boundary); endOfWord != UBRK_DONE; startOfWord = endOfWord, endOfWord = ubrk_next(boundary)) {
    438497        if (startOfWord != 0) // Ignore first char of previous string
    439             capitalizedString->m_data[startOfWord - 1] = stringWithPrevious[startOfWord].upper();
     498            capitalizedString->m_data[startOfWord - 1] = u_totitle(stringWithPrevious[startOfWord]);
    440499        for (int i = startOfWord + 1; i < endOfWord; i++)
    441500            capitalizedString->m_data[i - 1] = stringWithPrevious[i];
    442501    }
    443502   
    444     deleteQCharVector(stringWithPrevious);
     503    deleteUCharVector(stringWithPrevious);
    445504    return capitalizedString;
    446505}
     
    451510
    452511    // Allow leading spaces.
    453     for (; i != m_length; ++i) {
    454         if (!m_data[i].isSpace())
     512    for (; i != m_length; ++i)
     513        if (!QChar(m_data[i]).isSpace())
    455514            break;
    456     }
    457515   
    458516    // Allow sign.
     
    461519   
    462520    // Allow digits.
    463     for (; i != m_length; ++i) {
    464         if (!m_data[i].isDigit())
     521    for (; i != m_length; ++i)
     522        if (!u_isdigit(m_data[i]))
    465523            break;
    466     }
    467    
    468     return QConstString(m_data, i).string().toInt(ok);
    469 }
    470 
    471 static bool equal(const QChar* a, const char* b, int m_length)
    472 {
    473     ASSERT(m_length >= 0);
    474     while (m_length--) {
    475         if (*a != *b)
     524   
     525    return QConstString(reinterpret_cast<const QChar*>(m_data), i).string().toInt(ok);
     526}
     527
     528static bool equal(const UChar* a, const char* b, int length)
     529{
     530    ASSERT(length >= 0);
     531    while (length--) {
     532        unsigned char bc = *b++;
     533        if (*a++ != bc)
    476534            return false;
    477         a++; b++;
    478535    }
    479536    return true;
    480537}
    481538
    482 static bool equalCaseInsensitive(const QChar* a, const char* b, int m_length)
    483 {
    484     ASSERT(m_length >= 0);
    485     while (m_length--) {
    486         if (tolower(a->unicode()) != tolower(*b))
     539static bool equalIgnoringCase(const UChar* a, const char* b, int length)
     540{
     541    ASSERT(length >= 0);
     542    while (length--) {
     543        unsigned char bc = *b++;
     544        if (u_foldCase(*a++, U_FOLD_CASE_DEFAULT) != u_foldCase(bc, U_FOLD_CASE_DEFAULT))
    487545            return false;
    488         a++; b++;
    489546    }
    490547    return true;
    491548}
    492549
    493 static bool equalCaseInsensitive(const QChar* a, const QChar* b, int m_length)
    494 {
    495     ASSERT(m_length >= 0);
    496     while (m_length--) {
    497         if (tolower(a->unicode()) != tolower(b->unicode()))
    498             return false;
    499         a++; b++;
    500     }
    501     return true;
     550static inline bool equalIgnoringCase(const UChar* a, const UChar* b, int length)
     551{
     552    ASSERT(length >= 0);
     553    return u_memcasecmp(a, b, length, U_FOLD_CASE_DEFAULT) == 0;
    502554}
    503555
     
    524576    int chsLengthMinusOne = chsLength - 1;
    525577   
    526     const QChar* ptr = m_data + index - 1;
     578    const UChar* ptr = m_data + index - 1;
    527579    if (caseSensitive) {
    528         QChar c = *chs;
     580        UChar c = *chs;
    529581        do {
    530582            if (*++ptr == c && equal(ptr + 1, chsPlusOne, chsLengthMinusOne))
     
    532584        } while (--n);
    533585    } else {
    534         int lc = tolower((unsigned char)*chs);
     586        UChar lc = u_foldCase(*chs, U_FOLD_CASE_DEFAULT);
    535587        do {
    536             if (tolower((++ptr)->unicode()) == lc && equalCaseInsensitive(ptr + 1, chsPlusOne, chsLengthMinusOne))
     588            if (u_foldCase(*++ptr, U_FOLD_CASE_DEFAULT) == lc
     589                    && equalIgnoringCase(ptr + 1, chsPlusOne, chsLengthMinusOne))
    537590                return m_length - chsLength - n + 1;
    538591        } while (--n);
     
    542595}
    543596
    544 int StringImpl::find(const QChar c, int start) const
     597int StringImpl::find(const UChar c, int start) const
    545598{
    546599    unsigned int index = start;
     
    566619      or ucstrnicmp.
    567620
    568       The hash value of a string is the sum of the cells of its
    569       QChars.
     621      The hash value of a string is the sum of its characters.
    570622    */
    571623    ASSERT(str);
     
    580632        return -1;
    581633
    582     const QChar* uthis = m_data + index;
    583     const QChar* ustr = str->m_data;
     634    const UChar* uthis = m_data + index;
     635    const UChar* ustr = str->m_data;
    584636    unsigned hthis = 0;
    585637    unsigned hstr = 0;
    586638    if (caseSensitive) {
    587639        for (int i = 0; i < lstr; i++) {
    588             hthis += uthis[i].unicode();
    589             hstr += ustr[i].unicode();
     640            hthis += uthis[i];
     641            hstr += ustr[i];
    590642        }
    591643        int i = 0;
    592644        while (1) {
    593             if (hthis == hstr && memcmp(uthis + i, ustr, lstr * sizeof(QChar)) == 0)
     645            if (hthis == hstr && memcmp(uthis + i, ustr, lstr * sizeof(UChar)) == 0)
    594646                return index + i;
    595647            if (i == delta)
    596648                return -1;
    597             hthis += uthis[i + lstr].unicode();
    598             hthis -= uthis[i].unicode();
     649            hthis += uthis[i + lstr];
     650            hthis -= uthis[i];
    599651            i++;
    600652        }
    601653    } else {
    602654        for (int i = 0; i < lstr; i++ ) {
    603             hthis += tolower(uthis[i].unicode());
    604             hstr += tolower(ustr[i].unicode());
     655            hthis += tolower(uthis[i]);
     656            hstr += tolower(ustr[i]);
    605657        }
    606658        int i = 0;
    607659        while (1) {
    608             if (hthis == hstr && equalCaseInsensitive(uthis + i, ustr, lstr))
     660            if (hthis == hstr && equalIgnoringCase(uthis + i, ustr, lstr))
    609661                return index + i;
    610662            if (i == delta)
    611663                return -1;
    612             hthis += tolower(uthis[i + lstr].unicode());
    613             hthis -= tolower(uthis[i].unicode());
     664            hthis += tolower(uthis[i + lstr]);
     665            hthis -= tolower(uthis[i]);
    614666            i++;
    615667        }
     
    626678}
    627679
    628 StringImpl* StringImpl::replace(QChar oldC, QChar newC)
     680StringImpl* StringImpl::replace(UChar oldC, UChar newC)
    629681{
    630682    if (oldC == newC)
     
    639691    StringImpl* c = new StringImpl;
    640692
    641     c->m_data = newQCharVector(m_length);
     693    c->m_data = newUCharVector(m_length);
    642694    c->m_length = m_length;
    643695
    644696    for (i = 0; i != m_length; ++i) {
    645         QChar ch = m_data[i];
     697        UChar ch = m_data[i];
    646698        if (ch == oldC)
    647699            ch = newC;
     
    660712}
    661713
    662 StringImpl* StringImpl::replace(QChar pattern, const StringImpl* str)
     714StringImpl* StringImpl::replace(UChar pattern, const StringImpl* str)
    663715{
    664716    int slen = str ? str->length() : 0;
     
    685737
    686738    unsigned length = a->length();
    687     const QChar* as = a->unicode();
     739    const UChar* as = a->characters();
    688740    for (unsigned i = 0; i != length; ++i) {
    689         char c = b[i];
    690         if (!c)
     741        unsigned char bc = b[i];
     742        if (!bc)
    691743            return false;
    692         if (as[i] != c)
     744        if (as[i] != bc)
    693745            return false;
    694746    }
     
    697749}
    698750
    699 bool equal(const char* a, const StringImpl* b)
     751bool equalIgnoringCase(const StringImpl* a, const StringImpl* b)
     752{
     753    return CaseInsensitiveHash::equal(a, b);
     754}
     755
     756bool equalIgnoringCase(const StringImpl* a, const char* b)
    700757{
    701758    if (!a)
     
    704761        return !a;
    705762
    706     unsigned length = b->length();
    707     const QChar* bs = b->unicode();
     763    unsigned length = a->length();
     764    const UChar* as = a->characters();
     765
     766    // Do a faster loop for the case where it's all ASCII.
     767    UChar ored = 0;
     768    bool equal = true;
    708769    for (unsigned i = 0; i != length; ++i) {
    709         char c = a[i];
    710         if (!c)
     770        unsigned char bc = b[i];
     771        if (!bc)
    711772            return false;
    712         if (c != bs[i])
    713             return false;
    714     }
    715 
    716     return !a[length];
    717 }
    718 
    719 bool equalIgnoringCase(const StringImpl* a, const StringImpl* b)
    720 {
    721     return CaseInsensitiveHash::equal(a, b);
    722 }
    723 
    724 bool equalIgnoringCase(const StringImpl* a, const char* b)
    725 {
    726     if (!a)
    727         return !b;
    728     if (!b)
    729         return !a;
    730 
    731     unsigned length = a->length();
    732     const QChar* as = a->unicode();
    733     for (unsigned i = 0; i != length; ++i) {
    734         char c = b[i];
    735         if (!c)
    736             return false;
    737         if (as[i].lower() != QChar(c).lower())
    738             return false;
    739     }
    740 
    741     return !b[length];
    742 }
    743 
    744 bool equalIgnoringCase(const char* a, const StringImpl* b)
    745 {
    746     if (!a)
    747         return !b;
    748     if (!b)
    749         return !a;
    750 
    751     unsigned length = b->length();
    752     const QChar* bs = b->unicode();
    753     for (unsigned i = 0; i != length; ++i) {
    754         char c = a[i];
    755         if (!c)
    756             return false;
    757         if (QChar(c).lower() != bs[i].lower())
    758             return false;
    759     }
    760 
    761     return !a[length];
     773        UChar ac = as[i];
     774        ored |= ac;
     775        equal &= tolower(ac) == tolower(bc);
     776    }
     777
     778    if (ored & ~0x7F) {
     779        equal = true;
     780        for (unsigned i = 0; i != length; ++i) {
     781            unsigned char bc = b[i];
     782            equal &= u_foldCase(as[i], U_FOLD_CASE_DEFAULT) == u_foldCase(bc, U_FOLD_CASE_DEFAULT);
     783        }
     784    }
     785
     786    return equal && !b[length];
    762787}
    763788
     
    768793// Paul Hsieh's SuperFastHash
    769794// http://www.azillionmonkeys.com/qed/hash.html
    770 unsigned StringImpl::computeHash(const QChar* m_data, unsigned len)
     795unsigned StringImpl::computeHash(const UChar* m_data, unsigned len)
    771796{
    772797    unsigned m_length = len;
     
    779804    // Main loop
    780805    for (; m_length > 0; m_length--) {
    781         hash += m_data[0].unicode();
    782         tmp = (m_data[1].unicode() << 11) ^ hash;
     806        hash += m_data[0];
     807        tmp = (m_data[1] << 11) ^ hash;
    783808        hash = (hash << 16) ^ tmp;
    784809        m_data += 2;
     
    788813    // Handle end case
    789814    if (rem) {
    790         hash += m_data[0].unicode();
     815        hash += m_data[0];
    791816        hash ^= hash << 11;
    792817        hash += hash >> 17;
     
    861886    char* p = buffer;
    862887    for (unsigned i = 0; i != m_length; ++i) {
    863         unsigned short c = m_data[i].unicode();
     888        UChar c = m_data[i];
    864889        if (c >= 0x20 && c < 0x7F)
    865890            *p++ = c;
     
    873898StringImpl::StringImpl(const Identifier& str)
    874899{
    875     initWithQChar(reinterpret_cast<const QChar*>(str.data()), str.size());
     900    init(reinterpret_cast<const UChar*>(str.data()), str.size());
    876901}
    877902
    878903StringImpl::StringImpl(const UString& str)
    879904{
    880     initWithQChar(reinterpret_cast<const QChar*>(str.data()), str.size());
     905    init(reinterpret_cast<const UChar*>(str.data()), str.size());
    881906}
    882907
  • trunk/WebCore/platform/StringImpl.h

    r14256 r14273  
    2525#define StringImpl_h
    2626
    27 #include "DeprecatedString.h"
     27#include "Shared.h"
     28#include <kjs/identifier.h>
    2829#include <wtf/Forward.h>
    2930#include <wtf/Noncopyable.h>
     31#include <unicode/umachine.h>
    3032#include <limits.h>
    3133
     
    3436#endif
    3537
     38class DeprecatedString;
     39
    3640namespace WebCore {
    3741
    3842class AtomicString;
    39 struct QCharBufferTranslator;
     43struct UCharBufferTranslator;
    4044struct CStringTranslator;
    4145struct Length;
    4246
    43 class StringImpl : public Shared<StringImpl>, Noncopyable
    44 {
     47class StringImpl : public Shared<StringImpl>, Noncopyable {
    4548private:
    4649    struct WithOneRef { };
    4750    StringImpl(WithOneRef) : m_length(0), m_data(0), m_hash(0), m_inTable(false) { ref(); }
    48     void initWithChar(const char*, unsigned len);
    49     void initWithQChar(const QChar*, unsigned len);
     51    void init(const char*, unsigned len);
     52    void init(const UChar*, unsigned len);
    5053
    5154protected:
    5255    StringImpl() : m_length(0), m_data(0), m_hash(0), m_inTable(false) { }
    5356public:
    54     StringImpl(const DeprecatedString&);
     57    StringImpl(const UChar*, unsigned len);
     58    StringImpl(const char*, unsigned len);
     59    StringImpl(const char*);
    5560    StringImpl(const KJS::Identifier&);
    5661    StringImpl(const KJS::UString&);
    57     StringImpl(const QChar*, unsigned len);
    58     StringImpl(const char*);
    59     StringImpl(const char*, unsigned len);
    6062    ~StringImpl();
    6163
    62     const QChar* unicode() const { return m_data; }
     64    const UChar* characters() const { return m_data; }
    6365    unsigned length() const { return m_length; }
    6466   
    6567    unsigned hash() const { if (m_hash == 0) m_hash = computeHash(m_data, m_length); return m_hash; }
    66     static unsigned computeHash(const QChar*, unsigned len);
     68    static unsigned computeHash(const UChar*, unsigned len);
    6769    static unsigned computeHash(const char*);
    6870   
     
    7173    void truncate(int len);
    7274    void remove(unsigned pos, int len = 1);
    73    
     75
    7476    StringImpl* split(unsigned pos);
    7577    StringImpl* copy() const { return new StringImpl(m_data, m_length); }
     
    7779    StringImpl* substring(unsigned pos, unsigned len = UINT_MAX);
    7880
    79     const QChar& operator[] (int pos) const { return m_data[pos]; }
     81    UChar operator[](int pos) const { return m_data[pos]; }
    8082
    8183    Length toLength() const;
    82    
     84
    8385    bool containsOnlyWhitespace() const;
    8486    bool containsOnlyWhitespace(unsigned from, unsigned len) const;
    85    
     87
    8688    // ignores trailing garbage, unlike DeprecatedString
    8789    int toInt(bool* ok = 0) const;
     
    9294    StringImpl* lower() const;
    9395    StringImpl* upper() const;
    94     StringImpl* capitalize(QChar previous) const;
     96    StringImpl* capitalize(UChar previousCharacter) const;
     97    StringImpl* foldCase() const;
    9598
    9699    int find(const char*, int index = 0, bool caseSensitive = true) const;
    97     int find(QChar, int index = 0) const;
     100    int find(UChar, int index = 0) const;
    98101    int find(const StringImpl*, int index, bool caseSensitive = true) const;
    99102
     
    102105
    103106    // Does not modify the string.
    104     StringImpl* replace(QChar, QChar);
    105     StringImpl* replace(QChar a, const StringImpl* b);
     107    StringImpl* replace(UChar, UChar);
     108    StringImpl* replace(UChar, const StringImpl*);
    106109    StringImpl* replace(unsigned index, unsigned len, const StringImpl*);
    107110
     
    120123#endif
    121124
     125    StringImpl(const DeprecatedString&);
     126
    122127private:
    123128    unsigned m_length;
    124     QChar* m_data;
     129    UChar* m_data;
    125130
    126131    friend class AtomicString;
    127     friend struct QCharBufferTranslator;
     132    friend struct UCharBufferTranslator;
    128133    friend struct CStringTranslator;
    129134   
     
    134139bool equal(const StringImpl*, const StringImpl*);
    135140bool equal(const StringImpl*, const char*);
    136 bool equal(const char*, const StringImpl*);
     141inline bool equal(const char* a, const StringImpl* b) { return equal(b, a); }
    137142
    138143bool equalIgnoringCase(const StringImpl*, const StringImpl*);
    139144bool equalIgnoringCase(const StringImpl*, const char*);
    140 bool equalIgnoringCase(const char*, const StringImpl*);
     145inline bool equalIgnoringCase(const char* a, const StringImpl* b) { return equalIgnoringCase(b, a); }
    141146
    142147}
  • trunk/WebCore/platform/TextBoundaries.h

    r13187 r14273  
    2727#define TextBoundaries_h
    2828
     29#include <unicode/umachine.h>
     30
    2931// FIXME: Change clients to use ICU and remove these functions.
    30 
    31 class QChar;
    3232
    3333namespace WebCore {
    3434
    35     void findWordBoundary(const QChar*, int len, int position, int *start, int *end);
    36     int findNextWordFromIndex(const QChar*, int len, int position, bool forward);
     35    void findWordBoundary(const UChar*, int len, int position, int *start, int *end);
     36    int findNextWordFromIndex(const UChar*, int len, int position, bool forward);
    3737
    38     void findSentenceBoundary(const QChar*, int len, int position, int *start, int *end);
    39     int findNextSentenceFromIndex(const QChar*, int len, int position, bool forward);
     38    void findSentenceBoundary(const UChar*, int len, int position, int *start, int *end);
     39    int findNextSentenceFromIndex(const UChar*, int len, int position, bool forward);
    4040
    4141}
  • trunk/WebCore/platform/TextEncoding.cpp

    r14256 r14273  
    4646    return charsetNameFromTextEncodingID(m_encodingID);
    4747}
    48 
    49 QChar TextEncoding::backslashAsCurrencySymbol() const
     48UChar TextEncoding::backslashAsCurrencySymbol() const
    5049{
    5150    if (m_flags & BackslashIsYen)
     
    129128    // Encoding will change the yen sign back into a backslash.
    130129    DeprecatedString copy = qcs;
    131     copy.replace(QChar('\\'), backslashAsCurrencySymbol());
     130    copy.replace('\\', backslashAsCurrencySymbol());
    132131
    133132    UErrorCode err = U_ZERO_ERROR;
  • trunk/WebCore/platform/TextEncoding.h

    r13821 r14273  
    8181        bool isJapanese() const { return m_flags & IsJapanese; }
    8282       
    83         QChar backslashAsCurrencySymbol() const;
     83        UChar backslashAsCurrencySymbol() const;
    8484       
    8585        DeprecatedCString fromUnicode(const DeprecatedString&, bool allowEntities = false) const;
  • trunk/WebCore/platform/mac/FontFamilyMac.mm

    r13821 r14273  
    5555            m_CFFamily = (CFStringRef)CFDictionaryGetValue(families, m_family.impl());
    5656            if (!m_CFFamily) {
    57                 m_CFFamily = CFStringCreateWithCharacters(0, (const UniChar *)m_family.unicode(), m_family.length());
     57                m_CFFamily = CFStringCreateWithCharacters(0, m_family.characters(), m_family.length());
    5858                CFDictionarySetValue(families, m_family.impl(), m_CFFamily);
    5959                CFRelease(m_CFFamily);
  • trunk/WebCore/platform/mac/FontMac.mm

    r14216 r14273  
    3939
    4040#import "IntRect.h"
     41
     42using namespace std;
    4143
    4244namespace WebCore {
     
    103105
    104106IntRect Font::selectionRectForText(const IntPoint& point, int h, int tabWidth, int xpos,
    105     const QChar* str, int slen, int pos, int l, int toAdd,
     107    const UChar* str, int slen, int pos, int l, int toAdd,
    106108    bool rtl, bool visuallyOrdered, int from, int to) const
    107109{
    108110    assert(m_fontList);
    109     int len = std::min(slen - pos, l);
     111    int len = min(slen - pos, l);
    110112
    111113    CREATE_FAMILY_ARRAY(fontDescription(), families);
     
    117119
    118120    WebCoreTextRun run;
    119     WebCoreInitializeTextRun(&run, (const UniChar *)(str+pos), len, from, to);   
     121    WebCoreInitializeTextRun(&run, str + pos, len, from, to);
    120122    WebCoreTextStyle style;
    121123    WebCoreInitializeEmptyTextStyle(&style);
     
    138140}
    139141                     
    140 void Font::drawText(GraphicsContext* context, const IntPoint& point, int tabWidth, int xpos, const QChar* str, int len, int from, int to,
     142void Font::drawText(GraphicsContext* context, const IntPoint& point, int tabWidth, int xpos, const UChar* str, int len, int from, int to,
    141143                    int toAdd, TextDirection d, bool visuallyOrdered) const
    142144{
     
    151153       
    152154    WebCoreTextRun run;
    153     WebCoreInitializeTextRun(&run, (const UniChar *)str, len, from, to);   
     155    WebCoreInitializeTextRun(&run, str, len, from, to);   
    154156    WebCoreTextStyle style;
    155157    WebCoreInitializeEmptyTextStyle(&style);
     
    171173}
    172174
    173 void Font::drawHighlightForText(GraphicsContext* context, const IntPoint& point, int h, int tabWidth, int xpos, const QChar* str,
     175void Font::drawHighlightForText(GraphicsContext* context, const IntPoint& point, int h, int tabWidth, int xpos, const UChar* str,
    174176                                int len, int from, int to, int toAdd,
    175177                                TextDirection d, bool visuallyOrdered, const Color& backgroundColor) const
     
    185187       
    186188    WebCoreTextRun run;
    187     WebCoreInitializeTextRun(&run, (const UniChar *)str, len, from, to);   
     189    WebCoreInitializeTextRun(&run, str, len, from, to);   
    188190    WebCoreTextStyle style;
    189191    WebCoreInitializeEmptyTextStyle(&style);
     
    223225}
    224226
    225 float Font::floatWidth(const QChar* uchars, int slen, int pos, int len, int tabWidth, int xpos, bool runRounding) const
     227float Font::floatWidth(const UChar* uchars, int slen, int pos, int len, int tabWidth, int xpos, bool runRounding) const
    226228{
    227229    assert(m_fontList);
     
    229231
    230232    WebCoreTextRun run;
    231     WebCoreInitializeTextRun(&run, (const UniChar *)uchars, slen, pos, pos+len);
     233    WebCoreInitializeTextRun(&run, uchars, slen, pos, pos + len);
    232234   
    233235    WebCoreTextStyle style;
     
    244246}
    245247
    246 int Font::checkSelectionPoint(const QChar* s, int slen, int pos, int len, int toAdd, int tabWidth, int xpos, int x, TextDirection d, bool visuallyOrdered, bool includePartialGlyphs) const
     248int Font::checkSelectionPoint(const UChar* s, int slen, int pos, int len, int toAdd, int tabWidth, int xpos, int x, TextDirection d, bool visuallyOrdered, bool includePartialGlyphs) const
    247249{
    248250    assert(m_fontList);
     
    250252   
    251253    WebCoreTextRun run;
    252     WebCoreInitializeTextRun(&run, (const UniChar *)(s+pos), std::min(slen - pos, len), 0, len);
     254    WebCoreInitializeTextRun(&run, s + pos, min(slen - pos, len), 0, len);
    253255   
    254256    WebCoreTextStyle style;
  • trunk/WebCore/platform/mac/TextBoundaries.mm

    r13187 r14273  
    3232namespace WebCore {
    3333
    34 void findWordBoundary(const QChar* chars, int len, int position, int* start, int* end)
     34void findWordBoundary(const UChar* chars, int len, int position, int* start, int* end)
    3535{
    36     NSString* string = [[NSString alloc] initWithCharactersNoCopy:const_cast<unichar*>(reinterpret_cast<const unichar*>(chars))
     36    NSString* string = [[NSString alloc] initWithCharactersNoCopy:const_cast<unichar*>(chars)
    3737        length:len freeWhenDone:NO];
    3838    NSAttributedString* attr = [[NSAttributedString alloc] initWithString:string];
     
    4444}
    4545
    46 int findNextWordFromIndex(const QChar* chars, int len, int position, bool forward)
     46int findNextWordFromIndex(const UChar* chars, int len, int position, bool forward)
    4747{   
    48     NSString* string = [[NSString alloc] initWithCharactersNoCopy:const_cast<unichar*>(reinterpret_cast<const unichar*>(chars))
     48    NSString* string = [[NSString alloc] initWithCharactersNoCopy:const_cast<unichar*>(chars)
    4949        length:len freeWhenDone:NO];
    5050    NSAttributedString* attr = [[NSAttributedString alloc] initWithString:string];
     
    100100}
    101101
    102 void findSentenceBoundary(const QChar* chars, int len, int position, int* start, int* end)
     102void findSentenceBoundary(const UChar* chars, int len, int position, int* start, int* end)
    103103{
    104104    int startPos = 0;
     
    106106
    107107    UErrorCode status = U_ZERO_ERROR;
    108     UBreakIterator* boundary = ubrk_open(UBRK_SENTENCE, currentTextBreakLocaleID(),
    109         const_cast<unichar*>(reinterpret_cast<const unichar*>(chars)), len, &status);
     108    UBreakIterator* boundary = ubrk_open(UBRK_SENTENCE, currentTextBreakLocaleID(), chars, len, &status);
    110109    if (boundary && U_SUCCESS(status)) {
    111110        startPos = ubrk_preceding(boundary, position);
     
    124123}
    125124
    126 int findNextSentenceFromIndex(const QChar* chars, int len, int position, bool forward)
     125int findNextSentenceFromIndex(const UChar* chars, int len, int position, bool forward)
    127126{
    128127    int pos = 0;
    129128   
    130129    UErrorCode status = U_ZERO_ERROR;
    131     UBreakIterator* boundary = ubrk_open(UBRK_SENTENCE, currentTextBreakLocaleID(),
    132         const_cast<unichar*>(reinterpret_cast<const unichar*>(chars)), len, &status);
     130    UBreakIterator* boundary = ubrk_open(UBRK_SENTENCE, currentTextBreakLocaleID(), chars, len, &status);
    133131    if (boundary && U_SUCCESS(status)) {
    134132        if (forward) {
  • trunk/WebCore/platform/mac/TextEncodingMac.cpp

    r14256 r14273  
    5252    // Encoding will change the yen sign back into a backslash.
    5353    DeprecatedString copy = qcs;
    54     copy.replace(QChar('\\'), backslashAsCurrencySymbol());
     54    copy.replace('\\', backslashAsCurrencySymbol());
    5555    CFStringRef cfs = copy.getCFString();
    5656    CFMutableStringRef cfms = CFStringCreateMutableCopy(0, 0, cfs); // in rare cases, normalization can make the string longer, thus no limit on its length
  • trunk/WebCore/rendering/InlineTextBox.cpp

    r14256 r14273  
    119119
    120120    IntRect r = f->selectionRectForText(IntPoint(tx + m_x, ty + selTop), selHeight, textObj->tabWidth(), textPos(),
    121                                         textObj->str->unicode(), textObj->str->length(), m_start, m_len,
     121                                        textObj->str->characters(), textObj->str->length(), m_start, m_len,
    122122                                        m_toAdd, m_reversed, m_dirOverride, sPos, ePos);
    123123    if (r.x() > tx + m_x + m_width)
     
    334334            endPoint = m_truncation - m_start;
    335335        i.p->drawText(IntPoint(m_x + tx, m_y + ty + m_baseline), textObject()->tabWidth(), textPos(),
    336                       textObject()->string()->unicode(), textObject()->string()->length(), m_start, endPoint,
     336                      textObject()->string()->characters(), textObject()->string()->length(), m_start, endPoint,
    337337                      m_toAdd, m_reversed ? RTL : LTR, m_dirOverride || styleToUse->visuallyOrdered());
    338338    } else {
     
    343343            if (sPos >= ePos)
    344344                i.p->drawText(IntPoint(m_x + tx, m_y + ty + m_baseline), textObject()->tabWidth(), textPos(),
    345                               textObject()->string()->unicode(), textObject()->string()->length(), m_start, m_len,
     345                              textObject()->string()->characters(), textObject()->string()->length(), m_start, m_len,
    346346                              m_toAdd, m_reversed ? RTL : LTR, m_dirOverride || styleToUse->visuallyOrdered());
    347347            else {
    348348                if (sPos - 1 >= 0)
    349349                    i.p->drawText(IntPoint(m_x + tx, m_y + ty + m_baseline), textObject()->tabWidth(), textPos(),
    350                                   textObject()->string()->unicode(), textObject()->string()->length(), m_start, m_len,
     350                                  textObject()->string()->characters(), textObject()->string()->length(), m_start, m_len,
    351351                                  m_toAdd, m_reversed ? RTL : LTR, m_dirOverride || styleToUse->visuallyOrdered(), 0, sPos);
    352352                if (ePos < m_start + m_len)
    353353                    i.p->drawText(IntPoint(m_x + tx, m_y + ty + m_baseline), textObject()->tabWidth(), textPos(),
    354                                   textObject()->string()->unicode(), textObject()->string()->length(), m_start, m_len,
     354                                  textObject()->string()->characters(), textObject()->string()->length(), m_start, m_len,
    355355                                  m_toAdd, m_reversed ? RTL : LTR, m_dirOverride || styleToUse->visuallyOrdered(), ePos, -1);
    356356            }
     
    367367                               selectionTextShadow->color);
    368368            i.p->drawText(IntPoint(m_x + tx, m_y + ty + m_baseline), textObject()->tabWidth(), textPos(),
    369                           textObject()->string()->unicode(), textObject()->string()->length(), m_start, m_len,
     369                          textObject()->string()->characters(), textObject()->string()->length(), m_start, m_len,
    370370                          m_toAdd, m_reversed ? RTL : LTR, m_dirOverride || styleToUse->visuallyOrdered(), sPos, ePos);
    371371            if (selectionTextShadow)
     
    452452    p->addClip(IntRect(m_x + tx, y + ty, m_width, h));
    453453    p->drawHighlightForText(IntPoint(m_x + tx, y + ty), h, textObject()->tabWidth(), textPos(),
    454                             textObject()->str->unicode(), textObject()->str->length(), m_start, m_len,
     454                            textObject()->str->characters(), textObject()->str->length(), m_start, m_len,
    455455                            m_toAdd, m_reversed ? RTL : LTR, m_dirOverride || style->visuallyOrdered(), sPos, ePos, c);
    456456    p->restore();
     
    476476    int h = r->selectionHeight();
    477477    p->drawHighlightForText(IntPoint(m_x + tx, y + ty), h, textObject()->tabWidth(), textPos(),
    478                             textObject()->str->unicode(), textObject()->str->length(), m_start, m_len,
     478                            textObject()->str->characters(), textObject()->str->length(), m_start, m_len,
    479479                            m_toAdd, m_reversed ? RTL : LTR, m_dirOverride || style->visuallyOrdered(), sPos, ePos, c);
    480480    p->restore();
     
    575575   
    576576    pt->drawHighlightForText(IntPoint(m_x + _tx, y + _ty), h, textObject()->tabWidth(), textPos(),
    577                              textObject()->str->unicode(), textObject()->str->length(), m_start, m_len,
     577                             textObject()->str->characters(), textObject()->str->length(), m_start, m_len,
    578578                             m_toAdd, m_reversed ? RTL : LTR, m_dirOverride || style->visuallyOrdered(), sPos, ePos, yellow);
    579579    pt->restore();
     
    689689    RenderStyle *style = text->style(m_firstLine);
    690690    const Font* f = &style->font();
    691     return f->checkSelectionPoint(text->str->unicode(), text->str->length(), m_start, m_len,
     691    return f->checkSelectionPoint(text->str->characters(), text->str->length(), m_start, m_len,
    692692        m_toAdd, text->tabWidth(), textPos(), _x - m_x,
    693693        m_reversed ? RTL : LTR, m_dirOverride || style->visuallyOrdered(), includePartialGlyphs);
     
    704704    int to = m_reversed ? m_len : offset - m_start;
    705705    // FIXME: Do we need to add rightBearing here?
    706     return f->selectionRectForText(IntPoint(m_x, 0), 0, text->tabWidth(), textPos(), text->str->unicode(), text->str->length(), m_start, m_len,
     706    return f->selectionRectForText(IntPoint(m_x, 0), 0, text->tabWidth(), textPos(), text->str->characters(), text->str->length(), m_start, m_len,
    707707        m_toAdd, m_reversed, m_dirOverride, from, to).right();
    708708}
  • trunk/WebCore/rendering/RenderBlock.cpp

    r14172 r14273  
    28322832        RenderText* t = static_cast<RenderText *>(trailingSpaceChild);
    28332833        const Font *f = t->font(false);  // FIXME: Why are we ignoring first-line?
    2834         QChar space[1]; space[0] = ' ';
    2835         int spaceWidth = f->width(space, 1);
     2834        const UChar space = ' ';
     2835        int spaceWidth = f->width(&space, 1);
    28362836        inlineMax -= spaceWidth;
    28372837        if (inlineMin > inlineMax)
     
    33983398           
    33993399            // account for leading spaces and punctuation
    3400             while (length < oldText->length() && ((*oldText)[length].isSpace() || (*oldText)[length].isPunct()))
     3400            while (length < oldText->length() && (QChar((*oldText)[length]).isSpace() || u_ispunct((*oldText)[length])))
    34013401                length++;
    34023402           
  • trunk/WebCore/rendering/RenderFlexibleBox.cpp

    r13859 r14273  
    729729                RenderBlock* blockChild = static_cast<RenderBlock*>(child);
    730730                int lineCount = blockChild->lineCount();
    731                 if (lineCount <= numVisibleLines) continue;
     731                if (lineCount <= numVisibleLines)
     732                    continue;
    732733               
    733734                int newHeight = blockChild->heightForLineCount(numVisibleLines);
    734                 if (newHeight == child->height()) continue;
     735                if (newHeight == child->height())
     736                    continue;
    735737               
    736738                child->setChildNeedsLayout(true);
     
    742744               
    743745                // FIXME: For now don't support RTL.
    744                 if (style()->direction() != LTR) continue;
     746                if (style()->direction() != LTR)
     747                    continue;
    745748               
    746749                // Get the last line
    747750                RootInlineBox* lastLine = blockChild->lineAtIndex(lineCount-1);
    748                 if (!lastLine) continue;
     751                if (!lastLine)
     752                    continue;
    749753               
    750754                // See if the last item is an anchor
    751755                InlineBox* anchorBox = lastLine->lastChild();
    752                 if (!anchorBox) continue;
    753                 if (!anchorBox->object()->element()) continue;
    754                 if (!anchorBox->object()->element()->isLink()) continue;
     756                if (!anchorBox)
     757                    continue;
     758                if (!anchorBox->object()->element())
     759                    continue;
     760                if (!anchorBox->object()->element()->isLink())
     761                    continue;
    755762               
    756763                RootInlineBox* lastVisibleLine = blockChild->lineAtIndex(numVisibleLines-1);
    757                 if (!lastVisibleLine) continue;
    758 
    759                 const unsigned short ellipsisAndSpace[2] = { 0x2026, ' ' };
     764                if (!lastVisibleLine)
     765                    continue;
     766
     767                const UChar ellipsisAndSpace[2] = { 0x2026, ' ' };
    760768                static AtomicString ellipsisAndSpaceStr(ellipsisAndSpace, 2);
     769
    761770                const Font& font = style(numVisibleLines == 1)->font();
    762                 int ellipsisAndSpaceWidth = font.width(const_cast<QChar*>(ellipsisAndSpaceStr.unicode()), 2, 0, 2, 0, 0);
     771                int ellipsisAndSpaceWidth = font.width(ellipsisAndSpace, 2, 0, 2, 0, 0);
    763772
    764773                // Get ellipsis width + " " + anchor width
     
    770779               
    771780                // FIXME: Directions of src/destBlock could be different from our direction and from one another.
    772                 if (srcBlock->style()->direction() != LTR) continue;
    773                 if (destBlock->style()->direction() != LTR) continue;
     781                if (srcBlock->style()->direction() != LTR)
     782                    continue;
     783                if (destBlock->style()->direction() != LTR)
     784                    continue;
    774785
    775786                int blockEdge = destBlock->rightOffset(lastVisibleLine->yPos());
  • trunk/WebCore/rendering/RenderImage.cpp

    r14102 r14273  
    105105        if (!m_altText.isEmpty()) {
    106106            const Font& font = style()->font();
    107             iw = max(iw, min(font.width(m_altText.deprecatedString()), 1024));
     107            iw = max(iw, min(font.width(m_altText.characters(), m_altText.length()), 1024));
    108108            ih = max(ih, min(font.height(), 256));
    109109        }
     
    238238            if (!m_altText.isEmpty()) {
    239239                DeprecatedString text = m_altText.deprecatedString();
    240                 text.replace(QChar('\\'), backslashAsCurrencySymbol());
     240                text.replace('\\', backslashAsCurrencySymbol());
    241241                p->setFont(style()->font());
    242242                p->setPen(style()->color());
     
    248248                // Only draw the alt text if it'll fit within the content box,
    249249                // and only if it fits above the error image.
    250                 int textWidth = font.width(text);
     250                int textWidth = font.width(reinterpret_cast<const UChar*>(text.unicode()), text.length());
    251251                if (errorPictureDrawn) {
    252252                    if (usableWidth >= textWidth && font.height() <= imageY)
    253                         p->drawText(IntPoint(ax, ay + ascent), 0, text);
     253                        p->drawText(IntPoint(ax, ay + ascent), text);
    254254                } else if (usableWidth >= textWidth && cHeight >= font.height())
    255                     p->drawText(IntPoint(ax, ay + ascent), 0, text);
     255                    p->drawText(IntPoint(ax, ay + ascent), text);
    256256            }
    257257        }
  • trunk/WebCore/rendering/RenderObject.cpp

    r14267 r14273  
    24972497}
    24982498
    2499 QChar RenderObject::backslashAsCurrencySymbol() const
     2499UChar RenderObject::backslashAsCurrencySymbol() const
    25002500{
    25012501    if (Node *node = element())
  • trunk/WebCore/rendering/RenderObject.h

    r14013 r14273  
    845845
    846846    // Convenience, to avoid repeating the code to dig down to get this.
    847     QChar backslashAsCurrencySymbol() const;
     847    UChar backslashAsCurrencySymbol() const;
    848848
    849849    virtual int caretMinOffset() const;
  • trunk/WebCore/rendering/RenderText.cpp

    r14256 r14273  
    5959
    6060    status = U_ZERO_ERROR;
    61     ubrk_setText(iterator, reinterpret_cast<const UChar*>(i->unicode()), i->length(), &status);
     61    ubrk_setText(iterator, reinterpret_cast<const UChar*>(i->characters()), i->length(), &status);
    6262    if (status != U_ZERO_ERROR)
    6363        return 0;
     
    102102    if (str)
    103103        str = str->replace('\\', backslashAsCurrencySymbol());
    104     KHTMLAssert(!str || !str->length() || str->unicode());
     104    KHTMLAssert(!str || !str->length() || str->characters());
    105105}
    106106
     
    437437    unsigned i;
    438438    for (i = 0; i < str->length(); i++)
    439         if ((*str)[i].unicode() >= 0x7f) {
     439        if ((*str)[i] > 0x7f) {
    440440            m_allAscii = false;
    441441            return m_allAscii;
     
    457457void RenderText::cacheWidths()
    458458{
    459     const Font *f = font(false);
     459    const Font* f = font(false);
    460460    if (shouldUseMonospaceCache(f)) {
    461         QChar c(' ');
     461        const UChar c = ' ';
    462462        m_monospaceCharacterWidth = (int)f->floatWidth(&c, 1, 0, 1, 0, 0);
    463463    } else {
     
    466466}
    467467
    468 ALWAYS_INLINE int RenderText::widthFromCache(const Font *f, int start, int len, int tabWidth, int xpos) const
     468ALWAYS_INLINE int RenderText::widthFromCache(const Font* f, int start, int len, int tabWidth, int xpos) const
    469469{
    470470    if (m_monospaceCharacterWidth != 0) {
    471471        int i, w = 0;
    472472        for (i = start; i < start+len; i++) {
    473             QChar c = (*str)[i];
    474             int dir = c.direction();
    475             if (dir != QChar::DirNSM && dir != QChar::DirBN) {
    476                 if (c == '\t' && tabWidth != 0) {
     473            UChar c = (*str)[i];
     474            UCharDirection dir = u_charDirection(c);
     475            if (dir != U_DIR_NON_SPACING_MARK && dir != U_BOUNDARY_NEUTRAL) {
     476                if (c == '\t' && tabWidth != 0)
    477477                    w += tabWidth - ((xpos + w) % tabWidth);
    478                 } else
     478                else
    479479                    w += m_monospaceCharacterWidth;
    480                 if (c.isSpace() && i>start && !(*str)[i-1].isSpace())
     480                if (QChar(c).isSpace() && i > start && !QChar((*str)[i - 1]).isSpace())
    481481                    w += f->wordSpacing();       
    482482            }
     
    486486    }
    487487   
    488     return f->width(str->unicode(), str->length(), start, len, tabWidth, xpos);
     488    return f->width(str->characters(), str->length(), start, len, tabWidth, xpos);
    489489}
    490490
     
    524524    if (stripFrontSpaces && ((*str)[0] == ' ' || ((*str)[0] == '\n' && !style()->preserveNewline()) || (*str)[0] == '\t')) {
    525525        const Font *f = font(false); // FIXME: Why is it ok to ignore first-line here?
    526         QChar space[1]; space[0] = ' ';
    527         int spaceWidth = f->width(space, 1);
     526        const UChar space = ' ';
     527        int spaceWidth = f->width(&space, 1);
    528528        maxW -= spaceWidth + f->wordSpacing();
    529529    }
     
    591591   
    592592    // FIXME: not 100% correct for first-line
    593     const Font *f = font(false);
     593    const Font* f = font(false);
    594594    int wordSpacing = style()->wordSpacing();
    595595    int len = str->length();
    596     const QChar *txt = str->unicode();
     596    const UChar* txt = str->characters();
    597597    bool needsWordSpacing = false;
    598598    bool ignoringSpaces = false;
     
    601601    bool firstLine = true;
    602602    int nextBreakable = -1;
    603     for(int i = 0; i < len; i++)
    604     {
    605         QChar c = txt[i];
     603    for (int i = 0; i < len; i++) {
     604        UChar c = txt[i];
    606605       
    607606        bool previousCharacterIsSpace = isSpace;
     
    637636       
    638637        // Ignore spaces and soft hyphens
    639         if (ignoringSpaces || c.unicode() == SOFT_HYPHEN) {
     638        if (ignoringSpaces || c == SOFT_HYPHEN) {
    640639            continue;
    641640        }
     
    643642        bool hasBreak = isBreakable(txt, i, len, nextBreakable);
    644643        int j = i;
    645         while (c != '\n' && c != ' ' && c != '\t' && c.unicode() != SOFT_HYPHEN) {
     644        while (c != '\n' && c != ' ' && c != '\t' && c != SOFT_HYPHEN) {
    646645            j++;
    647646            if (j == len)
     
    736735    unsigned currPos;
    737736    for (currPos = from;
    738          currPos < from+len && ((*str)[currPos] == '\n' || (*str)[currPos].unicode() == ' ' || (*str)[currPos] == '\t');
     737         currPos < from+len && ((*str)[currPos] == '\n' || (*str)[currPos] == ' ' || (*str)[currPos] == '\t');
    739738         currPos++);
    740739    return currPos >= (from+len);
     
    883882                    // find previous text renderer if one exists
    884883                    RenderObject* o;
    885                     QChar previous = ' ';
     884                    UChar previous = ' ';
    886885                    for (o = previousInPreOrder(); o && o->isInlineFlow(); o = o->previousInPreOrder())
    887886                        ;
     
    906905    // RenderBR object ?
    907906    KHTMLAssert(!isBR() || (str->length() == 1 && (*str)[0] == '\n'));
    908     KHTMLAssert(!str->length() || str->unicode());
     907    KHTMLAssert(!str->length() || str->characters());
    909908
    910909    setNeedsLayoutAndMinMaxRecalc();
     
    985984unsigned int RenderText::width(unsigned int from, unsigned int len, const Font *f, int xpos) const
    986985{
    987     if (!str->unicode() || from > str->length())
     986    if (!str->characters() || from > str->length())
    988987        return 0;
    989988    if (from + len > str->length())
     
    996995        w = widthFromCache(f, from, len, tabWidth(), xpos);
    997996    else
    998         w = f->width(str->unicode(), str->length(), from, len, tabWidth(), xpos );
     997        w = f->width(str->characters(), str->length(), from, len, tabWidth(), xpos );
    999998       
    1000999    return w;
  • trunk/WebCore/rendering/RenderText.h

    r14013 r14273  
    7979    virtual VisiblePosition positionForCoordinates(int x, int y);
    8080
    81     unsigned int length() const { return str->length(); }
    82     const QChar* text() const { return str->unicode(); }
    83     unsigned int stringLength() const { return str->length(); } // non virtual implementation of length()
     81    virtual unsigned length() const { return str->length(); }
     82    const UChar* text() const { return str->characters(); }
     83    unsigned stringLength() const { return str->length(); } // non virtual implementation of length()
    8484    virtual void position(InlineBox* box, int from, int len, bool reverse, bool override);
    8585
    86     virtual unsigned int width(unsigned int from, unsigned int len, const Font *f, int xpos) const;
    87     virtual unsigned int width(unsigned int from, unsigned int len, int xpos, bool firstLine = false) const;
     86    virtual unsigned width(unsigned from, unsigned len, const Font*, int xpos) const;
     87    virtual unsigned width(unsigned from, unsigned len, int xpos, bool firstLine = false) const;
    8888    virtual int width() const;
    8989    virtual int height() const;
     
    105105                                    int& minW, int& maxW, bool& stripFrontSpaces);
    106106   
    107     bool containsOnlyWhitespace(unsigned int from, unsigned int len) const;
     107    bool containsOnlyWhitespace(unsigned from, unsigned len) const;
    108108   
    109109    // returns the minimum x position of all runs relative to the parent.
  • trunk/WebCore/rendering/RenderTextField.cpp

    r14036 r14273  
    121121            if (value.isNull())
    122122                value = "";
    123             value.replace(QChar('\\'), backslashAsCurrencySymbol());
     123            value.replace('\\', backslashAsCurrencySymbol());
    124124            if (value != oldText) {
    125125                ExceptionCode ec = 0;
     
    231231            size = 20;
    232232
    233         QChar ch[1];
    234         ch[0] = '0';
    235         int sizeWidth = (int)ceilf(style()->font().floatWidth(ch, 1, 0, 1, 0, 0, false) * size);
     233        const UChar ch = '0';
     234        int sizeWidth = (int)ceilf(style()->font().floatWidth(&ch, 1, 0, 1, 0, 0, false) * size);
    236235        m_maxWidth = sizeWidth;
    237236    }
  • trunk/WebCore/rendering/RenderTreeAsText.cpp

    r14256 r14273  
    207207    result += '"';
    208208    for (unsigned i = 0; i != s.length(); ++i) {
    209         QChar c = s[i];
     209        UChar c = s[i];
    210210        if (c == '\\')
    211211            result += "\\\\";
    212212        else if (c == '"')
    213213            result += "\\\"";
    214         else if (c == '\n' || c.unicode() == 0x00A0)
     214        else if (c == '\n' || c == 0x00A0)
    215215            result += ' ';
    216216        else {
    217             unsigned short u = c.unicode();
    218             if (u >= 0x20 && u < 0x7F)
     217            if (c >= 0x20 && c < 0x7F)
    219218                result += c;
    220219            else {
    221220                DeprecatedString hex;
     221                unsigned u = c;
    222222                hex.sprintf("\\x{%X}", u);
    223223                result += hex;
  • trunk/WebCore/rendering/bidi.cpp

    r14256 r14273  
    33 *
    44 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
    5  * Copyright (C) 2004 Apple Computer, Inc.
     5 * Copyright (C) 2004, 2006 Apple Computer, Inc.
    66 *
    77 * This library is free software; you can redistribute it and/or
     
    3939
    4040// an iterator which traverses all the objects within a block
    41 struct BidiIterator
    42 {
     41struct BidiIterator {
    4342    BidiIterator() : block(0), obj(0), pos(0) {}
    4443    BidiIterator(RenderBlock* b, RenderObject* o, unsigned int p)
    45      :block(b), obj(o), pos(p) {}
     44        : block(b), obj(o), pos(p) {}
    4645   
    4746    void increment(BidiState& state);
    4847    bool atEnd() const;
    4948   
    50     const QChar& current() const;
    51    
    52     QChar::Direction direction() const;
     49    UChar current() const;
     50    UCharDirection direction() const;
    5351
    5452    RenderBlock* block;
     
    5856
    5957struct BidiState {
    60     BidiState() : context(0), dir(QChar::DirON), adjustEmbedding(false), reachedEndOfLine(false) {}
     58    BidiState() : context(0), dir(U_OTHER_NEUTRAL), adjustEmbedding(false), reachedEndOfLine(false) {}
    6159   
    6260    BidiIterator sor;
     
    6664    RefPtr<BidiContext> context;
    6765    BidiStatus status;
    68     QChar::Direction dir;
     66    UCharDirection dir;
    6967    bool adjustEmbedding;
    7068    BidiIterator endOfLine;
     
    105103static int numSpaces;
    106104
    107 static void embed(QChar::Direction d, BidiState &bidi);
    108 static void appendRun(BidiState &bidi);
     105static void embed(UCharDirection, BidiState&);
     106static void appendRun(BidiState&);
    109107
    110108static int getBPMWidth(int childValue, Length cssUnit)
     
    200198   relayouting
    201199*/
    202 BidiContext::BidiContext(unsigned char l, QChar::Direction e, BidiContext *p, bool o)
     200BidiContext::BidiContext(unsigned char l, UCharDirection e, BidiContext *p, bool o)
    203201    : level(l), override(o), m_dir(e)
    204202{
     
    281279                if (ub != UBNormal) {
    282280                    TextDirection dir = next->style()->direction();
    283                     QChar::Direction d = (ub == Embed
    284                         ? (dir == RTL ? QChar::DirRLE : QChar::DirLRE)
    285                         : (dir == RTL ? QChar::DirRLO : QChar::DirLRO));
     281                    UCharDirection d = (ub == Embed
     282                        ? (dir == RTL ? U_RIGHT_TO_LEFT_EMBEDDING : U_LEFT_TO_RIGHT_EMBEDDING)
     283                        : (dir == RTL ? U_RIGHT_TO_LEFT_OVERRIDE : U_LEFT_TO_RIGHT_OVERRIDE));
    286284                    embed(d, bidi);
    287285                }
     
    299297            while (current && current != block) {
    300298                if (bidi.adjustEmbedding && current->isInlineFlow() && current->style()->unicodeBidi() != UBNormal)
    301                     embed(QChar::DirPDF, bidi);
     299                    embed(U_POP_DIRECTIONAL_FORMAT, bidi);
    302300
    303301                next = current->nextSibling();
     
    307305                        if (ub != UBNormal) {
    308306                            TextDirection dir = next->style()->direction();
    309                             QChar::Direction d = (ub == Embed
    310                                 ? (dir == RTL ? QChar::DirRLE : QChar::DirLRE)
    311                                 : (dir == RTL ? QChar::DirRLO : QChar::DirLRO));
     307                            UCharDirection d = (ub == Embed
     308                                ? (dir == RTL ? U_RIGHT_TO_LEFT_EMBEDDING : U_LEFT_TO_RIGHT_EMBEDDING)
     309                                : (dir == RTL ? U_RIGHT_TO_LEFT_OVERRIDE : U_LEFT_TO_RIGHT_OVERRIDE));
    312310                            embed(d, bidi);
    313311                        }
     
    349347            if (ub != UBNormal) {
    350348                TextDirection dir = o->style()->direction();
    351                 QChar::Direction d = (ub == Embed
    352                     ? (dir == RTL ? QChar::DirRLE : QChar::DirLRE)
    353                     : (dir == RTL ? QChar::DirRLO : QChar::DirLRO));
     349                UCharDirection d = (ub == Embed
     350                    ? (dir == RTL ? U_RIGHT_TO_LEFT_EMBEDDING : U_LEFT_TO_RIGHT_EMBEDDING)
     351                    : (dir == RTL ? U_RIGHT_TO_LEFT_OVERRIDE : U_LEFT_TO_RIGHT_OVERRIDE));
    354352                embed(d, bidi);
    355353            }
     
    387385}
    388386
    389 const QChar& BidiIterator::current() const
    390 {
    391     static QChar nullCharacter;
    392    
     387UChar BidiIterator::current() const
     388{
    393389    if (!obj || !obj->isText())
    394         return nullCharacter;
     390        return 0;
    395391   
    396392    RenderText* text = static_cast<RenderText*>(obj);
    397393    if (!text->text())
    398         return nullCharacter;
     394        return 0;
    399395   
    400396    return text->text()[pos];
    401397}
    402398
    403 ALWAYS_INLINE QChar::Direction BidiIterator::direction() const
     399ALWAYS_INLINE UCharDirection BidiIterator::direction() const
    404400{
    405401    if (!obj)
    406         return QChar::DirON;
     402        return U_OTHER_NEUTRAL;
    407403    if (obj->isListMarker())
    408         return obj->style()->direction() == LTR ? QChar::DirL : QChar::DirR;
     404        return obj->style()->direction() == LTR ? U_LEFT_TO_RIGHT : U_RIGHT_TO_LEFT;
    409405    if (!obj->isText())
    410         return QChar::DirON;
    411 
    412     RenderText *renderTxt = static_cast<RenderText *>(obj);
     406        return U_OTHER_NEUTRAL;
     407    RenderText* renderTxt = static_cast<RenderText*>(obj);
    413408    if (pos >= renderTxt->stringLength())
    414         return QChar::DirON;
    415     return renderTxt->text()[pos].direction();
     409        return U_OTHER_NEUTRAL;
     410    return u_charDirection(renderTxt->text()[pos]);
    416411}
    417412
     
    434429        if (text->text()) {
    435430            for (int i = bidiRun->start; i < bidiRun->stop; i++) {
    436                 const QChar c = text->text()[i];
     431                UChar c = text->text()[i];
    437432                if (c == ' ' || c == '\n' || c == '\t')
    438433                    numSpaces++;
     
    525520                    RenderText* textObj = static_cast<RenderText*>(endpoint.obj);
    526521                    if (endpoint.pos+1 < textObj->length()) {
    527                         if (textObj->text()[endpoint.pos+1].unicode() == SOFT_HYPHEN)
     522                        if (textObj->text()[endpoint.pos+1] == SOFT_HYPHEN)
    528523                            return;
    529524                    } else if (startpoint.obj->isText()) {
    530525                        RenderText *startText = static_cast<RenderText*>(startpoint.obj);
    531                         if (startText->length() > 0 && startText->text()[0].unicode() == SOFT_HYPHEN)
     526                        if (startText->length() > 0 && startText->text()[0] == SOFT_HYPHEN)
    532527                            return;
    533528                    }
     
    626621    bidi.eor.increment(bidi);
    627622    bidi.sor = bidi.eor;
    628     bidi.dir = QChar::DirON;
    629     bidi.status.eor = QChar::DirON;
     623    bidi.dir = U_OTHER_NEUTRAL;
     624    bidi.status.eor = U_OTHER_NEUTRAL;
    630625    bidi.adjustEmbedding = b;
    631626}
    632627
    633 static void embed(QChar::Direction d, BidiState& bidi)
     628static void embed(UCharDirection d, BidiState& bidi)
    634629{
    635630    bool b = bidi.adjustEmbedding;
    636631    bidi.adjustEmbedding = false;
    637     if (d == QChar::DirPDF) {
     632    if (d == U_POP_DIRECTIONAL_FORMAT) {
    638633        BidiContext *c = bidi.context->parent;
    639634        if (c) {
    640635            if (!emptyRun && bidi.eor != bidi.last) {
    641                 assert(bidi.status.eor != QChar::DirON);
     636                assert(bidi.status.eor != U_OTHER_NEUTRAL);
    642637                // bidi.sor ... bidi.eor ... bidi.last eor; need to append the bidi.sor-bidi.eor run or extend it through bidi.last
    643                 assert(bidi.status.last == QChar::DirES || bidi.status.last == QChar::DirET || bidi.status.last == QChar::DirCS || bidi.status.last == QChar::DirBN || bidi.status.last == QChar::DirB || bidi.status.last == QChar::DirS || bidi.status.last == QChar::DirWS || bidi.status.last == QChar::DirON);
    644                 if (bidi.dir == QChar::DirON)
     638                assert(bidi.status.last == U_EUROPEAN_NUMBER_SEPARATOR
     639                    || bidi.status.last == U_EUROPEAN_NUMBER_TERMINATOR
     640                    || bidi.status.last == U_COMMON_NUMBER_SEPARATOR
     641                    || bidi.status.last == U_BOUNDARY_NEUTRAL
     642                    || bidi.status.last == U_BLOCK_SEPARATOR
     643                    || bidi.status.last == U_SEGMENT_SEPARATOR
     644                    || bidi.status.last == U_WHITE_SPACE_NEUTRAL
     645                    || bidi.status.last == U_OTHER_NEUTRAL);
     646                if (bidi.dir == U_OTHER_NEUTRAL)
    645647                    bidi.dir = bidi.context->dir();
    646                 if (bidi.context->dir() == QChar::DirL) {
     648                if (bidi.context->dir() == U_LEFT_TO_RIGHT) {
    647649                    // bidi.sor ... bidi.eor ... bidi.last L
    648                     if (bidi.status.eor == QChar::DirEN) {
    649                         if (bidi.status.lastStrong != QChar::DirL) {
    650                             bidi.dir = QChar::DirEN;
     650                    if (bidi.status.eor == U_EUROPEAN_NUMBER) {
     651                        if (bidi.status.lastStrong != U_LEFT_TO_RIGHT) {
     652                            bidi.dir = U_EUROPEAN_NUMBER;
    651653                            appendRun(bidi);
    652654                        }
    653                     } else if (bidi.status.eor == QChar::DirAN) {
    654                         bidi.dir = QChar::DirAN;
     655                    } else if (bidi.status.eor == U_ARABIC_NUMBER) {
     656                        bidi.dir = U_ARABIC_NUMBER;
    655657                        appendRun(bidi);
    656                     } else if (bidi.status.eor != QChar::DirL)
     658                    } else if (bidi.status.eor != U_LEFT_TO_RIGHT)
    657659                        appendRun(bidi);
    658                 } else if (bidi.status.eor != QChar::DirR && bidi.status.eor != QChar::DirAL)
     660                } else if (bidi.status.eor != U_RIGHT_TO_LEFT && bidi.status.eor != U_RIGHT_TO_LEFT_ARABIC)
    659661                    appendRun(bidi);
    660662                bidi.eor = bidi.last;
     
    670672        }
    671673    } else {
    672         QChar::Direction runDir;
    673         if (d == QChar::DirRLE || d == QChar::DirRLO)
    674             runDir = QChar::DirR;
     674        UCharDirection runDir;
     675        if (d == U_RIGHT_TO_LEFT_EMBEDDING || d == U_RIGHT_TO_LEFT_OVERRIDE)
     676            runDir = U_RIGHT_TO_LEFT;
    675677        else
    676             runDir = QChar::DirL;
    677         bool override = d == QChar::DirLRO || d == QChar::DirRLO;
     678            runDir = U_LEFT_TO_RIGHT;
     679        bool override = d == U_LEFT_TO_RIGHT_OVERRIDE || d == U_RIGHT_TO_LEFT_OVERRIDE;
    678680
    679681        unsigned char level = bidi.context->level;
    680         if (runDir == QChar::DirR) {
     682        if (runDir == U_RIGHT_TO_LEFT) {
    681683            if (level%2) // we have an odd level
    682684                level += 2;
     
    692694        if (level < 61) {
    693695            if (!emptyRun && bidi.eor != bidi.last) {
    694                 assert(bidi.status.eor != QChar::DirON);
     696                assert(bidi.status.eor != U_OTHER_NEUTRAL);
    695697                // bidi.sor ... bidi.eor ... bidi.last eor; need to append the bidi.sor-bidi.eor run or extend it through bidi.last
    696                 assert(bidi.status.last == QChar::DirES || bidi.status.last == QChar::DirET || bidi.status.last == QChar::DirCS || bidi.status.last == QChar::DirBN || bidi.status.last == QChar::DirB || bidi.status.last == QChar::DirS || bidi.status.last == QChar::DirWS || bidi.status.last == QChar::DirON);
    697                 if (bidi.dir == QChar::DirON)
     698                assert(bidi.status.last == U_EUROPEAN_NUMBER_SEPARATOR
     699                    || bidi.status.last == U_EUROPEAN_NUMBER_TERMINATOR
     700                    || bidi.status.last == U_COMMON_NUMBER_SEPARATOR
     701                    || bidi.status.last == U_BOUNDARY_NEUTRAL
     702                    || bidi.status.last == U_BLOCK_SEPARATOR
     703                    || bidi.status.last == U_SEGMENT_SEPARATOR
     704                    || bidi.status.last == U_WHITE_SPACE_NEUTRAL
     705                    || bidi.status.last == U_OTHER_NEUTRAL);
     706                if (bidi.dir == U_OTHER_NEUTRAL)
    698707                    bidi.dir = runDir;
    699                 if (runDir == QChar::DirL) {
     708                if (runDir == U_LEFT_TO_RIGHT) {
    700709                    // bidi.sor ... bidi.eor ... bidi.last L
    701                     if (bidi.status.eor == QChar::DirEN) {
    702                         if (bidi.status.lastStrong != QChar::DirL) {
    703                             bidi.dir = QChar::DirEN;
     710                    if (bidi.status.eor == U_EUROPEAN_NUMBER) {
     711                        if (bidi.status.lastStrong != U_LEFT_TO_RIGHT) {
     712                            bidi.dir = U_EUROPEAN_NUMBER;
    704713                            appendRun(bidi);
    705                             if (bidi.context->dir() != QChar::DirL)
    706                                 bidi.dir = QChar::DirR;
     714                            if (bidi.context->dir() != U_LEFT_TO_RIGHT)
     715                                bidi.dir = U_RIGHT_TO_LEFT;
    707716                        }
    708                     } else if (bidi.status.eor == QChar::DirAN) {
    709                         bidi.dir = QChar::DirAN;
     717                    } else if (bidi.status.eor == U_ARABIC_NUMBER) {
     718                        bidi.dir = U_ARABIC_NUMBER;
    710719                        appendRun(bidi);
    711                         if (bidi.context->dir() != QChar::DirL) {
     720                        if (bidi.context->dir() != U_LEFT_TO_RIGHT) {
    712721                            bidi.eor = bidi.last;
    713                             bidi.dir = QChar::DirR;
     722                            bidi.dir = U_RIGHT_TO_LEFT;
    714723                            appendRun(bidi);
    715724                        }
    716                     } else if (bidi.status.eor != QChar::DirL) {
    717                         if (bidi.context->dir() == QChar::DirL || bidi.status.lastStrong == QChar::DirL)
     725                    } else if (bidi.status.eor != U_LEFT_TO_RIGHT) {
     726                        if (bidi.context->dir() == U_LEFT_TO_RIGHT || bidi.status.lastStrong == U_LEFT_TO_RIGHT)
    718727                            appendRun(bidi);
    719728                        else
    720                             bidi.dir = QChar::DirR;
     729                            bidi.dir = U_RIGHT_TO_LEFT;
    721730                    }
    722                 } else if (bidi.status.eor != QChar::DirR && bidi.status.eor != QChar::DirAL) {
     731                } else if (bidi.status.eor != U_RIGHT_TO_LEFT && bidi.status.eor != U_RIGHT_TO_LEFT_ARABIC) {
    723732                    // bidi.sor ... bidi.eor ... bidi.last R; bidi.eor=L/EN/AN; EN,AN behave like R (rule N1)
    724                     if (bidi.context->dir() == QChar::DirR || bidi.status.lastStrong == QChar::DirR || bidi.status.lastStrong == QChar::DirAL)
     733                    if (bidi.context->dir() == U_RIGHT_TO_LEFT || bidi.status.lastStrong == U_RIGHT_TO_LEFT || bidi.status.lastStrong == U_RIGHT_TO_LEFT_ARABIC)
    725734                        appendRun(bidi);
    726735                    else
    727                         bidi.dir = QChar::DirL;
     736                        bidi.dir = U_LEFT_TO_RIGHT;
    728737                }
    729738                bidi.eor = bidi.last;
     
    836845
    837846    if (!m_tabWidth) {
    838         QChar spaceChar(' ');
     847        const UChar spaceChar = ' ';
    839848        const Font& font = style()->font();
    840849        int spaceWidth = font.width(&spaceChar, 1);
     
    864873            int rtLength = rt->length();
    865874            if (rtLength != 0) {
    866                 if (r->start == 0 && needsWordSpacing && rt->text()[r->start].isSpace())
     875                if (r->start == 0 && needsWordSpacing && QChar(rt->text()[r->start]).isSpace())
    867876                    effectiveWidth += rt->font(m_firstLine)->wordSpacing();
    868                 needsWordSpacing = !rt->text()[r->stop-1].isSpace() && r->stop == rtLength;         
     877                needsWordSpacing = !QChar(rt->text()[r->stop-1]).isSpace() && r->stop == rtLength;         
    869878            }
    870879            if (!r->compact) {
     
    909918            numSpaces = 0;
    910919            // for right to left fall through to right aligned
    911             if (bidi.context->basicDir() == QChar::DirL)
     920            if (bidi.context->basicDir() == U_LEFT_TO_RIGHT)
    912921                break;
    913922        case RIGHT:
     
    937946                int spaces = 0;
    938947                for ( int i = r->start; i < r->stop; i++ ) {
    939                     const QChar c = static_cast<RenderText *>(r->obj)->text()[i];
     948                    UChar c = static_cast<RenderText*>(r->obj)->text()[i];
    940949                    if (c == ' ' || c == '\n' || c == '\t')
    941950                        spaces++;
     
    10031012    sBidiRunCount = 0;
    10041013
    1005     assert(bidi.dir == QChar::DirON);
     1014    assert(bidi.dir == U_OTHER_NEUTRAL);
    10061015
    10071016    emptyRun = true;
     
    10171026
    10181027    while (true) {
    1019         QChar::Direction dirCurrent;
     1028        UCharDirection dirCurrent;
    10201029        if (pastEnd && (previousLineBrokeCleanly || bidi.current.atEnd())) {
    10211030            BidiContext *c = bidi.context.get();
     
    10331042        } else {
    10341043            dirCurrent = bidi.current.direction();
    1035             if (bidi.context->override && dirCurrent != QChar::DirRLE && dirCurrent != QChar::DirLRE && dirCurrent != QChar::DirRLO && dirCurrent != QChar::DirLRO && dirCurrent != QChar::DirPDF)
     1044            if (bidi.context->override
     1045                    && dirCurrent != U_RIGHT_TO_LEFT_EMBEDDING
     1046                    && dirCurrent != U_LEFT_TO_RIGHT_EMBEDDING
     1047                    && dirCurrent != U_RIGHT_TO_LEFT_OVERRIDE
     1048                    && dirCurrent != U_LEFT_TO_RIGHT_OVERRIDE
     1049                    && dirCurrent != U_POP_DIRECTIONAL_FORMAT)
    10361050                dirCurrent = bidi.context->dir();
    1037             else if (dirCurrent == QChar::DirNSM)
     1051            else if (dirCurrent == U_DIR_NON_SPACING_MARK)
    10381052                dirCurrent = bidi.status.last;
    10391053        }
    10401054
    1041         assert(bidi.status.eor != QChar::DirON);
     1055        assert(bidi.status.eor != U_OTHER_NEUTRAL);
    10421056        switch (dirCurrent) {
    10431057
    10441058        // embedding and overrides (X1-X9 in the Bidi specs)
    1045         case QChar::DirRLE:
    1046         case QChar::DirLRE:
    1047         case QChar::DirRLO:
    1048         case QChar::DirLRO:
    1049         case QChar::DirPDF:
     1059        case U_RIGHT_TO_LEFT_EMBEDDING:
     1060        case U_LEFT_TO_RIGHT_EMBEDDING:
     1061        case U_RIGHT_TO_LEFT_OVERRIDE:
     1062        case U_LEFT_TO_RIGHT_OVERRIDE:
     1063        case U_POP_DIRECTIONAL_FORMAT:
    10501064            embed(dirCurrent, bidi);
    10511065            break;
    10521066
    10531067            // strong types
    1054         case QChar::DirL:
     1068        case U_LEFT_TO_RIGHT:
    10551069            switch(bidi.status.last) {
    1056                 case QChar::DirR:
    1057                 case QChar::DirAL:
    1058                 case QChar::DirEN:
    1059                 case QChar::DirAN:
    1060                     if (bidi.status.last != QChar::DirEN || bidi.status.lastStrong != QChar::DirL)
     1070                case U_RIGHT_TO_LEFT:
     1071                case U_RIGHT_TO_LEFT_ARABIC:
     1072                case U_EUROPEAN_NUMBER:
     1073                case U_ARABIC_NUMBER:
     1074                    if (bidi.status.last != U_EUROPEAN_NUMBER || bidi.status.lastStrong != U_LEFT_TO_RIGHT)
    10611075                        appendRun(bidi);
    10621076                    break;
    1063                 case QChar::DirL:
     1077                case U_LEFT_TO_RIGHT:
    10641078                    break;
    1065                 case QChar::DirES:
    1066                 case QChar::DirET:
    1067                 case QChar::DirCS:
    1068                 case QChar::DirBN:
    1069                 case QChar::DirB:
    1070                 case QChar::DirS:
    1071                 case QChar::DirWS:
    1072                 case QChar::DirON:
    1073                     if (bidi.status.eor == QChar::DirEN) {
    1074                         if (bidi.status.lastStrong != QChar::DirL) {
     1079                case U_EUROPEAN_NUMBER_SEPARATOR:
     1080                case U_EUROPEAN_NUMBER_TERMINATOR:
     1081                case U_COMMON_NUMBER_SEPARATOR:
     1082                case U_BOUNDARY_NEUTRAL:
     1083                case U_BLOCK_SEPARATOR:
     1084                case U_SEGMENT_SEPARATOR:
     1085                case U_WHITE_SPACE_NEUTRAL:
     1086                case U_OTHER_NEUTRAL:
     1087                    if (bidi.status.eor == U_EUROPEAN_NUMBER) {
     1088                        if (bidi.status.lastStrong != U_LEFT_TO_RIGHT) {
    10751089                            // the numbers need to be on a higher embedding level, so let's close that run
    1076                             bidi.dir = QChar::DirEN;
     1090                            bidi.dir = U_EUROPEAN_NUMBER;
    10771091                            appendRun(bidi);
    1078                             if (bidi.context->dir() != QChar::DirL) {
     1092                            if (bidi.context->dir() != U_LEFT_TO_RIGHT) {
    10791093                                // the neutrals take the embedding direction, which is R
    10801094                                bidi.eor = bidi.last;
    1081                                 bidi.dir = QChar::DirR;
     1095                                bidi.dir = U_RIGHT_TO_LEFT;
    10821096                                appendRun(bidi);
    10831097                            }
    10841098                        }
    1085                     } else if (bidi.status.eor == QChar::DirAN) {
     1099                    } else if (bidi.status.eor == U_ARABIC_NUMBER) {
    10861100                        // Arabic numbers are always on a higher embedding level, so let's close that run
    1087                         bidi.dir = QChar::DirAN;
     1101                        bidi.dir = U_ARABIC_NUMBER;
    10881102                        appendRun(bidi);
    1089                         if (bidi.context->dir() != QChar::DirL) {
     1103                        if (bidi.context->dir() != U_LEFT_TO_RIGHT) {
    10901104                            // the neutrals take the embedding direction, which is R
    10911105                            bidi.eor = bidi.last;
    1092                             bidi.dir = QChar::DirR;
     1106                            bidi.dir = U_RIGHT_TO_LEFT;
    10931107                            appendRun(bidi);
    10941108                        }
    1095                     } else if(bidi.status.eor != QChar::DirL) {
     1109                    } else if(bidi.status.eor != U_LEFT_TO_RIGHT) {
    10961110                        //last stuff takes embedding dir
    1097                         if (bidi.context->dir() != QChar::DirL && bidi.status.lastStrong != QChar::DirL) {
     1111                        if (bidi.context->dir() != U_LEFT_TO_RIGHT && bidi.status.lastStrong != U_LEFT_TO_RIGHT) {
    10981112                            bidi.eor = bidi.last;
    1099                             bidi.dir = QChar::DirR;
     1113                            bidi.dir = U_RIGHT_TO_LEFT;
    11001114                        }
    11011115                        appendRun(bidi);
     
    11051119            }
    11061120            bidi.eor = bidi.current;
    1107             bidi.status.eor = QChar::DirL;
    1108             bidi.status.lastStrong = QChar::DirL;
    1109             bidi.dir = QChar::DirL;
     1121            bidi.status.eor = U_LEFT_TO_RIGHT;
     1122            bidi.status.lastStrong = U_LEFT_TO_RIGHT;
     1123            bidi.dir = U_LEFT_TO_RIGHT;
    11101124            break;
    1111         case QChar::DirAL:
    1112         case QChar::DirR:
     1125        case U_RIGHT_TO_LEFT_ARABIC:
     1126        case U_RIGHT_TO_LEFT:
    11131127            switch (bidi.status.last) {
    1114                 case QChar::DirL:
    1115                 case QChar::DirEN:
    1116                 case QChar::DirAN:
     1128                case U_LEFT_TO_RIGHT:
     1129                case U_EUROPEAN_NUMBER:
     1130                case U_ARABIC_NUMBER:
    11171131                    appendRun(bidi);
    1118                 case QChar::DirR:
    1119                 case QChar::DirAL:
     1132                case U_RIGHT_TO_LEFT:
     1133                case U_RIGHT_TO_LEFT_ARABIC:
    11201134                    break;
    1121                 case QChar::DirES:
    1122                 case QChar::DirET:
    1123                 case QChar::DirCS:
    1124                 case QChar::DirBN:
    1125                 case QChar::DirB:
    1126                 case QChar::DirS:
    1127                 case QChar::DirWS:
    1128                 case QChar::DirON:
    1129                     if (bidi.status.eor != QChar::DirR && bidi.status.eor != QChar::DirAL) {
     1135                case U_EUROPEAN_NUMBER_SEPARATOR:
     1136                case U_EUROPEAN_NUMBER_TERMINATOR:
     1137                case U_COMMON_NUMBER_SEPARATOR:
     1138                case U_BOUNDARY_NEUTRAL:
     1139                case U_BLOCK_SEPARATOR:
     1140                case U_SEGMENT_SEPARATOR:
     1141                case U_WHITE_SPACE_NEUTRAL:
     1142                case U_OTHER_NEUTRAL:
     1143                    if (bidi.status.eor != U_RIGHT_TO_LEFT && bidi.status.eor != U_RIGHT_TO_LEFT_ARABIC) {
    11301144                        //last stuff takes embedding dir
    1131                         if (bidi.context->dir() != QChar::DirR && bidi.status.lastStrong != QChar::DirR
    1132                             && bidi.status.lastStrong != QChar::DirAL) {
     1145                        if (bidi.context->dir() != U_RIGHT_TO_LEFT && bidi.status.lastStrong != U_RIGHT_TO_LEFT
     1146                            && bidi.status.lastStrong != U_RIGHT_TO_LEFT_ARABIC) {
    11331147                            bidi.eor = bidi.last;
    1134                             bidi.dir = QChar::DirL;
     1148                            bidi.dir = U_LEFT_TO_RIGHT;
    11351149                        }
    11361150                        appendRun(bidi);
     
    11401154            }
    11411155            bidi.eor = bidi.current;
    1142             bidi.status.eor = QChar::DirR;
     1156            bidi.status.eor = U_RIGHT_TO_LEFT;
    11431157            bidi.status.lastStrong = dirCurrent;
    1144             bidi.dir = QChar::DirR;
     1158            bidi.dir = U_RIGHT_TO_LEFT;
    11451159            break;
    11461160
    11471161            // weak types:
    11481162
    1149         case QChar::DirEN:
    1150             if (bidi.status.lastStrong != QChar::DirAL) {
     1163        case U_EUROPEAN_NUMBER:
     1164            if (bidi.status.lastStrong != U_RIGHT_TO_LEFT_ARABIC) {
    11511165                // if last strong was AL change EN to AN
    11521166                switch (bidi.status.last) {
    1153                     case QChar::DirEN:
    1154                     case QChar::DirL:
     1167                    case U_EUROPEAN_NUMBER:
     1168                    case U_LEFT_TO_RIGHT:
    11551169                        break;
    1156                     case QChar::DirR:
    1157                     case QChar::DirAL:
    1158                     case QChar::DirAN:
     1170                    case U_RIGHT_TO_LEFT:
     1171                    case U_RIGHT_TO_LEFT_ARABIC:
     1172                    case U_ARABIC_NUMBER:
    11591173                        bidi.eor = bidi.last;
    11601174                        appendRun(bidi);
    1161                         bidi.dir = QChar::DirEN;
     1175                        bidi.dir = U_EUROPEAN_NUMBER;
    11621176                        break;
    1163                     case QChar::DirES:
    1164                     case QChar::DirCS:
    1165                         if (bidi.status.eor == QChar::DirEN)
     1177                    case U_EUROPEAN_NUMBER_SEPARATOR:
     1178                    case U_COMMON_NUMBER_SEPARATOR:
     1179                        if (bidi.status.eor == U_EUROPEAN_NUMBER)
    11661180                            break;
    1167                     case QChar::DirET:
    1168                     case QChar::DirBN:
    1169                     case QChar::DirB:
    1170                     case QChar::DirS:
    1171                     case QChar::DirWS:
    1172                     case QChar::DirON:
    1173                         if (bidi.status.eor == QChar::DirR) {
     1181                    case U_EUROPEAN_NUMBER_TERMINATOR:
     1182                    case U_BOUNDARY_NEUTRAL:
     1183                    case U_BLOCK_SEPARATOR:
     1184                    case U_SEGMENT_SEPARATOR:
     1185                    case U_WHITE_SPACE_NEUTRAL:
     1186                    case U_OTHER_NEUTRAL:
     1187                        if (bidi.status.eor == U_RIGHT_TO_LEFT) {
    11741188                            // neutrals go to R
    1175                             bidi.eor = bidi.status.last == QChar::DirET ? bidi.lastBeforeET : bidi.last;
     1189                            bidi.eor = bidi.status.last == U_EUROPEAN_NUMBER_TERMINATOR ? bidi.lastBeforeET : bidi.last;
    11761190                            appendRun(bidi);
    1177                             bidi.dir = QChar::DirEN;
    1178                         } else if (bidi.status.eor != QChar::DirL &&
    1179                                  (bidi.status.eor != QChar::DirEN || bidi.status.lastStrong != QChar::DirL) &&
    1180                                  bidi.dir != QChar::DirL) {
     1191                            bidi.dir = U_EUROPEAN_NUMBER;
     1192                        } else if (bidi.status.eor != U_LEFT_TO_RIGHT &&
     1193                                 (bidi.status.eor != U_EUROPEAN_NUMBER || bidi.status.lastStrong != U_LEFT_TO_RIGHT) &&
     1194                                 bidi.dir != U_LEFT_TO_RIGHT) {
    11811195                            // numbers on both sides, neutrals get right to left direction
    11821196                            appendRun(bidi);
    1183                             bidi.eor = bidi.status.last == QChar::DirET ? bidi.lastBeforeET : bidi.last;
    1184                             bidi.dir = QChar::DirR;
     1197                            bidi.eor = bidi.status.last == U_EUROPEAN_NUMBER_TERMINATOR ? bidi.lastBeforeET : bidi.last;
     1198                            bidi.dir = U_RIGHT_TO_LEFT;
    11851199                            appendRun(bidi);
    1186                             bidi.dir = QChar::DirEN;
     1200                            bidi.dir = U_EUROPEAN_NUMBER;
    11871201                        }
    11881202                    default:
     
    11901204                }
    11911205                bidi.eor = bidi.current;
    1192                 bidi.status.eor = QChar::DirEN;
    1193                 if (bidi.dir == QChar::DirON)
    1194                     bidi.dir = QChar::DirL;
     1206                bidi.status.eor = U_EUROPEAN_NUMBER;
     1207                if (bidi.dir == U_OTHER_NEUTRAL)
     1208                    bidi.dir = U_LEFT_TO_RIGHT;
    11951209                break;
    11961210            }
    1197         case QChar::DirAN:
    1198             dirCurrent = QChar::DirAN;
     1211        case U_ARABIC_NUMBER:
     1212            dirCurrent = U_ARABIC_NUMBER;
    11991213            switch (bidi.status.last) {
    1200                 case QChar::DirL:
    1201                     if (bidi.context->dir() == QChar::DirL)
     1214                case U_LEFT_TO_RIGHT:
     1215                    if (bidi.context->dir() == U_LEFT_TO_RIGHT)
    12021216                        appendRun(bidi);
    12031217                    break;
    1204                 case QChar::DirAN:
     1218                case U_ARABIC_NUMBER:
    12051219                    break;
    1206                 case QChar::DirR:
    1207                 case QChar::DirAL:
    1208                 case QChar::DirEN:
     1220                case U_RIGHT_TO_LEFT:
     1221                case U_RIGHT_TO_LEFT_ARABIC:
     1222                case U_EUROPEAN_NUMBER:
    12091223                    bidi.eor = bidi.last;
    12101224                    appendRun(bidi);
    12111225                    break;
    1212                 case QChar::DirCS:
    1213                     if (bidi.status.eor == QChar::DirAN)
     1226                case U_COMMON_NUMBER_SEPARATOR:
     1227                    if (bidi.status.eor == U_ARABIC_NUMBER)
    12141228                        break;
    1215                 case QChar::DirES:
    1216                 case QChar::DirET:
    1217                 case QChar::DirBN:
    1218                 case QChar::DirB:
    1219                 case QChar::DirS:
    1220                 case QChar::DirWS:
    1221                 case QChar::DirON:
    1222                     if (bidi.status.eor != QChar::DirR && bidi.status.eor != QChar::DirAL) {
     1229                case U_EUROPEAN_NUMBER_SEPARATOR:
     1230                case U_EUROPEAN_NUMBER_TERMINATOR:
     1231                case U_BOUNDARY_NEUTRAL:
     1232                case U_BLOCK_SEPARATOR:
     1233                case U_SEGMENT_SEPARATOR:
     1234                case U_WHITE_SPACE_NEUTRAL:
     1235                case U_OTHER_NEUTRAL:
     1236                    if (bidi.status.eor != U_RIGHT_TO_LEFT && bidi.status.eor != U_RIGHT_TO_LEFT_ARABIC) {
    12231237                        // run of L before neutrals, neutrals take embedding dir (N2)
    1224                         if (bidi.context->dir() == QChar::DirR || bidi.status.lastStrong == QChar::DirR
    1225                             || bidi.status.lastStrong == QChar::DirAL) {
     1238                        if (bidi.context->dir() == U_RIGHT_TO_LEFT || bidi.status.lastStrong == U_RIGHT_TO_LEFT
     1239                            || bidi.status.lastStrong == U_RIGHT_TO_LEFT_ARABIC) {
    12261240                            // the embedding direction is R
    12271241                            // close the L run
    12281242                            appendRun(bidi);
    12291243                            // neutrals become an R run
    1230                             bidi.dir = QChar::DirR;
     1244                            bidi.dir = U_RIGHT_TO_LEFT;
    12311245                        } else {
    12321246                            // the embedding direction is L
    12331247                            // append neutrals to the L run and close it
    1234                             bidi.dir = QChar::DirL;
     1248                            bidi.dir = U_LEFT_TO_RIGHT;
    12351249                        }
    12361250                    }
     
    12411255            }
    12421256            bidi.eor = bidi.current;
    1243             bidi.status.eor = QChar::DirAN;
    1244             if (bidi.dir == QChar::DirON)
    1245                 bidi.dir = QChar::DirAN;
     1257            bidi.status.eor = U_ARABIC_NUMBER;
     1258            if (bidi.dir == U_OTHER_NEUTRAL)
     1259                bidi.dir = U_ARABIC_NUMBER;
    12461260            break;
    1247         case QChar::DirES:
    1248         case QChar::DirCS:
     1261        case U_EUROPEAN_NUMBER_SEPARATOR:
     1262        case U_COMMON_NUMBER_SEPARATOR:
    12491263            break;
    1250         case QChar::DirET:
    1251             if (bidi.status.last == QChar::DirEN) {
    1252                 dirCurrent = QChar::DirEN;
     1264        case U_EUROPEAN_NUMBER_TERMINATOR:
     1265            if (bidi.status.last == U_EUROPEAN_NUMBER) {
     1266                dirCurrent = U_EUROPEAN_NUMBER;
    12531267                bidi.eor = bidi.current;
    12541268                bidi.status.eor = dirCurrent;
    1255             } else if (bidi.status.last != QChar::DirET)
     1269            } else if (bidi.status.last != U_EUROPEAN_NUMBER_TERMINATOR)
    12561270                bidi.lastBeforeET = emptyRun ? bidi.eor : bidi.last;
    12571271            break;
    12581272
    12591273        // boundary neutrals should be ignored
    1260         case QChar::DirBN:
     1274        case U_BOUNDARY_NEUTRAL:
    12611275            if (bidi.eor == bidi.last)
    12621276                bidi.eor = bidi.current;
    12631277            break;
    12641278            // neutrals
    1265         case QChar::DirB:
     1279        case U_BLOCK_SEPARATOR:
    12661280            // ### what do we do with newline and paragraph seperators that come to here?
    12671281            break;
    1268         case QChar::DirS:
     1282        case U_SEGMENT_SEPARATOR:
    12691283            // ### implement rule L1
    12701284            break;
    1271         case QChar::DirWS:
     1285        case U_WHITE_SPACE_NEUTRAL:
    12721286            break;
    1273         case QChar::DirON:
     1287        case U_OTHER_NEUTRAL:
    12741288            break;
    12751289        default:
     
    12821296                    bidi.eor = bidi.endOfLine;
    12831297                    switch (bidi.status.eor) {
    1284                         case QChar::DirL:
    1285                         case QChar::DirR:
    1286                         case QChar::DirAN:
     1298                        case U_LEFT_TO_RIGHT:
     1299                        case U_RIGHT_TO_LEFT:
     1300                        case U_ARABIC_NUMBER:
    12871301                            bidi.dir = bidi.status.eor;
    12881302                            break;
    1289                         case QChar::DirEN:
    1290                             bidi.dir = bidi.status.lastStrong == QChar::DirL ? QChar::DirL : QChar::DirEN;
     1303                        case U_EUROPEAN_NUMBER:
     1304                            bidi.dir = bidi.status.lastStrong == U_LEFT_TO_RIGHT ? U_LEFT_TO_RIGHT : U_EUROPEAN_NUMBER;
    12911305                            break;
    12921306                        default:
     
    12961310                }
    12971311                bidi = stateAtEnd;
    1298                 bidi.dir = QChar::DirON;
     1312                bidi.dir = U_OTHER_NEUTRAL;
    12991313                break;
    13001314            }
     
    13031317        // set status.last as needed.
    13041318        switch (dirCurrent) {
    1305             case QChar::DirET:
    1306                 if (bidi.status.last != QChar::DirEN)
    1307                     bidi.status.last = QChar::DirET;
     1319            case U_EUROPEAN_NUMBER_TERMINATOR:
     1320                if (bidi.status.last != U_EUROPEAN_NUMBER)
     1321                    bidi.status.last = U_EUROPEAN_NUMBER_TERMINATOR;
    13081322                break;
    1309             case QChar::DirES:
    1310             case QChar::DirCS:
    1311             case QChar::DirS:
    1312             case QChar::DirWS:
    1313             case QChar::DirON:
     1323            case U_EUROPEAN_NUMBER_SEPARATOR:
     1324            case U_COMMON_NUMBER_SEPARATOR:
     1325            case U_SEGMENT_SEPARATOR:
     1326            case U_WHITE_SPACE_NEUTRAL:
     1327            case U_OTHER_NEUTRAL:
    13141328                switch(bidi.status.last) {
    1315                     case QChar::DirL:
    1316                     case QChar::DirR:
    1317                     case QChar::DirAL:
    1318                     case QChar::DirEN:
    1319                     case QChar::DirAN:
     1329                    case U_LEFT_TO_RIGHT:
     1330                    case U_RIGHT_TO_LEFT:
     1331                    case U_RIGHT_TO_LEFT_ARABIC:
     1332                    case U_EUROPEAN_NUMBER:
     1333                    case U_ARABIC_NUMBER:
    13201334                        bidi.status.last = dirCurrent;
    13211335                        break;
    13221336                    default:
    1323                         bidi.status.last = QChar::DirON;
     1337                        bidi.status.last = U_OTHER_NEUTRAL;
    13241338                    }
    13251339                break;
    1326             case QChar::DirNSM:
    1327             case QChar::DirBN:
    1328             case QChar::DirRLE:
    1329             case QChar::DirLRE:
    1330             case QChar::DirRLO:
    1331             case QChar::DirLRO:
    1332             case QChar::DirPDF:
     1340            case U_DIR_NON_SPACING_MARK:
     1341            case U_BOUNDARY_NEUTRAL:
     1342            case U_RIGHT_TO_LEFT_EMBEDDING:
     1343            case U_LEFT_TO_RIGHT_EMBEDDING:
     1344            case U_RIGHT_TO_LEFT_OVERRIDE:
     1345            case U_LEFT_TO_RIGHT_OVERRIDE:
     1346            case U_POP_DIRECTIONAL_FORMAT:
    13331347                // ignore these
    13341348                break;
    1335             case QChar::DirEN:
     1349            case U_EUROPEAN_NUMBER:
    13361350                // fall through
    13371351            default:
     
    13411355        bidi.last = bidi.current;
    13421356
    1343         if (emptyRun && !(dirCurrent == QChar::DirRLE || dirCurrent == QChar::DirLRE || dirCurrent == QChar::DirRLO || dirCurrent == QChar::DirLRO || dirCurrent == QChar::DirPDF)) {
     1357        if (emptyRun && !(dirCurrent == U_RIGHT_TO_LEFT_EMBEDDING
     1358                || dirCurrent == U_LEFT_TO_RIGHT_EMBEDDING
     1359                || dirCurrent == U_RIGHT_TO_LEFT_OVERRIDE
     1360                || dirCurrent == U_LEFT_TO_RIGHT_OVERRIDE
     1361                || dirCurrent == U_POP_DIRECTIONAL_FORMAT)) {
    13441362            bidi.sor = bidi.current;
    13451363            emptyRun = false;
     
    13511369        bidi.current.increment(bidi);
    13521370        bidi.adjustEmbedding = false;
    1353         if (emptyRun && (dirCurrent == QChar::DirRLE || dirCurrent == QChar::DirLRE || dirCurrent == QChar::DirRLO || dirCurrent == QChar::DirLRO || dirCurrent == QChar::DirPDF)) {
     1371        if (emptyRun && (dirCurrent == U_RIGHT_TO_LEFT_EMBEDDING
     1372                || dirCurrent == U_LEFT_TO_RIGHT_EMBEDDING
     1373                || dirCurrent == U_RIGHT_TO_LEFT_OVERRIDE
     1374                || dirCurrent == U_LEFT_TO_RIGHT_OVERRIDE
     1375                || dirCurrent == U_POP_DIRECTIONAL_FORMAT)) {
    13541376            // exclude the embedding char itself from the new run so that ATSUI will never see it
    13551377            bidi.eor.obj = 0;
     
    15341556        BidiContext *startEmbed;
    15351557        if (style()->direction() == LTR) {
    1536             startEmbed = new BidiContext( 0, QChar::DirL, NULL, style()->unicodeBidi() == Override );
    1537             bidi.status.eor = QChar::DirL;
     1558            startEmbed = new BidiContext( 0, U_LEFT_TO_RIGHT, NULL, style()->unicodeBidi() == Override );
     1559            bidi.status.eor = U_LEFT_TO_RIGHT;
    15381560        } else {
    1539             startEmbed = new BidiContext( 1, QChar::DirR, NULL, style()->unicodeBidi() == Override );
    1540             bidi.status.eor = QChar::DirR;
     1561            startEmbed = new BidiContext( 1, U_RIGHT_TO_LEFT, NULL, style()->unicodeBidi() == Override );
     1562            bidi.status.eor = U_RIGHT_TO_LEFT;
    15411563        }
    15421564
     
    15451567        bidi.status.eor = startEmbed->dir();
    15461568        bidi.context = startEmbed;
    1547         bidi.dir = QChar::DirON;
     1569        bidi.dir = U_OTHER_NEUTRAL;
    15481570       
    15491571        if (!smidpoints)
     
    18741896static inline bool skipNonBreakingSpace(BidiIterator &it)
    18751897{
    1876     if (it.obj->style()->nbspMode() != SPACE || it.current().unicode() != nonBreakingSpace)
     1898    if (it.obj->style()->nbspMode() != SPACE || it.current() != nonBreakingSpace)
    18771899        return false;
    18781900 
     
    19021924    while (!it.atEnd() && (it.obj->isInlineFlow() || (shouldCollapseWhiteSpace(it.obj->style()) && !it.obj->isBR() &&
    19031925          (it.current() == ' ' || it.current() == '\t' || (!it.obj->style()->preserveNewline() && it.current() == '\n') ||
    1904           it.current().unicode() == SOFT_HYPHEN || skipNonBreakingSpace(it) || it.obj->isFloatingOrPositioned())))) {
     1926          it.current() == SOFT_HYPHEN || skipNonBreakingSpace(it) || it.obj->isFloatingOrPositioned())))) {
    19051927        if (it.obj->isFloatingOrPositioned()) {
    19061928            RenderObject *o = it.obj;
     
    21032125                if (style()->collapseWhiteSpace() && next && !next->isBR() && next->isText() && static_cast<RenderText*>(next)->stringLength() > 0) {
    21042126                    RenderText *nextText = static_cast<RenderText*>(next);
    2105                     QChar nextChar = nextText->text()[0];
    2106 
     2127                    UChar nextChar = nextText->text()[0];
    21072128                    if (nextText->style()->isCollapsibleWhiteSpace(nextChar)) {
    21082129                        currentCharacterIsSpace = true;
     
    21192140            int strlen = t->stringLength();
    21202141            int len = strlen - pos;
    2121             const QChar* str = t->text();
     2142            const UChar* str = t->text();
    21222143
    21232144            const Font *f = t->font(m_firstLine);
     
    21352156                bool previousCharacterIsSpace = currentCharacterIsSpace;
    21362157                bool previousCharacterIsWS = currentCharacterIsWS;
    2137                 const QChar c = str[pos];
     2158                UChar c = str[pos];
    21382159                currentCharacterIsSpace = c == ' ' || c == '\t' || (!o->style()->preserveNewline() && (c == '\n'));
    21392160
     
    21422163               
    21432164                // Check for soft hyphens.  Go ahead and ignore them.
    2144                 if (c.unicode() == SOFT_HYPHEN) {
     2165                if (c == SOFT_HYPHEN) {
    21452166                    if (!ignoringSpaces) {
    21462167                        // Ignore soft hyphens
     
    21822203                bool breakWords = o->style()->wordWrap() == BREAK_WORD && ((allowBreak && w == 0) || o->style()->whiteSpace() == PRE);
    21832204
    2184                 currentCharacterIsWS = currentCharacterIsSpace || (breakNBSP && c.unicode() == nonBreakingSpace);
     2205                currentCharacterIsWS = currentCharacterIsSpace || (breakNBSP && c == nonBreakingSpace);
    21852206
    21862207                if (breakWords)
     
    22672288                            if (midWordBreak)
    22682289                                tmpW -= additionalTmpW;
    2269                             if (pos > 0 && str[pos-1].unicode() == SOFT_HYPHEN)
     2290                            if (pos > 0 && str[pos-1] == SOFT_HYPHEN)
    22702291                                // Subtract the width of the soft hyphen out since we fit on a line.
    22712292                                tmpW -= t->width(pos-1, 1, f, w+tmpW);
     
    23702391                    RenderText* nextText = static_cast<RenderText*>(next);
    23712392                    if (nextText->stringLength() != 0) {
    2372                         QChar c = nextText->text()[0];
    2373                         if (c == ' ' || c == '\t' || (c == '\n' && !next->style()->preserveNewline())) {
     2393                        UChar c = nextText->text()[0];
     2394                        if (c == ' ' || c == '\t' || (c == '\n' && !next->style()->preserveNewline()))
    23742395                            // If the next item on the line is text, and if we did not end with
    23752396                            // a space, then the next text run continues our word (and so it needs to
    23762397                            // keep adding to |tmpW|.  Just update and continue.
    23772398                            checkForBreak = true;
    2378                         }
    23792399                    }
    23802400                    bool canPlaceOnLine = (w + tmpW <= width) || !autoWrap;
     
    25092529        // For soft hyphens on line breaks, we have to chop out the midpoints that made us
    25102530        // ignore the hyphen so that it will render at the end of the line.
    2511         QChar c = static_cast<RenderText*>(lBreak.obj)->text()[lBreak.pos-1];
    2512         if (c.unicode() == SOFT_HYPHEN)
     2531        UChar c = static_cast<RenderText*>(lBreak.obj)->text()[lBreak.pos-1];
     2532        if (c == SOFT_HYPHEN)
    25132533            chopMidpointsAt(lBreak.obj, lBreak.pos-2);
    25142534    }
     
    25392559{
    25402560    // Determine the width of the ellipsis using the current font.
    2541     QChar ellipsis = 0x2026; // FIXME: CSS3 says this is configurable, also need to use 0x002E (FULL STOP) if 0x2026 not renderable
    2542     static AtomicString ellipsisStr(ellipsis);
     2561    const UChar ellipsis = 0x2026; // FIXME: CSS3 says this is configurable, also need to use 0x002E (FULL STOP) if 0x2026 not renderable
     2562    static AtomicString ellipsisStr(&ellipsis, 1);
    25432563    const Font& firstLineFont = firstLineStyle()->font();
    25442564    const Font& font = style()->font();
  • trunk/WebCore/rendering/bidi.h

    r13858 r14273  
    2121 *
    2222 */
     23
    2324#ifndef BIDI_H
    2425#define BIDI_H
    2526
    26 #include "DeprecatedString.h"
     27#include <unicode/uchar.h>
    2728
    2829class RenderArena;
    2930
    3031namespace WebCore {
     32
    3133    class RenderBlock;
    3234    class RenderObject;
     
    3436
    3537    struct BidiStatus {
    36         BidiStatus() : eor(QChar::DirON), lastStrong(QChar::DirON), last(QChar::DirON) {}
     38        BidiStatus() : eor(U_OTHER_NEUTRAL), lastStrong(U_OTHER_NEUTRAL), last(U_OTHER_NEUTRAL) {}
    3739       
    38         QChar::Direction eor;
    39         QChar::Direction lastStrong;
    40         QChar::Direction last;
     40        UCharDirection eor;
     41        UCharDirection lastStrong;
     42        UCharDirection last;
    4143    };
    4244       
    4345    class BidiContext {
    4446    public:
    45         BidiContext(unsigned char level, QChar::Direction embedding, BidiContext *parent = 0, bool override = false);
     47        BidiContext(unsigned char level, UCharDirection embedding, BidiContext* parent = 0, bool override = false);
    4648        ~BidiContext();
    4749
     
    4951        void deref() const;
    5052
    51         QChar::Direction dir() const { return static_cast<QChar::Direction>(m_dir); }
    52         QChar::Direction basicDir() const { return static_cast<QChar::Direction>(m_basicDir); }
     53        UCharDirection dir() const { return static_cast<UCharDirection>(m_dir); }
     54        UCharDirection basicDir() const { return static_cast<UCharDirection>(m_basicDir); }
    5355
    5456        unsigned char level;
    5557        bool override : 1;
    56         unsigned m_dir : 5; // QChar::Direction
    57         unsigned m_basicDir : 5; // QChar::Direction
    58        
    59         BidiContext *parent;
     58        unsigned m_dir : 5; // UCharDirection
     59        unsigned m_basicDir : 5; // UCharDirection
     60
     61        BidiContext* parent;
    6062
    6163        // refcounting....
     
    6466
    6567    struct BidiRun {
    66         BidiRun(int _start, int _stop, RenderObject *_obj, BidiContext *context, QChar::Direction dir)
    67             :  start( _start ), stop( _stop ), obj( _obj ), box(0), override(context->override), nextRun(0)
     68        BidiRun(int start_, int stop_, RenderObject* o, BidiContext* context, UCharDirection dir)
     69            :  start(start_), stop(stop_), obj(o), box(0), override(context->override), nextRun(0)
    6870        {
    69             if (dir == QChar::DirON)
     71            if (dir == U_OTHER_NEUTRAL)
    7072                dir = context->dir();
    7173
     
    7375
    7476            // add level of run (cases I1 & I2)
    75             if( level % 2 ) {
    76                 if(dir == QChar::DirL || dir == QChar::DirAN || dir == QChar::DirEN)
     77            if (level % 2) {
     78                if(dir == U_LEFT_TO_RIGHT || dir == U_ARABIC_NUMBER || dir == U_EUROPEAN_NUMBER)
    7779                    level++;
    7880            } else {
    79                 if( dir == QChar::DirR )
     81                if (dir == U_RIGHT_TO_LEFT)
    8082                    level++;
    81                 else if( dir == QChar::DirAN || dir == QChar::DirEN)
     83                else if (dir == U_ARABIC_NUMBER || dir == U_EUROPEAN_NUMBER)
    8284                    level += 2;
    8385            }
    8486        }
    8587
    86         void destroy(RenderArena* renderArena);
     88        void destroy(RenderArena*);
    8789
    8890        // Overloaded new operator.
    89         void* operator new(size_t sz, RenderArena* renderArena) throw();
     91        void* operator new(size_t, RenderArena*) throw();
    9092
    9193        // Overridden to prevent the normal delete from being called.
    92         void operator delete(void* ptr, size_t sz);
     94        void operator delete(void*, size_t);
    9395
    9496private:
    9597        // The normal operator new is disallowed.
    96         void* operator new(size_t sz) throw();
     98        void* operator new(size_t) throw();
    9799
    98100public:
  • trunk/WebCore/rendering/break_lines.cpp

    r13858 r14273  
    3232namespace WebCore {
    3333
    34 int nextBreakablePosition(const QChar *str, int pos, int len, bool breakNBSP)
     34int nextBreakablePosition(const UChar* str, int pos, int len, bool breakNBSP)
    3535{
    3636#if __APPLE__
     
    4242    unsigned short ch, lastCh;
    4343   
    44     lastCh = pos > 0 ? str[pos - 1].unicode() : 0;
     44    lastCh = pos > 0 ? str[pos - 1] : 0;
    4545    for (i = pos; i < len; i++) {
    46         ch = str[i].unicode();
     46        ch = str[i];
    4747        if (ch == ' ' || ch == '\n' || ch == '\t' || (breakNBSP && ch == 0xa0))
    4848            break;
  • trunk/WebCore/rendering/break_lines.h

    r13393 r14273  
    2121 */
    2222
    23 class QChar;
     23#include <unicode/umachine.h>
    2424
    2525namespace WebCore {
    2626
    27     int nextBreakablePosition(const QChar *str, int pos, int len, bool breakNBSP = false);
     27    int nextBreakablePosition(const UChar*, int pos, int len, bool breakNBSP = false);
    2828
    29     inline bool isBreakable(const QChar *str, int pos, int len, int &nextBreakable, bool breakNBSP = false)
     29    inline bool isBreakable(const UChar* str, int pos, int len, int& nextBreakable, bool breakNBSP = false)
    3030    {
    3131        if (pos > nextBreakable)
  • trunk/WebCore/rendering/render_form.cpp

    r14207 r14273  
    258258        String widgetText = w->text();
    259259        String newText = e->value();
    260         newText.replace(QChar('\\'), backslashAsCurrencySymbol());
     260        newText.replace('\\', backslashAsCurrencySymbol());
    261261        if (widgetText != newText) {
    262262            int pos = w->cursorPosition();
     
    653653                HTMLOptGroupElement *optgroupElement = static_cast<HTMLOptGroupElement*>(listItems[listIndex]);
    654654                DeprecatedString label = optgroupElement->getAttribute(labelAttr).deprecatedString();
    655                 label.replace(QChar('\\'), backslashAsCurrencySymbol());
     655                label.replace('\\', backslashAsCurrencySymbol());
    656656               
    657657                // In WinIE, an optgroup can't start or end with whitespace (other than the indent
     
    676676                    itemText = optionElement->text().deprecatedString();
    677677               
    678                 itemText.replace(QChar('\\'), backslashAsCurrencySymbol());
     678                itemText.replace('\\', backslashAsCurrencySymbol());
    679679
    680680                // In WinIE, leading and trailing whitespace is ignored in options. We match this behavior.
     
    996996    String widgetText = text();
    997997    String text = e->value();
    998     text.replace(QChar('\\'), backslashAsCurrencySymbol());
     998    text.replace('\\', backslashAsCurrencySymbol());
    999999    if (widgetText != text) {
    10001000        int line, col;
     
    10151015{
    10161016    String txt = static_cast<QTextEdit*>(m_widget)->text();
    1017     return txt.replace(backslashAsCurrencySymbol(), QChar('\\'));
     1017    return txt.replace(backslashAsCurrencySymbol(), '\\');
    10181018}
    10191019
     
    10211021{
    10221022    String txt = static_cast<QTextEdit*>(m_widget)->textWithHardLineBreaks();
    1023     return txt.replace(backslashAsCurrencySymbol(), QChar('\\'));
     1023    return txt.replace(backslashAsCurrencySymbol(), '\\');
    10241024}
    10251025
  • trunk/WebCore/rendering/render_line.cpp

    r13992 r14273  
    476476            RenderText *rt = static_cast<RenderText*>(text->object());
    477477            if (rt->length()) {
    478                 if (needsWordSpacing && rt->text()[text->start()].isSpace())
     478                if (needsWordSpacing && QChar(rt->text()[text->start()]).isSpace())
    479479                    x += rt->font(m_firstLine)->wordSpacing();
    480                 needsWordSpacing = !rt->text()[text->end()].isSpace();
     480                needsWordSpacing = !QChar(rt->text()[text->end()]).isSpace();
    481481            }
    482482            text->setXPos(x);
     
    10861086
    10871087    const String& str = m_str;
    1088     p->drawText(IntPoint(m_x + _tx, m_y + _ty + m_baseline), 0, 0, str.unicode(), str.length(),
     1088    p->drawText(IntPoint(m_x + _tx, m_y + _ty + m_baseline), 0, 0, str.characters(), str.length(),
    10891089        0, str.length(), 0, LTR, _style->visuallyOrdered(), 0, str.length());
    10901090
  • trunk/WebCore/rendering/render_list.cpp

    r14102 r14273  
    4141const int cMarkerPadding = 7;
    4242
    43 static DeprecatedString toRoman( int number, bool upper )
     43static DeprecatedString toRoman(int number, bool upper)
    4444{
    4545    DeprecatedString roman;
    46     QChar ldigits[] = { 'i', 'v', 'x', 'l', 'c', 'd', 'm' };
    47     QChar udigits[] = { 'I', 'V', 'X', 'L', 'C', 'D', 'M' };
    48     QChar *digits = upper ? udigits : ldigits;
    49     int i, d = 0;
    50 
    51     do
    52     {
     46    const UChar ldigits[] = { 'i', 'v', 'x', 'l', 'c', 'd', 'm' };
     47    const UChar udigits[] = { 'I', 'V', 'X', 'L', 'C', 'D', 'M' };
     48    const UChar* digits = upper ? udigits : ldigits;
     49    int d = 0;
     50    do {
    5351        int num = number % 10;
    54 
    55         if ( num % 5 < 4 )
    56             for ( i = num % 5; i > 0; i-- )
    57                 roman.insert( 0, digits[ d ] );
    58 
    59         if ( num >= 4 && num <= 8)
    60             roman.insert( 0, digits[ d+1 ] );
    61 
    62         if ( num == 9 )
    63             roman.insert( 0, digits[ d+2 ] );
    64 
    65         if ( num % 5 == 4 )
    66             roman.insert( 0, digits[ d ] );
    67 
     52        if (num % 5 < 4)
     53            for (int i = num % 5; i > 0; i--)
     54                roman.insert(0, digits[d]);
     55        if (num >= 4 && num <= 8)
     56            roman.insert(0, digits[d + 1]);
     57        if (num == 9)
     58            roman.insert(0, digits[d + 2]);
     59        if (num % 5 == 4)
     60            roman.insert(0, digits[d]);
    6861        number /= 10;
    6962        d += 2;
    70     }
    71     while ( number );
    72 
     63    } while (number);
    7364    return roman;
    7465}
     
    7768{
    7869    if (number < 2)
    79         return (QChar)letterA; // match WinIE (A.) not FireFox (0.)
    80    
     70        return QChar(letterA); // match WinIE (A.) not FireFox (0.)
     71
    8172    DeprecatedString letterString;
    8273    while (number > 0) {
    83         int onesDigit = ((number - 1) % 26);
    84         letterString = (QChar)(letterA + onesDigit) + letterString;
     74        int onesDigit = (number - 1) % 26;
     75        letterString = QChar(letterA + onesDigit) + letterString;
    8576        number -= onesDigit;
    8677        number /= 26;
    8778    }
    88    
     79
    8980    return letterString;
    9081}
    9182
    92 static DeprecatedString toHebrew( int number ) {
     83static DeprecatedString toHebrew(int number)
     84{
    9385    const QChar tenDigit[] = {1497, 1499, 1500, 1502, 1504, 1505, 1506, 1508, 1510};
    9486
    9587    DeprecatedString letter;
    9688    if (number > 999) {
    97         letter = toHebrew(number/1000) + "'";
     89        letter = toHebrew(number / 1000) + "'";
    9890        number = number % 1000;
    9991    }
    100 
    101     int hunderts = (number/400);
    102     if (hunderts > 0) {
    103         for (int i=0; i<hunderts; i++)
    104             letter += QChar(1511 + 3);
    105     }
    106     number = number % 400;
    107     if ((number / 100) != 0)
    108         letter += QChar (1511 + (number / 100) -1);
    109     number = number % 100;
    110     int tens = number/10;
    111     if (tens > 0 && !(number == 15 || number == 16))
    112         letter += tenDigit[tens-1];
    113     if (number == 15 || number == 16) { // special because of religious
    114         letter += QChar(1487 + 9);       // reasons
     92    int fourHundreds = number / 400;
     93    for (int i = 0; i < fourHundreds; i++)
     94        letter += QChar(1511 + 3);
     95    number %= 400;
     96    if (number / 100)
     97        letter += QChar(1511 + (number / 100) - 1);
     98    number %= 100;
     99    if (number == 15 || number == 16) {
     100        letter += QChar(1487 + 9);
    115101        letter += QChar(1487 + number - 9);
    116102    } else {
     103        int tens = number / 10;
     104        if (tens)
     105            letter += tenDigit[tens - 1];
    117106        number = number % 10;
    118         if (number != 0)
    119             letter += QChar (1487 + number);
     107        if (number)
     108            letter += QChar(1487 + number);
    120109    }
    121110    return letter;
     
    128117{
    129118    // init RenderObject attributes
    130     setInline(false);   // our object is not Inline
     119    setInline(false); // our object is not Inline
    131120}
    132121
     
    292281}
    293282
    294 void RenderListItem::layout( )
    295 {
    296     KHTMLAssert( needsLayout() );
    297     KHTMLAssert( minMaxKnown() );
     283void RenderListItem::layout()
     284{
     285    KHTMLAssert(needsLayout());
     286    KHTMLAssert(minMaxKnown());
    298287   
    299288    updateMarkerLocation();   
     
    453442        if (!m_item.isEmpty()) {
    454443            const Font& font = style()->font();
    455             if( style()->direction() == LTR) {
    456                 p->drawText(marker.location(), AlignLeft, m_item);
    457                 p->drawText(marker.location() + IntSize(font.width(m_item), 0), AlignLeft, ". ");
     444            if (style()->direction() == LTR) {
     445                int width = font.width(reinterpret_cast<const UChar*>(m_item.unicode()), m_item.length());
     446                p->drawText(marker.location(), m_item);
     447                p->drawText(marker.location() + IntSize(width, 0), ". ");
    458448            } else {
    459                 p->drawText(marker.location(), AlignLeft, " .");
    460                 p->drawText(marker.location() + IntSize(font.width(" ."), 0), AlignLeft, m_item);
     449                UChar spacePeriod[2] = { '.', ' ' };
     450                int width = font.width(spacePeriod, 2);
     451                p->drawText(marker.location(), " .");
     452                p->drawText(marker.location() + IntSize(width, 0), m_item);
    461453            }
    462454        }
     
    557549    }
    558550
    559     m_width = font.width(m_item) + font.width(". ");
     551    {
     552        int itemWidth = font.width(reinterpret_cast<const UChar*>(m_item.unicode()), m_item.length());
     553        UChar periodSpace[2] = { '.', ' ' };
     554        int periodSpaceWidth = font.width(periodSpace, 2);
     555        m_width = itemWidth + periodSpaceWidth;
     556    }
    560557
    561558end:
     
    679676        case LNONE:
    680677            return IntRect();
    681         default:
    682             if (m_item.isEmpty())
    683                 return IntRect();
    684             return IntRect(m_x, m_y + ascent, font.width(m_item) + font.width(". "), font.height());
    685     }
     678        case ARMENIAN:
     679        case CJK_IDEOGRAPHIC:
     680        case DECIMAL_LEADING_ZERO:
     681        case GEORGIAN:
     682        case HEBREW:
     683        case HIRAGANA:
     684        case HIRAGANA_IROHA:
     685        case KATAKANA:
     686        case KATAKANA_IROHA:
     687        case LDECIMAL:
     688        case LOWER_ALPHA:
     689        case LOWER_GREEK:
     690        case LOWER_LATIN:
     691        case LOWER_ROMAN:
     692        case UPPER_ALPHA:
     693        case UPPER_LATIN:
     694        case UPPER_ROMAN:
     695            break;
     696    }
     697
     698    if (m_item.isEmpty())
     699        return IntRect();
     700
     701    int itemWidth = font.width(reinterpret_cast<const UChar*>(m_item.unicode()), m_item.length());
     702    UChar periodSpace[2] = { '.', ' ' };
     703    int periodSpaceWidth = font.width(periodSpace, 2);
     704    return IntRect(m_x, m_y + ascent, itemWidth + periodSpaceWidth, font.height());
    686705}
    687706
  • trunk/WebCore/rendering/render_style.cpp

    r13981 r14273  
    630630                  FIRST_LETTER_BIT = 0x8, SELECTION_BIT = 0x10, FIRST_LINE_INHERITED_BIT = 0x20 };
    631631
    632 static int pseudoBit(RenderStyle::PseudoId pseudo)
     632static inline int pseudoBit(RenderStyle::PseudoId pseudo)
    633633{
    634634    switch (pseudo) {
     
    652652bool RenderStyle::hasPseudoStyle(PseudoId pseudo) const
    653653{
    654     return (pseudoBit(pseudo) & noninherited_flags._pseudoBits) != 0;
     654    return pseudoBit(pseudo) & noninherited_flags._pseudoBits;
    655655}
    656656
     
    662662RenderStyle* RenderStyle::getPseudoStyle(PseudoId pid)
    663663{
    664     if (!pseudoStyle)
    665         return 0;
    666 
    667     RenderStyle *ps = 0;
    668     if (noninherited_flags._styleType==NOPSEUDO) {
    669         ps = pseudoStyle;
    670         while (ps) {
    671             if (styleType() == pid)
    672                     break;
    673    
    674             ps = ps->pseudoStyle;
    675         }
    676     }
     664    RenderStyle* ps = 0;
     665    if (noninherited_flags._styleType == NOPSEUDO)
     666        for (ps = pseudoStyle; ps; ps = ps->psuedoStyle)
     667            if (ps->styleType() == pid)
     668                break;
    677669    return ps;
    678670}
     
    680672void RenderStyle::addPseudoStyle(RenderStyle* pseudo)
    681673{
    682     if (!pseudo) return;
     674    if (!pseudo)
     675        return;
    683676    pseudo->ref();
    684677    pseudo->pseudoStyle = pseudoStyle;
  • trunk/WebCore/rendering/render_style.h

    r13959 r14273  
    12371237        return collapseWhiteSpace(whiteSpace());
    12381238    }
    1239     bool isCollapsibleWhiteSpace(const QChar& c) const {
    1240         switch (c.unicode()) {
     1239    bool isCollapsibleWhiteSpace(UChar c) const {
     1240        switch (c) {
    12411241            case ' ':
    12421242            case '\t':
  • trunk/WebCore/xml/XSLStyleSheet.cpp

    r13839 r14273  
    120120{
    121121    // Parse in a single chunk into an xmlDocPtr
    122     const QChar BOM(0xFEFF);
     122    const UChar BOM(0xFEFF);
    123123    const unsigned char BOMHighByte = *reinterpret_cast<const unsigned char*>(&BOM);
    124124    setLoaderForLibXMLCallbacks(docLoader());
     
    126126        xmlFreeDoc(m_stylesheetDoc);
    127127    m_stylesheetDocTaken = false;
    128     m_stylesheetDoc = xmlReadMemory(reinterpret_cast<const char *>(string.unicode()), string.length() * sizeof(QChar),
     128    m_stylesheetDoc = xmlReadMemory(reinterpret_cast<const char*>(string.characters()), string.length() * sizeof(UChar),
    129129        m_ownerDocument->URL().ascii(),
    130130        BOMHighByte == 0xFF ? "UTF-16LE" : "UTF-16BE",
  • trunk/WebCore/xml/xmlhttprequest.cpp

    r14212 r14273  
    8686    unsigned length = contentTypeString.length();
    8787    for (unsigned offset = 0; offset < length; offset++) {
    88         QChar c = contentTypeString[offset];
     88        UChar c = contentTypeString[offset];
    8989        if (c == ';')
    9090            break;
    91         else if (c.isSpace()) // FIXME: This seems wrong, " " is an invalid MIME type character according to RFC 2045.  bug 8644
     91        else if (QChar(c).isSpace()) // FIXME: This seems wrong, " " is an invalid MIME type character according to RFC 2045.  bug 8644
    9292            continue;
    93         mimeType += String(c);
     93        // FIXME: This is a very slow way to build a string, given WebCore::String's implementation.
     94        mimeType += String(&c, 1);
    9495    }
    9596    return mimeType;
     
    107108       
    108109        // is what we found a beginning of a word?
    109         if (contentTypeString[pos-1].unicode() > ' ' && contentTypeString[pos-1] != ';') {
     110        if (contentTypeString[pos-1] > ' ' && contentTypeString[pos-1] != ';') {
    110111            pos += 7;
    111112            continue;
     
    115116
    116117        // skip whitespace
    117         while (pos != length && contentTypeString[pos].unicode() <= ' ')
     118        while (pos != length && contentTypeString[pos] <= ' ')
    118119            ++pos;
    119120   
     
    121122            continue;
    122123
    123         while (pos != length && (contentTypeString[pos].unicode() <= ' ' || contentTypeString[pos] == '"' || contentTypeString[pos] == '\''))
     124        while (pos != length && (contentTypeString[pos] <= ' ' || contentTypeString[pos] == '"' || contentTypeString[pos] == '\''))
    124125            ++pos;
    125126
    126127        // we don't handle spaces within quoted parameter values, because charset names cannot have any
    127128        int endpos = pos;
    128         while (pos != length && contentTypeString[endpos].unicode() > ' ' && contentTypeString[endpos] != '"' && contentTypeString[endpos] != '\'' && contentTypeString[endpos] != ';')
     129        while (pos != length && contentTypeString[endpos] > ' ' && contentTypeString[endpos] != '"' && contentTypeString[endpos] != '\'' && contentTypeString[endpos] != ';')
    129130            ++endpos;
    130131   
  • trunk/WebCore/xpath/impl/XPathExpressionNode.cpp

    r14234 r14273  
    2424 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2525 */
     26
    2627#include "config.h"
    2728
    2829#if XPATH_SUPPORT
    2930
     31#include "XPathExpressionNode.h"
     32
    3033#include "Logging.h"
    31 #include "XPathExpressionNode.h"
    3234#include "Node.h"
    33 
    34 #include <cmath>
     35#include "XPathValue.h"
     36#include <math.h>
    3537
    3638using namespace std;
     
    5355{
    5456    deleteAllValues(m_subExpressions);
    55    
    5657    delete m_constantValue;
    5758}
     
    6162    if (m_constantValue)
    6263        return *m_constantValue;
    63 
    6464    return doEvaluate();
    6565}
     
    8989}
    9090
    91 unsigned int Expression::subExprCount() const
     91unsigned Expression::subExprCount() const
    9292{
    9393    return m_subExpressions.size();
     
    9797{
    9898    ASSERT(i < subExprCount());
    99 
    10099    return m_subExpressions[i];
    101100}
     
    104103{
    105104    ASSERT(i < subExprCount());
    106    
    107105    return m_subExpressions[i];
    108106}
     
    110108bool Expression::isConstant() const
    111109{
    112     for (unsigned i = 0; i < m_subExpressions.size(); i++) {
     110    for (unsigned i = 0; i < m_subExpressions.size(); i++)
    113111        if (!m_subExpressions[i]->isConstant())
    114112            return false;
    115     }
    116 
    117113    return true;
    118114}
  • trunk/WebCore/xpath/impl/XPathExpressionNode.h

    r14256 r14273  
    2424 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2525 */
     26
    2627#ifndef XPathExpressionNode_H
    2728#define XPathExpressionNode_H
    2829
    2930#if XPATH_SUPPORT
    30 
    31 #include "XPathValue.h"
    3231
    3332#include "StringHash.h"
     
    3635
    3736namespace WebCore {
     37
     38class Node;
    3839class XPathNSResolver;
    3940
    4041namespace XPath {
     42
     43class Value;
    4144       
    42 struct EvaluationContext
    43 {
     45struct EvaluationContext {
    4446    EvaluationContext() : node(0), size(0), position(0), resolver(0) { }
    4547
     
    5557};
    5658
    57 class ParseNode
    58 {
     59class ParseNode {
     60public:
     61    virtual ~ParseNode() { }
    5962};
    6063
     
    6669    Expression();
    6770    virtual ~Expression();
     71
    6872    virtual Value evaluate() const;
    6973
    70     void addSubExpression(Expression* expr);
     74    void addSubExpression(Expression*);
    7175    void optimize();
    7276    virtual bool isConstant() const;
    7377
    7478protected:
    75     unsigned int subExprCount() const;
     79    unsigned subExprCount() const;
    7680    Expression* subExpr(unsigned i);
    7781    const Expression* subExpr(unsigned i) const;
  • trunk/WebCore/xpath/impl/XPathFunctions.cpp

    r14264 r14273  
    2424 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2525 */
     26
    2627#include "config.h"
    2728
     
    3031#include "XPathFunctions.h"
    3132
     33#include "DeprecatedString.h"
    3234#include "Logging.h"
    3335#include "NamedAttrMap.h"
    3436#include "Node.h"
    35 
     37#include "XPathValue.h"
    3638#include <math.h>
    3739
     
    325327        s += "-Infinity";
    326328    else
    327         s += DeprecatedString::number(m_min);
     329        s += String::number(m_min);
    328330
    329331    s += "..";
     
    332334        s += "Infinity";
    333335    else
    334         s += DeprecatedString::number(m_max);
     336        s += String::number(m_max);
    335337
    336338    s += "]";
     
    374376Value FunLast::doEvaluate() const
    375377{
    376     return double(Expression::evaluationContext().size);
     378    return Expression::evaluationContext().size;
    377379}
    378380
     
    384386Value FunPosition::doEvaluate() const
    385387{
    386     return double(Expression::evaluationContext().position);
     388    return Expression::evaluationContext().position;
    387389}
    388390
     
    468470    }
    469471   
    470     return double(a.toNodeVector().size());
     472    return a.toNodeVector().size();
    471473}
    472474
     
    478480Value FunString::doEvaluate() const
    479481{
    480     if (argCount() == 0) {
    481         String s = Value(Expression::evaluationContext().node).toString();
    482         return s;
    483     }
     482    if (argCount() == 0)
     483        return Value(Expression::evaluationContext().node).toString();
    484484    return arg(0)->evaluate().toString();
    485485}
     
    487487Value FunConcat::doEvaluate() const
    488488{
    489     String str;
    490 
    491     for (unsigned int i = 0; i < argCount(); ++i)
     489    String str = "";
     490
     491    for (unsigned i = 0; i < argCount(); ++i)
    492492        str += arg(i)->evaluate().toString();
    493493
     
    545545        return "";
    546546
    547     return Value(s1.deprecatedString().mid(i + 1));
     547    return s1.substring(i + 1);
    548548}
    549549
     
    567567    }
    568568
    569     return Value(s.deprecatedString().mid(pos - 1, len));
     569    return s.substring(pos - 1, len);
    570570}
    571571
    572572Value FunStringLength::doEvaluate() const
    573573{
    574     if (argCount() == 0) {
    575         String s = Value(Expression::evaluationContext().node).toString();
    576         return double(s.length());
    577     }
    578 
    579     return double(arg(0)->evaluate().toString().length());
     574    if (argCount() == 0)
     575        return Value(Expression::evaluationContext().node).toString().length();
     576    return arg(0)->evaluate().toString().length();
    580577}
    581578
     
    598595    String newString;
    599596
     597    // FIXME: Building a String a character at a time is quite slow.
    600598    for (unsigned i1 = 0; i1 < s1.length(); ++i1) {
    601         QChar ch = s1[i1];
     599        UChar ch = s1[i1];
    602600        int i2 = s2.find(ch);
    603601       
    604         if (i2 == -1)
    605             newString += ch;
    606         else if ((unsigned)i2 < s3.length())
    607             newString += s3[ i2 ];
     602        if (i2 == -1)
     603            newString += String(&ch, 1);
     604        else if ((unsigned)i2 < s3.length()) {
     605            UChar c2 = s3[i2];
     606            newString += String(&c2, 1);
     607        }
    608608    }
    609609
     
    696696   
    697697    for (unsigned i = 0; i < nodes.size(); i++)
    698         sum += Value(stringValue(nodes[i].get()).deprecatedString()).toNumber();
     698        sum += Value(stringValue(nodes[i].get())).toNumber();
    699699   
    700700    return sum;
  • trunk/WebCore/xpath/impl/XPathGrammar.y

    r14234 r14273  
     1/*
     2 * Copyright 2005 Frerich Raabe <raabe@kde.org>
     3 * Copyright (C) 2006 Apple Computer, Inc.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 *
     9 * 1. Redistributions of source code must retain the above copyright
     10 *    notice, this list of conditions and the following disclaimer.
     11 * 2. Redistributions in binary form must reproduce the above copyright
     12 *    notice, this list of conditions and the following disclaimer in the
     13 *    documentation and/or other materials provided with the distribution.
     14 *
     15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     25 */
     26
    127%{
    228#include "config.h"
    329
     30#include "DeprecatedString.h"
     31#include "ExceptionCode.h"
     32#include "XPathEvaluator.h"
     33#include "XPathFunctions.h"
     34#include "XPathNSResolver.h"
    435#include "XPathParser.h"
    5 #include "XPathFunctions.h"
    636#include "XPathPath.h"
     37#include "XPathPredicate.h"
    738#include "XPathStep.h"
    8 #include "XPathPredicate.h"
    939#include "XPathUtil.h"
    1040#include "XPathVariableReference.h"
    11    
    12 #include "XPathNSResolver.h"
    13 #include "XPathEvaluator.h"
    14 #include "ExceptionCode.h"
    1541
    1642#define YYDEBUG 0
  • trunk/WebCore/xpath/impl/XPathParser.cpp

    r14254 r14273  
    2929
    3030#include "XPathParser.h"
     31
     32#include "DeprecatedString.h"
    3133#include "XPathEvaluator.h"
    3234
     
    3638#include "XPathGrammar.h"   
    3739
    38 struct AxisNameMapping
    39 {
     40struct AxisNameMapping {
    4041    const char* name;
    4142    Step::AxisType type;
     
    5859};
    5960
    60 static unsigned int axisNamesCount = sizeof(axisNames) / sizeof(axisNames[0]);
     61static unsigned axisNamesCount = sizeof(axisNames) / sizeof(axisNames[0]);
    6162static const char* const nodeTypeNames[] = {
    6263    "comment",
     
    7273Parser* Parser::currentParser = 0;
    7374
    74 Parser::XMLCat Parser::charCat(QChar aChar)
     75Parser::XMLCat Parser::charCat(UChar aChar)
    7576{
    7677    //### might need to add some special cases from the XML spec.
    7778
    78     if (aChar.unicode() == '_')
     79    if (aChar == '_')
    7980        return NameStart;
    8081
    81     if (aChar.unicode() == '.' || aChar.unicode() == '-')
     82    if (aChar == '.' || aChar == '-')
    8283        return NameCont;
    83     switch (u_charType(aChar.unicode())) {
     84    switch (u_charType(aChar)) {
    8485        case U_LOWERCASE_LETTER: //Ll
    8586        case U_UPPERCASE_LETTER: //Lu
     
    99100}
    100101
    101 bool Parser::isAxisName(String name, Step::AxisType& type)
     102bool Parser::isAxisName(const String& name, Step::AxisType& type)
    102103{
    103104    if (!s_axisNamesDict) {
    104105        s_axisNamesDict = new HashMap<String, Step::AxisType>;
    105         for (unsigned int p = 0; p < axisNamesCount; ++p)
    106             s_axisNamesDict->set(axisNames[p].name,
    107                                  axisNames[p].type);
     106        for (unsigned p = 0; p < axisNamesCount; ++p)
     107            s_axisNamesDict->set(axisNames[p].name, axisNames[p].type);
    108108    }
    109109
    110110    HashMap<String, Step::AxisType>::iterator it = s_axisNamesDict->find(name);
    111    
    112     if (it != s_axisNamesDict->end()) {
    113         type = it->second;
    114         return true;
    115     } else   
     111
     112    if (it == s_axisNamesDict->end())
    116113        return false;
    117 }
    118 
    119 bool Parser::isNodeTypeName(String name)
     114    type = it->second;
     115    return true;
     116}
     117
     118bool Parser::isNodeTypeName(const String& name)
    120119{
    121120    if (!s_nodeTypeNamesDict) {
     
    149148void Parser::skipWS()
    150149{
    151     while (m_nextPos < m_data.length() && m_data[m_nextPos].isSpace())
     150    while (m_nextPos < m_data.length() && QChar(m_data[m_nextPos]).isSpace())
    152151        ++m_nextPos;
    153152}
     
    165164}
    166165
    167 //Returns next char if it's there and interesting, 0 otherwise
     166// Returns next char if it's there and interesting, 0 otherwise
    168167char Parser::peekAheadHelper()
    169168{
    170169    if (m_nextPos + 1 >= m_data.length())
    171170        return 0;
    172     QChar next = m_data[m_nextPos + 1];
    173     if (next.unicode() >= 0xff)
     171    UChar next = m_data[m_nextPos + 1];
     172    if (next >= 0xff)
    174173        return 0;
    175 
    176     return next.unicode();
     174    return next;
    177175}
    178176
     
    181179    if (m_nextPos >= m_data.length())
    182180        return 0;
    183     QChar next = m_data[m_nextPos];
    184     if (next.unicode() >= 0xff)
     181    UChar next = m_data[m_nextPos];
     182    if (next >= 0xff)
    185183        return 0;
    186 
    187     return next.unicode();
     184    return next;
    188185}
    189186
    190187Token Parser::lexString()
    191188{
    192     QChar delimiter = m_data[m_nextPos];
     189    UChar delimiter = m_data[m_nextPos];
    193190    int   startPos  = m_nextPos + 1;
    194191
     
    215212    //Go until end or a non-digits character
    216213    for (; m_nextPos < m_data.length(); ++m_nextPos) {
    217         QChar aChar = m_data[m_nextPos];
    218         if (aChar.unicode() >= 0xff) break;
    219 
    220         if (aChar.unicode() < '0' || aChar.unicode() > '9') {
    221             if (aChar.unicode() == '.' && !seenDot)
     214        UChar aChar = m_data[m_nextPos];
     215        if (aChar >= 0xff) break;
     216
     217        if (aChar < '0' || aChar > '9') {
     218            if (aChar == '.' && !seenDot)
    222219                seenDot = true;
    223220            else
     
    337334
    338335    skipWS();
    339     //If we're in an operator context, check for any operator names
     336    // If we're in an operator context, check for any operator names
    340337    if (isOperatorContext()) {
    341338        if (t1.value == "and") //### hash?
     
    349346    }
    350347
    351     //See whether we are at a :
     348    // See whether we are at a :
    352349    if (peekCurHelper() == ':') {
    353350        m_nextPos++;
    354         //Any chance it's an axis name?
     351        // Any chance it's an axis name?
    355352        if (peekCurHelper() == ':') {
    356353            m_nextPos++;
     
    360357            if (isAxisName(t1.value, axisType))
    361358                return Token(AXISNAME, axisType);
    362             //Ugh, :: is only valid in axis names -> error
     359            // Ugh, :: is only valid in axis names -> error
    363360            return Token(ERROR);
    364361        }
    365362
    366         //Seems like this is a fully qualified qname, or perhaps the * modified one from NameTest
     363        // Seems like this is a fully qualified qname, or perhaps the * modified one from NameTest
    367364        skipWS();
    368365        if (peekCurHelper() == '*') {
     
    371368        }
    372369       
    373         //Make a full qname..
     370        // Make a full qname..
    374371        Token t2 = lexNCName();
    375         if (t2.type == ERROR) return t2;
    376        
    377         t1.value = t1.value + ':' + t2.value;
     372        if (t2.type == ERROR)
     373            return t2;
     374       
     375        t1.value = t1.value + ":" + t2.value;
    378376    }
    379377
     
    433431}
    434432
    435 Expression* Parser::parseStatement(const String& statement, ExceptionCode& code)
     433Expression* Parser::parseStatement(const String& statement, ExceptionCode& ec)
    436434{
    437435    reset(statement);
     
    449447       
    450448        if (m_gotNamespaceError)
    451             code = NAMESPACE_ERR;
     449            ec = NAMESPACE_ERR;
    452450        else
    453             code = INVALID_EXPRESSION_ERR;
     451            ec = INVALID_EXPRESSION_ERR;
    454452        return 0;
    455453    } else {
     
    550548
    551549#endif // XPATH_SUPPORT
    552 
  • trunk/WebCore/xpath/impl/XPathParser.h

    r14256 r14273  
    2424 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2525 */
     26
    2627#ifndef XPathParser_H
    2728#define XPathParser_H
     
    4344namespace XPath {
    4445
    45 struct Token
    46 {
     46struct Token {
    4747    int     type;
    4848    String value;
     
    5050   
    5151    Token(int t): type(t), intValue(0) {}
    52     Token(int t, String v): type(t), value(v) {}
     52    Token(int t, const String& v): type(t), value(v) {}
    5353    Token(int t, int v): type(t), intValue(v) {}
    5454};
     
    7272    };
    7373   
    74     XMLCat charCat(QChar aChar);
     74    XMLCat charCat(UChar);
    7575   
    76     bool isAxisName(String name, Step::AxisType &type);
    77     bool isNodeTypeName(String name);
     76    bool isAxisName(const String& name, Step::AxisType &type);
     77    bool isNodeTypeName(const String& name);
    7878    bool isOperatorContext();
    7979   
     
    9898    HashSet<Vector<Expression*>*> m_expressionVectors;
    9999    HashSet<String*> m_strings;
     100
    100101public:
    101102    Parser();
  • trunk/WebCore/xpath/impl/XPathPath.cpp

    r14234 r14273  
    2424 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2525 */
     26
    2627#include "config.h"
    2728
    2829#if XPATH_SUPPORT
    2930
    30 #include "Logging.h"
    31 
    3231#include "XPathPath.h"
    3332
    3433#include "Document.h"
     34#include "Logging.h"
    3535#include "Node.h"
     36#include "XPathValue.h"
    3637
    3738namespace WebCore {
     
    3940       
    4041Filter::Filter(Expression* expr, const Vector<Predicate*>& predicates)
    41     : m_expr(expr),
    42     m_predicates(predicates)
     42    : m_expr(expr), m_predicates(predicates)
    4343{
    4444}
  • trunk/WebCore/xpath/impl/XPathPredicate.cpp

    r14264 r14273  
    2424 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2525 */
     26
    2627#include "config.h"
    2728
     
    2930
    3031#include "XPathPredicate.h"
     32
     33#include "Logging.h"
     34#include "Node.h"
    3135#include "XPathFunctions.h"
    32 #include "Logging.h"
    33 
    34 #include "Node.h"
    35 
     36#include "XPathValue.h"
    3637#include <math.h>
    3738
  • trunk/WebCore/xpath/impl/XPathValue.cpp

    r14264 r14273  
    2424 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2525 */
     26
    2627#include "config.h"
    2728
     
    2930
    3031#include "XPathValue.h"
     32
     33#include "DeprecatedString.h"
    3134#include "Logging.h"
    3235
     
    4245
    4346Value::Value()
     47    : m_type(Boolean), m_bool(false)
    4448{
    4549}
     
    4852    : m_type(NodeVector_)
    4953{
    50     m_nodevector.append(value);
     54    m_nodeVector.append(value);
    5155}
    5256
    5357Value::Value(const NodeVector& value)
    54     : m_type(NodeVector_)
    55     , m_nodevector(value)
     58    : m_type(NodeVector_), m_nodeVector(value)
    5659{
    5760}
    5861
    5962Value::Value(bool value)
    60     : m_type(Boolean),
    61     m_bool(value)
     63    : m_type(Boolean), m_bool(value)
     64{
     65}
     66
     67Value::Value(unsigned value)
     68    : m_type(Number), m_number(value)
     69{
     70}
     71
     72Value::Value(unsigned long value)
     73    : m_type(Number), m_number(value)
    6274{
    6375}
    6476
    6577Value::Value(double value)
    66     : m_type(Number),
    67     m_number(value)
     78    : m_type(Number), m_number(value)
    6879{
    6980}
    7081
    7182Value::Value(const String& value)
    72     : m_type(String_),
    73     m_string(value)
     83    : m_type(String_), m_string(value)
    7484{
    75 }
    76 
    77 Value::Type Value::type() const
    78 {
    79     return m_type;
    80 }
    81 
    82 bool Value::isNodeVector() const
    83 {
    84     return m_type == NodeVector_;
    85 }
    86 
    87 bool Value::isBoolean() const
    88 {
    89     return m_type == Boolean;
    90 }
    91 
    92 bool Value::isNumber() const
    93 {
    94     return m_type == Number;
    95 }
    96 
    97 bool Value::isString() const
    98 {
    99     return m_type == String_;
    100 }
    101 
    102 NodeVector& Value::toNodeVector()
    103 {
    104     if (m_type != NodeVector_) {
    105         LOG(XPath, "Cannot convert anything to a nodevector.");
    106     }
    107     return m_nodevector;
    10885}
    10986
    11087const NodeVector &Value::toNodeVector() const
    11188{
    112     if (m_type != NodeVector_) {
    113         LOG(XPath, "Cannot convert anything to a nodevector.");
    114     }
    115    
    116     return m_nodevector;   
     89    if (m_type != NodeVector_)
     90        LOG(XPath, "Cannot convert anything to a nodevector.");   
     91    return m_nodeVector;   
    11792}   
    11893
     
    12196    switch (m_type) {
    12297        case NodeVector_:
    123             return !m_nodevector.isEmpty();
     98            return !m_nodeVector.isEmpty();
    12499        case Boolean:
    125100            return m_bool;
     
    141116        case String_: {
    142117            bool canConvert;
    143             DeprecatedString s = m_string.deprecatedString().simplifyWhiteSpace();
    144            
    145             double value = s.toDouble(&canConvert);
     118            double value = m_string.deprecatedString().simplifyWhiteSpace().toDouble(&canConvert);
    146119            if (canConvert)
    147120                return value;
    148 
    149121            return NAN;
    150122        }
     
    159131    switch (m_type) {
    160132        case NodeVector_:
    161             if (m_nodevector.isEmpty())
     133            if (m_nodeVector.isEmpty())
    162134                return "";
    163 
    164             return stringValue(m_nodevector[0].get());
     135            return stringValue(m_nodeVector[0].get());
    165136        case String_:
    166137            return m_string;
     
    168139            if (isnan(m_number))
    169140                return "NaN";
    170             else if (m_number == 0)
     141            if (m_number == 0)
    171142                return "0";
    172             else if (isinf(m_number)) {
    173                 if (signbit(m_number) == 0)
    174                     return "Infinity";
    175                 else
    176                     return "-Infinity";
    177             }
    178             return DeprecatedString::number(m_number);
     143            if (isinf(m_number))
     144                return signbit(m_number) ? "-Infinity" : "Infinity";
     145            return String::number(m_number);
    179146        case Boolean:
    180147            return m_bool ? "true" : "false";
    181148    }
    182    
    183149    return String();
    184150}
    185 
    186151
    187152}
  • trunk/WebCore/xpath/impl/XPathValue.h

    r14234 r14273  
    3434namespace XPath {
    3535   
    36 class Value
    37 {
     36class Value {
    3837public:
    39     enum Type {
    40         NodeVector_, Boolean, Number, String_
    41     };
     38    enum Type { NodeVector_, Boolean, Number, String_ };
    4239   
    4340    Value();
    44     Value(Node* value);
    45     Value(const NodeVector& value);
    46     Value(bool value);
    47     Value(double value);
    48     Value(const String& value);
     41    Value(Node*);
     42    Value(const NodeVector&);
     43    Value(bool);
     44    Value(unsigned);
     45    Value(unsigned long);
     46    Value(double);
     47    Value(const String&);
    4948   
    50     Type type() const;
    51     bool isNodeVector() const;
    52     bool isBoolean() const;
    53     bool isNumber() const;
    54     bool isString() const;
    55    
    56     NodeVector& toNodeVector();
    57     const NodeVector& toNodeVector() const;
    58    
     49    Type type() const { return m_type; }
     50
     51    bool isNodeVector() const { return m_type == NodeVector_; }
     52    bool isBoolean() const { return m_type == Boolean; }
     53    bool isNumber() const { return m_type == Number; }
     54    bool isString() const { return m_type == String_; }
     55
     56    const NodeVector& toNodeVector() const;   
    5957    bool toBoolean() const;
    6058    double toNumber() const;
     
    6361private:
    6462    Type m_type;
    65     NodeVector m_nodevector;
     63    NodeVector m_nodeVector;
    6664    bool m_bool;
    6765    double m_number;
  • trunk/WebCore/xpath/impl/XPathVariableReference.cpp

    r14234 r14273  
    2424 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2525 */
     26
    2627#include "config.h"
    2728
     
    3132
    3233#include "PlatformString.h"
     34#include "XPathValue.h"
    3335
    3436namespace WebCore {
Note: See TracChangeset for help on using the changeset viewer.