OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) |
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. |
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 #include <math.h> | 29 #include <math.h> |
30 #include <algorithm> | 30 #include <algorithm> |
31 #include "sky/engine/core/dom/Document.h" | 31 #include "sky/engine/core/dom/Document.h" |
32 #include "sky/engine/core/editing/htmlediting.h" | 32 #include "sky/engine/core/editing/htmlediting.h" |
33 #include "sky/engine/core/frame/FrameHost.h" | 33 #include "sky/engine/core/frame/FrameHost.h" |
34 #include "sky/engine/core/frame/FrameView.h" | 34 #include "sky/engine/core/frame/FrameView.h" |
35 #include "sky/engine/core/frame/LocalFrame.h" | 35 #include "sky/engine/core/frame/LocalFrame.h" |
36 #include "sky/engine/core/frame/Settings.h" | 36 #include "sky/engine/core/frame/Settings.h" |
37 #include "sky/engine/core/html/HTMLElement.h" | 37 #include "sky/engine/core/html/HTMLElement.h" |
38 #include "sky/engine/core/page/AutoscrollController.h" | |
39 #include "sky/engine/core/page/EventHandler.h" | 38 #include "sky/engine/core/page/EventHandler.h" |
40 #include "sky/engine/core/page/Page.h" | 39 #include "sky/engine/core/page/Page.h" |
41 #include "sky/engine/core/rendering/HitTestResult.h" | 40 #include "sky/engine/core/rendering/HitTestResult.h" |
42 #include "sky/engine/core/rendering/PaintInfo.h" | 41 #include "sky/engine/core/rendering/PaintInfo.h" |
43 #include "sky/engine/core/rendering/RenderFlexibleBox.h" | 42 #include "sky/engine/core/rendering/RenderFlexibleBox.h" |
44 #include "sky/engine/core/rendering/RenderGeometryMap.h" | 43 #include "sky/engine/core/rendering/RenderGeometryMap.h" |
45 #include "sky/engine/core/rendering/RenderInline.h" | 44 #include "sky/engine/core/rendering/RenderInline.h" |
46 #include "sky/engine/core/rendering/RenderLayer.h" | 45 #include "sky/engine/core/rendering/RenderLayer.h" |
47 #include "sky/engine/core/rendering/RenderView.h" | 46 #include "sky/engine/core/rendering/RenderView.h" |
48 #include "sky/engine/platform/LengthFunctions.h" | 47 #include "sky/engine/platform/LengthFunctions.h" |
49 #include "sky/engine/platform/geometry/FloatQuad.h" | 48 #include "sky/engine/platform/geometry/FloatQuad.h" |
50 #include "sky/engine/platform/geometry/TransformState.h" | 49 #include "sky/engine/platform/geometry/TransformState.h" |
51 #include "sky/engine/platform/graphics/GraphicsContextStateSaver.h" | 50 #include "sky/engine/platform/graphics/GraphicsContextStateSaver.h" |
52 | 51 |
53 namespace blink { | 52 namespace blink { |
54 | 53 |
55 // Size of border belt for autoscroll. When mouse pointer in border belt, | |
56 // autoscroll is started. | |
57 static const int autoscrollBeltSize = 20; | |
58 | |
59 RenderBox::RenderBox(ContainerNode* node) | 54 RenderBox::RenderBox(ContainerNode* node) |
60 : RenderBoxModelObject(node) | 55 : RenderBoxModelObject(node) |
61 , m_intrinsicContentLogicalHeight(-1) | 56 , m_intrinsicContentLogicalHeight(-1) |
62 , m_minPreferredLogicalWidth(-1) | 57 , m_minPreferredLogicalWidth(-1) |
63 , m_maxPreferredLogicalWidth(-1) | 58 , m_maxPreferredLogicalWidth(-1) |
64 { | 59 { |
65 setIsBox(); | 60 setIsBox(); |
66 } | 61 } |
67 | 62 |
68 void RenderBox::willBeDestroyed() | 63 void RenderBox::willBeDestroyed() |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 int RenderBox::pixelSnappedOffsetWidth() const | 174 int RenderBox::pixelSnappedOffsetWidth() const |
180 { | 175 { |
181 return snapSizeToPixel(offsetWidth(), x() + clientLeft()); | 176 return snapSizeToPixel(offsetWidth(), x() + clientLeft()); |
182 } | 177 } |
183 | 178 |
184 int RenderBox::pixelSnappedOffsetHeight() const | 179 int RenderBox::pixelSnappedOffsetHeight() const |
185 { | 180 { |
186 return snapSizeToPixel(offsetHeight(), y() + clientTop()); | 181 return snapSizeToPixel(offsetHeight(), y() + clientTop()); |
187 } | 182 } |
188 | 183 |
189 LayoutUnit RenderBox::scrollWidth() const | |
190 { | |
191 // FIXME(sky): Remove. | |
192 // For objects with visible overflow, this matches IE. | |
193 // FIXME: Need to work right with writing modes. | |
194 if (style()->isLeftToRightDirection()) | |
195 return std::max(clientWidth(), layoutOverflowRect().maxX() - borderLeft(
)); | |
196 return clientWidth() - std::min<LayoutUnit>(0, layoutOverflowRect().x() - bo
rderLeft()); | |
197 } | |
198 | |
199 LayoutUnit RenderBox::scrollHeight() const | |
200 { | |
201 // FIXME(sky): Remove. | |
202 // For objects with visible overflow, this matches IE. | |
203 // FIXME: Need to work right with writing modes. | |
204 return std::max(clientHeight(), layoutOverflowRect().maxY() - borderTop()); | |
205 } | |
206 | |
207 LayoutUnit RenderBox::scrollLeft() const | |
208 { | |
209 // FIXME(sky): Remove. | |
210 return 0; | |
211 } | |
212 | |
213 LayoutUnit RenderBox::scrollTop() const | |
214 { | |
215 // FIXME(sky): Remove. | |
216 return 0; | |
217 } | |
218 | |
219 int RenderBox::pixelSnappedScrollWidth() const | |
220 { | |
221 // FIXME(sky): Remove. | |
222 return snapSizeToPixel(scrollWidth(), x() + clientLeft()); | |
223 } | |
224 | |
225 int RenderBox::pixelSnappedScrollHeight() const | |
226 { | |
227 // FIXME(sky): Remove. | |
228 // For objects with visible overflow, this matches IE. | |
229 // FIXME: Need to work right with writing modes. | |
230 return snapSizeToPixel(scrollHeight(), y() + clientTop()); | |
231 } | |
232 | |
233 void RenderBox::setScrollLeft(LayoutUnit newLeft) | |
234 { | |
235 // FIXME(sky): Remove. | |
236 } | |
237 | |
238 void RenderBox::setScrollTop(LayoutUnit newTop) | |
239 { | |
240 // FIXME(sky): Remove. | |
241 } | |
242 | |
243 void RenderBox::scrollToOffset(const IntSize& offset) | |
244 { | |
245 // FIXME(sky): Remove. | |
246 } | |
247 | |
248 void RenderBox::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignmen
t& alignX, const ScrollAlignment& alignY) | |
249 { | |
250 // FIXME(sky): Remove. | |
251 } | |
252 | |
253 void RenderBox::absoluteQuads(Vector<FloatQuad>& quads) const | 184 void RenderBox::absoluteQuads(Vector<FloatQuad>& quads) const |
254 { | 185 { |
255 quads.append(localToAbsoluteQuad(FloatRect(0, 0, width().toFloat(), height()
.toFloat()), 0 /* mode */)); | 186 quads.append(localToAbsoluteQuad(FloatRect(0, 0, width().toFloat(), height()
.toFloat()), 0 /* mode */)); |
256 } | 187 } |
257 | 188 |
258 void RenderBox::updateLayerTransformAfterLayout() | 189 void RenderBox::updateLayerTransformAfterLayout() |
259 { | 190 { |
260 // Transform-origin depends on box size, so we need to update the layer tran
sform after layout. | 191 // Transform-origin depends on box size, so we need to update the layer tran
sform after layout. |
261 if (hasLayer()) | 192 if (hasLayer()) |
262 layer()->updateTransformationMatrix(); | 193 layer()->updateTransformationMatrix(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 LayoutRect rect = contentBoxRect(); | 237 LayoutRect rect = contentBoxRect(); |
307 return localToAbsoluteQuad(FloatRect(rect)); | 238 return localToAbsoluteQuad(FloatRect(rect)); |
308 } | 239 } |
309 | 240 |
310 void RenderBox::addFocusRingRects(Vector<IntRect>& rects, const LayoutPoint& add
itionalOffset, const RenderLayerModelObject*) const | 241 void RenderBox::addFocusRingRects(Vector<IntRect>& rects, const LayoutPoint& add
itionalOffset, const RenderLayerModelObject*) const |
311 { | 242 { |
312 if (!size().isEmpty()) | 243 if (!size().isEmpty()) |
313 rects.append(pixelSnappedIntRect(additionalOffset, size())); | 244 rects.append(pixelSnappedIntRect(additionalOffset, size())); |
314 } | 245 } |
315 | 246 |
316 bool RenderBox::scroll(ScrollDirection direction, ScrollGranularity granularity,
float delta) | |
317 { | |
318 // FIXME(sky): Remove. | |
319 return false; | |
320 } | |
321 | |
322 bool RenderBox::canBeProgramaticallyScrolled() const | |
323 { | |
324 Node* node = this->node(); | |
325 if (node && node->isDocumentNode()) | |
326 return true; | |
327 | |
328 if (!hasOverflowClip()) | |
329 return false; | |
330 | |
331 bool hasScrollableOverflow = hasScrollableOverflowX() || hasScrollableOverfl
owY(); | |
332 if (scrollsOverflow() && hasScrollableOverflow) | |
333 return true; | |
334 | |
335 return node && node->hasEditableStyle(); | |
336 } | |
337 | |
338 void RenderBox::autoscroll(const IntPoint& position) | |
339 { | |
340 LocalFrame* frame = this->frame(); | |
341 if (!frame) | |
342 return; | |
343 | |
344 FrameView* frameView = frame->view(); | |
345 if (!frameView) | |
346 return; | |
347 | |
348 IntPoint currentDocumentPosition = frameView->windowToContents(position); | |
349 scrollRectToVisible(LayoutRect(currentDocumentPosition, LayoutSize(1, 1)), S
crollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded); | |
350 } | |
351 | |
352 bool RenderBox::autoscrollInProgress() const | |
353 { | |
354 return frame() && frame()->page() && frame()->page()->autoscrollController()
.autoscrollInProgress(this); | |
355 } | |
356 | |
357 // FIXME(sky): Replace with canBeScrolledAndHasScrollableArea. | |
358 bool RenderBox::canAutoscroll() const | |
359 { | |
360 // FIXME(sky): Remove. | |
361 return false; | |
362 } | |
363 | |
364 // If specified point is in border belt, returned offset denotes direction of | |
365 // scrolling. | |
366 IntSize RenderBox::calculateAutoscrollDirection(const IntPoint& windowPoint) con
st | |
367 { | |
368 if (!frame()) | |
369 return IntSize(); | |
370 | |
371 FrameView* frameView = frame()->view(); | |
372 if (!frameView) | |
373 return IntSize(); | |
374 | |
375 IntRect box(absoluteBoundingBoxRect()); | |
376 IntRect windowBox = view()->frameView()->contentsToWindow(box); | |
377 | |
378 IntPoint windowAutoscrollPoint = windowPoint; | |
379 | |
380 if (windowAutoscrollPoint.x() < windowBox.x() + autoscrollBeltSize) | |
381 windowAutoscrollPoint.move(-autoscrollBeltSize, 0); | |
382 else if (windowAutoscrollPoint.x() > windowBox.maxX() - autoscrollBeltSize) | |
383 windowAutoscrollPoint.move(autoscrollBeltSize, 0); | |
384 | |
385 if (windowAutoscrollPoint.y() < windowBox.y() + autoscrollBeltSize) | |
386 windowAutoscrollPoint.move(0, -autoscrollBeltSize); | |
387 else if (windowAutoscrollPoint.y() > windowBox.maxY() - autoscrollBeltSize) | |
388 windowAutoscrollPoint.move(0, autoscrollBeltSize); | |
389 | |
390 return windowAutoscrollPoint - windowPoint; | |
391 } | |
392 | |
393 RenderBox* RenderBox::findAutoscrollable(RenderObject* renderer) | |
394 { | |
395 while (renderer && !(renderer->isBox() && toRenderBox(renderer)->canAutoscro
ll())) { | |
396 renderer = renderer->parent(); | |
397 } | |
398 | |
399 return renderer && renderer->isBox() ? toRenderBox(renderer) : 0; | |
400 } | |
401 | |
402 void RenderBox::scrollByRecursively(const IntSize& delta, ScrollOffsetClamping c
lamp) | |
403 { | |
404 // FIXME(sky): Remove. | |
405 } | |
406 | |
407 bool RenderBox::needsPreferredWidthsRecalculation() const | 247 bool RenderBox::needsPreferredWidthsRecalculation() const |
408 { | 248 { |
409 return style()->paddingStart().isPercent() || style()->paddingEnd().isPercen
t(); | 249 return style()->paddingStart().isPercent() || style()->paddingEnd().isPercen
t(); |
410 } | 250 } |
411 | 251 |
412 IntSize RenderBox::scrolledContentOffset() const | |
413 { | |
414 // FIXME(sky): Remove. | |
415 return IntSize(); | |
416 } | |
417 | |
418 void RenderBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layou
tUnit& maxLogicalWidth) const | 252 void RenderBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layou
tUnit& maxLogicalWidth) const |
419 { | 253 { |
420 minLogicalWidth = minPreferredLogicalWidth() - borderAndPaddingLogicalWidth(
); | 254 minLogicalWidth = minPreferredLogicalWidth() - borderAndPaddingLogicalWidth(
); |
421 maxLogicalWidth = maxPreferredLogicalWidth() - borderAndPaddingLogicalWidth(
); | 255 maxLogicalWidth = maxPreferredLogicalWidth() - borderAndPaddingLogicalWidth(
); |
422 } | 256 } |
423 | 257 |
424 LayoutUnit RenderBox::minPreferredLogicalWidth() const | 258 LayoutUnit RenderBox::minPreferredLogicalWidth() const |
425 { | 259 { |
426 if (preferredLogicalWidthsDirty()) { | 260 if (preferredLogicalWidthsDirty()) { |
427 #if ENABLE(ASSERT) | 261 #if ENABLE(ASSERT) |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 } | 485 } |
652 paintFillLayers(paintInfo, backgroundColor, style()->backgroundLayers(), pai
ntRect, bleedAvoidance); | 486 paintFillLayers(paintInfo, backgroundColor, style()->backgroundLayers(), pai
ntRect, bleedAvoidance); |
653 } | 487 } |
654 | 488 |
655 bool RenderBox::backgroundHasOpaqueTopLayer() const | 489 bool RenderBox::backgroundHasOpaqueTopLayer() const |
656 { | 490 { |
657 const FillLayer& fillLayer = style()->backgroundLayers(); | 491 const FillLayer& fillLayer = style()->backgroundLayers(); |
658 if (fillLayer.clip() != BorderFillBox) | 492 if (fillLayer.clip() != BorderFillBox) |
659 return false; | 493 return false; |
660 | 494 |
661 // Clipped with local scrolling | |
662 if (hasOverflowClip() && fillLayer.attachment() == LocalBackgroundAttachment
) | |
663 return false; | |
664 | |
665 if (fillLayer.hasOpaqueImage(this) && fillLayer.hasRepeatXY() && fillLayer.i
mage()->canRender(*this)) | 495 if (fillLayer.hasOpaqueImage(this) && fillLayer.hasRepeatXY() && fillLayer.i
mage()->canRender(*this)) |
666 return true; | 496 return true; |
667 | 497 |
668 // If there is only one layer and no image, check whether the background col
or is opaque | 498 // If there is only one layer and no image, check whether the background col
or is opaque |
669 if (!fillLayer.next() && !fillLayer.hasImage()) { | 499 if (!fillLayer.next() && !fillLayer.hasImage()) { |
670 Color bgColor = resolveColor(CSSPropertyBackgroundColor); | 500 Color bgColor = resolveColor(CSSPropertyBackgroundColor); |
671 if (bgColor.alpha() == 255) | 501 if (bgColor.alpha() == 255) |
672 return true; | 502 return true; |
673 } | 503 } |
674 | 504 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 | 597 |
768 if (contentsClipBehavior == SkipContentsClipIfPossible) { | 598 if (contentsClipBehavior == SkipContentsClipIfPossible) { |
769 LayoutRect contentsVisualOverflow = contentsVisualOverflowRect(); | 599 LayoutRect contentsVisualOverflow = contentsVisualOverflowRect(); |
770 if (contentsVisualOverflow.isEmpty()) | 600 if (contentsVisualOverflow.isEmpty()) |
771 return false; | 601 return false; |
772 | 602 |
773 LayoutRect conservativeClipRect = clipRect; | 603 LayoutRect conservativeClipRect = clipRect; |
774 if (hasBorderRadius) | 604 if (hasBorderRadius) |
775 conservativeClipRect.intersect(clipRoundedRect.radiusCenterRect()); | 605 conservativeClipRect.intersect(clipRoundedRect.radiusCenterRect()); |
776 conservativeClipRect.moveBy(-accumulatedOffset); | 606 conservativeClipRect.moveBy(-accumulatedOffset); |
777 if (hasLayer()) | |
778 conservativeClipRect.move(scrolledContentOffset()); | |
779 if (conservativeClipRect.contains(contentsVisualOverflow)) | 607 if (conservativeClipRect.contains(contentsVisualOverflow)) |
780 return false; | 608 return false; |
781 } | 609 } |
782 | 610 |
783 if (paintInfo.phase == PaintPhaseOutline) | 611 if (paintInfo.phase == PaintPhaseOutline) |
784 paintInfo.phase = PaintPhaseChildOutlines; | 612 paintInfo.phase = PaintPhaseChildOutlines; |
785 paintInfo.context->save(); | 613 paintInfo.context->save(); |
786 if (hasBorderRadius) | 614 if (hasBorderRadius) |
787 paintInfo.context->clipRoundedRect(clipRoundedRect); | 615 paintInfo.context->clipRoundedRect(clipRoundedRect); |
788 paintInfo.context->clip(pixelSnappedIntRect(clipRect)); | 616 paintInfo.context->clip(pixelSnappedIntRect(clipRect)); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 { | 705 { |
878 ASSERT(o == container()); | 706 ASSERT(o == container()); |
879 | 707 |
880 LayoutSize offset; | 708 LayoutSize offset; |
881 if (isRelPositioned()) | 709 if (isRelPositioned()) |
882 offset += offsetForInFlowPosition(); | 710 offset += offsetForInFlowPosition(); |
883 | 711 |
884 if (!isInline() || isReplaced()) | 712 if (!isInline() || isReplaced()) |
885 offset += locationOffset(); | 713 offset += locationOffset(); |
886 | 714 |
887 if (o->hasOverflowClip()) | |
888 offset -= toRenderBox(o)->scrolledContentOffset(); | |
889 | |
890 if (style()->position() == AbsolutePosition && o->isRelPositioned() && o->is
RenderInline()) | 715 if (style()->position() == AbsolutePosition && o->isRelPositioned() && o->is
RenderInline()) |
891 offset += toRenderInline(o)->offsetForInFlowPositionedInline(*this); | 716 offset += toRenderInline(o)->offsetForInFlowPositionedInline(*this); |
892 | 717 |
893 return offset; | 718 return offset; |
894 } | 719 } |
895 | 720 |
896 InlineBox* RenderBox::createInlineBox() | 721 InlineBox* RenderBox::createInlineBox() |
897 { | 722 { |
898 return new InlineBox(*this); | 723 return new InlineBox(*this); |
899 } | 724 } |
(...skipping 1995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2895 | 2720 |
2896 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style) | 2721 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style) |
2897 { | 2722 { |
2898 backgroundColor = style.colorIncludingFallback(CSSPropertyBackgroundColor); | 2723 backgroundColor = style.colorIncludingFallback(CSSPropertyBackgroundColor); |
2899 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage(); | 2724 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage(); |
2900 ASSERT(hasBackground == style.hasBackground()); | 2725 ASSERT(hasBackground == style.hasBackground()); |
2901 hasBorder = style.hasBorder(); | 2726 hasBorder = style.hasBorder(); |
2902 } | 2727 } |
2903 | 2728 |
2904 } // namespace blink | 2729 } // namespace blink |
OLD | NEW |