diff options
Diffstat (limited to 'Source/WebCore/rendering')
175 files changed, 3710 insertions, 1021 deletions
diff --git a/Source/WebCore/rendering/CounterNode.cpp b/Source/WebCore/rendering/CounterNode.cpp index ac83d5a..fe2148a 100644 --- a/Source/WebCore/rendering/CounterNode.cpp +++ b/Source/WebCore/rendering/CounterNode.cpp @@ -247,9 +247,9 @@ static void showTreeAndMark(const CounterNode* node) root = root->parent(); for (const CounterNode* current = root; current; current = current->nextInPreOrder()) { - fwrite((current == node) ? "*" : " ", 1, 1, stderr); + fprintf(stderr, "%c", (current == node) ? '*' : ' '); for (const CounterNode* parent = current; parent && parent != root; parent = parent->parent()) - fwrite(" ", 1, 2, stderr); + fprintf(stderr, " "); fprintf(stderr, "%p %s: %d %d P:%p PS:%p NS:%p R:%p\n", current, current->actsAsReset() ? "reset____" : "increment", current->value(), current->countInParent(), current->parent(), current->previousSibling(), diff --git a/Source/WebCore/rendering/EllipsisBox.cpp b/Source/WebCore/rendering/EllipsisBox.cpp index f9c4f03..39fa205 100644 --- a/Source/WebCore/rendering/EllipsisBox.cpp +++ b/Source/WebCore/rendering/EllipsisBox.cpp @@ -23,6 +23,7 @@ #include "Document.h" #include "GraphicsContext.h" #include "HitTestResult.h" +#include "PaintInfo.h" #include "RootInlineBox.h" namespace WebCore { diff --git a/Source/WebCore/rendering/InlineBox.cpp b/Source/WebCore/rendering/InlineBox.cpp index 145096b..bbf5a748 100644 --- a/Source/WebCore/rendering/InlineBox.cpp +++ b/Source/WebCore/rendering/InlineBox.cpp @@ -22,6 +22,7 @@ #include "HitTestResult.h" #include "InlineFlowBox.h" +#include "PaintInfo.h" #include "RenderArena.h" #include "RenderBlock.h" #include "RootInlineBox.h" diff --git a/Source/WebCore/rendering/InlineFlowBox.h b/Source/WebCore/rendering/InlineFlowBox.h index 63263fd..232c3b7 100644 --- a/Source/WebCore/rendering/InlineFlowBox.h +++ b/Source/WebCore/rendering/InlineFlowBox.h @@ -23,6 +23,7 @@ #include "InlineBox.h" #include "RenderOverflow.h" +#include "ShadowData.h" namespace WebCore { diff --git a/Source/WebCore/rendering/InlineTextBox.cpp b/Source/WebCore/rendering/InlineTextBox.cpp index aa00b7f..ae5be0f 100644 --- a/Source/WebCore/rendering/InlineTextBox.cpp +++ b/Source/WebCore/rendering/InlineTextBox.cpp @@ -33,6 +33,7 @@ #include "GraphicsContext.h" #include "HitTestResult.h" #include "Page.h" +#include "PaintInfo.h" #include "RenderArena.h" #include "RenderBlock.h" #include "RenderRubyRun.h" diff --git a/Source/WebCore/rendering/MediaControlElements.cpp b/Source/WebCore/rendering/MediaControlElements.cpp index accbf4f..1f66719 100644 --- a/Source/WebCore/rendering/MediaControlElements.cpp +++ b/Source/WebCore/rendering/MediaControlElements.cpp @@ -449,6 +449,12 @@ void MediaControlInputElement::attach() parentNode()->renderer()->addChild(renderer, sibling ? sibling->renderer() : 0); } ContainerNode::attach(); + // FIXME: Currently, MeidaControlInput circumvents the normal attachment + // and style recalc cycle and thus we need to add extra logic to be aware of + // the shadow DOM. Remove this once all media controls are transitioned to use the regular + // style calculation. + if (Node* shadowNode = shadowRoot()) + shadowNode->attach(); } void MediaControlInputElement::updateStyle() @@ -467,6 +473,13 @@ void MediaControlInputElement::updateStyle() attach(); else if (renderer()) renderer()->setStyle(style.get()); + + // FIXME: Currently, MeidaControlInput circumvents the normal attachment + // and style recalc cycle and thus we need to add extra logic to be aware of + // the shadow DOM. Remove this once all media controls are transitioned to use + // the new shadow DOM. + if (Node* shadowNode = shadowRoot()) + shadowNode->recalcStyle(Node::Force); } bool MediaControlInputElement::hitTest(const IntPoint& absPoint) diff --git a/Source/WebCore/rendering/RenderBlock.cpp b/Source/WebCore/rendering/RenderBlock.cpp index e0fe6a0..794bafc 100644 --- a/Source/WebCore/rendering/RenderBlock.cpp +++ b/Source/WebCore/rendering/RenderBlock.cpp @@ -35,6 +35,7 @@ #include "HTMLNames.h" #include "HitTestResult.h" #include "InlineTextBox.h" +#include "PaintInfo.h" #include "RenderFlexibleBox.h" #include "RenderImage.h" #include "RenderInline.h" @@ -116,6 +117,7 @@ RenderBlock::RenderBlock(Node* node) , m_positionedObjects(0) , m_rareData(0) , m_lineHeight(-1) + , m_beingDestroyed(false) { setChildrenInline(true); } @@ -150,6 +152,9 @@ RenderBlock::~RenderBlock() void RenderBlock::destroy() { + // Mark as being destroyed to avoid trouble with merges in removeChild(). + m_beingDestroyed = true; + // Make sure to destroy anonymous children first while they are still connected to the rest of the tree, so that they will // properly dirty line boxes that they are removed from. Effects that do :before/:after only on hover could crash otherwise. children()->destroyLeftoverChildren(); @@ -192,7 +197,7 @@ void RenderBlock::destroy() void RenderBlock::styleWillChange(StyleDifference diff, const RenderStyle* newStyle) { - setReplaced(newStyle->isDisplayReplacedType()); + setReplaced(newStyle->isDisplayInlineType()); if (style() && parent() && diff == StyleDifferenceLayout && style()->position() != newStyle->position()) { if (newStyle->position() == StaticPosition) @@ -930,8 +935,8 @@ static bool canMergeContiguousAnonymousBlocks(RenderObject* oldChild, RenderObje if (oldChild->documentBeingDestroyed() || oldChild->isInline() || oldChild->virtualContinuation()) return false; - if ((prev && (!prev->isAnonymousBlock() || toRenderBlock(prev)->continuation())) - || (next && (!next->isAnonymousBlock() || toRenderBlock(next)->continuation()))) + if ((prev && (!prev->isAnonymousBlock() || toRenderBlock(prev)->continuation() || toRenderBlock(prev)->beingDestroyed())) + || (next && (!next->isAnonymousBlock() || toRenderBlock(next)->continuation() || toRenderBlock(next)->beingDestroyed()))) return false; // FIXME: This check isn't required when inline run-ins can't be split into continuations. @@ -991,27 +996,12 @@ void RenderBlock::removeChild(RenderObject* oldChild) } else { // Take all the children out of the |next| block and put them in // the |prev| block. - nextBlock->moveAllChildrenTo(prevBlock, nextBlock->hasLayer() || prevBlock->hasLayer()); - - // FIXME: When we destroy nextBlock, it might happen that nextBlock's next sibling block and - // oldChild can get merged. Since oldChild is getting removed, we do not want to move - // nextBlock's next sibling block's children into it. By setting a fake continuation, - // we prevent this from happening. This is not the best approach, we should replace this - // something better later to automatically detect that oldChild is getting removed. - RenderBlock* oldChildBlock = 0; - if (oldChild->isAnonymous() && oldChild->isRenderBlock() && !toRenderBlock(oldChild)->continuation()) { - oldChildBlock = toRenderBlock(oldChild); - oldChildBlock->setContinuation(oldChildBlock); - } + nextBlock->moveAllChildrenTo(prevBlock, nextBlock->hasLayer() || prevBlock->hasLayer()); // Delete the now-empty block's lines and nuke it. nextBlock->deleteLineBoxTree(); nextBlock->destroy(); next = 0; - - // FIXME: Revert the continuation change done above. - if (oldChildBlock) - oldChildBlock->setContinuation(0); } } diff --git a/Source/WebCore/rendering/RenderBlock.h b/Source/WebCore/rendering/RenderBlock.h index bd8be2c..9529bd6 100644 --- a/Source/WebCore/rendering/RenderBlock.h +++ b/Source/WebCore/rendering/RenderBlock.h @@ -38,6 +38,7 @@ class LayoutStateMaintainer; class RenderInline; struct BidiRun; +struct PaintInfo; template <class Iterator, class Run> class BidiResolver; template <class Iterator> struct MidpointState; @@ -55,6 +56,7 @@ public: RenderObjectChildList* children() { return &m_children; } virtual void destroy(); + bool beingDestroyed() const { return m_beingDestroyed; } // These two functions are overridden for inline-block. virtual int lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; @@ -712,7 +714,8 @@ private: RenderObjectChildList m_children; RenderLineBoxList m_lineBoxes; // All of the root line boxes created for this block flow. For example, <div>Hello<br>world.</div> will have two total lines for the <div>. - mutable int m_lineHeight; + mutable int m_lineHeight : 31; + bool m_beingDestroyed : 1; // RenderRubyBase objects need to be able to split and merge, moving their children around // (calling moveChildTo, moveAllChildrenTo, and makeChildrenNonInline). diff --git a/Source/WebCore/rendering/RenderBox.cpp b/Source/WebCore/rendering/RenderBox.cpp index 355d385..93228e1 100644 --- a/Source/WebCore/rendering/RenderBox.cpp +++ b/Source/WebCore/rendering/RenderBox.cpp @@ -39,9 +39,13 @@ #include "FloatQuad.h" #include "Frame.h" #include "Page.h" +<<<<<<< HEAD #if PLATFORM(ANDROID) #include "PlatformBridge.h" #endif +======= +#include "PaintInfo.h" +>>>>>>> WebKit.org @ r75993 #include "RenderArena.h" #include "RenderFlexibleBox.h" #include "RenderInline.h" @@ -227,26 +231,30 @@ void RenderBox::removeFloatingOrPositionedChildFromBlockLists() return; if (isFloating()) { - RenderBlock* outermostBlock = containingBlock(); - for (RenderBlock* p = outermostBlock; p && !p->isRenderView(); p = p->containingBlock()) { - if (p->containsFloat(this)) - outermostBlock = p; + RenderBlock* parentBlock = 0; + for (RenderObject* curr = parent(); curr && !curr->isRenderView(); curr = curr->parent()) { + if (curr->isRenderBlock()) { + RenderBlock* currBlock = toRenderBlock(curr); + if (currBlock->containsFloat(this)) + parentBlock = currBlock; + else + break; + } } - if (outermostBlock) { - RenderObject* parent = outermostBlock->parent(); + if (parentBlock) { + RenderObject* parent = parentBlock->parent(); if (parent && parent->isFlexibleBox()) - outermostBlock = toRenderBlock(parent); + parentBlock = toRenderBlock(parent); - outermostBlock->markAllDescendantsWithFloatsForLayout(this, false); + parentBlock->markAllDescendantsWithFloatsForLayout(this, false); } } if (isPositioned()) { - RenderObject* p; - for (p = parent(); p; p = p->parent()) { - if (p->isRenderBlock()) - toRenderBlock(p)->removePositionedObject(this); + for (RenderObject* curr = parent(); curr; curr = curr->parent()) { + if (curr->isRenderBlock()) + toRenderBlock(curr)->removePositionedObject(this); } } } diff --git a/Source/WebCore/rendering/RenderBox.h b/Source/WebCore/rendering/RenderBox.h index 53a4cfe..0a7b175 100644 --- a/Source/WebCore/rendering/RenderBox.h +++ b/Source/WebCore/rendering/RenderBox.h @@ -29,6 +29,8 @@ namespace WebCore { +struct PaintInfo; + enum LogicalWidthType { LogicalWidth, MinLogicalWidth, MaxLogicalWidth }; class RenderBox : public RenderBoxModelObject { diff --git a/Source/WebCore/rendering/RenderBoxModelObject.h b/Source/WebCore/rendering/RenderBoxModelObject.h index 98e386b..8f9f465 100644 --- a/Source/WebCore/rendering/RenderBoxModelObject.h +++ b/Source/WebCore/rendering/RenderBoxModelObject.h @@ -25,6 +25,7 @@ #define RenderBoxModelObject_h #include "RenderObject.h" +#include "ShadowData.h" namespace WebCore { diff --git a/Source/WebCore/rendering/RenderButton.cpp b/Source/WebCore/rendering/RenderButton.cpp index 2642f23..4bf7c19 100644 --- a/Source/WebCore/rendering/RenderButton.cpp +++ b/Source/WebCore/rendering/RenderButton.cpp @@ -92,7 +92,6 @@ void RenderButton::styleDidChange(StyleDifference diff, const RenderStyle* oldSt m_buttonText->setStyle(style()); if (m_inner) // RenderBlock handled updating the anonymous block's style. setupInnerStyle(m_inner->style()); - setReplaced(isInline()); if (!m_default && theme()->isDefault(this)) { if (!m_timer) diff --git a/Source/WebCore/rendering/RenderEmbeddedObject.cpp b/Source/WebCore/rendering/RenderEmbeddedObject.cpp index fa31ddf..ac72fe1 100644 --- a/Source/WebCore/rendering/RenderEmbeddedObject.cpp +++ b/Source/WebCore/rendering/RenderEmbeddedObject.cpp @@ -41,6 +41,7 @@ #include "MIMETypeRegistry.h" #include "MouseEvent.h" #include "Page.h" +#include "PaintInfo.h" #include "Path.h" #include "PluginViewBase.h" #include "RenderTheme.h" diff --git a/Source/WebCore/rendering/RenderFieldset.cpp b/Source/WebCore/rendering/RenderFieldset.cpp index c83396c..8c65314 100644 --- a/Source/WebCore/rendering/RenderFieldset.cpp +++ b/Source/WebCore/rendering/RenderFieldset.cpp @@ -25,8 +25,9 @@ #include "RenderFieldset.h" #include "CSSPropertyNames.h" -#include "HTMLNames.h" #include "GraphicsContext.h" +#include "HTMLNames.h" +#include "PaintInfo.h" #if ENABLE(WML) #include "WMLNames.h" @@ -208,16 +209,4 @@ void RenderFieldset::paintMask(PaintInfo& paintInfo, int tx, int ty) paintMaskImages(paintInfo, tx, ty, w, h); } -void RenderFieldset::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) -{ - RenderBlock::styleDidChange(diff, oldStyle); - - // WinIE renders fieldsets with display:inline like they're inline-blocks. For us, - // an inline-block is just a block element with replaced set to true and inline set - // to true. Ensure that if we ended up being inline that we set our replaced flag - // so that we're treated like an inline-block. - if (isInline()) - setReplaced(true); -} - } // namespace WebCore diff --git a/Source/WebCore/rendering/RenderFieldset.h b/Source/WebCore/rendering/RenderFieldset.h index b340794..267f352 100644 --- a/Source/WebCore/rendering/RenderFieldset.h +++ b/Source/WebCore/rendering/RenderFieldset.h @@ -44,8 +44,6 @@ private: virtual bool avoidsFloats() const { return true; } virtual bool stretchesToMinIntrinsicLogicalWidth() const { return true; } - virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle); - virtual void paintBoxDecorations(PaintInfo&, int tx, int ty); virtual void paintMask(PaintInfo&, int tx, int ty); }; diff --git a/Source/WebCore/rendering/RenderFileUploadControl.cpp b/Source/WebCore/rendering/RenderFileUploadControl.cpp index 3c10f43..3e4d216 100644 --- a/Source/WebCore/rendering/RenderFileUploadControl.cpp +++ b/Source/WebCore/rendering/RenderFileUploadControl.cpp @@ -32,6 +32,7 @@ #include "Icon.h" #include "LocalizedStrings.h" #include "Page.h" +#include "PaintInfo.h" #include "RenderButton.h" #include "RenderText.h" #include "RenderTheme.h" @@ -74,8 +75,6 @@ void RenderFileUploadControl::styleDidChange(StyleDifference diff, const RenderS RenderBlock::styleDidChange(diff, oldStyle); if (m_button) m_button->renderer()->setStyle(createButtonStyle(style())); - - setReplaced(isInline()); } void RenderFileUploadControl::valueChanged() diff --git a/Source/WebCore/rendering/RenderFrameSet.cpp b/Source/WebCore/rendering/RenderFrameSet.cpp index 600d65e..06b2a7a 100644 --- a/Source/WebCore/rendering/RenderFrameSet.cpp +++ b/Source/WebCore/rendering/RenderFrameSet.cpp @@ -34,6 +34,7 @@ #include "HitTestRequest.h" #include "HitTestResult.h" #include "MouseEvent.h" +#include "PaintInfo.h" #include "RenderFrame.h" #include "RenderView.h" #include "Settings.h" diff --git a/Source/WebCore/rendering/RenderFullScreen.cpp b/Source/WebCore/rendering/RenderFullScreen.cpp index 7cd452f..cc53a6e 100644 --- a/Source/WebCore/rendering/RenderFullScreen.cpp +++ b/Source/WebCore/rendering/RenderFullScreen.cpp @@ -35,7 +35,7 @@ using namespace WebCore; void RenderFullScreen::setAnimating(bool animating) { m_isAnimating = animating; -#if ENABLE(ACCELERATED_COMPOSITING) +#if USE(ACCELERATED_COMPOSITING) if (layer()) layer()->contentChanged(RenderLayer::FullScreenChanged); #endif diff --git a/Source/WebCore/rendering/RenderFullScreen.h b/Source/WebCore/rendering/RenderFullScreen.h index 52d4ee2..30f95c1 100644 --- a/Source/WebCore/rendering/RenderFullScreen.h +++ b/Source/WebCore/rendering/RenderFullScreen.h @@ -33,7 +33,7 @@ namespace WebCore { class RenderFullScreen : public RenderFlexibleBox { public: - RenderFullScreen(Node* node) : RenderFlexibleBox(node) { setReplaced(false); setIsAnonymous(false); } + RenderFullScreen(Node* node) : RenderFlexibleBox(node) { setReplaced(false); } virtual bool isRenderFullScreen() const { return true; } virtual const char* renderName() const { return "RenderFullScreen"; } diff --git a/Source/WebCore/rendering/RenderHTMLCanvas.cpp b/Source/WebCore/rendering/RenderHTMLCanvas.cpp index 68bb536..de2a2c1 100644 --- a/Source/WebCore/rendering/RenderHTMLCanvas.cpp +++ b/Source/WebCore/rendering/RenderHTMLCanvas.cpp @@ -28,11 +28,12 @@ #include "CanvasRenderingContext.h" #include "Document.h" +#include "FrameView.h" #include "GraphicsContext.h" #include "HTMLCanvasElement.h" #include "HTMLNames.h" +#include "PaintInfo.h" #include "RenderView.h" -#include "FrameView.h" namespace WebCore { diff --git a/Source/WebCore/rendering/RenderImageResource.cpp b/Source/WebCore/rendering/RenderImageResource.cpp index ea3ed2f..a943c3d 100644 --- a/Source/WebCore/rendering/RenderImageResource.cpp +++ b/Source/WebCore/rendering/RenderImageResource.cpp @@ -28,6 +28,7 @@ #include "config.h" #include "RenderImageResource.h" +#include "Image.h" #include "RenderImageResourceStyleImage.h" #include "RenderObject.h" diff --git a/Source/WebCore/rendering/RenderInputSpeech.cpp b/Source/WebCore/rendering/RenderInputSpeech.cpp index 5472025..8a1e73f 100644 --- a/Source/WebCore/rendering/RenderInputSpeech.cpp +++ b/Source/WebCore/rendering/RenderInputSpeech.cpp @@ -35,6 +35,7 @@ #include "GraphicsContext.h" #include "HTMLNames.h" +#include "PaintInfo.h" #include "RenderBox.h" #include "TextControlInnerElements.h" diff --git a/Source/WebCore/rendering/RenderLayer.cpp b/Source/WebCore/rendering/RenderLayer.cpp index 5623662..3613d95 100644 --- a/Source/WebCore/rendering/RenderLayer.cpp +++ b/Source/WebCore/rendering/RenderLayer.cpp @@ -51,7 +51,7 @@ #include "Chrome.h" #include "Document.h" #include "EventHandler.h" -#include "EventNames.h" +#include "EventQueue.h" #include "FloatPoint3D.h" #include "FloatRect.h" #include "FocusController.h" @@ -1413,10 +1413,7 @@ void RenderLayer::scrollToOffset(int x, int y, bool updateScrollbars, bool repai } // Schedule the scroll DOM event. - if (view) { - if (FrameView* frameView = view->frameView()) - frameView->scheduleEvent(Event::create(eventNames().scrollEvent, false, false), renderer()->node()); - } + renderer()->node()->document()->eventQueue()->enqueueScrollEvent(renderer()->node(), EventQueue::ScrollEventElementTarget); } void RenderLayer::scrollRectToVisible(const IntRect& rect, bool scrollToAnchor, const ScrollAlignment& alignX, const ScrollAlignment& alignY) @@ -2744,7 +2741,7 @@ bool RenderLayer::hitTest(const HitTestRequest& request, HitTestResult& result) { renderer()->document()->updateLayout(); - IntRect hitTestArea = result.rectForPoint(result.point()); + IntRect hitTestArea = renderer()->view()->documentRect(); if (!request.ignoreClipping()) hitTestArea.intersect(frameVisibleRect(renderer())); @@ -3575,6 +3572,16 @@ bool RenderLayer::hasCompositedMask() const } #endif +bool RenderLayer::paintsWithTransform(PaintBehavior paintBehavior) const +{ +#if USE(ACCELERATED_COMPOSITING) + bool paintsToWindow = !isComposited() || backing()->paintingGoesToWindow(); +#else + bool paintsToWindow = true; +#endif + return transform() && ((paintBehavior & PaintBehaviorFlattenCompositingLayers) || paintsToWindow); +} + void RenderLayer::setParent(RenderLayer* parent) { if (parent == m_parent) @@ -4035,6 +4042,14 @@ void RenderLayer::updateReflectionStyle() m_reflection->setStyle(newStyle.release()); } +void RenderLayer::updateContentsScale(float scale) +{ +#if USE(ACCELERATED_COMPOSITING) + if (m_backing) + m_backing->updateContentsScale(scale); +#endif +} + } // namespace WebCore #ifndef NDEBUG diff --git a/Source/WebCore/rendering/RenderLayer.h b/Source/WebCore/rendering/RenderLayer.h index cc3b21c..8245c2f 100644 --- a/Source/WebCore/rendering/RenderLayer.h +++ b/Source/WebCore/rendering/RenderLayer.h @@ -44,6 +44,7 @@ #ifndef RenderLayer_h #define RenderLayer_h +#include "PaintInfo.h" #include "RenderBox.h" #include "ScrollBehavior.h" #include "ScrollbarClient.h" @@ -488,10 +489,7 @@ public: return isTransparent() && ((paintBehavior & PaintBehaviorFlattenCompositingLayers) || !isComposited()); } - bool paintsWithTransform(PaintBehavior paintBehavior) const - { - return transform() && ((paintBehavior & PaintBehaviorFlattenCompositingLayers) || !isComposited()); - } + bool paintsWithTransform(PaintBehavior) const; private: // The normal operator new is disallowed on all render objects. @@ -621,6 +619,8 @@ private: void setMustOverlapCompositedLayers(bool b) { m_mustOverlapCompositedLayers = b; } #endif + void updateContentsScale(float); + private: friend class RenderLayerBacking; friend class RenderLayerCompositor; diff --git a/Source/WebCore/rendering/RenderLayerBacking.cpp b/Source/WebCore/rendering/RenderLayerBacking.cpp index c430bae..8001c42 100644 --- a/Source/WebCore/rendering/RenderLayerBacking.cpp +++ b/Source/WebCore/rendering/RenderLayerBacking.cpp @@ -105,6 +105,12 @@ void RenderLayerBacking::createGraphicsLayer() m_graphicsLayer->setName(nameForLayer()); #endif // NDEBUG +#if USE(ACCELERATED_COMPOSITING) + ASSERT(renderer() && renderer()->document() && renderer()->document()->frame()); + if (Frame* frame = renderer()->document()->frame()) + m_graphicsLayer->setContentsScale(frame->pageScaleFactor()); +#endif + updateLayerOpacity(renderer()->style()); updateLayerTransform(renderer()->style()); } @@ -543,6 +549,8 @@ bool RenderLayerBacking::updateForegroundLayer(bool needsForegroundLayer) #endif m_foregroundLayer->setDrawsContent(true); m_foregroundLayer->setPaintingPhase(GraphicsLayerPaintForeground); + if (Frame* frame = renderer()->document()->frame()) + m_foregroundLayer->setContentsScale(frame->pageScaleFactor()); layerChanged = true; } } else if (m_foregroundLayer) { @@ -568,6 +576,8 @@ bool RenderLayerBacking::updateMaskLayer(bool needsMaskLayer) #endif m_maskLayer->setDrawsContent(true); m_maskLayer->setPaintingPhase(GraphicsLayerPaintMask); + if (Frame* frame = renderer()->document()->frame()) + m_maskLayer->setContentsScale(frame->pageScaleFactor()); layerChanged = true; } } else if (m_maskLayer) { @@ -933,7 +943,7 @@ FloatPoint RenderLayerBacking::contentsToGraphicsLayerCoordinates(const Graphics bool RenderLayerBacking::paintingGoesToWindow() const { if (m_owningLayer->isRootLayer()) - return !m_owningLayer->hasTransform() && (compositor()->rootLayerAttachment() != RenderLayerCompositor::RootLayerAttachedViaEnclosingIframe); + return compositor()->rootLayerAttachment() != RenderLayerCompositor::RootLayerAttachedViaEnclosingIframe; return false; } @@ -1275,7 +1285,7 @@ void RenderLayerBacking::notifyAnimationStarted(const GraphicsLayer*, double tim void RenderLayerBacking::notifySyncRequired(const GraphicsLayer*) { if (!renderer()->documentBeingDestroyed()) - compositor()->scheduleSync(); + compositor()->scheduleLayerFlush(); } // This is used for the 'freeze' API, for testing only. @@ -1361,6 +1371,18 @@ CompositingLayerType RenderLayerBacking::compositingLayerType() const return ContainerCompositingLayer; } +void RenderLayerBacking::updateContentsScale(float scale) +{ + if (m_graphicsLayer) + m_graphicsLayer->setContentsScale(scale); + + if (m_foregroundLayer) + m_foregroundLayer->setContentsScale(scale); + + if (m_maskLayer) + m_maskLayer->setContentsScale(scale); +} + } // namespace WebCore #endif // USE(ACCELERATED_COMPOSITING) diff --git a/Source/WebCore/rendering/RenderLayerBacking.h b/Source/WebCore/rendering/RenderLayerBacking.h index c5489f3..5c6ed12 100644 --- a/Source/WebCore/rendering/RenderLayerBacking.h +++ b/Source/WebCore/rendering/RenderLayerBacking.h @@ -139,6 +139,8 @@ public: // For informative purposes only. CompositingLayerType compositingLayerType() const; + void updateContentsScale(float); + private: void createGraphicsLayer(); void destroyGraphicsLayer(); diff --git a/Source/WebCore/rendering/RenderLayerCompositor.cpp b/Source/WebCore/rendering/RenderLayerCompositor.cpp index 960aa37..15bb8ec 100644 --- a/Source/WebCore/rendering/RenderLayerCompositor.cpp +++ b/Source/WebCore/rendering/RenderLayerCompositor.cpp @@ -176,7 +176,7 @@ void RenderLayerCompositor::setCompositingLayersNeedRebuild(bool needRebuild) m_compositingLayersNeedRebuild = needRebuild; } -void RenderLayerCompositor::scheduleSync() +void RenderLayerCompositor::scheduleLayerFlush() { Frame* frame = m_renderView->frameView()->frame(); Page* page = frame ? frame->page() : 0; @@ -186,6 +186,16 @@ void RenderLayerCompositor::scheduleSync() page->chrome()->client()->scheduleCompositingLayerSync(); } +void RenderLayerCompositor::flushPendingLayerChanges() +{ + // FIXME: FrameView::syncCompositingStateRecursive() calls this for each + // frame, so when compositing layers are connected between frames, we'll + // end up syncing subframe's layers multiple times. + // https://bugs.webkit.org/show_bug.cgi?id=52489 + if (GraphicsLayer* rootLayer = rootPlatformLayer()) + rootLayer->syncCompositingState(); +} + void RenderLayerCompositor::scheduleCompositingLayerUpdate() { if (!m_updateCompositingLayersTimer.isActive()) @@ -1171,7 +1181,12 @@ bool RenderLayerCompositor::shouldPropagateCompositingToEnclosingIFrame() const return true; // On Mac, only propagate compositing if the iframe is overlapped in the parent - // document, or the parent is already compositing. + // document, or the parent is already compositing, or the main frame is scaled. + Frame* frame = m_renderView->frameView()->frame(); + Page* page = frame ? frame->page() : 0; + if (page->mainFrame()->pageScaleFactor() != 1) + return true; + RenderIFrame* iframeRenderer = toRenderIFrame(renderer); if (iframeRenderer->widget()) { ASSERT(iframeRenderer->widget()->isFrameView()); @@ -1663,6 +1678,34 @@ bool RenderLayerCompositor::layerHas3DContent(const RenderLayer* layer) const return false; } +void RenderLayerCompositor::updateContentsScale(float scale, RenderLayer* layer) +{ + if (!layer) + layer = rootRenderLayer(); + + layer->updateContentsScale(scale); + + if (layer->isStackingContext()) { + if (Vector<RenderLayer*>* negZOrderList = layer->negZOrderList()) { + size_t listSize = negZOrderList->size(); + for (size_t i = 0; i < listSize; ++i) + updateContentsScale(scale, negZOrderList->at(i)); + } + + if (Vector<RenderLayer*>* posZOrderList = layer->posZOrderList()) { + size_t listSize = posZOrderList->size(); + for (size_t i = 0; i < listSize; ++i) + updateContentsScale(scale, posZOrderList->at(i)); + } + } + + if (Vector<RenderLayer*>* normalFlowList = layer->normalFlowList()) { + size_t listSize = normalFlowList->size(); + for (size_t i = 0; i < listSize; ++i) + updateContentsScale(scale, normalFlowList->at(i)); + } +} + } // namespace WebCore #endif // USE(ACCELERATED_COMPOSITING) diff --git a/Source/WebCore/rendering/RenderLayerCompositor.h b/Source/WebCore/rendering/RenderLayerCompositor.h index 53a0f9a..24e182c 100644 --- a/Source/WebCore/rendering/RenderLayerCompositor.h +++ b/Source/WebCore/rendering/RenderLayerCompositor.h @@ -84,7 +84,10 @@ public: void setCompositingConsultsOverlap(bool b) { m_compositingConsultsOverlap = b; } bool compositingConsultsOverlap() const { return m_compositingConsultsOverlap; } - void scheduleSync(); + // GraphicsLayers buffer state, which gets pushed to the underlying platform layers + // at specific times. + void scheduleLayerFlush(); + void flushPendingLayerChanges(); // Rebuild the tree of compositing layers void updateCompositingLayers(CompositingUpdateType = CompositingUpdateAfterLayoutOrStyleChange, RenderLayer* updateRoot = 0); @@ -174,10 +177,12 @@ public: bool compositorShowDebugBorders() const { return m_showDebugBorders; } bool compositorShowRepaintCounter() const { return m_showRepaintCounter; } + void updateContentsScale(float, RenderLayer* = 0); + private: // GraphicsLayerClient Implementation virtual void notifyAnimationStarted(const GraphicsLayer*, double) { } - virtual void notifySyncRequired(const GraphicsLayer*) { scheduleSync(); } + virtual void notifySyncRequired(const GraphicsLayer*) { scheduleLayerFlush(); } virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect&) { } // These calls return false always. They are saying that the layers associated with this client diff --git a/Source/WebCore/rendering/RenderLineBoxList.cpp b/Source/WebCore/rendering/RenderLineBoxList.cpp index 85d7f18..1488ecc 100644 --- a/Source/WebCore/rendering/RenderLineBoxList.cpp +++ b/Source/WebCore/rendering/RenderLineBoxList.cpp @@ -31,6 +31,7 @@ #include "HitTestResult.h" #include "InlineTextBox.h" +#include "PaintInfo.h" #include "RenderArena.h" #include "RenderInline.h" #include "RenderView.h" diff --git a/Source/WebCore/rendering/RenderListBox.cpp b/Source/WebCore/rendering/RenderListBox.cpp index ed7f8ee..e6ce340 100644 --- a/Source/WebCore/rendering/RenderListBox.cpp +++ b/Source/WebCore/rendering/RenderListBox.cpp @@ -36,7 +36,7 @@ #include "CSSStyleSelector.h" #include "Document.h" #include "EventHandler.h" -#include "EventNames.h" +#include "EventQueue.h" #include "FocusController.h" #include "Frame.h" #include "FrameView.h" @@ -46,6 +46,7 @@ #include "OptionGroupElement.h" #include "OptionElement.h" #include "Page.h" +#include "PaintInfo.h" #include "RenderScrollbar.h" #include "RenderTheme.h" #include "RenderView.h" @@ -87,12 +88,6 @@ RenderListBox::~RenderListBox() setHasVerticalScrollbar(false); } -void RenderListBox::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) -{ - RenderBlock::styleDidChange(diff, oldStyle); - setReplaced(isInline()); -} - void RenderListBox::updateFromElement() { if (m_optionsChanged) { @@ -545,7 +540,7 @@ void RenderListBox::valueChanged(Scrollbar*) if (newOffset != m_indexOffset) { m_indexOffset = newOffset; repaint(); - node()->dispatchEvent(Event::create(eventNames().scrollEvent, false, false)); + node()->document()->eventQueue()->enqueueScrollEvent(node(), EventQueue::ScrollEventElementTarget); } } diff --git a/Source/WebCore/rendering/RenderListBox.h b/Source/WebCore/rendering/RenderListBox.h index 1fbff0d..243fcbe 100644 --- a/Source/WebCore/rendering/RenderListBox.h +++ b/Source/WebCore/rendering/RenderListBox.h @@ -94,8 +94,6 @@ private: virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction); - virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle); - // ScrollbarClient interface. virtual int scrollSize(ScrollbarOrientation orientation) const; virtual void setScrollOffsetFromAnimation(const IntPoint&); diff --git a/Source/WebCore/rendering/RenderMediaControlsChromium.cpp b/Source/WebCore/rendering/RenderMediaControlsChromium.cpp index f938a52..71fca91 100644 --- a/Source/WebCore/rendering/RenderMediaControlsChromium.cpp +++ b/Source/WebCore/rendering/RenderMediaControlsChromium.cpp @@ -32,6 +32,7 @@ #include "GraphicsContext.h" #include "HTMLMediaElement.h" #include "HTMLNames.h" +#include "PaintInfo.h" namespace WebCore { diff --git a/Source/WebCore/rendering/RenderMenuList.cpp b/Source/WebCore/rendering/RenderMenuList.cpp index 5ad661f..61f1084 100644 --- a/Source/WebCore/rendering/RenderMenuList.cpp +++ b/Source/WebCore/rendering/RenderMenuList.cpp @@ -123,8 +123,6 @@ void RenderMenuList::styleDidChange(StyleDifference diff, const RenderStyle* old if (m_innerBlock) // RenderBlock handled updating the anonymous block's style. adjustInnerStyle(); - setReplaced(isInline()); - bool fontChanged = !oldStyle || oldStyle->font() != style()->font(); if (fontChanged) updateOptionsWidth(); diff --git a/Source/WebCore/rendering/RenderObject.cpp b/Source/WebCore/rendering/RenderObject.cpp index 27a53d0..670f818 100644 --- a/Source/WebCore/rendering/RenderObject.cpp +++ b/Source/WebCore/rendering/RenderObject.cpp @@ -28,8 +28,9 @@ #include "RenderObject.h" #include "AXObjectCache.h" -#include "Chrome.h" #include "CSSStyleSelector.h" +#include "Chrome.h" +#include "ContentData.h" #include "DashArray.h" #include "EditingBoundary.h" #include "FloatQuad.h" diff --git a/Source/WebCore/rendering/RenderObject.h b/Source/WebCore/rendering/RenderObject.h index 2f443ef..cf08a0d 100644 --- a/Source/WebCore/rendering/RenderObject.h +++ b/Source/WebCore/rendering/RenderObject.h @@ -28,11 +28,10 @@ #include "AffineTransform.h" #include "CachedResourceClient.h" -#include "CSSPrimitiveValue.h" #include "Document.h" #include "Element.h" #include "FloatQuad.h" -#include "PaintInfo.h" +#include "PaintPhase.h" #include "RenderObjectChildList.h" #include "RenderStyle.h" #include "TextAffinity.h" @@ -64,6 +63,8 @@ class VisiblePosition; class RenderSVGResourceContainer; #endif +struct PaintInfo; + enum HitTestFilter { HitTestAll, HitTestSelf, diff --git a/Source/WebCore/rendering/RenderObjectChildList.cpp b/Source/WebCore/rendering/RenderObjectChildList.cpp index c7c8e44..fa4f902 100644 --- a/Source/WebCore/rendering/RenderObjectChildList.cpp +++ b/Source/WebCore/rendering/RenderObjectChildList.cpp @@ -28,6 +28,7 @@ #include "RenderObjectChildList.h" #include "AXObjectCache.h" +#include "ContentData.h" #include "RenderBlock.h" #include "RenderCounter.h" #include "RenderImage.h" diff --git a/Source/WebCore/rendering/RenderProgress.cpp b/Source/WebCore/rendering/RenderProgress.cpp index 84de6fb..4194e2b 100644 --- a/Source/WebCore/rendering/RenderProgress.cpp +++ b/Source/WebCore/rendering/RenderProgress.cpp @@ -26,6 +26,7 @@ #include "HTMLNames.h" #include "HTMLProgressElement.h" +#include "PaintInfo.h" #include "RenderTheme.h" #include "ShadowElement.h" #include <wtf/CurrentTime.h> diff --git a/Source/WebCore/rendering/RenderSVGTransformableContainer.h b/Source/WebCore/rendering/RenderSVGTransformableContainer.h deleted file mode 100644 index b49a403..0000000 --- a/Source/WebCore/rendering/RenderSVGTransformableContainer.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - Copyright (C) 2007 Eric Seidel <eric@webkit.org> - 2009 Google, Inc. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - */ - -#ifndef RenderSVGTransformableContainer_h -#define RenderSVGTransformableContainer_h - -#if ENABLE(SVG) -#include "RenderSVGContainer.h" - -namespace WebCore { - - class SVGStyledTransformableElement; - class RenderSVGTransformableContainer : public RenderSVGContainer { - public: - explicit RenderSVGTransformableContainer(SVGStyledTransformableElement*); - - virtual const AffineTransform& localToParentTransform() const { return m_localTransform; } - virtual void setNeedsTransformUpdate() { m_needsTransformUpdate = true; } - - private: - virtual bool calculateLocalTransform(); - virtual AffineTransform localTransform() const { return m_localTransform; } - - bool m_needsTransformUpdate : 1; - AffineTransform m_localTransform; - }; -} - -#endif // ENABLE(SVG) -#endif // RenderSVGTransformableContainer_h diff --git a/Source/WebCore/rendering/RenderScrollbarPart.cpp b/Source/WebCore/rendering/RenderScrollbarPart.cpp index 16cc204..9cf55fc 100644 --- a/Source/WebCore/rendering/RenderScrollbarPart.cpp +++ b/Source/WebCore/rendering/RenderScrollbarPart.cpp @@ -25,6 +25,8 @@ #include "config.h" #include "RenderScrollbarPart.h" + +#include "PaintInfo.h" #include "RenderScrollbar.h" #include "RenderScrollbarTheme.h" #include "RenderView.h" diff --git a/Source/WebCore/rendering/RenderSlider.cpp b/Source/WebCore/rendering/RenderSlider.cpp index b73a1ac..b0dc0d9 100644 --- a/Source/WebCore/rendering/RenderSlider.cpp +++ b/Source/WebCore/rendering/RenderSlider.cpp @@ -22,6 +22,7 @@ #include "RenderSlider.h" #include "CSSPropertyNames.h" +#include "CSSStyleSelector.h" #include "Document.h" #include "Event.h" #include "EventHandler.h" @@ -60,8 +61,6 @@ RenderSlider::RenderSlider(HTMLInputElement* element) RenderSlider::~RenderSlider() { - if (m_thumb) - m_thumb->detach(); } int RenderSlider::baselinePosition(FontBaseline, bool /*firstLine*/, LineDirectionMode, LinePositionMode) const @@ -100,50 +99,14 @@ void RenderSlider::computePreferredLogicalWidths() setPreferredLogicalWidthsDirty(false); } -void RenderSlider::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) -{ - RenderBlock::styleDidChange(diff, oldStyle); - - if (m_thumb) - m_thumb->renderer()->setStyle(createThumbStyle(style())); - - setReplaced(isInline()); -} - -PassRefPtr<RenderStyle> RenderSlider::createThumbStyle(const RenderStyle* parentStyle) -{ - RefPtr<RenderStyle> style; - RenderStyle* pseudoStyle = getCachedPseudoStyle(SLIDER_THUMB); - if (pseudoStyle) - // We may be sharing style with another slider, but we must not share the thumb style. - style = RenderStyle::clone(pseudoStyle); - else - style = RenderStyle::create(); - - if (parentStyle) - style->inheritFrom(parentStyle); - - style->setDisplay(BLOCK); - - if (parentStyle->appearance() == SliderVerticalPart) - style->setAppearance(SliderThumbVerticalPart); - else if (parentStyle->appearance() == SliderHorizontalPart) - style->setAppearance(SliderThumbHorizontalPart); - else if (parentStyle->appearance() == MediaSliderPart) - style->setAppearance(MediaSliderThumbPart); - else if (parentStyle->appearance() == MediaVolumeSliderPart) - style->setAppearance(MediaVolumeSliderThumbPart); - - return style.release(); -} - IntRect RenderSlider::thumbRect() { - if (!m_thumb) + SliderThumbElement* thumbElement = sliderThumbElement(); + if (!thumbElement) return IntRect(); IntRect thumbRect; - RenderBox* thumb = toRenderBox(m_thumb->renderer()); + RenderBox* thumb = toRenderBox(thumbElement->renderer()); thumbRect.setWidth(thumb->style()->width().calcMinValue(contentWidth())); thumbRect.setHeight(thumb->style()->height().calcMinValue(contentHeight())); @@ -165,7 +128,8 @@ void RenderSlider::layout() { ASSERT(needsLayout()); - RenderBox* thumb = m_thumb ? toRenderBox(m_thumb->renderer()) : 0; + SliderThumbElement* thumbElement = sliderThumbElement(); + RenderBox* thumb = thumbElement ? toRenderBox(thumbElement->renderer()) : 0; IntSize baseSize(borderAndPaddingWidth(), borderAndPaddingHeight()); @@ -212,43 +176,35 @@ void RenderSlider::layout() setNeedsLayout(false); } -void RenderSlider::updateFromElement() +SliderThumbElement* RenderSlider::sliderThumbElement() const { - // Layout will take care of the thumb's size and position. - if (!m_thumb) { - m_thumb = SliderThumbElement::create(static_cast<HTMLElement*>(node())); - RefPtr<RenderStyle> thumbStyle = createThumbStyle(style()); - m_thumb->setRenderer(m_thumb->createRenderer(renderArena(), thumbStyle.get())); - m_thumb->renderer()->setStyle(thumbStyle.release()); - m_thumb->setAttached(); - m_thumb->setInDocument(); - addChild(m_thumb->renderer()); - } - setNeedsLayout(true); + return toSliderThumbElement(static_cast<Element*>(node())->shadowRoot()); } bool RenderSlider::mouseEventIsInThumb(MouseEvent* evt) { - if (!m_thumb || !m_thumb->renderer()) + SliderThumbElement* thumbElement = sliderThumbElement(); + if (!thumbElement || !thumbElement->renderer()) return false; #if ENABLE(VIDEO) if (style()->appearance() == MediaSliderPart || style()->appearance() == MediaVolumeSliderPart) { - MediaControlInputElement *sliderThumb = static_cast<MediaControlInputElement*>(m_thumb->renderer()->node()); + MediaControlInputElement* sliderThumb = static_cast<MediaControlInputElement*>(thumbElement->renderer()->node()); return sliderThumb->hitTest(evt->absoluteLocation()); } #endif - FloatPoint localPoint = m_thumb->renderBox()->absoluteToLocal(evt->absoluteLocation(), false, true); - IntRect thumbBounds = m_thumb->renderBox()->borderBoxRect(); + FloatPoint localPoint = thumbElement->renderBox()->absoluteToLocal(evt->absoluteLocation(), false, true); + IntRect thumbBounds = thumbElement->renderBox()->borderBoxRect(); return thumbBounds.contains(roundedIntPoint(localPoint)); } FloatPoint RenderSlider::mouseEventOffsetToThumb(MouseEvent* evt) { - ASSERT(m_thumb && m_thumb->renderer()); - FloatPoint localPoint = m_thumb->renderBox()->absoluteToLocal(evt->absoluteLocation(), false, true); - IntRect thumbBounds = m_thumb->renderBox()->borderBoxRect(); + SliderThumbElement* thumbElement = sliderThumbElement(); + ASSERT(thumbElement && thumbElement->renderer()); + FloatPoint localPoint = thumbElement->renderBox()->absoluteToLocal(evt->absoluteLocation(), false, true); + IntRect thumbBounds = thumbElement->renderBox()->borderBoxRect(); FloatPoint offset; offset.setX(thumbBounds.x() + thumbBounds.width() / 2 - localPoint.x()); offset.setY(thumbBounds.y() + thumbBounds.height() / 2 - localPoint.y()); @@ -257,7 +213,8 @@ FloatPoint RenderSlider::mouseEventOffsetToThumb(MouseEvent* evt) void RenderSlider::setValueForPosition(int position) { - if (!m_thumb || !m_thumb->renderer()) + SliderThumbElement* thumbElement = sliderThumbElement(); + if (!thumbElement || !thumbElement->renderer()) return; HTMLInputElement* element = static_cast<HTMLInputElement*>(node()); @@ -282,40 +239,45 @@ void RenderSlider::setValueForPosition(int position) int RenderSlider::positionForOffset(const IntPoint& p) { - if (!m_thumb || !m_thumb->renderer()) + SliderThumbElement* thumbElement = sliderThumbElement(); + if (!thumbElement || !thumbElement->renderer()) return 0; int position; if (style()->appearance() == SliderVerticalPart || style()->appearance() == MediaVolumeSliderPart) - position = p.y() - m_thumb->renderBox()->height() / 2; + position = p.y() - thumbElement->renderBox()->height() / 2; else - position = p.x() - m_thumb->renderBox()->width() / 2; + position = p.x() - thumbElement->renderBox()->width() / 2; return max(0, min(position, trackSize())); } int RenderSlider::currentPosition() { - ASSERT(m_thumb); - ASSERT(m_thumb->renderer()); + SliderThumbElement* thumbElement = sliderThumbElement(); + ASSERT(thumbElement && thumbElement->renderer()); if (style()->appearance() == SliderVerticalPart || style()->appearance() == MediaVolumeSliderPart) - return toRenderBox(m_thumb->renderer())->y() - contentBoxRect().y(); - return toRenderBox(m_thumb->renderer())->x() - contentBoxRect().x(); + return toRenderBox(thumbElement->renderer())->y() - contentBoxRect().y(); + return toRenderBox(thumbElement->renderer())->x() - contentBoxRect().x(); } int RenderSlider::trackSize() { - ASSERT(m_thumb); - ASSERT(m_thumb->renderer()); + SliderThumbElement* thumbElement = sliderThumbElement(); + ASSERT(thumbElement && thumbElement->renderer()); if (style()->appearance() == SliderVerticalPart || style()->appearance() == MediaVolumeSliderPart) - return contentHeight() - m_thumb->renderBox()->height(); - return contentWidth() - m_thumb->renderBox()->width(); + return contentHeight() - thumbElement->renderBox()->height(); + return contentWidth() - thumbElement->renderBox()->width(); } void RenderSlider::forwardEvent(Event* event) { + SliderThumbElement* thumbElement = sliderThumbElement(); + if (!thumbElement) + return; + if (event->isMouseEvent()) { MouseEvent* mouseEvent = static_cast<MouseEvent*>(event); if (event->type() == eventNames().mousedownEvent && mouseEvent->button() == LeftButton) { @@ -326,12 +288,13 @@ void RenderSlider::forwardEvent(Event* event) } } - m_thumb->defaultEventHandler(event); + thumbElement->defaultEventHandler(event); } bool RenderSlider::inDragMode() const { - return m_thumb && m_thumb->inDragMode(); + SliderThumbElement* thumbElement = sliderThumbElement(); + return thumbElement && thumbElement->inDragMode(); } } // namespace WebCore diff --git a/Source/WebCore/rendering/RenderSlider.h b/Source/WebCore/rendering/RenderSlider.h index 03779a3..5fb5921 100644 --- a/Source/WebCore/rendering/RenderSlider.h +++ b/Source/WebCore/rendering/RenderSlider.h @@ -45,8 +45,10 @@ namespace WebCore { virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; virtual void computePreferredLogicalWidths(); virtual void layout(); - virtual void updateFromElement(); + // FIXME: Eventually, the logic of manipulating slider thumb should move to + // SliderThumbElement and accessing sliderThumbElement should not be necessary in this class. + SliderThumbElement* sliderThumbElement() const; bool mouseEventIsInThumb(MouseEvent*); FloatPoint mouseEventOffsetToThumb(MouseEvent*); @@ -56,16 +58,10 @@ namespace WebCore { int currentPosition(); - virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle); - virtual bool requiresForcedStyleRecalcPropagation() const { return true; } - PassRefPtr<RenderStyle> createThumbStyle(const RenderStyle* parentStyle); - int trackSize(); - RefPtr<SliderThumbElement> m_thumb; - friend class SliderThumbElement; }; diff --git a/Source/WebCore/rendering/RenderTable.cpp b/Source/WebCore/rendering/RenderTable.cpp index f0cc264..3fc1c72 100644 --- a/Source/WebCore/rendering/RenderTable.cpp +++ b/Source/WebCore/rendering/RenderTable.cpp @@ -27,6 +27,7 @@ #include "RenderTable.h" #include "AutoTableLayout.h" +#include "CollapsedBorderValue.h" #include "DeleteButtonController.h" #include "Document.h" #include "FixedTableLayout.h" diff --git a/Source/WebCore/rendering/RenderTable.h b/Source/WebCore/rendering/RenderTable.h index 6afb108..b9a7bad 100644 --- a/Source/WebCore/rendering/RenderTable.h +++ b/Source/WebCore/rendering/RenderTable.h @@ -31,6 +31,7 @@ namespace WebCore { +class CollapsedBorderValue; class RenderTableCol; class RenderTableCell; class RenderTableSection; diff --git a/Source/WebCore/rendering/RenderTableCell.cpp b/Source/WebCore/rendering/RenderTableCell.cpp index 0c2cf2f..8549f49 100644 --- a/Source/WebCore/rendering/RenderTableCell.cpp +++ b/Source/WebCore/rendering/RenderTableCell.cpp @@ -25,10 +25,12 @@ #include "config.h" #include "RenderTableCell.h" +#include "CollapsedBorderValue.h" #include "FloatQuad.h" #include "GraphicsContext.h" #include "HTMLNames.h" #include "HTMLTableCellElement.h" +#include "PaintInfo.h" #include "RenderTableCol.h" #include "RenderView.h" #include "TransformState.h" diff --git a/Source/WebCore/rendering/RenderTableRow.cpp b/Source/WebCore/rendering/RenderTableRow.cpp index 5bb3ff4..595e156 100644 --- a/Source/WebCore/rendering/RenderTableRow.cpp +++ b/Source/WebCore/rendering/RenderTableRow.cpp @@ -28,6 +28,7 @@ #include "CachedImage.h" #include "Document.h" #include "HTMLNames.h" +#include "PaintInfo.h" #include "RenderTableCell.h" #include "RenderView.h" diff --git a/Source/WebCore/rendering/RenderTableSection.cpp b/Source/WebCore/rendering/RenderTableSection.cpp index cb1276d..7aaad62 100644 --- a/Source/WebCore/rendering/RenderTableSection.cpp +++ b/Source/WebCore/rendering/RenderTableSection.cpp @@ -29,6 +29,7 @@ #include "Document.h" #include "HitTestResult.h" #include "HTMLNames.h" +#include "PaintInfo.h" #include "RenderTableCell.h" #include "RenderTableCol.h" #include "RenderTableRow.h" diff --git a/Source/WebCore/rendering/RenderTextControl.cpp b/Source/WebCore/rendering/RenderTextControl.cpp index 0192ee4..40aa4c2 100644 --- a/Source/WebCore/rendering/RenderTextControl.cpp +++ b/Source/WebCore/rendering/RenderTextControl.cpp @@ -33,6 +33,7 @@ #include "HTMLInputElement.h" #include "HTMLNames.h" #include "HitTestResult.h" +#include "Position.h" #include "RenderLayer.h" #include "RenderText.h" #include "ScrollbarTheme.h" @@ -97,8 +98,6 @@ void RenderTextControl::styleDidChange(StyleDifference diff, const RenderStyle* textBlockRenderer->style()->setWidth(Length()); setInnerTextStyle(textBlockStyle); } - - setReplaced(isInline()); } void RenderTextControl::setInnerTextStyle(PassRefPtr<RenderStyle> style) @@ -273,12 +272,49 @@ bool RenderTextControl::isSelectableElement(Node* node) const || (shadowAncestor->hasTagName(inputTag) && static_cast<HTMLInputElement*>(shadowAncestor)->isTextField())); } +static inline void setContainerAndOffsetForRange(Node* node, int offset, Node*& containerNode, int& offsetInContainer) +{ + if (node->isTextNode()) { + containerNode = node; + offsetInContainer = offset; + } else { + containerNode = node->parentNode(); + offsetInContainer = node->nodeIndex() + offset; + } +} + PassRefPtr<Range> RenderTextControl::selection(int start, int end) const { + ASSERT(start <= end); if (!m_innerText) return 0; - return Range::create(document(), m_innerText, start, m_innerText, end); + if (!m_innerText->firstChild()) + return Range::create(document(), m_innerText, 0, m_innerText, 0); + + int offset = 0; + Node* startNode = 0; + Node* endNode = 0; + for (Node* node = m_innerText->firstChild(); node; node = node->traverseNextNode(m_innerText.get())) { + ASSERT(!node->firstChild()); + ASSERT(node->isTextNode() || node->hasTagName(brTag)); + int length = node->isTextNode() ? lastOffsetInNode(node) : 1; + + if (offset <= start && start <= offset + length) + setContainerAndOffsetForRange(node, start - offset, startNode, start); + + if (offset <= end && end <= offset + length) { + setContainerAndOffsetForRange(node, end - offset, endNode, end); + break; + } + + offset += length; + } + + if (!startNode || !endNode) + return 0; + + return Range::create(document(), startNode, start, endNode, end); } VisiblePosition RenderTextControl::visiblePositionForIndex(int index) const diff --git a/Source/WebCore/rendering/RenderTextControlSingleLine.cpp b/Source/WebCore/rendering/RenderTextControlSingleLine.cpp index 29538ce..b54c45b 100644 --- a/Source/WebCore/rendering/RenderTextControlSingleLine.cpp +++ b/Source/WebCore/rendering/RenderTextControlSingleLine.cpp @@ -671,21 +671,6 @@ void RenderTextControlSingleLine::createSubtreeIfNeeded() } } -#if ENABLE(INPUT_SPEECH) -void RenderTextControlSingleLine::speechAttributeChanged() -{ - // The inner text element of this renderer has different styles depending on whether the - // speech button is visible or not. So when the speech attribute changes, we reset the - // whole thing and recreate to get the right styles and layout. - if (m_speechButton) - m_speechButton->detach(); - setChildrenInline(true); - RenderStyle* parentStyle = m_innerBlock ? m_innerBlock->renderer()->style() : style(); - setStyle(createInnerTextStyle(parentStyle)); - updateFromElement(); -} -#endif - void RenderTextControlSingleLine::updateFromElement() { createSubtreeIfNeeded(); diff --git a/Source/WebCore/rendering/RenderTextControlSingleLine.h b/Source/WebCore/rendering/RenderTextControlSingleLine.h index 51509c0..16ce1e4 100644 --- a/Source/WebCore/rendering/RenderTextControlSingleLine.h +++ b/Source/WebCore/rendering/RenderTextControlSingleLine.h @@ -59,10 +59,6 @@ public: // Decoration width outside of the text field. int decorationWidthRight() const; -#if ENABLE(INPUT_SPEECH) - void speechAttributeChanged(); -#endif - private: int preferredDecorationWidthRight() const; virtual bool hasControlClip() const; diff --git a/Source/WebCore/rendering/RenderTheme.cpp b/Source/WebCore/rendering/RenderTheme.cpp index 538b6c6..e67ecfc 100644 --- a/Source/WebCore/rendering/RenderTheme.cpp +++ b/Source/WebCore/rendering/RenderTheme.cpp @@ -33,6 +33,7 @@ #include "HTMLNames.h" #include "MediaControlElements.h" #include "Page.h" +#include "PaintInfo.h" #include "RenderStyle.h" #include "RenderView.h" #include "SelectionController.h" diff --git a/Source/WebCore/rendering/RenderThemeChromiumLinux.cpp b/Source/WebCore/rendering/RenderThemeChromiumLinux.cpp index de83ae9..90736c7 100644 --- a/Source/WebCore/rendering/RenderThemeChromiumLinux.cpp +++ b/Source/WebCore/rendering/RenderThemeChromiumLinux.cpp @@ -27,6 +27,7 @@ #include "CSSValueKeywords.h" #include "Color.h" +#include "PaintInfo.h" #include "PlatformThemeChromiumGtk.h" #include "RenderObject.h" #include "ScrollbarTheme.h" diff --git a/Source/WebCore/rendering/RenderThemeChromiumMac.mm b/Source/WebCore/rendering/RenderThemeChromiumMac.mm index e8ffe6c..02eb134 100644 --- a/Source/WebCore/rendering/RenderThemeChromiumMac.mm +++ b/Source/WebCore/rendering/RenderThemeChromiumMac.mm @@ -21,6 +21,7 @@ #import "config.h" #import "RenderThemeChromiumMac.h" #import "ChromiumBridge.h" +#import "PaintInfo.h" #import "RenderMediaControlsChromium.h" #import "UserAgentStyleSheets.h" #import <Carbon/Carbon.h> diff --git a/Source/WebCore/rendering/RenderThemeChromiumSkia.cpp b/Source/WebCore/rendering/RenderThemeChromiumSkia.cpp index 9824851..bb60c1f 100644 --- a/Source/WebCore/rendering/RenderThemeChromiumSkia.cpp +++ b/Source/WebCore/rendering/RenderThemeChromiumSkia.cpp @@ -32,6 +32,7 @@ #include "HTMLNames.h" #include "Image.h" #include "MediaControlElements.h" +#include "PaintInfo.h" #include "PlatformContextSkia.h" #include "RenderBox.h" #include "RenderMediaControlsChromium.h" diff --git a/Source/WebCore/rendering/RenderThemeChromiumWin.cpp b/Source/WebCore/rendering/RenderThemeChromiumWin.cpp index be670ff..5b41ea2 100644 --- a/Source/WebCore/rendering/RenderThemeChromiumWin.cpp +++ b/Source/WebCore/rendering/RenderThemeChromiumWin.cpp @@ -38,6 +38,7 @@ #include "HTMLMediaElement.h" #include "HTMLNames.h" #include "MediaControlElements.h" +#include "PaintInfo.h" #include "RenderBox.h" #include "RenderProgress.h" #include "RenderSlider.h" diff --git a/Source/WebCore/rendering/RenderThemeMac.mm b/Source/WebCore/rendering/RenderThemeMac.mm index a13b4aa..0764093 100644 --- a/Source/WebCore/rendering/RenderThemeMac.mm +++ b/Source/WebCore/rendering/RenderThemeMac.mm @@ -35,6 +35,7 @@ #import "ImageBuffer.h" #import "LocalCurrentGraphicsContext.h" #import "MediaControlElements.h" +#import "PaintInfo.h" #import "RenderMedia.h" #import "RenderSlider.h" #import "RenderView.h" diff --git a/Source/WebCore/rendering/RenderThemeSafari.cpp b/Source/WebCore/rendering/RenderThemeSafari.cpp index 6d5d322..3c1dedc 100644 --- a/Source/WebCore/rendering/RenderThemeSafari.cpp +++ b/Source/WebCore/rendering/RenderThemeSafari.cpp @@ -35,6 +35,7 @@ #include "HTMLInputElement.h" #include "HTMLMediaElement.h" #include "HTMLNames.h" +#include "PaintInfo.h" #include "RenderMediaControls.h" #include "RenderSlider.h" #include "RenderView.h" diff --git a/Source/WebCore/rendering/RenderThemeWinCE.cpp b/Source/WebCore/rendering/RenderThemeWinCE.cpp index 27b8783..2c55f31 100644 --- a/Source/WebCore/rendering/RenderThemeWinCE.cpp +++ b/Source/WebCore/rendering/RenderThemeWinCE.cpp @@ -28,10 +28,11 @@ #include "CSSValueKeywords.h" #include "Document.h" #include "GraphicsContext.h" -#include "NotImplemented.h" #if ENABLE(VIDEO) #include "HTMLMediaElement.h" #endif +#include "NotImplemented.h" +#include "PaintInfo.h" #include <windows.h> diff --git a/Source/WebCore/rendering/RenderVideo.cpp b/Source/WebCore/rendering/RenderVideo.cpp index 5b82deb..0f3b551 100644 --- a/Source/WebCore/rendering/RenderVideo.cpp +++ b/Source/WebCore/rendering/RenderVideo.cpp @@ -34,6 +34,7 @@ #include "HTMLNames.h" #include "HTMLVideoElement.h" #include "MediaPlayer.h" +#include "PaintInfo.h" #include "RenderView.h" #if USE(ACCELERATED_COMPOSITING) diff --git a/Source/WebCore/rendering/RenderView.cpp b/Source/WebCore/rendering/RenderView.cpp index 6820e34..687ba85 100644 --- a/Source/WebCore/rendering/RenderView.cpp +++ b/Source/WebCore/rendering/RenderView.cpp @@ -147,20 +147,32 @@ void RenderView::layout() setNeedsLayout(false); } -void RenderView::mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed, bool /*useTransforms*/, TransformState& transformState) const +void RenderView::mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed, bool useTransforms, TransformState& transformState) const { // If a container was specified, and was not 0 or the RenderView, // then we should have found it by now. ASSERT_UNUSED(repaintContainer, !repaintContainer || repaintContainer == this); + if (useTransforms && shouldUseTransformFromContainer(0)) { + TransformationMatrix t; + getTransformFromContainer(0, IntSize(), t); + transformState.applyTransform(t); + } + if (fixed && m_frameView) transformState.move(m_frameView->scrollOffset()); } -void RenderView::mapAbsoluteToLocalPoint(bool fixed, bool /*useTransforms*/, TransformState& transformState) const +void RenderView::mapAbsoluteToLocalPoint(bool fixed, bool useTransforms, TransformState& transformState) const { if (fixed && m_frameView) transformState.move(-m_frameView->scrollOffset()); + + if (useTransforms && shouldUseTransformFromContainer(0)) { + TransformationMatrix t; + getTransformFromContainer(0, IntSize(), t); + transformState.applyTransform(t); + } } void RenderView::paint(PaintInfo& paintInfo, int tx, int ty) diff --git a/Source/WebCore/rendering/RenderWidget.cpp b/Source/WebCore/rendering/RenderWidget.cpp index 152bb2f..22283a0 100644 --- a/Source/WebCore/rendering/RenderWidget.cpp +++ b/Source/WebCore/rendering/RenderWidget.cpp @@ -157,9 +157,8 @@ RenderWidget::~RenderWidget() clearWidget(); } -bool RenderWidget::setWidgetGeometry(const IntRect& frame) +bool RenderWidget::setWidgetGeometry(const IntRect& frame, const IntSize& boundsSize) { - ASSERT(!widgetHierarchyUpdateSuspendCount); if (!node()) return false; @@ -175,6 +174,8 @@ bool RenderWidget::setWidgetGeometry(const IntRect& frame) RenderWidgetProtector protector(this); RefPtr<Node> protectedNode(node()); m_widget->setFrameRect(frame); + if (m_widget) // setFrameRect can run arbitrary script, which might clear m_widget. + m_widget->setBoundsSize(boundsSize); #if USE(ACCELERATED_COMPOSITING) if (hasLayer() && layer()->isComposited()) @@ -202,7 +203,7 @@ void RenderWidget::setWidget(PassRefPtr<Widget> widget) // style pointer). if (style()) { if (!needsLayout()) - setWidgetGeometry(absoluteContentBox()); + setWidgetGeometry(IntRect(localToAbsoluteQuad(FloatQuad(contentBoxRect())).boundingBox()), contentBoxRect().size()); if (style()->visibility() != VISIBLE) m_widget->hide(); else @@ -342,14 +343,9 @@ void RenderWidget::updateWidgetPosition() if (!m_widget || !node()) // Check the node in case destroy() has been called. return; - // FIXME: This doesn't work correctly with transforms. - FloatPoint absPos = localToAbsolute(); - absPos.move(borderLeft() + paddingLeft(), borderTop() + paddingTop()); - - int w = width() - borderAndPaddingWidth(); - int h = height() - borderAndPaddingHeight(); - - bool boundsChanged = setWidgetGeometry(IntRect(absPos.x(), absPos.y(), w, h)); + IntRect contentBox = contentBoxRect(); + IntRect absoluteContentBox = IntRect(localToAbsoluteQuad(FloatQuad(contentBox)).boundingBox()); + bool boundsChanged = setWidgetGeometry(absoluteContentBox, contentBox.size()); // if the frame bounds got changed, or if view needs layout (possibly indicating // content size is wrong) we have to do a layout to set the right widget size diff --git a/Source/WebCore/rendering/RenderWidget.h b/Source/WebCore/rendering/RenderWidget.h index d2ec096..5cbdfaf 100644 --- a/Source/WebCore/rendering/RenderWidget.h +++ b/Source/WebCore/rendering/RenderWidget.h @@ -70,7 +70,7 @@ private: virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction); virtual void setOverlapTestResult(bool); - bool setWidgetGeometry(const IntRect&); + bool setWidgetGeometry(const IntRect&, const IntSize&); RefPtr<Widget> m_widget; RefPtr<Image> m_substituteImage; diff --git a/Source/WebCore/rendering/RenderingAllInOne.cpp b/Source/WebCore/rendering/RenderingAllInOne.cpp index 37ba704..faa3566 100644 --- a/Source/WebCore/rendering/RenderingAllInOne.cpp +++ b/Source/WebCore/rendering/RenderingAllInOne.cpp @@ -53,7 +53,6 @@ #include "RenderFieldset.cpp" #include "RenderFileUploadControl.cpp" #include "RenderFlexibleBox.cpp" -#include "RenderForeignObject.cpp" #include "RenderFrame.cpp" #include "RenderFrameBase.cpp" #include "RenderFrameSet.cpp" diff --git a/Source/WebCore/rendering/RootInlineBox.cpp b/Source/WebCore/rendering/RootInlineBox.cpp index 710224e..65130e7 100644 --- a/Source/WebCore/rendering/RootInlineBox.cpp +++ b/Source/WebCore/rendering/RootInlineBox.cpp @@ -29,6 +29,7 @@ #include "GraphicsContext.h" #include "HitTestResult.h" #include "Page.h" +#include "PaintInfo.h" #include "RenderArena.h" #include "RenderBlock.h" diff --git a/Source/WebCore/rendering/SVGResourcesCycleSolver.h b/Source/WebCore/rendering/SVGResourcesCycleSolver.h deleted file mode 100644 index e63ee63..0000000 --- a/Source/WebCore/rendering/SVGResourcesCycleSolver.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - Copyright (C) Research In Motion Limited 2010. All rights reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef SVGResourcesCycleSolver_h -#define SVGResourcesCycleSolver_h - -#if ENABLE(SVG) -#include <wtf/HashSet.h> - -namespace WebCore { - -class RenderObject; -class RenderSVGResourceContainer; -class SVGResources; - -class SVGResourcesCycleSolver : public Noncopyable { -public: - SVGResourcesCycleSolver(RenderObject*, SVGResources*); - ~SVGResourcesCycleSolver(); - - void resolveCycles(); - -private: - bool resourceContainsCycles(RenderObject*) const; - void breakCycle(RenderSVGResourceContainer*); - - RenderObject* m_renderer; - SVGResources* m_resources; - HashSet<RenderSVGResourceContainer*> m_allResources; -}; - -} - -#endif -#endif diff --git a/Source/WebCore/rendering/TextControlInnerElements.cpp b/Source/WebCore/rendering/TextControlInnerElements.cpp index d6fc7aa..5b8712d 100644 --- a/Source/WebCore/rendering/TextControlInnerElements.cpp +++ b/Source/WebCore/rendering/TextControlInnerElements.cpp @@ -383,7 +383,7 @@ inline InputFieldSpeechButtonElement::InputFieldSpeechButtonElement(HTMLElement* InputFieldSpeechButtonElement::~InputFieldSpeechButtonElement() { SpeechInput* speech = speechInput(); - if (speech) { // Could be null when page is unloading. + if (speech && m_listenerId) { // Could be null when page is unloading. if (m_state != Idle) speech->cancelRecognition(m_listenerId); speech->unregisterListener(m_listenerId); @@ -416,6 +416,7 @@ void InputFieldSpeechButtonElement::defaultEventHandler(Event* event) // remove the input element from DOM. To make sure it remains valid until we finish our work // here, we take a temporary reference. RefPtr<HTMLInputElement> holdRef(input); + RefPtr<InputFieldSpeechButtonElement> holdRefButton(this); input->focus(); input->select(); event->setDefaultHandled(); @@ -482,9 +483,14 @@ void InputFieldSpeechButtonElement::setRecognitionResult(int, const SpeechInputR // remove the input element from DOM. To make sure it remains valid until we finish our work // here, we take a temporary reference. RefPtr<HTMLInputElement> holdRef(input); + RefPtr<InputFieldSpeechButtonElement> holdRefButton(this); input->setValue(results.isEmpty() ? "" : results[0]->utterance()); input->dispatchEvent(SpeechInputEvent::create(eventNames().webkitspeechchangeEvent, results)); - renderer()->repaint(); + + // Check before accessing the renderer as the above event could have potentially turned off + // speech in the input element, hence removing this button and renderer from the hierarchy. + if (renderer()) + renderer()->repaint(); } void InputFieldSpeechButtonElement::detach() @@ -494,8 +500,12 @@ void InputFieldSpeechButtonElement::detach() frame->eventHandler()->setCapturingMouseEventsNode(0); } - if (m_state != Idle) - speechInput()->cancelRecognition(m_listenerId); + if (m_listenerId) { + if (m_state != Idle) + speechInput()->cancelRecognition(m_listenerId); + speechInput()->unregisterListener(m_listenerId); + m_listenerId = 0; + } TextControlInnerElement::detach(); } diff --git a/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp b/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp new file mode 100644 index 0000000..14e7656 --- /dev/null +++ b/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2009 Alex Milowski (alex@milowski.com). 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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" + +#if ENABLE(MATHML) + +#include "RenderMathMLBlock.h" + +#include "FontSelector.h" +#include "GraphicsContext.h" +#include "MathMLNames.h" +#include "RenderInline.h" +#include "RenderText.h" + +namespace WebCore { + +using namespace MathMLNames; + +RenderMathMLBlock::RenderMathMLBlock(Node* container) + : RenderBlock(container) +{ +} + +bool RenderMathMLBlock::isChildAllowed(RenderObject* child, RenderStyle*) const +{ + return child->node() && child->node()->nodeType() == Node::ELEMENT_NODE; +} + +PassRefPtr<RenderStyle> RenderMathMLBlock::makeBlockStyle() +{ + RefPtr<RenderStyle> newStyle = RenderStyle::create(); + newStyle->inheritFrom(style()); + newStyle->setDisplay(BLOCK); + return newStyle; +} + +int RenderMathMLBlock::nonOperatorHeight() const +{ + if (!isRenderMathMLOperator()) + return offsetHeight(); + + return 0; +} + +void RenderMathMLBlock::stretchToHeight(int height) +{ + for (RenderObject* current = firstChild(); current; current = current->nextSibling()) + if (current->isRenderMathMLBlock()) { + RenderMathMLBlock* block = toRenderMathMLBlock(current); + block->stretchToHeight(height); + } +} + +#if ENABLE(DEBUG_MATH_LAYOUT) +void RenderMathMLBlock::paint(PaintInfo& info, int tx, int ty) +{ + RenderBlock::paint(info, tx, ty); + + if (info.context->paintingDisabled() || info.phase != PaintPhaseForeground) + return; + + tx += x(); + ty += y(); + + info.context->save(); + + info.context->setStrokeThickness(1.0f); + info.context->setStrokeStyle(SolidStroke); + info.context->setStrokeColor(Color(0, 0, 255), ColorSpaceSRGB); + + info.context->drawLine(IntPoint(tx, ty), IntPoint(tx + offsetWidth(), ty)); + info.context->drawLine(IntPoint(tx + offsetWidth(), ty), IntPoint(tx + offsetWidth(), ty + offsetHeight())); + info.context->drawLine(IntPoint(tx, ty + offsetHeight()), IntPoint(tx + offsetWidth(), ty + offsetHeight())); + info.context->drawLine(IntPoint(tx, ty), IntPoint(tx, ty + offsetHeight())); + + int topStart = paddingTop(); + + info.context->setStrokeColor(Color(0, 255, 0), ColorSpaceSRGB); + + info.context->drawLine(IntPoint(tx, ty + topStart), IntPoint(tx + offsetWidth(), ty + topStart)); + + int baseline = baselinePosition(AlphabeticBaseline, true, HorizontalLine); + + info.context->setStrokeColor(Color(255, 0, 0), ColorSpaceSRGB); + + info.context->drawLine(IntPoint(tx, ty + baseline), IntPoint(tx + offsetWidth(), ty + baseline)); + + info.context->restore(); + +} +#endif // ENABLE(DEBUG_MATH_LAYOUT) + + +} + +#endif diff --git a/Source/WebCore/rendering/mathml/RenderMathMLBlock.h b/Source/WebCore/rendering/mathml/RenderMathMLBlock.h new file mode 100644 index 0000000..f05122a --- /dev/null +++ b/Source/WebCore/rendering/mathml/RenderMathMLBlock.h @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2010 Alex Milowski (alex@milowski.com). 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 RenderMathMLBlock_h +#define RenderMathMLBlock_h + +#if ENABLE(MATHML) + +#include "RenderBlock.h" + +#define ENABLE_DEBUG_MATH_LAYOUT 0 + +namespace WebCore { + +class RenderMathMLBlock : public RenderBlock { +public: + RenderMathMLBlock(Node* container); + virtual bool isChildAllowed(RenderObject*, RenderStyle*) const; + + virtual bool isRenderMathMLBlock() const { return true; } + virtual bool isRenderMathMLOperator() const { return false; } + virtual bool isRenderMathMLRow() const { return false; } + virtual bool isRenderMathMLMath() const { return false; } + virtual bool hasBase() const { return false; } + virtual int nonOperatorHeight() const; + virtual void stretchToHeight(int height); + +#if ENABLE(DEBUG_MATH_LAYOUT) + virtual void paint(PaintInfo&, int tx, int ty); +#endif + +protected: + int getBoxModelObjectHeight(RenderObject* object) + { + if (object && object->isBoxModelObject()) { + RenderBoxModelObject* box = toRenderBoxModelObject(object); + return box->offsetHeight(); + } + + return 0; + } + int getBoxModelObjectHeight(const RenderObject* object) + { + if (object && object->isBoxModelObject()) { + const RenderBoxModelObject* box = toRenderBoxModelObject(object); + return box->offsetHeight(); + } + + return 0; + } + int getBoxModelObjectWidth(RenderObject* object) + { + if (object && object->isBoxModelObject()) { + RenderBoxModelObject* box = toRenderBoxModelObject(object); + return box->offsetWidth(); + } + + return 0; + } + int getBoxModelObjectWidth(const RenderObject* object) + { + if (object && object->isBoxModelObject()) { + const RenderBoxModelObject* box = toRenderBoxModelObject(object); + return box->offsetWidth(); + } + + return 0; + } + virtual PassRefPtr<RenderStyle> makeBlockStyle(); + +}; + +inline RenderMathMLBlock* toRenderMathMLBlock(RenderObject* object) +{ + ASSERT(!object || object->isRenderMathMLBlock()); + return static_cast<RenderMathMLBlock*>(object); +} + +inline const RenderMathMLBlock* toRenderMathMLBlock(const RenderObject* object) +{ + ASSERT(!object || object->isRenderMathMLBlock()); + return static_cast<const RenderMathMLBlock*>(object); +} + +} + + +#endif // ENABLE(MATHML) +#endif // RenderMathMLBlock_h diff --git a/Source/WebCore/rendering/mathml/RenderMathMLFenced.cpp b/Source/WebCore/rendering/mathml/RenderMathMLFenced.cpp new file mode 100644 index 0000000..f7bbf71 --- /dev/null +++ b/Source/WebCore/rendering/mathml/RenderMathMLFenced.cpp @@ -0,0 +1,147 @@ +/* + * Copyright (C) 2009 Alex Milowski (alex@milowski.com). 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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" + +#if ENABLE(MATHML) + +#include "RenderMathMLFenced.h" + +#include "FontSelector.h" +#include "MathMLNames.h" +#include "RenderInline.h" +#include "RenderMathMLOperator.h" +#include "RenderText.h" + +namespace WebCore { + +using namespace MathMLNames; + +enum Braces { OpeningBraceChar = 0x28, ClosingBraceChar = 0x29 }; + +static const float gOperatorPadding = 0.1f; + +RenderMathMLFenced::RenderMathMLFenced(Node* fenced) + : RenderMathMLRow(fenced) + , m_open(OpeningBraceChar) + , m_close(ClosingBraceChar) +{ +} + +void RenderMathMLFenced::updateFromElement() +{ + Element* fenced = static_cast<Element*>(node()); + + // FIXME: Handle open/close values with more than one character (they should be treated like text). + AtomicString openValue = fenced->getAttribute(MathMLNames::openAttr); + if (openValue.length() > 0) + m_open = openValue[0]; + AtomicString closeValue = fenced->getAttribute(MathMLNames::closeAttr); + if (closeValue.length() > 0) + m_close = closeValue[0]; + + AtomicString separators = static_cast<Element*>(fenced)->getAttribute(MathMLNames::separatorsAttr); + if (!separators.isNull()) { + Vector<UChar> characters; + for (unsigned int i = 0; i < separators.length(); i++) { + if (!isSpaceOrNewline(separators[i])) + characters.append(separators[i]); + } + m_separators = !characters.size() ? 0 : StringImpl::create(characters.data() , characters.size()); + } else { + // The separator defaults to a single comma. + m_separators = StringImpl::create(","); + } + + if (isEmpty()) + makeFences(); +} + +RefPtr<RenderStyle> RenderMathMLFenced::makeOperatorStyle() +{ + RefPtr<RenderStyle> newStyle = RenderStyle::create(); + newStyle->inheritFrom(style()); + newStyle->setDisplay(INLINE_BLOCK); + newStyle->setPaddingRight(Length(static_cast<int>(gOperatorPadding * style()->fontSize()), Fixed)); + return newStyle; +} + +void RenderMathMLFenced::makeFences() +{ + RenderObject* openFence = new (renderArena()) RenderMathMLOperator(node(), m_open); + openFence->setStyle(makeOperatorStyle().release()); + RenderBlock::addChild(openFence, firstChild()); + RenderObject* closeFence = new (renderArena()) RenderMathMLOperator(node(), m_close); + closeFence->setStyle(makeOperatorStyle().release()); + RenderBlock::addChild(closeFence); +} + +void RenderMathMLFenced::addChild(RenderObject* child, RenderObject*) +{ + // make the fences if the render object is empty + if (isEmpty()) + updateFromElement(); + + if (m_separators.get()) { + unsigned int count = 0; + for (Node* position = child->node(); position; position = position->previousSibling()) { + if (position->nodeType() == Node::ELEMENT_NODE) + count++; + } + + if (count > 1) { + UChar separator; + + // Use the last separator if we've run out of specified separators. + if ((count - 1) >= m_separators.get()->length()) + separator = (*m_separators.get())[m_separators.get()->length() - 1]; + else + separator = (*m_separators.get())[count - 1]; + + RenderObject* separatorObj = new (renderArena()) RenderMathMLOperator(node(), separator); + separatorObj->setStyle(makeOperatorStyle().release()); + RenderBlock::addChild(separatorObj, lastChild()); + } + } + + // If we have a block, we'll wrap it in an inline-block. + if (child->isBlockFlow() && child->style()->display() != INLINE_BLOCK) { + // Block objects wrapper. + + RenderBlock* block = new (renderArena()) RenderBlock(node()); + RefPtr<RenderStyle> newStyle = RenderStyle::create(); + newStyle->inheritFrom(style()); + newStyle->setDisplay(INLINE_BLOCK); + block->setStyle(newStyle.release()); + + RenderBlock::addChild(block, lastChild()); + block->addChild(child); + } else + RenderBlock::addChild(child, lastChild()); +} + +} + +#endif diff --git a/Source/WebCore/rendering/mathml/RenderMathMLFenced.h b/Source/WebCore/rendering/mathml/RenderMathMLFenced.h new file mode 100644 index 0000000..64e4d90 --- /dev/null +++ b/Source/WebCore/rendering/mathml/RenderMathMLFenced.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2009 Alex Milowski (alex@milowski.com). 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 RenderMathMLFenced_h +#define RenderMathMLFenced_h + +#if ENABLE(MATHML) + +#include "RenderMathMLRow.h" + +namespace WebCore { + +class RenderMathMLFenced : public RenderMathMLRow { +public: + RenderMathMLFenced(Node *fraction); + virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0); + virtual void updateFromElement(); + +private: + void makeFences(); + RefPtr<RenderStyle> makeOperatorStyle(); + UChar m_open; + UChar m_close; + RefPtr<StringImpl> m_separators; +}; + +} + +#endif // ENABLE(MATHML) + +#endif // RenderMathMLFenced_h diff --git a/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp b/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp new file mode 100644 index 0000000..7117618 --- /dev/null +++ b/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp @@ -0,0 +1,188 @@ +/* + * Copyright (C) 2009 Alex Milowski (alex@milowski.com). All rights reserved. + * Copyright (C) 2010 François Sausset (sausset@gmail.com). 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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" + +#if ENABLE(MATHML) + +#include "RenderMathMLFraction.h" + +#include "GraphicsContext.h" +#include "MathMLNames.h" +#include "PaintInfo.h" +#include "RenderText.h" + +namespace WebCore { + +using namespace MathMLNames; + +static const double gHorizontalPad = 0.2; +static const double gLineThin = 0.33; +static const double gLineMedium = 1.; +static const double gLineThick = 3.; +static const double gFractionBarWidth = 0.05; +static const double gDenominatorPad = 0.1; + +RenderMathMLFraction::RenderMathMLFraction(Element* fraction) + : RenderMathMLBlock(fraction) + , m_lineThickness(gLineMedium) +{ + setChildrenInline(false); +} + +void RenderMathMLFraction::updateFromElement() +{ + // FIXME: mfrac where bevelled=true will need to reorganize the descendants + if (isEmpty()) + return; + + Element* fraction = static_cast<Element*>(node()); + + RenderObject* numerator = firstChild(); + String nalign = fraction->getAttribute(MathMLNames::numalignAttr); + if (equalIgnoringCase(nalign, "left")) + numerator->style()->setTextAlign(LEFT); + else if (equalIgnoringCase(nalign, "right")) + numerator->style()->setTextAlign(RIGHT); + else + numerator->style()->setTextAlign(CENTER); + + RenderObject* denominator = numerator->nextSibling(); + if (!denominator) + return; + + String dalign = fraction->getAttribute(MathMLNames::denomalignAttr); + if (equalIgnoringCase(dalign, "left")) + denominator->style()->setTextAlign(LEFT); + else if (equalIgnoringCase(dalign, "right")) + denominator->style()->setTextAlign(RIGHT); + else + denominator->style()->setTextAlign(CENTER); + + // FIXME: parse units + String thickness = fraction->getAttribute(MathMLNames::linethicknessAttr); + m_lineThickness = gLineMedium; + if (equalIgnoringCase(thickness, "thin")) + m_lineThickness = gLineThin; + else if (equalIgnoringCase(thickness, "medium")) + m_lineThickness = gLineMedium; + else if (equalIgnoringCase(thickness, "thick")) + m_lineThickness = gLineThick; + else if (equalIgnoringCase(thickness, "0")) + m_lineThickness = 0; + + // Update the style for the padding of the denominator for the line thickness + lastChild()->style()->setPaddingTop(Length(static_cast<int>(m_lineThickness + style()->fontSize() * gDenominatorPad), Fixed)); +} + +void RenderMathMLFraction::addChild(RenderObject* child, RenderObject* beforeChild) +{ + RenderBlock* row = new (renderArena()) RenderMathMLBlock(node()); + RefPtr<RenderStyle> rowStyle = makeBlockStyle(); + + rowStyle->setTextAlign(CENTER); + Length pad(static_cast<int>(rowStyle->fontSize() * gHorizontalPad), Fixed); + rowStyle->setPaddingLeft(pad); + rowStyle->setPaddingRight(pad); + + // Only add padding for rows as denominators + bool isNumerator = isEmpty(); + if (!isNumerator) + rowStyle->setPaddingTop(Length(2, Fixed)); + + row->setStyle(rowStyle.release()); + RenderBlock::addChild(row, beforeChild); + row->addChild(child); + updateFromElement(); +} + +void RenderMathMLFraction::layout() +{ + updateFromElement(); + + // Adjust the fraction line thickness for the zoom + if (lastChild() && lastChild()->isRenderBlock()) + m_lineThickness *= ceil(gFractionBarWidth * style()->fontSize()); + + RenderBlock::layout(); + +} + +void RenderMathMLFraction::paint(PaintInfo& info, int tx, int ty) +{ + RenderMathMLBlock::paint(info, tx, ty); + if (info.context->paintingDisabled() || info.phase != PaintPhaseForeground) + return; + + if (!firstChild() ||!m_lineThickness) + return; + + int verticalOffset = 0; + // The children are always RenderMathMLBlock instances + if (firstChild()->isRenderMathMLBlock()) { + int adjustForThickness = m_lineThickness > 1 ? int(m_lineThickness / 2) : 1; + if (int(m_lineThickness) % 2 == 1) + adjustForThickness++; + RenderMathMLBlock* numerator = toRenderMathMLBlock(firstChild()); + if (numerator->isRenderMathMLRow()) + verticalOffset = numerator->offsetHeight() + adjustForThickness; + else + verticalOffset = numerator->offsetHeight(); + } + + tx += x(); + ty += y() + verticalOffset; + + info.context->save(); + + info.context->setStrokeThickness(static_cast<float>(m_lineThickness)); + info.context->setStrokeStyle(SolidStroke); + info.context->setStrokeColor(style()->visitedDependentColor(CSSPropertyColor), ColorSpaceSRGB); + + info.context->drawLine(IntPoint(tx, ty), IntPoint(tx + offsetWidth(), ty)); + + info.context->restore(); +} + +int RenderMathMLFraction::baselinePosition(FontBaseline, bool firstLine, LineDirectionMode lineDirection, LinePositionMode linePositionMode) const +{ + if (firstChild() && firstChild()->isRenderMathMLBlock()) { + RenderMathMLBlock* numerator = toRenderMathMLBlock(firstChild()); + RenderStyle* refStyle = style(); + if (previousSibling()) + refStyle = previousSibling()->style(); + else if (nextSibling()) + refStyle = nextSibling()->style(); + int shift = int(ceil((refStyle->font().xHeight() + 1) / 2)); + return numerator->offsetHeight() + shift; + } + return RenderBlock::baselinePosition(AlphabeticBaseline, firstLine, lineDirection, linePositionMode); +} + +} + + +#endif // ENABLE(MATHML) diff --git a/Source/WebCore/rendering/mathml/RenderMathMLFraction.h b/Source/WebCore/rendering/mathml/RenderMathMLFraction.h new file mode 100644 index 0000000..2a03f81 --- /dev/null +++ b/Source/WebCore/rendering/mathml/RenderMathMLFraction.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2009 Alex Milowski (alex@milowski.com). All rights reserved. + * Copyright (C) 2010 François Sausset (sausset@gmail.com). 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 RenderMathMLFraction_h +#define RenderMathMLFraction_h + +#if ENABLE(MATHML) + +#include "RenderMathMLBlock.h" + +namespace WebCore { + +class RenderMathMLFraction : public RenderMathMLBlock { +public: + RenderMathMLFraction(Element* fraction); + virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0); + virtual void updateFromElement(); + virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; + virtual void paint(PaintInfo&, int tx, int ty); +protected: + virtual void layout(); +private: + double m_lineThickness; +}; + +} + +#endif // ENABLE(MATHML) + +#endif // RenderMathMLFraction_h diff --git a/Source/WebCore/rendering/mathml/RenderMathMLMath.cpp b/Source/WebCore/rendering/mathml/RenderMathMLMath.cpp new file mode 100644 index 0000000..2b65f69 --- /dev/null +++ b/Source/WebCore/rendering/mathml/RenderMathMLMath.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2010 Alex Milowski (alex@milowski.com). 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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" + +#if ENABLE(MATHML) + +#include "RenderMathMLMath.h" + +#include "MathMLNames.h" + +namespace WebCore { + +using namespace MathMLNames; + +RenderMathMLMath::RenderMathMLMath(Node* math) + : RenderMathMLRow(math) +{ +} + +} + +#endif // ENABLE(MATHML) + diff --git a/Source/WebCore/rendering/mathml/RenderMathMLMath.h b/Source/WebCore/rendering/mathml/RenderMathMLMath.h new file mode 100644 index 0000000..26f2093 --- /dev/null +++ b/Source/WebCore/rendering/mathml/RenderMathMLMath.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2010 Alex Milowski (alex@milowski.com). 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 RenderMathMLMath_h +#define RenderMathMLMath_h + +#if ENABLE(MATHML) + +#include "RenderMathMLRow.h" + +namespace WebCore { + +class RenderMathMLMath : public RenderMathMLRow { +public: + RenderMathMLMath(Node* container); + virtual bool isRenderMathMLMath() const { return true; } +}; + +} + + +#endif // ENABLE(MATHML) +#endif // RenderMathMLMath_h diff --git a/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp b/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp new file mode 100644 index 0000000..7f039b9 --- /dev/null +++ b/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp @@ -0,0 +1,344 @@ +/* + * Copyright (C) 2010 Alex Milowski (alex@milowski.com). All rights reserved. + * Copyright (C) 2010 François Sausset (sausset@gmail.com). 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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" + +#if ENABLE(MATHML) + +#include "RenderMathMLOperator.h" + +#include "FontSelector.h" +#include "MathMLNames.h" +#include "RenderText.h" + +namespace WebCore { + +using namespace MathMLNames; + +RenderMathMLOperator::RenderMathMLOperator(Node* container) + : RenderMathMLBlock(container) + , m_stretchHeight(0) + , m_operator(0) +{ +} + +RenderMathMLOperator::RenderMathMLOperator(Node* container, UChar operatorChar) + : RenderMathMLBlock(container) + , m_stretchHeight(0) + , m_operator(convertHyphenMinusToMinusSign(operatorChar)) +{ +} + +bool RenderMathMLOperator::isChildAllowed(RenderObject*, RenderStyle*) const +{ + return false; +} + +static const float gOperatorSpacer = 0.1f; +static const float gOperatorExpansion = 1.2f; + +void RenderMathMLOperator::stretchToHeight(int height) +{ + if (height == m_stretchHeight) + return; + m_stretchHeight = static_cast<int>(height * gOperatorExpansion); + + updateBoxModelInfoFromStyle(); + setNeedsLayout(true); +} + +void RenderMathMLOperator::layout() +{ + // FIXME: This probably shouldn't be called here but when the operator + // isn't stretched (e.g. outside of a mrow), it needs to be called somehow + updateFromElement(); + RenderBlock::layout(); +} + +// This is a table of stretchy characters. +// FIXME: Should this be read from the unicode characteristics somehow? +// table: stretchy operator, top char, extension char, bottom char, middle char +static struct StretchyCharacter { + UChar character; + UChar topGlyph; + UChar extensionGlyph; + UChar bottomGlyph; + UChar middleGlyph; +} stretchyCharacters[13] = { + { 0x28 , 0x239b, 0x239c, 0x239d, 0x0 }, // left parenthesis + { 0x29 , 0x239e, 0x239f, 0x23a0, 0x0 }, // right parenthesis + { 0x5b , 0x23a1, 0x23a2, 0x23a3, 0x0 }, // left square bracket + { 0x2308, 0x23a1, 0x23a2, 0x23a2, 0x0 }, // left ceiling + { 0x230a, 0x23a2, 0x23a2, 0x23a3, 0x0 }, // left floor + { 0x5d , 0x23a4, 0x23a5, 0x23a6, 0x0 }, // right square bracket + { 0x2309, 0x23a4, 0x23a5, 0x23a5, 0x0 }, // right ceiling + { 0x230b, 0x23a5, 0x23a5, 0x23a6, 0x0 }, // right floor + { 0x7b , 0x23a7, 0x23aa, 0x23a9, 0x23a8 }, // left curly bracket + { 0x7c , 0x23d0, 0x23d0, 0x23d0, 0x0 }, // vertical bar + { 0x2016, 0x2016, 0x2016, 0x2016, 0x0 }, // double vertical line + { 0x7d , 0x23ab, 0x23aa, 0x23ad, 0x23ac }, // right curly bracket + { 0x222b, 0x2320, 0x23ae, 0x2321, 0x0 } // integral sign +}; + +// We stack glyphs using a 14px height with a displayed glyph height +// of 10px. The line height is set to less than the 14px so that there +// are no blank spaces between the stacked glyphs. +// +// Certain glyphs (e.g. middle and bottom) need to be adjusted upwards +// in the stack so that there isn't a gap. +// +// All of these settings are represented in the constants below. + +// FIXME: use fractions of style()->fontSize() for proper zooming/resizing. +static const int gGlyphFontSize = 14; +static const int gGlyphLineHeight = 11; +static const int gMinimumStretchHeight = 24; +static const int gGlyphHeight = 10; +static const int gTopGlyphTopAdjust = 1; +static const int gMiddleGlyphTopAdjust = -1; +static const int gBottomGlyphTopAdjust = -3; +static const float gMinimumRatioForStretch = 0.10f; + +void RenderMathMLOperator::updateFromElement() +{ + // Destroy our current children + children()->destroyLeftoverChildren(); + + // Since we share a node with our children, destroying our children will set our node's + // renderer to 0, so we need to re-set it back to this. + node()->setRenderer(this); + + // If the operator is fixed, it will be contained in m_operator + UChar firstChar = m_operator; + + // This boolean indicates whether stretching is disabled via the markup. + bool stretchDisabled = false; + + // We made need the element later if we can't stretch. + if (node()->nodeType() == Node::ELEMENT_NODE) { + if (Element* mo = static_cast<Element*>(node())) { + AtomicString stretchyAttr = mo->getAttribute(MathMLNames::stretchyAttr); + stretchDisabled = equalIgnoringCase(stretchyAttr, "false"); + + // If stretching isn't disabled, get the character from the text content. + if (!stretchDisabled && !firstChar) { + String opText = mo->textContent(); + for (unsigned int i = 0; !firstChar && i < opText.length(); i++) { + if (!isSpaceOrNewline(opText[i])) + firstChar = opText[i]; + } + } + } + } + + // The 'index' holds the stretchable character's glyph information + int index = -1; + + // isStretchy indicates whether the character is streatchable via a number of factors. + bool isStretchy = false; + + // Check for a stretchable character. + if (!stretchDisabled && firstChar) { + const int maxIndex = WTF_ARRAY_LENGTH(stretchyCharacters); + for (index++; index < maxIndex; index++) { + if (stretchyCharacters[index].character == firstChar) { + isStretchy = true; + break; + } + } + } + + // We only stretch character if the stretch height is larger than a minimum size (e.g. 24px). + bool shouldStretch = isStretchy && m_stretchHeight>gMinimumStretchHeight; + + // Either stretch is disabled or we don't have a stretchable character over the minimum height + if (stretchDisabled || !shouldStretch) { + m_isStacked = false; + RenderBlock* container = new (renderArena()) RenderMathMLBlock(node()); + + RefPtr<RenderStyle> newStyle = RenderStyle::create(); + newStyle->inheritFrom(style()); + newStyle->setDisplay(INLINE_BLOCK); + newStyle->setVerticalAlign(BASELINE); + + // Check for a stretchable character that is under the minimum height and use the + // font size to adjust the glyph size. + int currentFontSize = style()->fontSize(); + if (!stretchDisabled && isStretchy && m_stretchHeight > 0 && m_stretchHeight <= gMinimumStretchHeight && m_stretchHeight > currentFontSize) { + FontDescription desc; + desc.setIsAbsoluteSize(true); + desc.setSpecifiedSize(m_stretchHeight); + desc.setComputedSize(m_stretchHeight); + newStyle->setFontDescription(desc); + newStyle->font().update(newStyle->font().fontSelector()); + } + + container->setStyle(newStyle.release()); + addChild(container); + + // Build the text of the operator. + RenderText* text = 0; + if (m_operator) + text = new (renderArena()) RenderText(node(), StringImpl::create(&m_operator, 1)); + else if (node()->nodeType() == Node::ELEMENT_NODE) + if (Element* mo = static_cast<Element*>(node())) + text = new (renderArena()) RenderText(node(), mo->textContent().replace(hyphenMinus, minusSign).impl()); + // If we can't figure out the text, leave it blank. + if (text) { + RefPtr<RenderStyle> textStyle = RenderStyle::create(); + textStyle->inheritFrom(container->style()); + text->setStyle(textStyle.release()); + container->addChild(text); + } + } else { + // Build stretchable characters as a stack of glyphs. + m_isStacked = true; + + if (stretchyCharacters[index].middleGlyph) { + // We have a middle glyph (e.g. a curly bracket) that requires special processing. + int half = (m_stretchHeight - gGlyphHeight) / 2; + if (half <= gGlyphHeight) { + // We only have enough space for a single middle glyph. + createGlyph(stretchyCharacters[index].topGlyph, half, gTopGlyphTopAdjust); + createGlyph(stretchyCharacters[index].middleGlyph, gGlyphHeight, gMiddleGlyphTopAdjust); + createGlyph(stretchyCharacters[index].bottomGlyph, 0, gBottomGlyphTopAdjust); + } else { + // We have to extend both the top and bottom to the middle. + createGlyph(stretchyCharacters[index].topGlyph, gGlyphHeight, gTopGlyphTopAdjust); + int remaining = half - gGlyphHeight; + while (remaining > 0) { + if (remaining < gGlyphHeight) { + createGlyph(stretchyCharacters[index].extensionGlyph, remaining); + remaining = 0; + } else { + createGlyph(stretchyCharacters[index].extensionGlyph, gGlyphHeight); + remaining -= gGlyphHeight; + } + } + + // The middle glyph in the stack. + createGlyph(stretchyCharacters[index].middleGlyph, gGlyphHeight, gMiddleGlyphTopAdjust); + + // The remaining is the top half minus the middle glyph height. + remaining = half - gGlyphHeight; + // We need to make sure we have the full height in case the height is odd. + if (m_stretchHeight % 2 == 1) + remaining++; + + // Extend to the bottom glyph. + while (remaining > 0) { + if (remaining < gGlyphHeight) { + createGlyph(stretchyCharacters[index].extensionGlyph, remaining); + remaining = 0; + } else { + createGlyph(stretchyCharacters[index].extensionGlyph, gGlyphHeight); + remaining -= gGlyphHeight; + } + } + + // The bottom glyph in the stack. + createGlyph(stretchyCharacters[index].bottomGlyph, 0, gBottomGlyphTopAdjust); + } + } else { + // We do not have a middle glyph and so we just extend from the top to the bottom glyph. + int remaining = m_stretchHeight - 2 * gGlyphHeight; + createGlyph(stretchyCharacters[index].topGlyph, gGlyphHeight, gTopGlyphTopAdjust); + while (remaining > 0) { + if (remaining < gGlyphHeight) { + createGlyph(stretchyCharacters[index].extensionGlyph, remaining); + remaining = 0; + } else { + createGlyph(stretchyCharacters[index].extensionGlyph, gGlyphHeight); + remaining -= gGlyphHeight; + } + } + createGlyph(stretchyCharacters[index].bottomGlyph, 0, gBottomGlyphTopAdjust); + } + } +} + +RefPtr<RenderStyle> RenderMathMLOperator::createStackableStyle(int size, int topRelative) +{ + RefPtr<RenderStyle> newStyle = RenderStyle::create(); + newStyle->inheritFrom(style()); + newStyle->setDisplay(BLOCK); + + FontDescription desc; + desc.setIsAbsoluteSize(true); + desc.setSpecifiedSize(gGlyphFontSize); + desc.setComputedSize(gGlyphFontSize); + newStyle->setFontDescription(desc); + newStyle->font().update(newStyle->font().fontSelector()); + newStyle->setLineHeight(Length(gGlyphLineHeight, Fixed)); + newStyle->setVerticalAlign(TOP); + + if (size > 0) + newStyle->setMaxHeight(Length(size, Fixed)); + + newStyle->setOverflowY(OHIDDEN); + newStyle->setOverflowX(OHIDDEN); + if (topRelative) { + newStyle->setTop(Length(topRelative, Fixed)); + newStyle->setPosition(RelativePosition); + } + + return newStyle; +} + +RenderBlock* RenderMathMLOperator::createGlyph(UChar glyph, int size, int charRelative, int topRelative) +{ + RenderBlock* container = new (renderArena()) RenderMathMLBlock(node()); + container->setStyle(createStackableStyle(size, topRelative).release()); + addChild(container); + RenderBlock* parent = container; + if (charRelative) { + RenderBlock* charBlock = new (renderArena()) RenderBlock(node()); + RefPtr<RenderStyle> charStyle = RenderStyle::create(); + charStyle->inheritFrom(container->style()); + charStyle->setDisplay(INLINE_BLOCK); + charStyle->setTop(Length(charRelative, Fixed)); + charStyle->setPosition(RelativePosition); + charBlock->setStyle(charStyle); + parent->addChild(charBlock); + parent = charBlock; + } + + RenderText* text = new (renderArena()) RenderText(node(), StringImpl::create(&glyph, 1)); + text->setStyle(container->style()); + parent->addChild(text); + return container; +} + +int RenderMathMLOperator::baselinePosition(FontBaseline, bool firstLine, LineDirectionMode lineDirection, LinePositionMode linePositionMode) const +{ + if (m_isStacked) + return m_stretchHeight * 2 / 3 - (m_stretchHeight - static_cast<int>(m_stretchHeight / gOperatorExpansion)) / 2; + return RenderBlock::baselinePosition(AlphabeticBaseline, firstLine, lineDirection, linePositionMode); +} + +} + +#endif diff --git a/Source/WebCore/rendering/mathml/RenderMathMLOperator.h b/Source/WebCore/rendering/mathml/RenderMathMLOperator.h new file mode 100644 index 0000000..6501494 --- /dev/null +++ b/Source/WebCore/rendering/mathml/RenderMathMLOperator.h @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2010 Alex Milowski (alex@milowski.com). 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 RenderMathMLOperator_h +#define RenderMathMLOperator_h + +#if ENABLE(MATHML) + +#include "CharacterNames.h" +#include "RenderMathMLBlock.h" + +namespace WebCore { + +class RenderMathMLOperator : public RenderMathMLBlock { +public: + RenderMathMLOperator(Node* container); + RenderMathMLOperator(Node* container, UChar operatorChar); + virtual bool isRenderMathMLOperator() const { return true; } + virtual void stretchToHeight(int pixelHeight); + virtual void updateFromElement(); + virtual bool isChildAllowed(RenderObject*, RenderStyle*) const; + virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; + +protected: + virtual void layout(); + virtual RefPtr<RenderStyle> createStackableStyle(int size, int topRelative); + virtual RenderBlock* createGlyph(UChar glyph, int size = 0, int charRelative = 0, int topRelative = 0); + +private: + int m_stretchHeight; + bool m_isStacked; + UChar m_operator; +}; + +inline RenderMathMLOperator* toRenderMathMLOperator(RenderMathMLBlock* block) +{ + ASSERT(!block || block->isRenderMathMLOperator()); + return static_cast<RenderMathMLOperator*>(block); +} + +inline const RenderMathMLOperator* toRenderMathMLOperator(const RenderMathMLBlock* block) +{ + ASSERT(!block || block->isRenderMathMLOperator()); + return static_cast<const RenderMathMLOperator*>(block); +} + +inline UChar convertHyphenMinusToMinusSign(UChar glyph) +{ + // When rendered as a mathematical operator, minus glyph should be larger. + if (glyph == hyphenMinus) + return minusSign; + + return glyph; +} + +} + +#endif // ENABLE(MATHML) +#endif // RenderMathMLOperator_h diff --git a/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp b/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp new file mode 100644 index 0000000..075f6ba --- /dev/null +++ b/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp @@ -0,0 +1,259 @@ +/* + * Copyright (C) 2009 Alex Milowski (alex@milowski.com). All rights reserved. + * Copyright (C) 2010 François Sausset (sausset@gmail.com). 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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" + +#if ENABLE(MATHML) + +#include "RenderMathMLRoot.h" + +#include "GraphicsContext.h" +#include "MathMLNames.h" +#include "PaintInfo.h" + +namespace WebCore { + +using namespace MathMLNames; + +// Left margin of the radical (px) +const int gRadicalLeftMargin = 3; +// Bottom padding of the radical (px) +const int gRadicalBasePad = 3; +// Threshold above which the radical shape is modified to look nice with big bases (%) +const float gThresholdBaseHeight = 1.5f; +// Radical width (%) +const float gRadicalWidth = 0.75f; +// Horizontal position of the bottom point of the radical (%) +const float gRadicalBottomPointXPos= 0.5f; +// Horizontal position of the top left point of the radical (%) +const float gRadicalTopLeftPointXPos = 0.8f; +// Vertical position of the top left point of the radical (%) +const float gRadicalTopLeftPointYPos = 0.625f; +// Vertical shift of the left end point of the radical (%) +const float gRadicalLeftEndYShift = 0.05f; +// Root padding around the base (%) +const float gRootPadding = 0.2f; +// Additional bottom root padding (%) +const float gRootBottomPadding = 0.2f; + +// Radical line thickness (%) +const float gRadicalLineThickness = 0.02f; +// Radical thick line thickness (%) +const float gRadicalThickLineThickness = 0.1f; + +RenderMathMLRoot::RenderMathMLRoot(Node *expression) +: RenderMathMLBlock(expression) +{ +} + +void RenderMathMLRoot::addChild(RenderObject* child, RenderObject* ) +{ + if (isEmpty()) { + // Add a block for the index + RenderBlock* block = new (renderArena()) RenderBlock(node()); + RefPtr<RenderStyle> indexStyle = makeBlockStyle(); + indexStyle->setDisplay(INLINE_BLOCK); + block->setStyle(indexStyle.release()); + RenderBlock::addChild(block); + + // FIXME: the wrapping does not seem to be needed anymore. + // this is the base, so wrap it so we can pad it + block = new (renderArena()) RenderBlock(node()); + RefPtr<RenderStyle> baseStyle = makeBlockStyle(); + baseStyle->setDisplay(INLINE_BLOCK); + baseStyle->setPaddingLeft(Length(5 * gRadicalWidth , Percent)); + block->setStyle(baseStyle.release()); + RenderBlock::addChild(block); + block->addChild(child); + } else { + // always add to the index + firstChild()->addChild(child); + } +} + +void RenderMathMLRoot::paint(PaintInfo& info, int tx, int ty) +{ + RenderMathMLBlock::paint(info , tx , ty); + + if (info.context->paintingDisabled()) + return; + + if (!firstChild() || !lastChild()) + return; + + tx += x(); + ty += y(); + + RenderBoxModelObject* indexBox = toRenderBoxModelObject(lastChild()); + + int maxHeight = indexBox->offsetHeight(); + // default to the font size in pixels if we're empty + if (!maxHeight) + maxHeight = style()->fontSize(); + int width = indexBox->offsetWidth(); + + int indexWidth = 0; + RenderObject* current = firstChild(); + while (current != lastChild()) { + if (current->isBoxModelObject()) { + RenderBoxModelObject* box = toRenderBoxModelObject(current); + indexWidth += box->offsetWidth(); + } + current = current->nextSibling(); + } + + int frontWidth = static_cast<int>(style()->fontSize() * gRadicalWidth); + int topStartShift = 0; + // Base height above which the shape of the root changes + int thresholdHeight = static_cast<int>(gThresholdBaseHeight * style()->fontSize()); + + if (maxHeight > thresholdHeight && thresholdHeight) { + float shift = (maxHeight - thresholdHeight) / static_cast<float>(thresholdHeight); + if (shift > 1.) + shift = 1.0f; + topStartShift = static_cast<int>(gRadicalBottomPointXPos * frontWidth * shift); + } + + width += topStartShift; + + int rootPad = static_cast<int>(gRootPadding * style()->fontSize()); + int start = tx + indexWidth + gRadicalLeftMargin + style()->paddingLeft().value() - rootPad; + ty += style()->paddingTop().value() - rootPad; + + FloatPoint topStart(start - topStartShift, ty); + FloatPoint bottomLeft(start - gRadicalBottomPointXPos * frontWidth , ty + maxHeight + gRadicalBasePad); + FloatPoint topLeft(start - gRadicalTopLeftPointXPos * frontWidth , ty + gRadicalTopLeftPointYPos * maxHeight); + FloatPoint leftEnd(start - frontWidth , topLeft.y() + gRadicalLeftEndYShift * style()->fontSize()); + + info.context->save(); + + info.context->setStrokeThickness(gRadicalLineThickness * style()->fontSize()); + info.context->setStrokeStyle(SolidStroke); + info.context->setStrokeColor(style()->visitedDependentColor(CSSPropertyColor), ColorSpaceDeviceRGB); + info.context->setLineJoin(MiterJoin); + info.context->setMiterLimit(style()->fontSize()); + + Path root; + + root.moveTo(FloatPoint(topStart.x() + width, ty)); + // draw top + root.addLineTo(topStart); + // draw from top left corner to bottom point of radical + root.addLineTo(bottomLeft); + // draw from bottom point to top of left part of radical base "pocket" + root.addLineTo(topLeft); + // draw to end + root.addLineTo(leftEnd); + + info.context->strokePath(root); + + info.context->save(); + + // Build a mask to draw the thick part of the root. + Path mask; + + mask.moveTo(topStart); + mask.addLineTo(bottomLeft); + mask.addLineTo(topLeft); + mask.addLineTo(FloatPoint(2 * topLeft.x() - leftEnd.x(), 2 * topLeft.y() - leftEnd.y())); + + info.context->clip(mask); + + // Draw the thick part of the root. + info.context->setStrokeThickness(gRadicalThickLineThickness * style()->fontSize()); + info.context->setLineCap(SquareCap); + + Path line; + line.moveTo(bottomLeft); + line.addLineTo(topLeft); + + info.context->strokePath(line); + + info.context->restore(); + + info.context->restore(); + +} + +void RenderMathMLRoot::layout() +{ + RenderBlock::layout(); + + if (!firstChild() || !lastChild()) + return; + + int maxHeight = toRenderBoxModelObject(lastChild())->offsetHeight(); + + RenderObject* current = lastChild()->firstChild(); + if (current) + current->style()->setVerticalAlign(BASELINE); + + if (!maxHeight) + maxHeight = style()->fontSize(); + + // Base height above which the shape of the root changes + int thresholdHeight = static_cast<int>(gThresholdBaseHeight * style()->fontSize()); + int topStartShift = 0; + + if (maxHeight > thresholdHeight && thresholdHeight) { + float shift = (maxHeight - thresholdHeight) / static_cast<float>(thresholdHeight); + if (shift > 1.) + shift = 1.0f; + int frontWidth = static_cast<int>(style()->fontSize() * gRadicalWidth); + topStartShift = static_cast<int>(gRadicalBottomPointXPos * frontWidth * shift); + + style()->setPaddingBottom(Length(static_cast<int>(gRootBottomPadding * style()->fontSize()), Fixed)); + } + + // Positioning of the index + RenderBoxModelObject* indexBox = toRenderBoxModelObject(firstChild()->firstChild()); + if (!indexBox) + return; + + int indexShift = indexBox->offsetWidth() + topStartShift; + int radicalHeight = static_cast<int>((1 - gRadicalTopLeftPointYPos) * maxHeight); + int rootMarginTop = radicalHeight + style()->paddingBottom().value() + indexBox->offsetHeight() - (maxHeight + static_cast<int>(gRootPadding * style()->fontSize())); + + style()->setPaddingLeft(Length(indexShift, Fixed)); + if (rootMarginTop > 0) + style()->setPaddingTop(Length(rootMarginTop + static_cast<int>(gRootPadding * style()->fontSize()), Fixed)); + + setNeedsLayout(true); + setPreferredLogicalWidthsDirty(true, false); + RenderBlock::layout(); + + indexBox->style()->setBottom(Length(radicalHeight + style()->paddingBottom().value(), Fixed)); + + // Now that we've potentially changed its position, we need layout the index again. + indexBox->setNeedsLayout(true); + indexBox->layout(); +} + +} + +#endif // ENABLE(MATHML) + + diff --git a/Source/WebCore/rendering/mathml/RenderMathMLRoot.h b/Source/WebCore/rendering/mathml/RenderMathMLRoot.h new file mode 100644 index 0000000..80f56ac --- /dev/null +++ b/Source/WebCore/rendering/mathml/RenderMathMLRoot.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2009 Alex Milowski (alex@milowski.com). 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 RenderMathMLRoot_h +#define RenderMathMLRoot_h + +#if ENABLE(MATHML) + +#include "RenderMathMLBlock.h" + +namespace WebCore { + +class RenderMathMLRoot : public RenderMathMLBlock { +public: + RenderMathMLRoot(Node* fraction); + virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0); + virtual void paint(PaintInfo&, int tx, int ty); +protected: + virtual void layout(); +}; + +} + +#endif // ENABLE(MATHML) + +#endif // RenderMathMLRoot_h diff --git a/Source/WebCore/rendering/mathml/RenderMathMLRow.cpp b/Source/WebCore/rendering/mathml/RenderMathMLRow.cpp new file mode 100644 index 0000000..ad54846 --- /dev/null +++ b/Source/WebCore/rendering/mathml/RenderMathMLRow.cpp @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2010 Alex Milowski (alex@milowski.com). 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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" + +#if ENABLE(MATHML) + +#include "RenderMathMLRow.h" + +#include "MathMLNames.h" +#include "RenderMathMLOperator.h" + +namespace WebCore { + +using namespace MathMLNames; + +RenderMathMLRow::RenderMathMLRow(Node* row) + : RenderMathMLBlock(row) +{ +} + +int RenderMathMLRow::nonOperatorHeight() const +{ + int maxHeight = 0; + for (RenderObject* current = firstChild(); current; current = current->nextSibling()) { + if (current->isRenderMathMLBlock()) { + RenderMathMLBlock* block = toRenderMathMLBlock(current); + int blockHeight = block->nonOperatorHeight(); + // Check to see if this box has a larger height + if (blockHeight > maxHeight) + maxHeight = blockHeight; + } else if (current->isBoxModelObject()) { + RenderBoxModelObject* box = toRenderBoxModelObject(current); + // Check to see if this box has a larger height + if (box->offsetHeight() > maxHeight) + maxHeight = box->offsetHeight(); + } + + } + return maxHeight; +} + +void RenderMathMLRow::layout() +{ + RenderBlock::layout(); + + int maxHeight = 0; + int childCount = 0; + int operatorCount = 0; + + // Calculate the non-operator max height of the row. + int operatorHeight = 0; + for (RenderObject* current = firstChild(); current; current = current->nextSibling()) { + childCount++; + if (current->isRenderMathMLBlock()) { + RenderMathMLBlock* block = toRenderMathMLBlock(current); + // Check to see if the non-operator block has a greater height. + if (!block->hasBase() && !block->isRenderMathMLOperator() && block->offsetHeight() > maxHeight) + maxHeight = block->offsetHeight(); + if (block->hasBase() && block->nonOperatorHeight() > maxHeight) + maxHeight = block->nonOperatorHeight(); + // If the block is an operator, capture the maximum height and increment the count. + if (block->isRenderMathMLOperator()) { + if (block->offsetHeight() > operatorHeight) + operatorHeight = block->offsetHeight(); + operatorCount++; + } + } else if (current->isBoxModelObject()) { + RenderBoxModelObject* box = toRenderBoxModelObject(current); + // Check to see if this box has a larger height. + if (box->offsetHeight() > maxHeight) + maxHeight = box->offsetHeight(); + } + } + + if (childCount > 0 && childCount == operatorCount) { + // We have only operators and so set the max height to the operator height. + maxHeight = operatorHeight; + } + + // Stretch everything to the same height (blocks can ignore the request). + if (maxHeight > 0) { + bool didStretch = false; + for (RenderObject* current = firstChild(); current; current = current->nextSibling()) { + if (current->isRenderMathMLBlock()) { + RenderMathMLBlock* block = toRenderMathMLBlock(current); + block->stretchToHeight(maxHeight); + didStretch = true; + } + } + if (didStretch) { + setNeedsLayout(true); + setPreferredLogicalWidthsDirty(true, false); + RenderBlock::layout(); + } + } + +} + +int RenderMathMLRow::baselinePosition(FontBaseline, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const +{ + if (firstChild() && firstChild()->isRenderMathMLBlock()) { + RenderMathMLBlock* block = toRenderMathMLBlock(firstChild()); + if (block->isRenderMathMLOperator()) + return block->y() + block->baselinePosition(AlphabeticBaseline, firstLine, direction, linePositionMode); + } + + return RenderBlock::baselinePosition(AlphabeticBaseline, firstLine, direction, linePositionMode); +} + +} + +#endif // ENABLE(MATHML) + diff --git a/Source/WebCore/rendering/mathml/RenderMathMLRow.h b/Source/WebCore/rendering/mathml/RenderMathMLRow.h new file mode 100644 index 0000000..62a0d09 --- /dev/null +++ b/Source/WebCore/rendering/mathml/RenderMathMLRow.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2010 Alex Milowski (alex@milowski.com). 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 RenderMathMLRow_h +#define RenderMathMLRow_h + +#if ENABLE(MATHML) + +#include "RenderMathMLBlock.h" + +namespace WebCore { + +class RenderMathMLRow : public RenderMathMLBlock { +public: + RenderMathMLRow(Node* container); + virtual bool isRenderMathMLRow() const { return true; } + virtual int nonOperatorHeight() const; + virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; + virtual void stretchToHeight(int) {} +protected: + virtual void layout(); +}; + +} + + +#endif // ENABLE(MATHML) +#endif // RenderMathMLRow_h diff --git a/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.cpp b/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.cpp new file mode 100644 index 0000000..3f99e6d --- /dev/null +++ b/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.cpp @@ -0,0 +1,198 @@ +/* + * Copyright (C) 2009 Alex Milowski (alex@milowski.com). All rights reserved. + * Copyright (C) 2010 François Sausset (sausset@gmail.com). 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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" + +#if ENABLE(MATHML) + +#include "RenderMathMLSquareRoot.h" + +#include "GraphicsContext.h" +#include "MathMLNames.h" +#include "PaintInfo.h" +#include "Path.h" + +namespace WebCore { + +using namespace MathMLNames; + +// Bottom padding of the radical (px) +const int gRadicalBasePad = 3; +// Threshold above which the radical shape is modified to look nice with big bases (%) +const float gThresholdBaseHeight = 1.5f; +// Radical width (%) +const float gRadicalWidth = 0.75f; +// Horizontal position of the bottom point of the radical (%) +const float gRadicalBottomPointXPos= 0.5f; +// Horizontal position of the top left point of the radical (%) +const float gRadicalTopLeftPointXPos = 0.2f; +// Vertical position of the top left point of the radical (%) +const float gRadicalTopLeftPointYPos = 0.5f; +// Vertical shift of the left end point of the radical (%) +const float gRadicalLeftEndYShift = 0.05f; +// Additional bottom root padding (%) +const float gRootBottomPadding = 0.2f; + +// Radical line thickness (%) +const float gRadicalLineThickness = 0.02f; +// Radical thick line thickness (%) +const float gRadicalThickLineThickness = 0.1f; + +RenderMathMLSquareRoot::RenderMathMLSquareRoot(Node *expression) + : RenderMathMLBlock(expression) +{ +} + +void RenderMathMLSquareRoot::paint(PaintInfo& info, int tx, int ty) +{ + RenderMathMLBlock::paint(info, tx, ty); + + if (info.context->paintingDisabled()) + return; + + tx += x(); + ty += y(); + + int maxHeight = 0; + int width = 0; + RenderObject* current = firstChild(); + while (current) { + if (current->isBoxModelObject()) { + + RenderBoxModelObject* box = toRenderBoxModelObject(current); + + // Check to see if this box has a larger height + if (box->offsetHeight() > maxHeight) + maxHeight = box->offsetHeight(); + width += box->offsetWidth(); + } + current = current->nextSibling(); + } + // default to the font size in pixels if we're empty + if (!maxHeight) + maxHeight = style()->fontSize(); + + int frontWidth = static_cast<int>(style()->fontSize() * gRadicalWidth); + int topStartShift = 0; + // Base height above which the shape of the root changes + int thresholdHeight = static_cast<int>(gThresholdBaseHeight * style()->fontSize()); + + if (maxHeight > thresholdHeight && thresholdHeight) { + float shift = (maxHeight - thresholdHeight) / static_cast<float>(thresholdHeight); + if (shift > 1.) + shift = 1.0f; + topStartShift = static_cast<int>(gRadicalBottomPointXPos * frontWidth * shift); + } + + width += topStartShift; + + FloatPoint topStart(tx + frontWidth - topStartShift, ty); + FloatPoint bottomLeft(tx + frontWidth * gRadicalBottomPointXPos , ty + maxHeight + gRadicalBasePad); + FloatPoint topLeft(tx + frontWidth * gRadicalTopLeftPointXPos , ty + gRadicalTopLeftPointYPos * maxHeight); + FloatPoint leftEnd(tx , topLeft.y() + gRadicalLeftEndYShift * style()->fontSize()); + + info.context->save(); + + info.context->setStrokeThickness(gRadicalLineThickness * style()->fontSize()); + info.context->setStrokeStyle(SolidStroke); + info.context->setStrokeColor(style()->visitedDependentColor(CSSPropertyColor), ColorSpaceDeviceRGB); + info.context->setLineJoin(MiterJoin); + info.context->setMiterLimit(style()->fontSize()); + + Path root; + + root.moveTo(FloatPoint(topStart.x() + width , ty)); + // draw top + root.addLineTo(topStart); + // draw from top left corner to bottom point of radical + root.addLineTo(bottomLeft); + // draw from bottom point to top of left part of radical base "pocket" + root.addLineTo(topLeft); + // draw to end + root.addLineTo(leftEnd); + + info.context->strokePath(root); + + info.context->save(); + + // Build a mask to draw the thick part of the root. + Path mask; + + mask.moveTo(topStart); + mask.addLineTo(bottomLeft); + mask.addLineTo(topLeft); + mask.addLineTo(FloatPoint(2 * topLeft.x() - leftEnd.x(), 2 * topLeft.y() - leftEnd.y())); + + info.context->clip(mask); + + // Draw the thick part of the root. + info.context->setStrokeThickness(gRadicalThickLineThickness * style()->fontSize()); + info.context->setLineCap(SquareCap); + + Path line; + line.moveTo(bottomLeft); + line.addLineTo(topLeft); + + info.context->strokePath(line); + + info.context->restore(); + + info.context->restore(); +} + +void RenderMathMLSquareRoot::layout() +{ + int maxHeight = 0; + + RenderObject* current = firstChild(); + while (current) { + if (current->isBoxModelObject()) { + RenderBoxModelObject* box = toRenderBoxModelObject(current); + + if (box->offsetHeight() > maxHeight) + maxHeight = box->offsetHeight(); + + box->style()->setVerticalAlign(BASELINE); + } + current = current->nextSibling(); + } + + if (!maxHeight) + maxHeight = style()->fontSize(); + + + if (maxHeight > static_cast<int>(gThresholdBaseHeight * style()->fontSize())) + style()->setPaddingBottom(Length(static_cast<int>(gRootBottomPadding * style()->fontSize()), Fixed)); + + + RenderBlock::layout(); +} + +} + +#endif // ENABLE(MATHML) + + diff --git a/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.h b/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.h new file mode 100644 index 0000000..d40b1ba --- /dev/null +++ b/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2009 Alex Milowski (alex@milowski.com). 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 RenderMathMLSquareRoot_h +#define RenderMathMLSquareRoot_h + +#if ENABLE(MATHML) + +#include "RenderMathMLBlock.h" + +namespace WebCore { + +class RenderMathMLSquareRoot : public RenderMathMLBlock { +public: + RenderMathMLSquareRoot(Node* fraction); + virtual void paint(PaintInfo&, int tx, int ty); +protected: + virtual void layout(); +}; + +} + +#endif // ENABLE(MATHML) + +#endif // RenderMathMLSquareRoot_h + + + diff --git a/Source/WebCore/rendering/mathml/RenderMathMLSubSup.cpp b/Source/WebCore/rendering/mathml/RenderMathMLSubSup.cpp new file mode 100644 index 0000000..0ea6667 --- /dev/null +++ b/Source/WebCore/rendering/mathml/RenderMathMLSubSup.cpp @@ -0,0 +1,212 @@ +/* + * Copyright (C) 2010 Alex Milowski (alex@milowski.com). 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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" + +#if ENABLE(MATHML) + +#include "RenderMathMLSubSup.h" + +#include "FontSelector.h" +#include "MathMLNames.h" +#include "RenderInline.h" +#include "RenderTable.h" +#include "RenderTableCell.h" +#include "RenderTableRow.h" +#include "RenderTableSection.h" +#include "RenderText.h" + +namespace WebCore { + +using namespace MathMLNames; + +static const int gTopAdjustDivisor = 3; +static const int gSubsupScriptMargin = 1; +static const float gSubSupStretch = 1.2f; + +RenderMathMLSubSup::RenderMathMLSubSup(Element* element) + : RenderMathMLBlock(element) + , m_scripts(0) +{ + // Determine what kind of under/over expression we have by element name + if (element->hasLocalName(MathMLNames::msubTag)) + m_kind = Sub; + else if (element->hasLocalName(MathMLNames::msupTag)) + m_kind = Sup; + else if (element->hasLocalName(MathMLNames::msubsupTag)) + m_kind = SubSup; + else + m_kind = SubSup; +} + +void RenderMathMLSubSup::addChild(RenderObject* child, RenderObject* beforeChild) +{ + if (firstChild()) { + // We already have a base, so this is the super/subscripts being added. + + if (m_kind == SubSup) { + if (!m_scripts) { + m_scripts = new (renderArena()) RenderMathMLBlock(node()); + RefPtr<RenderStyle> scriptsStyle = RenderStyle::create(); + scriptsStyle->inheritFrom(style()); + scriptsStyle->setDisplay(INLINE_BLOCK); + scriptsStyle->setVerticalAlign(TOP); + scriptsStyle->setMarginLeft(Length(gSubsupScriptMargin, Fixed)); + scriptsStyle->setTextAlign(LEFT); + m_scripts->setStyle(scriptsStyle.release()); + RenderMathMLBlock::addChild(m_scripts, beforeChild); + } + + RenderBlock* script = new (renderArena()) RenderMathMLBlock(node()); + RefPtr<RenderStyle> scriptStyle = RenderStyle::create(); + scriptStyle->inheritFrom(m_scripts->style()); + scriptStyle->setDisplay(BLOCK); + script->setStyle(scriptStyle.release()); + + m_scripts->addChild(script, m_scripts->firstChild()); + script->addChild(child); + } else + RenderMathMLBlock::addChild(child, beforeChild); + + } else { + RenderMathMLBlock* wrapper = new (renderArena()) RenderMathMLBlock(node()); + RefPtr<RenderStyle> wrapperStyle = RenderStyle::create(); + wrapperStyle->inheritFrom(style()); + wrapperStyle->setDisplay(INLINE_BLOCK); + wrapperStyle->setVerticalAlign(BASELINE); + wrapper->setStyle(wrapperStyle.release()); + RenderMathMLBlock::addChild(wrapper, beforeChild); + wrapper->addChild(child); + + } +} + +void RenderMathMLSubSup::stretchToHeight(int height) +{ + RenderObject* base = firstChild(); + if (!base) + return; + + if (base->firstChild()->isRenderMathMLBlock()) { + RenderMathMLBlock* block = toRenderMathMLBlock(base->firstChild()); + block->stretchToHeight(static_cast<int>(gSubSupStretch * height)); + + // Adjust the script placement after we stretch + if (height > 0 && m_kind == SubSup && m_scripts) { + RenderObject* script = m_scripts->firstChild(); + if (script) { + // Calculate the script height without the container margins. + RenderObject* top = script; + int topHeight = getBoxModelObjectHeight(top->firstChild()); + int topAdjust = topHeight / gTopAdjustDivisor; + top->style()->setMarginTop(Length(-topAdjust, Fixed)); + top->style()->setMarginBottom(Length(height - topHeight + topAdjust, Fixed)); + if (top->isBoxModelObject()) { + RenderBoxModelObject* topBox = toRenderBoxModelObject(top); + topBox->updateBoxModelInfoFromStyle(); + } + m_scripts->setNeedsLayout(true); + setNeedsLayout(true); + } + } + + } +} + +int RenderMathMLSubSup::nonOperatorHeight() const +{ + if (m_kind == SubSup) + return static_cast<int>(style()->fontSize()*gSubSupStretch); + return static_cast<int>(style()->fontSize()); +} + +void RenderMathMLSubSup::layout() +{ + if (firstChild()) + firstChild()->setNeedsLayout(true); + if (m_scripts) + m_scripts->setNeedsLayout(true); + + RenderBlock::layout(); + + if (m_kind == SubSup) { + if (RenderObject* base = firstChild()) { + int maxHeight = 0; + RenderObject* current = base->firstChild(); + while (current) { + int height = getBoxModelObjectHeight(current); + if (height > maxHeight) + maxHeight = height; + current = current->nextSibling(); + } + int heightDiff = m_scripts ? (m_scripts->offsetHeight() - maxHeight) / 2 : 0; + if (heightDiff < 0) + heightDiff = 0; + base->style()->setPaddingTop(Length(heightDiff, Fixed)); + base->setNeedsLayout(true); + } + setNeedsLayout(true); + RenderBlock::layout(); + } +} + +int RenderMathMLSubSup::baselinePosition(FontBaseline, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const +{ + RenderObject* base = firstChild(); + if (!base) + return offsetHeight(); + + int baseline = offsetHeight(); + if (!base || !base->isBoxModelObject()) + return baseline; + + switch (m_kind) { + case SubSup: + base = base->firstChild(); + if (m_scripts && base->isBoxModelObject()) { + RenderBoxModelObject* box = toRenderBoxModelObject(base); + + int topAdjust = (m_scripts->offsetHeight() - box->offsetHeight()) / 2; + + // FIXME: The last bit of this calculation should be more exact. Why is the 2-3px scaled for zoom necessary? + // The baseline is top spacing of the base + the baseline of the base + adjusted space for zoom + float zoomFactor = style()->effectiveZoom(); + return topAdjust + box->baselinePosition(AlphabeticBaseline, firstLine, direction, linePositionMode) + static_cast<int>((zoomFactor > 1.25 ? 2 : 3) * zoomFactor); + } + break; + case Sup: + case Sub: + RenderBoxModelObject* box = toRenderBoxModelObject(base); + baseline = box->baselinePosition(AlphabeticBaseline, firstLine, direction, linePositionMode); + break; + } + + return baseline; + +} + +} + +#endif // ENABLE(MATHML) diff --git a/Source/WebCore/rendering/mathml/RenderMathMLSubSup.h b/Source/WebCore/rendering/mathml/RenderMathMLSubSup.h new file mode 100644 index 0000000..7a9d310 --- /dev/null +++ b/Source/WebCore/rendering/mathml/RenderMathMLSubSup.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2010 Alex Milowski (alex@milowski.com). 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 RenderMathMLSubSup_h +#define RenderMathMLSubSup_h + +#if ENABLE(MATHML) + +#include "RenderMathMLBlock.h" +#include "RenderTable.h" + +namespace WebCore { + +class RenderMathMLSubSup : public RenderMathMLBlock { +public: + RenderMathMLSubSup(Element* fraction); + virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0); + virtual bool hasBase() const { return true; } + virtual int nonOperatorHeight() const; + virtual void stretchToHeight(int pixelHeight); + virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; + +protected: + virtual void layout(); + +private: + enum SubSupType { Sub, Sup, SubSup }; + SubSupType m_kind; + RenderBlock* m_scripts; +}; + +} + +#endif // ENABLE(MATHML) + +#endif // RenderMathMLSubSup_h + diff --git a/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp b/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp new file mode 100644 index 0000000..a3de697 --- /dev/null +++ b/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp @@ -0,0 +1,299 @@ +/* + * Copyright (C) 2009 Alex Milowski (alex@milowski.com). 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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" + +#if ENABLE(MATHML) + +#include "RenderMathMLUnderOver.h" + +#include "FontSelector.h" +#include "MathMLNames.h" + +namespace WebCore { + +using namespace MathMLNames; + +static const double gOverSpacingAdjustment = 0.5; + +RenderMathMLUnderOver::RenderMathMLUnderOver(Node* expression) + : RenderMathMLBlock(expression) +{ + Element* element = static_cast<Element*>(expression); + // Determine what kind of under/over expression we have by element name + + if (element->hasLocalName(MathMLNames::munderTag)) + m_kind = Under; + else if (element->hasLocalName(MathMLNames::moverTag)) + m_kind = Over; + else if (element->hasLocalName(MathMLNames::munderoverTag)) + m_kind = UnderOver; + else + m_kind = Under; + +} + +void RenderMathMLUnderOver::addChild(RenderObject* child, RenderObject* beforeChild) +{ + RenderMathMLBlock* row = new (renderArena()) RenderMathMLBlock(node()); + RefPtr<RenderStyle> rowStyle = makeBlockStyle(); + row->setStyle(rowStyle.release()); + + // look through the children for rendered elements counting the blocks so we know what child + // we are adding + int blocks = 0; + RenderObject* current = this->firstChild(); + while (current) { + blocks++; + current = current->nextSibling(); + } + + switch (blocks) { + case 0: + // this is the base so just append it + RenderBlock::addChild(row, beforeChild); + break; + case 1: + // the under or over + // FIXME: text-align: center does not work + row->style()->setTextAlign(CENTER); + if (m_kind == Over) { + // add the over as first + RenderBlock::addChild(row, firstChild()); + } else { + // add the under as last + RenderBlock::addChild(row, beforeChild); + } + break; + case 2: + // the under or over + // FIXME: text-align: center does not work + row->style()->setTextAlign(CENTER); + if (m_kind == UnderOver) { + // add the over as first + RenderBlock::addChild(row, firstChild()); + } else { + // we really shouldn't get here as only munderover should have three children + RenderBlock::addChild(row, beforeChild); + } + break; + default: + // munderover shouldn't have more than three children. In theory we shouldn't + // get here if the MathML is correctly formed, but that isn't a guarantee. + // We will treat this as another under element and they'll get something funky. + RenderBlock::addChild(row, beforeChild); + } + row->addChild(child); +} + +inline int getOffsetHeight(RenderObject* obj) +{ + if (obj->isBoxModelObject()) { + RenderBoxModelObject* box = toRenderBoxModelObject(obj); + return box->offsetHeight(); + } + + return 0; +} + +void RenderMathMLUnderOver::stretchToHeight(int height) +{ + + RenderObject* base = firstChild(); + if (!base) + return; + + // For over or underover, the base is the sibling of the first child + if (m_kind != Under) + base = base->nextSibling(); + + if (!base) + return; + + // use the child of the row which is the actual base + base = base->firstChild(); + + if (base && base->isRenderMathMLBlock()) { + RenderMathMLBlock* block = toRenderMathMLBlock(base); + block->stretchToHeight(height); + setNeedsLayout(true); + } +} + +void RenderMathMLUnderOver::layout() +{ + RenderBlock::layout(); + RenderObject* over = 0; + RenderObject* base = 0; + switch (m_kind) { + case Over: + // We need to calculate the baseline over the over versus the start of the base and + // adjust the placement of the base. + over = firstChild(); + if (over) { + // FIXME: descending glyphs intrude into base (e.g. lowercase y over base) + // FIXME: bases that ascend higher than the line box intrude into the over + if (!over->firstChild()->isBoxModelObject()) + break; + + int overSpacing = static_cast<int>(gOverSpacingAdjustment * (getOffsetHeight(over) - toRenderBoxModelObject(over->firstChild())->baselinePosition(AlphabeticBaseline, true, HorizontalLine))); + + // base row wrapper + base = over->nextSibling(); + if (base) { + if (overSpacing > 0) + base->style()->setMarginTop(Length(-overSpacing, Fixed)); + else + base->style()->setMarginTop(Length(0, Fixed)); + } + + } + break; + case Under: + // FIXME: Non-ascending glyphs in the under should be moved closer to the base + + // We need to calculate the baseline of the base versus the start of the under block and + // adjust the placement of the under block. + + // base row wrapper + base = firstChild(); + if (base) { + int baseHeight = getOffsetHeight(base); + // actual base + base = base->firstChild(); + if (!base->isBoxModelObject()) + break; + + // FIXME: We need to look at the space between a single maximum height of + // the line boxes and the baseline and squeeze them together + int underSpacing = baseHeight - toRenderBoxModelObject(base)->baselinePosition(AlphabeticBaseline, true, HorizontalLine); + + // adjust the base's intrusion into the under + RenderObject* under = lastChild(); + if (under && underSpacing > 0) + under->style()->setMarginTop(Length(-underSpacing, Fixed)); + } + break; + case UnderOver: + // FIXME: Non-descending glyphs in the over should be moved closer to the base + // FIXME: Non-ascending glyphs in the under should be moved closer to the base + + // We need to calculate the baseline of the over versus the start of the base and + // adjust the placement of the base. + + over = firstChild(); + if (over) { + // FIXME: descending glyphs intrude into base (e.g. lowercase y over base) + // FIXME: bases that ascend higher than the line box intrude into the over + if (!over->firstChild()->isBoxModelObject()) + break; + int overSpacing = static_cast<int>(gOverSpacingAdjustment * (getOffsetHeight(over) - toRenderBoxModelObject(over->firstChild())->baselinePosition(AlphabeticBaseline, true, HorizontalLine))); + + // base row wrapper + base = over->nextSibling(); + + if (base) { + if (overSpacing > 0) + base->style()->setMarginTop(Length(-overSpacing, Fixed)); + + // We need to calculate the baseline of the base versus the start of the under block and + // adjust the placement of the under block. + + int baseHeight = getOffsetHeight(base); + // actual base + base = base->firstChild(); + if (!base->isBoxModelObject()) + break; + + // FIXME: We need to look at the space between a single maximum height of + // the line boxes and the baseline and squeeze them together + int underSpacing = baseHeight - toRenderBoxModelObject(base)->baselinePosition(AlphabeticBaseline, true, HorizontalLine); + + RenderObject* under = lastChild(); + if (under && under->firstChild()->isRenderInline() && underSpacing > 0) + under->style()->setMarginTop(Length(-underSpacing, Fixed)); + + } + } + break; + } + setNeedsLayout(true); + RenderBlock::layout(); +} + +int RenderMathMLUnderOver::baselinePosition(FontBaseline, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const +{ + RenderObject* current = firstChild(); + if (!current) + return RenderBlock::baselinePosition(AlphabeticBaseline, firstLine, direction, linePositionMode); + + int baseline = 0; + switch (m_kind) { + case UnderOver: + case Over: + baseline += getOffsetHeight(current); + current = current->nextSibling(); + if (current) { + // actual base + RenderObject* base = current->firstChild(); + if (!base || !base->isBoxModelObject()) + break; + baseline += toRenderBoxModelObject(base)->baselinePosition(AlphabeticBaseline, firstLine, HorizontalLine, linePositionMode); + // added the negative top margin + baseline += current->style()->marginTop().value(); + } + break; + case Under: + RenderObject* base = current->firstChild(); + if (base && base->isBoxModelObject()) + baseline += toRenderBoxModelObject(base)->baselinePosition(AlphabeticBaseline, true, HorizontalLine); + } + + // FIXME: Where is the extra 2-3px adjusted for zoom coming from? + float zoomFactor = style()->effectiveZoom(); + baseline += static_cast<int>((zoomFactor > 1.25 ? 2 : 3) * zoomFactor); + return baseline; +} + + +int RenderMathMLUnderOver::nonOperatorHeight() const +{ + int nonOperators = 0; + for (RenderObject* current = firstChild(); current; current = current->nextSibling()) { + if (current->firstChild()->isRenderMathMLBlock()) { + RenderMathMLBlock* block = toRenderMathMLBlock(current->firstChild()); + if (!block->isRenderMathMLOperator()) + nonOperators += getOffsetHeight(current); + } else { + nonOperators += getOffsetHeight(current); + } + } + return nonOperators; +} + +} + + +#endif // ENABLE(MATHML) diff --git a/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h b/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h new file mode 100644 index 0000000..fbab72a --- /dev/null +++ b/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2009 Alex Milowski (alex@milowski.com). 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 RenderMathMLUnderOver_h +#define RenderMathMLUnderOver_h + +#if ENABLE(MATHML) + +#include "RenderMathMLBlock.h" + +namespace WebCore { + +class RenderMathMLUnderOver : public RenderMathMLBlock { +public: + RenderMathMLUnderOver(Node* expression); + virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0); + virtual void layout(); + virtual bool hasBase() const { return true; } + virtual int nonOperatorHeight() const; + virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; + virtual void stretchToHeight(int pixelHeight); +private: + enum UnderOverType { Under, Over, UnderOver }; + UnderOverType m_kind; +}; + +} + +#endif // ENABLE(MATHML) + +#endif // RenderMathMLUnderOver_h diff --git a/Source/WebCore/rendering/style/RenderStyle.cpp b/Source/WebCore/rendering/style/RenderStyle.cpp index 881818c..4665e52 100644 --- a/Source/WebCore/rendering/style/RenderStyle.cpp +++ b/Source/WebCore/rendering/style/RenderStyle.cpp @@ -22,12 +22,15 @@ #include "config.h" #include "RenderStyle.h" +#include "ContentData.h" +#include "CursorList.h" #include "CSSPropertyNames.h" #include "CSSStyleSelector.h" #include "FontSelector.h" #include "RenderArena.h" #include "RenderObject.h" #include "ScaleTransformOperation.h" +#include "ShadowData.h" #include "StyleImage.h" #include <wtf/StdLibExtras.h> #include <algorithm> diff --git a/Source/WebCore/rendering/style/RenderStyle.h b/Source/WebCore/rendering/style/RenderStyle.h index 7e61e46..14329bc 100644 --- a/Source/WebCore/rendering/style/RenderStyle.h +++ b/Source/WebCore/rendering/style/RenderStyle.h @@ -25,36 +25,24 @@ #ifndef RenderStyle_h #define RenderStyle_h -#include "TransformationMatrix.h" #include "AnimationList.h" -#include "BorderData.h" #include "BorderValue.h" -#include "CSSImageGeneratorValue.h" #include "CSSPrimitiveValue.h" #include "CSSPropertyNames.h" -#include "CSSReflectionDirection.h" -#include "CSSValueList.h" -#include "CollapsedBorderValue.h" #include "Color.h" #include "ColorSpace.h" -#include "ContentData.h" #include "CounterDirectives.h" -#include "CursorList.h" #include "DataRef.h" #include "FillLayer.h" -#include "FloatPoint.h" #include "Font.h" #include "GraphicsTypes.h" -#include "IntRect.h" #include "Length.h" #include "LengthBox.h" #include "LengthSize.h" #include "LineClampValue.h" #include "NinePieceImage.h" #include "OutlineValue.h" -#include "Pair.h" #include "RenderStyleConstants.h" -#include "ShadowData.h" #include "StyleBackgroundData.h" #include "StyleBoxData.h" #include "StyleFlexibleBoxData.h" @@ -69,7 +57,6 @@ #include "StyleVisualData.h" #include "TextDirection.h" #include "ThemeTypes.h" -#include "TimingFunction.h" #include "TransformOperations.h" #include <wtf/Forward.h> #include <wtf/OwnPtr.h> @@ -99,10 +86,17 @@ namespace WebCore { using std::max; +class BorderData; class CSSStyleSelector; -class CSSValueList; +class CounterContent; +class CursorList; +class IntRect; class Pair; +class ShadowData; class StyleImage; +class TransformationMatrix; + +struct ContentData; typedef Vector<RefPtr<RenderStyle>, 4> PseudoStyleCache; diff --git a/Source/WebCore/rendering/style/RenderStyleConstants.h b/Source/WebCore/rendering/style/RenderStyleConstants.h index 0839864..7cd4903 100644 --- a/Source/WebCore/rendering/style/RenderStyleConstants.h +++ b/Source/WebCore/rendering/style/RenderStyleConstants.h @@ -68,7 +68,7 @@ enum StyleDifferenceContextSensitiveProperty { enum PseudoId { // The order must be NOP ID, public IDs, and then internal IDs. NOPSEUDO, FIRST_LINE, FIRST_LETTER, BEFORE, AFTER, SELECTION, FIRST_LINE_INHERITED, SCROLLBAR, FILE_UPLOAD_BUTTON, INPUT_PLACEHOLDER, - SLIDER_THUMB, SEARCH_CANCEL_BUTTON, SEARCH_DECORATION, SEARCH_RESULTS_DECORATION, SEARCH_RESULTS_BUTTON, MEDIA_CONTROLS_PANEL, + SEARCH_CANCEL_BUTTON, SEARCH_DECORATION, SEARCH_RESULTS_DECORATION, SEARCH_RESULTS_BUTTON, MEDIA_CONTROLS_PANEL, MEDIA_CONTROLS_PLAY_BUTTON, MEDIA_CONTROLS_MUTE_BUTTON, MEDIA_CONTROLS_TIMELINE, MEDIA_CONTROLS_TIMELINE_CONTAINER, MEDIA_CONTROLS_VOLUME_SLIDER, MEDIA_CONTROLS_VOLUME_SLIDER_CONTAINER, MEDIA_CONTROLS_VOLUME_SLIDER_MUTE_BUTTON, MEDIA_CONTROLS_CURRENT_TIME_DISPLAY, MEDIA_CONTROLS_TIME_REMAINING_DISPLAY, diff --git a/Source/WebCore/rendering/style/StyleRareInheritedData.cpp b/Source/WebCore/rendering/style/StyleRareInheritedData.cpp index 6138df2..0953dae 100644 --- a/Source/WebCore/rendering/style/StyleRareInheritedData.cpp +++ b/Source/WebCore/rendering/style/StyleRareInheritedData.cpp @@ -22,8 +22,10 @@ #include "config.h" #include "StyleRareInheritedData.h" +#include "CursorList.h" #include "RenderStyle.h" #include "RenderStyleConstants.h" +#include "ShadowData.h" namespace WebCore { diff --git a/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp b/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp index 42cf966..3771f13 100644 --- a/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp +++ b/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp @@ -26,6 +26,7 @@ #include "ContentData.h" #include "RenderCounter.h" #include "RenderStyle.h" +#include "ShadowData.h" #include "StyleImage.h" namespace WebCore { diff --git a/Source/WebCore/rendering/RenderSVGAllInOne.cpp b/Source/WebCore/rendering/svg/RenderSVGAllInOne.cpp index 7002747..835bce8 100644 --- a/Source/WebCore/rendering/RenderSVGAllInOne.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGAllInOne.cpp @@ -27,9 +27,12 @@ #include "RenderSVGBlock.cpp" #include "RenderSVGContainer.cpp" +#include "RenderSVGForeignObject.cpp" #include "RenderSVGGradientStop.cpp" #include "RenderSVGHiddenContainer.cpp" #include "RenderSVGImage.cpp" +#include "RenderSVGInline.cpp" +#include "RenderSVGInlineText.cpp" #include "RenderSVGModelObject.cpp" #include "RenderSVGResource.cpp" #include "RenderSVGResourceClipper.cpp" @@ -45,32 +48,28 @@ #include "RenderSVGResourceSolidColor.cpp" #include "RenderSVGRoot.cpp" #include "RenderSVGShadowTreeRootContainer.cpp" +#include "RenderSVGTSpan.cpp" +#include "RenderSVGText.cpp" +#include "RenderSVGTextPath.cpp" #include "RenderSVGTransformableContainer.cpp" #include "RenderSVGViewportContainer.cpp" #include "SVGImageBufferTools.cpp" +#include "SVGInlineFlowBox.cpp" +#include "SVGInlineTextBox.cpp" #include "SVGMarkerLayoutInfo.cpp" #include "SVGRenderSupport.cpp" #include "SVGRenderTreeAsText.cpp" #include "SVGResources.cpp" #include "SVGResourcesCache.cpp" #include "SVGResourcesCycleSolver.cpp" +#include "SVGRootInlineBox.cpp" #include "SVGShadowTreeElements.cpp" - -// FIXME: As soon as all SVG renderers live in rendering/svg, this file should be moved there as well, removing the need for the svg/ includes below. -#include "svg/RenderSVGInline.cpp" -#include "svg/RenderSVGInlineText.cpp" -#include "svg/RenderSVGTSpan.cpp" -#include "svg/RenderSVGText.cpp" -#include "svg/RenderSVGTextPath.cpp" -#include "svg/SVGInlineFlowBox.cpp" -#include "svg/SVGInlineTextBox.cpp" -#include "svg/SVGRootInlineBox.cpp" -#include "svg/SVGTextChunk.cpp" -#include "svg/SVGTextChunkBuilder.cpp" -#include "svg/SVGTextLayoutAttributes.cpp" -#include "svg/SVGTextLayoutAttributesBuilder.cpp" -#include "svg/SVGTextLayoutEngine.cpp" -#include "svg/SVGTextLayoutEngineBaseline.cpp" -#include "svg/SVGTextLayoutEngineSpacing.cpp" -#include "svg/SVGTextMetrics.cpp" -#include "svg/SVGTextQuery.cpp" +#include "SVGTextChunk.cpp" +#include "SVGTextChunkBuilder.cpp" +#include "SVGTextLayoutAttributes.cpp" +#include "SVGTextLayoutAttributesBuilder.cpp" +#include "SVGTextLayoutEngine.cpp" +#include "SVGTextLayoutEngineBaseline.cpp" +#include "SVGTextLayoutEngineSpacing.cpp" +#include "SVGTextMetrics.cpp" +#include "SVGTextQuery.cpp" diff --git a/Source/WebCore/rendering/RenderSVGBlock.cpp b/Source/WebCore/rendering/svg/RenderSVGBlock.cpp index b2d727a..ed8e24e 100644 --- a/Source/WebCore/rendering/RenderSVGBlock.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGBlock.cpp @@ -17,7 +17,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #include "config.h" @@ -59,7 +58,7 @@ void RenderSVGBlock::updateBoxModelInfoFromStyle() // Render(SVGText|ForeignObject) return 'false' on 'requiresLayer'. Fine for RenderSVGText. // // If we want to support overflow rules for <foreignObject> we can choose between two solutions: - // a) make RenderForeignObject require layers and SVG layer aware + // a) make RenderSVGForeignObject require layers and SVG layer aware // b) reactor overflow logic out of RenderLayer (as suggested by dhyatt), which is a large task // // Until this is resolved, disable overflow support. Opera/FF don't support it as well at the moment (Feb 2010). diff --git a/Source/WebCore/rendering/RenderSVGBlock.h b/Source/WebCore/rendering/svg/RenderSVGBlock.h index a9dd5db..350fdde 100644 --- a/Source/WebCore/rendering/RenderSVGBlock.h +++ b/Source/WebCore/rendering/svg/RenderSVGBlock.h @@ -15,7 +15,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #ifndef RenderSVGBlock_h diff --git a/Source/WebCore/rendering/RenderSVGContainer.cpp b/Source/WebCore/rendering/svg/RenderSVGContainer.cpp index 32e0598..1897f53 100644 --- a/Source/WebCore/rendering/RenderSVGContainer.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGContainer.cpp @@ -1,25 +1,25 @@ /* - Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> - 2004, 2005, 2007, 2008 Rob Buis <buis@kde.org> - 2007 Eric Seidel <eric@webkit.org> - Copyright (C) 2009 Google, Inc. All rights reserved. - 2009 Dirk Schulze <krit@webkit.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> + * Copyright (C) 2004, 2005, 2007, 2008 Rob Buis <buis@kde.org> + * Copyright (C) 2007 Eric Seidel <eric@webkit.org> + * Copyright (C) 2009 Google, Inc. All rights reserved. + * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ #include "config.h" diff --git a/Source/WebCore/rendering/RenderSVGContainer.h b/Source/WebCore/rendering/svg/RenderSVGContainer.h index 3bd5346..d478c49 100644 --- a/Source/WebCore/rendering/RenderSVGContainer.h +++ b/Source/WebCore/rendering/svg/RenderSVGContainer.h @@ -1,24 +1,24 @@ /* - Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> - 2004, 2005, 2007 Rob Buis <buis@kde.org> - Copyright (C) 2009 Google, Inc. All rights reserved. - Copyright (C) 2009 Apple Inc. All rights reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> + * Copyright (C) 2004, 2005, 2007 Rob Buis <buis@kde.org> + * Copyright (C) 2009 Google, Inc. All rights reserved. + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ #ifndef RenderSVGContainer_h #define RenderSVGContainer_h diff --git a/Source/WebCore/rendering/RenderForeignObject.cpp b/Source/WebCore/rendering/svg/RenderSVGForeignObject.cpp index f9f6988..200fab2 100644 --- a/Source/WebCore/rendering/RenderForeignObject.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGForeignObject.cpp @@ -17,13 +17,12 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #include "config.h" #if ENABLE(SVG) && ENABLE(SVG_FOREIGN_OBJECT) -#include "RenderForeignObject.h" +#include "RenderSVGForeignObject.h" #include "GraphicsContext.h" #include "RenderSVGResource.h" @@ -35,17 +34,17 @@ namespace WebCore { -RenderForeignObject::RenderForeignObject(SVGForeignObjectElement* node) +RenderSVGForeignObject::RenderSVGForeignObject(SVGForeignObjectElement* node) : RenderSVGBlock(node) , m_needsTransformUpdate(true) { } -RenderForeignObject::~RenderForeignObject() +RenderSVGForeignObject::~RenderSVGForeignObject() { } -void RenderForeignObject::paint(PaintInfo& paintInfo, int, int) +void RenderSVGForeignObject::paint(PaintInfo& paintInfo, int, int) { if (paintInfo.context->paintingDisabled()) return; @@ -69,36 +68,36 @@ void RenderForeignObject::paint(PaintInfo& paintInfo, int, int) childPaintInfo.context->restore(); } -IntRect RenderForeignObject::clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) +IntRect RenderSVGForeignObject::clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) { return SVGRenderSupport::clippedOverflowRectForRepaint(this, repaintContainer); } -void RenderForeignObject::computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& repaintRect, bool fixed) +void RenderSVGForeignObject::computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& repaintRect, bool fixed) { SVGRenderSupport::computeRectForRepaint(this, repaintContainer, repaintRect, fixed); } -const AffineTransform& RenderForeignObject::localToParentTransform() const +const AffineTransform& RenderSVGForeignObject::localToParentTransform() const { m_localToParentTransform = localTransform(); m_localToParentTransform.translate(m_viewport.x(), m_viewport.y()); return m_localToParentTransform; } -void RenderForeignObject::computeLogicalWidth() +void RenderSVGForeignObject::computeLogicalWidth() { // FIXME: Investigate in size rounding issues setWidth(static_cast<int>(roundf(m_viewport.width()))); } -void RenderForeignObject::computeLogicalHeight() +void RenderSVGForeignObject::computeLogicalHeight() { // FIXME: Investigate in size rounding issues setHeight(static_cast<int>(roundf(m_viewport.height()))); } -void RenderForeignObject::layout() +void RenderSVGForeignObject::layout() { ASSERT(needsLayout()); ASSERT(!view()->layoutStateEnabled()); // RenderSVGRoot disables layoutState for the SVG rendering tree. @@ -125,7 +124,7 @@ void RenderForeignObject::layout() // positions. A regular RenderBoxModelObject would pull this information from RenderStyle - in SVG those // properties are ignored for non <svg> elements, so we mimic what happens when specifying them through CSS. - // FIXME: Investigate in location rounding issues - only affects RenderForeignObject & RenderSVGText + // FIXME: Investigate in location rounding issues - only affects RenderSVGForeignObject & RenderSVGText setLocation(roundedIntPoint(viewportLocation)); bool layoutChanged = m_everHadLayout && selfNeedsLayout(); @@ -143,7 +142,7 @@ void RenderForeignObject::layout() repainter.repaintAfterLayout(); } -bool RenderForeignObject::nodeAtFloatPoint(const HitTestRequest& request, HitTestResult& result, const FloatPoint& pointInParent, HitTestAction hitTestAction) +bool RenderSVGForeignObject::nodeAtFloatPoint(const HitTestRequest& request, HitTestResult& result, const FloatPoint& pointInParent, HitTestAction hitTestAction) { FloatPoint localPoint = localTransform().inverse().mapPoint(pointInParent); @@ -155,13 +154,13 @@ bool RenderForeignObject::nodeAtFloatPoint(const HitTestRequest& request, HitTes return RenderBlock::nodeAtPoint(request, result, roundedLocalPoint.x(), roundedLocalPoint.y(), 0, 0, hitTestAction); } -bool RenderForeignObject::nodeAtPoint(const HitTestRequest&, HitTestResult&, int, int, int, int, HitTestAction) +bool RenderSVGForeignObject::nodeAtPoint(const HitTestRequest&, HitTestResult&, int, int, int, int, HitTestAction) { ASSERT_NOT_REACHED(); return false; } -void RenderForeignObject::mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed, bool useTransforms, TransformState& transformState) const +void RenderSVGForeignObject::mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed, bool useTransforms, TransformState& transformState) const { // When crawling up the hierachy starting from foreignObject child content, useTransforms may not be set to true. if (!useTransforms) diff --git a/Source/WebCore/rendering/RenderForeignObject.h b/Source/WebCore/rendering/svg/RenderSVGForeignObject.h index bdf96ce..a1cf91a 100644 --- a/Source/WebCore/rendering/RenderForeignObject.h +++ b/Source/WebCore/rendering/svg/RenderSVGForeignObject.h @@ -16,11 +16,10 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ -#ifndef RenderForeignObject_h -#define RenderForeignObject_h +#ifndef RenderSVGForeignObject_h +#define RenderSVGForeignObject_h #if ENABLE(SVG) && ENABLE(SVG_FOREIGN_OBJECT) #include "AffineTransform.h" @@ -31,12 +30,12 @@ namespace WebCore { class SVGForeignObjectElement; -class RenderForeignObject : public RenderSVGBlock { +class RenderSVGForeignObject : public RenderSVGBlock { public: - explicit RenderForeignObject(SVGForeignObjectElement*); - virtual ~RenderForeignObject(); + explicit RenderSVGForeignObject(SVGForeignObjectElement*); + virtual ~RenderSVGForeignObject(); - virtual const char* renderName() const { return "RenderForeignObject"; } + virtual const char* renderName() const { return "RenderSVGForeignObject"; } virtual void paint(PaintInfo&, int parentX, int parentY); @@ -54,10 +53,10 @@ public: virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction); virtual bool isSVGForeignObject() const { return true; } - virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed , bool useTransforms, TransformState& transformState) const; + virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed , bool useTransforms, TransformState&) const; virtual void setNeedsTransformUpdate() { m_needsTransformUpdate = true; } - private: +private: virtual void computeLogicalWidth(); virtual void computeLogicalHeight(); diff --git a/Source/WebCore/rendering/RenderSVGGradientStop.cpp b/Source/WebCore/rendering/svg/RenderSVGGradientStop.cpp index 094fc7f..46c3e2b 100644 --- a/Source/WebCore/rendering/RenderSVGGradientStop.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGGradientStop.cpp @@ -1,6 +1,4 @@ /* - * This file is part of the WebKit project. - * * Copyright (C) 2007 Eric Seidel <eric@webkit.org> * * This library is free software; you can redistribute it and/or @@ -17,7 +15,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #include "config.h" diff --git a/Source/WebCore/rendering/RenderSVGGradientStop.h b/Source/WebCore/rendering/svg/RenderSVGGradientStop.h index f06a9a5..ae90f37 100644 --- a/Source/WebCore/rendering/RenderSVGGradientStop.h +++ b/Source/WebCore/rendering/svg/RenderSVGGradientStop.h @@ -16,7 +16,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #ifndef RenderSVGGradientStop_h diff --git a/Source/WebCore/rendering/RenderSVGHiddenContainer.cpp b/Source/WebCore/rendering/svg/RenderSVGHiddenContainer.cpp index fb14ffe..9ddabef 100644 --- a/Source/WebCore/rendering/RenderSVGHiddenContainer.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGHiddenContainer.cpp @@ -1,6 +1,4 @@ /* - * This file is part of the WebKit project. - * * Copyright (C) 2007 Eric Seidel <eric@webkit.org> * * This library is free software; you can redistribute it and/or @@ -17,7 +15,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #include "config.h" diff --git a/Source/WebCore/rendering/RenderSVGHiddenContainer.h b/Source/WebCore/rendering/svg/RenderSVGHiddenContainer.h index c591a88..d35de2d 100644 --- a/Source/WebCore/rendering/RenderSVGHiddenContainer.h +++ b/Source/WebCore/rendering/svg/RenderSVGHiddenContainer.h @@ -1,6 +1,4 @@ /* - * This file is part of the WebKit project. - * * Copyright (C) 2007 Eric Seidel <eric@webkit.org> * * This library is free software; you can redistribute it and/or @@ -17,7 +15,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #ifndef RenderSVGHiddenContainer_h @@ -28,30 +25,30 @@ namespace WebCore { - class SVGStyledElement; - - // This class is for containers which are never drawn, but do need to support style - // <defs>, <linearGradient>, <radialGradient> are all good examples - class RenderSVGHiddenContainer : public RenderSVGContainer { - public: - explicit RenderSVGHiddenContainer(SVGStyledElement*); +class SVGStyledElement; - virtual const char* renderName() const { return "RenderSVGHiddenContainer"; } +// This class is for containers which are never drawn, but do need to support style +// <defs>, <linearGradient>, <radialGradient> are all good examples +class RenderSVGHiddenContainer : public RenderSVGContainer { +public: + explicit RenderSVGHiddenContainer(SVGStyledElement*); - protected: - virtual void layout(); + virtual const char* renderName() const { return "RenderSVGHiddenContainer"; } - private: - virtual bool isSVGHiddenContainer() const { return true; } - virtual bool requiresLayer() const { return false; } +protected: + virtual void layout(); - virtual void paint(PaintInfo&, int parentX, int parentY); - - virtual IntRect clippedOverflowRectForRepaint(RenderBoxModelObject*) { return IntRect(); } - virtual void absoluteQuads(Vector<FloatQuad>&); +private: + virtual bool isSVGHiddenContainer() const { return true; } + virtual bool requiresLayer() const { return false; } + + virtual void paint(PaintInfo&, int parentX, int parentY); + + virtual IntRect clippedOverflowRectForRepaint(RenderBoxModelObject*) { return IntRect(); } + virtual void absoluteQuads(Vector<FloatQuad>&); - virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction); - }; + virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction); +}; } #endif // ENABLE(SVG) diff --git a/Source/WebCore/rendering/RenderSVGImage.cpp b/Source/WebCore/rendering/svg/RenderSVGImage.cpp index 237dbaa..0f5a55e 100644 --- a/Source/WebCore/rendering/RenderSVGImage.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGImage.cpp @@ -1,27 +1,27 @@ /* - Copyright (C) 2006 Alexander Kellett <lypanov@kde.org> - Copyright (C) 2006 Apple Computer, Inc. - Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> - Copyright (C) 2007, 2008, 2009 Rob Buis <buis@kde.org> - Copyright (C) 2009, Google, Inc. - Copyright (C) 2009 Dirk Schulze <krit@webkit.org> - Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org> + * Copyright (C) 2006 Apple Computer, Inc. + * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> + * Copyright (C) 2007, 2008, 2009 Rob Buis <buis@kde.org> + * Copyright (C) 2009 Google, Inc. + * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> + * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ #include "config.h" diff --git a/Source/WebCore/rendering/RenderSVGImage.h b/Source/WebCore/rendering/svg/RenderSVGImage.h index 485d6ab..2c91b52 100644 --- a/Source/WebCore/rendering/RenderSVGImage.h +++ b/Source/WebCore/rendering/svg/RenderSVGImage.h @@ -1,25 +1,25 @@ /* - Copyright (C) 2006 Alexander Kellett <lypanov@kde.org> - Copyright (C) 2006, 2009 Apple Inc. All rights reserved. - Copyright (C) 2007 Rob Buis <buis@kde.org> - Copyright (C) 2009 Google, Inc. - Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org> + * Copyright (C) 2006, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2007 Rob Buis <buis@kde.org> + * Copyright (C) 2009 Google, Inc. + * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ #ifndef RenderSVGImage_h #define RenderSVGImage_h diff --git a/Source/WebCore/rendering/svg/RenderSVGInline.cpp b/Source/WebCore/rendering/svg/RenderSVGInline.cpp index 4d0c533..543d14b 100644 --- a/Source/WebCore/rendering/svg/RenderSVGInline.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGInline.cpp @@ -17,7 +17,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #include "config.h" diff --git a/Source/WebCore/rendering/svg/RenderSVGInline.h b/Source/WebCore/rendering/svg/RenderSVGInline.h index d7b7e66..33d7d13 100644 --- a/Source/WebCore/rendering/svg/RenderSVGInline.h +++ b/Source/WebCore/rendering/svg/RenderSVGInline.h @@ -1,8 +1,6 @@ /* - * This file is part of the WebKit project. - * * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> - * (C) 2006 Apple Computer Inc. + * Copyright (C) 2006 Apple Computer Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -18,7 +16,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #ifndef RenderSVGInline_h diff --git a/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp b/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp index b791f3e..91ffb5c 100644 --- a/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp @@ -19,7 +19,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #include "config.h" diff --git a/Source/WebCore/rendering/svg/RenderSVGInlineText.h b/Source/WebCore/rendering/svg/RenderSVGInlineText.h index 926ec43..f5247f6 100644 --- a/Source/WebCore/rendering/svg/RenderSVGInlineText.h +++ b/Source/WebCore/rendering/svg/RenderSVGInlineText.h @@ -1,9 +1,7 @@ /* - * This file is part of the WebKit project. - * * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. - * (C) 2008 Rob Buis <buis@kde.org> + * Copyright (C) 2008 Rob Buis <buis@kde.org> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -19,7 +17,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #ifndef RenderSVGInlineText_h diff --git a/Source/WebCore/rendering/RenderSVGModelObject.cpp b/Source/WebCore/rendering/svg/RenderSVGModelObject.cpp index 28760a0..28760a0 100644 --- a/Source/WebCore/rendering/RenderSVGModelObject.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGModelObject.cpp diff --git a/Source/WebCore/rendering/RenderSVGModelObject.h b/Source/WebCore/rendering/svg/RenderSVGModelObject.h index fb8f89f..a04db96 100644 --- a/Source/WebCore/rendering/RenderSVGModelObject.h +++ b/Source/WebCore/rendering/svg/RenderSVGModelObject.h @@ -67,7 +67,7 @@ public: private: // This method should never be called, SVG uses a different nodeAtPoint method - bool nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int xInContainer, int yInContainer, int dxParentToContainer, int dyParentToContainer, HitTestAction hitTestAction); + bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int xInContainer, int yInContainer, int dxParentToContainer, int dyParentToContainer, HitTestAction); }; } diff --git a/Source/WebCore/rendering/svg/RenderSVGPath.cpp b/Source/WebCore/rendering/svg/RenderSVGPath.cpp index 0c8ac0c..1d9eca1 100644 --- a/Source/WebCore/rendering/svg/RenderSVGPath.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGPath.cpp @@ -1,27 +1,27 @@ /* - Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> - 2004, 2005, 2008 Rob Buis <buis@kde.org> - 2005, 2007 Eric Seidel <eric@webkit.org> - 2009 Google, Inc. - 2009 Dirk Schulze <krit@webkit.org> - Copyright (C) Research In Motion Limited 2010. All rights reserved. - 2009 Jeff Schiller <codedread@gmail.com> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> + * Copyright (C) 2004, 2005, 2008 Rob Buis <buis@kde.org> + * Copyright (C) 2005, 2007 Eric Seidel <eric@webkit.org> + * Copyright (C) 2009 Google, Inc. + * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> + * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * Copyright (C) 2009 Jeff Schiller <codedread@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ #include "config.h" diff --git a/Source/WebCore/rendering/svg/RenderSVGPath.h b/Source/WebCore/rendering/svg/RenderSVGPath.h index 41b0e51..c5c8377 100644 --- a/Source/WebCore/rendering/svg/RenderSVGPath.h +++ b/Source/WebCore/rendering/svg/RenderSVGPath.h @@ -1,25 +1,25 @@ /* - Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> - 2004, 2005 Rob Buis <buis@kde.org> - 2005 Eric Seidel <eric@webkit.org> - 2006 Apple Computer, Inc - 2009 Google, Inc. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> + * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> + * Copyright (C) 2005 Eric Seidel <eric@webkit.org> + * Copyright (C) 2006 Apple Computer, Inc + * Copyright (C) 2009 Google, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ #ifndef RenderSVGPath_h #define RenderSVGPath_h diff --git a/Source/WebCore/rendering/RenderSVGResource.cpp b/Source/WebCore/rendering/svg/RenderSVGResource.cpp index f4c65d5..c0b16c5 100644 --- a/Source/WebCore/rendering/RenderSVGResource.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGResource.cpp @@ -18,7 +18,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #include "config.h" diff --git a/Source/WebCore/rendering/RenderSVGResource.h b/Source/WebCore/rendering/svg/RenderSVGResource.h index 6fc2dae..a67ba73 100644 --- a/Source/WebCore/rendering/RenderSVGResource.h +++ b/Source/WebCore/rendering/svg/RenderSVGResource.h @@ -15,7 +15,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #ifndef RenderSVGResource_h diff --git a/Source/WebCore/rendering/RenderSVGResourceClipper.cpp b/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp index 190c1a4..c57f8b0 100644 --- a/Source/WebCore/rendering/RenderSVGResourceClipper.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> - * 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org> + * Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org> * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. * * This library is free software; you can redistribute it and/or @@ -17,7 +17,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #include "config.h" diff --git a/Source/WebCore/rendering/RenderSVGResourceClipper.h b/Source/WebCore/rendering/svg/RenderSVGResourceClipper.h index 20153e9..7f862a7 100644 --- a/Source/WebCore/rendering/RenderSVGResourceClipper.h +++ b/Source/WebCore/rendering/svg/RenderSVGResourceClipper.h @@ -15,7 +15,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #ifndef RenderSVGResourceClipper_h diff --git a/Source/WebCore/rendering/RenderSVGResourceContainer.cpp b/Source/WebCore/rendering/svg/RenderSVGResourceContainer.cpp index fb30efd..2a8a47f 100644 --- a/Source/WebCore/rendering/RenderSVGResourceContainer.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGResourceContainer.cpp @@ -15,7 +15,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #include "config.h" diff --git a/Source/WebCore/rendering/RenderSVGResourceContainer.h b/Source/WebCore/rendering/svg/RenderSVGResourceContainer.h index 4e5e475..d98a83a 100644 --- a/Source/WebCore/rendering/RenderSVGResourceContainer.h +++ b/Source/WebCore/rendering/svg/RenderSVGResourceContainer.h @@ -15,7 +15,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #ifndef RenderSVGResourceContainer_h diff --git a/Source/WebCore/rendering/RenderSVGResourceFilter.cpp b/Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp index 8aa9370..4ba4e0a 100644 --- a/Source/WebCore/rendering/RenderSVGResourceFilter.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp @@ -44,8 +44,9 @@ #include "SVGNames.h" #include "SVGStyledElement.h" #include "SVGUnitTypes.h" -#include <wtf/Vector.h> + #include <wtf/UnusedParam.h> +#include <wtf/Vector.h> static const float kMaxFilterSize = 5000.0f; diff --git a/Source/WebCore/rendering/RenderSVGResourceFilter.h b/Source/WebCore/rendering/svg/RenderSVGResourceFilter.h index 5950c44..f9a15ce 100644 --- a/Source/WebCore/rendering/RenderSVGResourceFilter.h +++ b/Source/WebCore/rendering/svg/RenderSVGResourceFilter.h @@ -1,8 +1,8 @@ /* * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - * 2004, 2005 Rob Buis <buis@kde.org> - * 2005 Eric Seidel <eric@webkit.org> - * 2009 Dirk Schulze <krit@webkit.org> + * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> + * Copyright (C) 2005 Eric Seidel <eric@webkit.org> + * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> * Copyright (C) Research In Motion Limited 2010. All rights reserved. * * This library is free software; you can redistribute it and/or @@ -19,7 +19,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #ifndef RenderSVGResourceFilter_h diff --git a/Source/WebCore/rendering/RenderSVGResourceFilterPrimitive.cpp b/Source/WebCore/rendering/svg/RenderSVGResourceFilterPrimitive.cpp index bf2ef6e..fc7362e 100644 --- a/Source/WebCore/rendering/RenderSVGResourceFilterPrimitive.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGResourceFilterPrimitive.cpp @@ -28,6 +28,7 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "RenderSVGResourceFilterPrimitive.h" + #include "SVGFEImage.h" namespace WebCore { diff --git a/Source/WebCore/rendering/RenderSVGResourceFilterPrimitive.h b/Source/WebCore/rendering/svg/RenderSVGResourceFilterPrimitive.h index c890ffe..f25f62e 100644 --- a/Source/WebCore/rendering/RenderSVGResourceFilterPrimitive.h +++ b/Source/WebCore/rendering/svg/RenderSVGResourceFilterPrimitive.h @@ -30,8 +30,8 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "RenderSVGHiddenContainer.h" -#include "SVGFilterPrimitiveStandardAttributes.h" #include "SVGFilter.h" +#include "SVGFilterPrimitiveStandardAttributes.h" namespace WebCore { @@ -44,7 +44,7 @@ public: } // They depend on the RenderObject argument of RenderSVGResourceFilter::applyResource. - static FloatRect determineFilterPrimitiveSubregion(FilterEffect* effect, SVGFilter* filter); + static FloatRect determineFilterPrimitiveSubregion(FilterEffect*, SVGFilter*); private: virtual const char* renderName() const { return "RenderSVGResourceFilterPrimitive"; } diff --git a/Source/WebCore/rendering/RenderSVGResourceGradient.cpp b/Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp index 7c383d0..5ad5d84 100644 --- a/Source/WebCore/rendering/RenderSVGResourceGradient.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp @@ -18,7 +18,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #include "config.h" diff --git a/Source/WebCore/rendering/RenderSVGResourceGradient.h b/Source/WebCore/rendering/svg/RenderSVGResourceGradient.h index 1c7f52d..ad40b53 100644 --- a/Source/WebCore/rendering/RenderSVGResourceGradient.h +++ b/Source/WebCore/rendering/svg/RenderSVGResourceGradient.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> - * 2008 Eric Seidel <eric@webkit.org> + * Copyright (C) 2008 Eric Seidel <eric@webkit.org> * Copyright (C) Research In Motion Limited 2010. All rights reserved. * * This library is free software; you can redistribute it and/or @@ -17,7 +17,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #ifndef RenderSVGResourceGradient_h diff --git a/Source/WebCore/rendering/RenderSVGResourceLinearGradient.cpp b/Source/WebCore/rendering/svg/RenderSVGResourceLinearGradient.cpp index ce8d69e..14dbd8c 100644 --- a/Source/WebCore/rendering/RenderSVGResourceLinearGradient.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGResourceLinearGradient.cpp @@ -16,7 +16,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #include "config.h" diff --git a/Source/WebCore/rendering/RenderSVGResourceLinearGradient.h b/Source/WebCore/rendering/svg/RenderSVGResourceLinearGradient.h index 9e4530d..2d35418 100644 --- a/Source/WebCore/rendering/RenderSVGResourceLinearGradient.h +++ b/Source/WebCore/rendering/svg/RenderSVGResourceLinearGradient.h @@ -16,7 +16,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #ifndef RenderSVGResourceLinearGradient_h diff --git a/Source/WebCore/rendering/RenderSVGResourceMarker.cpp b/Source/WebCore/rendering/svg/RenderSVGResourceMarker.cpp index 1d5663b..2a68d92 100644 --- a/Source/WebCore/rendering/RenderSVGResourceMarker.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGResourceMarker.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> - * 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org> + * Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org> * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. * * This library is free software; you can redistribute it and/or @@ -17,7 +17,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #include "config.h" diff --git a/Source/WebCore/rendering/RenderSVGResourceMarker.h b/Source/WebCore/rendering/svg/RenderSVGResourceMarker.h index e41096e..fd3b5e3 100644 --- a/Source/WebCore/rendering/RenderSVGResourceMarker.h +++ b/Source/WebCore/rendering/svg/RenderSVGResourceMarker.h @@ -15,7 +15,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #ifndef RenderSVGResourceMarker_h diff --git a/Source/WebCore/rendering/RenderSVGResourceMasker.cpp b/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp index ebbbe93..7b24248 100644 --- a/Source/WebCore/rendering/RenderSVGResourceMasker.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp @@ -15,7 +15,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #include "config.h" @@ -39,8 +38,8 @@ #include "SVGUnitTypes.h" #include <wtf/ByteArray.h> -#include <wtf/Vector.h> #include <wtf/UnusedParam.h> +#include <wtf/Vector.h> namespace WebCore { diff --git a/Source/WebCore/rendering/RenderSVGResourceMasker.h b/Source/WebCore/rendering/svg/RenderSVGResourceMasker.h index fddecd0..0a7deb1 100644 --- a/Source/WebCore/rendering/RenderSVGResourceMasker.h +++ b/Source/WebCore/rendering/svg/RenderSVGResourceMasker.h @@ -15,7 +15,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #ifndef RenderSVGResourceMasker_h diff --git a/Source/WebCore/rendering/RenderSVGResourcePattern.cpp b/Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp index cd64183..330a21a 100644 --- a/Source/WebCore/rendering/RenderSVGResourcePattern.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp @@ -16,7 +16,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #include "config.h" diff --git a/Source/WebCore/rendering/RenderSVGResourcePattern.h b/Source/WebCore/rendering/svg/RenderSVGResourcePattern.h index ee3fb23..a697c71 100644 --- a/Source/WebCore/rendering/RenderSVGResourcePattern.h +++ b/Source/WebCore/rendering/svg/RenderSVGResourcePattern.h @@ -16,7 +16,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #ifndef RenderSVGResourcePattern_h diff --git a/Source/WebCore/rendering/RenderSVGResourceRadialGradient.cpp b/Source/WebCore/rendering/svg/RenderSVGResourceRadialGradient.cpp index 300afcb..a8830fc 100644 --- a/Source/WebCore/rendering/RenderSVGResourceRadialGradient.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGResourceRadialGradient.cpp @@ -16,7 +16,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #include "config.h" diff --git a/Source/WebCore/rendering/RenderSVGResourceRadialGradient.h b/Source/WebCore/rendering/svg/RenderSVGResourceRadialGradient.h index 6492ee3..9d37d11 100644 --- a/Source/WebCore/rendering/RenderSVGResourceRadialGradient.h +++ b/Source/WebCore/rendering/svg/RenderSVGResourceRadialGradient.h @@ -16,7 +16,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #ifndef RenderSVGResourceRadialGradient_h diff --git a/Source/WebCore/rendering/svg/RenderSVGResourceSolidColor.cpp b/Source/WebCore/rendering/svg/RenderSVGResourceSolidColor.cpp new file mode 100644 index 0000000..9f6c063 --- /dev/null +++ b/Source/WebCore/rendering/svg/RenderSVGResourceSolidColor.cpp @@ -0,0 +1,92 @@ +/* + * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "config.h" + +#if ENABLE(SVG) +#include "RenderSVGResourceSolidColor.h" + +#include "GraphicsContext.h" +#include "RenderStyle.h" +#include "SVGRenderSupport.h" + +#if PLATFORM(SKIA) +#include "PlatformContextSkia.h" +#endif + +namespace WebCore { + +RenderSVGResourceType RenderSVGResourceSolidColor::s_resourceType = SolidColorResourceType; + +RenderSVGResourceSolidColor::RenderSVGResourceSolidColor() +{ +} + +RenderSVGResourceSolidColor::~RenderSVGResourceSolidColor() +{ +} + +bool RenderSVGResourceSolidColor::applyResource(RenderObject* object, RenderStyle* style, GraphicsContext*& context, unsigned short resourceMode) +{ + // We are NOT allowed to ASSERT(object) here, unlike all other resources. + // RenderSVGResourceSolidColor is the only resource which may be used from HTML, when rendering + // SVG Fonts for a HTML document. This will be indicated by a null RenderObject pointer. + ASSERT(context); + ASSERT(resourceMode != ApplyToDefaultMode); + + const SVGRenderStyle* svgStyle = style ? style->svgStyle() : 0; + ColorSpace colorSpace = style ? style->colorSpace() : ColorSpaceDeviceRGB; + + if (resourceMode & ApplyToFillMode) { + context->setAlpha(svgStyle ? svgStyle->fillOpacity() : 1.0f); + context->setFillColor(m_color, colorSpace); + context->setFillRule(svgStyle ? svgStyle->fillRule() : RULE_NONZERO); + + if (resourceMode & ApplyToTextMode) + context->setTextDrawingMode(TextModeFill); + } else if (resourceMode & ApplyToStrokeMode) { + context->setAlpha(svgStyle ? svgStyle->strokeOpacity() : 1.0f); + context->setStrokeColor(m_color, colorSpace); + + if (style) + SVGRenderSupport::applyStrokeStyleToContext(context, style, object); + + if (resourceMode & ApplyToTextMode) + context->setTextDrawingMode(TextModeStroke); + } + + return true; +} + +void RenderSVGResourceSolidColor::postApplyResource(RenderObject*, GraphicsContext*& context, unsigned short resourceMode, const Path* path) +{ + ASSERT(context); + ASSERT(resourceMode != ApplyToDefaultMode); + + if (path && !(resourceMode & ApplyToTextMode)) { + if (resourceMode & ApplyToFillMode) + context->fillPath(*path); + else if (resourceMode & ApplyToStrokeMode) + context->strokePath(*path); + } +} + +} + +#endif diff --git a/Source/WebCore/rendering/RenderSVGResourceSolidColor.h b/Source/WebCore/rendering/svg/RenderSVGResourceSolidColor.h index 72de3b2..02ceb31 100644 --- a/Source/WebCore/rendering/RenderSVGResourceSolidColor.h +++ b/Source/WebCore/rendering/svg/RenderSVGResourceSolidColor.h @@ -15,7 +15,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #ifndef RenderSVGResourceSolidColor_h diff --git a/Source/WebCore/rendering/RenderSVGRoot.cpp b/Source/WebCore/rendering/svg/RenderSVGRoot.cpp index 215aac7..aa87b09 100644 --- a/Source/WebCore/rendering/RenderSVGRoot.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGRoot.cpp @@ -1,24 +1,24 @@ /* - Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> - 2004, 2005, 2007, 2008, 2009 Rob Buis <buis@kde.org> - 2007 Eric Seidel <eric@webkit.org> - 2009 Google, Inc. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> + * Copyright (C) 2004, 2005, 2007, 2008, 2009 Rob Buis <buis@kde.org> + * Copyright (C) 2007 Eric Seidel <eric@webkit.org> + * Copyright (C) 2009 Google, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ #include "config.h" @@ -318,10 +318,10 @@ void RenderSVGRoot::updateCachedBoundaries() m_repaintBoundingBox.inflate(borderAndPaddingWidth()); } -bool RenderSVGRoot::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int _x, int _y, int _tx, int _ty, HitTestAction hitTestAction) +bool RenderSVGRoot::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int x, int y, int tx, int ty, HitTestAction hitTestAction) { - IntPoint pointInContainer(_x, _y); - IntSize containerToParentOffset(_tx, _ty); + IntPoint pointInContainer(x, y); + IntSize containerToParentOffset(tx, ty); IntPoint pointInParent = pointInContainer - containerToParentOffset; IntPoint pointInBorderBox = pointInParent - parentOriginToBorderBox(); @@ -338,7 +338,7 @@ bool RenderSVGRoot::nodeAtPoint(const HitTestRequest& request, HitTestResult& re // FIXME: CSS/HTML assumes the local point is relative to the border box, right? updateHitTestResult(result, pointInBorderBox); // FIXME: nodeAtFloatPoint() doesn't handle rect-based hit tests yet. - result.addNodeToRectBasedTestResult(child->node(), _x, _y); + result.addNodeToRectBasedTestResult(child->node(), x, y); return true; } } diff --git a/Source/WebCore/rendering/RenderSVGRoot.h b/Source/WebCore/rendering/svg/RenderSVGRoot.h index 1b6aa22..7aec3f8 100644 --- a/Source/WebCore/rendering/RenderSVGRoot.h +++ b/Source/WebCore/rendering/svg/RenderSVGRoot.h @@ -1,31 +1,32 @@ /* - Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> - 2004, 2005, 2007 Rob Buis <buis@kde.org> - Copyright (C) 2009 Google, Inc. All rights reserved. - Copyright (C) 2009 Apple Inc. All rights reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> + * Copyright (C) 2004, 2005, 2007 Rob Buis <buis@kde.org> + * Copyright (C) 2009 Google, Inc. All rights reserved. + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ #ifndef RenderSVGRoot_h #define RenderSVGRoot_h #if ENABLE(SVG) -#include "RenderBox.h" #include "FloatRect.h" +#include "RenderBox.h" + #include "SVGRenderSupport.h" namespace WebCore { diff --git a/Source/WebCore/rendering/RenderSVGShadowTreeRootContainer.cpp b/Source/WebCore/rendering/svg/RenderSVGShadowTreeRootContainer.cpp index 11b398a..5736333 100644 --- a/Source/WebCore/rendering/RenderSVGShadowTreeRootContainer.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGShadowTreeRootContainer.cpp @@ -1,21 +1,21 @@ /* - Copyright (C) Research In Motion Limited 2010. All rights reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ #include "config.h" diff --git a/Source/WebCore/rendering/RenderSVGShadowTreeRootContainer.h b/Source/WebCore/rendering/svg/RenderSVGShadowTreeRootContainer.h index bff2a87..cee8409 100644 --- a/Source/WebCore/rendering/RenderSVGShadowTreeRootContainer.h +++ b/Source/WebCore/rendering/svg/RenderSVGShadowTreeRootContainer.h @@ -1,21 +1,21 @@ /* - Copyright (C) Research In Motion Limited 2010. All rights reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ #ifndef RenderSVGShadowTreeRootContainer_h #define RenderSVGShadowTreeRootContainer_h diff --git a/Source/WebCore/rendering/svg/RenderSVGTSpan.cpp b/Source/WebCore/rendering/svg/RenderSVGTSpan.cpp index 90ff36c..872d076 100644 --- a/Source/WebCore/rendering/svg/RenderSVGTSpan.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGTSpan.cpp @@ -2,7 +2,7 @@ * This file is part of the WebKit project. * * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> - * (C) 2006 Apple Computer Inc. + * Copyright (C) 2006 Apple Computer Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -18,7 +18,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #include "config.h" diff --git a/Source/WebCore/rendering/svg/RenderSVGTSpan.h b/Source/WebCore/rendering/svg/RenderSVGTSpan.h index 97e0eb0..d5e2ed7 100644 --- a/Source/WebCore/rendering/svg/RenderSVGTSpan.h +++ b/Source/WebCore/rendering/svg/RenderSVGTSpan.h @@ -1,7 +1,7 @@ /* * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> - * (C) 2006 Apple Computer Inc. - * (C) 2009 Google Inc. + * Copyright (C) 2006 Apple Computer Inc. + * Copyright (C) 2009 Google Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -17,7 +17,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #ifndef RenderSVGTSpan_h diff --git a/Source/WebCore/rendering/svg/RenderSVGText.cpp b/Source/WebCore/rendering/svg/RenderSVGText.cpp index 01a92b0..dad0b70 100644 --- a/Source/WebCore/rendering/svg/RenderSVGText.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGText.cpp @@ -21,7 +21,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #include "config.h" diff --git a/Source/WebCore/rendering/svg/RenderSVGText.h b/Source/WebCore/rendering/svg/RenderSVGText.h index deae78c..188d5fc 100644 --- a/Source/WebCore/rendering/svg/RenderSVGText.h +++ b/Source/WebCore/rendering/svg/RenderSVGText.h @@ -17,7 +17,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #ifndef RenderSVGText_h diff --git a/Source/WebCore/rendering/svg/RenderSVGTextPath.cpp b/Source/WebCore/rendering/svg/RenderSVGTextPath.cpp index 4ba2eeb..4712ddc 100644 --- a/Source/WebCore/rendering/svg/RenderSVGTextPath.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGTextPath.cpp @@ -1,6 +1,4 @@ /* - * This file is part of the WebKit project. - * * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> * * This library is free software; you can redistribute it and/or @@ -17,7 +15,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #include "config.h" diff --git a/Source/WebCore/rendering/svg/RenderSVGTextPath.h b/Source/WebCore/rendering/svg/RenderSVGTextPath.h index a71edf5..f1871b0 100644 --- a/Source/WebCore/rendering/svg/RenderSVGTextPath.h +++ b/Source/WebCore/rendering/svg/RenderSVGTextPath.h @@ -1,6 +1,4 @@ /* - * This file is part of the WebKit project. - * * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> * Copyright (C) 2009 Apple Inc. All rights reserved. * @@ -18,7 +16,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #ifndef RenderSVGTextPath_h diff --git a/Source/WebCore/rendering/RenderSVGTransformableContainer.cpp b/Source/WebCore/rendering/svg/RenderSVGTransformableContainer.cpp index 3c91170..23aaa89 100644 --- a/Source/WebCore/rendering/RenderSVGTransformableContainer.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGTransformableContainer.cpp @@ -1,22 +1,22 @@ /* - Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> - 2004, 2005, 2006 Rob Buis <buis@kde.org> - 2009 Google, Inc. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> + * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> + * Copyright (C) 2009 Google, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. */ #include "config.h" @@ -50,7 +50,7 @@ bool RenderSVGTransformableContainer::calculateLocalTransform() return needsUpdate; FloatSize translation = static_cast<SVGShadowTreeContainerElement*>(element)->containerTranslation(); - if (translation.width() == 0 && translation.height() == 0) + if (!translation.width() && !translation.height()) return needsUpdate; // FIXME: Could optimize this case for use to avoid refetching the animatedLocalTransform() here, if only the containerTranslation() changed. diff --git a/Source/WebCore/rendering/svg/RenderSVGTransformableContainer.h b/Source/WebCore/rendering/svg/RenderSVGTransformableContainer.h new file mode 100644 index 0000000..401bfa8 --- /dev/null +++ b/Source/WebCore/rendering/svg/RenderSVGTransformableContainer.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2007 Eric Seidel <eric@webkit.org> + * Copyright (C) 2009 Google, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef RenderSVGTransformableContainer_h +#define RenderSVGTransformableContainer_h + +#if ENABLE(SVG) +#include "RenderSVGContainer.h" + +namespace WebCore { + +class SVGStyledTransformableElement; +class RenderSVGTransformableContainer : public RenderSVGContainer { +public: + explicit RenderSVGTransformableContainer(SVGStyledTransformableElement*); + + virtual const AffineTransform& localToParentTransform() const { return m_localTransform; } + virtual void setNeedsTransformUpdate() { m_needsTransformUpdate = true; } + +private: + virtual bool calculateLocalTransform(); + virtual AffineTransform localTransform() const { return m_localTransform; } + + bool m_needsTransformUpdate : 1; + AffineTransform m_localTransform; +}; +} + +#endif // ENABLE(SVG) +#endif // RenderSVGTransformableContainer_h diff --git a/Source/WebCore/rendering/RenderSVGViewportContainer.cpp b/Source/WebCore/rendering/svg/RenderSVGViewportContainer.cpp index 8031328..7f4b6f7 100644 --- a/Source/WebCore/rendering/RenderSVGViewportContainer.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGViewportContainer.cpp @@ -1,25 +1,24 @@ /* - Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> - 2004, 2005, 2007 Rob Buis <buis@kde.org> - 2007 Eric Seidel <eric@webkit.org> - 2009 Google, Inc. - Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> + * Copyright (C) 2004, 2005, 2007 Rob Buis <buis@kde.org> + * Copyright (C) 2007 Eric Seidel <eric@webkit.org> + * Copyright (C) 2009 Google, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ #include "config.h" diff --git a/Source/WebCore/rendering/RenderSVGViewportContainer.h b/Source/WebCore/rendering/svg/RenderSVGViewportContainer.h index 5373ca8..66037e6 100644 --- a/Source/WebCore/rendering/RenderSVGViewportContainer.h +++ b/Source/WebCore/rendering/svg/RenderSVGViewportContainer.h @@ -1,24 +1,24 @@ /* - Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> - 2004, 2005, 2007 Rob Buis <buis@kde.org> - 2009 Google, Inc. - Copyright (C) 2009 Apple Inc. All rights reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> + * Copyright (C) 2004, 2005, 2007 Rob Buis <buis@kde.org> + * Copyright (C) 2009 Google, Inc. + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ #ifndef RenderSVGViewportContainer_h #define RenderSVGViewportContainer_h diff --git a/Source/WebCore/rendering/SVGImageBufferTools.cpp b/Source/WebCore/rendering/svg/SVGImageBufferTools.cpp index 2dc0a6f..f0657af 100644 --- a/Source/WebCore/rendering/SVGImageBufferTools.cpp +++ b/Source/WebCore/rendering/svg/SVGImageBufferTools.cpp @@ -1,21 +1,21 @@ /* - Copyright (C) Research In Motion Limited 2010. All rights reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ #include "config.h" diff --git a/Source/WebCore/rendering/SVGImageBufferTools.h b/Source/WebCore/rendering/svg/SVGImageBufferTools.h index 9bcc7a4..cfb15b2 100644 --- a/Source/WebCore/rendering/SVGImageBufferTools.h +++ b/Source/WebCore/rendering/svg/SVGImageBufferTools.h @@ -1,21 +1,21 @@ /* - Copyright (C) Research In Motion Limited 2010. All rights reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ #ifndef SVGImageBufferTools_h #define SVGImageBufferTools_h diff --git a/Source/WebCore/rendering/svg/SVGInlineFlowBox.cpp b/Source/WebCore/rendering/svg/SVGInlineFlowBox.cpp index ea806c7..10735f6 100644 --- a/Source/WebCore/rendering/svg/SVGInlineFlowBox.cpp +++ b/Source/WebCore/rendering/svg/SVGInlineFlowBox.cpp @@ -1,7 +1,7 @@ /* * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> - * (C) 2006 Apple Computer Inc. - * (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> + * Copyright (C) 2006 Apple Computer Inc. + * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> * Copyright (C) Research In Motion Limited 2010. All rights reserved. * * This library is free software; you can redistribute it and/or @@ -18,7 +18,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #include "config.h" diff --git a/Source/WebCore/rendering/svg/SVGInlineFlowBox.h b/Source/WebCore/rendering/svg/SVGInlineFlowBox.h index 2358f2d..0e56c9f 100644 --- a/Source/WebCore/rendering/svg/SVGInlineFlowBox.h +++ b/Source/WebCore/rendering/svg/SVGInlineFlowBox.h @@ -1,8 +1,6 @@ /* - * This file is part of the WebKit project. - * * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> - * (C) 2006 Apple Computer Inc. + * Copyright (C) 2006 Apple Computer Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -18,7 +16,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #ifndef SVGInlineFlowBox_h diff --git a/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp b/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp index 5d0278b..f370310 100644 --- a/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp +++ b/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp @@ -1,6 +1,6 @@ /** * Copyright (C) 2007 Rob Buis <buis@kde.org> - * (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> + * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> * Copyright (C) Research In Motion Limited 2010. All rights reserved. * * This library is free software; you can redistribute it and/or @@ -17,7 +17,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #include "config.h" diff --git a/Source/WebCore/rendering/svg/SVGInlineTextBox.h b/Source/WebCore/rendering/svg/SVGInlineTextBox.h index acc5e9f..0458de0 100644 --- a/Source/WebCore/rendering/svg/SVGInlineTextBox.h +++ b/Source/WebCore/rendering/svg/SVGInlineTextBox.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2007 Rob Buis <buis@kde.org> - * (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> + * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> * Copyright (C) Research In Motion Limited 2010. All rights reserved. * * This library is free software; you can redistribute it and/or @@ -17,7 +17,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #ifndef SVGInlineTextBox_h diff --git a/Source/WebCore/rendering/SVGMarkerData.h b/Source/WebCore/rendering/svg/SVGMarkerData.h index ba11e7e..57c35cd 100644 --- a/Source/WebCore/rendering/SVGMarkerData.h +++ b/Source/WebCore/rendering/svg/SVGMarkerData.h @@ -1,21 +1,21 @@ /* - Copyright (C) Research In Motion Limited 2010. All rights reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ #ifndef SVGMarkerData_h #define SVGMarkerData_h diff --git a/Source/WebCore/rendering/SVGMarkerLayoutInfo.cpp b/Source/WebCore/rendering/svg/SVGMarkerLayoutInfo.cpp index aed756a..dea5a0c 100644 --- a/Source/WebCore/rendering/SVGMarkerLayoutInfo.cpp +++ b/Source/WebCore/rendering/svg/SVGMarkerLayoutInfo.cpp @@ -1,25 +1,25 @@ /* - Copyright (C) Research In Motion Limited 2010. All rights reserved. - 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> - 2004, 2005, 2008 Rob Buis <buis@kde.org> - 2005, 2007 Eric Seidel <eric@webkit.org> - 2009 Google, Inc. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> + * Copyright (C) 2004, 2005, 2008 Rob Buis <buis@kde.org> + * Copyright (C) 2005, 2007 Eric Seidel <eric@webkit.org> + * Copyright (C) 2009 Google, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ #include "config.h" diff --git a/Source/WebCore/rendering/SVGMarkerLayoutInfo.h b/Source/WebCore/rendering/svg/SVGMarkerLayoutInfo.h index 8f59703..0eb3689 100644 --- a/Source/WebCore/rendering/SVGMarkerLayoutInfo.h +++ b/Source/WebCore/rendering/svg/SVGMarkerLayoutInfo.h @@ -1,21 +1,21 @@ /* - Copyright (C) Research In Motion Limited 2010. All rights reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ #ifndef SVGMarkerLayoutInfo_h #define SVGMarkerLayoutInfo_h diff --git a/Source/WebCore/rendering/SVGRenderSupport.cpp b/Source/WebCore/rendering/svg/SVGRenderSupport.cpp index cbde49b..bfc74f0 100644 --- a/Source/WebCore/rendering/SVGRenderSupport.cpp +++ b/Source/WebCore/rendering/svg/SVGRenderSupport.cpp @@ -1,9 +1,9 @@ /* * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org> - * (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> - * (C) 2007 Eric Seidel <eric@webkit.org> - * (C) 2009 Google, Inc. All rights reserved. - * (C) 2009 Dirk Schulze <krit@webkit.org> + * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> + * Copyright (C) 2007 Eric Seidel <eric@webkit.org> + * Copyright (C) 2009 Google, Inc. All rights reserved. + * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. * * This library is free software; you can redistribute it and/or @@ -20,7 +20,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #include "config.h" diff --git a/Source/WebCore/rendering/SVGRenderSupport.h b/Source/WebCore/rendering/svg/SVGRenderSupport.h index 7814863..9e6aa5c 100644 --- a/Source/WebCore/rendering/SVGRenderSupport.h +++ b/Source/WebCore/rendering/svg/SVGRenderSupport.h @@ -1,7 +1,7 @@ /** * Copyright (C) 2007 Rob Buis <buis@kde.org> - * (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> - * (C) 2007 Eric Seidel <eric@webkit.org> + * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> + * Copyright (C) 2007 Eric Seidel <eric@webkit.org> * Copyright (C) 2009 Google, Inc. All rights reserved. * Copyright (C) Research In Motion Limited 2010. All rights reserved. * @@ -19,7 +19,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #ifndef SVGRenderSupport_h @@ -59,7 +58,7 @@ public: static bool pointInClippingArea(RenderObject*, const FloatPoint&); static void computeContainerBoundingBoxes(const RenderObject* container, FloatRect& objectBoundingBox, FloatRect& strokeBoundingBox, FloatRect& repaintBoundingBox); - static bool paintInfoIntersectsRepaintRect(const FloatRect& localRepaintRect, const AffineTransform& localTransform, const PaintInfo& paintInfo); + static bool paintInfoIntersectsRepaintRect(const FloatRect& localRepaintRect, const AffineTransform& localTransform, const PaintInfo&); // Important functions used by nearly all SVG renderers centralizing coordinate transformations / repaint rect calculations static IntRect clippedOverflowRectForRepaint(RenderObject*, RenderBoxModelObject* repaintContainer); @@ -70,7 +69,7 @@ public: static void applyStrokeStyleToContext(GraphicsContext*, const RenderStyle*, const RenderObject*); // FIXME: These methods do not belong here. - static const RenderSVGRoot* findTreeRootObject(const RenderObject* start); + static const RenderSVGRoot* findTreeRootObject(const RenderObject*); private: // This class is not constructable. diff --git a/Source/WebCore/rendering/SVGRenderTreeAsText.cpp b/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp index ea843c2..97e15af 100644 --- a/Source/WebCore/rendering/SVGRenderTreeAsText.cpp +++ b/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp @@ -243,15 +243,15 @@ static TextStream& operator<<(TextStream& ts, const DashArray& a) static TextStream& operator<<(TextStream& ts, LineCap style) { switch (style) { - case ButtCap: - ts << "BUTT"; - break; - case RoundCap: - ts << "ROUND"; - break; - case SquareCap: - ts << "SQUARE"; - break; + case ButtCap: + ts << "BUTT"; + break; + case RoundCap: + ts << "ROUND"; + break; + case SquareCap: + ts << "SQUARE"; + break; } return ts; } @@ -260,15 +260,15 @@ static TextStream& operator<<(TextStream& ts, LineCap style) static TextStream& operator<<(TextStream& ts, LineJoin style) { switch (style) { - case MiterJoin: - ts << "MITER"; - break; - case RoundJoin: - ts << "ROUND"; - break; - case BevelJoin: - ts << "BEVEL"; - break; + case MiterJoin: + ts << "MITER"; + break; + case RoundJoin: + ts << "ROUND"; + break; + case BevelJoin: + ts << "BEVEL"; + break; } return ts; } diff --git a/Source/WebCore/rendering/SVGRenderTreeAsText.h b/Source/WebCore/rendering/svg/SVGRenderTreeAsText.h index 4e9ba5d..ce07a5c 100644 --- a/Source/WebCore/rendering/SVGRenderTreeAsText.h +++ b/Source/WebCore/rendering/svg/SVGRenderTreeAsText.h @@ -32,20 +32,20 @@ namespace WebCore { - class Color; - class FloatRect; - class FloatSize; - class Node; - class RenderBlock; - class RenderImage; - class RenderObject; - class RenderSVGGradientStop; - class RenderSVGImage; - class RenderSVGPath; - class RenderSVGRoot; - class RenderText; - class AffineTransform; - class SVGUnitTypes; +class Color; +class FloatRect; +class FloatSize; +class Node; +class RenderBlock; +class RenderImage; +class RenderObject; +class RenderSVGGradientStop; +class RenderSVGImage; +class RenderSVGPath; +class RenderSVGRoot; +class RenderText; +class AffineTransform; +class SVGUnitTypes; // functions used by the main RenderTreeAsText code void write(TextStream&, const RenderSVGPath&, int indent); diff --git a/Source/WebCore/rendering/SVGResources.cpp b/Source/WebCore/rendering/svg/SVGResources.cpp index e162f83..9a2c999 100644 --- a/Source/WebCore/rendering/SVGResources.cpp +++ b/Source/WebCore/rendering/svg/SVGResources.cpp @@ -1,21 +1,21 @@ /* - Copyright (C) Research In Motion Limited 2010. All rights reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ #include "config.h" #include "SVGResources.h" diff --git a/Source/WebCore/rendering/SVGResources.h b/Source/WebCore/rendering/svg/SVGResources.h index 49591cf..dd328b8 100644 --- a/Source/WebCore/rendering/SVGResources.h +++ b/Source/WebCore/rendering/svg/SVGResources.h @@ -1,21 +1,21 @@ /* - Copyright (C) Research In Motion Limited 2010. All rights reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ #ifndef SVGResources_h #define SVGResources_h diff --git a/Source/WebCore/rendering/SVGResourcesCache.cpp b/Source/WebCore/rendering/svg/SVGResourcesCache.cpp index 88cbb3a..886f76a 100644 --- a/Source/WebCore/rendering/SVGResourcesCache.cpp +++ b/Source/WebCore/rendering/svg/SVGResourcesCache.cpp @@ -1,21 +1,21 @@ /* - Copyright (C) Research In Motion Limited 2010. All rights reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ #include "config.h" #include "SVGResourcesCache.h" diff --git a/Source/WebCore/rendering/SVGResourcesCache.h b/Source/WebCore/rendering/svg/SVGResourcesCache.h index 4a61570..30eaeca 100644 --- a/Source/WebCore/rendering/SVGResourcesCache.h +++ b/Source/WebCore/rendering/svg/SVGResourcesCache.h @@ -1,21 +1,21 @@ /* - Copyright (C) Research In Motion Limited 2010. All rights reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ #ifndef SVGResourcesCache_h #define SVGResourcesCache_h diff --git a/Source/WebCore/rendering/SVGResourcesCycleSolver.cpp b/Source/WebCore/rendering/svg/SVGResourcesCycleSolver.cpp index 8cd2e80..fa91e80 100644 --- a/Source/WebCore/rendering/SVGResourcesCycleSolver.cpp +++ b/Source/WebCore/rendering/svg/SVGResourcesCycleSolver.cpp @@ -1,21 +1,21 @@ /* - Copyright (C) Research In Motion Limited 2010. All rights reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ #include "config.h" #include "SVGResourcesCycleSolver.h" diff --git a/Source/WebCore/rendering/svg/SVGResourcesCycleSolver.h b/Source/WebCore/rendering/svg/SVGResourcesCycleSolver.h new file mode 100644 index 0000000..0653304 --- /dev/null +++ b/Source/WebCore/rendering/svg/SVGResourcesCycleSolver.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef SVGResourcesCycleSolver_h +#define SVGResourcesCycleSolver_h + +#if ENABLE(SVG) +#include <wtf/HashSet.h> + +namespace WebCore { + +class RenderObject; +class RenderSVGResourceContainer; +class SVGResources; + +class SVGResourcesCycleSolver : public Noncopyable { +public: + SVGResourcesCycleSolver(RenderObject*, SVGResources*); + ~SVGResourcesCycleSolver(); + + void resolveCycles(); + +private: + bool resourceContainsCycles(RenderObject*) const; + void breakCycle(RenderSVGResourceContainer*); + + RenderObject* m_renderer; + SVGResources* m_resources; + HashSet<RenderSVGResourceContainer*> m_allResources; +}; + +} + +#endif +#endif diff --git a/Source/WebCore/rendering/svg/SVGRootInlineBox.cpp b/Source/WebCore/rendering/svg/SVGRootInlineBox.cpp index 49c76de..c2289d6 100644 --- a/Source/WebCore/rendering/svg/SVGRootInlineBox.cpp +++ b/Source/WebCore/rendering/svg/SVGRootInlineBox.cpp @@ -18,7 +18,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #include "config.h" diff --git a/Source/WebCore/rendering/svg/SVGRootInlineBox.h b/Source/WebCore/rendering/svg/SVGRootInlineBox.h index 418c289..2e073c9 100644 --- a/Source/WebCore/rendering/svg/SVGRootInlineBox.h +++ b/Source/WebCore/rendering/svg/SVGRootInlineBox.h @@ -1,7 +1,7 @@ /* * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> - * (C) 2006 Apple Computer Inc. - * (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> + * Copyright (C) 2006 Apple Computer Inc. + * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> * Copyright (C) Research In Motion Limited 2010. All rights reserved. * * This library is free software; you can redistribute it and/or @@ -18,7 +18,6 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * */ #ifndef SVGRootInlineBox_h diff --git a/Source/WebCore/rendering/SVGShadowTreeElements.cpp b/Source/WebCore/rendering/svg/SVGShadowTreeElements.cpp index 7c5e1a9..2d84c48 100644 --- a/Source/WebCore/rendering/SVGShadowTreeElements.cpp +++ b/Source/WebCore/rendering/svg/SVGShadowTreeElements.cpp @@ -1,21 +1,21 @@ /* - Copyright (C) Research In Motion Limited 2010. All rights reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ #include "config.h" diff --git a/Source/WebCore/rendering/SVGShadowTreeElements.h b/Source/WebCore/rendering/svg/SVGShadowTreeElements.h index fe25678..3406f95 100644 --- a/Source/WebCore/rendering/SVGShadowTreeElements.h +++ b/Source/WebCore/rendering/svg/SVGShadowTreeElements.h @@ -1,21 +1,21 @@ /* - Copyright (C) Research In Motion Limited 2010. All rights reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ #ifndef SVGShadowTreeElements_h #define SVGShadowTreeElements_h diff --git a/Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp b/Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp index 7060ac6..3863322 100644 --- a/Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp +++ b/Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp @@ -154,8 +154,7 @@ float SVGTextLayoutEngineBaseline::calculateGlyphOrientationAngle(bool isVertica ASSERT(style); switch (isVerticalText ? style->glyphOrientationVertical() : style->glyphOrientationHorizontal()) { - case GO_AUTO: - { + case GO_AUTO: { // Spec: Fullwidth ideographic and fullwidth Latin text will be set with a glyph-orientation of 0-degrees. // Text which is not fullwidth will be set with a glyph-orientation of 90-degrees. unsigned int unicodeRange = findCharUnicodeRange(character); diff --git a/Source/WebCore/rendering/svg/SVGTextQuery.cpp b/Source/WebCore/rendering/svg/SVGTextQuery.cpp index fcc7924..42d511b 100644 --- a/Source/WebCore/rendering/svg/SVGTextQuery.cpp +++ b/Source/WebCore/rendering/svg/SVGTextQuery.cpp @@ -1,21 +1,21 @@ /* - Copyright (C) Research In Motion Limited 2010. All rights reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ #include "config.h" #include "SVGTextQuery.h" diff --git a/Source/WebCore/rendering/svg/SVGTextQuery.h b/Source/WebCore/rendering/svg/SVGTextQuery.h index 9a671f4..331dd94 100644 --- a/Source/WebCore/rendering/svg/SVGTextQuery.h +++ b/Source/WebCore/rendering/svg/SVGTextQuery.h @@ -1,21 +1,21 @@ /* - Copyright (C) Research In Motion Limited 2010. All rights reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ #ifndef SVGTextQuery_h #define SVGTextQuery_h |