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

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: Add first-letter-block-change.html to TestExpectations for rebaseline 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
« no previous file with comments | « LayoutTests/fast/css/first-letter-block-change-expected.txt ('k') | no next file » | 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) 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 5765 matching lines...) Expand 10 before | Expand all | Expand 10 after
5806 } 5807 }
5807 5808
5808 void RenderBlock::updateFirstLetter() 5809 void RenderBlock::updateFirstLetter()
5809 { 5810 {
5810 if (!document().styleEngine()->usesFirstLetterRules()) 5811 if (!document().styleEngine()->usesFirstLetterRules())
5811 return; 5812 return;
5812 // Don't recur 5813 // Don't recur
5813 if (style()->styleType() == FIRST_LETTER) 5814 if (style()->styleType() == FIRST_LETTER)
5814 return; 5815 return;
5815 5816
5816 // FIXME: We need to destroy the first-letter object if it is no longer the first child. Need to find
5817 // an efficient way to check for that situation though before implementing a nything.
5818 RenderObject* firstLetterBlock = findFirstLetterBlock(this); 5817 RenderObject* firstLetterBlock = findFirstLetterBlock(this);
5819 if (!firstLetterBlock) 5818 if (!firstLetterBlock)
5820 return; 5819 return;
5821 5820
5822 // Drill into inlines looking for our first text child. 5821 // Drill into inlines looking for our first text child.
5823 RenderObject* currChild = firstLetterBlock->firstChild(); 5822 RenderObject* currChild = firstLetterBlock->firstChild();
5824 while (currChild) { 5823 while (currChild) {
5825 if (currChild->isText()) 5824 if (currChild->isText())
5826 break; 5825 break;
5827 if (currChild->isListMarker()) 5826 if (currChild->isListMarker())
(...skipping 10 matching lines...) Expand all
5838 // We found a lower-level node with first-letter, which supersedes t he higher-level style 5837 // We found a lower-level node with first-letter, which supersedes t he higher-level style
5839 firstLetterBlock = currChild; 5838 firstLetterBlock = currChild;
5840 currChild = currChild->firstChild(); 5839 currChild = currChild->firstChild();
5841 } else 5840 } else
5842 currChild = currChild->firstChild(); 5841 currChild = currChild->firstChild();
5843 } 5842 }
5844 5843
5845 if (!currChild) 5844 if (!currChild)
5846 return; 5845 return;
5847 5846
5848 // If the child already has style, then it has already been created, so we j ust want
5849 // to update it.
5850 if (currChild->parent()->style()->styleType() == FIRST_LETTER) { 5847 if (currChild->parent()->style()->styleType() == FIRST_LETTER) {
5848 // Destroy the first-letter object if it is no longer the first child.
5849 RenderObject* remainingText = currChild->parent()->nextSibling();
5850 if (remainingText && currChild->node() != remainingText->node()) {
5851 if (!remainingText->isText() || remainingText->isBR())
5852 return;
5853
5854 LayoutStateDisabler layoutStateDisabler(view());
5855
5856 if (RenderObject* oldRemainingText = toRenderBoxModelObject(currChil d->parent())->firstLetterRemainingText())
5857 toRenderText(oldRemainingText)->setText(toText(oldRemainingText- >node())->data().impl());
5858
5859 createFirstLetterRenderer(firstLetterBlock, remainingText);
5860 return;
5861 }
5862
5863 // If the child already has style, then it has already been created, so we just want
5864 // to update it.
5851 updateFirstLetterStyle(firstLetterBlock, currChild); 5865 updateFirstLetterStyle(firstLetterBlock, currChild);
5852 return; 5866 return;
5853 } 5867 }
5854 5868
5855 if (!currChild->isText() || currChild->isBR()) 5869 if (!currChild->isText() || currChild->isBR())
5856 return; 5870 return;
5857 5871
5858 // Our layout state is not valid for the repaints we are going to trigger by 5872 // Our layout state is not valid for the repaints we are going to trigger by
5859 // adding and removing children of firstLetterContainer. 5873 // adding and removing children of firstLetterContainer.
5860 LayoutStateDisabler layoutStateDisabler(view()); 5874 LayoutStateDisabler layoutStateDisabler(view());
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
6801 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 6815 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
6802 { 6816 {
6803 showRenderObject(); 6817 showRenderObject();
6804 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 6818 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
6805 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 6819 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
6806 } 6820 }
6807 6821
6808 #endif 6822 #endif
6809 6823
6810 } // namespace WebCore 6824 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/css/first-letter-block-change-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698