OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 , m_selectionStart(nullptr) | 55 , m_selectionStart(nullptr) |
56 , m_selectionEnd(nullptr) | 56 , m_selectionEnd(nullptr) |
57 , m_selectionStartPos(-1) | 57 , m_selectionStartPos(-1) |
58 , m_selectionEndPos(-1) | 58 , m_selectionEndPos(-1) |
59 , m_pageLogicalHeight(0) | 59 , m_pageLogicalHeight(0) |
60 , m_pageLogicalHeightChanged(false) | 60 , m_pageLogicalHeightChanged(false) |
61 , m_layoutState(nullptr) | 61 , m_layoutState(nullptr) |
62 , m_layoutQuoteHead(nullptr) | 62 , m_layoutQuoteHead(nullptr) |
63 , m_layoutCounterCount(0) | 63 , m_layoutCounterCount(0) |
64 , m_hitTestCount(0) | 64 , m_hitTestCount(0) |
| 65 , m_hitTestCacheHits(0) |
| 66 , m_hitTestCache(HitTestCache::create()) |
65 , m_pendingSelection(PendingSelection::create()) | 67 , m_pendingSelection(PendingSelection::create()) |
66 { | 68 { |
67 // init LayoutObject attributes | 69 // init LayoutObject attributes |
68 setInline(false); | 70 setInline(false); |
69 | 71 |
70 m_minPreferredLogicalWidth = 0; | 72 m_minPreferredLogicalWidth = 0; |
71 m_maxPreferredLogicalWidth = 0; | 73 m_maxPreferredLogicalWidth = 0; |
72 | 74 |
73 setPreferredLogicalWidthsDirty(MarkOnlyThis); | 75 setPreferredLogicalWidthsDirty(MarkOnlyThis); |
74 | 76 |
75 setPositionState(AbsolutePosition); // to 0,0 :) | 77 setPositionState(AbsolutePosition); // to 0,0 :) |
76 } | 78 } |
77 | 79 |
78 LayoutView::~LayoutView() | 80 LayoutView::~LayoutView() |
79 { | 81 { |
80 } | 82 } |
81 | 83 |
82 bool LayoutView::hitTest(HitTestResult& result) | 84 bool LayoutView::hitTest(HitTestResult& result) |
83 { | 85 { |
84 return hitTest(result.hitTestRequest(), result.hitTestLocation(), result); | |
85 } | |
86 | |
87 bool LayoutView::hitTest(const HitTestRequest& request, const HitTestLocation& l
ocation, HitTestResult& result) | |
88 { | |
89 TRACE_EVENT_BEGIN0("blink,devtools.timeline", "HitTest"); | 86 TRACE_EVENT_BEGIN0("blink,devtools.timeline", "HitTest"); |
90 m_hitTestCount++; | 87 m_hitTestCount++; |
91 | 88 |
92 ASSERT(!location.isRectBasedTest() || request.listBased()); | 89 ASSERT(!result.hitTestLocation().isRectBasedTest() || result.hitTestRequest(
).listBased()); |
93 | 90 |
94 // We have to recursively update layout/style here because otherwise, when t
he hit test recurses | 91 // We have to recursively update layout/style here because otherwise, when t
he hit test recurses |
95 // into a child document, it could trigger a layout on the parent document,
which can destroy DeprecatedPaintLayer | 92 // into a child document, it could trigger a layout on the parent document,
which can destroy DeprecatedPaintLayer |
96 // that are higher up in the call stack, leading to crashes. | 93 // that are higher up in the call stack, leading to crashes. |
97 // Note that Document::updateLayout calls its parent's updateLayout. | 94 // Note that Document::updateLayout calls its parent's updateLayout. |
98 // FIXME: It should be the caller's responsibility to ensure an up-to-date l
ayout. | 95 // FIXME: It should be the caller's responsibility to ensure an up-to-date l
ayout. |
99 frameView()->updateLayoutAndStyleForPainting(); | 96 frameView()->updateLayoutAndStyleForPainting(); |
100 commitPendingSelection(); | 97 commitPendingSelection(); |
101 | 98 |
102 bool hitLayer = layer()->hitTest(request, location, result); | 99 uint64_t domTreeVersion = document().domTreeVersion(); |
| 100 HitTestResult cacheResult = result; |
| 101 bool cacheHit = m_hitTestCache->lookupCachedResult(cacheResult, domTreeVersi
on); |
| 102 bool hitLayer = layer()->hitTest(result); |
103 | 103 |
104 // FrameView scrollbars are not the same as Layer scrollbars tested by Layer
::hitTestOverflowControls, | 104 // FrameView scrollbars are not the same as Layer scrollbars tested by Layer
::hitTestOverflowControls, |
105 // so we need to test FrameView scrollbars separately here. Note that it's i
mportant we do this after | 105 // so we need to test FrameView scrollbars separately here. Note that it's i
mportant we do this after |
106 // the hit test above, because that may overwrite the entire HitTestResult w
hen it finds a hit. | 106 // the hit test above, because that may overwrite the entire HitTestResult w
hen it finds a hit. |
107 IntPoint framePoint = frameView()->contentsToFrame(location.roundedPoint()); | 107 IntPoint framePoint = frameView()->contentsToFrame(result.hitTestLocation().
roundedPoint()); |
108 if (Scrollbar* frameScrollbar = frameView()->scrollbarAtFramePoint(framePoin
t)) | 108 if (Scrollbar* frameScrollbar = frameView()->scrollbarAtFramePoint(framePoin
t)) |
109 result.setScrollbar(frameScrollbar); | 109 result.setScrollbar(frameScrollbar); |
110 | 110 |
111 TRACE_EVENT_END1("blink,devtools.timeline", "HitTest", "endData", InspectorH
itTestEvent::endData(request, location, result)); | 111 if (cacheHit) { |
| 112 m_hitTestCacheHits++; |
| 113 m_hitTestCache->verifyCachedResult(result, cacheResult); |
| 114 } |
| 115 |
| 116 if (hitLayer) |
| 117 m_hitTestCache->addCachedResult(result, domTreeVersion); |
| 118 |
| 119 TRACE_EVENT_END1("blink,devtools.timeline", "HitTest", "endData", InspectorH
itTestEvent::endData(result.hitTestRequest(), result.hitTestLocation(), result))
; |
112 return hitLayer; | 120 return hitLayer; |
113 } | 121 } |
114 | 122 |
115 void LayoutView::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit, Logi
calExtentComputedValues& computedValues) const | 123 void LayoutView::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit, Logi
calExtentComputedValues& computedValues) const |
116 { | 124 { |
117 computedValues.m_extent = (!shouldUsePrintingLayout() && m_frameView) ? Layo
utUnit(viewLogicalHeightForBoxSizing()) : logicalHeight; | 125 computedValues.m_extent = (!shouldUsePrintingLayout() && m_frameView) ? Layo
utUnit(viewLogicalHeightForBoxSizing()) : logicalHeight; |
118 } | 126 } |
119 | 127 |
120 void LayoutView::updateLogicalWidth() | 128 void LayoutView::updateLogicalWidth() |
121 { | 129 { |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
950 return viewHeight(IncludeScrollbars) / scale; | 958 return viewHeight(IncludeScrollbars) / scale; |
951 } | 959 } |
952 | 960 |
953 void LayoutView::willBeDestroyed() | 961 void LayoutView::willBeDestroyed() |
954 { | 962 { |
955 LayoutBlockFlow::willBeDestroyed(); | 963 LayoutBlockFlow::willBeDestroyed(); |
956 m_compositor.clear(); | 964 m_compositor.clear(); |
957 } | 965 } |
958 | 966 |
959 } // namespace blink | 967 } // namespace blink |
OLD | NEW |