Changeset 14273 in webkit
- Timestamp:
- May 9, 2006 9:59:57 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 104 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r14270 r14273 1 2006-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 1 9 2006-05-09 Levi Weintraub <lweintraub@apple.com> 2 10 -
trunk/WebCore/ChangeLog
r14271 r14273 1 2006-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 1 437 2006-05-09 Tim Omernick <timo@apple.com> 2 438 … … 655 1091 * css/quirks.css: 656 1092 657 2006-05-0 6Darin Adler <darin@apple.com>1093 2006-05-07 Darin Adler <darin@apple.com> 658 1094 659 1095 Suggested by Mitz. Reviewed and landed by Maciej. -
trunk/WebCore/bindings/js/JSXMLSerializer.cpp
r13992 r14273 23 23 #include "JSXMLSerializer.lut.h" 24 24 25 #include "DeprecatedString.h" 25 26 #include "PlatformString.h" 26 27 #include "kjs_dom.h" -
trunk/WebCore/bindings/js/kjs_css.cpp
r14094 r14273 49 49 int i = prop.length(); 50 50 while (--i) { 51 char c = prop[i].latin1();51 ::UChar c = prop[i].unicode(); 52 52 if (c >= 'A' && c <= 'Z') 53 53 prop.insert(i, '-'); -
trunk/WebCore/bindings/js/kjs_navigator.cpp
r13821 r14273 159 159 return jsString("Mozilla"); 160 160 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"); 167 162 case AppVersion: 168 163 // We assume the string is something like Mozilla/version (properties) 169 164 return jsString(userAgent.substring(userAgent.find('/') + 1)); 170 165 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"); 176 167 case ProductSub: 177 168 return jsString("20030107"); … … 185 176 return jsString(userAgent); 186 177 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 193 185 case _Plugins: 194 186 return new Plugins(exec); -
trunk/WebCore/bindings/js/kjs_proxy.cpp
r13865 r14273 35 35 namespace WebCore { 36 36 37 KJSProxy::KJSProxy(Frame *frame)37 KJSProxy::KJSProxy(Frame* frame) 38 38 { 39 39 m_script = 0; … … 49 49 } 50 50 51 JSValue* KJSProxy::evaluate(const String& filename, int baseLine, const String& str, Node *n)51 JSValue* KJSProxy::evaluate(const String& filename, int baseLine, const String& str, Node* n) 52 52 { 53 53 // evaluate code. Returns the JS return value or 0 … … 66 66 67 67 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); 69 69 70 70 if (comp.complType() == Normal || comp.complType() == ReturnValue) … … 92 92 } 93 93 94 EventListener* KJSProxy::createHTMLEventHandler(const String& functionName, const String& code, Node *node)94 EventListener* KJSProxy::createHTMLEventHandler(const String& functionName, const String& code, Node* node) 95 95 { 96 96 initScriptIfNeeded(); … … 100 100 101 101 #if SVG_SUPPORT 102 EventListener* KJSProxy::createSVGEventHandler(const String& functionName, const String& code, Node *node)102 EventListener* KJSProxy::createSVGEventHandler(const String& functionName, const String& code, Node* node) 103 103 { 104 104 initScriptIfNeeded(); … … 108 108 #endif 109 109 110 void KJSProxy::finishedWithEvent(Event *event)110 void KJSProxy::finishedWithEvent(Event* event) 111 111 { 112 112 // This is called when the DOM implementation has finished with a particular event. This … … 117 117 } 118 118 119 ScriptInterpreter *KJSProxy::interpreter()119 ScriptInterpreter* KJSProxy::interpreter() 120 120 { 121 121 initScriptIfNeeded(); … … 128 128 public: 129 129 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); 131 131 }; 132 132 133 JSValue *TestFunctionImp::callAsFunction(ExecState *exec, JSObject */*thisObj*/, const List &args)133 JSValue *TestFunctionImp::callAsFunction(ExecState* exec, JSObject*, const List& args) 134 134 { 135 fprintf(stderr,"--> %s\n", args[0]->toString(exec).ascii());135 fprintf(stderr,"--> %s\n", args[0]->toString(exec).ascii()); 136 136 return jsUndefined(); 137 137 } -
trunk/WebCore/bindings/js/kjs_window.cpp
r14094 r14273 1379 1379 1380 1380 // Though isspace() considers \t and \v to be whitespace, Win IE doesn't. 1381 static bool isSeparator( QChar c)1381 static bool isSeparator(UChar c) 1382 1382 { 1383 1383 return c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '=' || c == ',' || c == '\0'; -
trunk/WebCore/bindings/objc/DOMInternal.mm
r13821 r14273 101 101 StringImpl::operator NSString *() const 102 102 { 103 return [NSString stringWithCharacters: reinterpret_cast<const unichar *>(m_data)length:m_length];103 return [NSString stringWithCharacters:m_data length:m_length]; 104 104 } 105 105 106 String::String(NSString *str)106 String::String(NSString* str) 107 107 { 108 108 if (!str) … … 113 113 m_impl = StringImpl::empty(); 114 114 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); 125 118 } 126 119 } -
trunk/WebCore/bridge/mac/FrameMac.mm
r14185 r14273 79 79 80 80 using namespace std; 81 82 using namespace KJS; 83 using namespace Bindings; 84 81 using namespace KJS::Bindings; 85 82 using namespace KIO; 83 84 using KJS::JSLock; 85 using KJS::PausedTimeouts; 86 using KJS::SavedBuiltins; 87 using KJS::SavedProperties; 86 88 87 89 namespace WebCore { … … 90 92 using namespace HTMLNames; 91 93 92 NSEvent *FrameMac::_currentEvent = nil;94 NSEvent* FrameMac::_currentEvent = nil; 93 95 94 96 static NSMutableDictionary* createNSDictionary(const HashMap<String, String>& map) … … 115 117 116 118 SEL selector = NULL; 117 switch (key[0U] .unicode()) {119 switch (key[0U]) { 118 120 case NSUpArrowFunctionKey: 119 121 selector = @selector(moveUp:); break; … … 633 635 { 634 636 String text = title; 635 text.replace( QChar('\\'), backslashAsCurrencySymbol());637 text.replace('\\', backslashAsCurrencySymbol()); 636 638 637 639 BEGIN_BLOCK_OBJC_EXCEPTIONS; … … 643 645 { 644 646 String text = status; 645 text.replace( QChar('\\'), backslashAsCurrencySymbol());647 text.replace('\\', backslashAsCurrencySymbol()); 646 648 647 649 BEGIN_BLOCK_OBJC_EXCEPTIONS; … … 731 733 while (1) { 732 734 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(); 734 736 int len = it.length(); 735 if (len > 1 || ! chars[0].isSpace()) {736 NSString *chunk = [[NSString alloc] initWithCharactersNoCopy: (unichar *)charslength: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]; 737 739 NSRange misspelling = [checker checkSpellingOfString:chunk startingAt:0 language:nil wrap:NO inSpellDocumentWithTag:[_bridge spellCheckerDocumentTag] wordCount:NULL]; 738 740 [chunk release]; … … 1227 1229 { 1228 1230 String text = message; 1229 text.replace( QChar('\\'), backslashAsCurrencySymbol());1231 text.replace('\\', backslashAsCurrencySymbol()); 1230 1232 BEGIN_BLOCK_OBJC_EXCEPTIONS; 1231 1233 [_bridge runJavaScriptAlertPanelWithMessage:text]; … … 1236 1238 { 1237 1239 String text = message; 1238 text.replace( QChar('\\'), backslashAsCurrencySymbol());1240 text.replace('\\', backslashAsCurrencySymbol()); 1239 1241 1240 1242 BEGIN_BLOCK_OBJC_EXCEPTIONS; … … 1248 1250 { 1249 1251 String promptText = prompt; 1250 promptText.replace( QChar('\\'), backslashAsCurrencySymbol());1252 promptText.replace('\\', backslashAsCurrencySymbol()); 1251 1253 String defaultValueText = defaultValue; 1252 defaultValueText.replace( QChar('\\'), backslashAsCurrencySymbol());1254 defaultValueText.replace('\\', backslashAsCurrencySymbol()); 1253 1255 1254 1256 bool ok; … … 1261 1263 if (ok) { 1262 1264 result = String(returnedText); 1263 result.replace(backslashAsCurrencySymbol(), QChar('\\'));1265 result.replace(backslashAsCurrencySymbol(), '\\'); 1264 1266 } 1265 1267 … … 2284 2286 [pendingStyledSpace release]; 2285 2287 pendingStyledSpace = nil; 2286 addedSpace = str[runEnd-1].direction() == QChar::DirWS;2288 addedSpace = u_charDirection(str[runEnd - 1].unicode()) == U_WHITE_SPACE_NEUTRAL; 2287 2289 } 2288 2290 else { … … 2319 2321 [pendingStyledSpace release]; 2320 2322 pendingStyledSpace = nil; 2321 addedSpace = str[runEnd-1].direction() == QChar::DirWS;2323 addedSpace = u_charDirection(str[runEnd - 1].unicode()) == U_WHITE_SPACE_NEUTRAL; 2322 2324 start = -1; 2323 2325 } … … 2329 2331 } 2330 2332 2331 text.replace( QChar('\\'), renderer->backslashAsCurrencySymbol());2333 text.replace('\\', renderer->backslashAsCurrencySymbol()); 2332 2334 2333 2335 if (text.length() > 0 || needSpace) { … … 3106 3108 3107 3109 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(); 3109 3111 int len = it.length(); 3110 if (len > 1 || ! chars[0].isSpace()) {3111 NSString *chunk = [[NSString alloc] initWithCharactersNoCopy: (unichar *)charslength: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]; 3112 3114 int startIndex = 0; 3113 3115 // Loop over the chunk to find each misspelling in it. … … 3403 3405 3404 3406 String text = event->result(); 3405 text.replace( QChar('\\'), backslashAsCurrencySymbol());3407 text.replace('\\', backslashAsCurrencySymbol()); 3406 3408 3407 3409 return [_bridge runBeforeUnloadConfirmPanelWithMessage:text]; -
trunk/WebCore/bridge/mac/WebCoreFrameBridge.mm
r14258 r14273 752 752 { 753 753 String text = m_frame->selectedText(); 754 text.replace( QChar('\\'), m_frame->backslashAsCurrencySymbol());754 text.replace('\\', m_frame->backslashAsCurrencySymbol()); 755 755 return [[(NSString*)text copy] autorelease]; 756 756 } … … 759 759 { 760 760 String text = plainText([range _range]); 761 text.replace( QChar('\\'), m_frame->backslashAsCurrencySymbol());761 text.replace('\\', m_frame->backslashAsCurrencySymbol()); 762 762 return [[(NSString*)text copy] autorelease]; 763 763 } -
trunk/WebCore/css/CSSGrammar.y
r13874 r14273 56 56 namespace WebCore { 57 57 58 int getPropertyID(const char *tagStr, int len)58 int getPropertyID(const char* tagStr, int len) 59 59 { 60 60 DeprecatedString prop; … … 79 79 } 80 80 } 81 82 const struct props *propsPtr = findProp(tagStr, len);81 82 const struct props* propsPtr = findProp(tagStr, len); 83 83 if (!propsPtr) 84 84 return 0; … … 89 89 } 90 90 91 static inline int getValueID(const char *tagStr, int len)91 static inline int getValueID(const char* tagStr, int len) 92 92 { 93 93 DeprecatedString prop; … … 370 370 371 371 maybe_ns_prefix: 372 /* empty */ { $$. string= 0; }372 /* empty */ { $$.characters = 0; } 373 373 | IDENT WHITESPACE { $$ = $1; } 374 374 ; … … 390 390 medium { 391 391 $$ = static_cast<CSSParser*>(parser)->createMediaList(); 392 $$->appendMedium( domString($1).lower());392 $$->appendMedium(domString($1).lower()); 393 393 } 394 394 | media_list ',' maybe_space medium { 395 395 $$ = $1; 396 396 if ($$) 397 $$->appendMedium( domString($4));397 $$->appendMedium(domString($4).lower()); 398 398 } 399 399 | media_list error { … … 530 530 531 531 namespace_selector: 532 /* empty */ '|' { $$. string= 0; $$.length = 0; }533 | '*' '|' { static unsigned short star = '*'; $$.string= ☆ $$.length = 1; }532 /* empty */ '|' { $$.characters = 0; $$.length = 0; } 533 | '*' '|' { static UChar star = '*'; $$.characters = ☆ $$.length = 1; } 534 534 | IDENT '|' { $$ = $1; } 535 535 ; … … 601 601 } 602 602 | '*' { 603 static unsigned shortstar = '*';604 $$. string= ☆603 static UChar star = '*'; 604 $$.characters = ☆ 605 605 $$.length = 1; 606 606 } … … 842 842 property: 843 843 IDENT maybe_space { 844 $1.lower(); 844 845 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); 846 849 #if SVG_SUPPORT 847 if ($$ == 0)848 $$ = SVG::getSVGCSSPropertyID(str.lower().latin1(), str.length());850 if ($$ == 0) 851 $$ = SVG::getSVGCSSPropertyID(s, l); 849 852 #endif 850 853 } -
trunk/WebCore/css/css_valueimpl.cpp
r14008 r14273 47 47 48 48 // 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)49 int getPropertyID(const char* str, int len); 50 51 static int propertyID(const String& s) 52 52 { 53 53 char buffer[maxCSSPropertyNameLength]; … … 58 58 59 59 for (unsigned i = 0; i != len; ++i) { 60 unsigned short c = s[i].unicode();60 UChar c = s[i]; 61 61 if (c == 0 || c >= 0x7F) 62 62 return 0; // illegal character … … 86 86 s.replace('\\', "\\\\"); 87 87 s.replace('\'', "\\'"); 88 return '\'' + s + '\'';88 return "'" + s + "'"; 89 89 } 90 90 -
trunk/WebCore/css/css_valueimpl.h
r14256 r14273 27 27 #include "css_base.h" 28 28 #include "DeprecatedPtrList.h" 29 #include "DeprecatedString.h" 29 30 #include "DeprecatedValueList.h" 30 31 #include <wtf/PassRefPtr.h> -
trunk/WebCore/css/csshelper.cpp
r14256 r14273 39 39 int l = i->length(); 40 40 41 while (o < l && (*i)[o] .unicode()<= ' ') {41 while (o < l && (*i)[o] <= ' ') { 42 42 ++o; 43 43 --l; 44 44 } 45 while (l > 0 && (*i)[o+l-1] .unicode()<= ' ')45 while (l > 0 && (*i)[o+l-1] <= ' ') 46 46 --l; 47 47 48 48 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') 52 52 && (*i)[o + 3] == '(' 53 53 && (*i)[o + l - 1] == ')') { … … 56 56 } 57 57 58 while (o < l && (*i)[o] .unicode()<= ' ') {58 while (o < l && (*i)[o] <= ' ') { 59 59 ++o; 60 60 --l; 61 61 } 62 while (l > 0 && (*i)[o+l-1] .unicode()<= ' ')62 while (l > 0 && (*i)[o+l-1] <= ' ') 63 63 --l; 64 64 … … 68 68 } 69 69 70 while (o < l && (*i)[o] .unicode()<= ' ') {70 while (o < l && (*i)[o] <= ' ') { 71 71 ++o; 72 72 --l; 73 73 } 74 while (l > 0 && (*i)[o+l-1] .unicode()<= ' ')74 while (l > 0 && (*i)[o+l-1] <= ' ') 75 75 --l; 76 76 77 Vector< unsigned short, 2048> buffer(l);77 Vector<UChar, 2048> buffer(l); 78 78 79 79 int nl = 0; 80 80 for (int k = o; k < o + l; k++) { 81 unsigned short c = (*i)[k].unicode();81 UChar c = (*i)[k]; 82 82 if (c > '\r') 83 83 buffer[nl++] = c; 84 84 } 85 85 86 return new StringImpl( reinterpret_cast<QChar*>(buffer.data()), nl);86 return new StringImpl(buffer.data(), nl); 87 87 } 88 88 -
trunk/WebCore/css/cssparser.cpp
r14008 r14273 117 117 void ParseString::lower() 118 118 { 119 // Fast case for all-ASCII. 120 UChar ored = 0; 119 121 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]); 121 129 } 122 130 … … 125 133 int length = string.length() + strlen(prefix) + strlen(suffix) + 2; 126 134 127 data = (unsigned short*)fastMalloc(length * sizeof(unsigned short));135 data = static_cast<UChar*>(fastMalloc(length * sizeof(UChar))); 128 136 for (unsigned i = 0; i < strlen(prefix); i++) 129 137 data[i] = prefix[i]; 130 138 131 memcpy(data + strlen(prefix), string. unicode(), string.length() * sizeof(unsigned short));139 memcpy(data + strlen(prefix), string.characters(), string.length() * sizeof(UChar)); 132 140 133 141 unsigned start = strlen(prefix) + string.length(); … … 2571 2579 #include "CSSGrammar.h" 2572 2580 2573 int CSSParser::lex(void *_yylval) { 2574 YYSTYPE *yylval = (YYSTYPE *)_yylval; 2581 int CSSParser::lex(void* yylvalWithoutType) 2582 { 2583 YYSTYPE* yylval = static_cast<YYSTYPE*>(yylvalWithoutType); 2575 2584 int token = lex(); 2576 2585 int length; 2577 unsigned short *t = text(&length);2586 UChar* t = text(&length); 2578 2587 2579 2588 #ifdef TOKEN_DEBUG … … 2594 2603 case UNICODERANGE: 2595 2604 case FUNCTION: 2596 yylval->string. string= t;2605 yylval->string.characters = t; 2597 2606 yylval->string.length = length; 2598 2607 break; … … 2652 2661 } 2653 2662 2654 unsigned short *CSSParser::text(int *length)2655 { 2656 unsigned short *start = yytext;2663 UChar* CSSParser::text(int *length) 2664 { 2665 UChar* start = yytext; 2657 2666 int l = yyleng; 2658 2667 switch(yyTok) { … … 2693 2702 2694 2703 // process escapes 2695 unsigned short *out = start;2696 unsigned short *escape = 0;2704 UChar* out = start; 2705 UChar* escape = 0; 2697 2706 2698 2707 for (int i = 0; i < l; i++) { 2699 unsigned short *current = start+i;2708 UChar* current = start + i; 2700 2709 if (escape == current - 1) { 2701 2710 if ((*current >= '0' && *current <= '9') || … … 2728 2737 if (escape) { 2729 2738 // add escaped char 2730 intuc = 0;2739 unsigned uc = 0; 2731 2740 escape++; 2732 2741 while (escape < current) { … … 2738 2747 if (uc > 0xffff) 2739 2748 uc = 0xfffd; 2740 * (out++) = (unsigned short)uc;2749 *out++ = uc; 2741 2750 escape = 0; 2742 2751 if (*current == ' ' || … … 2751 2760 continue; 2752 2761 } 2753 * (out++)= *current;2762 *out++ = *current; 2754 2763 } 2755 2764 if (escape) { 2756 2765 // add escaped char 2757 intuc = 0;2766 unsigned uc = 0; 2758 2767 escape++; 2759 2768 while (escape < start+l) { … … 2765 2774 if (uc > 0xffff) 2766 2775 uc = 0xfffd; 2767 * (out++) = (unsigned short)uc;2776 *out++ = uc; 2768 2777 } 2769 2778 … … 2882 2891 clearProperties(); 2883 2892 return rule; 2893 } 2894 2895 DeprecatedString deprecatedString(const ParseString& ps) 2896 { 2897 return DeprecatedString(reinterpret_cast<const QChar*>(ps.characters), ps.length); 2884 2898 } 2885 2899 -
trunk/WebCore/css/cssparser.h
r14256 r14273 46 46 47 47 struct ParseString { 48 unsigned short* string;48 UChar* characters; 49 49 int length; 50 50 … … 70 70 }; 71 71 72 static inline DeprecatedString deprecatedString(const ParseString& ps) { 73 return DeprecatedString((QChar *)ps.string, ps.length); 74 } 72 DeprecatedString deprecatedString(const ParseString&); 75 73 static inline String domString(const ParseString& ps) { 76 return String( (QChar *)ps.string, ps.length);74 return String(ps.characters, ps.length); 77 75 } 78 76 static inline AtomicString atomicString(const ParseString& ps) { 79 return AtomicString(ps. string, ps.length);77 return AtomicString(ps.characters, ps.length); 80 78 } 81 79 … … 202 200 int lex(void* yylval); 203 201 int token() { return yyTok; } 204 unsigned short* text(int* length);202 UChar* text(int* length); 205 203 int lex(); 206 204 … … 212 210 bool inShorthand() const { return m_inParseShorthand; } 213 211 214 unsigned short* data;215 unsigned short* yytext;216 unsigned short* yy_c_buf_p;217 unsigned shortyy_hold_char;212 UChar* data; 213 UChar* yytext; 214 UChar* yy_c_buf_p; 215 UChar yy_hold_char; 218 216 int yy_last_accepting_state; 219 unsigned short* yy_last_accepting_cpos;217 UChar* yy_last_accepting_cpos; 220 218 int yyleng; 221 219 int yyTok; -
trunk/WebCore/css/cssstyleselector.cpp
r14261 r14273 557 557 } 558 558 559 QConstString cu( attr.unicode(), attr.length());559 QConstString cu(reinterpret_cast<const QChar*>(attr.characters()), attr.length()); 560 560 DeprecatedString u = cu.string(); 561 561 if (!u.contains("://")) { -
trunk/WebCore/dom/CharacterData.cpp
r13973 r14273 45 45 : EventTargetNode(doc) 46 46 { 47 str = _text.impl() ? _text.impl() : new StringImpl( (QChar*)0, 0);47 str = _text.impl() ? _text.impl() : new StringImpl(static_cast<UChar*>(0), 0); 48 48 str->ref(); 49 49 } -
trunk/WebCore/dom/Document.cpp
r14234 r14273 2393 2393 bool Document::isValidName(const String &name) 2394 2394 { 2395 const UChar *s = reinterpret_cast<const UChar *>(name.unicode());2395 const UChar* s = reinterpret_cast<const UChar*>(name.characters()); 2396 2396 unsigned length = name.length(); 2397 2397 … … 2426 2426 int colonPos = 0; 2427 2427 2428 const UChar* s = reinterpret_cast<const UChar*>(qualifiedName. unicode());2428 const UChar* s = reinterpret_cast<const UChar*>(qualifiedName.characters()); 2429 2429 for (unsigned i = 0; i < length;) { 2430 2430 UChar32 c; … … 2490 2490 } 2491 2491 2492 QChar Document::backslashAsCurrencySymbol() const2492 UChar Document::backslashAsCurrencySymbol() const 2493 2493 { 2494 2494 if (!m_decoder) … … 3099 3099 3100 3100 #if XPATH_SUPPORT 3101 3101 3102 PassRefPtr<XPathExpression> Document::createExpression(const String& expression, 3102 3103 XPathNSResolver* resolver, … … 3105 3106 if (!m_xpathEvaluator) 3106 3107 m_xpathEvaluator = new XPathEvaluator; 3107 3108 3108 return m_xpathEvaluator->createExpression(expression, resolver, ec); 3109 3109 } 3110 3110 3111 PassRefPtr<XPathNSResolver> Document::createNSResolver(Node *nodeResolver)3111 PassRefPtr<XPathNSResolver> Document::createNSResolver(Node* nodeResolver) 3112 3112 { 3113 3113 if (!m_xpathEvaluator) 3114 3114 m_xpathEvaluator = new XPathEvaluator; 3115 3116 3115 return m_xpathEvaluator->createNSResolver(nodeResolver); 3117 3116 } … … 3126 3125 if (!m_xpathEvaluator) 3127 3126 m_xpathEvaluator = new XPathEvaluator; 3128 3129 3127 return m_xpathEvaluator->evaluate(expression, contextNode, resolver, type, result, ec); 3130 3128 } -
trunk/WebCore/dom/Document.h
r14256 r14273 706 706 Decoder* decoder() const { return m_decoder.get(); } 707 707 708 QChar backslashAsCurrencySymbol() const;708 UChar backslashAsCurrencySymbol() const; 709 709 710 710 #if __APPLE__ -
trunk/WebCore/dom/NamedMappedAttrMap.cpp
r13547 r14273 77 77 } 78 78 79 inline static bool isClassWhitespace( QChar c)79 inline static bool isClassWhitespace(UChar c) 80 80 { 81 81 return c == ' ' || c == '\r' || c == '\n' || c == '\t'; … … 94 94 AtomicStringList* curr = 0; 95 95 96 const QChar* str = classAttr.unicode();96 const UChar* str = classAttr.characters(); 97 97 int length = classAttr.length(); 98 98 int sPos = 0; -
trunk/WebCore/dom/Position.cpp
r14172 r14273 40 40 41 41 using namespace HTMLNames; 42 43 const UChar nonBreakingSpace = 0xa0; 42 44 43 45 static Node *nextRenderedEditable(Node *node) … … 627 629 if (prev != *this && prev.node()->inSameContainingBlockFlowElement(node()) && prev.node()->isTextNode()) { 628 630 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)) 631 633 return prev; 632 634 } … … 641 643 642 644 if (node()->isTextNode()) { 643 Text *textNode = static_cast<Text*>(node());645 Text* textNode = static_cast<Text*>(node()); 644 646 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)) 648 650 return *this; 649 651 return Position(); … … 656 658 Position next = nextCharacterPosition(affinity); 657 659 if (next != *this && next.node()->inSameContainingBlockFlowElement(node()) && next.node()->isTextNode()) { 658 String string = static_cast<Text 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)) 661 663 return next; 662 664 } -
trunk/WebCore/dom/StyledElement.cpp
r14256 r14273 102 102 } 103 103 104 inline static bool isClassWhitespace( QChar c)104 inline static bool isClassWhitespace(UChar c) 105 105 { 106 106 return c == ' ' || c == '\r' || c == '\n' || c == '\t'; … … 296 296 unsigned int l = 0; 297 297 298 while (l < v->length() && (*v)[l] .unicode()<= ' ')298 while (l < v->length() && (*v)[l] <= ' ') 299 299 l++; 300 300 301 301 for (; l < v->length(); l++) { 302 char cc = (*v)[l].latin1();302 UChar cc = (*v)[l]; 303 303 if (cc > '9' || (cc < '0' && cc != '*' && cc != '%' && cc != '.')) 304 304 break; … … 359 359 int numDigits = 0; 360 360 while (pos < (int)color.length() && numDigits < basicLength) { 361 int hex = toHex(color[pos] .unicode());361 int hex = toHex(color[pos]); 362 362 colors[component] = (colors[component] << 4); 363 363 if (hex > 0) { -
trunk/WebCore/dom/dom2_eventsimpl.cpp
r13821 r14273 514 514 if (text.length() != 1) 515 515 return 0; 516 return text[0] .unicode();516 return text[0]; 517 517 } 518 518 -
trunk/WebCore/dom/xml_tokenizer.h
r14256 r14273 63 63 Tokenizer* newXMLTokenizer(Document*, FrameView* = 0); 64 64 #if KHTML_XSLT 65 void* xmlDocPtrForString(const DeprecatedString& source, const DeprecatedString& URL = DeprecatedString());65 void* xmlDocPtrForString(const DeprecatedString& source, const DeprecatedString& URL); 66 66 void setLoaderForLibXMLCallbacks(DocLoader*); 67 67 #endif -
trunk/WebCore/editing/HTMLInterchange.cpp
r13821 r14273 62 62 while (i < in.length()) { 63 63 consumed = 1; 64 if (isCollapsibleWhitespace(in[i] )) {64 if (isCollapsibleWhitespace(in[i].unicode())) { 65 65 // count number of adjoining spaces 66 66 unsigned int j = i + 1; 67 while (j < in.length() && isCollapsibleWhitespace(in[j] ))67 while (j < in.length() && isCollapsibleWhitespace(in[j].unicode())) 68 68 j++; 69 69 unsigned int count = j - i; -
trunk/WebCore/editing/InsertTextCommand.cpp
r13821 r14273 79 79 80 80 return pos; 81 }82 83 static inline bool isNBSP(const QChar &c)84 {85 return c.unicode() == 0xa0;86 81 } 87 82 -
trunk/WebCore/editing/RebalanceWhitespaceCommand.cpp
r14256 r14273 39 39 } 40 40 41 static inline bool isWhitespace( const QChar &c)41 static inline bool isWhitespace(UChar c) 42 42 { 43 return c .unicode()== 0xa0 || isCollapsibleWhitespace(c);43 return c == 0xa0 || isCollapsibleWhitespace(c); 44 44 } 45 45 -
trunk/WebCore/editing/ReplaceSelectionCommand.cpp
r14212 r14273 620 620 addLeadingSpace = startPos.leadingWhitespacePosition(VP_DEFAULT_AFFINITY, true).isNull() && !isStartOfParagraph(visiblePos); 621 621 if (addLeadingSpace) { 622 QChar previousChar = visiblePos.previous().characterAfter();623 if (previousChar .unicode())622 UChar previousChar = visiblePos.previous().characterAfter(); 623 if (previousChar) 624 624 addLeadingSpace = !frame->isCharacterSmartReplaceExempt(previousChar, true); 625 625 } 626 626 addTrailingSpace = startPos.trailingWhitespacePosition(VP_DEFAULT_AFFINITY, true).isNull() && !isEndOfParagraph(visiblePos); 627 627 if (addTrailingSpace) { 628 QChar thisChar = visiblePos.characterAfter();629 if (thisChar .unicode())628 UChar thisChar = visiblePos.characterAfter(); 629 if (thisChar) 630 630 addTrailingSpace = !frame->isCharacterSmartReplaceExempt(thisChar, false); 631 631 } -
trunk/WebCore/editing/TextIterator.cpp
r14248 r14273 44 44 using namespace HTMLNames; 45 45 46 const unsigned shortnonBreakingSpace = 0xA0;46 const UChar nonBreakingSpace = 0xA0; 47 47 48 48 // Buffer that knows how to compare with a search target. … … 55 55 56 56 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); 59 59 60 60 int neededCharacters() const; … … 66 66 bool m_isCaseSensitive; 67 67 68 QChar *m_buffer;69 QChar *m_cursor;68 UChar* m_buffer; 69 UChar* m_cursor; 70 70 bool m_bufferFull; 71 71 … … 74 74 }; 75 75 76 TextIterator::TextIterator() : m_endContainer(0), m_endOffset(0), m_positionNode(0) 76 TextIterator::TextIterator() : m_endContainer(0), m_endOffset(0), m_positionNode(0), m_lastCharacter(0) 77 77 { 78 78 } … … 230 230 m_positionStartOffset = runStart; 231 231 m_positionEndOffset = runEnd; 232 m_textCharacters = str. unicode() + runStart;232 m_textCharacters = str.characters() + runStart; 233 233 m_textLength = runEnd - runStart; 234 234 … … 272 272 bool needSpace = m_lastTextNodeEndedWithCollapsedSpace 273 273 || (m_textBox == firstTextBox && textBoxStart == runStart && runStart > 0); 274 if (needSpace && !isCollapsibleWhitespace(m_lastCharacter) && m_lastCharacter .unicode()) {274 if (needSpace && !isCollapsibleWhitespace(m_lastCharacter) && m_lastCharacter) { 275 275 emitCharacter(' ', m_node, 0, runStart, runStart); 276 276 return; … … 305 305 m_positionStartOffset = runStart; 306 306 m_positionEndOffset = subrunEnd; 307 m_textCharacters = str. unicode() + runStart;307 m_textCharacters = str.characters() + runStart; 308 308 m_textLength = subrunEnd - runStart; 309 309 … … 506 506 } 507 507 508 void TextIterator::emitCharacter( QChar c, Node *textNode, Node *offsetBaseNode, int textStartOffset, int textEndOffset)508 void TextIterator::emitCharacter(UChar c, Node *textNode, Node *offsetBaseNode, int textStartOffset, int textEndOffset) 509 509 { 510 510 // remember information with which to construct the TextIterator::range() … … 690 690 m_positionStartOffset = m_offset; 691 691 m_textLength = m_positionEndOffset - m_positionStartOffset; 692 m_textCharacters = str. unicode() + m_positionStartOffset;692 m_textCharacters = str.characters() + m_positionStartOffset; 693 693 694 694 m_lastCharacter = str[m_positionEndOffset - 1]; … … 735 735 } 736 736 737 void SimplifiedBackwardsTextIterator::emitCharacter( QChar c, Node *node, int startOffset, int endOffset)737 void SimplifiedBackwardsTextIterator::emitCharacter(UChar c, Node *node, int startOffset, int endOffset) 738 738 { 739 739 m_singleCharacterBuffer = c; … … 844 844 while (numChars > 0 && !atEnd()) { 845 845 int runSize = min(numChars, length()); 846 result.append( characters(), runSize);846 result.append(reinterpret_cast<const QChar*>(characters()), runSize); 847 847 numChars -= runSize; 848 848 advance(runSize); … … 895 895 while (1) { 896 896 // 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()) 898 898 return; 899 899 … … 906 906 // Look ahead to next chunk. If it is whitespace or a break, we can use the previous stuff 907 907 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()) { 909 909 m_didLookAhead = true; 910 910 return; … … 913 913 if (m_buffer.isEmpty()) { 914 914 // 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); 916 916 m_previousText = 0; 917 917 } 918 m_buffer.append( m_textIterator.characters(), m_textIterator.length());918 m_buffer.append(reinterpret_cast<const QChar*>(m_textIterator.characters()), m_textIterator.length()); 919 919 int exception = 0; 920 920 m_range->setEnd(m_textIterator.range()->endContainer(exception), m_textIterator.range()->endOffset(exception), exception); … … 926 926 if (!m_buffer.isEmpty()) 927 927 return m_buffer.length(); 928 elseif (m_previousText)928 if (m_previousText) 929 929 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 933 const UChar* WordAwareIterator::characters() const 935 934 { 936 935 if (!m_buffer.isEmpty()) 937 return m_buffer.unicode();938 elseif (m_previousText)936 return reinterpret_cast<const UChar*>(m_buffer.unicode()); 937 if (m_previousText) 939 938 return m_previousText; 940 else 941 return m_textIterator.characters(); 939 return m_textIterator.characters(); 942 940 } 943 941 … … 948 946 949 947 if (!isCaseSensitive) 950 m_target = s. lower();948 m_target = s.foldCase(); 951 949 m_target.replace(nonBreakingSpace, ' '); 952 950 m_isCaseSensitive = isCaseSensitive; 953 951 954 m_buffer = static_cast< QChar *>(fastMalloc(s.length() * sizeof(QChar)));952 m_buffer = static_cast<UChar*>(fastMalloc(s.length() * sizeof(UChar))); 955 953 m_cursor = m_buffer; 956 954 m_bufferFull = false; 957 955 } 958 956 959 void CircularSearchBuffer::append( const QChar &c)957 void CircularSearchBuffer::append(UChar c) 960 958 { 961 959 if (m_isCaseSensitive) 962 *m_cursor++ = c .unicode() == nonBreakingSpace ? ' ' : c.unicode();960 *m_cursor++ = c == nonBreakingSpace ? ' ' : c; 963 961 else 964 *m_cursor++ = c .unicode() == nonBreakingSpace ? ' ' : c.lower().unicode();962 *m_cursor++ = c == nonBreakingSpace ? ' ' : u_foldCase(c, U_FOLD_CASE_DEFAULT); 965 963 if (m_cursor == m_buffer + length()) { 966 964 m_cursor = m_buffer; … … 972 970 // and when then count is small enough to fit in the buffer. 973 971 // No need for a more general version for the search algorithm. 974 void CircularSearchBuffer::append(int count, const QChar *characters)972 void CircularSearchBuffer::append(int count, const UChar* characters) 975 973 { 976 974 int tailSpace = m_buffer + length() - m_cursor; … … 981 979 if (m_isCaseSensitive) { 982 980 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; 985 983 } 986 984 } else { 987 985 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); 990 988 } 991 989 } … … 1009 1007 int headSpace = m_cursor - m_buffer; 1010 1008 int tailSpace = length() - headSpace; 1011 return memcmp(m_cursor, m_target. unicode(), tailSpace * sizeof(QChar)) == 01012 && 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; 1013 1011 } 1014 1012 … … 1095 1093 } 1096 1094 1097 DeprecatedString plainText(const Range *r)1095 DeprecatedString plainText(const Range* r) 1098 1096 { 1099 1097 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()); 1103 1100 return result; 1104 1101 } -
trunk/WebCore/editing/TextIterator.h
r14256 r14273 1 1 /* 2 * Copyright (C) 2004 Apple Computer, Inc. All rights reserved.2 * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 36 36 // FIXME: Move this along with the white-space position functions above 37 37 // somewhere else in the editing directory. It doesn't belong here. 38 inline bool isCollapsibleWhitespace( const QChar&c)38 inline bool isCollapsibleWhitespace(UChar c) 39 39 { 40 switch (c .unicode()) {40 switch (c) { 41 41 case ' ': 42 42 case '\n': … … 66 66 67 67 int length() const { return m_textLength; } 68 const QChar *characters() const { return m_textCharacters; }68 const UChar* characters() const { return m_textCharacters; } 69 69 70 70 PassRefPtr<Range> range() const; … … 79 79 bool handleNonTextNode(); 80 80 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); 82 82 83 83 // Current position, not necessarily of the text being returned, but position … … 98 98 mutable int m_positionStartOffset; 99 99 mutable int m_positionEndOffset; 100 const QChar *m_textCharacters;100 const UChar* m_textCharacters; 101 101 int m_textLength; 102 102 … … 109 109 Node *m_lastTextNode; 110 110 bool m_lastTextNodeEndedWithCollapsedSpace; 111 QChar m_lastCharacter;111 UChar m_lastCharacter; 112 112 113 113 // Used for whitespace characters that aren't in the DOM, so we can point at them. 114 QChar m_singleCharacterBuffer;114 UChar m_singleCharacterBuffer; 115 115 116 116 // Used when text boxes are out of order (Hebrew/Arabic w/ embeded LTR text) … … 132 132 133 133 int length() const { return m_textLength; } 134 const QChar *characters() const { return m_textCharacters; }134 const UChar* characters() const { return m_textCharacters; } 135 135 136 136 PassRefPtr<Range> range() const; … … 141 141 bool handleReplacedElement(); 142 142 bool handleNonTextNode(); 143 void emitCharacter( QChar, Node *Node, int startOffset, int endOffset);143 void emitCharacter(UChar, Node *Node, int startOffset, int endOffset); 144 144 void emitNewline(); 145 145 146 146 // Current position, not necessarily of the text being returned, but position 147 147 // as we walk through the DOM tree. 148 Node *m_node;148 Node* m_node; 149 149 int m_offset; 150 150 bool m_handledNode; … … 152 152 153 153 // End of the range. 154 Node *m_startNode;154 Node* m_startNode; 155 155 int m_startOffset; 156 156 157 157 // The current text and its position, in the form to be returned from the iterator. 158 Node *m_positionNode;158 Node* m_positionNode; 159 159 int m_positionStartOffset; 160 160 int m_positionEndOffset; 161 const QChar *m_textCharacters;161 const UChar* m_textCharacters; 162 162 int m_textLength; 163 163 164 164 // Used to do the whitespace logic. 165 Node *m_lastTextNode;166 QChar m_lastCharacter;165 Node* m_lastTextNode; 166 UChar m_lastCharacter; 167 167 168 168 // Used for whitespace characters that aren't in the DOM, so we can point at them. 169 QChar m_singleCharacterBuffer;169 UChar m_singleCharacterBuffer; 170 170 }; 171 171 … … 183 183 184 184 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; } 186 186 DeprecatedString string(int numChars); 187 187 … … 208 208 209 209 int length() const; 210 const QChar *characters() const;210 const UChar* characters() const; 211 211 212 212 // Range of the text we're currently returning … … 215 215 private: 216 216 // text from the previous chunk from the textIterator 217 const QChar *m_previousText;217 const UChar* m_previousText; 218 218 int m_previousLength; 219 219 -
trunk/WebCore/editing/VisiblePosition.cpp
r14172 r14273 199 199 } 200 200 201 QChar VisiblePosition::characterAfter() const201 UChar VisiblePosition::characterAfter() const 202 202 { 203 203 // We canonicalize to the first of two equivalent candidates, but the second of the two candidates 204 204 // is the one that will be inside the text node containing the character after this visible position. 205 205 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()); 211 210 int offset = pos.offset(); 212 if ((unsigned)offset >= textNode->length()) { 213 return QChar(); 214 } 211 if ((unsigned)offset >= textNode->length()) 212 return 0; 215 213 return textNode->data()[offset]; 216 214 } -
trunk/WebCore/editing/VisiblePosition.h
r14172 r14273 67 67 bool isLastInBlock() const; 68 68 69 QChar characterAfter() const;69 UChar characterAfter() const; 70 70 71 71 void debugPosition(const char* msg = "") const; -
trunk/WebCore/editing/markup.cpp
r14234 r14273 55 55 unsigned len = in.length(); 56 56 for (unsigned i = 0; i < len; ++i) { 57 switch (in[i]. latin1()) {57 switch (in[i].unicode()) { 58 58 case '&': 59 59 s += "&"; -
trunk/WebCore/editing/visible_units.cpp
r13868 r14273 39 39 using namespace HTMLNames; 40 40 41 static VisiblePosition previousBoundary(const VisiblePosition &c, unsigned (*searchFunction)(const QChar *, unsigned))41 static VisiblePosition previousBoundary(const VisiblePosition &c, unsigned (*searchFunction)(const UChar *, unsigned)) 42 42 { 43 43 Position pos = c.deepEquivalent(); … … 73 73 while (!it.atEnd() && it.length() > 0) { 74 74 // 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()); 77 77 if (next != 0) 78 78 break; … … 93 93 chars[1] = ' '; 94 94 string.prepend(chars, 2); 95 unsigned pastImage = searchFunction( string.unicode(), string.length());95 unsigned pastImage = searchFunction(reinterpret_cast<const UChar*>(string.unicode()), string.length()); 96 96 RefPtr<Range> range(it.range()); 97 97 if (pastImage == 0) … … 116 116 } 117 117 118 static VisiblePosition nextBoundary(const VisiblePosition &c, unsigned (*searchFunction)(const QChar *, unsigned))118 static VisiblePosition nextBoundary(const VisiblePosition &c, unsigned (*searchFunction)(const UChar *, unsigned)) 119 119 { 120 120 Position pos = c.deepEquivalent(); … … 144 144 // Keep asking the iterator for chunks until the search function 145 145 // 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()); 148 148 if (next != string.length()) 149 149 break; … … 165 165 chars[1] = 'X'; 166 166 string.append(chars, 2); 167 unsigned pastImage = searchFunction( string.unicode(), string.length());167 unsigned pastImage = searchFunction(reinterpret_cast<const UChar*>(string.unicode()), string.length()); 168 168 RefPtr<Range> range(it.range()); 169 169 int exception = 0; … … 185 185 // --------- 186 186 187 static unsigned startWordBoundary(const QChar *characters, unsigned length)187 static unsigned startWordBoundary(const UChar* characters, unsigned length) 188 188 { 189 189 int start, end; … … 207 207 } 208 208 209 static unsigned endWordBoundary(const QChar *characters, unsigned length)209 static unsigned endWordBoundary(const UChar* characters, unsigned length) 210 210 { 211 211 int start, end; … … 235 235 } 236 236 237 static unsigned previousWordPositionBoundary(const QChar *characters, unsigned length)237 static unsigned previousWordPositionBoundary(const UChar* characters, unsigned length) 238 238 { 239 239 return findNextWordFromIndex(characters, length, length, false); … … 245 245 } 246 246 247 static unsigned nextWordPositionBoundary(const QChar *characters, unsigned length)247 static unsigned nextWordPositionBoundary(const UChar* characters, unsigned length) 248 248 { 249 249 return findNextWordFromIndex(characters, length, 0, true); … … 491 491 // --------- 492 492 493 static unsigned startSentenceBoundary(const QChar *characters, unsigned length)493 static unsigned startSentenceBoundary(const UChar* characters, unsigned length) 494 494 { 495 495 int start, end; … … 503 503 } 504 504 505 static unsigned endSentenceBoundary(const QChar *characters, unsigned length)505 static unsigned endSentenceBoundary(const UChar* characters, unsigned length) 506 506 { 507 507 int start, end; … … 515 515 } 516 516 517 static unsigned previousSentencePositionBoundary(const QChar *characters, unsigned length)517 static unsigned previousSentencePositionBoundary(const UChar* characters, unsigned length) 518 518 { 519 519 return findNextSentenceFromIndex(characters, length, length, false); … … 525 525 } 526 526 527 static unsigned nextSentencePositionBoundary(const QChar *characters, unsigned length)527 static unsigned nextSentencePositionBoundary(const UChar* characters, unsigned length) 528 528 { 529 529 return findNextSentenceFromIndex(characters, length, 0, true); … … 564 564 if (r->isText()) { 565 565 if (style->preserveNewline()) { 566 const QChar* text = static_cast<RenderText*>(r)->text();566 const UChar* text = static_cast<RenderText*>(r)->text(); 567 567 int i = static_cast<RenderText*>(r)->length(); 568 568 int o = offset; … … 624 624 int length = static_cast<RenderText *>(r)->length(); 625 625 if (style->preserveNewline()) { 626 const QChar* text = static_cast<RenderText *>(r)->text();626 const UChar* text = static_cast<RenderText *>(r)->text(); 627 627 int o = n == startNode ? offset : 0; 628 628 for (int i = o; i < length; ++i) -
trunk/WebCore/html/HTMLInputElement.cpp
r14212 r14273 1443 1443 int newLen = numCharactersInGraphemeClusters(s, maxLen); 1444 1444 for (int i = 0; i < newLen; ++i) 1445 if ((*s)[i] .unicode()< ' ') {1445 if ((*s)[i] < ' ') { 1446 1446 newLen = i; 1447 1447 break; -
trunk/WebCore/html/HTMLParser.cpp
r14207 r14273 49 49 50 50 using namespace HTMLNames; 51 52 const UChar nonBreakingSpace = 0xa0; 51 53 52 54 /** … … 474 476 StringImpl *i = t->string(); 475 477 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)) 477 479 pos++; 478 480 if (pos == i->length()) -
trunk/WebCore/html/HTMLTokenizer.cpp
r14212 r14273 66 66 static const char textareaEnd [] = "</textarea"; 67 67 static 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 ))71 68 72 69 // Full support for MS Windows extensions to Latin-1. … … 85 82 // We only need this for entities. For non-entity text, we handle this in the text encoding. 86 83 87 static const unsigned shortwindowsLatin1ExtensionArray[32] = {84 static const UChar windowsLatin1ExtensionArray[32] = { 88 85 0x20AC, 0x0081, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, // 80-87 89 86 0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x008D, 0x017D, 0x008F, // 88-8F … … 92 89 }; 93 90 94 static inline QChar fixUpChar(QChar c) 95 { 96 unsigned short code = c.unicode(); 97 if ((code & ~0x1F) != 0x0080) 91 static inline UChar fixUpChar(UChar c) 92 { 93 if ((c & ~0x1F) != 0x0080) 98 94 return c; 99 return windowsLatin1ExtensionArray[c ode- 0x80];100 } 101 102 inline bool tagMatch(const char *s1, const QChar *s2, unsigned length)95 return windowsLatin1ExtensionArray[c - 0x80]; 96 } 97 98 static inline bool tagMatch(const char* s1, const UChar* s2, unsigned length) 103 99 { 104 100 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]; 108 104 if (c1 != c2 && uc1 != c2) 109 105 return false; … … 112 108 } 113 109 114 void Token::addAttribute(Document* doc, const AtomicString& attrName, const AtomicString& v) 115 { 116 Attribute* a = 0; 110 inline void Token::addAttribute(Document* doc, const AtomicString& attrName, const AtomicString& v) 111 { 117 112 if (!attrName.isEmpty() && attrName != "/") { 118 a = new MappedAttribute(attrName, v);113 Attribute* a = new MappedAttribute(attrName, v); 119 114 if (!attrs) 120 115 attrs = new NamedMappedAttrMap(0); … … 167 162 } 168 163 169 if (buffer) 170 KHTML_DELETE_QCHAR_VEC(buffer); 164 fastFree(buffer); 171 165 buffer = dest = 0; 172 166 size = 0; 173 167 174 if (scriptCode) 175 KHTML_DELETE_QCHAR_VEC(scriptCode); 168 fastFree(scriptCode); 176 169 scriptCode = 0; 177 170 scriptCodeSize = scriptCodeMaxSize = scriptCodeResync = 0; … … 190 183 reset(); 191 184 size = 254; 192 buffer = KHTML_ALLOC_QCHAR_VEC( 255);185 buffer = static_cast<UChar*>(fastMalloc(sizeof(UChar) * 254)); 193 186 dest = buffer; 194 187 tquote = NoQuote; … … 262 255 while ( !src.isEmpty() ) { 263 256 checkScriptBuffer(); 264 unsigned char ch = src->latin1();257 UChar ch = *src; 265 258 if (!scriptCodeResync && !brokenComments && !state.inTextArea() && !state.inXmp() && !state.inTitle() && ch == '-' && scriptCodeSize >= 3 && !src.escaped() && scriptCode[scriptCodeSize-3] == '<' && scriptCode[scriptCodeSize-2] == '!' && scriptCode[scriptCodeSize-1] == '-') { 266 259 state.setInComment(true); … … 268 261 continue; 269 262 } 270 if ( scriptCodeResync && !tquote && ( ch == '>' )) {263 if (scriptCodeResync && !tquote && ch == '>') { 271 264 ++src; 272 265 scriptCodeSize = scriptCodeResync-1; … … 303 296 } 304 297 // 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 && 306 299 scriptCodeSize >= searchStopperLen && 307 300 tagMatch( searchStopper, scriptCode+scriptCodeSize-searchStopperLen, searchStopperLen )) { … … 310 303 continue; 311 304 } 312 if ( scriptCodeResync && !state.escaped()) {313 if (ch == '\"')305 if (scriptCodeResync && !state.escaped()) { 306 if (ch == '\"') 314 307 tquote = (tquote == NoQuote) ? DoubleQuote : ((tquote == SingleQuote) ? SingleQuote : NoQuote); 315 else if (ch == '\'')308 else if (ch == '\'') 316 309 tquote = (tquote == NoQuote) ? SingleQuote : (tquote == DoubleQuote) ? DoubleQuote : NoQuote; 317 310 else if (tquote != NoQuote && (ch == '\r' || ch == '\n')) … … 320 313 state.setEscaped(!state.escaped() && ch == '\\'); 321 314 if (!scriptCodeResync && (state.inTextArea() || state.inTitle()) && !src.escaped() && ch == '&') { 322 QChar *scriptCodeDest = scriptCode+scriptCodeSize;315 UChar* scriptCodeDest = scriptCode+scriptCodeSize; 323 316 ++src; 324 317 state = parseEntity(src, scriptCodeDest, state, m_cBufferPos, true, false); 325 318 scriptCodeSize = scriptCodeDest-scriptCode; 326 } 327 else { 319 } else { 328 320 scriptCode[scriptCodeSize++] = *src; 329 321 ++src; … … 371 363 } 372 364 state = processListing(SegmentedString(scriptCode, scriptCodeSize), state); 373 DeprecatedString exScript( buffer, dest-buffer);365 DeprecatedString exScript(reinterpret_cast<QChar*>(buffer), dest - buffer); 374 366 processToken(); 375 367 currToken.tagName = scriptTag.localName(); … … 507 499 while ( !src.isEmpty() ) { 508 500 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 == '>') { 515 503 bool handleBrokenComments = brokenComments && !(state.inScript() || state.inStyle()); 516 504 int endCharsCount = 1; // start off with one for the '>' character … … 556 544 while (!src.isEmpty()) { 557 545 scriptCode[scriptCodeSize++] = *src; 558 if ( src->unicode()== '>' &&546 if (*src == '>' && 559 547 scriptCodeSize > 1 && scriptCode[scriptCodeSize-2] == '%') { 560 548 ++src; … … 570 558 HTMLTokenizer::State HTMLTokenizer::parseProcessingInstruction(SegmentedString &src, State state) 571 559 { 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 == '\'') 577 564 tquote = tquote == SingleQuote ? NoQuote : SingleQuote; 578 } 579 else if(chbegin == '\"') { 565 else if (chbegin == '\"') 580 566 tquote = tquote == DoubleQuote ? NoQuote : DoubleQuote; 581 }582 567 // Look for '?>' 583 // some crappy sites omit the "?" before it, so568 // Some crappy sites omit the "?" before it, so 584 569 // we look for an unquoted '>' instead. (IE compatible) 585 else if ( chbegin == '>' && ( !tquote || oldchar == '?' ) ) 586 { 570 else if (chbegin == '>' && (!tquote || oldchar == '?')) { 587 571 // We got a '?>' sequence 588 572 state.setInProcessingInstruction(false); … … 601 585 { 602 586 while (!src.isEmpty()) { 603 unsigned short cc = src->unicode();587 UChar cc = *src; 604 588 605 589 if (state.skipLF()) { … … 626 610 627 611 628 HTMLTokenizer::State HTMLTokenizer::parseEntity(SegmentedString &src, QChar *&dest, State state, unsigned &cBufferPos, bool start, bool parsingTag)612 HTMLTokenizer::State HTMLTokenizer::parseEntity(SegmentedString &src, UChar*& dest, State state, unsigned &cBufferPos, bool start, bool parsingTag) 629 613 { 630 614 if (start) … … 637 621 while(!src.isEmpty()) 638 622 { 639 unsigned short cc = src->unicode();623 UChar cc = *src; 640 624 switch(state.entityState()) { 641 625 case NoEntity: … … 655 639 656 640 case NumericSearch: 657 if (cc == 'x' || cc == 'X') {641 if (cc == 'x' || cc == 'X') { 658 642 cBuffer[cBufferPos++] = cc; 659 643 ++src; 660 644 state.setEntityState(Hexadecimal); 661 } 662 else if(cc >= '0' && cc <= '9') 645 } else if (cc >= '0' && cc <= '9') 663 646 state.setEntityState(Decimal); 664 647 else 665 648 state.setEntityState(SearchSemicolon); 666 667 649 break; 668 650 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'))) { 677 656 state.setEntityState(SearchSemicolon); 678 657 break; 679 658 } 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; 681 665 cBuffer[cBufferPos++] = cc; 682 666 ++src; … … 690 674 int ll = min(src.length(), 9-cBufferPos); 691 675 while(ll--) { 692 cc = src->unicode();676 cc = *src; 693 677 694 678 if (!(cc >= '0' && cc <= '9')) { … … 709 693 int ll = min(src.length(), 9-cBufferPos); 710 694 while(ll--) { 711 QChar csrc = *src; 712 cc = csrc.unicode(); 695 cc = *src; 713 696 714 697 if (!((cc >= 'a' && cc <= 'z') || (cc >= '0' && cc <= '9') || (cc >= 'A' && cc <= 'Z'))) { … … 738 721 case SearchSemicolon: 739 722 // Don't allow values that are more than 21 bits. 740 if (EntityUnicodeValue > 0 && EntityUnicodeValue <= 0x1FFFFF) { 741 723 if (EntityUnicodeValue > 0 && EntityUnicodeValue <= 0x10FFFF) { 742 724 if (*src == ';') 743 725 ++src; 744 745 726 if (EntityUnicodeValue <= 0xFFFF) { 746 727 checkBuffer(); … … 748 729 } else { 749 730 // 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));752 731 checkBuffer(2); 753 src.push( c1);754 src.push( c2);732 src.push(U16_LEAD(EntityUnicodeValue)); 733 src.push(U16_TRAIL(EntityUnicodeValue)); 755 734 } 756 735 } else { … … 780 759 { 781 760 checkBuffer(); 782 #if defined(TOKEN_DEBUG) && TOKEN_DEBUG > 1783 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 #endif789 761 switch(state.tagState()) { 790 762 case NoTag: … … 822 794 if (!src.isEmpty()) 823 795 // cuts off high bits, which is okay 824 cBuffer[cBufferPos++] = src->unicode();796 cBuffer[cBufferPos++] = *src; 825 797 } 826 798 else … … 831 803 } 832 804 // cuts off high bits, which is okay 833 cBuffer[cBufferPos++] = src->unicode();805 cBuffer[cBufferPos++] = *src; 834 806 ++src; 835 807 break; … … 842 814 unsigned int ll = min(src.length(), CBUFLEN-cBufferPos); 843 815 while(ll--) { 844 unsigned short curchar = src->unicode();816 UChar curchar = *src; 845 817 if(curchar <= ' ' || curchar == '>' ) { 846 818 finish = true; … … 894 866 #endif 895 867 while(!src.isEmpty()) { 896 unsigned short curchar = src->unicode();868 UChar curchar = *src; 897 869 // In this mode just ignore any quotes we encounter and treat them like spaces. 898 870 if (curchar > ' ' && curchar != '\'' && curchar != '"') { … … 915 887 int ll = min(src.length(), CBUFLEN-cBufferPos); 916 888 while(ll--) { 917 unsigned short curchar = src->unicode();889 UChar curchar = *src; 918 890 if (curchar <= '>' && (curchar >= '=' || curchar <= ' ')) { 919 891 cBuffer[cBufferPos] = '\0'; … … 953 925 #endif 954 926 while(!src.isEmpty()) { 955 unsigned short curchar = src->unicode();927 UChar curchar = *src; 956 928 // In this mode just ignore any quotes we encounter and treat them like spaces. 957 929 if (curchar > ' ' && curchar != '\'' && curchar != '"') { … … 975 947 case SearchValue: 976 948 while(!src.isEmpty()) { 977 unsigned short curchar = src->unicode();949 UChar curchar = *src; 978 950 if(curchar > ' ') { 979 951 if(( curchar == '\'' || curchar == '\"' )) { … … 996 968 checkBuffer(); 997 969 998 unsigned short curchar = src->unicode();970 UChar curchar = *src; 999 971 if (curchar == '>' && attrName.isEmpty()) { 1000 972 // Handle a case like <img '>. Just go ahead and be willing … … 1052 1024 while(!src.isEmpty()) { 1053 1025 checkBuffer(); 1054 unsigned short curchar = src->unicode();1026 UChar curchar = *src; 1055 1027 if(curchar <= '>' && !src.escaped()) { 1056 1028 // parse Entities … … 1341 1313 checkBuffer(); 1342 1314 1343 unsigned short cc = src->unicode();1315 UChar cc = *src; 1344 1316 1345 1317 bool wasSkipLF = state.skipLF(); … … 1506 1478 processToken(); 1507 1479 1508 if (scriptCode) 1509 KHTML_DELETE_QCHAR_VEC(scriptCode); 1480 fastFree(scriptCode); 1510 1481 scriptCode = 0; 1511 1482 scriptCodeSize = scriptCodeMaxSize = scriptCodeResync = 0; 1512 1483 1513 KHTML_DELETE_QCHAR_VEC(buffer);1484 fastFree(buffer); 1514 1485 buffer = 0; 1515 1486 } … … 1533 1504 DeprecatedString food; 1534 1505 if (m_state.inScript() || m_state.inStyle()) 1535 food.setUnicode( scriptCode, scriptCodeSize);1506 food.setUnicode(reinterpret_cast<QChar*>(scriptCode), scriptCodeSize); 1536 1507 else if (m_state.inServer()) { 1537 1508 food = "<"; 1538 food += DeprecatedString( scriptCode, scriptCodeSize);1509 food += DeprecatedString(reinterpret_cast<QChar*>(scriptCode), scriptCodeSize); 1539 1510 } else { 1540 pos = QConstString( scriptCode, scriptCodeSize).string().find('>');1541 food.setUnicode( scriptCode+pos+1, scriptCodeSize-pos-1); // deep copy1542 } 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); 1544 1515 scriptCode = 0; 1545 1516 scriptCodeSize = scriptCodeMaxSize = scriptCodeResync = 0; … … 1627 1598 void HTMLTokenizer::enlargeBuffer(int len) 1628 1599 { 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; 1635 1605 } 1636 1606 1637 1607 void HTMLTokenizer::enlargeScriptBuffer(int len) 1638 1608 { 1639 int new size = max(scriptCodeMaxSize*2, scriptCodeMaxSize+len);1640 scriptCode = (QChar*)fastRealloc(scriptCode, newsize*sizeof(QChar));1641 scriptCodeMaxSize = new size;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 1614 void HTMLTokenizer::notifyFinished(CachedObject*) 1645 1615 { 1646 1616 #if INSTRUMENT_LAYOUT_SCHEDULING … … 1729 1699 } 1730 1700 1731 unsigned shortdecodeNamedEntity(const char* name)1701 UChar decodeNamedEntity(const char* name) 1732 1702 { 1733 1703 const Entity* e = findEntity(name, strlen(name)); -
trunk/WebCore/html/HTMLTokenizer.h
r13858 r14273 83 83 virtual ~HTMLTokenizer(); 84 84 85 virtual bool write(const SegmentedString &str, bool appendData);85 virtual bool write(const SegmentedString&, bool appendData); 86 86 virtual void finish(); 87 87 virtual void setForceSynchronous(bool force); … … 107 107 State parseSpecial(SegmentedString&, State); 108 108 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); 110 110 State parseProcessingInstruction(SegmentedString&, State); 111 111 State scriptHandler(State); 112 112 State scriptExecution(const DeprecatedString& script, State state, DeprecatedString scriptURL = DeprecatedString(), int baseLine = 0); 113 void setSrc(const SegmentedString &source);113 void setSrc(const SegmentedString&); 114 114 115 115 // check if we have enough space in the buffer. … … 129 129 void enlargeScriptBuffer(int len); 130 130 131 bool continueProcessing(int& processedCount, double startTime, State &state);131 bool continueProcessing(int& processedCount, double startTime, State&); 132 132 void timerFired(Timer<HTMLTokenizer>*); 133 133 void allDataProcessed(); … … 138 138 // Internal buffers 139 139 /////////////////// 140 QChar *buffer;141 QChar *dest;140 UChar* buffer; 141 UChar* dest; 142 142 143 143 Token currToken; … … 149 149 ////////////////// 150 150 // 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; 157 152 158 153 // Are we in a &... character entity description? … … 274 269 275 270 // Used to store the code of a srcipting sequence 276 QChar *scriptCode;271 UChar* scriptCode; 277 272 // Size of the script sequenze stored in @ref #scriptCode 278 273 int scriptCodeSize; … … 283 278 284 279 // Stores characters if we are scanning for a string like "</script>" 285 QChar searchBuffer[ 10];280 UChar searchBuffer[10]; 286 281 // Counts where we are in the string we are scanning for 287 282 int searchCount; 288 283 // The string we are searching for 289 const QChar *searchFor;284 const UChar* searchFor; 290 285 // the stopper string 291 286 const char* searchStopper; … … 340 335 void parseHTMLDocumentFragment(const String&, DocumentFragment*); 341 336 342 unsigned shortdecodeNamedEntity(const char*);337 UChar decodeNamedEntity(const char*); 343 338 344 339 } -
trunk/WebCore/html/html_inlineimpl.cpp
r14212 r14273 407 407 // Allows trailing nonnumeric characters. 408 408 // Returns 10 for any size greater than 9. 409 static bool parseFontSizeNumber(const String &s, int &size)409 static bool parseFontSizeNumber(const String& s, int& size) 410 410 { 411 411 unsigned pos = 0; 412 412 413 413 // Skip leading spaces. 414 while ( pos < s.length() && s[pos].isSpace())414 while (QChar(s[pos]).isSpace()) 415 415 ++pos; 416 416 … … 418 418 bool sawPlus = false; 419 419 bool sawMinus = false; 420 if ( pos < s.length() &&s[pos] == '+') {420 if (s[pos] == '+') { 421 421 ++pos; 422 422 sawPlus = true; 423 } else if ( pos < s.length() &&s[pos] == '-') {423 } else if (s[pos] == '-') { 424 424 ++pos; 425 425 sawMinus = true; … … 427 427 428 428 // Parse a single digit. 429 if ( pos >= s.length() || !s[pos].isNumber())429 if (!u_isdigit(s[pos])) 430 430 return false; 431 int num = s[pos++].digitValue();431 int num = u_charDigitValue(s[pos++]); 432 432 433 433 // Check for an additional digit. 434 if ( pos < s.length() && s[pos].isNumber())434 if (u_isdigit(s[pos])) 435 435 num = 10; 436 436 -
trunk/WebCore/kwq/KWQLoader.mm
r13821 r14273 27 27 #import "KWQLoader.h" 28 28 29 #import "BlockExceptions.h" 29 30 #import "Cache.h" 30 31 #import "CachedImage.h" 31 32 #import "DocLoader.h" 32 33 #import "FoundationExtras.h" 33 #import " BlockExceptions.h"34 #import "FrameMac.h" 34 35 #import "KWQFormData.h" 36 #import "KWQResourceLoader.h" 37 #import "Logging.h" 38 #import "Request.h" 35 39 #import "TransferJob.h" 36 #import "Logging.h"37 #import "KWQResourceLoader.h"38 #import "FrameMac.h"39 #import "Request.h"40 40 #import "WebCoreFrameBridge.h" 41 41 #import "loader.h" 42 #import "loader.h"43 44 42 #import <Foundation/NSURLResponse.h> 45 43 … … 216 214 } 217 215 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 216 bool KWQIsResponseURLEqualToURL(NSURLResponse *response, const WebCore::String& m_url) 217 { 225 218 NSURL *responseURL = [(NSURLResponse *)response URL]; 226 219 NSString *urlString = [responseURL absoluteString]; 227 220 228 if (m_url.length() != [urlString length]) 221 size_t length = m_url.length(); 222 if (length != [urlString length]) 229 223 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)); 249 228 } 250 229 -
trunk/WebCore/kwq/KWQTextStream.cpp
r13404 r14273 27 27 #include "KWQTextStream.h" 28 28 29 #include "DeprecatedString.h" 29 30 #include "PlatformString.h" 30 31 #include "Logging.h" -
trunk/WebCore/kwq/WebCoreAXObject.mm
r13901 r14273 1269 1269 } 1270 1270 1271 static void AXAttributedStringAppendText (NSMutableAttributedString *attrString, Node *nodeImpl, const QChar *chars, int length)1271 static void AXAttributedStringAppendText(NSMutableAttributedString* attrString, Node* nodeImpl, const UChar* chars, int length) 1272 1272 { 1273 1273 // skip invisible text … … 1279 1279 1280 1280 // 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]]; 1282 1282 1283 1283 // add new attributes and remove irrelevant inherited ones … … 1351 1351 // non-zero length means textual node, zero length means replaced node (AKA "attachments" in AX) 1352 1352 if (it.length() != 0) { 1353 AXAttributedStringAppendText 1353 AXAttributedStringAppendText(attrString, nodeImpl, it.characters(), it.length()); 1354 1354 } else { 1355 AXAttributedStringAppendReplaced 1355 AXAttributedStringAppendReplaced(attrString, nodeImpl->childNode(it.range()->startOffset(exception))); 1356 1356 } 1357 1357 -
trunk/WebCore/loader/Cache.cpp
r14251 r14273 228 228 } 229 229 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 238 230 CachedScript *Cache::requestScript(DocLoader* dl, const String& url, bool reload, time_t expireDate, const DeprecatedString& charset) 239 231 { … … 285 277 updateCacheStatus(dl, url, o); 286 278 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));295 279 } 296 280 -
trunk/WebCore/loader/Cache.h
r14256 r14273 49 49 /** 50 50 * Provides a cache/loader for objects needed for displaying the html page. 51 * At the moment these are stylesheets, scripts and images52 51 */ 53 52 class Cache { … … 55 54 public: 56 55 /** 57 * init the cache in case it's not already. This needs to get called once58 * before using it.56 * Initialize the cache in case it's not already. 57 * This needs to get called once before using it. 59 58 */ 60 59 static void init(); 61 60 62 61 /** 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 67 64 */ 68 65 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); 92 69 93 70 #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); 96 72 #endif 97 73 98 74 #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); 101 76 #endif 102 77 103 78 /** 104 * Sets the size of the cache. This will only ho d approximately, since the size some105 * cached objects (like stylesheets) take up in memory is not exac lty 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. 106 81 */ 107 82 static void setSize(int bytes); 83 108 84 /** 109 85 * returns the size of the cache … … 126 102 /** 127 103 * 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). 130 106 */ 131 107 static void clear(); -
trunk/WebCore/loader/CachedObject.h
r14256 r14273 28 28 #define KHTML_CachedObject_h 29 29 30 #include "DeprecatedString.h" 30 31 #include "PlatformString.h" 31 32 #include "KWQKIOGlobal.h" -
trunk/WebCore/page/Frame.cpp
r14258 r14273 83 83 84 84 using namespace std; 85 using namespace KJS; 85 86 using KJS::JSLock; 87 using KJS::JSValue; 88 using KJS::Location; 89 using KJS::PausedTimeouts; 90 using KJS::SavedProperties; 91 using KJS::SavedBuiltins; 92 using KJS::UString; 93 using KJS::Window; 86 94 87 95 namespace WebCore { … … 97 105 UserStyleSheetLoader(Frame* frame, const String& url, DocLoader* dl) 98 106 : m_frame(frame) 99 , m_cachedSheet(Cache::requestStyleSheet(dl, url ))107 , m_cachedSheet(Cache::requestStyleSheet(dl, url, false, 0, "")) 100 108 { 101 109 m_cachedSheet->ref(this); … … 3255 3263 } 3256 3264 3257 QChar Frame::backslashAsCurrencySymbol() const3265 UChar Frame::backslashAsCurrencySymbol() const 3258 3266 { 3259 3267 Document *doc = document(); -
trunk/WebCore/page/Frame.h
r14256 r14273 713 713 // Convenience, to avoid repeating the code to dig down to get this. 714 714 715 QChar backslashAsCurrencySymbol() const;715 UChar backslashAsCurrencySymbol() const; 716 716 717 717 DeprecatedValueList<MarkedTextUnderline> markedTextUnderlines() const; -
trunk/WebCore/platform/AtomicString.cpp
r14256 r14273 24 24 25 25 #if AVOID_STATIC_CONSTRUCTORS 26 #define KHTML_ATOMICSTRING_HIDE_GLOBALS 126 #define ATOMICSTRING_HIDE_GLOBALS 1 27 27 #endif 28 28 29 29 #include "AtomicString.h" 30 30 31 #include "DeprecatedString.h" 31 32 #include "StaticConstructors.h" 32 33 #include "StringHash.h" … … 34 35 #include <wtf/HashSet.h> 35 36 36 using namespace KJS; 37 using KJS::Identifier; 38 using KJS::UString; 37 39 38 40 namespace WebCore { 39 41 40 42 static HashSet<StringImpl*>* stringTable; 41 43 … … 50 52 { 51 53 int length = r->length(); 52 const QChar* d = r->unicode();54 const UChar* d = r->characters(); 53 55 for (int i = 0; i != length; ++i) 54 56 if (d[i] != s[i]) … … 69 71 { 70 72 StringImpl* impl = a.impl(); 71 if ((!impl || !impl-> unicode()) && !b)73 if ((!impl || !impl->characters()) && !b) 72 74 return true; 73 if ((!impl || !impl-> unicode()) || !b)75 if ((!impl || !impl->characters()) || !b) 74 76 return false; 75 77 return CStringTranslator::equal(impl, b); … … 87 89 } 88 90 89 struct QCharBuffer {90 const QChar* s;91 struct UCharBuffer { 92 const UChar* s; 91 93 unsigned length; 92 94 }; 93 95 94 struct QCharBufferTranslator {95 static unsigned hash(const QCharBuffer& buf)96 struct UCharBufferTranslator { 97 static unsigned hash(const UCharBuffer& buf) 96 98 { 97 99 return StringImpl::computeHash(buf.s, buf.length); 98 100 } 99 101 100 static bool equal(StringImpl* const& str, const QCharBuffer& buf)102 static bool equal(StringImpl* const& str, const UCharBuffer& buf) 101 103 { 102 104 unsigned strLength = str->length(); … … 105 107 return false; 106 108 107 const uint32_t* strChars = reinterpret_cast<const uint32_t*>(str-> unicode());109 const uint32_t* strChars = reinterpret_cast<const uint32_t*>(str->characters()); 108 110 const uint32_t* bufChars = reinterpret_cast<const uint32_t*>(buf.s); 109 111 … … 121 123 } 122 124 123 static void translate(StringImpl*& location, const QCharBuffer& buf, unsigned hash)125 static void translate(StringImpl*& location, const UCharBuffer& buf, unsigned hash) 124 126 { 125 127 StringImpl *r = new StringImpl(buf.s, buf.length); … … 131 133 }; 132 134 133 StringImpl* AtomicString::add(const QChar* s, int length)135 StringImpl* AtomicString::add(const UChar* s, int length) 134 136 { 135 137 if (!s) … … 139 141 return StringImpl::empty(); 140 142 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; 143 145 } 144 146 … … 164 166 StringImpl* AtomicString::add(const KJS::Identifier& str) 165 167 { 166 return add(reinterpret_cast<const QChar*>(str.data()), str.size());168 return add(reinterpret_cast<const UChar*>(str.data()), str.size()); 167 169 } 168 170 169 171 StringImpl* AtomicString::add(const KJS::UString& str) 170 172 { 171 return add(reinterpret_cast<const QChar*>(str.data()), str.size());173 return add(reinterpret_cast<const UChar*>(str.data()), str.size()); 172 174 } 173 175 174 176 AtomicString::operator Identifier() const 175 177 { 176 return domString();178 return m_string; 177 179 } 178 180 179 181 AtomicString::operator UString() const 180 182 { 181 return domString(); 183 return m_string; 184 } 185 186 AtomicString::AtomicString(const DeprecatedString& s) 187 : m_string(add(reinterpret_cast<const UChar*>(s.unicode()), s.length())) 188 { 189 } 190 191 DeprecatedString AtomicString::deprecatedString() const 192 { 193 return m_string.deprecatedString(); 182 194 } 183 195 -
trunk/WebCore/platform/AtomicString.h
r13706 r14273 34 34 35 35 AtomicString() { } 36 AtomicString(QChar c) : m_string(add(&c, 1)) { }37 36 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)) { } 41 38 AtomicString(const KJS::UString& s) : m_string(add(s)) { } 42 39 AtomicString(const KJS::Identifier& s) : m_string(add(s)) { } … … 44 41 AtomicString(AtomicStringImpl* imp) : m_string(imp) { } 45 42 AtomicString(const String& s) : m_string(add(s.impl())) { } 46 43 47 44 operator const String&() const { return m_string; } 48 45 const String& domString() const { return m_string; }; 49 DeprecatedString deprecatedString() const { return m_string.deprecatedString(); }; 50 46 51 47 operator KJS::Identifier() const; 52 48 operator KJS::UString() const; … … 54 50 AtomicStringImpl* impl() const { return static_cast<AtomicStringImpl *>(m_string.impl()); } 55 51 56 const QChar* unicode() const { return m_string.unicode(); }52 const UChar* characters() const { return m_string.characters(); } 57 53 unsigned length() const { return m_string.length(); } 58 54 59 const QChar& operator[](unsigned int i) const { return m_string[i]; }55 UChar operator[](unsigned int i) const { return m_string[i]; } 60 56 61 bool contains( QChar c) const { return m_string.contains(c); }57 bool contains(UChar c) const { return m_string.contains(c); } 62 58 bool contains(const AtomicString& s, bool caseSensitive = true) const 63 59 { return m_string.contains(s.domString(), caseSensitive); } 64 60 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); } 66 62 int find(const AtomicString& s, int start = 0, bool caseSentitive = true) const 67 63 { return m_string.find(s.domString(), start, caseSentitive); } … … 87 83 #endif 88 84 85 AtomicString(const DeprecatedString&); 86 DeprecatedString deprecatedString() const; 87 89 88 private: 90 89 String m_string; 91 90 92 91 static StringImpl* add(const char*); 93 static StringImpl* add(const QChar*, int length);92 static StringImpl* add(const UChar*, int length); 94 93 static StringImpl* add(StringImpl*); 95 94 static StringImpl* add(const KJS::UString&); … … 116 115 117 116 // Define external global variables for the commonly used atomic strings. 118 #if ! KHTML_ATOMICSTRING_HIDE_GLOBALS117 #if !ATOMICSTRING_HIDE_GLOBALS 119 118 extern const AtomicString nullAtom; 120 119 extern const AtomicString emptyAtom; -
trunk/WebCore/platform/Color.cpp
r14256 r14273 27 27 #include "Color.h" 28 28 29 #include "DeprecatedString.h" 29 30 #include "PlatformString.h" 30 31 #include <wtf/Assertions.h> -
trunk/WebCore/platform/DeprecatedString.h
r14212 r14273 51 51 class QChar { 52 52 public: 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, DirBN57 };58 59 53 QChar(); 60 54 QChar(char); … … 68 62 char latin1() const; 69 63 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;76 64 QChar lower() const; 77 65 QChar upper() const; 78 Direction direction() const;79 66 80 67 private: … … 119 106 // Use isspace() for basic Latin-1. 120 107 // 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); 157 109 } 158 110 … … 167 119 // FIXME: If fast enough, we should just call u_toupper directly. 168 120 return c <= 0x7F ? toupper(c) : u_toupper(c); 169 }170 171 inline QChar::Direction QChar::direction() const172 {173 return static_cast<Direction>(u_charDirection(c));174 121 } 175 122 -
trunk/WebCore/platform/Font.cpp
r14216 r14273 77 77 } 78 78 79 int Font::width(const QChar* chs, int slen, int pos, int len, int tabWidth, int xpos) const79 int Font::width(const UChar* chs, int slen, int pos, int len, int tabWidth, int xpos) const 80 80 { 81 81 // FIXME: Want to define an lroundf for win32. -
trunk/WebCore/platform/Font.h
r14216 r14273 74 74 75 75 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, 77 77 TextDirection, bool visuallyOrdered) const; 78 78 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, 80 80 TextDirection d, bool visuallyOrdered, const Color& backgroundColor) const; 81 81 void drawLineForText(GraphicsContext*, const IntPoint&, int yOffset, int width) const; … … 83 83 int misspellingLineThickness(GraphicsContext*) const; 84 84 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; 86 86 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, 88 88 int x, TextDirection, bool visuallyOrdered, bool includePartialGlyphs) const; 89 89 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, 91 91 bool rtl, bool visuallyOrdered = false, int from = -1, int to = -1) const; 92 92 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); } 96 95 97 96 bool isSmallCaps() const { return m_fontDescription.smallCaps(); } -
trunk/WebCore/platform/GraphicsContext.cpp
r14174 r14273 27 27 #include "GraphicsContext.h" 28 28 29 #include "DeprecatedString.h" 29 30 #include "Font.h" 30 31 … … 193 194 194 195 // 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.197 196 // 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, 197 void 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 205 void GraphicsContext::drawText(const IntPoint& point, int tabWidth, int xpos, const UChar* str, int slen, int pos, int len, int toAdd, 210 206 TextDirection d, bool visuallyOrdered, int from, int to) 211 207 { … … 220 216 } 221 217 222 void GraphicsContext::drawHighlightForText(const IntPoint& point, int h, int tabWidth, int xpos, const QChar *str, int slen, int pos, int len, int toAdd,218 void GraphicsContext::drawHighlightForText(const IntPoint& point, int h, int tabWidth, int xpos, const UChar* str, int slen, int pos, int len, int toAdd, 223 219 TextDirection d, bool visuallyOrdered, int from, int to, const Color& backgroundColor) 224 220 { -
trunk/WebCore/platform/GraphicsContext.h
r14256 r14273 33 33 #include "TextDirection.h" 34 34 #include <wtf/Noncopyable.h> 35 #include <unicode/umachine.h> 35 36 36 37 #if __APPLE__ … … 44 45 45 46 class DeprecatedString; 46 class QChar;47 47 48 48 namespace WebCore { … … 107 107 void clearFocusRingClip(); 108 108 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); 110 113 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, 112 115 TextDirection, bool visuallyOrdered, 113 116 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);117 117 void drawLineForText(const IntPoint&, int yOffset, int width); 118 118 void drawLineForMisspelling(const IntPoint&, int width); -
trunk/WebCore/platform/PlatformString.h
r14256 r14273 39 39 */ 40 40 41 // FIXME: Move to unsigned short instead of QChar.42 43 41 class String { 44 42 public: 45 43 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); 49 45 String(const KJS::Identifier&); 50 46 String(const KJS::UString&); … … 56 52 operator KJS::UString() const; 57 53 58 String& operator +=(const String&); 54 unsigned length() const; 55 const UChar* characters() const; 59 56 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 63 58 64 bool contains( QChar c) const { return find(c) != -1; }59 bool contains(UChar c) const { return find(c) != -1; } 65 60 bool contains(const char* str, bool caseSensitive = true) const { return find(str, 0, caseSensitive) != -1; } 66 61 bool contains(const String& str, bool caseSensitive = true) const { return find(str, 0, caseSensitive) != -1; } 67 62 68 int find( QChar c, int start = 0) const63 int find(UChar c, int start = 0) const 69 64 { return m_impl ? m_impl->find(c, start) : -1; } 70 65 int find(const char* str, int start = 0, bool caseSensitive = true) const … … 78 73 { return m_impl ? m_impl->endsWith(s.impl(), caseSensitive) : s.isEmpty(); } 79 74 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; } 82 80 String& replace(unsigned index, unsigned len, const String& b) { if (m_impl) m_impl = m_impl->replace(index, len, b.impl()); return *this; } 83 81 84 unsigned length() const;85 82 void truncate(unsigned len); 86 83 void remove(unsigned pos, int len = 1); … … 97 94 String upper() const; 98 95 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 102 99 static String number(int); 103 100 static String number(unsigned); … … 108 105 static String sprintf(const char *, ...) 109 106 #if __GNUC__ 110 __attribute__ ((format (printf, 1, 2)))107 __attribute__ ((format (printf, 1, 2))) 111 108 #endif 112 ;109 ; 113 110 114 111 int toInt(bool* ok = 0) const; … … 138 135 #endif 139 136 137 String(const DeprecatedString&); 138 DeprecatedString deprecatedString() const; 139 140 140 private: 141 141 RefPtr<StringImpl> m_impl; … … 145 145 String operator+(const String&, const char*); 146 146 String 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 148 inline String& operator+=(String& a, const String& b) { a.append(b); return a; } 151 149 152 150 inline bool operator==(const String& a, const String& b) { return equal(a.impl(), b.impl()); } … … 163 161 164 162 bool operator==(const String& a, const DeprecatedString& b); 165 inline bool operator==( 163 inline bool operator==(const DeprecatedString& b, const String& a) { return a == b; } 166 164 inline bool operator!=(const String& a, const DeprecatedString& b) { return !(a == b); } 167 165 inline bool operator!=(const DeprecatedString& b, const String& a ) { return !(a == b); } -
trunk/WebCore/platform/SegmentedString.cpp
r14212 r14273 57 57 { 58 58 unsigned length = m_currentString.m_length; 59 if (m_pushedChar1 .unicode()) {59 if (m_pushedChar1) { 60 60 ++length; 61 if (m_pushedChar2 .unicode())61 if (m_pushedChar2) 62 62 ++length; 63 63 } … … 119 119 append(*i); 120 120 } 121 m_currentChar = m_pushedChar1 .unicode()? &m_pushedChar1 : m_currentString.m_current;121 m_currentChar = m_pushedChar1 ? &m_pushedChar1 : m_currentString.m_current; 122 122 } 123 123 … … 133 133 } 134 134 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; 136 136 } 137 137 … … 151 151 { 152 152 DeprecatedString result; 153 if (m_pushedChar1 .unicode()) {153 if (m_pushedChar1) { 154 154 result.append(m_pushedChar1); 155 if (m_pushedChar2 .unicode())155 if (m_pushedChar2) 156 156 result.append(m_pushedChar2); 157 157 } -
trunk/WebCore/platform/SegmentedString.h
r14213 r14273 2 2 This file is part of the KDE libraries 3 3 4 Copyright (C) 2004 -6 Apple Computer4 Copyright (C) 2004, 2005, 2006 Apple Computer 5 5 6 6 This library is free software; you can redistribute it and/or … … 19 19 Boston, MA 02111-1307, USA. 20 20 */ 21 //----------------------------------------------------------------------------22 //23 // KDE HTML Widget -- String class24 21 25 #ifndef KHTMLSTRING_H26 #define KHTMLSTRING_H22 #ifndef SegmentedString_h 23 #define SegmentedString_h 27 24 25 #include "DeprecatedString.h" 28 26 #include "DeprecatedValueList.h" 29 27 #include "PlatformString.h" … … 40 38 SegmentedSubstring() : m_length(0), m_current(0) {} 41 39 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()); 43 41 } 44 42 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) {} 46 44 47 45 void clear() { m_length = 0; m_current = 0; } 48 46 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) { 51 49 if (str.isEmpty()) 52 50 str = m_string; … … 54 52 str.append(m_string); 55 53 } else { 56 str.insert(str.length(), m_current, m_length);54 str.insert(str.length(), reinterpret_cast<const QChar*>(m_current), m_length); 57 55 } 58 56 } … … 60 58 DeprecatedString m_string; 61 59 int m_length; 62 const QChar *m_current;60 const UChar* m_current; 63 61 }; 64 62 65 63 class SegmentedString { 66 64 public: 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) {} 70 75 SegmentedString(const SegmentedString&); 71 76 … … 77 82 void prepend(const SegmentedString &); 78 83 79 void push( QChar c) {80 if (!m_pushedChar1 .unicode()) {84 void push(UChar c) { 85 if (!m_pushedChar1) { 81 86 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; 83 88 } else { 84 assert(!m_pushedChar2 .unicode());89 assert(!m_pushedChar2); 85 90 m_pushedChar2 = c; 86 91 } … … 91 96 92 97 void advance() { 93 if (m_pushedChar1 .unicode()) {98 if (m_pushedChar1) { 94 99 m_pushedChar1 = m_pushedChar2; 95 100 m_pushedChar2 = 0; … … 99 104 advanceSubstring(); 100 105 } 101 m_currentChar = m_pushedChar1 .unicode()? &m_pushedChar1 : m_currentString.m_current;106 m_currentChar = m_pushedChar1 ? &m_pushedChar1 : m_currentString.m_current; 102 107 } 103 108 104 bool escaped() const { return m_pushedChar1 .unicode(); }109 bool escaped() const { return m_pushedChar1; } 105 110 106 111 int lineCount() const { return m_lines; } … … 110 115 111 116 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(); } 114 119 115 120 private: … … 118 123 119 124 void advanceSubstring(); 120 const QChar *current() const { return m_currentChar; }125 const UChar* current() const { return m_currentChar; } 121 126 122 QChar m_pushedChar1;123 QChar m_pushedChar2;127 UChar m_pushedChar1; 128 UChar m_pushedChar2; 124 129 SegmentedSubstring m_currentString; 125 const QChar *m_currentChar;130 const UChar* m_currentChar; 126 131 DeprecatedValueList<SegmentedSubstring> m_substrings; 127 132 int m_lines; -
trunk/WebCore/platform/StreamingTextDecoder.cpp
r14256 r14273 45 45 static const UChar replacementCharacter = 0xFFFD; 46 46 static const UChar BOM = 0xFEFF; 47 static const int ConversionBufferSize = 16384;47 static const size_t ConversionBufferSize = 16384; 48 48 49 49 static UConverter* cachedConverterICU; … … 60 60 } 61 61 62 DeprecatedString StreamingTextDecoder::convertUTF16(const unsigned char *s, int length)62 DeprecatedString StreamingTextDecoder::convertUTF16(const unsigned char* s, int length) 63 63 { 64 64 ASSERT(m_numBufferedBytes == 0 || m_numBufferedBytes == 1); 65 65 66 const unsigned char *p = s;67 unsignedlen = length;66 const unsigned char* p = s; 67 size_t len = length; 68 68 69 69 DeprecatedString result(""); … … 80 80 81 81 if (c) 82 result.append(reinterpret_cast<QChar 82 result.append(reinterpret_cast<QChar*>(&c), 1); 83 83 84 84 m_numBufferedBytes = 0; … … 89 89 while (len > 1) { 90 90 UChar buffer[ConversionBufferSize]; 91 int runLength = min(len / 2, (unsigned)(sizeof(buffer) / sizeof(buffer[0])));91 int runLength = min(len / 2, ConversionBufferSize); 92 92 int bufferLength = 0; 93 93 if (m_littleEndian) { … … 95 95 UChar c = p[0] | (p[1] << 8); 96 96 p += 2; 97 if (c && c!= BOM)97 if (c != BOM) 98 98 buffer[bufferLength++] = c; 99 99 } … … 102 102 UChar c = (p[0] << 8) | p[1]; 103 103 p += 2; 104 if (c && c!= BOM)104 if (c != BOM) 105 105 buffer[bufferLength++] = c; 106 106 } 107 107 } 108 result.append(reinterpret_cast<QChar 108 result.append(reinterpret_cast<QChar*>(buffer), bufferLength); 109 109 len -= runLength * 2; 110 110 } … … 119 119 } 120 120 121 bool 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 121 150 static inline TextEncoding effectiveEncoding(const TextEncoding& encoding) 122 151 { … … 127 156 } 128 157 129 UErrorCodeStreamingTextDecoder::createICUConverter()158 void StreamingTextDecoder::createICUConverter() 130 159 { 131 160 TextEncoding encoding = effectiveEncoding(m_encoding); … … 142 171 ASSERT(!m_converterICU); 143 172 m_converterICU = ucnv_open(encodingName, &err); 173 #if !LOG_DISABLED 144 174 if (err == U_AMBIGUOUS_ALIAS_WARNING) 145 175 LOG_ERROR("ICU ambiguous alias warning for encoding: %s", encodingName); 146 147 if (!m_converterICU) { 176 if (!m_converterICU) 148 177 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 } 154 180 } 155 181 … … 163 189 } 164 190 165 void StreamingTextDecoder::appendOmittingUnwanted(DeprecatedString &s, const UChar *characters, int byteCount)191 void StreamingTextDecoder::appendOmittingUnwanted(DeprecatedString& s, const UChar* characters, int byteCount) 166 192 { 167 193 ASSERT(byteCount % sizeof(UChar) == 0); … … 171 197 if (unwanted(characters[i])) { 172 198 if (start != i) 173 s.append(reinterpret_cast<const QChar 199 s.append(reinterpret_cast<const QChar*>(&characters[start]), i - start); 174 200 start = i + 1; 175 201 } 176 202 } 177 203 if (start != characterCount) 178 s.append(reinterpret_cast<const QChar 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 207 DeprecatedString StreamingTextDecoder::convertUsingICU(const unsigned char* chs, int len, bool flush) 182 208 { 183 209 // 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 } 188 215 189 216 DeprecatedString result(""); … … 191 218 192 219 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; 196 223 UErrorCode err; 197 224 198 225 do { 199 UChar *target = buffer;200 const UChar *targetLimit = target + ConversionBufferSize;226 UChar* target = buffer; 227 const UChar* targetLimit = target + ConversionBufferSize; 201 228 err = U_ZERO_ERROR; 202 229 ucnv_toUnicode(m_converterICU, &target, targetLimit, &source, sourceLimit, offsets, flush, &err); 203 230 int count = target - buffer; 204 appendOmittingUnwanted(result, reinterpret_cast<const UChar 231 appendOmittingUnwanted(result, reinterpret_cast<const UChar*>(buffer), count * sizeof(UChar)); 205 232 } while (err == U_BUFFER_OVERFLOW_ERROR); 206 233 … … 216 243 return DeprecatedString(); 217 244 } 218 245 219 246 return result; 220 247 } 221 248 222 DeprecatedString StreamingTextDecoder::convert(const unsigned char *chs, int len, bool flush) 223 { 249 DeprecatedString 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 224 278 //#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:231 279 #if PARTIAL_CHARACTER_HANDLING_TEST_CHUNK_SIZE 232 233 234 235 236 237 238 239 240 241 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; 242 290 #else 243 291 return convertUsingICU(chs, len, flush); 244 292 #endif 245 } 246 ASSERT_NOT_REACHED(); 247 return DeprecatedString(); 248 } 249 250 DeprecatedString StreamingTextDecoder::toUnicode(const char *chs, int len, bool flush) 293 } 294 295 DeprecatedString StreamingTextDecoder::toUnicode(const char* chs, int len, bool flush) 251 296 { 252 297 ASSERT_ARG(len, len >= 0); … … 266 311 int buf1Len = numBufferedBytes; 267 312 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); 270 315 unsigned char c1 = buf1Len ? (--buf1Len, *buf1++) : buf2Len ? (--buf2Len, *buf2++) : 0; 271 316 unsigned char c2 = buf1Len ? (--buf1Len, *buf1++) : buf2Len ? (--buf2Len, *buf2++) : 0; -
trunk/WebCore/platform/StreamingTextDecoder.h
r14256 r14273 38 38 StreamingTextDecoder(const TextEncoding&); 39 39 ~StreamingTextDecoder(); 40 40 41 41 DeprecatedString toUnicode(const char* chs, int len, bool flush = false); 42 42 43 43 private: 44 DeprecatedString convert(const char* chs, int len, bool flush)44 DeprecatedString convert(const char* chs, int len, bool flush) 45 45 { return convert(reinterpret_cast<const unsigned char*>(chs), len, flush); } 46 46 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();52 47 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); 54 55 55 56 TextEncoding m_encoding; -
trunk/WebCore/platform/String.cpp
r14256 r14273 24 24 #include "PlatformString.h" 25 25 26 #include "DeprecatedString.h" 26 27 #include <kjs/identifier.h> 27 28 #include <wtf/Vector.h> 28 29 #include <stdarg.h> 29 30 30 using namespace KJS; 31 using KJS::Identifier; 32 using KJS::UString; 31 33 32 34 namespace WebCore { 33 35 34 String::String(const QChar* str, unsigned len)36 String::String(const UChar* str, unsigned len) 35 37 { 36 38 if (!str) … … 51 53 m_impl = StringImpl::empty(); 52 54 else 53 m_impl = new StringImpl( str.unicode(), str.length());55 m_impl = new StringImpl(reinterpret_cast<const UChar*>(str.unicode()), str.length()); 54 56 } 55 57 … … 77 79 } 78 80 79 String& String::operator+=(const String &str)81 void String::append(const String &str) 80 82 { 81 83 if (str.m_impl) { … … 83 85 // ### FIXME!!! 84 86 m_impl = str.m_impl; 85 return *this;87 return; 86 88 } 87 89 m_impl = m_impl->copy(); 88 90 m_impl->append(str.m_impl.get()); 89 91 } 90 return *this;91 92 } 92 93 … … 112 113 } 113 114 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 134 115 void String::insert(const String& str, unsigned pos) 135 116 { … … 140 121 } 141 122 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); 123 UChar String::operator[](unsigned i) const 124 { 125 if (!m_impl || i >= m_impl->length()) 126 return 0; 127 return m_impl->characters()[i]; 148 128 } 149 129 … … 195 175 } 196 176 177 String String::foldCase() const 178 { 179 if (!m_impl) 180 return String(); 181 return m_impl->foldCase(); 182 } 183 197 184 bool String::percentage(int& result) const 198 185 { … … 200 187 return false; 201 188 202 if ( *(m_impl->unicode()+m_impl->length()-1)!= '%')189 if ((*m_impl)[m_impl->length() - 1] != '%') 203 190 return false; 204 191 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(); 206 193 return true; 207 194 } 208 195 209 const QChar* String::unicode() const196 const UChar* String::characters() const 210 197 { 211 198 if (!m_impl) 212 199 return 0; 213 return m_impl-> unicode();200 return m_impl->characters(); 214 201 } 215 202 … … 218 205 if (!m_impl) 219 206 return DeprecatedString::null; 220 if (!m_impl-> unicode())207 if (!m_impl->characters()) 221 208 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()); 223 210 } 224 211 … … 230 217 Vector<char, 256> buffer; 231 218 #if PLATFORM(WIN_OS) 232 // Windows v nsprintf does not return the expected size on overflow219 // Windows vsnprintf does not return the expected size on overflow 233 220 // So we just have to keep looping until our vsprintf call works! 234 221 int result = 0; … … 237 224 buffer.resize(buffer.capacity() * 2); 238 225 result = vsnprintf(buffer.data(), buffer.capacity(), format, args); 239 // Windows v nsprintf returns -1 both for all errors. There is no226 // Windows vsnprintf returns -1 for both errors. Since there is no 240 227 // way to distinguish between "not enough room" and "invalid format" 241 228 // we just keep trying until we hit an arbitrary size and then stop. … … 309 296 bool String::isEmpty() const 310 297 { 311 return (!m_impl || m_impl->length() == 0);298 return !m_impl || !m_impl->length(); 312 299 } 313 300 … … 334 321 if (l != b.length()) 335 322 return false; 336 if (!memcmp(a. unicode(), b.unicode(), l * sizeof(QChar)))323 if (!memcmp(a.characters(), b.unicode(), l * sizeof(UChar))) 337 324 return true; 338 325 return false; … … 347 334 m_impl = StringImpl::empty(); 348 335 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()); 350 337 } 351 338 … … 358 345 m_impl = StringImpl::empty(); 359 346 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()); 361 348 } 362 349 … … 365 352 if (!m_impl) 366 353 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()); 368 355 } 369 356 … … 372 359 if (!m_impl) 373 360 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 25 25 #include "PlatformString.h" 26 26 #include <wtf/HashTraits.h> 27 #include <unicode/uchar.h> 28 #include <unicode/ustring.h> 27 29 28 30 namespace WTF { … … 44 46 return false; 45 47 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()); 48 50 49 51 unsigned halfLength = aLength >> 1; … … 69 71 { 70 72 unsigned l = str->length(); 71 const QChar* s = str->unicode();73 const UChar* s = str->characters(); 72 74 uint32_t hash = PHI; 73 75 uint32_t tmp; … … 78 80 // Main loop 79 81 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; 82 84 hash = (hash << 16) ^ tmp; 83 85 s += 2; … … 87 89 // Handle end case 88 90 if (rem) { 89 hash += s[0].lower().unicode();91 hash += u_foldCase(s[0], U_FOLD_CASE_DEFAULT); 90 92 hash ^= hash << 11; 91 93 hash += hash >> 17; … … 124 126 // Main loop 125 127 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; 128 130 hash = (hash << 16) ^ tmp; 129 131 s += 2; … … 133 135 // Handle end case 134 136 if (rem) { 135 hash += QChar(s[0]).lower().unicode();137 hash += u_foldCase(s[0], U_FOLD_CASE_DEFAULT); 136 138 hash ^= hash << 11; 137 139 hash += hash >> 17; … … 156 158 static bool equal(const WebCore::StringImpl* a, const WebCore::StringImpl* b) 157 159 { 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; 160 164 unsigned length = a->length(); 161 165 if (length != b->length()) 162 166 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*> { }; 174 172 175 173 template<> struct StrHash<RefPtr<WebCore::StringImpl> > { -
trunk/WebCore/platform/StringImpl.cpp
r14256 r14273 29 29 30 30 #include "AtomicString.h" 31 #include "DeprecatedString.h" 31 32 #include "Length.h" 32 33 #include "StringHash.h" … … 34 35 #include <wtf/Assertions.h> 35 36 #include <unicode/ubrk.h> 37 #include <unicode/ustring.h> 36 38 #include <assert.h> 37 39 38 using namespace KJS;39 40 using namespace WTF; 40 41 42 using KJS::Identifier; 43 using KJS::UString; 44 41 45 namespace WebCore { 42 46 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) 47 const UChar nonBreakingSpace = 0xA0; 48 49 static inline UChar* newUCharVector(unsigned n) 50 { 51 return static_cast<UChar*>(fastMalloc(sizeof(UChar) * n)); 52 } 53 54 static inline void deleteUCharVector(UChar* p) 49 55 { 50 56 fastFree(p); … … 60 66 StringImpl::StringImpl(const DeprecatedString& str) 61 67 { 62 init WithQChar(str.unicode(), str.length());63 } 64 65 StringImpl::StringImpl(const QChar* str, unsigned len)66 { 67 init WithQChar(str, len);68 init(reinterpret_cast<const UChar*>(str.unicode()), str.length()); 69 } 70 71 StringImpl::StringImpl(const UChar* str, unsigned len) 72 { 73 init(str, len); 68 74 } 69 75 70 76 StringImpl::StringImpl(const char* str) 71 77 { 72 init WithChar(str, strlen(str));78 init(str, strlen(str)); 73 79 } 74 80 75 81 StringImpl::StringImpl(const char* str, unsigned len) 76 82 { 77 init WithChar(str, len);78 } 79 80 void StringImpl::init WithChar(const char* str, unsigned len)83 init(str, len); 84 } 85 86 void StringImpl::init(const char* str, unsigned len) 81 87 { 82 88 m_hash = 0; … … 88 94 } 89 95 90 m_data = new QCharVector(m_length);96 m_data = newUCharVector(m_length); 91 97 int i = m_length; 92 QChar* ptr = m_data;98 UChar* ptr = m_data; 93 99 while (i--) 94 100 *ptr++ = *str++; 95 101 } 96 102 97 void StringImpl::init WithQChar(const QChar* str, unsigned len)103 void StringImpl::init(const UChar* str, unsigned len) 98 104 { 99 105 m_hash = 0; … … 105 111 } 106 112 107 m_data = new QCharVector(len);108 memcpy(m_data, str, len * sizeof( QChar));113 m_data = newUCharVector(len); 114 memcpy(m_data, str, len * sizeof(UChar)); 109 115 } 110 116 … … 113 119 if (m_inTable) 114 120 AtomicString::remove(this); 115 delete QCharVector(m_data);121 deleteUCharVector(m_data); 116 122 } 117 123 … … 122 128 { 123 129 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 delete QCharVector(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); 128 134 m_data = c; 129 135 m_length = newlen; … … 140 146 if (str && str->m_length != 0) { 141 147 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 delete QCharVector(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); 147 153 m_data = c; 148 154 m_length = newlen; … … 156 162 return; 157 163 int nl = len < 1 ? 1 : len; 158 QChar* c = newQCharVector(nl);159 memcpy(c, m_data, nl *sizeof(QChar));160 delete QCharVector(m_data);164 UChar* c = newUCharVector(nl); 165 memcpy(c, m_data, nl * sizeof(UChar)); 166 deleteUCharVector(m_data); 161 167 m_data = c; 162 168 m_length = len; … … 168 174 if (len <= 0) 169 175 return; 170 if (pos >= m_length 176 if (pos >= m_length) 171 177 return; 172 178 if ((unsigned)len > m_length - pos) … … 174 180 175 181 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 delete QCharVector(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); 180 186 m_data = c; 181 187 m_length = newLen; … … 188 194 189 195 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)); 192 198 193 199 StringImpl* str = new StringImpl(m_data + pos, newLen); … … 205 211 if (!m_data) 206 212 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])) 215 218 return false; 216 }217 219 return true; 218 220 } … … 227 229 } 228 230 229 static Length parseLength(const QChar* m_data, unsigned int m_length)231 static Length parseLength(const UChar* m_data, unsigned int m_length) 230 232 { 231 233 if (m_length == 0) … … 233 235 234 236 unsigned i = 0; 235 while (i < m_length && m_data[i].isSpace())237 while (i < m_length && QChar(m_data[i]).isSpace()) 236 238 ++i; 237 239 if (i < m_length && (m_data[i] == '+' || m_data[i] == '-')) 238 240 ++i; 239 while (i < m_length && m_data[i].isDigit())241 while (i < m_length && u_isdigit(m_data[i])) 240 242 ++i; 241 243 242 244 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); 244 246 245 247 /* 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] == '.')) 247 249 ++i; 248 250 249 251 /* 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()) 251 253 ++i; 252 254 253 255 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 == '%') 260 259 return Length(r, Percent); 261 262 if (*next == '*') 260 if (next == '*') 263 261 return Length(r, Relative); 264 262 } … … 266 264 } else { 267 265 if (i < m_length) { 268 const QChar* next = m_data + i; 269 270 if (*next == '*') 266 UChar next = m_data[i]; 267 if (next == '*') 271 268 return Length(1, Relative); 272 273 if (*next == '%') 269 if (next == '%') 274 270 return Length(1, Relative); 275 271 } … … 285 281 Length* StringImpl::toCoordsArray(int& len) const 286 282 { 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] = ' '; 293 288 else 294 289 spacified[i] = cc; 295 290 } 296 DeprecatedString str( spacified, m_length);297 delete QCharVector(spacified);291 DeprecatedString str(reinterpret_cast<const QChar*>(spacified), m_length); 292 deleteUCharVector(spacified); 298 293 299 294 str = str.simplifyWhiteSpace(); … … 307 302 308 303 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); 310 305 pos = pos2+1; 311 306 } 312 r[i] = parseLength( str.unicode() + pos, str.length()-pos);307 r[i] = parseLength(reinterpret_cast<const UChar*>(str.unicode()) + pos, str.length() - pos); 313 308 314 309 return r; … … 321 316 return 0; 322 317 } 323 DeprecatedString str( m_data, m_length);318 DeprecatedString str(reinterpret_cast<const QChar*>(m_data), m_length); 324 319 str = str.simplifyWhiteSpace(); 325 320 … … 331 326 int pos2; 332 327 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); 335 330 pos = pos2+1; 336 331 } … … 338 333 /* IE Quirk: If the last comma is the last char skip it and reduce len by one */ 339 334 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); 341 336 else 342 337 len--; … … 347 342 bool StringImpl::isLower() const 348 343 { 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; 354 360 } 355 361 … … 360 366 return c; 361 367 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 } 368 405 return c; 369 406 } … … 374 411 if (!m_length) 375 412 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 } 383 424 return c; 384 425 } 385 426 386 static UBreakIterator* getWordBreakIterator(const QChar* string, int length) 427 StringImpl* 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 446 static UBreakIterator* getWordBreakIterator(const UChar* string, int length) 387 447 { 388 448 // The locale is currently ignored when determining character cluster breaks. … … 401 461 status = U_ZERO_ERROR; 402 462 ubrk_setText(iterator, reinterpret_cast<const ::UChar*>(string), length, &status); 403 if ( status != U_ZERO_ERROR)463 if (U_FAILURE(status)) 404 464 return 0; 405 465 … … 407 467 } 408 468 409 StringImpl* StringImpl::capitalize( QChar previous) const469 StringImpl* StringImpl::capitalize(UChar previous) const 410 470 { 411 471 StringImpl* capitalizedString = new StringImpl; … … 413 473 return capitalizedString; 414 474 415 QChar* stringWithPrevious = newQCharVector(m_length + 1);475 UChar* stringWithPrevious = newUCharVector(m_length + 1); 416 476 stringWithPrevious[0] = previous; 417 const char nonBreakingSpace = '\xa0';418 477 for (unsigned i = 1; i < m_length + 1; i++) { 419 478 // Replace   with a real space since ICU no longer treats   as a word separator. … … 423 482 stringWithPrevious[i] = m_data[i - 1]; 424 483 } 425 484 426 485 UBreakIterator* boundary = getWordBreakIterator(stringWithPrevious, m_length + 1); 427 486 if (!boundary) { 428 delete QCharVector(stringWithPrevious);487 deleteUCharVector(stringWithPrevious); 429 488 return capitalizedString; 430 489 } 431 490 432 capitalizedString->m_data = new QCharVector(m_length);491 capitalizedString->m_data = newUCharVector(m_length); 433 492 capitalizedString->m_length = m_length; 434 493 … … 437 496 for (endOfWord = ubrk_next(boundary); endOfWord != UBRK_DONE; startOfWord = endOfWord, endOfWord = ubrk_next(boundary)) { 438 497 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]); 440 499 for (int i = startOfWord + 1; i < endOfWord; i++) 441 500 capitalizedString->m_data[i - 1] = stringWithPrevious[i]; 442 501 } 443 502 444 delete QCharVector(stringWithPrevious);503 deleteUCharVector(stringWithPrevious); 445 504 return capitalizedString; 446 505 } … … 451 510 452 511 // 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()) 455 514 break; 456 }457 515 458 516 // Allow sign. … … 461 519 462 520 // 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])) 465 523 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 528 static 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) 476 534 return false; 477 a++; b++;478 535 } 479 536 return true; 480 537 } 481 538 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)) 539 static 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)) 487 545 return false; 488 a++; b++;489 546 } 490 547 return true; 491 548 } 492 549 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; 550 static 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; 502 554 } 503 555 … … 524 576 int chsLengthMinusOne = chsLength - 1; 525 577 526 const QChar* ptr = m_data + index - 1;578 const UChar* ptr = m_data + index - 1; 527 579 if (caseSensitive) { 528 QChar c = *chs;580 UChar c = *chs; 529 581 do { 530 582 if (*++ptr == c && equal(ptr + 1, chsPlusOne, chsLengthMinusOne)) … … 532 584 } while (--n); 533 585 } else { 534 int lc = tolower((unsigned char)*chs);586 UChar lc = u_foldCase(*chs, U_FOLD_CASE_DEFAULT); 535 587 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)) 537 590 return m_length - chsLength - n + 1; 538 591 } while (--n); … … 542 595 } 543 596 544 int StringImpl::find(const QChar c, int start) const597 int StringImpl::find(const UChar c, int start) const 545 598 { 546 599 unsigned int index = start; … … 566 619 or ucstrnicmp. 567 620 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. 570 622 */ 571 623 ASSERT(str); … … 580 632 return -1; 581 633 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; 584 636 unsigned hthis = 0; 585 637 unsigned hstr = 0; 586 638 if (caseSensitive) { 587 639 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]; 590 642 } 591 643 int i = 0; 592 644 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) 594 646 return index + i; 595 647 if (i == delta) 596 648 return -1; 597 hthis += uthis[i + lstr] .unicode();598 hthis -= uthis[i] .unicode();649 hthis += uthis[i + lstr]; 650 hthis -= uthis[i]; 599 651 i++; 600 652 } 601 653 } else { 602 654 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]); 605 657 } 606 658 int i = 0; 607 659 while (1) { 608 if (hthis == hstr && equal CaseInsensitive(uthis + i, ustr, lstr))660 if (hthis == hstr && equalIgnoringCase(uthis + i, ustr, lstr)) 609 661 return index + i; 610 662 if (i == delta) 611 663 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]); 614 666 i++; 615 667 } … … 626 678 } 627 679 628 StringImpl* StringImpl::replace( QChar oldC, QChar newC)680 StringImpl* StringImpl::replace(UChar oldC, UChar newC) 629 681 { 630 682 if (oldC == newC) … … 639 691 StringImpl* c = new StringImpl; 640 692 641 c->m_data = new QCharVector(m_length);693 c->m_data = newUCharVector(m_length); 642 694 c->m_length = m_length; 643 695 644 696 for (i = 0; i != m_length; ++i) { 645 QChar ch = m_data[i];697 UChar ch = m_data[i]; 646 698 if (ch == oldC) 647 699 ch = newC; … … 660 712 } 661 713 662 StringImpl* StringImpl::replace( QChar pattern, const StringImpl* str)714 StringImpl* StringImpl::replace(UChar pattern, const StringImpl* str) 663 715 { 664 716 int slen = str ? str->length() : 0; … … 685 737 686 738 unsigned length = a->length(); 687 const QChar* as = a->unicode();739 const UChar* as = a->characters(); 688 740 for (unsigned i = 0; i != length; ++i) { 689 charc = b[i];690 if (! c)741 unsigned char bc = b[i]; 742 if (!bc) 691 743 return false; 692 if (as[i] != c)744 if (as[i] != bc) 693 745 return false; 694 746 } … … 697 749 } 698 750 699 bool equal(const char* a, const StringImpl* b) 751 bool equalIgnoringCase(const StringImpl* a, const StringImpl* b) 752 { 753 return CaseInsensitiveHash::equal(a, b); 754 } 755 756 bool equalIgnoringCase(const StringImpl* a, const char* b) 700 757 { 701 758 if (!a) … … 704 761 return !a; 705 762 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; 708 769 for (unsigned i = 0; i != length; ++i) { 709 char c = a[i];710 if (! c)770 unsigned char bc = b[i]; 771 if (!bc) 711 772 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]; 762 787 } 763 788 … … 768 793 // Paul Hsieh's SuperFastHash 769 794 // http://www.azillionmonkeys.com/qed/hash.html 770 unsigned StringImpl::computeHash(const QChar* m_data, unsigned len)795 unsigned StringImpl::computeHash(const UChar* m_data, unsigned len) 771 796 { 772 797 unsigned m_length = len; … … 779 804 // Main loop 780 805 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; 783 808 hash = (hash << 16) ^ tmp; 784 809 m_data += 2; … … 788 813 // Handle end case 789 814 if (rem) { 790 hash += m_data[0] .unicode();815 hash += m_data[0]; 791 816 hash ^= hash << 11; 792 817 hash += hash >> 17; … … 861 886 char* p = buffer; 862 887 for (unsigned i = 0; i != m_length; ++i) { 863 unsigned short c = m_data[i].unicode();888 UChar c = m_data[i]; 864 889 if (c >= 0x20 && c < 0x7F) 865 890 *p++ = c; … … 873 898 StringImpl::StringImpl(const Identifier& str) 874 899 { 875 init WithQChar(reinterpret_cast<const QChar*>(str.data()), str.size());900 init(reinterpret_cast<const UChar*>(str.data()), str.size()); 876 901 } 877 902 878 903 StringImpl::StringImpl(const UString& str) 879 904 { 880 init WithQChar(reinterpret_cast<const QChar*>(str.data()), str.size());905 init(reinterpret_cast<const UChar*>(str.data()), str.size()); 881 906 } 882 907 -
trunk/WebCore/platform/StringImpl.h
r14256 r14273 25 25 #define StringImpl_h 26 26 27 #include "DeprecatedString.h" 27 #include "Shared.h" 28 #include <kjs/identifier.h> 28 29 #include <wtf/Forward.h> 29 30 #include <wtf/Noncopyable.h> 31 #include <unicode/umachine.h> 30 32 #include <limits.h> 31 33 … … 34 36 #endif 35 37 38 class DeprecatedString; 39 36 40 namespace WebCore { 37 41 38 42 class AtomicString; 39 struct QCharBufferTranslator;43 struct UCharBufferTranslator; 40 44 struct CStringTranslator; 41 45 struct Length; 42 46 43 class StringImpl : public Shared<StringImpl>, Noncopyable 44 { 47 class StringImpl : public Shared<StringImpl>, Noncopyable { 45 48 private: 46 49 struct WithOneRef { }; 47 50 StringImpl(WithOneRef) : m_length(0), m_data(0), m_hash(0), m_inTable(false) { ref(); } 48 void init WithChar(const char*, unsigned len);49 void init WithQChar(const QChar*, unsigned len);51 void init(const char*, unsigned len); 52 void init(const UChar*, unsigned len); 50 53 51 54 protected: 52 55 StringImpl() : m_length(0), m_data(0), m_hash(0), m_inTable(false) { } 53 56 public: 54 StringImpl(const DeprecatedString&); 57 StringImpl(const UChar*, unsigned len); 58 StringImpl(const char*, unsigned len); 59 StringImpl(const char*); 55 60 StringImpl(const KJS::Identifier&); 56 61 StringImpl(const KJS::UString&); 57 StringImpl(const QChar*, unsigned len);58 StringImpl(const char*);59 StringImpl(const char*, unsigned len);60 62 ~StringImpl(); 61 63 62 const QChar* unicode() const { return m_data; }64 const UChar* characters() const { return m_data; } 63 65 unsigned length() const { return m_length; } 64 66 65 67 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); 67 69 static unsigned computeHash(const char*); 68 70 … … 71 73 void truncate(int len); 72 74 void remove(unsigned pos, int len = 1); 73 75 74 76 StringImpl* split(unsigned pos); 75 77 StringImpl* copy() const { return new StringImpl(m_data, m_length); } … … 77 79 StringImpl* substring(unsigned pos, unsigned len = UINT_MAX); 78 80 79 const QChar& operator[](int pos) const { return m_data[pos]; }81 UChar operator[](int pos) const { return m_data[pos]; } 80 82 81 83 Length toLength() const; 82 84 83 85 bool containsOnlyWhitespace() const; 84 86 bool containsOnlyWhitespace(unsigned from, unsigned len) const; 85 87 86 88 // ignores trailing garbage, unlike DeprecatedString 87 89 int toInt(bool* ok = 0) const; … … 92 94 StringImpl* lower() const; 93 95 StringImpl* upper() const; 94 StringImpl* capitalize(QChar previous) const; 96 StringImpl* capitalize(UChar previousCharacter) const; 97 StringImpl* foldCase() const; 95 98 96 99 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; 98 101 int find(const StringImpl*, int index, bool caseSensitive = true) const; 99 102 … … 102 105 103 106 // 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*); 106 109 StringImpl* replace(unsigned index, unsigned len, const StringImpl*); 107 110 … … 120 123 #endif 121 124 125 StringImpl(const DeprecatedString&); 126 122 127 private: 123 128 unsigned m_length; 124 QChar* m_data;129 UChar* m_data; 125 130 126 131 friend class AtomicString; 127 friend struct QCharBufferTranslator;132 friend struct UCharBufferTranslator; 128 133 friend struct CStringTranslator; 129 134 … … 134 139 bool equal(const StringImpl*, const StringImpl*); 135 140 bool equal(const StringImpl*, const char*); 136 bool equal(const char*, const StringImpl*); 141 inline bool equal(const char* a, const StringImpl* b) { return equal(b, a); } 137 142 138 143 bool equalIgnoringCase(const StringImpl*, const StringImpl*); 139 144 bool equalIgnoringCase(const StringImpl*, const char*); 140 bool equalIgnoringCase(const char*, const StringImpl*); 145 inline bool equalIgnoringCase(const char* a, const StringImpl* b) { return equalIgnoringCase(b, a); } 141 146 142 147 } -
trunk/WebCore/platform/TextBoundaries.h
r13187 r14273 27 27 #define TextBoundaries_h 28 28 29 #include <unicode/umachine.h> 30 29 31 // FIXME: Change clients to use ICU and remove these functions. 30 31 class QChar;32 32 33 33 namespace WebCore { 34 34 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); 37 37 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); 40 40 41 41 } -
trunk/WebCore/platform/TextEncoding.cpp
r14256 r14273 46 46 return charsetNameFromTextEncodingID(m_encodingID); 47 47 } 48 49 QChar TextEncoding::backslashAsCurrencySymbol() const 48 UChar TextEncoding::backslashAsCurrencySymbol() const 50 49 { 51 50 if (m_flags & BackslashIsYen) … … 129 128 // Encoding will change the yen sign back into a backslash. 130 129 DeprecatedString copy = qcs; 131 copy.replace( QChar('\\'), backslashAsCurrencySymbol());130 copy.replace('\\', backslashAsCurrencySymbol()); 132 131 133 132 UErrorCode err = U_ZERO_ERROR; -
trunk/WebCore/platform/TextEncoding.h
r13821 r14273 81 81 bool isJapanese() const { return m_flags & IsJapanese; } 82 82 83 QChar backslashAsCurrencySymbol() const;83 UChar backslashAsCurrencySymbol() const; 84 84 85 85 DeprecatedCString fromUnicode(const DeprecatedString&, bool allowEntities = false) const; -
trunk/WebCore/platform/mac/FontFamilyMac.mm
r13821 r14273 55 55 m_CFFamily = (CFStringRef)CFDictionaryGetValue(families, m_family.impl()); 56 56 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()); 58 58 CFDictionarySetValue(families, m_family.impl(), m_CFFamily); 59 59 CFRelease(m_CFFamily); -
trunk/WebCore/platform/mac/FontMac.mm
r14216 r14273 39 39 40 40 #import "IntRect.h" 41 42 using namespace std; 41 43 42 44 namespace WebCore { … … 103 105 104 106 IntRect 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, 106 108 bool rtl, bool visuallyOrdered, int from, int to) const 107 109 { 108 110 assert(m_fontList); 109 int len = std::min(slen - pos, l);111 int len = min(slen - pos, l); 110 112 111 113 CREATE_FAMILY_ARRAY(fontDescription(), families); … … 117 119 118 120 WebCoreTextRun run; 119 WebCoreInitializeTextRun(&run, (const UniChar *)(str+pos), len, from, to);121 WebCoreInitializeTextRun(&run, str + pos, len, from, to); 120 122 WebCoreTextStyle style; 121 123 WebCoreInitializeEmptyTextStyle(&style); … … 138 140 } 139 141 140 void Font::drawText(GraphicsContext* context, const IntPoint& point, int tabWidth, int xpos, const QChar* str, int len, int from, int to,142 void Font::drawText(GraphicsContext* context, const IntPoint& point, int tabWidth, int xpos, const UChar* str, int len, int from, int to, 141 143 int toAdd, TextDirection d, bool visuallyOrdered) const 142 144 { … … 151 153 152 154 WebCoreTextRun run; 153 WebCoreInitializeTextRun(&run, (const UniChar *)str, len, from, to);155 WebCoreInitializeTextRun(&run, str, len, from, to); 154 156 WebCoreTextStyle style; 155 157 WebCoreInitializeEmptyTextStyle(&style); … … 171 173 } 172 174 173 void Font::drawHighlightForText(GraphicsContext* context, const IntPoint& point, int h, int tabWidth, int xpos, const QChar* str,175 void Font::drawHighlightForText(GraphicsContext* context, const IntPoint& point, int h, int tabWidth, int xpos, const UChar* str, 174 176 int len, int from, int to, int toAdd, 175 177 TextDirection d, bool visuallyOrdered, const Color& backgroundColor) const … … 185 187 186 188 WebCoreTextRun run; 187 WebCoreInitializeTextRun(&run, (const UniChar *)str, len, from, to);189 WebCoreInitializeTextRun(&run, str, len, from, to); 188 190 WebCoreTextStyle style; 189 191 WebCoreInitializeEmptyTextStyle(&style); … … 223 225 } 224 226 225 float Font::floatWidth(const QChar* uchars, int slen, int pos, int len, int tabWidth, int xpos, bool runRounding) const227 float Font::floatWidth(const UChar* uchars, int slen, int pos, int len, int tabWidth, int xpos, bool runRounding) const 226 228 { 227 229 assert(m_fontList); … … 229 231 230 232 WebCoreTextRun run; 231 WebCoreInitializeTextRun(&run, (const UniChar *)uchars, slen, pos, pos+len);233 WebCoreInitializeTextRun(&run, uchars, slen, pos, pos + len); 232 234 233 235 WebCoreTextStyle style; … … 244 246 } 245 247 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) const248 int 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 247 249 { 248 250 assert(m_fontList); … … 250 252 251 253 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); 253 255 254 256 WebCoreTextStyle style; -
trunk/WebCore/platform/mac/TextBoundaries.mm
r13187 r14273 32 32 namespace WebCore { 33 33 34 void findWordBoundary(const QChar* chars, int len, int position, int* start, int* end)34 void findWordBoundary(const UChar* chars, int len, int position, int* start, int* end) 35 35 { 36 NSString* string = [[NSString alloc] initWithCharactersNoCopy:const_cast<unichar*>( reinterpret_cast<const unichar*>(chars))36 NSString* string = [[NSString alloc] initWithCharactersNoCopy:const_cast<unichar*>(chars) 37 37 length:len freeWhenDone:NO]; 38 38 NSAttributedString* attr = [[NSAttributedString alloc] initWithString:string]; … … 44 44 } 45 45 46 int findNextWordFromIndex(const QChar* chars, int len, int position, bool forward)46 int findNextWordFromIndex(const UChar* chars, int len, int position, bool forward) 47 47 { 48 NSString* string = [[NSString alloc] initWithCharactersNoCopy:const_cast<unichar*>( reinterpret_cast<const unichar*>(chars))48 NSString* string = [[NSString alloc] initWithCharactersNoCopy:const_cast<unichar*>(chars) 49 49 length:len freeWhenDone:NO]; 50 50 NSAttributedString* attr = [[NSAttributedString alloc] initWithString:string]; … … 100 100 } 101 101 102 void findSentenceBoundary(const QChar* chars, int len, int position, int* start, int* end)102 void findSentenceBoundary(const UChar* chars, int len, int position, int* start, int* end) 103 103 { 104 104 int startPos = 0; … … 106 106 107 107 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); 110 109 if (boundary && U_SUCCESS(status)) { 111 110 startPos = ubrk_preceding(boundary, position); … … 124 123 } 125 124 126 int findNextSentenceFromIndex(const QChar* chars, int len, int position, bool forward)125 int findNextSentenceFromIndex(const UChar* chars, int len, int position, bool forward) 127 126 { 128 127 int pos = 0; 129 128 130 129 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); 133 131 if (boundary && U_SUCCESS(status)) { 134 132 if (forward) { -
trunk/WebCore/platform/mac/TextEncodingMac.cpp
r14256 r14273 52 52 // Encoding will change the yen sign back into a backslash. 53 53 DeprecatedString copy = qcs; 54 copy.replace( QChar('\\'), backslashAsCurrencySymbol());54 copy.replace('\\', backslashAsCurrencySymbol()); 55 55 CFStringRef cfs = copy.getCFString(); 56 56 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 119 119 120 120 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, 122 122 m_toAdd, m_reversed, m_dirOverride, sPos, ePos); 123 123 if (r.x() > tx + m_x + m_width) … … 334 334 endPoint = m_truncation - m_start; 335 335 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, 337 337 m_toAdd, m_reversed ? RTL : LTR, m_dirOverride || styleToUse->visuallyOrdered()); 338 338 } else { … … 343 343 if (sPos >= ePos) 344 344 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, 346 346 m_toAdd, m_reversed ? RTL : LTR, m_dirOverride || styleToUse->visuallyOrdered()); 347 347 else { 348 348 if (sPos - 1 >= 0) 349 349 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, 351 351 m_toAdd, m_reversed ? RTL : LTR, m_dirOverride || styleToUse->visuallyOrdered(), 0, sPos); 352 352 if (ePos < m_start + m_len) 353 353 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, 355 355 m_toAdd, m_reversed ? RTL : LTR, m_dirOverride || styleToUse->visuallyOrdered(), ePos, -1); 356 356 } … … 367 367 selectionTextShadow->color); 368 368 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, 370 370 m_toAdd, m_reversed ? RTL : LTR, m_dirOverride || styleToUse->visuallyOrdered(), sPos, ePos); 371 371 if (selectionTextShadow) … … 452 452 p->addClip(IntRect(m_x + tx, y + ty, m_width, h)); 453 453 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, 455 455 m_toAdd, m_reversed ? RTL : LTR, m_dirOverride || style->visuallyOrdered(), sPos, ePos, c); 456 456 p->restore(); … … 476 476 int h = r->selectionHeight(); 477 477 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, 479 479 m_toAdd, m_reversed ? RTL : LTR, m_dirOverride || style->visuallyOrdered(), sPos, ePos, c); 480 480 p->restore(); … … 575 575 576 576 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, 578 578 m_toAdd, m_reversed ? RTL : LTR, m_dirOverride || style->visuallyOrdered(), sPos, ePos, yellow); 579 579 pt->restore(); … … 689 689 RenderStyle *style = text->style(m_firstLine); 690 690 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, 692 692 m_toAdd, text->tabWidth(), textPos(), _x - m_x, 693 693 m_reversed ? RTL : LTR, m_dirOverride || style->visuallyOrdered(), includePartialGlyphs); … … 704 704 int to = m_reversed ? m_len : offset - m_start; 705 705 // 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, 707 707 m_toAdd, m_reversed, m_dirOverride, from, to).right(); 708 708 } -
trunk/WebCore/rendering/RenderBlock.cpp
r14172 r14273 2832 2832 RenderText* t = static_cast<RenderText *>(trailingSpaceChild); 2833 2833 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); 2836 2836 inlineMax -= spaceWidth; 2837 2837 if (inlineMin > inlineMax) … … 3398 3398 3399 3399 // 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]))) 3401 3401 length++; 3402 3402 -
trunk/WebCore/rendering/RenderFlexibleBox.cpp
r13859 r14273 729 729 RenderBlock* blockChild = static_cast<RenderBlock*>(child); 730 730 int lineCount = blockChild->lineCount(); 731 if (lineCount <= numVisibleLines) continue; 731 if (lineCount <= numVisibleLines) 732 continue; 732 733 733 734 int newHeight = blockChild->heightForLineCount(numVisibleLines); 734 if (newHeight == child->height()) continue; 735 if (newHeight == child->height()) 736 continue; 735 737 736 738 child->setChildNeedsLayout(true); … … 742 744 743 745 // FIXME: For now don't support RTL. 744 if (style()->direction() != LTR) continue; 746 if (style()->direction() != LTR) 747 continue; 745 748 746 749 // Get the last line 747 750 RootInlineBox* lastLine = blockChild->lineAtIndex(lineCount-1); 748 if (!lastLine) continue; 751 if (!lastLine) 752 continue; 749 753 750 754 // See if the last item is an anchor 751 755 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; 755 762 756 763 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, ' ' }; 760 768 static AtomicString ellipsisAndSpaceStr(ellipsisAndSpace, 2); 769 761 770 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); 763 772 764 773 // Get ellipsis width + " " + anchor width … … 770 779 771 780 // 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; 774 785 775 786 int blockEdge = destBlock->rightOffset(lastVisibleLine->yPos()); -
trunk/WebCore/rendering/RenderImage.cpp
r14102 r14273 105 105 if (!m_altText.isEmpty()) { 106 106 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)); 108 108 ih = max(ih, min(font.height(), 256)); 109 109 } … … 238 238 if (!m_altText.isEmpty()) { 239 239 DeprecatedString text = m_altText.deprecatedString(); 240 text.replace( QChar('\\'), backslashAsCurrencySymbol());240 text.replace('\\', backslashAsCurrencySymbol()); 241 241 p->setFont(style()->font()); 242 242 p->setPen(style()->color()); … … 248 248 // Only draw the alt text if it'll fit within the content box, 249 249 // 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()); 251 251 if (errorPictureDrawn) { 252 252 if (usableWidth >= textWidth && font.height() <= imageY) 253 p->drawText(IntPoint(ax, ay + ascent), 0,text);253 p->drawText(IntPoint(ax, ay + ascent), text); 254 254 } else if (usableWidth >= textWidth && cHeight >= font.height()) 255 p->drawText(IntPoint(ax, ay + ascent), 0,text);255 p->drawText(IntPoint(ax, ay + ascent), text); 256 256 } 257 257 } -
trunk/WebCore/rendering/RenderObject.cpp
r14267 r14273 2497 2497 } 2498 2498 2499 QChar RenderObject::backslashAsCurrencySymbol() const2499 UChar RenderObject::backslashAsCurrencySymbol() const 2500 2500 { 2501 2501 if (Node *node = element()) -
trunk/WebCore/rendering/RenderObject.h
r14013 r14273 845 845 846 846 // Convenience, to avoid repeating the code to dig down to get this. 847 QChar backslashAsCurrencySymbol() const;847 UChar backslashAsCurrencySymbol() const; 848 848 849 849 virtual int caretMinOffset() const; -
trunk/WebCore/rendering/RenderText.cpp
r14256 r14273 59 59 60 60 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); 62 62 if (status != U_ZERO_ERROR) 63 63 return 0; … … 102 102 if (str) 103 103 str = str->replace('\\', backslashAsCurrencySymbol()); 104 KHTMLAssert(!str || !str->length() || str-> unicode());104 KHTMLAssert(!str || !str->length() || str->characters()); 105 105 } 106 106 … … 437 437 unsigned i; 438 438 for (i = 0; i < str->length(); i++) 439 if ((*str)[i] .unicode() >=0x7f) {439 if ((*str)[i] > 0x7f) { 440 440 m_allAscii = false; 441 441 return m_allAscii; … … 457 457 void RenderText::cacheWidths() 458 458 { 459 const Font *f = font(false);459 const Font* f = font(false); 460 460 if (shouldUseMonospaceCache(f)) { 461 QChar c(' ');461 const UChar c = ' '; 462 462 m_monospaceCharacterWidth = (int)f->floatWidth(&c, 1, 0, 1, 0, 0); 463 463 } else { … … 466 466 } 467 467 468 ALWAYS_INLINE int RenderText::widthFromCache(const Font *f, int start, int len, int tabWidth, int xpos) const468 ALWAYS_INLINE int RenderText::widthFromCache(const Font* f, int start, int len, int tabWidth, int xpos) const 469 469 { 470 470 if (m_monospaceCharacterWidth != 0) { 471 471 int i, w = 0; 472 472 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) 477 477 w += tabWidth - ((xpos + w) % tabWidth); 478 }else478 else 479 479 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()) 481 481 w += f->wordSpacing(); 482 482 } … … 486 486 } 487 487 488 return f->width(str-> unicode(), str->length(), start, len, tabWidth, xpos);488 return f->width(str->characters(), str->length(), start, len, tabWidth, xpos); 489 489 } 490 490 … … 524 524 if (stripFrontSpaces && ((*str)[0] == ' ' || ((*str)[0] == '\n' && !style()->preserveNewline()) || (*str)[0] == '\t')) { 525 525 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); 528 528 maxW -= spaceWidth + f->wordSpacing(); 529 529 } … … 591 591 592 592 // FIXME: not 100% correct for first-line 593 const Font *f = font(false);593 const Font* f = font(false); 594 594 int wordSpacing = style()->wordSpacing(); 595 595 int len = str->length(); 596 const QChar *txt = str->unicode();596 const UChar* txt = str->characters(); 597 597 bool needsWordSpacing = false; 598 598 bool ignoringSpaces = false; … … 601 601 bool firstLine = true; 602 602 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]; 606 605 607 606 bool previousCharacterIsSpace = isSpace; … … 637 636 638 637 // Ignore spaces and soft hyphens 639 if (ignoringSpaces || c .unicode()== SOFT_HYPHEN) {638 if (ignoringSpaces || c == SOFT_HYPHEN) { 640 639 continue; 641 640 } … … 643 642 bool hasBreak = isBreakable(txt, i, len, nextBreakable); 644 643 int j = i; 645 while (c != '\n' && c != ' ' && c != '\t' && c .unicode()!= SOFT_HYPHEN) {644 while (c != '\n' && c != ' ' && c != '\t' && c != SOFT_HYPHEN) { 646 645 j++; 647 646 if (j == len) … … 736 735 unsigned currPos; 737 736 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'); 739 738 currPos++); 740 739 return currPos >= (from+len); … … 883 882 // find previous text renderer if one exists 884 883 RenderObject* o; 885 QChar previous = ' ';884 UChar previous = ' '; 886 885 for (o = previousInPreOrder(); o && o->isInlineFlow(); o = o->previousInPreOrder()) 887 886 ; … … 906 905 // RenderBR object ? 907 906 KHTMLAssert(!isBR() || (str->length() == 1 && (*str)[0] == '\n')); 908 KHTMLAssert(!str->length() || str-> unicode());907 KHTMLAssert(!str->length() || str->characters()); 909 908 910 909 setNeedsLayoutAndMinMaxRecalc(); … … 985 984 unsigned int RenderText::width(unsigned int from, unsigned int len, const Font *f, int xpos) const 986 985 { 987 if (!str-> unicode() || from > str->length())986 if (!str->characters() || from > str->length()) 988 987 return 0; 989 988 if (from + len > str->length()) … … 996 995 w = widthFromCache(f, from, len, tabWidth(), xpos); 997 996 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 ); 999 998 1000 999 return w; -
trunk/WebCore/rendering/RenderText.h
r14013 r14273 79 79 virtual VisiblePosition positionForCoordinates(int x, int y); 80 80 81 unsigned intlength() const { return str->length(); }82 const QChar* text() const { return str->unicode(); }83 unsigned intstringLength() 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() 84 84 virtual void position(InlineBox* box, int from, int len, bool reverse, bool override); 85 85 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 intlen, 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; 88 88 virtual int width() const; 89 89 virtual int height() const; … … 105 105 int& minW, int& maxW, bool& stripFrontSpaces); 106 106 107 bool containsOnlyWhitespace(unsigned int from, unsigned intlen) const;107 bool containsOnlyWhitespace(unsigned from, unsigned len) const; 108 108 109 109 // returns the minimum x position of all runs relative to the parent. -
trunk/WebCore/rendering/RenderTextField.cpp
r14036 r14273 121 121 if (value.isNull()) 122 122 value = ""; 123 value.replace( QChar('\\'), backslashAsCurrencySymbol());123 value.replace('\\', backslashAsCurrencySymbol()); 124 124 if (value != oldText) { 125 125 ExceptionCode ec = 0; … … 231 231 size = 20; 232 232 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); 236 235 m_maxWidth = sizeWidth; 237 236 } -
trunk/WebCore/rendering/RenderTreeAsText.cpp
r14256 r14273 207 207 result += '"'; 208 208 for (unsigned i = 0; i != s.length(); ++i) { 209 QChar c = s[i];209 UChar c = s[i]; 210 210 if (c == '\\') 211 211 result += "\\\\"; 212 212 else if (c == '"') 213 213 result += "\\\""; 214 else if (c == '\n' || c .unicode()== 0x00A0)214 else if (c == '\n' || c == 0x00A0) 215 215 result += ' '; 216 216 else { 217 unsigned short u = c.unicode(); 218 if (u >= 0x20 && u < 0x7F) 217 if (c >= 0x20 && c < 0x7F) 219 218 result += c; 220 219 else { 221 220 DeprecatedString hex; 221 unsigned u = c; 222 222 hex.sprintf("\\x{%X}", u); 223 223 result += hex; -
trunk/WebCore/rendering/bidi.cpp
r14256 r14273 3 3 * 4 4 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 5 * Copyright (C) 2004 Apple Computer, Inc.5 * Copyright (C) 2004, 2006 Apple Computer, Inc. 6 6 * 7 7 * This library is free software; you can redistribute it and/or … … 39 39 40 40 // an iterator which traverses all the objects within a block 41 struct BidiIterator 42 { 41 struct BidiIterator { 43 42 BidiIterator() : block(0), obj(0), pos(0) {} 44 43 BidiIterator(RenderBlock* b, RenderObject* o, unsigned int p) 45 :block(b), obj(o), pos(p) {}44 : block(b), obj(o), pos(p) {} 46 45 47 46 void increment(BidiState& state); 48 47 bool atEnd() const; 49 48 50 const QChar& current() const; 51 52 QChar::Direction direction() const; 49 UChar current() const; 50 UCharDirection direction() const; 53 51 54 52 RenderBlock* block; … … 58 56 59 57 struct BidiState { 60 BidiState() : context(0), dir( QChar::DirON), adjustEmbedding(false), reachedEndOfLine(false) {}58 BidiState() : context(0), dir(U_OTHER_NEUTRAL), adjustEmbedding(false), reachedEndOfLine(false) {} 61 59 62 60 BidiIterator sor; … … 66 64 RefPtr<BidiContext> context; 67 65 BidiStatus status; 68 QChar::Direction dir;66 UCharDirection dir; 69 67 bool adjustEmbedding; 70 68 BidiIterator endOfLine; … … 105 103 static int numSpaces; 106 104 107 static void embed( QChar::Direction d, BidiState &bidi);108 static void appendRun(BidiState &bidi);105 static void embed(UCharDirection, BidiState&); 106 static void appendRun(BidiState&); 109 107 110 108 static int getBPMWidth(int childValue, Length cssUnit) … … 200 198 relayouting 201 199 */ 202 BidiContext::BidiContext(unsigned char l, QChar::Direction e, BidiContext *p, bool o)200 BidiContext::BidiContext(unsigned char l, UCharDirection e, BidiContext *p, bool o) 203 201 : level(l), override(o), m_dir(e) 204 202 { … … 281 279 if (ub != UBNormal) { 282 280 TextDirection dir = next->style()->direction(); 283 QChar::Direction d = (ub == Embed284 ? (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)); 286 284 embed(d, bidi); 287 285 } … … 299 297 while (current && current != block) { 300 298 if (bidi.adjustEmbedding && current->isInlineFlow() && current->style()->unicodeBidi() != UBNormal) 301 embed( QChar::DirPDF, bidi);299 embed(U_POP_DIRECTIONAL_FORMAT, bidi); 302 300 303 301 next = current->nextSibling(); … … 307 305 if (ub != UBNormal) { 308 306 TextDirection dir = next->style()->direction(); 309 QChar::Direction d = (ub == Embed310 ? (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)); 312 310 embed(d, bidi); 313 311 } … … 349 347 if (ub != UBNormal) { 350 348 TextDirection dir = o->style()->direction(); 351 QChar::Direction d = (ub == Embed352 ? (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)); 354 352 embed(d, bidi); 355 353 } … … 387 385 } 388 386 389 const QChar& BidiIterator::current() const 390 { 391 static QChar nullCharacter; 392 387 UChar BidiIterator::current() const 388 { 393 389 if (!obj || !obj->isText()) 394 return nullCharacter;390 return 0; 395 391 396 392 RenderText* text = static_cast<RenderText*>(obj); 397 393 if (!text->text()) 398 return nullCharacter;394 return 0; 399 395 400 396 return text->text()[pos]; 401 397 } 402 398 403 ALWAYS_INLINE QChar::Direction BidiIterator::direction() const399 ALWAYS_INLINE UCharDirection BidiIterator::direction() const 404 400 { 405 401 if (!obj) 406 return QChar::DirON;402 return U_OTHER_NEUTRAL; 407 403 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; 409 405 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); 413 408 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]); 416 411 } 417 412 … … 434 429 if (text->text()) { 435 430 for (int i = bidiRun->start; i < bidiRun->stop; i++) { 436 const QChar c = text->text()[i];431 UChar c = text->text()[i]; 437 432 if (c == ' ' || c == '\n' || c == '\t') 438 433 numSpaces++; … … 525 520 RenderText* textObj = static_cast<RenderText*>(endpoint.obj); 526 521 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) 528 523 return; 529 524 } else if (startpoint.obj->isText()) { 530 525 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) 532 527 return; 533 528 } … … 626 621 bidi.eor.increment(bidi); 627 622 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; 630 625 bidi.adjustEmbedding = b; 631 626 } 632 627 633 static void embed( QChar::Direction d, BidiState& bidi)628 static void embed(UCharDirection d, BidiState& bidi) 634 629 { 635 630 bool b = bidi.adjustEmbedding; 636 631 bidi.adjustEmbedding = false; 637 if (d == QChar::DirPDF) {632 if (d == U_POP_DIRECTIONAL_FORMAT) { 638 633 BidiContext *c = bidi.context->parent; 639 634 if (c) { 640 635 if (!emptyRun && bidi.eor != bidi.last) { 641 assert(bidi.status.eor != QChar::DirON);636 assert(bidi.status.eor != U_OTHER_NEUTRAL); 642 637 // 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) 645 647 bidi.dir = bidi.context->dir(); 646 if (bidi.context->dir() == QChar::DirL) {648 if (bidi.context->dir() == U_LEFT_TO_RIGHT) { 647 649 // 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; 651 653 appendRun(bidi); 652 654 } 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; 655 657 appendRun(bidi); 656 } else if (bidi.status.eor != QChar::DirL)658 } else if (bidi.status.eor != U_LEFT_TO_RIGHT) 657 659 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) 659 661 appendRun(bidi); 660 662 bidi.eor = bidi.last; … … 670 672 } 671 673 } 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; 675 677 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; 678 680 679 681 unsigned char level = bidi.context->level; 680 if (runDir == QChar::DirR) {682 if (runDir == U_RIGHT_TO_LEFT) { 681 683 if (level%2) // we have an odd level 682 684 level += 2; … … 692 694 if (level < 61) { 693 695 if (!emptyRun && bidi.eor != bidi.last) { 694 assert(bidi.status.eor != QChar::DirON);696 assert(bidi.status.eor != U_OTHER_NEUTRAL); 695 697 // 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) 698 707 bidi.dir = runDir; 699 if (runDir == QChar::DirL) {708 if (runDir == U_LEFT_TO_RIGHT) { 700 709 // 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; 704 713 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; 707 716 } 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; 710 719 appendRun(bidi); 711 if (bidi.context->dir() != QChar::DirL) {720 if (bidi.context->dir() != U_LEFT_TO_RIGHT) { 712 721 bidi.eor = bidi.last; 713 bidi.dir = QChar::DirR;722 bidi.dir = U_RIGHT_TO_LEFT; 714 723 appendRun(bidi); 715 724 } 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) 718 727 appendRun(bidi); 719 728 else 720 bidi.dir = QChar::DirR;729 bidi.dir = U_RIGHT_TO_LEFT; 721 730 } 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) { 723 732 // 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) 725 734 appendRun(bidi); 726 735 else 727 bidi.dir = QChar::DirL;736 bidi.dir = U_LEFT_TO_RIGHT; 728 737 } 729 738 bidi.eor = bidi.last; … … 836 845 837 846 if (!m_tabWidth) { 838 QChar spaceChar(' ');847 const UChar spaceChar = ' '; 839 848 const Font& font = style()->font(); 840 849 int spaceWidth = font.width(&spaceChar, 1); … … 864 873 int rtLength = rt->length(); 865 874 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()) 867 876 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; 869 878 } 870 879 if (!r->compact) { … … 909 918 numSpaces = 0; 910 919 // 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) 912 921 break; 913 922 case RIGHT: … … 937 946 int spaces = 0; 938 947 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]; 940 949 if (c == ' ' || c == '\n' || c == '\t') 941 950 spaces++; … … 1003 1012 sBidiRunCount = 0; 1004 1013 1005 assert(bidi.dir == QChar::DirON);1014 assert(bidi.dir == U_OTHER_NEUTRAL); 1006 1015 1007 1016 emptyRun = true; … … 1017 1026 1018 1027 while (true) { 1019 QChar::Direction dirCurrent;1028 UCharDirection dirCurrent; 1020 1029 if (pastEnd && (previousLineBrokeCleanly || bidi.current.atEnd())) { 1021 1030 BidiContext *c = bidi.context.get(); … … 1033 1042 } else { 1034 1043 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) 1036 1050 dirCurrent = bidi.context->dir(); 1037 else if (dirCurrent == QChar::DirNSM)1051 else if (dirCurrent == U_DIR_NON_SPACING_MARK) 1038 1052 dirCurrent = bidi.status.last; 1039 1053 } 1040 1054 1041 assert(bidi.status.eor != QChar::DirON);1055 assert(bidi.status.eor != U_OTHER_NEUTRAL); 1042 1056 switch (dirCurrent) { 1043 1057 1044 1058 // 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: 1050 1064 embed(dirCurrent, bidi); 1051 1065 break; 1052 1066 1053 1067 // strong types 1054 case QChar::DirL:1068 case U_LEFT_TO_RIGHT: 1055 1069 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) 1061 1075 appendRun(bidi); 1062 1076 break; 1063 case QChar::DirL:1077 case U_LEFT_TO_RIGHT: 1064 1078 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) { 1075 1089 // 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; 1077 1091 appendRun(bidi); 1078 if (bidi.context->dir() != QChar::DirL) {1092 if (bidi.context->dir() != U_LEFT_TO_RIGHT) { 1079 1093 // the neutrals take the embedding direction, which is R 1080 1094 bidi.eor = bidi.last; 1081 bidi.dir = QChar::DirR;1095 bidi.dir = U_RIGHT_TO_LEFT; 1082 1096 appendRun(bidi); 1083 1097 } 1084 1098 } 1085 } else if (bidi.status.eor == QChar::DirAN) {1099 } else if (bidi.status.eor == U_ARABIC_NUMBER) { 1086 1100 // 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; 1088 1102 appendRun(bidi); 1089 if (bidi.context->dir() != QChar::DirL) {1103 if (bidi.context->dir() != U_LEFT_TO_RIGHT) { 1090 1104 // the neutrals take the embedding direction, which is R 1091 1105 bidi.eor = bidi.last; 1092 bidi.dir = QChar::DirR;1106 bidi.dir = U_RIGHT_TO_LEFT; 1093 1107 appendRun(bidi); 1094 1108 } 1095 } else if(bidi.status.eor != QChar::DirL) {1109 } else if(bidi.status.eor != U_LEFT_TO_RIGHT) { 1096 1110 //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) { 1098 1112 bidi.eor = bidi.last; 1099 bidi.dir = QChar::DirR;1113 bidi.dir = U_RIGHT_TO_LEFT; 1100 1114 } 1101 1115 appendRun(bidi); … … 1105 1119 } 1106 1120 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; 1110 1124 break; 1111 case QChar::DirAL:1112 case QChar::DirR:1125 case U_RIGHT_TO_LEFT_ARABIC: 1126 case U_RIGHT_TO_LEFT: 1113 1127 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: 1117 1131 appendRun(bidi); 1118 case QChar::DirR:1119 case QChar::DirAL:1132 case U_RIGHT_TO_LEFT: 1133 case U_RIGHT_TO_LEFT_ARABIC: 1120 1134 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) { 1130 1144 //last stuff takes embedding dir 1131 if (bidi.context->dir() != QChar::DirR && bidi.status.lastStrong != QChar::DirR1132 && 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) { 1133 1147 bidi.eor = bidi.last; 1134 bidi.dir = QChar::DirL;1148 bidi.dir = U_LEFT_TO_RIGHT; 1135 1149 } 1136 1150 appendRun(bidi); … … 1140 1154 } 1141 1155 bidi.eor = bidi.current; 1142 bidi.status.eor = QChar::DirR;1156 bidi.status.eor = U_RIGHT_TO_LEFT; 1143 1157 bidi.status.lastStrong = dirCurrent; 1144 bidi.dir = QChar::DirR;1158 bidi.dir = U_RIGHT_TO_LEFT; 1145 1159 break; 1146 1160 1147 1161 // weak types: 1148 1162 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) { 1151 1165 // if last strong was AL change EN to AN 1152 1166 switch (bidi.status.last) { 1153 case QChar::DirEN:1154 case QChar::DirL:1167 case U_EUROPEAN_NUMBER: 1168 case U_LEFT_TO_RIGHT: 1155 1169 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: 1159 1173 bidi.eor = bidi.last; 1160 1174 appendRun(bidi); 1161 bidi.dir = QChar::DirEN;1175 bidi.dir = U_EUROPEAN_NUMBER; 1162 1176 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) 1166 1180 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) { 1174 1188 // 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; 1176 1190 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) { 1181 1195 // numbers on both sides, neutrals get right to left direction 1182 1196 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; 1185 1199 appendRun(bidi); 1186 bidi.dir = QChar::DirEN;1200 bidi.dir = U_EUROPEAN_NUMBER; 1187 1201 } 1188 1202 default: … … 1190 1204 } 1191 1205 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; 1195 1209 break; 1196 1210 } 1197 case QChar::DirAN:1198 dirCurrent = QChar::DirAN;1211 case U_ARABIC_NUMBER: 1212 dirCurrent = U_ARABIC_NUMBER; 1199 1213 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) 1202 1216 appendRun(bidi); 1203 1217 break; 1204 case QChar::DirAN:1218 case U_ARABIC_NUMBER: 1205 1219 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: 1209 1223 bidi.eor = bidi.last; 1210 1224 appendRun(bidi); 1211 1225 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) 1214 1228 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) { 1223 1237 // run of L before neutrals, neutrals take embedding dir (N2) 1224 if (bidi.context->dir() == QChar::DirR || bidi.status.lastStrong == QChar::DirR1225 || 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) { 1226 1240 // the embedding direction is R 1227 1241 // close the L run 1228 1242 appendRun(bidi); 1229 1243 // neutrals become an R run 1230 bidi.dir = QChar::DirR;1244 bidi.dir = U_RIGHT_TO_LEFT; 1231 1245 } else { 1232 1246 // the embedding direction is L 1233 1247 // append neutrals to the L run and close it 1234 bidi.dir = QChar::DirL;1248 bidi.dir = U_LEFT_TO_RIGHT; 1235 1249 } 1236 1250 } … … 1241 1255 } 1242 1256 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; 1246 1260 break; 1247 case QChar::DirES:1248 case QChar::DirCS:1261 case U_EUROPEAN_NUMBER_SEPARATOR: 1262 case U_COMMON_NUMBER_SEPARATOR: 1249 1263 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; 1253 1267 bidi.eor = bidi.current; 1254 1268 bidi.status.eor = dirCurrent; 1255 } else if (bidi.status.last != QChar::DirET)1269 } else if (bidi.status.last != U_EUROPEAN_NUMBER_TERMINATOR) 1256 1270 bidi.lastBeforeET = emptyRun ? bidi.eor : bidi.last; 1257 1271 break; 1258 1272 1259 1273 // boundary neutrals should be ignored 1260 case QChar::DirBN:1274 case U_BOUNDARY_NEUTRAL: 1261 1275 if (bidi.eor == bidi.last) 1262 1276 bidi.eor = bidi.current; 1263 1277 break; 1264 1278 // neutrals 1265 case QChar::DirB:1279 case U_BLOCK_SEPARATOR: 1266 1280 // ### what do we do with newline and paragraph seperators that come to here? 1267 1281 break; 1268 case QChar::DirS:1282 case U_SEGMENT_SEPARATOR: 1269 1283 // ### implement rule L1 1270 1284 break; 1271 case QChar::DirWS:1285 case U_WHITE_SPACE_NEUTRAL: 1272 1286 break; 1273 case QChar::DirON:1287 case U_OTHER_NEUTRAL: 1274 1288 break; 1275 1289 default: … … 1282 1296 bidi.eor = bidi.endOfLine; 1283 1297 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: 1287 1301 bidi.dir = bidi.status.eor; 1288 1302 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; 1291 1305 break; 1292 1306 default: … … 1296 1310 } 1297 1311 bidi = stateAtEnd; 1298 bidi.dir = QChar::DirON;1312 bidi.dir = U_OTHER_NEUTRAL; 1299 1313 break; 1300 1314 } … … 1303 1317 // set status.last as needed. 1304 1318 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; 1308 1322 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: 1314 1328 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: 1320 1334 bidi.status.last = dirCurrent; 1321 1335 break; 1322 1336 default: 1323 bidi.status.last = QChar::DirON;1337 bidi.status.last = U_OTHER_NEUTRAL; 1324 1338 } 1325 1339 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: 1333 1347 // ignore these 1334 1348 break; 1335 case QChar::DirEN:1349 case U_EUROPEAN_NUMBER: 1336 1350 // fall through 1337 1351 default: … … 1341 1355 bidi.last = bidi.current; 1342 1356 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)) { 1344 1362 bidi.sor = bidi.current; 1345 1363 emptyRun = false; … … 1351 1369 bidi.current.increment(bidi); 1352 1370 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)) { 1354 1376 // exclude the embedding char itself from the new run so that ATSUI will never see it 1355 1377 bidi.eor.obj = 0; … … 1534 1556 BidiContext *startEmbed; 1535 1557 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; 1538 1560 } 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; 1541 1563 } 1542 1564 … … 1545 1567 bidi.status.eor = startEmbed->dir(); 1546 1568 bidi.context = startEmbed; 1547 bidi.dir = QChar::DirON;1569 bidi.dir = U_OTHER_NEUTRAL; 1548 1570 1549 1571 if (!smidpoints) … … 1874 1896 static inline bool skipNonBreakingSpace(BidiIterator &it) 1875 1897 { 1876 if (it.obj->style()->nbspMode() != SPACE || it.current() .unicode()!= nonBreakingSpace)1898 if (it.obj->style()->nbspMode() != SPACE || it.current() != nonBreakingSpace) 1877 1899 return false; 1878 1900 … … 1902 1924 while (!it.atEnd() && (it.obj->isInlineFlow() || (shouldCollapseWhiteSpace(it.obj->style()) && !it.obj->isBR() && 1903 1925 (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())))) { 1905 1927 if (it.obj->isFloatingOrPositioned()) { 1906 1928 RenderObject *o = it.obj; … … 2103 2125 if (style()->collapseWhiteSpace() && next && !next->isBR() && next->isText() && static_cast<RenderText*>(next)->stringLength() > 0) { 2104 2126 RenderText *nextText = static_cast<RenderText*>(next); 2105 QChar nextChar = nextText->text()[0]; 2106 2127 UChar nextChar = nextText->text()[0]; 2107 2128 if (nextText->style()->isCollapsibleWhiteSpace(nextChar)) { 2108 2129 currentCharacterIsSpace = true; … … 2119 2140 int strlen = t->stringLength(); 2120 2141 int len = strlen - pos; 2121 const QChar* str = t->text();2142 const UChar* str = t->text(); 2122 2143 2123 2144 const Font *f = t->font(m_firstLine); … … 2135 2156 bool previousCharacterIsSpace = currentCharacterIsSpace; 2136 2157 bool previousCharacterIsWS = currentCharacterIsWS; 2137 const QChar c = str[pos];2158 UChar c = str[pos]; 2138 2159 currentCharacterIsSpace = c == ' ' || c == '\t' || (!o->style()->preserveNewline() && (c == '\n')); 2139 2160 … … 2142 2163 2143 2164 // Check for soft hyphens. Go ahead and ignore them. 2144 if (c .unicode()== SOFT_HYPHEN) {2165 if (c == SOFT_HYPHEN) { 2145 2166 if (!ignoringSpaces) { 2146 2167 // Ignore soft hyphens … … 2182 2203 bool breakWords = o->style()->wordWrap() == BREAK_WORD && ((allowBreak && w == 0) || o->style()->whiteSpace() == PRE); 2183 2204 2184 currentCharacterIsWS = currentCharacterIsSpace || (breakNBSP && c .unicode()== nonBreakingSpace);2205 currentCharacterIsWS = currentCharacterIsSpace || (breakNBSP && c == nonBreakingSpace); 2185 2206 2186 2207 if (breakWords) … … 2267 2288 if (midWordBreak) 2268 2289 tmpW -= additionalTmpW; 2269 if (pos > 0 && str[pos-1] .unicode()== SOFT_HYPHEN)2290 if (pos > 0 && str[pos-1] == SOFT_HYPHEN) 2270 2291 // Subtract the width of the soft hyphen out since we fit on a line. 2271 2292 tmpW -= t->width(pos-1, 1, f, w+tmpW); … … 2370 2391 RenderText* nextText = static_cast<RenderText*>(next); 2371 2392 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())) 2374 2395 // If the next item on the line is text, and if we did not end with 2375 2396 // a space, then the next text run continues our word (and so it needs to 2376 2397 // keep adding to |tmpW|. Just update and continue. 2377 2398 checkForBreak = true; 2378 }2379 2399 } 2380 2400 bool canPlaceOnLine = (w + tmpW <= width) || !autoWrap; … … 2509 2529 // For soft hyphens on line breaks, we have to chop out the midpoints that made us 2510 2530 // 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) 2513 2533 chopMidpointsAt(lBreak.obj, lBreak.pos-2); 2514 2534 } … … 2539 2559 { 2540 2560 // 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 renderable2542 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); 2543 2563 const Font& firstLineFont = firstLineStyle()->font(); 2544 2564 const Font& font = style()->font(); -
trunk/WebCore/rendering/bidi.h
r13858 r14273 21 21 * 22 22 */ 23 23 24 #ifndef BIDI_H 24 25 #define BIDI_H 25 26 26 #include "DeprecatedString.h"27 #include <unicode/uchar.h> 27 28 28 29 class RenderArena; 29 30 30 31 namespace WebCore { 32 31 33 class RenderBlock; 32 34 class RenderObject; … … 34 36 35 37 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) {} 37 39 38 QChar::Direction eor;39 QChar::Direction lastStrong;40 QChar::Direction last;40 UCharDirection eor; 41 UCharDirection lastStrong; 42 UCharDirection last; 41 43 }; 42 44 43 45 class BidiContext { 44 46 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); 46 48 ~BidiContext(); 47 49 … … 49 51 void deref() const; 50 52 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); } 53 55 54 56 unsigned char level; 55 57 bool override : 1; 56 unsigned m_dir : 5; // QChar::Direction57 unsigned m_basicDir : 5; // QChar::Direction58 59 BidiContext *parent;58 unsigned m_dir : 5; // UCharDirection 59 unsigned m_basicDir : 5; // UCharDirection 60 61 BidiContext* parent; 60 62 61 63 // refcounting.... … … 64 66 65 67 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) 68 70 { 69 if (dir == QChar::DirON)71 if (dir == U_OTHER_NEUTRAL) 70 72 dir = context->dir(); 71 73 … … 73 75 74 76 // 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) 77 79 level++; 78 80 } else { 79 if ( dir == QChar::DirR)81 if (dir == U_RIGHT_TO_LEFT) 80 82 level++; 81 else if ( dir == QChar::DirAN || dir == QChar::DirEN)83 else if (dir == U_ARABIC_NUMBER || dir == U_EUROPEAN_NUMBER) 82 84 level += 2; 83 85 } 84 86 } 85 87 86 void destroy(RenderArena* renderArena);88 void destroy(RenderArena*); 87 89 88 90 // Overloaded new operator. 89 void* operator new(size_t sz, RenderArena* renderArena) throw();91 void* operator new(size_t, RenderArena*) throw(); 90 92 91 93 // 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); 93 95 94 96 private: 95 97 // The normal operator new is disallowed. 96 void* operator new(size_t sz) throw();98 void* operator new(size_t) throw(); 97 99 98 100 public: -
trunk/WebCore/rendering/break_lines.cpp
r13858 r14273 32 32 namespace WebCore { 33 33 34 int nextBreakablePosition(const QChar *str, int pos, int len, bool breakNBSP)34 int nextBreakablePosition(const UChar* str, int pos, int len, bool breakNBSP) 35 35 { 36 36 #if __APPLE__ … … 42 42 unsigned short ch, lastCh; 43 43 44 lastCh = pos > 0 ? str[pos - 1] .unicode(): 0;44 lastCh = pos > 0 ? str[pos - 1] : 0; 45 45 for (i = pos; i < len; i++) { 46 ch = str[i] .unicode();46 ch = str[i]; 47 47 if (ch == ' ' || ch == '\n' || ch == '\t' || (breakNBSP && ch == 0xa0)) 48 48 break; -
trunk/WebCore/rendering/break_lines.h
r13393 r14273 21 21 */ 22 22 23 class QChar; 23 #include <unicode/umachine.h> 24 24 25 25 namespace WebCore { 26 26 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); 28 28 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) 30 30 { 31 31 if (pos > nextBreakable) -
trunk/WebCore/rendering/render_form.cpp
r14207 r14273 258 258 String widgetText = w->text(); 259 259 String newText = e->value(); 260 newText.replace( QChar('\\'), backslashAsCurrencySymbol());260 newText.replace('\\', backslashAsCurrencySymbol()); 261 261 if (widgetText != newText) { 262 262 int pos = w->cursorPosition(); … … 653 653 HTMLOptGroupElement *optgroupElement = static_cast<HTMLOptGroupElement*>(listItems[listIndex]); 654 654 DeprecatedString label = optgroupElement->getAttribute(labelAttr).deprecatedString(); 655 label.replace( QChar('\\'), backslashAsCurrencySymbol());655 label.replace('\\', backslashAsCurrencySymbol()); 656 656 657 657 // In WinIE, an optgroup can't start or end with whitespace (other than the indent … … 676 676 itemText = optionElement->text().deprecatedString(); 677 677 678 itemText.replace( QChar('\\'), backslashAsCurrencySymbol());678 itemText.replace('\\', backslashAsCurrencySymbol()); 679 679 680 680 // In WinIE, leading and trailing whitespace is ignored in options. We match this behavior. … … 996 996 String widgetText = text(); 997 997 String text = e->value(); 998 text.replace( QChar('\\'), backslashAsCurrencySymbol());998 text.replace('\\', backslashAsCurrencySymbol()); 999 999 if (widgetText != text) { 1000 1000 int line, col; … … 1015 1015 { 1016 1016 String txt = static_cast<QTextEdit*>(m_widget)->text(); 1017 return txt.replace(backslashAsCurrencySymbol(), QChar('\\'));1017 return txt.replace(backslashAsCurrencySymbol(), '\\'); 1018 1018 } 1019 1019 … … 1021 1021 { 1022 1022 String txt = static_cast<QTextEdit*>(m_widget)->textWithHardLineBreaks(); 1023 return txt.replace(backslashAsCurrencySymbol(), QChar('\\'));1023 return txt.replace(backslashAsCurrencySymbol(), '\\'); 1024 1024 } 1025 1025 -
trunk/WebCore/rendering/render_line.cpp
r13992 r14273 476 476 RenderText *rt = static_cast<RenderText*>(text->object()); 477 477 if (rt->length()) { 478 if (needsWordSpacing && rt->text()[text->start()].isSpace())478 if (needsWordSpacing && QChar(rt->text()[text->start()]).isSpace()) 479 479 x += rt->font(m_firstLine)->wordSpacing(); 480 needsWordSpacing = ! rt->text()[text->end()].isSpace();480 needsWordSpacing = !QChar(rt->text()[text->end()]).isSpace(); 481 481 } 482 482 text->setXPos(x); … … 1086 1086 1087 1087 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(), 1089 1089 0, str.length(), 0, LTR, _style->visuallyOrdered(), 0, str.length()); 1090 1090 -
trunk/WebCore/rendering/render_list.cpp
r14102 r14273 41 41 const int cMarkerPadding = 7; 42 42 43 static DeprecatedString toRoman( int number, bool upper)43 static DeprecatedString toRoman(int number, bool upper) 44 44 { 45 45 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 { 53 51 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]); 68 61 number /= 10; 69 62 d += 2; 70 } 71 while ( number ); 72 63 } while (number); 73 64 return roman; 74 65 } … … 77 68 { 78 69 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 81 72 DeprecatedString letterString; 82 73 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; 85 76 number -= onesDigit; 86 77 number /= 26; 87 78 } 88 79 89 80 return letterString; 90 81 } 91 82 92 static DeprecatedString toHebrew( int number ) { 83 static DeprecatedString toHebrew(int number) 84 { 93 85 const QChar tenDigit[] = {1497, 1499, 1500, 1502, 1504, 1505, 1506, 1508, 1510}; 94 86 95 87 DeprecatedString letter; 96 88 if (number > 999) { 97 letter = toHebrew(number /1000) + "'";89 letter = toHebrew(number / 1000) + "'"; 98 90 number = number % 1000; 99 91 } 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); 115 101 letter += QChar(1487 + number - 9); 116 102 } else { 103 int tens = number / 10; 104 if (tens) 105 letter += tenDigit[tens - 1]; 117 106 number = number % 10; 118 if (number != 0)119 letter += QChar 107 if (number) 108 letter += QChar(1487 + number); 120 109 } 121 110 return letter; … … 128 117 { 129 118 // init RenderObject attributes 130 setInline(false); 119 setInline(false); // our object is not Inline 131 120 } 132 121 … … 292 281 } 293 282 294 void RenderListItem::layout( 295 { 296 KHTMLAssert( needsLayout());297 KHTMLAssert( minMaxKnown());283 void RenderListItem::layout() 284 { 285 KHTMLAssert(needsLayout()); 286 KHTMLAssert(minMaxKnown()); 298 287 299 288 updateMarkerLocation(); … … 453 442 if (!m_item.isEmpty()) { 454 443 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), ". "); 458 448 } 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); 461 453 } 462 454 } … … 557 549 } 558 550 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 } 560 557 561 558 end: … … 679 676 case LNONE: 680 677 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()); 686 705 } 687 706 -
trunk/WebCore/rendering/render_style.cpp
r13981 r14273 630 630 FIRST_LETTER_BIT = 0x8, SELECTION_BIT = 0x10, FIRST_LINE_INHERITED_BIT = 0x20 }; 631 631 632 static in t pseudoBit(RenderStyle::PseudoId pseudo)632 static inline int pseudoBit(RenderStyle::PseudoId pseudo) 633 633 { 634 634 switch (pseudo) { … … 652 652 bool RenderStyle::hasPseudoStyle(PseudoId pseudo) const 653 653 { 654 return (pseudoBit(pseudo) & noninherited_flags._pseudoBits) != 0;654 return pseudoBit(pseudo) & noninherited_flags._pseudoBits; 655 655 } 656 656 … … 662 662 RenderStyle* RenderStyle::getPseudoStyle(PseudoId pid) 663 663 { 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; 677 669 return ps; 678 670 } … … 680 672 void RenderStyle::addPseudoStyle(RenderStyle* pseudo) 681 673 { 682 if (!pseudo) return; 674 if (!pseudo) 675 return; 683 676 pseudo->ref(); 684 677 pseudo->pseudoStyle = pseudoStyle; -
trunk/WebCore/rendering/render_style.h
r13959 r14273 1237 1237 return collapseWhiteSpace(whiteSpace()); 1238 1238 } 1239 bool isCollapsibleWhiteSpace( const QChar&c) const {1240 switch (c .unicode()) {1239 bool isCollapsibleWhiteSpace(UChar c) const { 1240 switch (c) { 1241 1241 case ' ': 1242 1242 case '\t': -
trunk/WebCore/xml/XSLStyleSheet.cpp
r13839 r14273 120 120 { 121 121 // Parse in a single chunk into an xmlDocPtr 122 const QChar BOM(0xFEFF);122 const UChar BOM(0xFEFF); 123 123 const unsigned char BOMHighByte = *reinterpret_cast<const unsigned char*>(&BOM); 124 124 setLoaderForLibXMLCallbacks(docLoader()); … … 126 126 xmlFreeDoc(m_stylesheetDoc); 127 127 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), 129 129 m_ownerDocument->URL().ascii(), 130 130 BOMHighByte == 0xFF ? "UTF-16LE" : "UTF-16BE", -
trunk/WebCore/xml/xmlhttprequest.cpp
r14212 r14273 86 86 unsigned length = contentTypeString.length(); 87 87 for (unsigned offset = 0; offset < length; offset++) { 88 QChar c = contentTypeString[offset];88 UChar c = contentTypeString[offset]; 89 89 if (c == ';') 90 90 break; 91 else if ( c.isSpace()) // FIXME: This seems wrong, " " is an invalid MIME type character according to RFC 2045. bug 864491 else if (QChar(c).isSpace()) // FIXME: This seems wrong, " " is an invalid MIME type character according to RFC 2045. bug 8644 92 92 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); 94 95 } 95 96 return mimeType; … … 107 108 108 109 // 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] != ';') { 110 111 pos += 7; 111 112 continue; … … 115 116 116 117 // skip whitespace 117 while (pos != length && contentTypeString[pos] .unicode()<= ' ')118 while (pos != length && contentTypeString[pos] <= ' ') 118 119 ++pos; 119 120 … … 121 122 continue; 122 123 123 while (pos != length && (contentTypeString[pos] .unicode()<= ' ' || contentTypeString[pos] == '"' || contentTypeString[pos] == '\''))124 while (pos != length && (contentTypeString[pos] <= ' ' || contentTypeString[pos] == '"' || contentTypeString[pos] == '\'')) 124 125 ++pos; 125 126 126 127 // we don't handle spaces within quoted parameter values, because charset names cannot have any 127 128 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] != ';') 129 130 ++endpos; 130 131 -
trunk/WebCore/xpath/impl/XPathExpressionNode.cpp
r14234 r14273 24 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 25 */ 26 26 27 #include "config.h" 27 28 28 29 #if XPATH_SUPPORT 29 30 31 #include "XPathExpressionNode.h" 32 30 33 #include "Logging.h" 31 #include "XPathExpressionNode.h"32 34 #include "Node.h" 33 34 #include < cmath>35 #include "XPathValue.h" 36 #include <math.h> 35 37 36 38 using namespace std; … … 53 55 { 54 56 deleteAllValues(m_subExpressions); 55 56 57 delete m_constantValue; 57 58 } … … 61 62 if (m_constantValue) 62 63 return *m_constantValue; 63 64 64 return doEvaluate(); 65 65 } … … 89 89 } 90 90 91 unsigned intExpression::subExprCount() const91 unsigned Expression::subExprCount() const 92 92 { 93 93 return m_subExpressions.size(); … … 97 97 { 98 98 ASSERT(i < subExprCount()); 99 100 99 return m_subExpressions[i]; 101 100 } … … 104 103 { 105 104 ASSERT(i < subExprCount()); 106 107 105 return m_subExpressions[i]; 108 106 } … … 110 108 bool Expression::isConstant() const 111 109 { 112 for (unsigned i = 0; i < m_subExpressions.size(); i++) {110 for (unsigned i = 0; i < m_subExpressions.size(); i++) 113 111 if (!m_subExpressions[i]->isConstant()) 114 112 return false; 115 }116 117 113 return true; 118 114 } -
trunk/WebCore/xpath/impl/XPathExpressionNode.h
r14256 r14273 24 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 25 */ 26 26 27 #ifndef XPathExpressionNode_H 27 28 #define XPathExpressionNode_H 28 29 29 30 #if XPATH_SUPPORT 30 31 #include "XPathValue.h"32 31 33 32 #include "StringHash.h" … … 36 35 37 36 namespace WebCore { 37 38 class Node; 38 39 class XPathNSResolver; 39 40 40 41 namespace XPath { 42 43 class Value; 41 44 42 struct EvaluationContext 43 { 45 struct EvaluationContext { 44 46 EvaluationContext() : node(0), size(0), position(0), resolver(0) { } 45 47 … … 55 57 }; 56 58 57 class ParseNode 58 { 59 class ParseNode { 60 public: 61 virtual ~ParseNode() { } 59 62 }; 60 63 … … 66 69 Expression(); 67 70 virtual ~Expression(); 71 68 72 virtual Value evaluate() const; 69 73 70 void addSubExpression(Expression* expr);74 void addSubExpression(Expression*); 71 75 void optimize(); 72 76 virtual bool isConstant() const; 73 77 74 78 protected: 75 unsigned intsubExprCount() const;79 unsigned subExprCount() const; 76 80 Expression* subExpr(unsigned i); 77 81 const Expression* subExpr(unsigned i) const; -
trunk/WebCore/xpath/impl/XPathFunctions.cpp
r14264 r14273 24 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 25 */ 26 26 27 #include "config.h" 27 28 … … 30 31 #include "XPathFunctions.h" 31 32 33 #include "DeprecatedString.h" 32 34 #include "Logging.h" 33 35 #include "NamedAttrMap.h" 34 36 #include "Node.h" 35 37 #include "XPathValue.h" 36 38 #include <math.h> 37 39 … … 325 327 s += "-Infinity"; 326 328 else 327 s += DeprecatedString::number(m_min);329 s += String::number(m_min); 328 330 329 331 s += ".."; … … 332 334 s += "Infinity"; 333 335 else 334 s += DeprecatedString::number(m_max);336 s += String::number(m_max); 335 337 336 338 s += "]"; … … 374 376 Value FunLast::doEvaluate() const 375 377 { 376 return double(Expression::evaluationContext().size);378 return Expression::evaluationContext().size; 377 379 } 378 380 … … 384 386 Value FunPosition::doEvaluate() const 385 387 { 386 return double(Expression::evaluationContext().position);388 return Expression::evaluationContext().position; 387 389 } 388 390 … … 468 470 } 469 471 470 return double(a.toNodeVector().size());472 return a.toNodeVector().size(); 471 473 } 472 474 … … 478 480 Value FunString::doEvaluate() const 479 481 { 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(); 484 484 return arg(0)->evaluate().toString(); 485 485 } … … 487 487 Value FunConcat::doEvaluate() const 488 488 { 489 String str ;490 491 for (unsigned i nt i= 0; i < argCount(); ++i)489 String str = ""; 490 491 for (unsigned i = 0; i < argCount(); ++i) 492 492 str += arg(i)->evaluate().toString(); 493 493 … … 545 545 return ""; 546 546 547 return Value(s1.deprecatedString().mid(i + 1));547 return s1.substring(i + 1); 548 548 } 549 549 … … 567 567 } 568 568 569 return Value(s.deprecatedString().mid(pos - 1, len));569 return s.substring(pos - 1, len); 570 570 } 571 571 572 572 Value FunStringLength::doEvaluate() const 573 573 { 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(); 580 577 } 581 578 … … 598 595 String newString; 599 596 597 // FIXME: Building a String a character at a time is quite slow. 600 598 for (unsigned i1 = 0; i1 < s1.length(); ++i1) { 601 QChar ch = s1[i1];599 UChar ch = s1[i1]; 602 600 int i2 = s2.find(ch); 603 601 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 } 608 608 } 609 609 … … 696 696 697 697 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(); 699 699 700 700 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 1 27 %{ 2 28 #include "config.h" 3 29 30 #include "DeprecatedString.h" 31 #include "ExceptionCode.h" 32 #include "XPathEvaluator.h" 33 #include "XPathFunctions.h" 34 #include "XPathNSResolver.h" 4 35 #include "XPathParser.h" 5 #include "XPathFunctions.h"6 36 #include "XPathPath.h" 37 #include "XPathPredicate.h" 7 38 #include "XPathStep.h" 8 #include "XPathPredicate.h"9 39 #include "XPathUtil.h" 10 40 #include "XPathVariableReference.h" 11 12 #include "XPathNSResolver.h"13 #include "XPathEvaluator.h"14 #include "ExceptionCode.h"15 41 16 42 #define YYDEBUG 0 -
trunk/WebCore/xpath/impl/XPathParser.cpp
r14254 r14273 29 29 30 30 #include "XPathParser.h" 31 32 #include "DeprecatedString.h" 31 33 #include "XPathEvaluator.h" 32 34 … … 36 38 #include "XPathGrammar.h" 37 39 38 struct AxisNameMapping 39 { 40 struct AxisNameMapping { 40 41 const char* name; 41 42 Step::AxisType type; … … 58 59 }; 59 60 60 static unsigned intaxisNamesCount = sizeof(axisNames) / sizeof(axisNames[0]);61 static unsigned axisNamesCount = sizeof(axisNames) / sizeof(axisNames[0]); 61 62 static const char* const nodeTypeNames[] = { 62 63 "comment", … … 72 73 Parser* Parser::currentParser = 0; 73 74 74 Parser::XMLCat Parser::charCat( QChar aChar)75 Parser::XMLCat Parser::charCat(UChar aChar) 75 76 { 76 77 //### might need to add some special cases from the XML spec. 77 78 78 if (aChar .unicode()== '_')79 if (aChar == '_') 79 80 return NameStart; 80 81 81 if (aChar .unicode() == '.' || aChar.unicode()== '-')82 if (aChar == '.' || aChar == '-') 82 83 return NameCont; 83 switch (u_charType(aChar .unicode())) {84 switch (u_charType(aChar)) { 84 85 case U_LOWERCASE_LETTER: //Ll 85 86 case U_UPPERCASE_LETTER: //Lu … … 99 100 } 100 101 101 bool Parser::isAxisName( Stringname, Step::AxisType& type)102 bool Parser::isAxisName(const String& name, Step::AxisType& type) 102 103 { 103 104 if (!s_axisNamesDict) { 104 105 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); 108 108 } 109 109 110 110 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()) 116 113 return false; 117 } 118 119 bool Parser::isNodeTypeName(String name) 114 type = it->second; 115 return true; 116 } 117 118 bool Parser::isNodeTypeName(const String& name) 120 119 { 121 120 if (!s_nodeTypeNamesDict) { … … 149 148 void Parser::skipWS() 150 149 { 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()) 152 151 ++m_nextPos; 153 152 } … … 165 164 } 166 165 167 // Returns next char if it's there and interesting, 0 otherwise166 // Returns next char if it's there and interesting, 0 otherwise 168 167 char Parser::peekAheadHelper() 169 168 { 170 169 if (m_nextPos + 1 >= m_data.length()) 171 170 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) 174 173 return 0; 175 176 return next.unicode(); 174 return next; 177 175 } 178 176 … … 181 179 if (m_nextPos >= m_data.length()) 182 180 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) 185 183 return 0; 186 187 return next.unicode(); 184 return next; 188 185 } 189 186 190 187 Token Parser::lexString() 191 188 { 192 QChar delimiter = m_data[m_nextPos];189 UChar delimiter = m_data[m_nextPos]; 193 190 int startPos = m_nextPos + 1; 194 191 … … 215 212 //Go until end or a non-digits character 216 213 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) 222 219 seenDot = true; 223 220 else … … 337 334 338 335 skipWS(); 339 // If we're in an operator context, check for any operator names336 // If we're in an operator context, check for any operator names 340 337 if (isOperatorContext()) { 341 338 if (t1.value == "and") //### hash? … … 349 346 } 350 347 351 // See whether we are at a :348 // See whether we are at a : 352 349 if (peekCurHelper() == ':') { 353 350 m_nextPos++; 354 // Any chance it's an axis name?351 // Any chance it's an axis name? 355 352 if (peekCurHelper() == ':') { 356 353 m_nextPos++; … … 360 357 if (isAxisName(t1.value, axisType)) 361 358 return Token(AXISNAME, axisType); 362 // Ugh, :: is only valid in axis names -> error359 // Ugh, :: is only valid in axis names -> error 363 360 return Token(ERROR); 364 361 } 365 362 366 // Seems like this is a fully qualified qname, or perhaps the * modified one from NameTest363 // Seems like this is a fully qualified qname, or perhaps the * modified one from NameTest 367 364 skipWS(); 368 365 if (peekCurHelper() == '*') { … … 371 368 } 372 369 373 // Make a full qname..370 // Make a full qname.. 374 371 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; 378 376 } 379 377 … … 433 431 } 434 432 435 Expression* Parser::parseStatement(const String& statement, ExceptionCode& code)433 Expression* Parser::parseStatement(const String& statement, ExceptionCode& ec) 436 434 { 437 435 reset(statement); … … 449 447 450 448 if (m_gotNamespaceError) 451 code= NAMESPACE_ERR;449 ec = NAMESPACE_ERR; 452 450 else 453 code= INVALID_EXPRESSION_ERR;451 ec = INVALID_EXPRESSION_ERR; 454 452 return 0; 455 453 } else { … … 550 548 551 549 #endif // XPATH_SUPPORT 552 -
trunk/WebCore/xpath/impl/XPathParser.h
r14256 r14273 24 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 25 */ 26 26 27 #ifndef XPathParser_H 27 28 #define XPathParser_H … … 43 44 namespace XPath { 44 45 45 struct Token 46 { 46 struct Token { 47 47 int type; 48 48 String value; … … 50 50 51 51 Token(int t): type(t), intValue(0) {} 52 Token(int t, Stringv): type(t), value(v) {}52 Token(int t, const String& v): type(t), value(v) {} 53 53 Token(int t, int v): type(t), intValue(v) {} 54 54 }; … … 72 72 }; 73 73 74 XMLCat charCat( QChar aChar);74 XMLCat charCat(UChar); 75 75 76 bool isAxisName( Stringname, Step::AxisType &type);77 bool isNodeTypeName( Stringname);76 bool isAxisName(const String& name, Step::AxisType &type); 77 bool isNodeTypeName(const String& name); 78 78 bool isOperatorContext(); 79 79 … … 98 98 HashSet<Vector<Expression*>*> m_expressionVectors; 99 99 HashSet<String*> m_strings; 100 100 101 public: 101 102 Parser(); -
trunk/WebCore/xpath/impl/XPathPath.cpp
r14234 r14273 24 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 25 */ 26 26 27 #include "config.h" 27 28 28 29 #if XPATH_SUPPORT 29 30 30 #include "Logging.h"31 32 31 #include "XPathPath.h" 33 32 34 33 #include "Document.h" 34 #include "Logging.h" 35 35 #include "Node.h" 36 #include "XPathValue.h" 36 37 37 38 namespace WebCore { … … 39 40 40 41 Filter::Filter(Expression* expr, const Vector<Predicate*>& predicates) 41 : m_expr(expr), 42 m_predicates(predicates) 42 : m_expr(expr), m_predicates(predicates) 43 43 { 44 44 } -
trunk/WebCore/xpath/impl/XPathPredicate.cpp
r14264 r14273 24 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 25 */ 26 26 27 #include "config.h" 27 28 … … 29 30 30 31 #include "XPathPredicate.h" 32 33 #include "Logging.h" 34 #include "Node.h" 31 35 #include "XPathFunctions.h" 32 #include "Logging.h" 33 34 #include "Node.h" 35 36 #include "XPathValue.h" 36 37 #include <math.h> 37 38 -
trunk/WebCore/xpath/impl/XPathValue.cpp
r14264 r14273 24 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 25 */ 26 26 27 #include "config.h" 27 28 … … 29 30 30 31 #include "XPathValue.h" 32 33 #include "DeprecatedString.h" 31 34 #include "Logging.h" 32 35 … … 42 45 43 46 Value::Value() 47 : m_type(Boolean), m_bool(false) 44 48 { 45 49 } … … 48 52 : m_type(NodeVector_) 49 53 { 50 m_node vector.append(value);54 m_nodeVector.append(value); 51 55 } 52 56 53 57 Value::Value(const NodeVector& value) 54 : m_type(NodeVector_) 55 , m_nodevector(value) 58 : m_type(NodeVector_), m_nodeVector(value) 56 59 { 57 60 } 58 61 59 62 Value::Value(bool value) 60 : m_type(Boolean), 61 m_bool(value) 63 : m_type(Boolean), m_bool(value) 64 { 65 } 66 67 Value::Value(unsigned value) 68 : m_type(Number), m_number(value) 69 { 70 } 71 72 Value::Value(unsigned long value) 73 : m_type(Number), m_number(value) 62 74 { 63 75 } 64 76 65 77 Value::Value(double value) 66 : m_type(Number), 67 m_number(value) 78 : m_type(Number), m_number(value) 68 79 { 69 80 } 70 81 71 82 Value::Value(const String& value) 72 : m_type(String_), 73 m_string(value) 83 : m_type(String_), m_string(value) 74 84 { 75 }76 77 Value::Type Value::type() const78 {79 return m_type;80 }81 82 bool Value::isNodeVector() const83 {84 return m_type == NodeVector_;85 }86 87 bool Value::isBoolean() const88 {89 return m_type == Boolean;90 }91 92 bool Value::isNumber() const93 {94 return m_type == Number;95 }96 97 bool Value::isString() const98 {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;108 85 } 109 86 110 87 const NodeVector &Value::toNodeVector() const 111 88 { 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; 117 92 } 118 93 … … 121 96 switch (m_type) { 122 97 case NodeVector_: 123 return !m_node vector.isEmpty();98 return !m_nodeVector.isEmpty(); 124 99 case Boolean: 125 100 return m_bool; … … 141 116 case String_: { 142 117 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); 146 119 if (canConvert) 147 120 return value; 148 149 121 return NAN; 150 122 } … … 159 131 switch (m_type) { 160 132 case NodeVector_: 161 if (m_node vector.isEmpty())133 if (m_nodeVector.isEmpty()) 162 134 return ""; 163 164 return stringValue(m_nodevector[0].get()); 135 return stringValue(m_nodeVector[0].get()); 165 136 case String_: 166 137 return m_string; … … 168 139 if (isnan(m_number)) 169 140 return "NaN"; 170 elseif (m_number == 0)141 if (m_number == 0) 171 142 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); 179 146 case Boolean: 180 147 return m_bool ? "true" : "false"; 181 148 } 182 183 149 return String(); 184 150 } 185 186 151 187 152 } -
trunk/WebCore/xpath/impl/XPathValue.h
r14234 r14273 34 34 namespace XPath { 35 35 36 class Value 37 { 36 class Value { 38 37 public: 39 enum Type { 40 NodeVector_, Boolean, Number, String_ 41 }; 38 enum Type { NodeVector_, Boolean, Number, String_ }; 42 39 43 40 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&); 49 48 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; 59 57 bool toBoolean() const; 60 58 double toNumber() const; … … 63 61 private: 64 62 Type m_type; 65 NodeVector m_node vector;63 NodeVector m_nodeVector; 66 64 bool m_bool; 67 65 double m_number; -
trunk/WebCore/xpath/impl/XPathVariableReference.cpp
r14234 r14273 24 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 25 */ 26 26 27 #include "config.h" 27 28 … … 31 32 32 33 #include "PlatformString.h" 34 #include "XPathValue.h" 33 35 34 36 namespace WebCore {
Note: See TracChangeset
for help on using the changeset viewer.