diff options
Diffstat (limited to 'src/3rdparty/webkit/WebCore/rendering')
41 files changed, 549 insertions, 459 deletions
diff --git a/src/3rdparty/webkit/WebCore/rendering/CounterNode.cpp b/src/3rdparty/webkit/WebCore/rendering/CounterNode.cpp index 22a11b9..f546abb 100644 --- a/src/3rdparty/webkit/WebCore/rendering/CounterNode.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/CounterNode.cpp @@ -63,11 +63,17 @@ void CounterNode::recount() for (CounterNode* c = this; c; c = c->m_nextSibling) { int oldCount = c->m_countInParent; int newCount = c->computeCountInParent(); - c->m_countInParent = newCount; if (oldCount == newCount) break; - if (c->m_renderer->isCounter()) - c->m_renderer->setNeedsLayoutAndPrefWidthsRecalc(); + c->m_countInParent = newCount; + // m_renderer contains the parent of the render node + // corresponding to a CounterNode. Let's find the counter + // child and make this re-layout. + for (RenderObject* o = c->m_renderer->firstChild(); o; o = o->nextSibling()) + if (!o->documentBeingDestroyed() && o->isCounter()) { + o->setNeedsLayoutAndPrefWidthsRecalc(); + break; + } } } diff --git a/src/3rdparty/webkit/WebCore/rendering/InlineFlowBox.cpp b/src/3rdparty/webkit/WebCore/rendering/InlineFlowBox.cpp index 599129b..baea956 100644 --- a/src/3rdparty/webkit/WebCore/rendering/InlineFlowBox.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/InlineFlowBox.cpp @@ -429,7 +429,7 @@ void InlineFlowBox::computeLogicalBoxHeights(int& maxPositionTop, int& maxPositi } lineHeight = baseline + baselineToBottom; } else if (parentLineHeight.isPercent()) { - lineHeight = parentLineHeight.calcMinValue(curr->renderer()->style()->fontSize()); + lineHeight = parentLineHeight.calcMinValue(curr->renderer()->style()->fontSize(), true); baseline = 0; for (size_t i = 0; i < usedFonts.size(); ++i) { int halfLeading = (lineHeight - usedFonts[i]->ascent() - usedFonts[i]->descent()) / 2; @@ -578,28 +578,23 @@ void InlineFlowBox::computeVerticalOverflow(int lineTop, int lineBottom, bool st topVisualOverflow = min(curr->y() + childOverflowTop, topVisualOverflow); bottomVisualOverflow = max(curr->y() + text->height() + childOverflowBottom, bottomVisualOverflow); - } else { - // Only include overflow from inline flows and replaced inlines if they do not paint themselves. - bool childIsSelfPainting = curr->boxModelObject()->hasSelfPaintingLayer(); - if (curr->renderer()->isRenderInline()) { - InlineFlowBox* flow = static_cast<InlineFlowBox*>(curr); - flow->computeVerticalOverflow(lineTop, lineBottom, strictMode); - if (!childIsSelfPainting) { - topLayoutOverflow = min(topLayoutOverflow, flow->topLayoutOverflow()); - bottomLayoutOverflow = max(bottomLayoutOverflow, flow->bottomLayoutOverflow()); - topVisualOverflow = min(topVisualOverflow, flow->topVisualOverflow()); - bottomVisualOverflow = max(bottomVisualOverflow, flow->bottomVisualOverflow()); - } - } else if (!childIsSelfPainting){ - RenderBox* box = toRenderBox(curr->renderer()); - int boxY = curr->y(); - int childTopOverflow = box->hasOverflowClip() ? 0 : box->topLayoutOverflow(); - int childBottomOverflow = box->hasOverflowClip() ? curr->height() : box->bottomLayoutOverflow(); - topLayoutOverflow = min(boxY + childTopOverflow, topLayoutOverflow); - bottomLayoutOverflow = max(boxY + childBottomOverflow, bottomLayoutOverflow); - topVisualOverflow = min(boxY + box->topVisualOverflow(), topVisualOverflow); - bottomVisualOverflow = max(boxY + box->bottomVisualOverflow(), bottomVisualOverflow); - } + } else if (curr->renderer()->isRenderInline()) { + InlineFlowBox* flow = static_cast<InlineFlowBox*>(curr); + flow->computeVerticalOverflow(lineTop, lineBottom, strictMode); + topLayoutOverflow = min(topLayoutOverflow, flow->topLayoutOverflow()); + bottomLayoutOverflow = max(bottomLayoutOverflow, flow->bottomLayoutOverflow()); + topVisualOverflow = min(topVisualOverflow, flow->topVisualOverflow()); + bottomVisualOverflow = max(bottomVisualOverflow, flow->bottomVisualOverflow()); + } else if (!curr->boxModelObject()->hasSelfPaintingLayer()){ + // Only include overflow from replaced inlines if they do not paint themselves. + RenderBox* box = toRenderBox(curr->renderer()); + int boxY = curr->y(); + int childTopOverflow = box->hasOverflowClip() ? 0 : box->topLayoutOverflow(); + int childBottomOverflow = box->hasOverflowClip() ? curr->height() : box->bottomLayoutOverflow(); + topLayoutOverflow = min(boxY + childTopOverflow, topLayoutOverflow); + bottomLayoutOverflow = max(boxY + childBottomOverflow, bottomLayoutOverflow); + topVisualOverflow = min(boxY + box->topVisualOverflow(), topVisualOverflow); + bottomVisualOverflow = max(boxY + box->bottomVisualOverflow(), bottomVisualOverflow); } } diff --git a/src/3rdparty/webkit/WebCore/rendering/MediaControlElements.cpp b/src/3rdparty/webkit/WebCore/rendering/MediaControlElements.cpp index 29e2e57..73b9a3a 100644 --- a/src/3rdparty/webkit/WebCore/rendering/MediaControlElements.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/MediaControlElements.cpp @@ -46,6 +46,16 @@ namespace WebCore { using namespace HTMLNames; +HTMLMediaElement* toParentMediaElement(RenderObject* o) +{ + Node* node = o->node(); + Node* mediaNode = node ? node->shadowAncestorNode() : 0; + if (!mediaNode || (!mediaNode->hasTagName(HTMLNames::videoTag) && !mediaNode->hasTagName(HTMLNames::audioTag))) + return 0; + + return static_cast<HTMLMediaElement*>(mediaNode); +} + // FIXME: These constants may need to be tweaked to better match the seeking in the QuickTime plug-in. static const float cSeekRepeatDelay = 0.1f; static const float cStepTime = 0.07f; @@ -138,7 +148,7 @@ bool MediaControlElement::rendererIsNeeded(RenderStyle* style) ASSERT(document()->page()); return HTMLDivElement::rendererIsNeeded(style) && parent() && parent()->renderer() - && document()->page()->theme()->shouldRenderMediaControlPart(style->appearance(), m_mediaElement); + && (!style->hasAppearance() || document()->page()->theme()->shouldRenderMediaControlPart(style->appearance(), m_mediaElement)); } void MediaControlElement::attach() @@ -366,7 +376,7 @@ bool MediaControlInputElement::rendererIsNeeded(RenderStyle* style) ASSERT(document()->page()); return HTMLInputElement::rendererIsNeeded(style) && parent() && parent()->renderer() - && document()->page()->theme()->shouldRenderMediaControlPart(style->appearance(), m_mediaElement); + && (!style->hasAppearance() || document()->page()->theme()->shouldRenderMediaControlPart(style->appearance(), m_mediaElement)); } void MediaControlInputElement::attach() @@ -646,12 +656,12 @@ MediaControlFullscreenButtonElement::MediaControlFullscreenButtonElement(Documen void MediaControlFullscreenButtonElement::defaultEventHandler(Event* event) { if (event->type() == eventNames().clickEvent) { + m_mediaElement->enterFullscreen(); event->setDefaultHandled(); } HTMLInputElement::defaultEventHandler(event); } - // ---------------------------- MediaControlTimeDisplayElement::MediaControlTimeDisplayElement(Document* document, PseudoId pseudo, HTMLMediaElement* element) diff --git a/src/3rdparty/webkit/WebCore/rendering/MediaControlElements.h b/src/3rdparty/webkit/WebCore/rendering/MediaControlElements.h index f692485..e562bb5 100644 --- a/src/3rdparty/webkit/WebCore/rendering/MediaControlElements.h +++ b/src/3rdparty/webkit/WebCore/rendering/MediaControlElements.h @@ -66,6 +66,8 @@ enum MediaControlElementType { MediaVolumeSliderThumb }; +HTMLMediaElement* toParentMediaElement(RenderObject*); + class MediaControlShadowRootElement : public HTMLDivElement { public: MediaControlShadowRootElement(Document*, HTMLMediaElement*); diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderBR.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderBR.cpp index f407099..e05c8b4 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderBR.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderBR.cpp @@ -64,7 +64,7 @@ int RenderBR::lineHeight(bool firstLine, bool /*isRootLineBox*/) const return s->font().lineSpacing(); } if (lh.isPercent()) - return lh.calcMinValue(s->fontSize()); + return lh.calcMinValue(s->fontSize(), true); return lh.value(); } diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderBlock.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderBlock.cpp index ae0d76d..237478d 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderBlock.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderBlock.cpp @@ -774,7 +774,9 @@ void RenderBlock::layoutBlock(bool relayoutChildren) // Repaint with our new bounds if they are different from our old bounds. bool didFullRepaint = repainter.repaintAfterLayout(); if (!didFullRepaint && repaintTop != repaintBottom && (style()->visibility() == VISIBLE || enclosingLayer()->hasVisibleContent())) { - IntRect repaintRect(leftVisibleOverflow(), repaintTop, rightVisibleOverflow() - leftVisibleOverflow(), repaintBottom - repaintTop); + int repaintLeft = min(leftVisualOverflow(), leftLayoutOverflow()); + int repaintRight = max(rightVisualOverflow(), rightLayoutOverflow()); + IntRect repaintRect(repaintLeft, repaintTop, repaintRight - repaintLeft, repaintBottom - repaintTop); // FIXME: Deal with multiple column repainting. We have to split the repaint // rect up into multiple rects if it spans columns. diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderBox.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderBox.cpp index c8d3037..1df82a4 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderBox.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderBox.cpp @@ -139,6 +139,8 @@ void RenderBox::styleWillChange(StyleDifference diff, const RenderStyle* newStyl markContainingBlocksForLayout(); if (style()->position() == StaticPosition) repaint(); + else if (newStyle->position() == AbsolutePosition || newStyle->position() == FixedPosition) + parent()->setChildNeedsLayout(true); if (isFloating() && !isPositioned() && (newStyle->position() == AbsolutePosition || newStyle->position() == FixedPosition)) removeFloatingOrPositionedChildFromBlockLists(); } @@ -961,10 +963,10 @@ void RenderBox::mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool transformState.move(containerOffset.width(), containerOffset.height(), preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransform); if (containerSkipped) { - // There can't be a transfrom between repaintContainer and o, because transforms create containers, so it should be safe + // There can't be a transform between repaintContainer and o, because transforms create containers, so it should be safe // to just subtract the delta between the repaintContainer and o. - IntSize repaintContainerOffset = repaintContainer->offsetFromContainer(o); - transformState.move(-repaintContainerOffset.width(), -repaintContainerOffset.height(), preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransform); + IntSize containerOffset = repaintContainer->offsetFromAncestorContainer(o); + transformState.move(-containerOffset.width(), -containerOffset.height(), preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransform); return; } @@ -1201,7 +1203,7 @@ void RenderBox::computeRectForRepaint(RenderBoxModelObject* repaintContainer, In if (containerSkipped) { // If the repaintContainer is below o, then we need to map the rect into repaintContainer's coordinates. - IntSize containerOffset = repaintContainer->offsetFromContainer(o); + IntSize containerOffset = repaintContainer->offsetFromAncestorContainer(o); rect.move(-containerOffset); return; } diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderCounter.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderCounter.cpp index 67e5cba..17c6dad 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderCounter.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderCounter.cpp @@ -143,13 +143,19 @@ static bool findPlaceForCounter(RenderObject* object, const AtomicString& counte RenderObject* resetCandidate = isReset ? object->parent() : previousSiblingOrParent(object); RenderObject* prevCounterCandidate = object; CounterNode* candidateCounter = 0; + // When a reset counter is chosen as candidateCounter, we'll + // decide the new node should be a child of the reset node or a + // sibling or the reset node. This flag controls it. + bool createChildForReset = true; while ((prevCounterCandidate = prevCounterCandidate->previousInPreOrder())) { CounterNode* c = counter(prevCounterCandidate, counterName, false); if (prevCounterCandidate == resetCandidate) { - if (!candidateCounter) + if (!candidateCounter) { candidateCounter = c; + createChildForReset = true; + } if (candidateCounter) { - if (candidateCounter->isReset()) { + if (createChildForReset && candidateCounter->isReset()) { parent = candidateCounter; previousSibling = 0; } else { @@ -160,10 +166,19 @@ static bool findPlaceForCounter(RenderObject* object, const AtomicString& counte } resetCandidate = previousSiblingOrParent(resetCandidate); } else if (c) { - if (c->isReset()) - candidateCounter = 0; - else if (!candidateCounter) + if (c->isReset()) { + if (c->parent()) { + // The new node may be the next sibling of this reset node. + createChildForReset = false; + candidateCounter = c; + } else { + createChildForReset = true; + candidateCounter = 0; + } + } else if (!candidateCounter) { + createChildForReset = true; candidateCounter = c; + } } } diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderImage.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderImage.cpp index 51c3073..4206b1c 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderImage.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderImage.cpp @@ -227,7 +227,7 @@ bool RenderImage::setImageSizeForAltText(CachedImage* newImage /* = 0 */) imageHeight = paddingHeight; } - if (newImage) { + if (newImage && newImage->image()) { // imageSize() returns 0 for the error image. We need the true size of the // error image, so we have to get it by grabbing image() directly. imageWidth += newImage->image()->width() * style()->effectiveZoom(); diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderInline.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderInline.cpp index a5e973e..05d29d0 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderInline.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderInline.cpp @@ -697,7 +697,7 @@ void RenderInline::computeRectForRepaint(RenderBoxModelObject* repaintContainer, if (containerSkipped) { // If the repaintContainer is below o, then we need to map the rect into repaintContainer's coordinates. - IntSize containerOffset = repaintContainer->offsetFromContainer(o); + IntSize containerOffset = repaintContainer->offsetFromAncestorContainer(o); rect.move(-containerOffset); return; } diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderLayer.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderLayer.cpp index 95db43a..fea61c9 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderLayer.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderLayer.cpp @@ -311,12 +311,19 @@ void RenderLayer::updateLayerPositions(UpdateLayerPositionsFlags flags) if (m_reflection) m_reflection->layout(); +#if USE(ACCELERATED_COMPOSITING) + // Clear the IsCompositingUpdateRoot flag once we've found the first compositing layer in this update. + bool isUpdateRoot = (flags & IsCompositingUpdateRoot); + if (isComposited()) + flags &= ~IsCompositingUpdateRoot; +#endif + for (RenderLayer* child = firstChild(); child; child = child->nextSibling()) child->updateLayerPositions(flags); #if USE(ACCELERATED_COMPOSITING) if ((flags & UpdateCompositingLayers) && isComposited()) - backing()->updateAfterLayout(RenderLayerBacking::CompositingChildren); + backing()->updateAfterLayout(RenderLayerBacking::CompositingChildren, isUpdateRoot); #endif // With all our children positioned, now update our marquee if we need to. @@ -662,21 +669,20 @@ RenderLayer* RenderLayer::enclosingTransformedAncestor() const return curr; } +static inline const RenderLayer* compositingContainer(const RenderLayer* layer) +{ + return layer->isNormalFlowOnly() ? layer->parent() : layer->stackingContext(); +} + #if USE(ACCELERATED_COMPOSITING) RenderLayer* RenderLayer::enclosingCompositingLayer(bool includeSelf) const { if (includeSelf && isComposited()) return const_cast<RenderLayer*>(this); - // Compositing layers are parented according to stacking order and overflow list, - // so we have to check whether the parent is a stacking context, or whether - // the child is overflow-only. - bool inNormalFlowList = isNormalFlowOnly(); - for (RenderLayer* curr = parent(); curr; curr = curr->parent()) { - if (curr->isComposited() && (inNormalFlowList || curr->isStackingContext())) - return curr; - - inNormalFlowList = curr->isNormalFlowOnly(); + for (const RenderLayer* curr = compositingContainer(this); curr; curr = compositingContainer(curr)) { + if (curr->isComposited()) + return const_cast<RenderLayer*>(curr); } return 0; @@ -1140,8 +1146,10 @@ void RenderLayer::scrollToOffset(int x, int y, bool updateScrollbars, bool repai #if USE(ACCELERATED_COMPOSITING) if (compositor()->inCompositingMode()) { - if (RenderLayer* compositingAncestor = ancestorCompositingLayer()) - compositingAncestor->backing()->updateAfterLayout(RenderLayerBacking::AllDescendants); + if (RenderLayer* compositingAncestor = ancestorCompositingLayer()) { + bool isUpdateRoot = true; + compositingAncestor->backing()->updateAfterLayout(RenderLayerBacking::AllDescendants, isUpdateRoot); + } } #endif diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderLayer.h b/src/3rdparty/webkit/WebCore/rendering/RenderLayer.h index 9d2212b..a274638 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderLayer.h +++ b/src/3rdparty/webkit/WebCore/rendering/RenderLayer.h @@ -298,10 +298,11 @@ public: enum UpdateLayerPositionsFlag { DoFullRepaint = 1, CheckForRepaint = 1 << 1, - UpdateCompositingLayers = 1 << 2, + IsCompositingUpdateRoot = 1 << 2, + UpdateCompositingLayers = 1 << 3, }; typedef unsigned UpdateLayerPositionsFlags; - void updateLayerPositions(UpdateLayerPositionsFlags = DoFullRepaint | UpdateCompositingLayers); + void updateLayerPositions(UpdateLayerPositionsFlags = DoFullRepaint | IsCompositingUpdateRoot | UpdateCompositingLayers); void updateTransform(); @@ -327,6 +328,7 @@ public: Vector<RenderLayer*>* normalFlowList() const { return m_normalFlowList; } bool hasVisibleContent() const { return m_hasVisibleContent; } + bool hasVisibleDescendant() const { return m_hasVisibleDescendant; } void setHasVisibleContent(bool); void dirtyVisibleContentStatus(); diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderLayerBacking.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderLayerBacking.cpp index 941817c..d7248d4 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderLayerBacking.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderLayerBacking.cpp @@ -89,8 +89,8 @@ void RenderLayerBacking::createGraphicsLayer() m_graphicsLayer->setName("Anonymous Node"); #endif // NDEBUG - updateLayerOpacity(); - updateLayerTransform(); + updateLayerOpacity(renderer()->style()); + updateLayerTransform(renderer()->style()); } void RenderLayerBacking::destroyGraphicsLayer() @@ -104,15 +104,13 @@ void RenderLayerBacking::destroyGraphicsLayer() m_maskLayer = 0; } -void RenderLayerBacking::updateLayerOpacity() +void RenderLayerBacking::updateLayerOpacity(const RenderStyle* style) { - m_graphicsLayer->setOpacity(compositingOpacity(renderer()->opacity())); + m_graphicsLayer->setOpacity(compositingOpacity(style->opacity())); } -void RenderLayerBacking::updateLayerTransform() +void RenderLayerBacking::updateLayerTransform(const RenderStyle* style) { - RenderStyle* style = renderer()->style(); - // FIXME: This could use m_owningLayer->transform(), but that currently has transform-origin // baked into it, and we don't want that. TransformationMatrix t; @@ -148,7 +146,7 @@ void RenderLayerBacking::updateCompositedBounds() setCompositedBounds(layerBounds); } -void RenderLayerBacking::updateAfterLayout(UpdateDepth updateDepth) +void RenderLayerBacking::updateAfterLayout(UpdateDepth updateDepth, bool isUpdateRoot) { RenderLayerCompositor* layerCompositor = compositor(); if (!layerCompositor->compositingLayersNeedRebuild()) { @@ -162,7 +160,7 @@ void RenderLayerBacking::updateAfterLayout(UpdateDepth updateDepth) updateCompositedBounds(); layerCompositor->updateCompositingDescendantGeometry(m_owningLayer, m_owningLayer, updateDepth); - if (!m_owningLayer->parent()) { + if (isUpdateRoot) { updateGraphicsLayerGeometry(); layerCompositor->updateRootLayerPosition(); } @@ -219,11 +217,11 @@ void RenderLayerBacking::updateGraphicsLayerGeometry() // Set transform property, if it is not animating. We have to do this here because the transform // is affected by the layer dimensions. if (!renderer()->animation()->isAnimatingPropertyOnRenderer(renderer(), CSSPropertyWebkitTransform)) - updateLayerTransform(); + updateLayerTransform(renderer()->style()); // Set opacity, if it is not animating. if (!renderer()->animation()->isAnimatingPropertyOnRenderer(renderer(), CSSPropertyOpacity)) - updateLayerOpacity(); + updateLayerOpacity(renderer()->style()); RenderStyle* style = renderer()->style(); m_graphicsLayer->setPreserves3D(style->transformStyle3D() == TransformStyle3DPreserve3D); @@ -886,7 +884,7 @@ void RenderLayerBacking::paintIntoLayer(RenderLayer* rootLayer, GraphicsContext* if (paintingRoot && !renderer()->isDescendantOf(paintingRoot)) paintingRootForRenderer = paintingRoot; - bool shouldPaint = m_owningLayer->hasVisibleContent() && m_owningLayer->isSelfPaintingLayer(); + bool shouldPaint = (m_owningLayer->hasVisibleContent() || m_owningLayer->hasVisibleDescendant()) && m_owningLayer->isSelfPaintingLayer(); if (shouldPaint && (paintingPhase & GraphicsLayerPaintBackground)) { // If this is the root then we need to send in a bigger bounding box @@ -1082,8 +1080,11 @@ bool RenderLayerBacking::startTransition(double beginTime, int property, const R opacityVector.insert(new FloatAnimationValue(0, compositingOpacity(fromStyle->opacity()))); opacityVector.insert(new FloatAnimationValue(1, compositingOpacity(toStyle->opacity()))); // The boxSize param is only used for transform animations (which can only run on RenderBoxes), so we pass an empty size here. - if (m_graphicsLayer->addAnimation(opacityVector, IntSize(), opacityAnim, String(), beginTime)) + if (m_graphicsLayer->addAnimation(opacityVector, IntSize(), opacityAnim, String(), beginTime)) { + // To ensure that the correct opacity is visible when the animation ends, also set the final opacity. + updateLayerOpacity(toStyle); didAnimate = true; + } } } @@ -1093,8 +1094,11 @@ bool RenderLayerBacking::startTransition(double beginTime, int property, const R KeyframeValueList transformVector(AnimatedPropertyWebkitTransform); transformVector.insert(new TransformAnimationValue(0, &fromStyle->transform())); transformVector.insert(new TransformAnimationValue(1, &toStyle->transform())); - if (m_graphicsLayer->addAnimation(transformVector, toRenderBox(renderer())->borderBoxRect().size(), transformAnim, String(), beginTime)) + if (m_graphicsLayer->addAnimation(transformVector, toRenderBox(renderer())->borderBoxRect().size(), transformAnim, String(), beginTime)) { + // To ensure that the correct transform is visible when the animation ends, also set the final opacity. + updateLayerTransform(toStyle); didAnimate = true; + } } } diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderLayerBacking.h b/src/3rdparty/webkit/WebCore/rendering/RenderLayerBacking.h index e12aa58..17bcaf7 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderLayerBacking.h +++ b/src/3rdparty/webkit/WebCore/rendering/RenderLayerBacking.h @@ -54,7 +54,7 @@ public: RenderLayer* owningLayer() const { return m_owningLayer; } enum UpdateDepth { CompositingChildren, AllDescendants }; - void updateAfterLayout(UpdateDepth); + void updateAfterLayout(UpdateDepth, bool isUpdateRoot); // Returns true if layer configuration changed. bool updateGraphicsLayerConfiguration(); @@ -140,8 +140,8 @@ private: // Result is perspective origin in pixels. FloatPoint computePerspectiveOrigin(const IntRect& borderBox) const; - void updateLayerOpacity(); - void updateLayerTransform(); + void updateLayerOpacity(const RenderStyle*); + void updateLayerTransform(const RenderStyle*); // Return the opacity value that this layer should use for compositing. float compositingOpacity(float rendererOpacity) const; diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderLayerCompositor.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderLayerCompositor.cpp index bcd1f08..5201287 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderLayerCompositor.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderLayerCompositor.cpp @@ -535,6 +535,7 @@ void RenderLayerCompositor::computeCompositingRequirements(RenderLayer* layer, O void RenderLayerCompositor::setCompositingParent(RenderLayer* childLayer, RenderLayer* parentLayer) { + ASSERT(!parentLayer || childLayer->ancestorCompositingLayer() == parentLayer); ASSERT(childLayer->isComposited()); // It's possible to be called with a parent that isn't yet composited when we're doing diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderListBox.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderListBox.cpp index f94f7ce..0edfdef 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderListBox.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderListBox.cpp @@ -508,7 +508,7 @@ bool RenderListBox::listIndexIsVisible(int index) return index >= m_indexOffset && index < m_indexOffset + numVisibleItems(); } -bool RenderListBox::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier) +bool RenderListBox::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Node**) { return m_vBar && m_vBar->scroll(direction, granularity, multiplier); } diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderListBox.h b/src/3rdparty/webkit/WebCore/rendering/RenderListBox.h index e5454e5..aafb87e 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderListBox.h +++ b/src/3rdparty/webkit/WebCore/rendering/RenderListBox.h @@ -68,7 +68,7 @@ private: virtual bool isPointInOverflowControl(HitTestResult&, int x, int y, int tx, int ty); - virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0f); + virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0f, Node** stopNode = 0); virtual void calcPrefWidths(); virtual int baselinePosition(bool firstLine, bool isRootLineBox) const; diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderMediaControls.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderMediaControls.cpp index 0ce0642..9cc1493 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderMediaControls.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderMediaControls.cpp @@ -37,7 +37,7 @@ using namespace std; namespace WebCore { -#if !defined(NDEBUG) && defined(USE_DEBUG_SAFARI_THEME) +#ifdef DEBUG_ALL SOFT_LINK_DEBUG_LIBRARY(SafariTheme) #else SOFT_LINK_LIBRARY(SafariTheme) @@ -82,16 +82,6 @@ void RenderMediaControls::adjustMediaSliderThumbSize(RenderObject* o) o->style()->setHeight(Length(static_cast<int>(mediaSliderThumbHeight * zoomLevel), Fixed)); } -static HTMLMediaElement* parentMediaElement(RenderObject* o) -{ - Node* node = o->node(); - Node* mediaNode = node ? node->shadowAncestorNode() : 0; - if (!mediaNode || (!mediaNode->hasTagName(HTMLNames::videoTag) && !mediaNode->hasTagName(HTMLNames::audioTag))) - return 0; - - return static_cast<HTMLMediaElement*>(mediaNode); -} - bool RenderMediaControls::paintMediaControlsPart(MediaControlElementType part, RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) { ASSERT(SafariThemeLibrary()); @@ -121,7 +111,7 @@ bool RenderMediaControls::paintMediaControlsPart(MediaControlElementType part, R paintThemePart(SafariTheme::MediaSeekForwardButtonPart, paintInfo.context->platformContext(), r, NSRegularControlSize, determineState(o)); break; case MediaSlider: { - if (HTMLMediaElement* mediaElement = parentMediaElement(o)) + if (HTMLMediaElement* mediaElement = toParentMediaElement(o)) STPaintProgressIndicator(SafariTheme::MediaType, paintInfo.context->platformContext(), r, NSRegularControlSize, 0, mediaElement->percentLoaded()); break; } @@ -159,4 +149,3 @@ bool RenderMediaControls::paintMediaControlsPart(MediaControlElementType part, R #endif // #if ENABLE(VIDEO) } // namespace WebCore - diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderMediaControlsChromium.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderMediaControlsChromium.cpp new file mode 100644 index 0000000..ed20ecf --- /dev/null +++ b/src/3rdparty/webkit/WebCore/rendering/RenderMediaControlsChromium.cpp @@ -0,0 +1,287 @@ +/* + * Copyright (C) 2009 Apple Inc. + * Copyright (C) 2009 Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "RenderMediaControlsChromium.h" + +#include "Gradient.h" +#include "GraphicsContext.h" +#include "HTMLMediaElement.h" +#include "HTMLNames.h" + +namespace WebCore { + +#if ENABLE(VIDEO) + +typedef WTF::HashMap<const char*, Image*> MediaControlImageMap; +static MediaControlImageMap* gMediaControlImageMap = 0; + +static Image* platformResource(const char* name) +{ + if (!gMediaControlImageMap) + gMediaControlImageMap = new MediaControlImageMap(); + if (Image* image = gMediaControlImageMap->get(name)) + return image; + if (Image* image = Image::loadPlatformResource(name).releaseRef()) { + gMediaControlImageMap->set(name, image); + return image; + } + ASSERT_NOT_REACHED(); + return 0; +} + +static bool paintMediaButton(GraphicsContext* context, const IntRect& rect, Image* image) +{ + IntRect imageRect = image->rect(); + context->drawImage(image, rect); + return true; +} + +static bool paintMediaMuteButton(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) +{ + HTMLMediaElement* mediaElement = toParentMediaElement(object); + if (!mediaElement) + return false; + + static Image* soundFull = platformResource("mediaSoundFull"); + static Image* soundNone = platformResource("mediaSoundNone"); + static Image* soundDisabled = platformResource("mediaSoundDisabled"); + + if (mediaElement->networkState() == HTMLMediaElement::NETWORK_NO_SOURCE || !mediaElement->hasAudio()) + return paintMediaButton(paintInfo.context, rect, soundDisabled); + + return paintMediaButton(paintInfo.context, rect, mediaElement->muted() ? soundNone: soundFull); +} + +static bool paintMediaPlayButton(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) +{ + HTMLMediaElement* mediaElement = toParentMediaElement(object); + if (!mediaElement) + return false; + + static Image* mediaPlay = platformResource("mediaPlay"); + static Image* mediaPause = platformResource("mediaPause"); + static Image* mediaPlayDisabled = platformResource("mediaPlayDisabled"); + + if (mediaElement->networkState() == HTMLMediaElement::NETWORK_EMPTY || + mediaElement->networkState() == HTMLMediaElement::NETWORK_NO_SOURCE) + return paintMediaButton(paintInfo.context, rect, mediaPlayDisabled); + + return paintMediaButton(paintInfo.context, rect, mediaElement->paused() ? mediaPlay : mediaPause); +} + +static bool paintMediaSlider(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) +{ + HTMLMediaElement* mediaElement = toParentMediaElement(object); + if (!mediaElement) + return false; + + RenderStyle* style = object->style(); + GraphicsContext* context = paintInfo.context; + + // Draw the border of the time bar. + // FIXME: this should be a rounded rect but need to fix GraphicsContextSkia first. + // https://bugs.webkit.org/show_bug.cgi?id=30143 + context->save(); + context->setShouldAntialias(true); + context->setStrokeStyle(SolidStroke); + context->setStrokeColor(style->borderLeftColor()); + context->setStrokeThickness(style->borderLeftWidth()); + context->setFillColor(style->backgroundColor()); + context->drawRect(rect); + context->restore(); + + // Draw the buffered ranges. + // FIXME: Draw multiple ranges if there are multiple buffered ranges. + IntRect bufferedRect = rect; + bufferedRect.inflate(-style->borderLeftWidth()); + bufferedRect.setWidth((bufferedRect.width() * mediaElement->percentLoaded())); + + // Don't bother drawing an empty area. + if (!bufferedRect.isEmpty()) { + IntPoint sliderTopLeft = bufferedRect.location(); + IntPoint sliderTopRight = sliderTopLeft; + sliderTopRight.move(0, bufferedRect.height()); + + RefPtr<Gradient> gradient = Gradient::create(sliderTopLeft, sliderTopRight); + Color startColor = object->style()->color(); + gradient->addColorStop(0.0, startColor); + gradient->addColorStop(1.0, Color(startColor.red() / 2, startColor.green() / 2, startColor.blue() / 2, startColor.alpha())); + + context->save(); + context->setStrokeStyle(NoStroke); + context->setFillGradient(gradient); + context->fillRect(bufferedRect); + context->restore(); + } + + return true; +} + +static bool paintMediaSliderThumb(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) +{ + if (!object->parent()->isSlider()) + return false; + + static Image* mediaSliderThumb = platformResource("mediaSliderThumb"); + return paintMediaButton(paintInfo.context, rect, mediaSliderThumb); +} + +static bool paintMediaVolumeSlider(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) +{ + HTMLMediaElement* mediaElement = toParentMediaElement(object); + if (!mediaElement) + return false; + + GraphicsContext* context = paintInfo.context; + Color originalColor = context->strokeColor(); + if (originalColor != Color::white) + context->setStrokeColor(Color::white); + + int x = rect.x() + rect.width() / 2; + context->drawLine(IntPoint(x, rect.y()), IntPoint(x, rect.y() + rect.height())); + + if (originalColor != Color::white) + context->setStrokeColor(originalColor); + return true; +} + +static bool paintMediaVolumeSliderThumb(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) +{ + if (!object->parent()->isSlider()) + return false; + + static Image* mediaVolumeSliderThumb = platformResource("mediaVolumeSliderThumb"); + return paintMediaButton(paintInfo.context, rect, mediaVolumeSliderThumb); +} + +static bool paintMediaTimelineContainer(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) +{ + HTMLMediaElement* mediaElement = toParentMediaElement(object); + if (!mediaElement) + return false; + + if (!rect.isEmpty()) { + GraphicsContext* context = paintInfo.context; + Color originalColor = context->strokeColor(); + float originalThickness = context->strokeThickness(); + StrokeStyle originalStyle = context->strokeStyle(); + + context->setStrokeStyle(SolidStroke); + + // Draw the left border using CSS defined width and color. + context->setStrokeThickness(object->style()->borderLeftWidth()); + context->setStrokeColor(object->style()->borderLeftColor().rgb()); + context->drawLine(IntPoint(rect.x() + 1, rect.y()), + IntPoint(rect.x() + 1, rect.y() + rect.height())); + + // Draw the right border using CSS defined width and color. + context->setStrokeThickness(object->style()->borderRightWidth()); + context->setStrokeColor(object->style()->borderRightColor().rgb()); + context->drawLine(IntPoint(rect.x() + rect.width() - 1, rect.y()), + IntPoint(rect.x() + rect.width() - 1, rect.y() + rect.height())); + + context->setStrokeColor(originalColor); + context->setStrokeThickness(originalThickness); + context->setStrokeStyle(originalStyle); + } + return true; +} + +bool RenderMediaControlsChromium::shouldRenderMediaControlPart(ControlPart part, Element* e) +{ + UNUSED_PARAM(e); + + switch (part) { + case MediaMuteButtonPart: + case MediaPlayButtonPart: + case MediaSliderPart: + case MediaSliderThumbPart: + case MediaVolumeSliderContainerPart: + case MediaVolumeSliderPart: + case MediaVolumeSliderThumbPart: + case MediaControlsBackgroundPart: + case MediaCurrentTimePart: + case MediaTimeRemainingPart: + return true; + } + return false; +} + +bool RenderMediaControlsChromium::paintMediaControlsPart(MediaControlElementType part, RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) +{ + switch (part) { + case MediaMuteButton: + case MediaUnMuteButton: + return paintMediaMuteButton(object, paintInfo, rect); + case MediaPauseButton: + case MediaPlayButton: + return paintMediaPlayButton(object, paintInfo, rect); + case MediaSlider: + return paintMediaSlider(object, paintInfo, rect); + case MediaSliderThumb: + return paintMediaSliderThumb(object, paintInfo, rect); + case MediaVolumeSlider: + return paintMediaVolumeSlider(object, paintInfo, rect); + case MediaVolumeSliderThumb: + return paintMediaVolumeSliderThumb(object, paintInfo, rect); + case MediaTimelineContainer: + return paintMediaTimelineContainer(object, paintInfo, rect); + case MediaFullscreenButton: + case MediaSeekBackButton: + case MediaSeekForwardButton: + case MediaVolumeSliderContainer: + case MediaCurrentTimeDisplay: + case MediaTimeRemainingDisplay: + case MediaControlsPanel: + ASSERT_NOT_REACHED(); + break; + } + return false; +} + +void RenderMediaControlsChromium::adjustMediaSliderThumbSize(RenderObject* object) +{ + static Image* mediaSliderThumb = platformResource("mediaSliderThumb"); + static Image* mediaVolumeSliderThumb = platformResource("mediaVolumeSliderThumb"); + + Image* thumbImage = 0; + if (object->style()->appearance() == MediaSliderThumbPart) + thumbImage = mediaSliderThumb; + else if (object->style()->appearance() == MediaVolumeSliderThumbPart) + thumbImage = mediaVolumeSliderThumb; + + float zoomLevel = object->style()->effectiveZoom(); + if (thumbImage) { + object->style()->setWidth(Length(static_cast<int>(thumbImage->width() * zoomLevel), Fixed)); + object->style()->setHeight(Length(static_cast<int>(thumbImage->height() * zoomLevel), Fixed)); + } +} + +#endif // #if ENABLE(VIDEO) + +} // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderMediaControlsChromium.h b/src/3rdparty/webkit/WebCore/rendering/RenderMediaControlsChromium.h new file mode 100644 index 0000000..d6d986c --- /dev/null +++ b/src/3rdparty/webkit/WebCore/rendering/RenderMediaControlsChromium.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2009 Apple Inc. + * Copyright (C) 2009 Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef RenderMediaControlsChromium_h +#define RenderMediaControlsChromium_h + +#include "RenderObject.h" +#include "MediaControlElements.h" + +namespace WebCore { + +class HTMLMediaElement; +class RenderMediaControlsChromium { +public: + static bool shouldRenderMediaControlPart(ControlPart, Element*); + static bool paintMediaControlsPart(MediaControlElementType, RenderObject*, const RenderObject::PaintInfo&, const IntRect&); + static void adjustMediaSliderThumbSize(RenderObject*); +}; + +} // namespace WebCore + +#endif // RenderMediaControlsChromium_h diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderObject.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderObject.cpp index b7f59e1..a10ffd9 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderObject.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderObject.cpp @@ -1568,7 +1568,7 @@ void RenderObject::styleWillChange(StyleDifference diff, const RenderStyle* newS // For changes in float styles, we need to conceivably remove ourselves // from the floating objects list. toRenderBox(this)->removeFloatingOrPositionedChildFromBlockLists(); - else if (isPositioned() && (newStyle->position() != AbsolutePosition && newStyle->position() != FixedPosition)) + else if (isPositioned() && (m_style->position() != newStyle->position())) // For changes in positioning styles, we need to conceivably remove ourselves // from the positioned objects list. toRenderBox(this)->removeFloatingOrPositionedChildFromBlockLists(); @@ -1755,6 +1755,23 @@ IntSize RenderObject::offsetFromContainer(RenderObject* o) const return offset; } +IntSize RenderObject::offsetFromAncestorContainer(RenderObject* container) const +{ + IntSize offset; + const RenderObject* currContainer = this; + do { + RenderObject* nextContainer = currContainer->container(); + ASSERT(nextContainer); // This means we reached the top without finding container. + if (!nextContainer) + break; + ASSERT(!currContainer->hasTransform()); + offset += currContainer->offsetFromContainer(nextContainer); + currContainer = nextContainer; + } while (currContainer != container); + + return offset; +} + IntRect RenderObject::localCaretRect(InlineBox*, int, int* extraWidthToEndOfLine) { if (extraWidthToEndOfLine) diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderObject.h b/src/3rdparty/webkit/WebCore/rendering/RenderObject.h index 367eaa6..e358c98 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderObject.h +++ b/src/3rdparty/webkit/WebCore/rendering/RenderObject.h @@ -541,6 +541,8 @@ public: // Return the offset from the container() renderer (excluding transforms) virtual IntSize offsetFromContainer(RenderObject*) const; + // Return the offset from an object up the container() chain. Asserts that none of the intermediate objects have transforms. + IntSize offsetFromAncestorContainer(RenderObject*) const; virtual void absoluteRects(Vector<IntRect>&, int, int) { } // FIXME: useTransforms should go away eventually diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderPartObject.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderPartObject.cpp index 199c0da..e2c8e7d 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderPartObject.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderPartObject.cpp @@ -249,7 +249,8 @@ void RenderPartObject::updateWidget(bool onlyCreateNonNetscapePlugins) return; } - bool success = frame->loader()->requestObject(this, url, o->getAttribute(nameAttr), serviceType, paramNames, paramValues); + bool success = o->dispatchBeforeLoadEvent(url) && + frame->loader()->requestObject(this, url, o->getAttribute(nameAttr), serviceType, paramNames, paramValues); if (!success && m_hasFallbackContent) o->renderFallbackContent(); } else if (node()->hasTagName(embedTag)) { @@ -283,7 +284,8 @@ void RenderPartObject::updateWidget(bool onlyCreateNonNetscapePlugins) } - frame->loader()->requestObject(this, url, o->getAttribute(nameAttr), serviceType, paramNames, paramValues); + if (o->dispatchBeforeLoadEvent(url)) + frame->loader()->requestObject(this, url, o->getAttribute(nameAttr), serviceType, paramNames, paramValues); } #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) else if (node()->hasTagName(videoTag) || node()->hasTagName(audioTag)) { @@ -306,7 +308,9 @@ void RenderPartObject::updateWidget(bool onlyCreateNonNetscapePlugins) } serviceType = "application/x-media-element-proxy-plugin"; - frame->loader()->requestObject(this, url, nullAtom, serviceType, paramNames, paramValues); + + if (o->dispatchBeforeLoadEvent(url)) + frame->loader()->requestObject(this, url, nullAtom, serviceType, paramNames, paramValues); } #endif } diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderSlider.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderSlider.cpp index 247acda..442af39 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderSlider.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderSlider.cpp @@ -50,7 +50,7 @@ static const int defaultTrackLength = 129; struct SliderRange { bool isIntegral; double minimum; - double maximum; + double maximum; // maximum must be >= minimum. explicit SliderRange(HTMLInputElement*); double clampValue(double value); @@ -80,12 +80,8 @@ SliderRange::SliderRange(HTMLInputElement* element) isIntegral = !equalIgnoringCase(element->getAttribute(precisionAttr), "float"); - // FIXME: This treats maximum strings that can't be parsed as 0, but perhaps 100 would be more appropriate. - const AtomicString& maxString = element->getAttribute(maxAttr); - maximum = maxString.isNull() ? 100.0 : maxString.toDouble(); - - // If the maximum is smaller, use it as the minimum. - minimum = min(element->getAttribute(minAttr).toDouble(), maximum); + maximum = element->rangeMaximum(); + minimum = element->rangeMinimum(); } double SliderRange::clampValue(double value) @@ -96,12 +92,14 @@ double SliderRange::clampValue(double value) double SliderRange::valueFromElement(HTMLInputElement* element, bool* wasClamped) { - String valueString = element->value(); - double oldValue = valueString.isNull() ? (minimum + maximum) / 2 : valueString.toDouble(); + double oldValue; + bool parseSuccess = HTMLInputElement::formStringToDouble(element->value(), &oldValue); + if (!parseSuccess) + oldValue = (minimum + maximum) / 2; double newValue = clampValue(oldValue); if (wasClamped) - *wasClamped = valueString.isNull() || newValue != oldValue; + *wasClamped = !parseSuccess || newValue != oldValue; return newValue; } diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderTextControlMultiLine.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderTextControlMultiLine.cpp index 8478432..a49e092 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderTextControlMultiLine.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderTextControlMultiLine.cpp @@ -45,7 +45,9 @@ RenderTextControlMultiLine::~RenderTextControlMultiLine() void RenderTextControlMultiLine::subtreeHasChanged() { RenderTextControl::subtreeHasChanged(); - static_cast<Element*>(node())->setFormControlValueMatchesRenderer(false); + HTMLTextAreaElement* textArea = static_cast<HTMLTextAreaElement*>(node()); + textArea->setFormControlValueMatchesRenderer(false); + textArea->updateValidity(); if (!node()->focused()) return; @@ -53,7 +55,7 @@ void RenderTextControlMultiLine::subtreeHasChanged() node()->dispatchEvent(Event::create(eventNames().inputEvent, true, false)); if (Frame* frame = document()->frame()) - frame->textDidChangeInTextArea(static_cast<Element*>(node())); + frame->textDidChangeInTextArea(textArea); } bool RenderTextControlMultiLine::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int x, int y, int tx, int ty, HitTestAction hitTestAction) diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderTextControlSingleLine.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderTextControlSingleLine.cpp index 8d8ba97..be800a7 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderTextControlSingleLine.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderTextControlSingleLine.cpp @@ -808,12 +808,12 @@ void RenderTextControlSingleLine::setScrollTop(int newTop) innerTextElement()->setScrollTop(newTop); } -bool RenderTextControlSingleLine::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier) +bool RenderTextControlSingleLine::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Node** stopNode) { RenderLayer* layer = innerTextElement()->renderBox()->layer(); if (layer && layer->scroll(direction, granularity, multiplier)) return true; - return RenderBlock::scroll(direction, granularity, multiplier); + return RenderBlock::scroll(direction, granularity, multiplier, stopNode); } PassRefPtr<Scrollbar> RenderTextControlSingleLine::createScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize controlSize) diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderTextControlSingleLine.h b/src/3rdparty/webkit/WebCore/rendering/RenderTextControlSingleLine.h index 4a17918..e30ff0d 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderTextControlSingleLine.h +++ b/src/3rdparty/webkit/WebCore/rendering/RenderTextControlSingleLine.h @@ -72,7 +72,7 @@ private: virtual int scrollHeight() const; virtual void setScrollLeft(int); virtual void setScrollTop(int); - virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0f); + virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0f, Node** stopNode = 0); int textBlockWidth() const; virtual int preferredContentWidth(float charWidth) const; diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderTheme.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderTheme.cpp index b5826cd..5ee01e4 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderTheme.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderTheme.cpp @@ -85,6 +85,7 @@ void RenderTheme::adjustStyle(CSSStyleSelector* selector, RenderStyle* style, El #if USE(NEW_THEME) switch (part) { + case ListButtonPart: case CheckboxPart: case RadioPart: case PushButtonPart: @@ -171,6 +172,7 @@ void RenderTheme::adjustStyle(CSSStyleSelector* selector, RenderStyle* style, El return adjustRadioStyle(selector, style, e); case PushButtonPart: case SquareButtonPart: + case ListButtonPart: case DefaultButtonPart: case ButtonPart: return adjustButtonStyle(selector, style, e); @@ -227,6 +229,7 @@ bool RenderTheme::paint(RenderObject* o, const RenderObject::PaintInfo& paintInf case RadioPart: case PushButtonPart: case SquareButtonPart: + case ListButtonPart: case DefaultButtonPart: case ButtonPart: m_theme->paint(part, controlStatesForRenderer(o), const_cast<GraphicsContext*>(paintInfo.context), r, o->style()->effectiveZoom(), o->view()->frameView()); @@ -245,6 +248,7 @@ bool RenderTheme::paint(RenderObject* o, const RenderObject::PaintInfo& paintInf return paintRadio(o, paintInfo, r); case PushButtonPart: case SquareButtonPart: + case ListButtonPart: case DefaultButtonPart: case ButtonPart: return paintButton(o, paintInfo, r); @@ -335,6 +339,7 @@ bool RenderTheme::paintBorderOnly(RenderObject* o, const RenderObject::PaintInfo case RadioPart: case PushButtonPart: case SquareButtonPart: + case ListButtonPart: case DefaultButtonPart: case ButtonPart: case MenulistPart: @@ -369,6 +374,7 @@ bool RenderTheme::paintDecorations(RenderObject* o, const RenderObject::PaintInf case RadioPart: case PushButtonPart: case SquareButtonPart: + case ListButtonPart: case DefaultButtonPart: case ButtonPart: case MenulistPart: diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderThemeChromiumMac.h b/src/3rdparty/webkit/WebCore/rendering/RenderThemeChromiumMac.h index 9f412a0..61b5e8f 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderThemeChromiumMac.h +++ b/src/3rdparty/webkit/WebCore/rendering/RenderThemeChromiumMac.h @@ -121,6 +121,7 @@ protected: virtual bool paintSearchFieldResultsButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); #if ENABLE(VIDEO) + virtual bool shouldRenderMediaControlPart(ControlPart, Element*); virtual bool paintMediaPlayButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); virtual bool paintMediaMuteButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); virtual bool paintMediaSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderThemeChromiumMac.mm b/src/3rdparty/webkit/WebCore/rendering/RenderThemeChromiumMac.mm index 695f9fa..bcfcd57 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderThemeChromiumMac.mm +++ b/src/3rdparty/webkit/WebCore/rendering/RenderThemeChromiumMac.mm @@ -29,7 +29,6 @@ #import "Document.h" #import "Element.h" #import "FrameView.h" -#import "Gradient.h" #import "GraphicsContext.h" #import "HTMLInputElement.h" #import "HTMLMediaElement.h" @@ -38,6 +37,7 @@ #import "LocalCurrentGraphicsContext.h" #import "MediaControlElements.h" #import "RenderMedia.h" +#import "RenderMediaControlsChromium.h" #import "RenderSlider.h" #import "RenderView.h" #import "SharedBuffer.h" @@ -1251,20 +1251,6 @@ bool RenderThemeChromiumMac::paintSliderThumb(RenderObject* o, const RenderObjec return false; } -#if ENABLE(VIDEO) -static Image* mediaSliderThumbImage() -{ - static Image* mediaSliderThumb = Image::loadPlatformResource("mediaSliderThumb").releaseRef(); - return mediaSliderThumb; -} - -static Image* mediaVolumeSliderThumbImage() -{ - static Image* mediaVolumeSliderThumb = Image::loadPlatformResource("mediaVolumeSliderThumb").releaseRef(); - return mediaVolumeSliderThumb; -} -#endif - void RenderThemeChromiumMac::adjustSliderThumbSize(RenderObject* o) const { static const int sliderThumbWidth = 15; @@ -1277,16 +1263,7 @@ void RenderThemeChromiumMac::adjustSliderThumbSize(RenderObject* o) const } #if ENABLE(VIDEO) - Image* thumbImage = 0; - if (o->style()->appearance() == MediaSliderThumbPart) - thumbImage = mediaSliderThumbImage(); - else if (o->style()->appearance() == MediaVolumeSliderThumbPart) - thumbImage = mediaVolumeSliderThumbImage(); - - if (thumbImage) { - o->style()->setWidth(Length(thumbImage->width(), Fixed)); - o->style()->setHeight(Length(thumbImage->height(), Fixed)); - } + RenderMediaControlsChromium::adjustMediaSliderThumbSize(o); #endif } @@ -1537,173 +1514,44 @@ bool RenderThemeChromiumMac::paintSearchFieldResultsButton(RenderObject* o, cons } #if ENABLE(VIDEO) -// Attempt to retrieve a HTMLMediaElement from a Node. Returns 0 if one cannot be found. -static HTMLMediaElement* mediaElementParent(Node* node) -{ - if (!node) - return 0; - Node* mediaNode = node->shadowAncestorNode(); - if (!mediaNode || (!mediaNode->hasTagName(HTMLNames::videoTag) && !mediaNode->hasTagName(HTMLNames::audioTag))) - return 0; - - return static_cast<HTMLMediaElement*>(mediaNode); -} - -bool RenderThemeChromiumMac::paintMediaButtonInternal(GraphicsContext* context, const IntRect& rect, Image* image) +bool RenderThemeChromiumMac::shouldRenderMediaControlPart(ControlPart part, Element* e) { - // Create a destination rectangle for the image that is centered in the drawing rectangle, rounded left, and down. - IntRect imageRect = image->rect(); - imageRect.setY(rect.y() + (rect.height() - image->height() + 1) / 2); - imageRect.setX(rect.x() + (rect.width() - image->width() + 1) / 2); - - context->drawImage(image, imageRect); - return true; + return RenderMediaControlsChromium::shouldRenderMediaControlPart(part, e); } bool RenderThemeChromiumMac::paintMediaPlayButton(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) { - HTMLMediaElement* mediaElement = mediaElementParent(object->node()); - if (!mediaElement) - return false; - - static Image* mediaPlay = Image::loadPlatformResource("mediaPlay").releaseRef(); - static Image* mediaPause = Image::loadPlatformResource("mediaPause").releaseRef(); - static Image* mediaPlayDisabled = Image::loadPlatformResource("mediaPlayDisabled").releaseRef(); - - if (mediaElement->networkState() == HTMLMediaElement::NETWORK_NO_SOURCE) - return paintMediaButtonInternal(paintInfo.context, rect, mediaPlayDisabled); - - return paintMediaButtonInternal(paintInfo.context, rect, mediaElement->paused() ? mediaPlay : mediaPause); + return RenderMediaControlsChromium::paintMediaControlsPart(MediaPlayButton, object, paintInfo, rect); } bool RenderThemeChromiumMac::paintMediaMuteButton(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) { - HTMLMediaElement* mediaElement = mediaElementParent(object->node()); - if (!mediaElement) - return false; - - static Image* soundFull = Image::loadPlatformResource("mediaSoundFull").releaseRef(); - static Image* soundNone = Image::loadPlatformResource("mediaSoundNone").releaseRef(); - static Image* soundDisabled = Image::loadPlatformResource("mediaSoundDisabled").releaseRef(); - - if (mediaElement->networkState() == HTMLMediaElement::NETWORK_NO_SOURCE || !mediaElement->hasAudio()) - return paintMediaButtonInternal(paintInfo.context, rect, soundDisabled); - - return paintMediaButtonInternal(paintInfo.context, rect, mediaElement->muted() ? soundNone : soundFull); + return RenderMediaControlsChromium::paintMediaControlsPart(MediaMuteButton, object, paintInfo, rect); } bool RenderThemeChromiumMac::paintMediaSliderTrack(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) { - HTMLMediaElement* mediaElement = mediaElementParent(object->node()); - if (!mediaElement) - return false; - - RenderStyle* style = object->style(); - GraphicsContext* context = paintInfo.context; - context->save(); - - context->setShouldAntialias(true); - - IntSize topLeftRadius = style->borderTopLeftRadius(); - IntSize topRightRadius = style->borderTopRightRadius(); - IntSize bottomLeftRadius = style->borderBottomLeftRadius(); - IntSize bottomRightRadius = style->borderBottomRightRadius(); - float borderWidth = style->borderLeftWidth(); - - // Draw the border of the time bar. - context->setStrokeColor(style->borderLeftColor()); - context->setStrokeThickness(borderWidth); - context->setFillColor(style->backgroundColor()); - context->addPath(Path::createRoundedRectangle(rect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius)); - context->drawPath(); - - // Draw the buffered ranges. - // FIXME: Draw multiple ranges if there are multiple buffered ranges. - FloatRect bufferedRect = rect; - bufferedRect.inflate(-1.0 - borderWidth); - bufferedRect.setWidth(bufferedRect.width() * mediaElement->percentLoaded()); - bufferedRect = context->roundToDevicePixels(bufferedRect); - - // Don't bother drawing an empty area. - if (bufferedRect.width() > 0 && bufferedRect.height() > 0) { - FloatPoint sliderTopLeft = bufferedRect.location(); - FloatPoint sliderTopRight = sliderTopLeft; - sliderTopRight.move(0.0f, bufferedRect.height()); - - RefPtr<Gradient> gradient = Gradient::create(sliderTopLeft, sliderTopRight); - Color startColor = object->style()->color(); - gradient->addColorStop(0.0, startColor); - gradient->addColorStop(1.0, Color(startColor.red() / 2, startColor.green() / 2, startColor.blue() / 2, startColor.alpha())); - - context->setFillGradient(gradient); - context->addPath(Path::createRoundedRectangle(bufferedRect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius)); - context->fillPath(); - } - - context->restore(); - return true; + return RenderMediaControlsChromium::paintMediaControlsPart(MediaSlider, object, paintInfo, rect); } bool RenderThemeChromiumMac::paintMediaVolumeSliderTrack(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) { - HTMLMediaElement* mediaElement = mediaElementParent(object->node()); - if (!mediaElement) - return false; - - GraphicsContext* context = paintInfo.context; - Color originalColor = context->strokeColor(); - if (originalColor != Color::white) - context->setStrokeColor(Color::white); - - int x = rect.x() + rect.width() / 2; - context->drawLine(IntPoint(x, rect.y()), IntPoint(x, rect.y() + rect.height())); - - if (originalColor != Color::white) - context->setStrokeColor(originalColor); - return true; + return RenderMediaControlsChromium::paintMediaControlsPart(MediaVolumeSlider, object, paintInfo, rect); } bool RenderThemeChromiumMac::paintMediaSliderThumb(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) { - if (!object->parent()->isSlider()) - return false; - - return paintMediaButtonInternal(paintInfo.context, rect, mediaSliderThumbImage()); + return RenderMediaControlsChromium::paintMediaControlsPart(MediaSliderThumb, object, paintInfo, rect); } bool RenderThemeChromiumMac::paintMediaVolumeSliderThumb(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) { - if (!object->parent()->isSlider()) - return false; - - return paintMediaButtonInternal(paintInfo.context, rect, mediaVolumeSliderThumbImage()); + return RenderMediaControlsChromium::paintMediaControlsPart(MediaVolumeSliderThumb, object, paintInfo, rect); } bool RenderThemeChromiumMac::paintMediaControlsBackground(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) { - HTMLMediaElement* mediaElement = mediaElementParent(object->node()); - if (!mediaElement) - return false; - - if (!rect.isEmpty()) - { - GraphicsContext* context = paintInfo.context; - Color originalColor = context->strokeColor(); - - // Draws the left border, it is always 1px wide. - context->setStrokeColor(object->style()->borderLeftColor()); - context->drawLine(IntPoint(rect.x() + 1, rect.y()), - IntPoint(rect.x() + 1, rect.y() + rect.height())); - - - // Draws the right border, it is always 1px wide. - context->setStrokeColor(object->style()->borderRightColor()); - context->drawLine(IntPoint(rect.x() + rect.width() - 1, rect.y()), - IntPoint(rect.x() + rect.width() - 1, rect.y() + rect.height())); - - context->setStrokeColor(originalColor); - } - return true; + return RenderMediaControlsChromium::paintMediaControlsPart(MediaTimelineContainer, object, paintInfo, rect); } String RenderThemeChromiumMac::extraMediaControlsStyleSheet() diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderThemeChromiumSkia.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderThemeChromiumSkia.cpp index 4f486d5..fb42bb7 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderThemeChromiumSkia.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderThemeChromiumSkia.cpp @@ -33,6 +33,7 @@ #include "MediaControlElements.h" #include "PlatformContextSkia.h" #include "RenderBox.h" +#include "RenderMediaControlsChromium.h" #include "RenderObject.h" #include "RenderSlider.h" #include "ScrollbarTheme.h" @@ -96,20 +97,6 @@ static void drawBox(SkCanvas* canvas, const IntRect& rect, const SkPaint& paint) drawVertLine(canvas, rect.x(), rect.y(), bottom, paint); } -#if ENABLE(VIDEO) -// Attempt to retrieve a HTMLMediaElement from a Node. Returns NULL if one cannot be found. -static HTMLMediaElement* mediaElementParent(Node* node) -{ - if (!node) - return 0; - Node* mediaNode = node->shadowAncestorNode(); - if (!mediaNode || (!mediaNode->hasTagName(HTMLNames::videoTag) && !mediaNode->hasTagName(HTMLNames::audioTag))) - return 0; - - return static_cast<HTMLMediaElement*>(mediaNode); -} -#endif - // We aim to match IE here. // -IE uses a font based on the encoding as the default font for form controls. // -Gecko uses MS Shell Dlg (actually calls GetStockObject(DEFAULT_GUI_FONT), @@ -486,42 +473,10 @@ bool RenderThemeChromiumSkia::paintSearchFieldResultsButton(RenderObject* o, con return false; } -bool RenderThemeChromiumSkia::paintMediaButtonInternal(GraphicsContext* context, const IntRect& rect, Image* image) -{ - // Create a destination rectangle for the image that is centered in the drawing rectangle, rounded left, and down. - IntRect imageRect = image->rect(); - imageRect.setY(rect.y() + (rect.height() - image->height() + 1) / 2); - imageRect.setX(rect.x() + (rect.width() - image->width() + 1) / 2); - - context->drawImage(image, imageRect); - return true; -} - bool RenderThemeChromiumSkia::paintMediaControlsBackground(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) { #if ENABLE(VIDEO) - HTMLMediaElement* mediaElement = mediaElementParent(object->node()); - if (!mediaElement) - return false; - - if (!rect.isEmpty()) - { - SkCanvas* canvas = paintInfo.context->platformContext()->canvas(); - SkPaint paint; - - // Draws the left border, it is always 1px wide. - paint.setColor(object->style()->borderLeftColor().rgb()); - canvas->drawLine(rect.x() + 1, rect.y(), - rect.x() + 1, rect.y() + rect.height(), - paint); - - // Draws the right border, it is always 1px wide. - paint.setColor(object->style()->borderRightColor().rgb()); - canvas->drawLine(rect.x() + rect.width() - 1, rect.y(), - rect.x() + rect.width() - 1, rect.y() + rect.height(), - paint); - } - return true; + return RenderMediaControlsChromium::paintMediaControlsPart(MediaTimelineContainer, object, paintInfo, rect); #else UNUSED_PARAM(object); UNUSED_PARAM(paintInfo); @@ -533,62 +488,7 @@ bool RenderThemeChromiumSkia::paintMediaControlsBackground(RenderObject* object, bool RenderThemeChromiumSkia::paintMediaSliderTrack(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) { #if ENABLE(VIDEO) - HTMLMediaElement* mediaElement = mediaElementParent(object->node()); - if (!mediaElement) - return false; - - SkCanvas* canvas = paintInfo.context->platformContext()->canvas(); - SkRect backgroundRect; - backgroundRect.set(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height()); - - SkPaint paint; - paint.setAntiAlias(true); - - // Draw the border of the time bar. The border only has one single color, - // width and radius. So use the property of the left border. - SkColor borderColor = object->style()->borderLeftColor().rgb(); - int borderWidth = object->style()->borderLeftWidth(); - IntSize borderRadius = object->style()->borderTopLeftRadius(); - paint.setStyle(SkPaint::kStroke_Style); - paint.setStrokeWidth(borderWidth); - paint.setColor(borderColor); - canvas->drawRoundRect(backgroundRect, borderRadius.width(), borderRadius.height(), paint); - - // Draw the background of the time bar. - SkColor backgroundColor = object->style()->backgroundColor().rgb(); - paint.setStyle(SkPaint::kFill_Style); - paint.setColor(backgroundColor); - canvas->drawRoundRect(backgroundRect, borderRadius.width(), borderRadius.height(), paint); - - if (backgroundRect.width() >= 3 && backgroundRect.height() >= 3) - { - // Draw the buffered ranges. - // FIXME: Draw multiple ranges if there are multiple buffered ranges. - SkRect bufferedRect; - bufferedRect.set(backgroundRect.fLeft + 2, backgroundRect.fTop + 2, - backgroundRect.fRight - 1, backgroundRect.fBottom - 1); - int width = static_cast<int>(bufferedRect.width() * mediaElement->percentLoaded()); - bufferedRect.fRight = bufferedRect.fLeft + width; - - SkPoint points[2] = { { 0, bufferedRect.fTop }, { 0, bufferedRect.fBottom } }; - SkColor startColor = object->style()->color().rgb(); - SkColor endColor = SkColorSetRGB(SkColorGetR(startColor) / 2, - SkColorGetG(startColor) / 2, - SkColorGetB(startColor) / 2); - SkColor colors[2] = { startColor, endColor }; - SkShader* gradient = SkGradientShader::CreateLinear(points, colors, 0, - sizeof(points) / sizeof(points[0]), - SkShader::kMirror_TileMode, 0); - - paint.reset(); - paint.setShader(gradient); - paint.setAntiAlias(true); - // Check for round rect with zero width or height, otherwise Skia will assert - if (bufferedRect.width() > 0 && bufferedRect.height() > 0) - canvas->drawRoundRect(bufferedRect, borderRadius.width(), borderRadius.height(), paint); - gradient->unref(); - } - return true; + return RenderMediaControlsChromium::paintMediaControlsPart(MediaSlider, object, paintInfo, rect); #else UNUSED_PARAM(object); UNUSED_PARAM(paintInfo); @@ -600,17 +500,7 @@ bool RenderThemeChromiumSkia::paintMediaSliderTrack(RenderObject* object, const bool RenderThemeChromiumSkia::paintMediaVolumeSliderTrack(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) { #if ENABLE(VIDEO) - HTMLMediaElement* mediaElement = mediaElementParent(object->node()); - if (!mediaElement) - return false; - - SkCanvas* canvas = paintInfo.context->platformContext()->canvas(); - SkPaint paint; - paint.setColor(SK_ColorWHITE); - - int x = rect.x() + rect.width() / 2; - canvas->drawLine(x, rect.y(), x, rect.y() + rect.height(), paint); - return true; + return RenderMediaControlsChromium::paintMediaControlsPart(MediaVolumeSlider, object, paintInfo, rect); #else UNUSED_PARAM(object); UNUSED_PARAM(paintInfo); @@ -619,31 +509,10 @@ bool RenderThemeChromiumSkia::paintMediaVolumeSliderTrack(RenderObject* object, #endif } -static Image* mediaSliderThumbImage() -{ - static Image* mediaSliderThumb = Image::loadPlatformResource("mediaSliderThumb").releaseRef(); - return mediaSliderThumb; -} - -static Image* mediaVolumeSliderThumbImage() -{ - static Image* mediaVolumeSliderThumb = Image::loadPlatformResource("mediaVolumeSliderThumb").releaseRef(); - return mediaVolumeSliderThumb; -} - void RenderThemeChromiumSkia::adjustSliderThumbSize(RenderObject* object) const { #if ENABLE(VIDEO) - Image* thumbImage = 0; - if (object->style()->appearance() == MediaSliderThumbPart) - thumbImage = mediaSliderThumbImage(); - else if (object->style()->appearance() == MediaVolumeSliderThumbPart) - thumbImage = mediaVolumeSliderThumbImage(); - - if (thumbImage) { - object->style()->setWidth(Length(thumbImage->width(), Fixed)); - object->style()->setHeight(Length(thumbImage->height(), Fixed)); - } + RenderMediaControlsChromium::adjustMediaSliderThumbSize(object); #else UNUSED_PARAM(object); #endif @@ -652,10 +521,7 @@ void RenderThemeChromiumSkia::adjustSliderThumbSize(RenderObject* object) const bool RenderThemeChromiumSkia::paintMediaSliderThumb(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) { #if ENABLE(VIDEO) - if (!object->parent()->isSlider()) - return false; - - return paintMediaButtonInternal(paintInfo.context, rect, mediaSliderThumbImage()); + return RenderMediaControlsChromium::paintMediaControlsPart(MediaSliderThumb, object, paintInfo, rect); #else UNUSED_PARAM(object); UNUSED_PARAM(paintInfo); @@ -667,10 +533,7 @@ bool RenderThemeChromiumSkia::paintMediaSliderThumb(RenderObject* object, const bool RenderThemeChromiumSkia::paintMediaVolumeSliderThumb(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) { #if ENABLE(VIDEO) - if (!object->parent()->isSlider()) - return false; - - return paintMediaButtonInternal(paintInfo.context, rect, mediaVolumeSliderThumbImage()); + return RenderMediaControlsChromium::paintMediaControlsPart(MediaVolumeSliderThumb, object, paintInfo, rect); #else UNUSED_PARAM(object); UNUSED_PARAM(paintInfo); @@ -682,18 +545,7 @@ bool RenderThemeChromiumSkia::paintMediaVolumeSliderThumb(RenderObject* object, bool RenderThemeChromiumSkia::paintMediaPlayButton(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) { #if ENABLE(VIDEO) - HTMLMediaElement* mediaElement = mediaElementParent(object->node()); - if (!mediaElement) - return false; - - static Image* mediaPlay = Image::loadPlatformResource("mediaPlay").releaseRef(); - static Image* mediaPause = Image::loadPlatformResource("mediaPause").releaseRef(); - static Image* mediaPlayDisabled = Image::loadPlatformResource("mediaPlayDisabled").releaseRef(); - - if (mediaElement->networkState() == HTMLMediaElement::NETWORK_NO_SOURCE) - return paintMediaButtonInternal(paintInfo.context, rect, mediaPlayDisabled); - - return paintMediaButtonInternal(paintInfo.context, rect, mediaElement->paused() ? mediaPlay : mediaPause); + return RenderMediaControlsChromium::paintMediaControlsPart(MediaPlayButton, object, paintInfo, rect); #else UNUSED_PARAM(object); UNUSED_PARAM(paintInfo); @@ -705,18 +557,7 @@ bool RenderThemeChromiumSkia::paintMediaPlayButton(RenderObject* object, const R bool RenderThemeChromiumSkia::paintMediaMuteButton(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) { #if ENABLE(VIDEO) - HTMLMediaElement* mediaElement = mediaElementParent(object->node()); - if (!mediaElement) - return false; - - static Image* soundFull = Image::loadPlatformResource("mediaSoundFull").releaseRef(); - static Image* soundNone = Image::loadPlatformResource("mediaSoundNone").releaseRef(); - static Image* soundDisabled = Image::loadPlatformResource("mediaSoundDisabled").releaseRef(); - - if (mediaElement->networkState() == HTMLMediaElement::NETWORK_NO_SOURCE || !mediaElement->hasAudio()) - return paintMediaButtonInternal(paintInfo.context, rect, soundDisabled); - - return paintMediaButtonInternal(paintInfo.context, rect, mediaElement->muted() ? soundNone: soundFull); + return RenderMediaControlsChromium::paintMediaControlsPart(MediaMuteButton, object, paintInfo, rect); #else UNUSED_PARAM(object); UNUSED_PARAM(paintInfo); @@ -744,8 +585,9 @@ bool RenderThemeChromiumSkia::paintMenuList(RenderObject* o, const RenderObject: paint.setAntiAlias(true); paint.setStyle(SkPaint::kFill_Style); + int arrowXPosition = (o->style()->direction() == RTL) ? rect.x() + 7 : right - 13; SkPath path; - path.moveTo(right - 13, middle - 3); + path.moveTo(arrowXPosition, middle - 3); path.rLineTo(6, 0); path.rLineTo(-3, 6); path.close(); @@ -871,13 +713,7 @@ int RenderThemeChromiumSkia::buttonInternalPaddingBottom() const #if ENABLE(VIDEO) bool RenderThemeChromiumSkia::shouldRenderMediaControlPart(ControlPart part, Element* e) { - HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(e); - switch (part) { - case MediaMuteButtonPart: - return true; - default: - return RenderTheme::shouldRenderMediaControlPart(part, e); - } + return RenderMediaControlsChromium::shouldRenderMediaControlPart(part, e); } #endif diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderThemeChromiumWin.h b/src/3rdparty/webkit/WebCore/rendering/RenderThemeChromiumWin.h index bbc54a7..3b86980 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderThemeChromiumWin.h +++ b/src/3rdparty/webkit/WebCore/rendering/RenderThemeChromiumWin.h @@ -59,7 +59,7 @@ namespace WebCore { // System fonts. virtual void systemFont(int propId, FontDescription&) const; - virtual Color systemColor(int cssValueId) const; + virtual Color systemColor(int cssValueId) const;
virtual void adjustSliderThumbSize(RenderObject*) const; diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderThemeMac.h b/src/3rdparty/webkit/WebCore/rendering/RenderThemeMac.h index 85f141f..1d68c63 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderThemeMac.h +++ b/src/3rdparty/webkit/WebCore/rendering/RenderThemeMac.h @@ -132,6 +132,8 @@ protected: // Media controls virtual String extraMediaControlsStyleSheet(); + + virtual bool shouldRenderMediaControlPart(ControlPart, Element*); #endif private: diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderThemeSafari.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderThemeSafari.cpp index 8e53088..2ea3b8b 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderThemeSafari.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderThemeSafari.cpp @@ -86,7 +86,7 @@ PassRefPtr<RenderTheme> RenderTheme::themeForPage(Page* page) return safariTheme; // keep the reference of one. } -#if !defined(NDEBUG) && defined(USE_DEBUG_SAFARI_THEME) +#ifdef DEBUG_ALL SOFT_LINK_DEBUG_LIBRARY(SafariTheme) #else SOFT_LINK_LIBRARY(SafariTheme) diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderWidget.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderWidget.cpp index ef78b07..9af7137 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderWidget.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderWidget.cpp @@ -175,6 +175,12 @@ void RenderWidget::styleDidChange(StyleDifference diff, const RenderStyle* oldSt } } +void RenderWidget::showSubstituteImage(PassRefPtr<Image> prpImage) +{ + m_substituteImage = prpImage; + repaint(); +} + void RenderWidget::paint(PaintInfo& paintInfo, int tx, int ty) { if (!shouldPaint(paintInfo, tx, ty)) @@ -222,7 +228,10 @@ void RenderWidget::paint(PaintInfo& paintInfo, int tx, int ty) // Tell the widget to paint now. This is the only time the widget is allowed // to paint itself. That way it will composite properly with z-indexed layers. - m_widget->paint(paintInfo.context, paintInfo.rect); + if (m_substituteImage) + paintInfo.context->drawImage(m_substituteImage.get(), m_widget->frameRect()); + else + m_widget->paint(paintInfo.context, paintInfo.rect); if (m_widget->isFrameView() && paintInfo.overlapTestRequests && !static_cast<FrameView*>(m_widget.get())->useSlowRepaints()) { ASSERT(!paintInfo.overlapTestRequests->contains(this)); diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderWidget.h b/src/3rdparty/webkit/WebCore/rendering/RenderWidget.h index 098f69e..78537fd 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderWidget.h +++ b/src/3rdparty/webkit/WebCore/rendering/RenderWidget.h @@ -40,6 +40,8 @@ public: void updateWidgetPosition(); + void showSubstituteImage(PassRefPtr<Image>); + protected: RenderWidget(Node*); @@ -66,6 +68,7 @@ private: void deref(RenderArena*); RefPtr<Widget> m_widget; + RefPtr<Image> m_substituteImage; FrameView* m_frameView; int m_refCount; }; diff --git a/src/3rdparty/webkit/WebCore/rendering/SVGRenderSupport.cpp b/src/3rdparty/webkit/WebCore/rendering/SVGRenderSupport.cpp index fb6866f..0f295e4 100644 --- a/src/3rdparty/webkit/WebCore/rendering/SVGRenderSupport.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/SVGRenderSupport.cpp @@ -220,7 +220,7 @@ FloatRect SVGRenderBase::filterBoundingBoxForRenderer(const RenderObject* object #if ENABLE(FILTERS) SVGResourceFilter* filter = getFilterById(object->document(), object->style()->svgStyle()->filter()); if (filter) - return filter->filterBBoxForItemBBox(object->objectBoundingBox()); + return filter->filterBoundingBox(); #else UNUSED_PARAM(object); #endif diff --git a/src/3rdparty/webkit/WebCore/rendering/style/RenderStyle.h b/src/3rdparty/webkit/WebCore/rendering/style/RenderStyle.h index be5d1cf..1e1688c 100644 --- a/src/3rdparty/webkit/WebCore/rendering/style/RenderStyle.h +++ b/src/3rdparty/webkit/WebCore/rendering/style/RenderStyle.h @@ -462,7 +462,7 @@ public: return font().lineSpacing(); if (lh.isPercent()) - return lh.calcMinValue(fontSize()); + return lh.calcMinValue(fontSize(), true); return lh.value(); } diff --git a/src/3rdparty/webkit/WebCore/rendering/style/RenderStyleConstants.h b/src/3rdparty/webkit/WebCore/rendering/style/RenderStyleConstants.h index a47defb..3010947 100644 --- a/src/3rdparty/webkit/WebCore/rendering/style/RenderStyleConstants.h +++ b/src/3rdparty/webkit/WebCore/rendering/style/RenderStyleConstants.h @@ -72,6 +72,7 @@ enum PseudoId { MEDIA_CONTROLS_VOLUME_SLIDER, MEDIA_CONTROLS_VOLUME_SLIDER_CONTAINER, MEDIA_CONTROLS_CURRENT_TIME_DISPLAY, MEDIA_CONTROLS_TIME_REMAINING_DISPLAY, MEDIA_CONTROLS_SEEK_BACK_BUTTON, MEDIA_CONTROLS_SEEK_FORWARD_BUTTON, MEDIA_CONTROLS_FULLSCREEN_BUTTON, MEDIA_CONTROLS_REWIND_BUTTON, MEDIA_CONTROLS_RETURN_TO_REALTIME_BUTTON, MEDIA_CONTROLS_STATUS_DISPLAY, SCROLLBAR_THUMB, SCROLLBAR_BUTTON, SCROLLBAR_TRACK, SCROLLBAR_TRACK_PIECE, SCROLLBAR_CORNER, RESIZER, + INPUT_LIST_BUTTON, FIRST_INTERNAL_PSEUDOID = FILE_UPLOAD_BUTTON }; diff --git a/src/3rdparty/webkit/WebCore/rendering/style/SVGRenderStyle.h b/src/3rdparty/webkit/WebCore/rendering/style/SVGRenderStyle.h index 0e9dae4..e50d349 100644 --- a/src/3rdparty/webkit/WebCore/rendering/style/SVGRenderStyle.h +++ b/src/3rdparty/webkit/WebCore/rendering/style/SVGRenderStyle.h @@ -65,7 +65,6 @@ namespace WebCore { SVG_RS_DEFINE_ATTRIBUTE_INHERITED(LineJoin, JoinStyle, joinStyle, MiterJoin) SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EShapeRendering, ShapeRendering, shapeRendering, SR_AUTO) SVG_RS_DEFINE_ATTRIBUTE_INHERITED(ETextAnchor, TextAnchor, textAnchor, TA_START) - SVG_RS_DEFINE_ATTRIBUTE_INHERITED(ETextRendering, TextRendering, textRendering, TR_AUTO) SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EWritingMode, WritingMode, writingMode, WM_LRTB) SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EGlyphOrientation, GlyphOrientationHorizontal, glyphOrientationHorizontal, GO_0DEG) SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EGlyphOrientation, GlyphOrientationVertical, glyphOrientationVertical, GO_AUTO) @@ -113,7 +112,6 @@ namespace WebCore { return (_colorRendering == other._colorRendering) && (_imageRendering == other._imageRendering) && (_shapeRendering == other._shapeRendering) && - (_textRendering == other._textRendering) && (_clipRule == other._clipRule) && (_fillRule == other._fillRule) && (_capStyle == other._capStyle) && @@ -134,7 +132,6 @@ namespace WebCore { unsigned _colorRendering : 2; // EColorRendering unsigned _imageRendering : 2; // EImageRendering unsigned _shapeRendering : 2; // EShapeRendering - unsigned _textRendering : 2; // ETextRendering unsigned _clipRule : 1; // WindRule unsigned _fillRule : 1; // WindRule unsigned _capStyle : 2; // LineCap @@ -190,7 +187,6 @@ namespace WebCore { svg_inherited_flags._fillRule = initialFillRule(); svg_inherited_flags._imageRendering = initialImageRendering(); svg_inherited_flags._shapeRendering = initialShapeRendering(); - svg_inherited_flags._textRendering = initialTextRendering(); svg_inherited_flags._textAnchor = initialTextAnchor(); svg_inherited_flags._capStyle = initialCapStyle(); svg_inherited_flags._joinStyle = initialJoinStyle(); diff --git a/src/3rdparty/webkit/WebCore/rendering/style/SVGRenderStyleDefs.h b/src/3rdparty/webkit/WebCore/rendering/style/SVGRenderStyleDefs.h index b7bf026..c0f5d4e 100644 --- a/src/3rdparty/webkit/WebCore/rendering/style/SVGRenderStyleDefs.h +++ b/src/3rdparty/webkit/WebCore/rendering/style/SVGRenderStyleDefs.h @@ -95,10 +95,6 @@ namespace WebCore { SR_AUTO, SR_OPTIMIZESPEED, SR_CRISPEDGES, SR_GEOMETRICPRECISION }; - enum ETextRendering { - TR_AUTO, TR_OPTIMIZESPEED, TR_OPTIMIZELEGIBILITY, TR_GEOMETRICPRECISION - }; - enum EWritingMode { WM_LRTB, WM_LR, WM_RLTB, WM_RL, WM_TBRL, WM_TB }; |