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

Side by Side Diff: Source/core/rendering/RenderBlock.cpp

Issue 14113040: Update the first letter when the first line is changed by adding a new text at its start. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@first-letter-rendering-issue
Patch Set: fixed test case failures Created 7 years, 2 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
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) 2007 David Smith (catfish.man@gmail.com) 4 * (C) 2007 David Smith (catfish.man@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
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 10 matching lines...) Expand all
21 * Boston, MA 02110-1301, USA. 21 * Boston, MA 02110-1301, USA.
22 */ 22 */
23 23
24 #include "config.h" 24 #include "config.h"
25 #include "core/rendering/RenderBlock.h" 25 #include "core/rendering/RenderBlock.h"
26 26
27 #include "HTMLNames.h" 27 #include "HTMLNames.h"
28 #include "core/accessibility/AXObjectCache.h" 28 #include "core/accessibility/AXObjectCache.h"
29 #include "core/dom/Document.h" 29 #include "core/dom/Document.h"
30 #include "core/dom/Element.h" 30 #include "core/dom/Element.h"
31 #include "core/dom/Text.h"
31 #include "core/events/OverflowEvent.h" 32 #include "core/events/OverflowEvent.h"
32 #include "core/dom/shadow/ShadowRoot.h" 33 #include "core/dom/shadow/ShadowRoot.h"
33 #include "core/editing/Editor.h" 34 #include "core/editing/Editor.h"
34 #include "core/editing/FrameSelection.h" 35 #include "core/editing/FrameSelection.h"
35 #include "core/page/Frame.h" 36 #include "core/page/Frame.h"
36 #include "core/page/FrameView.h" 37 #include "core/page/FrameView.h"
37 #include "core/page/Page.h" 38 #include "core/page/Page.h"
38 #include "core/page/Settings.h" 39 #include "core/page/Settings.h"
39 #include "core/platform/graphics/FloatQuad.h" 40 #include "core/platform/graphics/FloatQuad.h"
40 #include "core/platform/graphics/GraphicsContextStateSaver.h" 41 #include "core/platform/graphics/GraphicsContextStateSaver.h"
(...skipping 5762 matching lines...) Expand 10 before | Expand all | Expand 10 after
5803 } 5804 }
5804 5805
5805 void RenderBlock::updateFirstLetter() 5806 void RenderBlock::updateFirstLetter()
5806 { 5807 {
5807 if (!document().styleEngine()->usesFirstLetterRules()) 5808 if (!document().styleEngine()->usesFirstLetterRules())
5808 return; 5809 return;
5809 // Don't recur 5810 // Don't recur
5810 if (style()->styleType() == FIRST_LETTER) 5811 if (style()->styleType() == FIRST_LETTER)
5811 return; 5812 return;
5812 5813
5813 // FIXME: We need to destroy the first-letter object if it is no longer the first child. Need to find
5814 // an efficient way to check for that situation though before implementing a nything.
5815 RenderObject* firstLetterBlock = findFirstLetterBlock(this); 5814 RenderObject* firstLetterBlock = findFirstLetterBlock(this);
5816 if (!firstLetterBlock) 5815 if (!firstLetterBlock)
5817 return; 5816 return;
5818 5817
5819 // Drill into inlines looking for our first text child. 5818 // Drill into inlines looking for our first text child.
5820 RenderObject* currChild = firstLetterBlock->firstChild(); 5819 RenderObject* currChild = firstLetterBlock->firstChild();
5821 while (currChild) { 5820 while (currChild) {
5822 if (currChild->isText()) 5821 if (currChild->isText())
5823 break; 5822 break;
5824 if (currChild->isListMarker()) 5823 if (currChild->isListMarker())
(...skipping 10 matching lines...) Expand all
5835 // We found a lower-level node with first-letter, which supersedes t he higher-level style 5834 // We found a lower-level node with first-letter, which supersedes t he higher-level style
5836 firstLetterBlock = currChild; 5835 firstLetterBlock = currChild;
5837 currChild = currChild->firstChild(); 5836 currChild = currChild->firstChild();
5838 } else 5837 } else
5839 currChild = currChild->firstChild(); 5838 currChild = currChild->firstChild();
5840 } 5839 }
5841 5840
5842 if (!currChild) 5841 if (!currChild)
5843 return; 5842 return;
5844 5843
5845 // If the child already has style, then it has already been created, so we j ust want
5846 // to update it.
5847 if (currChild->parent()->style()->styleType() == FIRST_LETTER) { 5844 if (currChild->parent()->style()->styleType() == FIRST_LETTER) {
5845 // Destroy the first-letter object if it is no longer the first child.
5846 RenderObject* remainingText = currChild->parent()->nextSibling();
5847 if (remainingText && currChild->node() != remainingText->node()) {
5848 if (!remainingText->isText() || remainingText->isBR())
5849 return;
5850
5851 LayoutStateDisabler layoutStateDisabler(view());
5852
5853 RenderObject* oldRemainingText = toRenderBoxModelObject(currChild->p arent())->firstLetterRemainingText();
5854 if (oldRemainingText)
esprehn 2013/09/27 18:30:15 We usually write these as one statement: if (Rend
5855 toRenderText(oldRemainingText)->setText(toText(oldRemainingText- >node())->data().impl());
5856
5857 createFirstLetterRenderer(firstLetterBlock, remainingText);
5858 return;
5859 }
5860
5861 // If the child already has style, then it has already been created, so we just want
5862 // to update it.
5848 updateFirstLetterStyle(firstLetterBlock, currChild); 5863 updateFirstLetterStyle(firstLetterBlock, currChild);
5849 return; 5864 return;
5850 } 5865 }
5851 5866
5852 if (!currChild->isText() || currChild->isBR()) 5867 if (!currChild->isText() || currChild->isBR())
5853 return; 5868 return;
5854 5869
5855 // Our layout state is not valid for the repaints we are going to trigger by 5870 // Our layout state is not valid for the repaints we are going to trigger by
5856 // adding and removing children of firstLetterContainer. 5871 // adding and removing children of firstLetterContainer.
5857 LayoutStateDisabler layoutStateDisabler(view()); 5872 LayoutStateDisabler layoutStateDisabler(view());
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
6798 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 6813 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
6799 { 6814 {
6800 showRenderObject(); 6815 showRenderObject();
6801 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 6816 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
6802 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 6817 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
6803 } 6818 }
6804 6819
6805 #endif 6820 #endif
6806 6821
6807 } // namespace WebCore 6822 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698