Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(606)

Side by Side Diff: sky/engine/core/dom/Element.cpp

Issue 1027563002: Integrate custom paint with the DocumentLifecycle (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: nits Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/engine/core/core.gni ('k') | sky/engine/core/page/PageAnimator.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 * modify it under the terms of the GNU Library General Public 11 * modify it under the terms of the GNU Library General Public
12 * License as published by the Free Software Foundation; either 12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version. 13 * version 2 of the License, or (at your option) any later version.
14 * 14 *
15 * This library is distributed in the hope that it will be useful, 15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Library General Public License for more details. 18 * Library General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU Library General Public License 20 * You should have received a copy of the GNU Library General Public License
21 * along with this library; see the file COPYING.LIB. If not, write to 21 * along with this library; see the file COPYING.LIB. If not, write to
22 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 22 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 * Boston, MA 02110-1301, USA. 23 * Boston, MA 02110-1301, USA.
24 */ 24 */
25 25
26 #include "sky/engine/config.h" 26 #include "sky/engine/config.h"
27 #include "sky/engine/core/dom/Element.h" 27 #include "sky/engine/core/dom/Element.h"
28 28
29 #include "base/bind.h"
30 #include "gen/sky/core/CSSValueKeywords.h" 29 #include "gen/sky/core/CSSValueKeywords.h"
31 #include "gen/sky/core/HTMLNames.h" 30 #include "gen/sky/core/HTMLNames.h"
32 #include "gen/sky/platform/RuntimeEnabledFeatures.h" 31 #include "gen/sky/platform/RuntimeEnabledFeatures.h"
33 #include "sky/engine/bindings/exception_messages.h" 32 #include "sky/engine/bindings/exception_messages.h"
34 #include "sky/engine/bindings/exception_state.h" 33 #include "sky/engine/bindings/exception_state.h"
35 #include "sky/engine/core/animation/AnimationTimeline.h" 34 #include "sky/engine/core/animation/AnimationTimeline.h"
36 #include "sky/engine/core/animation/css/CSSAnimations.h" 35 #include "sky/engine/core/animation/css/CSSAnimations.h"
37 #include "sky/engine/core/css/CSSImageValue.h" 36 #include "sky/engine/core/css/CSSImageValue.h"
38 #include "sky/engine/core/css/CSSStyleSheet.h" 37 #include "sky/engine/core/css/CSSStyleSheet.h"
39 #include "sky/engine/core/css/CSSValuePool.h" 38 #include "sky/engine/core/css/CSSValuePool.h"
(...skipping 30 matching lines...) Expand all
70 #include "sky/engine/core/frame/LocalFrame.h" 69 #include "sky/engine/core/frame/LocalFrame.h"
71 #include "sky/engine/core/frame/Settings.h" 70 #include "sky/engine/core/frame/Settings.h"
72 #include "sky/engine/core/html/HTMLCanvasElement.h" 71 #include "sky/engine/core/html/HTMLCanvasElement.h"
73 #include "sky/engine/core/html/HTMLElement.h" 72 #include "sky/engine/core/html/HTMLElement.h"
74 #include "sky/engine/core/html/HTMLTemplateElement.h" 73 #include "sky/engine/core/html/HTMLTemplateElement.h"
75 #include "sky/engine/core/html/parser/HTMLDocumentParser.h" 74 #include "sky/engine/core/html/parser/HTMLDocumentParser.h"
76 #include "sky/engine/core/html/parser/HTMLParserIdioms.h" 75 #include "sky/engine/core/html/parser/HTMLParserIdioms.h"
77 #include "sky/engine/core/page/ChromeClient.h" 76 #include "sky/engine/core/page/ChromeClient.h"
78 #include "sky/engine/core/page/FocusController.h" 77 #include "sky/engine/core/page/FocusController.h"
79 #include "sky/engine/core/page/Page.h" 78 #include "sky/engine/core/page/Page.h"
80 #include "sky/engine/core/painting/PaintingContext.h"
81 #include "sky/engine/core/painting/PaintingCallback.h" 79 #include "sky/engine/core/painting/PaintingCallback.h"
80 #include "sky/engine/core/painting/PaintingTasks.h"
82 #include "sky/engine/core/rendering/RenderLayer.h" 81 #include "sky/engine/core/rendering/RenderLayer.h"
83 #include "sky/engine/core/rendering/RenderView.h" 82 #include "sky/engine/core/rendering/RenderView.h"
84 #include "sky/engine/platform/EventDispatchForbiddenScope.h" 83 #include "sky/engine/platform/EventDispatchForbiddenScope.h"
85 #include "sky/engine/tonic/dart_state.h" 84 #include "sky/engine/tonic/dart_state.h"
86 #include "sky/engine/wtf/BitVector.h" 85 #include "sky/engine/wtf/BitVector.h"
87 #include "sky/engine/wtf/HashFunctions.h" 86 #include "sky/engine/wtf/HashFunctions.h"
88 #include "sky/engine/wtf/text/CString.h" 87 #include "sky/engine/wtf/text/CString.h"
89 #include "sky/engine/wtf/text/StringBuilder.h" 88 #include "sky/engine/wtf/text/StringBuilder.h"
90 #include "sky/engine/wtf/text/TextPosition.h" 89 #include "sky/engine/wtf/text/TextPosition.h"
91 90
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 if (quads.isEmpty()) 409 if (quads.isEmpty())
411 return ClientRect::create(); 410 return ClientRect::create();
412 411
413 FloatRect result = quads[0].boundingBox(); 412 FloatRect result = quads[0].boundingBox();
414 for (size_t i = 1; i < quads.size(); ++i) 413 for (size_t i = 1; i < quads.size(); ++i)
415 result.unite(quads[i].boundingBox()); 414 result.unite(quads[i].boundingBox());
416 415
417 return ClientRect::create(result); 416 return ClientRect::create(result);
418 } 417 }
419 418
420 // TODO(abarth): We should schedule this work at a more reasonable time.
421 static void handlePaintingCommit(RefPtr<Element> element, RefPtr<PaintingContext > context)
422 {
423 if (!element->document().isActive())
424 return;
425 element->document().updateLayout();
426 RenderObject* renderer = element->renderer();
427 if (!renderer || !renderer->isBox())
428 return;
429 toRenderBox(renderer)->setCustomPainting(context->takeDisplayList());
430 element->document().scheduleVisualUpdate();
431 }
432
433 // TODO(abarth): We should schedule this work at a more reasonable time.
434 static void runPaintingCallback(RefPtr<Element> element, PassOwnPtr<PaintingCall back> callback)
435 {
436 if (!element->document().isActive())
437 return;
438 element->document().updateLayout();
439 RenderObject* renderer = element->renderer();
440 if (!renderer || !renderer->isBox())
441 return;
442 RefPtr<PaintingContext> context = PaintingContext::create(
443 toRenderBox(renderer)->size(), base::Bind(&handlePaintingCommit, element ));
444 callback->handleEvent(context.get());
445 }
446
447 void Element::requestPaint(PassOwnPtr<PaintingCallback> callback) 419 void Element::requestPaint(PassOwnPtr<PaintingCallback> callback)
448 { 420 {
449 Microtask::enqueueMicrotask(base::Bind(&runPaintingCallback, this, callback) ); 421 PaintingTasks::enqueueRequest(this, callback);
422 document().scheduleVisualUpdate();
450 } 423 }
451 424
452 void Element::setAttribute(const AtomicString& localName, const AtomicString& va lue, ExceptionState& exceptionState) 425 void Element::setAttribute(const AtomicString& localName, const AtomicString& va lue, ExceptionState& exceptionState)
453 { 426 {
454 if (!Document::isValidName(localName)) { 427 if (!Document::isValidName(localName)) {
455 exceptionState.ThrowDOMException(InvalidCharacterError, "'" + localName + "' is not a valid attribute name."); 428 exceptionState.ThrowDOMException(InvalidCharacterError, "'" + localName + "' is not a valid attribute name.");
456 return; 429 return;
457 } 430 }
458 431
459 synchronizeAttribute(localName); 432 synchronizeAttribute(localName);
(...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1592 return false; 1565 return false;
1593 if (treeScope().scopedStyleResolver().hasSelectorForId(idValue)) 1566 if (treeScope().scopedStyleResolver().hasSelectorForId(idValue))
1594 return true; 1567 return true;
1595 // Host rules could also have effects. 1568 // Host rules could also have effects.
1596 if (ShadowRoot* shadowRoot = this->shadowRoot()) 1569 if (ShadowRoot* shadowRoot = this->shadowRoot())
1597 return shadowRoot->scopedStyleResolver().hasSelectorForId(idValue); 1570 return shadowRoot->scopedStyleResolver().hasSelectorForId(idValue);
1598 return false; 1571 return false;
1599 } 1572 }
1600 1573
1601 } // namespace blink 1574 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/core.gni ('k') | sky/engine/core/page/PageAnimator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698