diff options
Diffstat (limited to 'Source')
32 files changed, 257 insertions, 228 deletions
diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp index 60d3af1..7ba603b 100644 --- a/Source/WebCore/dom/Document.cpp +++ b/Source/WebCore/dom/Document.cpp @@ -695,10 +695,7 @@ void Document::setDocType(PassRefPtr<DocumentType> docType) if (m_docType && !ownerElement() && m_docType->publicId().startsWith("-//wapforum//dtd xhtml mobile 1.", false)) { // fit mobile sites directly in the screen - if (Frame *f = frame()) - f->settings()->setMetadataSettings("width", "device-width"); - if (FrameView* frameView = view()) - PlatformBridge::updateViewport(frameView); + processViewport("width=device-width"); } #endif } @@ -2729,9 +2726,9 @@ void Document::processArguments(const String& features, void* data, ArgumentsCal #ifdef ANDROID_META_SUPPORT if (frame()) frame()->settings()->setMetadataSettings(keyString, valueString); -#else - callback(keyString, valueString, this, data); #endif + if (callback && data) + callback(keyString, valueString, this, data); } } diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h index 5ab6d77..179293c 100644 --- a/Source/WebCore/dom/Document.h +++ b/Source/WebCore/dom/Document.h @@ -794,11 +794,10 @@ public: void processViewport(const String& features); #ifdef ANDROID_META_SUPPORT - /** - * Handles viewport like <meta name = "viewport" content = "width = device-width"> - * or format-detection like <meta name = "format-detection" content = "telephone=no"> - */ - void processMetadataSettings(const String& content); + /** + * Handles format-detection like <meta name = "format-detection" content = "telephone=no"> + */ + void processMetadataSettings(const String& content); #endif // Returns the owning element in the parent document. diff --git a/Source/WebCore/html/HTMLBodyElement.cpp b/Source/WebCore/html/HTMLBodyElement.cpp index 9cf8730..0c93c95 100644 --- a/Source/WebCore/html/HTMLBodyElement.cpp +++ b/Source/WebCore/html/HTMLBodyElement.cpp @@ -206,13 +206,7 @@ void HTMLBodyElement::insertedIntoDocument() if (settings->viewportWidth() == -1 && (host.startsWith("m.") || host.startsWith("mobile.") || host.startsWith("wap.") || host.contains(".m.") || host.contains(".mobile." || host.contains(".wap.")))) { // fit mobile sites directly in the screen - settings->setMetadataSettings("width", "device-width"); - // update the meta data if it is the top document - if (!ownerElement) { - FrameView* view = document()->view(); - if (view) - PlatformBridge::updateViewport(view); - } + document()->processViewport("width=device-width"); } } #endif diff --git a/Source/WebCore/html/HTMLMetaElement.cpp b/Source/WebCore/html/HTMLMetaElement.cpp index d8d9fb3..cb7f4c0 100644 --- a/Source/WebCore/html/HTMLMetaElement.cpp +++ b/Source/WebCore/html/HTMLMetaElement.cpp @@ -75,30 +75,18 @@ void HTMLMetaElement::process() { if (!inDocument() || m_content.isNull()) return; + if (equalIgnoringCase(name(), "viewport")) + document()->processViewport(m_content); #ifdef ANDROID_META_SUPPORT // TODO: Evaluate whether to take upstreamed meta support - bool updateViewport = false; - if (equalIgnoringCase(name(), "viewport")) { - document()->processMetadataSettings(m_content); - updateViewport = true; - } else if (equalIgnoringCase(name(), "format-detection")) + else if (equalIgnoringCase(name(), "format-detection")) document()->processMetadataSettings(m_content); else if (((equalIgnoringCase(name(), "HandheldFriendly") && equalIgnoringCase(m_content, "true")) || equalIgnoringCase(name(), "MobileOptimized")) && document()->settings() && document()->settings()->viewportWidth() == -1) { // fit mobile sites directly in the screen - document()->settings()->setMetadataSettings("width", "device-width"); - updateViewport = true; + document()->processViewport("width=device-width"); } - // update the meta data if it is the top document - if (updateViewport && !document()->ownerElement()) { - FrameView* view = document()->view(); - if (view) - PlatformBridge::updateViewport(view); - } -#else - if (equalIgnoringCase(name(), "viewport")) - document()->processViewport(m_content); #endif #if ENABLE(ANDROID_INSTALLABLE_WEB_APPS) diff --git a/Source/WebCore/platform/android/ScrollViewAndroid.cpp b/Source/WebCore/platform/android/ScrollViewAndroid.cpp index f54e5ea..87c6a1f 100644 --- a/Source/WebCore/platform/android/ScrollViewAndroid.cpp +++ b/Source/WebCore/platform/android/ScrollViewAndroid.cpp @@ -68,32 +68,36 @@ IntSize ScrollView::platformContentsSize() const return m_contentsSize; } +static float getWebViewCoreScale(const ScrollView* view) { + return android::WebViewCore::getWebViewCore(view)->scale(); +} + int ScrollView::platformActualWidth() const { if (parent()) return width(); - return platformWidget()->visibleWidth(); + return platformWidget()->visibleWidth() * getWebViewCoreScale(this); } int ScrollView::platformActualHeight() const { if (parent()) return height(); - return platformWidget()->visibleHeight(); + return platformWidget()->visibleHeight() * getWebViewCoreScale(this); } int ScrollView::platformActualScrollX() const { if (parent()) return scrollX(); - return platformWidget()->visibleX(); + return platformWidget()->visibleX() * getWebViewCoreScale(this); } int ScrollView::platformActualScrollY() const { if (parent()) return scrollY(); - return platformWidget()->visibleY(); + return platformWidget()->visibleY() * getWebViewCoreScale(this); } void ScrollView::platformSetScrollPosition(const WebCore::IntPoint& pt) diff --git a/Source/WebCore/platform/graphics/android/AndroidAnimation.cpp b/Source/WebCore/platform/graphics/android/AndroidAnimation.cpp index e7d4780..2939cf0 100644 --- a/Source/WebCore/platform/graphics/android/AndroidAnimation.cpp +++ b/Source/WebCore/platform/graphics/android/AndroidAnimation.cpp @@ -83,10 +83,10 @@ AndroidAnimation::AndroidAnimation(AndroidAnimation* anim) , m_iterationCount(anim->m_iterationCount) , m_direction(anim->m_direction) , m_timingFunction(anim->m_timingFunction) + , m_name(anim->name()) , m_type(anim->m_type) , m_operations(anim->m_operations) , m_originalLayer(0) - , m_name(anim->name()) { gDebugAndroidAnimationInstances++; } diff --git a/Source/WebCore/platform/graphics/android/BaseTile.cpp b/Source/WebCore/platform/graphics/android/BaseTile.cpp index 2fa2427..ed2ad3e 100644 --- a/Source/WebCore/platform/graphics/android/BaseTile.cpp +++ b/Source/WebCore/platform/graphics/android/BaseTile.cpp @@ -28,8 +28,8 @@ #if USE(ACCELERATED_COMPOSITING) -#include "RasterRenderer.h" #include "GLUtils.h" +#include "RasterRenderer.h" #include "TextureInfo.h" #include "TilesManager.h" @@ -54,7 +54,8 @@ namespace WebCore { BaseTile::BaseTile() - : m_page(0) + : m_glWebViewState(0) + , m_page(0) , m_x(-1) , m_y(-1) , m_texture(0) @@ -63,15 +64,25 @@ BaseTile::BaseTile() , m_repaintPending(false) , m_usable(true) , m_lastDirtyPicture(0) - , m_fullRepaintA(true) - , m_fullRepaintB(true) , m_lastPaintedPicture(0) { #ifdef DEBUG_COUNT ClassTracker::instance()->increment("BaseTile"); #endif - m_currentDirtyArea = &m_dirtyAreaA; + m_currentDirtyAreaIndex = 0; m_renderer = new RasterRenderer(); + + // For EglImage Mode, the internal buffer should be 2. + // And for Async Surface Texture mode, this is 3. + if (TilesManager::instance()->getSharedTextureMode() == EglImageMode) + m_maxBufferNumber = 2; + else + m_maxBufferNumber = 3; + + m_dirtyArea = new SkRegion[m_maxBufferNumber]; + m_fullRepaint = new bool[m_maxBufferNumber]; + for (int i = 0; i < m_maxBufferNumber; i++) + m_fullRepaint[i] = true; } BaseTile::~BaseTile() @@ -81,6 +92,8 @@ BaseTile::~BaseTile() m_texture->release(this); delete m_renderer; + delete[] m_dirtyArea; + delete[] m_fullRepaint; #ifdef DEBUG_COUNT ClassTracker::instance()->decrement("BaseTile"); @@ -121,10 +134,10 @@ bool BaseTile::removeTexture(BaseTileTexture* texture) void BaseTile::fullInval() { - m_dirtyAreaA.setEmpty(); - m_dirtyAreaB.setEmpty(); - m_fullRepaintA = true; - m_fullRepaintB = true; + for (int i = 0; i < m_maxBufferNumber; i++) { + m_dirtyArea[i].setEmpty(); + m_fullRepaint[i] = true; + } m_dirty = true; } @@ -142,8 +155,8 @@ void BaseTile::markAsDirty(int unsigned pictureCount, { android::AutoMutex lock(m_atomicSync); m_lastDirtyPicture = pictureCount; - m_dirtyAreaA.op(dirtyArea, SkRegion::kUnion_Op); - m_dirtyAreaB.op(dirtyArea, SkRegion::kUnion_Op); + for (int i = 0; i < m_maxBufferNumber; i++) + m_dirtyArea[i].op(dirtyArea, SkRegion::kUnion_Op); m_dirty = true; } @@ -259,15 +272,14 @@ void BaseTile::paintBitmap() m_atomicSync.lock(); bool dirty = m_dirty; BaseTileTexture* texture = m_texture; - SkRegion dirtyArea = *m_currentDirtyArea; + SkRegion dirtyArea = m_dirtyArea[m_currentDirtyAreaIndex]; float scale = m_scale; const int x = m_x; const int y = m_y; m_atomicSync.unlock(); - if (!dirty || !texture) { + if (!dirty || !texture) return; - } TiledPage* tiledPage = m_page; @@ -298,12 +310,12 @@ void BaseTile::paintBitmap() SkRegion::Iterator cliperator(dirtyArea); bool fullRepaint = false; + // TODO: Implement the partial invalidate in Surface Texture Mode - if (((m_currentDirtyArea == &m_dirtyAreaA) && m_fullRepaintA) - || ((m_currentDirtyArea == &m_dirtyAreaB) && m_fullRepaintB) - || textureInfo->m_width != tileWidth - || textureInfo->m_height != tileHeight - || textureInfo->getSharedTextureMode() == SurfaceTextureMode) { + if (m_fullRepaint[m_currentDirtyAreaIndex] + || textureInfo->m_width != tileWidth + || textureInfo->m_height != tileHeight + || textureInfo->getSharedTextureMode() == SurfaceTextureMode) { fullRepaint = true; } @@ -378,12 +390,7 @@ void BaseTile::paintBitmap() m_lastPaintedPicture = pictureCount; // set the fullrepaint flags - - if ((m_currentDirtyArea == &m_dirtyAreaA) && m_fullRepaintA) - m_fullRepaintA = false; - - if ((m_currentDirtyArea == &m_dirtyAreaB) && m_fullRepaintB) - m_fullRepaintB = false; + m_fullRepaint[m_currentDirtyAreaIndex] = false; // The various checks to see if we are still dirty... @@ -393,18 +400,19 @@ void BaseTile::paintBitmap() m_dirty = true; if (fullRepaint) - m_currentDirtyArea->setEmpty(); + m_dirtyArea[m_currentDirtyAreaIndex].setEmpty(); else - m_currentDirtyArea->op(dirtyArea, SkRegion::kDifference_Op); + m_dirtyArea[m_currentDirtyAreaIndex].op(dirtyArea, SkRegion::kDifference_Op); - if (!m_currentDirtyArea->isEmpty()) + if (!m_dirtyArea[m_currentDirtyAreaIndex].isEmpty()) m_dirty = true; // Now we can swap the dirty areas + // TODO: For surface texture in Async mode, the index will be updated + // according to the current buffer just dequeued. + m_currentDirtyAreaIndex = (m_currentDirtyAreaIndex+1) % m_maxBufferNumber; - m_currentDirtyArea = m_currentDirtyArea == &m_dirtyAreaA ? &m_dirtyAreaB : &m_dirtyAreaA; - - if (!m_currentDirtyArea->isEmpty()) + if (!m_dirtyArea[m_currentDirtyAreaIndex].isEmpty()) m_dirty = true; if (!m_dirty) diff --git a/Source/WebCore/platform/graphics/android/BaseTile.h b/Source/WebCore/platform/graphics/android/BaseTile.h index d336ae2..b5fc7ba 100644 --- a/Source/WebCore/platform/graphics/android/BaseTile.h +++ b/Source/WebCore/platform/graphics/android/BaseTile.h @@ -40,6 +40,7 @@ namespace WebCore { class TextureInfo; class TiledPage; class BaseTileTexture; +class GLWebViewState; /** * An individual tile that is used to construct part of a webpage's BaseLayer of @@ -94,11 +95,16 @@ public: unsigned int lastPaintedPicture() const { return m_lastPaintedPicture; } BaseTileTexture* texture() { return m_texture; } + void setGLWebViewState(GLWebViewState* state) { m_glWebViewState = state; } + // TextureOwner implementation virtual bool removeTexture(BaseTileTexture* texture); virtual TiledPage* page() { return m_page; } + virtual GLWebViewState* state() { return m_glWebViewState; } private: + GLWebViewState* m_glWebViewState; + // these variables are only set when the object is constructed TiledPage* m_page; int m_x; @@ -119,11 +125,10 @@ private: unsigned int m_lastDirtyPicture; // store the dirty region - SkRegion m_dirtyAreaA; - SkRegion m_dirtyAreaB; - bool m_fullRepaintA; - bool m_fullRepaintB; - SkRegion* m_currentDirtyArea; + SkRegion* m_dirtyArea; + bool* m_fullRepaint; + int m_maxBufferNumber; + int m_currentDirtyAreaIndex; // stores the id of the latest picture painted to the tile. If the id is 0 // then we know that the picture has not yet been painted an there is nothing diff --git a/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp b/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp index ee8cebf..f66019a 100644 --- a/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp +++ b/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp @@ -39,7 +39,8 @@ namespace WebCore { BaseTileTexture::BaseTileTexture(uint32_t w, uint32_t h) - : DoubleBufferedTexture(eglGetCurrentContext(), SurfaceTextureMode) + : DoubleBufferedTexture(eglGetCurrentContext(), + TilesManager::instance()->getSharedTextureMode()) , m_usedLevel(-1) , m_owner(0) , m_delayedReleaseOwner(0) @@ -147,13 +148,12 @@ bool BaseTileTexture::acquire(TextureOwner* owner, bool force) return setOwner(owner, force); } -bool BaseTileTexture::tryAcquire(TextureOwner* owner, TiledPage* currentPage, TiledPage* nextPage) +bool BaseTileTexture::tryAcquire(TextureOwner* owner) { m_busyLock.lock(); if (!m_busy && m_owner - && m_owner->page() != currentPage - && m_owner->page() != nextPage) { + && m_owner->state() != owner->state()) { m_busyLock.unlock(); return this->acquire(owner); } diff --git a/Source/WebCore/platform/graphics/android/BaseTileTexture.h b/Source/WebCore/platform/graphics/android/BaseTileTexture.h index 0a7534a..5496e66 100644 --- a/Source/WebCore/platform/graphics/android/BaseTileTexture.h +++ b/Source/WebCore/platform/graphics/android/BaseTileTexture.h @@ -86,7 +86,7 @@ public: // returns false if ownership cannot be transferred because the tile is busy bool acquire(TextureOwner* owner, bool force = false); bool release(TextureOwner* owner); - bool tryAcquire(TextureOwner* owner, TiledPage* currentPage, TiledPage* nextPage); + bool tryAcquire(TextureOwner* owner); // set the texture owner if not busy. Return false if busy, true otherwise. bool setOwner(TextureOwner* owner, bool force = false); diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp index dda5dee..54176e0 100644 --- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp +++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp @@ -116,6 +116,7 @@ GLWebViewState::~GLWebViewState() #ifdef DEBUG_COUNT ClassTracker::instance()->decrement("GLWebViewState"); #endif + TilesManager::instance()->unregisterGLWebViewState(this); } void GLWebViewState::setBaseLayer(BaseLayerAndroid* layer, const SkRegion& inval, @@ -497,6 +498,7 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect, IntRect& clip, float scale, SkColor color) { glFinish(); + TilesManager::instance()->registerGLWebViewState(this); m_baseLayerLock.lock(); BaseLayerAndroid* baseLayer = m_currentBaseLayer; diff --git a/Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp b/Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp index 429a125..e015f5a 100644 --- a/Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp @@ -624,10 +624,10 @@ static void setrectForUnderline(SkRect* r, GraphicsContext* context, const Float if (lineThickness < 1) // Do we really need/want this? lineThickness = 1; #endif - r->fLeft = SkIntToScalar(point.x()); - r->fTop = SkIntToScalar(point.y() + yOffset); - r->fRight = r->fLeft + SkIntToScalar(width); - r->fBottom = r->fTop + SkFloatToScalar(lineThickness); + r->fLeft = point.x(); + r->fTop = point.y() + yOffset; + r->fRight = r->fLeft + width; + r->fBottom = r->fTop + lineThickness; } void GraphicsContext::drawLineForText(const FloatPoint& pt, float width, bool) diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.h b/Source/WebCore/platform/graphics/android/LayerAndroid.h index 9dfe973..bd6c0ef 100644 --- a/Source/WebCore/platform/graphics/android/LayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/LayerAndroid.h @@ -102,6 +102,7 @@ public: LayerTexture* texture() { return m_reservedTexture; } virtual TiledPage* page() { return 0; } + virtual GLWebViewState* state() { return 0; } void setBackfaceVisibility(bool value) { m_backfaceVisibility = value; } void setTransform(const TransformationMatrix& matrix) { m_transform = matrix; } diff --git a/Source/WebCore/platform/graphics/android/TextureOwner.h b/Source/WebCore/platform/graphics/android/TextureOwner.h index bd3a291..15395bb 100644 --- a/Source/WebCore/platform/graphics/android/TextureOwner.h +++ b/Source/WebCore/platform/graphics/android/TextureOwner.h @@ -30,12 +30,14 @@ namespace WebCore { class TiledPage; class BaseTileTexture; +class GLWebViewState; class TextureOwner { public: virtual ~TextureOwner() { } virtual bool removeTexture(BaseTileTexture* texture) = 0; virtual TiledPage* page() = 0; + virtual GLWebViewState* state() = 0; }; } diff --git a/Source/WebCore/platform/graphics/android/TiledPage.cpp b/Source/WebCore/platform/graphics/android/TiledPage.cpp index 0e1e947..b532d7a 100644 --- a/Source/WebCore/platform/graphics/android/TiledPage.cpp +++ b/Source/WebCore/platform/graphics/android/TiledPage.cpp @@ -171,6 +171,7 @@ void TiledPage::prepareRow(bool goingLeft, int tilesInRow, int firstTileX, int y if (currentTile) { currentTile->setScale(m_scale); + currentTile->setGLWebViewState(m_glWebViewState); // ensure there is a texture associated with the tile and then check to // see if the texture is dirty and in need of repainting diff --git a/Source/WebCore/platform/graphics/android/TilesManager.cpp b/Source/WebCore/platform/graphics/android/TilesManager.cpp index da7e89c..ad4cbd3 100644 --- a/Source/WebCore/platform/graphics/android/TilesManager.cpp +++ b/Source/WebCore/platform/graphics/android/TilesManager.cpp @@ -93,6 +93,7 @@ TilesManager::TilesManager() , m_expandedTileBounds(false) , m_generatorReady(false) , m_showVisualIndicator(false) + , m_drawRegistrationCount(0) { XLOG("TilesManager ctor"); m_textures.reserveCapacity(MAX_TEXTURE_ALLOCATION); @@ -168,47 +169,41 @@ BaseTileTexture* TilesManager::getAvailableTexture(BaseTile* owner) } // The heuristic for selecting a texture is as follows: - // 1. return an unused texture if one exists - // 2. return the farthest texture from the viewport (from any tiled page) - // 3. return any texture not used by the tile's page or the page's sibiling - // - // The texture level indicates a tiles closeness to the current viewport + // 1. If usedLevel == -1, break with that one + // 2. Otherwise, select the highest usedLevel available + // 3. Break ties with the lowest LRU(RecentLevel) valued GLWebViewState + BaseTileTexture* farthestTexture = 0; int farthestTextureLevel = 0; + unsigned int lowestDrawCount = ~0; //maximum uint const unsigned int max = m_textures.size(); for (unsigned int i = 0; i < max; i++) { BaseTileTexture* texture = m_textures[i]; + if (texture->usedLevel() == -1) { // found an unused texture, grab it farthestTexture = texture; break; } - if (farthestTextureLevel < texture->usedLevel()) { - farthestTextureLevel = texture->usedLevel(); + + int textureLevel = texture->usedLevel(); + unsigned int textureDrawCount = getGLWebViewStateDrawCount(texture->owner()->state()); + + // if (higher distance or equal distance but less recently rendered) + if (farthestTextureLevel < textureLevel + || ((farthestTextureLevel == textureLevel) && (lowestDrawCount > textureDrawCount))) { farthestTexture = texture; + farthestTextureLevel = textureLevel; + lowestDrawCount = textureDrawCount; } } + if (farthestTexture && farthestTexture->acquire(owner)) { - XLOG("farthest texture, getAvailableTexture(%x) => texture %x (level %d)", - owner, farthestTexture, farthestTexture->usedLevel()); + XLOG("farthest texture, getAvailableTexture(%x) => texture %x (level %d, drawCount %d)", + owner, farthestTexture, farthestTextureLevel, lowestDrawCount); farthestTexture->setUsedLevel(0); return farthestTexture; } - // At this point, all textures are used or we failed to aquire the farthest - // texture. Now let's just grab a texture not in use by either of the two - // tiled pages associated with this view. - TiledPage* currentPage = owner->page(); - TiledPage* nextPage = currentPage->sibling(); - for (unsigned int i = 0; i < max; i++) { - BaseTileTexture* texture = m_textures[i]; - if (texture->tryAcquire(owner, currentPage, nextPage)) { - XLOG("grab a texture that wasn't ours, (%x != %x) at %d => texture %x", - owner->page(), texture->owner()->page(), i, texture); - texture->setUsedLevel(0); - return texture; - } - } - XLOG("Couldn't find an available texture for BaseTile %x (%d, %d) !!!", owner, owner->x(), owner->y()); #ifdef DEBUG @@ -424,6 +419,25 @@ int TilesManager::expandedTileBoundsY() { return m_expandedTileBounds ? EXPANDED_TILE_BOUNDS_Y : 0; } +void TilesManager::registerGLWebViewState(GLWebViewState* state) +{ + m_glWebViewStateMap.set(state, m_drawRegistrationCount); + m_drawRegistrationCount++; + XLOG("now state %p, total of %d states", state, m_glWebViewStateMap.size()); +} + +void TilesManager::unregisterGLWebViewState(GLWebViewState* state) +{ + m_glWebViewStateMap.remove(state); + XLOG("state %p now removed, total of %d states", state, m_glWebViewStateMap.size()); +} + +unsigned int TilesManager::getGLWebViewStateDrawCount(GLWebViewState* state) +{ + XLOG("looking up state %p, contains=%s", state, m_glWebViewStateMap.contains(state) ? "TRUE" : "FALSE"); + return m_glWebViewStateMap.find(state)->second; +} + TilesManager* TilesManager::instance() { if (!gInstance) { diff --git a/Source/WebCore/platform/graphics/android/TilesManager.h b/Source/WebCore/platform/graphics/android/TilesManager.h index 5237c14..fe53666 100644 --- a/Source/WebCore/platform/graphics/android/TilesManager.h +++ b/Source/WebCore/platform/graphics/android/TilesManager.h @@ -37,6 +37,7 @@ #include "TiledPage.h" #include "VideoLayerManager.h" #include <utils/threads.h> +#include <wtf/HashMap.h> namespace WebCore { @@ -108,6 +109,8 @@ public: static float tileHeight(); int expandedTileBoundsX(); int expandedTileBoundsY(); + void registerGLWebViewState(GLWebViewState* state); + void unregisterGLWebViewState(GLWebViewState* state); void allocateTiles(); @@ -123,6 +126,10 @@ public: m_showVisualIndicator = showVisualIndicator; } + SharedTextureMode getSharedTextureMode() { + return SurfaceTextureMode; + } + private: TilesManager(); @@ -156,6 +163,11 @@ private: ShaderProgram m_shader; VideoLayerManager m_videoLayerManager; + + HashMap<GLWebViewState*, unsigned int> m_glWebViewStateMap; + unsigned int m_drawRegistrationCount; + + unsigned int getGLWebViewStateDrawCount(GLWebViewState* state); }; } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/android/VideoLayerAndroid.h b/Source/WebCore/platform/graphics/android/VideoLayerAndroid.h index 0f3f007..abc1c13 100644 --- a/Source/WebCore/platform/graphics/android/VideoLayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/VideoLayerAndroid.h @@ -44,7 +44,7 @@ namespace WebCore { // Otherwise will draw a static image. // NOTE: These values are matching the ones in HTML5VideoView.java // Please keep them in sync when changed here. -typedef enum {INITIALIZED, PREPARING, PREPARED, PLAYING} PlayerState; +typedef enum {INITIALIZED, PREPARING, PREPARED, PLAYING, RELEASED} PlayerState; class VideoLayerAndroid : public LayerAndroid { diff --git a/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp b/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp index 1fd8ee9..7ff5b19 100644 --- a/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp +++ b/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp @@ -347,6 +347,22 @@ void ChromeClientAndroid::scrollbarsModeDidChange() const notImplemented(); } +void ChromeClientAndroid::dispatchViewportDataDidChange(const ViewportArguments& input) const { +#ifdef ANDROID_META_SUPPORT + const ViewportArguments emptyArgument; + if (input == emptyArgument) { + // Empty Argument is for a page with no viewport meta tag; so reset everything. + m_webFrame->page()->settings()->resetMetadataSettings(); + } + Document* doc = m_webFrame->page()->mainFrame()->document(); + if (!doc->ownerElement()) { + FrameView* view = doc->view(); + if (view) + PlatformBridge::updateViewport(view); + } +#endif +} + void ChromeClientAndroid::mouseDidMoveOverElement(const HitTestResult&, unsigned int) {} void ChromeClientAndroid::setToolTip(const String&, TextDirection) {} void ChromeClientAndroid::print(Frame*) {} diff --git a/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.h b/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.h index acb7792..36576e6 100644 --- a/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.h +++ b/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.h @@ -124,6 +124,8 @@ namespace android { virtual void scrollRectIntoView(const IntRect&, const ScrollView*) const; // End methods used by HostWindow. + virtual void dispatchViewportDataDidChange(const ViewportArguments&) const; + virtual void scrollbarsModeDidChange() const; virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned int); diff --git a/Source/WebKit/android/WebCoreSupport/ChromiumIncludes.h b/Source/WebKit/android/WebCoreSupport/ChromiumIncludes.h index 670b307..dac555f 100644 --- a/Source/WebKit/android/WebCoreSupport/ChromiumIncludes.h +++ b/Source/WebKit/android/WebCoreSupport/ChromiumIncludes.h @@ -47,12 +47,12 @@ #include <android/net/android_network_library_impl.h> #include <base/callback.h> -#include <base/synchronization/lock.h> +#include <base/memory/ref_counted.h> #include <base/message_loop_proxy.h> #include <base/openssl_util.h> -#include <base/ref_counted.h> #include <base/string_util.h> #include <base/synchronization/condition_variable.h> +#include <base/synchronization/lock.h> #include <base/sys_string_conversions.h> #include <base/threading/thread.h> #include <base/time.h> @@ -86,7 +86,7 @@ #include <autofill/autofill_profile.h> #include <autofill/personal_data_manager.h> #include <base/logging.h> -#include <base/scoped_vector.h> +#include <base/memory/scoped_vector.h> #include <base/string16.h> #include <base/utf_string_conversions.h> #include <chrome/browser/autofill/autofill_host.h> diff --git a/Source/WebKit/android/WebCoreSupport/UrlInterceptResponse.cpp b/Source/WebKit/android/WebCoreSupport/UrlInterceptResponse.cpp index 3779ba8..77e3c32 100644 --- a/Source/WebKit/android/WebCoreSupport/UrlInterceptResponse.cpp +++ b/Source/WebKit/android/WebCoreSupport/UrlInterceptResponse.cpp @@ -46,6 +46,7 @@ public: LOG_ALWAYS_FATAL_IF(!m_read); m_close = env->GetMethodID(inputStreamClass, "close", "()V"); LOG_ALWAYS_FATAL_IF(!m_close); + env->DeleteLocalRef(inputStreamClass); } ~JavaInputStreamWrapper() { @@ -112,6 +113,7 @@ UrlInterceptResponse::UrlInterceptResponse(JNIEnv* env, jobject response) { } env->DeleteLocalRef(javaResponse); + env->DeleteLocalRef(stream); env->DeleteLocalRef(mimeStr); env->DeleteLocalRef(encodingStr); } diff --git a/Source/WebKit/android/WebCoreSupport/WebCookieJar.cpp b/Source/WebKit/android/WebCoreSupport/WebCookieJar.cpp index dfb249d..1dc4637 100644 --- a/Source/WebKit/android/WebCoreSupport/WebCookieJar.cpp +++ b/Source/WebKit/android/WebCoreSupport/WebCookieJar.cpp @@ -165,14 +165,14 @@ int WebCookieJar::getNumCookiesInDatabase() } // From CookiePolicy in chromium -int WebCookieJar::CanGetCookies(const GURL&, const GURL&, net::CompletionCallback*) +int WebCookieJar::CanGetCookies(const GURL&, const GURL&) const { MutexLocker lock(m_allowCookiesMutex); return m_allowCookies ? net::OK : net::ERR_ACCESS_DENIED; } // From CookiePolicy in chromium -int WebCookieJar::CanSetCookie(const GURL&, const GURL&, const std::string&, net::CompletionCallback*) +int WebCookieJar::CanSetCookie(const GURL&, const GURL&, const std::string&) const { MutexLocker lock(m_allowCookiesMutex); return m_allowCookies ? net::OK : net::ERR_ACCESS_DENIED; diff --git a/Source/WebKit/android/WebCoreSupport/WebCookieJar.h b/Source/WebKit/android/WebCoreSupport/WebCookieJar.h index 1f4266c..b6490af 100644 --- a/Source/WebKit/android/WebCoreSupport/WebCookieJar.h +++ b/Source/WebKit/android/WebCoreSupport/WebCookieJar.h @@ -43,8 +43,8 @@ public: static void flush(); // CookiePolicy implementation from external/chromium - virtual int CanGetCookies(const GURL& url, const GURL& first_party_for_cookies, net::CompletionCallback*); - virtual int CanSetCookie(const GURL& url, const GURL& first_party_for_cookies, const std::string& cookie_line, net::CompletionCallback*); + virtual int CanGetCookies(const GURL& url, const GURL& first_party_for_cookies) const; + virtual int CanSetCookie(const GURL& url, const GURL& first_party_for_cookies, const std::string& cookie_line) const; bool allowCookies(); void setAllowCookies(bool allow); @@ -70,7 +70,7 @@ private: scoped_refptr<SQLitePersistentCookieStore> m_cookieDb; scoped_refptr<net::CookieStore> m_cookieStore; bool m_allowCookies; - WTF::Mutex m_allowCookiesMutex; + mutable WTF::Mutex m_allowCookiesMutex; }; } diff --git a/Source/WebKit/android/WebCoreSupport/WebViewClientError.cpp b/Source/WebKit/android/WebCoreSupport/WebViewClientError.cpp index 59542da..d5270a9 100644 --- a/Source/WebKit/android/WebCoreSupport/WebViewClientError.cpp +++ b/Source/WebKit/android/WebCoreSupport/WebViewClientError.cpp @@ -98,7 +98,6 @@ WebViewClientError ToWebViewClientError(net::Error error) { case ERR_SSL_BAD_RECORD_MAC_ALERT: case ERR_SSL_UNSAFE_NEGOTIATION: case ERR_SSL_WEAK_SERVER_EPHEMERAL_DH_KEY: - case ERR_SSL_SNAP_START_NPN_MISPREDICTION: case ERR_SSL_CLIENT_AUTH_PRIVATE_KEY_ACCESS_DENIED: case ERR_SSL_CLIENT_AUTH_CERT_NO_PRIVATE_KEY: return ERROR_FAILED_SSL_HANDSHAKE; diff --git a/Source/WebKit/android/WebCoreSupport/autofill/FormFieldAndroid.cpp b/Source/WebKit/android/WebCoreSupport/autofill/FormFieldAndroid.cpp index 6af0875..1116b7f 100644 --- a/Source/WebKit/android/WebCoreSupport/autofill/FormFieldAndroid.cpp +++ b/Source/WebKit/android/WebCoreSupport/autofill/FormFieldAndroid.cpp @@ -52,31 +52,31 @@ using namespace WebCore::HTMLNames; namespace webkit_glue { FormField::FormField() - : max_length_(0), - is_autofilled_(false) { + : max_length(0), + is_autofilled(false) { } // TODO: This constructor should probably be deprecated and the // functionality moved to FormManager. FormField::FormField(const HTMLFormControlElement& element) - : max_length_(0), - is_autofilled_(false) { - name_ = nameForAutoFill(element); + : max_length(0), + is_autofilled(false) { + name = nameForAutoFill(element); // TODO: Extract the field label. For now we just use the field // name. - label_ = name_; + label = name; - form_control_type_ = formControlType(element); - if (form_control_type_ == kText) { + form_control_type = formControlType(element); + if (form_control_type == kText) { const HTMLInputElement& input_element = static_cast<const HTMLInputElement&>(element); - value_ = WTFStringToString16(input_element.value()); - max_length_ = input_element.size(); - is_autofilled_ = input_element.isAutofilled(); - } else if (form_control_type_ == kSelectOne) { + value = WTFStringToString16(input_element.value()); + max_length = input_element.size(); + is_autofilled = input_element.isAutofilled(); + } else if (form_control_type == kSelectOne) { const HTMLSelectElement& const_select_element = static_cast<const HTMLSelectElement&>(element); HTMLSelectElement& select_element = const_cast<HTMLSelectElement&>(const_select_element); - value_ = WTFStringToString16(select_element.value()); + value = WTFStringToString16(select_element.value()); // For select-one elements copy option strings. WTF::Vector<Element*> list_items = select_element.listItems(); @@ -87,16 +87,16 @@ FormField::FormField(const HTMLFormControlElement& element) } } - TrimWhitespace(value_, TRIM_LEADING, &value_); + TrimWhitespace(value, TRIM_LEADING, &value); } -FormField::FormField(const string16& label, const string16& name, const string16& value, const string16& form_control_type, int max_length, bool is_autofilled) - : label_(label), - name_(name), - value_(value), - form_control_type_(form_control_type), - max_length_(max_length), - is_autofilled_(is_autofilled) { +FormField::FormField(const string16& _label, const string16& _name, const string16& _value, const string16& _form_control_type, int _max_length, bool _is_autofilled) + : label(_label), + name(_name), + value(_value), + form_control_type(_form_control_type), + max_length(_max_length), + is_autofilled(_is_autofilled) { } FormField::~FormField() { @@ -105,10 +105,10 @@ FormField::~FormField() { bool FormField::operator==(const FormField& field) const { // A FormField stores a value, but the value is not part of the identity of // the field, so we don't want to compare the values. - return (label_ == field.label_ && - name_ == field.name_ && - form_control_type_ == field.form_control_type_ && - max_length_ == field.max_length_); + return (label == field.label && + name == field.name && + form_control_type == field.form_control_type && + max_length == field.max_length); } bool FormField::operator!=(const FormField& field) const { @@ -116,24 +116,24 @@ bool FormField::operator!=(const FormField& field) const { } bool FormField::StrictlyEqualsHack(const FormField& field) const { - return (label_ == field.label_ && - name_ == field.name_ && - value_ == field.value_ && - form_control_type_ == field.form_control_type_ && - max_length_ == field.max_length_); + return (label == field.label && + name == field.name && + value == field.value && + form_control_type == field.form_control_type && + max_length == field.max_length); } std::ostream& operator<<(std::ostream& os, const FormField& field) { return os - << UTF16ToUTF8(field.label()) + << UTF16ToUTF8(field.label) << " " - << UTF16ToUTF8(field.name()) + << UTF16ToUTF8(field.name) << " " - << UTF16ToUTF8(field.value()) + << UTF16ToUTF8(field.value) << " " - << UTF16ToUTF8(field.form_control_type()) + << UTF16ToUTF8(field.form_control_type) << " " - << field.max_length(); + << field.max_length; } } // namespace webkit_glue diff --git a/Source/WebKit/android/WebCoreSupport/autofill/FormFieldAndroid.h b/Source/WebKit/android/WebCoreSupport/autofill/FormFieldAndroid.h index c5e3ecc..9379c09 100644 --- a/Source/WebKit/android/WebCoreSupport/autofill/FormFieldAndroid.h +++ b/Source/WebKit/android/WebCoreSupport/autofill/FormFieldAndroid.h @@ -48,23 +48,17 @@ public: FormField(const string16& label, const string16& name, const string16& value, const string16& form_control_type, int max_length, bool is_autofilled); virtual ~FormField(); - const string16& label() const { return label_; } - const string16& name() const { return name_; } - const string16& value() const { return value_; } - const string16& form_control_type() const { return form_control_type_; } - int max_length() const { return max_length_; } - bool is_autofilled() const { return is_autofilled_; } + string16 label; + string16 name; + string16 value; + string16 form_control_type; + int max_length; + bool is_autofilled; // Returns option string for elements for which they make sense (select-one, // for example) for the rest of elements return an empty array. const std::vector<string16>& option_strings() const { return option_strings_; } - void set_label(const string16& label) { label_ = label; } - void set_name(const string16& name) { name_ = name; } - void set_value(const string16& value) { value_ = value; } - void set_form_control_type(const string16& form_control_type) { form_control_type_ = form_control_type; } - void set_max_length(int max_length) { max_length_ = max_length; } - void set_autofilled(bool is_autofilled) { is_autofilled_ = is_autofilled; } void set_option_strings(const std::vector<string16>& strings) { option_strings_ = strings; } // Equality tests for identity which does not include |value_| or |size_|. @@ -79,12 +73,6 @@ public: bool StrictlyEqualsHack(const FormField& field) const; private: - string16 label_; - string16 name_; - string16 value_; - string16 form_control_type_; - int max_length_; - bool is_autofilled_; std::vector<string16> option_strings_; }; diff --git a/Source/WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.cpp b/Source/WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.cpp index 9652794..44a8c34 100644 --- a/Source/WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.cpp +++ b/Source/WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.cpp @@ -310,8 +310,8 @@ void FormManager::HTMLFormControlElementToFormField(HTMLFormControlElement* elem // The label is not officially part of a HTMLFormControlElement; however, the // labels for all form control elements are scraped from the DOM and set in // WebFormElementToFormData. - field->set_name(nameForAutoFill(*element)); - field->set_form_control_type(formControlType(*element)); + field->name = nameForAutoFill(*element); + field->form_control_type = formControlType(*element); if (extract_mask & EXTRACT_OPTIONS) { std::vector<string16> option_strings; @@ -321,8 +321,8 @@ void FormManager::HTMLFormControlElementToFormField(HTMLFormControlElement* elem if (formControlType(*element) == kText) { HTMLInputElement* input_element = static_cast<HTMLInputElement*>(element); - field->set_max_length(input_element->maxLength()); - field->set_autofilled(input_element->isAutofilled()); + field->max_length = input_element->maxLength(); + field->is_autofilled = input_element->isAutofilled(); } if (!(extract_mask & EXTRACT_VALUE)) @@ -359,7 +359,7 @@ void FormManager::HTMLFormControlElementToFormField(HTMLFormControlElement* elem if (value.size() > kMaxDataLength) value = value.substr(0, kMaxDataLength); - field->set_value(value); + field->value = value; } // static @@ -442,7 +442,7 @@ bool FormManager::HTMLFormElementToFormData(HTMLFormElement* element, Requiremen // TODO: A label element is mapped to a form control element's id. // field->name() will contain the id only if the name does not exist. Add // an id() method to HTMLFormControlElement and use that here. - name_map[field->name()] = field; + name_map[field->name] = field; fields_extracted[i] = true; } @@ -465,7 +465,7 @@ bool FormManager::HTMLFormElementToFormData(HTMLFormElement* element, Requiremen std::map<string16, FormField*>::iterator iter = name_map.find(nameForAutoFill(*field_element)); if (iter != name_map.end()) - iter->second->set_label(FindChildText(label)); + iter->second->label = FindChildText(label); } // Loop through the form control elements, extracting the label text from the @@ -482,8 +482,8 @@ bool FormManager::HTMLFormElementToFormData(HTMLFormElement* element, Requiremen continue; const HTMLFormControlElement* control_element = static_cast<HTMLFormControlElement*>(control_elements[i]); - if (form_fields[field_idx]->label().empty()) - form_fields[field_idx]->set_label(FormManager::InferLabelForElement(*control_element)); + if (form_fields[field_idx]->label.empty()) + form_fields[field_idx]->label = FormManager::InferLabelForElement(*control_element); ++field_idx; @@ -786,13 +786,13 @@ void FormManager::ForEachMatchingFormField(FormElement* form, Node* node, Requir // Search forward in the |form| for a corresponding field. size_t k = j; - while (k < data.fields.size() && element_name != data.fields[k].name()) + while (k < data.fields.size() && element_name != data.fields[k].name) k++; if (k >= data.fields.size()) continue; - DCHECK_EQ(data.fields[k].name(), element_name); + DCHECK_EQ(data.fields[k].name, element_name); bool is_initiating_node = false; @@ -829,7 +829,7 @@ void FormManager::ForEachMatchingFormField(FormElement* form, Node* node, Requir void FormManager::FillFormField(HTMLFormControlElement* field, const FormField* data, bool is_initiating_node) { // Nothing to fill. - if (data->value().empty()) + if (data->value.empty()) return; if (formControlType(*field) == kText) { @@ -837,7 +837,7 @@ void FormManager::FillFormField(HTMLFormControlElement* field, const FormField* // If the maxlength attribute contains a negative value, maxLength() // returns the default maxlength value. - input_element->setValue(data->value().substr(0, input_element->maxLength()).c_str()); + input_element->setValue(data->value.substr(0, input_element->maxLength()).c_str()); input_element->setAutofilled(true); if (is_initiating_node) { int length = input_element->value().length(); @@ -845,13 +845,13 @@ void FormManager::FillFormField(HTMLFormControlElement* field, const FormField* } } else if (formControlType(*field) == kSelectOne) { HTMLSelectElement* select_element = static_cast<HTMLSelectElement*>(field); - select_element->setValue(data->value().c_str()); + select_element->setValue(data->value.c_str()); } } void FormManager::PreviewFormField(HTMLFormControlElement* field, const FormField* data, bool is_initiating_node) { // Nothing to preview. - if (data->value().empty()) + if (data->value.empty()) return; // Only preview input fields. @@ -862,7 +862,7 @@ void FormManager::PreviewFormField(HTMLFormControlElement* field, const FormFiel // If the maxlength attribute contains a negative value, maxLength() // returns the default maxlength value. - input_element->setSuggestedValue(data->value().substr(0, input_element->maxLength()).c_str()); + input_element->setSuggestedValue(data->value.substr(0, input_element->maxLength()).c_str()); input_element->setAutofilled(true); if (is_initiating_node) input_element->setSelectionRange(0, input_element->suggestedValue().length()); diff --git a/Source/WebKit/android/WebCoreSupport/autofill/WebAutofill.cpp b/Source/WebKit/android/WebCoreSupport/autofill/WebAutofill.cpp index ff4f593..7ab7abd 100644 --- a/Source/WebKit/android/WebCoreSupport/autofill/WebAutofill.cpp +++ b/Source/WebKit/android/WebCoreSupport/autofill/WebAutofill.cpp @@ -160,7 +160,7 @@ void WebAutofill::formFieldFocused(WebCore::HTMLFormControlElement* formFieldEle // Get the FormField from the Node. webkit_glue::FormField* formField = new webkit_glue::FormField; FormManager::HTMLFormControlElementToFormField(formFieldElement, FormManager::EXTRACT_NONE, formField); - formField->set_label(FormManager::LabelForElement(*formFieldElement)); + formField->label = FormManager::LabelForElement(*formFieldElement); webkit_glue::FormData* form = new webkit_glue::FormData; mFormManager->FindFormWithFormControlElement(formFieldElement, FormManager::REQUIRE_AUTOCOMPLETE, form); @@ -235,22 +235,22 @@ void WebAutofill::setProfile(const string16& fullName, const string16& emailAddr const string16& state, const string16& zipCode, const string16& country, const string16& phoneNumber) { if (!mAutofillProfile) - mAutofillProfile.set(new AutoFillProfile()); + mAutofillProfile.set(new AutofillProfile()); // Update the profile. // Constants for Autofill field types are found in external/chromium/chrome/browser/autofill/field_types.h. - mAutofillProfile->SetInfo(AutofillType(NAME_FULL), fullName); - mAutofillProfile->SetInfo(AutofillType(EMAIL_ADDRESS), emailAddress); - mAutofillProfile->SetInfo(AutofillType(COMPANY_NAME), companyName); - mAutofillProfile->SetInfo(AutofillType(ADDRESS_HOME_LINE1), addressLine1); - mAutofillProfile->SetInfo(AutofillType(ADDRESS_HOME_LINE2), addressLine2); - mAutofillProfile->SetInfo(AutofillType(ADDRESS_HOME_CITY), city); - mAutofillProfile->SetInfo(AutofillType(ADDRESS_HOME_STATE), state); - mAutofillProfile->SetInfo(AutofillType(ADDRESS_HOME_ZIP), zipCode); - mAutofillProfile->SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), country); - mAutofillProfile->SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER), phoneNumber); - - std::vector<AutoFillProfile> profiles; + mAutofillProfile->SetInfo(AutofillFieldType(NAME_FULL), fullName); + mAutofillProfile->SetInfo(AutofillFieldType(EMAIL_ADDRESS), emailAddress); + mAutofillProfile->SetInfo(AutofillFieldType(COMPANY_NAME), companyName); + mAutofillProfile->SetInfo(AutofillFieldType(ADDRESS_HOME_LINE1), addressLine1); + mAutofillProfile->SetInfo(AutofillFieldType(ADDRESS_HOME_LINE2), addressLine2); + mAutofillProfile->SetInfo(AutofillFieldType(ADDRESS_HOME_CITY), city); + mAutofillProfile->SetInfo(AutofillFieldType(ADDRESS_HOME_STATE), state); + mAutofillProfile->SetInfo(AutofillFieldType(ADDRESS_HOME_ZIP), zipCode); + mAutofillProfile->SetInfo(AutofillFieldType(ADDRESS_HOME_COUNTRY), country); + mAutofillProfile->SetInfo(AutofillFieldType(PHONE_HOME_WHOLE_NUMBER), phoneNumber); + + std::vector<AutofillProfile> profiles; profiles.push_back(*mAutofillProfile); updateProfileLabel(); mTabContents->profile()->GetPersonalDataManager()->SetProfiles(&profiles); @@ -258,9 +258,9 @@ void WebAutofill::setProfile(const string16& fullName, const string16& emailAddr bool WebAutofill::updateProfileLabel() { - std::vector<AutoFillProfile*> profiles; + std::vector<AutofillProfile*> profiles; profiles.push_back(mAutofillProfile.get()); - return AutoFillProfile::AdjustInferredLabels(&profiles); + return AutofillProfile::AdjustInferredLabels(&profiles); } void WebAutofill::clearProfiles() diff --git a/Source/WebKit/android/WebCoreSupport/autofill/WebAutofill.h b/Source/WebKit/android/WebCoreSupport/autofill/WebAutofill.h index a2f56a2..5300087 100644 --- a/Source/WebKit/android/WebCoreSupport/autofill/WebAutofill.h +++ b/Source/WebKit/android/WebCoreSupport/autofill/WebAutofill.h @@ -37,7 +37,7 @@ #include <wtf/ThreadingPrimitives.h> class AutofillManager; -class AutoFillProfile; +class AutofillProfile; class AutoFillHost; namespace WebCore { @@ -99,7 +99,7 @@ private: OwnPtr<AutofillManager> mAutofillManager; OwnPtr<AutoFillHost> mAutofillHost; OwnPtr<TabContents> mTabContents; - OwnPtr<AutoFillProfile> mAutofillProfile; + OwnPtr<AutofillProfile> mAutofillProfile; typedef std::vector<webkit_glue::FormData, std::allocator<webkit_glue::FormData> > FormList; FormList mForms; diff --git a/Source/WebKit/android/jni/WebCoreFrameBridge.cpp b/Source/WebKit/android/jni/WebCoreFrameBridge.cpp index 762c667..5ec4468 100644 --- a/Source/WebKit/android/jni/WebCoreFrameBridge.cpp +++ b/Source/WebKit/android/jni/WebCoreFrameBridge.cpp @@ -525,7 +525,9 @@ WebFrame::shouldInterceptRequest(const WTF::String& url) env->DeleteLocalRef(urlStr); if (response == 0) return 0; - return new UrlInterceptResponse(env, response); + UrlInterceptResponse* result = new UrlInterceptResponse(env, response); + env->DeleteLocalRef(response); + return result; } void @@ -1771,37 +1773,36 @@ private: JNIEnv* env = getJNIEnv(); // JavaInstance creates a global ref to instance in its constructor. env->DeleteGlobalRef(m_instance->instance()); - // Set the object to a weak reference. - m_instance->setInstance(env->NewWeakGlobalRef(instance)); + // Create a weak ref, cache it, and set the underlying JavaInstance to use it. + m_weakRef = env->NewWeakGlobalRef(instance); + m_instance->setInstance(m_weakRef); } ~WeakJavaInstance() { + // TODO: Check whether it's OK for calls to begin() and end() to be unbalanced. + // See b/5006441 + if (m_beginEndDepth) + LOGW("Unbalanced calls to WeakJavaInstance::begin() / end()"); JNIEnv* env = getJNIEnv(); - // Store the weak reference so we can delete it later. - jweak weak = m_instance->instance(); // The JavaInstance destructor attempts to delete the global ref stored // in m_instance. Since we replaced it in our constructor with a weak // reference, restore the global ref here so the vm will not complain. - m_instance->setInstance(env->NewGlobalRef( - getRealObject(env, m_instance->instance()).get())); + m_instance->setInstance(env->NewGlobalRef(m_weakRef)); // Delete the weak reference. - env->DeleteWeakGlobalRef(weak); + env->DeleteWeakGlobalRef(m_weakRef); } virtual void begin() { if (m_beginEndDepth++ > 0) return; - m_weakRef = m_instance->instance(); JNIEnv* env = getJNIEnv(); // This is odd. getRealObject returns an AutoJObject which is used to // cleanly create and delete a local reference. But, here we need to // maintain the local reference across calls to virtualBegin() and // virtualEnd(). So, release the local reference from the AutoJObject // and delete the local reference in virtualEnd(). - m_realObject = getRealObject(env, m_weakRef).release(); - // Point to the real object - m_instance->setInstance(m_realObject); + m_instance->setInstance(getRealObject(env, m_weakRef).release()); // Call the base class method INHERITED::begin(); } @@ -1813,7 +1814,7 @@ private: // Call the base class method first to pop the local frame. INHERITED::end(); // Get rid of the local reference to the real object. - getJNIEnv()->DeleteLocalRef(m_realObject); + getJNIEnv()->DeleteLocalRef(m_instance->instance()); // Point back to the WeakReference. m_instance->setInstance(m_weakRef); } @@ -1824,7 +1825,6 @@ private: #elif USE(V8) typedef JavaInstanceJobject INHERITED; #endif - jobject m_realObject; jweak m_weakRef; // The current depth of nested calls to virtualBegin and virtualEnd. int m_beginEndDepth; diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index 966a540..1c51b14 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -2971,16 +2971,11 @@ void WebViewCore::openFileChooser(PassRefPtr<WebCore::FileChooser> chooser) checkException(env); env->DeleteLocalRef(jAcceptType); - const UChar* string = static_cast<const UChar*>(env->GetStringChars(jName, 0)); + WTF::String wtfString = jstringToWtfString(env, jName); + env->DeleteLocalRef(jName); - if (!string) - return; - - WTF::String webcoreString = jstringToWtfString(env, jName); - env->ReleaseStringChars(jName, string); - - if (webcoreString.length()) - chooser->chooseFile(webcoreString); + if (!wtfString.isEmpty()) + chooser->chooseFile(wtfString); } void WebViewCore::listBoxRequest(WebCoreReply* reply, const uint16_t** labels, size_t count, const int enabled[], size_t enabledCount, |
