diff options
Diffstat (limited to 'WebKit/android/plugins')
-rw-r--r-- | WebKit/android/plugins/ANPTypefaceInterface.cpp | 27 | ||||
-rw-r--r-- | WebKit/android/plugins/PluginWidgetAndroid.cpp | 25 | ||||
-rw-r--r-- | WebKit/android/plugins/PluginWidgetAndroid.h | 17 | ||||
-rw-r--r-- | WebKit/android/plugins/android_npapi.h | 67 |
4 files changed, 129 insertions, 7 deletions
diff --git a/WebKit/android/plugins/ANPTypefaceInterface.cpp b/WebKit/android/plugins/ANPTypefaceInterface.cpp index 17b3067..f4823d6 100644 --- a/WebKit/android/plugins/ANPTypefaceInterface.cpp +++ b/WebKit/android/plugins/ANPTypefaceInterface.cpp @@ -26,6 +26,7 @@ // must include config.h first for webkit to fiddle with new/delete #include "config.h" #include "SkANP.h" +#include "SkFontHost.h" static ANPTypeface* anp_createFromName(const char name[], ANPTypefaceStyle s) { SkTypeface* tf = SkTypeface::CreateFromName(name, @@ -57,6 +58,28 @@ static ANPTypefaceStyle anp_getStyle(const ANPTypeface* tf) { return static_cast<ANPTypefaceStyle>(s); } +static uint32_t anp_countTables(const ANPTypeface* tf) { + SkFontID id = SkTypeface::UniqueID(tf); + return SkFontHost::CountTables(id); +} + +static uint32_t anp_getTableTags(const ANPTypeface* tf, + ANPFontTableTag tags[]) { + SkFontID id = SkTypeface::UniqueID(tf); + return SkFontHost::GetTableTags(id, tags); +} + +static uint32_t anp_getTableSize(const ANPTypeface* tf, ANPFontTableTag tag) { + SkFontID id = SkTypeface::UniqueID(tf); + return SkFontHost::GetTableSize(id, tag); +} + +static uint32_t anp_getTableData(const ANPTypeface* tf, ANPFontTableTag tag, + uint32_t offset, uint32_t length, void* data) { + SkFontID id = SkTypeface::UniqueID(tf); + return SkFontHost::GetTableData(id, tag, offset, length, data); +} + /////////////////////////////////////////////////////////////////////////////// #define ASSIGN(obj, name) (obj)->name = anp_##name @@ -70,5 +93,9 @@ void ANPTypefaceInterfaceV0_Init(ANPInterface* v) { ASSIGN(i, ref); ASSIGN(i, unref); ASSIGN(i, getStyle); + ASSIGN(i, countTables); + ASSIGN(i, getTableTags); + ASSIGN(i, getTableSize); + ASSIGN(i, getTableData); } diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp index 350243e..ddb07bf 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.cpp +++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp @@ -25,6 +25,9 @@ #include "config.h" #include "android_graphics.h" +#include "Document.h" +#include "Element.h" +#include "Frame.h" #include "PluginPackage.h" #include "PluginView.h" #include "PluginWidgetAndroid.h" @@ -37,6 +40,7 @@ PluginWidgetAndroid::PluginWidgetAndroid(WebCore::PluginView* view) m_flipPixelRef = NULL; m_core = NULL; m_drawingModel = kBitmap_ANPDrawingModel; + m_eventFlags = 0; m_x = m_y = 0; } @@ -156,3 +160,24 @@ bool PluginWidgetAndroid::sendEvent(const ANPEvent& evt) { return false; } +void PluginWidgetAndroid::updateEventFlags(ANPEventFlags flags) { + + // if there are no differences then immediately return + if (m_eventFlags == flags) { + return; + } + + Document* doc = m_pluginView->getParentFrame()->document(); + if((m_eventFlags ^ flags) & kTouch_ANPEventFlag) { + if(flags & kTouch_ANPEventFlag) + doc->addTouchEventListener(m_pluginView->getElement()); + else + doc->removeTouchEventListener(m_pluginView->getElement()); + } + + m_eventFlags = flags; +} + +bool PluginWidgetAndroid::isAcceptingEvent(ANPEventFlag flag) { + return m_eventFlags & flag; +} diff --git a/WebKit/android/plugins/PluginWidgetAndroid.h b/WebKit/android/plugins/PluginWidgetAndroid.h index 157651c..1b0cfa9 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.h +++ b/WebKit/android/plugins/PluginWidgetAndroid.h @@ -62,7 +62,7 @@ struct PluginWidgetAndroid { /* Called whenever the plugin itself requests a new drawing model */ void setDrawingModel(ANPDrawingModel); - + /* Utility method to convert from local (plugin) coordinates to docuemnt coordinates. Needed (for instance) to convert the dirty rectangle into document coordinates to inturn inval the screen. @@ -78,22 +78,33 @@ struct PluginWidgetAndroid { a subsequent call to draw(NULL). */ void inval(const WebCore::IntRect&, bool signalRedraw); - + /* Called to draw into the plugin's bitmap. If canvas is non-null, the bitmap itself is then drawn into the canvas. */ void draw(SkCanvas* canvas = NULL); - + /* Send this event to the plugin instance, and return true if the plugin handled it. */ bool sendEvent(const ANPEvent&); + /* Update the plugins event flags. If a flag is set to true then the plugin + wants to be notified of events of this type. + */ + void updateEventFlags(ANPEventFlags); + + /* Called to check if a plugin wants to accept a given event type. It + returns true if the plugin wants the events and false otherwise. + */ + bool isAcceptingEvent(ANPEventFlag); + private: WebCore::PluginView* m_pluginView; android::WebViewCore* m_core; SkFlipPixelRef* m_flipPixelRef; ANPDrawingModel m_drawingModel; + ANPEventFlags m_eventFlags; int m_x; int m_y; }; diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h index bda8eeb..32fa1c0 100644 --- a/WebKit/android/plugins/android_npapi.h +++ b/WebKit/android/plugins/android_npapi.h @@ -126,9 +126,9 @@ typedef uint32_t ANPMatrixFlag; #define kSupportedDrawingModel_ANPGetValue ((NPNVariable)2000) /////////////////////////////////////////////////////////////////////////////// -// NPN_GetValue +// NPN_SetValue -/** Reqeust to set the drawing model. +/** Request to set the drawing model. NPN_SetValue(inst, ANPRequestDrawingModel_EnumValue, (void*)foo_DrawingModel) */ @@ -147,6 +147,24 @@ enum ANPDrawingModels { }; typedef int32_t ANPDrawingModel; +/** Request to receive/disable events. If the pointer is NULL then all input will + be disabled. Otherwise, the input type will be enabled iff its corresponding + bit in the EventFlags bit field is set. + + NPN_SetValue(inst, ANPAcceptEvents, (void*)EventFlags) + */ +#define kAcceptEvents_ANPSetValue ((NPPVariable)1001) + +/* The EventFlags are a set of bits used to determine which types of input the + plugin wishes to receive. For example, if the value is 0x03 then both key + and touch events will be provided to the plugin. + */ +enum ANPEventFlag { + kKey_ANPEventFlag = 0x01, + kTouch_ANPEventFlag = 0x02, +}; +typedef uint32_t ANPEventFlags; + /* Interfaces provide additional functionality to the plugin via function ptrs. Once an interface is retrived, it is valid for the lifetime of the plugin (just like browserfuncs). @@ -347,6 +365,8 @@ enum ANPTypefaceStyles { }; typedef uint32_t ANPTypefaceStyle; +typedef uint32_t ANPFontTableTag; + struct ANPFontMetrics { //! The greatest distance above the baseline for any glyph (will be <= 0) float fTop; @@ -403,6 +423,43 @@ struct ANPTypefaceInterfaceV0 : ANPInterface { /** Return the style bits for the specified typeface */ ANPTypefaceStyle (*getStyle)(const ANPTypeface*); + + /** Return the number of tables in the font + */ + uint32_t (*countTables)(const ANPTypeface*); + + /** Copy into tags[] (allocated by the caller) the list of table tags in + the font, and return the number. This will be the same as CountTables() + or 0 if an error occured. + */ + uint32_t (*getTableTags)(const ANPTypeface*, ANPFontTableTag tags[]); + + /** Given a table tag, return the size of its contents, or 0 if not present + */ + uint32_t (*getTableSize)(const ANPTypeface*, ANPFontTableTag); + + /** Copy the contents of a table into data (allocated by the caller). Note + that the contents of the table will be in their native endian order + (which for most truetype tables is big endian). If the table tag is + not found, or there is an error copying the data, then 0 is returned. + If this happens, it is possible that some or all of the memory pointed + to by data may have been written to, even though an error has occured. + + @param fontID the font to copy the table from + @param tag The table tag whose contents are to be copied + @param offset The offset in bytes into the table's contents where the + copy should start from. + @param length The number of bytes, starting at offset, of table data + to copy. + @param data storage address where the table contents are copied to + @return the number of bytes actually copied into data. If offset+length + exceeds the table's size, then only the bytes up to the table's + size are actually copied, and this is the value returned. If + offset > the table's size, or tag is not a valid table, + then 0 is returned. + */ + uint32_t (*getTableData)(const ANPTypeface*, ANPFontTableTag, + uint32_t offset, uint32_t length, void* data); }; struct ANPPaintInterfaceV0 : ANPInterface { @@ -660,8 +717,10 @@ enum ANPKeyModifiers { typedef uint32_t ANPKeyModifier; enum ANPTouchActions { - kDown_ANPTouchAction = 0, - kUp_ANPTouchAction = 1, + kDown_ANPTouchAction = 0, + kUp_ANPTouchAction = 1, + kMove_ANPTouchAction = 2, + kCancel_ANPTouchAction = 3, }; typedef int32_t ANPTouchAction; |