diff options
Diffstat (limited to 'WebCore/platform')
-rw-r--r-- | WebCore/platform/android/FileChooserAndroid.cpp | 3 | ||||
-rw-r--r-- | WebCore/platform/android/FileSystemAndroid.cpp | 41 | ||||
-rw-r--r-- | WebCore/platform/android/KeyEventAndroid.cpp | 18 | ||||
-rw-r--r-- | WebCore/platform/android/LocalizedStringsAndroid.cpp | 4 | ||||
-rw-r--r-- | WebCore/platform/android/PopupMenuAndroid.cpp | 1 | ||||
-rw-r--r-- | WebCore/platform/android/RenderThemeAndroid.cpp | 136 | ||||
-rw-r--r-- | WebCore/platform/android/RenderThemeAndroid.h | 44 | ||||
-rw-r--r-- | WebCore/platform/android/TextBoundaries.cpp | 78 | ||||
-rw-r--r-- | WebCore/platform/text/android/TextBreakIteratorInternalICU.cpp (renamed from WebCore/platform/android/TextBreakIteratorInternalICU.cpp) | 0 |
9 files changed, 127 insertions, 198 deletions
diff --git a/WebCore/platform/android/FileChooserAndroid.cpp b/WebCore/platform/android/FileChooserAndroid.cpp index a8c4150..ec1b758 100644 --- a/WebCore/platform/android/FileChooserAndroid.cpp +++ b/WebCore/platform/android/FileChooserAndroid.cpp @@ -32,9 +32,8 @@ namespace WebCore { String FileChooser::basenameForWidth(const Font& font, int width) const { - if (m_filenames.size() == 0) { + if (!m_filenames.size()) return String(); - } // FIXME: This could be a lot faster, but assuming the data will not // often be much longer than the provided width, this may be fast enough. String output = m_filenames[0].copy(); diff --git a/WebCore/platform/android/FileSystemAndroid.cpp b/WebCore/platform/android/FileSystemAndroid.cpp index fcb0413..f2665a2 100644 --- a/WebCore/platform/android/FileSystemAndroid.cpp +++ b/WebCore/platform/android/FileSystemAndroid.cpp @@ -29,6 +29,7 @@ #include "FileSystem.h" #include "CString.h" +#include "StringBuilder.h" #include <fnmatch.h> #include <dlfcn.h> #include <dirent.h> @@ -42,7 +43,8 @@ namespace WebCore { // This is set in WebSettings.cpp String sPluginPath; -CString fileSystemRepresentation(const String& path) { +CString fileSystemRepresentation(const String& path) +{ return path.utf8(); } @@ -51,19 +53,20 @@ CString openTemporaryFile(const char* prefix, PlatformFileHandle& handle) int number = rand() % 10000 + 1; CString filename; do { - String path = sPluginPath; - path.append("/"); - path.append(prefix); - path.append(String::number(number)); - filename = path.utf8(); - const char *fstr = filename.data(); + StringBuilder builder; + builder.append(sPluginPath); + builder.append('/'); + builder.append(prefix); + builder.append(String::number(number)); + filename = builder.toString().utf8(); + const char* fstr = filename.data(); handle = open(filename.data(), O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); number++; - } while (handle == -1 && errno == EEXIST); + + if (handle != -1) + return filename; + } while (errno == EEXIST); - if (handle != -1) { - return filename; - } return CString(); } @@ -84,7 +87,7 @@ int writeToFile(PlatformFileHandle handle, const char* data, int length) { int totalBytesWritten = 0; while (totalBytesWritten < length) { - int bytesWritten = write(handle, data, length - totalBytesWritten); + int bytesWritten = write(handle, data, (size_t)(length - totalBytesWritten)); if (bytesWritten < 0 && errno != EINTR) return -1; else if (bytesWritten > 0) @@ -94,13 +97,11 @@ int writeToFile(PlatformFileHandle handle, const char* data, int length) return totalBytesWritten; } -// new as of SVN change 36269, Sept 8, 2008 String homeDirectoryPath() { return sPluginPath; } -// new as of webkit4, Feb 28, 2009 Vector<String> listDirectory(const String& path, const String& filter) { Vector<String> entries; @@ -108,15 +109,13 @@ Vector<String> listDirectory(const String& path, const String& filter) CString cfilter = filter.utf8(); DIR* dir = opendir(cpath.data()); if (dir) { - struct dirent * dp; - while ((dp = readdir(dir)) != NULL) { + struct dirent* dp; + while (dp = readdir(dir)) { const char* name = dp->d_name; - if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0) { + if (!strcmp(name, ".") || !strcmp(name, "..")) continue; - } - if (fnmatch(cfilter.data(), name, 0) != 0) { + if (fnmatch(cfilter.data(), name, 0)) continue; - } char filePath[1024]; if ((int) (sizeof(filePath) - 1) < snprintf(filePath, sizeof(filePath), "%s/%s", cpath.data(), name)) { @@ -129,4 +128,4 @@ Vector<String> listDirectory(const String& path, const String& filter) return entries; } -} +} // namespace WebCore diff --git a/WebCore/platform/android/KeyEventAndroid.cpp b/WebCore/platform/android/KeyEventAndroid.cpp index 5496bbc..ab848bd 100644 --- a/WebCore/platform/android/KeyEventAndroid.cpp +++ b/WebCore/platform/android/KeyEventAndroid.cpp @@ -1,5 +1,10 @@ /* * Copyright 2007, The Android Open Source Project + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com + * Copyright (C) 2007 Holger Hans Peter Freyther + * Copyright (C) 2008 Collabora, Ltd. All rights reserved. + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -33,7 +38,8 @@ namespace WebCore { // compare to same function in gdk/KeyEventGdk.cpp -static int windowsKeyCodeForKeyEvent(unsigned int keyCode) { +static int windowsKeyCodeForKeyEvent(unsigned int keyCode) +{ // Does not provide all key codes, and does not handle all keys. switch(keyCode) { case kKeyCodeDel: @@ -190,7 +196,7 @@ static String keyIdentifierForAndroidKeyCode(int keyCode) } } -static inline String singleCharacterString(int c) +static inline String singleCharacterString(UChar32 c) { if (!c) return String(); @@ -215,10 +221,10 @@ PlatformKeyboardEvent::PlatformKeyboardEvent(int keyCode, UChar32 unichar, , m_windowsVirtualKeyCode(windowsKeyCodeForKeyEvent(keyCode)) , m_nativeVirtualKeyCode(keyCode) , m_isKeypad(false) - , m_shiftKey((mods & ShiftKey) != 0) - , m_ctrlKey((mods & CtrlKey) != 0) - , m_altKey((mods & AltKey) != 0) - , m_metaKey((mods & MetaKey) != 0) + , m_shiftKey((mods & ShiftKey)) + , m_ctrlKey((mods & CtrlKey)) + , m_altKey((mods & AltKey)) + , m_metaKey((mods & MetaKey)) // added for android , m_repeatCount(repeatCount) , m_unichar(unichar) diff --git a/WebCore/platform/android/LocalizedStringsAndroid.cpp b/WebCore/platform/android/LocalizedStringsAndroid.cpp index 02f135f..1fe80d8 100644 --- a/WebCore/platform/android/LocalizedStringsAndroid.cpp +++ b/WebCore/platform/android/LocalizedStringsAndroid.cpp @@ -37,12 +37,12 @@ namespace WebCore { String contextMenuItemTagInspectElement() { - return String::fromUTF8("Inspect Element"); + return String("Inspect Element"); } String unknownFileSizeText() { - return String::fromUTF8("Unknown"); + return String("Unknown"); } String imageTitle(const String& filename, const IntSize& size) diff --git a/WebCore/platform/android/PopupMenuAndroid.cpp b/WebCore/platform/android/PopupMenuAndroid.cpp index 4d1fe04..8a1ed07 100644 --- a/WebCore/platform/android/PopupMenuAndroid.cpp +++ b/WebCore/platform/android/PopupMenuAndroid.cpp @@ -39,7 +39,6 @@ PopupMenu::~PopupMenu() void PopupMenu::show(const IntRect&, FrameView*, int) { - } void PopupMenu::hide() diff --git a/WebCore/platform/android/RenderThemeAndroid.cpp b/WebCore/platform/android/RenderThemeAndroid.cpp index 4f31967..a1e8bf6 100644 --- a/WebCore/platform/android/RenderThemeAndroid.cpp +++ b/WebCore/platform/android/RenderThemeAndroid.cpp @@ -36,18 +36,19 @@ #include "RenderSkinRadio.h" #include "SkCanvas.h" -#define MAX_COMBO_HEIGHT 20 +namespace WebCore { -// Add a constant amount of padding to the textsize to get the final height of buttons, -// so that our button images are large enough to properly fit the text. -#define BUTTON_PADDING 18 +const int MAX_COMBO_HEIGHT = 20; -// Add padding to the fontSize of ListBoxes to get their maximum sizes. -// Listboxes often have a specified size. Since we change them into dropdowns, -// we want a much smaller height, which encompasses the text. -#define LISTBOX_PADDING 5 +// Add a constant amount of padding to the textsize to get the final height +// of buttons, so that our button images are large enough to properly fit +// the text. +const int BUTTON_PADDING = 18; -namespace WebCore { +// Add padding to the fontSize of ListBoxes to get their maximum sizes. +// Listboxes often have a specified size. Since we change them into +// dropdowns, we want a much smaller height, which encompasses the text. +const int LISTBOX_PADDING = 5; // This is the color of selection in a textfield. It was obtained by checking // the color of selection in TextViews in the system. @@ -76,10 +77,10 @@ void RenderThemeAndroid::close() { } -bool RenderThemeAndroid::stateChanged(RenderObject* o, ControlState state) const +bool RenderThemeAndroid::stateChanged(RenderObject* obj, ControlState state) const { if (CheckedState == state) { - o->repaint(); + obj->repaint(); return true; } return false; @@ -149,18 +150,18 @@ void RenderThemeAndroid::addIntrinsicMargins(RenderStyle* style) const bool RenderThemeAndroid::supportsFocus(ControlPart appearance) { switch (appearance) { - case PushButtonPart: - case ButtonPart: - case TextFieldPart: - return true; - default: - return false; + case PushButtonPart: + case ButtonPart: + case TextFieldPart: + return true; + default: + return false; } return false; } -void RenderThemeAndroid::adjustButtonStyle(CSSStyleSelector* selector, RenderStyle* style, WebCore::Element* e) const +void RenderThemeAndroid::adjustButtonStyle(CSSStyleSelector*, RenderStyle* style, WebCore::Element*) const { // Padding code is taken from RenderThemeSafari.cpp // It makes sure we have enough space for the button text. @@ -170,30 +171,30 @@ void RenderThemeAndroid::adjustButtonStyle(CSSStyleSelector* selector, RenderSty style->setMinHeight(Length(style->fontSize() + BUTTON_PADDING, Fixed)); } -bool RenderThemeAndroid::paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& ir) +bool RenderThemeAndroid::paintCheckbox(RenderObject* obj, const RenderObject::PaintInfo& info, const IntRect& rect) { - RenderSkinRadio::Draw(getCanvasFromInfo(i), o->node(), ir, true); + RenderSkinRadio::Draw(getCanvasFromInfo(info), obj->node(), rect, true); return false; } -bool RenderThemeAndroid::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& ir) +bool RenderThemeAndroid::paintButton(RenderObject* obj, const RenderObject::PaintInfo& info, const IntRect& rect) { // If it is a disabled button, simply paint it to the master picture. - Node* node = o->node(); + Node* node = obj->node(); FormControlElement* formControlElement = toFormControlElement(static_cast<Element*>(node)); - if (formControlElement && !formControlElement->isEnabled()) { - RenderSkinButton::Draw(getCanvasFromInfo(i), ir, RenderSkinAndroid::kDisabled); - } else { + if (formControlElement && !formControlElement->isEnabled()) + RenderSkinButton::Draw(getCanvasFromInfo(info), rect, RenderSkinAndroid::kDisabled); + else // Store all the important information in the platform context. - i.context->platformContext()->storeButtonInfo(node, ir); - } + info.context->platformContext()->storeButtonInfo(node, rect); + // We always return false so we do not request to be redrawn. return false; } -bool RenderThemeAndroid::paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& ir) +bool RenderThemeAndroid::paintRadio(RenderObject* obj, const RenderObject::PaintInfo& info, const IntRect& rect) { - RenderSkinRadio::Draw(getCanvasFromInfo(i), o->node(), ir, false); + RenderSkinRadio::Draw(getCanvasFromInfo(info), obj->node(), rect, false); return false; } @@ -209,40 +210,39 @@ void RenderThemeAndroid::setRadioSize(RenderStyle* style) const setCheckboxSize(style); } -void RenderThemeAndroid::adjustTextFieldStyle(CSSStyleSelector* selector, RenderStyle* style, WebCore::Element* e) const +void RenderThemeAndroid::adjustTextFieldStyle(CSSStyleSelector*, RenderStyle* style, WebCore::Element*) const { addIntrinsicMargins(style); } -bool RenderThemeAndroid::paintTextField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& ir) +bool RenderThemeAndroid::paintTextField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } -void RenderThemeAndroid::adjustTextAreaStyle(CSSStyleSelector* selector, RenderStyle* style, WebCore::Element* e) const +void RenderThemeAndroid::adjustTextAreaStyle(CSSStyleSelector*, RenderStyle* style, WebCore::Element*) const { addIntrinsicMargins(style); } -bool RenderThemeAndroid::paintTextArea(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& ir) +bool RenderThemeAndroid::paintTextArea(RenderObject* obj, const RenderObject::PaintInfo& info, const IntRect& rect) { - if (o->isMenuList()) { - return paintCombo(o, i, ir); - } + if (obj->isMenuList()) + return paintCombo(obj, info, rect); return true; } -void RenderThemeAndroid::adjustSearchFieldStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const +void RenderThemeAndroid::adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle* style, Element*) const { addIntrinsicMargins(style); } -bool RenderThemeAndroid::paintSearchField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& ir) +bool RenderThemeAndroid::paintSearchField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } -void RenderThemeAndroid::adjustListboxStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const +void RenderThemeAndroid::adjustListboxStyle(CSSStyleSelector*, RenderStyle* style, Element*) const { style->setPaddingRight(Length(RenderSkinCombo::extraWidth(), Fixed)); style->setMaxHeight(Length(style->fontSize() + LISTBOX_PADDING, Fixed)); @@ -261,34 +261,34 @@ static void adjustMenuListStyleCommon(RenderStyle* style, Element* e) style->setColor(isEnabled ? Color::black : Color::darkGray); } -void RenderThemeAndroid::adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const +void RenderThemeAndroid::adjustMenuListStyle(CSSStyleSelector*, RenderStyle* style, Element* e) const { adjustMenuListStyleCommon(style, e); addIntrinsicMargins(style); } -bool RenderThemeAndroid::paintCombo(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& ir) +bool RenderThemeAndroid::paintCombo(RenderObject* obj, const RenderObject::PaintInfo& info, const IntRect& rect) { - if (o->style() && o->style()->backgroundColor().alpha() == 0) + if (obj->style() && !obj->style()->backgroundColor().alpha()) return true; - Node* node = o->node(); - int height = ir.height(); - int y = ir.y(); + Node* node = obj->node(); + int height = rect.height(); + int y = rect.y(); // If the combo box is too large, leave it at its max height, and center it. if (height > MAX_COMBO_HEIGHT) { y += (height - MAX_COMBO_HEIGHT) >> 1; height = MAX_COMBO_HEIGHT; } - return RenderSkinCombo::Draw(getCanvasFromInfo(i), node, ir.x(), y, - ir.width(), height); + return RenderSkinCombo::Draw(getCanvasFromInfo(info), node, rect.x(), y, + rect.width(), height); } -bool RenderThemeAndroid::paintMenuList(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& ir) +bool RenderThemeAndroid::paintMenuList(RenderObject* obj, const RenderObject::PaintInfo& info, const IntRect& rect) { - return paintCombo(o, i, ir); + return paintCombo(obj, info, rect); } -void RenderThemeAndroid::adjustMenuListButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const +void RenderThemeAndroid::adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle* style, Element* e) const { // Copied from RenderThemeSafari. const float baseFontSize = 11.0f; @@ -309,26 +309,26 @@ void RenderThemeAndroid::adjustMenuListButtonStyle(CSSStyleSelector* selector, R adjustMenuListStyleCommon(style, e); } -bool RenderThemeAndroid::paintMenuListButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& ir) +bool RenderThemeAndroid::paintMenuListButton(RenderObject* obj, const RenderObject::PaintInfo& info, const IntRect& rect) { - return paintCombo(o, i, ir); + return paintCombo(obj, info, rect); } bool RenderThemeAndroid::supportsFocusRing(const RenderStyle* style) const { - return (style->opacity() > 0 && style->hasAppearance() - && style->appearance() != TextFieldPart - && style->appearance() != SearchFieldPart - && style->appearance() != TextAreaPart - && style->appearance() != CheckboxPart - && style->appearance() != RadioPart - && style->appearance() != PushButtonPart - && style->appearance() != SquareButtonPart - && style->appearance() != ButtonPart - && style->appearance() != ButtonBevelPart - && style->appearance() != MenulistPart - && style->appearance() != MenulistButtonPart - ); -} - -} + return style->opacity() > 0 + && style->hasAppearance() + && style->appearance() != TextFieldPart + && style->appearance() != SearchFieldPart + && style->appearance() != TextAreaPart + && style->appearance() != CheckboxPart + && style->appearance() != RadioPart + && style->appearance() != PushButtonPart + && style->appearance() != SquareButtonPart + && style->appearance() != ButtonPart + && style->appearance() != ButtonBevelPart + && style->appearance() != MenulistPart + && style->appearance() != MenulistButtonPart; +} + +} // namespace WebCore diff --git a/WebCore/platform/android/RenderThemeAndroid.h b/WebCore/platform/android/RenderThemeAndroid.h index 3b6e9cb..056b2d6 100644 --- a/WebCore/platform/android/RenderThemeAndroid.h +++ b/WebCore/platform/android/RenderThemeAndroid.h @@ -35,7 +35,11 @@ class RenderSkinRadio; class RenderSkinCombo; struct ThemeData { - ThemeData() :m_part(0), m_state(0) {} + ThemeData() + : m_part(0) + , m_state(0) + { + } unsigned m_part; unsigned m_state; @@ -48,7 +52,7 @@ public: virtual bool stateChanged(RenderObject*, ControlState) const; - virtual bool supportsFocusRing(const RenderStyle* style) const; + virtual bool supportsFocusRing(const RenderStyle*) const; // A method asking if the theme's controls actually care about redrawing when hovered. virtual bool supportsHover(const RenderStyle* style) const { return style->affectedByHoverRules(); } @@ -65,38 +69,38 @@ public: virtual int minimumMenuListSize(RenderStyle*) const { return 0; } protected: - virtual bool paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r); - virtual void setCheckboxSize(RenderStyle* style) const; + virtual bool paintCheckbox(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); + virtual void setCheckboxSize(RenderStyle*) const; - virtual bool paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r); - virtual void setRadioSize(RenderStyle* style) const; + virtual bool paintRadio(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); + virtual void setRadioSize(RenderStyle*) const; - virtual void adjustButtonStyle(CSSStyleSelector* selector, RenderStyle* style, WebCore::Element* e) const; - virtual bool paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r); + virtual void adjustButtonStyle(CSSStyleSelector*, RenderStyle*, WebCore::Element*) const; + virtual bool paintButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); - virtual void adjustTextFieldStyle(CSSStyleSelector* selector, RenderStyle* style, WebCore::Element* e) const; - virtual bool paintTextField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r); + virtual void adjustTextFieldStyle(CSSStyleSelector*, RenderStyle*, WebCore::Element*) const; + virtual bool paintTextField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); - virtual void adjustTextAreaStyle(CSSStyleSelector* selector, RenderStyle* style, WebCore::Element* e) const; - virtual bool paintTextArea(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r); + virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle*, WebCore::Element*) const; + virtual bool paintTextArea(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); - bool paintCombo(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& ir); + bool paintCombo(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); - virtual void adjustListboxStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const; - virtual void adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const; - virtual bool paintMenuList(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r); + virtual void adjustListboxStyle(CSSStyleSelector*, RenderStyle*, Element*) const; + virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const; + virtual bool paintMenuList(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); - virtual void adjustMenuListButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const; - virtual bool paintMenuListButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r); + virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; + virtual bool paintMenuListButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const; virtual bool paintSearchField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); private: - void addIntrinsicMargins(RenderStyle* style) const; + void addIntrinsicMargins(RenderStyle*) const; void close(); - bool supportsFocus(ControlPart appearance); + bool supportsFocus(ControlPart); }; } // namespace WebCore diff --git a/WebCore/platform/android/TextBoundaries.cpp b/WebCore/platform/android/TextBoundaries.cpp deleted file mode 100644 index 457a36e..0000000 --- a/WebCore/platform/android/TextBoundaries.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2009, The Android Open Source Project - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "TextBoundaries.h" - -#include <unicode/ubrk.h> - -#include "TextBreakIterator.h" - -namespace WebCore { - -int findNextWordFromIndex(const UChar* chars, int len, int position, bool forward) -{ - UBreakIterator* it = wordBreakIterator(chars, len); - - int newPosition = position; - - if (forward) { - position = ubrk_following(it, position); - while (position != UBRK_DONE) { - // We stop searching when the character preceeding the break - // is alphanumeric. - if (position < len && u_isalnum(chars[position - 1])) - return position; - - position = ubrk_following(it, position); - } - - return len; - } else { - position = ubrk_preceding(it, position); - while (position != UBRK_DONE) { - // We stop searching when the character following the break - // is alphanumeric. - if (position > 0 && u_isalnum(chars[position])) - return position; - - position = ubrk_preceding(it, position); - } - - return 0; - } -} - -void findWordBoundary(const UChar* chars, int len, int position, int* start, int* end) -{ - UBreakIterator* it = wordBreakIterator(chars, len); - *end = ubrk_following(it, position); - if (*end < 0) - *end = ubrk_last(it); - *start = ubrk_previous(it); -} - -} // namespace WebCore diff --git a/WebCore/platform/android/TextBreakIteratorInternalICU.cpp b/WebCore/platform/text/android/TextBreakIteratorInternalICU.cpp index 9bebe74..9bebe74 100644 --- a/WebCore/platform/android/TextBreakIteratorInternalICU.cpp +++ b/WebCore/platform/text/android/TextBreakIteratorInternalICU.cpp |