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) 2000 Simon Hausmann (hausmann@kde.org) | 4 * (C) 2000 Simon Hausmann (hausmann@kde.org) |
5 * (C) 2001 Dirk Mueller (mueller@kde.org) | 5 * (C) 2001 Dirk Mueller (mueller@kde.org) |
6 * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. | 6 * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 18 matching lines...) Expand all Loading... | |
29 #include "bindings/v8/ScriptEventListener.h" | 29 #include "bindings/v8/ScriptEventListener.h" |
30 #include "core/css/CSSImageValue.h" | 30 #include "core/css/CSSImageValue.h" |
31 #include "core/css/parser/BisonCSSParser.h" | 31 #include "core/css/parser/BisonCSSParser.h" |
32 #include "core/css/StylePropertySet.h" | 32 #include "core/css/StylePropertySet.h" |
33 #include "core/dom/Attribute.h" | 33 #include "core/dom/Attribute.h" |
34 #include "core/events/ThreadLocalEventNames.h" | 34 #include "core/events/ThreadLocalEventNames.h" |
35 #include "core/html/HTMLFrameElementBase.h" | 35 #include "core/html/HTMLFrameElementBase.h" |
36 #include "core/html/parser/HTMLParserIdioms.h" | 36 #include "core/html/parser/HTMLParserIdioms.h" |
37 #include "core/frame/Frame.h" | 37 #include "core/frame/Frame.h" |
38 #include "core/frame/FrameView.h" | 38 #include "core/frame/FrameView.h" |
39 #include "core/rendering/RenderBox.h" | |
39 | 40 |
40 namespace WebCore { | 41 namespace WebCore { |
41 | 42 |
42 using namespace HTMLNames; | 43 using namespace HTMLNames; |
43 | 44 |
44 HTMLBodyElement::HTMLBodyElement(Document& document) | 45 HTMLBodyElement::HTMLBodyElement(Document& document) |
45 : HTMLElement(bodyTag, document) | 46 : HTMLElement(bodyTag, document) |
46 { | 47 { |
47 ScriptWrappable::init(this); | 48 ScriptWrappable::init(this); |
48 } | 49 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 Frame* frame = document->frame(); | 191 Frame* frame = document->frame(); |
191 float zoomFactor = frame->pageZoomFactor(); | 192 float zoomFactor = frame->pageZoomFactor(); |
192 if (zoomFactor == 1) | 193 if (zoomFactor == 1) |
193 return value; | 194 return value; |
194 // Needed because of truncation (rather than rounding) when scaling up. | 195 // Needed because of truncation (rather than rounding) when scaling up. |
195 if (zoomFactor > 1) | 196 if (zoomFactor > 1) |
196 value++; | 197 value++; |
197 return static_cast<int>(value / zoomFactor); | 198 return static_cast<int>(value / zoomFactor); |
198 } | 199 } |
199 | 200 |
200 // FIXME: There are cases where body.scrollLeft is allowed to return | 201 // Blink, Gecko and Presto's quirks mode implementations of overflow set to the |
201 // non-zero values in both quirks and strict mode. It happens when | 202 // body element differ from IE's: the formers can create a scrollable area for t he |
202 // <body> has an overflow that is not the Frame overflow. | 203 // body element that is not the same as the root elements's one. On IE's quirks mode |
203 // http://dev.w3.org/csswg/cssom-view/#dom-element-scrollleft | 204 // though, as body is the root element, body's and the root element's scrollable areas, |
204 // http://code.google.com/p/chromium/issues/detail?id=312435 | 205 // if any, are the same. |
206 // In order words, a <body> will only have an overflow clip (that differs from | |
207 // documentElement's) if both html and body nodes have its overflow set to eith er hidden, | |
208 // auto or scroll. | |
209 // That said, Blink's {set}scroll{Top,Left} behaviors match Gecko's: even if the re is a non-overflown | |
210 // scrollable area, scrolling should not get propageted to the viewport in neith er strict | |
Julien - ping for review
2014/01/28 18:03:29
typo: propagated
| |
211 // or quirks modes. | |
205 int HTMLBodyElement::scrollLeft() | 212 int HTMLBodyElement::scrollLeft() |
206 { | 213 { |
207 Document& document = this->document(); | 214 Document& document = this->document(); |
208 document.updateLayoutIgnorePendingStylesheets(); | 215 document.updateLayoutIgnorePendingStylesheets(); |
209 | 216 |
210 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { | 217 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { |
218 RenderBox* render = renderBox(); | |
219 if (!render) | |
220 return 0; | |
221 if (render->hasOverflowClip()) | |
222 return adjustForAbsoluteZoom(render->scrollLeft(), render); | |
211 if (!document.inQuirksMode()) | 223 if (!document.inQuirksMode()) |
212 return 0; | 224 return 0; |
213 } | 225 } |
214 | 226 |
215 FrameView* view = document.view(); | 227 FrameView* view = document.view(); |
216 return view ? adjustForZoom(view->scrollX(), &document) : 0; | 228 return view ? adjustForZoom(view->scrollX(), &document) : 0; |
217 } | 229 } |
218 | 230 |
219 void HTMLBodyElement::setScrollLeft(int scrollLeft) | 231 void HTMLBodyElement::setScrollLeft(int scrollLeft) |
220 { | 232 { |
221 Document& document = this->document(); | 233 Document& document = this->document(); |
222 document.updateLayoutIgnorePendingStylesheets(); | 234 document.updateLayoutIgnorePendingStylesheets(); |
223 | 235 |
224 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { | 236 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { |
237 RenderBox* render = renderBox(); | |
238 if (!render) | |
239 return; | |
240 if (render->hasOverflowClip()) { | |
241 // FIXME: Investigate if the explicit cast here is actually needed. | |
Julien - ping for review
2014/01/28 18:03:29
I prefer actionable FIXMEs, here this FIXME doesn'
| |
242 render->setScrollLeft(static_cast<int>(scrollLeft * render->style()- >effectiveZoom())); | |
243 return; | |
244 } | |
225 if (!document.inQuirksMode()) | 245 if (!document.inQuirksMode()) |
226 return; | 246 return; |
227 } | 247 } |
228 | 248 |
229 Frame* frame = document.frame(); | 249 Frame* frame = document.frame(); |
230 if (!frame) | 250 if (!frame) |
231 return; | 251 return; |
232 FrameView* view = frame->view(); | 252 FrameView* view = frame->view(); |
233 if (!view) | 253 if (!view) |
234 return; | 254 return; |
235 view->setScrollPosition(IntPoint(static_cast<int>(scrollLeft * frame->pageZo omFactor()), view->scrollY())); | 255 view->setScrollPosition(IntPoint(static_cast<int>(scrollLeft * frame->pageZo omFactor()), view->scrollY())); |
236 } | 256 } |
237 | 257 |
238 int HTMLBodyElement::scrollTop() | 258 int HTMLBodyElement::scrollTop() |
239 { | 259 { |
240 Document& document = this->document(); | 260 Document& document = this->document(); |
241 document.updateLayoutIgnorePendingStylesheets(); | 261 document.updateLayoutIgnorePendingStylesheets(); |
242 | 262 |
243 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { | 263 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { |
264 RenderBox* render = renderBox(); | |
265 if (!render) | |
266 return 0; | |
267 if (render->hasOverflowClip()) | |
268 return adjustForAbsoluteZoom(render->scrollTop(), render); | |
244 if (!document.inQuirksMode()) | 269 if (!document.inQuirksMode()) |
245 return 0; | 270 return 0; |
246 } | 271 } |
247 | 272 |
248 FrameView* view = document.view(); | 273 FrameView* view = document.view(); |
249 return view ? adjustForZoom(view->scrollY(), &document) : 0; | 274 return view ? adjustForZoom(view->scrollY(), &document) : 0; |
250 } | 275 } |
251 | 276 |
252 void HTMLBodyElement::setScrollTop(int scrollTop) | 277 void HTMLBodyElement::setScrollTop(int scrollTop) |
253 { | 278 { |
254 Document& document = this->document(); | 279 Document& document = this->document(); |
255 document.updateLayoutIgnorePendingStylesheets(); | 280 document.updateLayoutIgnorePendingStylesheets(); |
256 | 281 |
257 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { | 282 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { |
283 RenderBox* render = renderBox(); | |
284 if (!render) | |
285 return; | |
286 if (render->hasOverflowClip()) { | |
287 // FIXME: Investigate if the explicit cast here is actually needed. | |
288 render->setScrollTop(static_cast<int>(scrollTop * render->style()->e ffectiveZoom())); | |
289 return; | |
290 } | |
258 if (!document.inQuirksMode()) | 291 if (!document.inQuirksMode()) |
259 return; | 292 return; |
260 } | 293 } |
261 | 294 |
262 Frame* frame = document.frame(); | 295 Frame* frame = document.frame(); |
263 if (!frame) | 296 if (!frame) |
264 return; | 297 return; |
265 FrameView* view = frame->view(); | 298 FrameView* view = frame->view(); |
266 if (!view) | 299 if (!view) |
267 return; | 300 return; |
(...skipping 12 matching lines...) Expand all Loading... | |
280 int HTMLBodyElement::scrollWidth() | 313 int HTMLBodyElement::scrollWidth() |
281 { | 314 { |
282 // Update the document's layout. | 315 // Update the document's layout. |
283 Document& document = this->document(); | 316 Document& document = this->document(); |
284 document.updateLayoutIgnorePendingStylesheets(); | 317 document.updateLayoutIgnorePendingStylesheets(); |
285 FrameView* view = document.view(); | 318 FrameView* view = document.view(); |
286 return view ? adjustForZoom(view->contentsWidth(), &document) : 0; | 319 return view ? adjustForZoom(view->contentsWidth(), &document) : 0; |
287 } | 320 } |
288 | 321 |
289 } // namespace WebCore | 322 } // namespace WebCore |
OLD | NEW |