From ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24 Mon Sep 17 00:00:00 2001 From: Steve Block Date: Thu, 8 Jul 2010 12:51:48 +0100 Subject: Merge WebKit at r62496: Initial merge by git Change-Id: Ie3da0770eca22a70a632e3571f31cfabc80facb2 --- WebCore/rendering/EllipsisBox.cpp | 2 +- WebCore/rendering/EllipsisBox.h | 2 +- WebCore/rendering/InlineBox.cpp | 6 +- WebCore/rendering/InlineBox.h | 2 +- WebCore/rendering/InlineFlowBox.cpp | 22 +- WebCore/rendering/InlineFlowBox.h | 12 +- WebCore/rendering/InlineTextBox.cpp | 50 +++-- WebCore/rendering/InlineTextBox.h | 5 +- WebCore/rendering/MediaControlElements.cpp | 4 +- WebCore/rendering/PaintInfo.h | 105 ++++++++++ WebCore/rendering/PaintPhase.h | 66 ++++++ WebCore/rendering/RenderBlock.cpp | 16 +- WebCore/rendering/RenderBlock.h | 1 - WebCore/rendering/RenderBlockLineLayout.cpp | 8 +- WebCore/rendering/RenderBox.cpp | 15 +- WebCore/rendering/RenderBox.h | 4 - WebCore/rendering/RenderBoxModelObject.cpp | 233 +++++++++++++++++++++ WebCore/rendering/RenderBoxModelObject.h | 2 + WebCore/rendering/RenderEmbeddedObject.cpp | 4 + WebCore/rendering/RenderEmbeddedObject.h | 2 + WebCore/rendering/RenderFieldset.cpp | 2 +- WebCore/rendering/RenderForeignObject.cpp | 13 +- WebCore/rendering/RenderInputSpeech.cpp | 89 ++++++++ WebCore/rendering/RenderInputSpeech.h | 49 +++++ WebCore/rendering/RenderLayer.cpp | 28 +-- WebCore/rendering/RenderLayer.h | 8 +- WebCore/rendering/RenderLayerBacking.cpp | 8 +- WebCore/rendering/RenderLineBoxList.cpp | 4 +- WebCore/rendering/RenderLineBoxList.h | 2 +- WebCore/rendering/RenderMediaControls.cpp | 2 +- WebCore/rendering/RenderMediaControls.h | 2 +- WebCore/rendering/RenderMediaControlsChromium.cpp | 16 +- WebCore/rendering/RenderMediaControlsChromium.h | 2 +- WebCore/rendering/RenderObject.cpp | 178 ++++++++++++++++ WebCore/rendering/RenderObject.h | 91 ++------ WebCore/rendering/RenderPath.cpp | 16 +- WebCore/rendering/RenderProgress.cpp | 7 +- WebCore/rendering/RenderReplaced.cpp | 4 +- WebCore/rendering/RenderSVGAllInOne.cpp | 64 ++++++ WebCore/rendering/RenderSVGBlock.h | 3 +- WebCore/rendering/RenderSVGContainer.cpp | 32 ++- WebCore/rendering/RenderSVGHiddenContainer.cpp | 2 +- WebCore/rendering/RenderSVGImage.cpp | 18 +- WebCore/rendering/RenderSVGImage.h | 3 +- WebCore/rendering/RenderSVGInline.cpp | 14 +- WebCore/rendering/RenderSVGInline.h | 3 +- WebCore/rendering/RenderSVGModelObject.cpp | 14 +- WebCore/rendering/RenderSVGModelObject.h | 4 +- WebCore/rendering/RenderSVGResource.cpp | 57 +++++ WebCore/rendering/RenderSVGResource.h | 2 + WebCore/rendering/RenderSVGResourceClipper.cpp | 4 +- WebCore/rendering/RenderSVGResourceGradient.cpp | 8 +- WebCore/rendering/RenderSVGResourceMarker.cpp | 8 +- WebCore/rendering/RenderSVGResourceMarker.h | 2 +- WebCore/rendering/RenderSVGResourceMasker.cpp | 2 +- WebCore/rendering/RenderSVGResourcePattern.cpp | 21 +- WebCore/rendering/RenderSVGResourceSolidColor.cpp | 3 +- WebCore/rendering/RenderSVGRoot.cpp | 34 ++- WebCore/rendering/RenderSVGRoot.h | 9 +- WebCore/rendering/RenderSVGText.cpp | 15 +- WebCore/rendering/RenderSVGViewportContainer.cpp | 6 +- WebCore/rendering/RenderScrollbarPart.cpp | 2 +- WebCore/rendering/RenderTable.cpp | 4 +- WebCore/rendering/RenderTableCell.cpp | 6 +- WebCore/rendering/RenderTextControlSingleLine.cpp | 23 +- WebCore/rendering/RenderTheme.cpp | 28 ++- WebCore/rendering/RenderTheme.h | 83 ++++---- WebCore/rendering/RenderThemeChromiumLinux.cpp | 6 +- WebCore/rendering/RenderThemeChromiumMac.h | 12 +- WebCore/rendering/RenderThemeChromiumMac.mm | 12 +- WebCore/rendering/RenderThemeChromiumSkia.cpp | 54 ++--- WebCore/rendering/RenderThemeChromiumSkia.h | 42 ++-- WebCore/rendering/RenderThemeChromiumWin.cpp | 33 +-- WebCore/rendering/RenderThemeChromiumWin.h | 18 +- WebCore/rendering/RenderThemeMac.h | 56 ++--- WebCore/rendering/RenderThemeMac.mm | 68 +++--- WebCore/rendering/RenderThemeSafari.cpp | 46 ++-- WebCore/rendering/RenderThemeSafari.h | 46 ++-- WebCore/rendering/RenderThemeWin.cpp | 36 ++-- WebCore/rendering/RenderThemeWin.h | 44 ++-- WebCore/rendering/RenderThemeWince.cpp | 34 +-- WebCore/rendering/RenderThemeWince.h | 42 ++-- WebCore/rendering/RenderWidget.cpp | 4 + WebCore/rendering/RootInlineBox.cpp | 12 +- WebCore/rendering/RootInlineBox.h | 8 +- WebCore/rendering/SVGInlineFlowBox.cpp | 11 +- WebCore/rendering/SVGInlineFlowBox.h | 2 +- WebCore/rendering/SVGInlineTextBox.cpp | 67 +++--- WebCore/rendering/SVGInlineTextBox.h | 3 +- WebCore/rendering/SVGMarkerLayoutInfo.cpp | 2 +- WebCore/rendering/SVGMarkerLayoutInfo.h | 2 +- WebCore/rendering/SVGRenderSupport.cpp | 204 ++++++------------ WebCore/rendering/SVGRenderSupport.h | 76 +++---- WebCore/rendering/SVGRenderTreeAsText.cpp | 2 +- WebCore/rendering/SVGRootInlineBox.cpp | 12 +- WebCore/rendering/SVGRootInlineBox.h | 5 +- WebCore/rendering/ShadowElement.cpp | 4 +- WebCore/rendering/TextControlInnerElements.cpp | 2 +- WebCore/rendering/style/RenderStyle.cpp | 46 +++- WebCore/rendering/style/RenderStyle.h | 7 + WebCore/rendering/style/SVGRenderStyle.cpp | 84 ++++++++ WebCore/rendering/style/SVGRenderStyle.h | 6 +- .../rendering/style/StyleRareNonInheritedData.cpp | 6 + .../rendering/style/StyleRareNonInheritedData.h | 13 +- 104 files changed, 1798 insertions(+), 885 deletions(-) create mode 100644 WebCore/rendering/PaintInfo.h create mode 100644 WebCore/rendering/PaintPhase.h create mode 100644 WebCore/rendering/RenderInputSpeech.cpp create mode 100644 WebCore/rendering/RenderInputSpeech.h create mode 100644 WebCore/rendering/RenderSVGAllInOne.cpp (limited to 'WebCore/rendering') diff --git a/WebCore/rendering/EllipsisBox.cpp b/WebCore/rendering/EllipsisBox.cpp index 9d36086..96efbe2 100644 --- a/WebCore/rendering/EllipsisBox.cpp +++ b/WebCore/rendering/EllipsisBox.cpp @@ -27,7 +27,7 @@ namespace WebCore { -void EllipsisBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty) +void EllipsisBox::paint(PaintInfo& paintInfo, int tx, int ty) { GraphicsContext* context = paintInfo.context; RenderStyle* style = m_renderer->style(m_firstLine); diff --git a/WebCore/rendering/EllipsisBox.h b/WebCore/rendering/EllipsisBox.h index 087fc72..476331c 100644 --- a/WebCore/rendering/EllipsisBox.h +++ b/WebCore/rendering/EllipsisBox.h @@ -39,7 +39,7 @@ public: { } - virtual void paint(RenderObject::PaintInfo&, int tx, int ty); + virtual void paint(PaintInfo&, int tx, int ty); virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty); void setSelectionState(RenderObject::SelectionState s) { m_selectionState = s; } IntRect selectionRect(int tx, int ty); diff --git a/WebCore/rendering/InlineBox.cpp b/WebCore/rendering/InlineBox.cpp index 213737c..5475187 100644 --- a/WebCore/rendering/InlineBox.cpp +++ b/WebCore/rendering/InlineBox.cpp @@ -159,16 +159,16 @@ void InlineBox::adjustPosition(int dx, int dy) } } -void InlineBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty) +void InlineBox::paint(PaintInfo& paintInfo, int tx, int ty) { - if (!renderer()->shouldPaintWithinRoot(paintInfo) || (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection)) + if (!paintInfo.shouldPaintWithinRoot(renderer()) || (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection)) return; // Paint all phases of replaced elements atomically, as though the replaced element established its // own stacking context. (See Appendix E.2, section 6.4 on inline block/table elements in the CSS2.1 // specification.) bool preservePhase = paintInfo.phase == PaintPhaseSelection || paintInfo.phase == PaintPhaseTextClip; - RenderObject::PaintInfo info(paintInfo); + PaintInfo info(paintInfo); info.phase = preservePhase ? paintInfo.phase : PaintPhaseBlockBackground; renderer()->paint(info, tx, ty); if (!preservePhase) { diff --git a/WebCore/rendering/InlineBox.h b/WebCore/rendering/InlineBox.h index eec9c1b..ab0167c 100644 --- a/WebCore/rendering/InlineBox.h +++ b/WebCore/rendering/InlineBox.h @@ -112,7 +112,7 @@ public: virtual void adjustPosition(int dx, int dy); - virtual void paint(RenderObject::PaintInfo&, int tx, int ty); + virtual void paint(PaintInfo&, int tx, int ty); virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty); // Overloaded new operator. diff --git a/WebCore/rendering/InlineFlowBox.cpp b/WebCore/rendering/InlineFlowBox.cpp index c329b23..c2d8549 100644 --- a/WebCore/rendering/InlineFlowBox.cpp +++ b/WebCore/rendering/InlineFlowBox.cpp @@ -648,7 +648,7 @@ bool InlineFlowBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re return false; } -void InlineFlowBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty) +void InlineFlowBox::paint(PaintInfo& paintInfo, int tx, int ty) { IntRect overflowRect(visibleOverflowRect()); overflowRect.inflate(renderer()->maximalOutlineSize(paintInfo.phase)); @@ -687,9 +687,9 @@ void InlineFlowBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty) return; PaintPhase paintPhase = paintInfo.phase == PaintPhaseChildOutlines ? PaintPhaseOutline : paintInfo.phase; - RenderObject::PaintInfo childInfo(paintInfo); + PaintInfo childInfo(paintInfo); childInfo.phase = paintPhase; - childInfo.paintingRoot = renderer()->paintingRootForChildren(paintInfo); + childInfo.updatePaintingRootForChildren(renderer()); // 3. Paint our children. if (paintPhase != PaintPhaseSelfOutline) { @@ -704,7 +704,7 @@ void InlineFlowBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty) paintTextDecorations(paintInfo, tx, ty, true); } -void InlineFlowBox::paintFillLayers(const RenderObject::PaintInfo& paintInfo, const Color& c, const FillLayer* fillLayer, int _tx, int _ty, int w, int h, CompositeOperator op) +void InlineFlowBox::paintFillLayers(const PaintInfo& paintInfo, const Color& c, const FillLayer* fillLayer, int _tx, int _ty, int w, int h, CompositeOperator op) { if (!fillLayer) return; @@ -712,7 +712,7 @@ void InlineFlowBox::paintFillLayers(const RenderObject::PaintInfo& paintInfo, co paintFillLayer(paintInfo, c, fillLayer, _tx, _ty, w, h, op); } -void InlineFlowBox::paintFillLayer(const RenderObject::PaintInfo& paintInfo, const Color& c, const FillLayer* fillLayer, int tx, int ty, int w, int h, CompositeOperator op) +void InlineFlowBox::paintFillLayer(const PaintInfo& paintInfo, const Color& c, const FillLayer* fillLayer, int tx, int ty, int w, int h, CompositeOperator op) { StyleImage* img = fillLayer->image(); bool hasFillImage = img && img->canRender(renderer()->style()->effectiveZoom()); @@ -752,9 +752,9 @@ void InlineFlowBox::paintBoxShadow(GraphicsContext* context, RenderStyle* s, Sha } } -void InlineFlowBox::paintBoxDecorations(RenderObject::PaintInfo& paintInfo, int tx, int ty) +void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty) { - if (!renderer()->shouldPaintWithinRoot(paintInfo) || renderer()->style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseForeground) + if (!paintInfo.shouldPaintWithinRoot(renderer()) || renderer()->style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseForeground) return; int x = m_x; @@ -828,9 +828,9 @@ void InlineFlowBox::paintBoxDecorations(RenderObject::PaintInfo& paintInfo, int } } -void InlineFlowBox::paintMask(RenderObject::PaintInfo& paintInfo, int tx, int ty) +void InlineFlowBox::paintMask(PaintInfo& paintInfo, int tx, int ty) { - if (!renderer()->shouldPaintWithinRoot(paintInfo) || renderer()->style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) + if (!paintInfo.shouldPaintWithinRoot(renderer()) || renderer()->style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) return; int x = m_x; @@ -920,11 +920,11 @@ static bool shouldDrawTextDecoration(RenderObject* obj) return false; } -void InlineFlowBox::paintTextDecorations(RenderObject::PaintInfo& paintInfo, int tx, int ty, bool paintedChildren) +void InlineFlowBox::paintTextDecorations(PaintInfo& paintInfo, int tx, int ty, bool paintedChildren) { // Paint text decorations like underlines/overlines. We only do this if we aren't in quirks mode (i.e., in // almost-strict mode or strict mode). - if (renderer()->style()->htmlHacks() || !renderer()->shouldPaintWithinRoot(paintInfo) || + if (renderer()->style()->htmlHacks() || !paintInfo.shouldPaintWithinRoot(renderer()) || renderer()->style()->visibility() != VISIBLE) return; diff --git a/WebCore/rendering/InlineFlowBox.h b/WebCore/rendering/InlineFlowBox.h index b933c09..9589c0a 100644 --- a/WebCore/rendering/InlineFlowBox.h +++ b/WebCore/rendering/InlineFlowBox.h @@ -91,13 +91,13 @@ public: virtual void clearTruncation(); - virtual void paintBoxDecorations(RenderObject::PaintInfo&, int tx, int ty); - virtual void paintMask(RenderObject::PaintInfo&, int tx, int ty); - void paintFillLayers(const RenderObject::PaintInfo&, const Color&, const FillLayer*, int tx, int ty, int w, int h, CompositeOperator = CompositeSourceOver); - void paintFillLayer(const RenderObject::PaintInfo&, const Color&, const FillLayer*, int tx, int ty, int w, int h, CompositeOperator = CompositeSourceOver); + virtual void paintBoxDecorations(PaintInfo&, int tx, int ty); + virtual void paintMask(PaintInfo&, int tx, int ty); + void paintFillLayers(const PaintInfo&, const Color&, const FillLayer*, int tx, int ty, int w, int h, CompositeOperator = CompositeSourceOver); + void paintFillLayer(const PaintInfo&, const Color&, const FillLayer*, int tx, int ty, int w, int h, CompositeOperator = CompositeSourceOver); void paintBoxShadow(GraphicsContext*, RenderStyle*, ShadowStyle, int tx, int ty, int w, int h); - virtual void paintTextDecorations(RenderObject::PaintInfo&, int tx, int ty, bool paintedChildren = false); - virtual void paint(RenderObject::PaintInfo&, int tx, int ty); + virtual void paintTextDecorations(PaintInfo&, int tx, int ty, bool paintedChildren = false); + virtual void paint(PaintInfo&, int tx, int ty); virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty); virtual RenderLineBoxList* rendererLineBoxes() const; diff --git a/WebCore/rendering/InlineTextBox.cpp b/WebCore/rendering/InlineTextBox.cpp index 09825b6..d6bd70c 100644 --- a/WebCore/rendering/InlineTextBox.cpp +++ b/WebCore/rendering/InlineTextBox.cpp @@ -306,6 +306,31 @@ bool InlineTextBox::nodeAtPoint(const HitTestRequest&, HitTestResult& result, in return false; } +FloatSize InlineTextBox::applyShadowToGraphicsContext(GraphicsContext* context, const ShadowData* shadow, const FloatRect& textRect, bool stroked, bool opaque) +{ + if (!shadow) + return FloatSize(); + + FloatSize extraOffset; + FloatSize shadowOffset(shadow->x(), shadow->y()); + int shadowBlur = shadow->blur(); + const Color& shadowColor = shadow->color(); + + if (shadow->next() || stroked || !opaque) { + FloatRect shadowRect(textRect); + shadowRect.inflate(shadowBlur); + shadowRect.move(shadowOffset); + context->save(); + context->clip(shadowRect); + + extraOffset = FloatSize(0, 2 * textRect.height() + max(0.0f, shadowOffset.height()) + shadowBlur); + shadowOffset -= extraOffset; + } + + context->setShadow(shadowOffset, shadowBlur, shadowColor, context->fillColorSpace()); + return extraOffset; +} + static void paintTextWithShadows(GraphicsContext* context, const Font& font, const TextRun& textRun, int startOffset, int endOffset, int truncationPoint, const IntPoint& textOrigin, int x, int y, int w, int h, const ShadowData* shadow, bool stroked) { Color fillColor = context->fillColor(); @@ -316,24 +341,9 @@ static void paintTextWithShadows(GraphicsContext* context, const Font& font, con do { IntSize extraOffset; - - if (shadow) { - IntSize shadowOffset(shadow->x(), shadow->y()); - int shadowBlur = shadow->blur(); - const Color& shadowColor = shadow->color(); - - if (shadow->next() || stroked || !opaque) { - IntRect shadowRect(x, y, w, h); - shadowRect.inflate(shadowBlur); - shadowRect.move(shadowOffset); - context->save(); - context->clip(shadowRect); - - extraOffset = IntSize(0, 2 * h + max(0, shadowOffset.height()) + shadowBlur); - shadowOffset -= extraOffset; - } - context->setShadow(shadowOffset, shadowBlur, shadowColor, fillColorSpace); - } else if (!opaque) + if (shadow) + extraOffset = roundedIntSize(InlineTextBox::applyShadowToGraphicsContext(context, shadow, FloatRect(x, y, w, h), stroked, opaque)); + else if (!opaque) context->setFillColor(fillColor, fillColorSpace); if (startOffset <= endOffset) @@ -357,9 +367,9 @@ static void paintTextWithShadows(GraphicsContext* context, const Font& font, con } while (shadow || stroked || !opaque); } -void InlineTextBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty) +void InlineTextBox::paint(PaintInfo& paintInfo, int tx, int ty) { - if (isLineBreak() || !renderer()->shouldPaintWithinRoot(paintInfo) || renderer()->style()->visibility() != VISIBLE || + if (isLineBreak() || !paintInfo.shouldPaintWithinRoot(renderer()) || renderer()->style()->visibility() != VISIBLE || m_truncation == cFullTruncation || paintInfo.phase == PaintPhaseOutline) return; diff --git a/WebCore/rendering/InlineTextBox.h b/WebCore/rendering/InlineTextBox.h index 2ef5ec9..fcbf23a 100644 --- a/WebCore/rendering/InlineTextBox.h +++ b/WebCore/rendering/InlineTextBox.h @@ -80,7 +80,7 @@ public: virtual void selectionStartEnd(int& sPos, int& ePos); protected: - virtual void paint(RenderObject::PaintInfo&, int tx, int ty); + virtual void paint(PaintInfo&, int tx, int ty); virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty); public: @@ -121,6 +121,9 @@ public: bool containsCaretOffset(int offset) const; // false for offset after line break + // Needs to be public, so the static paintTextWithShadows() function can use it. + static FloatSize applyShadowToGraphicsContext(GraphicsContext*, const ShadowData*, const FloatRect& textRect, bool stroked, bool opaque); + private: InlineTextBox* m_prevTextBox; // The previous box that also uses our RenderObject InlineTextBox* m_nextTextBox; // The next box that also uses our RenderObject diff --git a/WebCore/rendering/MediaControlElements.cpp b/WebCore/rendering/MediaControlElements.cpp index 383a8cf..d5cb187 100644 --- a/WebCore/rendering/MediaControlElements.cpp +++ b/WebCore/rendering/MediaControlElements.cpp @@ -135,7 +135,7 @@ PassRefPtr MediaControlElement::create(HTMLMediaElement* me void MediaControlElement::attachToParent(Element* parent) { - parent->addChild(this); + parent->legacyParserAddChild(this); } void MediaControlElement::update() @@ -389,7 +389,7 @@ MediaControlInputElement::MediaControlInputElement(HTMLMediaElement* mediaElemen void MediaControlInputElement::attachToParent(Element* parent) { - parent->addChild(this); + parent->legacyParserAddChild(this); } void MediaControlInputElement::update() diff --git a/WebCore/rendering/PaintInfo.h b/WebCore/rendering/PaintInfo.h new file mode 100644 index 0000000..213eb30 --- /dev/null +++ b/WebCore/rendering/PaintInfo.h @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2000 Lars Knoll (knoll@kde.org) + * (C) 2000 Antti Koivisto (koivisto@kde.org) + * (C) 2000 Dirk Mueller (mueller@kde.org) + * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) + * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2009 Google 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 PaintInfo_h +#define PaintInfo_h + +#if ENABLE(SVG) +#include "AffineTransform.h" +#endif + +#include "GraphicsContext.h" +#include "IntRect.h" +#include "PaintPhase.h" +#include +#include + +namespace WebCore { + +class OverlapTestRequestClient; +class RenderInline; +class RenderObject; + +typedef HashMap OverlapTestRequestMap; + +/* + * Paint the object and its children, clipped by (x|y|w|h). + * (tx|ty) is the calculated position of the parent + */ +struct PaintInfo { + PaintInfo(GraphicsContext* newContext, const IntRect& newRect, PaintPhase newPhase, bool newForceBlackText, + RenderObject* newPaintingRoot, ListHashSet* newOutlineObjects, + OverlapTestRequestMap* overlapTestRequests = 0) + : context(newContext) + , rect(newRect) + , phase(newPhase) + , forceBlackText(newForceBlackText) + , paintingRoot(newPaintingRoot) + , outlineObjects(newOutlineObjects) + , overlapTestRequests(overlapTestRequests) + { + } + + void updatePaintingRootForChildren(const RenderObject* renderer) + { + if (!paintingRoot) + return; + + // If we're the painting root, kids draw normally, and see root of 0. + if (paintingRoot == renderer) { + paintingRoot = 0; + return; + } + } + + bool shouldPaintWithinRoot(const RenderObject* renderer) const + { + return !paintingRoot || paintingRoot == renderer; + } + +#if ENABLE(SVG) + void applyTransform(const AffineTransform& localToAncestorTransform) + { + if (localToAncestorTransform.isIdentity()) + return; + + context->concatCTM(localToAncestorTransform); + rect = localToAncestorTransform.inverse().mapRect(rect); + } +#endif + + // FIXME: Introduce setters/getters at some point. Requires a lot of changes throughout rendering/. + GraphicsContext* context; + IntRect rect; + PaintPhase phase; + bool forceBlackText; + RenderObject* paintingRoot; // used to draw just one element and its visual kids + ListHashSet* outlineObjects; // used to list outlines that should be painted by a block with inline children + OverlapTestRequestMap* overlapTestRequests; +}; + +} // namespace WebCore + +#endif // PaintInfo_h diff --git a/WebCore/rendering/PaintPhase.h b/WebCore/rendering/PaintPhase.h new file mode 100644 index 0000000..396131f --- /dev/null +++ b/WebCore/rendering/PaintPhase.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2000 Lars Knoll (knoll@kde.org) + * (C) 2000 Antti Koivisto (koivisto@kde.org) + * (C) 2000 Dirk Mueller (mueller@kde.org) + * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) + * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2009 Google 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 PaintPhase_h +#define PaintPhase_h + +namespace WebCore { + +/* + * The painting of a layer occurs in three distinct phases. Each phase involves + * a recursive descent into the layer's render objects. The first phase is the background phase. + * The backgrounds and borders of all blocks are painted. Inlines are not painted at all. + * Floats must paint above block backgrounds but entirely below inline content that can overlap them. + * In the foreground phase, all inlines are fully painted. Inline replaced elements will get all + * three phases invoked on them during this phase. + */ + +enum PaintPhase { + PaintPhaseBlockBackground, + PaintPhaseChildBlockBackground, + PaintPhaseChildBlockBackgrounds, + PaintPhaseFloat, + PaintPhaseForeground, + PaintPhaseOutline, + PaintPhaseChildOutlines, + PaintPhaseSelfOutline, + PaintPhaseSelection, + PaintPhaseCollapsedTableBorders, + PaintPhaseTextClip, + PaintPhaseMask +}; + +enum PaintBehaviorFlags { + PaintBehaviorNormal = 0, + PaintBehaviorSelectionOnly = 1 << 0, + PaintBehaviorForceBlackText = 1 << 1, + PaintBehaviorFlattenCompositingLayers = 1 << 2 +}; + +typedef unsigned PaintBehavior; + +} // namespace WebCore + +#endif // PaintPhase_h diff --git a/WebCore/rendering/RenderBlock.cpp b/WebCore/rendering/RenderBlock.cpp index f60b13c..58c5842 100644 --- a/WebCore/rendering/RenderBlock.cpp +++ b/WebCore/rendering/RenderBlock.cpp @@ -2007,7 +2007,7 @@ void RenderBlock::paint(PaintInfo& paintInfo, int tx, int ty) // Our scrollbar widgets paint exactly when we tell them to, so that they work properly with // z-index. We paint after we painted the background/border, so that the scrollbars will // sit above the background/border. - if (hasOverflowClip() && style()->visibility() == VISIBLE && (phase == PaintPhaseBlockBackground || phase == PaintPhaseChildBlockBackground) && shouldPaintWithinRoot(paintInfo)) + if (hasOverflowClip() && style()->visibility() == VISIBLE && (phase == PaintPhaseBlockBackground || phase == PaintPhaseChildBlockBackground) && paintInfo.shouldPaintWithinRoot(this)) layer()->paintOverflowControls(paintInfo.context, tx, ty, paintInfo.rect); } @@ -2122,13 +2122,13 @@ void RenderBlock::paintChildren(PaintInfo& paintInfo, int tx, int ty) // We don't paint our own background, but we do let the kids paint their backgrounds. PaintInfo info(paintInfo); info.phase = newPhase; - info.paintingRoot = paintingRootForChildren(paintInfo); + info.updatePaintingRootForChildren(this); bool checkPageBreaks = document()->printing() && !document()->settings()->paginateDuringLayoutEnabled(); bool checkColumnBreaks = !checkPageBreaks && !view()->printRect().isEmpty() && !document()->settings()->paginateDuringLayoutEnabled(); for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) { // Check for page-break-before: always, and if it's set, break and bail. - bool checkBeforeAlways = !childrenInline() && (checkPageBreaks && child->style()->pageBreakBefore() == PBALWAYS || checkColumnBreaks && child->style()->columnBreakBefore() == PBALWAYS); + bool checkBeforeAlways = !childrenInline() && ((checkPageBreaks && child->style()->pageBreakBefore() == PBALWAYS) || (checkColumnBreaks && child->style()->columnBreakBefore() == PBALWAYS)); if (checkBeforeAlways && (ty + child->y()) > paintInfo.rect.y() && (ty + child->y()) < paintInfo.rect.bottom()) { @@ -2137,7 +2137,7 @@ void RenderBlock::paintChildren(PaintInfo& paintInfo, int tx, int ty) } // Check for page-break-inside: avoid, and it it's set, break and bail. - bool checkInsideAvoid = !childrenInline() && (checkPageBreaks && child->style()->pageBreakInside() == PBAVOID || checkColumnBreaks && child->style()->columnBreakInside() == PBAVOID); + bool checkInsideAvoid = !childrenInline() && ((checkPageBreaks && child->style()->pageBreakInside() == PBAVOID) || (checkColumnBreaks && child->style()->columnBreakInside() == PBAVOID)); if (checkInsideAvoid && ty + child->y() > paintInfo.rect.y() && ty + child->y() < paintInfo.rect.bottom() @@ -2150,7 +2150,7 @@ void RenderBlock::paintChildren(PaintInfo& paintInfo, int tx, int ty) child->paint(info, tx, ty); // Check for page-break-after: always, and if it's set, break and bail. - bool checkAfterAlways = !childrenInline() && (checkPageBreaks && child->style()->pageBreakAfter() == PBALWAYS || checkColumnBreaks && child->style()->columnBreakAfter() == PBALWAYS); + bool checkAfterAlways = !childrenInline() && ((checkPageBreaks && child->style()->pageBreakAfter() == PBALWAYS) || (checkColumnBreaks && child->style()->columnBreakAfter() == PBALWAYS)); if (checkAfterAlways && (ty + child->y() + child->height()) > paintInfo.rect.y() && (ty + child->y() + child->height()) < paintInfo.rect.bottom()) { @@ -2289,7 +2289,7 @@ void RenderBlock::paintFloats(PaintInfo& paintInfo, int tx, int ty, bool preserv void RenderBlock::paintEllipsisBoxes(PaintInfo& paintInfo, int tx, int ty) { - if (!shouldPaintWithinRoot(paintInfo) || !firstLineBox()) + if (!paintInfo.shouldPaintWithinRoot(this) || !firstLineBox()) return; if (style()->visibility() == VISIBLE && paintInfo.phase == PaintPhaseForeground) { @@ -2452,7 +2452,7 @@ void RenderBlock::paintSelection(PaintInfo& paintInfo, int tx, int ty) } #ifndef BUILDING_ON_TIGER -static void clipOutPositionedObjects(const RenderObject::PaintInfo* paintInfo, int tx, int ty, RenderBlock::PositionedObjectsListHashSet* positionedObjects) +static void clipOutPositionedObjects(const PaintInfo* paintInfo, int tx, int ty, RenderBlock::PositionedObjectsListHashSet* positionedObjects) { if (!positionedObjects) return; @@ -4282,7 +4282,7 @@ int RenderBlock::layoutColumns(int endOfContent, int requestedColumnHeight) v->setPrintRect(pageRect); v->setTruncatedAt(truncationPoint); GraphicsContext context((PlatformGraphicsContext*)0); - RenderObject::PaintInfo paintInfo(&context, pageRect, PaintPhaseForeground, false, 0, 0); + PaintInfo paintInfo(&context, pageRect, PaintPhaseForeground, false, 0, 0); setHasColumns(false); paintObject(paintInfo, 0, 0); diff --git a/WebCore/rendering/RenderBlock.h b/WebCore/rendering/RenderBlock.h index e3a11c8..95d0c29 100644 --- a/WebCore/rendering/RenderBlock.h +++ b/WebCore/rendering/RenderBlock.h @@ -295,7 +295,6 @@ private: }; // The following functions' implementations are in RenderBlockLineLayout.cpp. - void bidiReorderLine(InlineBidiResolver&, const InlineIterator& end, bool previousLineBrokeCleanly); RootInlineBox* determineStartPosition(bool& firstLine, bool& fullLayout, bool& previousLineBrokeCleanly, InlineBidiResolver&, Vector& floats, unsigned& numCleanFloats); RootInlineBox* determineEndPosition(RootInlineBox* startBox, InlineIterator& cleanLineStart, diff --git a/WebCore/rendering/RenderBlockLineLayout.cpp b/WebCore/rendering/RenderBlockLineLayout.cpp index 097b661..1a7f983 100644 --- a/WebCore/rendering/RenderBlockLineLayout.cpp +++ b/WebCore/rendering/RenderBlockLineLayout.cpp @@ -521,12 +521,6 @@ void RenderBlock::computeVerticalPositionsForLine(RootInlineBox* lineBox, BidiRu lineBox->markDirty(false); } -// collects one line of the paragraph and transforms it to visual order -void RenderBlock::bidiReorderLine(InlineBidiResolver& resolver, const InlineIterator& end, bool previousLineBrokeCleanly) -{ - resolver.createBidiRunsForLine(end, style()->visuallyOrdered(), previousLineBrokeCleanly); -} - static inline bool isCollapsibleSpace(UChar character, RenderText* renderer) { if (character == ' ' || character == '\t' || character == softHyphen) @@ -809,7 +803,7 @@ void RenderBlock::layoutInlineChildren(bool relayoutChildren, int& repaintTop, i ASSERT(end != resolver.position()); if (!isLineEmpty) { - bidiReorderLine(resolver, end, previousLineBrokeCleanly); + resolver.createBidiRunsForLine(end, style()->visuallyOrdered(), previousLineBrokeCleanly); ASSERT(resolver.position() == end); BidiRun* trailingSpaceRun = 0; diff --git a/WebCore/rendering/RenderBox.cpp b/WebCore/rendering/RenderBox.cpp index c845ba7..f337a9a 100644 --- a/WebCore/rendering/RenderBox.cpp +++ b/WebCore/rendering/RenderBox.cpp @@ -591,7 +591,7 @@ void RenderBox::paint(PaintInfo& paintInfo, int tx, int ty) // default implementation. Just pass paint through to the children PaintInfo childInfo(paintInfo); - childInfo.paintingRoot = paintingRootForChildren(paintInfo); + childInfo.updatePaintingRootForChildren(this); for (RenderObject* child = firstChild(); child; child = child->nextSibling()) child->paint(childInfo, tx, ty); } @@ -643,7 +643,7 @@ void RenderBox::paintRootBoxDecorations(PaintInfo& paintInfo, int tx, int ty) void RenderBox::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty) { - if (!shouldPaintWithinRoot(paintInfo)) + if (!paintInfo.shouldPaintWithinRoot(this)) return; if (isRoot()) { @@ -685,7 +685,7 @@ void RenderBox::paintBoxDecorationsWithSize(PaintInfo& paintInfo, int tx, int ty void RenderBox::paintMask(PaintInfo& paintInfo, int tx, int ty) { - if (!shouldPaintWithinRoot(paintInfo) || style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) + if (!paintInfo.shouldPaintWithinRoot(this) || style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) return; int w = width(); @@ -2972,13 +2972,4 @@ void RenderBox::clearLayoutOverflow() m_overflow->resetLayoutOverflow(borderBoxRect()); } -#if ENABLE(SVG) - -AffineTransform RenderBox::localTransform() const -{ - return AffineTransform(1, 0, 0, 1, x(), y()); -} - -#endif - } // namespace WebCore diff --git a/WebCore/rendering/RenderBox.h b/WebCore/rendering/RenderBox.h index c033275..3e95cea 100644 --- a/WebCore/rendering/RenderBox.h +++ b/WebCore/rendering/RenderBox.h @@ -297,10 +297,6 @@ public: bool shrinkToAvoidFloats() const; virtual bool avoidsFloats() const; -#if ENABLE(SVG) - virtual AffineTransform localTransform() const; -#endif - protected: virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle); virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle); diff --git a/WebCore/rendering/RenderBoxModelObject.cpp b/WebCore/rendering/RenderBoxModelObject.cpp index 3f1b5ae..c81289b 100644 --- a/WebCore/rendering/RenderBoxModelObject.cpp +++ b/WebCore/rendering/RenderBoxModelObject.cpp @@ -30,6 +30,7 @@ #include "HTMLElement.h" #include "HTMLNames.h" #include "ImageBuffer.h" +#include "Path.h" #include "RenderBlock.h" #include "RenderInline.h" #include "RenderLayer.h" @@ -931,9 +932,182 @@ bool RenderBoxModelObject::paintNinePieceImage(GraphicsContext* graphicsContext, return true; } +#if HAVE(PATH_BASED_BORDER_RADIUS_DRAWING) +static bool borderWillArcInnerEdge(const IntSize& firstRadius, const IntSize& secondRadius, int firstBorderWidth, int secondBorderWidth, int middleBorderWidth) +{ + // FIXME: This test is insufficient. We need to take border style into account. + return (!firstRadius.width() || firstRadius.width() >= firstBorderWidth) + && (!firstRadius.height() || firstRadius.height() >= middleBorderWidth) + && (!secondRadius.width() || secondRadius.width() >= secondBorderWidth) + && (!secondRadius.height() || secondRadius.height() >= middleBorderWidth); +} + +void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, int ty, int w, int h, + const RenderStyle* style, bool begin, bool end) +{ + if (paintNinePieceImage(graphicsContext, tx, ty, w, h, style, style->borderImage())) + return; + + if (graphicsContext->paintingDisabled()) + return; + + const Color& topColor = style->visitedDependentColor(CSSPropertyBorderTopColor); + const Color& bottomColor = style->visitedDependentColor(CSSPropertyBorderBottomColor); + const Color& leftColor = style->visitedDependentColor(CSSPropertyBorderLeftColor); + const Color& rightColor = style->visitedDependentColor(CSSPropertyBorderRightColor); + + bool topTransparent = style->borderTopIsTransparent(); + bool bottomTransparent = style->borderBottomIsTransparent(); + bool rightTransparent = style->borderRightIsTransparent(); + bool leftTransparent = style->borderLeftIsTransparent(); + + EBorderStyle topStyle = style->borderTopStyle(); + EBorderStyle bottomStyle = style->borderBottomStyle(); + EBorderStyle leftStyle = style->borderLeftStyle(); + EBorderStyle rightStyle = style->borderRightStyle(); + + bool renderTop = topStyle > BHIDDEN && !topTransparent; + bool renderLeft = leftStyle > BHIDDEN && begin && !leftTransparent; + bool renderRight = rightStyle > BHIDDEN && end && !rightTransparent; + bool renderBottom = bottomStyle > BHIDDEN && !bottomTransparent; + + bool renderRadii = false; + Path roundedPath; + IntSize topLeft, topRight, bottomLeft, bottomRight; + IntRect borderRect(tx, ty, w, h); + + if (style->hasBorderRadius()) { + IntSize topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius; + style->getBorderRadiiForRect(borderRect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius); + + IntRect innerBorderRect = borderInnerRect(borderRect, style->borderTopWidth(), style->borderBottomWidth(), + style->borderLeftWidth(), style->borderRightWidth()); + + IntSize innerTopLeftRadius, innerTopRightRadius, innerBottomLeftRadius, innerBottomRightRadius; + style->getInnerBorderRadiiForRectWithBorderWidths(innerBorderRect, style->borderTopWidth(), style->borderBottomWidth(), + style->borderLeftWidth(), style->borderRightWidth(), innerTopLeftRadius, innerTopRightRadius, + innerBottomLeftRadius, innerBottomRightRadius); + + if (begin) { + topLeft = topLeftRadius; + bottomLeft = bottomLeftRadius; + } + if (end) { + topRight = topRightRadius; + bottomRight = bottomRightRadius; + } + + renderRadii = true; + + // Clip to the inner and outer radii rects. + graphicsContext->save(); + graphicsContext->addRoundedRectClip(borderRect, topLeft, topRight, bottomLeft, bottomRight); + graphicsContext->clipOutRoundedRect(innerBorderRect, innerTopLeftRadius, innerTopRightRadius, innerBottomLeftRadius, innerBottomRightRadius); + + roundedPath = Path::createRoundedRectangle(borderRect, topLeft, topRight, bottomLeft, bottomRight); + graphicsContext->addPath(roundedPath); + } + + if (renderTop) { + int x = tx; + int x2 = tx + w; + + if (renderRadii && borderWillArcInnerEdge(topLeft, topRight, style->borderLeftWidth(), style->borderRightWidth(), style->borderTopWidth())) { + graphicsContext->save(); + clipBorderSidePolygon(graphicsContext, borderRect, topLeft, topRight, bottomLeft, bottomRight, BSTop, style); + float thickness = max(max(style->borderTopWidth(), style->borderLeftWidth()), style->borderRightWidth()); + drawBoxSideFromPath(graphicsContext, borderRect, roundedPath, style->borderTopWidth(), thickness, BSTop, style, topColor, topStyle); + graphicsContext->restore(); + } else { + bool ignoreLeft = (topColor == leftColor && topTransparent == leftTransparent && topStyle >= OUTSET + && (leftStyle == DOTTED || leftStyle == DASHED || leftStyle == SOLID || leftStyle == OUTSET)); + bool ignoreRight = (topColor == rightColor && topTransparent == rightTransparent && topStyle >= OUTSET + && (rightStyle == DOTTED || rightStyle == DASHED || rightStyle == SOLID || rightStyle == INSET)); + + drawLineForBoxSide(graphicsContext, x, ty, x2, ty + style->borderTopWidth(), BSTop, topColor, topStyle, + ignoreLeft ? 0 : style->borderLeftWidth(), ignoreRight ? 0 : style->borderRightWidth()); + } + } + + if (renderBottom) { + int x = tx; + int x2 = tx + w; + + if (renderRadii && borderWillArcInnerEdge(bottomLeft, bottomRight, style->borderLeftWidth(), style->borderRightWidth(), style->borderBottomWidth())) { + graphicsContext->save(); + clipBorderSidePolygon(graphicsContext, borderRect, topLeft, topRight, bottomLeft, bottomRight, BSBottom, style); + float thickness = max(max(style->borderBottomWidth(), style->borderLeftWidth()), style->borderRightWidth()); + drawBoxSideFromPath(graphicsContext, borderRect, roundedPath, style->borderBottomWidth(), thickness, BSBottom, style, bottomColor, bottomStyle); + graphicsContext->restore(); + } else { + bool ignoreLeft = (bottomColor == leftColor && bottomTransparent == leftTransparent && bottomStyle >= OUTSET + && (leftStyle == DOTTED || leftStyle == DASHED || leftStyle == SOLID || leftStyle == OUTSET)); + + bool ignoreRight = (bottomColor == rightColor && bottomTransparent == rightTransparent && bottomStyle >= OUTSET + && (rightStyle == DOTTED || rightStyle == DASHED || rightStyle == SOLID || rightStyle == INSET)); + + drawLineForBoxSide(graphicsContext, x, ty + h - style->borderBottomWidth(), x2, ty + h, BSBottom, bottomColor, + bottomStyle, ignoreLeft ? 0 : style->borderLeftWidth(), + ignoreRight ? 0 : style->borderRightWidth()); + } + } + + if (renderLeft) { + int y = ty; + int y2 = ty + h; + + if (renderRadii && borderWillArcInnerEdge(bottomLeft, topLeft, style->borderBottomWidth(), style->borderTopWidth(), style->borderLeftWidth())) { + graphicsContext->save(); + clipBorderSidePolygon(graphicsContext, borderRect, topLeft, topRight, bottomLeft, bottomRight, BSLeft, style); + float thickness = max(max(style->borderLeftWidth(), style->borderTopWidth()), style->borderBottomWidth()); + drawBoxSideFromPath(graphicsContext, borderRect, roundedPath, style->borderLeftWidth(), thickness, BSLeft, style, leftColor, leftStyle); + graphicsContext->restore(); + } else { + bool ignoreTop = (topColor == leftColor && topTransparent == leftTransparent && leftStyle >= OUTSET + && (topStyle == DOTTED || topStyle == DASHED || topStyle == SOLID || topStyle == OUTSET)); + + bool ignoreBottom = (bottomColor == leftColor && bottomTransparent == leftTransparent && leftStyle >= OUTSET + && (bottomStyle == DOTTED || bottomStyle == DASHED || bottomStyle == SOLID || bottomStyle == INSET)); + + drawLineForBoxSide(graphicsContext, tx, y, tx + style->borderLeftWidth(), y2, BSLeft, leftColor, + leftStyle, ignoreTop ? 0 : style->borderTopWidth(), ignoreBottom ? 0 : style->borderBottomWidth()); + } + } + + if (renderRight) { + if (renderRadii && borderWillArcInnerEdge(bottomRight, topRight, style->borderBottomWidth(), style->borderTopWidth(), style->borderRightWidth())) { + graphicsContext->save(); + clipBorderSidePolygon(graphicsContext, borderRect, topLeft, topRight, bottomLeft, bottomRight, BSRight, style); + float thickness = max(max(style->borderRightWidth(), style->borderTopWidth()), style->borderBottomWidth()); + drawBoxSideFromPath(graphicsContext, borderRect, roundedPath, style->borderRightWidth(), thickness, BSRight, style, rightColor, rightStyle); + graphicsContext->restore(); + } else { + bool ignoreTop = ((topColor == rightColor) && (topTransparent == rightTransparent) + && (rightStyle >= DOTTED || rightStyle == INSET) + && (topStyle == DOTTED || topStyle == DASHED || topStyle == SOLID || topStyle == OUTSET)); + + bool ignoreBottom = ((bottomColor == rightColor) && (bottomTransparent == rightTransparent) + && (rightStyle >= DOTTED || rightStyle == INSET) + && (bottomStyle == DOTTED || bottomStyle == DASHED || bottomStyle == SOLID || bottomStyle == INSET)); + + int y = ty; + int y2 = ty + h; + + drawLineForBoxSide(graphicsContext, tx + w - style->borderRightWidth(), y, tx + w, y2, BSRight, rightColor, + rightStyle, ignoreTop ? 0 : style->borderTopWidth(), + ignoreBottom ? 0 : style->borderBottomWidth()); + } + } + + if (renderRadii) + graphicsContext->restore(); +} +#else void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, int ty, int w, int h, const RenderStyle* style, bool begin, bool end) { + // FIXME: This old version of paintBorder should be removed when all ports implement + // GraphicsContext::clipConvexPolygon()!! This should happen soon. if (paintNinePieceImage(graphicsContext, tx, ty, w, h, style, style->borderImage())) return; @@ -1279,6 +1453,65 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, if (renderRadii) graphicsContext->restore(); } +#endif + +void RenderBoxModelObject::clipBorderSidePolygon(GraphicsContext* graphicsContext, const IntRect& box, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const BoxSide side, const RenderStyle* style) +{ + FloatPoint quad[4]; + int tx = box.x(); + int ty = box.y(); + int w = box.width(); + int h = box.height(); + + // For each side, create an array of FloatPoints where each point is based on whichever value in each corner + // is larger -- the radius width/height or the border width/height -- as appropriate. + switch (side) { + case BSTop: + quad[0] = FloatPoint(tx, ty); + quad[1] = FloatPoint( + tx + max(topLeft.width(), (int) style->borderLeftWidth()), + ty + max(topLeft.height(), (int) style->borderTopWidth())); + quad[2] = FloatPoint( + tx + w - max(topRight.width(), (int) style->borderRightWidth()), + ty + max(topRight.height(), (int)style->borderTopWidth())); + quad[3] = FloatPoint(tx + w, ty); + break; + case BSLeft: + quad[0] = FloatPoint(tx, ty); + quad[1] = FloatPoint( + tx + max(topLeft.width(), (int) style->borderLeftWidth()), + ty + max(topLeft.height(), (int) style->borderTopWidth())); + quad[2] = FloatPoint( + tx + max(bottomLeft.width(), (int) style->borderLeftWidth()), + ty + h - max(bottomLeft.height(), (int)style->borderBottomWidth())); + quad[3] = FloatPoint(tx, ty + h); + break; + case BSBottom: + quad[0] = FloatPoint(tx, ty + h); + quad[1] = FloatPoint( + tx + max(bottomLeft.width(), (int) style->borderLeftWidth()), + ty + h - max(bottomLeft.height(), (int)style->borderBottomWidth())); + quad[2] = FloatPoint( + tx + w - max(bottomRight.width(), (int) style->borderRightWidth()), + ty + h - max(bottomRight.height(), (int)style->borderBottomWidth())); + quad[3] = FloatPoint(tx + w, ty + h); + break; + case BSRight: + quad[0] = FloatPoint(tx + w, ty); + quad[1] = FloatPoint( + tx + w - max(topRight.width(), (int) style->borderRightWidth()), + ty + max(topRight.height(), (int) style->borderTopWidth())); + quad[2] = FloatPoint( + tx + w - max(bottomRight.width(), (int) style->borderRightWidth()), + ty + h - max(bottomRight.height(), (int)style->borderBottomWidth())); + quad[3] = FloatPoint(tx + w, ty + h); + break; + default: + break; + } + + graphicsContext->clipConvexPolygon(4, quad); +} void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int ty, int w, int h, const RenderStyle* s, ShadowStyle shadowStyle, bool begin, bool end) { diff --git a/WebCore/rendering/RenderBoxModelObject.h b/WebCore/rendering/RenderBoxModelObject.h index f022495..45602f0 100644 --- a/WebCore/rendering/RenderBoxModelObject.h +++ b/WebCore/rendering/RenderBoxModelObject.h @@ -115,6 +115,8 @@ private: IntSize calculateFillTileSize(const FillLayer*, IntSize scaledSize) const; + void clipBorderSidePolygon(GraphicsContext*, const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const BoxSide side, const RenderStyle* style); + friend class RenderView; RenderLayer* m_layer; diff --git a/WebCore/rendering/RenderEmbeddedObject.cpp b/WebCore/rendering/RenderEmbeddedObject.cpp index 7ab12a1..3d6575c 100644 --- a/WebCore/rendering/RenderEmbeddedObject.cpp +++ b/WebCore/rendering/RenderEmbeddedObject.cpp @@ -67,6 +67,7 @@ static const float replacementTextTextOpacity = 0.55f; RenderEmbeddedObject::RenderEmbeddedObject(Element* element) : RenderPart(element) , m_hasFallbackContent(false) + , m_showsMissingPluginIndicator(false) { view()->frameView()->setIsVisuallyNonEmpty(); } @@ -344,11 +345,14 @@ void RenderEmbeddedObject::updateWidget(bool onlyCreateNonNetscapePlugins) void RenderEmbeddedObject::setShowsMissingPluginIndicator() { + ASSERT(m_replacementText.isEmpty()); m_replacementText = missingPluginText(); + m_showsMissingPluginIndicator = true; } void RenderEmbeddedObject::setShowsCrashedPluginIndicator() { + ASSERT(m_replacementText.isEmpty()); m_replacementText = crashedPluginText(); } diff --git a/WebCore/rendering/RenderEmbeddedObject.h b/WebCore/rendering/RenderEmbeddedObject.h index b68108d..bfb7b96 100644 --- a/WebCore/rendering/RenderEmbeddedObject.h +++ b/WebCore/rendering/RenderEmbeddedObject.h @@ -37,6 +37,7 @@ public: void updateWidget(bool onlyCreateNonNetscapePlugins); void setShowsMissingPluginIndicator(); void setShowsCrashedPluginIndicator(); + bool showsMissingPluginIndicator() const { return m_showsMissingPluginIndicator; } bool hasFallbackContent() const { return m_hasFallbackContent; } @@ -60,6 +61,7 @@ private: String m_replacementText; bool m_hasFallbackContent; + bool m_showsMissingPluginIndicator; }; inline RenderEmbeddedObject* toRenderEmbeddedObject(RenderObject* object) diff --git a/WebCore/rendering/RenderFieldset.cpp b/WebCore/rendering/RenderFieldset.cpp index 734c348..bd245c7 100644 --- a/WebCore/rendering/RenderFieldset.cpp +++ b/WebCore/rendering/RenderFieldset.cpp @@ -120,7 +120,7 @@ RenderBox* RenderFieldset::findLegend() const void RenderFieldset::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty) { - if (!shouldPaintWithinRoot(paintInfo)) + if (!paintInfo.shouldPaintWithinRoot(this)) return; int w = width(); diff --git a/WebCore/rendering/RenderForeignObject.cpp b/WebCore/rendering/RenderForeignObject.cpp index 9f0889b..4b94bab 100644 --- a/WebCore/rendering/RenderForeignObject.cpp +++ b/WebCore/rendering/RenderForeignObject.cpp @@ -47,10 +47,9 @@ void RenderForeignObject::paint(PaintInfo& paintInfo, int, int) PaintInfo childPaintInfo(paintInfo); childPaintInfo.context->save(); + childPaintInfo.applyTransform(localTransform()); - applyTransformToPaintInfo(childPaintInfo, localTransform()); - - if (SVGRenderBase::isOverflowHidden(this)) + if (SVGRenderSupport::isOverflowHidden(this)) childPaintInfo.context->clip(m_viewport); float opacity = style()->opacity(); @@ -67,12 +66,12 @@ void RenderForeignObject::paint(PaintInfo& paintInfo, int, int) IntRect RenderForeignObject::clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) { - return SVGRenderBase::clippedOverflowRectForRepaint(this, repaintContainer); + return SVGRenderSupport::clippedOverflowRectForRepaint(this, repaintContainer); } void RenderForeignObject::computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& repaintRect, bool fixed) { - SVGRenderBase::computeRectForRepaint(this, repaintContainer, repaintRect, fixed); + SVGRenderSupport::computeRectForRepaint(this, repaintContainer, repaintRect, fixed); } const AffineTransform& RenderForeignObject::localToParentTransform() const @@ -128,7 +127,7 @@ bool RenderForeignObject::nodeAtFloatPoint(const HitTestRequest& request, HitTes FloatPoint localPoint = localTransform().inverse().mapPoint(pointInParent); // Early exit if local point is not contained in clipped viewport area - if (SVGRenderBase::isOverflowHidden(this) && !m_viewport.contains(localPoint)) + if (SVGRenderSupport::isOverflowHidden(this) && !m_viewport.contains(localPoint)) return false; IntPoint roundedLocalPoint = roundedIntPoint(localPoint); @@ -146,7 +145,7 @@ void RenderForeignObject::mapLocalToContainer(RenderBoxModelObject* repaintConta // When crawling up the hierachy starting from foreignObject child content, useTransforms may not be set to true. if (!useTransforms) useTransforms = true; - SVGRenderBase::mapLocalToContainer(this, repaintContainer, fixed, useTransforms, transformState); + SVGRenderSupport::mapLocalToContainer(this, repaintContainer, fixed, useTransforms, transformState); } } diff --git a/WebCore/rendering/RenderInputSpeech.cpp b/WebCore/rendering/RenderInputSpeech.cpp new file mode 100644 index 0000000..df17944 --- /dev/null +++ b/WebCore/rendering/RenderInputSpeech.cpp @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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" +#include "RenderInputSpeech.h" + +#if ENABLE(INPUT_SPEECH) + +#include "GraphicsContext.h" +#include "HTMLNames.h" +#include "RenderBox.h" + +namespace WebCore { + +static const float defaultControlFontPixelSize = 13; +static const float defaultSpeechButtonSize = 16; +static const float minSpeechButtonSize = 8; +static const float maxSpeechButtonSize = 40; + +void RenderInputSpeech::adjustInputFieldSpeechButtonStyle(CSSStyleSelector*, RenderStyle* style, Element*) +{ + // Scale the button size based on the font size. + float fontScale = style->fontSize() / defaultControlFontPixelSize; + int speechButtonSize = lroundf(std::min(std::max(minSpeechButtonSize, defaultSpeechButtonSize * fontScale), maxSpeechButtonSize)); + style->setWidth(Length(speechButtonSize, Fixed)); + style->setHeight(Length(speechButtonSize, Fixed)); +} + +bool RenderInputSpeech::paintInputFieldSpeechButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) +{ + // Get the renderer of element. + Node* input = object->node()->shadowAncestorNode(); + if (!input->renderer()->isBox()) + return false; + RenderBox* inputRenderBox = toRenderBox(input->renderer()); + IntRect inputContentBox = inputRenderBox->contentBoxRect(); + + // Make sure the scaled button stays square and will fit in its parent's box. + int buttonSize = std::min(inputContentBox.width(), std::min(inputContentBox.height(), rect.height())); + // Calculate button's coordinates relative to the input element. + // Center the button vertically. Round up though, so if it has to be one pixel off-center, it will + // be one pixel closer to the bottom of the field. This tends to look better with the text. + IntRect buttonRect(object->offsetFromAncestorContainer(inputRenderBox).width(), + inputContentBox.y() + (inputContentBox.height() - buttonSize + 1) / 2, + buttonSize, buttonSize); + + // Compute an offset between the part renderer and the input renderer. + IntSize offsetFromInputRenderer = -(object->offsetFromAncestorContainer(inputRenderBox)); + // Move the rect into partRenderer's coords. + buttonRect.move(offsetFromInputRenderer); + // Account for the local drawing offset. + buttonRect.move(rect.x(), rect.y()); + + DEFINE_STATIC_LOCAL(RefPtr, imageStateNormal, (Image::loadPlatformResource("inputSpeech"))); + paintInfo.context->drawImage(imageStateNormal.get(), object->style()->colorSpace(), buttonRect); + + return false; +} + +} // namespace WebCore + +#endif // ENABLE(INPUT_SPEECH) diff --git a/WebCore/rendering/RenderInputSpeech.h b/WebCore/rendering/RenderInputSpeech.h new file mode 100644 index 0000000..63ef8ae --- /dev/null +++ b/WebCore/rendering/RenderInputSpeech.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 RenderInputSpeech_h +#define RenderInputSpeech_h + +#include "RenderObject.h" + +#if ENABLE(INPUT_SPEECH) + +namespace WebCore { + +class RenderInputSpeech { +public: + static void adjustInputFieldSpeechButtonStyle(CSSStyleSelector*, RenderStyle*, Element*); + static bool paintInputFieldSpeechButton(RenderObject*, const PaintInfo&, const IntRect&); +}; + +} // namespace WebCore + +#endif +#endif // RenderInputSpeech_h diff --git a/WebCore/rendering/RenderLayer.cpp b/WebCore/rendering/RenderLayer.cpp index fcb9c07..a672f4b 100644 --- a/WebCore/rendering/RenderLayer.cpp +++ b/WebCore/rendering/RenderLayer.cpp @@ -2257,10 +2257,10 @@ bool RenderLayer::scroll(ScrollDirection direction, ScrollGranularity granularit void RenderLayer::paint(GraphicsContext* p, const IntRect& damageRect, PaintBehavior paintBehavior, RenderObject *paintingRoot) { - RenderObject::OverlapTestRequestMap overlapTestRequests; + OverlapTestRequestMap overlapTestRequests; paintLayer(this, p, damageRect, paintBehavior, paintingRoot, &overlapTestRequests); - RenderObject::OverlapTestRequestMap::iterator end = overlapTestRequests.end(); - for (RenderObject::OverlapTestRequestMap::iterator it = overlapTestRequests.begin(); it != end; ++it) + OverlapTestRequestMap::iterator end = overlapTestRequests.end(); + for (OverlapTestRequestMap::iterator it = overlapTestRequests.begin(); it != end; ++it) it->first->setOverlapTestResult(false); } @@ -2279,11 +2279,11 @@ static void restoreClip(GraphicsContext* p, const IntRect& paintDirtyRect, const p->restore(); } -static void performOverlapTests(RenderObject::OverlapTestRequestMap& overlapTestRequests, const IntRect& layerBounds) +static void performOverlapTests(OverlapTestRequestMap& overlapTestRequests, const IntRect& layerBounds) { Vector overlappedRequestClients; - RenderObject::OverlapTestRequestMap::iterator end = overlapTestRequests.end(); - for (RenderObject::OverlapTestRequestMap::iterator it = overlapTestRequests.begin(); it != end; ++it) { + OverlapTestRequestMap::iterator end = overlapTestRequests.end(); + for (OverlapTestRequestMap::iterator it = overlapTestRequests.begin(); it != end; ++it) { if (!layerBounds.intersects(it->second)) continue; @@ -2303,7 +2303,7 @@ static bool shouldDoSoftwarePaint(const RenderLayer* layer, bool paintingReflect void RenderLayer::paintLayer(RenderLayer* rootLayer, GraphicsContext* p, const IntRect& paintDirtyRect, PaintBehavior paintBehavior, - RenderObject* paintingRoot, RenderObject::OverlapTestRequestMap* overlapTestRequests, + RenderObject* paintingRoot, OverlapTestRequestMap* overlapTestRequests, PaintLayerFlags paintFlags) { #if USE(ACCELERATED_COMPOSITING) @@ -2425,7 +2425,7 @@ void RenderLayer::paintLayer(RenderLayer* rootLayer, GraphicsContext* p, setClip(p, paintDirtyRect, damageRect); // Paint the background. - RenderObject::PaintInfo paintInfo(p, damageRect, PaintPhaseBlockBackground, false, paintingRootForRenderer, 0); + PaintInfo paintInfo(p, damageRect, PaintPhaseBlockBackground, false, paintingRootForRenderer, 0); renderer()->paint(paintInfo, tx, ty); // Restore the clip. @@ -2443,7 +2443,7 @@ void RenderLayer::paintLayer(RenderLayer* rootLayer, GraphicsContext* p, // Set up the clip used when painting our children. setClip(p, paintDirtyRect, clipRectToApply); - RenderObject::PaintInfo paintInfo(p, clipRectToApply, + PaintInfo paintInfo(p, clipRectToApply, selectionOnly ? PaintPhaseSelection : PaintPhaseChildBlockBackgrounds, forceBlackText, paintingRootForRenderer, 0); renderer()->paint(paintInfo, tx, ty); @@ -2463,7 +2463,7 @@ void RenderLayer::paintLayer(RenderLayer* rootLayer, GraphicsContext* p, if (!outlineRect.isEmpty() && isSelfPaintingLayer()) { // Paint our own outline - RenderObject::PaintInfo paintInfo(p, outlineRect, PaintPhaseSelfOutline, false, paintingRootForRenderer, 0); + PaintInfo paintInfo(p, outlineRect, PaintPhaseSelfOutline, false, paintingRootForRenderer, 0); setClip(p, paintDirtyRect, outlineRect); renderer()->paint(paintInfo, tx, ty); restoreClip(p, paintDirtyRect, outlineRect); @@ -2479,7 +2479,7 @@ void RenderLayer::paintLayer(RenderLayer* rootLayer, GraphicsContext* p, setClip(p, paintDirtyRect, damageRect); // Paint the mask. - RenderObject::PaintInfo paintInfo(p, damageRect, PaintPhaseMask, false, paintingRootForRenderer, 0); + PaintInfo paintInfo(p, damageRect, PaintPhaseMask, false, paintingRootForRenderer, 0); renderer()->paint(paintInfo, tx, ty); // Restore the clip. @@ -2496,7 +2496,7 @@ void RenderLayer::paintLayer(RenderLayer* rootLayer, GraphicsContext* p, void RenderLayer::paintList(Vector* list, RenderLayer* rootLayer, GraphicsContext* p, const IntRect& paintDirtyRect, PaintBehavior paintBehavior, - RenderObject* paintingRoot, RenderObject::OverlapTestRequestMap* overlapTestRequests, + RenderObject* paintingRoot, OverlapTestRequestMap* overlapTestRequests, PaintLayerFlags paintFlags) { if (!list) @@ -2513,7 +2513,7 @@ void RenderLayer::paintList(Vector* list, RenderLayer* rootLayer, void RenderLayer::paintPaginatedChildLayer(RenderLayer* childLayer, RenderLayer* rootLayer, GraphicsContext* context, const IntRect& paintDirtyRect, PaintBehavior paintBehavior, - RenderObject* paintingRoot, RenderObject::OverlapTestRequestMap* overlapTestRequests, + RenderObject* paintingRoot, OverlapTestRequestMap* overlapTestRequests, PaintLayerFlags paintFlags) { // We need to do multiple passes, breaking up our child layer into strips. @@ -2534,7 +2534,7 @@ void RenderLayer::paintPaginatedChildLayer(RenderLayer* childLayer, RenderLayer* void RenderLayer::paintChildLayerIntoColumns(RenderLayer* childLayer, RenderLayer* rootLayer, GraphicsContext* context, const IntRect& paintDirtyRect, PaintBehavior paintBehavior, - RenderObject* paintingRoot, RenderObject::OverlapTestRequestMap* overlapTestRequests, + RenderObject* paintingRoot, OverlapTestRequestMap* overlapTestRequests, PaintLayerFlags paintFlags, const Vector& columnLayers, size_t colIndex) { RenderBlock* columnBlock = toRenderBlock(columnLayers[colIndex]->renderer()); diff --git a/WebCore/rendering/RenderLayer.h b/WebCore/rendering/RenderLayer.h index 45b64e0..e8c290b 100644 --- a/WebCore/rendering/RenderLayer.h +++ b/WebCore/rendering/RenderLayer.h @@ -487,19 +487,19 @@ private: typedef unsigned PaintLayerFlags; void paintLayer(RenderLayer* rootLayer, GraphicsContext*, const IntRect& paintDirtyRect, - PaintBehavior, RenderObject* paintingRoot, RenderObject::OverlapTestRequestMap* = 0, + PaintBehavior, RenderObject* paintingRoot, OverlapTestRequestMap* = 0, PaintLayerFlags = 0); void paintList(Vector*, RenderLayer* rootLayer, GraphicsContext* p, const IntRect& paintDirtyRect, PaintBehavior, - RenderObject* paintingRoot, RenderObject::OverlapTestRequestMap*, + RenderObject* paintingRoot, OverlapTestRequestMap*, PaintLayerFlags); void paintPaginatedChildLayer(RenderLayer* childLayer, RenderLayer* rootLayer, GraphicsContext*, const IntRect& paintDirtyRect, PaintBehavior, - RenderObject* paintingRoot, RenderObject::OverlapTestRequestMap*, + RenderObject* paintingRoot, OverlapTestRequestMap*, PaintLayerFlags); void paintChildLayerIntoColumns(RenderLayer* childLayer, RenderLayer* rootLayer, GraphicsContext*, const IntRect& paintDirtyRect, PaintBehavior, - RenderObject* paintingRoot, RenderObject::OverlapTestRequestMap*, + RenderObject* paintingRoot, OverlapTestRequestMap*, PaintLayerFlags, const Vector& columnLayers, size_t columnIndex); RenderLayer* hitTestLayer(RenderLayer* rootLayer, RenderLayer* containerLayer, const HitTestRequest& request, HitTestResult& result, diff --git a/WebCore/rendering/RenderLayerBacking.cpp b/WebCore/rendering/RenderLayerBacking.cpp index 794b55a..c5a7e19 100644 --- a/WebCore/rendering/RenderLayerBacking.cpp +++ b/WebCore/rendering/RenderLayerBacking.cpp @@ -955,7 +955,7 @@ void RenderLayerBacking::paintIntoLayer(RenderLayer* rootLayer, GraphicsContext* // Establish the clip used to paint our background. setClip(context, paintDirtyRect, damageRect); - RenderObject::PaintInfo info(context, paintBox, PaintPhaseBlockBackground, false, paintingRootForRenderer, 0); + PaintInfo info(context, paintBox, PaintPhaseBlockBackground, false, paintingRootForRenderer, 0); renderer()->paint(info, tx, ty); // Our scrollbar widgets paint exactly when we tell them to, so that they work properly with @@ -981,7 +981,7 @@ void RenderLayerBacking::paintIntoLayer(RenderLayer* rootLayer, GraphicsContext* // Set up the clip used when painting our children. setClip(context, paintDirtyRect, clipRectToApply); - RenderObject::PaintInfo paintInfo(context, clipRectToApply, + PaintInfo paintInfo(context, clipRectToApply, selectionOnly ? PaintPhaseSelection : PaintPhaseChildBlockBackgrounds, forceBlackText, paintingRootForRenderer, 0); renderer()->paint(paintInfo, tx, ty); @@ -1002,7 +1002,7 @@ void RenderLayerBacking::paintIntoLayer(RenderLayer* rootLayer, GraphicsContext* if (!outlineRect.isEmpty()) { // Paint our own outline - RenderObject::PaintInfo paintInfo(context, outlineRect, PaintPhaseSelfOutline, false, paintingRootForRenderer, 0); + PaintInfo paintInfo(context, outlineRect, PaintPhaseSelfOutline, false, paintingRootForRenderer, 0); setClip(context, paintDirtyRect, outlineRect); renderer()->paint(paintInfo, tx, ty); restoreClip(context, paintDirtyRect, outlineRect); @@ -1028,7 +1028,7 @@ void RenderLayerBacking::paintIntoLayer(RenderLayer* rootLayer, GraphicsContext* setClip(context, paintDirtyRect, damageRect); // Paint the mask. - RenderObject::PaintInfo paintInfo(context, damageRect, PaintPhaseMask, false, paintingRootForRenderer, 0); + PaintInfo paintInfo(context, damageRect, PaintPhaseMask, false, paintingRootForRenderer, 0); renderer()->paint(paintInfo, tx, ty); // Restore the clip. diff --git a/WebCore/rendering/RenderLineBoxList.cpp b/WebCore/rendering/RenderLineBoxList.cpp index 2d3ee7e..3e4c882 100644 --- a/WebCore/rendering/RenderLineBoxList.cpp +++ b/WebCore/rendering/RenderLineBoxList.cpp @@ -148,7 +148,7 @@ void RenderLineBoxList::dirtyLineBoxes() curr->dirtyLineBoxes(); } -void RenderLineBoxList::paint(RenderBoxModelObject* renderer, RenderObject::PaintInfo& paintInfo, int tx, int ty) const +void RenderLineBoxList::paint(RenderBoxModelObject* renderer, PaintInfo& paintInfo, int tx, int ty) const { // Only paint during the foreground/selection phases. if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection && paintInfo.phase != PaintPhaseOutline @@ -181,7 +181,7 @@ void RenderLineBoxList::paint(RenderBoxModelObject* renderer, RenderObject::Pain if (yPos >= paintInfo.rect.bottom() || yPos + h <= paintInfo.rect.y()) return; - RenderObject::PaintInfo info(paintInfo); + PaintInfo info(paintInfo); ListHashSet outlineObjects; info.outlineObjects = &outlineObjects; diff --git a/WebCore/rendering/RenderLineBoxList.h b/WebCore/rendering/RenderLineBoxList.h index 52d7542..f7d9960 100644 --- a/WebCore/rendering/RenderLineBoxList.h +++ b/WebCore/rendering/RenderLineBoxList.h @@ -63,7 +63,7 @@ public: void dirtyLineBoxes(); void dirtyLinesFromChangedChild(RenderObject* parent, RenderObject* child); - void paint(RenderBoxModelObject*, RenderObject::PaintInfo&, int x, int y) const; + void paint(RenderBoxModelObject*, PaintInfo&, int x, int y) const; bool hitTest(RenderBoxModelObject*, const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction) const; private: diff --git a/WebCore/rendering/RenderMediaControls.cpp b/WebCore/rendering/RenderMediaControls.cpp index 17576ae..f75da70 100644 --- a/WebCore/rendering/RenderMediaControls.cpp +++ b/WebCore/rendering/RenderMediaControls.cpp @@ -82,7 +82,7 @@ void RenderMediaControls::adjustMediaSliderThumbSize(RenderObject* o) o->style()->setHeight(Length(static_cast(mediaSliderThumbHeight * zoomLevel), Fixed)); } -bool RenderMediaControls::paintMediaControlsPart(MediaControlElementType part, RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) +bool RenderMediaControls::paintMediaControlsPart(MediaControlElementType part, RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) { ASSERT(SafariThemeLibrary()); diff --git a/WebCore/rendering/RenderMediaControls.h b/WebCore/rendering/RenderMediaControls.h index 529dbac..9683dd7 100644 --- a/WebCore/rendering/RenderMediaControls.h +++ b/WebCore/rendering/RenderMediaControls.h @@ -34,7 +34,7 @@ namespace WebCore { class HTMLMediaElement; class RenderMediaControls { public: - static bool paintMediaControlsPart(MediaControlElementType, RenderObject*, const RenderObject::PaintInfo&, const IntRect&); + static bool paintMediaControlsPart(MediaControlElementType, RenderObject*, const PaintInfo&, const IntRect&); static void adjustMediaSliderThumbSize(RenderObject*); }; diff --git a/WebCore/rendering/RenderMediaControlsChromium.cpp b/WebCore/rendering/RenderMediaControlsChromium.cpp index ede3d11..ffd7a1e 100644 --- a/WebCore/rendering/RenderMediaControlsChromium.cpp +++ b/WebCore/rendering/RenderMediaControlsChromium.cpp @@ -67,7 +67,7 @@ static bool paintMediaButton(GraphicsContext* context, const IntRect& rect, Imag return true; } -static bool paintMediaMuteButton(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) +static bool paintMediaMuteButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) @@ -83,7 +83,7 @@ static bool paintMediaMuteButton(RenderObject* object, const RenderObject::Paint return paintMediaButton(paintInfo.context, rect, mediaElement->muted() ? soundNone: soundFull); } -static bool paintMediaPlayButton(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) +static bool paintMediaPlayButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) @@ -105,7 +105,7 @@ static Image* getMediaSliderThumb() return mediaSliderThumb; } -static bool paintMediaSlider(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) +static bool paintMediaSlider(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) @@ -164,7 +164,7 @@ static bool paintMediaSlider(RenderObject* object, const RenderObject::PaintInfo return true; } -static bool paintMediaSliderThumb(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) +static bool paintMediaSliderThumb(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { if (!object->parent()->isSlider()) return false; @@ -180,7 +180,7 @@ static bool paintMediaSliderThumb(RenderObject* object, const RenderObject::Pain return paintMediaButton(paintInfo.context, rect, mediaSliderThumb); } -static bool paintMediaVolumeSlider(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) +static bool paintMediaVolumeSlider(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) @@ -199,7 +199,7 @@ static bool paintMediaVolumeSlider(RenderObject* object, const RenderObject::Pai return true; } -static bool paintMediaVolumeSliderThumb(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) +static bool paintMediaVolumeSliderThumb(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { if (!object->parent()->isSlider()) return false; @@ -208,7 +208,7 @@ static bool paintMediaVolumeSliderThumb(RenderObject* object, const RenderObject return paintMediaButton(paintInfo.context, rect, mediaVolumeSliderThumb); } -static bool paintMediaTimelineContainer(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) +static bool paintMediaTimelineContainer(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) @@ -263,7 +263,7 @@ bool RenderMediaControlsChromium::shouldRenderMediaControlPart(ControlPart part, return false; } -bool RenderMediaControlsChromium::paintMediaControlsPart(MediaControlElementType part, RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) +bool RenderMediaControlsChromium::paintMediaControlsPart(MediaControlElementType part, RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { switch (part) { case MediaMuteButton: diff --git a/WebCore/rendering/RenderMediaControlsChromium.h b/WebCore/rendering/RenderMediaControlsChromium.h index d6d986c..060a9d4 100644 --- a/WebCore/rendering/RenderMediaControlsChromium.h +++ b/WebCore/rendering/RenderMediaControlsChromium.h @@ -37,7 +37,7 @@ class HTMLMediaElement; class RenderMediaControlsChromium { public: static bool shouldRenderMediaControlPart(ControlPart, Element*); - static bool paintMediaControlsPart(MediaControlElementType, RenderObject*, const RenderObject::PaintInfo&, const IntRect&); + static bool paintMediaControlsPart(MediaControlElementType, RenderObject*, const PaintInfo&, const IntRect&); static void adjustMediaSliderThumbSize(RenderObject*); }; diff --git a/WebCore/rendering/RenderObject.cpp b/WebCore/rendering/RenderObject.cpp index 143e2c0..156df15 100644 --- a/WebCore/rendering/RenderObject.cpp +++ b/WebCore/rendering/RenderObject.cpp @@ -30,6 +30,7 @@ #include "AXObjectCache.h" #include "Chrome.h" #include "CSSStyleSelector.h" +#include "DashArray.h" #include "FloatQuad.h" #include "Frame.h" #include "FrameView.h" @@ -880,10 +881,186 @@ void RenderObject::drawLineForBoxSide(GraphicsContext* graphicsContext, int x1, } } +IntRect RenderObject::borderInnerRect(const IntRect& borderRect, unsigned short topWidth, unsigned short bottomWidth, unsigned short leftWidth, unsigned short rightWidth) const +{ + return IntRect( + borderRect.x() + leftWidth, + borderRect.y() + topWidth, + borderRect.width() - leftWidth - rightWidth, + borderRect.height() - topWidth - bottomWidth); +} + +#if HAVE(PATH_BASED_BORDER_RADIUS_DRAWING) +void RenderObject::drawBoxSideFromPath(GraphicsContext* graphicsContext, IntRect borderRect, Path borderPath, + float thickness, float drawThickness, BoxSide s, const RenderStyle* style, + Color c, EBorderStyle borderStyle) +{ + if (thickness <= 0) + return; + + if (borderStyle == DOUBLE && thickness < 3) + borderStyle = SOLID; + + switch (borderStyle) { + case BNONE: + case BHIDDEN: + return; + case DOTTED: + case DASHED: { + graphicsContext->setStrokeColor(c, style->colorSpace()); + + // The stroke is doubled here because the provided path is the + // outside edge of the border so half the stroke is clipped off. + // The extra multiplier is so that the clipping mask can antialias + // the edges to prevent jaggies. + graphicsContext->setStrokeThickness(drawThickness * 2 * 1.1f); + graphicsContext->setStrokeStyle(borderStyle == DASHED ? DashedStroke : DottedStroke); + + // If the number of dashes that fit in the path is odd and non-integral then we + // will have an awkwardly-sized dash at the end of the path. To try to avoid that + // here, we simply make the whitespace dashes ever so slightly bigger. + // FIXME: This could be even better if we tried to manipulate the dash offset + // and possibly the whiteSpaceWidth to get the corners dash-symmetrical. + float patWidth = thickness * ((borderStyle == DASHED) ? 3.0f : 1.0f); + float whiteSpaceWidth = patWidth; + float numberOfDashes = borderPath.length() / patWidth; + bool evenNumberOfFullDashes = !((int)numberOfDashes % 2); + bool integralNumberOfDashes = !(numberOfDashes - (int)numberOfDashes); + if (!evenNumberOfFullDashes && !integralNumberOfDashes) { + float numberOfWhitespaceDashes = numberOfDashes / 2; + whiteSpaceWidth += (patWidth / numberOfWhitespaceDashes); + } + + DashArray* lineDash = new DashArray(); + lineDash->append(patWidth); + lineDash->append(whiteSpaceWidth); + graphicsContext->setLineDash(*lineDash, patWidth); + graphicsContext->addPath(borderPath); + graphicsContext->strokePath(); + return; + } + case DOUBLE: { + int outerBorderTopWidth = style->borderTopWidth() / 3; + int outerBorderRightWidth = style->borderRightWidth() / 3; + int outerBorderBottomWidth = style->borderBottomWidth() / 3; + int outerBorderLeftWidth = style->borderLeftWidth() / 3; + + int innerBorderTopWidth = style->borderTopWidth() * 2 / 3; + int innerBorderRightWidth = style->borderRightWidth() * 2 / 3; + int innerBorderBottomWidth = style->borderBottomWidth() * 2 / 3; + int innerBorderLeftWidth = style->borderLeftWidth() * 2 / 3; + + // We need certain integer rounding results + if (style->borderTopWidth() % 3 == 2) + outerBorderTopWidth += 1; + if (style->borderRightWidth() % 3 == 2) + outerBorderRightWidth += 1; + if (style->borderBottomWidth() % 3 == 2) + outerBorderBottomWidth += 1; + if (style->borderLeftWidth() % 3 == 2) + outerBorderLeftWidth += 1; + + if (style->borderTopWidth() % 3 == 1) + innerBorderTopWidth += 1; + if (style->borderRightWidth() % 3 == 1) + innerBorderRightWidth += 1; + if (style->borderBottomWidth() % 3 == 1) + innerBorderBottomWidth += 1; + if (style->borderLeftWidth() % 3 == 1) + innerBorderLeftWidth += 1; + + // Get the inner border rects for both the outer border line and the inner border line + IntRect outerBorderInnerRect = borderInnerRect(borderRect, outerBorderTopWidth, outerBorderBottomWidth, + outerBorderLeftWidth, outerBorderRightWidth); + IntRect innerBorderInnerRect = borderInnerRect(borderRect, innerBorderTopWidth, innerBorderBottomWidth, + innerBorderLeftWidth, innerBorderRightWidth); + + // Get the inner radii for the outer border line + IntSize outerBorderTopLeftInnerRadius, outerBorderTopRightInnerRadius, outerBorderBottomLeftInnerRadius, + outerBorderBottomRightInnerRadius; + style->getInnerBorderRadiiForRectWithBorderWidths(outerBorderInnerRect, outerBorderTopWidth, outerBorderBottomWidth, + outerBorderLeftWidth, outerBorderRightWidth, outerBorderTopLeftInnerRadius, outerBorderTopRightInnerRadius, + outerBorderBottomLeftInnerRadius, outerBorderBottomRightInnerRadius); + + // Get the inner radii for the inner border line + IntSize innerBorderTopLeftInnerRadius, innerBorderTopRightInnerRadius, innerBorderBottomLeftInnerRadius, + innerBorderBottomRightInnerRadius; + style->getInnerBorderRadiiForRectWithBorderWidths(innerBorderInnerRect, innerBorderTopWidth, innerBorderBottomWidth, + innerBorderLeftWidth, innerBorderRightWidth, innerBorderTopLeftInnerRadius, innerBorderTopRightInnerRadius, + innerBorderBottomLeftInnerRadius, innerBorderBottomRightInnerRadius); + + // Draw inner border line + graphicsContext->save(); + graphicsContext->addRoundedRectClip(innerBorderInnerRect, innerBorderTopLeftInnerRadius, + innerBorderTopRightInnerRadius, innerBorderBottomLeftInnerRadius, innerBorderBottomRightInnerRadius); + drawBoxSideFromPath(graphicsContext, borderRect, borderPath, thickness, drawThickness, s, style, c, SOLID); + graphicsContext->restore(); + + // Draw outer border line + graphicsContext->save(); + graphicsContext->clipOutRoundedRect(outerBorderInnerRect, outerBorderTopLeftInnerRadius, + outerBorderTopRightInnerRadius, outerBorderBottomLeftInnerRadius, outerBorderBottomRightInnerRadius); + drawBoxSideFromPath(graphicsContext, borderRect, borderPath, thickness, drawThickness, s, style, c, SOLID); + graphicsContext->restore(); + + return; + } + case RIDGE: + case GROOVE: + { + EBorderStyle s1; + EBorderStyle s2; + if (borderStyle == GROOVE) { + s1 = INSET; + s2 = OUTSET; + } else { + s1 = OUTSET; + s2 = INSET; + } + + IntRect halfBorderRect = borderInnerRect(borderRect, style->borderLeftWidth() / 2, style->borderBottomWidth() / 2, + style->borderLeftWidth() / 2, style->borderRightWidth() / 2); + + IntSize topLeftHalfRadius, topRightHalfRadius, bottomLeftHalfRadius, bottomRightHalfRadius; + style->getInnerBorderRadiiForRectWithBorderWidths(halfBorderRect, style->borderLeftWidth() / 2, + style->borderBottomWidth() / 2, style->borderLeftWidth() / 2, style->borderRightWidth() / 2, + topLeftHalfRadius, topRightHalfRadius, bottomLeftHalfRadius, bottomRightHalfRadius); + + // Paint full border + drawBoxSideFromPath(graphicsContext, borderRect, borderPath, thickness, drawThickness, s, style, c, s1); + + // Paint inner only + graphicsContext->save(); + graphicsContext->addRoundedRectClip(halfBorderRect, topLeftHalfRadius, topRightHalfRadius, + bottomLeftHalfRadius, bottomRightHalfRadius); + drawBoxSideFromPath(graphicsContext, borderRect, borderPath, thickness, drawThickness, s, style, c, s2); + graphicsContext->restore(); + + return; + } + case INSET: + if (s == BSTop || s == BSLeft) + c = c.dark(); + break; + case OUTSET: + if (s == BSBottom || s == BSRight) + c = c.dark(); + break; + default: + break; + } + + graphicsContext->setStrokeStyle(NoStroke); + graphicsContext->setFillColor(c, style->colorSpace()); + graphicsContext->drawRect(borderRect); +} +#else void RenderObject::drawArcForBoxSide(GraphicsContext* graphicsContext, int x, int y, float thickness, IntSize radius, int angleStart, int angleSpan, BoxSide s, Color c, EBorderStyle style, bool firstCorner) { + // FIXME: This function should be removed when all ports implement GraphicsContext::clipConvexPolygon()!! + // At that time, everyone can use RenderObject::drawBoxSideFromPath() instead. This should happen soon. if ((style == DOUBLE && thickness / 2 < 3) || ((style == RIDGE || style == GROOVE) && thickness / 2 < 2)) style = SOLID; @@ -960,6 +1137,7 @@ void RenderObject::drawArcForBoxSide(GraphicsContext* graphicsContext, int x, in break; } } +#endif void RenderObject::addPDFURLRect(GraphicsContext* context, const IntRect& rect) { diff --git a/WebCore/rendering/RenderObject.h b/WebCore/rendering/RenderObject.h index 3446a00..33271df 100644 --- a/WebCore/rendering/RenderObject.h +++ b/WebCore/rendering/RenderObject.h @@ -31,12 +31,17 @@ #include "Document.h" #include "Element.h" #include "FloatQuad.h" +#include "PaintInfo.h" #include "RenderObjectChildList.h" #include "RenderStyle.h" #include "TextAffinity.h" #include "TransformationMatrix.h" #include +#if PLATFORM(CG) +#define HAVE_PATH_BASED_BORDER_RADIUS_DRAWING 1 +#endif + namespace WebCore { class AnimationController; @@ -44,6 +49,7 @@ class HitTestResult; class InlineBox; class InlineFlowBox; class OverlapTestRequestClient; +class Path; class Position; class RenderBoxModelObject; class RenderInline; @@ -57,39 +63,6 @@ class VisiblePosition; class RenderSVGResourceContainer; #endif -/* - * The painting of a layer occurs in three distinct phases. Each phase involves - * a recursive descent into the layer's render objects. The first phase is the background phase. - * The backgrounds and borders of all blocks are painted. Inlines are not painted at all. - * Floats must paint above block backgrounds but entirely below inline content that can overlap them. - * In the foreground phase, all inlines are fully painted. Inline replaced elements will get all - * three phases invoked on them during this phase. - */ - -// FIXME: These enums should move to their own header since they're used by other headers. -enum PaintPhase { - PaintPhaseBlockBackground, - PaintPhaseChildBlockBackground, - PaintPhaseChildBlockBackgrounds, - PaintPhaseFloat, - PaintPhaseForeground, - PaintPhaseOutline, - PaintPhaseChildOutlines, - PaintPhaseSelfOutline, - PaintPhaseSelection, - PaintPhaseCollapsedTableBorders, - PaintPhaseTextClip, - PaintPhaseMask -}; - -enum PaintBehaviorFlags { - PaintBehaviorNormal = 0, - PaintBehaviorSelectionOnly = 1 << 0, - PaintBehaviorForceBlackText = 1 << 1, - PaintBehaviorFlattenCompositingLayers = 1 << 2 -}; -typedef unsigned PaintBehavior; - enum HitTestFilter { HitTestAll, HitTestSelf, @@ -436,8 +409,19 @@ public: void drawLineForBoxSide(GraphicsContext*, int x1, int y1, int x2, int y2, BoxSide, Color, EBorderStyle, int adjbw1, int adjbw2); +#if HAVE(PATH_BASED_BORDER_RADIUS_DRAWING) + void drawBoxSideFromPath(GraphicsContext*, IntRect, Path, + float thickness, float drawThickness, BoxSide, const RenderStyle*, + Color, EBorderStyle); +#else + // FIXME: This function should be removed when all ports implement GraphicsContext::clipConvexPolygon()!! + // At that time, everyone can use RenderObject::drawBoxSideFromPath() instead. This should happen soon. void drawArcForBoxSide(GraphicsContext*, int x, int y, float thickness, IntSize radius, int angleStart, int angleSpan, BoxSide, Color, EBorderStyle, bool firstCorner); +#endif + + IntRect borderInnerRect(const IntRect&, unsigned short topWidth, unsigned short bottomWidth, + unsigned short leftWidth, unsigned short rightWidth) const; // The pseudo element style can be cached or uncached. Use the cached method if the pseudo element doesn't respect // any pseudo classes (and therefore has no concept of changing state). @@ -506,36 +490,6 @@ public: // for the vertical-align property of inline elements // the offset of baseline from the top of the object. virtual int baselinePosition(bool firstLine, bool isRootLineBox = false) const; - - typedef HashMap OverlapTestRequestMap; - - /* - * Paint the object and its children, clipped by (x|y|w|h). - * (tx|ty) is the calculated position of the parent - */ - struct PaintInfo { - PaintInfo(GraphicsContext* newContext, const IntRect& newRect, PaintPhase newPhase, bool newForceBlackText, - RenderObject* newPaintingRoot, ListHashSet* newOutlineObjects, - OverlapTestRequestMap* overlapTestRequests = 0) - : context(newContext) - , rect(newRect) - , phase(newPhase) - , forceBlackText(newForceBlackText) - , paintingRoot(newPaintingRoot) - , outlineObjects(newOutlineObjects) - , overlapTestRequests(overlapTestRequests) - { - } - - GraphicsContext* context; - IntRect rect; - PaintPhase phase; - bool forceBlackText; - RenderObject* paintingRoot; // used to draw just one element and its visual kids - ListHashSet* outlineObjects; // used to list outlines that should be painted by a block with inline children - OverlapTestRequestMap* overlapTestRequests; - }; - virtual void paint(PaintInfo&, int tx, int ty); // Recursive function that computes the size and position of this object and all its descendants. @@ -768,17 +722,6 @@ public: void selectionStartEnd(int& spos, int& epos) const; - RenderObject* paintingRootForChildren(PaintInfo& paintInfo) const - { - // if we're the painting root, kids draw normally, and see root of 0 - return (!paintInfo.paintingRoot || paintInfo.paintingRoot == this) ? 0 : paintInfo.paintingRoot; - } - - bool shouldPaintWithinRoot(PaintInfo& paintInfo) const - { - return !paintInfo.paintingRoot || paintInfo.paintingRoot == this; - } - bool hasOverrideSize() const { return m_hasOverrideSize; } void setHasOverrideSize(bool b) { m_hasOverrideSize = b; } diff --git a/WebCore/rendering/RenderPath.cpp b/WebCore/rendering/RenderPath.cpp index 238a4e6..0010e3f 100644 --- a/WebCore/rendering/RenderPath.cpp +++ b/WebCore/rendering/RenderPath.cpp @@ -34,7 +34,6 @@ #include "HitTestRequest.h" #include "PointerEventsHitRules.h" #include "RenderSVGContainer.h" -#include "RenderSVGResourceFilter.h" #include "RenderSVGResourceMarker.h" #include "StrokeStyleApplier.h" #include "SVGRenderSupport.h" @@ -57,7 +56,7 @@ public: void strokeStyle(GraphicsContext* gc) { - applyStrokeStyleToContext(gc, m_style, m_object); + SVGRenderSupport::applyStrokeStyleToContext(gc, m_style, m_object); } private: @@ -105,7 +104,7 @@ void RenderPath::layout() // as the viewport size may have changed. It would be nice to optimize this to detect these changes, and only // update when needed, even when using relative values. bool needsPathUpdate = m_needsPathUpdate; - if (!needsPathUpdate && element->hasRelativeValues()) + if (!needsPathUpdate && element->hasRelativeLengths()) needsPathUpdate = true; if (needsPathUpdate) { @@ -172,13 +171,12 @@ void RenderPath::paint(PaintInfo& paintInfo, int, int) bool drawsOutline = style()->outlineWidth() && (childPaintInfo.phase == PaintPhaseOutline || childPaintInfo.phase == PaintPhaseSelfOutline); if (drawsOutline || childPaintInfo.phase == PaintPhaseForeground) { childPaintInfo.context->save(); - applyTransformToPaintInfo(childPaintInfo, m_localTransform); - RenderSVGResourceFilter* filter = 0; + childPaintInfo.applyTransform(m_localTransform); if (childPaintInfo.phase == PaintPhaseForeground) { PaintInfo savedInfo(childPaintInfo); - if (prepareToRenderSVGContent(this, childPaintInfo, boundingBox, filter)) { + if (SVGRenderSupport::prepareToRenderSVGContent(this, childPaintInfo)) { const SVGRenderStyle* svgStyle = style()->svgStyle(); if (svgStyle->shapeRendering() == SR_CRISPEDGES) childPaintInfo.context->setShouldAntialias(false); @@ -189,7 +187,7 @@ void RenderPath::paint(PaintInfo& paintInfo, int, int) m_markerLayoutInfo.drawMarkers(childPaintInfo); } - finishRenderSVGContent(this, childPaintInfo, filter, savedInfo.context); + SVGRenderSupport::finishRenderSVGContent(this, childPaintInfo, savedInfo.context); } if (drawsOutline) @@ -217,7 +215,7 @@ bool RenderPath::nodeAtFloatPoint(const HitTestRequest& request, HitTestResult& FloatPoint localPoint = m_localTransform.inverse().mapPoint(pointInParent); - if (!pointInClippingArea(this, localPoint)) + if (!SVGRenderSupport::pointInClippingArea(this, localPoint)) return false; PointerEventsHitRules hitRules(PointerEventsHitRules::SVG_PATH_HITTESTING, request, style()->pointerEvents()); @@ -317,7 +315,7 @@ void RenderPath::updateCachedBoundaries() // Cache smallest possible repaint rectangle m_repaintBoundingBox = m_strokeAndMarkerBoundingBox; - intersectRepaintRectWithResources(this, m_repaintBoundingBox); + SVGRenderSupport::intersectRepaintRectWithResources(this, m_repaintBoundingBox); } } diff --git a/WebCore/rendering/RenderProgress.cpp b/WebCore/rendering/RenderProgress.cpp index 2587e4b..6072e1e 100644 --- a/WebCore/rendering/RenderProgress.cpp +++ b/WebCore/rendering/RenderProgress.cpp @@ -98,12 +98,17 @@ void RenderProgress::layoutParts() bool RenderProgress::shouldHaveParts() const { - return !style()->hasAppearance(); + if (!style()->hasAppearance()) + return true; + if (ShadowBlockElement::partShouldHaveStyle(this, PROGRESS_BAR_VALUE)) + return true; + return false; } void RenderProgress::updatePartsState() { if (shouldHaveParts() && !m_valuePart) { + style()->setAppearance(NoControlPart); m_valuePart = ShadowBlockElement::createForPart(this->node(), PROGRESS_BAR_VALUE); addChild(m_valuePart->renderer()); } else if (!shouldHaveParts() && m_valuePart) { diff --git a/WebCore/rendering/RenderReplaced.cpp b/WebCore/rendering/RenderReplaced.cpp index d579b99..0da321e 100644 --- a/WebCore/rendering/RenderReplaced.cpp +++ b/WebCore/rendering/RenderReplaced.cpp @@ -114,7 +114,7 @@ void RenderReplaced::paint(PaintInfo& paintInfo, int tx, int ty) if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection) return; - if (!shouldPaintWithinRoot(paintInfo)) + if (!paintInfo.shouldPaintWithinRoot(this)) return; bool drawSelectionTint = selectionState() != SelectionNone && !document()->printing(); @@ -163,7 +163,7 @@ bool RenderReplaced::shouldPaint(PaintInfo& paintInfo, int& tx, int& ty) && paintInfo.phase != PaintPhaseSelection && paintInfo.phase != PaintPhaseMask) return false; - if (!shouldPaintWithinRoot(paintInfo)) + if (!paintInfo.shouldPaintWithinRoot(this)) return false; // if we're invisible or haven't received a layout yet, then just bail. diff --git a/WebCore/rendering/RenderSVGAllInOne.cpp b/WebCore/rendering/RenderSVGAllInOne.cpp new file mode 100644 index 0000000..da86f84 --- /dev/null +++ b/WebCore/rendering/RenderSVGAllInOne.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2009, 2010 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// This all-in-one cpp file cuts down on template bloat to allow us to build our Windows release build. + +#include "RenderSVGBlock.cpp" +#include "RenderSVGContainer.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" +#include "RenderSVGResourceFilter.cpp" +#include "RenderSVGResourceGradient.cpp" +#include "RenderSVGResourceLinearGradient.cpp" +#include "RenderSVGResourceMarker.cpp" +#include "RenderSVGResourceMasker.cpp" +#include "RenderSVGResourcePattern.cpp" +#include "RenderSVGResourceRadialGradient.cpp" +#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 "SVGCharacterData.cpp" +#include "SVGCharacterLayoutInfo.cpp" +#include "SVGInlineFlowBox.cpp" +#include "SVGInlineTextBox.cpp" +#include "SVGMarkerLayoutInfo.cpp" +#include "SVGRenderSupport.cpp" +#include "SVGRenderTreeAsText.cpp" +#include "SVGRootInlineBox.cpp" +#include "SVGShadowTreeElements.cpp" +#include "SVGTextChunkLayoutInfo.cpp" +#include "SVGTextLayoutUtilities.cpp" +#include "SVGTextQuery.cpp" diff --git a/WebCore/rendering/RenderSVGBlock.h b/WebCore/rendering/RenderSVGBlock.h index af819fd..8dd140b 100644 --- a/WebCore/rendering/RenderSVGBlock.h +++ b/WebCore/rendering/RenderSVGBlock.h @@ -29,8 +29,7 @@ namespace WebCore { class SVGElement; -class RenderSVGBlock : public RenderBlock - , protected SVGRenderBase { +class RenderSVGBlock : public RenderBlock { public: RenderSVGBlock(SVGElement*); diff --git a/WebCore/rendering/RenderSVGContainer.cpp b/WebCore/rendering/RenderSVGContainer.cpp index 66889ac..27584d9 100644 --- a/WebCore/rendering/RenderSVGContainer.cpp +++ b/WebCore/rendering/RenderSVGContainer.cpp @@ -60,7 +60,7 @@ void RenderSVGContainer::layout() LayoutRepainter repainter(*this, checkForRepaintDuringLayout() || selfWillPaint()); calculateLocalTransform(); // Allow RenderSVGTransformableContainer to update its transform - layoutChildren(this, selfNeedsLayout()); + SVGRenderSupport::layoutChildren(this, selfNeedsLayout()); repainter.repaintAfterLayout(); setNeedsLayout(false); @@ -87,29 +87,25 @@ void RenderSVGContainer::paint(PaintInfo& paintInfo, int, int) return; PaintInfo childPaintInfo(paintInfo); - childPaintInfo.context->save(); // Let the RenderSVGViewportContainer subclass clip if necessary applyViewportClip(childPaintInfo); - applyTransformToPaintInfo(childPaintInfo, localToParentTransform()); - - RenderSVGResourceFilter* filter = 0; - FloatRect boundingBox = repaintRectInLocalCoordinates(); + childPaintInfo.applyTransform(localToParentTransform()); bool continueRendering = true; if (childPaintInfo.phase == PaintPhaseForeground) - continueRendering = prepareToRenderSVGContent(this, childPaintInfo, boundingBox, filter); + continueRendering = SVGRenderSupport::prepareToRenderSVGContent(this, childPaintInfo); if (continueRendering) { - childPaintInfo.paintingRoot = paintingRootForChildren(childPaintInfo); + childPaintInfo.updatePaintingRootForChildren(this); for (RenderObject* child = firstChild(); child; child = child->nextSibling()) child->paint(childPaintInfo, 0, 0); } if (paintInfo.phase == PaintPhaseForeground) - finishRenderSVGContent(this, childPaintInfo, filter, paintInfo.context); + SVGRenderSupport::finishRenderSVGContent(this, childPaintInfo, paintInfo.context); childPaintInfo.context->restore(); @@ -118,9 +114,10 @@ void RenderSVGContainer::paint(PaintInfo& paintInfo, int, int) // outline rect into parent coords before drawing. // FIXME: This means our focus ring won't share our rotation like it should. // We should instead disable our clip during PaintPhaseOutline - IntRect paintRectInParent = enclosingIntRect(localToParentTransform().mapRect(repaintRectInLocalCoordinates())); - if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && style()->outlineWidth() && style()->visibility() == VISIBLE) + if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && style()->outlineWidth() && style()->visibility() == VISIBLE) { + IntRect paintRectInParent = enclosingIntRect(localToParentTransform().mapRect(repaintRectInLocalCoordinates())); paintOutline(paintInfo.context, paintRectInParent.x(), paintRectInParent.y(), paintRectInParent.width(), paintRectInParent.height()); + } } // addFocusRingRects is called from paintOutline and needs to be in the same coordinates as the paintOuline call @@ -133,21 +130,18 @@ void RenderSVGContainer::addFocusRingRects(Vector& rects, int, int) FloatRect RenderSVGContainer::objectBoundingBox() const { - return computeContainerBoundingBox(this, false); + return SVGRenderSupport::computeContainerBoundingBox(this, SVGRenderSupport::ObjectBoundingBox); } FloatRect RenderSVGContainer::strokeBoundingBox() const { - return computeContainerBoundingBox(this, true); + return SVGRenderSupport::computeContainerBoundingBox(this, SVGRenderSupport::StrokeBoundingBox); } -// RenderSVGContainer is used for elements which do not themselves have a -// width or height, so we union all of our child rects as our repaint rect. FloatRect RenderSVGContainer::repaintRectInLocalCoordinates() const { - FloatRect repaintRect = computeContainerBoundingBox(this, true); - intersectRepaintRectWithResources(this, repaintRect); - + FloatRect repaintRect = SVGRenderSupport::computeContainerBoundingBox(this, SVGRenderSupport::RepaintBoundingBox); + SVGRenderSupport::intersectRepaintRectWithResources(this, repaintRect); return repaintRect; } @@ -159,7 +153,7 @@ bool RenderSVGContainer::nodeAtFloatPoint(const HitTestRequest& request, HitTest FloatPoint localPoint = localToParentTransform().inverse().mapPoint(pointInParent); - if (!pointInClippingArea(this, localPoint)) + if (!SVGRenderSupport::pointInClippingArea(this, localPoint)) return false; for (RenderObject* child = lastChild(); child; child = child->previousSibling()) { diff --git a/WebCore/rendering/RenderSVGHiddenContainer.cpp b/WebCore/rendering/RenderSVGHiddenContainer.cpp index 5d6bd25..0af4236 100644 --- a/WebCore/rendering/RenderSVGHiddenContainer.cpp +++ b/WebCore/rendering/RenderSVGHiddenContainer.cpp @@ -38,7 +38,7 @@ RenderSVGHiddenContainer::RenderSVGHiddenContainer(SVGStyledElement* element) void RenderSVGHiddenContainer::layout() { ASSERT(needsLayout()); - layoutChildren(this, selfNeedsLayout()); + SVGRenderSupport::layoutChildren(this, selfNeedsLayout()); setNeedsLayout(false); } diff --git a/WebCore/rendering/RenderSVGImage.cpp b/WebCore/rendering/RenderSVGImage.cpp index 45898c7..a4572e6 100644 --- a/WebCore/rendering/RenderSVGImage.cpp +++ b/WebCore/rendering/RenderSVGImage.cpp @@ -83,11 +83,9 @@ void RenderSVGImage::paint(PaintInfo& paintInfo, int, int) paintInfo.context->concatCTM(localToParentTransform()); if (paintInfo.phase == PaintPhaseForeground) { - RenderSVGResourceFilter* filter = 0; - PaintInfo savedInfo(paintInfo); - if (prepareToRenderSVGContent(this, paintInfo, m_localBounds, filter)) { + if (SVGRenderSupport::prepareToRenderSVGContent(this, paintInfo)) { FloatRect destRect = m_localBounds; FloatRect srcRect(0, 0, image()->width(), image()->height()); @@ -97,7 +95,7 @@ void RenderSVGImage::paint(PaintInfo& paintInfo, int, int) paintInfo.context->drawImage(image(), DeviceColorSpace, destRect, srcRect); } - finishRenderSVGContent(this, paintInfo, filter, savedInfo.context); + SVGRenderSupport::finishRenderSVGContent(this, paintInfo, savedInfo.context); } if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && style()->outlineWidth()) @@ -108,7 +106,7 @@ void RenderSVGImage::paint(PaintInfo& paintInfo, int, int) void RenderSVGImage::destroy() { - deregisterFromResources(this); + RenderSVGResource::invalidateAllResourcesOfRenderer(this); RenderImage::destroy(); } @@ -123,7 +121,7 @@ bool RenderSVGImage::nodeAtFloatPoint(const HitTestRequest& request, HitTestResu if (isVisible || !hitRules.requireVisible) { FloatPoint localPoint = localToParentTransform().inverse().mapPoint(pointInParent); - if (!pointInClippingArea(this, localPoint)) + if (!SVGRenderSupport::pointInClippingArea(this, localPoint)) return false; if (hitRules.canHitFill) { @@ -150,7 +148,7 @@ FloatRect RenderSVGImage::repaintRectInLocalCoordinates() const return m_cachedLocalRepaintRect; m_cachedLocalRepaintRect = m_localBounds; - intersectRepaintRectWithResources(this, m_cachedLocalRepaintRect); + SVGRenderSupport::intersectRepaintRectWithResources(this, m_cachedLocalRepaintRect); return m_cachedLocalRepaintRect; } @@ -169,17 +167,17 @@ void RenderSVGImage::imageChanged(WrappedImagePtr image, const IntRect* rect) IntRect RenderSVGImage::clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) { - return SVGRenderBase::clippedOverflowRectForRepaint(this, repaintContainer); + return SVGRenderSupport::clippedOverflowRectForRepaint(this, repaintContainer); } void RenderSVGImage::computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& repaintRect, bool fixed) { - SVGRenderBase::computeRectForRepaint(this, repaintContainer, repaintRect, fixed); + SVGRenderSupport::computeRectForRepaint(this, repaintContainer, repaintRect, fixed); } void RenderSVGImage::mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed , bool useTransforms, TransformState& transformState) const { - SVGRenderBase::mapLocalToContainer(this, repaintContainer, fixed, useTransforms, transformState); + SVGRenderSupport::mapLocalToContainer(this, repaintContainer, fixed, useTransforms, transformState); } void RenderSVGImage::addFocusRingRects(Vector& rects, int, int) diff --git a/WebCore/rendering/RenderSVGImage.h b/WebCore/rendering/RenderSVGImage.h index 37d2aee..3baac23 100644 --- a/WebCore/rendering/RenderSVGImage.h +++ b/WebCore/rendering/RenderSVGImage.h @@ -34,8 +34,7 @@ namespace WebCore { class SVGImageElement; -class RenderSVGImage : public RenderImage - , protected SVGRenderBase { +class RenderSVGImage : public RenderImage { public: RenderSVGImage(SVGImageElement*); diff --git a/WebCore/rendering/RenderSVGInline.cpp b/WebCore/rendering/RenderSVGInline.cpp index ca0fdb5..ffc6b62 100644 --- a/WebCore/rendering/RenderSVGInline.cpp +++ b/WebCore/rendering/RenderSVGInline.cpp @@ -44,7 +44,7 @@ InlineFlowBox* RenderSVGInline::createInlineFlowBox() FloatRect RenderSVGInline::objectBoundingBox() const { - if (const RenderObject* object = findTextRootObject(this)) + if (const RenderObject* object = SVGRenderSupport::findTextRootObject(this)) return object->objectBoundingBox(); return FloatRect(); @@ -52,7 +52,7 @@ FloatRect RenderSVGInline::objectBoundingBox() const FloatRect RenderSVGInline::strokeBoundingBox() const { - if (const RenderObject* object = findTextRootObject(this)) + if (const RenderObject* object = SVGRenderSupport::findTextRootObject(this)) return object->strokeBoundingBox(); return FloatRect(); @@ -60,7 +60,7 @@ FloatRect RenderSVGInline::strokeBoundingBox() const FloatRect RenderSVGInline::repaintRectInLocalCoordinates() const { - if (const RenderObject* object = findTextRootObject(this)) + if (const RenderObject* object = SVGRenderSupport::findTextRootObject(this)) return object->repaintRectInLocalCoordinates(); return FloatRect(); @@ -68,22 +68,22 @@ FloatRect RenderSVGInline::repaintRectInLocalCoordinates() const IntRect RenderSVGInline::clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) { - return SVGRenderBase::clippedOverflowRectForRepaint(this, repaintContainer); + return SVGRenderSupport::clippedOverflowRectForRepaint(this, repaintContainer); } void RenderSVGInline::computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& repaintRect, bool fixed) { - SVGRenderBase::computeRectForRepaint(this, repaintContainer, repaintRect, fixed); + SVGRenderSupport::computeRectForRepaint(this, repaintContainer, repaintRect, fixed); } void RenderSVGInline::mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState& transformState) const { - SVGRenderBase::mapLocalToContainer(this, repaintContainer, useTransforms, fixed, transformState); + SVGRenderSupport::mapLocalToContainer(this, repaintContainer, useTransforms, fixed, transformState); } void RenderSVGInline::absoluteQuads(Vector& quads) { - const RenderObject* object = findTextRootObject(this); + const RenderObject* object = SVGRenderSupport::findTextRootObject(this); if (!object) return; diff --git a/WebCore/rendering/RenderSVGInline.h b/WebCore/rendering/RenderSVGInline.h index 2efb1aa..6f44162 100644 --- a/WebCore/rendering/RenderSVGInline.h +++ b/WebCore/rendering/RenderSVGInline.h @@ -31,8 +31,7 @@ namespace WebCore { -class RenderSVGInline : public RenderInline - , protected SVGRenderBase { +class RenderSVGInline : public RenderInline { public: RenderSVGInline(Node*); diff --git a/WebCore/rendering/RenderSVGModelObject.cpp b/WebCore/rendering/RenderSVGModelObject.cpp index a80a963..3d22e7a 100644 --- a/WebCore/rendering/RenderSVGModelObject.cpp +++ b/WebCore/rendering/RenderSVGModelObject.cpp @@ -33,9 +33,7 @@ #if ENABLE(SVG) #include "RenderSVGModelObject.h" -#include "GraphicsContext.h" -#include "RenderLayer.h" -#include "RenderView.h" +#include "RenderSVGResource.h" #include "SVGStyledElement.h" namespace WebCore { @@ -47,21 +45,21 @@ RenderSVGModelObject::RenderSVGModelObject(SVGStyledElement* node) IntRect RenderSVGModelObject::clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) { - return SVGRenderBase::clippedOverflowRectForRepaint(this, repaintContainer); + return SVGRenderSupport::clippedOverflowRectForRepaint(this, repaintContainer); } void RenderSVGModelObject::computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& repaintRect, bool fixed) { - SVGRenderBase::computeRectForRepaint(this, repaintContainer, repaintRect, fixed); + SVGRenderSupport::computeRectForRepaint(this, repaintContainer, repaintRect, fixed); } void RenderSVGModelObject::mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed , bool useTransforms, TransformState& transformState) const { - SVGRenderBase::mapLocalToContainer(this, repaintContainer, fixed, useTransforms, transformState); + SVGRenderSupport::mapLocalToContainer(this, repaintContainer, fixed, useTransforms, transformState); } // Copied from RenderBox, this method likely requires further refactoring to work easily for both SVG and CSS Box Model content. -// FIXME: This may also need to move into SVGRenderBase as the RenderBox version depends +// FIXME: This may also need to move into SVGRenderSupport as the RenderBox version depends // on borderBoundingBox() which SVG RenderBox subclases (like SVGRenderBlock) do not implement. IntRect RenderSVGModelObject::outlineBoundsForRepaint(RenderBoxModelObject* repaintContainer, IntPoint*) const { @@ -85,7 +83,7 @@ void RenderSVGModelObject::absoluteQuads(Vector& quads) void RenderSVGModelObject::destroy() { - deregisterFromResources(this); + RenderSVGResource::invalidateAllResourcesOfRenderer(this); RenderObject::destroy(); } diff --git a/WebCore/rendering/RenderSVGModelObject.h b/WebCore/rendering/RenderSVGModelObject.h index 42ca27f..82c08c0 100644 --- a/WebCore/rendering/RenderSVGModelObject.h +++ b/WebCore/rendering/RenderSVGModelObject.h @@ -41,11 +41,11 @@ namespace WebCore { // Most renderers in the SVG rendering tree will inherit from this class // but not all. (e.g. RenderSVGForeignObject, RenderSVGBlock, RenderSVGImage) thus methods // required by SVG renders need to be declared on RenderObject, but shared -// logic can go in this class or in SVGRenderBase. +// logic can go in this class or in SVGRenderSupport. class SVGStyledElement; -class RenderSVGModelObject : public RenderObject, protected SVGRenderBase { +class RenderSVGModelObject : public RenderObject { public: RenderSVGModelObject(SVGStyledElement*); diff --git a/WebCore/rendering/RenderSVGResource.cpp b/WebCore/rendering/RenderSVGResource.cpp index 129d800..0aa7182 100644 --- a/WebCore/rendering/RenderSVGResource.cpp +++ b/WebCore/rendering/RenderSVGResource.cpp @@ -26,7 +26,11 @@ #if ENABLE(SVG) #include "RenderSVGResource.h" +#include "RenderSVGResourceClipper.h" #include "RenderSVGResourceContainer.h" +#include "RenderSVGResourceFilter.h" +#include "RenderSVGResourceMarker.h" +#include "RenderSVGResourceMasker.h" #include "RenderSVGResourceSolidColor.h" #include "SVGURIReference.h" @@ -197,6 +201,59 @@ void RenderSVGResource::markForLayoutAndResourceInvalidation(RenderObject* objec static_cast(element)->invalidateResourcesInAncestorChain(); } +static inline void invalidatePaintingResource(SVGPaint* paint, RenderObject* object) +{ + ASSERT(paint); + + SVGPaint::SVGPaintType paintType = paint->paintType(); + if (paintType != SVGPaint::SVG_PAINTTYPE_URI && paintType != SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR) + return; + + AtomicString id(SVGURIReference::getTarget(paint->uri())); + if (RenderSVGResourceContainer* paintingResource = getRenderSVGResourceContainerById(object->document(), id)) + paintingResource->invalidateClient(object); +} + +void RenderSVGResource::invalidateAllResourcesOfRenderer(RenderObject* object) +{ + ASSERT(object); + ASSERT(object->style()); + + Document* document = object->document(); + ASSERT(document); + + const SVGRenderStyle* svgStyle = object->style()->svgStyle(); + ASSERT(svgStyle); + + // Masker + if (RenderSVGResourceMasker* masker = getRenderSVGResourceById(document, svgStyle->maskerResource())) + masker->invalidateClient(object); + + // Clipper + if (RenderSVGResourceClipper* clipper = getRenderSVGResourceById(document, svgStyle->clipperResource())) + clipper->invalidateClient(object); + + // Filter +#if ENABLE(FILTERS) + if (RenderSVGResourceFilter* filter = getRenderSVGResourceById(document, svgStyle->filterResource())) + filter->invalidateClient(object); +#endif + + // Markers + if (RenderSVGResourceMarker* startMarker = getRenderSVGResourceById(document, svgStyle->markerStartResource())) + startMarker->invalidateClient(object); + if (RenderSVGResourceMarker* midMarker = getRenderSVGResourceById(document, svgStyle->markerMidResource())) + midMarker->invalidateClient(object); + if (RenderSVGResourceMarker* endMarker = getRenderSVGResourceById(document, svgStyle->markerEndResource())) + endMarker->invalidateClient(object); + + // Gradients/Patterns + if (svgStyle->hasFill()) + invalidatePaintingResource(svgStyle->fillPaint(), object); + if (svgStyle->hasStroke()) + invalidatePaintingResource(svgStyle->strokePaint(), object); +} + } #endif diff --git a/WebCore/rendering/RenderSVGResource.h b/WebCore/rendering/RenderSVGResource.h index a14a972..34ff14e 100644 --- a/WebCore/rendering/RenderSVGResource.h +++ b/WebCore/rendering/RenderSVGResource.h @@ -79,6 +79,8 @@ public: static RenderSVGResource* strokePaintingResource(const RenderObject*, const RenderStyle*); static RenderSVGResourceSolidColor* sharedSolidPaintingResource(); + static void invalidateAllResourcesOfRenderer(RenderObject*); + private: static void adjustColorForPseudoRules(const RenderStyle*, bool useFillPaint, Color&); diff --git a/WebCore/rendering/RenderSVGResourceClipper.cpp b/WebCore/rendering/RenderSVGResourceClipper.cpp index 450c5d6..cc499bf 100644 --- a/WebCore/rendering/RenderSVGResourceClipper.cpp +++ b/WebCore/rendering/RenderSVGResourceClipper.cpp @@ -242,7 +242,7 @@ bool RenderSVGResourceClipper::createClipData(ClipperData* clipperData, const Fl // In the case of a element, we obtained its renderere above, to retrieve its clipRule. // We hsve to pass the renderer itself to renderSubtreeToImage() to apply it's x/y/transform/etc. values when rendering. // So if isUseElement is true, refetch the childNode->renderer(), as renderer got overriden above. - renderSubtreeToImage(clipperData->clipMaskImage.get(), isUseElement ? childNode->renderer() : renderer); + SVGRenderSupport::renderSubtreeToImage(clipperData->clipMaskImage.get(), isUseElement ? childNode->renderer() : renderer); renderer->setStyle(oldRenderStyle.release()); } @@ -271,7 +271,7 @@ void RenderSVGResourceClipper::calculateClipContentRepaintRect() bool RenderSVGResourceClipper::hitTestClipContent(const FloatRect& objectBoundingBox, const FloatPoint& nodeAtPoint) { FloatPoint point = nodeAtPoint; - if (!pointInClippingArea(this, point)) + if (!SVGRenderSupport::pointInClippingArea(this, point)) return false; if (static_cast(node())->clipPathUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { diff --git a/WebCore/rendering/RenderSVGResourceGradient.cpp b/WebCore/rendering/RenderSVGResourceGradient.cpp index e715f6f..7ea70d2 100644 --- a/WebCore/rendering/RenderSVGResourceGradient.cpp +++ b/WebCore/rendering/RenderSVGResourceGradient.cpp @@ -91,7 +91,7 @@ static inline bool createMaskAndSwapContextForTextGradient(GraphicsContext*& con OwnPtr& imageBuffer, const RenderObject* object) { - const RenderObject* textRootBlock = findTextRootObject(object); + const RenderObject* textRootBlock = SVGRenderSupport::findTextRootObject(object); AffineTransform transform = absoluteTransformForRenderer(textRootBlock); FloatRect maskAbsoluteBoundingBox = transform.mapRect(textRootBlock->repaintRectInLocalCoordinates()); @@ -123,7 +123,7 @@ static inline AffineTransform clipToTextMask(GraphicsContext* context, const RenderObject* object, GradientData* gradientData) { - const RenderObject* textRootBlock = findTextRootObject(object); + const RenderObject* textRootBlock = SVGRenderSupport::findTextRootObject(object); context->clipToImageBuffer(textRootBlock->repaintRectInLocalCoordinates(), imageBuffer.get()); AffineTransform matrix; @@ -211,7 +211,7 @@ bool RenderSVGResourceGradient::applyResource(RenderObject* object, RenderStyle* gradientData->gradient->setGradientSpaceTransform(transformOnNonScalingStroke(object, gradientData->userspaceTransform)); context->setAlpha(svgStyle->strokeOpacity()); context->setStrokeGradient(gradientData->gradient); - applyStrokeStyleToContext(context, style, object); + SVGRenderSupport::applyStrokeStyleToContext(context, style, object); } return true; @@ -235,7 +235,7 @@ void RenderSVGResourceGradient::postApplyResource(RenderObject* object, Graphics gradientData->gradient->setGradientSpaceTransform(clipToTextMask(context, m_imageBuffer, object, gradientData)); context->setFillGradient(gradientData->gradient); - const RenderObject* textRootBlock = findTextRootObject(object); + const RenderObject* textRootBlock = SVGRenderSupport::findTextRootObject(object); context->fillRect(textRootBlock->repaintRectInLocalCoordinates()); m_imageBuffer.clear(); diff --git a/WebCore/rendering/RenderSVGResourceMarker.cpp b/WebCore/rendering/RenderSVGResourceMarker.cpp index 4a300c2..ce331a7 100644 --- a/WebCore/rendering/RenderSVGResourceMarker.cpp +++ b/WebCore/rendering/RenderSVGResourceMarker.cpp @@ -88,7 +88,7 @@ void RenderSVGResourceMarker::invalidateClient(RenderObject* object) void RenderSVGResourceMarker::applyViewportClip(PaintInfo& paintInfo) { - if (SVGRenderBase::isOverflowHidden(this)) + if (SVGRenderSupport::isOverflowHidden(this)) paintInfo.context->clip(m_viewport); } @@ -146,7 +146,7 @@ AffineTransform RenderSVGResourceMarker::markerTransformation(const FloatPoint& return transform; } -void RenderSVGResourceMarker::draw(RenderObject::PaintInfo& paintInfo, const AffineTransform& transform) +void RenderSVGResourceMarker::draw(PaintInfo& paintInfo, const AffineTransform& transform) { DEFINE_STATIC_LOCAL(HashSet, currentlyDrawingMarkers, ()); @@ -155,9 +155,9 @@ void RenderSVGResourceMarker::draw(RenderObject::PaintInfo& paintInfo, const Aff return; currentlyDrawingMarkers.add(this); - RenderObject::PaintInfo info(paintInfo); + PaintInfo info(paintInfo); info.context->save(); - applyTransformToPaintInfo(info, transform); + info.applyTransform(transform); RenderSVGContainer::paint(info, 0, 0); info.context->restore(); diff --git a/WebCore/rendering/RenderSVGResourceMarker.h b/WebCore/rendering/RenderSVGResourceMarker.h index 533a03b..75c442e 100644 --- a/WebCore/rendering/RenderSVGResourceMarker.h +++ b/WebCore/rendering/RenderSVGResourceMarker.h @@ -45,7 +45,7 @@ public: virtual void invalidateClients(); virtual void invalidateClient(RenderObject*); - void draw(RenderObject::PaintInfo&, const AffineTransform&); + void draw(PaintInfo&, const AffineTransform&); // Calculates marker boundaries, mapped to the target element's coordinate space FloatRect markerBoundaries(const AffineTransform& markerTransformation) const; diff --git a/WebCore/rendering/RenderSVGResourceMasker.cpp b/WebCore/rendering/RenderSVGResourceMasker.cpp index ea79439..74d3fe6 100644 --- a/WebCore/rendering/RenderSVGResourceMasker.cpp +++ b/WebCore/rendering/RenderSVGResourceMasker.cpp @@ -173,7 +173,7 @@ void RenderSVGResourceMasker::createMaskImage(MaskerData* maskerData, const SVGM RenderStyle* style = renderer->style(); if (!style || style->display() == NONE || style->visibility() != VISIBLE) continue; - renderSubtreeToImage(maskerData->maskImage.get(), renderer); + SVGRenderSupport::renderSubtreeToImage(maskerData->maskImage.get(), renderer); } maskImageContext->restore(); diff --git a/WebCore/rendering/RenderSVGResourcePattern.cpp b/WebCore/rendering/RenderSVGResourcePattern.cpp index 040b2e2..ba24fcf 100644 --- a/WebCore/rendering/RenderSVGResourcePattern.cpp +++ b/WebCore/rendering/RenderSVGResourcePattern.cpp @@ -24,6 +24,7 @@ #if ENABLE(SVG) #include "RenderSVGResourcePattern.h" +#include "FrameView.h" #include "GraphicsContext.h" #include "PatternAttributes.h" #include "SVGRenderSupport.h" @@ -120,7 +121,7 @@ bool RenderSVGResourcePattern::applyResource(RenderObject* object, RenderStyle* patternData->pattern->setPatternSpaceTransform(transformOnNonScalingStroke(object, patternData->transform)); context->setAlpha(svgStyle->strokeOpacity()); context->setStrokePattern(patternData->pattern); - applyStrokeStyleToContext(context, style, object); + SVGRenderSupport::applyStrokeStyleToContext(context, style, object); } if (resourceMode & ApplyToTextMode) { @@ -208,6 +209,22 @@ FloatRect RenderSVGResourcePattern::calculatePatternBoundariesIncludingOverflow( return patternBoundariesIncludingOverflow; } +// FIXME: This method should be removed. RenderSVGResourcePatterns usage of it is just wrong. +static inline void clampImageBufferSizeToViewport(FrameView* frameView, IntSize& size) +{ + if (!frameView) + return; + + int viewWidth = frameView->visibleWidth(); + int viewHeight = frameView->visibleHeight(); + + if (size.width() > viewWidth) + size.setWidth(viewWidth); + + if (size.height() > viewHeight) + size.setHeight(viewHeight); +} + PassOwnPtr RenderSVGResourcePattern::createTileImage(PatternData* patternData, const SVGPatternElement* patternElement, RenderObject* object) const @@ -268,7 +285,7 @@ PassOwnPtr RenderSVGResourcePattern::createTileImage(PatternData* p for (Node* node = attributes.patternContentElement()->firstChild(); node; node = node->nextSibling()) { if (!node->isSVGElement() || !static_cast(node)->isStyled() || !node->renderer()) continue; - renderSubtreeToImage(tileImage.get(), node->renderer()); + SVGRenderSupport::renderSubtreeToImage(tileImage.get(), node->renderer()); } patternData->boundaries = patternBoundaries; diff --git a/WebCore/rendering/RenderSVGResourceSolidColor.cpp b/WebCore/rendering/RenderSVGResourceSolidColor.cpp index 792908f..51ad658 100644 --- a/WebCore/rendering/RenderSVGResourceSolidColor.cpp +++ b/WebCore/rendering/RenderSVGResourceSolidColor.cpp @@ -24,6 +24,7 @@ #include "RenderSVGResourceSolidColor.h" #include "GraphicsContext.h" +#include "RenderStyle.h" #include "SVGRenderSupport.h" #if PLATFORM(SKIA) && !PLATFORM(ANDROID) @@ -65,7 +66,7 @@ bool RenderSVGResourceSolidColor::applyResource(RenderObject* object, RenderStyl context->setStrokeColor(m_color, colorSpace); if (style) - applyStrokeStyleToContext(context, style, object); + SVGRenderSupport::applyStrokeStyleToContext(context, style, object); if (resourceMode & ApplyToTextMode) context->setTextDrawingMode(cTextStroke); diff --git a/WebCore/rendering/RenderSVGRoot.cpp b/WebCore/rendering/RenderSVGRoot.cpp index 70ff938..ad3303f 100644 --- a/WebCore/rendering/RenderSVGRoot.cpp +++ b/WebCore/rendering/RenderSVGRoot.cpp @@ -30,6 +30,7 @@ #include "HitTestResult.h" #endif #include "RenderSVGContainer.h" +#include "RenderSVGResource.h" #include "RenderView.h" #include "SVGLength.h" #include "SVGRenderSupport.h" @@ -121,7 +122,7 @@ void RenderSVGRoot::layout() // RenderSVGRoot needs to take special care to propagate window size changes to the children, // if the outermost is using relative x/y/width/height values. Hence the additonal parameters. SVGSVGElement* svg = static_cast(node()); - layoutChildren(this, needsLayout || (svg->hasRelativeValues() && oldSize != size())); + SVGRenderSupport::layoutChildren(this, needsLayout || (svg->hasRelativeLengths() && oldSize != size())); repainter.repaintAfterLayout(); view()->enableLayoutState(); @@ -162,8 +163,8 @@ void RenderSVGRoot::paint(PaintInfo& paintInfo, int parentX, int parentY) if (!firstChild() && !selfWillPaint()) return; - // Make a copy of the PaintInfo because applyTransformToPaintInfo will modify the damage rect. - RenderObject::PaintInfo childPaintInfo(paintInfo); + // Make a copy of the PaintInfo because applyTransform will modify the damage rect. + PaintInfo childPaintInfo(paintInfo); childPaintInfo.context->save(); // Apply initial viewport clip - not affected by overflow handling @@ -171,20 +172,17 @@ void RenderSVGRoot::paint(PaintInfo& paintInfo, int parentX, int parentY) // Convert from container offsets (html renderers) to a relative transform (svg renderers). // Transform from our paint container's coordinate system to our local coords. - applyTransformToPaintInfo(childPaintInfo, localToRepaintContainerTransform(parentOriginInContainer)); - - RenderSVGResourceFilter* filter = 0; - FloatRect boundingBox = repaintRectInLocalCoordinates(); + childPaintInfo.applyTransform(localToRepaintContainerTransform(parentOriginInContainer)); bool continueRendering = true; if (childPaintInfo.phase == PaintPhaseForeground) - continueRendering = prepareToRenderSVGContent(this, childPaintInfo, boundingBox, filter); + continueRendering = SVGRenderSupport::prepareToRenderSVGContent(this, childPaintInfo); if (continueRendering) RenderBox::paint(childPaintInfo, 0, 0); if (childPaintInfo.phase == PaintPhaseForeground) - finishRenderSVGContent(this, childPaintInfo, filter, paintInfo.context); + SVGRenderSupport::finishRenderSVGContent(this, childPaintInfo, paintInfo.context); childPaintInfo.context->restore(); @@ -194,7 +192,7 @@ void RenderSVGRoot::paint(PaintInfo& paintInfo, int parentX, int parentY) void RenderSVGRoot::destroy() { - deregisterFromResources(this); + RenderSVGResource::invalidateAllResourcesOfRenderer(this); RenderBox::destroy(); } @@ -202,7 +200,7 @@ void RenderSVGRoot::calcViewport() { SVGSVGElement* svg = static_cast(node()); - if (!selfNeedsLayout() && !svg->hasRelativeValues()) + if (!selfNeedsLayout() && !svg->hasRelativeLengths()) return; if (!svg->hasSetContainerSize()) { @@ -262,22 +260,22 @@ const AffineTransform& RenderSVGRoot::localToParentTransform() const FloatRect RenderSVGRoot::objectBoundingBox() const { - return computeContainerBoundingBox(this, false); + return SVGRenderSupport::computeContainerBoundingBox(this, SVGRenderSupport::ObjectBoundingBox); +} + +FloatRect RenderSVGRoot::strokeBoundingBox() const +{ + return SVGRenderSupport::computeContainerBoundingBox(this, SVGRenderSupport::StrokeBoundingBox); } FloatRect RenderSVGRoot::repaintRectInLocalCoordinates() const { // FIXME: This does not include the border but it should! - FloatRect repaintRect = computeContainerBoundingBox(this, true); + FloatRect repaintRect = SVGRenderSupport::computeContainerBoundingBox(this, SVGRenderSupport::RepaintBoundingBox); style()->svgStyle()->inflateForShadow(repaintRect); return repaintRect; } -AffineTransform RenderSVGRoot::localTransform() const -{ - return AffineTransform(); -} - void RenderSVGRoot::computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& repaintRect, bool fixed) { // Apply our local transforms (except for x/y translation), then our shadow, diff --git a/WebCore/rendering/RenderSVGRoot.h b/WebCore/rendering/RenderSVGRoot.h index 53c1298..48263aa 100644 --- a/WebCore/rendering/RenderSVGRoot.h +++ b/WebCore/rendering/RenderSVGRoot.h @@ -33,7 +33,7 @@ namespace WebCore { class SVGStyledElement; class AffineTransform; -class RenderSVGRoot : public RenderBox, protected SVGRenderBase { +class RenderSVGRoot : public RenderBox { public: RenderSVGRoot(SVGStyledElement*); @@ -63,12 +63,9 @@ private: bool strokeContains(const FloatPoint&) const; virtual FloatRect objectBoundingBox() const; - virtual FloatRect strokeBoundingBox() const { return computeContainerBoundingBox(this, true); } + virtual FloatRect strokeBoundingBox() const; virtual FloatRect repaintRectInLocalCoordinates() const; - // FIXME: This override should be removed. - virtual AffineTransform localTransform() const; - virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction); virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& repaintRect, bool fixed); @@ -108,5 +105,3 @@ void toRenderSVGRoot(const RenderSVGRoot*); #endif // ENABLE(SVG) #endif // RenderSVGRoot_h - -// vim:ts=4:noet diff --git a/WebCore/rendering/RenderSVGText.cpp b/WebCore/rendering/RenderSVGText.cpp index 84f5329..12f3cb5 100644 --- a/WebCore/rendering/RenderSVGText.cpp +++ b/WebCore/rendering/RenderSVGText.cpp @@ -36,6 +36,7 @@ #include "HitTestRequest.h" #include "PointerEventsHitRules.h" #include "RenderLayer.h" +#include "RenderSVGResource.h" #include "RenderSVGRoot.h" #include "SVGLengthList.h" #include "SVGRenderSupport.h" @@ -56,17 +57,17 @@ RenderSVGText::RenderSVGText(SVGTextElement* node) IntRect RenderSVGText::clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) { - return SVGRenderBase::clippedOverflowRectForRepaint(this, repaintContainer); + return SVGRenderSupport::clippedOverflowRectForRepaint(this, repaintContainer); } void RenderSVGText::computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& repaintRect, bool fixed) { - SVGRenderBase::computeRectForRepaint(this, repaintContainer, repaintRect, fixed); + SVGRenderSupport::computeRectForRepaint(this, repaintContainer, repaintRect, fixed); } void RenderSVGText::mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed, bool useTransforms, TransformState& transformState) const { - SVGRenderBase::mapLocalToContainer(this, repaintContainer, fixed, useTransforms, transformState); + SVGRenderSupport::mapLocalToContainer(this, repaintContainer, fixed, useTransforms, transformState); } void RenderSVGText::layout() @@ -117,7 +118,7 @@ bool RenderSVGText::nodeAtFloatPoint(const HitTestRequest& request, HitTestResul || (hitRules.canHitFill && (style()->svgStyle()->hasFill() || !hitRules.requireFill))) { FloatPoint localPoint = localToParentTransform().inverse().mapPoint(pointInParent); - if (!pointInClippingArea(this, localPoint)) + if (!SVGRenderSupport::pointInClippingArea(this, localPoint)) return false; return RenderBlock::nodeAtPoint(request, result, (int)localPoint.x(), (int)localPoint.y(), 0, 0, hitTestAction); @@ -129,7 +130,7 @@ bool RenderSVGText::nodeAtFloatPoint(const HitTestRequest& request, HitTestResul void RenderSVGText::destroy() { - deregisterFromResources(this); + RenderSVGResource::invalidateAllResourcesOfRenderer(this); RenderSVGBlock::destroy(); } @@ -156,7 +157,7 @@ void RenderSVGText::paint(PaintInfo& paintInfo, int, int) PaintInfo blockInfo(paintInfo); blockInfo.context->save(); - applyTransformToPaintInfo(blockInfo, localToParentTransform()); + blockInfo.applyTransform(localToParentTransform()); RenderBlock::paint(blockInfo, 0, 0); blockInfo.context->restore(); } @@ -174,7 +175,7 @@ FloatRect RenderSVGText::strokeBoundingBox() const FloatRect RenderSVGText::repaintRectInLocalCoordinates() const { FloatRect repaintRect = strokeBoundingBox(); - intersectRepaintRectWithResources(this, repaintRect); + SVGRenderSupport::intersectRepaintRectWithResources(this, repaintRect); return repaintRect; } diff --git a/WebCore/rendering/RenderSVGViewportContainer.cpp b/WebCore/rendering/RenderSVGViewportContainer.cpp index 1587e7f..ca735d2 100644 --- a/WebCore/rendering/RenderSVGViewportContainer.cpp +++ b/WebCore/rendering/RenderSVGViewportContainer.cpp @@ -39,7 +39,7 @@ RenderSVGViewportContainer::RenderSVGViewportContainer(SVGStyledElement* node) void RenderSVGViewportContainer::applyViewportClip(PaintInfo& paintInfo) { - if (SVGRenderBase::isOverflowHidden(this)) + if (SVGRenderSupport::isOverflowHidden(this)) paintInfo.context->clip(m_viewport); } @@ -49,7 +49,7 @@ void RenderSVGViewportContainer::calcViewport() if (svgelem->hasTagName(SVGNames::svgTag)) { SVGSVGElement* svg = static_cast(node()); - if (!selfNeedsLayout() && !svg->hasRelativeValues()) + if (!selfNeedsLayout() && !svg->hasRelativeLengths()) return; float x = svg->x().value(svg); @@ -82,7 +82,7 @@ const AffineTransform& RenderSVGViewportContainer::localToParentTransform() cons bool RenderSVGViewportContainer::pointIsInsideViewportClip(const FloatPoint& pointInParent) { // Respect the viewport clip (which is in parent coords) - if (!SVGRenderBase::isOverflowHidden(this)) + if (!SVGRenderSupport::isOverflowHidden(this)) return true; return m_viewport.contains(pointInParent); diff --git a/WebCore/rendering/RenderScrollbarPart.cpp b/WebCore/rendering/RenderScrollbarPart.cpp index c83248a..d2f1612 100644 --- a/WebCore/rendering/RenderScrollbarPart.cpp +++ b/WebCore/rendering/RenderScrollbarPart.cpp @@ -164,7 +164,7 @@ void RenderScrollbarPart::paintIntoRect(GraphicsContext* graphicsContext, int tx return; // Now do the paint. - RenderObject::PaintInfo paintInfo(graphicsContext, rect, PaintPhaseBlockBackground, false, 0, 0); + PaintInfo paintInfo(graphicsContext, rect, PaintPhaseBlockBackground, false, 0, 0); paint(paintInfo, tx, ty); paintInfo.phase = PaintPhaseChildBlockBackgrounds; paint(paintInfo, tx, ty); diff --git a/WebCore/rendering/RenderTable.cpp b/WebCore/rendering/RenderTable.cpp index 00c6ac0..65a0cde 100644 --- a/WebCore/rendering/RenderTable.cpp +++ b/WebCore/rendering/RenderTable.cpp @@ -524,7 +524,7 @@ void RenderTable::paintObject(PaintInfo& paintInfo, int tx, int ty) PaintInfo info(paintInfo); info.phase = paintPhase; - info.paintingRoot = paintingRootForChildren(paintInfo); + info.updatePaintingRootForChildren(this); for (RenderObject* child = firstChild(); child; child = child->nextSibling()) { if (child->isBox() && !toRenderBox(child)->hasSelfPaintingLayer() && (child->isTableSection() || child == m_caption)) @@ -555,7 +555,7 @@ void RenderTable::paintObject(PaintInfo& paintInfo, int tx, int ty) void RenderTable::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty) { - if (!shouldPaintWithinRoot(paintInfo)) + if (!paintInfo.shouldPaintWithinRoot(this)) return; int w = width(); diff --git a/WebCore/rendering/RenderTableCell.cpp b/WebCore/rendering/RenderTableCell.cpp index de93107..11f3b52 100644 --- a/WebCore/rendering/RenderTableCell.cpp +++ b/WebCore/rendering/RenderTableCell.cpp @@ -681,7 +681,7 @@ int RenderTableCell::borderHalfBottom(bool outer) const void RenderTableCell::paint(PaintInfo& paintInfo, int tx, int ty) { if (paintInfo.phase == PaintPhaseCollapsedTableBorders && style()->visibility() == VISIBLE) { - if (!shouldPaintWithinRoot(paintInfo)) + if (!paintInfo.shouldPaintWithinRoot(this)) return; tx += x(); @@ -855,7 +855,7 @@ void RenderTableCell::paintCollapsedBorder(GraphicsContext* graphicsContext, int void RenderTableCell::paintBackgroundsBehindCell(PaintInfo& paintInfo, int tx, int ty, RenderObject* backgroundObject) { - if (!shouldPaintWithinRoot(paintInfo)) + if (!paintInfo.shouldPaintWithinRoot(this)) return; if (!backgroundObject) @@ -897,7 +897,7 @@ void RenderTableCell::paintBackgroundsBehindCell(PaintInfo& paintInfo, int tx, i void RenderTableCell::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty) { - if (!shouldPaintWithinRoot(paintInfo)) + if (!paintInfo.shouldPaintWithinRoot(this)) return; RenderTable* tableElt = table(); diff --git a/WebCore/rendering/RenderTextControlSingleLine.cpp b/WebCore/rendering/RenderTextControlSingleLine.cpp index ab56036..84ed8aa 100644 --- a/WebCore/rendering/RenderTextControlSingleLine.cpp +++ b/WebCore/rendering/RenderTextControlSingleLine.cpp @@ -276,7 +276,8 @@ void RenderTextControlSingleLine::layout() // remaining one pixel. It's good for Mac NSStepper because it has // shadow at the bottom. int y = (diff / 2) + (diff % 2); - spinBox->setLocation(spinBox->x() + paddingRight() + borderRight(), y); + int x = width() - borderRight() - paddingRight() - spinBox->width(); + spinBox->setLocation(x, y); } } @@ -368,20 +369,18 @@ void RenderTextControlSingleLine::forwardEvent(Event* event) FloatPoint localPoint = innerTextRenderer->absoluteToLocal(static_cast(event)->absoluteLocation(), false, true); int textRight = innerTextRenderer->borderBoxRect().right(); + #if ENABLE(INPUT_SPEECH) - int cancelRight = textRight; - if (m_cancelButton && m_cancelButton->renderBox()) { - RenderBox* cancelRenderer = m_cancelButton->renderBox(); - cancelRight += cancelRenderer->width() + cancelRenderer->marginLeft() + cancelRenderer->marginRight(); + if (RenderBox* speechBox = m_speechButton ? m_speechButton->renderBox() : 0) { + if (localPoint.x() >= speechBox->x() && localPoint.x() < speechBox->x() + speechBox->width()) { + m_speechButton->defaultEventHandler(event); + return; + } } #endif if (m_resultsButton && localPoint.x() < innerTextRenderer->borderBoxRect().x()) m_resultsButton->defaultEventHandler(event); -#if ENABLE(INPUT_SPEECH) - else if (m_speechButton && localPoint.x() > cancelRight) - m_speechButton->defaultEventHandler(event); -#endif else if (m_cancelButton && localPoint.x() > textRight) m_cancelButton->defaultEventHandler(event); else if (m_outerSpinButton && localPoint.x() > textRight) @@ -618,6 +617,10 @@ void RenderTextControlSingleLine::createSubtreeIfNeeded() m_innerBlock = TextControlInnerElement::create(node()); m_innerBlock->attachInnerElement(node(), createInnerBlockStyle(style()), renderArena()); } + if (inputElement()->hasSpinButton() && !m_outerSpinButton) { + m_outerSpinButton = SpinButtonElement::create(node()); + m_outerSpinButton->attachInnerElement(node(), createOuterSpinButtonStyle(), renderArena()); + } if (inputElement()->isSearchField()) { if (!m_resultsButton) { @@ -722,7 +725,7 @@ PassRefPtr RenderTextControlSingleLine::createInnerBlockStyle(const RefPtr innerBlockStyle = RenderStyle::create(); innerBlockStyle->inheritFrom(startStyle); - innerBlockStyle->setDisplay(BLOCK); + innerBlockStyle->setDisplay(inputElement()->hasSpinButton() ? INLINE_BLOCK : BLOCK); innerBlockStyle->setDirection(LTR); // We don't want the shadow dom to be editable, so we set this block to read-only in case the input itself is editable. diff --git a/WebCore/rendering/RenderTheme.cpp b/WebCore/rendering/RenderTheme.cpp index 407f273..2c6e9da 100644 --- a/WebCore/rendering/RenderTheme.cpp +++ b/WebCore/rendering/RenderTheme.cpp @@ -44,6 +44,10 @@ #include "RenderMeter.h" #endif +#if ENABLE(INPUT_SPEECH) +#include "RenderInputSpeech.h" +#endif + // The methods in this file are shared by all themes on every platform. namespace WebCore { @@ -234,14 +238,14 @@ void RenderTheme::adjustStyle(CSSStyleSelector* selector, RenderStyle* style, El #endif #if ENABLE(INPUT_SPEECH) case InputSpeechButtonPart: - // FIXME: Adjust the speech button's style and sizes. + return adjustInputFieldSpeechButtonStyle(selector, style, e); #endif default: break; } } -bool RenderTheme::paint(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) +bool RenderTheme::paint(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) { // If painting is disabled, but we aren't updating control tints, then just bail. // If we are updating control tints, just schedule a repaint if the theme supports tinting @@ -368,7 +372,7 @@ bool RenderTheme::paint(RenderObject* o, const RenderObject::PaintInfo& paintInf return paintSearchFieldResultsButton(o, paintInfo, r); #if ENABLE(INPUT_SPEECH) case InputSpeechButtonPart: - // FIXME: Add painting code to draw the speech button. + return paintInputFieldSpeechButton(o, paintInfo, r); #endif default: break; @@ -377,7 +381,7 @@ bool RenderTheme::paint(RenderObject* o, const RenderObject::PaintInfo& paintInf return true; // We don't support the appearance, so let the normal background/border paint. } -bool RenderTheme::paintBorderOnly(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) +bool RenderTheme::paintBorderOnly(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) { if (paintInfo.context->paintingDisabled()) return false; @@ -428,7 +432,7 @@ bool RenderTheme::paintBorderOnly(RenderObject* o, const RenderObject::PaintInfo return false; } -bool RenderTheme::paintDecorations(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) +bool RenderTheme::paintDecorations(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) { if (paintInfo.context->paintingDisabled()) return false; @@ -926,6 +930,18 @@ void RenderTheme::adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) { } +#if ENABLE(INPUT_SPEECH) +void RenderTheme::adjustInputFieldSpeechButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* element) const +{ + RenderInputSpeech::adjustInputFieldSpeechButtonStyle(selector, style, element); +} + +bool RenderTheme::paintInputFieldSpeechButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) +{ + return RenderInputSpeech::paintInputFieldSpeechButton(object, paintInfo, rect); +} +#endif + #if ENABLE(METER_TAG) void RenderTheme::adjustMeterStyle(CSSStyleSelector*, RenderStyle* style, Element*) const { @@ -942,7 +958,7 @@ bool RenderTheme::supportsMeter(ControlPart, bool) const return false; } -bool RenderTheme::paintMeter(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) +bool RenderTheme::paintMeter(RenderObject*, const PaintInfo&, const IntRect&) { return true; } diff --git a/WebCore/rendering/RenderTheme.h b/WebCore/rendering/RenderTheme.h index 72a33dc..47217ca 100644 --- a/WebCore/rendering/RenderTheme.h +++ b/WebCore/rendering/RenderTheme.h @@ -76,9 +76,9 @@ public: // This method is called to paint the widget as a background of the RenderObject. A widget's foreground, e.g., the // text of a button, is always rendered by the engine itself. The boolean return value indicates // whether the CSS border/background should also be painted. - bool paint(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); - bool paintBorderOnly(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); - bool paintDecorations(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); + bool paint(RenderObject*, const PaintInfo&, const IntRect&); + bool paintBorderOnly(RenderObject*, const PaintInfo&, const IntRect&); + bool paintDecorations(RenderObject*, const PaintInfo&, const IntRect&); // The remaining methods should be implemented by the platform-specific portion of the theme, e.g., // RenderThemeMac.cpp for Mac OS X. @@ -173,7 +173,7 @@ public: virtual ScrollbarControlSize scrollbarControlSizeForPart(ControlPart) { return RegularScrollbar; } // Method for painting the caps lock indicator - virtual bool paintCapsLockIndicator(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return 0; }; + virtual bool paintCapsLockIndicator(RenderObject*, const PaintInfo&, const IntRect&) { return 0; }; #if ENABLE(PROGRESS_TAG) // Returns the repeat interval of the animation for the progress bar. @@ -216,85 +216,90 @@ protected: #if !USE(NEW_THEME) // Methods for each appearance value. virtual void adjustCheckboxStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintCheckbox(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } + virtual bool paintCheckbox(RenderObject*, const PaintInfo&, const IntRect&) { return true; } virtual void setCheckboxSize(RenderStyle*) const { } virtual void adjustRadioStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintRadio(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } + virtual bool paintRadio(RenderObject*, const PaintInfo&, const IntRect&) { return true; } virtual void setRadioSize(RenderStyle*) const { } virtual void adjustButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } + virtual bool paintButton(RenderObject*, const PaintInfo&, const IntRect&) { return true; } virtual void setButtonSize(RenderStyle*) const { } virtual void adjustInnerSpinButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintInnerSpinButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } + virtual bool paintInnerSpinButton(RenderObject*, const PaintInfo&, const IntRect&) { return true; } virtual void adjustOuterSpinButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintOuterSpinButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } + virtual bool paintOuterSpinButton(RenderObject*, const PaintInfo&, const IntRect&) { return true; } #endif virtual void adjustTextFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintTextField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } + virtual bool paintTextField(RenderObject*, const PaintInfo&, const IntRect&) { return true; } virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintTextArea(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } + virtual bool paintTextArea(RenderObject*, const PaintInfo&, const IntRect&) { return true; } #ifdef ANDROID_LISTBOX_USES_MENU_LIST virtual void adjustListboxStyle(CSSStyleSelector*, RenderStyle*, Element*) const {} #endif virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintMenuList(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } + virtual bool paintMenuList(RenderObject*, const PaintInfo&, const IntRect&) { return true; } virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintMenuListButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } + virtual bool paintMenuListButton(RenderObject*, const PaintInfo&, const IntRect&) { return true; } #if ENABLE(METER_TAG) virtual void adjustMeterStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintMeter(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); + virtual bool paintMeter(RenderObject*, const PaintInfo&, const IntRect&); #endif #if ENABLE(PROGRESS_TAG) virtual void adjustProgressBarStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintProgressBar(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } + virtual bool paintProgressBar(RenderObject*, const PaintInfo&, const IntRect&) { return true; } +#endif + +#if ENABLE(INPUT_SPEECH) + virtual void adjustInputFieldSpeechButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; + virtual bool paintInputFieldSpeechButton(RenderObject*, const PaintInfo&, const IntRect&); #endif virtual void adjustSliderTrackStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } + virtual bool paintSliderTrack(RenderObject*, const PaintInfo&, const IntRect&) { return true; } virtual void adjustSliderThumbStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } + virtual bool paintSliderThumb(RenderObject*, const PaintInfo&, const IntRect&) { return true; } virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintSearchField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } + virtual bool paintSearchField(RenderObject*, const PaintInfo&, const IntRect&) { return true; } virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintSearchFieldCancelButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } + virtual bool paintSearchFieldCancelButton(RenderObject*, const PaintInfo&, const IntRect&) { return true; } virtual void adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintSearchFieldDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } + virtual bool paintSearchFieldDecoration(RenderObject*, const PaintInfo&, const IntRect&) { return true; } virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintSearchFieldResultsDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } + virtual bool paintSearchFieldResultsDecoration(RenderObject*, const PaintInfo&, const IntRect&) { return true; } virtual void adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintSearchFieldResultsButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } - - virtual bool paintMediaFullscreenButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } - virtual bool paintMediaPlayButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } - virtual bool paintMediaMuteButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } - virtual bool paintMediaSeekBackButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } - virtual bool paintMediaSeekForwardButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } - virtual bool paintMediaSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } - virtual bool paintMediaSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } - virtual bool paintMediaVolumeSliderContainer(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } - virtual bool paintMediaVolumeSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } - virtual bool paintMediaVolumeSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } - virtual bool paintMediaRewindButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } - virtual bool paintMediaReturnToRealtimeButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } - virtual bool paintMediaToggleClosedCaptionsButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } - virtual bool paintMediaControlsBackground(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } - virtual bool paintMediaCurrentTime(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } - virtual bool paintMediaTimeRemaining(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return true; } + virtual bool paintSearchFieldResultsButton(RenderObject*, const PaintInfo&, const IntRect&) { return true; } + + virtual bool paintMediaFullscreenButton(RenderObject*, const PaintInfo&, const IntRect&) { return true; } + virtual bool paintMediaPlayButton(RenderObject*, const PaintInfo&, const IntRect&) { return true; } + virtual bool paintMediaMuteButton(RenderObject*, const PaintInfo&, const IntRect&) { return true; } + virtual bool paintMediaSeekBackButton(RenderObject*, const PaintInfo&, const IntRect&) { return true; } + virtual bool paintMediaSeekForwardButton(RenderObject*, const PaintInfo&, const IntRect&) { return true; } + virtual bool paintMediaSliderTrack(RenderObject*, const PaintInfo&, const IntRect&) { return true; } + virtual bool paintMediaSliderThumb(RenderObject*, const PaintInfo&, const IntRect&) { return true; } + virtual bool paintMediaVolumeSliderContainer(RenderObject*, const PaintInfo&, const IntRect&) { return true; } + virtual bool paintMediaVolumeSliderTrack(RenderObject*, const PaintInfo&, const IntRect&) { return true; } + virtual bool paintMediaVolumeSliderThumb(RenderObject*, const PaintInfo&, const IntRect&) { return true; } + virtual bool paintMediaRewindButton(RenderObject*, const PaintInfo&, const IntRect&) { return true; } + virtual bool paintMediaReturnToRealtimeButton(RenderObject*, const PaintInfo&, const IntRect&) { return true; } + virtual bool paintMediaToggleClosedCaptionsButton(RenderObject*, const PaintInfo&, const IntRect&) { return true; } + virtual bool paintMediaControlsBackground(RenderObject*, const PaintInfo&, const IntRect&) { return true; } + virtual bool paintMediaCurrentTime(RenderObject*, const PaintInfo&, const IntRect&) { return true; } + virtual bool paintMediaTimeRemaining(RenderObject*, const PaintInfo&, const IntRect&) { return true; } public: // Methods for state querying diff --git a/WebCore/rendering/RenderThemeChromiumLinux.cpp b/WebCore/rendering/RenderThemeChromiumLinux.cpp index 13c9cd6..c29353d 100644 --- a/WebCore/rendering/RenderThemeChromiumLinux.cpp +++ b/WebCore/rendering/RenderThemeChromiumLinux.cpp @@ -32,9 +32,9 @@ namespace WebCore { -unsigned RenderThemeChromiumLinux::m_thumbInactiveColor = 0xf0ebe5; -unsigned RenderThemeChromiumLinux::m_thumbActiveColor = 0xfaf8f5; -unsigned RenderThemeChromiumLinux::m_trackColor = 0xe3ddd8; +unsigned RenderThemeChromiumLinux::m_thumbInactiveColor = 0xeaeaea; +unsigned RenderThemeChromiumLinux::m_thumbActiveColor = 0xf4f4f4; +unsigned RenderThemeChromiumLinux::m_trackColor = 0xd3d3d3; unsigned RenderThemeChromiumLinux::m_activeSelectionBackgroundColor = 0xff1e90ff; unsigned RenderThemeChromiumLinux::m_activeSelectionForegroundColor = diff --git a/WebCore/rendering/RenderThemeChromiumMac.h b/WebCore/rendering/RenderThemeChromiumMac.h index aaaade0..2309081 100644 --- a/WebCore/rendering/RenderThemeChromiumMac.h +++ b/WebCore/rendering/RenderThemeChromiumMac.h @@ -34,15 +34,15 @@ public: protected: #if ENABLE(VIDEO) virtual void adjustMediaSliderThumbSize(RenderObject*) const; - virtual bool paintMediaPlayButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); - virtual bool paintMediaMuteButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); - virtual bool paintMediaSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); - virtual bool paintMediaControlsBackground(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); + virtual bool paintMediaPlayButton(RenderObject*, const PaintInfo&, const IntRect&); + virtual bool paintMediaMuteButton(RenderObject*, const PaintInfo&, const IntRect&); + virtual bool paintMediaSliderTrack(RenderObject*, const PaintInfo&, const IntRect&); + virtual bool paintMediaControlsBackground(RenderObject*, const PaintInfo&, const IntRect&); virtual bool shouldRenderMediaControlPart(ControlPart, Element*); virtual String extraMediaControlsStyleSheet(); - virtual bool paintMediaVolumeSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); - virtual bool paintMediaVolumeSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); + virtual bool paintMediaVolumeSliderTrack(RenderObject*, const PaintInfo&, const IntRect&); + virtual bool paintMediaVolumeSliderThumb(RenderObject*, const PaintInfo&, const IntRect&); #endif diff --git a/WebCore/rendering/RenderThemeChromiumMac.mm b/WebCore/rendering/RenderThemeChromiumMac.mm index e572b69..a43da1e 100644 --- a/WebCore/rendering/RenderThemeChromiumMac.mm +++ b/WebCore/rendering/RenderThemeChromiumMac.mm @@ -109,22 +109,22 @@ bool RenderThemeChromiumMac::shouldRenderMediaControlPart(ControlPart part, Elem return RenderMediaControlsChromium::shouldRenderMediaControlPart(part, e); } -bool RenderThemeChromiumMac::paintMediaPlayButton(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) +bool RenderThemeChromiumMac::paintMediaPlayButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { return RenderMediaControlsChromium::paintMediaControlsPart(MediaPlayButton, object, paintInfo, rect); } -bool RenderThemeChromiumMac::paintMediaMuteButton(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) +bool RenderThemeChromiumMac::paintMediaMuteButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { return RenderMediaControlsChromium::paintMediaControlsPart(MediaMuteButton, object, paintInfo, rect); } -bool RenderThemeChromiumMac::paintMediaSliderTrack(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) +bool RenderThemeChromiumMac::paintMediaSliderTrack(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { return RenderMediaControlsChromium::paintMediaControlsPart(MediaSlider, object, paintInfo, rect); } -bool RenderThemeChromiumMac::paintMediaControlsBackground(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) +bool RenderThemeChromiumMac::paintMediaControlsBackground(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { return RenderMediaControlsChromium::paintMediaControlsPart(MediaTimelineContainer, object, paintInfo, rect); } @@ -134,12 +134,12 @@ String RenderThemeChromiumMac::extraMediaControlsStyleSheet() return String(mediaControlsChromiumUserAgentStyleSheet, sizeof(mediaControlsChromiumUserAgentStyleSheet)); } -bool RenderThemeChromiumMac::paintMediaVolumeSliderTrack(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) +bool RenderThemeChromiumMac::paintMediaVolumeSliderTrack(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { return RenderMediaControlsChromium::paintMediaControlsPart(MediaVolumeSlider, object, paintInfo, rect); } -bool RenderThemeChromiumMac::paintMediaVolumeSliderThumb(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) +bool RenderThemeChromiumMac::paintMediaVolumeSliderThumb(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { return RenderMediaControlsChromium::paintMediaControlsPart(MediaVolumeSliderThumb, object, paintInfo, rect); } diff --git a/WebCore/rendering/RenderThemeChromiumSkia.cpp b/WebCore/rendering/RenderThemeChromiumSkia.cpp index e3afd1f..d90bbc2 100644 --- a/WebCore/rendering/RenderThemeChromiumSkia.cpp +++ b/WebCore/rendering/RenderThemeChromiumSkia.cpp @@ -235,19 +235,23 @@ IntRect center(const IntRect& original, int width, int height) return IntRect(x, y, width, height); } -bool RenderThemeChromiumSkia::paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect) +bool RenderThemeChromiumSkia::paintCheckbox(RenderObject* o, const PaintInfo& i, const IntRect& rect) { static Image* const checkedImage = Image::loadPlatformResource("linuxCheckboxOn").releaseRef(); static Image* const uncheckedImage = Image::loadPlatformResource("linuxCheckboxOff").releaseRef(); + static Image* const indeterminateImage = Image::loadPlatformResource("linuxCheckboxIndeterminate").releaseRef(); static Image* const disabledCheckedImage = Image::loadPlatformResource("linuxCheckboxDisabledOn").releaseRef(); static Image* const disabledUncheckedImage = Image::loadPlatformResource("linuxCheckboxDisabledOff").releaseRef(); + static Image* const disabledIndeterminateImage = Image::loadPlatformResource("linuxCheckboxDisabledIndeterminate").releaseRef(); Image* image; - if (this->isEnabled(o)) - image = this->isChecked(o) ? checkedImage : uncheckedImage; + if (isIndeterminate(o)) + image = isEnabled(o) ? indeterminateImage : disabledIndeterminateImage; + else if (isChecked(o)) + image = isEnabled(o) ? checkedImage : disabledCheckedImage; else - image = this->isChecked(o) ? disabledCheckedImage : disabledUncheckedImage; + image = isEnabled(o) ? uncheckedImage : disabledUncheckedImage; i.context->drawImage(image, o->style()->colorSpace(), center(rect, widgetStandardHeight, widgetStandardWidth)); return false; @@ -268,7 +272,7 @@ void RenderThemeChromiumSkia::setCheckboxSize(RenderStyle* style) const setSizeIfAuto(style, size); } -bool RenderThemeChromiumSkia::paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect) +bool RenderThemeChromiumSkia::paintRadio(RenderObject* o, const PaintInfo& i, const IntRect& rect) { static Image* const checkedImage = Image::loadPlatformResource("linuxRadioOn").releaseRef(); static Image* const uncheckedImage = Image::loadPlatformResource("linuxRadioOff").releaseRef(); @@ -302,7 +306,7 @@ static SkColor brightenColor(double h, double s, double l, float brightenAmount) return makeRGBAFromHSLA(h, s, l, 1.0); } -static void paintButtonLike(RenderTheme* theme, RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect) +static void paintButtonLike(RenderTheme* theme, RenderObject* o, const PaintInfo& i, const IntRect& rect) { SkCanvas* const canvas = i.context->platformContext()->canvas(); SkPaint paint; @@ -360,7 +364,7 @@ static void paintButtonLike(RenderTheme* theme, RenderObject* o, const RenderObj canvas->drawPoint(right - 2, bottom - 2, paint); } -bool RenderThemeChromiumSkia::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect) +bool RenderThemeChromiumSkia::paintButton(RenderObject* o, const PaintInfo& i, const IntRect& rect) { paintButtonLike(this, o, i, rect); return false; @@ -375,12 +379,12 @@ void RenderThemeChromiumSkia::adjustButtonStyle(CSSStyleSelector*, RenderStyle* } -bool RenderThemeChromiumSkia::paintTextField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect) +bool RenderThemeChromiumSkia::paintTextField(RenderObject* o, const PaintInfo& i, const IntRect& rect) { return true; } -bool RenderThemeChromiumSkia::paintTextArea(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) +bool RenderThemeChromiumSkia::paintTextArea(RenderObject* o, const PaintInfo& i, const IntRect& r) { return paintTextField(o, i, r); } @@ -391,7 +395,7 @@ void RenderThemeChromiumSkia::adjustSearchFieldStyle(CSSStyleSelector*, RenderSt style->setLineHeight(RenderStyle::initialLineHeight()); } -bool RenderThemeChromiumSkia::paintSearchField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) +bool RenderThemeChromiumSkia::paintSearchField(RenderObject* o, const PaintInfo& i, const IntRect& r) { return paintTextField(o, i, r); } @@ -417,7 +421,7 @@ IntRect RenderThemeChromiumSkia::convertToPaintingRect(RenderObject* inputRender return partRect; } -bool RenderThemeChromiumSkia::paintSearchFieldCancelButton(RenderObject* cancelButtonObject, const RenderObject::PaintInfo& paintInfo, const IntRect& r) +bool RenderThemeChromiumSkia::paintSearchFieldCancelButton(RenderObject* cancelButtonObject, const PaintInfo& paintInfo, const IntRect& r) { // Get the renderer of