diff options
20 files changed, 160 insertions, 191 deletions
diff --git a/JavaScriptCore/wtf/Platform.h b/JavaScriptCore/wtf/Platform.h index f30ca49..a6ded58 100644 --- a/JavaScriptCore/wtf/Platform.h +++ b/JavaScriptCore/wtf/Platform.h @@ -824,6 +824,10 @@ #define ENABLE_TEXT_CARET 1 #endif +#if !defined(ENABLE_COMPOSITED_FIXED_ELEMENTS) +#define ENABLE_COMPOSITED_FIXED_ELEMENTS 0 +#endif + // ENABLE_ARCHIVE is an Android addition. We need this default value to allow // us to build on Mac. // FIXME: Upstream to webkit.org. diff --git a/WebCore/Android.derived.jscbindings.mk b/WebCore/Android.derived.jscbindings.mk index e336d23..380b138 100644 --- a/WebCore/Android.derived.jscbindings.mk +++ b/WebCore/Android.derived.jscbindings.mk @@ -49,7 +49,7 @@ js_binding_scripts := $(addprefix $(LOCAL_PATH)/,\ bindings/scripts/generate-bindings.pl \ ) -FEATURE_DEFINES := ENABLE_ORIENTATION_EVENTS=1 ENABLE_TOUCH_EVENTS=1 ENABLE_DATABASE=1 ENABLE_OFFLINE_WEB_APPLICATIONS=1 ENABLE_DOM_STORAGE=1 ENABLE_VIDEO=1 ENABLE_WORKERS=1 ENABLE_GEOLOCATION=1 ENABLE_CHANNEL_MESSAGING=1 ENABLE_CONNECTION=1 ENABLE_APPLICATION_INSTALLED=1 +FEATURE_DEFINES := ENABLE_ORIENTATION_EVENTS=1 ENABLE_TOUCH_EVENTS=1 ENABLE_DATABASE=1 ENABLE_OFFLINE_WEB_APPLICATIONS=1 ENABLE_DOM_STORAGE=1 ENABLE_VIDEO=1 ENABLE_GEOLOCATION=1 ENABLE_CONNECTION=1 ENABLE_APPLICATION_INSTALLED=1 # CSS GEN := \ diff --git a/WebCore/Android.derived.v8bindings.mk b/WebCore/Android.derived.v8bindings.mk index 29899ef..c385111 100644 --- a/WebCore/Android.derived.v8bindings.mk +++ b/WebCore/Android.derived.v8bindings.mk @@ -31,7 +31,7 @@ js_binding_scripts := \ $(LOCAL_PATH)/bindings/scripts/generate-bindings.pl # Add ACCELERATED_COMPOSITING=1 and ENABLE_3D_RENDERING=1 for layers support -FEATURE_DEFINES := ENABLE_ORIENTATION_EVENTS=1 ENABLE_TOUCH_EVENTS=1 V8_BINDING ENABLE_DATABASE=1 ENABLE_OFFLINE_WEB_APPLICATIONS=1 ENABLE_DOM_STORAGE=1 ENABLE_WORKERS=1 ENABLE_VIDEO=1 ENABLE_GEOLOCATION=1 ENABLE_CONNECTION=1 ENABLE_APPLICATION_INSTALLED=1 +FEATURE_DEFINES := ENABLE_ORIENTATION_EVENTS=1 ENABLE_TOUCH_EVENTS=1 V8_BINDING ENABLE_DATABASE=1 ENABLE_OFFLINE_WEB_APPLICATIONS=1 ENABLE_DOM_STORAGE=1 ENABLE_VIDEO=1 ENABLE_GEOLOCATION=1 ENABLE_CONNECTION=1 ENABLE_APPLICATION_INSTALLED=1 # CSS GEN := \ diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm index 2b89b54..ee51ec3 100644 --- a/WebCore/bindings/scripts/CodeGeneratorV8.pm +++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm @@ -1949,12 +1949,8 @@ sub GenerateToV8Converters v8::Handle<v8::Object> ${className}::wrap(${nativeType}* impl${forceNewObjectInput}) { v8::Handle<v8::Object> wrapper; -END - if (!MayBeInWorkerContext($dataNode, $interfaceName)) { - push(@implContent, <<END); V8Proxy* proxy = 0; END - } if (IsNodeSubType($dataNode)) { push(@implContent, <<END); @@ -1993,15 +1989,9 @@ END END } - if (MayBeInWorkerContext($dataNode, $interfaceName)) { - push(@implContent, <<END); - wrapper = V8DOMWrapper::instantiateV8ObjectInWorkerContext(${wrapperType}, impl); -END - } else { - push(@implContent, <<END); + push(@implContent, <<END); wrapper = V8DOMWrapper::instantiateV8Object(proxy, ${wrapperType}, impl); END - } if (IsNodeSubType($dataNode)) { push(@implContent, <<END); @@ -2049,35 +2039,6 @@ END } } -sub MayBeInWorkerContext { - # These objects can be constructed under WorkerContextExecutionProxy. They need special - # handling, since if we call V8Proxy::retrieve(), we will crash. - # FIXME: websocket? - my $dataNode = shift; - my $interfaceName = shift; - # FIXME: Doing the extra work to handle the WorkerContext case for all Event - # types is sad. We can probably be cleverer and only do the extra work for certain types. - return 1 if IsEventSubType($dataNode); - return 1 if $interfaceName eq "DOMCoreException"; - return 1 if $interfaceName eq "EventException"; - return 1 if $interfaceName eq "RangeException"; - return 1 if $interfaceName eq "XMLHttpRequestException"; - return 1 if $interfaceName eq "MessagePort"; - return 1 if $interfaceName eq "DedicatedWorkerContext"; - return 1 if $interfaceName eq "WorkerContext"; - return 1 if $interfaceName eq "SharedWorkerContext"; - return 1 if $interfaceName eq "WorkerLocation"; - return 1 if $interfaceName eq "WorkerNavigator"; - return 1 if $interfaceName eq "Notification"; - return 1 if $interfaceName eq "NotificationCenter"; - return 1 if $interfaceName eq "XMLHttpRequest"; - return 1 if $interfaceName eq "WebSocket"; - return 1 if $interfaceName eq "Worker"; - return 1 if $interfaceName eq "SharedWorker"; - return 1 if $interfaceName eq "EventSource"; - return 0; -} - sub HasCustomToV8Implementation { # FIXME: This subroutine is lame. Probably should be an .idl attribute (CustomToV8)? $dataNode = shift; diff --git a/WebCore/bindings/v8/V8DOMWrapper.cpp b/WebCore/bindings/v8/V8DOMWrapper.cpp index 1605417..eabeb4d 100644 --- a/WebCore/bindings/v8/V8DOMWrapper.cpp +++ b/WebCore/bindings/v8/V8DOMWrapper.cpp @@ -61,6 +61,7 @@ #include "V8Proxy.h" #include "V8SVGElementInstance.h" #include "V8SharedWorker.h" +#include "V8SharedWorkerContext.h" #include "V8StyleSheet.h" #include "V8WebSocket.h" #include "V8Worker.h" @@ -211,6 +212,7 @@ v8::Local<v8::Function> V8DOMWrapper::getConstructor(V8ClassIndex::V8WrapperType return getConstructorForContext(type, context); } +#if ENABLE(WORKERS) v8::Local<v8::Function> V8DOMWrapper::getConstructor(V8ClassIndex::V8WrapperType type, WorkerContext*) { WorkerContextExecutionProxy* proxy = WorkerContextExecutionProxy::retrieve(); @@ -223,6 +225,7 @@ v8::Local<v8::Function> V8DOMWrapper::getConstructor(V8ClassIndex::V8WrapperType return getConstructorForContext(type, context); } +#endif void V8DOMWrapper::setHiddenWindowReference(Frame* frame, const int internalIndex, v8::Handle<v8::Object> jsObject) { @@ -267,36 +270,53 @@ PassRefPtr<NodeFilter> V8DOMWrapper::wrapNativeNodeFilter(v8::Handle<v8::Value> return NodeFilter::create(condition); } -v8::Local<v8::Object> V8DOMWrapper::instantiateV8ObjectInWorkerContext(V8ClassIndex::V8WrapperType type, void* impl) +static bool globalObjectPrototypeIsDOMWindow(v8::Handle<v8::Object> objectPrototype) { - WorkerContextExecutionProxy* workerContextProxy = WorkerContextExecutionProxy::retrieve(); - if (!workerContextProxy) - return instantiateV8Object(0, type, impl); - v8::Local<v8::Object> instance = SafeAllocation::newInstance(getConstructor(type, workerContextProxy->workerContext())); - if (!instance.IsEmpty()) { - // Avoid setting the DOM wrapper for failed allocations. - setDOMWrapper(instance, V8ClassIndex::ToInt(type), impl); - } - return instance; +#if ENABLE(SHARED_WORKERS) + // We can identify what type of context the global object is wrapping by looking at the + // internal field count of its prototype. This assumes WorkerContexts and DOMWindows have different numbers + // of internal fields, so a COMPILE_ASSERT is included to warn if this ever changes. DOMWindow has + // traditionally had far more internal fields than any other class. + COMPILE_ASSERT(V8DOMWindow::internalFieldCount != V8WorkerContext::internalFieldCount && V8DOMWindow::internalFieldCount != V8SharedWorkerContext::internalFieldCount, + DOMWindowAndWorkerContextHaveUnequalFieldCounts); +#endif + return objectPrototype->InternalFieldCount() == V8DOMWindow::internalFieldCount; } v8::Local<v8::Object> V8DOMWrapper::instantiateV8Object(V8Proxy* proxy, V8ClassIndex::V8WrapperType type, void* impl) { + WorkerContext* workerContext = 0; if (V8IsolatedContext::getEntered()) { // This effectively disables the wrapper cache for isolated worlds. proxy = 0; // FIXME: Do we need a wrapper cache for the isolated world? We should // see if the performance gains are worth while. // We'll get one once we give the isolated context a proper window shell. - } else if (!proxy) - proxy = V8Proxy::retrieve(); + } else if (!proxy) { + v8::Handle<v8::Context> context = v8::Context::GetCurrent(); + if (!context.IsEmpty()) { + v8::Handle<v8::Object> globalPrototype = v8::Handle<v8::Object>::Cast(context->Global()->GetPrototype()); + if (globalObjectPrototypeIsDOMWindow(globalPrototype)) + proxy = V8Proxy::retrieve(V8DOMWindow::toNative(globalPrototype)->frame()); +#if ENABLE(WORKERS) + else + workerContext = V8WorkerContext::toNative(globalPrototype); +#endif + } + } v8::Local<v8::Object> instance; if (proxy) // FIXME: Fix this to work properly with isolated worlds (see above). instance = proxy->windowShell()->createWrapperFromCache(type); - else - instance = SafeAllocation::newInstance(V8ClassIndex::getTemplate(type)->GetFunction()); + else { + v8::Local<v8::Function> function; + if (workerContext) + function = getConstructor(type, workerContext); + else + function = V8ClassIndex::getTemplate(type)->GetFunction(); + instance = SafeAllocation::newInstance(function); + } if (!instance.IsEmpty()) { // Avoid setting the DOM wrapper for failed allocations. setDOMWrapper(instance, V8ClassIndex::ToInt(type), impl); @@ -456,6 +476,9 @@ PassRefPtr<EventListener> V8DOMWrapper::getEventListener(SVGElementInstance* ele } #endif +// ANDROID +// Temporary fix until we merge http://trac.webkit.org/changeset/55096 +#if ENABLE(WORKERS) PassRefPtr<EventListener> V8DOMWrapper::getEventListener(AbstractWorker* worker, v8::Local<v8::Value> value, bool isAttribute, ListenerLookupType lookup) { if (worker->scriptExecutionContext()->isWorkerContext()) { @@ -466,6 +489,7 @@ PassRefPtr<EventListener> V8DOMWrapper::getEventListener(AbstractWorker* worker, return (lookup == ListenerFindOnly) ? V8EventListenerList::findWrapper(value, isAttribute) : V8EventListenerList::findOrCreateWrapper<V8EventListener>(value, isAttribute); } +#endif #if ENABLE(NOTIFICATIONS) PassRefPtr<EventListener> V8DOMWrapper::getEventListener(Notification* notification, v8::Local<v8::Value> value, bool isAttribute, ListenerLookupType lookup) @@ -480,6 +504,9 @@ PassRefPtr<EventListener> V8DOMWrapper::getEventListener(Notification* notificat } #endif +// ANDROID +// Temporary fix until we merge http://trac.webkit.org/changeset/55096 +#if ENABLE(WORKERS) PassRefPtr<EventListener> V8DOMWrapper::getEventListener(WorkerContext* workerContext, v8::Local<v8::Value> value, bool isAttribute, ListenerLookupType lookup) { WorkerContextExecutionProxy* workerContextProxy = workerContext->script()->proxy(); @@ -488,6 +515,7 @@ PassRefPtr<EventListener> V8DOMWrapper::getEventListener(WorkerContext* workerCo return 0; } +#endif PassRefPtr<EventListener> V8DOMWrapper::getEventListener(XMLHttpRequestUpload* upload, v8::Local<v8::Value> value, bool isAttribute, ListenerLookupType lookup) { diff --git a/WebCore/bindings/v8/V8DOMWrapper.h b/WebCore/bindings/v8/V8DOMWrapper.h index 78e9ae2..afac577 100644 --- a/WebCore/bindings/v8/V8DOMWrapper.h +++ b/WebCore/bindings/v8/V8DOMWrapper.h @@ -192,7 +192,6 @@ namespace WebCore { static void setHiddenWindowReference(Frame*, const int internalIndex, v8::Handle<v8::Object>); static v8::Local<v8::Object> instantiateV8Object(V8Proxy* proxy, V8ClassIndex::V8WrapperType type, void* impl); - static v8::Local<v8::Object> instantiateV8ObjectInWorkerContext(V8ClassIndex::V8WrapperType type, void* impl); static v8::Handle<v8::Object> getWrapper(Node*); }; diff --git a/WebCore/bindings/v8/V8Proxy.cpp b/WebCore/bindings/v8/V8Proxy.cpp index 9b1fff5..85db554 100644 --- a/WebCore/bindings/v8/V8Proxy.cpp +++ b/WebCore/bindings/v8/V8Proxy.cpp @@ -910,9 +910,11 @@ v8::Local<v8::Context> toV8Context(ScriptExecutionContext* context, const WorldC if (context->isDocument()) { if (V8Proxy* proxy = V8Proxy::retrieve(context)) return worldContext.adjustedContext(proxy); +#if ENABLE(WORKERS) } else if (context->isWorkerContext()) { if (WorkerContextExecutionProxy* proxy = static_cast<WorkerContext*>(context)->script()->proxy()) return proxy->context(); +#endif } return v8::Local<v8::Context>(); } diff --git a/WebCore/config.h b/WebCore/config.h index 4c7c2a9..702d244 100644 --- a/WebCore/config.h +++ b/WebCore/config.h @@ -85,7 +85,6 @@ #define LOG_DISABLED 1 #include <wtf/Assertions.h> // Central place to set which optional features Android uses. -#define ENABLE_CHANNEL_MESSAGING 1 #define ENABLE_DOM_STORAGE 1 #undef ENABLE_FTPDIR // Enabled by default in Platform.h #define ENABLE_FTPDIR 0 @@ -94,7 +93,6 @@ #endif #define ENABLE_3D_RENDERING 0 #define ENABLE_VIDEO 1 -#define ENABLE_WORKERS 1 #if ENABLE_SVG #if !defined(ENABLE_SVG_ANIMATION) @@ -126,6 +124,10 @@ #undef ENABLE_APPLICATION_INSTALLED #define ENABLE_APPLICATION_INSTALLED 1 +// Uses composited RenderLayers for fixed elements +#undef ENABLE_COMPOSITED_FIXED_ELEMENTS // Disabled by default in Platform.h +#define ENABLE_COMPOSITED_FIXED_ELEMENTS 1 + #define FLATTEN_FRAMESET #define FLATTEN_IFRAME diff --git a/WebCore/loader/SubresourceLoader.cpp b/WebCore/loader/SubresourceLoader.cpp index f92a074..ebb943a 100644 --- a/WebCore/loader/SubresourceLoader.cpp +++ b/WebCore/loader/SubresourceLoader.cpp @@ -81,7 +81,11 @@ PassRefPtr<SubresourceLoader> SubresourceLoader::create(Frame* frame, Subresourc if (SecurityOrigin::shouldHideReferrer(request.url(), fl->outgoingReferrer())) newRequest.clearHTTPReferrer(); +#ifdef ANDROID_FIX + else if (request.httpReferrer().isEmpty()) +#else else if (!request.httpReferrer()) +#endif newRequest.setHTTPReferrer(fl->outgoingReferrer()); FrameLoader::addHTTPOriginIfNeeded(newRequest, fl->outgoingOrigin()); diff --git a/WebCore/page/android/EventHandlerAndroid.cpp b/WebCore/page/android/EventHandlerAndroid.cpp index 48f35c3..bdc5f2a 100644 --- a/WebCore/page/android/EventHandlerAndroid.cpp +++ b/WebCore/page/android/EventHandlerAndroid.cpp @@ -78,16 +78,6 @@ bool EventHandler::eventActivatedView(const PlatformMouseEvent&) const return false; } -// This function is called for mouse events by FrameView::handleMousePressEvent(). -// 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&, Frame*, HitTestResult*) -{ - notImplemented(); - return false; -} - // 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. @@ -99,18 +89,21 @@ bool EventHandler::passWheelEventToWidget(PlatformWheelEvent&, Widget*) bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe) { - return passSubframeEventToSubframe(mev, subframe); + subframe->eventHandler()->handleMousePressEvent(mev.event()); + return true; } bool EventHandler::passMouseMoveEventToSubframe(MouseEventWithHitTestResults& mev, - Frame* subframe, HitTestResult*) + Frame* subframe, HitTestResult* hoveredNode) { - return passSubframeEventToSubframe(mev, subframe); + subframe->eventHandler()->handleMouseMoveEvent(mev.event(), hoveredNode); + return true; } bool EventHandler::passMouseReleaseEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe) { - return passSubframeEventToSubframe(mev, subframe); + subframe->eventHandler()->handleMouseReleaseEvent(mev.event()); + return true; } class Clipboard : public RefCounted<Clipboard> { diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp index b48ef49..93469b0 100644 --- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp +++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp @@ -218,39 +218,6 @@ void GraphicsLayerAndroid::needsSyncChildren() askForSync(); } -void GraphicsLayerAndroid::syncFixedDescendants() -{ - for (unsigned int i = 0; i < m_children.size(); i++) - (static_cast<GraphicsLayerAndroid*>(m_children[i]))->syncFixedDescendants(); - - if (!m_client) - return; - - RenderLayerBacking* backing = static_cast<RenderLayerBacking*>(m_client); - RenderLayer* renderLayer = backing->owningLayer(); - RenderView* view = static_cast<RenderView*>(renderLayer->renderer()); - - // If we have an ancestor that is a fixed position layer, we need to - // mark ourselve as a child of it, as the RenderLayer hierarchy only - // keeps track of the z-order. - // By calling setRelativeTo() we ensure that we will keep track of - // the fixed layer we are relative to, and will be able to update - // our position accordingly. - RenderLayer* positionedParent = renderLayer->parent(); - while (positionedParent && - !(positionedParent->renderer()->isPositioned() && - positionedParent->renderer()->style()->position() == FixedPosition)) - positionedParent = positionedParent->parent(); - - if (positionedParent && positionedParent->isComposited()) { - RenderLayerBacking* positionedParentBacking = positionedParent->backing(); - GraphicsLayerAndroid* positionedParentLayer = - static_cast<GraphicsLayerAndroid*>(positionedParentBacking->graphicsLayer()); - LayerAndroid* parentLayer = positionedParentLayer->contentLayer(); - m_contentLayer->setRelativeTo(parentLayer); - } -} - void GraphicsLayerAndroid::updateFixedPosition() { if (!m_client) @@ -456,7 +423,6 @@ void GraphicsLayerAndroid::sendImmediateRepaint() if (rootGraphicsLayer->m_frame && rootGraphicsLayer->m_frame->view()) { LayerAndroid* copyLayer = new LayerAndroid(*m_contentLayer); - copyLayer->ensureFixedLayersForDescendants(copyLayer); TLOG("(%x) sendImmediateRepaint, copy the layer, (%.2f,%.2f => %.2f,%.2f)", this, m_contentLayer->getSize().width(), m_contentLayer->getSize().height(), copyLayer->getSize().width(), copyLayer->getSize().height()); @@ -920,7 +886,6 @@ void GraphicsLayerAndroid::syncCompositingState() syncChildren(); syncMask(); syncPositionState(); - syncFixedDescendants(); if (!gPaused || WTF::currentTime() >= gPausedDelay) repaintAll(); diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.h b/WebCore/platform/graphics/android/GraphicsLayerAndroid.h index 09f4181..25f70b4 100644 --- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.h +++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.h @@ -110,7 +110,6 @@ public: virtual void setZPosition(float); void askForSync(); - void syncFixedDescendants(); void syncPositionState(); void needsSyncChildren(); void syncChildren(); diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp index 26372f0..c17a034 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -49,14 +49,10 @@ LayerAndroid::LayerAndroid(bool isRootLayer) : SkLayer(), m_haveClip(false), m_doRotation(false), m_isFixed(false), - m_isRelativeTo(false), - m_relativeFixedLayerID(0), m_recordingPicture(0), m_extra(0), - m_uniqueId(++gUniqueId), - m_relativeFixedLayer(0) + m_uniqueId(++gUniqueId) { - m_deltaPosition.set(0, 0); m_angleTransform = 0; m_translation.set(0, 0); m_scale.set(1, 1); @@ -69,14 +65,10 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer) : SkLayer(layer), m_isRootLayer(layer.m_isRootLayer), m_haveClip(layer.m_haveClip), m_extra(0), // deliberately not copied - m_uniqueId(layer.m_uniqueId), - m_relativeFixedLayer(0) + m_uniqueId(layer.m_uniqueId) { m_doRotation = layer.m_doRotation; m_isFixed = layer.m_isFixed; - m_isRelativeTo = layer.m_isRelativeTo; - m_relativeFixedLayerID = layer.m_relativeFixedLayerID; - m_deltaPosition = layer.m_deltaPosition; m_angleTransform = layer.m_angleTransform; m_translation = layer.m_translation; @@ -108,14 +100,10 @@ LayerAndroid::LayerAndroid(SkPicture* picture) : SkLayer(), m_haveClip(false), m_doRotation(false), m_isFixed(false), - m_isRelativeTo(false), - m_relativeFixedLayerID(0), m_recordingPicture(picture), m_extra(0), - m_uniqueId(-1), - m_relativeFixedLayer(0) + m_uniqueId(-1) { - m_deltaPosition.set(0, 0); m_angleTransform = 0; m_translation.set(0, 0); m_scale.set(1, 1); @@ -257,27 +245,6 @@ const LayerAndroid* LayerAndroid::find(int x, int y) const /////////////////////////////////////////////////////////////////////////////// -void LayerAndroid::setRelativeTo(LayerAndroid* container) { - ASSERT(container->m_isFixed); - m_relativeFixedLayerID = container->m_uniqueId; - m_isRelativeTo = true; - m_deltaPosition = getPosition() - container->getPosition(); -} - -void LayerAndroid::ensureFixedLayersForDescendants(const LayerAndroid* rootLayer) { - if (m_isRelativeTo && !m_relativeFixedLayer) { - LayerAndroid* containerLayer = const_cast<LayerAndroid*>( - rootLayer->findById(m_relativeFixedLayerID)); - if (containerLayer) - m_relativeFixedLayer = containerLayer; - } - - int count = countChildren(); - for (int i = 0; i < count; i++) { - getChild(i)->ensureFixedLayersForDescendants(rootLayer); - } -} - void LayerAndroid::updateFixedLayersPositions(const SkRect& viewport) { if (m_isFixed) { @@ -311,13 +278,6 @@ void LayerAndroid::updatePositions() { // apply the viewport to us SkMatrix matrix; if (!m_isFixed) { - // If we are defined as being relative to a fixed - // layer, we need to update our position... - if (m_isRelativeTo && m_relativeFixedLayer) { - this->setPosition(m_relativeFixedLayer->getPosition().fX + m_deltaPosition.fX, - m_relativeFixedLayer->getPosition().fY + m_deltaPosition.fY); - } - // turn our fields into a matrix. // // TODO: this should happen in the caller, and we should remove these diff --git a/WebCore/platform/graphics/android/LayerAndroid.h b/WebCore/platform/graphics/android/LayerAndroid.h index 005ef3d..247e902 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.h +++ b/WebCore/platform/graphics/android/LayerAndroid.h @@ -103,14 +103,6 @@ public: m_isFixed = true; } - /** Call that method to position the layer relative to another one. - We can only be set relative to a fixed layer. - The parameter is not refcounted -- we only save its ID as we - need to reconnect with the correct layer once we copy the tree - to the UI. - */ - void setRelativeTo(LayerAndroid* container); - void setBackgroundColor(SkColor color); void setMaskLayer(LayerAndroid*); void setMasksToBounds(bool); @@ -134,16 +126,6 @@ public: void dumpLayers(FILE*, int indentLevel) const; void dumpToLog() const; - /** Call this to be sure all fixed descendants correctly have - a pointer to their container layer before we try - to update the positions. The fixed layer we point to is - not refcounted (no need, it's already in the layers' tree). - - This call is recursive, so it should be called on the root of the - hierarchy. - */ - void ensureFixedLayersForDescendants(const LayerAndroid* rootLayer); - /** Call this with the current viewport (scrolling, zoom) to update the position of the fixed layers. @@ -185,7 +167,6 @@ private: bool m_haveClip; bool m_doRotation; bool m_isFixed; - bool m_isRelativeTo; bool m_backgroundColorSet; SkLength m_fixedLeft; @@ -194,8 +175,6 @@ private: SkLength m_fixedBottom; int m_fixedWidth; int m_fixedHeight; - int m_relativeFixedLayerID; - SkPoint m_deltaPosition; SkPoint m_translation; SkPoint m_scale; @@ -209,8 +188,6 @@ private: DrawExtra* m_extra; int m_uniqueId; - LayerAndroid* m_relativeFixedLayer; - typedef SkLayer INHERITED; }; diff --git a/WebCore/rendering/RenderLayer.cpp b/WebCore/rendering/RenderLayer.cpp index 6e51785..db079c7 100644 --- a/WebCore/rendering/RenderLayer.cpp +++ b/WebCore/rendering/RenderLayer.cpp @@ -1038,6 +1038,23 @@ RenderLayer::convertToLayerCoords(const RenderLayer* ancestorLayer, int& xPos, i return; } } + +#if ENABLE(COMPOSITED_FIXED_ELEMENTS) + // If fixed layers are composited, we need to look up for a parent layer + // that would be fixed, and compute the correct offset relative to it. + int intermediateX = 0; + int intermediateY = 0; + const RenderLayer* currLayer = this; + while ((currLayer = currLayer->parent())) { + if (currLayer->isComposited() && currLayer->isFixed()) { + xPos = x() + intermediateX; + yPos = y() + intermediateY; + return; + } + intermediateX += currLayer->x(); + intermediateY += currLayer->y(); + } +#endif RenderLayer* parentLayer; if (position == AbsolutePosition || position == FixedPosition) { diff --git a/WebCore/rendering/RenderLayer.h b/WebCore/rendering/RenderLayer.h index 3cdad3a..2c8d184 100644 --- a/WebCore/rendering/RenderLayer.h +++ b/WebCore/rendering/RenderLayer.h @@ -321,7 +321,15 @@ public: // Get the enclosing stacking context for this layer. A stacking context is a layer // that has a non-auto z-index. RenderLayer* stackingContext() const; - bool isStackingContext() const { return !hasAutoZIndex() || renderer()->isRenderView(); } +#if ENABLE(COMPOSITED_FIXED_ELEMENTS) + bool isFixed() const { return renderer()->isPositioned() && renderer()->style()->position() == FixedPosition; } + // If fixed elements are composited, they will be containing children + bool isStackingContext() const { + return !hasAutoZIndex() || renderer()->isRenderView() || (isComposited() && isFixed()); + } +#else + bool isStackingContext() const { return !hasAutoZIndex() || renderer()->isRenderView() ; } +#endif void dirtyZOrderLists(); void dirtyStackingContextZOrderLists(); diff --git a/WebCore/rendering/RenderLayerCompositor.cpp b/WebCore/rendering/RenderLayerCompositor.cpp index a831a8b..2768461 100644 --- a/WebCore/rendering/RenderLayerCompositor.cpp +++ b/WebCore/rendering/RenderLayerCompositor.cpp @@ -67,6 +67,9 @@ struct CompositingState { CompositingState(RenderLayer* compAncestor) : m_compositingAncestor(compAncestor) , m_subtreeIsCompositing(false) +#if ENABLE(COMPOSITED_FIXED_ELEMENTS) + , m_fixedSibling(false) +#endif #ifndef NDEBUG , m_depth(0) #endif @@ -75,6 +78,9 @@ struct CompositingState { RenderLayer* m_compositingAncestor; bool m_subtreeIsCompositing; +#if ENABLE(COMPOSITED_FIXED_ELEMENTS) + bool m_fixedSibling; +#endif #ifndef NDEBUG int m_depth; #endif @@ -496,7 +502,19 @@ void RenderLayerCompositor::computeCompositingRequirements(RenderLayer* layer, O #endif const bool willBeComposited = needsToBeComposited(layer); + +#if ENABLE(COMPOSITED_FIXED_ELEMENTS) + // If we are a fixed layer, signal it to our siblings + if (layer->isFixed()) + compositingState.m_fixedSibling = true; + + if (!willBeComposited && compositingState.m_fixedSibling) + layer->setMustOverlapCompositedLayers(true); + + if (willBeComposited || compositingState.m_fixedSibling) { +#else if (willBeComposited) { +#endif // Tell the parent it has compositing descendants. compositingState.m_subtreeIsCompositing = true; // This layer now acts as the ancestor for kids. @@ -517,6 +535,25 @@ void RenderLayerCompositor::computeCompositingRequirements(RenderLayer* layer, O ASSERT(!layer->m_zOrderListsDirty); if (Vector<RenderLayer*>* negZOrderList = layer->negZOrderList()) { size_t listSize = negZOrderList->size(); +#if ENABLE(COMPOSITED_FIXED_ELEMENTS) + childState.m_fixedSibling = false; + + // For the negative z-order, if we have a fixed layer + // we need to make all the siblings composited layers. + // Otherwise a negative layer (below the fixed layer) could + // still be drawn onto a higher z-order layer (e.g. the body) + // if not immediately intersecting with our fixed layer. + // So it's not enough here to only set m_fixedSibling for + // subsequent siblings as we do for the normal flow + // and positive z-order. + for (size_t j = 0; j < listSize; ++j) { + if ((negZOrderList->at(j))->isFixed()) { + childState.m_fixedSibling = true; + break; + } + } +#endif + for (size_t i = 0; i < listSize; ++i) { RenderLayer* curLayer = negZOrderList->at(i); computeCompositingRequirements(curLayer, overlapMap, childState, layersChanged); @@ -537,6 +574,9 @@ void RenderLayerCompositor::computeCompositingRequirements(RenderLayer* layer, O ASSERT(!layer->m_normalFlowListDirty); if (Vector<RenderLayer*>* normalFlowList = layer->normalFlowList()) { size_t listSize = normalFlowList->size(); +#if ENABLE(COMPOSITED_FIXED_ELEMENTS) + childState.m_fixedSibling = false; +#endif for (size_t i = 0; i < listSize; ++i) { RenderLayer* curLayer = normalFlowList->at(i); computeCompositingRequirements(curLayer, overlapMap, childState, layersChanged); @@ -546,6 +586,9 @@ void RenderLayerCompositor::computeCompositingRequirements(RenderLayer* layer, O if (layer->isStackingContext()) { if (Vector<RenderLayer*>* posZOrderList = layer->posZOrderList()) { size_t listSize = posZOrderList->size(); +#if ENABLE(COMPOSITED_FIXED_ELEMENTS) + childState.m_fixedSibling = false; +#endif for (size_t i = 0; i < listSize; ++i) { RenderLayer* curLayer = posZOrderList->at(i); computeCompositingRequirements(curLayer, overlapMap, childState, layersChanged); @@ -927,14 +970,12 @@ bool RenderLayerCompositor::needsToBeComposited(const RenderLayer* layer) const if (!m_hasAcceleratedCompositing || !layer->isSelfPaintingLayer()) return false; -#if PLATFORM(ANDROID) - // if an ancestor is fixed positionned, we need to be composited... - RenderObject* renderer = layer->renderer(); - RenderObject* parent = renderer->parent(); - while (parent && (parent = renderer->parent())) { - if (parent->isPositioned() && parent->style()->position() == FixedPosition) - return true; - renderer = parent; +#if ENABLE(COMPOSITED_FIXED_ELEMENTS) + // if an ancestor is fixed positioned, we need to be composited... + const RenderLayer* currLayer = layer; + while ((currLayer = currLayer->parent())) { + if (currLayer->isComposited() && currLayer->isFixed()) + return true; } #endif @@ -955,8 +996,8 @@ bool RenderLayerCompositor::requiresCompositingLayer(const RenderLayer* layer) c // The root layer always has a compositing layer, but it may not have backing. return (inCompositingMode() && layer->isRootLayer()) || requiresCompositingForTransform(renderer) || -#if PLATFORM(ANDROID) - (renderer->isPositioned() && renderer->style()->position() == FixedPosition) || +#if ENABLE(COMPOSITED_FIXED_ELEMENTS) + layer->isFixed() || #else requiresCompositingForVideo(renderer) || requiresCompositingForCanvas(renderer) || diff --git a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp index 60598f8..10cd0b3 100644 --- a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp +++ b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp @@ -891,11 +891,12 @@ void FrameLoaderClientAndroid::transitionToCommittedForNewPage() { Retain(webViewCore); // Save the old WebFrameView's bounds and apply them to the new WebFrameView - WebFrameView* oldFrameView = static_cast<WebFrameView*> (m_frame->view()->platformWidget()); - IntRect bounds = oldFrameView->getBounds(); - IntRect windowBounds = oldFrameView->getWindowBounds(); - // we only support opaque, white background for now - m_frame->createView(bounds.size(), Color::white, false, IntSize(), false); + WebFrameView* oldWebFrameView = static_cast<WebFrameView*> (m_frame->view()->platformWidget()); + IntRect bounds = oldWebFrameView->getBounds(); + IntRect windowBounds = oldWebFrameView->getWindowBounds(); + WebCore::FrameView* oldFrameView = oldWebFrameView->view(); + m_frame->createView(bounds.size(), oldFrameView->baseBackgroundColor(), oldFrameView->isTransparent(), IntSize(), false); + // Create a new WebFrameView for the new FrameView WebFrameView* newFrameView = new WebFrameView(m_frame->view(), webViewCore); newFrameView->setLocation(bounds.x(), bounds.y()); diff --git a/WebKit/android/jni/WebFrameView.h b/WebKit/android/jni/WebFrameView.h index d83def1..823f2b4 100644 --- a/WebKit/android/jni/WebFrameView.h +++ b/WebKit/android/jni/WebFrameView.h @@ -49,6 +49,10 @@ namespace android { void setView(WebCore::FrameView* frameView); + WebCore::FrameView* view() const { + return mFrameView; + } + virtual bool forFrameView() const { return true; } private: diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 6e0ef43..8556dd8 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -2365,6 +2365,10 @@ void WebViewCore::setBackgroundColor(SkColor c) WebCore::Color bcolor((int)SkColorGetR(c), (int)SkColorGetG(c), (int)SkColorGetB(c), (int)SkColorGetA(c)); view->setBaseBackgroundColor(bcolor); + + // Background color of 0 indicates we want a transparent background + if (c == 0) + view->setTransparent(true); } jclass WebViewCore::getPluginClass(const WebCore::String& libName, const char* className) |
