diff options
48 files changed, 1678 insertions, 543 deletions
@@ -186,3 +186,8 @@ include $(BASE_PATH)/WebKit/android/plugins/sample/Android.mk # Build the wds client include $(BASE_PATH)/WebKit/android/wds/client/Android.mk + +# Build the performance command line tool. +# XXX: Uncomment this include to build webcore_test. In order for the test to +# link with libwebcore, remove -fvisibility=hidden from LOCAL_CFLAGS above +#include $(BASE_PATH)/perf/Android.mk diff --git a/WebCore/WebCorePrefixAndroid.h b/WebCore/WebCorePrefixAndroid.h index ff70c01..c4782b6 100644 --- a/WebCore/WebCorePrefixAndroid.h +++ b/WebCore/WebCorePrefixAndroid.h @@ -55,7 +55,6 @@ #include "heap.h" #include <memory> #include <new> -#include <wtf/Vector.h> #endif diff --git a/WebCore/editing/android/EditorAndroid.cpp b/WebCore/editing/android/EditorAndroid.cpp index aa12fb0..8e00326 100644 --- a/WebCore/editing/android/EditorAndroid.cpp +++ b/WebCore/editing/android/EditorAndroid.cpp @@ -26,15 +26,8 @@ #include "config.h" #include "Editor.h" -#include "EditorClient.h" #include "ClipboardAndroid.h" -#include "Document.h" -#include "Element.h" -#include "htmlediting.h" -#include "NotImplemented.h" -#include "TextIterator.h" -#include "visible_units.h" namespace WebCore { diff --git a/WebCore/page/android/DragControllerAndroid.cpp b/WebCore/page/android/DragControllerAndroid.cpp index 48b60ca..ae87f02 100644 --- a/WebCore/page/android/DragControllerAndroid.cpp +++ b/WebCore/page/android/DragControllerAndroid.cpp @@ -28,9 +28,6 @@ #include "DragController.h" #include "DragData.h" -#include "Frame.h" -#include "FrameView.h" -#include "Page.h" namespace WebCore { @@ -49,7 +46,6 @@ DragOperation DragController::dragOperation(DragData* dragData) return DragOperationNone; } -// functions new to Jun-07 tip of tree merge: const float DragController::DragImageAlpha = 1.0f; static IntSize dummy; const IntSize& DragController::maxDragImageSize() { return dummy; } @@ -58,4 +54,4 @@ const int DragController::DragIconBottomInset = 0; const int DragController::LinkDragBorderInset = 0; const int DragController::MaxOriginalImageArea = 0; -} +} // namespace WebCore diff --git a/WebCore/page/android/EventHandlerAndroid.cpp b/WebCore/page/android/EventHandlerAndroid.cpp index c0ca503..62ccd2e 100644 --- a/WebCore/page/android/EventHandlerAndroid.cpp +++ b/WebCore/page/android/EventHandlerAndroid.cpp @@ -28,14 +28,10 @@ #include "config.h" #include "EventHandler.h" -#include "EventNames.h" -#include "FloatPoint.h" #include "FocusController.h" #include "Frame.h" -#include "FrameView.h" #include "KeyboardEvent.h" #include "MouseEventWithHitTestResults.h" -#include "NotImplemented.h" #include "Page.h" #include "PlatformKeyboardEvent.h" #include "PlatformWheelEvent.h" @@ -73,13 +69,13 @@ bool EventHandler::passWidgetMouseDownEventToWidget(RenderWidget* renderWidget) // This function is used to route the mouse down event to the native widgets, it seems like a // work around for the Mac platform which does not support double clicks, but browsers do. -bool EventHandler::passMouseDownEventToWidget(Widget* widget) +bool EventHandler::passMouseDownEventToWidget(Widget*) { // return false so the normal propogation handles the event return false; } -bool EventHandler::eventActivatedView(const PlatformMouseEvent& event) const +bool EventHandler::eventActivatedView(const PlatformMouseEvent&) const { notImplemented(); return false; @@ -89,8 +85,7 @@ bool EventHandler::eventActivatedView(const PlatformMouseEvent& event) const // It is used to ensure that events are sync'ed correctly between frames. For example // if the user presses down in one frame and up in another frame, this function will // returns true, and pass the event to the correct frame. -bool EventHandler::passSubframeEventToSubframe(MouseEventWithHitTestResults& event, - Frame* subframe, HitTestResult* hoveredNode) +bool EventHandler::passSubframeEventToSubframe(MouseEventWithHitTestResults&, Frame*, HitTestResult*) { notImplemented(); return false; @@ -99,7 +94,7 @@ bool EventHandler::passSubframeEventToSubframe(MouseEventWithHitTestResults& eve // This is called to route wheel events to child widgets when they are RenderWidget // as the parent usually gets wheel event. Don't have a mouse with a wheel to confirm // the operation of this function. -bool EventHandler::passWheelEventToWidget(PlatformWheelEvent& , Widget* widget) +bool EventHandler::passWheelEventToWidget(PlatformWheelEvent&, Widget*) { notImplemented(); return false; @@ -111,7 +106,7 @@ bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& m } bool EventHandler::passMouseMoveEventToSubframe(MouseEventWithHitTestResults& mev, - Frame* subframe, HitTestResult* hoveredNode) + Frame* subframe, HitTestResult*) { return passSubframeEventToSubframe(mev, subframe); } @@ -121,11 +116,14 @@ bool EventHandler::passMouseReleaseEventToSubframe(MouseEventWithHitTestResults& return passSubframeEventToSubframe(mev, subframe); } -// functions new to Jun-07 tip of tree merge: -class Clipboard : public RefCounted<Clipboard> {}; +class Clipboard : public RefCounted<Clipboard> { +}; -PassRefPtr<Clipboard> EventHandler::createDraggingClipboard() const { return PassRefPtr<Clipboard>(NULL); } +PassRefPtr<Clipboard> EventHandler::createDraggingClipboard() const +{ + return PassRefPtr<Clipboard>(0); +} -// new as of SVN change 36269, Sept 8, 2008 const double EventHandler::TextDragDelay = 0.0; -} + +} // namespace WebCore diff --git a/WebCore/page/android/InspectorControllerAndroid.cpp b/WebCore/page/android/InspectorControllerAndroid.cpp index db1b5ee..4f55ec4 100644 --- a/WebCore/page/android/InspectorControllerAndroid.cpp +++ b/WebCore/page/android/InspectorControllerAndroid.cpp @@ -24,8 +24,10 @@ */ #include "config.h" -#include "InspectorClient.h" #include "InspectorController.h" + +#include "InspectorClient.h" + #include "Frame.h" #include "Node.h" #include "Profile.h" @@ -62,7 +64,7 @@ struct InspectorDatabaseResource : public RefCounted<InspectorDatabaseResource> }; InspectorController::InspectorController(Page*, InspectorClient* client) - : m_startProfiling(this, NULL) + : m_startProfiling(this, 0) { m_client = client; } @@ -91,7 +93,6 @@ void InspectorController::addProfile(PassRefPtr<JSC::Profile>, unsigned int, con void InspectorController::inspectedPageDestroyed() {} void InspectorController::resourceRetrievedByXMLHttpRequest(unsigned long identifier, JSC::UString& sourceString) {} - // new as of SVN change 36269, Sept 8, 2008 void InspectorController::inspectedWindowScriptObjectCleared(Frame* frame) {} void InspectorController::startGroup(MessageSource source, JSC::ExecState* exec, const JSC::ArgList& arguments, unsigned lineNumber, const String& sourceURL) {} void InspectorController::endGroup(MessageSource source, unsigned lineNumber, const String& sourceURL) {} @@ -99,10 +100,10 @@ void InspectorController::startTiming(const JSC::UString& title) {} bool InspectorController::stopTiming(const JSC::UString& title, double& elapsed) { return false; } void InspectorController::count(const JSC::UString& title, unsigned lineNumber, const String& sourceID) {} - // new as of SVN change 38068, Nov 5, 2008 void InspectorController::mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags) {} void InspectorController::handleMousePressOnNode(Node*) {} void InspectorController::failedToParseSource(JSC::ExecState* exec, const JSC::SourceCode& source, int errorLine, const JSC::UString& errorMessage) {} void InspectorController::didParseSource(JSC::ExecState* exec, const JSC::SourceCode& source) {} void InspectorController::didPause() {} -} + +} // namespace WebCore diff --git a/WebCore/platform/Widget.h b/WebCore/platform/Widget.h index 78df197..1b82ab4 100644 --- a/WebCore/platform/Widget.h +++ b/WebCore/platform/Widget.h @@ -198,7 +198,7 @@ private: IntRect m_frame; // Not used when a native widget exists. -#if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(ANDROID) +#if PLATFORM(MAC) || PLATFORM(GTK) WidgetPrivate* m_data; #endif #if PLATFORM(ANDROID) diff --git a/WebCore/platform/android/ClipboardAndroid.cpp b/WebCore/platform/android/ClipboardAndroid.cpp index 83c65e2..942c628 100644 --- a/WebCore/platform/android/ClipboardAndroid.cpp +++ b/WebCore/platform/android/ClipboardAndroid.cpp @@ -28,35 +28,13 @@ #include "ClipboardAndroid.h" #include "CachedImage.h" -#include "CSSHelper.h" -#include "CString.h" -#include "Document.h" -#include "DragData.h" #include "Element.h" -#include "EventHandler.h" #include "Frame.h" -#include "FrameLoader.h" -#include "FrameView.h" -#include "HTMLNames.h" -#include "Image.h" -//#include "MimeTypeRegistry.h" -#include "markup.h" -#include "Page.h" -#include "Pasteboard.h" -#include "PlatformMouseEvent.h" -#include "PlatformString.h" #include "Range.h" -#include "RenderImage.h" -#include "ResourceResponse.h" -#include "StringHash.h" - -#include <wtf/RefPtr.h> namespace WebCore { -using namespace HTMLNames; - -// format string for +// format string for static const char szShellDotUrlTemplate[] = "[InternetShortcut]\r\nURL=%s\r\n"; // We provide the IE clipboard types (URL and Text), and the clipboard types specified in the WHATWG Web Applications 1.0 draft @@ -119,8 +97,9 @@ String ClipboardAndroid::getData(const String& type, bool& success) const return ""; } + /* ClipboardDataType dataType = clipboardTypeFromMIMEType(type); - /* if (dataType == ClipboardDataTypeText) + if (dataType == ClipboardDataTypeText) return getPlainText(m_dataObject.get(), success); else if (dataType == ClipboardDataTypeURL) return getURL(m_dataObject.get(), success); diff --git a/WebCore/platform/android/ContextMenuClientAndroid.cpp b/WebCore/platform/android/ContextMenuClientAndroid.cpp index 4b75333..7aabfc9 100644 --- a/WebCore/platform/android/ContextMenuClientAndroid.cpp +++ b/WebCore/platform/android/ContextMenuClientAndroid.cpp @@ -25,8 +25,9 @@ #include "config.h" #include "ContextMenuClientAndroid.h" + #include "NotImplemented.h" -#include "wtf/Assertions.h" +#include <wtf/Assertions.h> namespace WebCore { diff --git a/WebCore/platform/android/ContextMenuClientAndroid.h b/WebCore/platform/android/ContextMenuClientAndroid.h index 9d91a3a..1860e4e 100644 --- a/WebCore/platform/android/ContextMenuClientAndroid.h +++ b/WebCore/platform/android/ContextMenuClientAndroid.h @@ -45,6 +45,6 @@ public: virtual void stopSpeaking(); }; -} +} // namespace WebCore -#endif +#endif // ContextMenuClientAndroid_h diff --git a/WebCore/platform/android/CursorAndroid.cpp b/WebCore/platform/android/CursorAndroid.cpp index e84070f..7564384 100644 --- a/WebCore/platform/android/CursorAndroid.cpp +++ b/WebCore/platform/android/CursorAndroid.cpp @@ -31,12 +31,12 @@ namespace WebCore { -Cursor::Cursor(Image* image, const IntPoint& ) +Cursor::Cursor(Image*, const IntPoint&) { notImplemented(); } -Cursor::Cursor(const Cursor& other) +Cursor::Cursor(const Cursor&) { notImplemented(); } @@ -46,7 +46,7 @@ Cursor::~Cursor() notImplemented(); } -Cursor& Cursor::operator=(const Cursor& other) +Cursor& Cursor::operator=(const Cursor&) { notImplemented(); return *this; @@ -255,7 +255,7 @@ const Cursor& noneCursor() return c; } - // new as of SVN change 36269, Sept 8, 2008 +// new as of SVN change 36269, Sept 8, 2008 const Cursor& middlePanningCursor() { notImplemented(); @@ -319,8 +319,17 @@ const Cursor& westPanningCursor() return c; } - // new as of SVN change 38068, Nov 5, 2008 -const Cursor& grabCursor() {} -const Cursor& grabbingCursor() {} +// new as of SVN change 38068, Nov 5, 2008 +const Cursor& grabCursor() { + notImplemented(); + static Cursor c; + return c; +} + +const Cursor& grabbingCursor() { + notImplemented(); + static Cursor c; + return c; +} } diff --git a/WebCore/platform/android/DragDataAndroid.cpp b/WebCore/platform/android/DragDataAndroid.cpp index dca50a8..d62df20 100644 --- a/WebCore/platform/android/DragDataAndroid.cpp +++ b/WebCore/platform/android/DragDataAndroid.cpp @@ -61,7 +61,7 @@ class Clipboard : public RefCounted<Clipboard> {}; PassRefPtr<Clipboard> DragData::createClipboard(ClipboardAccessPolicy) const { - return PassRefPtr<Clipboard>(NULL); + return PassRefPtr<Clipboard>(0); } bool DragData::containsCompatibleContent() const diff --git a/WebCore/platform/android/EventLoopAndroid.cpp b/WebCore/platform/android/EventLoopAndroid.cpp index 86be31f..3a6d7ed 100644 --- a/WebCore/platform/android/EventLoopAndroid.cpp +++ b/WebCore/platform/android/EventLoopAndroid.cpp @@ -25,6 +25,7 @@ #include "config.h" #include "EventLoop.h" + #include "NotImplemented.h" namespace WebCore { diff --git a/WebCore/platform/android/FileChooserAndroid.cpp b/WebCore/platform/android/FileChooserAndroid.cpp index 4b72343..004b653 100644 --- a/WebCore/platform/android/FileChooserAndroid.cpp +++ b/WebCore/platform/android/FileChooserAndroid.cpp @@ -25,10 +25,8 @@ #include "config.h" #include "FileChooser.h" + #include "Font.h" -#include "Icon.h" -#include "LocalizedStrings.h" -#include "PlatformString.h" namespace WebCore { @@ -41,7 +39,6 @@ String FileChooser::basenameForWidth(const Font& font, int width) const output = output.replace(output.length() - 4, 4, String("...")); } return output; - } diff --git a/WebCore/platform/android/FileSystemAndroid.cpp b/WebCore/platform/android/FileSystemAndroid.cpp index d7cfbf1..b6d58bc 100644 --- a/WebCore/platform/android/FileSystemAndroid.cpp +++ b/WebCore/platform/android/FileSystemAndroid.cpp @@ -26,9 +26,8 @@ */ #include "config.h" - #include "FileSystem.h" -#include "PlatformString.h" + #include "CString.h" #include <dlfcn.h> #include <errno.h> @@ -93,7 +92,7 @@ int writeToFile(PlatformFileHandle handle, const char* data, int length) return totalBytesWritten; } - // new as of SVN change 36269, Sept 8, 2008 +// new as of SVN change 36269, Sept 8, 2008 String homeDirectoryPath() { return sPluginPath; diff --git a/WebCore/platform/android/KeyEventAndroid.cpp b/WebCore/platform/android/KeyEventAndroid.cpp index 7260320..1a245a4 100644 --- a/WebCore/platform/android/KeyEventAndroid.cpp +++ b/WebCore/platform/android/KeyEventAndroid.cpp @@ -24,16 +24,17 @@ */ #include "config.h" +#include "PlatformKeyboardEvent.h" + #include "KeyboardCodes.h" #include "NotImplemented.h" -#include "PlatformKeyboardEvent.h" #include <ui/KeycodeLabels.h> namespace WebCore { // compare to same function in gdk/KeyEventGdk.cpp static int windowsKeyCodeForKeyEvent(unsigned int keyCode) { -// Does not provide all key codes, and does not handle all keys. + // Does not provide all key codes, and does not handle all keys. switch(keyCode) { case kKeyCodeDel: return VK_BACK; @@ -161,9 +162,8 @@ static int windowsKeyCodeForKeyEvent(unsigned int keyCode) { static String keyIdentifierForAndroidKeyCode(int keyCode) { -/* Does not return all of the same key identifiers, and - * does not handle all the keys. - */ + // Does not return all of the same key identifiers, and + // does not handle all the keys. switch (keyCode) { case kKeyCodeClear: return "Clear"; @@ -180,7 +180,7 @@ static String keyIdentifierForAndroidKeyCode(int keyCode) return "Right"; case kKeyCodeDpadUp: return "Up"; - // Standard says that DEL becomes U+00007F. + // Standard says that DEL becomes U+00007F. case kKeyCodeDel: return "U+00007F"; default: diff --git a/WebCore/platform/android/KeyboardCodes.h b/WebCore/platform/android/KeyboardCodes.h index 758ee5e..321e9da 100644 --- a/WebCore/platform/android/KeyboardCodes.h +++ b/WebCore/platform/android/KeyboardCodes.h @@ -542,4 +542,4 @@ const int VK_UNKNOWN = 0; } -#endif +#endif // KeyboardCodes_h diff --git a/WebCore/platform/android/LocalizedStringsAndroid.cpp b/WebCore/platform/android/LocalizedStringsAndroid.cpp index 42152e5..540dc04 100644 --- a/WebCore/platform/android/LocalizedStringsAndroid.cpp +++ b/WebCore/platform/android/LocalizedStringsAndroid.cpp @@ -28,8 +28,8 @@ */ #include "config.h" - #include "LocalizedStrings.h" + #include "NotImplemented.h" #include "PlatformString.h" diff --git a/WebCore/platform/android/PopupMenuAndroid.cpp b/WebCore/platform/android/PopupMenuAndroid.cpp index 61e0535..2cc244b 100644 --- a/WebCore/platform/android/PopupMenuAndroid.cpp +++ b/WebCore/platform/android/PopupMenuAndroid.cpp @@ -36,7 +36,7 @@ PopupMenu::~PopupMenu() { } -void PopupMenu::show(const IntRect& rect, FrameView* view, int index) +void PopupMenu::show(const IntRect&, FrameView*, int) { } diff --git a/WebCore/platform/android/RenderThemeAndroid.cpp b/WebCore/platform/android/RenderThemeAndroid.cpp index 25e74bd..9cccc0c 100644 --- a/WebCore/platform/android/RenderThemeAndroid.cpp +++ b/WebCore/platform/android/RenderThemeAndroid.cpp @@ -25,7 +25,7 @@ #include "config.h" #include "RenderThemeAndroid.h" -#include "PopupMenu.h" + #include "RenderSkinAndroid.h" #include "RenderSkinButton.h" #include "RenderSkinCombo.h" @@ -48,6 +48,7 @@ #define LISTBOX_PADDING 5 namespace WebCore { + static SkCanvas* getCanvasFromInfo(const RenderObject::PaintInfo& info) { return info.context->platformContext()->mCanvas; @@ -59,7 +60,6 @@ static SkCanvas* getCanvasFromInfo(const RenderObject::PaintInfo& info) * the object to be painted, the PaintInfo, from which we get the canvas, the bounding rectangle, * returns false, meaning no one else has to paint it */ - static bool paintBrush(RenderSkinAndroid* rSkin, RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& ir) { Node* element = o->element(); @@ -96,7 +96,6 @@ RenderThemeAndroid::~RenderThemeAndroid() void RenderThemeAndroid::close() { - } bool RenderThemeAndroid::stateChanged(RenderObject* o, ControlState state) const @@ -280,9 +279,6 @@ bool RenderThemeAndroid::paintCombo(RenderObject* o, const RenderObject::PaintIn if (o->style() && o->style()->backgroundColor().alpha() == 0) return true; Node* element = o->element(); - SkCanvas* canvas = getCanvasFromInfo(i); - m_combo->notifyState(element); - canvas->save(); int height = ir.height(); int y = ir.y(); // If the combo box is too large, leave it at its max height, and center it. @@ -290,11 +286,7 @@ bool RenderThemeAndroid::paintCombo(RenderObject* o, const RenderObject::PaintIn y += (height - MAX_COMBO_HEIGHT) >> 1; height = MAX_COMBO_HEIGHT; } - canvas->translate(SkIntToScalar(ir.x()), SkIntToScalar(y)); - m_combo->setDim(ir.width(), height); - m_combo->draw(i.context->platformContext()); - canvas->restore(); - return false; + return m_combo->Draw(getCanvasFromInfo(i), element, ir.x(), y, ir.width(), height); } bool RenderThemeAndroid::paintMenuList(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& ir) @@ -304,12 +296,28 @@ bool RenderThemeAndroid::paintMenuList(RenderObject* o, const RenderObject::Pain void RenderThemeAndroid::adjustMenuListButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const { + // Copied from RenderThemeSafari. + const float baseFontSize = 11.0f; + const int baseBorderRadius = 5; + float fontScale = style->fontSize() / baseFontSize; + + style->resetPadding(); + style->setBorderRadius(IntSize(int(baseBorderRadius + fontScale - 1), int(baseBorderRadius + fontScale - 1))); // FIXME: Round up? + + const int minHeight = 15; + style->setMinHeight(Length(minHeight, Fixed)); + + style->setLineHeight(RenderStyle::initialLineHeight()); + // Found these padding numbers by trial and error. + const int padding = 4; + style->setPaddingTop(Length(padding, Fixed)); + style->setPaddingLeft(Length(padding, Fixed)); + // Added to make room for our arrow. style->setPaddingRight(Length(RenderSkinCombo::extraWidth(), Fixed)); - addIntrinsicMargins(style); } bool RenderThemeAndroid::paintMenuListButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& ir) -{ +{ return paintCombo(o, i, ir); } diff --git a/WebCore/platform/android/RenderThemeAndroid.h b/WebCore/platform/android/RenderThemeAndroid.h index 1844aed..632a2a3 100644 --- a/WebCore/platform/android/RenderThemeAndroid.h +++ b/WebCore/platform/android/RenderThemeAndroid.h @@ -30,7 +30,6 @@ namespace WebCore { -class PopupMenu; class RenderSkinButton; class RenderSkinRadio; class RenderSkinCombo; @@ -93,7 +92,6 @@ protected: virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const; virtual bool paintSearchField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); - private: void addIntrinsicMargins(RenderStyle* style) const; void close(); @@ -105,7 +103,7 @@ private: RenderSkinCombo* m_combo; }; -}; +} // namespace WebCore -#endif +#endif // RenderThemeAndroid_h diff --git a/WebCore/platform/android/ScreenAndroid.cpp b/WebCore/platform/android/ScreenAndroid.cpp index 20e0f68..c1e43b0 100644 --- a/WebCore/platform/android/ScreenAndroid.cpp +++ b/WebCore/platform/android/ScreenAndroid.cpp @@ -25,6 +25,7 @@ */ #define LOG_TAG "WebCore" + #include "config.h" #include "Screen.h" diff --git a/WebCore/platform/android/ScrollViewAndroid.cpp b/WebCore/platform/android/ScrollViewAndroid.cpp index e86ff5e..5622d8b 100644 --- a/WebCore/platform/android/ScrollViewAndroid.cpp +++ b/WebCore/platform/android/ScrollViewAndroid.cpp @@ -28,11 +28,8 @@ #include "ScrollView.h" #include "FloatRect.h" -#include "Frame.h" #include "FrameView.h" -#include "HostWindow.h" #include "IntRect.h" -#include "NotImplemented.h" #include "WebCoreFrameBridge.h" #include "WebCoreViewBridge.h" #include "WebViewCore.h" diff --git a/WebCore/platform/android/SearchPopupMenuAndroid.cpp b/WebCore/platform/android/SearchPopupMenuAndroid.cpp index fddfcf2..fa976e7 100644 --- a/WebCore/platform/android/SearchPopupMenuAndroid.cpp +++ b/WebCore/platform/android/SearchPopupMenuAndroid.cpp @@ -23,9 +23,6 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SearchPopupMenuAndroid_h -#define SearchPopupMenuAndroid_h - #include "config.h" #include "SearchPopupMenu.h" @@ -34,31 +31,22 @@ namespace WebCore { // Save the past searches stored in 'searchItems' to a database associated with 'name' void SearchPopupMenu::saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems) { - //ASSERT(0); //notImplemented(); - } // Load past searches associated with 'name' from the database to 'searchItems' void SearchPopupMenu::loadRecentSearches(const AtomicString& name, Vector<String>& searchItems) { - //ASSERT(0); //notImplemented(); - } // Create a search popup menu - not sure what else we have to do here SearchPopupMenu::SearchPopupMenu(PopupMenuClient* client) : PopupMenu(client) { - //ASSERT(0); //notImplemented(); - } // functions new to Jun-07 tip of tree merge: bool SearchPopupMenu::enabled() { return false; } -} // WebCore - -#endif - +} // namespace WebCore diff --git a/WebCore/platform/android/SharedTimerAndroid.cpp b/WebCore/platform/android/SharedTimerAndroid.cpp index fb856cc..d797cfb 100644 --- a/WebCore/platform/android/SharedTimerAndroid.cpp +++ b/WebCore/platform/android/SharedTimerAndroid.cpp @@ -26,6 +26,7 @@ #include "config.h" #include "SharedTimer.h" + #include "SystemTime.h" #include "JavaSharedClient.h" #include "TimerClient.h" @@ -35,31 +36,29 @@ using namespace android; namespace WebCore { - // Single timer, shared to implement all the timers managed by the Timer class. - // Not intended to be used directly; use the Timer class instead. - - void setSharedTimerFiredFunction(void (*f)()) - { - if (JavaSharedClient::GetTimerClient()) - JavaSharedClient::GetTimerClient()->setSharedTimerCallback(f); - } +// Single timer, shared to implement all the timers managed by the Timer class. +// Not intended to be used directly; use the Timer class instead. +void setSharedTimerFiredFunction(void (*f)()) +{ + if (JavaSharedClient::GetTimerClient()) + JavaSharedClient::GetTimerClient()->setSharedTimerCallback(f); +} - // The fire time is relative to the classic POSIX epoch of January 1, 1970, - // as the result of currentTime() is. +// The fire time is relative to the classic POSIX epoch of January 1, 1970, +// as the result of currentTime() is. +void setSharedTimerFireTime(double fireTime) +{ + long long timeInMS = (long long)((fireTime - currentTime()) * 1000); - void setSharedTimerFireTime(double fireTime) - { - long long timeInMS = (long long)((fireTime - currentTime()) * 1000); - - LOGV("setSharedTimerFireTime: in %ld millisec", timeInMS); - if (JavaSharedClient::GetTimerClient()) - JavaSharedClient::GetTimerClient()->setSharedTimer(timeInMS); - } - - void stopSharedTimer() - { - if (JavaSharedClient::GetTimerClient()) - JavaSharedClient::GetTimerClient()->stopSharedTimer(); - } + LOGV("setSharedTimerFireTime: in %ld millisec", timeInMS); + if (JavaSharedClient::GetTimerClient()) + JavaSharedClient::GetTimerClient()->setSharedTimer(timeInMS); +} +void stopSharedTimer() +{ + if (JavaSharedClient::GetTimerClient()) + JavaSharedClient::GetTimerClient()->stopSharedTimer(); } + +} // namespace WebCore diff --git a/WebCore/platform/android/SystemTimeAndroid.cpp b/WebCore/platform/android/SystemTimeAndroid.cpp index a3ab1ea..9ac32dc 100644 --- a/WebCore/platform/android/SystemTimeAndroid.cpp +++ b/WebCore/platform/android/SystemTimeAndroid.cpp @@ -25,6 +25,7 @@ #include "config.h" #include "SystemTime.h" + #include <sys/time.h> namespace WebCore { @@ -55,4 +56,4 @@ uint32_t get_thread_msec() #endif } -} +} // namespace WebCore diff --git a/WebCore/platform/android/TemporaryLinkStubs.cpp b/WebCore/platform/android/TemporaryLinkStubs.cpp index 349a75c..01789f4 100644 --- a/WebCore/platform/android/TemporaryLinkStubs.cpp +++ b/WebCore/platform/android/TemporaryLinkStubs.cpp @@ -90,12 +90,11 @@ using namespace WebCore; -// This function is called when the frame view has changed the state of it's border. +// This function is called when the frame view has changed the state of it's border. // iFrames, which are have a FrameView, are drawn with a 1px left/right border and 2px top/bottom border // Check function _shouldDrawBorder in WebFrameView.mm // We don't draw borders unless css draws them. -// void FrameView::updateBorder() { verifiedOk(); } - +//void FrameView::updateBorder() { verifiedOk(); } //int WebCore::screenDepthPerComponent(Widget*) { ASSERT(0); notImplemented(); return 0; } //bool WebCore::screenIsMonochrome(Widget*) { ASSERT(0); notImplemented(); return false; } @@ -106,36 +105,66 @@ using namespace WebCore; // This function is used by Javascript to find out what the default language // the user has selected. It is used by the JS object Navigator.language // I guess this information should be mapped with the Accept-Language: HTTP header. -String WebCore::defaultLanguage() { verifiedOk(); return "en"; } +String WebCore::defaultLanguage() +{ + verifiedOk(); + return "en"; +} namespace WebCore { #if !defined(ANDROID_PLUGINS) // If plugins support is turned on, don't use these stubs. -// Except for supportsMIMEType(), these Plugin functions are used by javascript's -// navigator.plugins[] object to provide the list of available plugins. This is most +// Except for supportsMIMEType(), these Plugin functions are used by javascript's +// navigator.plugins[] object to provide the list of available plugins. This is most // often used with to check to see if the browser supports Flash or which video // codec to use. // The supportsMIMEType() is used by the Frame to determine if a full screen instance // of a plugin can be used to render a mimetype that is not native to the browser. -PluginInfo* PluginInfoStore::createPluginInfoForPluginAtIndex(unsigned) { ASSERT(0); return 0;} -unsigned PluginInfoStore::pluginCount() const { verifiedOk(); return 0; } -// FIXME, return false for now. -String PluginInfoStore::pluginNameForMIMEType(const String& ) { notImplemented(); return String(); } -bool PluginInfoStore::supportsMIMEType(const String& ) { verifiedOk(); return false; } -void refreshPlugins(bool) { verifiedOk(); } +PluginInfo* PluginInfoStore::createPluginInfoForPluginAtIndex(unsigned) +{ + ASSERT(0); + return 0; +} + +unsigned PluginInfoStore::pluginCount() const +{ + verifiedOk(); + return 0; +} + +String PluginInfoStore::pluginNameForMIMEType(const String&) +{ + notImplemented(); + return String(); +} + +bool PluginInfoStore::supportsMIMEType(const String&) +{ + verifiedOk(); + return false; +} + +void refreshPlugins(bool) +{ + verifiedOk(); +} + #endif // !defined(ANDROID_PLUGINS) // This function tells the bridge that a resource was loaded from the cache and thus // the app may update progress with the amount of data loaded. -void CheckCacheObjectStatus(DocLoader*, CachedResource*) { ASSERT(0); notImplemented();} +void CheckCacheObjectStatus(DocLoader*, CachedResource*) +{ + ASSERT(0); + notImplemented(); +} // This class is used in conjunction with the File Upload form element, and // therefore relates to the above. When a file has been selected, an icon // representing the file type can be rendered next to the filename on the // web page. The icon for the file is encapsulated within this class. -//Icon::Icon() { notImplemented(); } Icon::~Icon() { } void Icon::paint(GraphicsContext*, const IntRect&) { } @@ -144,102 +173,449 @@ void Icon::paint(GraphicsContext*, const IntRect&) { } // The following functions are used to fetch localized text for HTML form // elements submit and reset. These strings are used when the page author // has not specified any text for these buttons. -String submitButtonDefaultLabel() { verifiedOk(); return "Submit"; } -String resetButtonDefaultLabel() { verifiedOk(); return "Reset"; } +String submitButtonDefaultLabel() +{ + verifiedOk(); + return "Submit"; +} + +String resetButtonDefaultLabel() +{ + verifiedOk(); + return "Reset"; +} // The alt text for an input element is not used visually, but rather is -// used for accessability - eg reading the web page. See +// used for accessability - eg reading the web page. See // HTMLInputElement::altText() for more information. -String inputElementAltText() { notImplemented(); return String(); } +String inputElementAltText() +{ + notImplemented(); + return String(); +} // This is the string that appears before an input box when the HTML element -// <ISINDEX> is used. The returned string is used if no PROMPT attribute is +// <ISINDEX> is used. The returned string is used if no PROMPT attribute is // provided. // note: Safari and FireFox use (too long for us imho) "This is a searchable index. Enter search keywords:" -String searchableIndexIntroduction() { verifiedOk(); return String("Enter search:"); } - +String searchableIndexIntroduction() +{ + verifiedOk(); + return String("Enter search:"); } // This function provides the default value for the CSS property: // -webkit-focus-ring-color // It is also related to the CSS property outline-color: -Color WebCore::focusRingColor() { verifiedOk(); return 0xFF0000FF; } +Color focusRingColor() +{ + verifiedOk(); + return 0xFF0000FF; +} // LocalizedStrings -String WebCore::contextMenuItemTagOpenLinkInNewWindow() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagDownloadLinkToDisk() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagCopyLinkToClipboard() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagOpenImageInNewWindow() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagDownloadImageToDisk() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagCopyImageToClipboard() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagOpenFrameInNewWindow() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagCopy() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagGoBack() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagGoForward() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagStop() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagReload() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagCut() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagPaste() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagNoGuessesFound() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagIgnoreSpelling() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagLearnSpelling() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagSearchWeb() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagLookUpInDictionary() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagOpenLink() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagIgnoreGrammar() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagSpellingMenu() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagShowSpellingPanel(bool show) { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagCheckSpelling() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagCheckSpellingWhileTyping() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagCheckGrammarWithSpelling() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagFontMenu() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagBold() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagItalic() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagUnderline() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagOutline() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagWritingDirectionMenu() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagDefaultDirection() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagLeftToRight() { ASSERT(0); return String(); } -String WebCore::contextMenuItemTagRightToLeft() { ASSERT(0); return String(); } +String contextMenuItemTagOpenLinkInNewWindow() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagDownloadLinkToDisk() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagCopyLinkToClipboard() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagOpenImageInNewWindow() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagDownloadImageToDisk() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagCopyImageToClipboard() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagOpenFrameInNewWindow() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagCopy() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagGoBack() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagGoForward() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagStop() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagReload() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagCut() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagPaste() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagNoGuessesFound() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagIgnoreSpelling() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagLearnSpelling() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagSearchWeb() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagLookUpInDictionary() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagOpenLink() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagIgnoreGrammar() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagSpellingMenu() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagShowSpellingPanel(bool) +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagCheckSpelling() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagCheckSpellingWhileTyping() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagCheckGrammarWithSpelling() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagFontMenu() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagBold() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagItalic() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagUnderline() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagOutline() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagWritingDirectionMenu() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagDefaultDirection() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagLeftToRight() +{ + ASSERT(0); + return String(); +} + +String contextMenuItemTagRightToLeft() +{ + ASSERT(0); + return String(); +} + +} // namespace WebCore // FIXME, no support for spelling yet. -Pasteboard* Pasteboard::generalPasteboard() { return new Pasteboard(); } -void Pasteboard::writeSelection(Range*, bool canSmartCopyOrDelete, Frame*) { notImplemented(); } -void Pasteboard::writeURL(const KURL&, const String&, Frame*) { notImplemented(); } -void Pasteboard::clear() { notImplemented(); } -bool Pasteboard::canSmartReplace() { notImplemented(); return false; } -PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame*, PassRefPtr<Range>, bool allowPlainText, bool& chosePlainText) { notImplemented(); return 0; } -String Pasteboard::plainText(Frame* frame) { notImplemented(); return String(); } -Pasteboard::Pasteboard() { notImplemented(); } -Pasteboard::~Pasteboard() { notImplemented(); } - -ContextMenu::ContextMenu(const HitTestResult& result) : m_hitTestResult(result) { ASSERT(0); notImplemented(); } -ContextMenu::~ContextMenu() { ASSERT(0); notImplemented(); } -void ContextMenu::appendItem(ContextMenuItem&) { ASSERT(0); notImplemented(); } -void ContextMenu::setPlatformDescription(PlatformMenuDescription menu) { ASSERT(0); m_platformDescription = menu; } -PlatformMenuDescription ContextMenu::platformDescription() const { ASSERT(0); return m_platformDescription; } - -ContextMenuItem::ContextMenuItem(PlatformMenuItemDescription) { ASSERT(0); notImplemented(); } -ContextMenuItem::ContextMenuItem(ContextMenu*) { ASSERT(0); notImplemented(); } -ContextMenuItem::ContextMenuItem(ContextMenuItemType type, ContextMenuAction action, const String& title, ContextMenu* subMenu) { ASSERT(0); notImplemented(); } -ContextMenuItem::~ContextMenuItem() { ASSERT(0); notImplemented(); } -PlatformMenuItemDescription ContextMenuItem::releasePlatformDescription() { ASSERT(0); notImplemented(); return m_platformDescription; } -ContextMenuItemType ContextMenuItem::type() const { ASSERT(0); notImplemented(); return ActionType; } -void ContextMenuItem::setType(ContextMenuItemType) { ASSERT(0); notImplemented(); } -ContextMenuAction ContextMenuItem::action() const { ASSERT(0); notImplemented(); return ContextMenuItemTagNoAction; } -void ContextMenuItem::setAction(ContextMenuAction) { ASSERT(0); notImplemented(); } -String ContextMenuItem::title() const { ASSERT(0); notImplemented(); return String(); } -void ContextMenuItem::setTitle(const String&) { ASSERT(0); notImplemented(); } -PlatformMenuDescription ContextMenuItem::platformSubMenu() const { ASSERT(0); notImplemented(); return 0; } -void ContextMenuItem::setSubMenu(ContextMenu*) { ASSERT(0); notImplemented(); } -void ContextMenuItem::setChecked(bool) { ASSERT(0); notImplemented(); } -void ContextMenuItem::setEnabled(bool) { ASSERT(0); notImplemented(); } +Pasteboard* Pasteboard::generalPasteboard() +{ + return new Pasteboard(); +} + +void Pasteboard::writeSelection(Range*, bool, Frame*) +{ + notImplemented(); +} + +void Pasteboard::writeURL(const KURL&, const String&, Frame*) +{ + notImplemented(); +} + +void Pasteboard::clear() +{ + notImplemented(); +} + +bool Pasteboard::canSmartReplace() +{ + notImplemented(); + return false; +} + +PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame*, PassRefPtr<Range>, bool, bool&) +{ + notImplemented(); + return 0; +} + +String Pasteboard::plainText(Frame*) +{ + notImplemented(); + return String(); +} + +Pasteboard::Pasteboard() +{ + notImplemented(); +} + +Pasteboard::~Pasteboard() +{ + notImplemented(); +} + + +ContextMenu::ContextMenu(const HitTestResult& result) : m_hitTestResult(result) +{ + ASSERT(0); + notImplemented(); +} + +ContextMenu::~ContextMenu() +{ + ASSERT(0); + notImplemented(); +} + +void ContextMenu::appendItem(ContextMenuItem&) +{ + ASSERT(0); + notImplemented(); +} + +void ContextMenu::setPlatformDescription(PlatformMenuDescription menu) +{ + ASSERT(0); + m_platformDescription = menu; +} + +PlatformMenuDescription ContextMenu::platformDescription() const +{ + ASSERT(0); + return m_platformDescription; +} + +ContextMenuItem::ContextMenuItem(PlatformMenuItemDescription) +{ + ASSERT(0); + notImplemented(); +} + +ContextMenuItem::ContextMenuItem(ContextMenu*) +{ + ASSERT(0); + notImplemented(); +} + +ContextMenuItem::ContextMenuItem(ContextMenuItemType, ContextMenuAction, const String&, ContextMenu*) +{ + ASSERT(0); + notImplemented(); +} + +ContextMenuItem::~ContextMenuItem() +{ + ASSERT(0); + notImplemented(); +} + +PlatformMenuItemDescription ContextMenuItem::releasePlatformDescription() +{ + ASSERT(0); + notImplemented(); + return m_platformDescription; +} + +ContextMenuItemType ContextMenuItem::type() const +{ + ASSERT(0); + notImplemented(); + return ActionType; +} + +void ContextMenuItem::setType(ContextMenuItemType) +{ + ASSERT(0); + notImplemented(); +} + +ContextMenuAction ContextMenuItem::action() const +{ + ASSERT(0); + notImplemented(); + return ContextMenuItemTagNoAction; +} + +void ContextMenuItem::setAction(ContextMenuAction) +{ + ASSERT(0); + notImplemented(); +} + +String ContextMenuItem::title() const +{ + ASSERT(0); + notImplemented(); + return String(); +} + +void ContextMenuItem::setTitle(const String&) +{ + ASSERT(0); + notImplemented(); +} + +PlatformMenuDescription ContextMenuItem::platformSubMenu() const +{ + ASSERT(0); + notImplemented(); + return 0; +} + +void ContextMenuItem::setSubMenu(ContextMenu*) +{ + ASSERT(0); + notImplemented(); +} + +void ContextMenuItem::setChecked(bool) +{ + ASSERT(0); + notImplemented(); +} + +void ContextMenuItem::setEnabled(bool) +{ + ASSERT(0); + notImplemented(); +} namespace WebCore { -float userIdleTime() { notImplemented(); return 0; } -// systemBeep() is called by the Editor to indicate that there was nothing to copy, and may be called from + +float userIdleTime() +{ + notImplemented(); + return 0; +} + +// systemBeep() is called by the Editor to indicate that there was nothing to copy, and may be called from // other places too. -void systemBeep() { notImplemented(); } +void systemBeep() +{ + notImplemented(); +} + } // functions new to Jun-07 tip of tree merge: @@ -251,64 +627,143 @@ void systemBeep() { notImplemented(); } //void WebCore::Frame::cleanupPlatformScriptObjects() {} // void WebCore::Frame::dashboardRegionsChanged() {} //bool WebCore::Frame::isCharacterSmartReplaceExempt(unsigned short, bool) { return false; } -void* WebCore::Frame::dragImageForSelection() { return NULL; } -WebCore::String WebCore::MIMETypeRegistry::getMIMETypeForExtension(WebCore::String const&) { +void* WebCore::Frame::dragImageForSelection() +{ + return 0; +} + + +WebCore::String WebCore::MIMETypeRegistry::getMIMETypeForExtension(WebCore::String const&) +{ return WebCore::String(); } void WebCore::Pasteboard::writeImage(WebCore::Node*, WebCore::KURL const&, WebCore::String const&) {} namespace WebCore { -IntSize dragImageSize(void*) { return IntSize(0, 0); } + +IntSize dragImageSize(void*) +{ + return IntSize(0, 0); +} + void deleteDragImage(void*) {} -void* createDragImageFromImage(Image*) { return NULL; } -void* dissolveDragImageToFraction(void*, float) { return NULL; } -void* createDragImageIconForCachedImage(CachedImage*) { return NULL; } +void* createDragImageFromImage(Image*) +{ + return 0; +} + +void* dissolveDragImageToFraction(void*, float) +{ + return 0; +} + +void* createDragImageIconForCachedImage(CachedImage*) +{ + return 0; +} + Cursor dummyCursor; -const Cursor& zoomInCursor() { return dummyCursor; } -const Cursor& zoomOutCursor() { return dummyCursor; } -const Cursor& notAllowedCursor() { return dummyCursor; } -void* scaleDragImage(void*, FloatSize) { return NULL; } -String searchMenuRecentSearchesText() { return String(); } -String searchMenuNoRecentSearchesText() { return String(); } -String searchMenuClearRecentSearchesText() { return String(); } -Vector<String> supportedKeySizes() { notImplemented(); return Vector<String>(); } -String signedPublicKeyAndChallengeString(unsigned int, String const&, WebCore::KURL const&) { return String(); } +const Cursor& zoomInCursor() +{ + return dummyCursor; +} + +const Cursor& zoomOutCursor() +{ + return dummyCursor; +} + +const Cursor& notAllowedCursor() +{ + return dummyCursor; +} + +void* scaleDragImage(void*, FloatSize) +{ + return 0; +} + +String searchMenuRecentSearchesText() +{ + return String(); +} + +String searchMenuNoRecentSearchesText() +{ + return String(); +} + +String searchMenuClearRecentSearchesText() +{ + return String(); +} + +Vector<String> supportedKeySizes() +{ + notImplemented(); + return Vector<String>(); +} +String signedPublicKeyAndChallengeString(unsigned int, String const&, WebCore::KURL const&) +{ + return String(); } +} // namespace WebCore + // added for Nov-16-07 ToT integration //namespace WebCore { //void Frame::clearPlatformScriptObjects() { notImplemented(); } + //} // functions new to Feb-19 tip of tree merge: namespace WebCore { // isCharacterSmartReplaceExempt is defined in SmartReplaceICU.cpp; in theory, we could use that one -// but we don't support all of the required icu functions -bool isCharacterSmartReplaceExempt(UChar32 , bool ) { notImplemented(); return false; } +// but we don't support all of the required icu functions +bool isCharacterSmartReplaceExempt(UChar32, bool) +{ + notImplemented(); + return false; } +} // WebCore + int MakeDataExecutable; // functions new to Mar-2 tip of tree merge: -String KURL::fileSystemPath() const { notImplemented(); return String(); } +String KURL::fileSystemPath() const +{ + notImplemented(); + return String(); +} + // functions new to Jun-1 tip of tree merge: -PassRefPtr<SharedBuffer> SharedBuffer::createWithContentsOfFile(const String&) { notImplemented(); return 0; } +PassRefPtr<SharedBuffer> SharedBuffer::createWithContentsOfFile(const String&) +{ + notImplemented(); + return 0; +} + -namespace JSC { -namespace Bindings { -bool dispatchJNICall(ExecState*, void const*, _jobject*, bool, JNIType, - _jmethodID*, jvalue*, jvalue&, char const*, JSValue*&) { +namespace JSC { namespace Bindings { +bool dispatchJNICall(ExecState*, void const*, _jobject*, bool, JNIType, + _jmethodID*, jvalue*, jvalue&, char const*, JSValue*&) +{ notImplemented(); return false; } -} -} -char* dirname(const char*) { notImplemented(); return NULL; } +} } // namespace JSC::Bindings + +char* dirname(const char*) +{ + notImplemented(); + return 0; +} // new as of SVN change 36269, Sept 8, 2008 const String& Database::databaseInfoTableName() @@ -320,21 +775,50 @@ const String& Database::databaseInfoTableName() // new as of SVN change 38068, Nov 5, 2008 namespace WebCore { -void prefetchDNS(const String& hostname) { notImplemented(); } -void getSupportedKeySizes(Vector<String>&) { notImplemented(); } -PassRefPtr<Icon> Icon::createIconForFile(const String& filename) { notImplemented(); return 0; } -PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames) { notImplemented(); return 0; } -// ScrollbarTheme::nativeTheme() is called by RenderTextControl::calcPrefWidths() +void prefetchDNS(const String&) +{ + notImplemented(); +} + +void getSupportedKeySizes(Vector<String>&) +{ + notImplemented(); +} + +PassRefPtr<Icon> Icon::createIconForFile(const String&) +{ + notImplemented(); + return 0; +} + +PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>&) +{ + notImplemented(); + return 0; +} + +// ScrollbarTheme::nativeTheme() is called by RenderTextControl::calcPrefWidths() // like this: scrollbarSize = ScrollbarTheme::nativeTheme()->scrollbarThickness(); -// with this comment: +// with this comment: // // FIXME: We should get the size of the scrollbar from the RenderTheme instead. // since our text control doesn't have scrollbars, the default size of 0 width should be // ok. notImplemented() is commented out below so that we can find other unresolved // unimplemented functions. -ScrollbarTheme* ScrollbarTheme::nativeTheme() { /* notImplemented(); */ static ScrollbarTheme theme; return &theme; } -JSC::JSValue* toJS(JSC::ExecState* , JSC::Profile* ) { notImplemented(); return NULL; } +ScrollbarTheme* ScrollbarTheme::nativeTheme() +{ + /* notImplemented(); */ + static ScrollbarTheme theme; + return &theme; } +JSC::JSValue* toJS(JSC::ExecState*, JSC::Profile*) +{ + notImplemented(); + return 0; +} + +} // namespace WebCore + FileList::FileList() { notImplemented(); @@ -343,7 +827,7 @@ FileList::FileList() File* FileList::item(unsigned index) const { notImplemented(); - return NULL; + return 0; } AXObjectCache::~AXObjectCache() @@ -355,12 +839,12 @@ AXObjectCache::~AXObjectCache() bool AXObjectCache::gAccessibilityEnabled = false; bool AXObjectCache::gAccessibilityEnhancedUserInterfaceEnabled = false; -void AXObjectCache::childrenChanged(RenderObject* renderer) +void AXObjectCache::childrenChanged(RenderObject*) { notImplemented(); } -void AXObjectCache::remove(RenderObject* renderer) +void AXObjectCache::remove(RenderObject*) { notImplemented(); } @@ -379,22 +863,23 @@ OpaqueJSClassContextData::~OpaqueJSClassContextData() } namespace WebCore { + JSC::JSValue* JavaScriptCallFrame::evaluate(JSC::UString const&, JSC::JSValue*&) const { notImplemented(); - return NULL; + return 0; } const JSC::ScopeChainNode* JavaScriptCallFrame::scopeChain() const { notImplemented(); - return NULL; + return 0; } JSC::JSObject* JavaScriptCallFrame::thisObject() const { notImplemented(); - return NULL; + return 0; } JSC::DebuggerCallFrame::Type JavaScriptCallFrame::type() const @@ -406,7 +891,7 @@ JSC::DebuggerCallFrame::Type JavaScriptCallFrame::type() const JavaScriptCallFrame* JavaScriptCallFrame::caller() { notImplemented(); - return NULL; + return 0; } String JavaScriptCallFrame::functionName() const @@ -417,7 +902,7 @@ String JavaScriptCallFrame::functionName() const } JavaScriptDebugServer::JavaScriptDebugServer() : - m_recompileTimer(this, NULL) + m_recompileTimer(this, 0) { notImplemented(); } @@ -434,48 +919,47 @@ JavaScriptDebugServer& JavaScriptDebugServer::shared() return server; } -void JavaScriptDebugServer::atStatement(const DebuggerCallFrame& debuggerCallFrame, int sourceID, int lineNumber) +void JavaScriptDebugServer::atStatement(const DebuggerCallFrame&, int, int) { notImplemented(); } -void JavaScriptDebugServer::callEvent(const DebuggerCallFrame& debuggerCallFrame, int sourceID, int lineNumber) +void JavaScriptDebugServer::callEvent(const DebuggerCallFrame&, int, int) { notImplemented(); } -void JavaScriptDebugServer::didExecuteProgram(const DebuggerCallFrame& debuggerCallFrame, int sourceID, int lineNumber) +void JavaScriptDebugServer::didExecuteProgram(const DebuggerCallFrame&, int, int) { notImplemented(); } -void JavaScriptDebugServer::didReachBreakpoint(const DebuggerCallFrame& debuggerCallFrame, int sourceID, int lineNumber) +void JavaScriptDebugServer::didReachBreakpoint(const DebuggerCallFrame&, int, int) { notImplemented(); } -void JavaScriptDebugServer::exception(const DebuggerCallFrame& debuggerCallFrame, int sourceID, int lineNumber) +void JavaScriptDebugServer::exception(const DebuggerCallFrame&, int, int) { notImplemented(); } -void JavaScriptDebugServer::sourceParsed(ExecState* exec, const SourceCode&, - int sourceID, const UString& sourceURL) +void JavaScriptDebugServer::sourceParsed(ExecState*, const SourceCode&, int, const UString&) { notImplemented(); } -void JavaScriptDebugServer::pageCreated(Page* page) +void JavaScriptDebugServer::pageCreated(Page*) { notImplemented(); } -void JavaScriptDebugServer::returnEvent(const DebuggerCallFrame& debuggerCallFrame, int sourceID, int lineNumber) +void JavaScriptDebugServer::returnEvent(const DebuggerCallFrame&, int, int) { notImplemented(); } -void JavaScriptDebugServer::willExecuteProgram(const DebuggerCallFrame& debuggerCallFrame, int sourceID, int lineNumber) +void JavaScriptDebugServer::willExecuteProgram(const DebuggerCallFrame&, int, int) { notImplemented(); } diff --git a/WebCore/platform/android/WidgetAndroid.cpp b/WebCore/platform/android/WidgetAndroid.cpp index 2f9f997..84ab26c 100644 --- a/WebCore/platform/android/WidgetAndroid.cpp +++ b/WebCore/platform/android/WidgetAndroid.cpp @@ -26,112 +26,101 @@ #include "config.h" #include "Widget.h" -#include "Document.h" -#include "Element.h" #include "Font.h" #include "FrameView.h" #include "GraphicsContext.h" -#include "HostWindow.h" #include "NotImplemented.h" - #include "WebCoreFrameBridge.h" #include "WebCoreViewBridge.h" #include "WebViewCore.h" namespace WebCore { - class WidgetPrivate - { - public: - Font m_font; - }; - - Widget::Widget(PlatformWidget widget) : m_data(new WidgetPrivate) - { - init(widget); - } - - Widget::~Widget() - { - ASSERT(!parent()); - releasePlatformWidget(); - delete m_data; - } - - IntRect Widget::frameRect() const - { - // FIXME: use m_frame instead? - if (!platformWidget()) - return IntRect(0, 0, 0, 0); - return platformWidget()->getBounds(); - } - - void Widget::setFocus() - { - notImplemented(); - } - - void Widget::paint(GraphicsContext* ctx, const IntRect& r) - { - // FIXME: in what case, will this be called for the top frame? - if (!platformWidget()) - return; - platformWidget()->draw(ctx, r); - } - - void Widget::releasePlatformWidget() - { - Release(platformWidget()); - } - - void Widget::retainPlatformWidget() - { - Retain(platformWidget()); - } - - void Widget::setCursor(const Cursor& cursor) - { - notImplemented(); - } - - void Widget::show() - { - notImplemented(); - } - - void Widget::hide() - { - notImplemented(); - } - - void Widget::setFrameRect(const IntRect& rect) - { - // FIXME: set m_frame instead? - // platformWidget() is NULL when called from Scrollbar - if (!platformWidget()) - return; - platformWidget()->setLocation(rect.x(), rect.y()); - platformWidget()->setSize(rect.width(), rect.height()); - } - - void Widget::setIsSelected(bool isSelected) - { - notImplemented(); - } - - int Widget::screenWidth() const - { - const Widget* widget = this; - while (!widget->isFrameView()) { - widget = widget->parent(); - if (!widget) - break; - } +Widget::Widget(PlatformWidget widget) +{ + init(widget); +} + +Widget::~Widget() +{ + ASSERT(!parent()); + releasePlatformWidget(); +} + +IntRect Widget::frameRect() const +{ + // FIXME: use m_frame instead? + if (!platformWidget()) + return IntRect(0, 0, 0, 0); + return platformWidget()->getBounds(); +} + +void Widget::setFocus() +{ + notImplemented(); +} + +void Widget::paint(GraphicsContext* ctx, const IntRect& r) +{ + // FIXME: in what case, will this be called for the top frame? + if (!platformWidget()) + return; + platformWidget()->draw(ctx, r); +} + +void Widget::releasePlatformWidget() +{ + Release(platformWidget()); +} + +void Widget::retainPlatformWidget() +{ + Retain(platformWidget()); +} + +void Widget::setCursor(const Cursor& cursor) +{ + notImplemented(); +} + +void Widget::show() +{ + notImplemented(); +} + +void Widget::hide() +{ + notImplemented(); +} + +void Widget::setFrameRect(const IntRect& rect) +{ + // FIXME: set m_frame instead? + // platformWidget() is NULL when called from Scrollbar + if (!platformWidget()) + return; + platformWidget()->setLocation(rect.x(), rect.y()); + platformWidget()->setSize(rect.width(), rect.height()); +} + +void Widget::setIsSelected(bool isSelected) +{ + notImplemented(); +} + +int Widget::screenWidth() const +{ + const Widget* widget = this; + while (!widget->isFrameView()) { + widget = widget->parent(); if (!widget) - return 0; - - return android::WebViewCore::getWebViewCore( - static_cast<const ScrollView*>(widget))->screenWidth(); + break; } + if (!widget) + return 0; + + return android::WebViewCore::getWebViewCore( + static_cast<const ScrollView*>(widget))->screenWidth(); +} } // WebCore namepsace diff --git a/WebKit/android/RenderSkinCombo.cpp b/WebKit/android/RenderSkinCombo.cpp index 4fed8d8..902f2c0 100644 --- a/WebKit/android/RenderSkinCombo.cpp +++ b/WebKit/android/RenderSkinCombo.cpp @@ -24,69 +24,48 @@ */ #include "config.h" +#include "RenderSkinCombo.h" + #include "Document.h" #include "Node.h" -#include "PlatformGraphicsContext.h" -#include "RenderSkinCombo.h" #include "SkCanvas.h" #include "SkNinePatch.h" namespace WebCore { -static const int margin = 2; -static const SkIRect mar = { margin, margin, RenderSkinCombo::extraWidth(), margin }; - -SkBitmap RenderSkinCombo::m_bitmap[2]; -bool RenderSkinCombo::m_decoded; +static SkBitmap s_bitmap[2]; // Collection of assets for a combo box +static bool s_decoded; // True if all assets were decoded +static const int s_margin = 2; +static const SkIRect s_mar = { s_margin, s_margin, + RenderSkinCombo::extraWidth(), s_margin }; RenderSkinCombo::RenderSkinCombo() { - m_height = 20; - m_width = 75; - m_state = kNormal; - m_bounds.set(0, 0, SkIntToScalar(m_width), SkIntToScalar(m_height)); } void RenderSkinCombo::Init(android::AssetManager* am) { - if (m_decoded) + if (s_decoded) return; // Maybe short circuiting is fine, since I don't even draw if one state is not decoded properly // but is that necessary in the final version? - m_decoded = RenderSkinAndroid::DecodeBitmap(am, "images/combobox-noHighlight.png", &m_bitmap[kNormal]); - m_decoded = RenderSkinAndroid::DecodeBitmap(am, "images/combobox-disabled.png", &m_bitmap[kDisabled]) && m_decoded; + s_decoded = RenderSkinAndroid::DecodeBitmap(am, "images/combobox-noHighlight.png", &s_bitmap[kNormal]); + s_decoded = RenderSkinAndroid::DecodeBitmap(am, "images/combobox-disabled.png", &s_bitmap[kDisabled]) && s_decoded; } -bool RenderSkinCombo::draw(PlatformGraphicsContext *p) +bool RenderSkinCombo::Draw(SkCanvas* canvas, Node* element, int x, int y, int width, int height) { - // The text is drawn right next to the left side - should I draw the box slightly to the left? - if (!m_decoded) - return false; - SkCanvas* canvas = p->mCanvas; - SkNinePatch::DrawNine(canvas, m_bounds, m_bitmap[m_state], mar); - return false; -} - -void RenderSkinCombo::notifyState(Node* element) -{ - m_state = kDisabled; - if (!element) - return; - if (element->isEnabled()) - m_state = kNormal; -} - -void RenderSkinCombo::setDim(int width, int height) -{ - if (width != m_width || height != m_height) { - m_width = width; - if (height < (margin<<1) + 1) - height = (margin<<1) + 1; - else - m_height = height; - m_bounds.set(0, 0, SkIntToScalar(m_width), SkIntToScalar(m_height)); + if (!s_decoded) + return true; + State state = element && element->isEnabled() ? kNormal : kDisabled; + if (height < (s_margin<<1) + 1) { + height = (s_margin<<1) + 1; } + SkRect bounds; + bounds.set(SkIntToScalar(x), SkIntToScalar(y), SkIntToScalar(x + width), SkIntToScalar(y + height)); + SkNinePatch::DrawNine(canvas, bounds, s_bitmap[state], s_mar); + return false; } } //WebCore diff --git a/WebKit/android/RenderSkinCombo.h b/WebKit/android/RenderSkinCombo.h index aeea6a0..0970b6b 100644 --- a/WebKit/android/RenderSkinCombo.h +++ b/WebKit/android/RenderSkinCombo.h @@ -27,10 +27,10 @@ #define RenderSkinCombo_h #include "RenderSkinAndroid.h" -#include "SkBitmap.h" -#include "SkPaint.h" #include "SkRect.h" +class SkCanvas; + namespace WebCore { // This is very similar to RenderSkinButton - maybe they should be the same class? @@ -45,21 +45,17 @@ public: */ static void Init(android::AssetManager*); - virtual bool draw(PlatformGraphicsContext*); - virtual void notifyState(Node* element); - virtual void setDim(int width, int height); + /** + * Draw the provided Node on the SkCanvas, using the dimensions provided by + * x,y,w,h. Return true if we did not draw, and WebKit needs to draw it, + * false otherwise. + */ + static bool Draw(SkCanvas* , Node* , int x, int y, int w, int h); // The image is an extra 30 pixels wider than the RenderObject, so this accounts for that. static int extraWidth() { return arrowMargin; } private: - SkRect m_bounds; // Maybe this should become a protected member of RenderSkinAndroid... - static SkBitmap m_bitmap[2]; // Collection of assets for a combo box - static bool m_decoded; // True if all assets were decoded - SkPaint m_paint; - // Could probably move m_state into RenderSkinAndroid... - // Although notice that the state for RenderSkinRadio is just an integer, and it behaves differently - State m_state; static const int arrowMargin = 30; }; diff --git a/WebKit/android/jni/JavaBridge.cpp b/WebKit/android/jni/JavaBridge.cpp index 37bb5d2..eefeea5 100644 --- a/WebKit/android/jni/JavaBridge.cpp +++ b/WebKit/android/jni/JavaBridge.cpp @@ -94,7 +94,6 @@ public: static void ServiceFuncPtrQueue(JNIEnv*); private: - JavaVM* mJvm; jobject mJavaObject; jmethodID mSetSharedTimer; jmethodID mStopSharedTimer; @@ -109,7 +108,6 @@ static JavaBridge* gJavaBridge; JavaBridge::JavaBridge(JNIEnv* env, jobject obj) { - mJvm = jnienv_to_javavm(env); mJavaObject = adoptGlobalRef(env, obj); jclass clazz = env->GetObjectClass(obj); @@ -134,7 +132,7 @@ JavaBridge::JavaBridge(JNIEnv* env, jobject obj) JavaBridge::~JavaBridge() { if (mJavaObject) { - JNIEnv* env = javavm_to_jnienv(mJvm); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->DeleteGlobalRef(mJavaObject); mJavaObject = 0; } @@ -146,7 +144,7 @@ JavaBridge::~JavaBridge() void JavaBridge::setSharedTimer(long long timemillis) { - JNIEnv* env = javavm_to_jnienv(mJvm); + JNIEnv* env = JSC::Bindings::getJNIEnv(); AutoJObject obj = getRealObject(env, mJavaObject); env->CallVoidMethod(obj.get(), mSetSharedTimer, timemillis); } @@ -154,7 +152,7 @@ JavaBridge::setSharedTimer(long long timemillis) void JavaBridge::stopSharedTimer() { - JNIEnv* env = javavm_to_jnienv(mJvm); + JNIEnv* env = JSC::Bindings::getJNIEnv(); AutoJObject obj = getRealObject(env, mJavaObject); env->CallVoidMethod(obj.get(), mStopSharedTimer); } @@ -162,7 +160,7 @@ JavaBridge::stopSharedTimer() void JavaBridge::setCookies(WebCore::KURL const& url, WebCore::KURL const& docUrl, WebCore::String const& value) { - JNIEnv* env = javavm_to_jnienv(mJvm); + JNIEnv* env = JSC::Bindings::getJNIEnv(); const WebCore::String& urlStr = url.string(); jstring jUrlStr = env->NewString(urlStr.characters(), urlStr.length()); const WebCore::String& docUrlStr = docUrl.string(); @@ -179,7 +177,7 @@ JavaBridge::setCookies(WebCore::KURL const& url, WebCore::KURL const& docUrl, We WebCore::String JavaBridge::cookies(WebCore::KURL const& url) { - JNIEnv* env = javavm_to_jnienv(mJvm); + JNIEnv* env = JSC::Bindings::getJNIEnv(); const WebCore::String& urlStr = url.string(); jstring jUrlStr = env->NewString(urlStr.characters(), urlStr.length()); @@ -195,7 +193,7 @@ JavaBridge::cookies(WebCore::KURL const& url) bool JavaBridge::cookiesEnabled() { - JNIEnv* env = javavm_to_jnienv(mJvm); + JNIEnv* env = JSC::Bindings::getJNIEnv(); AutoJObject obj = getRealObject(env, mJavaObject); jboolean ret = env->CallBooleanMethod(obj.get(), mCookiesEnabled); return (ret != 0); @@ -215,8 +213,7 @@ void JavaBridge::signalServiceFuncPtrQueue() // In order to signal the main thread we must go through JNI. This // is the only usage on most threads, so we need to ensure a JNI // environment is setup. - JSC::Bindings::getJNIEnv(); - JNIEnv* env = javavm_to_jnienv(mJvm); + JNIEnv* env = JSC::Bindings::getJNIEnv(); AutoJObject obj = getRealObject(env, mJavaObject); env->CallVoidMethod(obj.get(), mSignalFuncPtrQueue); } diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp index 8cf9cbe..860109b 100644 --- a/WebKit/android/jni/WebCoreFrameBridge.cpp +++ b/WebKit/android/jni/WebCoreFrameBridge.cpp @@ -108,7 +108,6 @@ namespace android { struct WebFrame::JavaBrowserFrame { - JavaVM* mJVM; jobject mObj; jobject mHistoryList; // WebBackForwardList object jmethodID mStartLoadingResource; @@ -146,7 +145,6 @@ WebFrame::WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page* { jclass clazz = env->GetObjectClass(obj); mJavaFrame = new JavaBrowserFrame; - mJavaFrame->mJVM = jnienv_to_javavm(env); mJavaFrame->mObj = adoptGlobalRef(env, obj); mJavaFrame->mHistoryList = adoptGlobalRef(env, historyList); mJavaFrame->mStartLoadingResource = env->GetMethodID(clazz, "startLoadingResource", @@ -206,7 +204,7 @@ WebFrame::WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page* WebFrame::~WebFrame() { if (mJavaFrame->mObj) { - JNIEnv* env = javavm_to_jnienv(mJavaFrame->mJVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->DeleteGlobalRef(mJavaFrame->mObj); env->DeleteGlobalRef(mJavaFrame->mHistoryList); mJavaFrame->mObj = 0; @@ -264,7 +262,7 @@ WebFrame::startLoadingResource(WebCore::ResourceHandle* loader, WebCore::String method = request.httpMethod(); WebCore::HTTPHeaderMap headers = request.httpHeaderFields(); - JNIEnv* env = javavm_to_jnienv(mJavaFrame->mJVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); WebCore::String urlStr = request.url().string(); jstring jUrlStr = env->NewString(urlStr.characters(), urlStr.length()); jstring jMethodStr = NULL; @@ -362,7 +360,7 @@ WebFrame::reportError(int errorCode, const WebCore::String& description, TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif LOGV("::WebCore:: reportError(%d, %s)", errorCode, description.ascii().data()); - JNIEnv* env = javavm_to_jnienv(mJavaFrame->mJVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); jstring descStr = env->NewString((unsigned short*)description.characters(), description.length()); jstring failUrl = env->NewString((unsigned short*)failingUrl.characters(), failingUrl.length()); @@ -391,7 +389,7 @@ WebFrame::loadStarted(WebCore::Frame* frame) !isMainFrame)) return; - JNIEnv* env = javavm_to_jnienv(mJavaFrame->mJVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); WebCore::String urlString(url.string()); // If this is the main frame and we already have a favicon in the database, // send it along with the page started notification. @@ -418,7 +416,7 @@ WebFrame::transitionToCommitted(WebCore::Frame* frame) #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif - JNIEnv* env = javavm_to_jnienv(mJavaFrame->mJVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); WebCore::FrameLoadType loadType = frame->loader()->loadType(); bool isMainFrame = (!frame->tree() || !frame->tree()->parent()); env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mTransitionToCommitted, @@ -432,7 +430,7 @@ WebFrame::didFinishLoad(WebCore::Frame* frame) #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif - JNIEnv* env = javavm_to_jnienv(mJavaFrame->mJVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); WebCore::FrameLoader* loader = frame->loader(); const WebCore::KURL& url = loader->activeDocumentLoader()->url(); if (url.isEmpty()) @@ -456,7 +454,7 @@ WebFrame::addHistoryItem(WebCore::HistoryItem* item) TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif LOGV("::WebCore:: addHistoryItem"); - JNIEnv* env = javavm_to_jnienv(mJavaFrame->mJVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); WebHistory::AddItem(mJavaFrame->history(env), item); } @@ -467,7 +465,7 @@ WebFrame::removeHistoryItem(int index) TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif LOGV("::WebCore:: removeHistoryItem at %d", index); - JNIEnv* env = javavm_to_jnienv(mJavaFrame->mJVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); WebHistory::RemoveItem(mJavaFrame->history(env), index); } @@ -478,7 +476,7 @@ WebFrame::updateHistoryIndex(int newIndex) TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif LOGV("::WebCore:: updateHistoryIndex to %d", newIndex); - JNIEnv* env = javavm_to_jnienv(mJavaFrame->mJVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); WebHistory::UpdateHistoryIndex(mJavaFrame->history(env), newIndex); } @@ -491,7 +489,7 @@ WebFrame::setTitle(const WebCore::String& title) #ifndef NDEBUG LOGV("setTitle(%s)", title.ascii().data()); #endif - JNIEnv* env = javavm_to_jnienv(mJavaFrame->mJVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); jstring jTitleStr = env->NewString((unsigned short *)title.characters(), title.length()); env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mSetTitle, @@ -507,7 +505,7 @@ WebFrame::windowObjectCleared(WebCore::Frame* frame) TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif LOGV("::WebCore:: windowObjectCleared"); - JNIEnv* env = javavm_to_jnienv(mJavaFrame->mJVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mWindowObjectCleared, (int)frame); checkException(env); @@ -519,7 +517,7 @@ WebFrame::setProgress(float newProgress) #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif - JNIEnv* env = javavm_to_jnienv(mJavaFrame->mJVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); int progress = (int) (100 * newProgress); env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mSetProgress, progress); checkException(env); @@ -538,7 +536,7 @@ WebFrame::didReceiveIcon(WebCore::Image* icon) TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif LOG_ASSERT(icon, "DidReceiveIcon called without an image!"); - JNIEnv* env = javavm_to_jnienv(mJavaFrame->mJVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); jobject bitmap = webcoreImageToJavaBitmap(env, icon); if (!bitmap) return; @@ -555,7 +553,7 @@ WebFrame::updateVisitedHistory(const WebCore::KURL& url, bool reload) TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif WebCore::String urlStr(url.string()); - JNIEnv* env = javavm_to_jnienv(mJavaFrame->mJVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); jstring jUrlStr = env->NewString((unsigned short*)urlStr.characters(), urlStr.length()); env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mUpdateVisitedHistory, jUrlStr, reload); @@ -587,7 +585,7 @@ WebFrame::canHandleRequest(const WebCore::ResourceRequest& request) // Empty urls should not be sent to java if (url.isEmpty()) return true; - JNIEnv* env = javavm_to_jnienv(mJavaFrame->mJVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); jstring jUrlStr = env->NewString((unsigned short *)url.characters(), url.length()); // check to see whether browser app wants to hijack url loading. @@ -603,7 +601,7 @@ WebFrame::createWindow(bool dialog, bool userGesture) #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif - JNIEnv* env = javavm_to_jnienv(mJavaFrame->mJVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); jobject obj = env->CallObjectMethod(mJavaFrame->frame(env).get(), mJavaFrame->mCreateWindow, dialog, userGesture); if (obj) { @@ -619,7 +617,7 @@ WebFrame::requestFocus() const #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif - JNIEnv* env = javavm_to_jnienv(mJavaFrame->mJVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mRequestFocus); checkException(env); } @@ -631,7 +629,7 @@ WebFrame::closeWindow(WebViewCore* webViewCore) TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif assert(webViewCore); - JNIEnv* env = javavm_to_jnienv(mJavaFrame->mJVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mCloseWindow, webViewCore->getJavaObject().get()); } @@ -646,7 +644,7 @@ WebFrame::decidePolicyForFormResubmission(WebCore::FramePolicyFunction func) #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif - JNIEnv* env = javavm_to_jnienv(mJavaFrame->mJVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); PolicyFunctionWrapper* p = new PolicyFunctionWrapper; p->func = func; env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mDecidePolicyForFormResubmission, p); @@ -655,7 +653,7 @@ WebFrame::decidePolicyForFormResubmission(WebCore::FramePolicyFunction func) WebCore::String WebFrame::getRawResourceFilename(RAW_RES_ID id) const { - JNIEnv* env = javavm_to_jnienv(mJavaFrame->mJVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); jstring ret = (jstring) env->CallObjectMethod(mJavaFrame->frame(env).get(), mJavaFrame->mGetRawResFilename, (int)id); diff --git a/WebKit/android/jni/WebCoreFrameBridge.h b/WebKit/android/jni/WebCoreFrameBridge.h index 3793042..f554117 100644 --- a/WebKit/android/jni/WebCoreFrameBridge.h +++ b/WebKit/android/jni/WebCoreFrameBridge.h @@ -61,7 +61,7 @@ class WebFrame : public WebCoreRefObject { // helper function static WebFrame* getWebFrame(const WebCore::Frame* frame); - WebCoreResourceLoader* startLoadingResource(WebCore::ResourceHandle*, + virtual WebCoreResourceLoader* startLoadingResource(WebCore::ResourceHandle*, const WebCore::ResourceRequest& request, bool isHighPriority, bool synchronous); @@ -93,7 +93,7 @@ class WebFrame : public WebCoreRefObject { void updateVisitedHistory(const WebCore::KURL& url, bool reload); - bool canHandleRequest(const WebCore::ResourceRequest& request); + virtual bool canHandleRequest(const WebCore::ResourceRequest& request); WebCore::Frame* createWindow(bool dialog, bool userGesture); diff --git a/WebKit/android/jni/WebCoreJni.cpp b/WebKit/android/jni/WebCoreJni.cpp index e4634d0..f9d9cc9 100644 --- a/WebKit/android/jni/WebCoreJni.cpp +++ b/WebKit/android/jni/WebCoreJni.cpp @@ -93,18 +93,6 @@ WebCore::String to_string(JNIEnv* env, jstring str) return ret; } -JavaVM* jnienv_to_javavm(JNIEnv* env) -{ - JavaVM* vm; - return env->GetJavaVM(&vm) >= 0 ? vm : NULL; -} - -JNIEnv* javavm_to_jnienv(JavaVM* vm) -{ - JNIEnv* env; - return vm->GetEnv((void **)&env, JNI_VERSION_1_4) >= 0 ? env : NULL; -} - } struct RegistrationMethod { diff --git a/WebKit/android/jni/WebCoreJni.h b/WebKit/android/jni/WebCoreJni.h index 6e7ea43..d6e48c7 100644 --- a/WebKit/android/jni/WebCoreJni.h +++ b/WebKit/android/jni/WebCoreJni.h @@ -66,12 +66,6 @@ jobject adoptGlobalRef(JNIEnv*, jobject); // occurred and logs the exception. bool checkException(JNIEnv* env); -// Get the JavaVM pointer for the given JNIEnv pointer -JavaVM* jnienv_to_javavm(JNIEnv* env); - -// Get the JNIEnv pointer for the given JavaVM pointer -JNIEnv* javavm_to_jnienv(JavaVM* vm); - // Create a WebCore::String object from a jstring object. WebCore::String to_string(JNIEnv* env, jstring str); diff --git a/WebKit/android/jni/WebCoreResourceLoader.cpp b/WebKit/android/jni/WebCoreResourceLoader.cpp index b335b49..d4eda81 100644 --- a/WebKit/android/jni/WebCoreResourceLoader.cpp +++ b/WebKit/android/jni/WebCoreResourceLoader.cpp @@ -70,13 +70,12 @@ static struct resourceloader_t { WebCoreResourceLoader::WebCoreResourceLoader(JNIEnv *env, jobject jLoadListener) { - mJvm = jnienv_to_javavm(env); mJLoader = env->NewGlobalRef(jLoadListener); } WebCoreResourceLoader::~WebCoreResourceLoader() { - JNIEnv* env = javavm_to_jnienv(mJvm); + JNIEnv* env = JSC::Bindings::getJNIEnv(); SET_NATIVE_HANDLE(env, mJLoader, 0); env->DeleteGlobalRef(mJLoader); mJLoader = 0; @@ -84,14 +83,14 @@ WebCoreResourceLoader::~WebCoreResourceLoader() void WebCoreResourceLoader::cancel() { - JNIEnv* env = javavm_to_jnienv(mJvm); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(mJLoader, gResourceLoader.mCancelMethodID); checkException(env); } void WebCoreResourceLoader::downloadFile() { - JNIEnv* env = javavm_to_jnienv(mJvm); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(mJLoader, gResourceLoader.mDownloadFileMethodID); checkException(env); } @@ -103,7 +102,7 @@ void WebCoreResourceLoader::downloadFile() */ bool WebCoreResourceLoader::willLoadFromCache(const WebCore::KURL& url) { - JNIEnv* env = javavm_to_jnienv(JSC::Bindings::getJavaVM()); + JNIEnv* env = JSC::Bindings::getJNIEnv(); WebCore::String urlStr = url.string(); jstring jUrlStr = env->NewString(urlStr.characters(), urlStr.length()); jclass resourceLoader = env->FindClass("android/webkit/LoadListener"); diff --git a/WebKit/android/jni/WebCoreResourceLoader.h b/WebKit/android/jni/WebCoreResourceLoader.h index 0b0de59..5dd5abe 100644 --- a/WebKit/android/jni/WebCoreResourceLoader.h +++ b/WebKit/android/jni/WebCoreResourceLoader.h @@ -66,7 +66,6 @@ public: static void Error(JNIEnv*, jobject, jint, jstring, jstring); private: - JavaVM* mJvm; jobject mJLoader; }; diff --git a/WebKit/android/jni/WebHistory.cpp b/WebKit/android/jni/WebHistory.cpp index 5555ff1..028d62e 100644 --- a/WebKit/android/jni/WebHistory.cpp +++ b/WebKit/android/jni/WebHistory.cpp @@ -43,6 +43,7 @@ #include "TextEncoding.h" #include "WebCoreFrameBridge.h" #include "WebCoreJni.h" +#include "jni_utility.h" #include <JNIHelp.h> #include <SkUtils.h> @@ -231,15 +232,14 @@ jbyteArray WebHistory::Flatten(JNIEnv* env, WTF::Vector<char>& v, WebCore::Histo // Write our flattened data to the java array. jbyte* bytes = env->GetByteArrayElements(b, NULL); - memcpy(bytes, v.data(), v.size()); + if (bytes) + memcpy(bytes, v.data(), v.size()); env->ReleaseByteArrayElements(b, bytes, 0); return b; } WebHistoryItem::WebHistoryItem(JNIEnv* env, jobject obj, WebCore::HistoryItem* item) { - JavaVM* vm; - mJVM = env->GetJavaVM(&vm) >= 0 ? vm : NULL; mObject = adoptGlobalRef(env, obj); mScale = 100; mActive = false; @@ -249,8 +249,7 @@ WebHistoryItem::WebHistoryItem(JNIEnv* env, jobject obj, WebHistoryItem::~WebHistoryItem() { if (mObject) { - JNIEnv* env; - env = mJVM->GetEnv((void **)&env, JNI_VERSION_1_4) >= 0 ? env : NULL; + JNIEnv* env = JSC::Bindings::getJNIEnv(); if (!env) return; env->DeleteGlobalRef(mObject); @@ -278,8 +277,7 @@ void WebHistoryItem::updateHistoryItem(WebCore::HistoryItem* item) { webItem = webItem->parent(); item = webItem->historyItem(); } - JNIEnv* env; - env = webItem->mJVM->GetEnv((void **)&env, JNI_VERSION_1_4) >= 0 ? env : NULL; + JNIEnv* env = JSC::Bindings::getJNIEnv(); if (!env) return; diff --git a/WebKit/android/jni/WebHistory.h b/WebKit/android/jni/WebHistory.h index 6b6b61d..40dc8f8 100644 --- a/WebKit/android/jni/WebHistory.h +++ b/WebKit/android/jni/WebHistory.h @@ -51,7 +51,6 @@ public: WebHistoryItem(WebHistoryItem* parent) : mParent(parent) , mObject(NULL) - , mJVM(NULL) , mScale(100) , mActive(false) , mHistoryItem(NULL) {} @@ -67,7 +66,6 @@ public: private: RefPtr<WebHistoryItem> mParent; jobject mObject; - JavaVM* mJVM; int mScale; bool mActive; WebCore::HistoryItem* mHistoryItem; diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 9967b78..6aa92cb 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -90,6 +90,7 @@ #include "HistoryItem.h" #include "android_graphics.h" #include <ui/KeycodeLabels.h> +#include "jni_utility.h" #if DEBUG_NAV_UI #include "SkTime.h" @@ -135,7 +136,6 @@ struct WebViewCoreFields { // ---------------------------------------------------------------------------- struct WebViewCore::JavaGlue { - JavaVM* m_JVM; jobject m_obj; jmethodID m_spawnScrollTo; jmethodID m_scrollTo; @@ -201,7 +201,6 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m jclass clazz = env->GetObjectClass(javaWebViewCore); m_javaGlue = new JavaGlue; - m_javaGlue->m_JVM = jnienv_to_javavm(env); m_javaGlue->m_obj = adoptGlobalRef(env, javaWebViewCore); m_javaGlue->m_spawnScrollTo = GetJMethod(env, clazz, "contentSpawnScrollTo", "(II)V"); m_javaGlue->m_scrollTo = GetJMethod(env, clazz, "contentScrollTo", "(II)V"); @@ -236,7 +235,7 @@ WebViewCore::~WebViewCore() Release(m_popupReply); if (m_javaGlue->m_obj) { - JNIEnv* env = javavm_to_jnienv(m_javaGlue->m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->DeleteGlobalRef(m_javaGlue->m_obj); m_javaGlue->m_obj = 0; } @@ -563,7 +562,7 @@ void WebViewCore::scrollTo(int x, int y, bool animate) // LOGD("WebViewCore::scrollTo(%d %d)\n", x, y); - JNIEnv* env = javavm_to_jnienv(m_javaGlue->m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(m_javaGlue->object(env).get(), animate ? m_javaGlue->m_spawnScrollTo : m_javaGlue->m_scrollTo, x, y); checkException(env); } @@ -571,7 +570,7 @@ void WebViewCore::scrollTo(int x, int y, bool animate) void WebViewCore::sendMarkNodeInvalid(WebCore::Node* node) { LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!"); - JNIEnv* env = javavm_to_jnienv(m_javaGlue->m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_sendMarkNodeInvalid, (int) node); checkException(env); } @@ -579,7 +578,7 @@ void WebViewCore::sendMarkNodeInvalid(WebCore::Node* node) void WebViewCore::sendNotifyFocusSet() { LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!"); - JNIEnv* env = javavm_to_jnienv(m_javaGlue->m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_sendNotifyFocusSet); checkException(env); } @@ -587,7 +586,7 @@ void WebViewCore::sendNotifyFocusSet() void WebViewCore::sendNotifyProgressFinished() { LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!"); - JNIEnv* env = javavm_to_jnienv(m_javaGlue->m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_sendNotifyProgressFinished); checkException(env); } @@ -595,7 +594,7 @@ void WebViewCore::sendNotifyProgressFinished() void WebViewCore::sendRecomputeFocus() { LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!"); - JNIEnv* env = javavm_to_jnienv(m_javaGlue->m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_sendRecomputeFocus); checkException(env); } @@ -603,7 +602,7 @@ void WebViewCore::sendRecomputeFocus() void WebViewCore::viewInvalidate(const SkIRect& rect) { LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!"); - JNIEnv* env = javavm_to_jnienv(m_javaGlue->m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_sendViewInvalidate, rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); checkException(env); @@ -612,7 +611,7 @@ void WebViewCore::viewInvalidate(const SkIRect& rect) void WebViewCore::viewInvalidate(const WebCore::IntRect& rect) { LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!"); - JNIEnv* env = javavm_to_jnienv(m_javaGlue->m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_sendViewInvalidate, rect.x(), rect.y(), rect.right(), rect.bottom()); checkException(env); @@ -622,14 +621,14 @@ void WebViewCore::scrollBy(int dx, int dy) { if (!(dx | dy)) return; - JNIEnv* env = javavm_to_jnienv(m_javaGlue->m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_scrollBy, dx, dy); checkException(env); } void WebViewCore::contentDraw() { - JNIEnv* env = javavm_to_jnienv(m_javaGlue->m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_contentDraw); checkException(env); } @@ -677,7 +676,7 @@ void WebViewCore::didFirstLayout() return; LOGV("::WebCore:: didFirstLayout %s", url.string().ascii().data()); - JNIEnv* env = javavm_to_jnienv(m_javaGlue->m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_didFirstLayout); checkException(env); @@ -691,7 +690,7 @@ void WebViewCore::restoreScale(int scale) DEBUG_NAV_UI_LOGD("%s", __FUNCTION__); LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!"); - JNIEnv* env = javavm_to_jnienv(m_javaGlue->m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_restoreScale, scale); checkException(env); } @@ -702,7 +701,7 @@ void WebViewCore::needTouchEvents(bool need) LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!"); #if ENABLE(TOUCH_EVENTS) // Android - JNIEnv* env = javavm_to_jnienv(m_javaGlue->m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_needTouchEvents, need); checkException(env); #endif @@ -1384,7 +1383,7 @@ WebCore::Frame* WebViewCore::deleteSelection(WebCore::Frame* frame, WebCore::Nod void WebViewCore::replaceTextfieldText(WebCore::Frame* frame, WebCore::Node* node, int x, int y, int oldStart, int oldEnd, jstring replace, int start, int end) { - JNIEnv* env = javavm_to_jnienv(m_javaGlue->m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); WebCore::String webcoreString = to_string(env, replace); frame = setSelection(frame, node, x, y, oldStart, oldEnd); @@ -1423,7 +1422,7 @@ void WebViewCore::passToJs(WebCore::Frame* frame, WebCore::Node* node, int x, in WebCore::RenderObject* renderer = currentFocus->renderer(); if (renderer && (renderer->isTextField() || renderer->isTextArea())) { WebCore::RenderTextControl* renderText = static_cast<WebCore::RenderTextControl*>(renderer); - JNIEnv* env = javavm_to_jnienv(m_javaGlue->m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); WebCore::String current = to_string(env, currentText); WebCore::String test = renderText->text(); // If the text changed during the key event, update the UI text field. @@ -1548,7 +1547,7 @@ void WebViewCore::listBoxRequest(WebCoreReply* reply, const uint16_t** labels, s LOG_ASSERT(m_javaGlue->m_obj, "No java widget associated with this view!"); // Create an array of java Strings for the drop down. - JNIEnv* env = javavm_to_jnienv(m_javaGlue->m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); jobjectArray labelArray = makeLabelArray(env, labels, count); // Create an array determining whether each item is enabled. @@ -1765,7 +1764,7 @@ void WebViewCore::popupReply(const int* array, int count) void WebViewCore::jsAlert(const WebCore::String& url, const WebCore::String& text) { - JNIEnv* env = javavm_to_jnienv(m_javaGlue->m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); jstring jInputStr = env->NewString((unsigned short *)text.characters(), text.length()); jstring jUrlStr = env->NewString((unsigned short *)url.characters(), url.length()); env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_jsAlert, jUrlStr, jInputStr); @@ -1776,7 +1775,7 @@ void WebViewCore::jsAlert(const WebCore::String& url, const WebCore::String& tex bool WebViewCore::jsConfirm(const WebCore::String& url, const WebCore::String& text) { - JNIEnv* env = javavm_to_jnienv(m_javaGlue->m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); jstring jInputStr = env->NewString((unsigned short *)text.characters(), text.length()); jstring jUrlStr = env->NewString((unsigned short *)url.characters(), url.length()); jboolean result = env->CallBooleanMethod(m_javaGlue->object(env).get(), m_javaGlue->m_jsConfirm, jUrlStr, jInputStr); @@ -1788,7 +1787,7 @@ bool WebViewCore::jsConfirm(const WebCore::String& url, const WebCore::String& t bool WebViewCore::jsPrompt(const WebCore::String& url, const WebCore::String& text, const WebCore::String& defaultValue, WebCore::String& result) { - JNIEnv* env = javavm_to_jnienv(m_javaGlue->m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); jstring jInputStr = env->NewString((unsigned short *)text.characters(), text.length()); jstring jDefaultStr = env->NewString((unsigned short *)defaultValue.characters(), defaultValue.length()); jstring jUrlStr = env->NewString((unsigned short *)url.characters(), url.length()); @@ -1807,7 +1806,7 @@ bool WebViewCore::jsPrompt(const WebCore::String& url, const WebCore::String& te bool WebViewCore::jsUnload(const WebCore::String& url, const WebCore::String& message) { - JNIEnv* env = javavm_to_jnienv(m_javaGlue->m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); jstring jInputStr = env->NewString((unsigned short *)message.characters(), message.length()); jstring jUrlStr = env->NewString((unsigned short *)url.characters(), url.length()); jboolean result = env->CallBooleanMethod(m_javaGlue->object(env).get(), m_javaGlue->m_jsUnload, jUrlStr, jInputStr); @@ -1820,13 +1819,13 @@ bool WebViewCore::jsUnload(const WebCore::String& url, const WebCore::String& me AutoJObject WebViewCore::getJavaObject() { - return getRealObject(javavm_to_jnienv(m_javaGlue->m_JVM), m_javaGlue->m_obj); + return getRealObject(JSC::Bindings::getJNIEnv(), m_javaGlue->m_obj); } jobject WebViewCore::getWebViewJavaObject() { - JNIEnv* env = javavm_to_jnienv(m_javaGlue->m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); return env->GetObjectField(m_javaGlue->object(env).get(), gWebViewCoreFields.m_webView); } @@ -1835,7 +1834,7 @@ void WebViewCore::updateTextfield(WebCore::Node* ptr, bool changeToPassword, { if (m_blockTextfieldUpdates) return; - JNIEnv* env = javavm_to_jnienv(m_javaGlue->m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); if (changeToPassword) { env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_updateTextfield, (int) ptr, true, 0, m_textGeneration); diff --git a/WebKit/android/nav/FindCanvas.h b/WebKit/android/nav/FindCanvas.h index 4ecbf37..5d79b4c 100644 --- a/WebKit/android/nav/FindCanvas.h +++ b/WebKit/android/nav/FindCanvas.h @@ -32,6 +32,7 @@ #include "SkRegion.h" #include "SkTDArray.h" #include "icu/unicode/umachine.h" +#include "wtf/Vector.h" class SkRect; class SkTypeface; diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp index 2a11490..c645f72 100644 --- a/WebKit/android/nav/WebView.cpp +++ b/WebKit/android/nav/WebView.cpp @@ -53,6 +53,7 @@ #include "SkTime.h" #include "WebCoreJni.h" #include "WebViewCore.h" +#include "jni_utility.h" #ifdef GET_NATIVE_VIEW #undef GET_NATIVE_VIEW @@ -350,7 +351,6 @@ enum OutOfFocusFix { }; struct JavaGlue { - JavaVM* m_JVM; jobject m_obj; jmethodID m_clearTextEntry; jmethodID m_scrollBy; @@ -381,7 +381,6 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl) { jclass clazz = env->FindClass("android/webkit/WebView"); // m_javaGlue = new JavaGlue; - m_javaGlue.m_JVM = jnienv_to_javavm(env); m_javaGlue.m_obj = adoptGlobalRef(env, javaWebView); m_javaGlue.m_scrollBy = GetJMethod(env, clazz, "setContentScrollBy", "(II)V"); m_javaGlue.m_clearTextEntry = GetJMethod(env, clazz, "clearTextEntry", "()V"); @@ -434,7 +433,7 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl) { if (m_javaGlue.m_obj) { - JNIEnv* env = javavm_to_jnienv(m_javaGlue.m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->DeleteGlobalRef(m_javaGlue.m_obj); m_javaGlue.m_obj = 0; } @@ -476,7 +475,7 @@ void clearFocus(int x, int y, bool inval) void clearTextEntry() { DEBUG_NAV_UI_LOGD("%s", __FUNCTION__); - JNIEnv* env = javavm_to_jnienv(m_javaGlue.m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(m_javaGlue.object(env).get(), m_javaGlue.m_clearTextEntry); checkException(env); } @@ -890,7 +889,7 @@ CachedRoot* getFrameCache(FrameCachePermission allowNewer) int getScaledMaxXScroll() { LOG_ASSERT(m_javaGlue.m_obj, "A java object was not associated with this native WebView!"); - JNIEnv* env = javavm_to_jnienv(m_javaGlue.m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); int result = env->CallIntMethod(m_javaGlue.object(env).get(), m_javaGlue.m_getScaledMaxXScroll); checkException(env); return result; @@ -899,7 +898,7 @@ int getScaledMaxXScroll() int getScaledMaxYScroll() { LOG_ASSERT(m_javaGlue.m_obj, "A java object was not associated with this native WebView!"); - JNIEnv* env = javavm_to_jnienv(m_javaGlue.m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); int result = env->CallIntMethod(m_javaGlue.object(env).get(), m_javaGlue.m_getScaledMaxYScroll); checkException(env); return result; @@ -908,7 +907,7 @@ int getScaledMaxYScroll() void getVisibleRect(WebCore::IntRect* rect) { LOG_ASSERT(m_javaGlue.m_obj, "A java object was not associated with this native WebView!"); - JNIEnv* env = javavm_to_jnienv(m_javaGlue.m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); jobject jRect = env->CallObjectMethod(m_javaGlue.object(env).get(), m_javaGlue.m_getVisibleRect); checkException(env); int left = (int) env->GetIntField(jRect, m_javaGlue.m_rectLeft); @@ -1573,7 +1572,7 @@ void sendFinalFocus(WebCore::Frame* framePtr, WebCore::Node* nodePtr, int x, int { DBG_NAV_LOGD("framePtr=%p nodePtr=%p x=%d y=%d", framePtr, nodePtr, x, y); LOG_ASSERT(m_javaGlue.m_obj, "A java object was not associated with this native WebView!"); - JNIEnv* env = javavm_to_jnienv(m_javaGlue.m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(m_javaGlue.object(env).get(), m_javaGlue.m_sendFinalFocus, (jint) framePtr, (jint) nodePtr, x, y); checkException(env); @@ -1582,7 +1581,7 @@ void sendFinalFocus(WebCore::Frame* framePtr, WebCore::Node* nodePtr, int x, int void sendKitFocus() { LOG_ASSERT(m_javaGlue.m_obj, "A java object was not associated with this native WebView!"); - JNIEnv* env = javavm_to_jnienv(m_javaGlue.m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(m_javaGlue.object(env).get(), m_javaGlue.m_sendKitFocus); checkException(env); } @@ -1596,7 +1595,7 @@ void sendMotionUp(int buildGeneration, " x=%d y=%d slop=%d", buildGeneration, m_generation, framePtr, nodePtr, x, y, slop); LOG_ASSERT(m_javaGlue.m_obj, "A WebView was not associated with this WebViewNative!"); - JNIEnv* env = javavm_to_jnienv(m_javaGlue.m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(m_javaGlue.object(env).get(), m_javaGlue.m_sendMotionUp, m_generation, buildGeneration, (jint) framePtr, (jint) nodePtr, x, y, slop, isClick, retry); checkException(env); @@ -1609,7 +1608,7 @@ void setFocusData(int buildGeneration, WebCore::Frame* framePtr, DBG_NAV_LOGD("moveGeneration=%d buildGeneration=%d framePtr=%p nodePtr=%p" " x=%d y=%d", m_generation, buildGeneration, framePtr, nodePtr, x, y); LOG_ASSERT(m_javaGlue.m_obj, "A java object was not associated with this native WebView!"); - JNIEnv* env = javavm_to_jnienv(m_javaGlue.m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(m_javaGlue.object(env).get(), m_javaGlue.m_setFocusData, m_generation, buildGeneration, (jint) framePtr, (jint) nodePtr, x, y, ignoreNullFocus); checkException(env); @@ -1678,7 +1677,7 @@ void scrollBy(int dx, int dy) { LOG_ASSERT(m_javaGlue.m_obj, "A java object was not associated with this native WebView!"); - JNIEnv* env = javavm_to_jnienv(m_javaGlue.m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(m_javaGlue.object(env).get(), m_javaGlue.m_scrollBy, dx, dy); checkException(env); } @@ -1730,14 +1729,14 @@ bool updateFocusNode(JNIEnv* env) void updateTextEntry() { - JNIEnv* env = javavm_to_jnienv(m_javaGlue.m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(m_javaGlue.object(env).get(), m_javaGlue.m_updateTextEntry); checkException(env); } void displaySoftKeyboard() { - JNIEnv* env = javavm_to_jnienv(m_javaGlue.m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(m_javaGlue.object(env).get(), m_javaGlue.m_displaySoftKeyboard); checkException(env); @@ -1745,21 +1744,21 @@ void displaySoftKeyboard() void viewInvalidate() { - JNIEnv* env = javavm_to_jnienv(m_javaGlue.m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(m_javaGlue.object(env).get(), m_javaGlue.m_viewInvalidate); checkException(env); } void viewInvalidateRect(int l, int t, int r, int b) { - JNIEnv* env = javavm_to_jnienv(m_javaGlue.m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(m_javaGlue.object(env).get(), m_javaGlue.m_viewInvalidateRect, l, r, t, b); checkException(env); } void postInvalidateDelayed(int64_t delay, const WebCore::IntRect& bounds) { - JNIEnv* env = javavm_to_jnienv(m_javaGlue.m_JVM); + JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(m_javaGlue.object(env).get(), m_javaGlue.m_postInvalidateDelayed, delay, bounds.x(), bounds.y(), bounds.right(), bounds.bottom()); checkException(env); diff --git a/perf/Android.mk b/perf/Android.mk new file mode 100644 index 0000000..2e51cfc --- /dev/null +++ b/perf/Android.mk @@ -0,0 +1,110 @@ +## +## +## Copyright 2009, The Android Open Source Project +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions +## are met: +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * 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 THE COPYRIGHT HOLDERS ``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. +## + +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + Intercept.cpp \ + MyJavaVM.cpp \ + main.cpp + +WEBCORE := external/webkit/WebCore +WEBKIT := external/webkit/WebKit +JSC := external/webkit/JavaScriptCore + +LOCAL_CFLAGS += -include "WebCorePrefixAndroid.h" + +LOCAL_C_INCLUDES := \ + $(JNI_H_INCLUDE) \ + external/webkit \ + $(WEBCORE) \ + $(WEBCORE)/page \ + $(WEBCORE)/platform \ + $(WEBCORE)/platform/graphics \ + $(WEBCORE)/platform/network \ + $(WEBCORE)/platform/text \ + $(WEBCORE)/rendering \ + $(WEBKIT) \ + $(WEBKIT)/android/stl \ + $(JSC) \ + external/icu4c/common \ + external/libxml2/include \ + external/skia/include/effects \ + external/skia/include/images \ + external/skia/include/ports \ + external/skia/include/utils \ + external/skia/src/ports \ + external/sqlite/dist \ + $(WEBCORE)/bindings/js \ + $(WEBCORE)/bridge \ + $(WEBCORE)/bridge/c \ + $(WEBCORE)/bridge/jni \ + $(WEBCORE)/css \ + $(WEBCORE)/dom \ + $(WEBCORE)/editing \ + $(WEBCORE)/history \ + $(WEBCORE)/html \ + $(WEBCORE)/inspector \ + $(WEBCORE)/loader \ + $(WEBCORE)/loader/appcache \ + $(WEBCORE)/loader/icon \ + $(WEBCORE)/page/android \ + $(WEBCORE)/page/animation \ + $(WEBCORE)/platform/android \ + $(WEBCORE)/platform/graphics/android \ + $(WEBCORE)/platform/graphics/network \ + $(WEBCORE)/platform/image-decoders \ + $(WEBCORE)/platform/network/android \ + $(WEBCORE)/platform/sql \ + $(WEBCORE)/plugins \ + $(WEBCORE)/rendering/style \ + $(WEBCORE)/storage \ + $(WEBCORE)/xml \ + $(WEBKIT)/android \ + $(WEBKIT)/android/jni \ + $(WEBKIT)/android/nav \ + $(WEBKIT)/android/plugins \ + $(JSC)/API \ + $(JSC)/VM \ + $(JSC)/debugger \ + $(JSC)/kjs \ + $(JSC)/icu \ + $(JSC)/pcre \ + $(JSC)/profiler \ + $(JSC)/runtime \ + $(JSC)/wtf \ + $(JSC)/wtf/unicode \ + $(JSC)/wtf/unicode/icu \ + $(JSC)/ForwardingHeaders \ + $(call include-path-for, corecg graphics) + +LOCAL_SHARED_LIBRARIES := libwebcore + +LOCAL_MODULE:= webcore_test + +include $(BUILD_EXECUTABLE) + diff --git a/perf/Intercept.cpp b/perf/Intercept.cpp new file mode 100644 index 0000000..9c4517e --- /dev/null +++ b/perf/Intercept.cpp @@ -0,0 +1,176 @@ +/* + * Copyright 2009, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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 THE COPYRIGHT HOLDERS ``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. + */ + +#define LOG_TAG "webcore_test" +#include "config.h" + +#include "Base64.h" +#include "CString.h" +#include "HashMap.h" +#include "HTTPParsers.h" +#include "Intercept.h" +#include "ResourceHandle.h" +#include "ResourceHandleClient.h" +#include "ResourceRequest.h" +#include "ResourceResponse.h" +#include "StringHash.h" +#include "TextEncoding.h" +#include <utils/Log.h> + +void MyResourceLoader::handleRequest() { + if (protocolIs(m_url, "data")) + loadData(m_url.substring(5)); // 5 for data: + else if (protocolIs(m_url, "file")) + loadFile(m_url.substring(7)); // 7 for file:// +} + +void MyResourceLoader::loadData(const String& data) { + LOGD("Loading data (%s) ...", data.latin1().data()); + ResourceHandleClient* client = m_handle->client(); + int index = data.find(','); + if (index == -1) { + client->cannotShowURL(m_handle); + return; + } + + String mediaType = data.substring(0, index); + String base64 = data.substring(index + 1); + + bool decode = mediaType.endsWith(";base64", false); + if (decode) + mediaType = mediaType.left(mediaType.length() - 7); // 7 for base64; + + if (mediaType.isEmpty()) + mediaType = "text/plain;charset=US-ASCII"; + + String mimeType = extractMIMETypeFromMediaType(mediaType); + String charset = extractCharsetFromMediaType(mediaType); + + ResourceResponse response; + response.setMimeType(mimeType); + + if (decode) { + base64 = decodeURLEscapeSequences(base64); + response.setTextEncodingName(charset); + client->didReceiveResponse(m_handle, response); + + // FIXME: This is annoying. WebCore's Base64 decoder chokes on spaces. + // That is correct with strict decoding but html authors (particularly + // the acid3 authors) put spaces in the data which should be ignored. + // Remove them here before sending to the decoder. + Vector<char> in; + CString str = base64.latin1(); + const char* chars = str.data(); + unsigned i = 0; + while (i < str.length()) { + char c = chars[i]; + // Don't send spaces or control characters. + if (c != ' ' && c != '\n' && c != '\t' && c != '\b' + && c != '\f' && c != '\r') + in.append(chars[i]); + i++; + } + Vector<char> out; + if (base64Decode(in, out) && out.size() > 0) + client->didReceiveData(m_handle, out.data(), out.size(), 0); + } else { + base64 = decodeURLEscapeSequences(base64, TextEncoding(charset)); + response.setTextEncodingName("UTF-16"); + client->didReceiveResponse(m_handle, response); + if (base64.length() > 0) + client->didReceiveData(m_handle, (const char*)base64.characters(), + base64.length() * sizeof(UChar), 0); + } + client->didFinishLoading(m_handle); +} +static String mimeTypeForExtension(const String& file) { + static HashMap<String, String, CaseFoldingHash> extensionToMime; + if (extensionToMime.isEmpty()) { + extensionToMime.set("txt", "text/plain"); + extensionToMime.set("html", "text/html"); + extensionToMime.set("htm", "text/html"); + extensionToMime.set("png", "image/png"); + extensionToMime.set("jpeg", "image/jpeg"); + extensionToMime.set("jpg", "image/jpeg"); + extensionToMime.set("gif", "image/gif"); + extensionToMime.set("ico", "image/x-icon"); + extensionToMime.set("js", "text/javascript"); + } + int dot = file.reverseFind('.'); + String mime("text/plain"); + if (dot != -1) { + String ext = file.substring(dot + 1); + if (extensionToMime.contains(ext)) + mime = extensionToMime.get(ext); + } + return mime; +} + +void MyResourceLoader::loadFile(const String& file) { + LOGD("Loading file (%s) ...", file.latin1().data()); + FILE* f = fopen(file.latin1().data(), "r"); + ResourceHandleClient* client = m_handle->client(); + if (!f) { + client->didFail(m_handle, + ResourceError("", -14, file, "Could not open file")); + } else { + ResourceResponse response; + response.setTextEncodingName("utf-8"); + response.setMimeType(mimeTypeForExtension(file)); + client->didReceiveResponse(m_handle, response); + char buf[512]; + while (true) { + int res = fread(buf, 1, sizeof(buf), f); + if (res <= 0) + break; + client->didReceiveData(m_handle, buf, res, 0); + } + fclose(f); + client->didFinishLoading(m_handle); + } +} + +WebCoreResourceLoader* MyWebFrame::startLoadingResource(ResourceHandle* handle, + const ResourceRequest& req, bool ignore1, bool ignore2) { + MyResourceLoader* loader = new MyResourceLoader(handle, req.url().string()); + Retain(loader); + m_requests.append(loader); + if (!m_timer.isActive()) + m_timer.startOneShot(0); + return loader; +} + +void MyWebFrame::timerFired(Timer<MyWebFrame>*) { + LOGD("Handling requests..."); + Vector<MyResourceLoader*> reqs; + reqs.swap(m_requests); + Vector<MyResourceLoader*>::iterator i = reqs.begin(); + Vector<MyResourceLoader*>::iterator end = reqs.end(); + for (; i != end; i++) { + (*i)->handleRequest(); + Release(*i); + } + LOGD("...done"); +} diff --git a/perf/Intercept.h b/perf/Intercept.h new file mode 100644 index 0000000..3945582 --- /dev/null +++ b/perf/Intercept.h @@ -0,0 +1,80 @@ +/* + * Copyright 2009, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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 THE COPYRIGHT HOLDERS ``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. + */ + +#ifndef INTERCEPT_H +#define INTERCEPT_H + +#include "jni_utility.h" +#include "MyJavaVM.h" +#include "PlatformString.h" +#include "Timer.h" +#include "Vector.h" +#include "WebCoreFrameBridge.h" +#include "WebCoreResourceLoader.h" + +namespace WebCore { + class Page; + class ResourceHandle; + class ResourceRequest; +} + +using namespace android; +using namespace WebCore; +using namespace WTF; + +class MyResourceLoader : public WebCoreResourceLoader { +public: + MyResourceLoader(ResourceHandle* handle, String url) + : WebCoreResourceLoader(JSC::Bindings::getJNIEnv(), MY_JOBJECT) + , m_handle(handle) + , m_url(url) {} + + void handleRequest(); + +private: + void loadData(const String&); + void loadFile(const String&); + ResourceHandle* m_handle; + String m_url; +}; + +class MyWebFrame : public WebFrame { +public: + MyWebFrame(Page* page) + : WebFrame(JSC::Bindings::getJNIEnv(), MY_JOBJECT, MY_JOBJECT, page) + , m_timer(this, &MyWebFrame::timerFired) {} + + virtual WebCoreResourceLoader* startLoadingResource(ResourceHandle* handle, + const ResourceRequest& req, bool, bool); + + virtual bool canHandleRequest(const ResourceRequest&) { return true; } + +private: + void timerFired(Timer<MyWebFrame>*); + Vector<MyResourceLoader*> m_requests; + Timer<MyWebFrame> m_timer; +}; + +#endif diff --git a/perf/MyJavaVM.cpp b/perf/MyJavaVM.cpp new file mode 100644 index 0000000..d536e6f --- /dev/null +++ b/perf/MyJavaVM.cpp @@ -0,0 +1,126 @@ +/* + * Copyright 2009, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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 THE COPYRIGHT HOLDERS ``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 "MyJavaVM.h" +#include "jni_utility.h" + +#include <jni.h> + +static JNIEnv* s_env; +static JavaVM* s_jvm; + +// JavaVM functions +jint vm_attachCurrentThread(JavaVM*, JNIEnv** env, void*) { + *env = s_env; + return JNI_OK; +} + +// JNIEnv functions +jobject env_callObjectMethodV(JNIEnv*, jobject, jmethodID, va_list) { + return MY_JOBJECT; +} +void env_callVoidMethodV(JNIEnv*, jobject, jmethodID, va_list) {} +void env_deleteRef(JNIEnv*, jobject) {} +jboolean env_exceptionCheck(JNIEnv*) { + return false; +} +jclass env_findClass(JNIEnv*, const char*) { + return (jclass) 1; +} +jbyte* env_getByteArrayElements(JNIEnv*, jbyteArray, jboolean*) { + return NULL; +} +jmethodID env_getMethodID(JNIEnv*, jclass, const char*, const char*) { + return (jmethodID) 1; +} +jclass env_getObjectClass(JNIEnv*, jobject) { + return (jclass) 1; +} +static const char* s_fakeString = "Fake Java String"; +const jchar* env_getStringChars(JNIEnv*, jstring, jboolean* isCopy) { + if (isCopy) + *isCopy = false; + return (const jchar*)s_fakeString; +} +jsize env_getStringLength(JNIEnv*, jstring) { + return sizeof(s_fakeString) - 1; +} +jbyteArray env_newByteArray(JNIEnv*, jsize) { + return (jbyteArray) 1; +} +jobject env_newRef(JNIEnv*, jobject obj) { + return obj; +} +jobject env_newObjectV(JNIEnv*, jclass, jmethodID, va_list) { + return MY_JOBJECT; +} +jstring env_newString(JNIEnv*, const jchar*, jsize) { + return (jstring) 1; +} +void env_releaseByteArrayElements(JNIEnv*, jbyteArray, jbyte*, jint) {} +void env_releaseStringChars(JNIEnv*, jstring, const jchar*) {} +void env_setIntField(JNIEnv*, jobject, jfieldID, jint) {} + +void InitializeJavaVM() { + // First, create the fake vm + s_jvm = new JavaVM; + JNIInvokeInterface* i = new JNIInvokeInterface; + memset(i, 0, sizeof(JNIInvokeInterface)); + s_jvm->functions = i; + + // Now, assign the functions of the vm to our fake ones. + i->AttachCurrentThread = vm_attachCurrentThread; + + // Create the fake env next + s_env = new JNIEnv; + JNINativeInterface* n = new JNINativeInterface; + memset(n, 0, sizeof(JNINativeInterface)); + s_env->functions = n; + + // Point the functions we care about to out fake ones. + n->CallObjectMethodV = env_callObjectMethodV; + n->CallVoidMethodV = env_callVoidMethodV; + n->DeleteLocalRef = env_deleteRef; + n->DeleteGlobalRef = env_deleteRef; + n->ExceptionCheck = env_exceptionCheck; + n->FindClass = env_findClass; + n->GetByteArrayElements = env_getByteArrayElements; + n->GetMethodID = env_getMethodID; + n->GetObjectClass = env_getObjectClass; + n->GetStringChars = env_getStringChars; + n->GetStringLength = env_getStringLength; + n->NewByteArray = env_newByteArray; + n->NewGlobalRef = env_newRef; + n->NewObjectV = env_newObjectV; + n->NewString = env_newString; + n->ReleaseByteArrayElements = env_releaseByteArrayElements; + n->ReleaseStringChars = env_releaseStringChars; + n->SetIntField = env_setIntField; + + // Tell WebCore about the vm + JSC::Bindings::setJavaVM(s_jvm); +} diff --git a/perf/MyJavaVM.h b/perf/MyJavaVM.h new file mode 100644 index 0000000..36d478d --- /dev/null +++ b/perf/MyJavaVM.h @@ -0,0 +1,34 @@ +/* + * Copyright 2009, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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 THE COPYRIGHT HOLDERS ``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. + */ + +#ifndef MY_JAVA_VM_H +#define MY_JAVA_VM_H + +// Make it 1 just to appease any assertions or checks for valid objects +#define MY_JOBJECT ((jobject) 1) + +void InitializeJavaVM(); + +#endif diff --git a/perf/main.cpp b/perf/main.cpp new file mode 100644 index 0000000..cb5358d --- /dev/null +++ b/perf/main.cpp @@ -0,0 +1,221 @@ +/* + * Copyright 2009, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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 THE COPYRIGHT HOLDERS ``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. + */ + +#define LOG_TAG "webcore_test" + +#include "config.h" + +#include "BackForwardList.h" +#include "ChromeClientAndroid.h" +#include "ContextMenuClientAndroid.h" +#include "CookieClient.h" +#include "DragClientAndroid.h" +#include "EditorClientAndroid.h" +#include "Frame.h" +#include "FrameLoader.h" +#include "FrameLoaderClientAndroid.h" +#include "FrameView.h" +#include "GraphicsContext.h" +#include "HistoryItem.h" +#include "InitializeThreading.h" +#include "InspectorClientAndroid.h" +#include "Intercept.h" +#include "IntRect.h" +#include "JavaSharedClient.h" +#include "jni_utility.h" +#include "MyJavaVM.h" +#include "Page.h" +#include "PlatformGraphicsContext.h" +#include "ResourceRequest.h" +#include "SelectionController.h" +#include "Settings.h" +#include "SharedBuffer.h" +#include "SubstituteData.h" +#include "TimerClient.h" +#include "TextEncoding.h" +#include "WebCoreViewBridge.h" +#include "WebFrameView.h" +#include "WebViewCore.h" + +#include "SkBitmap.h" +#include "SkCanvas.h" +#include "SkImageEncoder.h" + +#include <getopt.h> +#include <utils/Log.h> + +using namespace android; +using namespace WebCore; + +class MyJavaSharedClient : public TimerClient, public CookieClient { +public: + MyJavaSharedClient() : m_hasTimer(false) {} + virtual void setSharedTimer(long long timemillis) { m_hasTimer = true; } + virtual void stopSharedTimer() { m_hasTimer = false; } + virtual void setSharedTimerCallback(void (*f)()) { m_func = f; } + + // Cookie methods that do nothing. + virtual void setCookies(const KURL&, const KURL&, const String&) {} + virtual String cookies(const KURL&) { return ""; } + virtual bool cookiesEnabled() { return false; } + + bool m_hasTimer; + void (*m_func)(); +}; + +static void historyItemChanged(HistoryItem* i) { + if (i->bridge()) + i->bridge()->updateHistoryItem(i); +} + +int main(int argc, char** argv) { + int width = 800; + int height = 600; + if (argc <= 1) { + LOGE("Please supply a file to read\n"); + return 1; + } else { + while (true) { + int c = getopt(argc, argv, "d:"); + if (c == -1) + break; + else if (c == 'd') { + char* x = strchr(optarg, 'x'); + if (x) { + width = atoi(optarg); + height = atoi(x + 1); + LOGD("Rendering page at %dx%d", width, height); + } + } + } + } + + JSC::initializeThreading(); + + // Setting this allows data: urls to load from a local file. + FrameLoader::setLocalLoadPolicy(FrameLoader::AllowLocalLoadsForAll); + + // Create the fake JNIEnv and JavaVM + InitializeJavaVM(); + + // The real function is private to libwebcore but we know what it does. + notifyHistoryItemChanged = historyItemChanged; + + // Implement the shared timer callback + MyJavaSharedClient client; + JavaSharedClient::SetTimerClient(&client); + JavaSharedClient::SetCookieClient(&client); + + // Create the page with all the various clients + ChromeClientAndroid* chrome = new ChromeClientAndroid; + EditorClientAndroid* editor = new EditorClientAndroid; + Page* page = new Page(chrome, new ContextMenuClientAndroid, editor, + new DragClientAndroid, new InspectorClientAndroid); + editor->setPage(page); + + // Create MyWebFrame that intercepts network requests + MyWebFrame* webFrame = new MyWebFrame(page); + webFrame->setUserAgent("Performance testing"); // needs to be non-empty + chrome->setWebFrame(webFrame); + // ChromeClientAndroid maintains the reference. + Release(webFrame); + + // Create the Frame and the FrameLoaderClient + FrameLoaderClientAndroid* loader = new FrameLoaderClientAndroid(webFrame); + RefPtr<Frame> frame = Frame::create(page, NULL, loader); + loader->setFrame(frame.get()); + + // Build our View system, resize it to the given dimensions and release our + // references. Note: We keep a referenec to frameView so we can layout and + // draw later without risk of it being deleted. + WebViewCore* webViewCore = new WebViewCore(JSC::Bindings::getJNIEnv(), + MY_JOBJECT, frame.get()); + FrameView* frameView = new FrameView(frame.get()); + WebFrameView* webFrameView = new WebFrameView(frameView, webViewCore); + frame->setView(frameView); + frameView->resize(width, height); + Release(webViewCore); + Release(webFrameView); + + // Initialize the frame and turn of low-bandwidth display (it fails an + // assertion in the Cache code) + frame->init(); + frame->selection()->setFocused(true); + frame->loader()->setUseLowBandwidthDisplay(false); + + // Set all the default settings the Browser normally uses. + Settings* s = frame->settings(); + s->setLayoutAlgorithm(Settings::kLayoutNormal); // Normal layout for now + s->setStandardFontFamily("sans-serif"); + s->setFixedFontFamily("monospace"); + s->setSansSerifFontFamily("sans-serif"); + s->setSerifFontFamily("serif"); + s->setCursiveFontFamily("cursive"); + s->setFantasyFontFamily("fantasy"); + s->setMinimumFontSize(8); + s->setMinimumLogicalFontSize(8); + s->setDefaultFontSize(16); + s->setDefaultFixedFontSize(13); + s->setLoadsImagesAutomatically(true); + s->setJavaScriptEnabled(true); + s->setDefaultTextEncodingName("latin1"); + s->setPluginsEnabled(false); + s->setShrinksStandaloneImagesToFit(false); + s->setUseWideViewport(false); + + // Finally, load the actual data + ResourceRequest req(argv[optind]); + frame->loader()->load(req); + + // Layout the page and service the timer + frameView->layout(); + while (client.m_hasTimer) + client.m_func(); + + // Layout more if needed. + while (frameView->needsLayout()) + frameView->layout(); + + // Draw into an offscreen bitmap + SkBitmap bmp; + bmp.setConfig(SkBitmap::kARGB_8888_Config, width, height); + bmp.allocPixels(); + SkCanvas canvas(bmp); + PlatformGraphicsContext ctx(&canvas, NULL); + GraphicsContext gc(&ctx); + frameView->paintContents(&gc, IntRect(0, 0, width, height)); + + // Write the bitmap to the sdcard + SkImageEncoder* enc = SkImageEncoder::Create(SkImageEncoder::kPNG_Type); + enc->encodeFile("/sdcard/webcore_test.png", bmp, 100); + delete enc; + + // Tear down the world. + frameView->deref(); + frame->loader()->detachFromParent(); + delete page; + + return 0; +} |