Changeset 18819 in webkit
- Timestamp:
- Jan 12, 2007, 2:53:40 PM (18 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r18816 r18819 1 2007-01-12 David Hyatt <hyatt@apple.com> 2 3 Fix for bug 11598, implement lightweight control clipping mechanism for 4 buttons, list boxes, and dropdown lists. Make sure list box respects 5 scrollLeft/Top/Width/Height as well as clientWidth/Height. 6 7 Fix bugs in RenderStyle::diff. CursorData was not being compared properly. 8 vertical-align had a non-inline display check that was wrong (preventing 9 dynamic changes to keyword-based vertical-align from working). 10 11 Reviewed by mitz 12 13 * page/EventHandler.cpp: 14 (WebCore::EventHandler::selectClosestWordFromMouseEvent): 15 * rendering/RenderBlock.cpp: 16 (WebCore::RenderBlock::layout): 17 (WebCore::RenderBlock::layoutBlock): 18 (WebCore::RenderBlock::determineHorizontalPosition): 19 (WebCore::RenderBlock::layoutBlockChildren): 20 (WebCore::RenderBlock::paint): 21 (WebCore::RenderBlock::fillHorizontalSelectionGap): 22 (WebCore::RenderBlock::nodeAtPoint): 23 (WebCore::RenderBlock::layoutColumns): 24 * rendering/RenderBox.cpp: 25 (WebCore::RenderBox::computeAbsoluteRepaintRect): 26 * rendering/RenderBox.h: 27 * rendering/RenderButton.cpp: 28 (WebCore::RenderButton::setStyle): 29 (WebCore::RenderButton::controlClipRect): 30 * rendering/RenderButton.h: 31 (WebCore::RenderButton::hasControlClip): 32 * rendering/RenderFlexibleBox.cpp: 33 (WebCore::RenderFlexibleBox::layoutBlock): 34 (WebCore::RenderFlexibleBox::layoutHorizontalBox): 35 (WebCore::RenderFlexibleBox::layoutVerticalBox): 36 * rendering/RenderFlow.cpp: 37 (WebCore::RenderFlow::addFocusRingRects): 38 * rendering/RenderListBox.cpp: 39 (WebCore::RenderListBox::itemBoundingBoxRect): 40 (WebCore::RenderListBox::paintObject): 41 (WebCore::RenderListBox::itemHeight): 42 (WebCore::RenderListBox::verticalScrollbarWidth): 43 (WebCore::RenderListBox::scrollWidth): 44 (WebCore::RenderListBox::scrollHeight): 45 (WebCore::RenderListBox::scrollLeft): 46 (WebCore::RenderListBox::setScrollLeft): 47 (WebCore::RenderListBox::scrollTop): 48 (WebCore::RenderListBox::setScrollTop): 49 (WebCore::RenderListBox::controlClipRect): 50 * rendering/RenderListBox.h: 51 (WebCore::RenderListBox::hasControlClip): 52 * rendering/RenderMenuList.cpp: 53 (WebCore::RenderMenuList::setStyle): 54 (WebCore::RenderMenuList::controlClipRect): 55 * rendering/RenderMenuList.h: 56 (WebCore::RenderMenuList::hasControlClip): 57 * rendering/RenderObject.cpp: 58 (WebCore::RenderObject::verticalScrollbarWidth): 59 (WebCore::RenderObject::horizontalScrollbarHeight): 60 (WebCore::RenderObject::clientWidth): 61 (WebCore::RenderObject::clientHeight): 62 (WebCore::RenderObject::setStyle): 63 * rendering/RenderObject.h: 64 (WebCore::RenderObject::hasControlClip): 65 (WebCore::RenderObject::controlClipRect): 66 (WebCore::RenderObject::contentWidth): 67 (WebCore::RenderObject::contentHeight): 68 * rendering/RenderStyle.cpp: 69 (WebCore::StyleVisualData::StyleVisualData): 70 (WebCore::cursorDataEqvuialent): 71 (WebCore::StyleInheritedData::operator==): 72 (WebCore::CursorList::operator==): 73 (WebCore::RenderStyle::diff): 74 * rendering/RenderStyle.h: 75 (WebCore::LengthBox::operator!=): 76 (WebCore::StyleVisualData::operator==): 77 (WebCore::CursorData::operator==): 78 (WebCore::CursorData::operator!=): 79 (WebCore::CursorList::operator!=): 80 (WebCore::RenderStyle::setTableLayout): 81 * rendering/bidi.cpp: 82 (WebCore::RenderBlock::layoutInlineChildren): 83 1 84 2007-01-12 David Hyatt <hyatt@apple.com> 2 85 -
trunk/WebCore/page/EventHandler.cpp
r18769 r18819 137 137 newSelection.expandUsingGranularity(WordGranularity); 138 138 } 139 }140 141 if (newSelection.isRange()) {142 m_frame->setSelectionGranularity(WordGranularity);143 m_beganSelectingText = true;144 }145 146 if (m_frame->shouldChangeSelection(newSelection))147 m_frame->selectionController()->setSelection(newSelection);139 140 if (newSelection.isRange()) { 141 m_frame->setSelectionGranularity(WordGranularity); 142 m_beganSelectingText = true; 143 } 144 145 if (m_frame->shouldChangeSelection(newSelection)) 146 m_frame->selectionController()->setSelection(newSelection); 147 } 148 148 } 149 149 -
trunk/WebCore/rendering/RenderBlock.cpp
r18799 r18819 437 437 // layoutBlock(). 438 438 layoutBlock(false); 439 440 // It's safe to check for control clip here, since controls can never be table cells. 441 if (hasControlClip()) { 442 // Because of the lightweight clip, there can never be any overflow from children. 443 m_overflowWidth = m_width; 444 m_overflowHeight = m_height; 445 m_overflowLeft = 0; 446 m_overflowTop = 0; 447 } 439 448 } 440 449 … … 517 526 518 527 // Expand our intrinsic height to encompass floats. 519 int toAdd = borderBottom() + paddingBottom(); 520 if (includeHorizontalScrollbarSize()) 521 toAdd += m_layer->horizontalScrollbarHeight(); 528 int toAdd = borderBottom() + paddingBottom() + horizontalScrollbarHeight(); 522 529 if (floatBottom() > (m_height - toAdd) && (isInlineBlockOrInlineTable() || isFloatingOrPositioned() || hasOverflowClip() || 523 530 (parent() && parent()->isFlexibleBox()))) … … 980 987 child->setPos(chPos, child->yPos()); 981 988 } else { 982 int xPos = m_width - borderRight() - paddingRight() - (includeVerticalScrollbarSize() ? m_layer->verticalScrollbarWidth() : 0);989 int xPos = m_width - borderRight() - paddingRight() - verticalScrollbarWidth(); 983 990 int chPos = xPos - (child->width() + child->marginRight()); 984 991 if (child->avoidsFloats()) { … … 1057 1064 { 1058 1065 int top = borderTop() + paddingTop(); 1059 int bottom = borderBottom() + paddingBottom() + (includeHorizontalScrollbarSize() ? m_layer->horizontalScrollbarHeight() : 0);1066 int bottom = borderBottom() + paddingBottom() + horizontalScrollbarHeight(); 1060 1067 1061 1068 m_height = m_overflowHeight = top; … … 1303 1310 } 1304 1311 1305 return paintObject(paintInfo, tx, ty); 1312 // Push a clip. 1313 bool useControlClip = paintInfo.phase == PaintPhaseForeground && hasControlClip(); 1314 if (useControlClip) { 1315 IntRect clipRect(controlClipRect(tx, ty)); 1316 if (clipRect.isEmpty()) 1317 return; 1318 paintInfo.context->save(); 1319 paintInfo.context->clip(clipRect); 1320 } 1321 1322 paintObject(paintInfo, tx, ty); 1323 1324 // Pop the clip. 1325 if (useControlClip) 1326 paintInfo.context->restore(); 1306 1327 } 1307 1328 … … 1734 1755 return IntRect(); 1735 1756 IntRect gapRect(xPos, yPos, width, height); 1736 if (paintInfo )1757 if (paintInfo && selObj->style()->visibility() == VISIBLE) 1737 1758 paintInfo->context->fillRect(gapRect, selObj->selectionBackgroundColor()); 1738 1759 return gapRect; … … 2635 2656 int tx = _tx + m_x; 2636 2657 int ty = _ty + m_y + borderTopExtra(); 2637 2658 2638 2659 if (!inlineFlow && !isRenderView()) { 2639 2660 // Check if we need to do anything at all. … … 2660 2681 } 2661 2682 2662 // Hit test descendants first. 2663 int scrolledX = tx; 2664 int scrolledY = ty; 2665 if (hasOverflowClip()) 2666 m_layer->subtractScrollOffset(scrolledX, scrolledY); 2667 2668 // Hit test contents if we don't have columns. 2669 if (!hasColumns() && hitTestContents(request, result, _x, _y, scrolledX, scrolledY, hitTestAction)) 2670 return true; 2671 2672 // Hit test our columns if we do have them. 2673 if (hasColumns() && hitTestColumns(request, result, _x, _y, scrolledX, scrolledY, hitTestAction)) 2674 return true; 2675 2676 // Hit test floats. 2677 if (hitTestAction == HitTestFloat && m_floatingObjects) { 2678 if (isRenderView()) { 2679 scrolledX += static_cast<RenderView*>(this)->frameView()->contentsX(); 2680 scrolledY += static_cast<RenderView*>(this)->frameView()->contentsY(); 2681 } 2682 2683 FloatingObject* o; 2684 DeprecatedPtrListIterator<FloatingObject> it(*m_floatingObjects); 2685 for (it.toLast(); (o = it.current()); --it) { 2686 if (!o->noPaint && !o->node->layer()) { 2687 int xoffset = scrolledX + o->left + o->node->marginLeft() - o->node->xPos(); 2688 int yoffset = scrolledY + o->startY + o->node->marginTop() - o->node->yPos(); 2689 if (o->node->hitTest(request, result, _x, _y, xoffset, yoffset)) { 2690 updateHitTestResult(result, IntPoint(_x - xoffset, _y - yoffset)); 2691 return true; 2683 // If we have lightweight control clipping, then we can't have any spillout. 2684 if (!hasControlClip() || controlClipRect(tx, ty).contains(_x, _y)) { 2685 // Hit test descendants first. 2686 int scrolledX = tx; 2687 int scrolledY = ty; 2688 if (hasOverflowClip()) 2689 m_layer->subtractScrollOffset(scrolledX, scrolledY); 2690 2691 // Hit test contents if we don't have columns. 2692 if (!hasColumns() && hitTestContents(request, result, _x, _y, scrolledX, scrolledY, hitTestAction)) 2693 return true; 2694 2695 // Hit test our columns if we do have them. 2696 if (hasColumns() && hitTestColumns(request, result, _x, _y, scrolledX, scrolledY, hitTestAction)) 2697 return true; 2698 2699 // Hit test floats. 2700 if (hitTestAction == HitTestFloat && m_floatingObjects) { 2701 if (isRenderView()) { 2702 scrolledX += static_cast<RenderView*>(this)->frameView()->contentsX(); 2703 scrolledY += static_cast<RenderView*>(this)->frameView()->contentsY(); 2704 } 2705 2706 FloatingObject* o; 2707 DeprecatedPtrListIterator<FloatingObject> it(*m_floatingObjects); 2708 for (it.toLast(); (o = it.current()); --it) { 2709 if (!o->noPaint && !o->node->layer()) { 2710 int xoffset = scrolledX + o->left + o->node->marginLeft() - o->node->xPos(); 2711 int yoffset = scrolledY + o->startY + o->node->marginTop() - o->node->yPos(); 2712 if (o->node->hitTest(request, result, _x, _y, xoffset, yoffset)) { 2713 updateHitTestResult(result, IntPoint(_x - xoffset, _y - yoffset)); 2714 return true; 2715 } 2692 2716 } 2693 2717 } … … 3071 3095 3072 3096 m_overflowHeight = maxColBottom; 3073 int toAdd = borderBottom() + paddingBottom(); 3074 if (includeHorizontalScrollbarSize()) 3075 toAdd += m_layer->horizontalScrollbarHeight(); 3097 int toAdd = borderBottom() + paddingBottom() + horizontalScrollbarHeight(); 3076 3098 3077 3099 if (computeIntrinsicHeight) -
trunk/WebCore/rendering/RenderBox.cpp
r18788 r18819 179 179 if (layer) 180 180 layer->destroy(arena); 181 }182 183 int RenderBox::contentWidth() const184 {185 int w = m_width - (borderLeft() + borderRight() + paddingLeft() + paddingRight());186 187 if (includeVerticalScrollbarSize())188 w -= m_layer->verticalScrollbarWidth();189 190 return w;191 }192 193 int RenderBox::contentHeight() const194 {195 int h = m_height - (borderTop() + borderBottom() + paddingTop() + paddingBottom());196 197 if (includeHorizontalScrollbarSize())198 h -= m_layer->horizontalScrollbarHeight();199 200 return h;201 181 } 202 182 … … 975 955 IntRect boxRect(0, 0, o->layer()->width(), o->layer()->height()); 976 956 o->layer()->subtractScrollOffset(x,y); // For overflow:auto/scroll/hidden. 957 IntRect repaintRect(x, y, r.width(), r.height()); 958 r = intersection(repaintRect, boxRect); 959 if (r.isEmpty()) 960 return; 961 } else if (o->hasControlClip()) { 962 // Some form controls use a lightweight clipping scheme to avoid the overhead of a layer. 963 IntRect boxRect(borderLeft(), borderTop(), m_width - borderLeft() - borderRight(), m_height - borderTop() - borderBottom()); 977 964 IntRect repaintRect(x, y, r.width(), r.height()); 978 965 r = intersection(repaintRect, boxRect); -
trunk/WebCore/rendering/RenderBox.h
r18788 r18819 45 45 virtual int minWidth() const { return m_minWidth; } 46 46 virtual int maxWidth() const { return m_maxWidth; } 47 48 virtual int contentWidth() const;49 virtual int contentHeight() const;50 47 51 48 virtual int overrideSize() const { return m_overrideSize; } -
trunk/WebCore/rendering/RenderButton.cpp
r18637 r18819 68 68 if (m_buttonText) 69 69 m_buttonText->setStyle(style); 70 if (m_inner) 70 if (m_inner) // RenderBlock handled updating the anonymous block's style. 71 71 m_inner->style()->setBoxFlex(1.0f); 72 72 setReplaced(isInline()); … … 109 109 } 110 110 111 void RenderButton::paintObject(PaintInfo& paintInfo, int tx, int ty) 111 IntRect RenderButton::controlClipRect(int tx, int ty) const 112 112 { 113 // Push a clip. 114 if (m_inner && paintInfo.phase == PaintPhaseForeground) { 115 IntRect clipRect(tx + borderLeft(), ty + borderTop(), 116 width() - borderLeft() - borderRight(), height() - borderBottom() - borderTop()); 117 if (clipRect.width() == 0 || clipRect.height() == 0) 118 return; 119 paintInfo.context->save(); 120 paintInfo.context->clip(clipRect); 121 } 122 123 // Paint the children. 124 RenderBlock::paintObject(paintInfo, tx, ty); 125 126 // Pop the clip. 127 if (m_inner && paintInfo.phase == PaintPhaseForeground) 128 paintInfo.context->restore(); 113 // Clip to the padding box to at least give content the extra padding space. 114 return IntRect(tx + borderLeft(), ty + borderTop(), m_width - borderLeft() - borderRight(), m_height - borderTop() - borderBottom()); 129 115 } 130 116 117 131 118 } // namespace WebCore -
trunk/WebCore/rendering/RenderButton.h
r17448 r18819 47 47 virtual void updatePseudoChild(RenderStyle::PseudoId); 48 48 49 virtual void paintObject(PaintInfo&, int tx, int ty); 49 virtual bool hasControlClip() const { return true; } 50 virtual IntRect controlClipRect(int /*tx*/, int /*ty*/) const; 50 51 51 52 void setText(const String&); -
trunk/WebCore/rendering/RenderFlexibleBox.cpp
r18764 r18819 293 293 // If the block got expanded in size, then increase our overflowheight to match. 294 294 if (m_overflowHeight > m_height) 295 m_overflowHeight -= (borderBottom() + paddingBottom() + (includeHorizontalScrollbarSize() ? m_layer->horizontalScrollbarHeight() : 0));295 m_overflowHeight -= (borderBottom() + paddingBottom() + horizontalScrollbarHeight()); 296 296 if (m_overflowHeight < m_height) 297 297 m_overflowHeight = m_height; … … 336 336 void RenderFlexibleBox::layoutHorizontalBox(bool relayoutChildren) 337 337 { 338 int toAdd = borderBottom() + paddingBottom() + (includeHorizontalScrollbarSize() ? m_layer->horizontalScrollbarHeight() : 0);338 int toAdd = borderBottom() + paddingBottom() + horizontalScrollbarHeight(); 339 339 int yPos = borderTop() + paddingTop(); 340 340 int xPos = borderLeft() + paddingLeft(); … … 662 662 if( style()->direction() == RTL ) 663 663 xPos = m_width - paddingRight() - borderRight(); 664 int toAdd = borderBottom() + paddingBottom() + (includeHorizontalScrollbarSize() ? m_layer->horizontalScrollbarHeight() : 0);;664 int toAdd = borderBottom() + paddingBottom() + horizontalScrollbarHeight(); 665 665 bool heightSpecified = false; 666 666 int oldHeight = 0; -
trunk/WebCore/rendering/RenderFlow.cpp
r18758 r18819 664 664 graphicsContext->addFocusRingRect(IntRect(tx, ty, width(), height())); 665 665 666 if (!hasOverflowClip() ) {666 if (!hasOverflowClip() && !hasControlClip()) { 667 667 for (InlineRunBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) 668 668 graphicsContext->addFocusRingRect(IntRect(tx + curr->xPos(), ty + curr->yPos(), curr->width(), curr->height())); -
trunk/WebCore/rendering/RenderListBox.cpp
r18648 r18819 205 205 IntRect RenderListBox::itemBoundingBoxRect(int tx, int ty, int index) 206 206 { 207 return IntRect 207 return IntRect(tx + borderLeft() + paddingLeft(), 208 208 ty + borderTop() + paddingTop() + ((style()->font().height() + optionsSpacingMiddle) * (index - m_indexOffset)), 209 absoluteBoundingBoxRect().width() - borderLeft() - borderRight() - paddingLeft() - paddingRight(),209 contentWidth(), 210 210 style()->font().height() + optionsSpacingMiddle); 211 211 } … … 213 213 void RenderListBox::paintObject(PaintInfo& paintInfo, int tx, int ty) 214 214 { 215 // Push a clip.216 IntRect clipRect(tx + borderLeft(), ty + borderTop(),217 width() - borderLeft() - borderRight() - (m_vBar ? m_vBar->width() : 0), height() - borderBottom() - borderTop());218 if (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseChildBlockBackgrounds) {219 if (clipRect.width() == 0 || clipRect.height() == 0)220 return;221 paintInfo.context->save();222 paintInfo.context->clip(clipRect);223 }224 225 215 HTMLSelectElement* select = static_cast<HTMLSelectElement*>(node()); 226 216 int listItemsSize = select->listItems().size(); … … 245 235 paintScrollbar(paintInfo); 246 236 } 247 // Pop the clip.248 if (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseChildBlockBackgrounds)249 paintInfo.context->restore();250 237 } 251 238 … … 452 439 } 453 440 441 int RenderListBox::itemHeight() const 442 { 443 return style()->font().height() + optionsSpacingMiddle; 444 } 445 446 int RenderListBox::verticalScrollbarWidth() const 447 { 448 return m_vBar ? m_vBar->width() : 0; 449 } 450 451 // FIXME: We ignore padding in the vertical direction as far as these values are concerned, since that's 452 // how the control currently paints. 453 int RenderListBox::scrollWidth() const 454 { 455 // There is no horizontal scrolling allowed. 456 return clientWidth(); 457 } 458 459 int RenderListBox::scrollHeight() const 460 { 461 HTMLSelectElement* select = static_cast<HTMLSelectElement*>(node()); 462 const Vector<HTMLElement*>& listItems = select->listItems(); 463 return max(clientHeight(), (int)listItems.size() * itemHeight()); 464 } 465 466 int RenderListBox::scrollLeft() const 467 { 468 return 0; 469 } 470 471 void RenderListBox::setScrollLeft(int) 472 { 473 } 474 475 int RenderListBox::scrollTop() const 476 { 477 return m_indexOffset * itemHeight(); 478 } 479 480 void RenderListBox::setScrollTop(int newTop) 481 { 482 // Determine an index and scroll to it. 483 HTMLSelectElement* select = static_cast<HTMLSelectElement*>(node()); 484 const Vector<HTMLElement*>& listItems = select->listItems(); 485 486 int index = newTop / itemHeight(); 487 if (index < 0 || index > (int)listItems.size() - 1 || listIndexIsVisible(index)) 488 return; 489 490 int newOffset = index; 491 492 if (m_vBar) { 493 IntRect rect = absoluteBoundingBoxRect(); 494 m_vBar->setValue(itemBoundingBoxRect(rect.x(), rect.y(), newOffset + m_indexOffset).y() - rect.y()); 495 } 496 m_indexOffset = newOffset; 497 } 498 499 IntRect RenderListBox::controlClipRect(int tx, int ty) const 500 { 501 // Clip to the padding box, since we have a scrollbar inside the padding box. 502 return IntRect(tx + borderLeft(), 503 ty + borderTop(), 504 clientWidth(), clientHeight()); 505 } 506 454 507 IntRect RenderListBox::windowClipRect() const 455 508 { -
trunk/WebCore/rendering/RenderListBox.h
r18637 r18819 46 46 virtual bool canHaveChildren() const { return false; } 47 47 48 virtual bool hasControlClip() const { return true; } 48 49 virtual void paintObject(PaintInfo&, int tx, int ty); 50 virtual IntRect controlClipRect(int /*tx*/, int /*ty*/) const; 51 49 52 virtual bool isPointInScrollbar(HitTestResult&, int x, int y, int tx, int ty); 50 53 … … 63 66 int listIndexAtOffset(int x, int y); 64 67 68 int itemHeight() const; 69 65 70 bool scrollToRevealElementAtListIndex(int index); 66 71 … … 68 73 virtual void autoscroll(); 69 74 virtual void stopAutoscroll(); 75 76 virtual int verticalScrollbarWidth() const; 77 virtual int scrollLeft() const; 78 virtual int scrollTop() const; 79 virtual int scrollWidth() const; 80 virtual int scrollHeight() const; 81 virtual void setScrollLeft(int); 82 virtual void setScrollTop(int); 70 83 71 84 private: … … 80 93 bool m_optionsChanged; 81 94 int m_optionsWidth; 82 int m_optionsMaxHeight;83 int m_optionsTotalHeight;84 95 int m_indexOffset; 85 96 bool m_selectionChanged; -
trunk/WebCore/rendering/RenderMenuList.cpp
r18248 r18819 96 96 if (m_buttonText) 97 97 m_buttonText->setStyle(style); 98 if (m_innerBlock) 98 if (m_innerBlock) // RenderBlock handled updating the anonymous block's style. 99 99 m_innerBlock->style()->setBoxFlex(1.0f); 100 100 setReplaced(isInline()); … … 169 169 } 170 170 171 void RenderMenuList::paintObject(PaintInfo& paintInfo, int x, int y) 172 { 173 // Push a clip. 174 if (paintInfo.phase == PaintPhaseForeground) { 175 IntRect clipRect(x + borderLeft() + paddingLeft(), y + borderTop() + paddingTop(), 176 width() - borderLeft() - borderRight() - paddingLeft() - paddingRight(), 177 height() - borderBottom() - borderTop() - paddingTop() - paddingBottom()); 178 if (clipRect.isEmpty()) 179 return; 180 paintInfo.context->save(); 181 paintInfo.context->clip(clipRect); 182 } 183 184 // Paint the children. 185 RenderBlock::paintObject(paintInfo, x, y); 186 187 // Pop the clip. 188 if (paintInfo.phase == PaintPhaseForeground) 189 paintInfo.context->restore(); 171 IntRect RenderMenuList::controlClipRect(int tx, int ty) const 172 { 173 // Clip to the content box, since the arrow sits in the padding space, and we don't want to draw over it. 174 return IntRect(tx + borderLeft() + paddingLeft(), 175 ty + borderTop() + paddingTop(), 176 contentWidth(), contentHeight()); 190 177 } 191 178 -
trunk/WebCore/rendering/RenderMenuList.h
r18248 r18819 54 54 virtual void updateFromElement(); 55 55 56 virtual void paintObject(PaintInfo&, int tx, int ty); 56 virtual bool hasControlClip() const { return true; } 57 virtual IntRect controlClipRect(int /*tx*/, int /*ty*/) const; 57 58 58 59 virtual const char* renderName() const { return "RenderMenuList"; } -
trunk/WebCore/rendering/RenderObject.cpp
r18758 r18819 654 654 } 655 655 656 int RenderObject::verticalScrollbarWidth() const 657 { 658 return includeVerticalScrollbarSize() ? layer()->verticalScrollbarWidth() : 0; 659 } 660 661 int RenderObject::horizontalScrollbarHeight() const 662 { 663 return includeHorizontalScrollbarSize() ? layer()->horizontalScrollbarHeight() : 0; 664 } 665 656 666 // More IE extensions. clientWidth and clientHeight represent the interior of an object 657 667 // excluding border and scrollbar. 658 668 int RenderObject::clientWidth() const 659 669 { 660 return width() - borderLeft() - borderRight() - 661 (includeVerticalScrollbarSize() ? layer()->verticalScrollbarWidth() : 0);670 return width() - borderLeft() - borderRight() - verticalScrollbarWidth(); 671 662 672 } 663 673 664 674 int RenderObject::clientHeight() const 665 675 { 666 return height() - borderTop() - borderBottom() - 667 (includeHorizontalScrollbarSize() ? layer()->horizontalScrollbarHeight() : 0); 676 return height() - borderTop() - borderBottom() - horizontalScrollbarHeight(); 668 677 } 669 678 … … 2311 2320 // No need to ever schedule repaints from a style change of a text run, since 2312 2321 // we already did this for the parent of the text run. 2313 if (d == RenderStyle::Layout && m_parent )2322 if (d == RenderStyle::Layout && m_parent && !isText()) 2314 2323 setNeedsLayoutAndMinMaxRecalc(); 2315 2324 else if (m_parent && !isText() && (d == RenderStyle::RepaintLayer || d == RenderStyle::Repaint)) -
trunk/WebCore/rendering/RenderObject.h
r18810 r18819 326 326 327 327 bool hasOverflowClip() const { return m_hasOverflowClip; } 328 virtual bool hasControlClip() const { return false; } 329 virtual IntRect controlClipRect(int /*tx*/, int /*ty*/) const { return IntRect(); } 328 330 329 331 bool hasAutoVerticalScrollbar() const { return hasOverflowClip() && (style()->overflowY() == OAUTO || style()->overflowY() == OOVERLAY); } … … 334 336 bool scrollsOverflowY() const { return hasOverflowClip() && (style()->overflowY() == OSCROLL || hasAutoVerticalScrollbar()); } 335 337 338 virtual int verticalScrollbarWidth() const; 339 virtual int horizontalScrollbarHeight() const; 340 private: 336 341 bool includeVerticalScrollbarSize() const { return hasOverflowClip() && (style()->overflowY() == OSCROLL || style()->overflowY() == OAUTO); } 337 342 bool includeHorizontalScrollbarSize() const { return hasOverflowClip() && (style()->overflowX() == OSCROLL || style()->overflowX() == OAUTO); } 338 343 344 public: 339 345 RenderStyle* getPseudoStyle(RenderStyle::PseudoId, RenderStyle* parentStyle = 0) const; 340 346 … … 549 555 550 556 // size of the content area (box size minus padding/border) 551 virtual int contentWidth() const { return 0; }552 virtual int contentHeight() const { return 0; }557 int contentWidth() const { return clientWidth() - paddingLeft() - paddingRight(); } 558 int contentHeight() const { return clientHeight() - paddingTop() - paddingBottom(); } 553 559 554 560 // intrinsic extend of replaced elements. undefined otherwise -
trunk/WebCore/rendering/RenderStyle.cpp
r18810 r18819 87 87 : hasClip(false) 88 88 , textDecoration(RenderStyle::initialTextDecoration()) 89 , colspan(1)90 89 , counterIncrement(0) 91 90 , counterReset(0) … … 102 101 , hasClip(o.hasClip) 103 102 , textDecoration(o.textDecoration) 104 , colspan(o.colspan)105 103 , counterIncrement(o.counterIncrement) 106 104 , counterReset(o.counterReset) … … 604 602 } 605 603 604 static bool cursorDataEqvuialent(const CursorList* c1, const CursorList* c2) 605 { 606 if (c1 == c2) 607 return true; 608 if (!c1 && c2 || c1 && !c2) 609 return false; 610 return (*c1 == *c2); 611 } 612 606 613 bool StyleInheritedData::operator==(const StyleInheritedData& o) const 607 614 { … … 610 617 line_height == o.line_height && 611 618 style_image == o.style_image && 612 cursorData == o.cursorData&&619 cursorDataEqvuialent(cursorData.get(), o.cursorData.get()) && 613 620 font == o.font && 614 621 color == o.color && … … 619 626 page_break_inside == o.page_break_inside; 620 627 } 628 629 bool CursorList::operator==(const CursorList& other) const 630 { 631 // If the lists aren't the same size, then they can't be equivalent. 632 if (size() != other.size()) 633 return false; 634 635 for (unsigned i = 0; i < size(); i++) { 636 if (m_vector[i] != other.m_vector[i]) 637 return false; 638 } 639 640 return true; 641 } 642 621 643 622 644 static inline bool operator!=(const CounterContent& a, const CounterContent& b) … … 872 894 #endif 873 895 874 // we anyway assume they are the same 875 // EDisplay _effectiveDisplay : 5; 876 877 // NonVisible: 878 // ECursor _cursor_style : 4; 879 880 // ### this needs work to know more exactly if we need a relayout 881 // or just a repaint 882 883 // non-inherited attributes 884 // DataRef<StyleBoxData> box; 885 // DataRef<StyleVisualData> visual; 886 // DataRef<StyleSurroundData> surround; 887 888 // inherited attributes 889 // DataRef<StyleInheritedData> inherited; 890 891 if ( box->width != other->box->width || 892 box->min_width != other->box->min_width || 893 box->max_width != other->box->max_width || 894 box->height != other->box->height || 895 box->min_height != other->box->min_height || 896 box->max_height != other->box->max_height || 897 box->vertical_align != other->box->vertical_align || 898 box->boxSizing != other->box->boxSizing || 899 !(surround->margin == other->surround->margin) || 900 !(surround->padding == other->surround->padding) || 901 rareNonInheritedData->m_appearance != other->rareNonInheritedData->m_appearance || 902 rareNonInheritedData->marginTopCollapse != other->rareNonInheritedData->marginTopCollapse || 903 rareNonInheritedData->marginBottomCollapse != other->rareNonInheritedData->marginBottomCollapse || 904 *rareNonInheritedData->flexibleBox.get() != *other->rareNonInheritedData->flexibleBox.get() || 905 *rareNonInheritedData->m_multiCol.get() != *other->rareNonInheritedData->m_multiCol.get() || 906 (rareNonInheritedData->lineClamp != other->rareNonInheritedData->lineClamp) || 907 (rareInheritedData->highlight != other->rareInheritedData->highlight) || 908 (rareInheritedData->textSizeAdjust != other->rareInheritedData->textSizeAdjust) || 909 (rareInheritedData->wordWrap != other->rareInheritedData->wordWrap) || 910 (rareInheritedData->nbspMode != other->rareInheritedData->nbspMode) || 911 (rareInheritedData->khtmlLineBreak != other->rareInheritedData->khtmlLineBreak) || 912 !(inherited->indent == other->inherited->indent) || 913 !(inherited->line_height == other->inherited->line_height) || 914 !(inherited->style_image == other->inherited->style_image) || 915 !(inherited->cursorData == other->inherited->cursorData) || 916 !(inherited->font == other->inherited->font) || 917 !(inherited->horizontal_border_spacing == other->inherited->horizontal_border_spacing) || 918 !(inherited->vertical_border_spacing == other->inherited->vertical_border_spacing) || 919 !(inherited_flags._box_direction == other->inherited_flags._box_direction) || 920 !(inherited_flags._visuallyOrdered == other->inherited_flags._visuallyOrdered) || 921 !(inherited_flags._htmlHacks == other->inherited_flags._htmlHacks) || 922 !(noninherited_flags._position == other->noninherited_flags._position) || 923 !(noninherited_flags._floating == other->noninherited_flags._floating) || 924 !(noninherited_flags._originalDisplay == other->noninherited_flags._originalDisplay) || 925 visual->colspan != other->visual->colspan || 926 visual->counterIncrement != other->visual->counterIncrement || 927 visual->counterReset != other->visual->counterReset || 928 rareNonInheritedData->textOverflow != other->rareNonInheritedData->textOverflow || 929 (rareInheritedData->textSecurity != other->rareInheritedData->textSecurity)) 896 if (box->width != other->box->width || 897 box->min_width != other->box->min_width || 898 box->max_width != other->box->max_width || 899 box->height != other->box->height || 900 box->min_height != other->box->min_height || 901 box->max_height != other->box->max_height) 930 902 return Layout; 903 904 if (box->vertical_align != other->box->vertical_align || noninherited_flags._vertical_align != other->noninherited_flags._vertical_align) 905 return Layout; 906 907 if (box->boxSizing != other->box->boxSizing) 908 return Layout; 909 910 if (surround->margin != other->surround->margin) 911 return Layout; 912 913 if (surround->padding != other->surround->padding) 914 return Layout; 915 916 if (rareNonInheritedData.get() != other->rareNonInheritedData.get()) { 917 if (rareNonInheritedData->m_appearance != other->rareNonInheritedData->m_appearance || 918 rareNonInheritedData->marginTopCollapse != other->rareNonInheritedData->marginTopCollapse || 919 rareNonInheritedData->marginBottomCollapse != other->rareNonInheritedData->marginBottomCollapse || 920 rareNonInheritedData->lineClamp != other->rareNonInheritedData->lineClamp || 921 rareNonInheritedData->textOverflow != other->rareNonInheritedData->textOverflow) 922 return Layout; 923 924 if (rareNonInheritedData->flexibleBox.get() != other->rareNonInheritedData->flexibleBox.get() && 925 *rareNonInheritedData->flexibleBox.get() != *other->rareNonInheritedData->flexibleBox.get()) 926 return Layout; 927 928 if (!rareNonInheritedData->shadowDataEquivalent(*other->rareNonInheritedData.get())) 929 return Layout; 930 931 if (rareNonInheritedData->m_multiCol.get() != other->rareNonInheritedData->m_multiCol.get() && 932 *rareNonInheritedData->m_multiCol.get() != *other->rareNonInheritedData->m_multiCol.get()) 933 return Layout; 934 935 // If regions change trigger a relayout to re-calc regions. 936 if (rareNonInheritedData->m_dashboardRegions != other->rareNonInheritedData->m_dashboardRegions) 937 return Layout; 938 } 939 940 if (rareInheritedData.get() != other->rareInheritedData.get()) { 941 if (rareInheritedData->highlight != other->rareInheritedData->highlight || 942 rareInheritedData->textSizeAdjust != other->rareInheritedData->textSizeAdjust || 943 rareInheritedData->wordWrap != other->rareInheritedData->wordWrap || 944 rareInheritedData->nbspMode != other->rareInheritedData->nbspMode || 945 rareInheritedData->khtmlLineBreak != other->rareInheritedData->khtmlLineBreak || 946 rareInheritedData->textSecurity != other->rareInheritedData->textSecurity) 947 return Layout; 948 949 if (!rareInheritedData->shadowDataEquivalent(*other->rareInheritedData.get())) 950 return Layout; 951 952 if (textStrokeWidth() != other->textStrokeWidth()) 953 return Layout; 954 } 955 956 if (inherited->indent != other->inherited->indent || 957 inherited->line_height != other->inherited->line_height || 958 inherited->style_image != other->inherited->style_image || 959 inherited->font != other->inherited->font || 960 inherited->horizontal_border_spacing != other->inherited->horizontal_border_spacing || 961 inherited->vertical_border_spacing != other->inherited->vertical_border_spacing || 962 inherited_flags._box_direction != other->inherited_flags._box_direction || 963 inherited_flags._visuallyOrdered != other->inherited_flags._visuallyOrdered || 964 inherited_flags._htmlHacks != other->inherited_flags._htmlHacks || 965 noninherited_flags._position != other->noninherited_flags._position || 966 noninherited_flags._floating != other->noninherited_flags._floating || 967 noninherited_flags._originalDisplay != other->noninherited_flags._originalDisplay) 968 return Layout; 969 931 970 932 // changes causing Layout changes: 933 934 // only for tables: 935 // _border_collapse 936 // EEmptyCell _empty_cells : 2 ; 937 // ECaptionSide _caption_side : 2; 938 // ETableLayout _table_layout : 1; 939 // EPosition _position : 2; 940 // EFloat _floating : 2; 941 if ( ((int)noninherited_flags._effectiveDisplay) >= TABLE ) { 942 // Stupid gcc gives a compile error on 943 // a != other->b if a and b are bitflags. Using 944 // !(a== other->b) instead. 945 if ( !(inherited_flags._border_collapse == other->inherited_flags._border_collapse) || 946 !(inherited_flags._empty_cells == other->inherited_flags._empty_cells) || 947 !(inherited_flags._caption_side == other->inherited_flags._caption_side) || 948 !(noninherited_flags._table_layout == other->noninherited_flags._table_layout)) 971 if (((int)noninherited_flags._effectiveDisplay) >= TABLE) { 972 if (inherited_flags._border_collapse != other->inherited_flags._border_collapse || 973 inherited_flags._empty_cells != other->inherited_flags._empty_cells || 974 inherited_flags._caption_side != other->inherited_flags._caption_side || 975 noninherited_flags._table_layout != other->noninherited_flags._table_layout) 949 976 return Layout; 950 977 … … 963 990 } 964 991 965 // only for lists: 966 // EListStyleType _list_style_type : 5 ; 967 // EListStylePosition _list_style_position :1; 968 if (noninherited_flags._effectiveDisplay == LIST_ITEM ) { 969 if ( !(inherited_flags._list_style_type == other->inherited_flags._list_style_type) || 970 !(inherited_flags._list_style_position == other->inherited_flags._list_style_position) ) 992 if (noninherited_flags._effectiveDisplay == LIST_ITEM) { 993 if (inherited_flags._list_style_type != other->inherited_flags._list_style_type || 994 inherited_flags._list_style_position != other->inherited_flags._list_style_position) 971 995 return Layout; 972 996 } 973 997 974 // ### These could be better optimised 975 // ETextAlign _text_align : 3; 976 // ETextTransform _text_transform : 4; 977 // EDirection _direction : 1; 978 // EWhiteSpace _white_space : 2; 979 // EFontVariant _font_variant : 1; 980 // EClear _clear : 2; 981 if ( !(inherited_flags._text_align == other->inherited_flags._text_align) || 982 !(inherited_flags._text_transform == other->inherited_flags._text_transform) || 983 !(inherited_flags._direction == other->inherited_flags._direction) || 984 !(inherited_flags._white_space == other->inherited_flags._white_space) || 985 !(noninherited_flags._clear == other->noninherited_flags._clear) || 986 !rareInheritedData->shadowDataEquivalent(*other->rareInheritedData.get()) || 987 !rareNonInheritedData->shadowDataEquivalent(*other->rareNonInheritedData.get()) || 988 textStrokeWidth() != other->textStrokeWidth() 989 ) 998 if (inherited_flags._text_align != other->inherited_flags._text_align || 999 inherited_flags._text_transform != other->inherited_flags._text_transform || 1000 inherited_flags._direction != other->inherited_flags._direction || 1001 inherited_flags._white_space != other->inherited_flags._white_space || 1002 noninherited_flags._clear != other->noninherited_flags._clear) 990 1003 return Layout; 991 1004 … … 994 1007 noninherited_flags._overflowY != other->noninherited_flags._overflowY) 995 1008 return Layout; 996 997 // only for inline: 998 // EVerticalAlign _vertical_align : 4; 999 1000 if ( !(noninherited_flags._effectiveDisplay == INLINE) && 1001 !(noninherited_flags._vertical_align == other->noninherited_flags._vertical_align)) 1002 return Layout; 1003 1009 1004 1010 // If our border widths change, then we need to layout. Other changes to borders 1005 1011 // only necessitate a repaint. … … 1010 1016 return Layout; 1011 1017 1012 // If regions change trigger a relayout to re-calc regions.1013 if (!(rareNonInheritedData->m_dashboardRegions == other->rareNonInheritedData->m_dashboardRegions))1014 return Layout;1015 1016 1018 // If the counter directives change, trigger a relayout to re-calculate counter values and rebuild the counter node tree. 1017 1019 const CounterDirectiveMap* mapA = rareNonInheritedData->m_counterDirectives; … … 1019 1021 if (!(mapA == mapB || (mapA && mapB && *mapA == *mapB))) 1020 1022 return Layout; 1023 if (visual->counterIncrement != other->visual->counterIncrement || 1024 visual->counterReset != other->visual->counterReset) 1025 return Layout; 1021 1026 1022 1027 // Make sure these left/top/right/bottom checks stay below all layout checks and above 1023 1028 // all visible checks. 1024 1029 if (other->position() != StaticPosition) { 1025 if ( !(surround->offset == other->surround->offset)) {1030 if (surround->offset != other->surround->offset) { 1026 1031 // FIXME: We will need to do a bit of work in RenderObject/Box::setStyle before we 1027 1032 // can stop doing a layout when relative positioned objects move. In particular, we'll need … … 1033 1038 } 1034 1039 else if (box->z_index != other->box->z_index || box->z_auto != other->box->z_auto || 1035 !(visual->clip == other->visual->clip)|| visual->hasClip != other->visual->hasClip)1040 visual->clip != other->visual->clip || visual->hasClip != other->visual->hasClip) 1036 1041 return RepaintLayer; 1037 1042 } … … 1040 1045 return RepaintLayer; 1041 1046 1042 // Repaint:1043 // EVisibility _visibility : 2;1044 // int _text_decoration : 4;1045 // DataRef<StyleBackgroundData> background;1046 1047 if (inherited->color != other->inherited->color || 1047 1048 inherited_flags._visibility != other->inherited_flags._visibility || 1048 !(inherited_flags._text_decorations == other->inherited_flags._text_decorations)||1049 !(inherited_flags._force_backgrounds_to_white == other->inherited_flags._force_backgrounds_to_white)||1050 !(surround->border == other->surround->border)||1049 inherited_flags._text_decorations != other->inherited_flags._text_decorations || 1050 inherited_flags._force_backgrounds_to_white != other->inherited_flags._force_backgrounds_to_white || 1051 surround->border != other->surround->border || 1051 1052 *background.get() != *other->background.get() || 1052 1053 visual->textDecoration != other->visual->textDecoration || … … 1055 1056 rareNonInheritedData->userDrag != other->rareNonInheritedData->userDrag || 1056 1057 rareInheritedData->textFillColor != other->rareInheritedData->textFillColor || 1057 rareInheritedData->textStrokeColor != other->rareInheritedData->textStrokeColor 1058 ) 1058 rareInheritedData->textStrokeColor != other->rareInheritedData->textStrokeColor) 1059 1059 return Repaint; 1060 1061 // Cursors are not checked, since they will be set appropriately in response to mouse events, 1062 // so they don't need to cause any repaint or layout. 1060 1063 1061 1064 return Equal; -
trunk/WebCore/rendering/RenderStyle.h
r18724 r18819 109 109 } 110 110 111 bool operator!=(const LengthBox& o) const 112 { 113 return !(*this == o); 114 } 111 115 112 116 bool nonZero() const { return !(left.isZero() && right.isZero() && top.isZero() && bottom.isZero()); } … … 413 417 return ( clip == o.clip && 414 418 hasClip == o.hasClip && 415 colspan == o.colspan &&416 419 counterIncrement == o.counterIncrement && 417 420 counterReset == o.counterReset && … … 423 426 bool hasClip : 1; 424 427 unsigned textDecoration : 4; // Text decorations defined *only* by this element. 425 426 short colspan; // for html, not a css2 attribute427 428 428 429 short counterIncrement; // ok, so these are not visual mode specific … … 962 963 {} 963 964 965 bool operator==(const CursorData& o) const { 966 return hotSpot == o.hotSpot && cursorImage == o.cursorImage && cursorFragmentId == o.cursorFragmentId; 967 } 968 bool operator!=(const CursorData& o) const { return !(*this == o); } 969 964 970 IntPoint hotSpot; // for CSS3 support 965 971 CachedImage* cursorImage; // weak pointer, the CSSValueImage takes care of deleting cursorImage … … 972 978 return m_vector[i]; 973 979 } 980 981 bool operator==(const CursorList&) const; 982 bool operator!=(const CursorList& o) const { return !(*this == o); } 974 983 975 984 size_t size() const { return m_vector.size(); } … … 1305 1314 EClear clear() const { return static_cast<EClear>(noninherited_flags._clear); } 1306 1315 ETableLayout tableLayout() const { return static_cast<ETableLayout>(noninherited_flags._table_layout); } 1307 1308 short colSpan() const { return visual->colspan; }1309 1316 1310 1317 const Font& font() { return inherited->font; } … … 1566 1573 void setClear(EClear v) { noninherited_flags._clear = v; } 1567 1574 void setTableLayout(ETableLayout v) { noninherited_flags._table_layout = v; } 1568 void ssetColSpan(short v) { SET_VAR(visual,colspan,v) }1569 1575 1570 1576 bool setFontDescription(const FontDescription& v) { -
trunk/WebCore/rendering/bidi.cpp
r18764 r18819 1493 1493 1494 1494 m_height = borderTop() + paddingTop(); 1495 int toAdd = borderBottom() + paddingBottom(); 1496 if (includeHorizontalScrollbarSize()) 1497 toAdd += m_layer->horizontalScrollbarHeight(); 1495 int toAdd = borderBottom() + paddingBottom() + horizontalScrollbarHeight(); 1498 1496 1499 1497 // Figure out if we should clear out our line boxes.
Note:
See TracChangeset
for help on using the changeset viewer.