View Issue Details

IDProjectCategoryView StatusLast Update
0037931PatchesLCLpublic2020-10-17 22:58
ReporterZaher Dirkey Assigned Towp  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Summary0037931: ipHTML Fix: Bug background color of text element
Descriptionif element have class with background color, it not applied to text element,
see example,
because the default textstyle not opaque, we need to set it if there is backcolor exists.
Steps To Reproduce[code]
<html>
<head>
    <style type="text/css">
        .class1 {
            color: #86f9c8;
            background-color: #fa8585;
        }
    </style>
</head>
<body>
    <p class="class1">Testing backcolor


</body>
</html>
[/code]
TagsipHTMLPanel
Fixed in Revision64036
LazTarget2.2
Widgetset
Attached Files

Activities

Zaher Dirkey

2020-10-16 01:15

reporter  

iphtmlblocklayout02.patch (2,201 bytes)   
Index: components/turbopower_ipro/iphtmlblocklayout.pas
===================================================================
--- components/turbopower_ipro/iphtmlblocklayout.pas	(revision 63936)
+++ components/turbopower_ipro/iphtmlblocklayout.pas	(working copy)
@@ -1267,6 +1267,7 @@
   P : TPoint;
   R : TRect;
   {$IFDEF IP_LAZARUS}
+  TextStyle: TTextStyle;
   OldBrushcolor: TColor;
   OldFontColor: TColor;
   OldFontStyle: TFontStyles;
@@ -1304,26 +1305,30 @@
   {$IFDEF IP_LAZARUS}
   //if (LastOwner <> aCurWord.Owner) then LastPoint := P;
   saveCanvasProperties;
+  TextStyle := FCanvas.TextStyle;
+  //debugln(['TIpHtmlNodeBlock.RenderQueue ',aCurWord.AnsiWord]);
+  FIpHtml.PageRectToScreen(aCurWord.WordRect2, R);
   if aCurWord.IsSelected or FIpHtml.AllSelected then begin
-    FCanvas.Font.color := clHighlightText;
+    FCanvas.Font.Color := clHighlightText;
     FCanvas.brush.Style := bsSolid;
-    FCanvas.brush.color := clHighLight;
-    FIpHtml.PageRectToScreen(aCurWord.WordRect2, R);
+    FCanvas.brush.Color := clHighLight;
     FCanvas.FillRect(R);
   end
-  else if FCurProps.BgColor > 0 then
+  else if FCurProps.BgColor <> 0 then
   begin
     FCanvas.brush.Style := bsSolid;
-    FCanvas.brush.color := FCurProps.BgColor;
+    FCanvas.brush.Color := FCurProps.BgColor;
+    TextStyle.Opaque := True;
   end
   else
+  begin
+    TextStyle.Opaque := True;
   {$ENDIF}
     FCanvas.Brush.Style := bsClear;
 
-  //debugln(['TIpHtmlNodeBlock.RenderQueue ',aCurWord.AnsiWord]);
-  FIpHtml.PageRectToScreen(aCurWord.WordRect2, R);
+  {$IFDEF IP_LAZARUS}
+  end;
 
-  {$IFDEF IP_LAZARUS}
   if aCurWord.Owner.ParentNode = aCurTabFocus then
     FCanvas.DrawFocusRect(R);
   if FCanvas.Font.color = -1 then
@@ -1331,8 +1336,12 @@
   FCanvas.Font.Quality := FOwner.Owner.FontQuality;
   {$ENDIF}
   if aCurWord.AnsiWord <> NAnchorChar then
-    FCanvas.TextRect(R, P.x, P.y, NoBreakToSpace(aCurWord.AnsiWord));
   {$IFDEF IP_LAZARUS}
+    FCanvas.TextRect(R, P.x, P.y, NoBreakToSpace(aCurWord.AnsiWord), TextStyle);
+  {$ELSE}
+  FCanvas.TextRect(R, P.x, P.y, NoBreakToSpace(aCurWord.AnsiWord));
+  {$ENDIF}
+  {$IFDEF IP_LAZARUS}
   RestoreCanvasProperties;
   {$ENDIF}
 
iphtmlblocklayout02.patch (2,201 bytes)   

wp

2020-10-16 18:02

developer   ~0126348

Last edited: 2020-10-16 18:19

View 4 revisions

There is one issue which has been there all the time but was not apparent because background color did not work before your patch: Background although property set is not painted when the color is black

<code>
<html>
<head>
    <style type="text/css">
        .class1 {
            color: #86f9c8;
            background-color: #fa8585;
        }
        .class2 {
            color: #86f9c8;
            background-color: #000000;
        }
    </style>
</head>
<body>
    <p class="class1">Testing backcolor


    

No back color


    <p class="class2">Back background


</body>
</html>
</code>

P.S.
The pasted HTML is badly malformed here... I am attaching a test program with a SynEdit containing this code and a IpHtmlPanel.

wp

2020-10-16 18:19

developer   ~0126349

Zaher Dirkey

2020-10-16 23:07

reporter   ~0126354

Sorry for mistake, in ipHTML they used -1 for color as none color, it should compared to -1 not 0, it is typo from me, please modify it to -1 not 0

else if FCurProps.BgColor <> -1 then 


Also
I want to change all -1 any where of ipHTML code to clNone instead, but I want permession to do that

Zaher Dirkey

2020-10-16 23:10

reporter   ~0126356

This is a new patch
iphtmlblocklayout03.patch (2,202 bytes)   
Index: components/turbopower_ipro/iphtmlblocklayout.pas
===================================================================
--- components/turbopower_ipro/iphtmlblocklayout.pas	(revision 63936)
+++ components/turbopower_ipro/iphtmlblocklayout.pas	(working copy)
@@ -1267,6 +1267,7 @@
   P : TPoint;
   R : TRect;
   {$IFDEF IP_LAZARUS}
+  TextStyle: TTextStyle;
   OldBrushcolor: TColor;
   OldFontColor: TColor;
   OldFontStyle: TFontStyles;
@@ -1304,26 +1305,30 @@
   {$IFDEF IP_LAZARUS}
   //if (LastOwner <> aCurWord.Owner) then LastPoint := P;
   saveCanvasProperties;
+  TextStyle := FCanvas.TextStyle;
+  //debugln(['TIpHtmlNodeBlock.RenderQueue ',aCurWord.AnsiWord]);
+  FIpHtml.PageRectToScreen(aCurWord.WordRect2, R);
   if aCurWord.IsSelected or FIpHtml.AllSelected then begin
-    FCanvas.Font.color := clHighlightText;
+    FCanvas.Font.Color := clHighlightText;
     FCanvas.brush.Style := bsSolid;
-    FCanvas.brush.color := clHighLight;
-    FIpHtml.PageRectToScreen(aCurWord.WordRect2, R);
+    FCanvas.brush.Color := clHighLight;
     FCanvas.FillRect(R);
   end
-  else if FCurProps.BgColor > 0 then
+  else if FCurProps.BgColor <> -1 then
   begin
     FCanvas.brush.Style := bsSolid;
-    FCanvas.brush.color := FCurProps.BgColor;
+    FCanvas.brush.Color := FCurProps.BgColor;
+    TextStyle.Opaque := True;
   end
   else
+  begin
+    TextStyle.Opaque := True;
   {$ENDIF}
     FCanvas.Brush.Style := bsClear;
 
-  //debugln(['TIpHtmlNodeBlock.RenderQueue ',aCurWord.AnsiWord]);
-  FIpHtml.PageRectToScreen(aCurWord.WordRect2, R);
+  {$IFDEF IP_LAZARUS}
+  end;
 
-  {$IFDEF IP_LAZARUS}
   if aCurWord.Owner.ParentNode = aCurTabFocus then
     FCanvas.DrawFocusRect(R);
   if FCanvas.Font.color = -1 then
@@ -1331,8 +1336,12 @@
   FCanvas.Font.Quality := FOwner.Owner.FontQuality;
   {$ENDIF}
   if aCurWord.AnsiWord <> NAnchorChar then
-    FCanvas.TextRect(R, P.x, P.y, NoBreakToSpace(aCurWord.AnsiWord));
   {$IFDEF IP_LAZARUS}
+    FCanvas.TextRect(R, P.x, P.y, NoBreakToSpace(aCurWord.AnsiWord), TextStyle);
+  {$ELSE}
+  FCanvas.TextRect(R, P.x, P.y, NoBreakToSpace(aCurWord.AnsiWord));
+  {$ENDIF}
+  {$IFDEF IP_LAZARUS}
   RestoreCanvasProperties;
   {$ENDIF}
 
iphtmlblocklayout03.patch (2,202 bytes)   

wp

2020-10-17 01:04

developer   ~0126359

> I want to change all -1 any where of ipHTML code to clNone instead, but I want permession to do that

That's a good idea. I'll put your blocklayout03 patch on hold then...

Zaher Dirkey

2020-10-17 10:50

reporter   ~0126360

Ok, but would you apply this patch because it fix a bug, and my next patch will generate bugs if i missed -1 there or there.

In my plan, I want to make it work with Right to Left languages.

wp

2020-10-17 11:39

developer   ~0126362

OK, done: r64036.

wp

2020-10-17 22:28

developer   ~0126378

Please test and close if ok.

Issue History

Date Modified Username Field Change
2020-10-16 01:15 Zaher Dirkey New Issue
2020-10-16 01:15 Zaher Dirkey File Added: iphtmlblocklayout02.patch
2020-10-16 17:52 wp Assigned To => wp
2020-10-16 17:52 wp Status new => assigned
2020-10-16 18:02 wp Status assigned => feedback
2020-10-16 18:02 wp LazTarget => -
2020-10-16 18:02 wp Note Added: 0126348
2020-10-16 18:05 wp Note Edited: 0126348 View Revisions
2020-10-16 18:06 wp Note Edited: 0126348 View Revisions
2020-10-16 18:19 wp Note Edited: 0126348 View Revisions
2020-10-16 18:19 wp Note Added: 0126349
2020-10-16 18:19 wp File Added: 37931 - IpHtmlPanel_TextBackgroundColor.zip
2020-10-16 23:07 Zaher Dirkey Note Added: 0126354
2020-10-16 23:07 Zaher Dirkey Status feedback => assigned
2020-10-16 23:10 Zaher Dirkey Note Added: 0126356
2020-10-16 23:10 Zaher Dirkey File Added: iphtmlblocklayout03.patch
2020-10-17 00:45 Zaher Dirkey Tag Attached: ipHTMLPanel
2020-10-17 01:04 wp Note Added: 0126359
2020-10-17 10:50 Zaher Dirkey Note Added: 0126360
2020-10-17 11:39 wp Note Added: 0126362
2020-10-17 22:28 wp Status assigned => resolved
2020-10-17 22:28 wp Resolution open => fixed
2020-10-17 22:28 wp Fixed in Revision => 64036
2020-10-17 22:28 wp LazTarget - => 2.2
2020-10-17 22:28 wp Note Added: 0126378
2020-10-17 22:58 Zaher Dirkey Status resolved => closed