diff options
Diffstat (limited to 'Source')
17 files changed, 174 insertions, 135 deletions
diff --git a/Source/WebCore/css/CSSStyleSelector.cpp b/Source/WebCore/css/CSSStyleSelector.cpp index 2424349..d81cc9d 100644 --- a/Source/WebCore/css/CSSStyleSelector.cpp +++ b/Source/WebCore/css/CSSStyleSelector.cpp @@ -1285,8 +1285,11 @@ PassRefPtr<RenderStyle> CSSStyleSelector::styleForElement(Element* e, RenderStyl if (m_parentStyle) m_style->inheritFrom(m_parentStyle); - else + else { m_parentStyle = style(); + // Make sure our fonts are initialized if we don't inherit them from our parent style. + m_style->font().update(0); + } if (e->isLink()) { m_style->setIsLink(true); diff --git a/Source/WebCore/dom/Range.cpp b/Source/WebCore/dom/Range.cpp index 268687f..37d0193 100644 --- a/Source/WebCore/dom/Range.cpp +++ b/Source/WebCore/dom/Range.cpp @@ -623,7 +623,9 @@ static inline Node* childOfCommonRootBeforeOffset(Node* container, unsigned offs { ASSERT(container); ASSERT(commonRoot); - ASSERT(commonRoot->contains(container)); + + if (!commonRoot->contains(container)) + return 0; if (container == commonRoot) { container = container->firstChild(); @@ -674,7 +676,7 @@ PassRefPtr<DocumentFragment> Range::processContents(ActionType action, Exception if (ec) return 0; - Node* commonRoot = commonAncestorContainer(ec); + RefPtr<Node> commonRoot = commonAncestorContainer(ec); if (ec) return 0; ASSERT(commonRoot); @@ -685,8 +687,8 @@ PassRefPtr<DocumentFragment> Range::processContents(ActionType action, Exception } // what is the highest node that partially selects the start / end of the range? - Node* partialStart = highestAncestorUnderCommonRoot(m_start.container(), commonRoot); - Node* partialEnd = highestAncestorUnderCommonRoot(m_end.container(), commonRoot); + RefPtr<Node> partialStart = highestAncestorUnderCommonRoot(m_start.container(), commonRoot.get()); + RefPtr<Node> partialEnd = highestAncestorUnderCommonRoot(m_end.container(), commonRoot.get()); // Start and end containers are different. // There are three possibilities here: @@ -705,29 +707,32 @@ PassRefPtr<DocumentFragment> Range::processContents(ActionType action, Exception // // These are deleted, cloned, or extracted (i.e. both) depending on action. + // Note that we are verifying that our common root hierarchy is still intact + // after any DOM mutation event, at various stages below. See webkit bug 60350. + RefPtr<Node> leftContents; - if (m_start.container() != commonRoot) { + if (m_start.container() != commonRoot && commonRoot->contains(m_start.container())) { leftContents = processContentsBetweenOffsets(action, 0, m_start.container(), m_start.offset(), lengthOfContentsInNode(m_start.container()), ec); - leftContents = processAncestorsAndTheirSiblings(action, m_start.container(), ProcessContentsForward, leftContents, commonRoot, ec); + leftContents = processAncestorsAndTheirSiblings(action, m_start.container(), ProcessContentsForward, leftContents, commonRoot.get(), ec); } RefPtr<Node> rightContents; - if (m_end.container() != commonRoot) { + if (m_end.container() != commonRoot && commonRoot->contains(m_end.container())) { rightContents = processContentsBetweenOffsets(action, 0, m_end.container(), 0, m_end.offset(), ec); - rightContents = processAncestorsAndTheirSiblings(action, m_end.container(), ProcessContentsBackward, rightContents, commonRoot, ec); + rightContents = processAncestorsAndTheirSiblings(action, m_end.container(), ProcessContentsBackward, rightContents, commonRoot.get(), ec); } // delete all children of commonRoot between the start and end container - Node* processStart = childOfCommonRootBeforeOffset(m_start.container(), m_start.offset(), commonRoot); - if (m_start.container() != commonRoot) // processStart contains nodes before m_start. + RefPtr<Node> processStart = childOfCommonRootBeforeOffset(m_start.container(), m_start.offset(), commonRoot.get()); + if (processStart && m_start.container() != commonRoot) // processStart contains nodes before m_start. processStart = processStart->nextSibling(); - Node* processEnd = childOfCommonRootBeforeOffset(m_end.container(), m_end.offset(), commonRoot); + RefPtr<Node> processEnd = childOfCommonRootBeforeOffset(m_end.container(), m_end.offset(), commonRoot.get()); // Collapse the range, making sure that the result is not within a node that was partially selected. if (action == EXTRACT_CONTENTS || action == DELETE_CONTENTS) { - if (partialStart) + if (partialStart && commonRoot->contains(partialStart.get())) setStart(partialStart->parentNode(), partialStart->nodeIndex() + 1, ec); - else if (partialEnd) + else if (partialEnd && commonRoot->contains(partialEnd.get())) setStart(partialEnd->parentNode(), partialEnd->nodeIndex(), ec); if (ec) return 0; @@ -742,7 +747,7 @@ PassRefPtr<DocumentFragment> Range::processContents(ActionType action, Exception if (processStart) { NodeVector nodes; - for (Node* n = processStart; n && n != processEnd; n = n->nextSibling()) + for (Node* n = processStart.get(); n && n != processEnd; n = n->nextSibling()) nodes.append(n); processNodes(action, nodes, commonRoot, fragment, ec); } @@ -832,7 +837,7 @@ PassRefPtr<Node> Range::processContentsBetweenOffsets(ActionType action, PassRef break; } - return result; + return result.release(); } void Range::processNodes(ActionType action, Vector<RefPtr<Node> >& nodes, PassRefPtr<Node> oldContainer, PassRefPtr<Node> newContainer, ExceptionCode& ec) @@ -902,7 +907,7 @@ PassRefPtr<Node> Range::processAncestorsAndTheirSiblings(ActionType action, Node firstChildInAncestorToProcess = direction == ProcessContentsForward ? ancestor->nextSibling() : ancestor->previousSibling(); } - return clonedContainer; + return clonedContainer.release(); } PassRefPtr<DocumentFragment> Range::extractContents(ExceptionCode& ec) diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp index 46e8a12..328b6db 100644 --- a/Source/WebCore/html/HTMLMediaElement.cpp +++ b/Source/WebCore/html/HTMLMediaElement.cpp @@ -186,8 +186,6 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document* docum document->registerForMediaVolumeCallbacks(this); document->registerForPrivateBrowsingStateChangedCallbacks(this); #if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS) - // Enable the Media Element to listen to all the touch events - document->addListenerTypeIfNeeded(eventNames().touchstartEvent); m_restrictions |= RequireUserGestureForRateChangeRestriction; #endif } diff --git a/Source/WebCore/html/shadow/SliderThumbElement.cpp b/Source/WebCore/html/shadow/SliderThumbElement.cpp index e68ab00..210fb7b 100644 --- a/Source/WebCore/html/shadow/SliderThumbElement.cpp +++ b/Source/WebCore/html/shadow/SliderThumbElement.cpp @@ -251,11 +251,19 @@ void SliderThumbElement::defaultEventHandler(Event* event) HTMLDivElement::defaultEventHandler(event); } +#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS) +void SliderThumbElement::attach() +{ + HTMLDivElement::attach(); + document()->addListenerTypeIfNeeded(eventNames().touchstartEvent); +} +#endif + void SliderThumbElement::detach() { if (m_inDragMode) { if (Frame* frame = document()->frame()) - frame->eventHandler()->setCapturingMouseEventsNode(0); + frame->eventHandler()->setCapturingMouseEventsNode(0); } HTMLDivElement::detach(); } diff --git a/Source/WebCore/html/shadow/SliderThumbElement.h b/Source/WebCore/html/shadow/SliderThumbElement.h index 2fa60cb..cdeb471 100644 --- a/Source/WebCore/html/shadow/SliderThumbElement.h +++ b/Source/WebCore/html/shadow/SliderThumbElement.h @@ -54,6 +54,9 @@ public: void dragFrom(const IntPoint&); virtual void defaultEventHandler(Event*); +#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS) + virtual void attach(); +#endif virtual void detach(); virtual const AtomicString& shadowPseudoId() const; diff --git a/Source/WebCore/platform/android/RenderThemeAndroid.cpp b/Source/WebCore/platform/android/RenderThemeAndroid.cpp index 173cfea..86380e7 100644 --- a/Source/WebCore/platform/android/RenderThemeAndroid.cpp +++ b/Source/WebCore/platform/android/RenderThemeAndroid.cpp @@ -439,10 +439,8 @@ void RenderThemeAndroid::adjustSliderThumbSize(RenderObject* o) const { static const int sliderThumbWidth = RenderSkinMediaButton::sliderThumbWidth(); static const int sliderThumbHeight = RenderSkinMediaButton::sliderThumbHeight(); - if (o->style()->appearance() == MediaSliderThumbPart) { - o->style()->setWidth(Length(sliderThumbWidth, Fixed)); - o->style()->setHeight(Length(sliderThumbHeight, Fixed)); - } + o->style()->setWidth(Length(sliderThumbWidth, Fixed)); + o->style()->setHeight(Length(sliderThumbHeight, Fixed)); } #endif @@ -647,6 +645,30 @@ bool RenderThemeAndroid::paintMenuListButton(RenderObject* obj, const PaintInfo& return paintCombo(obj, info, rect); } +bool RenderThemeAndroid::paintSliderTrack(RenderObject* o, const PaintInfo& i, const IntRect& r) +{ + SkCanvas* canvas = getCanvasFromInfo(i); + if (!canvas) + return true; + static const bool translucent = true; + RenderSkinMediaButton::Draw(canvas, r, + RenderSkinMediaButton::SLIDER_TRACK, + translucent, o, false); + return false; +} + +bool RenderThemeAndroid::paintSliderThumb(RenderObject* o, const PaintInfo& i, const IntRect& r) +{ + SkCanvas* canvas = getCanvasFromInfo(i); + if (!canvas) + return true; + static const bool translucent = true; + RenderSkinMediaButton::Draw(canvas, r, + RenderSkinMediaButton::SLIDER_THUMB, + translucent, 0, false); + return false; +} + Color RenderThemeAndroid::platformFocusRingColor() const { static Color focusRingColor(0x33, 0xB5, 0xE5, 0x66); diff --git a/Source/WebCore/platform/android/RenderThemeAndroid.h b/Source/WebCore/platform/android/RenderThemeAndroid.h index ed4d07f..06d272b 100644 --- a/Source/WebCore/platform/android/RenderThemeAndroid.h +++ b/Source/WebCore/platform/android/RenderThemeAndroid.h @@ -118,6 +118,9 @@ protected: virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const; virtual bool paintSearchField(RenderObject*, const PaintInfo&, const IntRect&); + virtual bool paintSliderTrack(RenderObject*, const PaintInfo&, const IntRect&); + virtual bool paintSliderThumb(RenderObject*, const PaintInfo&, const IntRect&); + private: RenderThemeAndroid(); void addIntrinsicMargins(RenderStyle*) const; diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp index 7a94eb5..89c0ead 100644 --- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp +++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp @@ -135,7 +135,7 @@ void GLWebViewState::setViewport(const SkRect& viewport, float scale) TilesManager* tilesManager = TilesManager::instance(); int maxTextureCount = viewMaxTileX * viewMaxTileY * (tilesManager->highEndGfx() ? 4 : 2); - tilesManager->setMaxTextureCount(maxTextureCount); + tilesManager->setCurrentTextureCount(maxTextureCount); // TODO: investigate whether we can move this return earlier. if ((m_viewport == viewport) @@ -227,11 +227,11 @@ bool GLWebViewState::setLayersRenderingMode(TexturesResult& nbTexturesNeeded) bool invalBase = false; if (!nbTexturesNeeded.full) - TilesManager::instance()->setMaxLayerTextureCount(0); + TilesManager::instance()->setCurrentLayerTextureCount(0); else - TilesManager::instance()->setMaxLayerTextureCount((2*nbTexturesNeeded.full)+1); + TilesManager::instance()->setCurrentLayerTextureCount((2 * nbTexturesNeeded.full) + 1); - int maxTextures = TilesManager::instance()->maxLayerTextureCount(); + int maxTextures = TilesManager::instance()->currentLayerTextureCount(); LayersRenderingMode layersRenderingMode = m_layersRenderingMode; if (m_layersRenderingMode == kSingleSurfaceRendering) { @@ -334,7 +334,7 @@ int GLWebViewState::drawGL(IntRect& rect, SkRect& visibleRect, IntRect* invalRec if (scale < MIN_SCALE_WARNING || scale > MAX_SCALE_WARNING) { ALOGW("WARNING, scale seems corrupted after update: %e", scale); - CRASH(); + scale = 1.0f; // WORKAROUND for corrupted scale: use 1.0 } // gather the textures we can use diff --git a/Source/WebCore/platform/graphics/android/rendering/TilesManager.cpp b/Source/WebCore/platform/graphics/android/rendering/TilesManager.cpp index 731db23..5693d28 100644 --- a/Source/WebCore/platform/graphics/android/rendering/TilesManager.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/TilesManager.cpp @@ -50,10 +50,10 @@ // one viewport, otherwise the allocation may stall. // We need n textures for one TiledPage, and another n textures for the // second page used when scaling. -// In our case, we use 256*256 textures. On the tablet, this equates to -// at least 60 textures, or 112 with expanded tile boundaries. -// 112(tiles)*256*256*4(bpp)*2(pages) = 56MB -// It turns out the viewport dependent value m_maxTextureCount is a reasonable +// In our case, we use 256*256 textures. Both base and layers can use up to +// MAX_TEXTURE_ALLOCATION textures, which is 224MB GPU memory in total. +// For low end graphics systems, we cut this upper limit to half. +// We've found the viewport dependent value m_currentTextureCount is a reasonable // number to cap the layer tile texturs, it worked on both phones and tablets. // TODO: after merge the pool of base tiles and layer tiles, we should revisit // the logic of allocation management. @@ -67,24 +67,26 @@ namespace WebCore { -GLint TilesManager::getMaxTextureSize() -{ - static GLint maxTextureSize = 0; - if (!maxTextureSize) - glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); - return maxTextureSize; -} - int TilesManager::getMaxTextureAllocation() { - return MAX_TEXTURE_ALLOCATION; + if (m_maxTextureAllocation == -1) { + GLint glMaxTextureSize = 0; + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glMaxTextureSize); + GLUtils::checkGlError("TilesManager::getMaxTextureAllocation"); + // Half of glMaxTextureSize can be used for base, the other half for layers. + m_maxTextureAllocation = std::min(MAX_TEXTURE_ALLOCATION, glMaxTextureSize / 2); + if (!m_highEndGfx) + m_maxTextureAllocation = m_maxTextureAllocation / 2; + } + return m_maxTextureAllocation; } TilesManager::TilesManager() : m_layerTexturesRemain(true) , m_highEndGfx(false) - , m_maxTextureCount(0) - , m_maxLayerTextureCount(0) + , m_currentTextureCount(0) + , m_currentLayerTextureCount(0) + , m_maxTextureAllocation(-1) , m_generatorReady(false) , m_showVisualIndicator(false) , m_invertedScreen(false) @@ -107,10 +109,10 @@ TilesManager::TilesManager() m_pixmapsGenerationThread->run("TexturesGenerator"); } -void TilesManager::allocateTiles() +void TilesManager::allocateTextures() { - int nbTexturesToAllocate = m_maxTextureCount - m_textures.size(); - ALOGV("%d tiles to allocate (%d textures planned)", nbTexturesToAllocate, m_maxTextureCount); + int nbTexturesToAllocate = m_currentTextureCount - m_textures.size(); + ALOGV("%d tiles to allocate (%d textures planned)", nbTexturesToAllocate, m_currentTextureCount); int nbTexturesAllocated = 0; for (int i = 0; i < nbTexturesToAllocate; i++) { TileTexture* texture = new TileTexture( @@ -124,9 +126,9 @@ void TilesManager::allocateTiles() nbTexturesAllocated++; } - int nbLayersTexturesToAllocate = m_maxLayerTextureCount - m_tilesTextures.size(); + int nbLayersTexturesToAllocate = m_currentLayerTextureCount - m_tilesTextures.size(); ALOGV("%d layers tiles to allocate (%d textures planned)", - nbLayersTexturesToAllocate, m_maxLayerTextureCount); + nbLayersTexturesToAllocate, m_currentLayerTextureCount); int nbLayersTexturesAllocated = 0; for (int i = 0; i < nbLayersTexturesToAllocate; i++) { TileTexture* texture = new TileTexture( @@ -202,9 +204,9 @@ void TilesManager::discardTexturesVector(unsigned long long sparedDrawCount, textures.remove(discardedIndex[i]); int remainedTextureNumber = textures.size(); - int* countPtr = base ? &m_maxTextureCount : &m_maxLayerTextureCount; + int* countPtr = base ? &m_currentTextureCount : &m_currentLayerTextureCount; if (remainedTextureNumber < *countPtr) { - ALOGV("reset maxTextureCount for %s tiles from %d to %d", + ALOGV("reset currentTextureCount for %s tiles from %d to %d", base ? "base" : "layer", *countPtr, remainedTextureNumber); *countPtr = remainedTextureNumber; } @@ -356,41 +358,39 @@ bool TilesManager::highEndGfx() return m_highEndGfx; } -int TilesManager::maxTextureCount() +int TilesManager::currentTextureCount() { android::Mutex::Autolock lock(m_texturesLock); - return m_maxTextureCount; + return m_currentTextureCount; } -int TilesManager::maxLayerTextureCount() +int TilesManager::currentLayerTextureCount() { android::Mutex::Autolock lock(m_texturesLock); - return m_maxLayerTextureCount; + return m_currentLayerTextureCount; } -void TilesManager::setMaxTextureCount(int max) +void TilesManager::setCurrentTextureCount(int newTextureCount) { - ALOGV("setMaxTextureCount: %d (current: %d, total:%d)", - max, m_maxTextureCount, MAX_TEXTURE_ALLOCATION); - if (m_maxTextureCount == MAX_TEXTURE_ALLOCATION || - max <= m_maxTextureCount) + int maxTextureAllocation = getMaxTextureAllocation(); + ALOGV("setCurrentTextureCount: %d (current: %d, max:%d)", + newTextureCount, m_currentTextureCount, maxTextureAllocation); + if (m_currentTextureCount == maxTextureAllocation || + newTextureCount <= m_currentTextureCount) return; android::Mutex::Autolock lock(m_texturesLock); + m_currentTextureCount = std::min(newTextureCount, maxTextureAllocation); - if (max < MAX_TEXTURE_ALLOCATION) - m_maxTextureCount = max; - else - m_maxTextureCount = MAX_TEXTURE_ALLOCATION; - - allocateTiles(); + allocateTextures(); } -void TilesManager::setMaxLayerTextureCount(int max) +void TilesManager::setCurrentLayerTextureCount(int newTextureCount) { - ALOGV("setMaxLayerTextureCount: %d (current: %d, total:%d)", - max, m_maxLayerTextureCount, MAX_TEXTURE_ALLOCATION); - if (!max && m_hasLayerTextures) { + int maxTextureAllocation = getMaxTextureAllocation(); + ALOGV("setCurrentLayerTextureCount: %d (current: %d, max:%d)", + newTextureCount, m_currentLayerTextureCount, maxTextureAllocation); + if (!newTextureCount && m_hasLayerTextures) { double secondsSinceLayersUsed = WTF::currentTime() - m_lastTimeLayersUsed; if (secondsSinceLayersUsed > LAYER_TEXTURES_DESTROY_TIMEOUT) { unsigned long long sparedDrawCount = ~0; // by default, spare no textures @@ -401,18 +401,14 @@ void TilesManager::setMaxLayerTextureCount(int max) return; } m_lastTimeLayersUsed = WTF::currentTime(); - if (m_maxLayerTextureCount == MAX_TEXTURE_ALLOCATION || - max <= m_maxLayerTextureCount) + if (m_currentLayerTextureCount == maxTextureAllocation || + newTextureCount <= m_currentLayerTextureCount) return; android::Mutex::Autolock lock(m_texturesLock); + m_currentLayerTextureCount = std::min(newTextureCount, maxTextureAllocation); - if (max < MAX_TEXTURE_ALLOCATION) - m_maxLayerTextureCount = max; - else - m_maxLayerTextureCount = MAX_TEXTURE_ALLOCATION; - - allocateTiles(); + allocateTextures(); m_hasLayerTextures = true; } diff --git a/Source/WebCore/platform/graphics/android/rendering/TilesManager.h b/Source/WebCore/platform/graphics/android/rendering/TilesManager.h index 17d44b5..834f36d 100644 --- a/Source/WebCore/platform/graphics/android/rendering/TilesManager.h +++ b/Source/WebCore/platform/graphics/android/rendering/TilesManager.h @@ -47,8 +47,6 @@ class TilesManager { public: // May only be called from the UI thread static TilesManager* instance(); - static GLint getMaxTextureSize(); - static int getMaxTextureAllocation(); static bool hardwareAccelerationEnabled() { @@ -85,14 +83,14 @@ public: void setHighEndGfx(bool highEnd); bool highEndGfx(); - int maxTextureCount(); - int maxLayerTextureCount(); - void setMaxTextureCount(int max); - void setMaxLayerTextureCount(int max); + int currentTextureCount(); + int currentLayerTextureCount(); + void setCurrentTextureCount(int newTextureCount); + void setCurrentLayerTextureCount(int newTextureCount); static float tileWidth(); static float tileHeight(); - void allocateTiles(); + void allocateTextures(); // remove all tiles from textures (and optionally deallocate gl memory) void discardTextures(bool allTextures, bool glTextures); @@ -168,6 +166,7 @@ private: bool deallocateGLTextures); void markAllGLTexturesZero(); bool updateContextIfChanged(); + int getMaxTextureAllocation(); WTF::Vector<TileTexture*> m_textures; WTF::Vector<TileTexture*> m_availableTextures; @@ -177,8 +176,9 @@ private: bool m_layerTexturesRemain; bool m_highEndGfx; - int m_maxTextureCount; - int m_maxLayerTextureCount; + int m_currentTextureCount; + int m_currentLayerTextureCount; + int m_maxTextureAllocation; bool m_generatorReady; diff --git a/Source/WebCore/rendering/RenderLayer.cpp b/Source/WebCore/rendering/RenderLayer.cpp index 66aab18..1ffa0de 100644 --- a/Source/WebCore/rendering/RenderLayer.cpp +++ b/Source/WebCore/rendering/RenderLayer.cpp @@ -1449,7 +1449,8 @@ void RenderLayer::scrollTo(int x, int y) #endif // Schedule the scroll DOM event. - renderer()->node()->document()->eventQueue()->enqueueOrDispatchScrollEvent(renderer()->node(), EventQueue::ScrollEventElementTarget); + if (renderer()->node()) + renderer()->node()->document()->eventQueue()->enqueueOrDispatchScrollEvent(renderer()->node(), EventQueue::ScrollEventElementTarget); } void RenderLayer::scrollRectToVisible(const IntRect& rect, bool scrollToAnchor, const ScrollAlignment& alignX, const ScrollAlignment& alignY) diff --git a/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp b/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp index d7c21e3..271fe58 100644 --- a/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp +++ b/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp @@ -945,11 +945,11 @@ void FrameLoaderClientAndroid::transitionToCommittedForNewPage() { Retain(webViewCore); // Save the old WebFrameView's bounds and apply them to the new WebFrameView - WebFrameView* oldWebFrameView = static_cast<WebFrameView*> (m_frame->view()->platformWidget()); + RefPtr<WebCore::FrameView> oldFrameView = m_frame->view(); + WebFrameView* oldWebFrameView = static_cast<WebFrameView*> (oldFrameView->platformWidget()); IntRect bounds; if (oldWebFrameView) bounds = oldWebFrameView->getBounds(); - WebCore::FrameView* oldFrameView = m_frame->view(); const float oldZoomFactor = oldFrameView->frame()->textZoomFactor(); m_frame->createView(bounds.size(), oldFrameView->baseBackgroundColor(), oldFrameView->isTransparent(), oldFrameView->fixedLayoutSize(), oldFrameView->useFixedLayout()); diff --git a/Source/WebKit/android/WebCoreSupport/PlatformBridge.cpp b/Source/WebKit/android/WebCoreSupport/PlatformBridge.cpp index 04b487a..9b8aac8 100644 --- a/Source/WebKit/android/WebCoreSupport/PlatformBridge.cpp +++ b/Source/WebKit/android/WebCoreSupport/PlatformBridge.cpp @@ -78,15 +78,21 @@ void PlatformBridge::setCookies(const Document* document, const KURL& url, const std::string cookieValue(value.utf8().data()); GURL cookieGurl(url.string().utf8().data()); bool isPrivateBrowsing = document->settings() && document->settings()->privateBrowsingEnabled(); - WebCookieJar::get(isPrivateBrowsing)->cookieStore()->SetCookie(cookieGurl, cookieValue); + WebCookieJar* cookieJar = WebCookieJar::get(isPrivateBrowsing); + if (cookieJar->allowCookies()) + cookieJar->cookieStore()->SetCookie(cookieGurl, cookieValue); } String PlatformBridge::cookies(const Document* document, const KURL& url) { GURL cookieGurl(url.string().utf8().data()); bool isPrivateBrowsing = document->settings() && document->settings()->privateBrowsingEnabled(); - std::string cookies = WebCookieJar::get(isPrivateBrowsing)->cookieStore()->GetCookies(cookieGurl); - String cookieString(cookies.c_str()); + WebCookieJar* cookieJar = WebCookieJar::get(isPrivateBrowsing); + String cookieString; + if (cookieJar->allowCookies()) { + std::string cookies = cookieJar->cookieStore()->GetCookies(cookieGurl); + cookieString = cookies.c_str(); + } return cookieString; } diff --git a/Source/WebKit/android/jni/ViewStateSerializer.cpp b/Source/WebKit/android/jni/ViewStateSerializer.cpp index 3fdc3e6..5f2480a 100644 --- a/Source/WebKit/android/jni/ViewStateSerializer.cpp +++ b/Source/WebKit/android/jni/ViewStateSerializer.cpp @@ -100,6 +100,10 @@ static BaseLayerAndroid* nativeDeserializeViewState(JNIEnv* env, jobject, jint v BaseLayerAndroid* layer = new BaseLayerAndroid(content); layer->setBackgroundColor(color); + SkRegion dirtyRegion; + dirtyRegion.setRect(0, 0, content->width(), content->height()); + layer->markAsDirty(dirtyRegion); + SkSafeUnref(content); SkSafeUnref(picture); int childCount = stream->readS32(); diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index 726a225..e0379a8 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -871,7 +871,7 @@ void WebViewCore::notifyAnimationStarted() } -BaseLayerAndroid* WebViewCore::createBaseLayer(SkRegion* region) +BaseLayerAndroid* WebViewCore::createBaseLayer() { // We set the background color Color background = Color::white; @@ -950,9 +950,8 @@ BaseLayerAndroid* WebViewCore::createBaseLayer(SkRegion* region) return realBase; } -BaseLayerAndroid* WebViewCore::recordContent(SkRegion* region, SkIPoint* point) +BaseLayerAndroid* WebViewCore::recordContent(SkIPoint* point) { - DBG_SET_LOG("start"); // If there is a pending style recalculation, just return. if (m_mainFrame->document()->isPendingStyleRecalc()) { DBG_SET_LOG("recordContent: pending style recalc, ignoring."); @@ -965,21 +964,20 @@ BaseLayerAndroid* WebViewCore::recordContent(SkRegion* region, SkIPoint* point) DBG_SET_LOGD("empty (progress=%g)", progress); return 0; } - region->set(m_addInval); + + BaseLayerAndroid* baseLayer = createBaseLayer(); + + baseLayer->markAsDirty(m_addInval); m_addInval.setEmpty(); #if USE(ACCELERATED_COMPOSITING) #else - region->op(m_rebuildInval, SkRegion::kUnion_Op); + baseLayer->markAsDirty(m_rebuildInval); #endif m_rebuildInval.setEmpty(); point->fX = m_content.width(); point->fY = m_content.height(); - DBG_SET_LOGD("region={%d,%d,r=%d,b=%d}", region->getBounds().fLeft, - region->getBounds().fTop, region->getBounds().fRight, - region->getBounds().fBottom); - DBG_SET_LOG("end"); - return createBaseLayer(region); + return baseLayer; } void WebViewCore::splitContent(PictureSet* content) @@ -4553,13 +4551,11 @@ static void NotifyAnimationStarted(JNIEnv* env, jobject obj, jint nativeClass) viewImpl->notifyAnimationStarted(); } -static jint RecordContent(JNIEnv* env, jobject obj, jint nativeClass, - jobject region, jobject pt) +static jint RecordContent(JNIEnv* env, jobject obj, jint nativeClass, jobject pt) { WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass); - SkRegion* nativeRegion = GraphicsJNI::getNativeRegion(env, region); SkIPoint nativePt; - BaseLayerAndroid* result = viewImpl->recordContent(nativeRegion, &nativePt); + BaseLayerAndroid* result = viewImpl->recordContent(&nativePt); GraphicsJNI::ipoint_to_jpoint(nativePt, env, pt); return reinterpret_cast<jint>(result); } @@ -5074,7 +5070,7 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = { (void*) GetContentMinPrefWidth }, { "nativeNotifyAnimationStarted", "(I)V", (void*) NotifyAnimationStarted }, - { "nativeRecordContent", "(ILandroid/graphics/Region;Landroid/graphics/Point;)I", + { "nativeRecordContent", "(ILandroid/graphics/Point;)I", (void*) RecordContent }, { "setViewportSettingsFromNative", "(I)V", (void*) SetViewportSettingsFromNative }, diff --git a/Source/WebKit/android/jni/WebViewCore.h b/Source/WebKit/android/jni/WebViewCore.h index eec98b0..3e1dbab 100644 --- a/Source/WebKit/android/jni/WebViewCore.h +++ b/Source/WebKit/android/jni/WebViewCore.h @@ -510,13 +510,13 @@ namespace android { bool focusBoundsChanged(); - // record the inval area, and the picture size - WebCore::BaseLayerAndroid* recordContent(SkRegion* , SkIPoint* ); + // record content in a new BaseLayerAndroid, copying the layer tree as well + WebCore::BaseLayerAndroid* recordContent(SkIPoint* ); // This creates a new BaseLayerAndroid by copying the current m_content // and doing a copy of the layers. The layers' content may be updated // as we are calling layersSync(). - WebCore::BaseLayerAndroid* createBaseLayer(SkRegion*); + WebCore::BaseLayerAndroid* createBaseLayer(); bool updateLayers(WebCore::LayerAndroid*); void notifyAnimationStarted(); diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp index 5739c78..07b69c7 100644 --- a/Source/WebKit/android/nav/WebView.cpp +++ b/Source/WebKit/android/nav/WebView.cpp @@ -521,18 +521,14 @@ static void copyScrollPositionRecursive(const LayerAndroid* from, BaseLayerAndroid* getBaseLayer() const { return m_baseLayer; } -bool setBaseLayer(BaseLayerAndroid* newBaseLayer, SkRegion& inval, bool showVisualIndicator, +bool setBaseLayer(BaseLayerAndroid* newBaseLayer, bool showVisualIndicator, bool isPictureAfterFirstLayout) { bool queueFull = false; #if USE(ACCELERATED_COMPOSITING) - if (m_glWebViewState) { - // TODO: mark as inval on webkit side - if (newBaseLayer) - newBaseLayer->markAsDirty(inval); + if (m_glWebViewState) queueFull = m_glWebViewState->setBaseLayer(newBaseLayer, showVisualIndicator, isPictureAfterFirstLayout); - } #endif #if ENABLE(ANDROID_OVERFLOW_SCROLL) @@ -707,6 +703,7 @@ class GLDrawFunctor : Functor { scale = _scale; extras = _extras; }; + status_t operator()(int messageId, void* data) { TRACE_METHOD(); @@ -877,15 +874,12 @@ static bool nativeEvaluateLayersAnimations(JNIEnv *env, jobject obj, jint native return false; } -static bool nativeSetBaseLayer(JNIEnv *env, jobject obj, jint nativeView, jint layer, jobject inval, +static bool nativeSetBaseLayer(JNIEnv *env, jobject obj, jint nativeView, jint layer, jboolean showVisualIndicator, jboolean isPictureAfterFirstLayout) { BaseLayerAndroid* layerImpl = reinterpret_cast<BaseLayerAndroid*>(layer); - SkRegion invalRegion; - if (inval) - invalRegion = *GraphicsJNI::getNativeRegion(env, inval); - return ((WebView*)nativeView)->setBaseLayer(layerImpl, invalRegion, showVisualIndicator, + return ((WebView*)nativeView)->setBaseLayer(layerImpl, showVisualIndicator, isPictureAfterFirstLayout); } @@ -1125,13 +1119,13 @@ static void nativeDumpDisplayTree(JNIEnv* env, jobject jwebview, jstring jurl) #endif } -static int nativeScrollableLayer(JNIEnv* env, jobject jwebview, jint x, jint y, - jobject rect, jobject bounds) +static int nativeScrollableLayer(JNIEnv* env, jobject jwebview, jint nativeView, + jint x, jint y, jobject rect, jobject bounds) { - WebView* view = GET_NATIVE_VIEW(env, jwebview); - ALOG_ASSERT(view, "view not set in %s", __FUNCTION__); + WebView* webview = reinterpret_cast<WebView*>(nativeView); + ALOG_ASSERT(webview, "webview not set in %s", __FUNCTION__); SkIRect nativeRect, nativeBounds; - int id = view->scrollableLayer(x, y, &nativeRect, &nativeBounds); + int id = webview->scrollableLayer(x, y, &nativeRect, &nativeBounds); if (rect) GraphicsJNI::irect_to_jrect(nativeRect, env, rect); if (bounds) @@ -1139,15 +1133,15 @@ static int nativeScrollableLayer(JNIEnv* env, jobject jwebview, jint x, jint y, return id; } -static bool nativeScrollLayer(JNIEnv* env, jobject obj, jint layerId, jint x, - jint y) +static bool nativeScrollLayer(JNIEnv* env, jobject obj, + jint nativeView, jint layerId, jint x, jint y) { #if ENABLE(ANDROID_OVERFLOW_SCROLL) - WebView* view = GET_NATIVE_VIEW(env, obj); - view->scrollLayer(layerId, x, y); + WebView* webview = reinterpret_cast<WebView*>(nativeView); + webview->scrollLayer(layerId, x, y); //TODO: the below only needed for the SW rendering path - LayerAndroid* baseLayer = view->getBaseLayer(); + LayerAndroid* baseLayer = webview->getBaseLayer(); if (!baseLayer) return false; LayerAndroid* layer = baseLayer->findById(layerId); @@ -1263,7 +1257,7 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeLayerBounds }, { "nativeSetHeightCanMeasure", "(Z)V", (void*) nativeSetHeightCanMeasure }, - { "nativeSetBaseLayer", "(IILandroid/graphics/Region;ZZ)Z", + { "nativeSetBaseLayer", "(IIZZ)Z", (void*) nativeSetBaseLayer }, { "nativeGetBaseLayer", "()I", (void*) nativeGetBaseLayer }, @@ -1291,9 +1285,9 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeTileProfilingGetFloat }, { "nativeStopGL", "()V", (void*) nativeStopGL }, - { "nativeScrollableLayer", "(IILandroid/graphics/Rect;Landroid/graphics/Rect;)I", + { "nativeScrollableLayer", "(IIILandroid/graphics/Rect;Landroid/graphics/Rect;)I", (void*) nativeScrollableLayer }, - { "nativeScrollLayer", "(III)Z", + { "nativeScrollLayer", "(IIII)Z", (void*) nativeScrollLayer }, { "nativeSetIsScrolling", "(Z)V", (void*) nativeSetIsScrolling }, |