| 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) 2001 Peter Kelly (pmk@post.com) | 4 * (C) 2001 Peter Kelly (pmk@post.com) |
| 5 * (C) 2001 Dirk Mueller (mueller@kde.org) | 5 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 6 * (C) 2007 David Smith (catfish.man@gmail.com) | 6 * (C) 2007 David Smith (catfish.man@gmail.com) |
| 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
All rights reserved. | 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
All rights reserved. |
| 8 * (C) 2007 Eric Seidel (eric@webkit.org) | 8 * (C) 2007 Eric Seidel (eric@webkit.org) |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 return toValidDirValue(getAttribute(HTMLNames::dirAttr)); | 351 return toValidDirValue(getAttribute(HTMLNames::dirAttr)); |
| 352 } | 352 } |
| 353 | 353 |
| 354 void Element::setDir(const AtomicString& value) | 354 void Element::setDir(const AtomicString& value) |
| 355 { | 355 { |
| 356 setAttribute(HTMLNames::dirAttr, value); | 356 setAttribute(HTMLNames::dirAttr, value); |
| 357 } | 357 } |
| 358 | 358 |
| 359 int Element::offsetLeft() | 359 int Element::offsetLeft() |
| 360 { | 360 { |
| 361 document().updateLayoutIgnorePendingStylesheets(); | 361 document().updateLayout(); |
| 362 if (RenderBoxModelObject* renderer = renderBoxModelObject()) | 362 if (RenderBoxModelObject* renderer = renderBoxModelObject()) |
| 363 return renderer->offsetLeft(); | 363 return renderer->offsetLeft(); |
| 364 return 0; | 364 return 0; |
| 365 } | 365 } |
| 366 | 366 |
| 367 int Element::offsetTop() | 367 int Element::offsetTop() |
| 368 { | 368 { |
| 369 document().updateLayoutIgnorePendingStylesheets(); | 369 document().updateLayout(); |
| 370 if (RenderBoxModelObject* renderer = renderBoxModelObject()) | 370 if (RenderBoxModelObject* renderer = renderBoxModelObject()) |
| 371 return renderer->pixelSnappedOffsetTop(); | 371 return renderer->pixelSnappedOffsetTop(); |
| 372 return 0; | 372 return 0; |
| 373 } | 373 } |
| 374 | 374 |
| 375 int Element::offsetWidth() | 375 int Element::offsetWidth() |
| 376 { | 376 { |
| 377 document().updateLayoutIgnorePendingStylesheets(); | 377 document().updateLayout(); |
| 378 if (RenderBoxModelObject* renderer = renderBoxModelObject()) | 378 if (RenderBoxModelObject* renderer = renderBoxModelObject()) |
| 379 return renderer->pixelSnappedOffsetWidth(); | 379 return renderer->pixelSnappedOffsetWidth(); |
| 380 return 0; | 380 return 0; |
| 381 } | 381 } |
| 382 | 382 |
| 383 int Element::offsetHeight() | 383 int Element::offsetHeight() |
| 384 { | 384 { |
| 385 document().updateLayoutIgnorePendingStylesheets(); | 385 document().updateLayout(); |
| 386 if (RenderBoxModelObject* renderer = renderBoxModelObject()) | 386 if (RenderBoxModelObject* renderer = renderBoxModelObject()) |
| 387 return renderer->pixelSnappedOffsetHeight(); | 387 return renderer->pixelSnappedOffsetHeight(); |
| 388 return 0; | 388 return 0; |
| 389 } | 389 } |
| 390 | 390 |
| 391 Element* Element::offsetParent() | 391 Element* Element::offsetParent() |
| 392 { | 392 { |
| 393 document().updateLayoutIgnorePendingStylesheets(); | 393 document().updateLayout(); |
| 394 if (RenderObject* renderer = this->renderer()) | 394 if (RenderObject* renderer = this->renderer()) |
| 395 return renderer->offsetParent(); | 395 return renderer->offsetParent(); |
| 396 return 0; | 396 return 0; |
| 397 } | 397 } |
| 398 | 398 |
| 399 int Element::clientLeft() | 399 int Element::clientLeft() |
| 400 { | 400 { |
| 401 document().updateLayoutIgnorePendingStylesheets(); | 401 document().updateLayout(); |
| 402 | 402 |
| 403 if (RenderBox* renderer = renderBox()) | 403 if (RenderBox* renderer = renderBox()) |
| 404 return roundToInt(renderer->clientLeft()); | 404 return roundToInt(renderer->clientLeft()); |
| 405 return 0; | 405 return 0; |
| 406 } | 406 } |
| 407 | 407 |
| 408 int Element::clientTop() | 408 int Element::clientTop() |
| 409 { | 409 { |
| 410 document().updateLayoutIgnorePendingStylesheets(); | 410 document().updateLayout(); |
| 411 | 411 |
| 412 if (RenderBox* renderer = renderBox()) | 412 if (RenderBox* renderer = renderBox()) |
| 413 return roundToInt(renderer->clientTop()); | 413 return roundToInt(renderer->clientTop()); |
| 414 return 0; | 414 return 0; |
| 415 } | 415 } |
| 416 | 416 |
| 417 int Element::clientWidth() | 417 int Element::clientWidth() |
| 418 { | 418 { |
| 419 document().updateLayoutIgnorePendingStylesheets(); | 419 document().updateLayout(); |
| 420 | 420 |
| 421 // FIXME(sky): Can we just use getBoundingClientRect() instead? | 421 // FIXME(sky): Can we just use getBoundingClientRect() instead? |
| 422 if (document().documentElement() == this) { | 422 if (document().documentElement() == this) { |
| 423 if (FrameView* view = document().view()) | 423 if (FrameView* view = document().view()) |
| 424 return view->layoutSize().width(); | 424 return view->layoutSize().width(); |
| 425 } | 425 } |
| 426 | 426 |
| 427 if (RenderBox* renderer = renderBox()) | 427 if (RenderBox* renderer = renderBox()) |
| 428 return renderer->pixelSnappedClientWidth(); | 428 return renderer->pixelSnappedClientWidth(); |
| 429 return 0; | 429 return 0; |
| 430 } | 430 } |
| 431 | 431 |
| 432 int Element::clientHeight() | 432 int Element::clientHeight() |
| 433 { | 433 { |
| 434 document().updateLayoutIgnorePendingStylesheets(); | 434 document().updateLayout(); |
| 435 | 435 |
| 436 // FIXME(sky): Can we just use getBoundingClientRect() instead? | 436 // FIXME(sky): Can we just use getBoundingClientRect() instead? |
| 437 if (document().documentElement() == this) { | 437 if (document().documentElement() == this) { |
| 438 if (FrameView* view = document().view()) | 438 if (FrameView* view = document().view()) |
| 439 return view->layoutSize().height(); | 439 return view->layoutSize().height(); |
| 440 } | 440 } |
| 441 | 441 |
| 442 if (RenderBox* renderer = renderBox()) | 442 if (RenderBox* renderer = renderBox()) |
| 443 return renderer->pixelSnappedClientHeight(); | 443 return renderer->pixelSnappedClientHeight(); |
| 444 return 0; | 444 return 0; |
| 445 } | 445 } |
| 446 | 446 |
| 447 int Element::scrollLeft() | 447 int Element::scrollLeft() |
| 448 { | 448 { |
| 449 document().updateLayoutIgnorePendingStylesheets(); | 449 document().updateLayout(); |
| 450 | 450 |
| 451 if (document().documentElement() != this) { | 451 if (document().documentElement() != this) { |
| 452 if (RenderBox* rend = renderBox()) | 452 if (RenderBox* rend = renderBox()) |
| 453 return rend->scrollLeft(); | 453 return rend->scrollLeft(); |
| 454 } | 454 } |
| 455 | 455 |
| 456 return 0; | 456 return 0; |
| 457 } | 457 } |
| 458 | 458 |
| 459 int Element::scrollTop() | 459 int Element::scrollTop() |
| 460 { | 460 { |
| 461 document().updateLayoutIgnorePendingStylesheets(); | 461 document().updateLayout(); |
| 462 | 462 |
| 463 if (document().documentElement() != this) { | 463 if (document().documentElement() != this) { |
| 464 if (RenderBox* rend = renderBox()) | 464 if (RenderBox* rend = renderBox()) |
| 465 return rend->scrollTop(); | 465 return rend->scrollTop(); |
| 466 } | 466 } |
| 467 | 467 |
| 468 return 0; | 468 return 0; |
| 469 } | 469 } |
| 470 | 470 |
| 471 void Element::setScrollLeft(int newLeft) | 471 void Element::setScrollLeft(int newLeft) |
| 472 { | 472 { |
| 473 document().updateLayoutIgnorePendingStylesheets(); | 473 document().updateLayout(); |
| 474 | 474 |
| 475 if (document().documentElement() != this) { | 475 if (document().documentElement() != this) { |
| 476 if (RenderBox* rend = renderBox()) | 476 if (RenderBox* rend = renderBox()) |
| 477 rend->setScrollLeft(newLeft); | 477 rend->setScrollLeft(newLeft); |
| 478 } | 478 } |
| 479 } | 479 } |
| 480 | 480 |
| 481 void Element::setScrollLeft(const Dictionary& scrollOptionsHorizontal, Exception
State& exceptionState) | 481 void Element::setScrollLeft(const Dictionary& scrollOptionsHorizontal, Exception
State& exceptionState) |
| 482 { | 482 { |
| 483 String scrollBehaviorString; | 483 String scrollBehaviorString; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 494 exceptionState.throwTypeError("ScrollOptionsHorizontal must include an '
x' member."); | 494 exceptionState.throwTypeError("ScrollOptionsHorizontal must include an '
x' member."); |
| 495 return; | 495 return; |
| 496 } | 496 } |
| 497 | 497 |
| 498 // FIXME: Use scrollBehavior to decide whether to scroll smoothly or instant
ly. | 498 // FIXME: Use scrollBehavior to decide whether to scroll smoothly or instant
ly. |
| 499 setScrollLeft(position); | 499 setScrollLeft(position); |
| 500 } | 500 } |
| 501 | 501 |
| 502 void Element::setScrollTop(int newTop) | 502 void Element::setScrollTop(int newTop) |
| 503 { | 503 { |
| 504 document().updateLayoutIgnorePendingStylesheets(); | 504 document().updateLayout(); |
| 505 | 505 |
| 506 if (document().documentElement() != this) { | 506 if (document().documentElement() != this) { |
| 507 if (RenderBox* rend = renderBox()) | 507 if (RenderBox* rend = renderBox()) |
| 508 rend->setScrollTop(newTop); | 508 rend->setScrollTop(newTop); |
| 509 } | 509 } |
| 510 } | 510 } |
| 511 | 511 |
| 512 void Element::setScrollTop(const Dictionary& scrollOptionsVertical, ExceptionSta
te& exceptionState) | 512 void Element::setScrollTop(const Dictionary& scrollOptionsVertical, ExceptionSta
te& exceptionState) |
| 513 { | 513 { |
| 514 String scrollBehaviorString; | 514 String scrollBehaviorString; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 525 exceptionState.throwTypeError("ScrollOptionsVertical must include a 'y'
member."); | 525 exceptionState.throwTypeError("ScrollOptionsVertical must include a 'y'
member."); |
| 526 return; | 526 return; |
| 527 } | 527 } |
| 528 | 528 |
| 529 // FIXME: Use scrollBehavior to decide whether to scroll smoothly or instant
ly. | 529 // FIXME: Use scrollBehavior to decide whether to scroll smoothly or instant
ly. |
| 530 setScrollTop(position); | 530 setScrollTop(position); |
| 531 } | 531 } |
| 532 | 532 |
| 533 int Element::scrollWidth() | 533 int Element::scrollWidth() |
| 534 { | 534 { |
| 535 document().updateLayoutIgnorePendingStylesheets(); | 535 document().updateLayout(); |
| 536 if (RenderBox* rend = renderBox()) | 536 if (RenderBox* rend = renderBox()) |
| 537 return rend->scrollWidth().toDouble(); | 537 return rend->scrollWidth().toDouble(); |
| 538 return 0; | 538 return 0; |
| 539 } | 539 } |
| 540 | 540 |
| 541 int Element::scrollHeight() | 541 int Element::scrollHeight() |
| 542 { | 542 { |
| 543 document().updateLayoutIgnorePendingStylesheets(); | 543 document().updateLayout(); |
| 544 if (RenderBox* rend = renderBox()) | 544 if (RenderBox* rend = renderBox()) |
| 545 return rend->scrollHeight().toDouble(); | 545 return rend->scrollHeight().toDouble(); |
| 546 return 0; | 546 return 0; |
| 547 } | 547 } |
| 548 | 548 |
| 549 PassRefPtr<ClientRectList> Element::getClientRects() | 549 PassRefPtr<ClientRectList> Element::getClientRects() |
| 550 { | 550 { |
| 551 document().updateLayoutIgnorePendingStylesheets(); | 551 document().updateLayout(); |
| 552 | 552 |
| 553 RenderBoxModelObject* renderBoxModelObject = this->renderBoxModelObject(); | 553 RenderBoxModelObject* renderBoxModelObject = this->renderBoxModelObject(); |
| 554 if (!renderBoxModelObject) | 554 if (!renderBoxModelObject) |
| 555 return ClientRectList::create(); | 555 return ClientRectList::create(); |
| 556 | 556 |
| 557 // FIXME: Handle SVG elements. | 557 // FIXME: Handle SVG elements. |
| 558 // FIXME: Handle table/inline-table with a caption. | 558 // FIXME: Handle table/inline-table with a caption. |
| 559 | 559 |
| 560 Vector<FloatQuad> quads; | 560 Vector<FloatQuad> quads; |
| 561 renderBoxModelObject->absoluteQuads(quads); | 561 renderBoxModelObject->absoluteQuads(quads); |
| 562 document().adjustFloatQuadsForScroll(quads); | 562 document().adjustFloatQuadsForScroll(quads); |
| 563 return ClientRectList::create(quads); | 563 return ClientRectList::create(quads); |
| 564 } | 564 } |
| 565 | 565 |
| 566 PassRefPtr<ClientRect> Element::getBoundingClientRect() | 566 PassRefPtr<ClientRect> Element::getBoundingClientRect() |
| 567 { | 567 { |
| 568 document().updateLayoutIgnorePendingStylesheets(); | 568 document().updateLayout(); |
| 569 | 569 |
| 570 Vector<FloatQuad> quads; | 570 Vector<FloatQuad> quads; |
| 571 // Get the bounding rectangle from the box model. | 571 // Get the bounding rectangle from the box model. |
| 572 if (renderBoxModelObject()) | 572 if (renderBoxModelObject()) |
| 573 renderBoxModelObject()->absoluteQuads(quads); | 573 renderBoxModelObject()->absoluteQuads(quads); |
| 574 | 574 |
| 575 if (quads.isEmpty()) | 575 if (quads.isEmpty()) |
| 576 return ClientRect::create(); | 576 return ClientRect::create(); |
| 577 | 577 |
| 578 FloatRect result = quads[0].boundingBox(); | 578 FloatRect result = quads[0].boundingBox(); |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 { | 1207 { |
| 1208 if (!inDocument()) | 1208 if (!inDocument()) |
| 1209 return; | 1209 return; |
| 1210 | 1210 |
| 1211 if (document().focusedElement() == this) | 1211 if (document().focusedElement() == this) |
| 1212 return; | 1212 return; |
| 1213 | 1213 |
| 1214 if (!document().isActive()) | 1214 if (!document().isActive()) |
| 1215 return; | 1215 return; |
| 1216 | 1216 |
| 1217 document().updateLayoutIgnorePendingStylesheets(); | 1217 document().updateLayout(); |
| 1218 if (!isFocusable()) | 1218 if (!isFocusable()) |
| 1219 return; | 1219 return; |
| 1220 | 1220 |
| 1221 RefPtr<Node> protect(this); | 1221 RefPtr<Node> protect(this); |
| 1222 if (!document().page()->focusController().setFocusedElement(this, document()
.frame(), type)) | 1222 if (!document().page()->focusController().setFocusedElement(this, document()
.frame(), type)) |
| 1223 return; | 1223 return; |
| 1224 | 1224 |
| 1225 // Setting the focused node above might have invalidated the layout due to s
cripts. | 1225 // Setting the focused node above might have invalidated the layout due to s
cripts. |
| 1226 document().updateLayoutIgnorePendingStylesheets(); | 1226 document().updateLayout(); |
| 1227 if (!isFocusable()) | 1227 if (!isFocusable()) |
| 1228 return; | 1228 return; |
| 1229 updateFocusAppearance(restorePreviousSelection); | 1229 updateFocusAppearance(restorePreviousSelection); |
| 1230 | 1230 |
| 1231 if (UserGestureIndicator::processedUserGestureSinceLoad()) { | 1231 if (UserGestureIndicator::processedUserGestureSinceLoad()) { |
| 1232 // Bring up the keyboard in the context of anything triggered by a user | 1232 // Bring up the keyboard in the context of anything triggered by a user |
| 1233 // gesture. Since tracking that across arbitrary boundaries (eg. | 1233 // gesture. Since tracking that across arbitrary boundaries (eg. |
| 1234 // animations) is difficult, for now we match IE's heuristic and bring | 1234 // animations) is difficult, for now we match IE's heuristic and bring |
| 1235 // up the keyboard if there's been any gesture since load. | 1235 // up the keyboard if there's been any gesture since load. |
| 1236 document().page()->chrome().client().showImeIfNeeded(); | 1236 document().page()->chrome().client().showImeIfNeeded(); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1383 // values returned for the ":selection" pseudo-element will be correct. | 1383 // values returned for the ":selection" pseudo-element will be correct. |
| 1384 if (RenderStyle* usedStyle = renderStyle()) | 1384 if (RenderStyle* usedStyle = renderStyle()) |
| 1385 return usedStyle; | 1385 return usedStyle; |
| 1386 | 1386 |
| 1387 if (!inActiveDocument()) | 1387 if (!inActiveDocument()) |
| 1388 // FIXME: Try to do better than this. Ensure that styleForElement() work
s for elements that are not in the | 1388 // FIXME: Try to do better than this. Ensure that styleForElement() work
s for elements that are not in the |
| 1389 // document tree and figure out when to destroy the computed style for s
uch elements. | 1389 // document tree and figure out when to destroy the computed style for s
uch elements. |
| 1390 return 0; | 1390 return 0; |
| 1391 | 1391 |
| 1392 ElementRareData& rareData = ensureElementRareData(); | 1392 ElementRareData& rareData = ensureElementRareData(); |
| 1393 if (!rareData.computedStyle()) | 1393 if (!rareData.computedStyle()) { |
| 1394 rareData.setComputedStyle(document().styleForElementIgnoringPendingStyle
sheets(this)); | 1394 RenderStyle* parentStyle = parentNode() ? parentNode()->computedStyle()
: 0; |
| 1395 rareData.setComputedStyle(document().ensureStyleResolver().styleForEleme
nt(this, parentStyle)); |
| 1396 } |
| 1395 return rareData.computedStyle(); | 1397 return rareData.computedStyle(); |
| 1396 } | 1398 } |
| 1397 | 1399 |
| 1398 AtomicString Element::computeInheritedLanguage() const | 1400 AtomicString Element::computeInheritedLanguage() const |
| 1399 { | 1401 { |
| 1400 const Node* n = this; | 1402 const Node* n = this; |
| 1401 AtomicString value; | 1403 AtomicString value; |
| 1402 // The language property is inherited, so we iterate over the parents to fin
d the first language. | 1404 // The language property is inherited, so we iterate over the parents to fin
d the first language. |
| 1403 do { | 1405 do { |
| 1404 if (n->isElementNode()) { | 1406 if (n->isElementNode()) { |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1821 return false; | 1823 return false; |
| 1822 // Turn off style sharing for elements that can gain layers for reasons outs
ide of the style system. | 1824 // Turn off style sharing for elements that can gain layers for reasons outs
ide of the style system. |
| 1823 // See comments in RenderObject::setStyle(). | 1825 // See comments in RenderObject::setStyle(). |
| 1824 // FIXME: Why does gaining a layer from outside the style system require dis
abling sharing? | 1826 // FIXME: Why does gaining a layer from outside the style system require dis
abling sharing? |
| 1825 if (isHTMLCanvasElement(*this)) | 1827 if (isHTMLCanvasElement(*this)) |
| 1826 return false; | 1828 return false; |
| 1827 return true; | 1829 return true; |
| 1828 } | 1830 } |
| 1829 | 1831 |
| 1830 } // namespace blink | 1832 } // namespace blink |
| OLD | NEW |