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/CSSParser.h" | 31 #include "core/css/CSSParser.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(const QualifiedName& tagName, Document& documen t) | 45 HTMLBodyElement::HTMLBodyElement(const QualifiedName& tagName, Document& documen t) |
45 : HTMLElement(tagName, document) | 46 : HTMLElement(tagName, document) |
46 { | 47 { |
47 ASSERT(hasTagName(bodyTag)); | 48 ASSERT(hasTagName(bodyTag)); |
48 ScriptWrappable::init(this); | 49 ScriptWrappable::init(this); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 Frame* frame = document->frame(); | 195 Frame* frame = document->frame(); |
195 float zoomFactor = frame->pageZoomFactor(); | 196 float zoomFactor = frame->pageZoomFactor(); |
196 if (zoomFactor == 1) | 197 if (zoomFactor == 1) |
197 return value; | 198 return value; |
198 // Needed because of truncation (rather than rounding) when scaling up. | 199 // Needed because of truncation (rather than rounding) when scaling up. |
199 if (zoomFactor > 1) | 200 if (zoomFactor > 1) |
200 value++; | 201 value++; |
201 return static_cast<int>(value / zoomFactor); | 202 return static_cast<int>(value / zoomFactor); |
202 } | 203 } |
203 | 204 |
205 // Blink, Gecko and Presto's quirks mode implementations of overflow:scroll set to | |
206 // body element differ from IE's: the formers can create a scrollable area for t he | |
207 // body element that is not the same as the root elements's one. On IE's quirks mode | |
208 // though, as body is the root element, body's and the root element's scrollable areas, | |
209 // if any, are the same. | |
210 // Blink's {set}scroll{Top,Left} behaviors match Gecko's: even if there is a non -overflown | |
211 // scrollable area, scrolling should not get propageted to the viewport in neith er strict | |
212 // or quirks modes. That is why canBeScrolledAndHasScrollableArea is not used, b ut hasOverflowClip. | |
204 int HTMLBodyElement::scrollLeft() | 213 int HTMLBodyElement::scrollLeft() |
205 { | 214 { |
206 Document& document = this->document(); | 215 Document& document = this->document(); |
216 document.updateLayoutIgnorePendingStylesheets(); | |
207 | 217 |
208 // FIXME: There are cases where body.scrollLeft is allowed to return | 218 RenderBox* rend = renderBox(); |
Julien - ping for review
2013/11/01 16:49:15
s/rend/renderBox/. Let's not save any character, s
| |
209 // non-zero values in both quirks and strict mode. It happens when | 219 if (!rend) |
210 // <body> has an overflow that is not the Frame overflow. | 220 return 0; |
211 // http://dev.w3.org/csswg/cssom-view/#dom-element-scrollleft | 221 if (rend->hasOverflowClip()) |
Julien - ping for review
2013/11/01 16:49:15
FYI if <body> is the document element, this will b
| |
222 return adjustForAbsoluteZoom(rend->scrollLeft(), rend); | |
223 | |
212 if (!document.inQuirksMode()) | 224 if (!document.inQuirksMode()) |
213 UseCounter::countDeprecation(&document, UseCounter::ScrollLeftBodyNotQui rksMode); | 225 UseCounter::countDeprecation(&document, UseCounter::ScrollLeftBodyNotQui rksMode); |
214 | 226 |
215 document.updateLayoutIgnorePendingStylesheets(); | |
216 FrameView* view = document.view(); | 227 FrameView* view = document.view(); |
217 return view ? adjustForZoom(view->scrollX(), &document) : 0; | 228 return view ? adjustForZoom(view->scrollX(), &document) : 0; |
218 } | 229 } |
219 | 230 |
220 void HTMLBodyElement::setScrollLeft(int scrollLeft) | 231 void HTMLBodyElement::setScrollLeft(int scrollLeft) |
221 { | 232 { |
222 Document& document = this->document(); | 233 Document& document = this->document(); |
234 document.updateLayoutIgnorePendingStylesheets(); | |
235 | |
236 RenderBox* rend = renderBox(); | |
237 if (!rend) | |
238 return; | |
239 if (rend->hasOverflowClip()) { | |
240 rend->setScrollLeft(static_cast<int>(scrollLeft * rend->style()->effecti veZoom())); | |
Julien - ping for review
2013/11/01 16:49:15
Why the explicit static_cast instead of an implici
| |
241 return; | |
242 } | |
223 | 243 |
224 if (!document.inQuirksMode()) | 244 if (!document.inQuirksMode()) |
225 UseCounter::countDeprecation(&document, UseCounter::ScrollLeftBodyNotQui rksMode); | 245 UseCounter::countDeprecation(&document, UseCounter::ScrollLeftBodyNotQui rksMode); |
226 | |
227 document.updateLayoutIgnorePendingStylesheets(); | |
228 Frame* frame = document.frame(); | 246 Frame* frame = document.frame(); |
229 if (!frame) | 247 if (!frame) |
230 return; | 248 return; |
231 FrameView* view = frame->view(); | 249 FrameView* view = frame->view(); |
232 if (!view) | 250 if (!view) |
233 return; | 251 return; |
234 view->setScrollPosition(IntPoint(static_cast<int>(scrollLeft * frame->pageZo omFactor()), view->scrollY())); | 252 view->setScrollPosition(IntPoint(static_cast<int>(scrollLeft * frame->pageZo omFactor()), view->scrollY())); |
235 } | 253 } |
236 | 254 |
237 int HTMLBodyElement::scrollTop() | 255 int HTMLBodyElement::scrollTop() |
238 { | 256 { |
239 Document& document = this->document(); | 257 Document& document = this->document(); |
258 document.updateLayoutIgnorePendingStylesheets(); | |
240 | 259 |
241 // FIXME: There are cases where body.scrollTop is allowed to return | 260 RenderBox* rend = renderBox(); |
242 // non-zero values in both quirks and strict mode. It happens when | 261 if (!rend) |
243 // body has a overflow that is not the Frame overflow. | 262 return 0; |
244 // http://dev.w3.org/csswg/cssom-view/#dom-element-scrolltop | 263 if (rend->hasOverflowClip()) |
264 return adjustForAbsoluteZoom(rend->scrollTop(), rend); | |
265 | |
245 if (!document.inQuirksMode()) | 266 if (!document.inQuirksMode()) |
246 UseCounter::countDeprecation(&document, UseCounter::ScrollTopBodyNotQuir ksMode); | 267 UseCounter::countDeprecation(&document, UseCounter::ScrollTopBodyNotQuir ksMode); |
247 | 268 |
248 document.updateLayoutIgnorePendingStylesheets(); | |
249 FrameView* view = document.view(); | 269 FrameView* view = document.view(); |
250 return view ? adjustForZoom(view->scrollY(), &document) : 0; | 270 return view ? adjustForZoom(view->scrollY(), &document) : 0; |
251 } | 271 } |
252 | 272 |
253 void HTMLBodyElement::setScrollTop(int scrollTop) | 273 void HTMLBodyElement::setScrollTop(int scrollTop) |
254 { | 274 { |
255 Document& document = this->document(); | 275 Document& document = this->document(); |
276 document.updateLayoutIgnorePendingStylesheets(); | |
277 | |
278 RenderBox* rend = renderBox(); | |
279 if (!rend) | |
280 return; | |
281 if (rend->hasOverflowClip()) { | |
282 rend->setScrollTop(static_cast<int>(scrollTop * rend->style()->effective Zoom())); | |
283 return; | |
284 } | |
256 | 285 |
257 if (!document.inQuirksMode()) | 286 if (!document.inQuirksMode()) |
258 UseCounter::countDeprecation(&document, UseCounter::ScrollTopBodyNotQuir ksMode); | 287 UseCounter::countDeprecation(&document, UseCounter::ScrollTopBodyNotQuir ksMode); |
259 | 288 |
260 document.updateLayoutIgnorePendingStylesheets(); | |
261 Frame* frame = document.frame(); | 289 Frame* frame = document.frame(); |
262 if (!frame) | 290 if (!frame) |
263 return; | 291 return; |
264 FrameView* view = frame->view(); | 292 FrameView* view = frame->view(); |
265 if (!view) | 293 if (!view) |
266 return; | 294 return; |
267 view->setScrollPosition(IntPoint(view->scrollX(), static_cast<int>(scrollTop * frame->pageZoomFactor()))); | 295 view->setScrollPosition(IntPoint(view->scrollX(), static_cast<int>(scrollTop * frame->pageZoomFactor()))); |
268 } | 296 } |
269 | 297 |
270 int HTMLBodyElement::scrollHeight() | 298 int HTMLBodyElement::scrollHeight() |
(...skipping 15 matching lines...) Expand all Loading... | |
286 } | 314 } |
287 | 315 |
288 void HTMLBodyElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const | 316 void HTMLBodyElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const |
289 { | 317 { |
290 HTMLElement::addSubresourceAttributeURLs(urls); | 318 HTMLElement::addSubresourceAttributeURLs(urls); |
291 | 319 |
292 addSubresourceURL(urls, document().completeURL(getAttribute(backgroundAttr)) ); | 320 addSubresourceURL(urls, document().completeURL(getAttribute(backgroundAttr)) ); |
293 } | 321 } |
294 | 322 |
295 } // namespace WebCore | 323 } // namespace WebCore |
OLD | NEW |