| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 { | 78 { |
| 79 sendUMAMetrics(); | 79 sendUMAMetrics(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 DEFINE_TRACE(VisualViewport) | 82 DEFINE_TRACE(VisualViewport) |
| 83 { | 83 { |
| 84 visitor->trace(m_frameHost); | 84 visitor->trace(m_frameHost); |
| 85 ScrollableArea::trace(visitor); | 85 ScrollableArea::trace(visitor); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void VisualViewport::updateLayoutIgnorePendingStylesheets() |
| 89 { |
| 90 if (!mainFrame()) |
| 91 return; |
| 92 |
| 93 if (Document* document = mainFrame()->document()) |
| 94 document->updateLayoutIgnorePendingStylesheets(); |
| 95 } |
| 96 |
| 97 void VisualViewport::enqueueChangedEvent() |
| 98 { |
| 99 if (!RuntimeEnabledFeatures::visualViewportAPIEnabled()) |
| 100 return; |
| 101 |
| 102 if (Document* document = mainFrame()->document()) |
| 103 document->enqueueVisualViewportChangedEvent(); |
| 104 } |
| 105 |
| 88 void VisualViewport::setSize(const IntSize& size) | 106 void VisualViewport::setSize(const IntSize& size) |
| 89 { | 107 { |
| 90 if (m_size == size) | 108 if (m_size == size) |
| 91 return; | 109 return; |
| 92 | 110 |
| 93 TRACE_EVENT2("blink", "VisualViewport::setSize", "width", size.width(), "hei
ght", size.height()); | 111 TRACE_EVENT2("blink", "VisualViewport::setSize", "width", size.width(), "hei
ght", size.height()); |
| 94 bool widthDidChange = size.width() != m_size.width(); | 112 bool widthDidChange = size.width() != m_size.width(); |
| 95 m_size = size; | 113 m_size = size; |
| 96 | 114 |
| 97 if (m_innerViewportContainerLayer) { | 115 if (m_innerViewportContainerLayer) { |
| 98 m_innerViewportContainerLayer->setSize(FloatSize(m_size)); | 116 m_innerViewportContainerLayer->setSize(FloatSize(m_size)); |
| 99 | 117 |
| 100 // Need to re-compute sizes for the overlay scrollbars. | 118 // Need to re-compute sizes for the overlay scrollbars. |
| 101 initializeScrollbars(); | 119 initializeScrollbars(); |
| 102 } | 120 } |
| 103 | 121 |
| 104 if (!mainFrame()) | 122 if (!mainFrame()) |
| 105 return; | 123 return; |
| 106 | 124 |
| 125 enqueueChangedEvent(); |
| 126 |
| 107 bool autosizerNeedsUpdating = widthDidChange | 127 bool autosizerNeedsUpdating = widthDidChange |
| 108 && mainFrame()->settings() | 128 && mainFrame()->settings() |
| 109 && mainFrame()->settings()->textAutosizingEnabled(); | 129 && mainFrame()->settings()->textAutosizingEnabled(); |
| 110 | 130 |
| 111 if (autosizerNeedsUpdating) { | 131 if (autosizerNeedsUpdating) { |
| 112 // This needs to happen after setting the m_size member since it'll be r
ead in the update call. | 132 // This needs to happen after setting the m_size member since it'll be r
ead in the update call. |
| 113 if (TextAutosizer* textAutosizer = mainFrame()->document()->textAutosize
r()) | 133 if (TextAutosizer* textAutosizer = mainFrame()->document()->textAutosize
r()) |
| 114 textAutosizer->updatePageInfoInAllFrames(); | 134 textAutosizer->updatePageInfoInAllFrames(); |
| 115 } | 135 } |
| 116 } | 136 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 void VisualViewport::move(const FloatSize& delta) | 202 void VisualViewport::move(const FloatSize& delta) |
| 183 { | 203 { |
| 184 setLocation(m_offset + delta); | 204 setLocation(m_offset + delta); |
| 185 } | 205 } |
| 186 | 206 |
| 187 void VisualViewport::setScale(float scale) | 207 void VisualViewport::setScale(float scale) |
| 188 { | 208 { |
| 189 setScaleAndLocation(scale, m_offset); | 209 setScaleAndLocation(scale, m_offset); |
| 190 } | 210 } |
| 191 | 211 |
| 212 double VisualViewport::scrollLeft() |
| 213 { |
| 214 updateLayoutIgnorePendingStylesheets(); |
| 215 |
| 216 return visibleRect().x(); |
| 217 } |
| 218 |
| 219 double VisualViewport::scrollTop() |
| 220 { |
| 221 updateLayoutIgnorePendingStylesheets(); |
| 222 |
| 223 return visibleRect().y(); |
| 224 } |
| 225 |
| 226 void VisualViewport::setScrollLeft(double x) |
| 227 { |
| 228 updateLayoutIgnorePendingStylesheets(); |
| 229 |
| 230 setLocation(FloatPoint(x, visibleRect().y())); |
| 231 } |
| 232 |
| 233 void VisualViewport::setScrollTop(double y) |
| 234 { |
| 235 updateLayoutIgnorePendingStylesheets(); |
| 236 |
| 237 setLocation(FloatPoint(visibleRect().x(), y)); |
| 238 } |
| 239 |
| 240 double VisualViewport::clientWidth() |
| 241 { |
| 242 updateLayoutIgnorePendingStylesheets(); |
| 243 |
| 244 return visibleRect().width(); |
| 245 } |
| 246 |
| 247 double VisualViewport::clientHeight() |
| 248 { |
| 249 updateLayoutIgnorePendingStylesheets(); |
| 250 |
| 251 return visibleRect().height(); |
| 252 } |
| 253 |
| 254 double VisualViewport::pageScale() |
| 255 { |
| 256 updateLayoutIgnorePendingStylesheets(); |
| 257 |
| 258 return m_scale; |
| 259 } |
| 260 |
| 192 void VisualViewport::setScaleAndLocation(float scale, const FloatPoint& location
) | 261 void VisualViewport::setScaleAndLocation(float scale, const FloatPoint& location
) |
| 193 { | 262 { |
| 194 if (!mainFrame()) | 263 if (!mainFrame()) |
| 195 return; | 264 return; |
| 196 | 265 |
| 197 bool valuesChanged = false; | 266 bool valuesChanged = false; |
| 198 | 267 |
| 199 if (scale != m_scale) { | 268 if (scale != m_scale) { |
| 200 m_scale = scale; | 269 m_scale = scale; |
| 201 valuesChanged = true; | 270 valuesChanged = true; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 217 document->enqueueScrollEventForNode(document); | 286 document->enqueueScrollEventForNode(document); |
| 218 } | 287 } |
| 219 | 288 |
| 220 mainFrame()->loader().client()->didChangeScrollOffset(); | 289 mainFrame()->loader().client()->didChangeScrollOffset(); |
| 221 valuesChanged = true; | 290 valuesChanged = true; |
| 222 } | 291 } |
| 223 | 292 |
| 224 if (!valuesChanged) | 293 if (!valuesChanged) |
| 225 return; | 294 return; |
| 226 | 295 |
| 296 enqueueChangedEvent(); |
| 297 |
| 227 InspectorInstrumentation::didUpdateLayout(mainFrame()); | 298 InspectorInstrumentation::didUpdateLayout(mainFrame()); |
| 228 mainFrame()->loader().saveScrollState(); | 299 mainFrame()->loader().saveScrollState(); |
| 229 | 300 |
| 230 clampToBoundaries(); | 301 clampToBoundaries(); |
| 231 } | 302 } |
| 232 | 303 |
| 233 bool VisualViewport::magnifyScaleAroundAnchor(float magnifyDelta, const FloatPoi
nt& anchor) | 304 bool VisualViewport::magnifyScaleAroundAnchor(float magnifyDelta, const FloatPoi
nt& anchor) |
| 234 { | 305 { |
| 235 const float oldPageScale = scale(); | 306 const float oldPageScale = scale(); |
| 236 const float newPageScale = frameHost().chromeClient().clampPageScaleFactorTo
Limits( | 307 const float newPageScale = frameHost().chromeClient().clampPageScaleFactorTo
Limits( |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 } else if (graphicsLayer == m_rootTransformLayer) { | 814 } else if (graphicsLayer == m_rootTransformLayer) { |
| 744 name = "Root Transform Layer"; | 815 name = "Root Transform Layer"; |
| 745 } else { | 816 } else { |
| 746 ASSERT_NOT_REACHED(); | 817 ASSERT_NOT_REACHED(); |
| 747 } | 818 } |
| 748 | 819 |
| 749 return name; | 820 return name; |
| 750 } | 821 } |
| 751 | 822 |
| 752 } // namespace blink | 823 } // namespace blink |
| OLD | NEW |