Changeset 17052 in webkit
- Timestamp:
- Oct 13, 2006 6:12:32 PM (18 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r17051 r17052 1 2006-10-13 Beth Dakin <bdakin@apple.com> 2 3 Patch written mostly by Ken Kraisler, but also by me. 4 5 Reviewed by Hyatt. 6 7 Fix for http://bugs.webkit.org/show_bug.cgi?id=10216 and <rdar:// 8 problem/3391162> PDF created by printing should have live 9 hyperlinks 10 11 * platform/GraphicsContext.cpp: 12 (WebCore::GraphicsContext::focusRingBoundingRect): 13 * platform/GraphicsContext.h: 14 * platform/cairo/GraphicsContextCairo.cpp: 15 (WebCore::GraphicsContext::setURLForRect): 16 * platform/cg/GraphicsContextCG.cpp: 17 (WebCore::GraphicsContext::setURLForRect): Implement method to add 18 URL link to PDF document. 19 * rendering/InlineFlowBox.cpp: 20 (WebCore::InlineFlowBox::paint): Ask hasOutline() instead of 21 querying the outline width 22 * rendering/RenderBlock.cpp: 23 (WebCore::RenderBlock::paintObject): Same as above. 24 * rendering/RenderFlow.cpp: 25 (WebCore::RenderFlow::paintLines): Call the new paintOutline() 26 (WebCore::RenderFlow::paintOutline): Take care of focus ring and 27 pdf url rects, and outline painting. 28 * rendering/RenderFlow.h: 29 * rendering/RenderObject.cpp: 30 (WebCore::RenderObject::addPDFURLRect): Declaration to apply a PDF 31 link to a rectanglular region. 32 (WebCore::RenderObject::paintOutline): Take care of pdf rects as 33 well as focus ring painting. 34 * rendering/RenderObject.h: 35 (WebCore::RenderObject::hasOutlineAnnotation): Returns true is the 36 element is a link and we are printing. 37 (WebCore::RenderObject::hasOutline): Returns true is the style has 38 an outline and hasOutlineAnnotation() is true. 39 * rendering/RenderStyle.h: 40 (WebCore::RenderStyle::hasOutline): Returns true if outlineWidth is 41 greater than 0 and outlineStyle is greater than BHIDDEN. 42 1 43 2006-10-13 Justin Garcia <justin.garcia@apple.com> 2 44 -
trunk/WebCore/platform/GraphicsContext.cpp
r16250 r17052 217 217 } 218 218 219 IntRect GraphicsContext::focusRingBoundingRect() 220 { 221 IntRect result = IntRect(0, 0, 0, 0); 222 223 const Vector<IntRect>& rects = focusRingRects(); 224 unsigned rectCount = rects.size(); 225 for (unsigned i = 0; i < rectCount; i++) 226 result.unite(rects[i]); 227 228 return result; 229 } 230 219 231 void GraphicsContext::addFocusRingRect(const IntRect& rect) 220 232 { -
trunk/WebCore/platform/GraphicsContext.h
r17046 r17052 61 61 class GraphicsContextPrivate; 62 62 class GraphicsContextPlatformPrivate; 63 class KURL; 63 64 class Path; 64 65 class TextRun; … … 146 147 void drawFocusRing(const Color&); 147 148 void clearFocusRing(); 149 IntRect focusRingBoundingRect(); 148 150 149 151 void setLineWidth(float); … … 162 164 void translate(float x, float y); 163 165 IntPoint origin(); 166 167 void setURLForRect(const KURL&, const IntRect&); 164 168 165 169 void concatCTM(const AffineTransform&); -
trunk/WebCore/platform/cairo/GraphicsContextCairo.cpp
r16826 r17052 461 461 } 462 462 463 void GraphicsContext::setURLForRect(const KURL& link, const IntRect& destRect) 464 { 465 } 466 463 467 } // namespace WebCore 464 468 -
trunk/WebCore/platform/cg/GraphicsContextCG.cpp
r17046 r17052 31 31 32 32 #include "AffineTransform.h" 33 #include "KURL.h" 33 34 #include "Path.h" 34 35 #include <wtf/MathExtras.h> … … 778 779 } 779 780 781 void GraphicsContext::setURLForRect(const KURL& link, const IntRect& destRect) 782 { 783 if (paintingDisabled()) 784 return; 785 786 CFURLRef urlRef = link.createCFURL(); 787 if (urlRef) { 788 CGContextRef context = platformContext(); 789 790 // Get the bounding box to handle clipping. 791 CGRect box = CGContextGetClipBoundingBox(context); 792 793 IntRect intBox((int)box.origin.x, (int)box.origin.y, (int)box.size.width, (int)box.size.height); 794 IntRect rect = destRect; 795 rect.intersect(intBox); 796 797 CGPDFContextSetURLForRect(context, urlRef, 798 CGRectApplyAffineTransform(rect, CGContextGetCTM(context))); 799 800 CFRelease(urlRef); 801 } 802 } 803 780 804 } 781 805 -
trunk/WebCore/rendering/InlineFlowBox.cpp
r16826 r17052 551 551 // Add ourselves to the paint info struct's list of inlines that need to paint their 552 552 // outlines. 553 if (object()->style()->visibility() == VISIBLE && object()-> style()->outlineWidth() > 0&&553 if (object()->style()->visibility() == VISIBLE && object()->hasOutline() && 554 554 !object()->isInlineContinuation() && !isRootInlineBox()) { 555 555 i.outlineObjects->add(flowObject()); -
trunk/WebCore/rendering/RenderBlock.cpp
r16815 r17052 1364 1364 // 5. paint outline. 1365 1365 if (!inlineFlow && (paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseSelfOutline) 1366 && style()->outlineWidth() && style()->visibility() == VISIBLE)1367 paintOutline(i.p, _tx, _ty, width(), height(), style());1366 && hasOutline() && style()->visibility() == VISIBLE) 1367 RenderObject::paintOutline(i.p, _tx, _ty, width(), height(), style()); 1368 1368 1369 1369 // 6. paint caret. -
trunk/WebCore/rendering/RenderFlow.cpp
r16044 r17052 411 411 for (RenderFlowSequencedSet::iterator it = info.outlineObjects->begin(); it != end; ++it) { 412 412 RenderFlow* flow = *it; 413 if (flow->style()->outlineStyleIsAuto()) 414 flow->paintFocusRing(info.p, _tx, _ty); 415 else 416 flow->paintOutlines(info.p, _tx, _ty); 413 flow->paintOutline(info.p, _tx, _ty); 417 414 } 418 415 info.outlineObjects->clear(); … … 688 685 } 689 686 690 void RenderFlow::paintFocusRing(GraphicsContext* p, int tx, int ty) 691 { 692 int ow = style()->outlineWidth(); 693 Color oc = style()->outlineColor(); 694 if (!oc.isValid()) 695 oc = style()->color(); 696 697 p->initFocusRing(ow, style()->outlineOffset()); 698 addFocusRingRects(p, tx, ty); 699 p->drawFocusRing(oc); 700 p->clearFocusRing(); 701 } 702 703 void RenderFlow::paintOutlines(GraphicsContext* p, int _tx, int _ty) 704 { 705 if (style()->outlineStyle() <= BHIDDEN) 687 void RenderFlow::paintOutline(GraphicsContext* p, int _tx, int _ty) 688 { 689 if (!hasOutline()) 706 690 return; 707 691 692 if (style()->outlineStyleIsAuto() || hasOutlineAnnotation()) { 693 int ow = style()->outlineWidth(); 694 Color oc = style()->outlineColor(); 695 if (!oc.isValid()) 696 oc = style()->color(); 697 698 p->initFocusRing(ow, style()->outlineOffset()); 699 addFocusRingRects(p, _tx, _ty); 700 if (style()->outlineStyleIsAuto()) 701 p->drawFocusRing(oc); 702 else 703 addPDFURLRect(p, p->focusRingBoundingRect()); 704 p->clearFocusRing(); 705 } 706 707 if (style()->outlineStyleIsAuto() || style()->outlineStyle() <= BHIDDEN) 708 return; 709 708 710 DeprecatedPtrList <IntRect> rects; 709 711 rects.setAutoDelete(true); 710 712 711 713 rects.append(new IntRect); 712 for (InlineRunBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) {714 for (InlineRunBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) 713 715 rects.append(new IntRect(curr->xPos(), curr->yPos(), curr->width(), curr->height())); 714 } 716 715 717 rects.append(new IntRect); 716 718 717 719 for (unsigned int i = 1; i < rects.count() - 1; i++) 718 720 paintOutlineForLine(p, _tx, _ty, *rects.at(i-1), *rects.at(i), *rects.at(i+1)); -
trunk/WebCore/rendering/RenderFlow.h
r15696 r17052 88 88 89 89 virtual void addFocusRingRects(GraphicsContext*, int _tx, int _ty); 90 void paintFocusRing(GraphicsContext*, int tx, int ty);91 90 void paintOutlineForLine(GraphicsContext*, int tx, int ty, const IntRect &prevLine, const IntRect &thisLine, const IntRect &nextLine); 92 void paintOutline s(GraphicsContext*, int tx, int ty);91 void paintOutline(GraphicsContext*, int tx, int ty); 93 92 94 93 protected: -
trunk/WebCore/rendering/RenderObject.cpp
r17018 r17052 34 34 #include "CounterResetNode.h" 35 35 #include "Decoder.h" 36 #include "Document.h"37 36 #include "Element.h" 38 37 #include "EventNames.h" … … 42 41 #include "HTMLNames.h" 43 42 #include "HTMLOListElement.h" 43 #include "KURL.h" 44 44 #include "Position.h" 45 45 #include "RenderArena.h" … … 1640 1640 } 1641 1641 1642 void RenderObject::addPDFURLRect(GraphicsContext* p, IntRect rect) 1643 { 1644 Node* node = element(); 1645 if (node) { 1646 if (p) { 1647 if (rect.width() > 0 && rect.height() > 0) { 1648 Element* element = static_cast<Element*>(node); 1649 String href; 1650 if (element->isLink()) 1651 href = element->getAttribute(hrefAttr); 1652 1653 if (!href.isNull()) { 1654 KURL link = element->document()->completeURL(href.deprecatedString()); 1655 if (link.isValid()) 1656 p->setURLForRect(link, rect); 1657 } 1658 } 1659 } 1660 } 1661 } 1662 1663 1642 1664 void RenderObject::addFocusRingRects(GraphicsContext* p, int _tx, int _ty) 1643 1665 { … … 1657 1679 void RenderObject::paintOutline(GraphicsContext* p, int _tx, int _ty, int w, int h, const RenderStyle* style) 1658 1680 { 1681 if (!hasOutline()) 1682 return; 1683 1659 1684 int ow = style->outlineWidth(); 1660 if(!ow) return;1661 1685 1662 1686 EBorderStyle os = style->outlineStyle(); 1663 if (os <= BHIDDEN)1664 return;1665 1687 1666 1688 Color oc = style->outlineColor(); … … 1670 1692 int offset = style->outlineOffset(); 1671 1693 1672 if (style->outlineStyleIsAuto() ) {1694 if (style->outlineStyleIsAuto() || hasOutlineAnnotation()) { 1673 1695 if (!theme()->supportsFocusRing(style)) { 1674 1696 // Only paint the focus ring by hand if the theme isn't able to draw the focus ring. 1675 1697 p->initFocusRing(ow, offset); 1676 addFocusRingRects(p, _tx, _ty); 1698 if (style->outlineStyleIsAuto()) 1699 addFocusRingRects(p, _tx, _ty); 1700 else 1701 addPDFURLRect(p, p->focusRingBoundingRect()); 1677 1702 p->drawFocusRing(oc); 1678 1703 p->clearFocusRing(); 1679 1704 } 1705 } 1706 1707 if (style->outlineStyleIsAuto() || style->outlineStyle() <= BHIDDEN) 1680 1708 return; 1681 }1682 1709 1683 1710 _tx -= offset; -
trunk/WebCore/rendering/RenderObject.h
r17002 r17052 30 30 #include "CachedResourceClient.h" 31 31 #include "DeprecatedValueList.h" 32 #include "Document.h" 32 33 #include "RenderStyle.h" 33 34 #include "ScrollBar.h" … … 347 348 Node* node() const { return m_node; } 348 349 350 bool hasOutlineAnnotation() { return element() && element()->isLink() && document()->printing(); } 351 bool hasOutline() { return style()->hasOutline() || hasOutlineAnnotation(); } 352 349 353 /** 350 354 * returns the object containing this one. can be different from parent for … … 703 707 IntRect paintingRootRect(IntRect& topLevelRect); 704 708 709 void addPDFURLRect(GraphicsContext* p, IntRect rect); 710 705 711 virtual void addFocusRingRects(GraphicsContext*, int tx, int ty); 706 712 -
trunk/WebCore/rendering/RenderStyle.h
r16721 r17052 1250 1250 return background->m_outline.width; 1251 1251 } 1252 bool hasOutline() const { return outlineWidth() > 0 && outlineStyle() > BHIDDEN; } 1252 1253 EBorderStyle outlineStyle() const { return background->m_outline.style(); } 1253 1254 bool outlineStyleIsAuto() const { return background->m_outline._auto; }
Note: See TracChangeset
for help on using the changeset viewer.