Changeset 21925 in webkit
- Timestamp:
- May 31, 2007 6:52:31 PM (17 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r21924 r21925 1 2007-05-31 Rob Buis <buis@kde.org> 2 3 Reviewed by Darin. 4 5 http://bugs.webkit.org/show_bug.cgi?id=11272 6 Implement currentScale(), setCurrentScale() and currentTranslate() in SVGSVGElement 7 8 Allow zooming and panning, thereby implementing the above methods. 9 10 * ksvg2/svg/SVGDocument.cpp: 11 (WebCore::SVGDocument::zoomEnabled): 12 (WebCore::SVGDocument::startPan): 13 (WebCore::SVGDocument::updatePan): 14 * ksvg2/svg/SVGDocument.h: 15 * ksvg2/svg/SVGSVGElement.cpp: 16 (WebCore::SVGSVGElement::currentScale): 17 (WebCore::SVGSVGElement::setCurrentScale): 18 (WebCore::SVGSVGElement::currentTranslate): 19 (WebCore::SVGSVGElement::setCurrentTranslate): 20 * ksvg2/svg/SVGSVGElement.h: 21 * page/EventHandler.cpp: 22 (WebCore::EventHandler::EventHandler): 23 (WebCore::EventHandler::handleMousePressEvent): 24 (WebCore::EventHandler::handleMouseMoveEvent): 25 (WebCore::EventHandler::handleMouseReleaseEvent): 26 * page/EventHandler.h: 27 * page/Frame.cpp: 28 (WebCore::Frame::setZoomFactor): 29 * rendering/RenderSVGContainer.cpp: 30 (WebCore::RenderSVGContainer::layout): 31 (WebCore::RenderSVGContainer::paint): 32 (WebCore::RenderSVGContainer::absoluteTransform): 33 * rendering/RenderSVGContainer.h: 34 1 35 2007-05-31 Eric Seidel <eric@webkit.org> 2 36 -
trunk/WebCore/ksvg2/svg/SVGDocument.cpp
r21179 r21925 1 1 /* 2 2 Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org> 3 2004, 2005, 2006 Rob Buis <buis@kde.org>3 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 4 4 5 5 This file is part of the KDE project … … 27 27 #include "EventNames.h" 28 28 #include "ExceptionCode.h" 29 #include "FrameView.h" 30 #include "RenderView.h" 29 31 #include "SVGElement.h" 30 32 #include "SVGNames.h" 31 33 #include "SVGSVGElement.h" 32 34 #include "SVGZoomEvent.h" 35 #include "SVGZoomAndPan.h" 33 36 34 37 namespace WebCore { … … 75 78 } 76 79 80 bool SVGDocument::zoomAndPanEnabled() const 81 { 82 if (rootElement()) 83 return rootElement()->zoomAndPan() == SVGZoomAndPan::SVG_ZOOMANDPAN_MAGNIFY; 84 85 return false; 86 } 87 88 void SVGDocument::startPan(const FloatPoint& start) 89 { 90 if (rootElement()) 91 m_translate = FloatPoint(start.x() - rootElement()->currentTranslate().x(), rootElement()->currentTranslate().y() + start.y()); 92 } 93 94 void SVGDocument::updatePan(const FloatPoint& pos) const 95 { 96 if (rootElement()) { 97 rootElement()->setCurrentTranslate(FloatPoint(pos.x() - m_translate.x(), m_translate.y() - pos.y())); 98 if (renderer()) 99 renderer()->repaint(); 100 } 101 } 102 77 103 } 78 104 -
trunk/WebCore/ksvg2/svg/SVGDocument.h
r21179 r21925 1 1 /* 2 2 Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org> 3 2004, 2005, 2006 Rob Buis <buis@kde.org>3 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 4 4 5 5 This file is part of the KDE project … … 26 26 27 27 #include "Document.h" 28 #include "FloatPoint.h" 28 29 29 30 namespace WebCore { 30 31 32 class DOMImplementation; 31 33 class SVGElement; 32 34 class SVGSVGElement; 33 class DOMImplementation;34 35 35 36 class SVGDocument : public Document { … … 46 47 void dispatchZoomEvent(float prevScale, float newScale); 47 48 void dispatchScrollEvent(); 49 50 virtual bool zoomAndPanEnabled() const; 51 52 void startPan(const FloatPoint& start); 53 void updatePan(const FloatPoint& pos) const; 54 55 private: 56 FloatPoint m_translate; 48 57 }; 49 58 -
trunk/WebCore/ksvg2/svg/SVGSVGElement.cpp
r21820 r21925 159 159 float SVGSVGElement::currentScale() const 160 160 { 161 // FIXME: Return the current zoom/scale value (see bug 11272) 162 return 1.; 161 if (document() && document()->frame()) 162 return document()->frame()->zoomFactor() / 100.0f; 163 return 1.0f; 163 164 } 164 165 165 166 void SVGSVGElement::setCurrentScale(float scale) 166 167 { 167 // FIXME: Set the current zoom/scale value (see bug 11272) 168 if (document() && document()->frame()) 169 document()->frame()->setZoomFactor(scale / 100.0f); 168 170 } 169 171 170 172 FloatPoint SVGSVGElement::currentTranslate() const 171 173 { 172 // FIXME: Return the current pan/translate value (see bug 11272) 173 return FloatPoint(); 174 return m_translation; 175 } 176 177 void SVGSVGElement::setCurrentTranslate(const FloatPoint &translation) 178 { 179 m_translation = translation; 174 180 } 175 181 … … 399 405 } 400 406 401 void SVGSVGElement::setZoomAndPan(unsigned short zoomAndPan)402 {403 SVGZoomAndPan::setZoomAndPan(zoomAndPan);404 //canvasView()->enableZoomAndPan(zoomAndPan == SVG_ZOOMANDPAN_MAGNIFY);405 }406 407 407 void SVGSVGElement::pauseAnimations() 408 408 { -
trunk/WebCore/ksvg2/svg/SVGSVGElement.h
r19855 r21925 1 1 /* 2 2 Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 3 2004, 2005, 2006 Rob Buis <buis@kde.org>3 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 4 4 5 5 This file is part of the KDE project … … 78 78 79 79 FloatPoint currentTranslate() const; 80 void setCurrentTranslate(const FloatPoint&); 80 81 81 82 TimeScheduler* timeScheduler() { return m_timeScheduler; } … … 120 121 virtual void removedFromDocument(); 121 122 122 // 'virtual SVGZoomAndPan functions123 virtual void setZoomAndPan(unsigned short zoomAndPan);124 125 123 virtual void attributeChanged(Attribute*, bool preserveDecls = false); 126 124 … … 145 143 bool m_useCurrentView; 146 144 TimeScheduler* m_timeScheduler; 145 FloatPoint m_translation; 147 146 }; 148 147 -
trunk/WebCore/page/EventHandler.cpp
r21749 r21925 62 62 #if ENABLE(SVG) 63 63 #include "SVGCursorElement.h" 64 #include "SVGDocument.h" 64 65 #include "SVGLength.h" 65 66 #include "SVGNames.h" … … 100 101 , m_mouseDownMayStartAutoscroll(false) 101 102 , m_mouseDownWasInSubframe(false) 103 #if ENABLE(SVG) 104 , m_svgPan(false) 105 #endif 102 106 , m_resizeLayer(0) 103 107 , m_capturingMouseEventsNode(0) … … 276 280 if (passWidgetMouseDownEventToWidget(event)) 277 281 return true; 282 283 #if ENABLE(SVG) 284 if (m_frame->document()->isSVGDocument() && 285 static_cast<SVGDocument*>(m_frame->document())->zoomAndPanEnabled()) { 286 if (event.event().shiftKey() && singleClick) { 287 m_svgPan = true; 288 static_cast<SVGDocument*>(m_frame->document())->startPan(event.event().pos()); 289 return true; 290 } 291 } 292 #endif 278 293 279 294 // We don't do this at the start of mouse down handling, … … 893 908 m_hoverTimer.stop(); 894 909 910 #if ENABLE(SVG) 911 if (m_svgPan) { 912 static_cast<SVGDocument*>(m_frame->document())->updatePan(m_currentMousePosition); 913 return true; 914 } 915 #endif 895 916 if (m_frameSetBeingResized) 896 917 return dispatchMouseEvent(mousemoveEvent, m_frameSetBeingResized.get(), false, 0, mouseEvent, false); … … 972 993 m_mousePressed = false; 973 994 m_currentMousePosition = mouseEvent.pos(); 995 996 #if ENABLE(SVG) 997 if (m_svgPan) { 998 m_svgPan = false; 999 return true; 1000 } 1001 #endif 974 1002 975 1003 if (m_frameSetBeingResized) -
trunk/WebCore/page/EventHandler.h
r21042 r21925 269 269 bool m_mouseDownMayStartAutoscroll; 270 270 bool m_mouseDownWasInSubframe; 271 #if ENABLE(SVG) 272 bool m_svgPan; 273 #endif 271 274 272 275 RenderLayer* m_resizeLayer; -
trunk/WebCore/page/Frame.cpp
r21773 r21925 642 642 643 643 d->m_zoomFactor = percent; 644 645 if (d->m_doc) 644 if (d->m_doc) { 645 #if ENABLE(SVG) 646 if (d->m_doc->isSVGDocument()) { 647 if (d->m_doc->renderer()) 648 d->m_doc->renderer()->repaint(); 649 return; 650 } 651 #endif 646 652 d->m_doc->recalcStyle(Node::Force); 653 } 647 654 648 655 for (Frame* child = tree()->firstChild(); child; child = child->tree()->nextSibling()) -
trunk/WebCore/rendering/RenderSVGContainer.cpp
r21820 r21925 118 118 119 119 m_absoluteBounds = absoluteClippedOverflowRect(); 120 if (!parent()->isSVGContainer()) { 121 SVGSVGElement* svg = static_cast<SVGSVGElement*>(element()); 122 m_width = float(m_width) * svg->currentScale(); 123 m_height = float(m_height) * svg->currentScale(); 124 } 120 125 121 126 if (selfNeedsLayout() && checkForRepaint) … … 169 174 } 170 175 parentX = parentY = 0; 176 SVGSVGElement* svg = static_cast<SVGSVGElement*>(element()); 177 paintInfo.context->concatCTM(AffineTransform().scale(svg->currentScale())); 171 178 } else { 172 179 // Only the root <svg> element should need any translations using the HTML/CSS system … … 184 191 paintInfo.context->concatCTM(AffineTransform().translate(viewport().x(), viewport().y())); 185 192 } 186 187 193 if (!localTransform().isIdentity()) 188 194 paintInfo.context->concatCTM(localTransform()); 195 if (!parent()->isSVGContainer()) { 196 SVGSVGElement* svg = static_cast<SVGSVGElement*>(element()); 197 paintInfo.context->concatCTM(AffineTransform().translate(svg->currentTranslate().x(), svg->currentTranslate().y())); 198 } 189 199 190 200 FloatRect strokeBBox = relativeBBox(true); … … 342 352 { 343 353 AffineTransform ctm = RenderContainer::absoluteTransform(); 354 if (!parent()->isSVGContainer()) { 355 SVGSVGElement* svg = static_cast<SVGSVGElement*>(element()); 356 ctm.scale(svg->currentScale()); 357 ctm.translate(svg->currentTranslate().x(), svg->currentTranslate().y()); 358 } 344 359 ctm.translate(viewport().x(), viewport().y()); 345 360 return viewportTransform() * ctm;
Note: See TracChangeset
for help on using the changeset viewer.